Browse Source

修改参团逻辑

Limengbo 6 years ago
parent
commit
fb6c283b3f

+ 16 - 8
component/group/group.js

@@ -35,17 +35,16 @@ export const groupInit = (that) => {
   //点击跳转
   that.more = function ({currentTarget}) {
     let type;
-    let title;
     if(currentTarget.dataset.type == 'group') {
-      type = true
-      title = '限量优惠团购'
+      wx.navigateTo({
+        url: `/pages/groupPage/discount-group/discount-group`
+      })
     }else {
-      type = false
-      title = '全部课'
+      wx.navigateTo({
+        url: `../main/books/books`
+      })
     }
-    wx.navigateTo({
-      url: `/pages/groupPage/discount-group/discount-group?type=${type}&title=${title}`
-    })
+
   }
   //发起团购
   that.sendGroup = function () {
@@ -100,4 +99,13 @@ export const groupInit = (that) => {
       url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
     })
   }
+  //跳转到课程详情
+  that.goToBook = function(e){
+    console.log(e.currentTarget.dataset)
+    let id = e.currentTarget.dataset.id;
+    let title = e.currentTarget.dataset.title;
+    wx.navigateTo({
+        url: `/pages/main/singleBook/singleBook?id=${id}&title=${title}`
+      })
+  }
 }

+ 2 - 2
component/group/group.wxml

@@ -26,12 +26,12 @@
       <view class="whole-group">
           <view class="title">
             <image class="ren" src="../../static/groupImg/Shape3.png" style="width: 30rpx; height: 38rpx;"></image>
-            <text class="left">全部课程<text class="quota" style="margin-left: 20rpx;">拼团大不同</text></text>
+            <text class="left">全部课程</text>
             <text class="right" bindtap="more" data-type="course">更多 ></text>
           </view>
           <view class="group-box"> 
             <block wx:for="{{groupData.bookList}}" wx:key="{{index}}">
-              <view class="group-item">
+              <view class="group-item" data-id="{{item.id}}" data-title="{{item.title}}" bindtap="goToBook">
                 <image class="item-img" src="{{item.iconImg}}"></image>
                 <view id="grade">一年级</view>
               </view>    

+ 2 - 2
pages/groupPage/collage-details/collage-details.js

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

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

@@ -6,8 +6,7 @@ Page({
    * 页面的初始数据
    */
   data: {
-    recommendList: [],
-    bookList: []
+    recommendList: []
   },
 
   //点击跳转到团购详情
@@ -20,9 +19,8 @@ Page({
    */
   onLoad: function (options) {
     wx.setNavigationBarTitle({
-      title: options.title
+      title: '优惠团购'
     })
-    if(options.type == 'true') {
       //优惠内容
       httpRequestApi.getGroupList().success( (res) => {
         console.log('推荐团购',res.data.data)
@@ -32,17 +30,6 @@ Page({
       }).fail((error) => {
         console.log('错误',error)
       })
-    }else {
-      //全部课
-      httpRequestApi.getAllBooks(1, 10).success((res) => {
-        console.log('全部课',res.data.data.list)
-        this.setData({
-          bookList: res.data.data.list
-        })
-      }).fail((error) => {
-        console.log('错误',error)
-      })
-    }
   },
 
   /**

+ 0 - 6
pages/groupPage/discount-group/discount-group.wxml

@@ -14,12 +14,6 @@
                   <text>{{item.headcount}}人团</text>
                 </view>
               </view>
-            </block> 
-            <block wx:for="{{bookList}}" wx:key="{{index}}">
-              <view class="group-item">
-                <image class="item-img" src="{{item.iconImg}}"></image>
-                <view id="grade">一年级</view>
-              </view>    
             </block>                
           </view>                        
         </view>

+ 11 - 23
pages/groupPage/grade-details/grade-details.js

@@ -54,7 +54,7 @@ Page({
           return false;
         }
         //掉起支付
-        this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrderDetail.orderId);
+        this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrder.id);
       }).fail( (error) => {
         
       })
@@ -78,27 +78,15 @@ Page({
             title: '提示',
             content: '支付成功',
             success (res) {
-              if (res.confirm) {
-                that.popup.close();
-                setTimeout(() => {
-                  wx.navigateTo({
-                    url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
-                  })
-                  wx.setNavigationBarTitle({
-                    title: '拼团详情'
-                  })
-                }, 1000)
-              } else if (res.cancel) {
-                that.popup.close();
-                setTimeout(() => {
-                  wx.navigateTo({
-                    url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
-                  })
-                  wx.setNavigationBarTitle({
-                    title: '拼团详情'
-                  })
-                }, 1000)                
-              }
+              that.popup.close();
+              setTimeout(() => {
+                wx.navigateTo({
+                  url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+                })
+                wx.setNavigationBarTitle({
+                  title: '拼团详情'
+                })
+              }, 1000)
             }
           })
 
@@ -124,7 +112,7 @@ Page({
       })
     }
     //课本详情
-    httpRequestApi.getBookDetail(productId).success( (res) =>{
+    httpRequestApi.getBookDetail(wx.getStorageSync('uid'),productId).success( (res) =>{
       console.log('课本详情',res.data.data);
       const bookInfo = res.data.data.product;
       const lessonList = res.data.data.lessonList;

+ 13 - 17
pages/groupPage/group-details/group-details.js

@@ -88,14 +88,14 @@ Page({
         return false;
       }  
       //掉起支付
-      this.prePayMap(res.data.data.prePayMap, res.data.data.orderId);
+      this.prePayMap(res.data.data.prePayMap, res.data.data.orderId, res.data.data.groupPurchaseOrder.id);
     }).fail( (error) => {
       
     })
   },
 
   //支付
-  prePayMap: function (prePayMap, orderId) {
+  prePayMap: function (prePayMap, orderId, detailId) {
     console.log(prePayMap)
     const that = this;
     wx.requestPayment(
@@ -112,16 +112,11 @@ Page({
             title: '提示',
             content: '支付成功',
             success (res) {
-              if (res.confirm) {
-                //获取拼团信息
-                this.jionSuccess(this.data.orderId);
-                this.groupSuccess(orderId);
-
-              } else if (res.cancel) {
-                //获取拼团信息
-                this.jionSuccess(this.data.orderId);                
-                this.groupSuccess(orderId);
-              }
+              //获取拼团信息
+              setTimeout( () => {
+                that.jionSuccess(that.data.orderId);
+                that.groupSuccess(orderId, detailId);
+              },2000)
             }
           })
 
@@ -143,9 +138,9 @@ Page({
       for(var i = 0; i < surplusNum; i++) {
         this.data.surplusList.push(1);
       }
-      console.log(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated)
+      console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
       //时间转换
-      const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated);
+      const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
       this.setData({
         surplusNum,
         joinUserList: res.data.data.joinUserList,
@@ -158,13 +153,13 @@ Page({
   },
 
   //拼团是否成功并弹窗
-  groupSuccess: function (orderId) {
+  groupSuccess: function (orderId, detailId) {
     httpRequestApi.groupSuccess(orderId).success( res => {
       console.log('团购是否成功',res.data.data)
       const status = res.data.data.status;
+      debugger;
       const uid = res.data.data.uid;
       if(status == 'successed') {
-
         if(wx.getStorageSync(uid) == uid) {
           this.setData({
             typeOf: 'success',
@@ -216,9 +211,10 @@ Page({
           })
         }
       }else {
+        debugger;
         setTimeout(() => {
           wx.navigateTo({
-            url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+            url: `/pages/groupPage/collage-details/collage-details?orderId=${detailId}`
           })
           wx.setNavigationBarTitle({
             title: '拼团详情'

+ 1 - 1
pages/groupPage/group-details/group-details.wxss

@@ -76,7 +76,7 @@
 }
 
 scroll-view {
-    height: 59%;
+    height: 64%;
     width: 100%;
 }
 

+ 2 - 2
pages/groupPage/make-money/make-money.js

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

+ 1 - 1
pages/main/class/class.js

@@ -93,7 +93,7 @@ Page({
       readInfo.forEach(item => {
         const temp = {};
         temp.nickName = item.user.wechatName;
-        temp.time = formatDate(item.userRead.gmtCreated, 3);
+        temp.time = formatDate(item.userRead.gmtModified, 3);
         temp.avatar = item.user.avatar;
         temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
         temp.uid = item.userRead.uid;

+ 2 - 2
pages/social/replyDetail/replyDetail.js

@@ -29,7 +29,7 @@ Page({
             const authorDetail = {};
             authorDetail.name = replied.user.wechatName;
             authorDetail.text = replied.detailDesc;
-            authorDetail.time = formatDate(replied.gmtCreated,3);
+            authorDetail.time = formatDate(replied.gmtModified,3);
             authorDetail.likes = replied.postsAttributeInfo.favors;
             authorDetail.avatar = replied.user.avatar;
             replyTemp.push(authorDetail);
@@ -37,7 +37,7 @@ Page({
                 const temp = {};
                 temp.name = item.user.wechatName;
                 temp.text = item.content;
-                temp.time = formatDate(item.gmtCreated,3);
+                temp.time = formatDate(item.gmtModified,3);
                 temp.likes = 0;
                 temp.id = item.postId;
                 temp.avatar = item.user.avatar;

+ 1 - 1
pages/social/works/works.js

@@ -162,7 +162,7 @@ Page({
                 temp.text = item.detailDesc;
                 temp.id = item.id;
                 temp.replyCount = item.replyCount;
-                temp.time = formatDate(item.gmtCreated, 3);
+                temp.time = formatDate(item.gmtModified, 3);
                 temp.likes = item.postsAttributeInfo.favors || 0;
                 console.log(temp.time)
                 replyTemp.push(temp);