Rorschach 6 năm trước cách đây
mục cha
commit
88825bc9e9
57 tập tin đã thay đổi với 1262 bổ sung370 xóa
  1. 2 1
      app.json
  2. 1 1
      app.wxss
  3. 91 4
      component/group/group.js
  4. 46 58
      component/group/group.wxml
  5. 89 23
      component/group/group.wxss
  6. 26 3
      component/popup/popup.js
  7. 81 1
      component/popup/popup.wxml
  8. 108 1
      component/popup/popup.wxss
  9. 8 2
      component/share/share.js
  10. 4 4
      component/share/share.wxml
  11. 23 2
      component/share/share.wxss
  12. 91 4
      pages/groupPage/collage-details/collage-details.js
  13. 2 1
      pages/groupPage/collage-details/collage-details.json
  14. 33 37
      pages/groupPage/collage-details/collage-details.wxml
  15. 4 7
      pages/groupPage/collage-details/collage-details.wxss
  16. 31 11
      pages/groupPage/discount-group/discount-group.js
  17. 18 73
      pages/groupPage/discount-group/discount-group.wxml
  18. 23 0
      pages/groupPage/discount-group/discount-group.wxss
  19. 148 4
      pages/groupPage/grade-details/grade-details.js
  20. 6 1
      pages/groupPage/grade-details/grade-details.json
  21. 23 29
      pages/groupPage/grade-details/grade-details.wxml
  22. 1 0
      pages/groupPage/grade-details/grade-details.wxss
  23. 175 25
      pages/groupPage/group-details/group-details.js
  24. 35 55
      pages/groupPage/group-details/group-details.wxml
  25. 5 4
      pages/groupPage/group-details/group-details.wxss
  26. 85 0
      pages/groupPage/my-group/my-group.js
  27. 1 0
      pages/groupPage/my-group/my-group.json
  28. 14 0
      pages/groupPage/my-group/my-group.wxml
  29. 39 0
      pages/groupPage/my-group/my-group.wxss
  30. 1 1
      pages/main/books/books.js
  31. 1 1
      pages/main/singleBook/singleBook.js
  32. 9 2
      project.config.json
  33. BIN
      static/groupImg/Group 11.png
  34. BIN
      static/groupImg/Group 11@2x.png
  35. BIN
      static/groupImg/Group 11@3x.png
  36. BIN
      static/groupImg/Rectangle 13.png
  37. BIN
      static/groupImg/Rectangle 13@2x.png
  38. BIN
      static/groupImg/Rectangle 13@3x.png
  39. BIN
      static/groupImg/Rectangle 30.png
  40. BIN
      static/groupImg/Rectangle 30@3x.png
  41. BIN
      static/groupImg/Shape.png
  42. BIN
      static/groupImg/Shape1.png
  43. BIN
      static/groupImg/Shape1@3x.png
  44. BIN
      static/groupImg/Shape2.png
  45. BIN
      static/groupImg/Shape2@3x.png
  46. BIN
      static/groupImg/Shape@3x.png
  47. BIN
      static/groupImg/bai.png
  48. BIN
      static/groupImg/cha.png
  49. BIN
      static/groupImg/lan.png
  50. BIN
      static/groupImg/shareBg.png
  51. BIN
      static/groupImg/sure.png
  52. BIN
      static/groupImg/tuandui.png
  53. BIN
      static/groupImg/tuandui@3x.png
  54. BIN
      static/groupImg/weisuccess.png
  55. BIN
      static/groupImg/yisuccess.png
  56. 31 7
      utils/APIClient.js
  57. 7 8
      utils/util.js

+ 2 - 1
app.json

@@ -13,7 +13,8 @@
     "pages/groupPage/grade-details/grade-details",
     "pages/groupPage/collage-details/collage-details",
     "pages/main/searchResult/searchResult",
-    "pages/user/myconcern/myconcern"
+    "pages/user/myconcern/myconcern",
+    "pages/groupPage/my-group/my-group"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 1 - 1
app.wxss

@@ -6,7 +6,7 @@ page {
 
 .container {
   height: 100%;
-  
+  box-sizing:border-box;
   padding-top: 80rpx;
  
 } 

+ 91 - 4
component/group/group.js

@@ -1,16 +1,103 @@
+import httpRequestApi from '../../utils/APIClient';
 export const groupInit = (that) => {
   that.setData({
     groupData: {
-      title: '关注'
+      recommendList: [],
+      bookList: [],
+      sendGroupFlag: true,
+      selectFlag: []
     }
   })
   //请求数据封装
-  that.more = function () {
+  that.getGroupList = function () {
+    httpRequestApi.getGroupList().success( (res) => {
+      console.log('推荐团购',res.data.data)
+      that.data.groupData.recommendList = res.data.data;
+      that.setData({
+        groupData: that.data.groupData
+      })
+    }).fail((error) => {
+      console.log('错误',error)
+    })
+    httpRequestApi.getAllBooks(1, 10).success((res) => {
+      console.log('全部课',res.data.data.list)
+      that.data.groupData.bookList = res.data.data.list;
+      res.data.data.list.forEach(element => {
+        that.data.groupData.selectFlag.push(true);
+      });
+      that.setData({
+        groupData: that.data.groupData
+      })
+    }).fail((error) => {
+      console.log('错误',error)
+    })
+  }();
+  //点击跳转
+  that.more = function ({currentTarget}) {
+    let type;
+    let title;
+    if(currentTarget.dataset.type == 'group') {
+      type = true
+      title = '限量优惠团购'
+    }else {
+      type = false
+      title = '全部课'
+    }
+    wx.navigateTo({
+      url: `/pages/groupPage/discount-group/discount-group?type=${type}&title=${title}`
+    })
+  }
+  //发起团购
+  that.sendGroup = function () {
+    that.data.groupData.sendGroupFlag = !that.data.groupData.sendGroupFlag;
+    that.setData({
+      groupData: that.data.groupData
+    })
+  }
+  //选中团购课程
+  that.selectImg = function ({ currentTarget }) {
+    const ind = currentTarget.dataset.ind;
+    //判断单选
+    that.data.groupData.selectFlag.forEach((item, index) => {
+      if(index == ind) {
+        that.data.groupData.selectFlag[ind] = !that.data.groupData.selectFlag[ind];
+      }else {
+        that.data.groupData.selectFlag[index] = true;
+      }
+    })
+    that.setData({
+      groupData: that.data.groupData
+    })
+  }
+  //点击确定
+  that.sure = function () {
+    that.data.groupData.selectFlag.forEach( (item ,index) => {
+      if(!item) {
+        const productId = that.data.groupData.bookList[index].id;
+        const title = that.data.groupData.bookList[index].title
+        wx.navigateTo({
+          url: `/pages/groupPage/grade-details/grade-details?productId=${productId}&title=${title}`
+        })
+      }
+    })
+
+  }
+  //跳转到我的团购
+  that.myGroup = function () {
     wx.navigateTo({
-      url: '/pages/groupPage/discount-group/discount-group'
+      url: `/pages/groupPage/my-group/my-group`
     })
     wx.setNavigationBarTitle({
-      title: '限量优惠团购'
+      title: '我的团购'
+    })
+  }
+  //跳转到团购详情页
+  that.groupDetail = function ({currentTarget}) {
+    const productId = currentTarget.dataset.productid;
+    const id = currentTarget.dataset.id;
+    const groupId = currentTarget.dataset.groupid;
+    wx.navigateTo({
+      url: `/pages/groupPage/group-details/group-details?productId=${productId}&id=${id}&groupId=${groupId}`
     })
   }
 }

+ 46 - 58
component/group/group.wxml

@@ -2,83 +2,71 @@
   <view class="group">
     <scroll-view scroll-y="{{true}}">
       <view class="group-container">
-        <view class="search">
-          <input type="text" placeholder="小学三年级下"></input>
-          <image class="sou" src="../../static/groupImg/Group 11@2x.png"></image>
-        </view>
         <view class="less-group">
           <view class="title">
             <image class="ren" src="../../static/groupImg/tuandui@2x.png"></image>
-            <text class="left">限量优惠团购<text class="quota">(名额还剩1000份)</text></text>
-            <text class="right" bindtap="more">更多 ></text>
+            <text class="left">限量优惠团购<text class="quota">(仅有1000份,售完为止)</text></text>
+            <text class="right" bindtap="more" data-type="group">更多 ></text>
           </view>
           <view class="group-box">
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>   
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view> 
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>                                 
+            <block wx:for="{{groupData.recommendList}}" wx:key="{{index}}">
+              <view class="group-item" bindtap="groupDetail" data-id="{{item.id}}" data-productId="{{item.productId}}" data-groupId="{{item.groupId}}">
+                <image class="item-img" src="{{item.iconImg}}"></image>
+                <view>拼团价 <text>¥{{item.price / 100}}</text></view>
+                <view>原价 <text style="text-decoration: line-through;">¥{{item.originPrice / 100}}</text></view>
+                <view class="group-num">
+                  <image src="../../static/groupImg/Rectangle_30.png" ></image>
+                  <text>{{item.headcount}}人团</text>
+                </view>
+              </view>
+            </block>                 
           </view>
         </view>
       </view>
       <view class="whole-group">
           <view class="title">
-            <image class="ren" src="../../static/groupImg/tuandui@2x.png"></image>
-            <text class="left">限量优惠团购<text class="quota">(名额还剩1000份)</text></text>
-            <text class="right">更多 ></text>
+            <image class="ren" src="../../static/groupImg/Shape3.png" style="width: 30rpx; height: 38rpx;"></image>
+            <text class="left">全部课程<text class="quota" style="margin-left: 20rpx;">拼团大不同</text></text>
+            <text class="right" bindtap="more" data-type="course">更多 ></text>
           </view>
-          <view class="group-box">
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view id="grade">一年级语文下册</view>
-            </view>
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view id="grade">一年级语文下册</view>
-            </view>   
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view id="grade">一年级语文下册</view>
-            </view>                               
+          <view class="group-box"> 
+            <block wx:for="{{groupData.bookList}}" wx:key="{{index}}">
+              <view class="group-item">
+                <image class="item-img" src="{{item.iconImg}}"></image>
+                <view id="grade">一年级</view>
+              </view>    
+            </block>          
           </view>
         </view>
     </scroll-view>
     <view class="Collage-bottom">
-      <image class="bg" src="../../static/groupImg/Rectangle 9.png"></image>
-      <view>
+      <image class="bg" src="../../static/groupImg/Rectangle_9.png"></image>
+      <view bindtap="sendGroup">
         <image src="../../static/groupImg/Shape1@2x.png"></image>
         <text>发起团购</text>
       </view>
-      <view>
-        <image src="../../static/groupImg/Shape2@2x.png"></image>
-        <text>发起团购</text>
+      <view bindtap="myGroup">
+        <image src="../../static/groupImg/Shape2@2x.png" style="width: 50rpx; height: 50rpx;"></image>
+        <text>我的拼团</text>
       </view>
     </view>
   </view>
-  <button open-type="getUserInfo">授权</button>
+  <view class="group-popup" bindtap="sendGroup" hidden="{{groupData.sendGroupFlag}}">
+      <view class="group-content">
+        <view class="group-title">请选择课本</view>
+        <view class="group-list">
+          <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>
+                <image class="select-img" src="../../static/groupImg/{{groupData.selectFlag[index] ? 'bai' : 'lan'}}.png"></image>
+              </view> 
+          </block>
+        </view>
+        <view class="sure" catchtap="sure">
+          <image src="../../static/groupImg/sure.png"></image>
+          <text>确定</text>
+        </view>
+      </view>
+  </view>
 </template>

+ 89 - 23
component/group/group.wxss

@@ -20,28 +20,6 @@ scroll-view {
     background: #fff;
 }
 
-.search {
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    width: 100%;
-    height: 60rpx;
-    border-radius: 12rpx;
-    background: #F0F1F5;
-    padding: 0 20rpx;
-    box-sizing: border-box;
-}
-
-.search input {
-    width: 80%;
-    height: 100%;
-}
-
-.search image {
-    width: 34rpx;
-    height: 34rpx;
-}
-
 .less-group,
 .whole-group {
     width: 100%;
@@ -93,15 +71,38 @@ scroll-view {
 }
 
 .group-item {
+    position: relative;
     display: flex;
     flex-direction: column;
 }
 
-.group-item image {
+.group-item .item-img {
     width: 214rpx;
     height: 278rpx;
 }
 
+.group-item .group-num {
+    position: absolute;
+    left: 0;
+    top: 14rpx;
+    width: 100rpx;
+    height: 40rpx;
+}
+
+.group-item .group-num image {
+    width: 100%;
+    height: 100%;
+}
+
+.group-item .group-num text {
+    color: #fff;
+    position: absolute;
+    left: 6rpx;
+    top: 4rpx;
+    z-index: 3;
+    font-size: 24rpx;
+}
+
 .group-item view:nth-child(2) {
     font-size: 32rpx;
     color: #E51C23;
@@ -151,4 +152,69 @@ scroll-view {
     width: 4rpx;
     height: 70%;
     transform: translateX(-50%);
+}
+
+.group-popup {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    background: rgba(0, 0, 0, .5);
+    z-index: 99;
+}
+
+.group-popup .group-content {
+    position: absolute;
+    left: 50%;
+    top: 50%;
+    transform: translate(-50%,-50%);
+    width: 80%;
+    background: #fff;
+    border-radius: 20rpx;
+}
+
+.group-title {
+    text-align: center;
+    margin: 36rpx 0;
+}
+
+.group-list {
+    display: flex;
+    justify-content: space-between;
+    flex-wrap: wrap;
+    padding: 0 62rpx;
+}
+
+.group-content-img {
+    width: 214rpx;
+    height: 290rpx;
+}
+
+.sure {
+    position: relative;
+    width: 392rpx;
+    height: 80rpx;
+    margin: 36rpx auto 26rpx auto;
+}
+
+.sure image {
+    width: 100%;
+    height: 100%;
+}
+
+.sure text {
+    position: absolute;
+    left: 164rpx;
+    top: 18rpx;
+    color: #fff;
+    z-index: 2;
+}
+
+.select-img {
+    position: absolute;
+    left: 10rpx;
+    top: 10rpx;
+    width: 52rpx;
+    height: 52rpx;
 }

+ 26 - 3
component/popup/popup.js

@@ -4,20 +4,43 @@ Component({
    * 组件的属性列表
    */
   properties: {
-
+    typeOf: {
+      type: "String",
+      value: ''
+    },
+    title: {
+      type: "String",
+      value: ''
+    },
+    headTextOne: {
+      type: "String",
+      value: ''
+    },
+    headTextTwo: {
+      type: "String",
+      value: ''
+    },
+    content: {
+      type: "Array",
+      value: ''
+    }
   },
 
   /**
    * 组件的初始数据
    */
   data: {
-
+    closeFlag: true
   },
 
   /**
    * 组件的方法列表
    */
   methods: {
-
+    close: function () {
+      this.setData({
+        closeFlag: !this.data.closeFlag
+      })
+    }
   }
 })

+ 81 - 1
component/popup/popup.wxml

@@ -1,2 +1,82 @@
 <!--component/popup/popup.wxml-->
-<text>component/popup/popup.wxml</text>
+<view class="popup" hidden="{{closeFlag}}">
+    <!--成功-->
+    <view class="popup-container" wx:if="{{typeOf == 'success' ? true : false}}">
+        <view class="head-img" style="height: 240rpx">
+            <image src="../../static/groupImg/success.png"></image>
+        </view>
+        <view class="head-txt">
+            <view class="title">{{title}}</view>
+            <view class="head-con">
+                {{headTextOne}}
+            </view>
+            <view>
+                {{headTextTwo}}
+            </view>
+        </view>
+        <view class="content">    
+            <block wx:for="{{content}}" wx:key="{{index}}">
+                <text style="color: {{item.color}};">{{item.text}}</text>
+            </block>
+        </view>
+        <view class="send-btn">
+            <image src="../../static/groupImg/Invitation.png"></image>
+            <text>发起团购</text>
+        </view>
+    </view>
+    <!--失败 -->
+    <view class="popup-container"  wx:if="{{typeOf == 'error' ? true : false}}">
+        <view class="head-img" style="height: 366rpx; margin-top: -120rpx;">
+            <image src="../../static/groupImg/error.png"></image>
+        </view>
+        <view class="head-txt">
+            <view class="title" style="margin-top: 80rpx; color: #4A90E2;">很遗憾拼团失败</view>
+            <view class="head-con" style="color: #000">
+                您发起的团购拼团成功
+            </view>
+        </view>
+        <view class="content" style="margin-top: 30rpx;">    
+            <text style="color: #000;">您可以继续发起新的团购,</text>
+            <text style="color: #FF9B00;">不再需要支付本课程费用,拼团成功,</text>
+            <text style="color: #FF0000;">您将得到xxx元奖励。</text>
+        </view>
+        <view class="send-btn">
+            <image src="../../static/groupImg/Invitation.png"></image>
+            <text>发起团购</text>
+        </view>
+    </view>
+    <!--发起拼团成功 -->
+    <view class="popup-container"  wx:if="{{typeOf == 'sendSuccess' ? true : false}}">
+        <view class="head-img"style="text-align: center;margin-top: 29rpx;">
+            <image src="../../static/groupImg/tuanzhang.png" style="width: 160rpx; height: 160rpx;"></image>
+        </view>
+        <view class="content">
+            <text style="color: #F66C1C; font-weight: bolder;">{{title}}</text>
+            <text style="color: #F66C1C;">{{headTextTwo}}</text>
+        </view>
+        <view class="content" style="margin-top: 30rpx; font-size:28rpx;">
+            <block wx:for="{{content}}" wx:key="{{index}}">
+                <text style="color: {{item.color}};">{{item.text}}</text>
+            </block>
+        </view>
+        <view class="bottom">
+            * 如果拼团失败,您预付的课程费将在48小时内退回您的账户。
+        </view>
+    </view>
+    <!--发起拼团失败 -->
+    <view class="popup-container"  wx:if="{{typeOf == 'senderror' ? true : false}}">
+        <view class="content">
+            <text style="color: #F66C1C; font-weight: bolder;">感谢团长</text>
+            <text style="color: #F66C1C;">不再需要支付本课程费用,拼团成功,</text>
+        </view>
+        <view class="head-img"style="text-align: center;margin-top: 29rpx;">
+            <image src="../../static/groupImg/liwu.png" style="width: 288rpx; height: 184rpx;"></image>
+        </view>
+        <view class="bottom" style="color: #000;">
+            * 如果拼团失败,您预付的课程费将在48小时内退回您的账户。
+        </view>
+    </view>
+    <view class="cha" bindtap="close">
+        <image src="../../static/groupImg/cha.png"></image>
+    </view>
+</view>

+ 108 - 1
component/popup/popup.wxss

@@ -1 +1,108 @@
-/* component/popup/popup.wxss */
+/* component/popup/popup.wxss */
+.popup {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    background: rgba(0, 0, 0, .5);
+    z-index: 999;
+}
+
+.popup-container {
+    position: absolute;
+    left: 5%;
+    top: 50%;
+    transform: translateY(-50%);
+    background: #fff;
+    width: 90%;
+    height: auto;
+    border-radius: 20rpx;
+}
+
+.head-img {
+    width: 100%;
+}
+
+.head-img image {
+    width: 100%;
+    height: 100%;
+}
+
+.head-txt {
+    position: absolute;
+    top: 26rpx;
+    left: 0;
+    width: 100%;
+    text-align: center;
+    color: #fff;
+
+}
+
+.head-txt .title {
+    font-size: 48rpx;
+    font-weight: bolder;
+}
+
+.head-txt .head-con {
+    margin: 20rpx 0;
+}
+
+.content {
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    font-size: 36rxp;
+}
+
+.content text {
+    margin: 6rpx 0;
+}
+
+
+.send-btn {
+    width: 70%;
+    height: 80rpx;
+    margin: 72rpx auto 40rpx auto;
+    position: relative;
+}
+
+.send-btn image {
+    width: 100%;
+    height: 100%;
+}
+
+.send-btn text {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    text-align: center;
+    line-height: 80rpx;
+    color: #fff;
+    z-index: 3;
+}
+
+.cha {
+    position: absolute;
+    left: 50%;
+    bottom: 5%;
+    transform: translateX(-50%);
+    width: 80rpx;
+    height: 80rpx;
+}
+
+.cha image {
+    width: 100%;
+    height: 100%; 
+}
+
+.bottom {
+    width: 100%;
+    font-size: 20rpx;
+    text-align: center;
+    color: #767676;
+    margin: 60rpx 0 10rpx 0;
+}

+ 8 - 2
component/share/share.js

@@ -4,7 +4,10 @@ Component({
    * 组件的属性列表
    */
   properties: {
-
+    shareType: {
+      type: 'String',
+      value: ''
+    }
   },
 
   /**
@@ -61,7 +64,7 @@ Component({
       ctx.setFontSize(20)  
       ctx.setFillStyle('red')
       ctx.fillText('¥1', 109, 403) 
-      ctx.drawImage('../../../static/groupImg/Group 5 Copy 7.png', 3, 419, 370, 192);  
+      ctx.drawImage('../../../static/groupImg/share_bottom.png', 3, 419, 370, 192);  
       ctx.setFontSize(20)
       ctx.setFillStyle('red')
       ctx.fillText('名额有限,售完截止', 9, 467)
@@ -105,6 +108,9 @@ Component({
           console.log('保存成功')
         }
       })
+    },
+    shareFriend: function () {
+      this.triggerEvent('customevent', {})
     }
   }
 })

+ 4 - 4
component/share/share.wxml

@@ -2,14 +2,14 @@
    <view class="btn" wx:if="{{!imgUrls}}">
        <image class="bg" src="../../static/groupImg/share.png"></image>
        <view class="share-btn">
-           <view class="share-friend">
+            <button class="share-friend" open-type="share" catchtap="shareFriend">
                <image  src="../../static/groupImg/weixin.png"></image>
                <text>发送给群/好友</text>
-           </view>
-           <view class="share-circle" catchtap="poster">
+            </button>
+            <view class="share-circle" catchtap="poster">
                <image  src="../../static/groupImg/circle.png"></image>
                <text>发朋友圈</text>
-           </view>           
+            </view>           
        </view>
    </view>
    <view class="share-img" wx:if="{{imgUrls}}">

+ 23 - 2
component/share/share.wxss

@@ -36,9 +36,10 @@
 .share-btn view {
     display: flex;
     flex-direction: column;
-    justify-content: center;
+    justify-content: space-between;
     align-items: center;
     font-size: 32rpx;
+    height: 120rpx;
 }
 
 .img {
@@ -73,4 +74,24 @@
     left: 30rpx;
     top: 20rpx;
     z-index: 9;
-}
+}
+
+.share-friend {
+    background: #fff;
+    display:flex;
+    flex-direction:column;
+    align-items: center;
+    outline:none;
+    padding:0;
+    margin:0;
+    border-radius:0;    
+    height: 140rpx;
+    font-size:32rpx;  
+}
+
+.share-friend image {
+    width: 66rpx;
+    height: 66rpx;
+}
+
+button::after{ border: none; } 

+ 91 - 4
pages/groupPage/collage-details/collage-details.js

@@ -1,11 +1,39 @@
 // pages/groupPage/collage-details/collage-details.js
+import httpRequestApi from '../../../utils/APIClient';
+import util from '../../../utils/util';
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    hideFlag: true
+    hideFlag: true,
+    surplusNum: '',
+    joinUserList: [],
+    surplusList: [],
+    timeList: [],
+    productId: '',
+    orderId: '',
+    groupId: '',
+    content: [
+      {
+          text: "转发给自己的朋友们,分享好课,",
+          color: "#000"
+      },
+      {
+          text: " 追随您一起学习进步。您的魅力不是吹的!",
+          color: "#000"
+      },
+      {
+          text: "在限定时间内内成功拼团,您将得到xx元的奖励金哦。",
+          color: "#FF4600"
+      }
+    ]
+  },
+
+  //分享好友触发事件
+  eventListener: function () {
+    //console.log(1);
   },
 
   //规则页显示和隐藏
@@ -22,7 +50,37 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    wx.setNavigationBarTitle({
+      title: '拼团详情'
+    })
+    console.log(options.orderId);
+    if(!options.orderId) {
+      return false;
+    }
+    const orderId = options.orderId;
+    this.setData({
+      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,
+        productId: res.data.data.groupPurchaseOrder.productId,
+        groupId: res.data.data.groupPurchaseOrder.groupId
+      })
+    }).fail( error => {
+      console.log('错误', error)
+    })
   },
 
   /**
@@ -70,7 +128,36 @@ Page({
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
-
+  onShareAppMessage: function (ops) {
+    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));
+      }
+    }
   }
 })

+ 2 - 1
pages/groupPage/collage-details/collage-details.json

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

+ 33 - 37
pages/groupPage/collage-details/collage-details.wxml

@@ -10,51 +10,39 @@
     </view>
     <view class="details-head">
         <view class="headImg">
-            <view class="headImg-item">
-                
-            </view>
-            <view class="headImg-item">
- 
-            </view>
-            <view class="headImg-item">
-                <image src="../../../static/groupImg/Mask Copy@2x.png"></image>
-            </view>
-            <view class="headImg-item">
-                <image src="../../../static/groupImg/Mask Copy@2x.png"></image>
-            </view>  
-            <view class="headImg-item">
-                <image src="../../../static/groupImg/Mask Copy@2x.png"></image>
-            </view>
-            <view class="headImg-item">
-                <image src="../../../static/groupImg/Mask Copy@2x.png"></image>
-            </view>                      
+            <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>3</text>个名额就拼团成功了</view>
+            <view class="shengyu-num">仅剩<text>{{surplusNum}}</text>个名额就拼团成功了</view>
             <view class="shengyu-time">
                 剩余时间:
                 <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</text>
+                    <image src="../../../static/groupImg/Rectangle_31.png"></image>
+                    <text>{{timeList[0]}}</text>
                 </view>
-                <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</text>
-                </view>
-                <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</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>
-                <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</text>
-                </view>
-                <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</text>
-                </view>                
+                <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>
@@ -73,5 +61,13 @@
     </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"/>
+<popup
+    typeOf="sendSuccess"
+    title="报告团长"
+    headTextTwo="您发起的团购已经成立,订单号:12345"
+    content="{{content}}"
+></popup>
 

+ 4 - 7
pages/groupPage/collage-details/collage-details.wxss

@@ -46,14 +46,14 @@
 .headImg-item {
     width: 106rpx;
     height: 106rpx;
-    background: red;
     border-radius: 50%;
     margin: 20rpx 22rpx;
 }
 
 .headImg-item image {
     width: 100%;
-    height: 100%
+    height: 100%;
+    border-radius: 50%;
 }
 
 .shengyu {
@@ -85,16 +85,13 @@
 }
 
 .shengyu-time .time image {
-    position: absolute;
-    left: 0;
-    top: 0;
-    width: 20rpx;
+    width: 24rpx;
     height: 40rpx;
 }
 
 .shengyu-time .time  text{
     position: absolute;
-    left: 0;
+    left: 2rpx;
     top: 0;
     z-index: 2;
     color: #fff;

+ 31 - 11
pages/groupPage/discount-group/discount-group.js

@@ -1,28 +1,48 @@
 // pages/groupPage//discount-group/discount-group.js
+import httpRequestApi from '../../../utils/APIClient';
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    recommendList: [],
+    bookList: []
   },
 
-//点击跳转到团购详情
-groupDetails:function () {
-  wx.navigateTo({
-    url: '/pages/groupPage/group-details/group-details'
-  })
-  wx.setNavigationBarTitle({
-    title: '拼团详情'
-  })
-},
+  //点击跳转到团购详情
+  groupDetails:function () {
+
+  },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    wx.setNavigationBarTitle({
+      title: options.title
+    })
+    if(options.type == 'true') {
+      //优惠内容
+      httpRequestApi.getGroupList().success( (res) => {
+        console.log('推荐团购',res.data.data)
+        this.setData({
+          recommendList: res.data.data
+        })
+      }).fail((error) => {
+        console.log('错误',error)
+      })
+    }else {
+      //全部课
+      httpRequestApi.getAllBooks(1, 10).success((res) => {
+        console.log('全部课',res.data.data.list)
+        this.setData({
+          bookList: res.data.data.list
+        })
+      }).fail((error) => {
+        console.log('错误',error)
+      })
+    }
   },
 
   /**

+ 18 - 73
pages/groupPage/discount-group/discount-group.wxml

@@ -4,80 +4,25 @@
       <view class="group-container">
         <view class="less-group">
           <view class="group-box">
-            <view class="group-item" bindtap="groupDetails">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>   
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>                  
-          </view>
+            <block wx:for="{{recommendList}}" wx:key="{{index}}">
+              <view class="group-item" bindtap="groupDetail" data-id="{{item.id}}" data-productId="{{item.productId}}" data-groupId="{{item.groupId}}">
+                <image class="item-img" src="{{item.iconImg}}"></image>
+                <view>拼团价 <text>¥{{item.price / 100}}</text></view>
+                <view>原价 <text style="text-decoration: line-through;">¥{{item.originPrice / 100}}</text></view>
+                <view class="group-num">
+                  <image src="../../../static/groupImg/Rectangle_30.png" ></image>
+                  <text>{{item.headcount}}人团</text>
+                </view>
+              </view>
+            </block> 
+            <block wx:for="{{bookList}}" wx:key="{{index}}">
+              <view class="group-item">
+                <image class="item-img" src="{{item.iconImg}}"></image>
+                <view id="grade">一年级</view>
+              </view>    
+            </block>                
+          </view>                        
         </view>
-<view class="less-group">
-          <view class="group-box">
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>   
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>                  
-          </view>
         </view>
-<view class="less-group">
-          <view class="group-box">
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>   
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>                  
-          </view>
-        </view>   
-<view class="less-group">
-          <view class="group-box">
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>   
-            <view class="group-item">
-              <image src="" style="background: red;"></image>
-              <view>拼团价 <text>¥1</text></view>
-              <view>原价 <text style="text-decoration: line-through;">¥99</text></view>
-            </view>                  
-          </view>
-        </view>                           
-      </view>
     </scroll-view>
   </view>

+ 23 - 0
pages/groupPage/discount-group/discount-group.wxss

@@ -35,6 +35,7 @@ scroll-view {
 .group-item {
     display: flex;
     flex-direction: column;
+    position: relative;
 }
 
 .group-item image {
@@ -81,4 +82,26 @@ scroll-view {
 
 .Collage-bottom text {
     vertical-align: middle;
+}
+
+.group-item .group-num {
+    position: absolute;
+    left: 0;
+    top: 14rpx;
+    width: 100rpx;
+    height: 40rpx;
+}
+
+.group-item .group-num image {
+    width: 100%;
+    height: 100%;
+}
+
+.group-item .group-num text {
+    color: #fff;
+    position: absolute;
+    left: 6rpx;
+    top: 4rpx;
+    z-index: 3;
+    font-size: 24rpx;
 }

+ 148 - 4
pages/groupPage/grade-details/grade-details.js

@@ -1,25 +1,169 @@
 // pages/grade-details/grade-details.js
+import httpRequestApi from '../../../utils/APIClient';
 Page({
-
   /**
    * 页面的初始数据
    */
   data: {
-
+    productId: '',
+    payList: [],
+    titleIcon: '',
+    title: '',
+    bookInfo: '',
+    lessonList: [],
+    content: [
+      {
+          text: "转发给自己的朋友们,分享好课,",
+          color: "#000"
+      },
+      {
+          text: " 追随您一起学习进步。您的魅力不是吹的!",
+          color: "#000"
+      },
+      {
+          text: "在限定时间内内成功拼团,您将得到xx元的奖励金哦。",
+          color: "#FF4600"
+      }
+    ]
+  },
+  //获取团购信息并掉起支付
+  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('用户点击取消')
+              }
+            }
+          })
+          return false;
+        }
+        //掉起支付
+        this.prePayMap(res.data.data.prePayMap, res.data.data.groupPurchaseOrderDetail.orderId);
+      }).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) {
+              if (res.confirm) {
+                that.popup.close();
+                setTimeout(() => {
+                  wx.navigateTo({
+                    url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+                  })
+                  wx.setNavigationBarTitle({
+                    title: '拼团详情'
+                  })
+                }, 1000)
+              } else if (res.cancel) {
+                that.popup.close();
+                setTimeout(() => {
+                  wx.navigateTo({
+                    url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+                  })
+                  wx.setNavigationBarTitle({
+                    title: '拼团详情'
+                  })
+                }, 1000)                
+              }
+            }
+          })
+
+        },
+        'fail':function(res){
+          console.log('支付失败', res)
+        }
+      })
   },
 
+
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    wx.setNavigationBarTitle({
+        title: options.title
+    })
+    const productId = options.productId;
+    if(productId) {
+      this.setData({
+        productId
+      })
+    }
+    //课本详情
+    httpRequestApi.getBookDetail(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
+      })
+      const lessonTemp = [];
+      lessonList.forEach(item => {
+          const temp = {};
+          temp.id = item.id;
+          temp.title = item.title;
+          temp.readNum = item.readCount;
+          lessonTemp.push(temp);
+      });
+      this.setData({
+          lessonList: lessonTemp
+      });
+    }).fail( (error) => {
+
+    })
+    //支付详情
+    httpRequestApi.getGroupPurchaseInfo(productId).success( (res) =>{
+      console.log('支付详情',res.data.data);
+      this.setData({
+        payList: res.data.data
+      })
+    }).fail( (error) => {
+
+    })
   },
 
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
-
+    //获取弹窗组件
+    this.popup = this.selectComponent("#popup");
   },
 
   /**

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

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

+ 23 - 29
pages/groupPage/grade-details/grade-details.wxml

@@ -2,43 +2,37 @@
 <view class="group-details">
     <scroll-view scroll-y="{{true}}">
         <view class="grade-details">
-            <image src="" style="background: red;"></image>
-            <text>【部编版】一年级语文同步-上学期</text>
-            <text>《语文一年级上册》为人教社2016年修订的教材,包括“我上学了识字汉语拼音课文口语交际语文园地”和“快乐读吧供一年级上学期使用。</text>
+            <image src="{{titleIcon}}"></image>
+            <text>{{title}}</text>
+            <text>{{bookInfo}}</text>
         </view>
         <view class="catalog">
             <image src="../../../static/groupImg/Rectangle 34@2x.png"></image>
             <text>语文目录</text>
         </view>
         <view class="catalog-list">
-            <view class="catalog-item">
-                <text class="left">第一课 小小的船</text>
-                <text class="right">3215朗读 ></text>
-            </view>
-            <view class="catalog-item">
-                <text class="left">第一课 小小的船</text>
-                <text class="right">3215朗读 ></text>
-            </view>
-            <view class="catalog-item">
-                <text class="left">第一课 小小的船</text>
-                <text class="right">3215朗读 ></text>
-            </view>            
+            <view class="catalog-item" wx:for="{{lessonList}}" wx:key="{{index}}" data-id="{{item.id}}" data-title="{{item.title}}">
+                <text class="left">{{item.title}}</text>
+                <text class="right">{{item.readingNum}}朗读 ></text>
+            </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>
-        <view class="Price">
-            <text>¥99</text>
-            <text>单人团</text>
-        </view>
-        <view class="Price">
-            <text>¥99</text>
-            <text>单人团</text>
-        </view>
-        <view class="Price">
-            <text>¥99</text>
-            <text>单人团</text>
-        </view>
+        <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}}" >
+            <view class="Price" bindtap="pay" data-id="{{item.id}}">
+                <text>¥{{item.price / 100}}</text>
+                <text>{{item.headcount}}人团</text>
+            </view>
+        </block>
     </view>
 </view>
+
+<popup
+    id="popup"
+    typeOf="sendSuccess"
+    title="报告团长"
+    headTextOne="您发起的团购已经成立,订单号:12345"
+    content="{{content}}"
+></popup>

+ 1 - 0
pages/groupPage/grade-details/grade-details.wxss

@@ -61,6 +61,7 @@ scroll-view {
     width: 100%;
     padding: 18rpx;
     box-sizing: border-box;
+    margin-bottom: 100rpx;
 }
 
 .catalog-item {

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

@@ -1,54 +1,204 @@
 // pages/group-details/group-details.js
 import httpRequestApi from '../../../utils/APIClient';
+import util from '../../../utils/util';
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    titleIcon: '',
+    title: '',
+    bookInfo: '',
+    lessonList: [],
+    surplusNum: '',
+    joinUserList: [],
+    surplusList: [],
+    timeList: [],
+    productId: '',
+    groupId: '',
+    orderId: ''
   },
   //跳转到年级
   gradeDetails: function () {
-    wx.navigateTo({
-      url: '/pages/groupPage/grade-details/grade-details'
-    })
+    // wx.navigateTo({
+    //   url: '/pages/groupPage/grade-details/grade-details'
+    // })
     // wx.setNavigationBarTitle({
     //   title: '限量优惠团购'
     // })
   
   },
-  //跳转到拼团详情
-  collage: function () {
-    wx.navigateTo({
-      url: '/pages/groupPage/collage-details/collage-details'
+  //开团
+  openGroup: function () {
+    const productId = this.data.productId;
+    const groupId = this.data.groupId;
+    //开始发起团购
+    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.groupPurchaseOrderDetail.orderId);
+    }).fail( (error) => {
+      
     })
-    wx.setNavigationBarTitle({
-      title: '拼团详情'
+  },
+  //参团
+  jionGroup: function () {
+    const orderId = this.data.orderId;
+    //开始发起团购
+    httpRequestApi.JoinGroupPurchas(orderId).success( (res) =>{
+      console.log('参加团购',res);
+      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.groupPurchaseOrderDetail.orderId);
+    }).fail( (error) => {
+      
     })
-  
+  },
+
+  //支付
+  prePayMap: function (prePayMap, orderId) {
+    console.log(prePayMap)
+    const that = this;
+    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) {
+              if (res.confirm) {
+                that.popup.close();
+                // setTimeout(() => {
+                //   wx.navigateTo({
+                //     url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+                //   })
+                //   wx.setNavigationBarTitle({
+                //     title: '拼团详情'
+                //   })
+                // }, 1000)
+              } else if (res.cancel) {
+                that.popup.close();
+                setTimeout(() => {
+                  wx.navigateTo({
+                    url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+                  })
+                  wx.setNavigationBarTitle({
+                    title: '拼团详情'
+                  })
+                }, 1000)                
+              }
+            }
+          })
+
+        },
+        'fail':function(res){
+          console.log('支付失败', res)
+        }
+      })
+  },
+  //跳转到拼团详情
+  collage: function () {
+
   },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    httpRequestApi.getGroupPurchaseInfo(1).success( (res) =>{
-      console.log(res);
-    }).fail( (error) => {
-
+    wx.setNavigationBarTitle({
+      title: '拼团详情'
     })
-    httpRequestApi.SendGroupPurchas({
-      "productId": "1",
-      "groupId": "1"
-    }).success( (res) =>{
-
-    }).fail( (error) => {
-      
+    if(!options.productId) return false;
+    const productId = options.productId;
+    const groupId = options.groupId;
+    const orderId = options.id;
+    this.setData({
+      productId,
+      groupId,
+      orderId
     })
-    httpRequestApi.JoinGroupPurchas('1541386476732288').success( (res) =>{
-
+    //课本详情
+    httpRequestApi.getBookDetail(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
+      })
+      const lessonTemp = [];
+      lessonList.forEach(item => {
+          const temp = {};
+          temp.id = item.id;
+          temp.title = item.title;
+          temp.readNum = item.readCount;
+          lessonTemp.push(temp);
+      });
+      this.setData({
+          lessonList: lessonTemp
+      });
     }).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)
     })
     
   },

+ 35 - 55
pages/groupPage/group-details/group-details.wxml

@@ -2,86 +2,66 @@
 <view class="group-details">
     <view class="details-head" bindtap="collage">
         <view class="headImg">
-            <view class="headImg-item">
-                
-            </view>
-            <view class="headImg-item">
- 
-            </view>
-            <view class="headImg-item">
-                <image src="../../../static/groupImg/Mask Copy@2x.png"></image>
-            </view>
-            <view class="headImg-item">
-                <image src="../../../static/groupImg/Mask Copy@2x.png"></image>
-            </view>  
-            <view class="headImg-item">
-                <image src="../../../static/groupImg/Mask Copy@2x.png"></image>
-            </view>
-            <view class="headImg-item">
-                <image src="../../../static/groupImg/Mask Copy@2x.png"></image>
-            </view>                      
+            <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>3</text>个名额就拼团成功了</view>
+            <view class="shengyu-num">仅剩<text>{{surplusNum}}</text>个名额就拼团成功了</view>
             <view class="shengyu-time">
                 剩余时间:
                 <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</text>
+                    <image src="../../../static/groupImg/Rectangle_31.png"></image>
+                    <text>{{timeList[0]}}</text>
                 </view>
-                <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</text>
-                </view>
-                <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</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>
-                <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</text>
-                </view>
-                <view class="time">
-                    <image src="../../../static/groupImg/Rectangle 31@2x.png"></image>
-                    <text>1</text>
-                </view>                
+                <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>
     <scroll-view scroll-y="{{true}}">
         <view class="grade-details" bindtap="gradeDetails">
-            <image src="" style="background: red;"></image>
-            <text>【部编版】一年级语文同步-上学期</text>
-            <text>《语文一年级上册》为人教社2016年修订的教材,包括“我上学了识字汉语拼音课文口语交际语文园地”和“快乐读吧供一年级上学期使用。</text>
+            <image src="{{titleIcon}}" ></image>
+            <text>{{title}}</text>
+            <text>{{bookInfo}}</text>
         </view>
         <view class="catalog">
             <image src="../../../static/groupImg/Rectangle 34@2x.png"></image>
             <text>语文目录</text>
         </view>
         <view class="catalog-list">
-            <view class="catalog-item">
-                <text class="left">第一课 小小的船</text>
-                <text class="right">3215朗读 ></text>
-            </view>
-            <view class="catalog-item">
-                <text class="left">第一课 小小的船</text>
-                <text class="right">3215朗读 ></text>
-            </view>
-            <view class="catalog-item">
-                <text class="left">第一课 小小的船</text>
-                <text class="right">3215朗读 ></text>
-            </view>            
+            <view class="catalog-item" wx:for="{{lessonList}}" wx:key="{{index}}" data-id="{{item.id}}" data-title="{{item.title}}">
+                <text class="left">{{item.title}}</text>
+                <text class="right">{{item.readingNum}}朗读 ></text>
+            </view>           
         </view>
     </scroll-view>
     <view class="group-details-btn">
-        <view class="left-btn">
+        <view class="left-btn" bindtap="openGroup">
             开团
         </view>
-        <view class="right-btn">
-            <image src="../../../static/groupImg/Rectangle 8 Copy@2x.png"></image>
+        <view class="right-btn" bindtap="jionGroup">
+            <image src="../../../static/groupImg/jionBg.png"></image>
             <text>参团</text>
         </view>
     </view>

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

@@ -20,14 +20,14 @@
 .headImg-item {
     width: 106rpx;
     height: 106rpx;
-    background: red;
     border-radius: 50%;
     margin: 20rpx 22rpx;
 }
 
 .headImg-item image {
     width: 100%;
-    height: 100%
+    height: 100%;
+    border-radius: 50%;
 }
 
 .shengyu {
@@ -62,13 +62,13 @@
     position: absolute;
     left: 0;
     top: 0;
-    width: 20rpx;
+    width: 24rpx;
     height: 40rpx;
 }
 
 .shengyu-time .time  text{
     position: absolute;
-    left: 0;
+    left: 2rpx;
     top: 0;
     z-index: 2;
     color: #fff;
@@ -129,6 +129,7 @@ scroll-view {
 .catalog-list {
     width: 100%;
     padding: 18rpx;
+    margin-bottom: 120rpx;
     box-sizing: border-box;
 }
 

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

@@ -0,0 +1,85 @@
+// pages/groupPage/my-group/my-group.js
+import httpRequestApi from '../../../utils/APIClient';
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    myGroupList: []
+  },
+    //跳转到团购详情页
+  collageDetails: function ({currentTarget}) {
+    const orderId = currentTarget.dataset.orderid;
+    const num = currentTarget.dataset.num;
+    console.log(num)
+    if(!num) {
+      wx.navigateTo({
+        url: `/pages/groupPage/collage-details/collage-details?orderId=${orderId}`
+      })
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    httpRequestApi.getMygroup().success((res) => {
+      console.log('我的团', res.data.data.list)
+      this.setData({
+        myGroupList: res.data.data.list
+      })
+    }).fail( error => {
+      console.log('错误', error)
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

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

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

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

@@ -0,0 +1,14 @@
+<!--pages/groupPage/my-group/my-group.wxml-->
+<view class="my-group">
+    <scroll-view scroll-y="{{true}}">
+        <view class="my-group-content">
+            <block wx:for="{{myGroupList}}" wx:key="{{index}}">
+                <view class="group-item" bindtap="collageDetails" data-num="{{item.joinCount >= item.headcount}}" data-orderId="{{item.id}}">
+                    <image class="item-img" src="{{item.iconImg}}" style="background: red;"></image>
+                    <view id="grade">{{item.groupTitle}}</view>
+                    <image class="type-img" src="../../../static/groupImg/{{item.joinCount >= item.headcount ? 'yisuccess' : 'weisuccess' }}.png"></image>
+                </view> 
+            </block>
+        </view>
+    </scroll-view>
+</view>

+ 39 - 0
pages/groupPage/my-group/my-group.wxss

@@ -0,0 +1,39 @@
+/* pages/groupPage/my-group/my-group.wxss */
+.my-group {
+    width: 100%;
+    height: 100%;
+}
+
+.my-group scroll-view {
+    width: 100%;
+    height: 100%;
+}
+
+.my-group-content {
+    width: 100%;
+    display: flex;
+    justify-content: space-between;
+    flex-wrap: wrap;
+    padding: 44rpx 28rpx;
+    box-sizing: border-box;
+}
+
+.group-item {
+    position: relative;
+    display: flex;
+    flex-direction: column;
+    text-align: center;
+}
+
+.group-item .item-img {
+    width: 214rpx;
+    height: 278rpx;
+}
+
+.type-img {
+    position: absolute;
+    left: 0;
+    top: 16rpx;
+    width: 100rpx;
+    height: 40rpx;
+}

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

@@ -7,7 +7,7 @@ Page({
         wx.setNavigationBarTitle({
             title: '全部课本'
         })
-        httpRequestApi.getAllBooks(1, 1, 10).success((res) => {
+        httpRequestApi.getAllBooks(1, 10).success((res) => {
             const books = res.data.data.list;
             const booksTemp = [];
             books.forEach(item => {

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

@@ -11,7 +11,7 @@ Page({
             title: options.title
         })
         const uid= wx.getStorageSync('uid');
-        httpRequestApi.getBookDetail(1, options.id).success((res) => {
+        httpRequestApi.getBookDetail(uid, options.id).success((res) => {
             console.log(res.data.data)
             const bookInfo = res.data.data.product;
             const lessonList = res.data.data.lessonList;

+ 9 - 2
project.config.json

@@ -36,7 +36,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 4,
+			"current": 5,
 			"list": [
 				{
 					"id": 0,
@@ -65,7 +65,14 @@
 				{
 					"id": -1,
 					"name": "团购",
-					"pathName": "pages/groupPage/collage-details/collage-details"
+					"pathName": "pages/groupPage/collage-details/collage-details",
+					"query": ""
+				},
+				{
+					"id": -1,
+					"name": "aaa",
+					"pathName": "pages/groupPage/collage-details/collage-details",
+					"query": "productId=1"
 				}
 			]
 		}

BIN
static/groupImg/Group 11.png


BIN
static/groupImg/Group 11@2x.png


BIN
static/groupImg/Group 11@3x.png


BIN
static/groupImg/Rectangle 13.png


BIN
static/groupImg/Rectangle 13@2x.png


BIN
static/groupImg/Rectangle 13@3x.png


BIN
static/groupImg/Rectangle 30.png


BIN
static/groupImg/Rectangle 30@3x.png


BIN
static/groupImg/Shape.png


BIN
static/groupImg/Shape1.png


BIN
static/groupImg/Shape1@3x.png


BIN
static/groupImg/Shape2.png


BIN
static/groupImg/Shape2@3x.png


BIN
static/groupImg/Shape@3x.png


BIN
static/groupImg/bai.png


BIN
static/groupImg/cha.png


BIN
static/groupImg/lan.png


BIN
static/groupImg/shareBg.png


BIN
static/groupImg/sure.png


BIN
static/groupImg/tuandui.png


BIN
static/groupImg/tuandui@3x.png


BIN
static/groupImg/weisuccess.png


BIN
static/groupImg/yisuccess.png


+ 31 - 7
utils/APIClient.js

@@ -38,20 +38,20 @@ module.exports = {
 		}).url(url).send();
 	},
 	// 获取全部课本
-	getAllBooks(uid,pageNo,pageSize) {
+	getAllBooks(pageNo,pageSize) {
 		let url = getProductUrl('wx/product');
 		return request.getInstance().header({
-			uid
+			uid: wx.getStorageSync('uid')
 		}).url(url).data({
 			pageNo,
 			pageSize
 		}).send();
 	},
 	// 获取课本详情
-	getBookDetail(uid,id) {
+	getBookDetail(id) {
 		let url = getProductUrl(`wx/product/${id}`);
 		return request.getInstance().header({
-			uid
+			uid: wx.getStorageSync('uid')
 		}).url(url).send();
 	},
 	// 获取单课详情
@@ -149,25 +149,32 @@ module.exports = {
 			uid
 		}).url(url).data(data).method('POST').send();
 	},
+	// 获取推荐团购信息
+	getGroupList () {
+		let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`);
+		return request.getInstance().header({
+			uid: wx.getStorageSync('uid')
+		}).url(url).send();
+	},
 	// 获取课程团购信息
 	getGroupPurchaseInfo (productId) {
 		let url = getBaseUrl(`wx/groupPurchaseInfo/info/${productId}`);
 		return request.getInstance().header({
-			uid: 1
+			uid: wx.getStorageSync('uid')
 		}).url(url).send();
 	},
 	// 发起团购
 	SendGroupPurchas (data) {
 		let url = getBaseUrl(`wx/groupPurchase/create`);
 		return request.getInstance().header({
-			uid: 1
+			uid: wx.getStorageSync('uid')
 		}).url(url).data(data).method('POST').send();
 	},
 	// 参加团购
 	JoinGroupPurchas (orderId) {
 		let url = getBaseUrl(`wx/groupPurchase/join`);
 		return request.getInstance().header({
-			uid: 1
+			uid: wx.getStorageSync('uid')
 		}).url(url).data({
 			orderId
 		}).method('POST').send();
@@ -179,4 +186,21 @@ module.exports = {
 			uid
 		}).url(url).data(data).method('POST').send();
 	},
+	//我的团
+	getMygroup () {
+		let url = getBaseUrl(`wx/groupPurchase/my`);
+		return request.getInstance().header({
+			uid: wx.getStorageSync('uid')
+		}).url(url).data({
+			pageNo: 1,
+			pageSize: 100
+		}).send();
+	},
+	//获取团购详情
+	getMygroupInfo (orderId) {
+		let url = getBaseUrl(`wx/groupPurchase/info/${orderId}`);
+		return request.getInstance().header({
+			uid: wx.getStorageSync('uid')
+		}).url(url).send();
+	},
 }

+ 7 - 8
utils/util.js

@@ -1,12 +1,11 @@
 const formatTime = date => {
-  const year = date.getFullYear()
-  const month = date.getMonth() + 1
-  const day = date.getDate()
-  const hour = date.getHours()
-  const minute = date.getMinutes()
-  const second = date.getSeconds()
-
-  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
+  console.log(date);
+  const day = parseInt(date / 1000 / 60 / 60 / 24);
+  const hour = parseInt(date / 1000 / 60 / 60  % 24);
+  const minute = parseInt(date / 1000 / 60 % 60);
+  const arr = [hour, minute].map(formatNumber);
+  arr.unshift(day);
+  return arr
 }
 
 const formatNumber = n => {