list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <div class="bg101010">
  3. <van-skeleton :row="4" :loading="isLoading" avatar-shape="square" />
  4. <div v-for="item in list" :key="item.id" class="m15">
  5. <div style="display: flex;align-items: center;">
  6. <div class="wh60">
  7. <img class="wh56" :src="iconURL(item.giftBagFileKey)" alt="" />
  8. </div>
  9. <div class="ml12">
  10. <div class="txt1">{{ item.giftBagName.length > 8 ? item.giftBagName.slice(0, 8) + '...' : item.giftBagName }}</div>
  11. <div class="txt2">{{ item.giftBagDetailed }}</div>
  12. </div>
  13. </div>
  14. <div :class="item.availableStatus === 1 ? 'gift-btn disabled' : 'gift-btn'" @click="receive(item)">{{ ['领取', '已领完', '查看'][item.availableStatus] }}</div>
  15. </div>
  16. <img class="w80h67" src="~/assets/image/activity/welfare-community/return.png" alt="" @click="returnUp">
  17. <van-popup v-model="showVideoSuccess" style="background: transparent;color: #999;" closeable close-icon-position="top-right" :close-on-click-overlay="false">
  18. <div class="w290h215 dialog-view">
  19. <div class="txt3">恭喜您获得礼包</div>
  20. <div class="txt4">请在游戏中兑换<br />激活码为:{{ gameActivationCode }}。<span class="c3B86FF">复制</span></div>
  21. <div class="buy-btn">购买云机</div>
  22. </div>
  23. </van-popup>
  24. <van-popup v-model="showAd" style="background: transparent;color: #999;" :close-on-click-overlay="false">
  25. <div v-for="(item, index) in adlist" :key="item.id">
  26. <div v-if="index === 0" class="fwc">
  27. <div v-if="time" class="countdown">{{ time }}s后关闭广告</div>
  28. <video ref="videoPlayer" class="w290h330" :src="item.adVideoBase.videoUrl" :controls="false" :autoplay="false" :muted="true" :loop="false" @ended="ended" />
  29. <van-icon name="close" color="#999999" size="34" style="margin:15px auto 0;" @click="showAd = time > 0 ? true : false; getAppGameGiftActivityDetailsList()" />
  30. </div>
  31. </div>
  32. </van-popup>
  33. <van-popup v-model="showBuy" style="background: transparent;color: #999;" closeable close-icon-position="top-right" :close-on-click-overlay="false">
  34. <div class="w290h276 dialog-view">
  35. <div class="txt3">平台内下1单,立得惊喜礼包</div>
  36. <img class="w100h107" src="~/assets/image/activity/welfare-community/gift.png" alt="">
  37. <div class="buy-btn" style="margin:15px auto 0;" @click="order">下单得惊喜礼包</div>
  38. </div>
  39. </van-popup>
  40. <van-popup v-model="showBuySuccess" style="background: transparent;color: #999;" closeable close-icon-position="top-right" :close-on-click-overlay="false">
  41. <div class="w290h233 dialog-view">
  42. <div class="txt3">恭喜您获得礼包</div>
  43. <div class="txt4">请在游戏中兑换<br />激活码为:{{ gameActivationCode }}。<span class="c3B86FF">复制</span></div>
  44. <div class="fsc mt20">
  45. <div class="fcc">
  46. <img class="wh40" src="~/assets/image/activity/welfare-community/icon_iphone@2x.png" alt="" />
  47. <span class="txt5">进入云机</span>
  48. </div>
  49. <img class="w12h10 ml10 mt15" src="~/assets/image/activity/welfare-community/arrow@2x.png" alt="">
  50. <div class="fcc">
  51. <img class="wh40" src="~/assets/image/activity/welfare-community/icon_yingyongshichang@2x.png" alt="">
  52. <span class="txt5">打开应用市场</span>
  53. </div>
  54. <img class="w12h10 mt15" src="~/assets/image/activity/welfare-community/arrow@2x.png" alt="">
  55. <div class="fcc">
  56. <img class="wh40" src="~/assets/image/activity/welfare-community/icon_xiazai@2x.png" alt="">
  57. <span class="txt5">下载{{ gameName }}游戏</span>
  58. </div>
  59. </div>
  60. </div>
  61. </van-popup>
  62. <van-popup v-model="showLogin" style="background: transparent;color: #999;" closeable close-icon-position="top-right" :close-on-click-overlay="false" @click-close-icon="returnUp">
  63. <div class="w290h215 dialog-view">
  64. <div class="txt3">领取礼包,请先<br />绑定手机号</div>
  65. <div class="buy-btn" style="margin:30px auto 0;" @click="login">立即绑定</div>
  66. </div>
  67. </van-popup>
  68. </div>
  69. </template>
  70. <script>
  71. import { Toast } from 'vant';
  72. import { fileKeyToUrl } from '@/plugins/file-center.js';
  73. export default {
  74. auth: false,
  75. data() {
  76. return {
  77. showVideoSuccess: false,
  78. showAd: false,
  79. showBuy: false,
  80. showBuySuccess: false,
  81. showLogin: false,
  82. list: [],
  83. isLoading: false,
  84. id: '',
  85. token: '',
  86. giftBagId: '',
  87. gameActivationCode: '',
  88. adlist: [],
  89. time: 30
  90. }
  91. },
  92. fetch() {
  93. this.token = this.$route.query.token;
  94. this.id = this.$route.query.id;
  95. this.user = this.$route.query.user;
  96. this.gameName = this.$route.query.gameName;
  97. this.getAppGameGiftActivityDetailsList();
  98. },
  99. head: {
  100. title: '福利社区',
  101. },
  102. computed: {
  103. iconURL() {
  104. return (key) => {
  105. return fileKeyToUrl(key)
  106. }
  107. }
  108. },
  109. methods: {
  110. order() {
  111. if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  112. window.webkit.messageHandlers.order.postMessage({});
  113. }
  114. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  115. window.native.startPurchase();
  116. }
  117. },
  118. login() {
  119. if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  120. window.webkit.messageHandlers.showLogin.postMessage({});
  121. }
  122. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  123. window.native.startBindPhone();
  124. }
  125. },
  126. ended() {
  127. this.showAd = false
  128. this.getAppGameGiftActivityDetailsList();
  129. },
  130. returnUp() {
  131. this.$router.push({ path: '/welfare-community', query: { token: this.$route.query.token, user: this.user } })
  132. },
  133. async receive(item) {
  134. console.log(item.availableStatus);
  135. console.log(this.$route.query.user === '1');
  136. if (item.availableStatus === 2) {
  137. this.buySuccess(item);
  138. return
  139. }
  140. if (item.availableStatus === 1) {
  141. return
  142. }
  143. this.giftBagId = item.id;
  144. if (this.$route.query.user === '2') {
  145. if (item.taskType === 2) {
  146. this.showBuy = true
  147. }
  148. if (item.taskType === 1) {
  149. this.adlist = await this.$axios.$post('/public/v5/advertising/getAdInfoByAdPlace', { id: 1, adPlace: 24, os: this.$userAgent.isAndroid ? 1 : 2 }, { headers: { Authorization: this.token } });
  150. this.showAd = true
  151. this.$nextTick(() => {
  152. this.$refs.videoPlayer.play();
  153. this.time = 30
  154. const timer = setInterval(
  155. () => --this.time <= 0 && clearInterval(timer),
  156. 1000);
  157. })
  158. }
  159. } else {
  160. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  161. this.showLogin = true
  162. }
  163. if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  164. window.webkit.messageHandlers.showLogin.postMessage({});
  165. }
  166. }
  167. },
  168. async getAppGameGiftActivityDetailsList() {
  169. try {
  170. this.isLoading = true;
  171. const res = await this.$axios.$get('/activity/game/giftActivity/getAppGameGiftActivityDetailsList?giftActivityId=' + this.id, { headers: { Authorization: this.token } });
  172. this.list = res.data;
  173. } finally {
  174. this.isLoading = false;
  175. }
  176. },
  177. async buySuccess(item) {
  178. this.showBuy = false;
  179. try {
  180. const res = await this.$axios.$get('/activity/game/giftActivity/receiveGameGift?giftBagId=' + item.id, { headers: { Authorization: this.token } });
  181. this.gameActivationCode = res.data.gameActivationCode;
  182. if (item.taskType === 1) {
  183. this.showVideoSuccess = true;
  184. }
  185. if (item.taskType === 2) {
  186. this.showBuySuccess = true;
  187. }
  188. } catch (err) {
  189. Toast({
  190. message: err.message,
  191. duration: 3000
  192. });
  193. }
  194. }
  195. }
  196. }
  197. </script>
  198. <style scoped>
  199. .w80h67 {
  200. width: 80px;
  201. height: 67px;
  202. position: absolute;
  203. left: 0;
  204. bottom: 0;
  205. }
  206. .disabled {
  207. background: #2B3C5C !important;
  208. color: #999999 !important;
  209. }
  210. .wh40 {
  211. width: 40px;
  212. height: 40px;
  213. }
  214. .mt20 {
  215. margin-top: 20px;
  216. }
  217. .fsc {
  218. display: flex;
  219. align-items: flex-start;
  220. justify-content: center;
  221. }
  222. .ml10 {
  223. margin-left: 10px;
  224. }
  225. .w12h10 {
  226. width: 12px;
  227. height: 10px;
  228. }
  229. .txt5 {
  230. font-size: 12px;
  231. color: #666666;
  232. margin-top: 3px;
  233. }
  234. .fcc {
  235. display: flex;
  236. flex-direction: column;
  237. justify-content: center;
  238. align-items: center;
  239. }
  240. .w100h107 {
  241. width: 100px;
  242. height: 107px;
  243. display: block;
  244. margin: 17px auto 0;
  245. }
  246. .w290h233 {
  247. width: 290px;
  248. height: 233px;
  249. }
  250. .w290h276 {
  251. width: 290px;
  252. height: 276px;
  253. }
  254. .dialog-view {
  255. background: linear-gradient(360deg, #FFFFFF 0%, #DFEFFF 100%);
  256. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.5);
  257. border-radius: 8px;
  258. position: relative;
  259. overflow: hidden;
  260. }
  261. .countdown {
  262. width: 92px;
  263. height: 25px;
  264. background: rgba(6, 6, 6, 0.5);
  265. border-radius: 13px;
  266. position: absolute;
  267. top: 10px;
  268. right: 10px;
  269. font-size: 11px;
  270. text-align: center;
  271. line-height: 25px;
  272. color: #cccccc;
  273. }
  274. .mt15 {
  275. margin-top: 15px;
  276. }
  277. .fwc {
  278. display: flex;
  279. flex-direction: column;
  280. justify-content: center;
  281. position: relative;
  282. }
  283. .w290h330 {
  284. width: 290px;
  285. height: 330px;
  286. }
  287. .buy-btn {
  288. width: 207px;
  289. height: 40px;
  290. background: linear-gradient(90deg, #38AEFC 0%, #3B7FFF 100%);
  291. border-radius: 20px;
  292. line-height: 40px;
  293. text-align: center;
  294. font-weight: 500;
  295. color: #ffffff;
  296. font-size: 16px;
  297. margin: 20px auto 0;
  298. }
  299. .c3B86FF {
  300. color: #3b86ff;
  301. }
  302. .txt4 {
  303. width: 290px;
  304. font-size: 14px;
  305. color: #666666;
  306. line-height: 20px;
  307. margin-top: 12px;
  308. text-align: center;
  309. }
  310. .txt3 {
  311. width: 290px;
  312. font-size: 18px;
  313. font-weight: 500;
  314. color: #363636;
  315. line-height: 25px;
  316. text-align: center;
  317. margin-top: 47px;
  318. }
  319. .w290h215 {
  320. width: 290px;
  321. height: 215px;
  322. }
  323. .gift-btn {
  324. width: 78px;
  325. height: 28px;
  326. background: #3B7FFF;
  327. border-radius: 4px;
  328. font-size: 14px;
  329. color: #ffffff;
  330. line-height: 28px;
  331. text-align: center;
  332. justify-self: end;
  333. }
  334. .ml12 {
  335. margin-left: 12px;
  336. }
  337. .txt2 {
  338. font-size: 14px;
  339. color: #CFD1D4;
  340. line-height: 20px;
  341. margin-top: 5px;
  342. }
  343. .txt1 {
  344. font-size: 18px;
  345. font-weight: 500;
  346. color: #CFD1D4;
  347. line-height: 25px;
  348. }
  349. .wh60 {
  350. width: 60px;
  351. height: 60px;
  352. border: 1px solid #eaeaea;
  353. border-radius: 50%;
  354. padding: 2px;
  355. box-sizing: border-box;
  356. }
  357. .wh56 {
  358. width: 56px;
  359. height: 56px;
  360. border-radius: 50%;
  361. }
  362. .bg101010 {
  363. background: #101010;
  364. min-height: 100vh;
  365. overflow: hidden;
  366. }
  367. .m15 {
  368. margin: 15px;
  369. height: 83px;
  370. background: #1E2022;
  371. box-shadow: 0px 3px 7px 0px #1E2022;
  372. border-radius: 8px;
  373. display: flex;
  374. align-items: center;
  375. justify-content: space-between;
  376. padding: 12px 15px 12px;
  377. box-sizing: border-box;
  378. }
  379. </style>