reward-popup.nvue 15 KB

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