index.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  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.isSzx && 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. },
  314. head: {
  315. title: '年卡抽奖活动',
  316. },
  317. created() {
  318. this.getLuckDrawActivity();
  319. this.getCarouselList();
  320. },
  321. methods: {
  322. async getCarouselList() {
  323. const res = await this.$axios.$post('/activity/v1/member/carousel');
  324. this.carousel = res.data;
  325. },
  326. async getMealInfo() {
  327. const res = await this.$axios.$get(
  328. '/pay/v2/meal/info?phoneType=' + this.phoneType,
  329. );
  330. this.mealList = res.data.list.filter(
  331. (item) =>
  332. (item.day === 30 || item.day === 365) && item.id !== this.mealId,
  333. );
  334. this.yearOriginalPrice = +res.data.list.filter((item) => (item.day === 365))[0].originalPrice
  335. this.originalPrice = this.yearOriginalPrice
  336. },
  337. async createOrder() {
  338. if (!this.checked) {
  339. Toast({
  340. message: '请勾选并且阅读购买协议',
  341. position: 'top',
  342. duration: 4000
  343. });
  344. return
  345. }
  346. try {
  347. Toast.loading({
  348. duration: 0,
  349. forbidClick: true,
  350. });
  351. this.makePoint('activity_立即购买');
  352. let taocan = {
  353. buyType: 1,
  354. couponId: 0,
  355. id: this.selMealId,
  356. mealType: 0,
  357. phoneType: this.phoneType,
  358. quantity: 1,
  359. };
  360. taocan = this.sort_ASCII(taocan);
  361. const sign = this.jiaqian(JSON.stringify(taocan));
  362. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  363. this.client = 1;
  364. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  365. this.client = 2;
  366. } else if (this.$userAgent.isMiniProgram) {
  367. this.client = 5;
  368. } else {
  369. this.client = 7;
  370. }
  371. const res = await this.$axios.$post('/pay/v1/order/create', taocan, {
  372. headers: { Authorization: this.token, sign, client: this.client }
  373. });
  374. Toast.clear();
  375. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  376. window.native.startPay(
  377. this.payType === 'aliPay' ? 3 : 2,
  378. res.data.myOrderNum,
  379. 1,
  380. );
  381. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  382. window.webkit.messageHandlers.startPay.postMessage({
  383. payType: this.payType === 'aliPay' ? 3 : 2,
  384. orderNum: res.data.myOrderNum,
  385. actualPrice: this.actualPrice,
  386. });
  387. } else if (this.$userAgent.isMiniProgram) {
  388. this.$wx.miniProgram.navigateTo({
  389. url:
  390. '/packageA/order/status/index?record=' +
  391. JSON.stringify({
  392. payActive: this.payType === 'wxPay' ? 1 : 0,
  393. myOrderNum: res.data.myOrderNum,
  394. }),
  395. });
  396. } else {
  397. // 使用postMessage 方法可以发送消息到应用, 消息内容需要在data 对象中,否则webview无法接收到
  398. webUni.webView.postMessage({
  399. data: {
  400. payType: this.payType === 'aliPay' ? 3 : 2,
  401. orderNum: res.data.myOrderNum,
  402. buyType: 1,
  403. price: this.actualPrice,
  404. },
  405. });
  406. }
  407. this.showPay = false;
  408. } catch (error) {
  409. Toast.clear();
  410. Toast({
  411. message: error.message,
  412. position: 'top',
  413. duration: 4000,
  414. });
  415. }
  416. },
  417. sort_ASCII(obj) {
  418. const arr = [];
  419. let num = 0;
  420. for (const i in obj) {
  421. arr[num] = i;
  422. num++;
  423. }
  424. const sortArr = arr.sort();
  425. const sortObj = {};
  426. for (const i in sortArr) {
  427. sortObj[sortArr[i]] = obj[sortArr[i]];
  428. }
  429. return sortObj;
  430. },
  431. jiaqian(content) {
  432. const PrivateKey =
  433. '-----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-----';
  434. const signature = new RSA.KJUR.crypto.Signature({
  435. alg: 'SHA256withRSA',
  436. });
  437. signature.init(PrivateKey);
  438. signature.updateString(content);
  439. const signData = signature.sign();
  440. // 将内容转成base64
  441. return RSA.hex2b64(signData);
  442. },
  443. async getLuckDrawActivity() {
  444. const res = await this.$axios.$post(
  445. '/activity/v1/member/luckDrawActivity',
  446. );
  447. this.activityId = res.data.activityId;
  448. this.status = res.data.status;
  449. this.num = res.data.count;
  450. if (this.num === 0) {
  451. await this.getLuckDraw();
  452. this.luckDrawType = 0;
  453. }
  454. },
  455. // 开始抽奖
  456. async startRotation() {
  457. // 如果还不可以转动
  458. if (!this.canBeRotated()) {
  459. return false;
  460. }
  461. this.makePoint('activity_立即抽奖');
  462. // 开始转动
  463. // 先上锁
  464. this.isLocking = true;
  465. await this.getLuckDraw();
  466. // 成功后次数减少一次
  467. if (this.num > 0) {
  468. this.num--;
  469. }
  470. console.log(this.num);
  471. // 告诉子组件,开始转动了
  472. this.$refs.roundTurntable.rotate(this.prizeIndex);
  473. },
  474. async getLuckDraw() {
  475. // 设置在哪里停下,应该与后台交互,这里随机抽取0~5
  476. const res = await this.$axios.$post(
  477. '/activity/v1/member/luckDraw?activityId=' + this.activityId,
  478. {},
  479. { headers: { Authorization: this.token } },
  480. );
  481. if (res.status === 0) {
  482. this.actualPrice = res.data.actualPrice;
  483. this.yearActualPrice = res.data.actualPrice;
  484. this.luckDrawType = res.data.luckDrawType;
  485. this.mealId = res.data.mealId
  486. this.selMealId = res.data.mealId
  487. this.getMealInfo()
  488. this.paySupportType = res.data.paySupportType
  489. if (this.$userAgent.isMiniProgram) {
  490. this.paySupportType = ['wxPay']
  491. }
  492. this.payType = this.paySupportType[0]
  493. this.phoneType = res.data.phoneType
  494. this.title = res.data.title
  495. this.prizeIndex = res.data.luckDrawType === 1 ? 5 : 2;
  496. if (this.num === 0) {
  497. this.showPay = true
  498. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  499. window.native.isMembersLotto(true)
  500. }
  501. }
  502. } else {
  503. Toast({
  504. message: res.msg,
  505. position: 'top',
  506. duration: 4000,
  507. });
  508. }
  509. },
  510. makePoint(positionButton) {
  511. const now = new Date();
  512. this.$axios.$post('/public/v5/buriedPointRecord/reportRecords', [
  513. {
  514. client: this.client,
  515. eventCode: '27_抽奖流程',
  516. userName: this.$auth.user.userName,
  517. positionButton,
  518. operationTime: now
  519. .toISOString()
  520. .replace(/T/g, ' ')
  521. .replace(/\.[\d]{3}Z/, ''),
  522. },
  523. ]);
  524. },
  525. // 已经转动完转盘触发的函数
  526. endRotation() {
  527. // 提示中奖
  528. this.showPay = true;
  529. // 解锁
  530. this.isLocking = false;
  531. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  532. window.native.isMembersLotto(true)
  533. }
  534. if (this.luckDrawType === 1) {
  535. this.makePoint('activity_15.9年卡');
  536. if (Number(localStorage.getItem('year-15-9')) !== 2) {
  537. localStorage.setItem('year-15-9', 1);
  538. }
  539. }
  540. if (this.luckDrawType === 2) {
  541. this.makePoint('activity_9.9年卡');
  542. if (Number(localStorage.getItem('year-9-9')) !== 2) {
  543. localStorage.setItem('year-9-9', 1);
  544. }
  545. }
  546. },
  547. // 判断是否可以转动
  548. canBeRotated() {
  549. if (this.isLocking) {
  550. return false;
  551. }
  552. if (this.status === 0) {
  553. Toast({
  554. message: '当前活动已过期',
  555. position: 'top',
  556. duration: 4000,
  557. });
  558. return false;
  559. }
  560. if (this.status === 2) {
  561. Toast({
  562. message: '当前活动未开启',
  563. position: 'top',
  564. duration: 4000,
  565. });
  566. return false;
  567. }
  568. if (this.status === 3) {
  569. Toast({
  570. message: '当前活动已结束',
  571. position: 'top',
  572. duration: 4000,
  573. });
  574. return false;
  575. }
  576. if (this.num === 0) {
  577. this.showPay = true;
  578. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  579. window.native.isMembersLotto(true)
  580. }
  581. return false;
  582. }
  583. this.time = 24 * 60 * 60 * 1000;
  584. return true;
  585. },
  586. closed() {
  587. this.makePoint('activity_关闭抽奖', 'eventCode传27_抽奖流程');
  588. this.selMealId = this.mealId;
  589. if (+localStorage.getItem('year-15-9') !== 2) {
  590. this.show = true;
  591. localStorage.setItem('year-15-9', 2);
  592. }
  593. if (+localStorage.getItem('year-9-9') !== 2) {
  594. this.show = true;
  595. localStorage.setItem('year-9-9', 2);
  596. }
  597. this.showPay = false
  598. },
  599. },
  600. };
  601. </script>
  602. <style>
  603. .lottery-container .van-grid-item__content {
  604. padding: 0 !important;
  605. }
  606. </style>
  607. <style lang="scss" scoped>
  608. .count-down-time {
  609. height: 46.5px;
  610. background: #333333;
  611. font-size: 12px;
  612. color: #ffffff;
  613. display: flex;
  614. justify-content: center;
  615. align-items: center;
  616. }
  617. .colon {
  618. display: inline-block;
  619. margin: 0 4.5px;
  620. color: #ffffff;
  621. }
  622. .block {
  623. display: inline-block;
  624. width: 17px;
  625. height: 17px;
  626. line-height: 17px;
  627. color: #fff;
  628. font-size: 11px;
  629. background: rgba($color: #ffffff, $alpha: 0.2);
  630. text-align: center;
  631. }
  632. .plr10 {
  633. padding: 0 10px;
  634. margin-bottom: 22px;
  635. }
  636. .dialog-view {
  637. width: 100vw;
  638. height: 100vh;
  639. background: url('../../../assets/image/activity/lottery/dialog-bg.png');
  640. background-size: 100%;
  641. background-repeat: no-repeat;
  642. position: relative;
  643. display: flex;
  644. flex-wrap: wrap;
  645. justify-content: center;
  646. align-items: flex-start;
  647. }
  648. .w283h81 {
  649. width: 283px;
  650. height: 81px;
  651. display: block;
  652. margin: 0 auto 16px;
  653. }
  654. .close {
  655. font-size: 30px;
  656. position: absolute;
  657. top: 18.5px;
  658. right: 26px;
  659. }
  660. .close1 {
  661. font-size: 30px;
  662. position: absolute;
  663. bottom: 0px;
  664. left: calc(50% - 15px);
  665. }
  666. .check {
  667. font-size: 15px;
  668. margin-right: 8.5px;
  669. line-height: 10px;
  670. }
  671. .buy-bar-btn {
  672. width: 184.5px;
  673. height: 50px;
  674. background: linear-gradient(0deg, #df4324 0%, #ffbf96 98%);
  675. border-radius: 10px;
  676. position: absolute;
  677. right: 0;
  678. bottom: 0;
  679. & div:nth-child(1) {
  680. text-align: center;
  681. font-size: 18px;
  682. font-weight: 600;
  683. color: #ffffff;
  684. line-height: 50px;
  685. }
  686. & .tip {
  687. width: 76px;
  688. height: 21px;
  689. background: url('../../../assets/image/activity/lottery/tip.png');
  690. background-size: 100% 100%;
  691. text-align: center;
  692. font-size: 12px;
  693. color: #fff;
  694. line-height: 18px;
  695. position: absolute;
  696. right: 0;
  697. top: -11px;
  698. }
  699. }
  700. .buy-bar {
  701. width: 320px;
  702. height: 40px;
  703. line-height: 40px;
  704. background: #ffffff;
  705. border-radius: 10px;
  706. margin-top: 25px;
  707. position: relative;
  708. font-size: 15px;
  709. text-decoration: line-through;
  710. color: #666666;
  711. padding-left: 28px;
  712. margin-top: 26px;
  713. }
  714. .van-grid-item__text {
  715. font-size: 11px;
  716. }
  717. .meal-item {
  718. margin: 10px;
  719. background: #f2f2f2;
  720. border-radius: 5px;
  721. padding: 7.5px;
  722. }
  723. .w219h26 {
  724. width: 219px;
  725. height: 26px;
  726. margin: 58px auto 0;
  727. display: block;
  728. }
  729. .sl {
  730. position: absolute;
  731. text-align: center;
  732. margin-top: 64px;
  733. .slogan {
  734. width: 270px;
  735. }
  736. .bannerTitle {
  737. width: 186px;
  738. margin-top: 5px;
  739. }
  740. }
  741. .gesture {
  742. position: absolute;
  743. z-index: 22;
  744. top: 174px;
  745. left: 185px;
  746. img {
  747. width: 101px;
  748. }
  749. }
  750. .fb {
  751. display: flex;
  752. justify-content: space-between;
  753. }
  754. .fw500 {
  755. font-weight: 500;
  756. }
  757. .mt5 {
  758. margin-top: 5px;
  759. }
  760. .mt14 {
  761. margin-top: 14px;
  762. }
  763. .lottery-container {
  764. background-color: #bbe5f2;
  765. background-image: url('../../../assets/image/activity/lottery/bg.png');
  766. background-size: contain;
  767. min-height: 100vh;
  768. overflow: hidden;
  769. margin: 0 auto;
  770. }
  771. .lottery-swipe {
  772. width: 100vw;
  773. height: 25px;
  774. background: rgba($color: #000000, $alpha: 0.24);
  775. position: absolute;
  776. top: 0px;
  777. left: 0;
  778. z-index: 1;
  779. }
  780. .lottery-swipe .van-swipe-item {
  781. color: #ffffff;
  782. font-size: 13px;
  783. line-height: 25px;
  784. text-align: center;
  785. }
  786. .w51h26 {
  787. width: 51px;
  788. height: 26px;
  789. position: absolute;
  790. top: 187px;
  791. right: 0;
  792. z-index: 2;
  793. }
  794. .roulette {
  795. width: 372px;
  796. height: 442px;
  797. background-image: url('../../../assets/image/activity/lottery/roulette.png');
  798. background-size: 100% 100%;
  799. margin: 178px auto 0;
  800. position: relative;
  801. }
  802. .arrow {
  803. width: 122px;
  804. height: 135px;
  805. position: absolute;
  806. top: 110px;
  807. left: 125px;
  808. background-image: url('../../../assets/image/activity/lottery/arrow.png');
  809. background-size: 100% 100%;
  810. z-index: 1;
  811. }
  812. .turntable {
  813. position: absolute;
  814. left: calc(50% - 144px);
  815. top: 214px;
  816. width: 288px;
  817. height: 288px;
  818. }
  819. .turntable-name {
  820. position: absolute;
  821. left: 10px;
  822. top: 20px;
  823. width: calc(100% - 20px);
  824. font-size: 20px;
  825. font-weight: 600;
  826. text-align: center;
  827. color: #b8320d;
  828. }
  829. .fs15 {
  830. font-size: 15px;
  831. }
  832. .turntable-img {
  833. position: relative;
  834. /*要居中就要50% - 宽度 / 2*/
  835. left: calc(50% - 40px / 2);
  836. top: 43px;
  837. width: 52px;
  838. height: 39px;
  839. img {
  840. display: inline-block;
  841. width: 52px;
  842. height: 39px;
  843. }
  844. }
  845. .start-btn {
  846. width: 276px;
  847. height: 55px;
  848. position: absolute;
  849. bottom: 16px;
  850. left: calc(50% - 138px);
  851. }
  852. .num {
  853. margin-top: 8px;
  854. text-align: center;
  855. font-size: 14px;
  856. color: #333333;
  857. line-height: 20px;
  858. }
  859. .popup-view {
  860. overflow: hidden;
  861. width: 320px;
  862. border-radius: 10px;
  863. background: #ffffff;
  864. text-align: center;
  865. margin-top: 26.5px;
  866. }
  867. .popup-view-rule {
  868. width: 324px;
  869. height: 452px;
  870. box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1);
  871. box-sizing: border-box;
  872. background: linear-gradient(
  873. 180deg,
  874. rgba(254, 178, 119, 1),
  875. rgba(255, 91, 46, 1)
  876. );
  877. position: relative;
  878. border-radius: 18px;
  879. padding: 6px;
  880. }
  881. .popup-view-rule-box {
  882. width: 312px;
  883. height: 440px;
  884. background: linear-gradient(181deg, #fffffe 0%, #f7f2e5 100%);
  885. border-radius: 18px;
  886. box-sizing: border-box;
  887. padding-top: 38px;
  888. }
  889. .popup-view-rule-title {
  890. width: 220px;
  891. height: 54px;
  892. background-image: url('../../../assets/image/activity/lottery/buy-rule-title.png');
  893. background-size: 100% 100%;
  894. position: absolute;
  895. top: -14px;
  896. left: 52px;
  897. font-size: 18px;
  898. font-weight: 600;
  899. color: #fffefc;
  900. line-height: 54px;
  901. text-align: center;
  902. }
  903. .h330 {
  904. height: 335px;
  905. overflow-y: auto;
  906. padding: 0 16px;
  907. }
  908. .txt1 {
  909. font-size: 30px;
  910. font-weight: 600;
  911. color: #333333;
  912. line-height: 24px;
  913. text-align: center;
  914. margin-top: 23.5px;
  915. }
  916. .coupon-1 {
  917. width: 283px;
  918. height: 81px;
  919. background: linear-gradient(0deg, #979797 0%, #c8c8c8 98%);
  920. border-radius: 6px;
  921. box-sizing: border-box;
  922. overflow: hidden;
  923. }
  924. .coupon-1.active,
  925. .coupon-2.active {
  926. background: linear-gradient(0deg, #df4324 0%, #ffbf96 98%);
  927. }
  928. .coupon-title {
  929. color: #ffffff;
  930. font-weight: 600;
  931. font-size: 20px;
  932. text-align: center;
  933. z-index: 1;
  934. width: 100%;
  935. }
  936. .txt2 {
  937. font-weight: 600;
  938. font-size: 34px;
  939. }
  940. .txt3 {
  941. color: #db6857;
  942. }
  943. .txt4 {
  944. text-align: center;
  945. font-size: 13px;
  946. font-weight: 600;
  947. color: #ffffff;
  948. z-index: 1;
  949. }
  950. .coupon-select-icon {
  951. width: 34px;
  952. height: 20px;
  953. position: absolute;
  954. top: 0;
  955. right: 0;
  956. z-index: 2;
  957. }
  958. .w253h73 {
  959. width: 253px;
  960. height: 73px;
  961. position: absolute;
  962. top: 15px;
  963. left: 15px;
  964. }
  965. .coupon-2 {
  966. width: 138px;
  967. height: 81px;
  968. box-sizing: border-box;
  969. margin-top: 7px;
  970. border-radius: 5px;
  971. background: linear-gradient(0deg, #979797 0%, #c8c8c8 98%);
  972. & .coupon-title {
  973. color: #ffffff;
  974. font-weight: 600;
  975. font-size: 15px;
  976. text-align: center;
  977. z-index: 1;
  978. margin-top: 22.5px;
  979. width: 100%;
  980. line-height: 24px;
  981. }
  982. & .txt2 {
  983. font-size: 15px;
  984. }
  985. }
  986. .w111h73 {
  987. width: 111px;
  988. height: 73px;
  989. position: absolute;
  990. top: 15px;
  991. left: 12px;
  992. }
  993. .txt5 {
  994. font-size: 15px;
  995. color: #333333;
  996. margin-left: 7px;
  997. font-weight: 300;
  998. }
  999. .icon-pay {
  1000. font-size: 26px;
  1001. line-height: inherit;
  1002. }
  1003. .fnc {
  1004. display: flex;
  1005. align-items: center;
  1006. }
  1007. .fnbc {
  1008. display: flex;
  1009. justify-content: space-between;
  1010. align-items: center;
  1011. height: 50px;
  1012. padding: 0 21px;
  1013. }
  1014. .fnbc1 {
  1015. display: flex;
  1016. justify-content: space-between;
  1017. align-items: center;
  1018. height: 91px;
  1019. margin: 0 22.5px;
  1020. border-top: 1px dashed rgba($color: #333, $alpha: 0.3);
  1021. position: relative;
  1022. &::before,
  1023. &::after {
  1024. content: '';
  1025. background: rgba($color: #000000, $alpha: 0.7);
  1026. width: 28px;
  1027. height: 28px;
  1028. border-radius: 50%;
  1029. }
  1030. &::before {
  1031. position: absolute;
  1032. left: -36.5px;
  1033. top: -14px;
  1034. }
  1035. &::after {
  1036. position: absolute;
  1037. right: -36.5px;
  1038. top: -14px;
  1039. }
  1040. }
  1041. .w304h62 {
  1042. width: 304px;
  1043. height: 62px;
  1044. margin: 0 auto;
  1045. }
  1046. .txt6 {
  1047. color: #ffffff;
  1048. font-size: 12px;
  1049. line-height: 16px;
  1050. height: 16px;
  1051. text-align: center;
  1052. margin-top: 10px;
  1053. a {
  1054. color: #f5e07e;
  1055. }
  1056. }
  1057. .txt11 {
  1058. color: #666666;
  1059. font-size: 15px;
  1060. line-height: 2;
  1061. margin-top: 8px;
  1062. text-align: center;
  1063. }
  1064. .popup-view-leave {
  1065. margin-bottom: 70px;
  1066. margin-top: 0 !important;
  1067. }
  1068. .btn-leave {
  1069. width: 106.5px;
  1070. height: 34px;
  1071. background: linear-gradient(0deg, #979797 0%, #c8c8c8 98%);
  1072. border-radius: 17px;
  1073. font-size: 16px;
  1074. font-weight: 600;
  1075. color: #ffffff;
  1076. text-align: center;
  1077. line-height: 34px;
  1078. }
  1079. .btn-pay {
  1080. width: 152px;
  1081. height: 40px;
  1082. background: linear-gradient(0deg, #df4324 0%, #ffbf96 98%);
  1083. border-radius: 20px;
  1084. font-size: 20px;
  1085. font-weight: 600;
  1086. color: #ffffff;
  1087. text-align: center;
  1088. line-height: 40px;
  1089. }
  1090. .txt7 {
  1091. font-size: 13px;
  1092. line-height: 19px;
  1093. color: #666666;
  1094. text-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
  1095. }
  1096. .txt8 {
  1097. font-size: 15px;
  1098. font-weight: 500;
  1099. line-height: 19px;
  1100. color: #333333;
  1101. text-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
  1102. }
  1103. .txt9 {
  1104. font-size: 13px;
  1105. color: #333333;
  1106. line-height: 19px;
  1107. text-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
  1108. }
  1109. .txt10 {
  1110. font-size: 13px;
  1111. line-height: 19px;
  1112. color: #333;
  1113. text-shadow: 0px 1px 20px rgba(0, 0, 0, 0.1);
  1114. }
  1115. </style>