list.vue 12 KB

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