index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  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. },
  305. head: {
  306. title: '年卡抽奖活动',
  307. },
  308. created() {
  309. this.getLuckDrawActivity();
  310. this.getCarouselList();
  311. },
  312. methods: {
  313. async getCarouselList() {
  314. const res = await this.$axios.$post('/activity/v1/member/carousel');
  315. this.carousel = res.data;
  316. },
  317. async getMealInfo() {
  318. const res = await this.$axios.$get(
  319. '/pay/v2/meal/info?phoneType=' + this.phoneType,
  320. );
  321. this.mealList = res.data.list.filter(
  322. (item) =>
  323. (item.day === 30 || item.day === 365) && item.id !== this.mealId,
  324. );
  325. this.yearOriginalPrice = +res.data.list.filter((item) => (item.day === 365))[0].originalPrice
  326. this.originalPrice = this.yearOriginalPrice
  327. },
  328. async createOrder() {
  329. if (!this.checked) {
  330. Toast({
  331. message: '请勾选并且阅读购买协议',
  332. position: 'top',
  333. duration: 4000
  334. });
  335. return
  336. }
  337. try {
  338. Toast.loading({
  339. duration: 0,
  340. forbidClick: true,
  341. });
  342. this.makePoint('activity_立即购买');
  343. let taocan = {
  344. buyType: 1,
  345. couponId: 0,
  346. id: this.selMealId,
  347. mealType: 0,
  348. phoneType: this.phoneType,
  349. quantity: 1,
  350. };
  351. taocan = this.sort_ASCII(taocan);
  352. const sign = this.jiaqian(JSON.stringify(taocan));
  353. if (this.$userAgent.isAndroid) {
  354. this.client = 1;
  355. } else if (this.$userAgent.isIos) {
  356. this.client = 2;
  357. } else if (this.$userAgent.isMiniProgram) {
  358. this.client = 5;
  359. } else {
  360. this.client = 7;
  361. }
  362. const res = await this.$axios.$post('/pay/v1/order/create', taocan, {
  363. headers: { Authorization: this.token, sign }, client: this.client
  364. });
  365. Toast.clear();
  366. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  367. window.native.startPay(
  368. this.payType === 'aliPay' ? 3 : 2,
  369. res.data.myOrderNum,
  370. 1,
  371. );
  372. } else if (this.$userAgent.isSzx && this.$userAgent.isIos) {
  373. window.webkit.messageHandlers.startPay.postMessage({
  374. payType: this.payType === 'aliPay' ? 3 : 2,
  375. orderNum: res.data.myOrderNum,
  376. actualPrice: this.actualPrice,
  377. });
  378. } else if (this.$userAgent.isMiniProgram) {
  379. this.$wx.miniProgram.navigateTo({
  380. url:
  381. '/packageA/order/status/index?record=' +
  382. JSON.stringify({
  383. payActive: this.payType === 'wxPay' ? 1 : 0,
  384. myOrderNum: res.data.myOrderNum,
  385. }),
  386. });
  387. } else {
  388. // 使用postMessage 方法可以发送消息到应用, 消息内容需要在data 对象中,否则webview无法接收到
  389. webUni.webView.postMessage({
  390. data: {
  391. payType: this.payType === 'aliPay' ? 3 : 2,
  392. orderNum: res.data.myOrderNum,
  393. buyType: 1,
  394. price: this.actualPrice,
  395. },
  396. });
  397. }
  398. this.showPay = false;
  399. } catch (error) {
  400. Toast.clear();
  401. Toast({
  402. message: error.message,
  403. position: 'top',
  404. duration: 4000,
  405. });
  406. }
  407. },
  408. sort_ASCII(obj) {
  409. const arr = [];
  410. let num = 0;
  411. for (const i in obj) {
  412. arr[num] = i;
  413. num++;
  414. }
  415. const sortArr = arr.sort();
  416. const sortObj = {};
  417. for (const i in sortArr) {
  418. sortObj[sortArr[i]] = obj[sortArr[i]];
  419. }
  420. return sortObj;
  421. },
  422. jiaqian(content) {
  423. const PrivateKey =
  424. '-----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-----';
  425. const signature = new RSA.KJUR.crypto.Signature({
  426. alg: 'SHA256withRSA',
  427. });
  428. signature.init(PrivateKey);
  429. signature.updateString(content);
  430. const signData = signature.sign();
  431. // 将内容转成base64
  432. return RSA.hex2b64(signData);
  433. },
  434. async getLuckDrawActivity() {
  435. const res = await this.$axios.$post(
  436. '/activity/v1/member/luckDrawActivity',
  437. );
  438. this.activityId = res.data.activityId;
  439. this.status = res.data.status;
  440. this.num = res.data.count;
  441. if (this.num === 0) {
  442. await this.getLuckDraw();
  443. this.luckDrawType = 0;
  444. }
  445. },
  446. // 开始抽奖
  447. async startRotation() {
  448. // 如果还不可以转动
  449. if (!this.canBeRotated()) {
  450. return false;
  451. }
  452. this.makePoint('activity_立即抽奖');
  453. // 开始转动
  454. // 先上锁
  455. this.isLocking = true;
  456. await this.getLuckDraw();
  457. // 成功后次数减少一次
  458. if (this.num > 0) {
  459. this.num--;
  460. }
  461. console.log(this.num);
  462. // 告诉子组件,开始转动了
  463. this.$refs.roundTurntable.rotate(this.prizeIndex);
  464. },
  465. async getLuckDraw() {
  466. // 设置在哪里停下,应该与后台交互,这里随机抽取0~5
  467. const res = await this.$axios.$post(
  468. '/activity/v1/member/luckDraw?activityId=' + this.activityId,
  469. {},
  470. { headers: { Authorization: this.token } },
  471. );
  472. if (res.status === 0) {
  473. this.actualPrice = res.data.actualPrice;
  474. this.yearActualPrice = res.data.actualPrice;
  475. this.luckDrawType = res.data.luckDrawType;
  476. this.mealId = res.data.mealId
  477. this.selMealId = res.data.mealId
  478. this.getMealInfo()
  479. this.paySupportType = res.data.paySupportType
  480. if (this.$userAgent.isMiniProgram) {
  481. this.paySupportType = ['wxPay']
  482. }
  483. this.payType = this.paySupportType[0]
  484. this.phoneType = res.data.phoneType
  485. this.title = res.data.title
  486. this.prizeIndex = res.data.luckDrawType === 1 ? 5 : 2;
  487. if (this.num === 0) {
  488. this.showPay = true
  489. if (this.$userAgent.isSzx && this.$userAgent.isAndroid) {
  490. window.native.isMembersLotto(true)
  491. }
  492. }
  493. } else {
  494. Toast({
  495. message: res.msg,
  496. position: 'top',
  497. duration: 4000,
  498. });
  499. }
  500. },
  501. makePoint(positionButton) {
  502. const now = new Date();
  503. if (this.$userAgent.isAndroid) {
  504. this.client = 1;
  505. } else if (this.$userAgent.isIos) {
  506. this.client = 2;
  507. } else if (this.$userAgent.isMiniProgram) {
  508. this.client = 5;
  509. } else {
  510. this.client = 7;
  511. }
  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>