reward-popup.nvue 14 KB

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