index.vue 34 KB

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