index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <template>
  2. <view class="goods-lucky">
  3. <!-- 转盘 -->
  4. <view class="spinning" :style="{backgroundImage:'url('+backImageUrl+')'}">
  5. <view class="spinning-title">
  6. <text>{{drawInfo.draw_template.name?drawInfo.draw_template.name:"幸运大轮盘"}}</text>
  7. </view>
  8. <q-turntable ref="turntable" :areaNumber='9' @start="turntableStart" @success="turntableSuccess">
  9. </q-turntable>
  10. </view>
  11. <view style="background-color: #f9f9f9; padding-bottom: 136rpx;">
  12. <!-- 产品信息 -->
  13. <view class="produce">
  14. <view class="produce-title">产品信息</view>
  15. <view class="produce-main" v-for="item in 6">
  16. <image style="width: 132rpx;height: 132rpx;border-radius: 10rpx;" src="/static/icon/banner02.png"
  17. mode=""></image>
  18. <view class="produce-main-text">
  19. <text class="produce-main-text-top">一等奖</text>
  20. <text class="produce-main-text-bom">HUAWEI MateBook X Pro</text>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 活动规则 -->
  25. <view class="rule">
  26. <view class="rule-title">
  27. 活动规则
  28. </view>
  29. <view class="rule-content">
  30. <view class="introduce-top">
  31. <text class="introduce-top-rule1"></text>
  32. <text style="margin: 0 8rpx;">活动规则</text>
  33. <text class="introduce-top-rule2"></text>
  34. </view>
  35. <view class="introduce-text">
  36. <text>{{drawInfo.draw_template.rule}}</text>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 我的奖品 -->
  41. <view class="prize">
  42. <view class="prize-title">
  43. 我的奖品
  44. </view>
  45. <view class="prize-main" v-for="item in drawRecord" :key="item.id">
  46. <view class="prize-main-left">
  47. <text class="prize-main-left-top">{{item.remark}}</text>
  48. <text class="prize-main-left-bom">{{item.created_at}}</text>
  49. </view>
  50. <view :class="item.status==1 ? 'prize-main-rightSelect' : 'prize-main-right' ">
  51. <text v-if="item.status==1">立即兑换</text>
  52. <text v-if="item.status==2">已兑换</text>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 中奖弹窗 -->
  58. <uni-popup ref="codePurchase" type="center">
  59. <view class="code-purchase">
  60. <view class="img">
  61. <image style="width: 80rpx;height: 82rpx" src="/static/icon/gift01.png"></image>
  62. <view class="text">
  63. <text>恭喜您抽中了<text>{{drawResult.name}}</text></text>
  64. <text>请尽快去奖品中心兑奖</text>
  65. </view>
  66. </view>
  67. <view class="btn">
  68. <view class="cancel" @click="dialogClose"><text>待会儿</text></view>
  69. <view class="download" @click="dialogConfirm"><text>去兑奖</text></view>
  70. </view>
  71. </view>
  72. </uni-popup>
  73. <!-- 未中奖弹窗 -->
  74. <uni-popup ref="codePurchaseNone" type="center">
  75. <view class="code-purchase">
  76. <view class="img">
  77. <image style="width: 108rpx;height: 68rpx" src="/static/icon/gift02.png"></image>
  78. <view class="text">
  79. <text>很遗憾您没有抽中奖品</text>
  80. <text>下次再来哟</text>
  81. </view>
  82. </view>
  83. <view class="btn">
  84. <view class="know" @click="dialogClose"><text>知道了</text></view>
  85. </view>
  86. </view>
  87. </uni-popup>
  88. </view>
  89. </template>
  90. <script>
  91. import QTurntable from '@/components/q-turntable/q-turntable.vue'
  92. export default {
  93. components: {
  94. QTurntable
  95. },
  96. data() {
  97. return {
  98. //中奖等级
  99. prizeLevel:'',
  100. isexchange: true,
  101. backImageUrl: 'http://t9.9026.com/imgs/banner02.png',
  102. award: 1,
  103. awardList: [{
  104. title: '一等奖'
  105. },
  106. {
  107. title: '四等奖'
  108. },
  109. {
  110. title: '谢谢参与'
  111. },
  112. {
  113. title: '一等奖'
  114. },
  115. {
  116. title: '谢谢参与'
  117. },
  118. {
  119. title: '三等奖'
  120. },
  121. {
  122. title: '三等奖'
  123. },
  124. {
  125. title: '二等奖'
  126. },
  127. {
  128. title: '一等奖'
  129. }
  130. ], // 顺时针对应每个奖项
  131. drawInfo:{
  132. draw_no: ''
  133. },
  134. drawRecord:[],
  135. drawResult:{}
  136. }
  137. },
  138. onLoad(params){
  139. const {draw_no} = params
  140. this.drawInfo.draw_no = draw_no;
  141. },
  142. onReady(){
  143. // this.judageIsDraw(); //判断是否有权限访问
  144. this.getDrawInfo(); //获取抽奖信息
  145. this.getDrawRecord(); //获取获奖记录
  146. },
  147. computed:{
  148. recordMsg:(status)=>{
  149. const di = ['未中奖','未兑换','已兑换'];
  150. return di[status];
  151. }
  152. },
  153. methods: {
  154. judageIsDraw(){
  155. if(!this.drawInfo.draw_no){
  156. uni.showToast({
  157. icon: 'error',
  158. title: "暂无权限",
  159. success:()=>{
  160. uni.reLaunch({
  161. url:'/pages/index/index'
  162. })
  163. }
  164. })
  165. }
  166. },
  167. getDrawInfo(){
  168. this.drawInfo.draw_no = "9HzqlNVBMRZo";
  169. this.$api.draw.drawInfo({
  170. draw_no: this.drawInfo.draw_no
  171. }).then(res=>{
  172. if(res.code == 0){
  173. this.drawInfo = res.data;
  174. }else{
  175. uni.showToast({
  176. icon: 'error',
  177. title: res.msg ? res.msg : "暂无权限"
  178. })
  179. }
  180. }).catch(err=>{
  181. uni.showToast({
  182. icon: 'error',
  183. title: "网络繁忙"
  184. })
  185. })
  186. },
  187. getDrawRecord(page = 1){
  188. if(page == 1){
  189. this.drawRecord = []
  190. }
  191. this.$api.draw.drawRecord({
  192. page:page
  193. }).then(res=>{
  194. if(res.code == 0){
  195. res.data.data.forEach(item => {
  196. if(item.source == 2){
  197. this.drawRecord.push(item);
  198. }
  199. })
  200. if(res.data.length >= 15){
  201. this.getDrawRecord(page + 1);
  202. }
  203. }
  204. })
  205. },
  206. //中奖去兑换按钮
  207. dialogConfirm() {
  208. this.$utils.jump({
  209. jump_type: 4,
  210. jump_config: '/pages/my/prize/prize'
  211. })
  212. },
  213. //中奖待会按钮
  214. dialogClose() {
  215. this.drawResult = {};
  216. this.$refs.codePurchaseNone.close();
  217. this.$refs.codePurchase.close();
  218. },
  219. // 用户点击开始抽奖
  220. turntableStart() {
  221. if(this.isDrawing) return;
  222. this.isDrawing = true
  223. let index = Math.floor(Math.random() * 6 + 1) //前端随机数,这里应该后台返回中奖结果
  224. // this.award = index
  225. this.award = 2
  226. this.$refs.turntable.begin(this.award);
  227. this.$api.draw.luckyDraw({
  228. draw_no: this.drawInfo.draw_no,
  229. }).then(res => {
  230. if(res.data.code != 0){
  231. uni.showToast({
  232. icon: 'error',
  233. title: res.msg?res.msg:"网络繁忙",
  234. })
  235. return;
  236. }
  237. this.drawResult = res.data;
  238. setTimeout(()=>{
  239. this.isDrawing = false
  240. }, 1000)
  241. });
  242. },
  243. // 抽奖完成后操作
  244. turntableSuccess() {
  245. let timer = setInterval(()=>{
  246. if(this.isDrawing){
  247. return;
  248. }
  249. if(this.drawResult.status == 1){
  250. this.$refs.codePurchase.open()
  251. }else{
  252. this.$refs.codePurchaseNone.open()
  253. }
  254. clearInterval(timer);
  255. }, 50)
  256. return;
  257. const index = this.award - 1;
  258. console.log('bind:success', this.awardList[index]);
  259. if(this.awardList[index].title == '谢谢参与'){
  260. this.$refs.codePurchaseNone.open()
  261. }else{
  262. let o = this.awardList[index].title
  263. console.log(this.awardList[index].title);
  264. this.prizeLevel = o
  265. this.$refs.codePurchase.open()
  266. }
  267. // uni.showToast({
  268. // title: `恭喜你获得${this.awardList[index].title}`,
  269. // icon: 'none'
  270. // });
  271. },
  272. }
  273. }
  274. </script>
  275. <style lang="scss" scoped>
  276. $pageColor:#F9F9F9;
  277. $bgColor:#FFFFFF;
  278. @mixin flexlayout {
  279. display: flex;
  280. align-items: center;
  281. justify-content: center;
  282. }
  283. page {
  284. height: 100% !important;
  285. background: #F9F9F9 !important;
  286. }
  287. .goods-lucky {
  288. height: 100%;
  289. background: #F9F9F9;
  290. }
  291. .code-purchase {
  292. width: 620rpx;
  293. // height: 357rpx;
  294. background: #fff;
  295. border-radius: 20rpx;
  296. padding-top: 44rpx;
  297. box-sizing: border-box;
  298. .img {
  299. display: flex;
  300. flex-direction: column;
  301. align-items: center;
  302. justify-content: center;
  303. }
  304. .text{
  305. margin-top: 26rpx;
  306. display: flex;
  307. flex-direction: column;
  308. align-items: center;
  309. justify-content: center;
  310. font-weight: 400;
  311. color: #333333;
  312. font-size: 32rpx;
  313. line-height: 44rpx;
  314. }
  315. .btn {
  316. margin-top: 26rpx;
  317. width: 100%;
  318. height: 90rpx;
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. border-top:2rpx solid #E5E5E5;
  323. .cancel{
  324. flex: 1;
  325. display: flex;
  326. align-items: center;
  327. justify-content: center;
  328. font-weight: 400;
  329. color: #333333;
  330. font-size: 32rpx;
  331. }
  332. .download{
  333. flex: 1;
  334. height: 90rpx;
  335. display: flex;
  336. align-items: center;
  337. justify-content: center;
  338. border-left:2rpx solid #E5E5E5;
  339. font-weight: 400;
  340. color: #FF6200;
  341. font-size: 32rpx;
  342. }
  343. .know{
  344. font-weight: 400;
  345. color: #FF6200;
  346. font-size: 32rpx;
  347. }
  348. }
  349. }
  350. .prize {
  351. margin-top: 24rpx;
  352. background: #FFFFFF;
  353. border-radius: 16rpx;
  354. padding: 40rpx 30rpx 40rpx;
  355. .prize-title {
  356. font-weight: bold;
  357. color: #080F18;
  358. font-size: 30rpx;
  359. }
  360. .prize-main {
  361. margin-top: 40rpx;
  362. display: flex;
  363. align-items: center;
  364. justify-content: space-between;
  365. border-bottom: 2rpx solid #F0F0F0;
  366. padding-bottom: 40rpx;
  367. &:last-child {
  368. border-bottom: none;
  369. padding-bottom: 0rpx;
  370. }
  371. .prize-main-left {
  372. display: flex;
  373. flex-direction: column;
  374. align-items: flex-start;
  375. justify-content: center;
  376. .prize-main-left-top {
  377. font-size: 32rpx;
  378. font-weight: bold;
  379. color: #333333;
  380. }
  381. .prize-main-left-bom {
  382. font-weight: 500;
  383. color: #999999;
  384. font-size: 24rpx;
  385. margin-top: 24rpx;
  386. }
  387. }
  388. .prize-main-right {
  389. flex: none;
  390. width: 148rpx;
  391. height: 60rpx;
  392. background: #FFFFFF;
  393. border-radius: 30rpx;
  394. border: 2rpx solid #D0D0D0;
  395. display: flex;
  396. align-items: center;
  397. justify-content: center;
  398. color: #D0D0D0;
  399. font-size: 26rpx;
  400. }
  401. .prize-main-rightSelect {
  402. flex: none;
  403. width: 148rpx;
  404. height: 60rpx;
  405. background: #FFFFFF;
  406. border-radius: 30rpx;
  407. border: 2rpx solid #FF6200;
  408. display: flex;
  409. align-items: center;
  410. justify-content: center;
  411. color: #FF6200;
  412. font-size: 26rpx;
  413. }
  414. }
  415. }
  416. .rule {
  417. margin-top: 24rpx;
  418. background: #FFFFFF;
  419. border-radius: 16rpx;
  420. padding: 40rpx 30rpx 32rpx;
  421. .rule-title {
  422. font-weight: bold;
  423. color: #080F18;
  424. font-size: 30rpx;
  425. }
  426. .rule-content {
  427. margin-top: 32rpx;
  428. background: #FFFFFF;
  429. border-radius: 4rpx;
  430. border: 2rpx solid #999999;
  431. padding: 48rpx 20rpx 34rpx;
  432. .introduce-top {
  433. height: 32rpx;
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. font-size: 32rpx;
  438. font-weight: bold;
  439. letter-spacing: 2rpx;
  440. .introduce-top-rule1 {
  441. width: 56rpx;
  442. height: 4rpx;
  443. background: linear-gradient(90deg, #FFFFFF 0%, #D9A94D 100%);
  444. }
  445. .introduce-top-rule2 {
  446. width: 56rpx;
  447. height: 4rpx;
  448. background: linear-gradient(-90deg, #FFFFFF 0%, #D9A94D 100%);
  449. }
  450. }
  451. .introduce-text {
  452. margin-top: 72rpx;
  453. font-weight: bold;
  454. color: #333333;
  455. font-size: 28rpx;
  456. line-height: 56rpx;
  457. }
  458. }
  459. }
  460. .produce {
  461. position: relative;
  462. top: -10rpx;
  463. background: #FFFFFF;
  464. border-radius: 16rpx;
  465. padding: 48rpx 30rpx 0rpx;
  466. .produce-title {
  467. font-weight: bold;
  468. color: #080F18;
  469. font-size: 30rpx;
  470. margin-bottom: 40rpx;
  471. }
  472. .produce-main {
  473. display: flex;
  474. align-items: center;
  475. justify-content: space-between;
  476. border-bottom: 2rpx solid #F0F0F0;
  477. padding-bottom: 32rpx;
  478. margin-bottom: 32rpx;
  479. &:last-child {
  480. border: none;
  481. margin-bottom: 0;
  482. }
  483. .produce-main-text {
  484. margin-left: 24rpx;
  485. flex: 1;
  486. display: flex;
  487. flex-direction: column;
  488. align-items: flex-start;
  489. justify-content: center;
  490. .produce-main-text-top {
  491. font-weight: 500;
  492. color: #080F18;
  493. font-size: 28rpx;
  494. }
  495. .produce-main-text-bom {
  496. font-weight: 500;
  497. color: #666666;
  498. font-size: 24rpx;
  499. margin-top: 14rpx;
  500. }
  501. }
  502. }
  503. }
  504. .spinning {
  505. padding-top: 64rpx;
  506. width: 100%;
  507. height: 790rpx;
  508. background-repeat: no-repeat;
  509. background-size: cover;
  510. .spinning-title {
  511. margin-bottom: 40rpx;
  512. display: flex;
  513. align-items: center;
  514. justify-content: center;
  515. font-weight: bold;
  516. color: #FFFFFF;
  517. font-size: 64rpx;
  518. }
  519. }
  520. </style>