Browse Source

Merge remote-tracking branch 'origin/bobo/feat/sign-in' into bobo/feat/sign-in

# Conflicts:
#	pages/signIn/activity/activity.json
bobo 3 years ago
parent
commit
536e81695e
3 changed files with 441 additions and 21 deletions
  1. 281 1
      pages/signIn/record/record.js
  2. 59 18
      pages/signIn/record/record.wxml
  3. 101 2
      pages/signIn/record/record.wxss

+ 281 - 1
pages/signIn/record/record.js

@@ -1,10 +1,33 @@
 // pages/signIn/record/record.js
+import SignIn from '../../../api/signIn'
+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,
+        noCoupon: false,
+        noDetail: false,
+        noUtility: false,
+        isLogin: false,
+        hiddenCoupon: false,
+        hiddenDetail: false,
+        hiddenUtility: false,
+        mobileTop: 'TONY WU',
+        couponNum: 0,
+        productNum: 0,
+        activityId: 1,
+        couponList: [],
+        detailList: [],
+        stateList: [],
+        notUseNum: 0
 
     },
 
@@ -12,7 +35,259 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        this.setData({
+            isLogin: getMobileCache() != ''
+        })
+        if(this.data.isLogin){
+            this.setData({
+                hiddenCoupon: false,
+                hiddenDetail: true,
+                hiddenUtility: true,
+                noCoupon: true,
+                noDetail: false,
+                noUtility: false,
+            })
+            this.getUserAwardCouponList();
+            this.getUserAwardCouponNum();
+            this.getUserSignInList();
+            this.getCouponStateList();
+        }
+        
+    },
+
+    // 优惠券数据
+    getUserAwardCouponList: function() {
+        SignIn.getUserAwardCouponList({
+            page: this.data.page,
+            pageSize: this.data.pageSize,
+            mobile: "16602120168",
+            activityId: this.data.activityId
+        }).then(res => {
+            if (res.code == 200) {
+                this.userCouponListView(res.data)
+            }
+            this.data.lock = false
+        }).catch(_ => {
+            console.log(_)
+            this.data.lock = false
+        })
+    },
+
+    userCouponListView: function(data) {
+        if (!Array.isArray(data) || data.length == 0) {
+            console.log("优惠券数据为空");
+            if (this.data.page == 1) {
+                this.setData({
+                    mobileTop:getMobileCache(),
+                    noResult: true
+                })
+            } else {
+                this.setData({
+                    mobileTop:getMobileCache(),
+                    noMore: true
+                })
+            }
+            return
+        }
+        data.forEach(v => {
+            let beginTime = v.coupon.couponBeginTimestamp
+            let endTime = v.coupon.couponEndTimestamp
+            v.coupon.couponBeginTimestamp = parseTime(beginTime, "{y}.{m}.{d}")
+            v.coupon.couponEndTimestamp = parseTime(endTime, "{y}.{m}.{d}")
+        })
+
+        this.data.couponList = this.data.couponList.concat(...data)
+        this.setData({
+            mobileTop:getMobileCache(),
+            couponList: this.data.couponList
+        })
+    },
 
+    //未使用的券数量
+    getUserAwardCouponNum: function() {
+        SignIn.getUserAwardCouponNum({
+            page: this.data.page,
+            pageSize: this.data.pageSize,
+            mobile: "16602120168",
+            activityId: this.data.activityId
+        }).then(res => {
+            if (res.code == 200) {
+                this.setData({
+                    notUseNum: res.data.notUseNum
+                })
+            }
+            this.data.lock = false
+        }).catch(_ => {
+            console.log(_)
+            this.data.lock = false
+        })
+    },
+
+    // 签到明细
+    getUserSignInList: function() {
+        SignIn.getUserSignInList({
+            page: this.data.page,
+            pageSize: this.data.pageSize,
+            mobile: "16602120168",
+            activityId: this.data.activityId
+        }).then(res => {
+            if (res.code == 200) {
+                this.userDetailListView(res.data)
+            }
+            this.data.lock = false
+        }).catch(_ => {
+            console.log(_)
+            this.data.lock = false
+        })
+    },
+
+    userDetailListView: function(data) {
+        if (!Array.isArray(data) || data.length == 0) {
+            console.log("获取明细数据为空");
+            if (this.data.page == 1) {
+                this.setData({
+                    mobileTop:getMobileCache(),
+                    noResult: true
+                })
+            } else {
+                this.setData({
+                    mobileTop:getMobileCache(),
+                    noMore: true
+                })
+            }
+            return
+        }
+        data.forEach(v => {
+            let crateTime = v.crateTime
+            v.crateTime = parseTime(crateTime, "{y}-{m}-{d} {h}:{i}")
+        })
+
+        this.data.detailList = this.data.detailList.concat(...data)
+        this.setData({
+            mobileTop:getMobileCache(),
+            detailList: this.data.detailList
+        })
+    },
+
+    // 使用失效
+    getCouponStateList: function() {
+        SignIn.getUserAwardCouponUseStateList({
+            page: this.data.page,
+            pageSize: this.data.pageSize,
+            mobile: "16602120168",
+            activityId: this.data.activityId
+        }).then(res => {
+            if (res.code == 200) {
+                this.userStateListView(res.data)
+            }
+            this.data.lock = false
+        }).catch(_ => {
+            console.log(_)
+            this.data.lock = false
+        })
+    },
+
+    userStateListView: function(data) {
+        if (!Array.isArray(data) || data.length == 0) {
+            console.log("使用失效数据为空");
+            if (this.data.page == 1) {
+                this.setData({
+                    mobileTop:getMobileCache(),
+                    noResult: true
+                })
+            } else {
+                this.setData({
+                    mobileTop:getMobileCache(),
+                    noMore: true
+                })
+            }
+            return
+        }
+        data.forEach(v => {
+            let crateTime = v.crateTime
+            v.crateTime = parseTime(crateTime, "{y}-{m}-{d} {h}:{i}")
+        })
+
+        this.data.stateList = this.data.stateList.concat(...data)
+        this.setData({
+            mobileTop:getMobileCache(),
+            stateList: this.data.stateList
+        })
+    },
+
+    // 授权手机号
+    getPhoneNumber(e) {
+        getPhoneNumberSync(e, _ => {
+            this.setData({
+                isLogin: true,
+                mobileTop: getMobileCache(),
+                // hidden1: false,
+                // hidden2: true,
+            })
+            this.getUserAwardCouponList();
+            this.getUserAwardCouponNum();
+            this.getUserSignInList();
+            this.getCouponStateList();
+        })
+    },
+
+    // 优惠券
+    getCoupon(e) {
+        this.setData({
+            hiddenCoupon: false,
+            hiddenDetail: true,
+            hiddenUtility: true,
+            page: 1,
+            goodsType: 1,
+            noMore: false,
+            noResult: false,
+            noCoupon: true,
+            noDetail: false,
+            noUtility: false,
+        })
+        this.data.couponList= [],
+        this.data.detailList= [],
+        this.data.stateList= [],
+        this.getUserAwardCouponList()
+    },
+    //明细
+    getDetail(e) {
+        this.setData({
+            hiddenCoupon: true,
+            hiddenDetail: false,
+            hiddenUtility: true,
+            page: 1,
+            goodsType: 2,
+            noMore: false,
+            noResult: false,
+            noDetail: true,
+            noCoupon: false,
+            noUtility: false,
+        })
+        this.data.couponList= [],
+        this.data.detailList= [],
+        this.data.stateList= [],
+        this.getUserSignInList()
+            
+    },
+   //使用失效
+    getUtility(e) {
+        this.setData({
+            hiddenCoupon: true,
+            hiddenDetail: true,
+            hiddenUtility: false,
+            page: 1,
+            goodsType: 2,
+            noMore: false,
+            noResult: false,
+            noUtility: true,
+            noCoupon: false,
+            noDetail: false,
+        })
+        this.data.couponList= [],
+        this.data.detailList= [],
+        this.data.stateList= [],
+        this.getCouponStateList()
     },
 
     /**
@@ -54,7 +329,12 @@ Page({
      * 页面上拉触底事件的处理函数
      */
     onReachBottom: function () {
-
+        if (this.data.lock || this.data.noMore) {
+            return
+        }
+        this.data.lock = true
+        this.data.page++
+        this.getUserAwardCouponList()
     },
 
     /**

+ 59 - 18
pages/signIn/record/record.wxml

@@ -2,22 +2,24 @@
 <view class="record flex-column">
   <!-- 首部信息 -->
   <view class="head flex-column">
-    <view class="head_num">4</view>
-    <view class="head_text">请在优惠券有效期内尽快使用</view>
+    <view class="head_num" wx:if="{{!isLogin}}">{{notUseNum}}</view>
+    <view class="head_num" wx:if="{{isLogin}}">{{notUseNum?notUseNum:0}}</view>
+    <view class="head_text" wx:if="{{isLogin}}">请在优惠券有效期内尽快使用</view>
+    <button class="sigin-isLogin" wx:if="{{!isLogin}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" >登录</button>
   </view>
   <!-- 中部说明 -->
   <view class="explain flex-row">
-    <view class="explain-left flex-column">
+    <view class="explain-left flex-column" catchtap="getCoupon">
       <view class="explain-discount">我的优惠</view>
-      <view class="explain-column"></view>
+      <view class="explain-column" wx:if="{{noCoupon}}"></view>
     </view>
-    <view class="explain-center flex-column">
+    <view class="explain-center flex-column" catchtap="getDetail">
       <view class="explain-detailed">获取明细</view>
-      <view class="explain-column"></view>
+      <view class="explain-column" wx:if="{{noDetail}}"></view>
     </view>
-    <view class="explain-right flex-column">
+    <view class="explain-right flex-column" catchtap="getUtility">
       <view class="explain-utility">使用/失效</view>
-      <view class="explain-column"></view>
+      <view class="explain-column" wx:if="{{noUtility}}"></view>
     </view>
   </view>
 
@@ -26,29 +28,68 @@
     <!-- 主要内容 -->
     <view class="check-in-content flex-column">
       <!-- 优惠券内容 -->
-      <view class="coupon flex-row">
+      <view hidden="{{hiddenCoupon}}">
+      <view class="{{item.coupon.couponType == 'C'?'coupon flex-row':'coupon2 flex-row'}}" wx:for="{{couponList}}" wx:key="index" data-id="{{item.id}}">
         <view class="coupon-left flex-row">
-          <view class="coupon-left-symbol">¥</view>
-          <view class="coupon-left-num">1.09</view>
+          <!-- 代金券 -->
+          <view class="coupon-left-symbol" wx:if="{{item.coupon.couponType == 'C'}}">¥</view>
+          <view class="coupon-left-num" wx:if="{{item.coupon.couponType == 'C'}}">{{item.coupon.formatReduceCost ?item.coupon.formatReduceCost:0}}</view>
+          <!-- 折扣券 -->
+          <view class="coupon-left-num" wx:if="{{item.coupon.couponType == 'D'}}">{{item.coupon.formatDiscount ?item.coupon.formatDiscount:0}}</view>
+          <view class="coupon-left-symbol" wx:if="{{tem.coupon.couponType == 'D'}}">折</view>
         </view>
         <view class="coupon-center flex-column">
-          <view class="coupon-center-upper">圣诞活动代金券</view>
+          <view class="coupon-center-upper">{{item.coupon.couponTitle}}</view>
           <view class="coupon-center-bm flex-row">
             <view class="coupon-center-block1"></view>
-            <view class="coupon-center-middle">满199使用</view>
+            <view class="coupon-center-middle" wx:if="{{item.coupon.formatLeastCost == '0'}}">无门槛</view>
+            <view class="coupon-center-middle" wx:if="{{item.coupon.formatLeastCost != '0'}}">满{{item.coupon.formatLeastCost}}使用</view>
             <view class="coupon-center-block2"></view>
           </view>
-          <view class="coupon-center-lower">2021.10.10-2022.01.02</view>
+          <view class="coupon-center-lower">{{item.coupon.couponBeginTimestamp}}-{{item.coupon.couponEndTimestamp}}</view>
         </view>
         <view class="coupon-right">
-          <view class="coupon-right-usenow"></view>
+          <view class="{{item.coupon.couponType == 'C'?'coupon-right-usenow flex-row':'coupon-right-usenow2 flex-row'}}">
+            <navigator class="btn_exchange" 
+            target = "miniProgram" 
+            app-id="wxd92a2d29f8022f40"
+            path="page/index/index"
+            open-type='navigate'> 
+            </navigator>
+          </view>
         </view>
       </view>
+    </view>
       <!-- 获得明细 -->
-      <view></view>
+      <view class="detailed flex-column" hidden="{{hiddenDetail}}">
+        <view class="detailed-content" wx:for="{{detailList}}" wx:key="index" data-id="{{item.id}}">
+          <view class="detailed-date flex-column">2021年10月</view>
+          <view class="detailed-sign flex-row">
+            <view class="detailed-sign-index flex-column">
+              <view class="detailed-sign-text">{{item.source =='1'?'签到':'任务'}}</view>
+              <view class="detailed-sign-date">{{item.crateTime}}</view>
+            </view>
+            <view class="detailed-coupon flex-column">{{item.coupon.couponTitle}}</view>
+          </view>
+          
+        </view>
+      </view>
       <!-- 使用/失效 -->
-      <view></view>
-      <view></view>  
+      <view class="detailed flex-column" hidden="{{hiddenUtility}}">
+        <view class="detailed-content" wx:for="{{stateList}}" wx:key="index" data-id="{{item.id}}">
+          <view class="detailed-date flex-column">2021年11月</view>
+          <view class="detailed-sign flex-row">
+            <view class="detailed-sign-index flex-column">
+              <view class="detailed-sign-text">{{item.coupon.couponTitle}}</view>
+              <view class="detailed-sign-date">{{item.crateTime}}</view>
+            </view>
+            <view class="detailed-coupon flex-column" style="color: #8F8F8F;">已失效</view>
+          </view>
+          
+        </view>
+      </view>
+        <view class="no_result" wx:if="{{noResult}}">———— 抱歉,您暂无可用优惠券 ————</view>
+        <view class="no_result" wx:if="{{noMore}}">———— 更多优惠券 | 敬请期待 ————</view>
     </view>
   </view>
 </view>

+ 101 - 2
pages/signIn/record/record.wxss

@@ -2,8 +2,7 @@
 .record{
   width: 750rpx;
   height: auto;
-  padding-bottom: 119rpx;
-  
+  padding-bottom: 119rpx; 
 }
 
 /* 垂直方向布局,水平居中 **/
@@ -44,6 +43,13 @@
   color: #FEFEFE;
 }
 
+.sigin-isLogin{
+  color: #FEFEFE;
+  font-weight: 400;
+  background-color: transparent;
+  border-style: none;
+}
+
 .explain{
   width: 750rpx;
   height: 120rpx;
@@ -93,6 +99,15 @@
   justify-content: left !important;
 }
 
+.coupon2{
+  width: 708rpx;
+  height: 220rpx;
+  background-image: url(https://dy.shpr.top/luckDraw/coupon.png);
+  background-size: 100% 100%;
+  margin-top: 30rpx;
+  justify-content: left !important;
+}
+
 .coupon-left{
   width: 110px;
   height: 100%;
@@ -179,6 +194,15 @@
   margin-left: -10px;
 }
 
+.coupon-right-usenow2{
+  width: 81px;
+  height: 28px;
+  background-image: url(https://dy.shpr.top/luckDraw/coupon_use_now.png);
+  background-size: 100% 100%;
+  margin-top: 47px;
+  margin-left: -10px;
+}
+
 .coupon-center-bm{
   width: 100px;
   height: 15px;
@@ -192,4 +216,79 @@
   margin: 0 10rpx;
 }
 
+.btn_exchange{
+  width: 100%;
+  height: 100%;
+}
+
+.no_result {
+  font-size: 24rpx;
+  color: #B1B1B1;
+  line-height: 100rpx;
+  font-weight: 1000;
+}
+
+.detailed{
+  width: 100%;
+  height: auto;
+  background: #F3F3F3;
+}
+
+.detailed-content{
+  width: 750rpx;
+  height: auto;
+  margin-top: 4px;
+}
+
+.detailed-date{
+  width: 100%;
+  height: 40px;
+  font-size: 14px;
+  font-weight: 400;
+  color: #6E6E6E;
+  align-items: flex-start;
+  justify-content: center;
+  margin-left: 26px;
+}
+
+.detailed-sign{
+  width: 750rpx;
+  height: 178rpx;
+  background: #FFFFFF;
+}
+
+.detailed-sign-index,.detailed-coupon{
+  width: 50%;
+  height: 100%;
+}
+
+.detailed-sign-index{
+  align-items: flex-start !important;
+  justify-content: space-between;
+}
+
+.detailed-sign-text{
+  font-size: 18px;
+  font-weight: 500;
+  color: #6E6E6E;
+  margin-left: 27px;
+  margin-top: 22px;
+}
+
+.detailed-sign-date{
+  font-size: 14px;
+  font-family: Source Han Sans CN;
+  font-weight: 400;
+  color: #6E6E6E;
+  margin-left: 26px;
+  margin-bottom: 20px;
+}
+
+.detailed-coupon{
+  font-size: 20px;
+  font-family: Source Han Sans CN;
+  font-weight: 500;
+  color: #BF2637;
+  justify-content: center;
+}