index.vue 32 KB

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