Explorar el Código

Merge branch 'dongyuan' of http://gogs.efunbox.cn:3000/Rorschach/reader into dongyuan

dongyuan0658 hace 6 años
padre
commit
90ebe0ac62

+ 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>

+ 76 - 51
component/share/share.js

@@ -15,7 +15,11 @@ Component({
    */
   data: {
     shareFlag: true,
-    imgUrls: ''
+    imgUrls: '',
+    avatar: '',
+    author: '',
+    iconImg: '',
+    title: '',
   },
 
   /**
@@ -33,44 +37,59 @@ Component({
       ctx.setFillStyle('#fff')
       ctx.fill()
       ctx.arc(185, 48, 37, 0, 2 * Math.PI, false)
-      ctx.clip();//画了圆 再剪切  原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内  
-      ctx.drawImage('../../../static/groupImg/Bitmap1.png', 148, 8, 100, 100);   //插入图片  
+      ctx.clip(); //画了圆 再剪切  原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内  
+      ctx.drawImage(this.data.avatar, 148, 8, 100, 100); //插入图片  
       ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 可以继续绘制
       ctx.setFontSize(20)
-      ctx.setFillStyle('#000')
-      ctx.fillText('喔喔', 166, 115)
+      ctx.setFillStyle('#535353')
+      ctx.fillText(this.data.author, (370 - ctx.measureText(this.data.author).width) / 2, 115)
       ctx.setFillStyle('#FF4400')
-      ctx.fillText('郎朗读书声是世上最美的声音', 50, 138) 
-      ctx.drawImage('../../../static/groupImg/Bitmap1.png', 9, 156, 352, 145);  
-      ctx.setFontSize(18)
-      ctx.setFillStyle('#000')
-      ctx.fillText('一年级语文上学期', 12, 329)
-      ctx.drawImage('../../../static/groupImg/Combined Shape.png', 11, 348, 196, 65);
-      ctx.drawImage('../../../static/groupImg/Rectangle 41.png', 134, 358, 59, 20);
-      ctx.setFontSize(14)  
-      ctx.setFillStyle('#fff')
-      ctx.fillText('五人团', 149, 373) 
-      ctx.setFontSize(16)  
-      ctx.setFillStyle('#A95A00')
-      ctx.fillText('原价', 24, 373)
-      ctx.setStrokeStyle('red')
-      ctx.moveTo(64, 368)
-      ctx.lineTo(114, 368)
-      ctx.stroke()
-      ctx.fillText('¥99元', 64, 373)
-      ctx.setFontSize(18)
-      ctx.fillText('团购价仅需', 20, 403)
-      ctx.fillText('元', 144, 403)
-      ctx.setFontSize(20)  
-      ctx.setFillStyle('red')
-      ctx.fillText('¥1', 109, 403) 
-      ctx.drawImage('../../../static/groupImg/share_bottom.png', 3, 419, 370, 192);  
-      ctx.setFontSize(20)
-      ctx.setFillStyle('red')
-      ctx.fillText('名额有限,售完截止', 9, 467)
-      ctx.setFontSize(18)
-      ctx.setFillStyle('#000')
-      ctx.fillText('长按识别二维码参加团购', 9, 493)
+      if (this.data.shareType === 'works') {
+        ctx.fillText('已使出洪荒之力,声情并茂的为', (370 - ctx.measureText('已使出洪荒之力,声情并茂的为').width) / 2, 138)
+        ctx.fillText(`《${this.data.title}》`, (370 - ctx.measureText(`《${this.data.title}》`).width) / 2, 160)
+        ctx.fillText(`配了一段惊世之作`, (370 - ctx.measureText(`配了一段惊世之作`).width) / 2, 182)
+        ctx.drawImage(this.data.iconImg, 9, 205, 352, 145);
+        ctx.setFontSize(18)
+        ctx.setFillStyle('#000')
+        ctx.drawImage('../../../static/groupImg/share_bottom.png', 3, 419, 370, 192);
+        ctx.setFontSize(20)
+        ctx.setFillStyle('red')
+        ctx.fillText('为TA疯狂打CALL', 9, 467)
+        ctx.setFontSize(18)
+        ctx.setFillStyle('#000')
+        ctx.fillText('长按识别二维码,快去听听', 9, 493)
+
+      } else {
+        ctx.fillText('郎朗读书声是世上最美的声音', 50, 138)
+        ctx.drawImage('../../../static/groupImg/Combined Shape.png', 11, 348, 196, 65);
+        ctx.drawImage('../../../static/groupImg/Rectangle 41.png', 134, 358, 59, 20);
+        ctx.setFontSize(14)
+        ctx.setFillStyle('#fff')
+        ctx.fillText('五人团', 149, 373)
+        ctx.setFontSize(16)
+        ctx.setFillStyle('#A95A00')
+        ctx.fillText('原价', 24, 373)
+        ctx.setStrokeStyle('red')
+        ctx.moveTo(64, 368)
+        ctx.lineTo(114, 368)
+        ctx.stroke()
+        ctx.fillText('¥99元', 64, 373)
+        ctx.setFontSize(18)
+        ctx.fillText('团购价仅需', 20, 403)
+        ctx.fillText('元', 144, 403)
+        ctx.setFontSize(20)
+        ctx.setFillStyle('red')
+        ctx.fillText('¥1', 109, 403)
+        ctx.drawImage('../../../static/groupImg/share_bottom.png', 3, 419, 370, 192);
+        ctx.setFontSize(20)
+        ctx.setFillStyle('red')
+        ctx.fillText('名额有限,售完截止', 9, 467)
+        ctx.setFontSize(18)
+        ctx.setFillStyle('#000')
+        ctx.fillText('长按识别二维码参加团购', 9, 493)
+      }
+
+
       ctx.drawImage('../../../static/groupImg/code.png', 217, 374, 135, 135);
       ctx.draw(true, function (res) {
         wx.canvasToTempFilePath({
@@ -81,30 +100,36 @@ Component({
           destWidth: 370,
           destHeight: 507,
           canvasId: 'myCanvas',
-          success:(res) => {
-              console.log(res.tempFilePath)
-              // wx.saveImageToPhotosAlbum({
-              //   filePath: res.path,
-              //   success(res) {
-              //     console.log(res);
-              //    }
-              // })
-              that.setData({
-                imgUrls: res.tempFilePath
-              })
+          success: (res) => {
+            console.log(res.tempFilePath)
+            // wx.saveImageToPhotosAlbum({
+            //   filePath: res.path,
+            //   success(res) {
+            //     console.log(res);
+            //    }
+            // })
+            that.setData({
+              imgUrls: res.tempFilePath
+            })
           }
         })
       })
     },
-    share: function () {
+    share: function (data) {
+      console.log(this.data)
+      console.log(data)
       this.setData({
-        shareFlag: !this.data.shareFlag
+        shareFlag: !this.data.shareFlag,
+        avatar: data.avatar,
+        author: data.author,
+        iconImg: data.iconImg,
+        title: data.title,
       })
     },
     PreservationImg: function () {
       wx.saveImageToPhotosAlbum({
         filePath: this.data.imgUrls,
-        success(res) { 
+        success(res) {
           console.log('保存成功')
         }
       })
@@ -113,4 +138,4 @@ Component({
       this.triggerEvent('customevent', {})
     }
   }
-})
+})

+ 1 - 1
component/share/share.wxml

@@ -13,7 +13,7 @@
        </view>
    </view>
    <view class="share-img" wx:if="{{imgUrls}}">
-       <image class="img" src="{{imgUrls}}"></image>
+       <cover-image class="img" src="{{imgUrls}}"></cover-image>
        <view class="Preservation">
            <image class="PreservationBg" src="../../static/groupImg/Preservation.png"></image>
            <text bindtap="PreservationImg">点我保存,并分享至朋友圈</text>

+ 1 - 1
component/share/share.wxss

@@ -10,7 +10,7 @@
 }
 
 .btn {
-    position: absolute;
+    position: fixed;
     bottom: 0;
     width: 100%;
     height: 290rpx;

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

@@ -44,6 +44,7 @@ Page({
   },
   //显示分享页 
   share: function () {
+    console.log(this.shareDialog)
     this.shareDialog.share();
   },
   /**
@@ -88,6 +89,7 @@ Page({
    */
   onReady: function () {
     this.shareDialog = this.selectComponent("#share-dialog");
+    
   },
 
   /**

+ 0 - 1
pages/groupPage/collage-details/collage-details.wxml

@@ -63,7 +63,6 @@
 <canvas canvas-id="myCanvas" style="width:370px; height: 507px; position: absolute; left: -99rpx; top: -999rpx;"></canvas>
 <shareDialog id="share-dialog" bindcustomevent="eventListener"/>
 
-<shareDialog id="share-dialog"/>
 <popup
     typeOf="sendSuccess"
     title="报告团长"

+ 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>

+ 38 - 16
pages/main/class/class.js

@@ -1,5 +1,7 @@
 import httpRequestApi from '../../../utils/APIClient';
-import {formatDate} from '../../../utils/util';
+import {
+  formatDate
+} from '../../../utils/util';
 Page({
   data: {
     fullScreenBtn: false,
@@ -9,7 +11,11 @@ Page({
     title: '',
     poster: '',
     works: [],
-    total: ''
+    total: '',
+    title: '',
+    id: '',
+    iconImg: '',
+    collectFlag: false,
   },
   onLoad: function (option) {
     console.log(option);
@@ -20,18 +26,30 @@ Page({
       title: option.title,
       id: option.id
     })
-    let uid = wx.getStorageSync('uid');;
 
-    httpRequestApi.getClassDetail(uid, option.id).success(res => {
+    this.uid = wx.getStorageSync('uid');;
+
+    httpRequestApi.getClassDetail(this.uid, option.id).success(res => {
       console.log(res);
       this.setData({
         title: res.data.data.title,
-        videoUrl: res.data.data.playUrl
+        videoUrl: res.data.data.playUrl,
+        iconImg: res.data.data.iconImg
+      })
+      this.getReadInfo(1, 10);
+      this.checkLike();
+    })
+  },
+  // 检查是否收藏
+  checkLike: function () {
+    httpRequestApi.classIsLike(this.uid, {
+      targetCode: this.data.id
+    }).success(res => {
+      this.setData({
+        collectFlag: res.data.data
       })
-      this.getReadInfo(1,10);
     })
   },
-
   goToReading: function () {
     let id = this.data.id;
     let title = this.data.title;
@@ -50,22 +68,26 @@ Page({
     })
   },
   collect: function (e) {
-    let uid =  wx.getStorageSync('uid');
+    // let uid =  wx.getStorageSync('uid');
     let data = {
-      
+      targetCode: this.data.id,
+      title: this.data.title,
+      iconImg: this.data.iconImg
     }
-    httpRequestApi.collectBook(uid, data).success(res => {
-      console.log(res);
+    httpRequestApi.collectClass(this.uid, data).success(res => {
+      this.setData({
+        collectFlag: !this.data.collectFlag
+      })
     })
   },
-  getReadInfo: function(pageNo,pageSize){
-    const uid =  wx.getStorageSync('uid');
+  getReadInfo: function (pageNo, pageSize) {
+    // const uid =  wx.getStorageSync('uid');
     const data = {
-      lessonId: 1 ,
+      lessonId: 1,
       pageNo: pageNo,
       pageSize: pageSize
     };
-    httpRequestApi.getClassRead(uid,data).success(res=>{
+    httpRequestApi.getClassRead(this.uid, data).success(res => {
       const readInfo = res.data.data.list;
       const readTemp = [];
       readInfo.forEach(item => {
@@ -85,7 +107,7 @@ Page({
     });
   },
   // 下拉加载
-  scrollUpdate:function(e){
+  scrollUpdate: function (e) {
     console.log(e)
   }
 })

+ 3 - 3
pages/main/class/class.wxml

@@ -19,9 +19,9 @@
     </scroll-view>
     <view class="footSection">
         <image class="blackbord" src="../../../static/image/blackbord.png" />
-        <view class="collectBtn footerBtn">
-            <image src="../../../static/image/collected.png" />
-            <text>收藏</text>
+        <view class="collectBtn footerBtn" bindtap="collect">
+            <image src=" {{collectFlag ? '../../../static/image/collected.png' : '../../../static/image/no_collect.png'}}" />
+            <text>{{collectFlag ? '取消收藏' : '收藏'}}</text>
         </view>
         <view class="readingBtn footerBtn" bindtap="goToReading">
             <image class="microphone" src="../../../static/image/microphone.png" />

+ 2 - 1
pages/main/singleBook/singleBook.js

@@ -11,12 +11,13 @@ Page({
             title: options.title
         })
         const uid= wx.getStorageSync('uid');
+        console.log(options.id)
         httpRequestApi.getBookDetail(uid, options.id).success((res) => {
             console.log(res.data.data)
             const bookInfo = res.data.data.product;
             const lessonList = res.data.data.lessonList;
             this.setData({
-                titleIcon: bookInfo.iconImg,
+                titleIcon: bookInfo.bgImg,
                 title: bookInfo.title,
                 bookInfo: bookInfo.description
             })

+ 16 - 1
pages/social/replyDetail/replyDetail.js

@@ -39,6 +39,7 @@ Page({
                 temp.text = item.content;
                 temp.time = formatDate(item.gmtCreated,3);
                 temp.likes = 0;
+                temp.id = item.postId;
                 temp.avatar = item.user.avatar;
                 replyTemp.push(temp);
                 console.log(replyTemp);
@@ -47,5 +48,19 @@ Page({
                 comment: replyTemp
             })
         });
-    }
+    },
+      // 点赞评论
+      likeCommend: function (e) {
+        console.log(e);
+        let uid = wx.getStorageSync('uid');
+        let followUid = e.currentTarget.dataset.id;
+        let index = e.currentTarget.dataset.index;
+        httpRequestApi.likeCommend(uid, followUid).success(res => {
+            console.log(res);
+            const str = `comment[${index}].likes`;
+            this.setData({
+                [str]: res.data.data.favors
+            })
+        });
+    },
 })

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

@@ -9,8 +9,8 @@
             <view class="btnWrapper">
                 <image class="commentBtn" src="../../../static/image/comment.png" wx:if="{{index===0}}" />
                 <text class="commentText" wx:if="{{index===0}}">评论</text>
-                <image class="likeBtn" src="../../../static/image/like.png" />
-                <text class="likeText">{{item.likes}}</text>
+                <!-- <image class="likeBtn" data-index="{{index}}" data-likes="{{item.likes}}" data-id="{{item.id}}" src="../../../static/image/like.png" bindtap="likeCommend" /> -->
+                <!-- <text class="likeText" >{{item.likes}}</text> -->
             </view>
         </view>
     </view>

+ 84 - 25
pages/social/works/works.js

@@ -16,23 +16,31 @@ Page({
         replyList: [],
         howMuch: '2000',
         moneySelect: 'moneySelect',
-        moneyNormal: 'moneyNormal'
+        moneyNormal: 'moneyNormal',
+        ifReward: false,
+        id: '',
+        // shareFlag: false
     },
     onLoad: function (option) {
-        if (option.title) {
-            wx.setNavigationBarTitle({
-                title: option.title //页面标题为路由参数
-            })
-            this.setData({
-                title: option.title,
-                id: option.id
-            })
-        }
-        let uid = wx.getStorageSync('uid');
-        this.getWorks(uid, option.id);
+        console.log(option)
+
+        wx.setNavigationBarTitle({
+            title: option.title //页面标题为路由参数
+        })
+
+        this.setData({
+            title: option.title,
+            id: option.id
+        })
+        this.uid = wx.getStorageSync('uid');
+        this.getWorks(this.uid, option.id);
     },
+    // onReady: function () {
+
+    // },
     getWorks: function (uid, id) {
         httpRequestApi.getWorksDetail(uid, id).success((res) => {
+            console.log(res);
             const others = res.data.data.otherRead;
             const author = res.data.data.user;
             const works = res.data.data.userRead;
@@ -49,7 +57,8 @@ Page({
                 authorAvatar: author.avatar,
                 authorUid: author.uid,
                 videoSrc: works.originVideo,
-                audioSrc: works.audioPath
+                audioSrc: works.audioPath,
+                iconImg: works.iconImg
             })
             // 设置音频路径
             this.innerAudioContext = wx.createInnerAudioContext();
@@ -60,8 +69,31 @@ Page({
             this.getReply();
         });
     },
+    likeWorks: function (e) {
+        httpRequestApi.likeWorks(this.uid, this.data.id).success(res => {
+            console.log(this.uid)
+        });
+    },
+    // 弹出分享框
+    openShare: function (e) {
+        // this.setData({
+        //     shareFlag: !this.data.shareFlag
+        // })
+        this.shareDialog = this.selectComponent("#share-dialog");
+        const data = {
+            avatar: this.data.authorAvatar,
+            author: this.data.author,
+            iconImg: this.data.iconImg,
+            title: this.data.title,
+            // tip: this.data.tip,
+        }
+        this.shareDialog.share(data);
+    },
     videoPlay: function () {
         this.innerAudioContext.play();
+        httpRequestApi.playWorks(this.uid, this.data.id).success(res => {
+
+        })
     },
     videoEnd: function () {
         this.innerAudioContext.stop();
@@ -87,12 +119,26 @@ Page({
         }
     },
     follow: function () {
-        let uid = wx.getStorageSync('uid');
+        // let uid = wx.getStorageSync('uid');
         let followUid = 2;
-        httpRequestApi.followUser(uid, followUid).success((res) => {
+        httpRequestApi.followUser(this.uid, followUid).success((res) => {
             console.log(res)
         });
     },
+    // 点赞评论
+    likeCommend: function (e) {
+        console.log(e);
+        // let uid = wx.getStorageSync('uid');
+        let followUid = e.currentTarget.dataset.id;
+        let index = e.currentTarget.dataset.index;
+        httpRequestApi.likeCommend(this.uid, followUid).success(res => {
+            console.log(res);
+            const str = `replyList[${index}].likes`;
+            this.setData({
+                [str]: res.data.data.favors
+            })
+        });
+    },
     // 去其他用户的作品页
     goToOthers: function (e) {
         wx.navigateTo({
@@ -101,11 +147,11 @@ Page({
     },
     // 查询回复
     getReply: function () {
-        let uid = wx.getStorageSync('uid');
+        // let uid = wx.getStorageSync('uid');
         let columnId = this.data.id;
         let pageNo = 1;
         let pageSize = 10;
-        httpRequestApi.getReply(uid, columnId, pageNo, pageSize).success((res) => {
+        httpRequestApi.getReply(this.uid, columnId, pageNo, pageSize).success((res) => {
             console.log(res.data.data.list);
             const replyList = res.data.data.list;
             const replyTemp = [];
@@ -117,6 +163,7 @@ Page({
                 temp.id = item.id;
                 temp.replyCount = item.replyCount;
                 temp.time = formatDate(item.gmtCreated, 3);
+                temp.likes = item.postsAttributeInfo.favors || 0;
                 console.log(temp.time)
                 replyTemp.push(temp);
             });
@@ -145,32 +192,37 @@ Page({
     sendHandler: function () {
         console.log(this.data.inputValue);
         if (this.data.inputValue !== '') {
-            let uid = wx.getStorageSync('uid');
+            // let uid = wx.getStorageSync('uid');
             let data = {
                 "columnId": this.data.id,
                 colunmNames: 'what',
                 "detailDesc": this.data.inputValue
             }
-            httpRequestApi.postReply(uid, data).success(res => {
+            httpRequestApi.postReply(this.uid, data).success(res => {
                 console.log(res);
             });
         }
     },
     // 选择金额
-    setMoney: function(e){
+    setMoney: function (e) {
         this.setData({
             howMuch: e.currentTarget.dataset.money
         })
     },
+    reward: function () {
+        this.setData({
+            ifReward: true
+        })
+    },
     // 奖励
     rewardMoney: function () {
         console.log(this.data.authorUid);
         const data = {
             targetUid: this.data.authorUid,
-            amount: "50"
+            amount: this.data.howMuch
         }
-        let uid = wx.getStorageSync('uid');
-        httpRequestApi.rewardMoney(uid, data).success(res => {
+        // let uid = wx.getStorageSync('uid');
+        httpRequestApi.rewardMoney(this.uid, data).success(res => {
             console.log(res);
             this.payMoneyt(res.data.data);
         })
@@ -192,15 +244,22 @@ Page({
                     content: '支付成功',
                     success(res) {
                         if (res.confirm) {
-                            console.log('点击确定')
+                            this.setData({
+                                ifReward: false
+                            })
                         } else if (res.cancel) {
-                            console.log('取消')
+                            this.setData({
+                                ifReward: false
+                            })
                         }
                     }
                 })
 
             },
             'fail': function (res) {
+                this.setData({
+                    ifReward: false
+                })
                 console.log('支付失败', res)
             }
         })

+ 7 - 1
pages/social/works/works.json

@@ -1 +1,7 @@
-{}
+{
+    "component": true,
+    "usingComponents": {
+        "shareDialog": "/component/share/share",
+        "popup": "/component/popup/popup"
+    }
+}

+ 11 - 7
pages/social/works/works.wxml

@@ -3,7 +3,7 @@
     <view class="readAuthorSection">
         <image class="avatar" src="{{authorAvatar}}" />
         <text class="nickName">{{author}}</text>
-        <view class="like">
+        <view class="like" bindtap="likeWorks">
             <image src="../../../static/image/liked.png" />
             <text class="likeBtn">点赞</text>
         </view>
@@ -42,8 +42,8 @@
             <view class="btnWrapper">
                 <image class="commentBtn" src="../../../static/image/comment.png" />
                 <text class="commentText">评论</text>
-                <image class="likeBtn" src="../../../static/image/like.png" />
-                <text class="likeText">165</text>
+                <image class="likeBtn" src="../../../static/image/like.png" data-index="{{index}}" data-likes="{{item.likes}}" data-id="{{item.id}}" bindtap="likeCommend" />
+                <text class="likeText">{{item.likes}}</text>
             </view>
         </view>
     </view>
@@ -57,15 +57,17 @@
             <image class="microphone" src="../../../static/image/microphone.png" />
             <text>我要朗读</text>
         </view>
-        <view class="shareBtn footerBtn">
-            <button open-type="share" plain="true" hover-class="none">
+        <view class="shareBtn footerBtn" bindtap="openShare">
+            <!-- <button open-type="share" plain="true" hover-class="none">
                 <image src="../../../static/image/share.png" />
                 <text>分享</text>
-            </button>
+            </button> -->
+            <image src="../../../static/image/share.png" />
+            <text>分享</text>
         </view>
     </view>
     <!-- 奖励弹窗 -->
-    <cover-view class="modalWrapper">
+    <cover-view class="modalWrapper" wx:if="{{ifReward}}">
         <cover-view class="rewardContent">
             <cover-image class="rewardWrapper" src="../../../static/image/reward_wrapper.png" />
             <cover-image class="rewardAvatar" src="{{authorAvatar}}" />
@@ -84,4 +86,6 @@
             <cover-view class="rewardBtn" bindtap="rewardMoney">立即奖励</cover-view>
         </cover-view>
     </cover-view>
+    <canvas canvas-id="myCanvas" style="width:370px;z-index=99999; height: 507px; position: absolute; left: -99rpx; top: -999rpx;"></canvas>
+    <shareDialog id="share-dialog" shareType = 'works'/>
 </view>

+ 3 - 3
pages/social/works/works.wxss

@@ -277,7 +277,7 @@
     margin-left: 80rpx
 }
 
-.shareBtn button {
+/* .shareBtn button {
     display: flex;
     flex-direction: column;
     outline: none;
@@ -293,12 +293,12 @@ button::after {
     height: 0;
     top: 0;
     left: 0
-}
+} */
 
 .shareBtn {
     margin-right: 80rpx;
     padding: 0;
-    background: #fff;
+    /* background: #fff; */
 }
 
 .footerBtn image {

+ 7 - 1
project.config.json

@@ -36,7 +36,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 5,
+			"current": 7,
 			"list": [
 				{
 					"id": 0,
@@ -79,6 +79,12 @@
 					"name": "concern",
 					"pathName": "pages/user/myconcern/myconcern",
 					"query": ""
+				},
+				{
+					"id": -1,
+					"name": "作品页面",
+					"pathName": "pages/social/works/works",
+					"query": "id=1541489786444388&title=铺满色巴掌的水泥道"
 				}
 			]
 		}

BIN
static/image/no_collect.png


+ 47 - 4
utils/APIClient.js

@@ -47,10 +47,10 @@ module.exports = {
 		}).send();
 	},
 	// 获取课本详情
-	getBookDetail(id) {
+	getBookDetail(uid,id) {
 		let url = getProductUrl(`wx/product/${id}`);
 		return request.getInstance().header({
-			uid: wx.getStorageSync('uid')
+			uid
 		}).url(url).send();
 	},
 	// 获取单课详情
@@ -60,6 +60,19 @@ module.exports = {
 			uid
 		}).url(url).send();
 	},
+	// 检查是否收藏过课程
+	classIsLike(uid,data){
+		let url = getProductUrl(`wx/favorites/isLike`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data(data).send();
+	},
+	getClassDetail(uid,id) {
+		let url = getProductUrl(`wx/lesson/${id}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).send();
+	},
 	// 获取单课朗读信息
 	getClassRead(uid,data){
 		let url = getBaseUrl(`wx/userRead`);
@@ -67,6 +80,13 @@ module.exports = {
 			uid
 		}).data(data).url(url).send();
 	},
+	// 作品播放了+1
+	playWorks(uid,readId){
+		let url = getBaseUrl(`wx/userRead/play/${readId}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).send();
+	},
 	// 发布作品
 	postWork(uid, data) {
 		console.log(data);
@@ -75,6 +95,13 @@ module.exports = {
 			uid
 		}).url(url).data(data).method('POST').send();
 	},
+	// 点赞作品
+	likeWorks(uid,readId){
+		let url = getBaseUrl(`wx/userRead/like/${readId}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).send();
+	},
 	// 关注用户 
 	followUser(uid, followUid) {
 		let url = getBaseUrl(`wx/fans`);
@@ -141,6 +168,13 @@ module.exports = {
 			uid
 		}).url(url).data(data).method('POST').send();
 	},
+	// 点赞评论
+	likeCommend(uid,likeUid){
+		let url = getBaseUrl(`wx/posts/attribute/${likeUid}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).method('GET').send();
+	},
 	// 发布讨论
 	postReply(uid, data){
 		let url = getBaseUrl(`wx/posts`);
@@ -179,8 +213,8 @@ module.exports = {
 		}).method('POST').send();
 	},
 	// 收藏课程
-	collectBook(uid, data){
-		let url = getBaseUrl(`wx/favorites`);
+	collectClass(uid, data){
+		let url = getProductUrl(`wx/favorites`);
 		return request.getInstance().header({
 			uid
 		}).url(url).data(data).method('POST').send();
@@ -202,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`);