index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  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. <div class="double-eleven-container">
  13. <div class="default" v-if="!couponsList.length">
  14. <img src="~/assets/image/activity/double-eleven/couponbj.png" width="100%" >
  15. <div class="default-img" >
  16. <img src="~/assets/image/activity/double-eleven/default.png" >
  17. 暂无优惠券哦~
  18. </div>
  19. </div>
  20. <!-- <div class="coupon" >
  21. <div class="let-title">
  22. <div><span>7</span>折</div>
  23. <div>折扣券</div>
  24. </div>
  25. <div class="content">
  26. <div class="title">月卡套餐7折优惠券</div>
  27. <div class="tips">满90元可用,优惠券有效期<span style="color:#D358A8">3</span>天</div>
  28. <div class="number">剩余数量:2893张</div>
  29. </div>
  30. <div class="btn" @click="receiveCouponRewards({id:11})"></div>
  31. </div> -->
  32. <div class="coupon" v-for="item in couponsList" :key="item.id">
  33. <!-- <div class="icon">{{item.couponName}}</div> -->
  34. <!-- 类型(1.抵扣券 2.折扣券 3.红包券)" -->
  35. <div class="let-title">
  36. <div v-if="item.couponType===1">¥<span>{{item.couponValue}}</span></div>
  37. <div v-else><span>{{item.couponValue}}</span>折</div>
  38. <div v-if="item.maxValue">满{{ item.maxValue }}元减</div>
  39. <div v-else>{{ item.useThreshold }}</div>
  40. </div>
  41. <div class="content">
  42. <div class="title">{{item.couponName}}</div>
  43. <div class="tips">{{item.couponExplain}}</div>
  44. <div class="number">剩余数量:{{item.remainder}}张</div>
  45. </div>
  46. <div v-if="item.receivingStatus===1" class="btn" @click="receiveCouponRewards(item)"></div>
  47. <div v-else-if="item.receivingStatus===2" class="btn-collect"></div>
  48. <div v-else-if="item.receivingStatus===3" class="btn-nocoupon"></div>
  49. </div>
  50. <img src="~/assets/image/activity/double-eleven/game.png" width="100%" style="margin-top:30px">
  51. <img src="~/assets/image/activity/double-eleven/blacktechnology.png" width="100%">
  52. <img src="~/assets/image/activity/double-eleven/advantage.png" width="100%">
  53. </div>
  54. </div>
  55. <van-popup v-model="show" style="background: transparent;" :close-on-click-overlay="false">
  56. <div class="popup-container">
  57. <div class="coupon">
  58. <div class="let-title">
  59. <div v-if="coupons.couponType===1">¥<span>{{coupons.couponValue}}</span></div>
  60. <div v-else><span>{{coupons.couponValue}}</span>折</div>
  61. <div v-if="coupons.maxValue">满{{ coupons.maxValue }}元减</div>
  62. <div v-else>{{ coupons.useThreshold }}</div>
  63. </div>
  64. <div class="content">
  65. <div class="title">{{coupons.couponName}}</div>
  66. <div class="tips">{{coupons.couponExplain}}</div>
  67. <div class="number">有效期:{{coupons.validityPeriod}}</div>
  68. </div>
  69. </div>
  70. <!-- <div class="coupon" >
  71. <div class="let-title">
  72. <div><span>7</span>折</div>
  73. <div>折扣券</div>
  74. </div>
  75. <div class="content">
  76. <div class="title">月卡套餐7折优惠券</div>
  77. <div class="tips">满90元可用,优惠券有效期<span style="color:#D358A8">3</span>天</div>
  78. <div class="number">剩余数量:2893张</div>
  79. </div>
  80. </div> -->
  81. <img src="~/assets/image/activity/double-eleven/btn2.png" width="100%" @click="goOrder">
  82. </div>
  83. <div class="coupon-tips">优惠券可在【我的】-【卡券】内查看</div>
  84. <img src="~/assets/image/activity/double-eleven/close.png" class="close" @click="show=false"/>
  85. </van-popup>
  86. </div>
  87. </template>
  88. <script>
  89. import { Toast } from 'vant';
  90. const RSA = require('../../../plugins/wx_rsa');
  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. return
  194. }
  195. if(this.loading) return
  196. this.loading = true
  197. Toast.loading({ duration: 0, forbidClick: true,});
  198. try {
  199. const data = { goodsId: row.id, };
  200. const sign = this.jiaqian(JSON.stringify(data));
  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.message,
  210. position: 'top',
  211. duration: 4000,
  212. });
  213. }
  214. // this.coupons ={"couponName":"8855","couponExplain":"双十一劵1","products":"","validityPeriod":"88天","rebate":88.00,"discount":0.0,"doorsill":0,"fullReduction":0.00}
  215. // this.show = true
  216. await this.getCoupons()
  217. this.loading = false
  218. Toast.clear();
  219. }catch (error) {
  220. Toast.clear();
  221. this.loading = false
  222. await this.getCoupons()
  223. Toast({
  224. message: error.message,
  225. position: 'top',
  226. duration: 4000,
  227. });
  228. }
  229. },
  230. jiaqian(content) {
  231. const PrivateKey =
  232. '-----BEGIN PRIVATE KEY-----MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKCIK/zTSJCP4XhNsb7Mc5lALog+oAja/spMjg8U6rAmVzRtKv8qhw1HK0CRbW/XV66uM+kY7fhjaYbjbbzu2PMMfs2GVpG15jCWLug9fn2hvPT1wkXfooJX61yHK7+inxAXPi4vPNi263mSQGbhZTeqbU5p7nLeRGbdFyBQXVKpAgMBAAECgYAu/475RxZAlI8rPHvkY1EYteypoMQTs6HSslUI31PSXHc9dxSWfenqHkLwdWM30jDuiDvUa6MIDHrRrfXr0XWcQ0IJ93jT7ABkFCdxcKEOG1WE8f1kZ5JyPDJjeQiI9R4jJCukpGU0DdzO7ORvRb4oTFQ15quM+3+SjnK5TtfUsQJBAOLLk03D2s7t2R0GPLZq+WL/ebowbRSy4VHP/IQi4K1bJrll0HLznov60m9UML1ATlS2ub98fBRFXEAaAwJE2O0CQQC1NDEWhrAPU5o3xjjcxIUbbYskskbhjaiX/1Vz0UzS4XfYek4SL68WBWPGWTrSbgbvXtaXj0gmcChF5jxOHtUtAkA4mPsqxfy99UdgYeUW1P1lgkH7gAhIyRdH1nK6+wU83el9DPaHKVrgrfiEBeuf3wNtSqhyK/u/B0wtRxCHKW1FAkAXfwcGdryJoDuVE9z3s3vXDKNIRN2wDaBY5UD9XZxqk9XoeiN5dDltz5EafSOFecLocxG8YVXntg9i0PHs506ZAkEAge9AKaXisZ4jCNHRn1LR2R82RtHTLb2mN3Cc6sGo+SnAKczwRwVg9RgnmaLG4Z/7kJpq0ALgEBlkOmy+9joxAw==-----END PRIVATE KEY-----';
  233. const signature = new RSA.KJUR.crypto.Signature({
  234. alg: 'SHA256withRSA',
  235. });
  236. signature.init(PrivateKey);
  237. signature.updateString(content);
  238. const signData = signature.sign();
  239. // 将内容转成base64
  240. return RSA.hex2b64(signData);
  241. }
  242. },
  243. };
  244. </script>
  245. <style lang="scss" scoped>
  246. .double-eleven{
  247. background-image: url('../../../assets/image/activity/double-eleven/bj.png');
  248. background-size: cover;
  249. background-repeat: round;
  250. min-height: 100vh;
  251. overflow: hidden;
  252. margin: 0 auto;
  253. margin-top: -1px;
  254. }
  255. img{
  256. display: block;
  257. }
  258. .double-eleven-container{
  259. padding: 10px;
  260. img{
  261. margin-bottom: 30px;
  262. }
  263. }
  264. .coupon{
  265. width: 100%;
  266. height: 105px;
  267. background: #FDFFFD;
  268. box-shadow: 0px 11px 12px 0px rgba(255,121,168,0.46);
  269. border-radius: 12px;
  270. margin-bottom: 10px;
  271. // padding: 18px 10px 8px 10px;
  272. .icon{
  273. width: 70px;
  274. height: 70px;
  275. background: url('../../../assets/image/activity/double-eleven/icon.png') no-repeat;
  276. background-size: 100% 100%;
  277. line-height: 70px;
  278. text-align: center;
  279. font-size: 10px;
  280. font-family: Yuanti SC;
  281. font-weight: bold;
  282. color: #F0F3FC;
  283. display: inline-block;
  284. margin-right: 5px;
  285. vertical-align: top;
  286. }
  287. .let-title{
  288. width: 100px;
  289. height: 105px;
  290. display: inline-block;
  291. background: #F6E1E1;
  292. font-size: 20px;
  293. font-family: Source Han Sans;
  294. font-weight: bold;
  295. color: #F04545;
  296. text-align: center;
  297. padding: 16px 0;
  298. border-radius: 12px 0 0 12px;
  299. vertical-align: top;
  300. span{
  301. font-size: 24px;
  302. }
  303. }
  304. .content{
  305. width: calc(100% - 180px);
  306. height: 105px;
  307. display: inline-block;
  308. // margin-top: -2px;
  309. // margin-left: 5px;
  310. padding: 10px 5px;
  311. .title{
  312. font-size: 12px;
  313. font-family: Source Han Sans CN;
  314. font-weight: 800;
  315. color: #333333;
  316. overflow: hidden;
  317. text-overflow: ellipsis;
  318. white-space: nowrap;
  319. }
  320. .tips{
  321. font-size: 10px;
  322. font-family: Source Han Sans CN;
  323. font-weight: 400;
  324. color: #333333;
  325. overflow: hidden;
  326. text-overflow: ellipsis;
  327. white-space: nowrap;
  328. line-height: 25px;
  329. }
  330. .number{
  331. margin-top: 5px;
  332. height: 20px;
  333. line-height: 20px;
  334. background: linear-gradient(90deg, #FF4BD3, #7492FE);
  335. font-size: 10px;
  336. font-family: Source Han Sans CN;
  337. font-weight: 400;
  338. color: #FFFFFF;
  339. padding: 0 5px;
  340. width: fit-content;
  341. margin-top: 3px;
  342. // display: block;
  343. }
  344. }
  345. .btn{
  346. width: 60px;
  347. height: 60px;
  348. background: url('../../../assets/image/activity/double-eleven/btn.png') no-repeat;
  349. background-size: 100% 100%;
  350. line-height: 80px;
  351. text-align: center;
  352. font-size: 15px;
  353. font-family: Yuanti SC;
  354. font-weight: bold;
  355. color: #F0F3FC;
  356. display: inline-block;
  357. margin-left: 2px;
  358. vertical-align: top;
  359. margin-top: 23px;
  360. // vertical-align: initial;
  361. // display: inline-block;
  362. // vertical-align:text-bottom;
  363. // float:right;
  364. }
  365. .btn-collect{
  366. width: 60px;
  367. height: 60px;
  368. background: url('../../../assets/image/activity/double-eleven/collect.png') no-repeat;
  369. background-size: 100% 100%;
  370. line-height: 80px;
  371. text-align: center;
  372. font-size: 15px;
  373. font-family: Yuanti SC;
  374. font-weight: bold;
  375. color: #F0F3FC;
  376. display: inline-block;
  377. margin-left: 2px;
  378. vertical-align: top;
  379. margin-top: 23px;
  380. }
  381. .btn-nocoupon{
  382. width: 60px;
  383. height: 60px;
  384. background: url('../../../assets/image/activity/double-eleven/nocoupon.png') no-repeat;
  385. background-size: 100% 100%;
  386. line-height: 80px;
  387. text-align: center;
  388. font-size: 15px;
  389. font-family: Yuanti SC;
  390. font-weight: bold;
  391. color: #F0F3FC;
  392. display: inline-block;
  393. margin-left: 2px;
  394. vertical-align: top;
  395. margin-top: 23px;
  396. }
  397. }
  398. .popup-container{
  399. width: 295px;
  400. height: 407px;
  401. background: url('../../../assets/image/activity/double-eleven/bj2.png') no-repeat;
  402. background-size: 100% 100%;
  403. padding-top: 210px;
  404. padding-left: 20px;
  405. padding-right: 20px;
  406. .coupon{
  407. width: 255px;
  408. height: 95px;
  409. margin-bottom: 20px;
  410. .let-title{
  411. width: 90px;
  412. height: 95px;
  413. display: inline-block;
  414. background: #F6E1E1;
  415. font-size: 18px;
  416. font-family: Source Han Sans;
  417. font-weight: bold;
  418. color: #F04545;
  419. text-align: center;
  420. padding: 16px 0;
  421. border-radius: 12px 0 0 12px;
  422. vertical-align: top;
  423. span{
  424. font-size: 20px;
  425. }
  426. }
  427. .content{
  428. width: calc(100% - 100px);
  429. margin-bottom: 25px;
  430. .title{
  431. font-size: 14px !important;
  432. font-family: Source Han Sans CN;
  433. font-weight: 800;
  434. color: #333333;
  435. overflow: hidden;
  436. text-overflow: ellipsis;
  437. white-space: nowrap;
  438. line-height: 23px;
  439. }
  440. .tips{
  441. font-size: 12px;
  442. font-family: Source Han Sans CN;
  443. font-weight: 400;
  444. color: #333333;
  445. overflow: hidden;
  446. text-overflow: ellipsis;
  447. white-space: nowrap;
  448. line-height: 20px;
  449. }
  450. .number{
  451. margin-top: 7px;
  452. height: 15px;
  453. line-height: 15px;
  454. background: linear-gradient(90deg, #FF4BD3, #7492FE);
  455. font-size: 12px;
  456. font-family: Source Han Sans CN;
  457. font-weight: 400;
  458. color: #FFFFFF;
  459. padding: 0 5px;
  460. width: fit-content;
  461. }
  462. }
  463. }
  464. }
  465. .coupon-tips{
  466. font-size: 14px;
  467. font-family: Source Han Sans CN;
  468. font-weight: 400;
  469. color: #FFFFFF;
  470. line-height: 30px;
  471. width: 100%;
  472. text-align: center;
  473. margin-top: 5px;
  474. }
  475. .close{
  476. margin-top: 15px;
  477. margin-left: calc(50% - 22px);
  478. width: 44px;
  479. }
  480. .wrapper {
  481. display: flex;
  482. align-items: center;
  483. justify-content: center;
  484. height: 100%;
  485. }
  486. .wrapper-login{
  487. width: 150px;
  488. height: 40px;
  489. background: #000000;
  490. opacity: 0.6;
  491. border-radius: 45px;
  492. color: #ffffff;
  493. line-height: 40px;
  494. text-align:center;
  495. }
  496. .login{
  497. background-color:transparent;
  498. }
  499. .default{
  500. width:100%;
  501. position: relative;
  502. border-radius: 24px;
  503. .default-img{
  504. position: absolute;
  505. top: calc(50% - 50px);
  506. left: calc(50% - 50px);
  507. color: #333;
  508. img {
  509. width: 100px;
  510. margin-bottom: 20px;
  511. }
  512. }
  513. }
  514. </style>