Bladeren bron

Merge branch 'bobo/feat/luck-draw' into jeffrey/feat/coupon-center

# Conflicts:
#	app.json
#	project.config.json
#	project.private.config.json
#	utils/request.js
xing.li 3 jaren geleden
bovenliggende
commit
ff9a646570
63 gewijzigde bestanden met toevoegingen van 2876 en 13 verwijderingen
  1. 104 0
      api/luck-draw.js
  2. 8 5
      app.json
  3. BIN
      images/luck-draw/0.png
  4. BIN
      images/luck-draw/1.png
  5. BIN
      images/luck-draw/2.png
  6. BIN
      images/luck-draw/3.png
  7. BIN
      images/luck-draw/4.png
  8. BIN
      images/luck-draw/5.png
  9. BIN
      images/luck-draw/6.png
  10. BIN
      images/luck-draw/7.png
  11. BIN
      images/luck-draw/8.png
  12. BIN
      images/luck-draw/9.png
  13. BIN
      images/luck-draw/cash_coupon.png
  14. BIN
      images/luck-draw/cc_use_now.png
  15. BIN
      images/luck-draw/choice.png
  16. BIN
      images/luck-draw/ci.png
  17. BIN
      images/luck-draw/cjjh.png
  18. BIN
      images/luck-draw/coupon1.png
  19. BIN
      images/luck-draw/coupon_use_now.png
  20. BIN
      images/luck-draw/gift-booth-active.png
  21. BIN
      images/luck-draw/gift-booth-center-disable.png
  22. BIN
      images/luck-draw/gift-booth-center.png
  23. BIN
      images/luck-draw/gift-booth.png
  24. BIN
      images/luck-draw/gift-box.png
  25. BIN
      images/luck-draw/gift.png
  26. BIN
      images/luck-draw/hbar.png
  27. BIN
      images/luck-draw/head-bg.png
  28. BIN
      images/luck-draw/hitdlgbg.png
  29. BIN
      images/luck-draw/home-active.png
  30. BIN
      images/luck-draw/home.png
  31. BIN
      images/luck-draw/niyou.png
  32. BIN
      images/luck-draw/nogift.png
  33. BIN
      images/luck-draw/per_head.png
  34. BIN
      images/luck-draw/portrait.png
  35. BIN
      images/luck-draw/prize.png
  36. BIN
      images/luck-draw/prizeNo.png
  37. BIN
      images/luck-draw/recordPrize.png
  38. BIN
      images/luck-draw/user-active.png
  39. BIN
      images/luck-draw/user.png
  40. 118 0
      pages/luckDraw/common.js
  41. 74 0
      pages/luckDraw/components/tabbar.js
  42. 4 0
      pages/luckDraw/components/tabbar.json
  43. 11 0
      pages/luckDraw/components/tabbar.wxml
  44. 28 0
      pages/luckDraw/components/tabbar.wxss
  45. 488 0
      pages/luckDraw/detail.js
  46. 4 0
      pages/luckDraw/detail.json
  47. 167 0
      pages/luckDraw/detail.wxml
  48. 445 0
      pages/luckDraw/detail.wxss
  49. 159 0
      pages/luckDraw/index.js
  50. 6 0
      pages/luckDraw/index.json
  51. 37 0
      pages/luckDraw/index.wxml
  52. 122 0
      pages/luckDraw/index.wxss
  53. 215 0
      pages/luckDraw/profile.js
  54. 6 0
      pages/luckDraw/profile.json
  55. 127 0
      pages/luckDraw/profile.wxml
  56. 332 0
      pages/luckDraw/profile.wxss
  57. 166 0
      pages/luckDraw/recordPrize.js
  58. 6 0
      pages/luckDraw/recordPrize.json
  59. 39 0
      pages/luckDraw/recordPrize.wxml
  60. 179 0
      pages/luckDraw/recordPrize.wxss
  61. 18 0
      project.private.config.json
  62. 11 7
      utils/request.js
  63. 2 1
      utils/util.js

+ 104 - 0
api/luck-draw.js

@@ -0,0 +1,104 @@
+import request from '../utils/request.js'
+
+class LuckDraw extends request {
+
+    static getActivityDetail(id) {
+        let params = {
+            id
+        }
+        return this.postRequest(`${this.BASE_URL}open/luck-draw/detail`, params, true)
+    }
+
+    static drawPrize(activityId, mobile) {
+        const params = {
+            activityId,
+            mobile
+        }
+        return this.postRequest(`${this.BASE_URL}open/luck-draw/draw-prize`, params, true)
+    }
+
+    static getHitList(activityId) {
+        const params = {
+            activityId
+        }
+        return this.postRequest(`${this.BASE_URL}open/luck-draw/hit-list`, params, true)
+    }
+
+    static getActivityList(params) {
+        return this.postRequest(`${this.BASE_URL}open/luck-draw/activity-list`, params)
+    }
+
+    /**
+     * 用户抽奖记录
+     * @param {} params 
+     */
+    static getUserDrawRecord(params) {
+        return this.postRequest(`${this.BASE_URL}open/luck-draw/user-draw-record`, params)
+    }
+
+    /**
+     * @param {*} params 
+     */
+    static getUserPrizeList(params) {
+        return this.postRequest(`${this.BASE_URL}open/luck-draw/user-prize-list`, params)
+    }
+
+    /**
+     * 分享回调
+     */
+    static shareActivity(activityId, mobile) {
+        const params = {
+            activityId,
+            mobile
+        }
+        return this.postRequest(`${this.BASE_URL}open/luck-draw/share-activity`, params, true)
+    }
+
+    static getTimes(activityId, mobile) {
+        const params = {
+            activityId,
+            mobile
+        }
+        return this.postRequest(`${this.BASE_URL}open/luck-draw/get-times`, params, true)
+    }
+
+}
+
+export default LuckDraw;
+
+// 示例
+// LuckDraw.drawPrize(3, "16602120168").then(res => {
+
+// }).catch(_ => {})
+// LuckDraw.getHitList(3).then(res => {
+
+// }).catch(_ => {})
+// LuckDraw.getActivityList({
+//     page: 1,
+//     pageSize: 20
+// }).then(res => {
+
+// }).catch(_ => {})
+
+// LuckDraw.getUserDrawRecord({
+//     mobile: "16602120168",
+//     activityId: 3,
+//     page: 1,
+//     pageSize: 20
+// }).then(res => {
+
+// }).catch(_ => {})
+
+// LuckDraw.getUserPrizeList({
+//     mobile: "16602120168",
+//     goodsType: 1,
+//     page: 1,
+//     pageSize: 20
+// }).then(res => {
+
+// }).catch(_ => {})
+
+// LuckDraw.shareActivity(3, "16602120168").then(res => {
+// }).catch(_ => {})
+// LuckDraw.getTimes(3, "16602120168").then(res => {
+// }).catch(_ => {})

+ 8 - 5
app.json

@@ -13,14 +13,17 @@
     "pages/welfareMall/refund/refund",
     "pages/welfareMall/feedback/feedback",
     "pages/welfareMall/activityList/activityList",
-    "pages/welfareMall/activityInfo/activityInfo"
-    
+    "pages/welfareMall/activityInfo/activityInfo",
+    "pages/luckDraw/detail",
+    "pages/luckDraw/index",
+    "pages/luckDraw/profile",
+    "pages/luckDraw/recordPrize"
   ],
-  "window": {
-    "backgroundTextStyle": "light",
+  "window":{
+    "backgroundTextStyle":"light",
     "navigationBarBackgroundColor": "#fff",
     "navigationBarTitleText": "Weixin",
-    "navigationBarTextStyle": "black"
+    "navigationBarTextStyle":"black"
   },
   "style": "v2",
   "sitemapLocation": "sitemap.json",

BIN
images/luck-draw/0.png


BIN
images/luck-draw/1.png


BIN
images/luck-draw/2.png


BIN
images/luck-draw/3.png


BIN
images/luck-draw/4.png


BIN
images/luck-draw/5.png


BIN
images/luck-draw/6.png


BIN
images/luck-draw/7.png


BIN
images/luck-draw/8.png


BIN
images/luck-draw/9.png


BIN
images/luck-draw/cash_coupon.png


BIN
images/luck-draw/cc_use_now.png


BIN
images/luck-draw/choice.png


BIN
images/luck-draw/ci.png


BIN
images/luck-draw/cjjh.png


BIN
images/luck-draw/coupon1.png


BIN
images/luck-draw/coupon_use_now.png


BIN
images/luck-draw/gift-booth-active.png


BIN
images/luck-draw/gift-booth-center-disable.png


BIN
images/luck-draw/gift-booth-center.png


BIN
images/luck-draw/gift-booth.png


BIN
images/luck-draw/gift-box.png


BIN
images/luck-draw/gift.png


BIN
images/luck-draw/hbar.png


BIN
images/luck-draw/head-bg.png


BIN
images/luck-draw/hitdlgbg.png


BIN
images/luck-draw/home-active.png


BIN
images/luck-draw/home.png


BIN
images/luck-draw/niyou.png


BIN
images/luck-draw/nogift.png


BIN
images/luck-draw/per_head.png


BIN
images/luck-draw/portrait.png


BIN
images/luck-draw/prize.png


BIN
images/luck-draw/prizeNo.png


BIN
images/luck-draw/recordPrize.png


BIN
images/luck-draw/user-active.png


BIN
images/luck-draw/user.png


+ 118 - 0
pages/luckDraw/common.js

@@ -0,0 +1,118 @@
+export default {
+    isEmpty(v) {
+        if (typeof v == "undefined" || v == null) {
+            return true
+        }
+        if (v == 0 || v == "") {
+            return true
+        }
+        return /^\s+$/g.test(v)
+    },
+
+    toTimeStamp(v, ymd) {
+        if (this.isEmpty(v)) {
+            return null
+        }
+        if (ymd) {
+            v = ymd + " " + v
+        }
+        return new Date(v).getTime() / 1000
+    },
+
+    setActivityCountdownTime(now, activity) {
+        let beginTime = activity.beginTime  // 活动开始时间
+        let endTime = activity.endTime  // 活动结束时间
+        let dayBeginTime = activity.dayBeginTime // 每天开始时间
+        let dayEndTime = activity.dayEndTime // 每天结束时间
+        let nowY = now.getFullYear()
+        let nowM = now.getMonth() + 1
+        let nowD = now.getDate()
+        const Ymd = nowY + "-" + nowM + "-" + nowD;
+        dayBeginTime = this.toTimeStamp(dayBeginTime, Ymd)
+        dayEndTime = this.toTimeStamp(dayEndTime, Ymd)
+        beginTime = this.toTimeStamp(beginTime)
+        endTime = this.toTimeStamp(endTime)
+        const nowTime = now.getTime() / 1000
+        let diffSec = 0;
+        if (activity.timeType == 2) {
+            if (beginTime == null || endTime == null) {
+                return
+            }
+            // 固定时间段内活动
+            beginTime = this.fixBeginTime(beginTime, activity.dayBeginTime)
+            endTime = this.fixEndTime(endTime, activity.dayEndTime)
+            if (nowTime < beginTime) {
+                diffSec = beginTime - nowTime
+                activity.status = 4
+                activity.countDownTime = this.formatTimeBySec(diffSec)
+                activity.statusText = "即将开始"
+                return
+            }
+            if (nowTime > endTime) {
+                activity.status = 3
+                activity.statusText = "已结束"
+                return
+            }
+        }
+        // 长期时间,只要计算,距离当天时间即可
+        if (dayBeginTime == null || dayEndTime == null) {
+            return
+        }
+        if (nowTime < dayBeginTime) {
+            diffSec = dayBeginTime - nowTime
+            activity.status = 4
+            activity.countDownTime = this.formatTimeBySec(diffSec)
+            activity.statusText = "即将开始"
+            return
+        } 
+        if (nowTime > dayEndTime) {
+            diffSec = dayBeginTime + 86400 - nowTime
+            activity.status = 5
+            activity.countDownTime = this.formatTimeBySec(diffSec)
+            activity.statusText = "即将开始"
+            return
+        } 
+        activity.status = 2
+        activity.statusText = "进行中"
+    },
+    
+    fixBeginTime(time, hourTime) {
+        if (this.isEmpty(hourTime)) {
+            return time
+        }
+        const date = new Date(time * 1000)
+        const ymd = date.getFullYear(date) + "-" + (date.getMonth() + 1) + "-" + date.getDate()
+        const fullH = new Date(ymd + " " + hourTime).getTime() / 1000;
+        return fullH > time ? fullH : time
+
+    },
+    fixEndTime(time, hourTime) {
+        if (this.isEmpty(hourTime)) {
+            return time
+        }
+        const date = new Date(time * 1000)
+        const ymd = date.getFullYear(date) + "-" + (date.getMonth() + 1) + "-" + date.getDate()
+        const fullH = new Date(ymd + " " + hourTime).getTime() / 1000;
+        return fullH < time ? fullH : time
+    },
+    formatTimeBySec(sec) {
+        const day = Math.floor(sec / 86400)
+        const hour = Math.floor((sec % 86400) / 3600)
+        const min = Math.floor(((sec % 86400) % 3600) / 60)
+        const s = Math.floor((sec % 86400) % 3600 % 60)
+        let rt = ''
+        if (day > 0) {
+            rt = day + '天'
+        }
+        rt += this.formatHMS(hour || 0) + ":"
+        rt += this.formatHMS(min || 0) + ":"
+        rt += this.formatHMS(s || 0)
+        return rt
+    },
+    formatHMS(h) {
+        if (h < 10) {
+            return 0 + "" + h
+        }
+        return h
+    }
+}

+ 74 - 0
pages/luckDraw/components/tabbar.js

@@ -0,0 +1,74 @@
+// pages/luckDraw/components/tabbar.js
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+
+    },
+
+    /**
+     * 组件的初始数据
+     */
+    data: {
+        list: [
+            {
+                text: "首页",
+                pagePath: "/pages/luckDraw/index",
+                selectedIconPath: "../../../images/luck-draw/home-active.png",
+                iconPath: "../../../images/luck-draw/home.png",
+            },
+            {
+                text: "我的",
+                pagePath: "/pages/luckDraw/profile",
+                selectedIconPath: "../../../images/luck-draw/user-active.png",
+                iconPath: "../../../images/luck-draw/user.png",
+            }
+        ]
+    },
+
+    attached: function() {
+        var url =getCurrentPages()[getCurrentPages().length-1].route
+        this.data.list.forEach(v => {
+            if (this.getPathName(v.pagePath) == this.getPathName(url)) {
+                v.active = true
+            }
+        })
+        this.setData({
+            list: this.data.list
+        })
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        toPage: function(e) {
+            const index = e.currentTarget.dataset.index;
+            this.data.list.forEach((v, i) => {
+                if (i == index) {
+                    v.active = true
+                } else {
+                    v.active = false
+                }
+            })
+            this.setData({
+                list: this.data.list
+            })
+            if (index == 0) {
+                wx.reLaunch({
+                  url: this.data.list[index].pagePath,
+                })
+                return
+            }
+            wx.redirectTo({
+              url: this.data.list[index].pagePath,
+            })
+        },
+        getPathName(path) {
+            let pos = path.indexOf("luckDraw/");
+            pos += "luckDraw/".length;
+            return path.substr(pos)
+        }
+    }
+})

+ 4 - 0
pages/luckDraw/components/tabbar.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 11 - 0
pages/luckDraw/components/tabbar.wxml

@@ -0,0 +1,11 @@
+<!--pages/luckDraw/components/tabbar.wxml-->
+<view class="tab-bar-body">
+    <view wx:for="{{list}}" wx:key="index" data-index="{{index}}" catchtap="toPage" class="{{item.active?'_active':''}}">
+       <view class="_ico">
+          <image class="_image" src="{{item.active ? item.selectedIconPath : item.iconPath}}" />
+       </view>
+       <view class="_text">
+          <text>{{item.text}}</text>
+       </view>
+    </view>
+</view>

+ 28 - 0
pages/luckDraw/components/tabbar.wxss

@@ -0,0 +1,28 @@
+/* pages/luckDraw/components/tabbar.wxss */
+.tab-bar-body{
+    position: fixed;
+    z-index: 1000;
+    left: 0;
+    bottom: 0;
+    height: 98rpx;
+    background: #fff;
+    width: 100vw;
+    box-shadow: 0 8px 49px 0 rgba(179, 117, 117, 0.22);
+    display: flex;
+    justify-content: space-around;
+}
+.tab-bar-body ._ico {
+    height: 60rpx;
+    width: 60rpx;
+    padding-top: 4rpx;
+}
+.tab-bar-body ._image {
+    width: 100%;
+    height: 100%;
+}
+.tab-bar-body ._text {
+    line-height: 28rpx;
+    height: 28px;
+    text-align: center;
+    font-size: 28rpx;
+}

+ 488 - 0
pages/luckDraw/detail.js

@@ -0,0 +1,488 @@
+// pages/luckDraw/detail.js
+import LuckDraw from '../../api/luck-draw'
+import Common from './common'
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../utils/user'
+const app = getApp();
+
+const DEFAULT_GIFTS = [
+    { icoUrl: '', text: '' }, { iconUrl: '', text: '' },{ icoUrl: '', text: '' }, { icoUrl: '', text: ''},
+    { icoUrl: '', text: ''}, { icoUrl: '', text: '' }, { icoUrl: '', text: ''}, { icoUrl: '', text: '' }
+];
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        pointerPos: 0,
+        hitPos: null,
+        isHit: null,
+        activityId: 0,
+        forbidTurn: false,
+        giftList: DEFAULT_GIFTS,
+        allNum: 0,
+        remainNum: 0,
+        remainNumSplits: [],
+        showHitPrizeDlg: false,
+        showNoHitPrizeDlg: false,
+        showNeedShareDlg: false,
+        showPage: false,
+        isLogin: false,
+        hitResult: null,
+        noHitResult: null,
+        hitRecordList: []
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+    },
+
+    popMessage(message) {
+        app.showToast(message, "none")
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        Object.assign(this, Common)
+        if (!options.id) {
+            this.popMessage ('入参错误');
+            wx.navigateTo({
+              url: './index',
+            })
+            return
+        }
+        this.setData({
+            isLogin: getMobileCache() != ''
+        })
+        this.data.activityId = options.id
+        this.loadActivity()
+        this.getDrawTimes()
+        // 获取中奖名单
+        this.getHitRecord()
+    },
+    loadActivity: function() {
+        LuckDraw.getActivityDetail(this.data.activityId).then(resp => {
+            if (resp.code == 200 && resp.data != null) {
+                this.mapDataToView(resp.data)
+            }
+       }).catch(err => {
+           this.setData({
+             errMessage: err.data.msg
+           })
+       }).finally(_ => {
+           this.setData({
+               showPage: true
+           })
+       })
+    },
+
+    /**
+     * 获取次数
+     */
+    getDrawTimes: function() {
+        if (!this.data.isLogin) {
+            this.setData({
+                remainNum: 0,
+                allNum: 0
+            })
+            this.setRemainNumSplits()
+            return
+        }
+        LuckDraw.getTimes(this.data.activityId, getMobileCache()).then(res => {
+            if (res.code == 200) {
+                this.setData({
+                    remainNum: res.data.remainTimes,
+                    allNum: res.data.allTimes,
+                })
+                this.setRemainNumSplits()
+            }
+        }).catch(_ => {})
+    },
+
+    /**
+     * 活动数据映射
+     */
+    mapDataToView: function(activity) {
+        activity.goodsItemList.forEach(v => {
+            const pos = parseInt(v.pos || 0)
+            if (pos > 0) {
+                if (this.data.giftList[pos-1].isLoaded) {
+                    return true
+                }
+                this.data.giftList[pos - 1].isLoaded = true
+                this.data.giftList[pos - 1].text = v.goodsName
+                this.data.giftList[pos - 1].iconUrl = v.goodsSmallImage
+                this.data.giftList[pos - 1].hitIconUrl = v.goodsBigImage
+                this.data.giftList[pos - 1].goodsId = v.goodsId
+                this.data.giftList[pos - 1].couponId = v.couponId
+                this.data.giftList[pos - 1].isSpecial = v.isSpecial
+                this.data.giftList[pos - 1].hitDesc = v.hitDesc
+                this.data.giftList[pos - 1].active = false
+            }
+        })
+        this.setData({
+            activityTitle: activity.activityTitle,
+            showBeginTime: activity.showBeginTime,
+            showEndTime: activity.showEndTime,
+            beginTime: activity.beginTime,
+            endTime: activity.endTime,
+            timeType: activity.timeType,
+            dayBeginTime: activity.dayBeginTime,
+            dayEndTime: activity.dayEndTime,
+            giftList: this.data.giftList,
+            ruleDesc: activity.ruleDesc || '',
+            forbidTurn: activity.status != 2,
+            opptyInitialVal: activity.opptyInitialVal || 0,
+            opptyMaxVal: activity.opptyMaxVal || 0,
+            status: activity.status
+        })
+
+        if (activity.status == 1 || activity.status ==4 || activity.status == 5) {
+
+            this.tmpTimeObject = {
+                beginTime: activity.beginTime,
+                endTime: activity.endTime,
+                timeType: activity.timeType,
+                dayBeginTime: activity.dayBeginTime,
+                dayEndTime: activity.dayEndTime
+            }
+            this.countDownTimer = setInterval(this.calcCountDownTime, 1000)
+            this.calcCountDownTime()
+        }
+    },
+    calcCountDownTime() {
+        this.setActivityCountdownTime(new Date(), this.tmpTimeObject)
+        this.setData({
+            countDownTime: this.tmpTimeObject.countDownTime,
+            status: this.tmpTimeObject.status
+        })
+        // 删除定时器
+        if (this.tmpTimeObject.status == 2 || this.tmpTimeObject.status == 3 && this.countDownTimer != null) {
+            clearInterval(this.countDownTimer)
+        }
+    },
+    /**
+     * 开始转动奖品,抽奖
+     */
+    turnPrize: function() {
+        console.log("开始抽奖")
+        if (this.isLock || !this.data.isLogin) {
+            return
+        }
+        // 预处理
+        if (this.data.remainNum <= 0) {
+            if (this.data.noHitResult != null ) {
+                // 可以通过分享获取
+                if (this.data.noHitResult.canShareGetTimes == 1) {
+                    this.popNeedShareDlg()
+                    return
+                } 
+                if (this.isSniffAgain) {
+                    this.popMessage('抱歉,您的抽奖机会已用完');
+                    return
+                }
+            }
+        }
+        this.isLock = true
+        this.isSniffAgain = false
+        let remainNum = this.data.remainNum - 1
+        if (remainNum < 0) {
+            this.isSniffAgain = true
+            remainNum = 0
+        }
+        this.setData({ remainNum })
+        this.setRemainNumSplits()
+        // 开始动画,开始是快阶段
+        this.data.duration = 50
+        this.data.hitPos = -1
+        this.data.hitTime = 0
+        this.data.isHit = null;
+        this.data.stopNotify = false
+        if (this.isSniffAgain) {
+            this.data.hitTime = new Date().getTime()
+            this.requestDrawPrize()
+            this.isLock = false;
+        } else {
+            this.startTurnAnimationFast()
+            // 开始调用后台
+            setTimeout(_ => {
+                this.data.hitTime = new Date().getTime()
+                this.requestDrawPrize()
+            }, (Math.random() + 1)*1000)
+        }
+    },
+    
+    requestDrawPrize: function() {
+        LuckDraw.drawPrize(this.data.activityId, getMobileCache()).then(res => {
+            if (res.code == 200) {
+                this.hitPrizeMapData(res.data)
+            }
+        }).catch(_ => {
+            console.log(_)
+            this.data.stopNotify = true
+            this.isLock = false
+            this.getDrawTimes()
+        })
+    },
+
+    hitPrizeMapData: function(hitData) {
+        if (hitData.isHit == 1) {
+            // 中奖
+            const hitResult = hitData.hitResult;
+            this.data.giftList.forEach((v, i) => {
+                if (v.goodsId == hitResult.goodsId) {
+                    // 设置中奖
+                    this.data.hitPos = i
+                    return false
+                }
+            })
+            this.setData({
+                hitResult,
+                isHit: 1,
+            })
+        } else {
+            // 未中奖
+            const noHitResult = hitData.noHitResult || {};
+            if (noHitResult.canShareGetTimes == 1) {
+                // 分享可获取抽奖机会,停止转动
+                this.data.stopNotify = true
+                this.setData({
+                    noHitResult,
+                    isHit: 0
+                })
+                this.isLock = false
+                this.popNeedShareDlg()
+            } else {
+                this.data.giftList.forEach((v, i) => {
+                    if (v.goodsId == noHitResult.goodsId) {
+                        // 设置中奖
+                        this.data.hitPos = i
+                        return false
+                    }
+                })
+                this.setData({
+                    noHitResult,
+                    isHit: 0,
+                })
+                if (this.data.hitPos == -1) {
+                    this.data.stopNotify = true
+                    this.setData({
+                        showNoHitPrizeDlg: true
+                    })
+                    this.isLock = false
+                }
+            }
+        }
+        // 重刷次数
+        this.getDrawTimes()
+    },
+
+    popNeedShareDlg: function() {
+        this.setData({
+            showNeedShareDlg: true
+        })
+    },
+
+    // 授权手机号
+    getPhoneNumber(e) {
+        getPhoneNumberSync(e, _ => {
+            this.setData({ isLogin: true })
+            this.getDrawTimes()
+        })
+    },
+    nextPos() {
+        let pos = 0
+        switch(this.data.pointerPos) {
+            case 0:
+                pos = 1
+                break
+            case 1:
+                pos = 2
+                break
+            case 2:
+                pos = 4
+                break
+            case 4:
+                pos = 7
+                break
+            case 7:
+                pos = 6
+                break  
+            case 6:
+                pos = 5
+                break
+            case 5:
+                pos = 3
+                break
+            case 3:
+                pos = 0
+                break                 
+        }
+        this.data.pointerPos = pos
+    },
+
+    startTurnAnimationFast: function() {
+        if (this.data.stopNotify) {
+            // 异常停止转动
+            this.setActiveGift(-1)
+            this.timer&&clearTimeout(this.timer)
+            return
+        }
+        const endTime = new Date().getTime()
+        const step = 10
+        this.timer = setTimeout(_ => {
+            this.setActiveGift(this.data.pointerPos)
+            if (this.data.hitPos == -1) {
+                this.nextPos()
+                this.startTurnAnimationFast()
+            } else {
+                // 收到抽中信号了,依然需要跑一段时间
+                if (endTime - this.data.hitTime < (Math.random() + 1)*1000) {
+                    this.data.duration += step
+                    this.nextPos()
+                    this.startTurnAnimationFast()
+                } else {
+                    // 可以定位了
+                    if (this.data.hitPos == this.data.pointerPos) {
+                        // 删除定时器,抽奖动作结束,开始回调
+                        this.timer && clearTimeout(this.timer)
+                        this.setActiveGift(this.data.pointerPos)
+                        this.dealHitResult()
+                    } else {
+                        this.data.duration += (step * 2)
+                        this.nextPos()
+                        this.startTurnAnimationFast()
+                    }
+                }
+            }
+        }, this.data.duration)
+    },
+
+    setActiveGift(pos) {
+        this.data.giftList.forEach((v, i) => {
+            if (i == pos) {
+                v.active = true
+            } else {
+                v.active = false
+            }
+        })
+        this.setData({
+            giftList: this.data.giftList
+        })
+    },
+
+    dealHitResult: function() {
+        setTimeout(_ => {
+            if (this.data.isHit == 1) {
+                this.setData({
+                    showHitPrizeDlg: true
+                })
+            } else {
+                this.setData({
+                    showNoHitPrizeDlg: true
+                })
+            }
+            this.isLock = false
+        }, 500)
+
+        // 刷新一下中奖名单
+        this.getHitRecord()
+    },
+
+    /**
+     * 中奖名单
+     */
+    getHitRecord: function() {
+        LuckDraw.getHitList(this.data.activityId).then(res => {
+            if (res.code == 200) {
+                this.setHitRecordDataMap(res.data)
+            }
+        }).catch(_ => {})
+    },
+    setHitRecordDataMap: function(hitRecordList) {
+        this.setData({
+            hitRecordList
+        })
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function (res) {
+        LuckDraw.shareActivity(this.data.activityId, getMobileCache()).then(res => {
+            if (res.code == 200) {
+                this.getDrawTimes()
+            }
+        }).catch(_ => {})
+        return {
+            title: this.data.activityTitle,
+            path: "/pages/luckDraw/detail?id=" + this.data.activityId
+        }
+    },
+
+    setRemainNumSplits: function() {
+        this.setData({
+            remainNumSplits: (this.data.remainNum || 0).toString().split("")
+        })
+    },
+
+    closeDlg: function() {
+        this.setData({
+            showHitPrizeDlg: false,
+            showNoHitPrizeDlg: false,
+            showNeedShareDlg: false,
+        })
+    },
+
+    toLuckDrawPage: function() {
+        wx.navigateTo({
+          url: '/pages/luckDraw/recordPrize?activityId=' + this.data.activityId,
+        })
+    },
+
+    turnActivityListPage() {
+        wx.redirectTo({
+          url: '/pages/luckDraw/index',
+        })
+    }
+    
+})

+ 4 - 0
pages/luckDraw/detail.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "活动抽奖",
+  "usingComponents": {}
+}

+ 167 - 0
pages/luckDraw/detail.wxml

@@ -0,0 +1,167 @@
+<!--pages/luckDraw/detail.wxml-->
+<view class="page" wx:if="{{showPage}}">
+    <view class="head-bg">
+       <image src="/images/luck-draw/head-bg.png" />
+    </view>
+    <!-- 抽奖视图 -->
+    <view class="luck-draw-box">
+
+       <view class="luck-draw-body">
+            <view class="luck-draw-tip">
+                <image class="_niyou" src="/images/luck-draw/niyou.png" />
+                <image wx:for="{{remainNumSplits}}" wx:key="key" class="_num _{{item}}" src="/images/luck-draw/{{item}}.png" />
+                <image class="_ci" src="/images/luck-draw/ci.png" />
+                <image class="_cjjh" src="/images/luck-draw/cjjh.png" />
+            </view>
+            <view class="luck-draw-record-btn" catchtap="toLuckDrawPage">抽奖记录</view>
+
+            <!-- 奖品转盘 -->
+            <view class="luck-draw-gifts">
+                <view wx:for="{{giftList}}" wx:key="idx" wx:for-index="idx" class="_gift _pos_{{idx}}">
+                    <view class="_ico">
+                        <image wx:if="item.iconPath" src="{{item.iconUrl}}"/>
+                    </view>
+                    <view class="_text">
+                    <text></text>
+                    </view>
+                    <image class="_bg" src="{{item.active ? '/images/luck-draw/gift-booth-active.png': '/images/luck-draw/gift-booth.png'}}" />
+                </view>
+
+                <!-- 抽奖按钮 -->
+                <block wx:if="{{forbidTurn}}">
+                    <view class="_gift _turn_btn">
+                        <image class="_bg" src="/images/luck-draw/gift-booth-center-disable.png" />
+                    </view>
+                </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 wx:if="{{isLogin}}" class="_nums">
+                            <text>{{remainNum}}/{{allNum}}</text>
+                        </view>
+                    </view>    
+                </block>
+
+            </view>
+
+        </view>
+
+        <!-- 背景 -->
+        <view class="luck-draw-bg">
+            <image src="/images/luck-draw/gift-box.png" />
+        </view>
+
+    </view>
+
+    <!-- 活动规则 -->
+    <view class="block-item-title">
+        <view/>
+        <text>活动规则</text>
+        <view/>
+    </view>
+    <view class="rule-des">
+        <text>{{ruleDesc}}</text>
+    </view>
+
+    <!-- 中奖名单 -->
+    <view class="block-item-title">
+        <view/>
+        <text>中奖名单</text>
+        <view/>
+    </view>
+    <view class="hit-record-list">
+        <view class="_item" wx:for="{{hitRecordList}}" wx:key="key">
+            <view>{{item.mobile}}</view>
+            <viwe>{{item.goodsName}}</viwe>
+        </view>
+    </view>
+
+    <!-- 中奖对话框 -->
+    <view class="dlg" wx:if="{{showHitPrizeDlg}}">
+        <view class="prize-body">
+            <view class="prize-title">
+                恭喜您中奖了!
+                <image src="/images/luck-draw/hbar.png" />
+            </view>
+            <view class="prize-subtitle">{{hitResult.goodsName}}</view>
+            <view class="prize-figure">
+            <!-- 图片封面 -->
+            <image wx:if="{{hitResult.goodsBigImage}}" src="{{hitResult.goodsBigImage}}" />
+            <image src="/images/luck-draw/gift.png" wx:else />
+            </view>
+            <view class="prize-tip">{{hitResult.hitDesc || ""}}</view>
+            <view class="btns">
+                <view class="_btn _confirm" catchtap="closeDlg">确定</view>
+                <navigator class="_btn _exchange" 
+                target = "miniProgram" 
+                app-id="wxd92a2d29f8022f40"
+                path="pages/index/index"
+                extra-data="{foo: 'bar'}"
+                open-type='navigate'>
+                    去使用
+                </navigator>
+            </view>
+            <image class="_bg" src="/images/luck-draw/hitdlgbg.png" />
+        </view>
+        <view class="_layer" catchtap="closeDlg" />
+    </view>
+
+    <!-- 未中奖对话框 -->
+    <view class="dlg" wx:if="{{showNoHitPrizeDlg}}">
+        <view class="prize-body">
+            <view class="prize-title">
+                再接再厉!
+                <image src="/images/luck-draw/hbar.png" />
+            </view>
+            <view class="prize-subtitle">离奖品只差一个手势~</view>
+            <view class="prize-figure">
+            <image src="/images/luck-draw/nogift.png" />
+            </view>
+            <view class="prize-tip">点击确认继续抽奖!</view>
+            <view class="btns">
+                <view class="_btn _share" catchtap="closeDlg">确认</view>
+            </view>
+            <image class="_bg" src="/images/luck-draw/hitdlgbg.png" />
+        </view>
+        <view class="_layer" catchtap="closeDlg" />
+    </view>
+
+
+    <!-- 需要分享显示 -->
+    <view class="dlg" wx:if="{{showNeedShareDlg}}">
+        <view class="prize-body">
+            <view class="prize-title">
+                再接再厉!
+                <image src="/images/luck-draw/hbar.png" />
+            </view>
+            <view class="prize-subtitle">离奖品只差一个手势~</view>
+            <view class="prize-figure">
+            <image src="/images/luck-draw/nogift.png" />
+            </view>
+            <view class="prize-tip">分享可获得更多抽奖机会!</view>
+            <view class="btns">
+                <button class="_btn _share" open-type="share">分享</button>
+            </view>
+            <image class="_bg" src="/images/luck-draw/hitdlgbg.png" />
+        </view>
+        <view class="_layer" catchtap="closeDlg" />
+    </view>
+
+    <!-- 状态 -->
+    <view wx:if="{{status != 2}}" class="status_tip_layer" catchtap="turnActivityListPage">
+        <view class="_text" wx:if="{{errMessage}}">
+            <view>{{errMessage}}</view>
+        </view>
+        <view wx:elif="{{status == 3}}" class="_text">
+            <view>此活动已结束</view>
+            <view>敬请关注其他活动...</view>
+        </view>
+        <view class="_text" wx:else>
+            <view>距活动开启还剩</view>
+            <view>{{countDownTime}}</view>
+        </view>
+    </view>
+
+</view>
+

+ 445 - 0
pages/luckDraw/detail.wxss

@@ -0,0 +1,445 @@
+/* pages/luckDraw/detail.wxss */
+page {
+    background: #BF2637;
+}
+.head-bg {
+    width: 750rpx;
+    height: 576rpx;
+    position: absolute;
+    left: 0;
+    top: 0;
+    z-index: 1;
+}
+.head-bg image {
+    width: 750rpx;
+    height: 576rpx
+}
+
+.luck-draw-box {
+    width: 680rpx;
+    height: 848rpx;
+    margin: 370rpx auto 0;
+    position: relative;
+    z-index: 2;
+}
+.luck-draw-bg {
+    width: 680rpx;
+    height: 848rpx;
+    position: absolute;
+    left: 0;
+    top: 0;
+    z-index: 0;
+}
+.luck-draw-bg image {
+    width: 680rpx;
+    height: 848rpx;
+}
+.luck-draw-body {
+    width: 680rpx;
+    height: 848rpx;
+    z-index: 2;
+    position: relative;
+}
+.luck-draw-tip {
+    width: 100%;
+    height: 68rpx;
+    margin: auto;
+    padding-top: 116rpx;
+    text-align: center;
+    font-size: 56rpx;
+    font-weight: 800;
+    color: #fff;
+    font-style: italic;
+}
+
+.luck-draw-tip image {
+    height: 46rpx;
+}
+.luck-draw-tip ._niyou {
+    width: 110rpx;
+    margin-right: 6rpx;
+}
+.luck-draw-tip ._ci {
+    width: 56rpx;
+    margin-left: 6rpx;
+}
+.luck-draw-tip ._cjjh {
+    width: 220rpx;
+}
+.luck-draw-tip ._num {
+    height: 38rpx;
+}
+.luck-draw-tip ._0 {
+    width: 40rpx;
+}
+.luck-draw-tip ._1 {
+    width: 18rpx;
+}
+.luck-draw-tip ._2 {
+    width: 40rpx;
+}
+.luck-draw-tip ._3 {
+    width: 42rpx;
+}
+
+.luck-draw-tip ._4 {
+    width: 38rpx;
+}
+
+.luck-draw-tip ._5 {
+    width: 40rpx;
+}
+
+.luck-draw-tip ._6 {
+    width: 40rpx;
+}
+
+.luck-draw-tip ._7 {
+    width: 36rpx;
+}
+
+.luck-draw-tip ._8 {
+    width: 40rpx;
+}
+.luck-draw-tip ._9 {
+    width: 40rpx;
+}
+
+.luck-draw-record-btn {
+    width: 178rpx;
+    height: 38rpx;
+    border-radius: 30rpx;
+    background: #FF7A95;
+    color: #fff;
+    font-size: 24rpx;
+    text-align: center;
+    margin: 20rpx auto;
+}
+
+.luck-draw-gifts {
+    width: 528rpx;
+    height: 510rpx;
+    margin: auto;
+    position: relative;
+}
+
+._gift {
+    position: absolute;
+}
+._pos_0 {
+    left: 0;
+    top: 0;
+}
+._pos_1 {
+    left: 178rpx;
+    top: 0;
+}
+._pos_2 {
+    left: 356rpx;
+    top: 0;
+}
+._pos_3 {
+    left: 0;
+    top: 176rpx;
+}
+._pos_4 {
+    left: 356rpx;
+    top: 176rpx;
+}
+._pos_5 {
+    left: 0;
+    top: 352rpx;
+}
+._pos_6 {
+    left: 178rpx;
+    top: 352rpx;
+}
+._pos_7 {
+    left: 356rpx;
+    top: 352rpx;
+}
+
+._gift ._ico {
+    width: 168rpx;
+    height: 160rpx;
+    position: absolute;
+    left: 0;
+    top: 0;
+    z-index: 1;
+}
+
+._gift ._ico image {
+    width: 168rpx;
+    height: 160rpx;
+}
+
+._gift ._text {
+    height: 24rpx;
+    font-size: 22rpx;
+    line-height: 24rpx;
+    width: 168rpx;
+    position: absolute;
+    text-align: center;
+    z-index: 2;
+    color: #6C4EC2;
+    left: 0;
+    top: 102rpx;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    padding: 0 10rpx;
+    width: 168rpx;
+    box-sizing: border-box;
+}
+
+._gift ._bg {
+    width: 168rpx;
+    height: 160rpx;
+    position: absolute;
+    left: 0;
+    top: 0;
+}
+
+._turn_btn {
+    left: 178rpx;
+    top: 176rpx;
+}
+
+._turn_btn ._nums {
+    width: 168rpx;
+    font-size: 32rpx;
+    font-weight: 800;
+    height: 32rpx;
+    position: absolute;
+    left: 0;
+    top: 88rpx;
+    color: #fff;
+    text-align: center;
+}
+
+.block-item-title {
+    height: 38rpx;
+    line-height: 38rpx;
+    text-align: center;
+    margin: 104rpx auto 80rpx;
+    display: flex;
+    justify-content: center;
+}
+
+.block-item-title view:nth-child(1) {
+    width: 90rpx;
+    height: 1px;
+    position: relative;
+    top: 20rpx;
+    background: linear-gradient(to left, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.5)); 
+}
+.block-item-title text {
+    font-weight: 580;
+    font-size: 40rpx;
+    color: #fff;
+    margin: 0 20rpx;
+}
+.block-item-title view:nth-child(3) {
+    width: 90rpx;
+    height: 1px;
+    background: #fff;
+    position: relative;
+    top: 20rpx;
+    background: linear-gradient(to right, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.5)); 
+}
+
+.rule-des {
+    width: 600rpx;
+    margin: auto;
+    color: #fff;
+    font-size: 28rpx;
+}
+.rule-des view {
+    margin-bottom: 20rpx;
+}
+
+.hit-record-list {
+    width: 600rpx;
+    margin: auto;
+    min-height: 300rpx;
+    max-height: 1000rpx;
+}
+.hit-record-list ._item {
+    display: flex;
+    justify-content: space-between;
+    color: #fff;
+    font-size: 28rpx;
+    height: 60rpx;
+}
+
+/**
+ * 弹出框
+**/
+.dlg {
+    width: 100vw;
+    height: 100vh;
+    z-index: 1001;
+    background: rgba(0, 0, 0, 0.5);
+    left: 0;
+    top: 0;
+    position: fixed;
+}
+.prize-body {
+    width: 630rpx;
+    height: 750rpx;
+    position: absolute;
+    left: calc(100vw / 2 - 630rpx / 2);
+    top: calc(100vh / 2 - 750rpx / 2);
+    z-index: 1;
+}
+.prize-body ._bg {
+    width: 630rpx;
+    height: 750rpx;
+    position: absolute;
+    left: 0;
+    top: 0;
+    z-index: -1;
+}
+
+.prize-title {
+    width: 534rpx;
+    height: 134rpx;
+    position: absolute;
+    left: calc(630rpx / 2 - 534rpx / 2);
+    top: 112rpx;
+    z-index: 0;
+    text-align: center;
+    font-size: 68rpx;
+    color: #F9635F;
+    font-weight: 800;
+    line-height: 134rpx;
+}
+.prize-title image {
+    width: 534rpx;
+    height: 134rpx;
+    position: absolute;
+    left: 0;
+    top: 0;
+    z-index: -1;
+}
+
+.prize-figure {
+    width: 306rpx;
+    height: 216rpx;
+    position: absolute;
+    left: 164rpx;
+    top: 365rpx;
+}
+.prize-figure image {
+    width: 306rpx;
+    height: 216rpx;
+}
+
+.prize-subtitle {
+    width: 100%;
+    height: 35rpx;
+    font-size: 34rpx;
+    color: #fff;
+    line-height: 35rpx;
+    position: absolute;
+    top: 265rpx;
+    left: 0;
+    text-align: center;
+    box-sizing: border-box;
+    padding: 0 120rpx;
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}
+
+.prize-tip {
+    width: 100%;
+    font-size: 30rpx;
+    height: 50rpx;
+    position: absolute;
+    top: 595rpx;
+    left: 0;
+    text-align: center;
+    color: #fff;
+    box-sizing: border-box;
+    padding: 0 60rpx;
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}
+
+.dlg .btns {
+    height: 96rpx;
+    width: 100%;
+    position: absolute;
+    top: 651rpx;
+    display: flex;
+    justify-content:center;
+}
+.dlg .btns ._btn {
+    height: 80rpx;
+    background: #FC7A73;
+    border-radius: 28rpx;
+    line-height: 80rpx;
+    text-align: center;
+    color: #fff;
+    font-size: 36rpx;
+    font-weight: 600;
+    margin: 0 10rpx;
+    box-shadow:rgba(229, 80, 79, 1) 0 0 5px;
+}
+.dlg ._confirm {
+    width: 240rpx;
+}
+.dlg ._exchange {
+    width: 240rpx;
+}
+.dlg ._share {
+    width: 400rpx;
+}
+.dlg button._share {
+    padding: 0;
+    margin: 0;
+}
+
+.dlg ._layer {
+    width: 100vw;
+    height: 100vh;
+    position: absolute;
+    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;
+}
+
+.status_tip_layer {
+    width: 100vw;
+    height: 100vh;
+    position: fixed;
+    z-index: 2000;
+    background:rgba(0,0,0, 0.9);
+    left: 0;
+    top: 0;
+}
+
+.status_tip_layer ._text {
+    color: #fff;
+    width: 100vw;
+    height: 200rpx;
+    position: absolute;
+    left: 0;
+    top: calc(100vh / 2 - 200rpx / 2);
+    text-align: center;
+    color: #FB766F;
+    font-weight: 800;
+    font-size: 60rpx;
+    font-style: italic;
+}

+ 159 - 0
pages/luckDraw/index.js

@@ -0,0 +1,159 @@
+// pages/luckDraw/index.js
+import LuckDraw from '../../api/luck-draw'
+import { parseTime } from '../../utils/util';
+import Common from './common'
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        page: 1,
+        pageSize: 10,
+        lock: false,
+        noResult: false,
+        noMore: false,
+        activityList: []
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        Object.assign(this, Common)
+        this.getActivityList();
+        this.startCountdownTimer()
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    },
+
+    getActivityList: function() {
+        LuckDraw.getActivityList({
+            page: this.data.page,
+            pageSize: this.data.pageSize
+        }).then(res => {
+            if (res.code == 200) {
+                this.drawListView(res.data)
+            }
+            this.data.lock = false
+        }).catch(_ => {
+            this.data.lock = false
+        })
+    },
+
+    drawListView: function(data) {
+        if (!Array.isArray(data) || data.length == 0) {
+            console.log("没有获取到数据");
+            if (this.data.page == 1) {
+                this.setData({
+                    noResult: true
+                })
+            } else {
+                this.setData({
+                    noMore: true
+                })
+            }
+            return
+        }
+        data.forEach(v => {
+            let beginTime = v.beginTime
+            let endTime = v.endTime
+            if (v.timeType == 1 || beginTime == null) {
+                beginTime = ""
+            }
+            if (v.timeType == 1 || endTime == null) {
+                endTime = ""
+            }
+            beginTime && (v._beginTime = parseTime(beginTime, "{y}.{m}.{d} {h}:{i}:{s}"))
+            endTime && (v._endTime = parseTime(endTime, "{y}.{m}.{d} {h}:{i}:{s}"))
+
+            if (v.activityTitle && v.activityTitle.length > 20) {
+                v.activityTitle = v.activityTitle.substr(0, 20) + "..."
+            }
+
+        })
+        this.data.activityList = this.data.activityList.concat(...data)
+        this.setData({
+            activityList: this.data.activityList
+        })
+        this.calcActivityCountdown()
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+        if (this.data.lock || this.data.noMore) {
+            return
+        }
+        this.data.lock = true
+        this.data.page++
+        this.getActivityList()
+    },
+
+    toDetail(e) {
+        const url = "detail?id=" + e.currentTarget.dataset.id
+        wx.redirectTo({
+            url
+        })
+    },
+
+    startCountdownTimer() {
+        setInterval(this.calcActivityCountdown, 1000)
+    },
+
+    calcActivityCountdown() {
+        // 当前时间毫秒数
+        if (this.data.activityList == null || this.data.activityList.length == 0) {
+            return
+        }
+        const now = new Date();
+        this.data.activityList.forEach(v => {
+            if (v.status == 1 || v.status == 4 || v.status == 5) {
+                this.setActivityCountdownTime(now, v)
+            }
+        })
+        this.setData({
+            activityList: this.data.activityList
+        })
+    }
+})

+ 6 - 0
pages/luckDraw/index.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "抽奖活动",
+  "usingComponents": {
+    "tab-bar": "./components/tabbar"
+  }
+}

+ 37 - 0
pages/luckDraw/index.wxml

@@ -0,0 +1,37 @@
+<!--pages/luckDraw/index.wxml-->
+<view>
+
+   <!-- 活动列表 -->
+   <view class="_list">
+       <view class="_item" wx:for="{{activityList}}" wx:key="index" data-id="{{item.id}}" catchtap="toDetail">
+            <view class="_figure">
+               <image mode="aspectFill" src="{{item.fullActivityFigure}}" />
+            </view>
+            <view class="_info">
+                <view class="_base_info">
+                    <view class="_title">{{item.activityTitle}}</view>
+                    <view class="_subtitle">{{item.activitySubtitle}}</view>
+                    <view class="_time" wx:if="{{item.timeType == 1}}">
+                    长期
+                    </view>
+                    <view class="_time" wx:else>{{item._beginTime}}-{{item._endTime}}</view>
+                </view>
+                <view class="_status">
+                    <view wx:if="{{item.status==1||item.status==4||item.status==5}}" class="_status_btn _status{{item.status}}">
+                        <view class="_dtext">即将开始</view>
+                        <view class="_dtime">{{item.countDownTime}}</view>
+                    </view>
+                    <view class="_status_btn _status{{item.status}}" wx:else>{{item.statusText}}</view>
+                </view>
+            </view>
+       </view>
+
+       <view class="_no_result" wx:if="{{noResult}}">———— 暂无抽奖活动|敬请期待 ————</view>
+       <view class="_no_more" wx:if="{{noMore}}">———— 更多活动 | 敬请期待 ————</view>
+
+   </view>
+
+</view>
+
+<!-- 底部导航 -->
+<tab-bar />

+ 122 - 0
pages/luckDraw/index.wxss

@@ -0,0 +1,122 @@
+/* pages/luckDraw/index.wxss */
+page {
+    background: #f0f0f0;
+    padding-bottom: 98rpx;
+}
+
+._list {
+    width: 702rpx;
+    margin: auto;
+    padding-top: 32rpx;
+}
+
+._item {
+    background: #fff;
+    margin-bottom: 28rpx;
+    border-radius: 10rpx;
+    box-sizing: border-box;
+}
+._figure {
+    height: 260rpx;
+    width: 100%;
+    border-radius: 10rpx 10rpx 0 0;
+    overflow: hidden;
+}
+._figure image {
+    height: 260rpx;
+    width: 100%;
+}
+
+._info {
+    display: flex;
+    flex-direction: row;
+    position: relative;
+}
+._base_info {
+    flex: 1;
+}
+._status {
+    width: 210rpx;
+    position: absolute;
+    right: 0;
+    top: 0;
+}
+
+._base_info {
+    padding: 28rpx 28rpx 28rpx 40rpx;
+}
+._title {
+    font-weight: 1000;
+    font-size: 36rpx;
+    color: #000;
+    margin-bottom: 16rpx;
+    width: 390rpx;
+}
+
+._subtitle {
+    font-size: 26rpx;
+    color: #8c8c8c;
+    font-size: 24rpx;
+    margin-bottom: 4rpx;
+    width: 400rpx;
+    height: 32rpx;
+    overflow: hidden;
+    text-overflow:ellipsis;
+    white-space: nowrap;
+}
+._time {
+    font-size: 28rpx;
+    color: #8c8c8c;
+}
+
+._status_btn {
+    width: 174rpx;
+    height: 60rpx;
+    border-radius: 60rpx;
+    line-height: 60rpx;
+    text-align: center;
+    font-size: 30rpx;
+    font-weight: 600;
+    margin: 60rpx 0 0 0;
+}
+._status2 {
+    border: 1rpx solid #CF4F58;
+    background: #FFE3E5;
+    color: #BD1925;
+}
+
+._status1, ._status4, ._status5 {
+    width: 226rpx;
+    height: 78rpx;
+    line-height: normal;
+    border: 1rpx solid #EE7C00;
+    background: #FFE6CB;
+    color: #EE7C00;
+    font-size: 26rpx;
+    position: relative;
+    left: -50rpx;
+    margin: 35rpx 0 0 0;
+}
+
+._status3 {
+    border: 1rpx solid #B1B1B1;
+    background: #F5F5F5;
+    color: #B1B1B1;
+}
+
+._no_more {
+    font-size: 24rpx;
+    color: #B1B1B1;
+    text-align: center;
+    line-height: 100rpx;
+    padding-bottom: 28rpx;
+    font-weight: 1000;
+}
+
+._no_result {
+    font-size: 24rpx;
+    color: #B1B1B1;
+    text-align: center;
+    line-height: 100rpx;
+    font-weight: 1000;
+}

+ 215 - 0
pages/luckDraw/profile.js

@@ -0,0 +1,215 @@
+// pages/luckDraw/profile.js
+import LuckDraw from '../../api/luck-draw'
+import { parseTime } from '../../utils/util'
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../utils/user'
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        page: 1,
+        pageSize: 10,
+        lock: false,
+        noResult: false,
+        noMore: false,
+        isLogin: false,
+        hidden1: false,
+        hidden2: false,
+        mobileTop: 'TONY WU',
+        couponNum: 0,
+        productNum: 0,
+        goodsType: 1,
+        goodsItemList: []
+
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        this.setData({
+            isLogin: getMobileCache() != '',
+            mobileTop:getMobileCache(),
+        })
+        if(this.data.isLogin){
+            this.setData({
+                hidden1: false,
+                hidden2: true,
+            })
+            this.getUserPrizeList();
+        }
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    },
+    getUserPrizeList: function() {
+        LuckDraw.getUserPrizeList({
+            page: this.data.page,
+            pageSize: this.data.pageSize,
+            mobile: getMobileCache(),
+            goodsType: this.data.goodsType
+        }).then(res => {
+            if (res.code == 200) {
+                this.uaerPrizeListView(res.data)
+            }
+            this.data.lock = false
+        }).catch(_ => {
+            console.log(_)
+            this.data.lock = false
+        })
+    },
+
+    uaerPrizeListView: function(data) {
+        if (!Array.isArray(data.goodsItemList) || data.goodsItemList.length == 0) {
+            console.log("数据为空");
+            if (this.data.page == 1) {
+                this.setData({
+                    mobileTop:getMobileCache(),
+                    couponNum: data.couponNum,
+                    productNum: data.productNum,
+                    noResult: true
+                })
+            } else {
+                this.setData({
+                    mobileTop:getMobileCache(),
+                    noMore: true
+                })
+            }
+            return
+        }
+        data.goodsItemList.forEach(v => {
+            let beginTime = v.couponBeginTimestamp
+            let endTime = v.couponEndTimestamp
+            v.couponBeginTimestamp = parseTime(beginTime, "{y}.{m}.{d}")
+            v.couponEndTimestamp = parseTime(endTime, "{y}.{m}.{d}")
+            if(v.couponType == 'D' && v.discount >0){
+                v.discount /= 10
+            }
+            if(v.couponType == 'C' && v.discount >0){
+                v.reduceCost /= 100
+            }
+        })
+
+        if (this.data.page == 1) {
+            this.setData({
+                couponNum: data.couponNum,
+                productNum: data.productNum
+            })
+          }
+        this.data.goodsItemList = this.data.goodsItemList.concat(...data.goodsItemList)
+        this.setData({
+            mobileTop:getMobileCache(),
+            goodsItemList: this.data.goodsItemList
+        })
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+    */
+    onReachBottom: function () {
+        if (this.data.lock || this.data.noMore) {
+            return
+        }
+        this.data.lock = true
+        this.data.page++
+        this.getUserPrizeList()
+    },
+    
+
+    toPrize(e) {
+        const url = "prize?id=" + e.currentTarget.dataset.id
+        wx.redirectTo({
+            url
+        })
+    },
+    getProfile(e) {
+        this.setData({
+            hidden1: false,
+            hidden2: true,
+            page: 1,
+            goodsType: 1,
+            noMore: false,
+            noResult: false
+        })
+        this.data.goodsItemList = [];
+        this.getUserPrizeList()
+    },
+    getPrize(e) {
+
+        this.setData({
+            hidden1: true,
+            hidden2: false,
+            page: 1,
+            goodsType: 2,
+            noMore: false,
+            noResult: false
+        })
+        this.data.goodsItemList = [];
+        this.getUserPrizeList()
+    },
+    turnPrize: function() {
+        console.log("开始查看")
+        if (this.lock || !this.data.isLogin) {
+            return
+        }
+        this.lock = true
+    },
+    // 授权手机号
+    getPhoneNumber(e) {
+        getPhoneNumberSync(e, _ => {
+            this.setData({
+                isLogin: true,
+                mobileTop: getMobileCache(),
+                hidden1: false,
+                hidden2: true,
+            })
+            this.getUserPrizeList()
+        })
+    },
+    toRecordPrize(e) {
+        const url = "recordPrize?id=" + e.currentTarget.dataset.id
+        wx.redirectTo({
+            url
+        })
+    },
+})

+ 6 - 0
pages/luckDraw/profile.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "个人中心",
+  "usingComponents": {
+    "tab-bar": "./components/tabbar"
+  }
+}

+ 127 - 0
pages/luckDraw/profile.wxml

@@ -0,0 +1,127 @@
+<!--pages/luckDraw/profile.wxml-->
+<view class="personal">
+<!-- 个人中心视图 -->
+    <view class="head-bg" catchtap="turnPrize">
+       <image class="image_bg" src="/images/luck-draw/per_head.png" />
+       <image class="image_portrait" src="/images/luck-draw/portrait.png" />
+       <button class="luck-draw-isLogin" wx:if="{{!isLogin}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" >登录</button>
+       <view class="luck-draw-pro-nickname" wx:if="{{isLogin}}">{{phone.toHide(mobileTop)}}</view>
+    </view>
+    <view class="luck-draw-pro-cp">
+      <!-- 优惠券 -->
+      <view class="luck-draw-coupon" catchtap="getProfile">
+        <view class="luck-draw-cn">{{couponNum}}</view>
+        <view class="luck-draw-cz">优惠券</view>
+        <view wx:if="{{goodsType == 1}}" class="luck-draw-cjh"><view class="luck-draw-cj"></view></view>
+      </view>
+      <!-- 奖品 -->
+      <view class="luck-draw-prize" catchtap="getPrize">
+        <view class="luck-draw-pn">{{productNum}}</view>
+        <view class="luck-draw-pz">奖品</view>
+        <view wx:if="{{goodsType == 2}}" class="luck-draw-cjh"><view class="luck-draw-cj"></view></view>
+      </view>
+    </view>
+    <view id="couponZD" class="luck-draw-theme" hidden="{{hidden1}}">
+      <!-- 折扣券 -->
+      <view class="luck-draw-content" wx:for="{{goodsItemList}}" wx:key="index" data-id="{{item.id}}" >
+        <view class="luck-draw-words">
+          <view class="luck-draw-discount1">
+            <view class="{{item.formatDiscoun.length > 3?'luck-draw-zkz4c':'luck-draw-zkz4'}}" wx:if="{{item.couponType == 'D'}}">{{item.formatDiscount ?item.formatDiscount:0}}</view>
+            <view class="{{item.formatDiscoun.length > 3?'luck-draw-zkz5c':'luck-draw-zkz5'}}" wx:if="{{item.couponType == 'D'}}">折</view>
+
+            <view class="luck-draw-djz4" wx:if="{{item.couponType == 'C'}}">¥</view>
+            <view class="{{item.formatReduceCost.length > 3 ?'luck-draw-djz5c':'luck-draw-djz5'}}" wx:if="{{item.couponType == 'C'}}">{{item.formatReduceCost ?item.formatReduceCost:0}}</view>
+          </view>
+          <view class="luck-draw-discount2">
+            <view class="luck-draw-zkz1">{{item.goodsName}}</view>
+           <view class="luck-draw-mj">
+            <view class="luck-draw-zkz21"></view>
+            <view class="luck-draw-zkz2" wx:if="{{item.formatLeastCost == '0'}}">无门槛</view>
+            <view class="luck-draw-zkz2" wx:if="{{item.formatLeastCost != '0'}}">满{{item.formatLeastCost}}使用</view>
+            <view class="luck-draw-zkz22"></view>
+           </view>
+            <view class="luck-draw-zkz3">{{item.couponBeginTimestamp}}-{{item.couponEndTimestamp}}</view>
+          </view>
+        </view>
+        <image wx:if="{{item.couponType == 'D'}}" class="image_zk" src="/images/luck-draw/coupon1.png" />
+        <image wx:if="{{item.couponType == 'D'}}" class="image_zk_un" src="/images/luck-draw/coupon_use_now.png" />
+
+        <image wx:if="{{item.couponType == 'C'}}" class="image_zk" src="/images/luck-draw/cash_coupon.png" />
+        <image wx:if="{{item.couponType == 'C'}}" class="image_zk_un" src="/images/luck-draw/cc_use_now.png" />
+        <navigator class="_btn _exchange" 
+            target = "miniProgram" 
+            app-id="wxd92a2d29f8022f40"
+            path="pages/index/index"
+            extra-data="{foo: 'bar'}"
+            open-type='navigate'> 
+            </navigator>
+      </view>
+      <!-- 代金券 
+      <view class="luck-draw-content" wx:for="{{goodsItemList}}" wx:key="index" data-id="{{item.id}}" wx:if="{{item.couponType == 'C' && item.goodsType == 1}}">
+        <image class="image_zk" src="/images/luck-draw/cash_coupon.png" />
+        <image class="image_zk_un" src="/images/luck-draw/cc_use_now.png" />
+            <navigator class="_btn _exchange" 
+            target = "miniProgram" 
+            app-id="wxd92a2d29f8022f40"
+            path="page/index/index"
+            open-type='navigate'> 
+            </navigator>
+        <view class="luck-draw-words">
+          <view class="luck-draw-discount1">
+            <view class="luck-draw-djz4">¥</view>
+            <view class="luck-draw-djz5">{{item.formatReduceCost ?item.formatReduceCost:0}}</view>
+          </view>
+          <view class="luck-draw-discount2">
+            <view class="luck-draw-zkz1">{{item.goodsName}}</view>
+           <view class="luck-draw-mj">
+            <view class="luck-draw-zkz21"></view>
+            <view class="luck-draw-zkz2" wx:if="{{item.formatLeastCost == '0'}}">无门槛</view>
+            <view class="luck-draw-zkz2" wx:if="{{item.formatLeastCost != '0'}}">满{{item.formatLeastCost}}使用</view>
+            <view class="luck-draw-zkz22"></view>
+           </view>
+            <view class="luck-draw-zkz3">{{item.couponBeginTimestamp ?item.couponBeginTimestamp:0}}-{{item.couponEndTimestamp ?item.couponEndTimestamp:0}}</view>
+          </view>
+        </view>
+      </view> -->
+      
+      <view class="no_result" wx:if="{{noResult}}">———— 抱歉,您暂无可用优惠券 ————</view>
+      <view class="no_result" wx:if="{{noMore}}">———— 更多优惠券 | 敬请期待 ————</view>
+    </view>
+
+    <view id="prize" class="luck-draw-theme" hidden="{{hidden2}}">
+      <!-- 奖品 -->
+      <view class="luck-draw-content" wx:for="{{goodsItemList}}" wx:key="index" data-id="{{item.id}}" wx:if="{{item.goodsType == 2}}">
+        <view class="luck-draw-wordsj">
+          <view class="luck-draw-discount1j">
+           
+            <image class="luck-draw-zkzj" src="/images/luck-draw/prize.png" />
+          </view>
+          <view class="luck-draw-discount2">
+            <view class="luck-draw-zkz1j">{{item.goodsName}}</view>
+            <view class="luck-draw-zkz3j">奖品参数</view>
+          </view>
+        </view>
+        <image class="image_zk_unj" src="/images/luck-draw/choice.png" />
+        <navigator class="_btn _exchange" 
+            target = "miniProgram" 
+            app-id="wxd92a2d29f8022f40"
+            path="pages/index/index"
+            extra-data="{foo: 'bar'}"
+            open-type='navigate'> 
+            </navigator>
+      </view>
+      <view class="no_result" wx:if="{{noResult}}">———— 抱歉,您暂无可领取奖品 ————</view>
+      <view class="no_result" wx:if="{{noMore}}">———— 更多奖品 | 敬请期待 ————</view>
+    </view>
+</view>
+
+<!-- 使用wxs 手机号码中间四位显示为*号 -->
+<wxs module="phone">
+var toHide = function(array) {
+  var mphone = array.substring(0, 3) + '****' + array.substring(7);
+  return mphone;
+}
+module.exports.toHide = toHide;
+</wxs>
+<!-- 底部导航 -->
+<tab-bar />

+ 332 - 0
pages/luckDraw/profile.wxss

@@ -0,0 +1,332 @@
+/* pages/luckDraw/profile.wxss */
+.personal{
+  width: 750rpx;
+  height: auto;
+  padding-bottom: 119rpx;
+}
+
+.head-bg{
+  width: 750rpx;
+  height: 464rpx;
+}
+.image_bg{
+  width: 750rpx;
+  height: 464rpx;
+  position: absolute;
+  left: 0;
+  top: 0;
+  z-index: 1;
+}
+
+.image_portrait{
+  width: 140rpx;
+  height: 144rpx;
+  position: relative;
+  z-index: 2;
+  left: 304rpx;
+  top: 170rpx;
+}
+
+.luck-draw-pro-nickname{
+  width: 750rpx;
+  height: 50rpx;
+  font-size: 40rpx;
+  font-family: Source Han Sans CN;
+  font-weight: 500;
+  color: #FEFEFE;
+  position: relative;
+  z-index: 2;
+  text-align: center;
+  top: 180rpx;
+}
+
+.luck-draw-pro-cp{
+  width: 750rpx;
+  height: 180rpx;
+}
+
+.luck-draw-coupon,.luck-draw-prize{
+  display: inline-block;
+  width: 50%;
+  height: 100%;
+}
+.luck-draw-cn,.luck-draw-cz,.luck-draw-pn,.luck-draw-pz,.luck-draw-cjh{
+  text-align: center;
+}
+.luck-draw-cn,.luck-draw-pn{
+  margin-top: 30rpx;
+  font-size: 36rpx;
+  font-family: Source Han Sans CN;
+  font-weight: 500;
+  color: #BF2637;
+}
+.luck-draw-cz,.luck-draw-pz{
+  font-size: 32rpx;
+  font-family: Source Han Sans CN;
+  font-weight: 400;
+  color: #303030;
+}
+.luck-draw-cj{
+  width: 78rpx;
+  height: 6rpx;
+  background: #BF2637;
+  border-radius: 4rpx;
+  margin: 10rpx auto;
+}
+
+.luck-draw-content{
+  width: 708rpx;
+  height: 220rpx;
+  position: relative;
+  margin: 0 auto 20rpx;
+}
+.image_zk{
+  width: 708rpx;
+  height: 220rpx;
+  position: absolute;
+  z-index: 1;
+  left: 0;
+  top: 0;
+}
+
+.image_zk_un{
+  display: inline-block;
+  width: 162rpx;
+  height: 56rpx;
+  position:absolute;
+  z-index: 3;
+  bottom: 70rpx;
+  right: 26rpx;
+}
+
+.image_zk_unj{
+  display: inline-block;
+  width: 162rpx;
+  height: 56rpx;
+  position:absolute;
+  z-index: 2;
+  bottom: 70rpx;
+  right: 26rpx;
+}
+._btn {
+  display: inline-block;
+  width: 162rpx;
+  height: 56rpx;
+  position:absolute;
+  z-index: 3;
+  bottom: 70rpx;
+  right: 26rpx;
+}
+
+.luck-draw-discount1,.luck-draw-discount2,.luck-draw-zkz21,.luck-draw-zkz22,.luck-draw-zkz2{
+  display: inline-block;
+}
+
+.luck-draw-zkz4, .luck-draw-zkz5, .luck-draw-djz4,.luck-draw-djz5,.luck-draw-zkz4c, .luck-draw-zkz5c, .luck-draw-djz4c,.luck-draw-djz5c {
+  display: inline;
+}
+
+.luck-draw-discountj,.luck-draw-zkzj{
+  display: inline-block;
+}
+.luck-draw-words{
+  position:relative;
+  z-index: 2;
+  width: 708rpx;
+  height: 220rpx;
+  display: flex;
+  flex-direction: row;
+}
+
+.luck-draw-wordsj{
+  position:relative;
+  z-index: 2;
+  width: 708rpx;
+  height: 220rpx;
+  display: flex;
+  flex-direction: row;
+  background: #FFFFFF;
+  border: 0.5rpx solid #FF7A03;
+  box-shadow: 0rpx 0rpx 50rpx 8rpx rgba(127, 127, 127, 0.09);
+  border-radius: 20rpx;
+}
+
+.luck-draw-discount1{
+  width: 208rpx;
+  height: 100%;
+  text-align: center;
+  line-height: 220rpx;
+}
+.luck-draw-discount1j{
+  width: 214rpx;
+  height: 220rpx;
+  background: #FFE9B0;
+  border: 0rpx solid #FF7A03;
+  border-radius: 20rpx 0 0 20rpx;
+  text-align: center;
+}
+.luck-draw-discount1 view:nth-child(1) {
+  position: relative;
+  top: 60rpx;
+}
+
+.luck-draw-discountj view:nth-child(1) {
+  position: relative;
+  top: 40rpx;
+}
+
+.luck-draw-discount1 view:nth-child(2) {
+  position: relative;
+  top: 60rpx;
+}
+
+.luck-draw-discount2{
+  width: 500rpx;
+  height: 100%;
+}
+
+.luck-draw-zkz4 {
+  font-size: 90rpx;
+  font-family: Impact;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 142rpx;
+}
+
+.luck-draw-zkz4c {
+  font-size: 70rpx;
+  font-family: Impact;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 142rpx;
+}
+
+.luck-draw-djz5{
+  font-size: 90rpx;
+  font-family: Impact;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 142rpx;
+}
+
+.luck-draw-djz5c{
+  font-size: 70rpx;
+  font-family: Impact;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 142rpx;
+}
+
+.luck-draw-zkzj{
+  width: 134rpx;
+  height: 106rpx;
+  position: relative;
+  top: 55rpx;
+}
+
+.luck-draw-zkz5,.luck-draw-djz4{
+  font-size: 40rpx;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 48rpx;
+}
+
+.luck-draw-zkz5c,.luck-draw-djz4c{
+  font-size: 30rpx;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 48rpx;
+}
+
+.luck-draw-zkz1{
+  font-size: 40rpx;
+  font-family: Source Han Sans CN;
+  font-weight: 500;
+  color: #443E5B;
+  line-height: 32rpx;
+  margin-top: 48rpx;
+  margin-left: 48rpx;
+}
+
+.luck-draw-zkz1j{
+  font-size: 40rpx;
+  font-family: Source Han Sans CN;
+  font-weight: 500;
+  color: #443E5B;
+  line-height: 40rpx;
+  margin-top: 48rpx;
+  margin-left: 48rpx;
+}
+
+.luck-draw-mj{
+  margin-left: 48rpx;
+  margin-top: 20rpx;
+  margin-bottom: 20rpx;
+}
+.luck-draw-zkz2{
+  font-size: 26rpx;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 32rpx;
+}
+.luck-draw-zkz21,.luck-draw-zkz22{
+  width: 14rpx;
+  height: 14rpx;
+  background: #443E5B;
+  transform:rotate(45deg);
+  margin: 0 10rpx;
+}
+.luck-draw-zkz3{
+  font-size: 26rpx;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 32rpx;
+  margin-left: 48rpx;
+}
+
+.luck-draw-zkz3j{
+  font-size: 26rpx;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 32rpx;
+  line-height: 32rpx;
+  margin-left: 48rpx;
+  margin-top: 30rpx;
+}
+
+.no_result {
+  font-size: 24rpx;
+  color: #B1B1B1;
+  text-align: center;
+  line-height: 100rpx;
+  font-weight: 1000;
+}
+
+.luck-draw-isLogin{
+  background-color: transparent;
+  width: 750rpx;
+  height: 70rpx;
+  font-size: 40rpx;
+  font-family: Source Han Sans CN;
+  font-weight: 500;
+  color: #FEFEFE;
+  position: relative;
+  z-index: 2;
+  text-align: center;
+  top: 180rpx;
+}
+
+.btns {
+  height: 96rpx;
+  width: 100%;
+  position: absolute;
+  top: 651rpx;
+  display: flex;
+  justify-content:center;
+  z-index: 3;
+}

+ 166 - 0
pages/luckDraw/recordPrize.js

@@ -0,0 +1,166 @@
+// pages/luckDraw/recordPrize.js
+import LuckDraw from '../../api/luck-draw'
+import { parseTime } from '../../utils/util'
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../utils/user'
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        page: 1,
+        pageSize: 10,
+        lock: false,
+        noResult: false,
+        noMore: false,
+        isLogin: false,
+        mobileTop: 'TONY WU',
+        userDrawItemList: []
+
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        if (!options.activityId) {
+            this.popMessage ('入参错误');
+            wx.navigateTo({
+              url: './index',
+            })
+            return
+        }
+        this.data.activityId = options.activityId
+        this.setData({
+            isLogin: getMobileCache() != ''
+        })
+        if(this.data.isLogin){
+            this.getUserDrawRecord();
+        }
+        
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    },
+    getUserDrawRecord: function() {
+        LuckDraw.getUserDrawRecord({
+            page: this.data.page,
+            pageSize: this.data.pageSize,
+            mobile: getMobileCache(),
+            activityId: this.data.activityId,
+        }).then(res => {
+            if (res.code == 200) {
+                this.uaerPrizeListView(res.data)
+            }
+            this.data.lock = false
+        }).catch(_ => {
+            console.log(_)
+            this.data.lock = false
+        })
+    },
+
+    uaerPrizeListView: function(data) {
+        if (!Array.isArray(data) || data.length == 0) {
+            console.log("抽奖记录数据为空");
+            if (this.data.page == 1) {
+                this.setData({
+                    noResult: true
+                })
+            } else {
+                this.setData({
+                    noMore: true
+                })
+            }
+            return
+        }
+        data.forEach(v => {
+            let beginTime = v.couponBeginTimestamp
+            let endTime = v.couponEndTimestamp
+            let createTime = v.createTime
+            v.couponBeginTimestamp = parseTime(beginTime, "{y}.{m}.{d}")
+            v.couponEndTimestamp = parseTime(endTime, "{y}.{m}.{d}")
+            v.createTime = parseTime(createTime, "{y}.{m}.{d} {h}:{i}")
+        })
+
+        this.data.userDrawItemList = this.data.userDrawItemList.concat(...data)
+        this.setData({
+            userDrawItemList: this.data.userDrawItemList
+        })
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+        if (this.data.lock || this.data.noMore) {
+            return
+        }
+        this.data.lock = true
+        this.data.page++
+        this.getUserDrawRecord()
+    },
+    
+
+   toRecordPrize(e) {
+        const url = "recordPrize?id=" + e.currentTarget.dataset.id
+        wx.redirectTo({
+            url
+        })
+    },
+    turnPrize: function() {
+        console.log("开始查看")
+        if (this.isLock || !this.data.isLogin) {
+            return
+        }
+    },
+    // 授权手机号
+    getPhoneNumber(e) {
+        getPhoneNumberSync(e, _ => {
+            this.setData({
+                isLogin: true,
+                mobileTop:getMobileCache(),
+            })
+            console.log(this.data.mobileTop)
+            this.getUserDrawRecord()
+        })
+    },
+})

+ 6 - 0
pages/luckDraw/recordPrize.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "抽奖记录",
+  "usingComponents": {
+    "tab-bar": "./components/tabbar"
+  }
+}

+ 39 - 0
pages/luckDraw/recordPrize.wxml

@@ -0,0 +1,39 @@
+<!--pages/luckDraw/recordPrize.wxml-->
+<view class="personal">
+<!-- 中奖记录 -->
+    <view class="luck-draw-theme" catchtap="turnPrize">
+      <button class="luck-draw-cz" wx:if="{{!isLogin}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" >请登录</button>
+      <!-- 奖品 -->
+      <view class="luck-draw-content" wx:for="{{userDrawItemList}}" wx:key="index" data-id="{{item.id}}">
+        <view class="luck-draw-words" wx:if="{{item.isHit == 1}}">
+          <view class="luck-draw-discount1">
+            
+            <image class="luck-draw-zkz5" src="/images/luck-draw/recordPrize.png" />
+          </view>
+          <view class="luck-draw-discount2">
+            <view class="luck-draw-zkz1">{{item.goodsName}}</view>
+            <view class="luck-draw-zkz3">{{item.createTime}}</view>
+          </view>
+        </view>
+
+        <view class="luck-draw-words1" wx:if="{{item.isHit != 1}}">
+          <view class="luck-draw-discount12">
+            
+            <image class="luck-draw-zkz52" src="/images/luck-draw/prizeNo.png" />
+          </view>
+          <view class="luck-draw-discount2">
+            <view class="luck-draw-zkz1"><text decode="true">很遗憾!您没中奖&gt;&lt;</text></view>
+            <view class="luck-draw-zkz3">{{item.createTime}}</view>
+          </view>
+        </view>
+      </view>
+      <view class="no_result" wx:if="{{noResult}}">———— 抱歉,您暂无抽奖记录 ————</view>
+      <view class="no_result" wx:if="{{noMore}}">———— 更多抽奖 | 敬请期待 ————</view>
+    </view>
+</view>
+
+
+<!-- 底部导航 -->
+<tab-bar />
+
+

+ 179 - 0
pages/luckDraw/recordPrize.wxss

@@ -0,0 +1,179 @@
+/* pages/luckDraw/recordPrize.wxss */
+.personal{
+  width: 750rpx;
+  height: auto;
+  padding-bottom: 119rpx;
+}
+
+.luck-draw-coupon,.luck-draw-prize{
+  display: inline-block;
+  width: 50%;
+  height: 100%;
+}
+.luck-draw-cn,.luck-draw-cz,.luck-draw-pn,.luck-draw-pz,.luck-draw-cjh{
+  text-align: center;
+}
+.luck-draw-cn,.luck-draw-pn{
+  margin-top: 30rpx;
+  font-size: 36rpx;
+  font-family: Source Han Sans CN;
+  font-weight: 500;
+  color: #BF2637;
+}
+.luck-draw-cz,.luck-draw-pz{
+  font-size: 32rpx;
+  font-family: Source Han Sans CN;
+  font-weight: 400;
+  color: #303030;
+}
+.luck-draw-cj{
+  width: 78rpx;
+  height: 6rpx;
+  background: #BF2637;
+  border-radius: 4rpx;
+  margin: 10rpx auto;
+}
+
+.luck-draw-content{
+  width: 708rpx;
+  height: 190rpx;
+  position: relative;
+  margin: 0 auto 20rpx;
+}
+.image_zk{
+  width: 708rpx;
+  height: 190rpx;
+  position: absolute;
+  z-index: 1;
+  left: 0;
+  top: 0;
+}
+
+.image_zk_un{
+  display: inline-block;
+  width: 162rpx;
+  height: 56rpx;
+  position:absolute;
+  z-index: 2;
+  bottom: 70rpx;
+  right: 26rpx;
+}
+.luck-draw-discount1,.luck-draw-discount2,.luck-draw-zkz2,.luck-draw-djz4,.luck-draw-djz5{
+  display: inline-block;
+}
+.luck-draw-words{
+  position:relative;
+  z-index: 2;
+  width: 708rpx;
+  height: 190rpx;
+  display: flex;
+  flex-direction: row;
+  background: #FFFFFF;
+  border: 0.5rpx solid #FF7A03;
+  box-shadow: 0 0 50rpx 8rpx rgba(127, 127, 127, 0.09);
+  border-radius: 20rpx;
+}
+
+.luck-draw-words1{
+  position:relative;
+  z-index: 2;
+  width: 708rpx;
+  height: 190rpx;
+  display: flex;
+  flex-direction: row;
+  background: #FFFFFF;
+  border: 0.5rpx solid #878787;
+  box-shadow: 0 0 50rpx 8rpx rgba(127, 127, 127, 0.09);
+  border-radius: 20rpx;
+}
+
+.luck-draw-discount1{
+  width: 214rpx;
+  height: 190rpx;
+  background: #FFE9B0;
+  border-right: 0.5rpx solid #FF7A03;
+  border-radius: 20rpx 0 0 20rpx;
+  text-align: center;
+}
+.luck-draw-discount12{
+  width: 214rpx;
+  height: 190rpx;
+  background: #F4F4F4;
+  border-right: 0.5rpx solid #878787;
+  border-radius: 20rpx 0 0 20rpx;
+  text-align: center;
+}
+
+.luck-draw-discount1 view:nth-child(1) {
+  position: relative;
+  top: 40rpx;
+}
+
+.luck-draw-discount2{
+  width: 500rpx;
+  height: 100%;
+}
+
+.luck-draw-zkz4{
+  font-size: 32rpx;
+  font-family: YouSheBiaoTiHei;
+  font-weight: 400;
+  color: #FF7A03;
+  line-height: 44rpx;
+}
+
+.luck-draw-zkz42{
+  font-size: 28rpx;
+  font-family: YouSheBiaoTiHei;
+  font-weight: 400;
+  color: #888888;
+  line-height: 44rpx;
+}
+
+.luck-draw-zkz5{
+  width: 116rpx;
+  height: 92rpx;
+  position: relative;
+  top: 50rpx;
+}
+
+.luck-draw-zkz52{
+  width: 84rpx;
+  height: 80rpx;
+  position: relative;
+  top: 55rpx;
+}
+
+.luck-draw-zkz1{
+  font-size: 32rpx;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 32rpx;
+  margin-top: 48rpx;
+  margin-left: 48rpx;
+}
+.luck-draw-mj{
+  margin-left: 48rpx;
+  margin-top: 20rpx;
+  margin-bottom: 20rpx;
+}
+
+.luck-draw-zkz3{
+  font-size: 26rpx;
+  font-family: Microsoft YaHei;
+  font-weight: 400;
+  color: #443E5B;
+  line-height: 32rpx;
+  line-height: 32rpx;
+  margin-left: 48rpx;
+  margin-top: 30rpx;
+}
+
+.no_result {
+  font-size: 24rpx;
+  color: #B1B1B1;
+  text-align: center;
+  line-height: 100rpx;
+  font-weight: 1000;
+}

+ 18 - 0
project.private.config.json

@@ -71,6 +71,24 @@
           "pathName": "pages/welfareMall/activityInfo/activityInfo",
           "query": "activityId=dl5v9NpmWQ",
           "scene": null
+        },
+        {
+          "name": "pages/luckDraw/detail",
+          "pathName": "pages/luckDraw/detail",
+          "query": "id=8",
+          "scene": null
+        },
+        {
+          "name": "pages/luckDraw/index",
+          "pathName": "pages/luckDraw/index",
+          "query": "",
+          "scene": null
+        },
+        {
+          "name": "pages/luckDraw/profile",
+          "pathName": "pages/luckDraw/profile",
+          "query": "",
+          "scene": null
         }
       ]
     }

+ 11 - 7
utils/request.js

@@ -4,9 +4,9 @@ class request {
     //本地的
     // static BASE_URL = 'http://localhost:8014/'
 //   pre环境的
-  static BASE_URL = 'https://oapi.shpr.top/'
+//   static BASE_URL = 'https://oapi.shpr.top/'
 //   正式的
-//   static BASE_URL = 'https://vapi.hsayi.com/'
+  static BASE_URL = 'https://vapi.hsayi.com/'
 //   @todo需要修改正式的域名
 
   static HEAD = {
@@ -37,9 +37,9 @@ class request {
   /**
    * POST类型的网络请求
    */
-  static postRequest(url, data) {
+  static postRequest(url, data, notUseLoading) {
       let  headerSign = this.getSignHead();
-      return this.requestAll(url, data, headerSign, 'POST')
+      return this.requestAll(url, data, headerSign, 'POST', notUseLoading)
   }
 
   static upload(url, name, path, ortherData, header = this.HEAD){
@@ -93,12 +93,15 @@ class request {
     }
     return signHeadInfo;
   }
+
+
   /**
    * 网络请求
    */
-  static requestAll(url, data, header, method) {
-     
-      wx.showLoading()
+  static requestAll(url, data, header, method, notUseLoading) {
+      if (!notUseLoading) {
+        wx.showLoading()
+      }
       return new Promise((resolve, reject) => {
           wx.request({
               url: url,
@@ -113,6 +116,7 @@ class request {
                   } else {
                     wx.showToast({
                         title: res?.data?.msg,
+                        icon: "none"
                     })
                       //其它错误,提示用户错误信息
                       if (this._errorHandler != null) {

+ 2 - 1
utils/util.js

@@ -144,5 +144,6 @@ module.exports = {
   getUnixTime,
   format,
   add0,
-  getQueryVariable
+  getQueryVariable,
+  parseTime
 }