index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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/buy/index',
  155. });
  156. } else {
  157. webUni.webView.navigateTo({
  158. url: '/pages/order/order?productId=' + productId
  159. });
  160. }
  161. },
  162. async getCoupons()
  163. {
  164. const res = await this.$axios.$post('/activity/v5/couponActivity/getCouponActivityInfo', {},
  165. { headers: { Authorization: this.token }});
  166. res.data.forEach(element => {
  167. if(element.receivingStatus !== 3)
  168. {
  169. element.remainder = element.remainder * 4
  170. }
  171. });
  172. this.couponsList = res.data;
  173. },
  174. async receiveCouponRewards(row)
  175. {
  176. if(!this.$route.query.token)
  177. {
  178. this.login = true
  179. const _this = this
  180. setTimeout(() => {window.location.href='https://client.phone.androidscloud.com/cloud/phone/web/#/pages/login/index';_this.login = false},1000);
  181. return
  182. }
  183. if(this.loading) return
  184. this.loading = true
  185. Toast.loading({ duration: 0, forbidClick: true,});
  186. try {
  187. const data = { goodsId: row.id, };
  188. const sign = this.jiaqian(JSON.stringify(data));
  189. const res = await this.$axios.$get('/activity/v5/couponActivity/receiveCouponRewards',{ params: { goodsId:row.id} ,headers: { Authorization: this.token }});
  190. if(res.status === 0)
  191. {
  192. this.coupons = res.data
  193. this.show = true
  194. }
  195. else{
  196. Toast({
  197. message: res.message,
  198. position: 'top',
  199. duration: 4000,
  200. });
  201. }
  202. // this.coupons ={"couponName":"8855","couponExplain":"双十一劵1","products":"","validityPeriod":"88天","rebate":88.00,"discount":0.0,"doorsill":0,"fullReduction":0.00}
  203. // this.show = true
  204. await this.getCoupons()
  205. this.loading = false
  206. Toast.clear();
  207. }catch (error) {
  208. Toast.clear();
  209. this.loading = false
  210. await this.getCoupons()
  211. Toast({
  212. message: error.message,
  213. position: 'top',
  214. duration: 4000,
  215. });
  216. }
  217. },
  218. jiaqian(content) {
  219. const PrivateKey =
  220. '-----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-----';
  221. const signature = new RSA.KJUR.crypto.Signature({
  222. alg: 'SHA256withRSA',
  223. });
  224. signature.init(PrivateKey);
  225. signature.updateString(content);
  226. const signData = signature.sign();
  227. // 将内容转成base64
  228. return RSA.hex2b64(signData);
  229. }
  230. },
  231. };
  232. </script>
  233. <style lang="scss" scoped>
  234. .double-eleven{
  235. background-image: url('../../../assets/image/activity/double-eleven/bj.png');
  236. background-size: cover;
  237. background-repeat: round;
  238. min-height: 100vh;
  239. overflow: hidden;
  240. margin: 0 auto;
  241. margin-top: -1px;
  242. }
  243. img{
  244. display: block;
  245. }
  246. .double-eleven-container{
  247. padding: 10px;
  248. img{
  249. margin-bottom: 30px;
  250. }
  251. }
  252. .coupon{
  253. width: 100%;
  254. height: 105px;
  255. background: #FDFFFD;
  256. box-shadow: 0px 11px 12px 0px rgba(255,121,168,0.46);
  257. border-radius: 12px;
  258. margin-bottom: 10px;
  259. // padding: 18px 10px 8px 10px;
  260. .icon{
  261. width: 70px;
  262. height: 70px;
  263. background: url('../../../assets/image/activity/double-eleven/icon.png') no-repeat;
  264. background-size: 100% 100%;
  265. line-height: 70px;
  266. text-align: center;
  267. font-size: 10px;
  268. font-family: Yuanti SC;
  269. font-weight: bold;
  270. color: #F0F3FC;
  271. display: inline-block;
  272. margin-right: 5px;
  273. vertical-align: top;
  274. }
  275. .let-title{
  276. width: 100px;
  277. height: 105px;
  278. display: inline-block;
  279. background: #F6E1E1;
  280. font-size: 20px;
  281. font-family: Source Han Sans;
  282. font-weight: bold;
  283. color: #F04545;
  284. text-align: center;
  285. padding: 16px 0;
  286. border-radius: 12px 0 0 12px;
  287. vertical-align: top;
  288. span{
  289. font-size: 24px;
  290. }
  291. }
  292. .content{
  293. width: calc(100% - 180px);
  294. height: 105px;
  295. display: inline-block;
  296. // margin-top: -2px;
  297. // margin-left: 5px;
  298. padding: 10px 5px;
  299. .title{
  300. font-size: 12px;
  301. font-family: Source Han Sans CN;
  302. font-weight: 800;
  303. color: #333333;
  304. overflow: hidden;
  305. text-overflow: ellipsis;
  306. white-space: nowrap;
  307. }
  308. .tips{
  309. font-size: 10px;
  310. font-family: Source Han Sans CN;
  311. font-weight: 400;
  312. color: #333333;
  313. overflow: hidden;
  314. text-overflow: ellipsis;
  315. white-space: nowrap;
  316. line-height: 25px;
  317. }
  318. .number{
  319. margin-top: 5px;
  320. height: 20px;
  321. line-height: 20px;
  322. background: linear-gradient(90deg, #FF4BD3, #7492FE);
  323. font-size: 10px;
  324. font-family: Source Han Sans CN;
  325. font-weight: 400;
  326. color: #FFFFFF;
  327. padding: 0 5px;
  328. width: fit-content;
  329. margin-top: 3px;
  330. // display: block;
  331. }
  332. }
  333. .btn{
  334. width: 60px;
  335. height: 60px;
  336. background: url('../../../assets/image/activity/double-eleven/btn.png') no-repeat;
  337. background-size: 100% 100%;
  338. line-height: 80px;
  339. text-align: center;
  340. font-size: 15px;
  341. font-family: Yuanti SC;
  342. font-weight: bold;
  343. color: #F0F3FC;
  344. display: inline-block;
  345. margin-left: 2px;
  346. vertical-align: initial;
  347. // display: inline-block;
  348. // vertical-align:text-bottom;
  349. // float:right;
  350. }
  351. .btn-collect{
  352. width: 60px;
  353. height: 60px;
  354. background: url('../../../assets/image/activity/double-eleven/collect.png') no-repeat;
  355. background-size: 100% 100%;
  356. line-height: 80px;
  357. text-align: center;
  358. font-size: 15px;
  359. font-family: Yuanti SC;
  360. font-weight: bold;
  361. color: #F0F3FC;
  362. display: inline-block;
  363. margin-left: 2px;
  364. vertical-align: initial;
  365. }
  366. .btn-nocoupon{
  367. width: 60px;
  368. height: 60px;
  369. background: url('../../../assets/image/activity/double-eleven/nocoupon.png') no-repeat;
  370. background-size: 100% 100%;
  371. line-height: 80px;
  372. text-align: center;
  373. font-size: 15px;
  374. font-family: Yuanti SC;
  375. font-weight: bold;
  376. color: #F0F3FC;
  377. display: inline-block;
  378. margin-left: 2px;
  379. vertical-align: initial;
  380. }
  381. }
  382. .popup-container{
  383. width: 295px;
  384. height: 407px;
  385. background: url('../../../assets/image/activity/double-eleven/bj2.png') no-repeat;
  386. background-size: 100% 100%;
  387. padding-top: 210px;
  388. padding-left: 20px;
  389. padding-right: 20px;
  390. .coupon{
  391. width: 255px;
  392. height: 95px;
  393. margin-bottom: 20px;
  394. .let-title{
  395. width: 90px;
  396. height: 95px;
  397. display: inline-block;
  398. background: #F6E1E1;
  399. font-size: 18px;
  400. font-family: Source Han Sans;
  401. font-weight: bold;
  402. color: #F04545;
  403. text-align: center;
  404. padding: 16px 0;
  405. border-radius: 12px 0 0 12px;
  406. vertical-align: top;
  407. span{
  408. font-size: 20px;
  409. }
  410. }
  411. .content{
  412. width: calc(100% - 100px);
  413. margin-bottom: 25px;
  414. .title{
  415. font-size: 14px !important;
  416. font-family: Source Han Sans CN;
  417. font-weight: 800;
  418. color: #333333;
  419. overflow: hidden;
  420. text-overflow: ellipsis;
  421. white-space: nowrap;
  422. line-height: 23px;
  423. }
  424. .tips{
  425. font-size: 12px;
  426. font-family: Source Han Sans CN;
  427. font-weight: 400;
  428. color: #333333;
  429. overflow: hidden;
  430. text-overflow: ellipsis;
  431. white-space: nowrap;
  432. line-height: 20px;
  433. }
  434. .number{
  435. margin-top: 7px;
  436. height: 15px;
  437. line-height: 15px;
  438. background: linear-gradient(90deg, #FF4BD3, #7492FE);
  439. font-size: 12px;
  440. font-family: Source Han Sans CN;
  441. font-weight: 400;
  442. color: #FFFFFF;
  443. padding: 0 5px;
  444. width: fit-content;
  445. }
  446. }
  447. }
  448. }
  449. .coupon-tips{
  450. font-size: 14px;
  451. font-family: Source Han Sans CN;
  452. font-weight: 400;
  453. color: #FFFFFF;
  454. line-height: 30px;
  455. width: 100%;
  456. text-align: center;
  457. margin-top: 5px;
  458. }
  459. .close{
  460. margin-top: 15px;
  461. margin-left: calc(50% - 22px);
  462. width: 44px;
  463. }
  464. .wrapper {
  465. display: flex;
  466. align-items: center;
  467. justify-content: center;
  468. height: 100%;
  469. }
  470. .wrapper-login{
  471. width: 150px;
  472. height: 40px;
  473. background: #000000;
  474. opacity: 0.6;
  475. border-radius: 45px;
  476. color: #ffffff;
  477. line-height: 40px;
  478. text-align:center;
  479. }
  480. .login{
  481. background-color:transparent;
  482. }
  483. </style>