index.vue 15 KB

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