index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <div>
  3. <img src="~/assets/image/activity/double-eleven/head.png" width="100%">
  4. <div class="double-eleven">
  5. <van-overlay :show="login" style="background: transparent;">
  6. <div class="wrapper">
  7. <div class="wrapper-login">
  8. 请先登录
  9. </div>
  10. </div>
  11. </van-overlay>
  12. token:{{this.token}}
  13. <div class="double-eleven-container">
  14. <div class="default" v-if="!couponsList.length">
  15. <img src="~/assets/image/activity/double-eleven/couponbj.png" width="100%" >
  16. <div class="default-img" >
  17. <img src="~/assets/image/activity/double-eleven/default.png" >
  18. 暂无优惠券哦~
  19. </div>
  20. </div>
  21. <!-- <div class="coupon" >
  22. <div class="let-title">
  23. <div><span>7</span>折</div>
  24. <div>折扣券</div>
  25. </div>
  26. <div class="content">
  27. <div class="title">月卡套餐7折优惠券</div>
  28. <div class="tips">满90元可用,优惠券有效期<span style="color:#D358A8">3</span>天</div>
  29. <div class="number">剩余数量:2893张</div>
  30. </div>
  31. <div class="btn" @click="receiveCouponRewards({id:11})"></div>
  32. </div> -->
  33. <div class="coupon" v-for="item in couponsList" :key="item.id">
  34. <!-- <div class="icon">{{item.couponName}}</div> -->
  35. <!-- 类型(1.抵扣券 2.折扣券 3.红包券)" -->
  36. <div class="let-title">
  37. <div v-if="item.couponType===1">¥<span>{{item.couponValue}}</span></div>
  38. <div v-else><span>{{item.deductionPrice}}</span>折</div>
  39. <div v-if="item.maxValue" class="maxValue">满{{ item.maxValue }}元减</div>
  40. <div v-else class="maxValue">{{ item.useThreshold }}</div>
  41. </div>
  42. <div class="content">
  43. <div class="title">{{item.couponName}}</div>
  44. <div class="tips">{{item.couponExplain}}</div>
  45. <div class="number">剩余数量:{{item.remainder}}张</div>
  46. </div>
  47. <div v-if="item.receivingStatus===1" class="btn" @click="receiveCouponRewards(item)"></div>
  48. <div v-else-if="item.receivingStatus===2" class="btn-collect"></div>
  49. <div v-else-if="item.receivingStatus===3" class="btn-nocoupon"></div>
  50. </div>
  51. <img src="~/assets/image/activity/double-eleven/game.png" width="100%" style="margin-top:30px">
  52. <img src="~/assets/image/activity/double-eleven/blacktechnology.png" width="100%">
  53. <img src="~/assets/image/activity/double-eleven/advantage.png" width="100%">
  54. </div>
  55. </div>
  56. <van-popup v-model="show" style="background: transparent;" :close-on-click-overlay="false">
  57. <div class="popup-container">
  58. <div class="coupon">
  59. <div class="let-title">
  60. <div v-if="coupons.couponType===1">¥<span>{{coupons.couponValue}}</span></div>
  61. <div v-else><span>{{coupons.couponValue}}</span>折</div>
  62. <div v-if="coupons.maxValue" class="maxValue">满{{ coupons.maxValue }}元减</div>
  63. <div v-else class="maxValue">{{ coupons.useThreshold }}</div>
  64. </div>
  65. <div class="content">
  66. <div class="title">{{coupons.couponName}}</div>
  67. <div class="tips">{{coupons.couponExplain}}</div>
  68. <div class="number">有效期:{{coupons.validityPeriod}}</div>
  69. </div>
  70. </div>
  71. <!-- <div class="coupon" >
  72. <div class="let-title">
  73. <div><span>7</span>折</div>
  74. <div class="maxValue">满5000元减</div>
  75. </div>
  76. <div class="content">
  77. <div class="title">月卡套餐7折优惠券</div>
  78. <div class="tips">满90元可用,优惠券有效期<span style="color:#D358A8">3</span>天</div>
  79. <div class="number">剩余数量:2893张</div>
  80. </div>
  81. </div> -->
  82. <img src="~/assets/image/activity/double-eleven/btn2.png" width="100%" @click="goOrder">
  83. </div>
  84. <div class="coupon-tips">优惠券可在【我的】-【卡券】内查看</div>
  85. <img src="~/assets/image/activity/double-eleven/close.png" class="close" @click="show=false"/>
  86. </van-popup>
  87. </div>
  88. </template>
  89. <script>
  90. import { Toast } from 'vant';
  91. const webUni = require('../../../plugins/uni');
  92. export default {
  93. name: 'doubleEleven',
  94. auth: false,
  95. components: {
  96. },
  97. data() {
  98. return {
  99. show:false,
  100. coupons:{},
  101. login:false,
  102. loading:false,
  103. couponsList:[],
  104. token:'',
  105. client:''
  106. };
  107. },
  108. async fetch() {
  109. if (this.$route.query.type === 'pc') {
  110. this.$router.push({ path: '/activity/doubleEleven/pc', query: { token: this.$route.query.token, type: 'pc' } })
  111. }
  112. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  113. this.token = await window.native.getToken();
  114. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  115. window.webkit.messageHandlers.getToken.postMessage('获取token');
  116. let _this = this
  117. window.getIosToken=(token) => {
  118. _this.token = token
  119. resolve();
  120. };
  121. }else if(this.$route.query.token){
  122. this.token = this.$route.query.token;
  123. }
  124. this.getCoupons()
  125. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  126. this.client = 1;
  127. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  128. this.client = 2;
  129. } else if (this.$userAgent.isMiniProgram) {
  130. this.client = 5;
  131. } else {
  132. this.client = 7;
  133. }
  134. this.visit()
  135. },
  136. head: {
  137. title: '双十一 大额优惠券免费领',
  138. },
  139. created() {
  140. // const _this = this
  141. // setInterval(() => {
  142. // _this.getCoupons()
  143. // }, 600000);
  144. },
  145. methods: {
  146. visit() {
  147. this.$axios.$post('/user/v5/userAccess/user/visit',
  148. {
  149. loginType: this.token ? 1 : 2,
  150. accessType: 13
  151. },
  152. );
  153. },
  154. goOrder()
  155. {
  156. const productId = !this.coupons.products || this.coupons.products.split(',').length > 1 ? -1 : parseInt(this.coupons.products)
  157. if (this.$route.query.type === 'pc') {
  158. window.vgeminipc.startPhoneMeal(productId)
  159. } else if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  160. window.native.startPurchasePage(productId);
  161. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  162. window.webkit.messageHandlers.activity202211.postMessage({productId:productId});
  163. } else if (this.$userAgent.isMiniProgram) {
  164. this.$wx.miniProgram.navigateTo({
  165. url:
  166. '/packageA/order/buy/index',
  167. });
  168. } else {
  169. webUni.webView.navigateTo({
  170. url: '/pages/order/order?productId=' + productId
  171. });
  172. }
  173. },
  174. async getCoupons()
  175. {
  176. const res = await this.$axios.$post('/activity/v5/couponActivity/getCouponActivityInfo', {},
  177. { headers: { Authorization: this.token }});
  178. res.data.forEach(element => {
  179. if(element.receivingStatus !== 3)
  180. {
  181. element.remainder = element.remainder * 4
  182. }
  183. });
  184. this.couponsList = res.data;
  185. },
  186. async receiveCouponRewards(row)
  187. {
  188. if(!this.token)
  189. {
  190. this.login = true
  191. const _this = this
  192. // setTimeout(() => {window.location.href='https://client.phone.androidscloud.com/cloud/phone/web/#/pages/login/index';_this.login = false},1000);
  193. setTimeout(() => {window.location.href='http://prese.phone.androidscloud.com/cloud/phone/web/#/pages/index/index';_this.login = false},1000);
  194. return
  195. }
  196. if(this.loading) return
  197. this.loading = true
  198. Toast.loading({ duration: 0, forbidClick: true,});
  199. try {
  200. const data = { goodsId: row.id, };
  201. const res = await this.$axios.$get('/activity/v5/couponActivity/receiveCouponRewards',{ params: { goodsId:row.id} ,headers: { Authorization: this.token }});
  202. if(res.status === 0)
  203. {
  204. this.coupons = res.data
  205. this.show = true
  206. }
  207. else{
  208. Toast({
  209. message: res.msg,
  210. position: 'top',
  211. duration: 4000,
  212. });
  213. }
  214. await this.getCoupons()
  215. this.loading = false
  216. Toast.clear();
  217. }catch (error) {
  218. Toast.clear();
  219. this.loading = false
  220. await this.getCoupons()
  221. Toast({
  222. message: error.message,
  223. position: 'top',
  224. duration: 4000,
  225. });
  226. }
  227. }
  228. },
  229. };
  230. </script>
  231. <style lang="scss" scoped>
  232. .double-eleven{
  233. background-image: url('../../../assets/image/activity/double-eleven/bj.png');
  234. background-size: cover;
  235. background-repeat: round;
  236. min-height: 100vh;
  237. overflow: hidden;
  238. margin: 0 auto;
  239. margin-top: -1px;
  240. }
  241. img{
  242. display: block;
  243. }
  244. .double-eleven-container{
  245. padding: 10px;
  246. img{
  247. margin-bottom: 30px;
  248. }
  249. }
  250. .coupon{
  251. width: 100%;
  252. height: 105px;
  253. background: #FDFFFD;
  254. box-shadow: 0px 11px 12px 0px rgba(255,121,168,0.46);
  255. border-radius: 12px;
  256. margin-bottom: 10px;
  257. // padding: 18px 10px 8px 10px;
  258. .icon{
  259. width: 70px;
  260. height: 70px;
  261. background: url('../../../assets/image/activity/double-eleven/icon.png') no-repeat;
  262. background-size: 100% 100%;
  263. line-height: 70px;
  264. text-align: center;
  265. font-size: 10px;
  266. font-family: Yuanti SC;
  267. font-weight: bold;
  268. color: #F0F3FC;
  269. display: inline-block;
  270. margin-right: 5px;
  271. vertical-align: top;
  272. }
  273. .let-title{
  274. width: 100px;
  275. height: 105px;
  276. display: inline-block;
  277. background: #F6E1E1;
  278. font-size: 20px;
  279. font-family: Source Han Sans;
  280. font-weight: bold;
  281. color: #F04545;
  282. text-align: center;
  283. padding: 16px 0;
  284. border-radius: 12px 0 0 12px;
  285. vertical-align: top;
  286. span{
  287. font-size: 24px;
  288. }
  289. .maxValue{
  290. font-size: 17px;
  291. }
  292. }
  293. .content{
  294. width: calc(100% - 180px);
  295. height: 105px;
  296. display: inline-block;
  297. // margin-top: -2px;
  298. // margin-left: 5px;
  299. padding: 10px 5px;
  300. .title{
  301. font-size: 12px;
  302. font-family: Source Han Sans CN;
  303. font-weight: 800;
  304. color: #333333;
  305. overflow: hidden;
  306. text-overflow: ellipsis;
  307. white-space: nowrap;
  308. }
  309. .tips{
  310. font-size: 10px;
  311. font-family: Source Han Sans CN;
  312. font-weight: 400;
  313. color: #333333;
  314. overflow: hidden;
  315. text-overflow: ellipsis;
  316. white-space: nowrap;
  317. line-height: 25px;
  318. }
  319. .number{
  320. margin-top: 5px;
  321. height: 20px;
  322. line-height: 20px;
  323. background: linear-gradient(90deg, #FF4BD3, #7492FE);
  324. font-size: 10px;
  325. font-family: Source Han Sans CN;
  326. font-weight: 400;
  327. color: #FFFFFF;
  328. padding: 0 5px;
  329. width: fit-content;
  330. margin-top: 3px;
  331. // display: block;
  332. }
  333. }
  334. .btn{
  335. width: 60px;
  336. height: 60px;
  337. background: url('../../../assets/image/activity/double-eleven/btn.png') no-repeat;
  338. background-size: 100% 100%;
  339. line-height: 80px;
  340. text-align: center;
  341. font-size: 15px;
  342. font-family: Yuanti SC;
  343. font-weight: bold;
  344. color: #F0F3FC;
  345. display: inline-block;
  346. margin-left: 2px;
  347. vertical-align: top;
  348. margin-top: 23px;
  349. // vertical-align: initial;
  350. // display: inline-block;
  351. // vertical-align:text-bottom;
  352. // float:right;
  353. }
  354. .btn-collect{
  355. width: 60px;
  356. height: 60px;
  357. background: url('../../../assets/image/activity/double-eleven/collect.png') no-repeat;
  358. background-size: 100% 100%;
  359. line-height: 80px;
  360. text-align: center;
  361. font-size: 15px;
  362. font-family: Yuanti SC;
  363. font-weight: bold;
  364. color: #F0F3FC;
  365. display: inline-block;
  366. margin-left: 2px;
  367. vertical-align: top;
  368. margin-top: 23px;
  369. }
  370. .btn-nocoupon{
  371. width: 60px;
  372. height: 60px;
  373. background: url('../../../assets/image/activity/double-eleven/nocoupon.png') no-repeat;
  374. background-size: 100% 100%;
  375. line-height: 80px;
  376. text-align: center;
  377. font-size: 15px;
  378. font-family: Yuanti SC;
  379. font-weight: bold;
  380. color: #F0F3FC;
  381. display: inline-block;
  382. margin-left: 2px;
  383. vertical-align: top;
  384. margin-top: 23px;
  385. }
  386. }
  387. .popup-container{
  388. width: 295px;
  389. height: 407px;
  390. background: url('../../../assets/image/activity/double-eleven/bj2.png') no-repeat;
  391. background-size: 100% 100%;
  392. padding-top: 210px;
  393. padding-left: 20px;
  394. padding-right: 20px;
  395. .coupon{
  396. width: 255px;
  397. height: 95px;
  398. margin-bottom: 20px;
  399. .let-title{
  400. width: 90px;
  401. height: 95px;
  402. display: inline-block;
  403. background: #F6E1E1;
  404. font-size: 18px;
  405. font-family: Source Han Sans;
  406. font-weight: bold;
  407. color: #F04545;
  408. text-align: center;
  409. padding: 16px 0;
  410. border-radius: 12px 0 0 12px;
  411. vertical-align: top;
  412. span{
  413. font-size: 20px;
  414. }
  415. .maxValue{
  416. font-size: 14px;
  417. }
  418. }
  419. .content{
  420. width: calc(100% - 100px);
  421. margin-bottom: 25px;
  422. .title{
  423. font-size: 14px !important;
  424. font-family: Source Han Sans CN;
  425. font-weight: 800;
  426. color: #333333;
  427. overflow: hidden;
  428. text-overflow: ellipsis;
  429. white-space: nowrap;
  430. line-height: 23px;
  431. }
  432. .tips{
  433. font-size: 12px;
  434. font-family: Source Han Sans CN;
  435. font-weight: 400;
  436. color: #333333;
  437. overflow: hidden;
  438. text-overflow: ellipsis;
  439. white-space: nowrap;
  440. line-height: 20px;
  441. }
  442. .number{
  443. margin-top: 7px;
  444. height: 15px;
  445. line-height: 15px;
  446. background: linear-gradient(90deg, #FF4BD3, #7492FE);
  447. font-size: 12px;
  448. font-family: Source Han Sans CN;
  449. font-weight: 400;
  450. color: #FFFFFF;
  451. padding: 0 5px;
  452. width: fit-content;
  453. }
  454. }
  455. }
  456. }
  457. .coupon-tips{
  458. font-size: 14px;
  459. font-family: Source Han Sans CN;
  460. font-weight: 400;
  461. color: #FFFFFF;
  462. line-height: 30px;
  463. width: 100%;
  464. text-align: center;
  465. margin-top: 5px;
  466. }
  467. .close{
  468. margin-top: 15px;
  469. margin-left: calc(50% - 22px);
  470. width: 44px;
  471. }
  472. .wrapper {
  473. display: flex;
  474. align-items: center;
  475. justify-content: center;
  476. height: 100%;
  477. }
  478. .wrapper-login{
  479. width: 150px;
  480. height: 40px;
  481. background: #000000;
  482. opacity: 0.6;
  483. border-radius: 45px;
  484. color: #ffffff;
  485. line-height: 40px;
  486. text-align:center;
  487. }
  488. .login{
  489. background-color:transparent;
  490. }
  491. .default{
  492. width:100%;
  493. position: relative;
  494. border-radius: 24px;
  495. .default-img{
  496. position: absolute;
  497. top: calc(50% - 50px);
  498. left: calc(50% - 50px);
  499. color: #333;
  500. img {
  501. width: 100px;
  502. margin-bottom: 20px;
  503. }
  504. }
  505. }
  506. </style>