reward-popup.nvue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <view class="wrapper">
  3. <!-- 领取奖励提示,解锁成就 -->
  4. <view v-if="currentType == 'levelReward'" class="reward-container">
  5. <image style="width: 548rpx; height: 240rpx;" mode="aspectFit"
  6. src="../../../static/common/subNVue/reward-title.png">
  7. </image>
  8. <view class="position-relative">
  9. <image style="width: 472rpx; height: 482rpx;" mode="aspectFit"
  10. src="../../../static/common/subNVue/bg-light.png">
  11. </image>
  12. <view class="position-absolute-center">
  13. <image class="reward-image"
  14. :style="{width:lists[levelRewardIndex].width+'px',height:lists[levelRewardIndex].height+'px'}"
  15. mode="aspectFit" :src="lists[levelRewardIndex].url">
  16. </image>
  17. </view>
  18. </view>
  19. <view class="position-relative">
  20. <image style="width: 502rpx;height: 94rpx;" mode="aspectFit"
  21. src="../../../static/common/subNVue/line-border@2x.png">
  22. </image>
  23. <view class="position-absolute-center">
  24. <text class="text-white text-15px text-center"
  25. style="line-height: 30rpx;height: 30rpx;">{{lists[levelRewardIndex].explain}}</text>
  26. </view>
  27. </view>
  28. <button class="make-bg-bPurple reward-button" @click="buttonMessage('confirm')"><text
  29. class="text-white text-18px">确定</text> </button>
  30. </view>
  31. <!-- 显示奖励信息 -->
  32. <view v-if="currentType == 'prompt'" class="reward-container" style="height: 1000rpx;">
  33. <view class="position-absolute-center-top" style="top: 20rpx;">
  34. <image style="width: 656rpx; height: 224rpx;" mode="aspectFit"
  35. src="../../../static/common/subNVue/prompt-bg-title@2x.png">
  36. </image>
  37. </view>
  38. <view class="prompt-mid" style="height: 622rpx; ">
  39. <block v-for="(item, index) in lists" :key="index">
  40. <view class="justify-center align-center" style="height: 230rpx; width: 160rpx; margin:5rpx;">
  41. <view class="prompt-cell-bg"></view>
  42. <image class="position-absolute-center-top" style="height:200rpx;"
  43. src="../../../static/common/subNVue/prompt-bg@2x.png"></image>
  44. <view class="position-absolute-center-top" style="height:140rpx;top: 40rpx;">
  45. <image :style="{width:item.width+'px',height:item.height+'px'}" mode="aspectFit"
  46. :src="item.url">
  47. </image>
  48. <view class="position-absolute-center-bottom">
  49. <text class="text-14px text-center"
  50. style="height: 14px;line-height: 14px;">{{item.explain}}</text>
  51. </view>
  52. </view>
  53. </view>
  54. </block>
  55. </view>
  56. <view class="position-absolute-center-top" style="top: 160rpx">
  57. <image class="prompt-title" mode="aspectFit"
  58. src="../../../static/common/subNVue/prompt-reward-title@2x.png">
  59. </image>
  60. <!-- 内容部分 -->
  61. <text class="text-18px text-black" style="margin-top: 44rpx;">本关卡可获得以下奖励</text>
  62. </view>
  63. <view class="position-absolute-center-bottom" style="bottom: 260rpx;">
  64. <button class="make-bg-bPurple prompt-button" @click="buttonMessage('confirm')"><text
  65. class="text-white text-18px">确定</text> </button>
  66. </view>
  67. </view>
  68. <!-- 解锁关卡 -->
  69. <view v-if="currentType == 'unlock'" class="reward-container" style="height: 1000rpx;">
  70. <view class="position-absolute-center-top" style="top: 20rpx;">
  71. <image style="width: 656rpx; height: 224rpx;" mode="aspectFit"
  72. src="../../../static/common/subNVue/prompt-bg-title@2x.png">
  73. </image>
  74. </view>
  75. <view class="prompt-mid flex-direction-column" style="height: 622rpx">
  76. <view class="" style="height: 230rpx; width: 500rpx; margin:5rpx;">
  77. <view class="position-absolute-center">
  78. <image class="" style="height:296rpx;width: 296rpx"
  79. src="../../../static/common/subNVue/unlock/unlock-mid-bg.png"></image>
  80. </view>
  81. <view class="position-absolute-center">
  82. <image style="width: 196rpx;height:196rpx;" mode="aspectFit"
  83. src="../../../static/common/subNVue/unlock/unlock-mid.png">
  84. </image>
  85. </view>
  86. </view>
  87. <view>
  88. <!-- 内容部分 -->
  89. <text class="text-18px text-black">解锁关卡消耗:</text>
  90. </view>
  91. <view class="justify-center align-center flex-direction-row unlock-cell">
  92. <view class="align-center flex-direction-row"
  93. style="margin-right: 40rpx; padding: 0 18px; height: 56rpx;">
  94. <image class="png-more" style="margin-right: 16rpx;"
  95. src="../../../static/common/sideBar/sGold.png">
  96. </image>
  97. <view class="text-14px" style="line-height: 28rpx;">{{unlockItem.consumeGold}}</view>
  98. </view>
  99. <view class=" align-center flex-direction-row" style="padding: 0 18px; height: 56rpx;">
  100. <image class="png-more" style="margin-right: 16rpx; "
  101. src="../../../static/common/sideBar/sDiamond.png">
  102. </image>
  103. <view class="text-14px" style="line-height: 28rpx;">{{unlockItem.consumeDiamond}}</view>
  104. </view>
  105. </view>
  106. </view>
  107. <view class="position-absolute-center-top" style="top: 160rpx">
  108. <image class="prompt-title" mode="aspectFit"
  109. src="../../../static/common/subNVue/unlock/unlock-title.png">
  110. </image>
  111. </view>
  112. <view class="position-absolute-center-bottom justify-center align-center flex-direction-row"
  113. style="bottom: 240rpx;">
  114. <button class="make-bg-bPurple unlock-button" @click="buttonMessage('confirm')"><text
  115. class="text-white text-18px">解锁</text> </button>
  116. <button class="bg-grey-mid unlock-button" style="margin-left: 44rpx; border-color: #CDCDCD;"
  117. @click="buttonMessage('cancle')"><text class="text-white text-18px">取消</text> </button>
  118. </view>
  119. </view>
  120. <!-- 显示签到信息 -->
  121. <view v-if="currentType == 'signIn'" class="reward-container" style="height: 1000rpx;">
  122. <view class="position-absolute-center-top" style="top: 20rpx;">
  123. <image style="width: 656rpx; height: 224rpx;" mode="aspectFit"
  124. src="../../../static/common/subNVue/prompt-bg-title@2x.png">
  125. </image>
  126. </view>
  127. <view class="prompt-mid justify-start flex-direction-column" style="height: 724rpx; ">
  128. <view style="height: 81rpx;"></view>
  129. <view class="flex-wrap flex-direction-row flex-sub justify-center">
  130. <block v-for="(item, index) in lists" :key="index">
  131. <view class="justify-center align-center" style="height: 148rpx; width: 116rpx; margin:5rpx;">
  132. <view class="prompt-cell-bg" style="height: 148rpx;" :style="{opacity:item.isSelect?0.5:1}">
  133. </view>
  134. <view class="position-absolute-center" style="height:148rpx;">
  135. <image style="" :style="{width:item.width+'px',height:item.height+'px'}"
  136. mode="aspectFit" :src="item.isSelect?item.selectedUrl:item.url">
  137. </image>
  138. <text class="text-14px text-center " :class="item.isSelect?'text-gray':''"
  139. style="height: 14px;line-height: 14px; margin-top:12rpx;">{{item.value}}</text>
  140. </view>
  141. </view>
  142. <view class="justify-center align-center" style=" margin:22rpx 5rpx;">
  143. <image v-if="item.isSelect" class="" style="height:34rpx;width:34rpx;"
  144. src="../../../static/common/subNVue/sign/sign-tick@2x.png"></image>
  145. <text v-else class="text-13px text-gray">第{{index+1}}天</text>
  146. </view>
  147. </block>
  148. </view>
  149. </view>
  150. <view class="position-absolute-center-top" style="top: 108rpx">
  151. <image class="prompt-title" mode="aspectFit"
  152. src="../../../static/common/subNVue/sign/sign-title@2x.png">
  153. </image>
  154. </view>
  155. <view class="position-absolute-center-bottom" style="bottom: 200rpx;">
  156. <block v-if="isSignIn">
  157. <button class="prompt-button" style="border: none;" type="default" disabled="true"><text class="text-18px text-gray">已签到领取</text> </button>
  158. </block>
  159. <block v-else>
  160. <button class="make-bg-bPurple prompt-button" @click="buttonMessage('confirm')"><text
  161. class="text-white text-18px">签到领取</text> </button>
  162. </block>
  163. </view>
  164. </view>
  165. <!-- pk过关面板 -->
  166. <view v-if="currentType == 'pkFinish'" class="reward-container" style="height: 1000rpx;">
  167. <view class="position-absolute-center-top" style="top: 20rpx;">
  168. <image style="width: 570rpx; height: 908rpx;" mode="aspectFit"
  169. src="../../../static/common/subNVue/pkFinish@2x.png">
  170. </image>
  171. </view>
  172. <view class="flex flex-direction justify-around align-center" style="position: relative;">
  173. <text class="make-text-bPurple " style="font-size: 23px;">胜利</text>
  174. <image class="margin-12px" style="width: 150rpx;height: 150rpx;" :src="pkFinishItem.url"></image>
  175. <text class="text-18px">{{pkFinishItem.name}}</text>
  176. <text class="text-15px text-grey margin-12px">{{pkFinishItem.score}}分</text>
  177. </view>
  178. <view class="flex-direction-row" style="margin-top: 82rpx;">
  179. <view class="flex flex-direction align-center">
  180. <text class="text-grey text-12px">时长(秒)</text>
  181. <text class="text-bold text-16px" style="margin-top: 5rpx;">{{pkFinishItem.consumeTime}}</text>
  182. </view>
  183. <view class="flex flex-direction align-center" style="margin: 0 35rpx;">
  184. <text class="text-grey text-12px">踩中(次)</text>
  185. <text class="text-bold text-16px" style="margin-top: 5rpx;">{{pkFinishItem.hit}}</text>
  186. </view>
  187. <view class="flex flex-direction align-center">
  188. <text class="text-grey text-12px">失误(次)</text>
  189. <text class="text-bold text-16px" style="margin-top: 5rpx;">{{pkFinishItem.miss}}</text>
  190. </view>
  191. </view>
  192. <button class="make-bg-bPurple reward-button" @click="buttonMessage('confirm')"><text
  193. class="text-white text-18px">确定</text> </button>
  194. </view>
  195. </view>
  196. </template>
  197. <script>
  198. export default {
  199. data() {
  200. return {
  201. title: '',
  202. content: '',
  203. lists: [],
  204. levelRewardIndex: 0,
  205. promptList: [{
  206. name: 'gold',
  207. width: 31,
  208. height: 31,
  209. url: '../../../static/common/sideBar/sGold.png',
  210. explain: ''
  211. }, {
  212. name: 'diamond',
  213. width: 31,
  214. height: 31,
  215. url: '../../../static/common/sideBar/sDiamond.png',
  216. explain: ''
  217. }, {
  218. name: 'medal',
  219. width: 36,
  220. height: 41,
  221. url: '../../../static/common/modal/medal.png',
  222. explain: ''
  223. }, {
  224. name: 'questionMark',
  225. width: 24,
  226. height: 35,
  227. url: '../../../static/common/subNVue/prompt-qm@2x.png',
  228. explain: '未知'
  229. }],
  230. rewardList: [{
  231. name: 'reward-gold',
  232. width: 98,
  233. height: 98,
  234. url: '../../../static/common/subNVue/reward-gold.png',
  235. explain: ''
  236. }, {
  237. name: 'reward-diamond',
  238. width: 98,
  239. height: 98,
  240. url: '../../../static/common/subNVue/reward-diamond.png',
  241. explain: ''
  242. }, {
  243. name: 'reward-medal',
  244. width: 118,
  245. height: 135,
  246. url: '../../../static/common/subNVue/big-medal.png',
  247. explain: ''
  248. }],
  249. currentType: 'none',
  250. /**
  251. * 解锁项目
  252. */
  253. unlockItem: {
  254. consumeGold: 0,
  255. consumeDiamond: 0
  256. },
  257. //当前传入操作的item
  258. operationItem: null,
  259. //pk 完成后对应的一个item
  260. pkFinishItem: {
  261. name: '',
  262. url: '../../../static/defaultAvatar.png',
  263. score: 0,
  264. consumeTime: 0,
  265. hit: 0,
  266. miss: 0
  267. },
  268. //isSignIn
  269. isSignIn: false
  270. }
  271. },
  272. created() {
  273. const vm = this;
  274. // for (let i = 1; i < 4; i++) {
  275. // this.lists.push('item' + i);
  276. // }
  277. uni.$on('reward-popup', (data) => {
  278. vm.title = data.title;
  279. vm.content = data.content;
  280. vm.lists = [];
  281. vm.currentType = data.type;
  282. vm.operationItem = data.operationItem;
  283. if (vm.currentType == 'prompt') {
  284. let _item = data.item;
  285. console.log(_item);
  286. if (_item.gold && _item.gold != 0) {
  287. let temp = Object.assign({}, vm.promptList[0]);
  288. temp.explain = _item.gold + '';
  289. vm.lists.push(temp);
  290. } else {
  291. vm.lists.push(vm.promptList[3]);
  292. }
  293. if (_item.diamond && _item.diamond != 0) {
  294. let temp = Object.assign({}, vm.promptList[1]);
  295. temp.explain = _item.diamond + '';
  296. vm.lists.push(temp);
  297. } else {
  298. vm.lists.push(vm.promptList[3]);
  299. }
  300. if (_item.honor && _item.honor.type != 0) {
  301. let temp = Object.assign({}, vm.promptList[2]);
  302. temp.explain = _item.honor.name + '';
  303. vm.lists.push(temp);
  304. } else {
  305. vm.lists.push(vm.promptList[3]);
  306. }
  307. } else if (vm.currentType == 'unlock') {
  308. vm.unlockItem.consumeGold = data.item.consumeGold;
  309. vm.unlockItem.consumeDiamond = data.item.consumeDiamond;
  310. } else if (vm.currentType == 'signIn') {
  311. vm.lists = data.lists;
  312. //判断是否签到完
  313. vm.isSignIn = data.isSignIn || vm.lists[vm.lists.length-1].isSelect;
  314. // console.log(data.isSignIn +" = "+ JSON.stringify(vm.lists[vm.lists.length-1]));
  315. } else if (vm.currentType == "levelReward") {
  316. let _item = data.item;
  317. if (_item.gold && _item.gold != 0) {
  318. let temp = Object.assign({}, vm.rewardList[0]);
  319. temp.explain = _item.gold + '';
  320. vm.lists.push(temp);
  321. }
  322. if (_item.diamond && _item.diamond != 0) {
  323. let temp = Object.assign({}, vm.rewardList[1]);
  324. temp.explain = _item.diamond + '';
  325. vm.lists.push(temp);
  326. }
  327. if (_item.honor && _item.honor.type != 0) {
  328. let temp = Object.assign({}, vm.rewardList[2]);
  329. temp.explain = _item.honor.explain + '';
  330. vm.lists.push(temp);
  331. }
  332. vm.levelRewardIndex = 0;
  333. console.log(vm.lists);
  334. } else if (vm.currentType == "pkFinish") {
  335. vm.pkFinishItem = Object.assign({}, data.item);
  336. console.log('vm.pkFinishItem:', vm.pkFinishItem);
  337. }
  338. })
  339. },
  340. beforeDestroy() {
  341. uni.$off('drawer-page')
  342. },
  343. methods: {
  344. sendMessage() {
  345. const subNVue = uni.getCurrentSubNVue()
  346. uni.$emit('reward-popup-page', {
  347. title: '已读完!',
  348. })
  349. },
  350. handle(item, index) {
  351. const subNVue = uni.getCurrentSubNVue()
  352. uni.$emit('reward-popup-page', {
  353. type: 'interactive',
  354. info: item + ' 该元素被点击了!',
  355. })
  356. },
  357. buttonMessage(buttonEvent) {
  358. const subNVue = uni.getCurrentSubNVue()
  359. uni.$emit('reward-popup-page', {
  360. type: 'button',
  361. messageType: this.currentType,
  362. confirm: buttonEvent == 'confirm' ? true : false,
  363. cancel: buttonEvent == 'cancel' ? true : false,
  364. info: buttonEvent + ' 该元素被点击了!',
  365. operationItem: this.operationItem
  366. })
  367. if (this.currentType == 'levelReward') {
  368. if (this.levelRewardIndex == this.lists.length - 1) {
  369. this.hidePupup();
  370. } else {
  371. this.levelRewardIndex++;
  372. }
  373. } else {
  374. this.hidePupup();
  375. }
  376. },
  377. hidePupup() {
  378. // const subNVue = uni.getCurrentSubNVue();
  379. // subNVue.hide("auto", 250);
  380. uni.getCurrentSubNVue().hide('auto', 250);
  381. setTimeout(() => {
  382. this.currentType = 'none';
  383. }, 250);
  384. }
  385. }
  386. }
  387. </script>
  388. <style>
  389. .wrapper {
  390. justify-content: center;
  391. }
  392. .title {
  393. height: 100rpx;
  394. line-height: 100rpx;
  395. border-bottom-style: solid;
  396. border-bottom-width: 1rpx;
  397. border-bottom-color: #CBCBCB;
  398. flex: 0;
  399. font-size: 30rpx;
  400. }
  401. .scroller {
  402. height: 400rpx;
  403. padding: 8rpx 15rpx;
  404. }
  405. .content {
  406. color: #555555;
  407. font-size: 32rpx;
  408. }
  409. .message-wrapper {
  410. flex: 0;
  411. border-top-style: solid;
  412. border-top-width: 1rpx;
  413. border-top-color: #CBCBCB;
  414. height: 80rpx;
  415. align-items: flex-end;
  416. }
  417. .send-message {
  418. font-size: 30rpx;
  419. line-height: 80rpx;
  420. color: #00CE47;
  421. margin-left: 20rpx;
  422. }
  423. .cell {
  424. margin: 10rpx;
  425. padding: 20rpx 0;
  426. top: 10rpx;
  427. align-items: center;
  428. justify-content: center;
  429. border-radius: 10rpx;
  430. background-color: #5989B9;
  431. }
  432. .text {
  433. font-size: 30rpx;
  434. text-align: center;
  435. color: white;
  436. }
  437. /**
  438. * 奖励样式
  439. */
  440. .reward-container {
  441. flex-direction: column;
  442. justify-content: space-between;
  443. padding: 10rpx 15rpx;
  444. /* background-color: #F4F5F6; */
  445. border-radius: 4rpx;
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. width: 750rpx;
  450. }
  451. .reward-item {
  452. position: absolute;
  453. top: 0;
  454. bottom: 0;
  455. left: 0;
  456. right: 0;
  457. justify-content: center;
  458. align-items: center;
  459. }
  460. .reward-image {
  461. width: 180rpx;
  462. height: 180rpx;
  463. }
  464. .reward-button {
  465. width: 348rpx;
  466. height: 88rpx;
  467. margin-top: 50rpx;
  468. border-color: rgba(151, 151, 255, 1);
  469. }
  470. /**
  471. * 提示奖励部分
  472. */
  473. .prompt-title {
  474. width: 368rpx;
  475. height: 90rpx;
  476. }
  477. .prompt-mid {
  478. border-width: 14rpx;
  479. border-style: solid;
  480. border-color: #E5E5FF;
  481. border-radius: 10px;
  482. background-color: #FFFFFF;
  483. width: 600rpx;
  484. height: 622rpx;
  485. flex-direction: row;
  486. justify-content: center;
  487. align-items: center;
  488. /* padding: 0 20px; */
  489. }
  490. .prompt-button {
  491. width: 348rpx;
  492. height: 88rpx;
  493. margin-top: 50rpx;
  494. border-color: rgba(151, 151, 255, 1);
  495. border-radius: 21px;
  496. }
  497. .prompt-cell {
  498. margin: 20rpx 5rpx 5rpx 5rpx;
  499. /* padding: 40rpx 0; */
  500. height: 260rpx;
  501. top: 10rpx;
  502. align-items: center;
  503. justify-content: center;
  504. border-radius: 10rpx;
  505. background-color: #F2F2FF;
  506. }
  507. .prompt-cell-bg {
  508. position: absolute;
  509. top: 0;
  510. bottom: 0;
  511. left: 0;
  512. right: 0;
  513. justify-content: center;
  514. align-items: center;
  515. height: 210rpx;
  516. align-items: center;
  517. justify-content: center;
  518. border-radius: 10rpx;
  519. background-color: #F2F2FF;
  520. }
  521. /**
  522. * 解锁样式
  523. */
  524. .unlock-cell {
  525. height: 80rpx;
  526. width: 466rpx;
  527. margin-top: 20rpx;
  528. margin-bottom: 120rpx;
  529. background-color: rgba(202, 202, 202, 0.13);
  530. border-radius: 40rpx;
  531. }
  532. .unlock-button {
  533. width: 208rpx;
  534. height: 80rpx;
  535. border-color: rgba(151, 151, 255, 1);
  536. border-radius: 9px;
  537. }
  538. </style>