Selaa lähdekoodia

合并limengbo

Rorschach 6 vuotta sitten
vanhempi
commit
455d0d13cd

+ 2 - 1
app.json

@@ -15,7 +15,8 @@
     "pages/main/searchResult/searchResult",
     "pages/user/myconcern/myconcern",
     "pages/groupPage/my-group/my-group",
-    "pages/user/myWallet/myWallet"
+    "pages/user/myWallet/myWallet",
+    "pages/groupPage/make-money/make-money"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 3 - 0
component/popup/popup.js

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

+ 1 - 1
component/popup/popup.wxml

@@ -19,7 +19,7 @@
                 <text style="color: {{item.color}};">{{item.text}}</text>
             </block>
         </view>
-        <view class="send-btn">
+        <view class="send-btn" bindtap="launchGroup">
             <image src="../../static/groupImg/Invitation.png"></image>
             <text>发起团购</text>
         </view>

+ 131 - 46
pages/groupPage/group-details/group-details.js

@@ -17,7 +17,12 @@ Page({
     timeList: [],
     productId: '',
     groupId: '',
-    orderId: ''
+    orderId: '',
+    typeOf:'',
+    title: '',
+    headTextOne: '',
+    headTextTwo: '',
+    content: [],
   },
   //跳转到年级
   gradeDetails: function () {
@@ -39,9 +44,6 @@ Page({
       groupId
     }).success( (res) =>{
       console.log('发起团购',res);
-      // wx.navigateTo({
-      //   url: `/pages/groupPage/collage-details/collage-details`
-      // })
       if(res.data.message) {
         wx.showModal({
           title: '提示',
@@ -56,8 +58,11 @@ Page({
         })
         return false;
       }
-      //掉起支付
-      this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrderDetail.orderId);
+      if(res.data.data.groupPurchaseOrder.groupType === 'BASE') {
+        //掉起支付
+        this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrderDetail.orderId);
+      }
+
     }).fail( (error) => {
       
     })
@@ -81,9 +86,9 @@ Page({
           }
         })
         return false;
-      }
+      }  
       //掉起支付
-      this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrderDetail.orderId);
+      //this.prePayMap(res.data.data.prePayMap, res.data.data.orderId);
     }).fail( (error) => {
       
     })
@@ -108,25 +113,14 @@ Page({
             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)
+                //获取拼团信息
+                this.jionSuccess(this.data.orderId);
+                this.groupSuccess(orderId);
+
               } else if (res.cancel) {
-                that.popup.close();
-                setTimeout(() => {
-                  wx.navigateTo({
-                    url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
-                  })
-                  wx.setNavigationBarTitle({
-                    title: '拼团详情'
-                  })
-                }, 1000)                
+                //获取拼团信息
+                this.jionSuccess(this.data.orderId);                
+                this.groupSuccess(orderId);
               }
             }
           })
@@ -141,6 +135,115 @@ Page({
   collage: function () {
 
   },
+  //拼团详情
+  jionSuccess: function (orderId) {
+    httpRequestApi.getMygroupInfo(orderId).success( res => {
+      console.log('拼团详情', res.data.data);
+      const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
+      for(var i = 0; i < surplusNum; i++) {
+        this.data.surplusList.push(1);
+      }
+      console.log(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated)
+      //时间转换
+      const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated);
+      this.setData({
+        surplusNum,
+        joinUserList: res.data.data.joinUserList,
+        surplusList: this.data.surplusList,
+        timeList,
+      })
+    }).fail( error => {
+      console.log('错误', error)
+    })    
+  },
+
+  //拼团是否成功并弹窗
+  groupSuccess: function (orderId) {
+    httpRequestApi.groupSuccess(orderId).success( res => {
+      console.log('团购是否成功',res.data.data)
+      const status = res.data.data.status;
+      const uid = res.data.data.uid;
+      if(status == 'successed') {
+
+        if(wx.getStorageSync(uid) == uid) {
+          this.setData({
+            typeOf: 'success',
+            title: '恭喜 !',
+            headTextOne: '您发起的团购拼团成功',
+            content: [
+              {
+                  text: "领袖体质魅力无穷!",
+                  color: "#000"
+              },
+              {
+                  text: " 您可以继续发起新的团购,",
+                  color: "#000"
+              },
+              {
+                text: " 不再需要支付本课程费用,拼团成功,",
+                color: "#FF9B00"
+              },                          
+              {
+                  text: " 您将得到xxx元奖励。",
+                  color: "#FF0000"
+              }
+            ],
+          })
+        }else {
+          this.setData({
+            typeOf: 'success',
+            title: '拼团成功 ! ',
+            headTextOne: '您参与的团购拼团成功',
+            headTextTwo: '订单号:12344',
+            content: [
+              {
+                  text: "感谢团长的分享",
+                  color: "#000"
+              },
+              {
+                  text: " 您也可以发起新的团购分享给需要的朋友们,",
+                  color: "#000"
+              },
+              {
+                  text: "作为新的发起人,您无需在支付本课程费用;",
+                  color: "#FF0000"
+              },
+              {
+                text: "团购成功,您将得到xxx元奖励。",
+                color: "#FF0000"
+              }                          
+            ],
+          })
+        }
+      }else {
+        setTimeout(() => {
+          wx.navigateTo({
+            url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+          })
+          wx.setNavigationBarTitle({
+            title: '拼团详情'
+          })
+        }, 1000)
+      }
+    }).fail( error => {
+      console.log('错误', eroor)
+    })    
+  },
+  //再次发起团
+  group: function () {
+    wx.showModal({
+      title: '提示',
+      content: '再次发起团',
+      success (res) {
+        if (res.confirm) {
+          console.log('用户点击确定')
+        } else if (res.cancel) {
+          console.log('用户点击取消')
+        }
+      }
+    })
+  },
+
   /**
    * 生命周期函数--监听页面加载
    */
@@ -181,26 +284,8 @@ Page({
     }).fail( (error) => {
 
     })
-    //拼团详情
-    httpRequestApi.getMygroupInfo(orderId).success( res => {
-      console.log('支付详情', res.data.data);
-      const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
-      for(var i = 0; i < surplusNum; i++) {
-        this.data.surplusList.push(1);
-      }
-      console.log(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated)
-      //时间转换
-      const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated);
-      this.setData({
-        surplusNum,
-        joinUserList: res.data.data.joinUserList,
-        surplusList: this.data.surplusList,
-        timeList,
-      })
-    }).fail( error => {
-      console.log('错误', error)
-    })
-    
+    //获取拼团信息
+    this.jionSuccess(orderId);
   },
 
   /**

+ 6 - 1
pages/groupPage/group-details/group-details.json

@@ -1 +1,6 @@
-{}
+{
+    "component": true,
+    "usingComponents": {
+        "popup": "/component/popup/popup"
+    }  
+}

+ 12 - 2
pages/groupPage/group-details/group-details.wxml

@@ -14,7 +14,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">
@@ -65,4 +66,13 @@
             <text>参团</text>
         </view>
     </view>
-</view>
+</view>
+
+<popup
+    typeOf="{{typeOf}}"
+    title="{{title}}"
+    headTextOne="{{headTextOne}}"
+    headTextTwo="{{headTextTwo}}"
+    content="{{content}}"
+    bindGroup="group"
+></popup>

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

@@ -0,0 +1,139 @@
+// pages/groupPage/make-money/make-money.js
+import httpRequestApi from '../../../utils/APIClient';
+import util from '../../../utils/util';
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    joinUserList: [],
+    surplusList: [],
+    timeList: [],
+    productId: '',
+    orderId: '',
+    groupId: ''
+  },
+  //显示分享页 
+  share: function () {
+    this.shareDialog.share();
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    wx.setNavigationBarTitle({
+      title: '邀请赚取奖学金'
+    })
+    console.log(options.id);
+    if(!options.id) {
+      return false;
+    }
+    const orderId = options.id;
+    const productId = options.productId;
+    const groupId = options.groupId;
+    this.setData({
+      orderId,
+      productId,
+      groupId
+    })
+    httpRequestApi.getMygroupInfo(orderId).success( res => {
+      console.log('支付详情', res.data.data);
+      const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
+      for(var i = 0; i < surplusNum; i++) {
+        this.data.surplusList.push(1);
+      }
+      //console.log(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated)
+      //时间转换
+      const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTimed - res.data.data.groupPurchaseOrder.gmtCreated);
+      this.setData({
+        surplusNum,
+        joinUserList: res.data.data.joinUserList,
+        surplusList: this.data.surplusList,
+        timeList,
+        productId: res.data.data.groupPurchaseOrder.productId,
+        groupId: res.data.data.groupPurchaseOrder.groupId
+      })
+    }).fail( error => {
+      console.log('错误', error)
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+    this.shareDialog = this.selectComponent("#share-dialog");
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {;
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+    if (ops.from === 'button') {
+      console.log(ops.target)
+    }
+    const productId = this.data.productId;
+    const groupId = this.data.groupId;
+    const id = this.data.orderId;
+    return {
+      title: '小学课文朗读',
+      path: `pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`,
+      imageUrl: '../../../static/groupImg/shareBg.png',
+      success: function (res) {
+        // 转发成功
+        console.log("转发成功:" + JSON.stringify(res));
+        var shareTickets = res.shareTickets;
+        // if (shareTickets.length == 0) {
+        //   return false;
+        // }
+        // //可以获取群组信息
+        // wx.getShareInfo({
+        //   shareTicket: shareTickets[0],
+        //   success: function (res) {
+        //     console.log(res)
+        //   }
+        // })
+      },
+      fail: function (res) {
+        // 转发失败
+        console.log("转发失败:" + JSON.stringify(res));
+      }
+    }
+  }
+})

+ 6 - 0
pages/groupPage/make-money/make-money.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "shareDialog": "/component/share/share"
+    }
+  }

+ 47 - 0
pages/groupPage/make-money/make-money.wxml

@@ -0,0 +1,47 @@
+<!--pages/groupPage/make-money/make-money.wxml-->
+<view class="details-head">
+    <view class="headImg">
+        <block wx:for="{{joinUserList}}" wx:key="{{index}}">
+            <view class="headImg-item">
+                <image src="{{item.avatar}}"></image>
+            </view>
+        </block>
+        <block wx:for="{{surplusList}}" wx:key="{{index}}">
+            <view class="headImg-item">
+                <image src="../../../static/groupImg/no_head.png"></image>
+            </view>  
+        </block>                   
+    </view>
+    <view class="shengyu">
+        <view class="shengyu-num">仅剩<text>{{surplusNum}}</text>个名额就拼团成功了</view>
+        <view class="shengyu-time">
+            剩余时间:
+            <view class="time">
+                <image src="../../../static/groupImg/Rectangle_31.png"></image>
+                <text>{{timeList[0]}}</text>
+            </view>
+            天
+            <block wx:for="{{timeList[1]}}" wx:key="{{index}}">
+                <view class="time">
+                    <image src="../../../static/groupImg/Rectangle_31.png"></image>
+                    <text>{{item}}</text>
+                </view>
+            </block>
+            时             
+            <block wx:for="{{timeList[2]}}" wx:key="{{index}}">
+                <view class="time">
+                    <image src="../../../static/groupImg/Rectangle_31.png"></image>
+                    <text>{{item}}</text>
+                </view>
+            </block>               
+            分             
+        </view>
+    </view>
+    <view class="invitation-btn" bindtap="share">
+        <image src="../../../static/groupImg/Invitation.png"></image>
+        <text>邀请朋友参加</text>
+    </view>
+</view>  
+
+<canvas canvas-id="myCanvas" style="width:370px; height: 507px; position: absolute; left: -99rpx; top: -999rpx;"></canvas>
+<shareDialog id="share-dialog" bindcustomevent="eventListener"/>

+ 97 - 0
pages/groupPage/make-money/make-money.wxss

@@ -0,0 +1,97 @@
+/* pages/groupPage/make-money/make-money.wxss */
+.details-head {
+    width: 100%;
+    height: 78%;
+    margin-top: 12rpx;
+    background: #fff;
+}
+
+.headImg {
+    display: flex;
+    flex-wrap: wrap;
+    padding: 40rpx 0;
+    box-sizing: border-box;
+}
+
+.headImg-item {
+    width: 106rpx;
+    height: 106rpx;
+    border-radius: 50%;
+    margin: 20rpx 22rpx;
+}
+
+.headImg-item image {
+    width: 100%;
+    height: 100%;
+    border-radius: 50%;
+}
+
+.shengyu {
+ display: flex;
+ flex-direction: column;   
+ color: #696969;
+}
+
+.shengyu-num {
+    text-align:center;    
+}
+
+.shengyu-num text {
+    color: #FF4330;
+}
+
+.shengyu-time {
+    display: flex;
+    justify-content: center;
+    align-items: center; 
+    margin-top: 8rpx;  
+}
+
+.shengyu-time .time {
+    position: relative;
+    width: 20rpx;
+    height: 40rpx;
+    margin:  0 8rpx;
+}
+
+.shengyu-time .time image {
+    width: 24rpx;
+    height: 40rpx;
+}
+
+.shengyu-time .time  text{
+    position: absolute;
+    left: 2rpx;
+    top: 0;
+    z-index: 2;
+    color: #fff;
+    font-size: 28rpx;
+}
+
+.invitation-btn {
+    position: absolute;
+    left: 50%;
+    top: 65%;
+    transform: translate(-50%);
+    width: 434rpx;
+    height: 80rpx;
+}
+
+.invitation-btn image{
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+}
+
+.invitation-btn text{
+    position: absolute;
+    width: 100%;
+    height: 100%;
+    display: inline-block;
+    text-align: center;
+    line-height: 80rpx;
+    z-index: 2;
+    color: #fff;
+}

+ 90 - 1
pages/groupPage/my-group/my-group.js

@@ -6,7 +6,15 @@ Page({
    * 页面的初始数据
    */
   data: {
-    myGroupList: []
+    myGroupList: [],
+    typeOf:'',
+    title: '',
+    headTextOne: '',
+    headTextTwo: '',
+    content: [],    
+    productId: '',
+    orderId: '',
+    groupId: ''
   },
     //跳转到团购详情页
   collageDetails: function ({currentTarget}) {
@@ -29,11 +37,92 @@ Page({
       this.setData({
         myGroupList: res.data.data.list
       })
+      res.data.data.list.forEach(element => {
+        console.log(element.status)
+        if(element.status == 'successed') {
+          this.setData({
+            productId: element.productId,
+            orderId: element.id,
+            groupId: element.groupId
+          })
+          if(wx.getStorageSync(uid) == element.organizer) {
+            this.setData({
+              typeOf: 'success',
+              title: '恭喜 !',
+              headTextOne: '您发起的团购拼团成功',
+              content: [
+                {
+                    text: "领袖体质魅力无穷!",
+                    color: "#000"
+                },
+                {
+                    text: " 您可以继续发起新的团购,",
+                    color: "#000"
+                },
+                {
+                  text: " 不再需要支付本课程费用,拼团成功,",
+                  color: "#FF9B00"
+                },                          
+                {
+                    text: " 您将得到xxx元奖励。",
+                    color: "#FF0000"
+                }
+              ],
+            })
+          }else {
+            this.setData({
+              typeOf: 'success',
+              title: '拼团成功 ! ',
+              headTextOne: '您参与的团购拼团成功',
+              headTextTwo: '订单号:12344',
+              content: [
+                {
+                    text: "感谢团长的分享",
+                    color: "#000"
+                },
+                {
+                    text: " 您也可以发起新的团购分享给需要的朋友们,",
+                    color: "#000"
+                },
+                {
+                    text: "作为新的发起人,您无需在支付本课程费用;",
+                    color: "#FF0000"
+                },
+                {
+                  text: "团购成功,您将得到xxx元奖励。",
+                  color: "#FF0000"
+                }                          
+              ],
+            })
+          }
+        }
+      });
     }).fail( error => {
       console.log('错误', error)
     })
   },
 
+  //再次发起团
+  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}`
+    })  
+  },
+
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 6 - 1
pages/groupPage/my-group/my-group.json

@@ -1 +1,6 @@
-{}
+{
+    "component": true,
+    "usingComponents": {
+        "popup": "/component/popup/popup"
+    }  
+}

+ 9 - 0
pages/groupPage/my-group/my-group.wxml

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

+ 9 - 0
utils/APIClient.js

@@ -236,6 +236,15 @@ module.exports = {
 			uid: wx.getStorageSync('uid')
 		}).url(url).send();
 	},
+	//团购是否成功
+	groupSuccess (orderId) {
+		let url = getBaseUrl(`wx/groupPurchase/joinStatus`);
+		return request.getInstance().header({
+			uid: wx.getStorageSync('uid')
+		}).url(url).data({
+			orderId
+		}).send();
+	},	
 	// 发起奖励
 	rewardMoney(uid, data){
 		let url = getBaseUrl(`wx/wallet/award`);