index.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. <template>
  2. <div class="lottery-container">
  3. <van-swipe v-if="carousel.length" :autoplay="3000" class="lottery-swipe" vertical :show-indicators="false">
  4. <van-swipe-item v-for="item in carousel" :key="item.mealId">有{{ item.count }}个用户 {{ ['', '抽奖', '购买'][item.type]
  5. }}{{ item.title }}</van-swipe-item>
  6. </van-swipe>
  7. <img class="w51h26" src="~/assets/image/activity/lottery/rule.png" alt="" @click="showRule = true;makePoint('activity_购买协议');" />
  8. <div class="sl">
  9. <img src="~/assets/image/activity/lottery/solgan.png" alt="" class="slogan" />
  10. <img src="~/assets/image/activity/lottery/bannerTitle.png" alt="" class="bannerTitle" />
  11. </div>
  12. <div class="roulette">
  13. <div class="arrow" @click="startRotation"></div>
  14. <div class="gesture" @click="startRotation">
  15. <img src="~/assets/image/activity/lottery/gesture.gif" />
  16. </div>
  17. <img class="start-btn" src="~/assets/image/activity/lottery/start-btn.png" alt="" @click="startRotation" />
  18. </div>
  19. <RoundTurntable ref="roundTurntable" :prize-data="prizeData" :rotate-circle="rotateCircle" :during-time="duringTime" :turntable-style-option="turntableStyleOption" class="turntable" @endRotation="endRotation">
  20. <template slot="item" slot-scope="scope">
  21. <div class="turntable-name">
  22. <span class="fs15">¥</span>{{ scope.item.level }}
  23. </div>
  24. <div class="turntable-img">
  25. <img src="~/assets/image/activity/lottery/yearCard.png" />
  26. </div>
  27. </template>
  28. </RoundTurntable>
  29. <van-popup v-model="showPay" style="background: transparent;" :close-on-click-overlay="false">
  30. <div class="dialog-view">
  31. <div>
  32. <img v-if="luckDrawType===0" class="w219h26" src="~/assets/image/activity/lottery/title-9.9.png" alt="">
  33. <img v-if="luckDrawType===1" class="w219h26" src="~/assets/image/activity/lottery/15.9.png" alt="">
  34. <img v-if="luckDrawType===2" class="w219h26" src="~/assets/image/activity/lottery/9.9.png" alt="">
  35. <van-icon name="close" class="close" color="#939393" @click="closed();" />
  36. <div class="popup-view">
  37. <div class="meal-item">
  38. <div :class="selMealId === mealId ? 'coupon-1 active' : 'coupon-1'" @click="selMealId = mealId;actualPrice=yearActualPrice;originalPrice=yearOriginalPrice;copy='按时计费'">
  39. <div class="coupon-title">
  40. <span>¥</span><span class="txt2">{{ yearActualPrice }}</span>
  41. </div>
  42. <div class="txt4"> 1年使用权 每月30小时</div>
  43. </div>
  44. <div class="fb">
  45. <div v-for="item in mealList" :key="item.id" :class="selMealId === item.id ? 'coupon-2 active' : 'coupon-2'" @click="selMealId = item.id;originalPrice=+item.originalPrice;actualPrice=item.actualPrice;copy=item.day===30?'包月':'包年';makePoint(item.day === 30 ? 'activity_38月卡' : 'activity_268年卡');">
  46. <div class="coupon-title">
  47. <span>¥</span><span class="txt2">{{ item.actualPrice }}</span>
  48. </div>
  49. <div class="txt4">{{ item.day === 30 ? '月卡 30天' : '年卡 365天' }}</div>
  50. </div>
  51. </div>
  52. </div>
  53. <van-grid :column-num="5" :border="false" class="plr10">
  54. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon1.png')" :text="copy" />
  55. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon2.png')" text="游戏托管" />
  56. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon3.png')" text="iOS玩安卓" />
  57. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon4.png')" text="上班自由" />
  58. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon5.png')" text="影音听歌" />
  59. </van-grid>
  60. <div v-for="item in paySupportType" :key="item" class="fnbc" @click="payType = item;makePoint(item === 'aliPay' ? 'activity_支付宝' : 'activity_微信');">
  61. <div v-if="item === 'aliPay'" class="fnc">
  62. <van-icon class="icon-pay" :name="require('~/assets/image/activity/lottery/alipay.png')" />
  63. <span class="txt5">支付宝支付</span>
  64. </div>
  65. <div v-else class="fnc">
  66. <van-icon class="icon-pay" :name="require('~/assets/image/activity/lottery/wx.png')" />
  67. <span class="txt5">微信支付</span>
  68. </div>
  69. <van-icon :name="payType === item? require('~/assets/image/activity/lottery/select-round-icon.png'): require('~/assets/image/activity/lottery/unselect-round-icon.png')" size="24" />
  70. </div>
  71. <div v-if="time" class="count-down-time">
  72. {{luckDrawType===1 ? '15.9':'9.9'}}元年卡抢购资格有效期:
  73. <van-count-down :time="time">
  74. <template #default="timeData">
  75. <span class="block">{{ timeData.hours }}</span>
  76. <span class="colon">:</span>
  77. <span class="block">{{ timeData.minutes }}</span>
  78. <span class="colon">:</span>
  79. <span class="block">{{ timeData.seconds }}</span>
  80. </template>
  81. </van-count-down>
  82. </div>
  83. </div>
  84. <div class="buy-bar">
  85. 原价¥{{originalPrice}}
  86. <div class="buy-bar-btn" @click="createOrder">
  87. <div>立即购买</div>
  88. <div class="tip">节省¥{{originalPrice-actualPrice}}</div>
  89. </div>
  90. </div>
  91. <div class="txt6">
  92. <van-icon :name="checked?'checked':'circle'" color="#666666" class="check" @click="checked=!checked" />开通前阅读并同意<a @click="showRule = true;makePoint('activity_购买协议');">《购买协议》</a>
  93. </div>
  94. </div>
  95. </div>
  96. </van-popup>
  97. <van-popup v-model="show" style="background: transparent" :close-on-click-overlay="false">
  98. <div class="popup-view popup-view-leave">
  99. <div class="txt1">确定离开吗</div>
  100. <div class="txt11">
  101. 离开后您将失去{{luckDrawType===1?'15.9元年卡':'9.9元年卡'}}
  102. </div>
  103. <img v-if="luckDrawType===2" class="w283h81" src="~/assets/image/activity/lottery/coupon-9.9.png" alt="">
  104. <img v-if="luckDrawType===1" class="w283h81" src="~/assets/image/activity/lottery/coupon-15.9.png" alt="">
  105. <van-grid :column-num="5" :border="false" class="plr10">
  106. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon1.png')" text="按时计费" />
  107. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon2.png')" text="游戏托管" />
  108. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon3.png')" text="iOS玩安卓" />
  109. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon4.png')" text="上班自由" />
  110. <van-grid-item :icon="require('../../../assets/image/activity/lottery/icon7.png')" text="年卡会员" />
  111. </van-grid>
  112. <div v-for="item in paySupportType" :key="item" class="fnbc" @click="payType = item;makePoint(item === 'aliPay' ? 'activity_支付宝' : 'activity_微信');">
  113. <div v-if="item === 'aliPay'" class="fnc">
  114. <van-icon class="icon-pay" :name="require('~/assets/image/activity/lottery/alipay.png')" />
  115. <span class="txt5">支付宝支付</span>
  116. </div>
  117. <div v-else class="fnc">
  118. <van-icon class="icon-pay" :name="require('~/assets/image/activity/lottery/wx.png')" />
  119. <span class="txt5">微信支付</span>
  120. </div>
  121. <van-icon :name="payType === item? require('~/assets/image/activity/lottery/select-round-icon.png'): require('~/assets/image/activity/lottery/unselect-round-icon.png')" size="24" />
  122. </div>
  123. <div class="fnbc1">
  124. <div class="btn-leave" @click="show = false;makePoint('activity_狠心离开');">
  125. {{luckDrawType===2 ? '狠心离开' : '继续抽奖' }}
  126. </div>
  127. <div class="btn-pay" @click="createOrder">立即购买</div>
  128. </div>
  129. </div>
  130. <van-icon name="close" class="close1" color="#939393" @click="show=false;makePoint('activity_关闭弹窗')" />
  131. </van-popup>
  132. <van-popup v-model="showRule" style="background: transparent; padding-top: 14px">
  133. <div class="popup-view-rule">
  134. <div class="popup-view-rule-box">
  135. <div class="popup-view-rule-title">购买协议</div>
  136. <div class="h330">
  137. <div class="txt7">
  138. 参与活动前,请仔细阅读购买协议,特别是产品说明和注意事项。用户参与本活动即视为已充分阅读、理解本活动规则,并自愿受活动规则约束。
  139. </div>
  140. <div class="txt8 mt14 fw500">年卡特惠包</div>
  141. <div class="txt9 mt5">每月自动续,时长不用愁</div>
  142. <div class="txt8 mt5 fw500">1年使用权 每月30小时</div>
  143. <div class="txt9 mt5">按实际使用计时,星曜机型可用,立即生效</div>
  144. <div class="txt9 mt14">
  145. <span class="txt7">有效时间:</span>按实际使用云手机的时间计时,不使用不计时;每月30H,当月时长不跨月;
  146. </div>
  147. <div class="txt9"><span class="txt7">可用范围:</span>星曜机型</div>
  148. <div class="txt9"><span class="txt7">生效方式:</span>立即生效</div>
  149. <div class="txt9">
  150. <span class="txt7">订购次数:</span>不可重复订购
  151. </div>
  152. <div class="txt9">
  153. <span class="txt7">退订说明:</span>特惠产品,不支持退订
  154. </div>
  155. <div class="txt9 mt14">产品说明:</div>
  156. <div class="txt7">
  157. 1、产品内容:本产品为臂云科技旗下双子星云手机星曜机型新人特惠年包,包含星曜机型云手机1年使用权,连续12个月每月发放30H时长;进入云手机开始计时,下机后不计时。
  158. </div>
  159. <div class="txt7">2、生效时间:订购扣费后立即生效。</div>
  160. <div class="txt7">3、注意事项:</div>
  161. <div class="txt7">
  162. (1)本产品合约期12个月,自生效当月起每月发放30H时长;
  163. </div>
  164. <div class="txt7">(2)合约到期后需用户另外购买时长;</div>
  165. <div class="txt7">
  166. (3)合约到期后,年卡特惠包剩余时长自动失效;
  167. </div>
  168. <div class="txt7">
  169. (4)合约到期后,另外续费时长包所得的时长仍有效,云机可继续使用;
  170. </div>
  171. <div class="txt7">
  172. (5)年卡特惠包云手机与普通包月云手机计时逻辑不同,两种云手机时长不可叠加,若另外订购普通包月云手机将获得一台新云手机。
  173. </div>
  174. <div class="txt8 mt14">温馨提示:</div>
  175. <div class="txt7">
  176. 1、请您理解:通过任何不正当手段参与活动,如借助非自然流量或外挂工具;利用技术漏洞,恶意退款,批量注册账号、买号等搅乱平台管理秩序的行为,臂云科技有权限制或取消用户的活动资格,不予发放或撤销相关交易及福利内容。
  177. </div>
  178. <div class="txt7">2、如有疑问请联系双子星APP客服咨询</div>
  179. <div class="txt8 mt5 fw500" style="color: #ec6250">
  180. 时长包使用规则
  181. </div>
  182. <div class="txt7 mt5">年卡特惠云手机,按需补充时长包</div>
  183. <div class="txt7">
  184. 有效时间:<span class="txt10">时长用完前一直有效,支持跨月</span>
  185. </div>
  186. <div class="txt7">
  187. 可用范围:<span class="txt10">可续时长的机型</span>
  188. </div>
  189. <div class="txt7">
  190. 生效方式:<span class="txt10">立即生效</span>
  191. </div>
  192. <div class="txt7">
  193. 退订说明:<span class="txt10">立即生效产品,不支持退订</span>
  194. </div>
  195. <div class="txt7 mt14">
  196. 产品说明<br />1、生效方式:时长补充包订购后立即生效,直至时长用完则失效,用户可重复订购。<br />
  197. 2、时长使用顺序:优先使用年卡特惠包时长,年卡特惠包时长耗尽,自动使用时长包时长。<br />3、年卡特惠包合约到期后,如时长补充包仍有时长,年卡特惠包所属云手机可继续使用至时长用尽。
  198. </div>
  199. </div>
  200. <img class="w304h62" src="~/assets/image/activity/lottery/buy-rule-icon.png" alt="" @click="showRule = false" />
  201. </div>
  202. </div>
  203. </van-popup>
  204. </div>
  205. </template>
  206. <script>
  207. import { Toast } from 'vant';
  208. import RoundTurntable from './component/roundTurntable.vue';
  209. const RSA = require('../../../plugins/wx_rsa');
  210. const webUni = require('../../../plugins/uni');
  211. export default {
  212. name: 'Lottery',
  213. auth: false,
  214. components: {
  215. RoundTurntable,
  216. },
  217. data() {
  218. return {
  219. copy: '按时计费',
  220. time: 0,
  221. yearOriginalPrice: 0,
  222. originalPrice: 0,
  223. checked: true,
  224. luckDrawType: 0,
  225. showRule: false,
  226. show: false,
  227. showPay: false,
  228. // 转盘上的奖品数据
  229. prizeData: [
  230. {
  231. id: 6,
  232. level: 29.9,
  233. },
  234. {
  235. id: 3,
  236. level: 58,
  237. },
  238. {
  239. id: 2,
  240. level: 9.9,
  241. },
  242. {
  243. id: 4,
  244. level: 39.9,
  245. },
  246. {
  247. id: 5,
  248. level: 378,
  249. },
  250. {
  251. id: 1,
  252. level: 15.9,
  253. },
  254. ],
  255. // 转动的圈数
  256. rotateCircle: 6,
  257. // 转动需要持续的时间(s)
  258. duringTime: 4.5,
  259. // 转盘样式的选项
  260. turntableStyleOption: {
  261. // 背景色
  262. prizeBgColors: [
  263. '#FFF9F8',
  264. '#FFECC9',
  265. '#FFF9F8',
  266. '#FFECC9',
  267. '#FFF9F8',
  268. '#FFECC9',
  269. ],
  270. // 转盘的外边框颜色
  271. borderColor: '#FFD790',
  272. },
  273. // 中奖的奖品的index
  274. prizeIndex: -1,
  275. // 用来锁定转盘,避免同时多次点击转动
  276. isLocking: false,
  277. // 剩余抽奖次数
  278. num: 2,
  279. token: '',
  280. activityId: '',
  281. actualPrice: 0,
  282. mealId: '',
  283. selMealId: '',
  284. paySupportType: [],
  285. title: '',
  286. payType: '',
  287. mealList: [],
  288. status: 0,
  289. carousel: [],
  290. phoneType: 'SVIP',
  291. client: 0,
  292. yearActualPrice: 0
  293. };
  294. },
  295. async fetch() {
  296. if (this.$route.query.type === 'pc') {
  297. this.$router.push({ path: '/activity/lottery/pc', query: { token: this.$route.query.token } })
  298. }
  299. if (this.$userAgent.isAndroid) {
  300. this.token = await window.native.getToken();
  301. } else {
  302. this.token = this.$route.query.token;
  303. }
  304. if (this.$userAgent.isAndroid) {
  305. this.client = 1;
  306. } else if (this.$userAgent.isIos) {
  307. this.client = 2;
  308. } else if (this.$userAgent.isMiniProgram) {
  309. this.client = 5;
  310. } else {
  311. this.client = 7;
  312. }
  313. console.log(this.client);
  314. },
  315. head: {
  316. title: '年卡抽奖活动',
  317. },
  318. created() {
  319. this.getLuckDrawActivity();
  320. this.getCarouselList();
  321. },
  322. methods: {
  323. async getCarouselList() {
  324. const res = await this.$axios.$post('/activity/v1/member/carousel');
  325. this.carousel = res.data;
  326. },
  327. async getMealInfo() {
  328. const res = await this.$axios.$get(
  329. '/pay/v2/meal/info?phoneType=' + this.phoneType,
  330. );
  331. this.mealList = res.data.list.filter(
  332. (item) =>
  333. (item.day === 30 || item.day === 365) && item.id !== this.mealId,
  334. );
  335. this.yearOriginalPrice = +res.data.list.filter((item) => (item.day === 365))[0].originalPrice
  336. this.originalPrice = this.yearOriginalPrice
  337. },
  338. async createOrder() {
  339. if (!this.checked) {
  340. Toast({
  341. message: '请勾选并且阅读购买协议',
  342. position: 'top',
  343. duration: 4000
  344. });
  345. return
  346. }
  347. try {
  348. Toast.loading({
  349. duration: 0,
  350. forbidClick: true,
  351. });
  352. this.makePoint('activity_立即购买');
  353. let taocan = {
  354. buyType: 1,
  355. couponId: 0,
  356. id: this.selMealId,
  357. mealType: 0,
  358. phoneType: this.phoneType,
  359. quantity: 1,
  360. };
  361. taocan = this.sort_ASCII(taocan);
  362. const sign = this.jiaqian(JSON.stringify(taocan));
  363. const res = await this.$axios.$post('/pay/v1/order/create', taocan, {
  364. headers: { Authorization: this.token, sign }, client: this.client
  365. });
  366. Toast.clear();
  367. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  368. window.native.startPay(
  369. this.payType === 'aliPay' ? 3 : 2,
  370. res.data.myOrderNum,
  371. 1,
  372. );
  373. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  374. window.webkit.messageHandlers.startPay.postMessage({
  375. payType: this.payType === 'aliPay' ? 3 : 2,
  376. orderNum: res.data.myOrderNum,
  377. actualPrice: this.actualPrice,
  378. });
  379. } else if (this.$userAgent.isMiniProgram) {
  380. this.$wx.miniProgram.navigateTo({
  381. url:
  382. '/packageA/order/status/index?record=' +
  383. JSON.stringify({
  384. payActive: this.payType === 'wxPay' ? 1 : 0,
  385. myOrderNum: res.data.myOrderNum,
  386. }),
  387. });
  388. } else {
  389. // 使用postMessage 方法可以发送消息到应用, 消息内容需要在data 对象中,否则webview无法接收到
  390. webUni.webView.postMessage({
  391. data: {
  392. payType: this.payType === 'aliPay' ? 3 : 2,
  393. orderNum: res.data.myOrderNum,
  394. buyType: 1,
  395. price: this.actualPrice,
  396. },
  397. });
  398. }
  399. this.showPay = false;
  400. } catch (error) {
  401. Toast.clear();
  402. Toast({
  403. message: error.message,
  404. position: 'top',
  405. duration: 4000,
  406. });
  407. }
  408. },
  409. sort_ASCII(obj) {
  410. const arr = [];
  411. let num = 0;
  412. for (const i in obj) {
  413. arr[num] = i;
  414. num++;
  415. }
  416. const sortArr = arr.sort();
  417. const sortObj = {};
  418. for (const i in sortArr) {
  419. sortObj[sortArr[i]] = obj[sortArr[i]];
  420. }
  421. return sortObj;
  422. },
  423. jiaqian(content) {
  424. const PrivateKey =
  425. '-----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-----';
  426. const signature = new RSA.KJUR.crypto.Signature({
  427. alg: 'SHA256withRSA',
  428. });
  429. signature.init(PrivateKey);
  430. signature.updateString(content);
  431. const signData = signature.sign();
  432. // 将内容转成base64
  433. return RSA.hex2b64(signData);
  434. },
  435. async getLuckDrawActivity() {
  436. const res = await this.$axios.$post(
  437. '/activity/v1/member/luckDrawActivity',
  438. );
  439. this.activityId = res.data.activityId;
  440. this.status = res.data.status;
  441. this.num = res.data.count;
  442. if (this.num === 0) {
  443. await this.getLuckDraw();
  444. this.luckDrawType = 0;
  445. }
  446. },
  447. // 开始抽奖
  448. async startRotation() {
  449. // 如果还不可以转动
  450. if (!this.canBeRotated()) {
  451. return false;
  452. }
  453. this.makePoint('activity_立即抽奖');
  454. // 开始转动
  455. // 先上锁
  456. this.isLocking = true;
  457. await this.getLuckDraw();
  458. // 成功后次数减少一次
  459. if (this.num > 0) {
  460. this.num--;
  461. }
  462. console.log(this.num);
  463. // 告诉子组件,开始转动了
  464. this.$refs.roundTurntable.rotate(this.prizeIndex);
  465. },
  466. async getLuckDraw() {
  467. // 设置在哪里停下,应该与后台交互,这里随机抽取0~5
  468. const res = await this.$axios.$post(
  469. '/activity/v1/member/luckDraw?activityId=' + this.activityId,
  470. {},
  471. { headers: { Authorization: this.token } },
  472. );
  473. if (res.status === 0) {
  474. this.actualPrice = res.data.actualPrice;
  475. this.yearActualPrice = res.data.actualPrice;
  476. this.luckDrawType = res.data.luckDrawType;
  477. if (res.data.luckDrawType === 1) {
  478. this.makePoint('activity_15.9年卡');
  479. if (Number(localStorage.getItem('year-15-9')) !== 2) {
  480. localStorage.setItem('year-15-9', 1);
  481. }
  482. }
  483. if (res.data.luckDrawType === 2) {
  484. this.makePoint('activity_9.9年卡');
  485. if (Number(localStorage.getItem('year-9-9')) !== 2) {
  486. localStorage.setItem('year-9-9', 1);
  487. }
  488. }
  489. this.mealId = res.data.mealId
  490. this.selMealId = res.data.mealId
  491. this.getMealInfo()
  492. this.paySupportType = res.data.paySupportType
  493. if (this.$userAgent.isMiniProgram) {
  494. this.paySupportType = ['wxPay']
  495. }
  496. this.payType = this.paySupportType[0]
  497. this.phoneType = res.data.phoneType
  498. this.title = res.data.title
  499. this.prizeIndex = res.data.luckDrawType === 1 ? 5 : 2;
  500. if (this.num === 0) {
  501. this.showPay = true
  502. if (this.$userAgent.isAndroid) {
  503. window.native.isMembersLotto(true)
  504. }
  505. }
  506. } else {
  507. Toast({
  508. message: res.msg,
  509. position: 'top',
  510. duration: 4000,
  511. });
  512. }
  513. },
  514. makePoint(positionButton) {
  515. const now = new Date();
  516. this.$axios.$post('/public/v5/buriedPointRecord/reportRecords', [
  517. {
  518. client: this.client,
  519. eventCode: '27_抽奖流程',
  520. userName: this.$auth.user.userName,
  521. positionButton,
  522. operationTime: now
  523. .toISOString()
  524. .replace(/T/g, ' ')
  525. .replace(/\.[\d]{3}Z/, ''),
  526. },
  527. ]);
  528. },
  529. // 已经转动完转盘触发的函数
  530. endRotation() {
  531. // 提示中奖
  532. this.showPay = true;
  533. // 解锁
  534. this.isLocking = false;
  535. if (this.$userAgent.isAndroid) {
  536. window.native.isMembersLotto(true)
  537. }
  538. },
  539. // 判断是否可以转动
  540. canBeRotated() {
  541. if (this.isLocking) {
  542. return false;
  543. }
  544. if (this.status === 0) {
  545. Toast({
  546. message: '当前活动已过期',
  547. position: 'top',
  548. duration: 4000,
  549. });
  550. return false;
  551. }
  552. if (this.status === 2) {
  553. Toast({
  554. message: '当前活动未开启',
  555. position: 'top',
  556. duration: 4000,
  557. });
  558. return false;
  559. }
  560. if (this.status === 3) {
  561. Toast({
  562. message: '当前活动已结束',
  563. position: 'top',
  564. duration: 4000,
  565. });
  566. return false;
  567. }
  568. if (this.num === 0) {
  569. this.showPay = true;
  570. if (this.$userAgent.isAndroid) {
  571. window.native.isMembersLotto(true)
  572. }
  573. return false;
  574. }
  575. this.time = 24 * 60 * 60 * 1000;
  576. return true;
  577. },
  578. closed() {
  579. this.makePoint('activity_关闭抽奖', 'eventCode传27_抽奖流程');
  580. if (+localStorage.getItem('year-15-9') !== 2) {
  581. this.show = true;
  582. localStorage.setItem('year-15-9', 2);
  583. }
  584. if (+localStorage.getItem('year-9-9') !== 2) {
  585. this.show = true;
  586. localStorage.setItem('year-9-9', 2);
  587. }
  588. this.showPay = false
  589. },
  590. },
  591. };
  592. </script>
  593. <style>
  594. .lottery-container .van-grid-item__content {
  595. padding: 0 !important;
  596. }
  597. </style>
  598. <style lang="scss" scoped>
  599. .count-down-time {
  600. height: 46.5px;
  601. background: #333333;
  602. font-size: 12px;
  603. color: #ffffff;
  604. display: flex;
  605. justify-content: center;
  606. align-items: center;
  607. }
  608. .colon {
  609. display: inline-block;
  610. margin: 0 4.5px;
  611. color: #ffffff;
  612. }
  613. .block {
  614. display: inline-block;
  615. width: 17px;
  616. height: 17px;
  617. line-height: 17px;
  618. color: #fff;
  619. font-size: 11px;
  620. background: rgba($color: #ffffff, $alpha: 0.2);
  621. text-align: center;
  622. }
  623. .plr10 {
  624. padding: 0 10px;
  625. margin-bottom: 22px;
  626. }
  627. .dialog-view {
  628. width: 100vw;
  629. height: 100vh;
  630. background: url('../../../assets/image/activity/lottery/dialog-bg.png');
  631. background-size: 100%;
  632. background-repeat: no-repeat;
  633. position: relative;
  634. display: flex;
  635. flex-wrap: wrap;
  636. justify-content: center;
  637. align-items: flex-start;
  638. }
  639. .w283h81 {
  640. width: 283px;
  641. height: 81px;
  642. display: block;
  643. margin: 0 auto 16px;
  644. }
  645. .close {
  646. font-size: 30px;
  647. position: absolute;
  648. top: 18.5px;
  649. right: 26px;
  650. }
  651. .close1 {
  652. font-size: 30px;
  653. position: absolute;
  654. bottom: 0px;
  655. left: calc(50% - 15px);
  656. }
  657. .check {
  658. font-size: 15px;
  659. margin-right: 8.5px;
  660. line-height: 10px;
  661. }
  662. .buy-bar-btn {
  663. width: 184.5px;
  664. height: 50px;
  665. background: linear-gradient(0deg, #df4324 0%, #ffbf96 98%);
  666. border-radius: 10px;
  667. position: absolute;
  668. right: 0;
  669. bottom: 0;
  670. & div:nth-child(1) {
  671. text-align: center;
  672. font-size: 18px;
  673. font-weight: 600;
  674. color: #ffffff;
  675. line-height: 50px;
  676. }
  677. & .tip {
  678. width: 76px;
  679. height: 21px;
  680. background: url('../../../assets/image/activity/lottery/tip.png');
  681. background-size: 100% 100%;
  682. text-align: center;
  683. font-size: 12px;
  684. color: #fff;
  685. line-height: 18px;
  686. position: absolute;
  687. right: 0;
  688. top: -11px;
  689. }
  690. }
  691. .buy-bar {
  692. width: 320px;
  693. height: 40px;
  694. line-height: 40px;
  695. background: #ffffff;
  696. border-radius: 10px;
  697. margin-top: 25px;
  698. position: relative;
  699. font-size: 15px;
  700. text-decoration: line-through;
  701. color: #666666;
  702. padding-left: 28px;
  703. margin-top: 26px;
  704. }
  705. .van-grid-item__text {
  706. font-size: 11px;
  707. }
  708. .meal-item {
  709. margin: 10px;
  710. background: #f2f2f2;
  711. border-radius: 5px;
  712. padding: 7.5px;
  713. }
  714. .w219h26 {
  715. width: 219px;
  716. height: 26px;
  717. margin: 58px auto 0;
  718. display: block;
  719. }
  720. .sl {
  721. position: absolute;
  722. text-align: center;
  723. margin-top: 64px;
  724. .slogan {
  725. width: 270px;
  726. }
  727. .bannerTitle {
  728. width: 186px;
  729. margin-top: 5px;
  730. }
  731. }
  732. .gesture {
  733. position: absolute;
  734. z-index: 22;
  735. top: 174px;
  736. left: 185px;
  737. img {
  738. width: 101px;
  739. }
  740. }
  741. .fb {
  742. display: flex;
  743. justify-content: space-between;
  744. }
  745. .fw500 {
  746. font-weight: 500;
  747. }
  748. .mt5 {
  749. margin-top: 5px;
  750. }
  751. .mt14 {
  752. margin-top: 14px;
  753. }
  754. .lottery-container {
  755. background-color: #bbe5f2;
  756. background-image: url('../../../assets/image/activity/lottery/bg.png');
  757. background-size: contain;
  758. min-height: 100vh;
  759. overflow: hidden;
  760. margin: 0 auto;
  761. }
  762. .lottery-swipe {
  763. width: 100vw;
  764. height: 25px;
  765. background: rgba($color: #000000, $alpha: 0.24);
  766. position: absolute;
  767. top: 0px;
  768. left: 0;
  769. z-index: 1;
  770. }
  771. .lottery-swipe .van-swipe-item {
  772. color: #ffffff;
  773. font-size: 13px;
  774. line-height: 25px;
  775. text-align: center;
  776. }
  777. .w51h26 {
  778. width: 51px;
  779. height: 26px;
  780. position: absolute;
  781. top: 187px;
  782. right: 0;
  783. z-index: 2;
  784. }
  785. .roulette {
  786. width: 372px;
  787. height: 442px;
  788. background-image: url('../../../assets/image/activity/lottery/roulette.png');
  789. background-size: 100% 100%;
  790. margin: 178px auto 0;
  791. position: relative;
  792. }
  793. .arrow {
  794. width: 122px;
  795. height: 135px;
  796. position: absolute;
  797. top: 110px;
  798. left: 125px;
  799. background-image: url('../../../assets/image/activity/lottery/arrow.png');
  800. background-size: 100% 100%;
  801. z-index: 1;
  802. }
  803. .turntable {
  804. position: absolute;
  805. left: calc(50% - 144px);
  806. top: 214px;
  807. width: 288px;
  808. height: 288px;
  809. }
  810. .turntable-name {
  811. position: absolute;
  812. left: 10px;
  813. top: 20px;
  814. width: calc(100% - 20px);
  815. font-size: 20px;
  816. font-weight: 600;
  817. text-align: center;
  818. color: #b8320d;
  819. }
  820. .fs15 {
  821. font-size: 15px;
  822. }
  823. .turntable-img {
  824. position: relative;
  825. /*要居中就要50% - 宽度 / 2*/
  826. left: calc(50% - 40px / 2);
  827. top: 43px;
  828. width: 52px;
  829. height: 39px;
  830. img {
  831. display: inline-block;
  832. width: 52px;
  833. height: 39px;
  834. }
  835. }
  836. .start-btn {
  837. width: 276px;
  838. height: 55px;
  839. position: absolute;
  840. bottom: 16px;
  841. left: calc(50% - 138px);
  842. }
  843. .num {
  844. margin-top: 8px;
  845. text-align: center;
  846. font-size: 14px;
  847. color: #333333;
  848. line-height: 20px;
  849. }
  850. .popup-view {
  851. overflow: hidden;
  852. width: 320px;
  853. border-radius: 10px;
  854. background: #ffffff;
  855. text-align: center;
  856. margin-top: 26.5px;
  857. }
  858. .popup-view-rule {
  859. width: 324px;
  860. height: 452px;
  861. box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1);
  862. box-sizing: border-box;
  863. background: linear-gradient(
  864. 180deg,
  865. rgba(254, 178, 119, 1),
  866. rgba(255, 91, 46, 1)
  867. );
  868. position: relative;
  869. border-radius: 18px;
  870. padding: 6px;
  871. }
  872. .popup-view-rule-box {
  873. width: 312px;
  874. height: 440px;
  875. background: linear-gradient(181deg, #fffffe 0%, #f7f2e5 100%);
  876. border-radius: 18px;
  877. box-sizing: border-box;
  878. padding-top: 38px;
  879. }
  880. .popup-view-rule-title {
  881. width: 220px;
  882. height: 54px;
  883. background-image: url('../../../assets/image/activity/lottery/buy-rule-title.png');
  884. background-size: 100% 100%;
  885. position: absolute;
  886. top: -14px;
  887. left: 52px;
  888. font-size: 18px;
  889. font-weight: 600;
  890. color: #fffefc;
  891. line-height: 54px;
  892. text-align: center;
  893. }
  894. .h330 {
  895. height: 335px;
  896. overflow-y: auto;
  897. padding: 0 16px;
  898. }
  899. .txt1 {
  900. font-size: 30px;
  901. font-weight: 600;
  902. color: #333333;
  903. line-height: 24px;
  904. text-align: center;
  905. margin-top: 23.5px;
  906. }
  907. .coupon-1 {
  908. width: 283px;
  909. height: 81px;
  910. background: linear-gradient(0deg, #979797 0%, #c8c8c8 98%);
  911. border-radius: 6px;
  912. box-sizing: border-box;
  913. overflow: hidden;
  914. }
  915. .coupon-1.active,
  916. .coupon-2.active {
  917. background: linear-gradient(0deg, #df4324 0%, #ffbf96 98%);
  918. }
  919. .coupon-title {
  920. color: #ffffff;
  921. font-weight: 600;
  922. font-size: 20px;
  923. text-align: center;
  924. z-index: 1;
  925. width: 100%;
  926. }
  927. .txt2 {
  928. font-weight: 600;
  929. font-size: 34px;
  930. }
  931. .txt3 {
  932. color: #db6857;
  933. }
  934. .txt4 {
  935. text-align: center;
  936. font-size: 13px;
  937. font-weight: 600;
  938. color: #ffffff;
  939. z-index: 1;
  940. }
  941. .coupon-select-icon {
  942. width: 34px;
  943. height: 20px;
  944. position: absolute;
  945. top: 0;
  946. right: 0;
  947. z-index: 2;
  948. }
  949. .w253h73 {
  950. width: 253px;
  951. height: 73px;
  952. position: absolute;
  953. top: 15px;
  954. left: 15px;
  955. }
  956. .coupon-2 {
  957. width: 138px;
  958. height: 81px;
  959. box-sizing: border-box;
  960. margin-top: 7px;
  961. border-radius: 5px;
  962. background: linear-gradient(0deg, #979797 0%, #c8c8c8 98%);
  963. & .coupon-title {
  964. color: #ffffff;
  965. font-weight: 600;
  966. font-size: 15px;
  967. text-align: center;
  968. z-index: 1;
  969. margin-top: 22.5px;
  970. width: 100%;
  971. line-height: 24px;
  972. }
  973. & .txt2 {
  974. font-size: 15px;
  975. }
  976. }
  977. .w111h73 {
  978. width: 111px;
  979. height: 73px;
  980. position: absolute;
  981. top: 15px;
  982. left: 12px;
  983. }
  984. .txt5 {
  985. font-size: 15px;
  986. color: #333333;
  987. margin-left: 7px;
  988. font-weight: 300;
  989. }
  990. .icon-pay {
  991. font-size: 26px;
  992. line-height: inherit;
  993. }
  994. .fnc {
  995. display: flex;
  996. align-items: center;
  997. }
  998. .fnbc {
  999. display: flex;
  1000. justify-content: space-between;
  1001. align-items: center;
  1002. height: 50px;
  1003. padding: 0 21px;
  1004. }
  1005. .fnbc1 {
  1006. display: flex;
  1007. justify-content: space-between;
  1008. align-items: center;
  1009. height: 91px;
  1010. margin: 0 22.5px;
  1011. border-top: 1px dashed rgba($color: #333, $alpha: 0.3);
  1012. position: relative;
  1013. &::before,
  1014. &::after {
  1015. content: '';
  1016. background: rgba($color: #000000, $alpha: 0.7);
  1017. width: 28px;
  1018. height: 28px;
  1019. border-radius: 50%;
  1020. }
  1021. &::before {
  1022. position: absolute;
  1023. left: -36.5px;
  1024. top: -14px;
  1025. }
  1026. &::after {
  1027. position: absolute;
  1028. right: -36.5px;
  1029. top: -14px;
  1030. }
  1031. }
  1032. .w304h62 {
  1033. width: 304px;
  1034. height: 62px;
  1035. margin: 0 auto;
  1036. }
  1037. .txt6 {
  1038. color: #ffffff;
  1039. font-size: 12px;
  1040. line-height: 16px;
  1041. height: 16px;
  1042. text-align: center;
  1043. margin-top: 10px;
  1044. a {
  1045. color: #f5e07e;
  1046. }
  1047. }
  1048. .txt11 {
  1049. color: #666666;
  1050. font-size: 15px;
  1051. line-height: 2;
  1052. margin-top: 8px;
  1053. text-align: center;
  1054. }
  1055. .popup-view-leave {
  1056. margin-bottom: 70px;
  1057. margin-top: 0 !important;
  1058. }
  1059. .btn-leave {
  1060. width: 106.5px;
  1061. height: 34px;
  1062. background: linear-gradient(0deg, #979797 0%, #c8c8c8 98%);
  1063. border-radius: 17px;
  1064. font-size: 16px;
  1065. font-weight: 600;
  1066. color: #ffffff;
  1067. text-align: center;
  1068. line-height: 34px;
  1069. }
  1070. .btn-pay {
  1071. width: 152px;
  1072. height: 40px;
  1073. background: linear-gradient(0deg, #df4324 0%, #ffbf96 98%);
  1074. border-radius: 20px;
  1075. font-size: 20px;
  1076. font-weight: 600;
  1077. color: #ffffff;
  1078. text-align: center;
  1079. line-height: 40px;
  1080. }
  1081. .txt7 {
  1082. font-size: 13px;
  1083. line-height: 19px;
  1084. color: #666666;
  1085. text-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
  1086. }
  1087. .txt8 {
  1088. font-size: 15px;
  1089. font-weight: 500;
  1090. line-height: 19px;
  1091. color: #333333;
  1092. text-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
  1093. }
  1094. .txt9 {
  1095. font-size: 13px;
  1096. color: #333333;
  1097. line-height: 19px;
  1098. text-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
  1099. }
  1100. .txt10 {
  1101. font-size: 13px;
  1102. line-height: 19px;
  1103. color: #333;
  1104. text-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
  1105. }
  1106. </style>