index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. methods: {
  65. async gameRentNoCodeInfo() {
  66. try {
  67. const res = await this.$axios.$get('/activity/game/rentNo/gameRentNoCodeInfo', { headers: { Authorization: this.token } });
  68. this.num = res.data
  69. } catch (err) {
  70. Toast({
  71. message: err.message,
  72. duration: 3000
  73. });
  74. }
  75. },
  76. async getRecordList() {
  77. try {
  78. const res = await this.$axios.$get('/activity/game/rentNo/receive/record?pageNum=1&pageSize=10000', { headers: { Authorization: this.token } });
  79. this.list = res.data.list;
  80. this.show = true
  81. } catch (err) {
  82. Toast({
  83. message: err.message,
  84. duration: 3000
  85. });
  86. }
  87. },
  88. async receiverGameRentNoCode() {
  89. try {
  90. const res = await this.$axios.$post('/activity/game/rentNo/receiverGameRentNoCode', { userName: this.$auth.user.username }, { headers: { Authorization: this.token } });
  91. this.code = res.data
  92. this.gameRentNoCodeInfo();
  93. this.showResult = true;
  94. } catch (err) {
  95. Toast({
  96. message: err.message,
  97. duration: 3000
  98. });
  99. }
  100. },
  101. async copy(code) {
  102. await this.$native.clipboard.writeText(code);
  103. this.$toast.success('复制成功');
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss">
  109. .bg {
  110. background-size: 100% auto;
  111. overflow: hidden;
  112. padding: 0;
  113. padding-bottom: env(safe-area-inset-bottom, 30px);
  114. background-image: url('~/assets/image/activity/rentNo/bg.png');
  115. height: 1052px;
  116. .btn {
  117. width: 300px;
  118. height: 72px;
  119. display: block;
  120. margin: 484px auto 0;
  121. }
  122. .tip {
  123. width: 100%;
  124. height: 40px;
  125. line-height: 40px;
  126. text-align: center;
  127. font-size: 15px;
  128. color: #FFFFFF;
  129. text-shadow: 0px 1px 2px rgba(253, 93, 190, 0.18);
  130. border-radius: 5px;
  131. margin-top: 11px;
  132. .cFE87C7 {
  133. color: #FE87C7;
  134. font-size: 20px;
  135. font-weight: bold;
  136. }
  137. }
  138. .rule {
  139. width: 35px;
  140. height: 103px;
  141. position: absolute;
  142. right: 0;
  143. top: 183px;
  144. }
  145. .w280h335 {
  146. width: 280px;
  147. height: 335px;
  148. background: url('~/assets/image/activity/rentNo/dialog.png');
  149. background-size: 100% 100%;
  150. overflow: hidden;
  151. .c333333 {
  152. height: 18px;
  153. font-size: 18px;
  154. font-weight: bold;
  155. color: #333333;
  156. text-align: center;
  157. margin-top: 91px;
  158. }
  159. .mlr15 {
  160. margin: 10px 15px 22px;
  161. .frnb {
  162. display: flex;
  163. justify-content: space-between;
  164. align-items: center;
  165. height: 30px;
  166. line-height: 30px;
  167. }
  168. .c666666 {
  169. font-size: 15px;
  170. color: #666666;
  171. }
  172. .ml20 {
  173. margin-left: 20px;
  174. }
  175. .mr30 {
  176. margin-right: 30px;
  177. }
  178. .bb1 {
  179. border-bottom: 1px solid #E6E6E6;
  180. }
  181. .fs15 {
  182. font-size: 15px;
  183. font-weight: 400;
  184. color: #333333;
  185. }
  186. .c2E76F9 {
  187. font-size: 15px;
  188. font-weight: 400;
  189. color: #2E76F9;
  190. }
  191. .h173 {
  192. height: 173px;
  193. overflow-y: auto;
  194. }
  195. }
  196. }
  197. .w280h248 {
  198. width: 280px;
  199. height: 248px;
  200. background: url('~/assets/image/activity/rentNo/dialog2.png');
  201. background-size: 100% 100%;
  202. overflow: hidden;
  203. .c333333 {
  204. font-size: 24px;
  205. font-weight: 400;
  206. color: #333333;
  207. text-align: center;
  208. margin-top: 108px;
  209. }
  210. .fs15 {
  211. font-size: 15px;
  212. font-weight: 400;
  213. color: #333333;
  214. text-align: center;
  215. margin-top: 10px;
  216. }
  217. .c0FA2EB {
  218. font-size: 15px;
  219. font-weight: 400;
  220. color: #0FA2EB !important;
  221. }
  222. .w160h44 {
  223. width: 160px;
  224. height: 44px;
  225. display: block;
  226. margin: 11px auto 0;
  227. }
  228. }
  229. .wh35 {
  230. width: 35px;
  231. height: 35px;
  232. margin: 23px auto 0;
  233. display: block;
  234. }
  235. }
  236. </style>