index.vue 34 KB

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