index.vue 32 KB

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