pc.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <div class="lottery-container">
  3. <van-swipe :autoplay="3000" class="lottery-swipe" vertical :show-indicators="false">
  4. <van-swipe-item>有23245个用户 购买15.9年卡</van-swipe-item>
  5. <van-swipe-item>有23245个用户 购买15.9年卡</van-swipe-item>
  6. <van-swipe-item>有23245个用户 购买15.9年卡</van-swipe-item>
  7. <van-swipe-item>有23245个用户 购买15.9年卡</van-swipe-item>
  8. </van-swipe>
  9. <img class="w51h26" src="~/assets/image/activity/lottery/rule.png" alt="" @click="showRule=true">
  10. <div class="roulette">
  11. <div class="arrow" @click="startRotation"></div>
  12. <img class="start-btn" src="~/assets/image/activity/lottery/start-btn.png" alt="" @click="startRotation">
  13. </div>
  14. <RoundTurntable ref="roundTurntable" :prize-data="prizeData" :rotate-circle="rotateCircle" :during-time="duringTime" :turntable-style-option="turntableStyleOption" class="turntable" @endRotation="endRotation">
  15. <template slot="item" slot-scope="scope">
  16. <div class="turntable-name"><span class="fs15">¥</span>{{ scope.item.level }}</div>
  17. <div class="turntable-img">
  18. <img src="~/assets/image/activity/lottery/yearCard.png" />
  19. </div>
  20. </template>
  21. </RoundTurntable>
  22. <div class="num">剩余机会{{num}}次</div>
  23. <van-popup v-model="showPay" closeable close-icon-position="top-right" round :close-on-click-overlay="false" @closed="closed">
  24. <div class="popup-view">
  25. <div class="txt1">恭喜你获得{{actualPrice}}年卡</div>
  26. <div :class="selMealId===mealId ? 'coupon-1 active' : 'coupon-1'" @click="selMealId=mealId">
  27. <img v-if="selMealId===mealId" class="coupon-select-icon" src="~/assets/image/activity/lottery/select-icon.png" alt="">
  28. <img v-else class="coupon-select-icon" src="~/assets/image/activity/lottery/unselect-icon.png" alt="">
  29. <div class="coupon-title"><span class="txt2">{{actualPrice}}</span><span>会员</span><span class="txt3">({{title}})</span></div>
  30. <div class="txt4">年卡(已获得)</div>
  31. <img class="w253h73" src="~/assets/image/activity/lottery/coupon-1.png" alt="">
  32. </div>
  33. <div v-for="item in mealList" :key="item.id" :class="selMealId===item.id ? 'coupon-2 active' : 'coupon-2'" @click="selMealId=item.id">
  34. <img v-if="selMealId===item.id" class="coupon-select-icon" src="~/assets/image/activity/lottery/select-icon.png" alt="">
  35. <img v-else class="coupon-select-icon" src="~/assets/image/activity/lottery/unselect-icon.png" alt="">
  36. <div class="coupon-title"><span class="txt2">{{item.actualPrice}}</span><span>会员</span></div>
  37. <div class="txt4">{{item.day === 30 ? '月卡' : '年卡'}}</div>
  38. <img class="w111h73" src="~/assets/image/activity/lottery/coupon-2.png" alt="">
  39. </div>
  40. <div v-for="item in paySupportType" :key="item" class="fnbc" @click="payType = item">
  41. <div v-if="item === 'aliPay'" class="fnc">
  42. <van-icon class="icon-pay" :name="require('~/assets/image/activity/lottery/alipay.png')" />
  43. <span class="txt5">支付宝支付</span>
  44. </div>
  45. <div v-else class="fnc">
  46. <van-icon class="icon-pay" :name="require('~/assets/image/activity/lottery/wx.png')" />
  47. <span class="txt5">微信支付</span>
  48. </div>
  49. <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" />
  50. </div>
  51. <img class="w304h62" src="~/assets/image/activity/lottery/pay-btn.png" alt="" @click="createOrder">
  52. <div class="txt6">开通前阅读并同意<a @click="showRule=true">购买协议</a></div>
  53. </div>
  54. </van-popup>
  55. <van-popup v-model="show" closeable close-icon-position="top-right" round>
  56. <div class="popup-view popup-view-leave">
  57. <div class="txt1">确定离开吗</div>
  58. <div class="txt6">离开后您将失去{{actualPrice}}年卡,24小时付款有效</div>
  59. <div class="coupon-1 active">
  60. <img class="coupon-select-icon" src="~/assets/image/activity/lottery/select-icon.png" alt="">
  61. <div class="coupon-title"><span class="txt2">{{actualPrice}}</span><span>会员</span><span class="txt3">({{title}})</span></div>
  62. <div class="txt4">年卡(已获得)</div>
  63. <img class="w253h73" src="~/assets/image/activity/lottery/coupon-1.png" alt="">
  64. </div>
  65. <div class="fnbc">
  66. <div class="btn-leave" @click="show=false">狠心离开</div>
  67. <div class="btn-pay" @click="createOrder">立即购买</div>
  68. </div>
  69. </div>
  70. </van-popup>
  71. <van-popup v-model="showRule" closeable close-icon-position="top-right" round>
  72. <div class="popup-view popup-view-leave" style="text-align: left;">
  73. <div class="txt1">购买协议</div>
  74. <div class="txt7">时长包使用规则</div>
  75. <div class="txt6"> 年卡特惠云手机,按需补充时长包</div>
  76. <div class="txt6">有效时间:时长用完前一直有效,支持跨月。</div>
  77. <div class="txt6">可用范围:可续时长的机型</div>
  78. <div class="txt6">生效方式:立即生效</div>
  79. <div class="txt6">退订说明:立即生效产品,不支持退订</div>
  80. <div class="txt7">产品说明</div>
  81. <div class="txt6">1、生效方式:时长补充包订购后立即生效,直至时长用完则失效,用户可重复订购。</div>
  82. <div class="txt6">2、时长使用顺序:优先使用年卡特惠包时长,年卡特惠包时长耗尽,自动使用时长包时长。</div>
  83. <div class="txt6">3、年卡特惠包合约到期后,如时长补充包仍有时长,年卡特惠包所属云手机可继续使用至时长用尽。</div>
  84. <div class="txt7">温馨提示:</div>
  85. <div class="txt6">1、请您理解:通过任何不正当手段参与活动,如借助非自然流量/外挂工具;利用技术漏洞,恶意退款,批量注册账号、买号等搅乱平台管理秩序的行为,臂云科技有权限制/取消用户的活动资格,不予发放/撤销相关交易及福利内容。</div>
  86. <div class="txt6">2、如有疑问请联系唔即云APP客服咨询。</div>
  87. </div>
  88. </van-popup>
  89. </div>
  90. </template>
  91. <script>
  92. import { Toast } from 'vant'
  93. import RoundTurntable from './component/roundTurntable.vue'
  94. export default {
  95. name: 'Lottery',
  96. auth: false,
  97. components: {
  98. RoundTurntable
  99. },
  100. data() {
  101. return {
  102. showRule: false,
  103. show: false,
  104. showPay: false,
  105. // 转盘上的奖品数据
  106. prizeData: [
  107. {
  108. id: 1,
  109. level: 29.9
  110. },
  111. {
  112. id: 2,
  113. level: 58
  114. },
  115. {
  116. id: 3,
  117. level: 9.9
  118. },
  119. {
  120. id: 4,
  121. level: 39.9
  122. },
  123. {
  124. id: 5,
  125. level: 378
  126. },
  127. {
  128. id: 6,
  129. level: 15.9
  130. }
  131. ],
  132. // 转动的圈数
  133. rotateCircle: 6,
  134. // 转动需要持续的时间(s)
  135. duringTime: 4.5,
  136. // 转盘样式的选项
  137. turntableStyleOption: {
  138. // 背景色
  139. prizeBgColors: ['#FFF9F8', '#FFECC9', '#FFF9F8', '#FFECC9', '#FFF9F8', '#FFECC9'],
  140. // 转盘的外边框颜色
  141. borderColor: '#FFD790'
  142. },
  143. // 中奖的奖品的index
  144. prizeIndex: -1,
  145. // 用来锁定转盘,避免同时多次点击转动
  146. isLocking: false,
  147. // 剩余抽奖次数
  148. num: 2,
  149. token: '',
  150. activityId: '',
  151. actualPrice: 0,
  152. mealId: '',
  153. selMealId: '',
  154. paySupportType: [],
  155. title: '',
  156. payType: '',
  157. mealList: [],
  158. status: 0
  159. }
  160. },
  161. async fetch() {
  162. if (this.$userAgent.isAndroid) {
  163. this.token = await window.native.getToken();
  164. } else {
  165. this.token = this.$route.query.token;
  166. }
  167. },
  168. head: {
  169. title: '年卡抽奖活动'
  170. },
  171. created() {
  172. this.getLuckDrawActivity()
  173. this.getMealInfo()
  174. },
  175. methods: {
  176. async getMealInfo() {
  177. const res = await this.$axios.$get('/pay/v2/meal/info?phoneType=SVIP');
  178. this.mealList = res.data.list.filter(item => item.day === 30 || item.day === 365)
  179. },
  180. createOrder() {
  181. if (this.$userAgent.isAndroid) {
  182. window.native.startPay(1, this.mealId, 1);
  183. }
  184. },
  185. async getLuckDrawActivity() {
  186. const res = await this.$axios.$post('/activity/v1/member/luckDrawActivity');
  187. this.activityId = res.data.activityId
  188. this.status = res.data.status
  189. },
  190. // 开始抽奖
  191. async startRotation() {
  192. // 如果还不可以转动
  193. if (!this.canBeRotated()) {
  194. return false;
  195. }
  196. // 开始转动
  197. // 先上锁
  198. this.isLocking = true;
  199. // 设置在哪里停下,应该与后台交互,这里随机抽取0~5
  200. const res = await this.$axios.$post('/activity/v1/member/luckDraw?activityId=' + this.activityId, {}, { headers: { Authorization: this.token } });
  201. if (res.status === 0) {
  202. const index = this.prizeData.findIndex(item => item.level === res.data.actualPrice)
  203. this.actualPrice = res.data.actualPrice
  204. if (Number(localStorage.getItem('year-15-9')) !== 2 && this.actualPrice === 15.9) {
  205. localStorage.setItem('year-15-9', 1)
  206. }
  207. if (Number(localStorage.getItem('year-9-9')) !== 2 && this.actualPrice === 9.9) {
  208. localStorage.setItem('year-9-9', 1)
  209. }
  210. this.mealId = res.data.mealId
  211. this.selMealId = res.data.mealId
  212. this.paySupportType = res.data.paySupportType
  213. this.payType = this.paySupportType[0]
  214. this.title = res.data.title
  215. this.prizeIndex = index;
  216. } else {
  217. return
  218. }
  219. // 成功后次数减少一次
  220. this.num--;
  221. // 告诉子组件,开始转动了
  222. this.$refs.roundTurntable.rotate(this.prizeIndex);
  223. },
  224. // 已经转动完转盘触发的函数
  225. endRotation() {
  226. // 提示中奖
  227. this.showPay = true
  228. // 解锁
  229. this.isLocking = false;
  230. },
  231. // 判断是否可以转动
  232. canBeRotated() {
  233. if (this.isLocking) {
  234. return false;
  235. }
  236. if (this.status === 0) {
  237. Toast({
  238. message: '当前活动已过期',
  239. position: 'top',
  240. className: 'lottery-container-toast'
  241. });
  242. return false;
  243. }
  244. if (this.status === 2) {
  245. Toast({
  246. message: '当前活动未开启',
  247. position: 'top',
  248. className: 'lottery-container-toast'
  249. });
  250. return false;
  251. }
  252. if (this.status === 3) {
  253. Toast({
  254. message: '当前活动已结束',
  255. position: 'top',
  256. className: 'lottery-container-toast'
  257. });
  258. return false;
  259. }
  260. return true;
  261. },
  262. closed() {
  263. if (Number(localStorage.getItem('year-15-9')) !== 2) {
  264. this.show = true
  265. localStorage.setItem('year-15-9', 2)
  266. }
  267. if (Number(localStorage.getItem('year-9-9')) !== 2) {
  268. this.show = true
  269. localStorage.setItem('year-9-9', 2)
  270. }
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="scss">
  276. @media (min-width: 0px) {
  277. .lottery-container-toast {
  278. &.van-toast--text {
  279. min-width: 94px;
  280. padding: 8px 12px;
  281. }
  282. &.van-toast {
  283. font-size: 13px;
  284. line-height: 21px;
  285. }
  286. }
  287. }
  288. </style>
  289. <style lang="scss" scoped>
  290. @media (min-width: 0px) {
  291. .lottery-container {
  292. background-color: #bbe5f2;
  293. background-image: url('../../../assets/image/activity/lottery/bg.png');
  294. background-size: contain;
  295. min-height: 100vh;
  296. overflow: hidden;
  297. max-width: 500px;
  298. margin: 0 auto;
  299. position: relative;
  300. }
  301. .lottery-swipe {
  302. width: 188px;
  303. height: 25px;
  304. background: rgba($color: #000000, $alpha: 0.24);
  305. border-radius: 0px 16px 16px 0px;
  306. position: absolute;
  307. top: 134px;
  308. left: 0;
  309. z-index: 1;
  310. }
  311. .lottery-swipe .van-swipe-item {
  312. color: #ffffff;
  313. font-size: 13px;
  314. line-height: 25px;
  315. text-align: center;
  316. }
  317. .w51h26 {
  318. width: 51px;
  319. height: 26px;
  320. position: absolute;
  321. top: 128px;
  322. right: 0;
  323. z-index: 2;
  324. }
  325. .roulette {
  326. width: 372px;
  327. height: 442px;
  328. background-image: url('../../../assets/image/activity/lottery/roulette.png');
  329. background-size: 100% 100%;
  330. margin: 127px auto 0;
  331. position: relative;
  332. }
  333. .arrow {
  334. width: 122px;
  335. height: 135px;
  336. position: absolute;
  337. top: 110px;
  338. left: 125px;
  339. background-image: url('../../../assets/image/activity/lottery/arrow.png');
  340. background-size: 100% 100%;
  341. z-index: 1;
  342. }
  343. .turntable {
  344. position: absolute;
  345. left: calc(50% - 144px);
  346. top: 163px;
  347. width: 288px;
  348. height: 288px;
  349. }
  350. .turntable-name {
  351. position: absolute;
  352. left: 10px;
  353. top: 20px;
  354. width: calc(100% - 20px);
  355. font-size: 20px;
  356. font-weight: 600;
  357. text-align: center;
  358. color: #b8320d;
  359. }
  360. .fs15 {
  361. font-size: 15px;
  362. }
  363. .turntable-img {
  364. position: relative;
  365. /*要居中就要50% - 宽度 / 2*/
  366. left: calc(50% - 40px / 2);
  367. top: 43px;
  368. width: 52px;
  369. height: 39px;
  370. img {
  371. display: inline-block;
  372. width: 52px;
  373. height: 39px;
  374. }
  375. }
  376. .start-btn {
  377. width: 276px;
  378. height: 55px;
  379. position: absolute;
  380. bottom: 16px;
  381. left: calc(50% - 138px);
  382. }
  383. .num {
  384. margin-top: 8px;
  385. text-align: center;
  386. font-size: 14px;
  387. color: #333333;
  388. line-height: 20px;
  389. }
  390. .popup-view {
  391. width: 324px;
  392. padding: 20px 10px;
  393. box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1);
  394. background: #ffffff;
  395. text-align: center;
  396. }
  397. .txt1 {
  398. font-size: 18px;
  399. font-weight: 600;
  400. color: #333333;
  401. line-height: 25px;
  402. text-align: center;
  403. }
  404. .coupon-1 {
  405. width: 286px;
  406. height: 106px;
  407. box-sizing: border-box;
  408. margin: 11px auto 0;
  409. position: relative;
  410. border-radius: 13px;
  411. border: 2px solid;
  412. border-color: #e8e8e8;
  413. box-sizing: border-box;
  414. &::before,
  415. &::after {
  416. background-color: white;
  417. border-radius: 50%;
  418. content: '';
  419. width: 20px;
  420. height: 20px;
  421. position: absolute;
  422. top: 43px;
  423. z-index: 1;
  424. }
  425. &::before {
  426. border-right: 2px solid;
  427. border-color: #e8e8e8;
  428. left: -12px;
  429. border-radius: 0 10px 10px 0;
  430. }
  431. &::after {
  432. border-left: 2px solid;
  433. border-color: #e8e8e8;
  434. right: -12px;
  435. border-radius: 10px 0 0 10px;
  436. }
  437. }
  438. .coupon-1.active,
  439. .coupon-2.active {
  440. border-left: 2px solid;
  441. border-color: #d96a57 !important;
  442. &::before {
  443. border-right: 2px solid;
  444. border-color: #d96a57;
  445. }
  446. &::after {
  447. border-left: 2px solid;
  448. border-color: #d96a57;
  449. }
  450. }
  451. .coupon-title {
  452. color: #362113;
  453. font-size: 12px;
  454. text-align: center;
  455. z-index: 1;
  456. position: absolute;
  457. top: 23px;
  458. width: 100%;
  459. }
  460. .txt2 {
  461. font-weight: 600;
  462. font-size: 24px;
  463. }
  464. .txt3 {
  465. color: #db6857;
  466. }
  467. .txt4 {
  468. position: absolute;
  469. top: 68px;
  470. width: 100%;
  471. text-align: center;
  472. font-size: 14px;
  473. font-weight: 600;
  474. color: #ffffff;
  475. line-height: 20px;
  476. z-index: 1;
  477. }
  478. .coupon-select-icon {
  479. width: 34px;
  480. height: 20px;
  481. position: absolute;
  482. top: 0;
  483. right: 0;
  484. z-index: 2;
  485. }
  486. .w253h73 {
  487. width: 253px;
  488. height: 73px;
  489. position: absolute;
  490. top: 15px;
  491. left: 15px;
  492. }
  493. .coupon-2 {
  494. display: inline-block;
  495. width: 138px;
  496. height: 106px;
  497. box-sizing: border-box;
  498. margin: 11px 4px 0;
  499. position: relative;
  500. border-radius: 13px;
  501. box-sizing: border-box;
  502. border: 2px solid;
  503. border-color: #e8e8e8;
  504. &::before,
  505. &::after {
  506. background-color: white;
  507. border-radius: 50%;
  508. content: '';
  509. width: 20px;
  510. height: 20px;
  511. position: absolute;
  512. top: 43px;
  513. z-index: 1;
  514. }
  515. &::before {
  516. border-right: 2px solid;
  517. border-color: #e8e8e8;
  518. left: -12px;
  519. border-radius: 0 10px 10px 0;
  520. }
  521. &::after {
  522. border-left: 2px solid;
  523. border-color: #e8e8e8;
  524. right: -12px;
  525. border-radius: 10px 0 0 10px;
  526. }
  527. }
  528. .w111h73 {
  529. width: 111px;
  530. height: 73px;
  531. position: absolute;
  532. top: 15px;
  533. left: 12px;
  534. }
  535. .txt5 {
  536. font-size: 16px;
  537. color: #333333;
  538. margin-left: 7px;
  539. }
  540. .icon-pay {
  541. font-size: 26px;
  542. line-height: inherit;
  543. }
  544. .fnc {
  545. display: flex;
  546. align-items: center;
  547. }
  548. .fnbc {
  549. display: flex;
  550. justify-content: space-between;
  551. align-items: center;
  552. height: 50px;
  553. padding: 0 10px;
  554. }
  555. .w304h62 {
  556. width: 304px;
  557. height: 62px;
  558. margin: 0 auto;
  559. }
  560. .txt6 {
  561. color: #333333;
  562. font-size: 11px;
  563. line-height: 16px;
  564. a {
  565. color: #ff7656;
  566. text-decoration: underline;
  567. }
  568. }
  569. .popup-view-leave {
  570. background: linear-gradient(180deg, #ffffff 0%, #f7f1e3 100%);
  571. }
  572. .btn-leave {
  573. width: 140px;
  574. height: 48px;
  575. background: linear-gradient(180deg, #ffdb94 0%, #ff9539 100%);
  576. box-shadow: 0px 2px 7px 0px rgba(237, 76, 0, 0.17),
  577. inset 0px -5px 0px 0px #ff7700;
  578. border-radius: 24px;
  579. font-size: 18px;
  580. font-weight: 600;
  581. color: #ffffff;
  582. text-align: center;
  583. line-height: 43px;
  584. margin-top: 15px;
  585. }
  586. .btn-pay {
  587. width: 140px;
  588. height: 48px;
  589. background: linear-gradient(180deg, #ff9278 0%, #ff562f 100%);
  590. box-shadow: 0px 2px 7px 0px rgba(237, 76, 0, 0.17),
  591. inset 0px -5px 0px 0px #f62e00;
  592. border-radius: 24px;
  593. border-radius: 24px;
  594. font-size: 18px;
  595. font-weight: 600;
  596. color: #ffffff;
  597. text-align: center;
  598. line-height: 43px;
  599. margin-top: 15px;
  600. }
  601. .txt7 {
  602. font-size: 14px;
  603. line-height: 18px;
  604. margin-top: 10px;
  605. }
  606. }
  607. </style>