index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="bg">
  3. <img v-if="num" class="btn" src="~/assets/image/activity/rentNo/btn-active.png" alt="" @click="receiverGameRentNoCode()">
  4. <img v-else class="btn" src="~/assets/image/activity/rentNo/btn.png" alt="">
  5. <div class="tip">
  6. 领取次数剩余 <span class="cFE87C7">{{ num }}</span> 次(数量有限 先到先得)
  7. </div>
  8. <img class="rule" src="~/assets/image/activity/rentNo/rule.png" alt="" @click="getRecordList()">
  9. <van-popup v-model="show" :style="{ background: 'transparent' }">
  10. <div class="w280h335">
  11. <div class="c333333">领取记录</div>
  12. <div class="mlr15">
  13. <div class="frnb bb1">
  14. <div class="c666666 ml20">激活码</div>
  15. <div class="c666666 mr30">操作</div>
  16. </div>
  17. <div class="h173">
  18. <div v-for="item in list" :key="item.id" class="frnb">
  19. <div class="fs15 ml20">{{ item.code | activationCodeMask }}</div>
  20. <div class="c2E76F9 mr30" @click="copy(item.code)">复制</div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <img class="wh35" src="~/assets/image/activity/rentNo/close.png" alt="" @click="show = false">
  26. </van-popup>
  27. <van-popup v-model="showResult" :style="{ background: 'transparent' }">
  28. <div class="w280h248">
  29. <div class="c333333">恭喜您获得体验会员</div>
  30. <div class="fs15">激活码:<span class="c0FA2EB">{{ code | activationCodeMask }}</span></div>
  31. <img class="w160h44" src="~/assets/image/activity/rentNo/btn-copy.png" alt="" @click="copy(code)">
  32. </div>
  33. <img class="wh35" src="~/assets/image/activity/rentNo/close.png" alt="" @click="showResult = false">
  34. </van-popup>
  35. </div>
  36. </template>
  37. <script>
  38. import { Toast } from 'vant';
  39. export default {
  40. auth: false,
  41. filters: {
  42. activationCodeMask(value) {
  43. // 微信环境不支持零宽断言
  44. return value.replace(/(.{4})(.*)(.{4}$)/, '$1***$3');
  45. },
  46. },
  47. data() {
  48. return {
  49. show: false,
  50. showResult: false,
  51. token: '',
  52. list: [],
  53. num: 0,
  54. code: ''
  55. }
  56. },
  57. head: {
  58. title: '惊喜礼包领取'
  59. },
  60. created() {
  61. this.token = this.$route.query.token;
  62. this.gameRentNoCodeInfo()
  63. },
  64. mounted() {
  65. document.addEventListener('visibilitychange', this.handleVisiable)
  66. },
  67. destroyed() {
  68. document.removeEventListener('visibilitychange', this.handleVisiable)
  69. },
  70. methods: {
  71. handleVisiable(e) {
  72. if (e.target.visibilityState === 'visible') {
  73. this.gameRentNoCodeInfo();
  74. }
  75. },
  76. async gameRentNoCodeInfo() {
  77. try {
  78. const res = await this.$axios.$get('/activity/game/rentNo/gameRentNoCodeInfo', { headers: { Authorization: this.token } });
  79. this.num = res.data
  80. } catch (err) {
  81. Toast({
  82. message: err.message,
  83. duration: 3000
  84. });
  85. }
  86. },
  87. async getRecordList() {
  88. try {
  89. const res = await this.$axios.$get('/activity/game/rentNo/receive/record?pageNum=1&pageSize=10000', { headers: { Authorization: this.token } });
  90. this.list = res.data.list;
  91. this.show = true
  92. } catch (err) {
  93. Toast({
  94. message: err.message,
  95. duration: 3000
  96. });
  97. }
  98. },
  99. async receiverGameRentNoCode() {
  100. try {
  101. const res = await this.$axios.$post('/activity/game/rentNo/receiverGameRentNoCode', { userName: this.$auth.user.username }, { headers: { Authorization: this.token } });
  102. this.code = res.data
  103. this.gameRentNoCodeInfo();
  104. this.showResult = true;
  105. } catch (err) {
  106. Toast({
  107. message: err.message,
  108. duration: 3000
  109. });
  110. }
  111. },
  112. async copy(code) {
  113. await this.$native.clipboard.writeText(code);
  114. this.$toast.success('复制成功');
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. .bg {
  121. background-size: 100% auto;
  122. overflow: hidden;
  123. padding: 0;
  124. padding-bottom: env(safe-area-inset-bottom, 30px);
  125. background-image: url('~/assets/image/activity/rentNo/bg.png');
  126. height: 1052px;
  127. .btn {
  128. width: 300px;
  129. height: 72px;
  130. display: block;
  131. margin: 484px auto 0;
  132. }
  133. .tip {
  134. width: 100%;
  135. height: 40px;
  136. line-height: 40px;
  137. text-align: center;
  138. font-size: 15px;
  139. color: #FFFFFF;
  140. text-shadow: 0px 1px 2px rgba(253, 93, 190, 0.18);
  141. border-radius: 5px;
  142. margin-top: 11px;
  143. .cFE87C7 {
  144. color: #FE87C7;
  145. font-size: 20px;
  146. font-weight: bold;
  147. }
  148. }
  149. .rule {
  150. width: 35px;
  151. height: 103px;
  152. position: absolute;
  153. right: 0;
  154. top: 183px;
  155. }
  156. .w280h335 {
  157. width: 280px;
  158. height: 335px;
  159. background: url('~/assets/image/activity/rentNo/dialog.png');
  160. background-size: 100% 100%;
  161. overflow: hidden;
  162. .c333333 {
  163. height: 18px;
  164. font-size: 18px;
  165. font-weight: bold;
  166. color: #333333;
  167. text-align: center;
  168. margin-top: 91px;
  169. }
  170. .mlr15 {
  171. margin: 10px 15px 22px;
  172. .frnb {
  173. display: flex;
  174. justify-content: space-between;
  175. align-items: center;
  176. height: 30px;
  177. line-height: 30px;
  178. }
  179. .c666666 {
  180. font-size: 15px;
  181. color: #666666;
  182. }
  183. .ml20 {
  184. margin-left: 20px;
  185. }
  186. .mr30 {
  187. margin-right: 30px;
  188. }
  189. .bb1 {
  190. border-bottom: 1px solid #E6E6E6;
  191. }
  192. .fs15 {
  193. font-size: 15px;
  194. font-weight: 400;
  195. color: #333333;
  196. }
  197. .c2E76F9 {
  198. font-size: 15px;
  199. font-weight: 400;
  200. color: #2E76F9;
  201. }
  202. .h173 {
  203. height: 173px;
  204. overflow-y: auto;
  205. }
  206. }
  207. }
  208. .w280h248 {
  209. width: 280px;
  210. height: 248px;
  211. background: url('~/assets/image/activity/rentNo/dialog2.png');
  212. background-size: 100% 100%;
  213. overflow: hidden;
  214. .c333333 {
  215. font-size: 24px;
  216. font-weight: 400;
  217. color: #333333;
  218. text-align: center;
  219. margin-top: 108px;
  220. }
  221. .fs15 {
  222. font-size: 15px;
  223. font-weight: 400;
  224. color: #333333;
  225. text-align: center;
  226. margin-top: 10px;
  227. }
  228. .c0FA2EB {
  229. font-size: 15px;
  230. font-weight: 400;
  231. color: #0FA2EB !important;
  232. }
  233. .w160h44 {
  234. width: 160px;
  235. height: 44px;
  236. display: block;
  237. margin: 11px auto 0;
  238. }
  239. }
  240. .wh35 {
  241. width: 35px;
  242. height: 35px;
  243. margin: 23px auto 0;
  244. display: block;
  245. }
  246. }
  247. </style>