list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <div class="bg101010">
  3. <div v-for="item in list" :key="item.id" class="m15">
  4. <div style="display: flex;align-items: center;">
  5. <div class="wh60">
  6. <img class="wh56" :src="iconURL(item.giftBagFileKey)" alt="" />
  7. </div>
  8. <div class="ml12">
  9. <div class="txt1">{{ item.giftBagName.length > 8 ? item.giftBagName.slice(0, 8) + '...' : item.giftBagName }}</div>
  10. <div class="txt2">{{ item.giftBagDetailed }}</div>
  11. </div>
  12. </div>
  13. <div :class="item.availableStatus === 1 ? 'gift-btn disabled' : 'gift-btn'" @click="receive(item)">{{ ['领取', '已领完', '查看'][item.availableStatus] }}</div>
  14. </div>
  15. <img class="w80h67" src="~/assets/image/activity/welfare-community/return.png" alt="" @click="returnUp">
  16. <van-popup v-model="showVideoSuccess" position="top" style="background: transparent;color: #999;" :close-on-click-overlay="false">
  17. <div class="w290h215 dialog-view">
  18. <div class="txt3">恭喜您获得礼包</div>
  19. <van-icon name="cross" color="#999999" size="15" class="icon-close" @click="showVideoSuccess = false" />
  20. <div class="txt4">请在游戏中兑换<br />激活码为:{{ gameActivationCode }}。<span class="c3B86FF" @click="copyCode()">复制</span></div>
  21. <div class="buy-btn" @click="order('showVideoSuccess')">购买云机</div>
  22. </div>
  23. </van-popup>
  24. <van-popup v-model="showAd" position="top" style="background: transparent;color: #999;" :close-on-click-overlay="false" @close="closeShowAd">
  25. <div v-for="(item, index) in adlist" :key="item.id" class="m114">
  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" x5-video-orientation="landscape" x5-video-player-type="h5" :x5-video-player-fullscreen="false" :controls="false" :webkit-playsinline="true" :playsinline="true" :autoplay="true" play-btn-position="center" :show-fullscreen-btn="false" :muted="true" @ended="ended" />
  29. <van-icon name="close" color="#999999" size="34" style="margin:15px auto 0;" @click="closeAd" />
  30. </div>
  31. </div>
  32. </van-popup>
  33. <van-popup v-model="showBuy" style="background: transparent;color: #999;" position="top" :close-on-click-overlay="false">
  34. <div class="w290h276 dialog-view">
  35. <div class="txt3">平台内下1单,立得惊喜礼包</div>
  36. <van-icon name="cross" color="#999999" size="15" class="icon-close" @click="showBuy = false" />
  37. <img class="w100h107" src="~/assets/image/activity/welfare-community/gift.png" alt="">
  38. <div class="buy-btn" style="margin:15px auto 0;" @click="order('showBuy')">下单得惊喜礼包</div>
  39. </div>
  40. </van-popup>
  41. <van-popup v-model="showBuySuccess" style="background: transparent;color: #999;" position="top" :close-on-click-overlay="false">
  42. <div class="w290h233 dialog-view">
  43. <div class="txt3">恭喜您获得礼包</div>
  44. <van-icon name="cross" color="#999999" size="15" class="icon-close" @click="showBuySuccess = false" />
  45. <div class="txt4">请在游戏中兑换<br />激活码为:{{ gameActivationCode }}。<span class="c3B86FF" @click="copyCode()">复制</span></div>
  46. <div class="fsc mt20">
  47. <div class="fcc">
  48. <img class="wh40" src="~/assets/image/activity/welfare-community/icon_iphone@2x.png" alt="" />
  49. <span class="txt5">进入云机</span>
  50. </div>
  51. <img class="w12h10 ml10 mt15" src="~/assets/image/activity/welfare-community/arrow@2x.png" alt="">
  52. <div class="fcc">
  53. <img class="wh40" src="~/assets/image/activity/welfare-community/icon_yingyongshichang@2x.png" alt="">
  54. <span class="txt5">打开应用市场</span>
  55. </div>
  56. <img class="w12h10 mt15" src="~/assets/image/activity/welfare-community/arrow@2x.png" alt="">
  57. <div class="fcc">
  58. <img class="wh40" src="~/assets/image/activity/welfare-community/icon_xiazai@2x.png" alt="">
  59. <span class="txt5">下载{{ gameName }}游戏</span>
  60. </div>
  61. </div>
  62. </div>
  63. </van-popup>
  64. <van-popup v-model="showLogin" style="background: transparent;color: #999;" position="top" :close-on-click-overlay="false" @click-close-icon="returnUp">
  65. <div class="w580h582">
  66. <img class="w412h238" src="~/assets/image/activity/welfare-community/tip.png" />
  67. <van-icon name="cross" color="#999999" size="15" class="icon-close" @click="returnUp" />
  68. <div class="txt6">领取礼包,请先绑定手机号</div>
  69. <img class="buy-btn-2" src="~/assets/image/activity/welfare-community/btn.png" @click="login" />
  70. </div>
  71. </van-popup>
  72. </div>
  73. </template>
  74. <script>
  75. import { Toast } from 'vant';
  76. import { fileKeyToUrl } from '@/plugins/file-center.js';
  77. export default {
  78. auth: false,
  79. data() {
  80. return {
  81. showVideoSuccess: false,
  82. showAd: false,
  83. showBuy: false,
  84. showBuySuccess: false,
  85. showLogin: false,
  86. list: [],
  87. id: '',
  88. token: '',
  89. giftBagId: '',
  90. gameActivationCode: '',
  91. adlist: [],
  92. time: 30,
  93. timer: null
  94. }
  95. },
  96. fetch() {
  97. this.token = this.$route.query.token;
  98. this.id = this.$route.query.id;
  99. this.user = this.$route.query.user;
  100. this.gameName = this.$route.query.gameName;
  101. this.getAppGameGiftActivityDetailsList();
  102. },
  103. head: {
  104. title: '福利社区',
  105. },
  106. computed: {
  107. iconURL() {
  108. return (key) => {
  109. return fileKeyToUrl(key)
  110. }
  111. }
  112. },
  113. methods: {
  114. closeShowAd() {
  115. this.showAd = false;
  116. clearInterval(this.timer);
  117. },
  118. closeAd() {
  119. this.showAd = false;
  120. clearInterval(this.timer);
  121. if (this.time === 0) {
  122. this.videoSuccess()
  123. }
  124. },
  125. async copyCode() {
  126. await this.$native.clipboard.writeText(this.gameActivationCode);
  127. this.$toast.success('复制成功');
  128. },
  129. order(key) {
  130. if (key === 'showBuy') {
  131. this.showBuy = false
  132. }
  133. if (key === 'showVideoSuccess') {
  134. this.showVideoSuccess = false
  135. }
  136. if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  137. window.webkit.messageHandlers.order.postMessage({});
  138. }
  139. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  140. window.native.startPurchase();
  141. }
  142. },
  143. login() {
  144. this.showLogin = false
  145. if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  146. window.webkit.messageHandlers.showLogin.postMessage({});
  147. }
  148. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  149. window.native.startBindPhone();
  150. }
  151. },
  152. ended() {
  153. this.showAd = false;
  154. clearInterval(this.timer);
  155. this.videoSuccess();
  156. },
  157. returnUp() {
  158. this.$router.push({ path: '/welfare-community', query: { token: this.$route.query.token, user: this.user } })
  159. },
  160. async receive(item) {
  161. if (item.availableStatus === 2) {
  162. this.gameActivationCode = item.gameActivationCode
  163. if (item.buy === 1) {
  164. this.showBuySuccess = true;
  165. }
  166. if (item.buy === 0) {
  167. this.showVideoSuccess = true;
  168. }
  169. return
  170. }
  171. if (item.availableStatus === 1) {
  172. return
  173. }
  174. this.giftBagId = item.id;
  175. if (this.$route.query.user === '2') {
  176. if (item.taskType === 2) {
  177. this.buySuccess(item);
  178. }
  179. if (item.taskType === 1) {
  180. const res = await this.$axios.$post('/public/v5/advertising/getAdInfoByAdPlace', { id: 1, adPlace: 24, os: this.$userAgent.isAndroid ? 1 : 2 }, { headers: { Authorization: this.token } });
  181. this.adlist = res.data
  182. if (!this.adlist.length) {
  183. return
  184. }
  185. this.adlist = this.adlist.length > 1 ? this.randomSort(this.adlist) : this.adlist;
  186. this.showAd = true
  187. setTimeout(() => {
  188. this.time = this.$refs.videoPlayer[0].duration > 30 ? 30 : parseInt(this.$refs.videoPlayer[0].duration);
  189. this.timer = setInterval(
  190. () => --this.time <= 0 && clearInterval(this.timer),
  191. 1000);
  192. }, 800)
  193. }
  194. } else {
  195. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  196. this.showLogin = true
  197. }
  198. if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  199. window.webkit.messageHandlers.showLogin.postMessage({});
  200. }
  201. }
  202. },
  203. randomSort(array) {
  204. const length = array.length;
  205. if (!Array.isArray(array) || length <= 1) return;
  206. for (let index = 0; index < length - 1; index++) {
  207. const randomIndex = Math.floor(Math.random() * (length - index)) + index;
  208. [array[index], array[randomIndex]] = [array[randomIndex], array[index]];
  209. }
  210. return array;
  211. },
  212. async getAppGameGiftActivityDetailsList() {
  213. try {
  214. const res = await this.$axios.$get('/activity/game/giftActivity/getAppGameGiftActivityDetailsList?giftActivityId=' + this.id, { headers: { Authorization: this.token } });
  215. this.list = res.data;
  216. } catch (err) {
  217. Toast({
  218. message: err.message,
  219. duration: 3000
  220. });
  221. }
  222. },
  223. async buySuccess(item) {
  224. try {
  225. const res = await this.$axios.$get('/activity/game/giftActivity/receiveGameGift?giftBagId=' + item.id, { headers: { Authorization: this.token } });
  226. this.gameActivationCode = res.data.gameActivationCode;
  227. if (res.data.buy === 1) {
  228. this.showBuySuccess = true;
  229. }
  230. if (res.data.buy === 0) {
  231. this.showVideoSuccess = true;
  232. }
  233. } catch (err) {
  234. if (err.response.data.status === 8500) {
  235. this.showBuy = true;
  236. } else {
  237. Toast({
  238. message: err.message,
  239. duration: 3000
  240. });
  241. }
  242. }
  243. },
  244. async videoSuccess() {
  245. try {
  246. const res = await this.$axios.$get('/activity/game/giftActivity/receiveGameGift?giftBagId=' + this.giftBagId, { headers: { Authorization: this.token } });
  247. this.gameActivationCode = res.data.gameActivationCode;
  248. this.getAppGameGiftActivityDetailsList();
  249. if (res.data.buy === 1) {
  250. this.showBuySuccess = true;
  251. }
  252. if (res.data.buy === 0) {
  253. this.showVideoSuccess = true;
  254. }
  255. } catch (err) {
  256. Toast({
  257. message: err.message,
  258. duration: 3000
  259. });
  260. }
  261. }
  262. }
  263. }
  264. </script>
  265. <style scoped>
  266. .w80h67 {
  267. width: 80px;
  268. height: 67px;
  269. position: fixed;
  270. left: 0;
  271. bottom: 70px;
  272. }
  273. .buy-btn-2 {
  274. width: 207px;
  275. height: 40px;
  276. display: block;
  277. margin: 27px auto 0;
  278. }
  279. .w580h582 {
  280. width: 290px;
  281. height: 291px;
  282. background-color: #ffffff;
  283. border-radius: 8px;
  284. overflow: hidden;
  285. margin: 0 auto;
  286. position: relative;
  287. }
  288. .w412h238 {
  289. width: 206px;
  290. height: 119px;
  291. display: block;
  292. margin: 40px auto 17px;
  293. }
  294. .disabled {
  295. background: #2b3c5c !important;
  296. color: #999999 !important;
  297. }
  298. .txt6 {
  299. height: 22px;
  300. font-size: 16px;
  301. font-weight: 500;
  302. color: #363636;
  303. line-height: 22px;
  304. text-align: center;
  305. }
  306. .wh40 {
  307. width: 40px;
  308. height: 40px;
  309. }
  310. .mt20 {
  311. margin-top: 20px;
  312. }
  313. .fsc {
  314. display: flex;
  315. align-items: flex-start;
  316. justify-content: center;
  317. }
  318. .ml10 {
  319. margin-left: 10px;
  320. }
  321. .w12h10 {
  322. width: 12px;
  323. height: 10px;
  324. }
  325. .txt5 {
  326. font-size: 12px;
  327. color: #666666;
  328. margin-top: 3px;
  329. }
  330. .fcc {
  331. display: flex;
  332. flex-direction: column;
  333. justify-content: center;
  334. align-items: center;
  335. }
  336. .w100h107 {
  337. width: 100px;
  338. height: 107px;
  339. display: block;
  340. margin: 17px auto 0;
  341. }
  342. .w290h233 {
  343. width: 290px;
  344. height: 233px;
  345. margin: 0 auto;
  346. }
  347. .w290h276 {
  348. width: 290px;
  349. height: 276px;
  350. margin: 0 auto;
  351. }
  352. .dialog-view {
  353. background: linear-gradient(360deg, #ffffff 0%, #dfefff 100%);
  354. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.5);
  355. border-radius: 8px;
  356. position: relative;
  357. overflow: hidden;
  358. }
  359. .countdown {
  360. width: 92px;
  361. height: 25px;
  362. background: rgba(6, 6, 6, 0.5);
  363. border-radius: 13px;
  364. position: absolute;
  365. top: 10px;
  366. right: 10px;
  367. font-size: 11px;
  368. text-align: center;
  369. line-height: 25px;
  370. color: #cccccc;
  371. }
  372. .mt15 {
  373. margin-top: 15px;
  374. }
  375. .fwc {
  376. display: flex;
  377. flex-direction: column;
  378. justify-content: center;
  379. position: relative;
  380. }
  381. .w290h330 {
  382. width: 290px;
  383. height: 330px;
  384. background: #000000;
  385. }
  386. .buy-btn {
  387. width: 207px;
  388. height: 40px;
  389. background: linear-gradient(90deg, #38aefc 0%, #3b7fff 100%);
  390. border-radius: 20px;
  391. line-height: 40px;
  392. text-align: center;
  393. font-weight: 500;
  394. color: #ffffff;
  395. font-size: 16px;
  396. margin: 20px auto 0;
  397. }
  398. .c3B86FF {
  399. color: #3b86ff;
  400. }
  401. .txt4 {
  402. width: 290px;
  403. font-size: 14px;
  404. color: #666666;
  405. line-height: 20px;
  406. margin-top: 12px;
  407. text-align: center;
  408. }
  409. .txt3 {
  410. width: 290px;
  411. font-size: 18px;
  412. font-weight: 500;
  413. color: #363636;
  414. line-height: 25px;
  415. text-align: center;
  416. margin-top: 47px;
  417. }
  418. .w290h215 {
  419. width: 290px;
  420. height: 215px;
  421. margin: 0 auto;
  422. position: relative;
  423. }
  424. .m114 {
  425. margin: 0 auto;
  426. width: 290px;
  427. }
  428. .icon-close {
  429. position: absolute;
  430. top: 20px;
  431. right: 20px;
  432. }
  433. .gift-btn {
  434. width: 78px;
  435. height: 28px;
  436. background: #3b7fff;
  437. border-radius: 4px;
  438. font-size: 14px;
  439. color: #ffffff;
  440. line-height: 28px;
  441. text-align: center;
  442. justify-self: end;
  443. }
  444. .ml12 {
  445. margin-left: 12px;
  446. }
  447. .txt2 {
  448. font-size: 14px;
  449. color: #cfd1d4;
  450. line-height: 20px;
  451. margin-top: 5px;
  452. }
  453. .txt1 {
  454. font-size: 18px;
  455. font-weight: 500;
  456. color: #cfd1d4;
  457. line-height: 25px;
  458. }
  459. .wh60 {
  460. width: 60px;
  461. height: 60px;
  462. border: 1px solid #eaeaea;
  463. border-radius: 50%;
  464. padding: 2px;
  465. box-sizing: border-box;
  466. }
  467. .wh56 {
  468. width: 56px;
  469. height: 56px;
  470. border-radius: 50%;
  471. }
  472. .bg101010 {
  473. background: #101010;
  474. min-height: 100vh;
  475. overflow: hidden;
  476. }
  477. .m15 {
  478. margin: 15px;
  479. height: 83px;
  480. background: #1e2022;
  481. box-shadow: 0px 3px 7px 0px #1e2022;
  482. border-radius: 8px;
  483. display: flex;
  484. align-items: center;
  485. justify-content: space-between;
  486. padding: 12px 15px 12px;
  487. box-sizing: border-box;
  488. }
  489. </style>