list.vue 13 KB

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