index.vue 33 KB

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