Prechádzať zdrojové kódy

个人中心优惠券与奖品跳转

kk.shi 3 rokov pred
rodič
commit
0fe8bfb4fb
2 zmenil súbory, kde vykonal 44 pridanie a 15 odobranie
  1. 40 12
      pages/luckDraw/profile.js
  2. 4 3
      pages/luckDraw/profile.wxml

+ 40 - 12
pages/luckDraw/profile.js

@@ -14,9 +14,12 @@ Page({
         noResult: false,
         noMore: false,
         isLogin: false,
+        hidden1: false,
+        hidden2: false,
         mobileTop: 'TONY WU',
         couponNum: 0,
         productNum: 0,
+        goodsType: 1,
         goodsItemList: []
 
     },
@@ -29,7 +32,11 @@ Page({
             isLogin: getMobileCache() != ''
         })
         if(this.data.isLogin){
-            this.getUserPrizeList(1);
+            this.setData({
+                hidden1: false,
+                hidden2: true,
+            })
+            this.getUserPrizeList();
         }
     },
 
@@ -74,12 +81,12 @@ Page({
     onShareAppMessage: function () {
 
     },
-    getUserPrizeList: function(sum) {
+    getUserPrizeList: function() {
         LuckDraw.getUserPrizeList({
             page: this.data.page,
             pageSize: this.data.pageSize,
-            mobile: "13205528979",
-            goodsType: sum
+            mobile: getMobileCache(),
+            goodsType: this.data.goodsType
         }).then(res => {
             if (res.code == 200) {
                 this.uaerPrizeListView(res.data)
@@ -93,7 +100,7 @@ Page({
 
     uaerPrizeListView: function(data) {
         if (!Array.isArray(data.goodsItemList) || data.goodsItemList.length == 0) {
-            console.log("优惠券数据为空");
+            console.log("数据为空");
             if (this.data.page == 1) {
                 this.setData({
                     mobileTop:getMobileCache(),
@@ -114,12 +121,12 @@ Page({
             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){
+            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) {
@@ -144,7 +151,7 @@ Page({
         }
         this.data.lock = true
         this.data.page++
-        this.getUserPrizeList(1)
+        this.getUserPrizeList()
     },
     
 
@@ -155,10 +162,29 @@ Page({
         })
     },
     getProfile(e) {
-        this.getUserPrizeList(1)
+        this.setData({
+            hidden1: false,
+            hidden2: true,
+            page: 1,
+            goodsType: 1,
+            noMore: false,
+            noResult: false
+        })
+        this.data.goodsItemList = [];
+        this.getUserPrizeList()
     },
     getPrize(e) {
-        this.getUserPrizeList(2)
+
+        this.setData({
+            hidden1: true,
+            hidden2: false,
+            page: 1,
+            goodsType: 2,
+            noMore: false,
+            noResult: false
+        })
+        this.data.goodsItemList = [];
+        this.getUserPrizeList()
     },
     turnPrize: function() {
         console.log("开始查看")
@@ -172,10 +198,12 @@ Page({
         getPhoneNumberSync(e, _ => {
             this.setData({
                 isLogin: true,
-                mobileTop:getMobileCache(),
+                mobileTop: getMobileCache(),
+                hidden1: false,
+                hidden2: true,
             })
             console.log(this.data.mobileTop)
-            this.getUserPrizeList(1)
+            this.getUserPrizeList()
         })
     },
     toRecordPrize(e) {

+ 4 - 3
pages/luckDraw/profile.wxml

@@ -12,15 +12,16 @@
       <view class="luck-draw-coupon" catchtap="getProfile">
         <view class="luck-draw-cn">{{couponNum}}</view>
         <view class="luck-draw-cz">优惠券</view>
-        <view class="luck-draw-cjh"><view class="luck-draw-cj"></view></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 class="luck-draw-theme">
+    <view id="couponZD" class="luck-draw-theme" hidden="{{hidden1}}">
       <!-- 折扣券 -->
       <view class="luck-draw-content" wx:for="{{goodsItemList}}" wx:key="index" data-id="{{item.id}}" wx:if="{{item.couponType == 'D' && item.goodsType == 1}}">
         <view class="luck-draw-words">
@@ -78,7 +79,7 @@
       <view class="no_result" wx:if="{{noMore}}">———— 更多优惠券 | 敬请期待 ————</view>
     </view>
 
-    <view class="luck-draw-theme">
+    <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">