소스 검색

更改团购后的一些逻辑

Rorschach 6 년 전
부모
커밋
63c0476103

+ 2 - 1
app.json

@@ -28,7 +28,8 @@
     "navigationBarTitleText": "小学语文朗读配音",
     "navigationBarTextStyle": "white",
     "backgroundColor": "#61CA54",
-    "onReachBottomDistance": 50
+    "onReachBottomDistance": 50,
+    "enablePullDownRefresh": true
   },
   "debug": false
 }

+ 15 - 3
component/group/group.js

@@ -96,9 +96,21 @@ export const groupInit = (that) => {
     const productId = currentTarget.dataset.productid;
     const id = currentTarget.dataset.id;
     const groupId = currentTarget.dataset.groupid;
-    wx.navigateTo({
-      url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
-    })
+    const ind = currentTarget.dataset.ind;
+    const groupType = that.data.groupData.recommendList[ind].groupType;
+      wx.navigateTo({
+        url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
+      })
+    // if(groupType === "PROMOTION") {
+    //   wx.navigateTo({
+    //     url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${id}&groupId=${groupId}`
+    //   })
+    // }else  {
+    //   wx.navigateTo({
+    //     url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
+    //   })
+    // }
+
   }
   //跳转到课程详情
   that.goToBook = function(e){

+ 1 - 1
component/group/group.wxml

@@ -10,7 +10,7 @@
           </view>
           <view class="group-box">
             <block wx:for="{{groupData.recommendList}}" wx:key="{{index}}">
-              <view class="group-item" bindtap="groupDetail" data-id="{{item.id}}" data-productId="{{item.productId}}" data-groupId="{{item.groupId}}">
+              <view class="group-item" bindtap="groupDetail" data-ind="{{index}}" data-id="{{item.id}}" data-productId="{{item.productId}}" data-groupId="{{item.groupId}}">
                 <image class="item-img" src="{{item.iconImg}}"></image>
                 <view>拼团价 <text>¥{{item.price / 100}}</text></view>
                 <view>原价 <text style="text-decoration: line-through;">¥{{item.originPrice / 100}}</text></view>

+ 4 - 4
component/my/my.wxml

@@ -21,7 +21,7 @@
       </view>
       <view class='mine-category'>
         <view class='play-count'>
-          <view>{{ myData.user.playAmount }}</view>
+          <view>{{ myData.user.playAmount || 0 }}</view>
           <view class='border-right'>
             <view class='play-img'>
               <image src='../../static/image/play.png'></image>
@@ -30,7 +30,7 @@
           </view>
         </view>
         <view class='follow-count'>
-          <view class='color'>{{ myData.user.fansAmount }}</view>
+          <view class='color'>{{ myData.user.fansAmount || 0 }}</view>
           <view class='border-right'>
             <view class='play-img'>
               <image src='../../static/image/follow.png'></image>
@@ -39,7 +39,7 @@
           </view>
         </view>
         <view class='point-count'>
-          <view class='color'>{{ myData.user.likeAmount }}</view>
+          <view class='color'>{{ myData.user.likeAmount || 0 }}</view>
           <view class='border-right'>
             <view class='play-img'>
               <image src='../../static/image/point.png'></image>
@@ -48,7 +48,7 @@
           </view>
         </view>
         <view class='flower-count'>
-          <view class='color'>{{ myData.user.pointAmount }}</view>
+          <view class='color'>{{ myData.user.pointAmount || 0 }}</view>
           <view class='border-right'>
             <view class='play-img'>
               <image src='../../static/image/flower.png'></image>

+ 1 - 0
component/popup/popup.js

@@ -41,6 +41,7 @@ Component({
       this.setData({
         closeFlag: !this.data.closeFlag
       })
+      this.triggerEvent('Close', {})
     },
     launchGroup: function () {
       this.triggerEvent('Group', {})

+ 4 - 4
component/popup/popup.wxml

@@ -14,15 +14,15 @@
                 {{headTextTwo}}
             </view>
         </view>
-        <view class="content">    
+        <view class="content" style="font-size:32rpx;">    
             <block wx:for="{{content}}" wx:key="{{index}}">
                 <text style="color: {{item.color}};">{{item.text}}</text>
             </block>
         </view>
-        <!-- <view class="send-btn" bindtap="launchGroup">
+         <view class="send-btn" bindtap="launchGroup">
             <image src="../../static/groupImg/Invitation.png"></image>
-            <text>发起团购</text>
-        </view> -->
+            <text>邀请好友赚奖学金</text>
+        </view>
     </view>
     <!--失败 -->
     <view class="popup-container"  wx:if="{{typeOf == 'error' ? true : false}}">

+ 1 - 1
component/share/share.wxss

@@ -5,7 +5,7 @@
     top: 0;
     width: 100%;
     height: 100%;
-    background: rgba(0, 0, 0, .9);
+    background: rgba(0, 0, 0, .6);
     z-index: 99;
 }
 

+ 35 - 13
pages/groupPage/collage-details/collage-details.js

@@ -30,7 +30,8 @@ Page({
           text: "在限定时间内内成功拼团,您将得到xx元的奖励金哦。",
           color: "#FF4600"
       }
-    ]
+    ],
+    read: false
   },
 
   //规则页显示和隐藏
@@ -41,22 +42,36 @@ Page({
   },
   //显示分享页 
   openShare: function () {
-    this.shareDialog = this.selectComponent("#share-dialog");
-    const data = {
-      avatar: this.data.organizer.avatar,
-      author: this.data.organizer.wechatName,
-      iconImg: this.data.groupPurchaseInfo.bgImg,
-      title: this.data.groupPurchaseInfo.productTitle,
-      path: `pages/groupPage/collage-details/collage-details`,
-      scene: `QR${this.data.orderId}`,
-      groupPurchaseInfo: this.data.groupPurchaseInfo
+    if(this.data.read){
+      const productId = this.data.productId;
+      const id = this.data.orderId;
+      const groupId = this.data.groupId;
+      wx.navigateTo({
+        url: `/pages/groupPage/grade-details/grade-details?productId=${productId}&id=${id}&groupId=${groupId}&share=true`
+      })
+    }else {
+      this.shareDialog = this.selectComponent("#share-dialog");
+      const data = {
+        avatar: this.data.organizer.avatar,
+        author: this.data.organizer.wechatName,
+        iconImg: this.data.groupPurchaseInfo.bgImg,
+        title: this.data.groupPurchaseInfo.productTitle,
+        path: `pages/groupPage/collage-details/collage-details`,
+        scene: `QR${this.data.orderId}`,
+        groupPurchaseInfo: this.data.groupPurchaseInfo
+      }
+      this.shareDialog.share(data);
     }
-    this.shareDialog.share(data);
   },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    if(options.read) {
+      this.setData({
+        read: options.read
+      })
+    }
     options.scene = 'QR1541862338777268';
     wx.setNavigationBarTitle({
       title: '拼团详情'
@@ -70,8 +85,9 @@ Page({
       orderId
     })
     httpRequestApi.getMygroupInfo(orderId).success( res => {
+      console.log(res);
       const groupOrder = res.data.data.groupPurchaseOrder;
-      const surplusNum = groupOrder.headcount - groupOrder.joinCount - 1;
+      const surplusNum = groupOrder.headcount - groupOrder.joinCount;
       for(var i = 0; i < surplusNum; i++) {
         this.data.surplusList.push(1);
       }
@@ -79,7 +95,7 @@ Page({
       //时间转换
       const timeList = util.formatTime(groupOrder.closeTime - Date.parse(new Date()));
       console.log(timeList)
-      res.data.data.joinUserList.unshift(res.data.data.organizer);
+      //res.data.data.joinUserList.unshift(res.data.data.organizer);
       this.setData({
         groupPurchaseInfo: res.data.data.groupPurchaseInfo,
         organizer: res.data.data.organizer,
@@ -90,6 +106,12 @@ Page({
         productId: groupOrder.productId,
         groupId: groupOrder.groupId
       })
+      if(groupOrder.groupType === 'PROMOTION'){
+        this.data.joinUserList.unshift(res.data.data.organizer);
+        this.setData({
+          joinUserList: this.data.joinUserList,
+        })
+      }
     }).fail( error => {
       console.log('错误', error)
     })

+ 3 - 2
pages/groupPage/collage-details/collage-details.wxml

@@ -22,7 +22,8 @@
             </block>                   
         </view>
         <view class="shengyu">
-            <view class="shengyu-num" >仅剩<text>{{surplusNum}}</text>个名额就拼团成功了</view>
+            <view class="shengyu-num" hidden="{{surplusNum == '0'}}">仅剩<text>{{surplusNum}}</text>个名额就拼团成功了</view>
+            <view class="shengyu-num" hidden="{{surplusNum != '0'}}">拼团成功!快去朗读吧</view>
             <view class="shengyu-time" >
                 剩余时间:
                 <view class="time">
@@ -48,7 +49,7 @@
         </view>
         <view class="invitation-btn" bindtap="openShare">
             <image src="../../../static/groupImg/Invitation.png"></image>
-            <text>邀请朋友参加</text>
+            <text>{{read ? '去朗读' : '邀请朋友参加'}}</text>
         </view>
     </view>  
     <view class="rule" style="{{hideFlag ? 'right' : 'left'}}: 0" bindtap="hide">

+ 18 - 2
pages/groupPage/discount-group/discount-group.js

@@ -10,8 +10,24 @@ Page({
   },
 
   //点击跳转到团购详情
-  groupDetails:function () {
-
+  groupDetail:function ({currentTarget}) {
+    const productId = currentTarget.dataset.productid;
+    const id = currentTarget.dataset.id;
+    const groupId = currentTarget.dataset.groupid;
+    const ind = currentTarget.dataset.ind;
+    //const groupType = this.data.groupData.recommendList[ind].groupType;
+      wx.navigateTo({
+        url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
+      })
+    // if(groupType === "PROMOTION") {
+    //   wx.navigateTo({
+    //     url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${id}&groupId=${groupId}`
+    //   })
+    // }else  {
+    //   wx.navigateTo({
+    //     url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
+    //   })
+    // }
   },
 
   /**

+ 1 - 1
pages/groupPage/discount-group/discount-group.wxml

@@ -5,7 +5,7 @@
         <view class="less-group">
           <view class="group-box">
             <block wx:for="{{recommendList}}" wx:key="{{index}}">
-              <view class="group-item" bindtap="groupDetail" data-id="{{item.id}}" data-productId="{{item.productId}}" data-groupId="{{item.groupId}}">
+              <view class="group-item" bindtap="groupDetail" data-ind="{{index}}" data-id="{{item.id}}" data-productId="{{item.productId}}" data-groupId="{{item.groupId}}">
                 <image class="item-img" src="{{item.iconImg}}"></image>
                 <view>拼团价 <text>¥{{item.price / 100}}</text></view>
                 <view>原价 <text style="text-decoration: line-through;">¥{{item.originPrice / 100}}</text></view>

+ 8 - 3
pages/groupPage/grade-details/grade-details.js

@@ -24,14 +24,14 @@ Page({
         color: "#FF4600"
       }
     ],
-
+    share: false
   },
   //获取团购信息并掉起支付
   pay: function ({
     currentTarget
   }) {
     const productId = this.data.productId;
-    const groupId = currentTarget.dataset.id;
+    const groupId =  currentTarget.dataset.id;
     //开始发起团购
     httpRequestApi.SendGroupPurchas({
       productId,
@@ -70,7 +70,7 @@ Page({
             if (res.data.data.groupPurchaseOrder.headCount !== 1) {
               setTimeout(() => {
                 wx.navigateTo({
-                  url: `/pages/groupPage/collage-details/collage-details?orderId=${res.data.data.groupPurchaseOrder.id}`
+                  url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${res.data.data.groupPurchaseOrder.id}&groupId=${groupId}`
                 })
                 wx.setNavigationBarTitle({
                   title: '拼团详情'
@@ -136,6 +136,11 @@ Page({
    */
   onLoad: function (options) {
     console.log(options)
+    if(options.share){
+      this.setData({
+        share: options.share
+      })
+    }
     // wx.setNavigationBarTitle({
     //   title: options.title
     // })

+ 5 - 1
pages/groupPage/grade-details/grade-details.wxml

@@ -20,8 +20,12 @@
     <view class="group-btn">
         <image class="bg1" src="../../../static/groupImg/Rectangle_9.png"></image>
         <image class="bg2" src="../../../static/groupImg/Rectangle_9.png"></image>
+        <view class="Price" bindtap="pay" data-id="{{payList[0].id}}" wx:if="{{share}}">
+            <text>去分享</text>
+            <text>好友</text>
+        </view>        
         <block wx:for="{{payList}}" wx:key="{{index}}">
-            <view class="Price" bindtap="pay" data-id="{{item.id}}">
+            <view class="Price" bindtap="pay" data-id="{{item.id}}" wx:if="{{share ? (index != 0) : true }}">
                 <text>¥{{item.price / 100}}</text>
                 <text>{{item.headcount}}人团</text>
             </view>

+ 25 - 15
pages/groupPage/group-details/group-details.js

@@ -23,6 +23,7 @@ Page({
     headTextOne: '',
     headTextTwo: '',
     content: [],
+    organizer: ''
   },
   //跳转到年级
   gradeDetails: function () {
@@ -59,9 +60,14 @@ Page({
         })
         return false;
       }
+      debugger;
       if (res.data.data.groupPurchaseOrder.groupType === 'BASE') {
         //掉起支付
         this.prePayMap(res.data.data.prePayMap, 'create');
+      }else {
+        wx.navigateTo({
+          url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${res.data.data.groupPurchaseOrder.id}&groupId=${groupId}`
+        })
       }
 
     }).fail((error) => {
@@ -147,9 +153,11 @@ Page({
       console.log('拼团详情', res.data.data);
       const groupOrder = res.data.data.groupPurchaseOrder;
       const surplusNum = groupOrder.headcount - groupOrder.joinCount;
+      this.setData({
+        organizer: groupOrder.organizer,
+      })
       if (type === 'join') {
         this.data.surplusList.pop();
-
         if (groupOrder.status === 'SUCCESSED') {
           this.showSuccess(groupOrder.organizer, groupOrder.organizerPrice)
         } else {
@@ -175,11 +183,11 @@ Page({
       })
       if(groupOrder.groupType === 'PROMOTION'){
         this.data.joinUserList.unshift(res.data.data.organizer);
-        this.data.surplusList.pop();
+        //this.data.surplusList.pop();
         this.setData({
           joinUserList: this.data.joinUserList,
-          surplusList: this.data.surplusList,
-          surplusNum: this.data.surplusNum - 1
+          //surplusList: this.data.surplusList,
+          surplusNum: this.data.surplusNum
         })
       }
       console.log(this.data.joinUserList)
@@ -216,6 +224,7 @@ Page({
         this.popup.close()
       })
     } else {
+      debugger;
       this.setData({
         typeOf: 'success',
         title: '拼团成功 ! ',
@@ -254,6 +263,14 @@ Page({
       })
     }, 3000)
   },
+  //跳到课程
+  goToClass: function (e) {
+    let id = e.currentTarget.dataset.id;
+    let title = e.currentTarget.dataset.title;
+    wx.navigateTo({
+      url: `../../main/class/class?id=${id}&title=${title}`
+    })
+  },
   //拼团是否成功并弹窗
   // groupSuccess: function (orderId, detailId) {
   //   httpRequestApi.groupSuccess(orderId).success(res => {
@@ -325,17 +342,10 @@ Page({
   // },
   //再次发起团
   group: function () {
-    wx.showModal({
-      title: '提示',
-      content: '再次发起团',
-      success(res) {
-        if (res.confirm) {
-          console.log('用户点击确定')
-        } else if (res.cancel) {
-          console.log('用户点击取消')
-        }
-      }
-    })
+    this.openGroup();
+      // wx.navigateTo({
+      //   url: `/pages/groupPage/make-money/make-money?productId=${this.data.productId}&id=${this.data.orderId}&groupId=${this.data.groupId}`
+      // })
   },
 
   /**

+ 5 - 4
pages/groupPage/group-details/group-details.wxml

@@ -3,7 +3,8 @@
     <view class="details-head" bindtap="collage">
         <view class="headImg">
             <block wx:for="{{joinUserList}}" wx:key="{{index}}">
-                <view class="headImg-item">
+                <view class="headImg-item {{organizer == item.uid ? 'bg-boder' : ''}}">
+                    <image wx:if="{{organizer == item.uid}}" class="tuanzhangIcon" src="../../../static/groupImg/tuanzhangIcon.png"></image>
                     <image src="{{item.avatar}}"></image>
                 </view>
             </block>
@@ -15,7 +16,7 @@
         </view>
         <view class="shengyu">
             <view class="shengyu-num" hidden="{{surplusNum == '0'}}">仅剩<text>{{surplusNum}}</text>个名额就拼团成功了</view>
-            <view class="shengyu-num" hidden="{{surplusNum != '0'}}">拼团成功</view>
+            <view class="shengyu-num" hidden="{{surplusNum != '0'}}">拼团成功!快去朗读吧</view>
             <view class="shengyu-time" hidden="{{surplusNum == '0'}}">
                 剩余时间:
                 <view class="time">
@@ -51,13 +52,13 @@
             <text>课文目录</text>
         </view>
         <view class="catalog-list">
-            <view class="catalog-item" wx:for="{{lessonList}}" wx:key="{{index}}" data-id="{{item.id}}" data-title="{{item.title}}">
+            <view class="catalog-item" wx:for="{{lessonList}}" wx:key="{{index}}" data-id="{{item.id}}" data-title="{{item.title}}" bindtap="goToClass">
                 <text class="left">{{item.title}}</text>
                 <text class="right">{{item.readingNum}}朗读 ></text>
             </view>           
         </view>
     </scroll-view>
-    <view class="group-details-btn">
+    <view class="group-details-btn" hidden="{{surplusNum == '0'}}">
         <view class="left-btn" bindtap="openGroup">
             开团
         </view>

+ 14 - 0
pages/groupPage/group-details/group-details.wxss

@@ -18,6 +18,7 @@
 }
 
 .headImg-item {
+    position: relative;
     width: 106rpx;
     height: 106rpx;
     border-radius: 50%;
@@ -30,10 +31,23 @@
     border-radius: 50%;
 }
 
+.headImg-item .tuanzhangIcon {
+    position: absolute;
+    right: -20rpx;
+    top: -10rpx;
+    width: 80rpx;
+    height: 30rpx;
+}
+
+.bg-boder {
+    border: 2px solid #000;
+}
+
 .shengyu {
  display: flex;
  flex-direction: column;   
  color: #696969;
+ padding-bottom:20px;
 }
 
 .shengyu-num {

+ 0 - 1
pages/groupPage/make-money/make-money.js

@@ -44,7 +44,6 @@ Page({
       for(var i = 0; i < surplusNum; i++) {
         this.data.surplusList.push(1);
       }
-      //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
       //时间转换
       const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
       this.setData({

+ 42 - 19
pages/groupPage/my-group/my-group.js

@@ -14,7 +14,8 @@ Page({
     content: [],    
     productId: '',
     orderId: '',
-    groupId: ''
+    groupId: '',
+    closeFlag: true
   },
     //跳转到团购详情页
   collageDetails: function ({currentTarget}) {
@@ -26,8 +27,13 @@ Page({
         url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
       })
     } else {
-      
-  
+      if(this.data.closeFlag) {
+        this.popup.close();
+      }else {
+        wx.navigateTo({
+          url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}&read=true`
+        })
+      }
     }
   },
 
@@ -54,13 +60,13 @@ Page({
       })
       res.data.data.list.forEach(element => {
         console.log(element.status)
-        if(element.status == 'successed') {
+        if(element.status == 'SUCCESSED') {
           this.setData({
             productId: element.productId,
             orderId: element.id,
             groupId: element.groupId
           })
-          if(wx.getStorageSync(uid) == element.organizer) {
+          if(wx.getStorageSync('uid') == element.organizer) {
             this.setData({
               typeOf: 'success',
               title: '恭喜 !',
@@ -117,24 +123,41 @@ Page({
     })
   },
 
+  close: function () {
+    this.setData({
+      closeFlag: false
+    })
+  },
+
   //再次发起团
   group: function () {
-    // wx.showModal({
-    //   title: '提示',
-    //   content: '再次发起团',
-    //   success (res) {
-    //     if (res.confirm) {
-    //       console.log('用户点击确定')
-    //     } else if (res.cancel) {
-    //       console.log('用户点击取消')
-    //     }
-    //   }
-    // })
     const productId = this.data.productId;
     const groupId = this.data.groupId;
     const id = this.data.orderId;
-    wx.navigateTo({
-      url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${id}&groupId=${groupId}`
+    //开始发起团购
+    httpRequestApi.SendGroupPurchas({
+      productId,
+      groupId
+    }).success((res) => {
+      console.log('发起团购', res);
+      if (res.data.message) {
+        wx.showModal({
+          title: '提示',
+          content: res.data.message,
+          success:(res) => {
+          }
+        })
+        return false;
+      }
+      wx.navigateTo({
+        url: `/pages/groupPage/make-money/make-money?productId=${productId}&id=${res.data.data.groupPurchaseOrder.id}&groupId=${groupId}`
+      })
+      //if(res.data.data.)
+      this.setData({
+        closeFlag: false
+      })
+    }).fail((error) => {
+
     })  
   },
 
@@ -142,7 +165,7 @@ Page({
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
-
+    this.popup = this.selectComponent("#popup");
   },
 
   /**

+ 2 - 1
pages/groupPage/my-group/my-group.wxml

@@ -12,12 +12,13 @@
         </view>
     </scroll-view>
 </view>
-
 <popup
+    id="popup"
     typeOf="{{typeOf}}"
     title="{{title}}"
     headTextOne="{{headTextOne}}"
     headTextTwo="{{headTextTwo}}"
     content="{{content}}"
     bindGroup="group"
+    bindClose="close"
 ></popup>

+ 10 - 0
pages/index/index.js

@@ -188,5 +188,15 @@ Page({
         console.log('没有更多')
       }
     }
+  },
+  onPullDownRefresh: function () {
+    //当前在团购页下拉加载
+    if (this.data.myIndex === 0) {
+      groupInit(this);
+    }
+    wx.startPullDownRefresh();
+    setTimeout(() => {
+      wx.stopPullDownRefresh()
+    },10)
   }
 })