浏览代码

转发功能

Rorschach 6 年之前
父节点
当前提交
51f7d4c26a

+ 1 - 0
.gitignore

@@ -1,2 +1,3 @@
 /.idea/
+/.idea
 

+ 1 - 0
app.json

@@ -5,6 +5,7 @@
     "pages/social/replyDetail/replyDetail",
     "pages/main/class/class",
     "pages/main/books/books",
+    "pages/main/week/week",
     "pages/main/singleBook/singleBook",
     "pages/main/reading/reading",
     "pages/main/searchResult/searchResult",

+ 3 - 1
component/group/group.js

@@ -22,6 +22,7 @@ export const groupInit = (that) => {
     httpRequestApi.getAllBooks(1, 10).success((res) => {
       console.log('全部课',res.data.data.list)
       that.data.groupData.bookList = res.data.data.list;
+      console.log(that.data.groupData.bookList)
       res.data.data.list.forEach(element => {
         that.data.groupData.selectFlag.push(true);
       });
@@ -104,8 +105,9 @@ export const groupInit = (that) => {
     console.log(e.currentTarget.dataset)
     let id = e.currentTarget.dataset.id;
     let title = e.currentTarget.dataset.title;
+    console.log(id)
     wx.navigateTo({
-        url: `/pages/main/singleBook/singleBook?id=${id}&title=${title}`
+        url: `/pages/groupPage/grade-details/grade-details?productId=${id}&title=${title}`
       })
   }
 }

+ 3 - 3
component/group/group.wxml

@@ -33,8 +33,8 @@
             <block wx:for="{{groupData.bookList}}" wx:key="{{index}}">
               <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>    
+                <view id="grade">{{item.subTitle}}</view>
+              </view>
             </block>          
           </view>
         </view>
@@ -58,7 +58,7 @@
           <block wx:for="{{groupData.bookList}}" wx:key="{{index}}">
               <view class="group-item" catchtap="selectImg" data-ind="{{index}}">
                 <image class="item-img" src="{{item.iconImg}}"></image>
-                <view id="grade">一年级</view>
+                <view id="grade">{{item.subTitle}}</view>
                 <image class="select-img" src="../../static/groupImg/{{groupData.selectFlag[index] ? 'bai' : 'lan'}}.png"></image>
               </view> 
           </block>

+ 7 - 2
component/hot/hot.js

@@ -37,13 +37,18 @@ export const hotInit = (that) => {
         hotInput: e.detail.value
       });
     }
-  // 打开课程页面
+  // 打开全部课本
   that.openBooks = (e) => {
     wx.navigateTo({
       url: `../main/books/books`
     })
   }
-
+  // 打开更多页面
+  that.openMore = () => {
+    wx.navigateTo({
+      url: `../main/week/week`
+    })
+  }
   // 打开课程页面
   that.openClass = (e, lessonId) => {
     if (lessonId) {

+ 1 - 1
component/hot/hot.wxml

@@ -19,7 +19,7 @@
                 <image class="recommendTag" src="../../static/image/course.png" alt="" />
                 <text>本周课程推荐</text>
             </view>
-            <view class="moreBtn" bindtap="openBooks">更多></view>
+            <view class="moreBtn" bindtap="openMore">更多></view>
         </view>
         <view class="hotWares" style="flex-direction:row;">
             <view wx:for="{{hotData.recommend}}" wx:key="{{index}}" class="hotWareCard" bindtap="openClass" data-classId="{{item.classId}}" data-title="{{item.title}}">

+ 215 - 123
component/share/share.js

@@ -15,7 +15,7 @@ Component({
    * 组件的初始数据
    */
   data: {
-    shareFlag: true,
+    shareFlag: false,
     imgUrls: '',
     avatar: '',
     author: '',
@@ -31,39 +31,184 @@ Component({
     poster: function () {
       const that = this;
       const ctx = wx.createCanvasContext('myCanvas');
-      ctx.rect(0, 0, 370, 507)
-      ctx.setFillStyle('#fff')
-      ctx.fill()
-      ctx.save()
-      ctx.beginPath()
-      ctx.setFillStyle('#fff')
-      ctx.fill()
-      ctx.arc(185, 48, 37, 0, 2 * Math.PI, false)
-      ctx.clip(); //画了圆 再剪切  原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内  
-      // wx.downloadFile({
-      //   url: this.data.avatar,
-      //   success(res) {
-      //     ctx.drawImage(res.tempFilePath, 148, 8, 100, 100);
-      //   }
-      // });
-      ctx.drawImage(this.data.avatar, 148, 8, 100, 100); //插入图片  
-      ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 可以继续绘制
-      ctx.setFontSize(20)
-      ctx.setFillStyle('#535353')
-      ctx.fillText(this.data.author, (370 - ctx.measureText(this.data.author).width) / 2, 115)
-      ctx.setFillStyle('#FF4400')
+      // 先画背景
+      this.drawBg(ctx)
+        .then(() => {
+          // 下载保存图片
+          console.log('背景画完');
+          return this.saveImg(ctx);
+        })
+        .then(() => {
+          // 画头像和作者||发起者
+          console.log('头像画完');
+          return this.drawAuthor(ctx);
+        })
+        .then(() => {
+          console.log(this.data.shareType)
+          if (this.data.shareType === 'works') {
+            // 分享作品的主题内容
+            console.log('主题画完');
+            return this.drawWorksGut(ctx)
+          } else {
+            return this.drawGroupGut(ctx)
+          }
+        })
+        .then(() => {
+          ctx.drawImage('../../../static/groupImg/code.png', 217, 374, 135, 135);
+          console.log(ctx)
+          ctx.draw(true, function (res) {
+            wx.canvasToTempFilePath({
+              x: 0,
+              y: 0,
+              width: 370,
+              height: 507,
+              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
+                },()=>{
+                  wx.hideLoading();
+                })
+              },
+              fail: (res) => {
+                console.log(res)
+              }
+            })
+          })
+        })
+
+
+
+
+    },
+    share: function (data) {
       if (this.data.shareType === 'works') {
+
+        this.setData({
+          shareFlag: !this.data.shareFlag,
+          avatar: data.avatar,
+          author: data.author,
+          iconImg: data.iconImg,
+          title: data.title,
+          // path: data.path,
+          // QRData:{
+          //   page: data.path,
+          //   scene: "par=no"
+          // }
+        })
+
+      }
+      if (this.data.shareType === 'group') {
+        console.log('团购分享')
+        this.setData({
+          shareFlag: !this.data.shareFlag
+        })
+      }
+      if (this.data.shareType === 'class') {
+        console.log('课程分享')
+        this.setData({
+          shareFlag: !this.data.shareFlag
+        })
+      }
+    },
+    // 保存图片到本地
+    saveImg: function () {
+      console.log('yibuububu')
+      let download = new Promise((resolve, reject) => {
+        let downAvatar = () =>{
+          wx.downloadFile({
+            url: this.data.avatar,
+            success: (res) => {
+              console.log('下载头像成功')
+              console.log(this.data.avatar)
+              this.setData({
+                avatar: res.tempFilePath
+              })
+              resolve();
+            }
+          });
+        }
+        // resolve(()=>{
+        // 下载icon
+        wx.downloadFile({
+          url: this.data.iconImg,
+          success: (res) => {
+            console.log('下载icon成功')
+            console.log(this.data.iconImg)
+            this.setData({
+              iconImg: res.tempFilePath
+            })
+            // 下载头像
+            downAvatar();
+          }
+        });
+
+        // 生成二维码并下载
+        // httpRequestApi.createQRCode(this.data.QRData).success(res => {
+        //   console.log(data.path)
+        //   console.log(res)
+        // })
+
+        // })
+
+      })
+      return download;
+    },
+    // 先画出背景
+    drawBg: function (ctx) {
+      let background = new Promise((resolve, reject) => {
+        wx.showLoading({
+          title: '海报生成中',
+          mask: true
+        })
+        console.log('开始画背景')
+        ctx.rect(0, 0, 370, 507)
+        ctx.setFillStyle('#fff')
+        ctx.fill()
+        ctx.save()
+        ctx.beginPath()
+        ctx.setFillStyle('#fff')
+        ctx.fill()
+        ctx.arc(185, 48, 37, 0, 2 * Math.PI, false)
+        ctx.clip(); //画
+        resolve();
+      });
+      return background;
+    },
+    // 画头像和作者||发起者
+    drawAuthor: function (ctx) {
+
+      let author = new Promise((resolve, reject) => {
+        // resolve(() => {
+        console.log('开始画头像')
+        ctx.drawImage(this.data.avatar, 148, 8, 100, 100); //插入图片  
+        ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 可以继续绘制
+        ctx.setFontSize(20)
+        ctx.setFillStyle('#535353')
+        ctx.fillText(this.data.author, (370 - ctx.measureText(this.data.author).width) / 2, 115)
+        ctx.setFillStyle('#FF4400')
+        // })
+        resolve();
+      })
+      return author;
+    },
+    // 分享作品的主题内容
+    drawWorksGut: function (ctx) {
+      let works = new Promise((resolve, reject) => {
+        // resolve(() => {
+        console.log('开始画内容')
         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)
-        // 保存图片到本地
-        // wx.downloadFile({
-        //   url: this.data.iconImg,
-        //   success(res) {
-        //     console.log(res)
-        //     ctx.drawImage(res.tempFilePath, 9, 205, 352, 145);
-        //   }
-        // });
         ctx.drawImage(this.data.iconImg, 9, 205, 352, 145);
         ctx.setFontSize(18)
         ctx.setFillStyle('#000')
@@ -74,103 +219,50 @@ Component({
         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);
-      console.log(ctx)
-      ctx.draw(true, function (res) {
-        wx.canvasToTempFilePath({
-          x: 0,
-          y: 0,
-          width: 370,
-          height: 507,
-          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
-            })
-          },
-          fail: (res) => {
-            console.log(res)
-          }
-        })
+        // })
+        resolve();
       })
+      return works;
     },
-    share: function (data) {
-      console.log(this.data)
-      console.log(data)
-      // 下载icon
-      wx.downloadFile({
-        url: data.iconImg,
-        success: (res) => {
-          this.setData({
-            iconImg: res.tempFilePath
-          })
-        }
-      });
-      // 下载头像
-      wx.downloadFile({
-        url: data.avatar,
-        success: (res) => {
-          this.setData({
-            avatar: res.tempFilePath
-          })
-        }
-      });
-      // 生成二维码并下载
-      httpRequestApi.createQRCode({
-        page: data.path,
-        scene: "par=no"
-      }).success(res => {
-        console.log(data.path)
-        console.log(res)
-      })
-      this.setData({
-        shareFlag: !this.data.shareFlag,
-        // avatar: data.avatar,
-        author: data.author,
-        // iconImg: data.iconImg,
-        title: data.title,
-        path: data.path
+
+    // 分享团购的主体内容
+    drawGroupGut: function (ctx) {
+      let group = new Promise((resolve, reject) => {
+        resolve(() => {
+          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)
+        })
       })
+      return group();
     },
+
+
+    // 保存最终图片
     PreservationImg: function () {
       wx.saveImageToPhotosAlbum({
         filePath: this.data.imgUrls,

+ 1 - 1
component/share/share.wxml

@@ -1,4 +1,4 @@
-<view class="share" bindtap="share" hidden="{{shareFlag}}">
+<view class="share" bindtap="share" wx:if="{{shareFlag}}">
    <view class="btn" wx:if="{{!imgUrls}}">
        <image class="bg" src="../../static/groupImg/share.png"></image>
        <view class="share-btn">

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

@@ -61,7 +61,7 @@
     </view>
 </view> 
 <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" shareType='group' bindcustomevent="eventListener"/>
 
 <popup
     typeOf="sendSuccess"

+ 89 - 83
pages/groupPage/grade-details/grade-details.js

@@ -11,90 +11,90 @@ Page({
     title: '',
     bookInfo: '',
     lessonList: [],
-    content: [
-      {
-          text: "转发给自己的朋友们,分享好课,",
-          color: "#000"
+    content: [{
+        text: "转发给自己的朋友们,分享好课,",
+        color: "#000"
       },
       {
-          text: " 追随您一起学习进步。您的魅力不是吹的!",
-          color: "#000"
+        text: " 追随您一起学习进步。您的魅力不是吹的!",
+        color: "#000"
       },
       {
-          text: "在限定时间内内成功拼团,您将得到xx元的奖励金哦。",
-          color: "#FF4600"
+        text: "在限定时间内内成功拼团,您将得到xx元的奖励金哦。",
+        color: "#FF4600"
       }
     ]
   },
   //获取团购信息并掉起支付
-  pay: function ({ currentTarget }) {
+  pay: function ({
+    currentTarget
+  }) {
     const productId = this.data.productId;
     const groupId = currentTarget.dataset.id;
     //开始发起团购
-      httpRequestApi.SendGroupPurchas({
-        productId,
-        groupId
-      }).success( (res) =>{
-        console.log('发起团购',res);
-        // wx.navigateTo({
-        //   url: `/pages/groupPage/collage-details/collage-details`
-        // })
-        if(res.data.message) {
-          wx.showModal({
-            title: '提示',
-            content: res.data.message,
-            success (res) {
-              if (res.confirm) {
-                console.log('用户点击确定')
-              } else if (res.cancel) {
-                console.log('用户点击取消')
-              }
+    httpRequestApi.SendGroupPurchas({
+      productId,
+      groupId
+    }).success((res) => {
+      console.log('发起团购', res);
+      // wx.navigateTo({
+      //   url: `/pages/groupPage/collage-details/collage-details`
+      // })
+      if (res.data.message) {
+        wx.showModal({
+          title: '提示',
+          content: res.data.message,
+          success(res) {
+            if (res.confirm) {
+              console.log('用户点击确定')
+            } else if (res.cancel) {
+              console.log('用户点击取消')
             }
-          })
-          return false;
-        }
-        //掉起支付
-        this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrder.id);
-      }).fail( (error) => {
-        
-      })
+          }
+        })
+        return false;
+      }
+      //掉起支付
+      this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrder.id);
+    }).fail((error) => {
+
+    })
   },
   //支付
   prePayMap: function (prePayMap, orderId) {
     console.log(prePayMap)
     const that = this;
     //console.log(new Date().getTime())
-    wx.requestPayment(
-      {
-        'appId': prePayMap.appId,
-        'timeStamp': prePayMap.timeStamp,
-        'nonceStr': prePayMap.nonceStr,
-        'package': prePayMap.package,
-        'signType': 'MD5',
-        'paySign': prePayMap.sign,
-        'success':function(res){
-          console.log('支付成功')
-          wx.showModal({
-            title: '提示',
-            content: '支付成功',
-            success (res) {
-              that.popup.close();
-              setTimeout(() => {
-                wx.navigateTo({
-                  url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
-                })
-                wx.setNavigationBarTitle({
-                  title: '拼团详情'
-                })
-              }, 1000)
-            }
-          })
+    wx.requestPayment({
+      'appId': prePayMap.appId,
+      'timeStamp': prePayMap.timeStamp,
+      'nonceStr': prePayMap.nonceStr,
+      'package': prePayMap.package,
+      'signType': 'MD5',
+      'paySign': prePayMap.sign,
+      'success': function (res) {
+        console.log('支付成功')
+        wx.showModal({
+          title: '提示',
+          content: '支付成功',
+          success(res) {
+            that.popup.close();
+            setTimeout(() => {
+              wx.navigateTo({
+                url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+              })
+              wx.setNavigationBarTitle({
+                title: '拼团详情'
+              })
+            }, 1000)
+          }
+        })
 
-        },
-        'fail':function(res){
-          console.log('支付失败', res)
-        }
-      })
+      },
+      'fail': function (res) {
+        console.log('支付失败', res)
+      }
+    })
   },
 
 
@@ -103,49 +103,55 @@ Page({
    */
   onLoad: function (options) {
     wx.setNavigationBarTitle({
-        title: options.title
+      title: options.title
     })
     const productId = options.productId;
-    if(productId) {
+    if (productId) {
       this.setData({
         productId
       })
     }
     //课本详情
-    httpRequestApi.getBookDetail(wx.getStorageSync('uid'),productId).success( (res) =>{
-      console.log('课本详情',res.data.data);
+    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;
       this.setData({
-          titleIcon: bookInfo.bgImg,
-          title: bookInfo.title,
-          bookInfo: bookInfo.description
+        titleIcon: bookInfo.bgImg,
+        title: bookInfo.title,
+        bookInfo: bookInfo.description
       })
       const lessonTemp = [];
       lessonList.forEach(item => {
-          const temp = {};
-          temp.id = item.id;
-          temp.title = item.title;
-          temp.readNum = item.readCount;
-          lessonTemp.push(temp);
+        const temp = {};
+        temp.id = item.id;
+        temp.title = item.title;
+        temp.readNum = item.readCount;
+        lessonTemp.push(temp);
       });
       this.setData({
-          lessonList: lessonTemp
+        lessonList: lessonTemp
       });
-    }).fail( (error) => {
+    }).fail((error) => {
 
     })
     //支付详情
-    httpRequestApi.getGroupPurchaseInfo(productId).success( (res) =>{
-      console.log('支付详情',res.data.data);
+    httpRequestApi.getGroupPurchaseInfo(productId).success((res) => {
+      console.log('支付详情', res.data.data);
       this.setData({
         payList: res.data.data
       })
-    }).fail( (error) => {
+    }).fail((error) => {
 
     })
   },
-
+  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}`
+    })
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

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

@@ -1,4 +1,4 @@
-<!--pages/grade-details/grade-details.wxml-->
+<!-- pages/grade-details/grade-details.wxml -->
 <view class="group-details">
     <scroll-view scroll-y="{{true}}">
         <view class="grade-details">
@@ -11,16 +11,16 @@
             <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>
         </view>
     </scroll-view>
     <view class="group-btn">
         <image class="bg1" src="../../../static/groupImg/Rectangle_9.png"></image>
         <image class="bg2" src="../../../static/groupImg/Rectangle_9.png"></image>
-        <block wx:for="{{payList}}" wx:key="{{index}}" >
+        <block wx:for="{{payList}}" wx:key="{{index}}">
             <view class="Price" bindtap="pay" data-id="{{item.id}}">
                 <text>¥{{item.price / 100}}</text>
                 <text>{{item.headcount}}人团</text>
@@ -28,11 +28,4 @@
         </block>
     </view>
 </view>
-
-<popup
-    id="popup"
-    typeOf="sendSuccess"
-    title="报告团长"
-    headTextOne="您发起的团购已经成立,订单号:12345"
-    content="{{content}}"
-></popup>
+<popup id="popup" typeOf="sendSuccess" title="报告团长" headTextOne="您发起的团购已经成立,订单号:12345" content="{{content}}"></popup>

+ 3 - 0
pages/groupPage/my-group/my-group.js

@@ -33,6 +33,9 @@ Page({
    */
   onLoad: function (options) {
     httpRequestApi.getMygroup().success((res) => {
+      if(!res.data.data.list){
+        return
+      }
       console.log('我的团', res.data.data.list)
       this.setData({
         myGroupList: res.data.data.list

+ 26 - 0
pages/index/index.js

@@ -95,7 +95,33 @@ Page({
       // });
     }
   },
+  aa: function(){
+    let a = new Promise((resolve, reject)=>{
+      resolve(console.log('aa'))
+    });
+    return a;
+  },
+  bb: function(){
+    let b = new Promise((resolve, reject)=>{
+      resolve(console.log('bb'))
+    });
+    return b
+  },
+  cc: function(){
+    let c = new Promise((resolve, reject)=>{
+      console.log('cc')
+    });
+    return c
+  },
   onLoad: function (options) {
+    this.aa().then(()=>{
+      console.log(1)
+      return this.bb()
+    }).then(()=>{
+      console.log(2)
+      return this.cc()
+    })
+    
     this.uid = wx.getStorageSync('uid');
     wx.getSystemInfo({
       success: (res) => {

+ 3 - 2
pages/main/books/books.js

@@ -27,9 +27,10 @@ Page({
         console.log(e.currentTarget.dataset)
         let id = e.currentTarget.dataset.id;
         let title = e.currentTarget.dataset.title;
-
+        
         wx.navigateTo({
-            url: `../singleBook/singleBook?id=${id}&title=${title}`
+            // url: `../singleBook/singleBook?id=${id}&title=${title}`
+            url: `../../groupPage/grade-details/grade-details?productId=${id}&title=${title}`
           })
     }
 })

+ 30 - 4
pages/main/class/class.js

@@ -58,6 +58,32 @@ Page({
       url: `../../main/reading/reading?id=${id}`
     })
   },
+  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,
+      path: `pages/social/works/works?id=${this.data.id}&title=${this.data.title}`
+      // tip: this.data.tip,
+    }
+    this.shareDialog.share(data);
+  },
+  onShareAppMessage: function (res) {
+    if (res.from === 'button') {
+        // 来自页面内转发按钮
+        console.log(res.target)
+    }
+    return {
+        title: this.data.title,
+        path: `pages/main/class/class?id=${this.data.id}&title=${this.data.title}`,
+        imageUrl: this.data.iconImg
+    }
+},
   goToWorks: function (e) {
     this.videoCtx = wx.createVideoContext('myVideo', this);
     this.videoCtx.stop();
@@ -109,14 +135,14 @@ Page({
     });
   },
   // 下拉加载
-  onReachBottom: function(e){
+  onReachBottom: function (e) {
     console.log(this.data.totalNo);
     this.setData({
-      pageNo: this.data.pageNo+1
+      pageNo: this.data.pageNo + 1
     })
-    if(this.data.pageNo <= this.data.totalNo ){
+    if (this.data.pageNo <= this.data.totalNo) {
       this.getReadInfo();
-      
+
     }
   }
 })

+ 6 - 1
pages/main/class/class.json

@@ -1,5 +1,10 @@
 {
     "window": {
         "onReachBottomDistance": 50
-      }
+    },
+    "component": true,
+    "usingComponents": {
+        "shareDialog": "/component/share/share",
+        "popup": "/component/popup/popup"
+    }
 }

+ 4 - 2
pages/main/class/class.wxml

@@ -20,16 +20,18 @@
     <view class="footSection">
         <image class="blackbord" src="../../../static/image/blackbord.png" />
         <view class="collectBtn footerBtn" bindtap="collect">
-            <image src=" {{collectFlag ? '../../../static/image/collected.png' : '../../../static/image/no_collect.png'}}" />
+            <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" />
             <text>我要朗读</text>
         </view>
-        <view class="shareBtn footerBtn">
+        <view class="shareBtn footerBtn" bindtap="openShare">
             <image src="../../../static/image/share.png" />
             <text>分享</text>
         </view>
     </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='class' />
 </view>

+ 5 - 3
pages/main/reading/reading.js

@@ -33,7 +33,8 @@ Page({
                 img: res.data.data.iconImg,
                 id: res.data.data.id,
                 // readingText: res.data.data.lessonText.replace(reg,'')
-                readingText: res.data.data.lessonText
+                readingText: res.data.data.lessonText,
+                grade: res.data.data.gradeClassify
             })
             console.log(this.data.readingText)
             console.log(this.data.img)
@@ -188,14 +189,15 @@ Page({
                 "originVideo": this.data.videoUrl,
                 "audioPath": audio,
                 "title": this.data.title,
-                "iconImg": this.data.img
+                "iconImg": this.data.img,
+                "summary": this.data.grade,
             };
             httpRequestApi.postWork(uid, data).success(res => {
                 wx.showToast({
                     title: '上传成功',
                     icon: 'success',
                     duration: 1000
-                  })
+                })
             })
         };
     }

+ 31 - 0
pages/main/week/week.js

@@ -0,0 +1,31 @@
+import httpRequestApi from '../../../utils/APIClient';
+Page({
+    data: {
+
+    },
+    onLoad: function (option) {
+        const uid = wx.getStorageSync('uid');
+        httpRequestApi.getIndex(uid).success(res => {
+            const recommend = res.data.data.recommendLesson;
+            const recommendTemp = [];
+            recommend.forEach(item => {
+              const oTemp = {};
+              oTemp.img = item.boothContent;
+              oTemp.classId = item.operationContent;
+              oTemp.title = item.title;
+              oTemp.grade = item.summary;
+              recommendTemp.push(oTemp);
+            });
+            this.setData({
+              recommend: recommendTemp
+            })
+        });
+    },
+    openClass: function(e) {
+          let id = e.currentTarget.dataset.classid;
+          let title = e.currentTarget.dataset.title;
+          wx.navigateTo({
+            url: `../class/class?id=${id}&title=${title}`
+          })
+      }
+})

+ 1 - 0
pages/main/week/week.json

@@ -0,0 +1 @@
+{}

+ 11 - 0
pages/main/week/week.wxml

@@ -0,0 +1,11 @@
+<view class="hotSection">
+        <view class="hotWares" style="flex-direction:row;">
+            <view wx:for="{{recommend}}" wx:key="{{index}}" class="hotWareCard" data-classId="{{item.classId}}" data-title="{{item.title}}">
+                <image class="wareCardImg" src="{{item.img}}" />
+                <text class="wareCardTitle">{{item.title}}</text>
+                <view class="bottomData">
+                    <text class="wareCardTip">{{item.grade}}</text>
+                </view>
+            </view>
+        </view>
+    </view>

+ 53 - 0
pages/main/week/week.wxss

@@ -0,0 +1,53 @@
+
+.hotSection {
+    width: 100%;
+    /* height: 50rpx; */
+    background: #fff;
+    margin-top: 10rpx;
+}
+
+.hotWares {
+    display: flex;
+    flex-wrap: wrap;
+}
+
+.hotSection .hotWares .hotWareCard {
+    position: relative;
+    overflow: hidden;
+    width: 704rpx;
+    height: 402rpx;
+    /* margin: 0 0 18rpx 16rpx; */
+    margin: 0 auto 20rpx;
+    /* box-shadow: 0 8rpx 6rpx 0 rgba(0, 0, 0, .28); */
+}
+
+
+
+.hotWareCard .wareCardImg {
+    width: 100%;
+    height: 290rpx;
+    border-radius: 20rpx;
+}
+
+
+
+.hotWareCard .wareCardTitle {
+    /* margin: 0 auto; */
+    width: 100%;
+    height: 46rpx;
+    display: block;
+    /* text-align: left; */
+    color: #414141;
+    font-size: 32rpx;
+    letter-spacing: 4rpx;
+    font-family: MicrosoftYaHei;
+}
+
+.hotWareCard .bottomData {
+    height: 34rpx;
+    margin-top: 10rpx;
+    display: flex;
+    /* flex-direction: row; */
+    justify-content: space-between;
+    align-items: center;
+}

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

@@ -13,14 +13,14 @@ Page({
         authorAvatar: '',
         user: [],
         inputValue: '',
-        inputSBValue:'',
+        inputSBValue: '',
         replyList: [],
         howMuch: '200',
         moneySelect: 'moneySelect',
         moneyNormal: 'moneyNormal',
         ifReward: false,
         id: '',
-        path:'',
+        path: '',
         replyModal: false
         // shareFlag: false
     },
@@ -77,26 +77,26 @@ Page({
         });
     },
     likeWorks: function (e) {
-        if(this.data.isLike){
+        if (this.data.isLike) {
             wx.showToast({
                 title: '不要重复点赞哦',
                 icon: 'fail',
                 duration: 1000
-              })
+            })
             return;
         }
         httpRequestApi.likeWorks(this.uid, this.data.id).success(res => {
             this.setData({
                 isLike: true
-            },()=>{
+            }, () => {
                 wx.showToast({
                     title: '点赞数+1',
                     icon: 'success',
                     duration: 1000
-                  })
+                })
             });
-            })
-            
+        })
+
     },
     // 弹出分享框
     openShare: function (e) {
@@ -133,27 +133,45 @@ Page({
             url: `../../main/reading/reading?id=${this.data.classId}`
         })
     },
-    onShareAppMessage: function(res) {
+    onShareAppMessage: function (res) {
         if (res.from === 'button') {
-          // 来自页面内转发按钮
-          console.log(res.target)
+            // 来自页面内转发按钮
+            console.log(res.target)
         }
         return {
-          title: this.data.title,
-          path: `pages/social/works/works?id=${this.data.id}&title=${this.data.title}`,
-          imageUrl: this.data.iconImg
+            title: this.data.title,
+            path: `pages/social/works/works?id=${this.data.id}&title=${this.data.title}`,
+            imageUrl: this.data.iconImg
         }
-      },
+    },
     follow: function () {
         // let uid = wx.getStorageSync('uid');
         let followUid = this.data.authorUid;
-        httpRequestApi.followUser(this.uid, followUid).success((res) => {
-            wx.showToast({
-                title: !this.data.isFans? '取消关注' : '关注啦',
-                icon: 'success',
-                duration: 1000
-              })
-        });
+        if (this.data.isFans) {
+            httpRequestApi.cancerFollow(this.uid, followUid).success((res) => {
+                this.setData({
+                    isFans: false
+                })
+                wx.showToast({
+                    title: '取消关注',
+                    icon: 'success',
+                    duration: 1000
+                })
+            });
+        } else {
+            httpRequestApi.followUser(this.uid, followUid).success((res) => {
+                this.setData({
+                    isFans: true
+                })
+                wx.showToast({
+                    title: '关注啦',
+                    icon: 'success',
+                    duration: 1000
+                })
+            });
+        }
+
+
     },
     // 点赞评论
     likeCommend: function (e) {
@@ -234,7 +252,7 @@ Page({
         }
     },
     // 设置点击时的id
-    setSBId: function(e){
+    setSBId: function (e) {
         console.log(e)
         this.setData({
             replySBId: e.currentTarget.dataset.id,
@@ -254,7 +272,7 @@ Page({
         });
     },
     // 获取回复楼中楼的内容
-    inputSBValue: function(e){
+    inputSBValue: function (e) {
         this.setData({
             inputSBValue: e.detail.value
         });
@@ -270,7 +288,7 @@ Page({
             ifReward: true
         })
     },
-    quitReward:function () {
+    quitReward: function () {
         this.setData({
             ifReward: false
         })

+ 4 - 2
pages/social/works/works.wxml

@@ -66,6 +66,9 @@
             <text>分享</text>
         </view>
     </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 class="replySection" wx:if="{{replyModal}}">
         <input bindblur="bindTextAreaBlur"  bindconfirm="replySB" confirm-type="send" placeholder="回复" bindinput="inputSBValue" auto-focus auto-height />
@@ -91,6 +94,5 @@
         </cover-view>
         <cover-image class="quitBtn" bindtap="quitReward" src="../../../static/groupImg/cha.png" />
     </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>

+ 0 - 2
project.config.json

@@ -84,7 +84,6 @@
 					"id": 7,
 					"name": "作品页面",
 					"pathName": "pages/social/works/works",
-<<<<<<< HEAD
 					"query": "id=1541489786444388&title=铺满色巴掌的水泥道"
 				},
 				{
@@ -122,7 +121,6 @@
 					"name": "course",
 					"pathName": "pages/user/mycourse/mycourse",
 					"query": "productId=1"
-					"query": "id=1541683622900612&title=【课文1】秋天"
 				},
 				{
 					"id": 8,

+ 9 - 0
utils/APIClient.js

@@ -111,6 +111,15 @@ module.exports = {
 			"uid": followUid
 		}).method('POST').send();
 	},
+	// 取消关注
+	cancerFollow(uid,followUid){
+		let url = getBaseUrl(`wx/fans`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data({
+			"uid": followUid
+		}).method('PUT').send();
+	},
 	//获取关注的用户列表
 	getFollowUsers(uid, pageNo, pageSize) {
 		let url = getBaseUrl(`wx/fans`);