index.vue 15 KB

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