reward-popup.nvue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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?1:0.5}">
  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.url:item.selectedUrl">
  137. </image>
  138. <text class="text-14px text-center"
  139. style="height: 14px;line-height: 14px; margin-top:12rpx;">{{item.explain}}+20</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. <button class="make-bg-bPurple prompt-button" @click="buttonMessage('confirm')"><text
  157. class="text-white text-18px">点击领取</text> </button>
  158. </view>
  159. </view>
  160. <!-- pk过关面板 -->
  161. <view v-if="currentType == 'pkFinish'" class="reward-container" style="height: 1000rpx;">
  162. <view class="position-absolute-center-top" style="top: 20rpx;">
  163. <image style="width: 570rpx; height: 908rpx;" mode="aspectFit"
  164. src="../../../static/common/subNVue/pkFinish@2x.png">
  165. </image>
  166. </view>
  167. <view class="flex flex-direction justify-around align-center" style="position: relative;">
  168. <text class="make-text-bPurple " style="font-size: 23px;">胜利</text>
  169. <image class="margin-12px" style="width: 150rpx;height: 150rpx;" :src="pkFinishItem.url"></image>
  170. <text class="text-18px">{{pkFinishItem.name}}</text>
  171. <text class="text-15px text-grey margin-12px">{{pkFinishItem.score}}分</text>
  172. </view>
  173. <view class="flex-direction-row" style="margin-top: 82rpx;">
  174. <view class="flex flex-direction align-center">
  175. <text class="text-grey text-12px">时长(秒)</text>
  176. <text class="text-bold text-16px" style="margin-top: 5rpx;">{{pkFinishItem.consumeTime}}</text>
  177. </view>
  178. <view class="flex flex-direction align-center" style="margin: 0 35rpx;">
  179. <text class="text-grey text-12px">踩中(次)</text>
  180. <text class="text-bold text-16px" style="margin-top: 5rpx;">{{pkFinishItem.hit}}</text>
  181. </view>
  182. <view class="flex flex-direction align-center">
  183. <text class="text-grey text-12px">失误(次)</text>
  184. <text class="text-bold text-16px" style="margin-top: 5rpx;">{{pkFinishItem.miss}}</text>
  185. </view>
  186. </view>
  187. <button class="make-bg-bPurple reward-button" @click="buttonMessage('confirm')"><text
  188. class="text-white text-18px">确定</text> </button>
  189. </view>
  190. </view>
  191. </template>
  192. <script>
  193. export default {
  194. data() {
  195. return {
  196. title: '',
  197. content: '',
  198. lists: [],
  199. levelRewardIndex: 0,
  200. promptList: [{
  201. name: 'gold',
  202. width: 31,
  203. height: 31,
  204. url: '../../../static/common/sideBar/sGold.png',
  205. explain: ''
  206. }, {
  207. name: 'diamond',
  208. width: 31,
  209. height: 31,
  210. url: '../../../static/common/sideBar/sDiamond.png',
  211. explain: ''
  212. }, {
  213. name: 'medal',
  214. width: 36,
  215. height: 41,
  216. url: '../../../static/common/modal/medal.png',
  217. explain: ''
  218. }, {
  219. name: 'questionMark',
  220. width: 24,
  221. height: 35,
  222. url: '../../../static/common/subNVue/prompt-qm@2x.png',
  223. explain: '未知'
  224. }],
  225. rewardList: [{
  226. name: 'reward-gold',
  227. width: 98,
  228. height: 98,
  229. url: '../../../static/common/subNVue/reward-gold.png',
  230. explain: ''
  231. }, {
  232. name: 'reward-diamond',
  233. width: 98,
  234. height: 98,
  235. url: '../../../static/common/subNVue/reward-diamond.png',
  236. explain: ''
  237. }, {
  238. name: 'reward-medal',
  239. width: 118,
  240. height: 135,
  241. url: '../../../static/common/subNVue/big-medal.png',
  242. explain: ''
  243. }],
  244. currentType: 'none',
  245. /**
  246. * 解锁项目
  247. */
  248. unlockItem: {
  249. consumeGold: 0,
  250. consumeDiamond: 0
  251. },
  252. //当前传入操作的item
  253. operationItem: null,
  254. //pk 完成后对应的一个item
  255. pkFinishItem: {
  256. name: '',
  257. url: '../../../static/defaultAvatar.png',
  258. score: 0,
  259. consumeTime: 0,
  260. hit: 0,
  261. miss: 0
  262. }
  263. }
  264. },
  265. created() {
  266. const vm = this;
  267. // for (let i = 1; i < 4; i++) {
  268. // this.lists.push('item' + i);
  269. // }
  270. uni.$on('reward-popup', (data) => {
  271. vm.title = data.title;
  272. vm.content = data.content;
  273. vm.lists = [];
  274. vm.currentType = data.type;
  275. vm.operationItem = data.operationItem;
  276. if (vm.currentType == 'prompt') {
  277. let _item = data.item;
  278. console.log(_item);
  279. if (_item.gold && _item.gold != 0) {
  280. let temp = Object.assign({}, vm.promptList[0]);
  281. temp.explain = _item.gold + '';
  282. vm.lists.push(temp);
  283. } else {
  284. vm.lists.push(vm.promptList[3]);
  285. }
  286. if (_item.diamond && _item.diamond != 0) {
  287. let temp = Object.assign({}, vm.promptList[1]);
  288. temp.explain = _item.diamond + '';
  289. vm.lists.push(temp);
  290. } else {
  291. vm.lists.push(vm.promptList[3]);
  292. }
  293. if (_item.honor && _item.honor.type != 0) {
  294. let temp = Object.assign({}, vm.promptList[2]);
  295. temp.explain = _item.honor.name + '';
  296. vm.lists.push(temp);
  297. } else {
  298. vm.lists.push(vm.promptList[3]);
  299. }
  300. } else if (vm.currentType == 'unlock') {
  301. vm.unlockItem.consumeGold = data.item.consumeGold;
  302. vm.unlockItem.consumeDiamond = data.item.consumeDiamond;
  303. } else if (vm.currentType == 'signIn') {
  304. vm.lists = data.lists;
  305. } else if (vm.currentType == "levelReward") {
  306. let _item = data.item;
  307. if (_item.gold && _item.gold != 0) {
  308. let temp = Object.assign({}, vm.rewardList[0]);
  309. temp.explain = _item.gold + '';
  310. vm.lists.push(temp);
  311. }
  312. if (_item.diamond && _item.diamond != 0) {
  313. let temp = Object.assign({}, vm.rewardList[1]);
  314. temp.explain = _item.diamond + '';
  315. vm.lists.push(temp);
  316. }
  317. if (_item.honor && _item.honor.type != 0) {
  318. let temp = Object.assign({}, vm.rewardList[2]);
  319. temp.explain = _item.honor.explain + '';
  320. vm.lists.push(temp);
  321. }
  322. vm.levelRewardIndex = 0;
  323. console.log(vm.lists);
  324. }else if(vm.currentType == "pkFinish"){
  325. vm.pkFinishItem = Object.assign({},data.item);
  326. console.log('vm.pkFinishItem:',vm.pkFinishItem);
  327. }
  328. })
  329. },
  330. beforeDestroy() {
  331. uni.$off('drawer-page')
  332. },
  333. methods: {
  334. sendMessage() {
  335. const subNVue = uni.getCurrentSubNVue()
  336. uni.$emit('reward-popup-page', {
  337. title: '已读完!',
  338. })
  339. },
  340. handle(item, index) {
  341. const subNVue = uni.getCurrentSubNVue()
  342. uni.$emit('reward-popup-page', {
  343. type: 'interactive',
  344. info: item + ' 该元素被点击了!',
  345. })
  346. },
  347. buttonMessage(buttonEvent) {
  348. const subNVue = uni.getCurrentSubNVue()
  349. uni.$emit('reward-popup-page', {
  350. type: 'button',
  351. messageType: this.currentType,
  352. confirm: buttonEvent == 'confirm' ? true : false,
  353. cancel: buttonEvent == 'cancel' ? true : false,
  354. info: buttonEvent + ' 该元素被点击了!',
  355. operationItem: this.operationItem
  356. })
  357. if (this.currentType == 'levelReward') {
  358. if (this.levelRewardIndex == this.lists.length - 1) {
  359. this.hidePupup();
  360. } else {
  361. this.levelRewardIndex++;
  362. }
  363. } else {
  364. this.hidePupup();
  365. }
  366. },
  367. hidePupup() {
  368. // const subNVue = uni.getCurrentSubNVue();
  369. // subNVue.hide("auto", 250);
  370. uni.getCurrentSubNVue().hide('auto', 250);
  371. setTimeout(() => {
  372. this.currentType = 'none';
  373. }, 250);
  374. }
  375. }
  376. }
  377. </script>
  378. <style>
  379. .wrapper {
  380. justify-content: center;
  381. }
  382. .title {
  383. height: 100rpx;
  384. line-height: 100rpx;
  385. border-bottom-style: solid;
  386. border-bottom-width: 1rpx;
  387. border-bottom-color: #CBCBCB;
  388. flex: 0;
  389. font-size: 30rpx;
  390. }
  391. .scroller {
  392. height: 400rpx;
  393. padding: 8rpx 15rpx;
  394. }
  395. .content {
  396. color: #555555;
  397. font-size: 32rpx;
  398. }
  399. .message-wrapper {
  400. flex: 0;
  401. border-top-style: solid;
  402. border-top-width: 1rpx;
  403. border-top-color: #CBCBCB;
  404. height: 80rpx;
  405. align-items: flex-end;
  406. }
  407. .send-message {
  408. font-size: 30rpx;
  409. line-height: 80rpx;
  410. color: #00CE47;
  411. margin-left: 20rpx;
  412. }
  413. .cell {
  414. margin: 10rpx;
  415. padding: 20rpx 0;
  416. top: 10rpx;
  417. align-items: center;
  418. justify-content: center;
  419. border-radius: 10rpx;
  420. background-color: #5989B9;
  421. }
  422. .text {
  423. font-size: 30rpx;
  424. text-align: center;
  425. color: white;
  426. }
  427. /**
  428. * 奖励样式
  429. */
  430. .reward-container {
  431. flex-direction: column;
  432. justify-content: space-between;
  433. padding: 10rpx 15rpx;
  434. /* background-color: #F4F5F6; */
  435. border-radius: 4rpx;
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. width: 750rpx;
  440. }
  441. .reward-item {
  442. position: absolute;
  443. top: 0;
  444. bottom: 0;
  445. left: 0;
  446. right: 0;
  447. justify-content: center;
  448. align-items: center;
  449. }
  450. .reward-image {
  451. width: 180rpx;
  452. height: 180rpx;
  453. }
  454. .reward-button {
  455. width: 348rpx;
  456. height: 88rpx;
  457. margin-top: 50rpx;
  458. border-color: rgba(151, 151, 255, 1);
  459. }
  460. /**
  461. * 提示奖励部分
  462. */
  463. .prompt-title {
  464. width: 368rpx;
  465. height: 90rpx;
  466. }
  467. .prompt-mid {
  468. border-width: 14rpx;
  469. border-style: solid;
  470. border-color: #E5E5FF;
  471. border-radius: 10px;
  472. background-color: #FFFFFF;
  473. width: 600rpx;
  474. height: 622rpx;
  475. flex-direction: row;
  476. justify-content: center;
  477. align-items: center;
  478. /* padding: 0 20px; */
  479. }
  480. .prompt-button {
  481. width: 348rpx;
  482. height: 88rpx;
  483. margin-top: 50rpx;
  484. border-color: rgba(151, 151, 255, 1);
  485. border-radius: 21px;
  486. }
  487. .prompt-cell {
  488. margin: 20rpx 5rpx 5rpx 5rpx;
  489. /* padding: 40rpx 0; */
  490. height: 260rpx;
  491. top: 10rpx;
  492. align-items: center;
  493. justify-content: center;
  494. border-radius: 10rpx;
  495. background-color: #F2F2FF;
  496. }
  497. .prompt-cell-bg {
  498. position: absolute;
  499. top: 0;
  500. bottom: 0;
  501. left: 0;
  502. right: 0;
  503. justify-content: center;
  504. align-items: center;
  505. height: 210rpx;
  506. align-items: center;
  507. justify-content: center;
  508. border-radius: 10rpx;
  509. background-color: #F2F2FF;
  510. }
  511. /**
  512. * 解锁样式
  513. */
  514. .unlock-cell {
  515. height: 80rpx;
  516. width: 466rpx;
  517. margin-top: 20rpx;
  518. margin-bottom: 120rpx;
  519. background-color: rgba(202, 202, 202, 0.13);
  520. border-radius: 40rpx;
  521. }
  522. .unlock-button {
  523. width: 208rpx;
  524. height: 80rpx;
  525. border-color: rgba(151, 151, 255, 1);
  526. border-radius: 9px;
  527. }
  528. </style>