bobo 3 年之前
父節點
當前提交
49dc54bcae
共有 3 個文件被更改,包括 51 次插入2 次删除
  1. 41 2
      pages/luckDraw/detail.js
  2. 1 0
      pages/luckDraw/detail.wxml
  3. 9 0
      pages/luckDraw/detail.wxss

+ 41 - 2
pages/luckDraw/detail.js

@@ -1,6 +1,6 @@
 // pages/luckDraw/detail.js
 import LuckDraw from '../../api/luck-draw'
-import {getMobileCache, getPhoneNumber} from '../../utils/user'
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../utils/user'
 const app = getApp();
 
 const DEFAULT_GIFTS = [
@@ -13,6 +13,7 @@ Page({
      * 页面的初始数据
      */
     data: {
+        pointerPos: 0,
         activityId: 0,
         forbidTurn: false,
         giftList: DEFAULT_GIFTS,
@@ -21,7 +22,8 @@ Page({
         remainNumSplits: [],
         showHitPrizeDlg: false,
         showNoHitPrizeDlg: false,
-        showPage: true
+        showPage: true,
+        isLogin: false
     },
 
     /**
@@ -35,6 +37,9 @@ Page({
             })
             return
         }
+        this.setData({
+            isLogin: getMobileCache() != ''
+        })
         this.data.activityId = options.id
         this.loadActivity()
         this.getDrawTimes()
@@ -107,6 +112,40 @@ Page({
      */
     turnPrize: function() {
         console.log("开始抽奖")
+        if (this.isLock || !this.data.isLogin) {
+            return
+        }
+        this.isLock = false
+        // 开始动画,开始是快阶段
+        this.startTurnAnimationFast();
+
+        // 开始调用后台
+    },
+
+    // 授权手机号
+    getPhoneNumber(e) {
+        getPhoneNumberSync(e, _ => {
+            this.getDrawTimes()
+        })
+    },
+
+    startTurnAnimationFast: function() {
+        const timer = setInterval(_ => {
+            if (this.data.pointerPos > 7) {
+                this.data.pointerPos = 0
+            }
+            this.data.giftList.forEach((v, i) => {
+                if (i == this.data.pointerPos) {
+                    v.active = true
+                } else {
+                    v.active = false
+                }
+            })
+            this.data.pointerPos++
+            this.setData({
+                giftList: this.data.giftList
+            })
+        }, 120)
     },
 
     /**

+ 1 - 0
pages/luckDraw/detail.wxml

@@ -35,6 +35,7 @@
                 </block>
                 <block wx:else>
                     <view class="_gift _turn_btn" catchtap="turnPrize">
+                        <button wx:if="{{!isLogin}}" class="phone-button" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" />
                         <image class="_bg" src="/images/luck-draw/gift-booth-center.png" />
                         <view class="_nums">
                             <text>{{remainNum}}/{{allNum}}</text>

+ 9 - 0
pages/luckDraw/detail.wxss

@@ -388,4 +388,13 @@ page {
     left: 0;
     top: 0;
     z-index: 0;
+}
+button.phone-button {
+    width: 168rpx !important;
+    height: 160rpx;
+    position: absolute;
+    left: 0;
+    top: 0;
+    opacity: 0;
+    z-index: 2;
 }