Browse Source

合并代码

Limengbo 6 years ago
parent
commit
f753143b94

+ 4 - 1
README.md

@@ -63,9 +63,12 @@ AppSecret: adece358e0d933e39d87b68fbf700651
 │   ├── mathematics      // 数学页面
 │   │
 │   ├── medal_rank        // 勋章排名页面
+|   |
+|   |──mistakes             //错题本
+|   |
 │   ├── quantity_rank     //  答题排名排名
 │   │
-│   ├── recommend       //  本周推荐
+│   ├── recommend       //  本周推荐改为了错题本暂时注释掉
 │   │
 │   ├── science     // 科学页面
 │   │

+ 2 - 1
app.json

@@ -17,7 +17,8 @@
     "pages/quantity_rank/quantity_rank",
     "pages/accuracy_rank/accuracy_rank",
     "pages/set_name/set_name",
-    "pages/particulars/particulars"
+    "pages/particulars/particulars",
+    "pages/mistakes/mistakes"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 26 - 4
compontents/chat/chat.js

@@ -46,6 +46,8 @@ Component({
    */
   data: {
     animationData: {},
+    ratio: '',
+    canvasHeight: ''
   },
 
   /**
@@ -77,12 +79,19 @@ Component({
     },
     //分享
     shareImage: function(e){
-      console.log(e);
+      this.triggerEvent('getHeight');
       //分享查询单条的时候会用到这个值
       const postId = e.currentTarget.dataset.postsid;
+      //获取分享的图片
+      const imgUrl = e.currentTarget.dataset.imgurl;
+      //获取分享的个人信息
+      const featureMap = e.currentTarget.dataset.featuremap;
+      //获取输入内容
+      const title = e.currentTarget.dataset.title;
+      //获取宽高比例
+      const ratio = this.data.ratio;
       //分享组件弹窗调用里边方法,在底下会获取
-      this.share.showPopup(postId);
-
+      this.share.showPopup(postId, imgUrl, featureMap, title, ratio);
     },
     //跳转详情页
     particulars: function (e) {
@@ -122,7 +131,20 @@ Component({
       var myEventDetail = {} // detail对象,提供给事件监听函数
       var myEventOption = {} // 触发事件的选项
       this.triggerEvent('myevent', myEventDetail, myEventOption)
-    }
+    },
+    //获取image宽高
+    imageLoad: function(e) {  
+      let height = e.detail.height;
+      let width = e.detail.width;
+      //获取屏幕宽度
+      const windowWidth = wx.getSystemInfoSync().windowWidth;
+      //获取图片高度
+      const imgHeight = windowWidth*(height/width);
+      this.setData({
+        ratio: height/width,
+        canvasHeight: imgHeight + 300
+      })
+    }  
   },
   ready: function(){
     //获取分享弹窗组件

+ 4 - 9
compontents/chat/chat.wxml

@@ -21,7 +21,7 @@
                 </view>
                 <view class="picture" wx:if="{{type == 2}}">
                     <block wx:for="{{item.imagesList}}" wx:for-item="items" wx:key="{{items}}">
-                        <image mode="aspectFill" src="{{items}}" catchtap="listenerButtonPreviewImage" data-img="{{items}}"></image>
+                        <image mode="aspectFill" src="{{items}}" catchtap="listenerButtonPreviewImage" data-img="{{items}}" bindload="imageLoad"></image>
                     </block>
                 </view>
                 <view class="icon" wx:if="{{type == 2}}">
@@ -40,18 +40,13 @@
                 </view>
             </view>
             <!--分享按钮 -->
-            <!--暂时注释海报分享功能改为直接分享
-            <view class="share-up-box" wx:if="{{type == 2}}" bindtap="shareImage" data-postsId="{{item.id}}">
+            <view class="share-up-box" wx:if="{{type == 2}}" bindtap="shareImage" data-postsId="{{item.id}}" data-imgUrl="{{item.imagesList}}" data-featureMap="{{item.featureMap}}" data-title="{{item.title}}">
                 <image class="share_up" src="../../pages/image/share_up.png"></image>
             </view>
-            -->
-            <button class='transmit' open-type="share" id="transmit" data-userId="{{userId}}" data-postId="{{item.id}}"  wx:if="{{type == 2}}">
-                <image class="share_up" src="../../pages/image/share_up.png"></image>
-            </button> 
         </view>
         <view class="more" wx:if="{{more}}" bindtap="examine">查看更多</view>
     </view>
-    <view class="no-con" wx:if="{{!productionData.list && type == 2}}">
+    <view class="no-con" wx:if="{{(productionData.list.length === 0) && type == 2}}">
         <view class="state">你还没有上传作品</view>
         <view class="upload-works" bindtap="uploadImage">
             <image src="../../pages/image/work_box.png" class="work-box"></image>
@@ -59,7 +54,7 @@
             <text>上传作品</text>
         </view>
     </view>
-    <view class="no-con" wx:if="{{!productionData.list && type == 1}}">
+    <view class="no-con" wx:if="{{(productionData.list.length === 0) && type == 1}}">
         <view class="state">你还没有提问过问题</view>
         <view class="upload-works" bindtap="uploadImage">
             <image src="../../pages/image/work_box.png" class="work-box"></image>

+ 2 - 2
compontents/curriculum/curriculum.js

@@ -38,9 +38,9 @@ Component({
   methods: {
     onTap (e) {
       let flage = e.target.dataset.flag;
-      const height = this.properties.studyLog.length * 68;
+      const height = this.properties.studyLog.length * 54;
       if(flage){
-        this.util(flage, '700rpx');
+        this.util(flage, '680rpx');
         this.setData({
           'flag': false,
           'downUp': '展开',

+ 3 - 2
compontents/curriculum/curriculum.wxss

@@ -3,7 +3,7 @@
     width:100%;
     margin:20rpx 0;
     border-radius:25rpx;
-    padding: 28rpx 28rpx 81rpx 28rpx;
+    padding: 28rpx 28rpx 61rpx 28rpx;
     box-sizing:border-box;
     background:#fff;
     position: relative;
@@ -34,7 +34,8 @@
     display: flex;
     justify-content: space-between;
     align-items: center;
-    margin-top: 30rpx;
+    height:32rpx;
+    margin-top:24rpx;
 }
 
 .record_list text {

+ 2 - 1
compontents/lesson_list/lessonList.wxss

@@ -27,7 +27,6 @@
 }
 
 .lesson-name text:nth-child(1) {
-    height: 38rpx;
     font-size: 36rpx;
     font-weight: 600;
 }
@@ -48,6 +47,7 @@
 
 .art-lesson {
      position: relative;
+     height:32rpx;
      margin-top: 24rpx;
  }
 
@@ -64,6 +64,7 @@
     justify-content: space-between;
     height:32rpx;
     margin-left: 53rpx;
+    height:32rpx;
     font-size: 28rpx;
     color: #878787;
 }

+ 1 - 1
compontents/preview/preview.wxss

@@ -27,7 +27,6 @@
 }
 
 .lesson-name text:nth-child(1) {
-    height: 38rpx;
     font-size: 36rpx;
     font-weight: 600;
 }
@@ -51,6 +50,7 @@
     justify-content: space-between;
     height:32rpx;
     margin-left: 53rpx;
+    height:32rpx;
     font-size: 28rpx;
     color: #303030;
     margin-top: 24rpx;

+ 10 - 10
compontents/rank-tarbar/rank-tarbar.js

@@ -14,7 +14,7 @@ Component({
    * navBtnSelectIdx点击改变的值
    */
   data: {
-    motto: ['好友数','勋章数','等级','答题量','准确率'],
+    motto: ['勋章数','等级','答题量','准确率'],
     navBtnSelectIdx: 0,
   },
 
@@ -28,29 +28,29 @@ Component({
       if (index != this.navBtnSelectIdx) {
         this.setData({ navBtnSelectIdx: index});
       }
+      // if(index == 0) {
+      //   wx.redirectTo({
+      //     url: '../competition/competition?ind=0'
+      //   })
+      // }
       if(index == 0) {
         wx.redirectTo({
-          url: '../competition/competition?ind=0'
+          url: '../medal_rank/medal_rank?ind=0'
         })
       }
       if(index == 1) {
         wx.redirectTo({
-          url: '../medal_rank/medal_rank?ind=1'
+          url: '../grade_rank/grade_rank?ind=1'
         })
       }
       if(index == 2) {
         wx.redirectTo({
-          url: '../grade_rank/grade_rank?ind=2'
+          url: '../quantity_rank/quantity_rank?ind=2'
         })
       }
       if(index == 3) {
         wx.redirectTo({
-          url: '../quantity_rank/quantity_rank?ind=3'
-        })
-      }
-      if(index == 4) {
-        wx.redirectTo({
-          url: '../accuracy_rank/accuracy_rank?ind=4'
+          url: '../accuracy_rank/accuracy_rank?ind=3'
         })
       }
     }

+ 82 - 0
compontents/set_grade/set_grade.js

@@ -0,0 +1,82 @@
+// compontents/share/share.js
+const util = require('../../utils/util.js');
+const APIClient = require('../../utils/APIClient.js');
+const login = require('../../utils/loginSchedule.js');
+Component({
+  /**
+   * 组件的属性列表
+   * grade年级
+   */
+  properties: {
+   "grade": {
+     type: String,
+     value: ''
+   }
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    flag: true,
+    gradeData: [
+      '一年级',
+      '二年级',
+      '三年级'
+    ]
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    //隐藏框
+    hidePopup: function () {
+      this.setData({
+        flag: !this.data.flag
+      })
+    },
+    //展示框
+    showPopup () {
+      this.setData({
+        flag: !this.data.flag
+      })
+    },
+    grade (e) {
+      const grade = e.currentTarget.dataset.grade + 1
+      this.setData({
+        grade:  util.gradeUpper(grade)
+      })
+      //调用更改年级接口
+      login.getOpenidSessionKey((res) => {
+        //console.log(res.data.data.uid);
+        APIClient.getSetNameSchedule({
+          uid: res.data.data.uid
+        }, {
+          grade: grade
+        }).success(res => {
+          console.log(res)
+          if(res.data.success) {  
+            wx.redirectTo({
+              url: '../index/index?ind=0'
+            })
+          }
+        })      
+      }, function() {
+        wx.showModal({
+          title: '提示',
+          content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
+          showCancel: false,
+          success: function (res) {
+            if (res.confirm) {
+              console.log('用户点击确定')
+            } else if (res.cancel) {
+              console.log('用户点击取消')
+            }
+          }
+        })
+      });
+    }
+  }
+
+})

+ 4 - 0
compontents/set_grade/set_grade.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 11 - 0
compontents/set_grade/set_grade.wxml

@@ -0,0 +1,11 @@
+<!--compontents/share/share.wxml-->
+<view class="container" bindtap="hidePopup" hidden="{{flag}}">
+    <view class="share">
+        <view class="title">年级</view>
+        <view class="share-img"> 
+            <view class="download" wx:for="{{gradeData}}" wx:key="{{index}}">
+                <text class="{{item === grade ? 'color' : ''}}" catchtap="grade" data-grade="{{index}}">{{item}}</text>
+            </view>
+        </view>
+    </view>
+</view>

+ 60 - 0
compontents/set_grade/set_grade.wxss

@@ -0,0 +1,60 @@
+/* compontents/share/share.wxss */
+.container {
+    position:fixed;
+    left: 0;
+    bottom: 0;   
+    width: 100%;
+    height: 100%;
+    z-index: 98;
+}
+
+.container:after {
+    content:'';
+    position:absolute;
+    left: 0;
+    bottom: 0;   
+    width: 100%;
+    height: 100%;
+    background: rgba(255,255,255,.8);
+    filter: blur(15px);
+    z-index: 99;
+}
+
+.share {
+    position:fixed;
+    left: 15rpx;
+    bottom: 0;
+    width: calc(100% - 30rpx);
+    border-radius:25rpx;
+    padding:32rpx 24rpx;
+    box-sizing:border-box;
+    background:#fff;
+    z-index: 100;
+}
+
+.share .title {
+    font-size: 32rpx;
+    font-weight: bolder;
+    color: #3F3F3F;
+    text-align: center;
+    padding-bottom: 20rpx;
+    border-bottom: 2rpx solid #C8C8C8;
+    
+}
+
+.share-img {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+}
+
+.share-img text {
+    font-size: 32rpx;
+    color: #3F3F3F;
+    margin-top: 43rpx;
+}
+
+.share-img .color {
+    color: red;
+}

+ 103 - 2
compontents/share/share.js

@@ -14,6 +14,10 @@ Component({
   data: {
     flag: true,
     postId: '',
+    imgUrl: [],
+    featureMap: {},
+    title: '',
+    ratio: ''
   },
 
   /**
@@ -27,12 +31,109 @@ Component({
       })
     },
     //展示分享框
-    showPopup (postId) {
+    showPopup (postId, imgUrl, featureMap, title, ratio) {
       this.setData({
         flag: !this.data.flag,
-        postId
+        postId,
+        imgUrl,
+        featureMap,
+        title,
+        ratio
       })
     },
+    //保存图片 
+    saveImage (e) {
+      const imgUrl = this.data.imgUrl;
+      const ratio = this.data.ratio;
+      const featureMap = this.data.featureMap;
+      const title = this.data.title;
+      //获取屏幕宽度
+      const windowWidth = wx.getSystemInfoSync().windowWidth;
+      //获取图片高度
+      const imgHeight = windowWidth*ratio;
+      //先绘制图片
+      for (let item of imgUrl) {
+        // wx.downloadFile({
+        //   url: item,
+        //   success: function (res) {
+        //     console.log(res);
+        //   }
+        // })
+        //canvas绘制文字和图片
+        const ctx = wx.createCanvasContext('myCanvas');
+        var imgPath = item;
+        ctx.setFillStyle('white')
+        ctx.fillRect(0, 0, windowWidth, imgHeight + 300)
+        //绘制用户上传的图片
+        ctx.drawImage(imgPath, 0, 0, windowWidth, imgHeight);
+        //绘制用户发表的内容和名字
+        ctx.setFontSize(16)
+        ctx.setFillStyle('black')
+        ctx.fillText(title, 135, imgHeight + 55)
+        ctx.setFontSize(18)
+        ctx.fillText(featureMap.wechatName, 135, imgHeight + 35);
+        //横线
+        ctx.moveTo(20, imgHeight + 140)
+        ctx.lineTo(windowWidth - 40, imgHeight + 140)
+        ctx.stroke()
+        //绘制用户头像圆形切割-开始
+        ctx.save();
+        ctx.beginPath();
+        ctx.arc(70, imgHeight + 70, 50, 0, Math.PI * 2, false);
+        ctx.fill();
+        ctx.clip();
+        //圆形切割-结束
+        ctx.drawImage(featureMap.headImgUrl, 20, imgHeight + 20, 100, 100);
+        ctx.restore();
+        //二维码和文字
+        ctx.setFontSize(16)
+        ctx.setFillStyle('black')
+        ctx.fillText('长按二维码', 50, imgHeight + 180)
+        ctx.fillText('进入小程序查看更多', 50, imgHeight + 210)
+        ctx.draw()
+      }
+      setTimeout(() => {
+        this.canvasToImage()
+      }, 200)
+    },
+    canvasToImage () {
+        let that = this;
+        //canvas生成图片
+        wx.canvasToTempFilePath({
+          x: 0,
+          y: 0,
+          width: that.windowWidth,
+          height: that.imgHeight + 300,
+          destWidth: that.windowWidth,
+          destHeight: that.imgHeight + 300,
+          canvasId: 'myCanvas',
+          success: (res) => {
+              console.log(res.tempFilePath);
+              //保存图片到本地
+              wx.saveImageToPhotosAlbum({
+                filePath: res.tempFilePath,
+                success(res) {
+                    wx.showModal({
+                        title: '存图成功',
+                        content: '图片成功保存到相册了,去发朋友圈',
+                        showCancel:false,
+                        confirmText:'我知道了',
+                        confirmColor:'#72B9C3',
+                        success: function(res) {
+                            if (res.confirm) {
+                                console.log('用户点击确定');
+                            }
+                            //that.hideShareImg()
+                        }
+                    })
+                }
+              })
+          },
+          fail:function (res) {
+              console.log(res)
+          }
+        })
+    }
   }
 
 })

+ 1 - 1
compontents/share/share.wxml

@@ -3,7 +3,7 @@
     <view class="share">
         <view class="title">分享</view>
         <view class="share-img">
-            <view class="download">
+            <view class="download" catchtap="saveImage">
                 <image src="../../pages/image/download.png"></image>
                 <text>生成海报分享</text>
             </view>

+ 2 - 2
compontents/tarbar/tarbar.js

@@ -13,7 +13,7 @@ Component({
    * 组件的初始数据
    */
   data: {
-    motto: ['我的','本周推荐','语文','数学','中文','英语','科学','艺术'],
+    motto: ['我的','错题本','语文','数学','中文','英语','科学','艺术'],
     navBtnSelectIdx: 0,
     left: 0
   },
@@ -42,7 +42,7 @@ Component({
       }
       if(index == 1) {
         wx.redirectTo({
-          url: '../recommend/recommend?ind=1'
+          url: '../mistakes/mistakes?ind=1'
         })
       }
       if(index == 2) {

+ 16 - 2
pages/art/art.js

@@ -33,7 +33,8 @@ Page({
     previewHeight: '',
     productionMore: '',
     questionsMore: '',
-    wxObjectives: []
+    wxObjectives: [],
+    canvasHeight: ''
   },
 
   /* 区分答疑和分享 */
@@ -113,6 +114,14 @@ Page({
     }
   },
 
+  /*点击获取canvas高度*/
+  onGetHeight: function (e) {
+    const canvasHeight = this.selectComponent("#chat").data.canvasHeight;
+    this.setData({
+      canvasHeight,
+    })
+  },
+
   /*点击定位*/
   location: function (e) {
     const position = e.currentTarget.dataset.id;
@@ -125,6 +134,7 @@ Page({
 
 
   onLoad: function (options) {
+    //this.chat = this.selectComponent("#chat");
     const columnId = util.column('6').columnId;
     /* 分享 */
     this.distinction(2, columnId, 1, 2, res => {
@@ -205,7 +215,11 @@ Page({
   },
 
   onShow: function () {
+    
+  },
+  keep: function () {
 
+    
   },
   /* 转发*/
   onShareAppMessage: function (ops) {
@@ -226,5 +240,5 @@ Page({
         console.log("转发失败:" + JSON.stringify(res));
       }
     }
-  },
+  }
 })

+ 5 - 0
pages/art/art.wxml

@@ -18,12 +18,14 @@
             height="{{previewHeight}}"/>
 
             <chat id="upload"
+                id="chat"
                 productionData="{{productionData}}" 
                 title="作品展示"
                 query="上传作品"
                 type="2"
                 columnType="6"
                 bind:myevent="onMyEvent"
+                bind:getHeight="onGetHeight"
                 data-type="2"
                 more="{{productionMore}}"/>
 
@@ -45,6 +47,9 @@
             <view class="upload-one" data-id="upload" bindtap="location">
                 <image src="../image/works.png" ></image>
             </view>  
+            <view class="canvas-box">
+                <canvas canvas-id="myCanvas" style="width:100%; height: {{canvasHeight}}px;"></canvas>
+            </view>
           </view>
       </scroll-view>
   </view>

+ 8 - 0
pages/art/art.wxss

@@ -306,4 +306,12 @@
     background: #F73861;
     font-size: 24rpx;
     border-radius: 50%;
+}
+/*canvas样式*/
+.canvas-box {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    z-index: -2;
 }

BIN
pages/image/analysis_bottom.png


BIN
pages/image/analysis_top.png


BIN
pages/image/bg.png


BIN
pages/image/no_gain.png


+ 73 - 4
pages/index/index.js

@@ -19,7 +19,10 @@ Page({
     share: false,
     studyLog: [],
     height: '',
-    flag: true
+    flag: true,
+    productionData: {},
+    num2: 0,
+    productionMore: ''
   },
   
   lower: function (e) {
@@ -44,7 +47,6 @@ Page({
       this.setData({
         flag: !this.data.flag
       })
-
       APIClient.getMySchedule({
         uid: res.data.data.uid
       }).success(res => {
@@ -89,6 +91,9 @@ Page({
     });  
   },
   onLoad: function (options) {
+    //获取更改年级组件
+    this.setGrade = this.selectComponent("#set-grade");
+    console.log(this.setGrade)
     //获取分享过来的值跳转页面
     const ind  = options.ind;
     const postsId = options.postId || '';
@@ -105,6 +110,23 @@ Page({
         this.setData({left: 200 });
       }  
     }
+    /* 分享 */
+    const columnId = util.column('6').columnId;
+    this.distinction(2, columnId, 1, 2, res => {
+      if(res.data.success) {
+        console.log(res.data.data)
+        this.setData({
+          productionData: res.data.data
+        })
+        if(res.data.data) {
+          if(res.data.data.totalSize > 2) {
+            this.setData({
+              productionMore: true
+            })
+          }
+        }
+      }
+    });
   },
   onShow: function () {
     //登录页信息
@@ -124,7 +146,7 @@ Page({
 
         if(res.data.data.studyLog.length > 10) {
           this.setData({
-            height: '700'
+            height: '680'
           })
         }
       })
@@ -144,5 +166,52 @@ Page({
       })
     });  
   },
-
+  /* 区分答疑和分享 */
+  distinction: function(type, columnId, pageNo, pageSize, success) {
+    login.getOpenidSessionKey(function(res) {
+      //console.log(res.data.data.uid);
+      APIClient.getProductionSchedule({
+        uid: res.data.data.uid
+      }, {
+        "type": type,
+        "category": columnId,
+        "pageNo": pageNo,
+        "pageSize": pageSize
+      }).success(success)
+    }, function() {
+      // wx.showModal({
+      //   title: '提示',
+      //   content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
+      //   showCancel: false,
+      //   success: function (res) {
+      //     if (res.confirm) {
+      //       console.log('用户点击确定')
+      //     } else if (res.cancel) {
+      //       console.log('用户点击取消')
+      //     }
+      //   }
+      // })
+    });
+  },
+  /*点击加载更多*/
+  onMyEvent: function(e){
+    const columnId = util.column('6').columnId;
+    this.data.num2++
+    this.setData({
+      num: this.data.num2
+    })
+    this.distinction(2, columnId, 1, 5*this.data.num2, res => {
+      if(res.data.success) {
+        console.log(res.data.data)
+        this.setData({
+          productionData: res.data.data,
+        }) 
+        if(5*this.data.num2 > res.data.data.totalSize) {
+          this.setData({
+            productionMore: ''
+          })
+        }
+      }
+    });
+  },
 })

+ 31 - 14
pages/index/index.wxml

@@ -13,17 +13,22 @@
                 <view class='head'>
                   <image class="userinfo-avatar" src="{{data.users.headImgUrl}}" background-size="cover"></image>
                   <view class='left'>
-                    <view class="name">
-                      {{data.users.wechatName}}
-                    </view>
                     <view class="student">
                       学号:<text>{{data.users.eid}}</text>
                     </view>
-                    <view class='LV'>{{grade}}</view>
+                    <view class="name">
+                      {{data.users.wechatName}}
+                      <text class='LV'>LV {{data.level}}</text>
+                    </view>
                   </view>
                 </view>
-                <view class='grade'>
-                  <navigator style='font-size:28rpx;' url="../set_name/set_name" >更改昵称</navigator>
+                <view>
+                  <view class='grade' bindtap="setgrade">
+                    {{grade}}
+                  </view>
+                  <view class='set-name'>
+                    <navigator style='font-size:28rpx;' url="../set_name/set_name" >更改昵称</navigator>
+                  </view>
                 </view>
               </view>
               <view class='personal'>
@@ -47,15 +52,9 @@
             </view>
             <!-- 答题 -->
             <view class="ranking">
-              <view class="title">
-                <text>好友比一比</text>
-              </view>
+              <view class="dashed"></view>
               <view class="ranking-con">
                 <view class="rank">
-                  <text>好友数: {{rankData.friendsRank.number}}位</text>
-                  <text>第{{rankData.friendsRank.rank}}名</text>
-                </view>
-                <view class="rank">
                   <text>勋章数量:{{rankData.metalsRank.number}}枚</text>
                   <text>第{{rankData.metalsRank.rank}}名</text>
                 </view>
@@ -73,7 +72,7 @@
                 </view>
               </view>
               <view class="particular">
-                <navigator url="../competition/competition" >查看详细排行</navigator>
+                <navigator url="../medal_rank/medal_rank" >查看详细排行</navigator>
               </view>
             </view>
             <!-- 勋章 -->
@@ -85,6 +84,11 @@
 
               <scroll-view scroll-x="true" >
                 <view class="img">
+                  <view wx:if="{{!data.isHave}}">
+                    <image src="../image/no_gain.png" class="no-gain"></image>
+                    <image src="{{data.currentMetals.unsoldImg}}"></image>
+                    <text>本周勋章</text>
+                  </view>
                   <view wx:for="{{data.metalsList}}" wx:key="{{item.id}}" >    
                     <image src="{{item.img}}"></image>
                     <text>{{item.name}}</text>
@@ -99,6 +103,19 @@
               studyLog="{{ studyLog }}"
               height="{{height}}"/>
             </view>
+            <!-- 上传作品 -->
+            <chat id="upload"
+              productionData="{{productionData}}" 
+              title="我的作品"
+              query="上传作品"
+              type="2"
+              columnType="6"
+              bind:myevent="onMyEvent"
+              more="{{productionMore}}"/>
+            <!-- 更改年级 -->
+            <setGrade 
+             id="set-grade"
+             grade="{{grade}}"/>
           </view>
       </scroll-view>
   </view>

+ 33 - 9
pages/index/index.wxss

@@ -22,6 +22,10 @@
   background: #fff;
 }
 
+.message {
+  margin: 20rpx 0 0 0;
+}
+
 .user {
   display: flex;
   justify-content: space-between;
@@ -49,30 +53,29 @@
 .userinfo-avatar {
   width: 86rpx;
   height: 86rpx;
-  border-radius: 50%;
+  border-radius: 20%;
 }
 
 .name {
   height:44rpx;
   font-size: 36rpx;
   font-weight: 600;
+  margin-top: 10rpx;
 }
 
 .LV {
-  position: absolute;
-  right:40rpx;
-  top:110rpx;
   font-size: 28rpx;
+  font-weight: 600;
 }
 
 .student {
   height:34rpx;
   font-size: 28rpx;
   color: #878787;
-  margin-top: 10rpx;
 }
 
-.grade {
+.grade,
+.set-name {
   width: 146rpx;
   height: 46rpx;
   font-size: 28rpx;
@@ -84,6 +87,10 @@
   line-height: 48rpx; 
 }
 
+.set-name {
+  margin-top: 10rpx;
+}
+
 .personal {
   display: flex;
   margin-top: 34rpx;
@@ -98,23 +105,32 @@
 
 /*排名*/
 .ranking {
+  margin: 0 0 20rpx 0;
   position: relative;
 }
 
+.dashed {
+  position: absolute;
+  top: 0;
+  left: 5%;
+  width: 90%;
+  border-top:2rpx dashed #878787;
+}
+
 .ranking .title text{
   font-size: 36rpx;
   font-weight: 600;
 }
 
 .ranking-con {
-  margin-bottom: 70rpx;
+  margin-bottom: 40rpx;
 }
 
 .rank {
   display: flex;
   justify-content: space-between;
   font-size: 28rpx;
-  margin-top: 30rpx;
+  margin-bottom: 30rpx;
 }
 
 .particular {
@@ -152,14 +168,22 @@
 }
 
 .img view {
+  position: relative;
   flex: 1;
   display: flex;
   flex-direction: column;
   justify-content: center;
-  align-items: center;
   margin-right: 15rpx;
 }
 
+.no-gain {
+  position: absolute;
+  left: 0;
+  top: 0;
+  width: 142rpx;
+  height: 142rpx;
+}
+
 .img image {
   width: 140rpx;
   height: 140rpx;

+ 149 - 0
pages/mistakes/mistakes.js

@@ -0,0 +1,149 @@
+// pages/mistakes/mistakes.js
+const util = require('../../utils/util.js');
+const APIClient = require('../../utils/APIClient.js');
+const login = require('../../utils/loginSchedule.js');
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    mistakesData: [],
+    animationData: {},
+    flag: [],
+    exponentData: []
+  },
+
+  particulars: function (e) {
+    let flage = e.currentTarget.dataset.flag;
+    let index = e.currentTarget.dataset.index;
+    if(flage){
+      this.util('60rpx');
+      this.data.flag[index] = false;
+      this.setData({
+        flag: this.data.flag,
+      })
+    } else {
+      this.data.flag[index] = true;
+      this.util('164rpx');
+      this.setData({
+        flag: this.data.flag,
+      })
+    }
+  },
+
+  /* 创建动画并执行 */
+  util (height) {
+    // 创建动画实例   
+    var animation = wx.createAnimation({  
+      duration: 200,  //动画时长  
+      timingFunction: "linear", //线性  
+      delay: 0  //0则不延迟  
+    });
+    
+    this.animation = animation;
+
+    animation.height(height).step();
+
+    this.setData({  
+      animationData: animation.export()  
+    })  
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    login.getOpenidSessionKey(res => {
+      APIClient.getErrorsSchedule({
+        uid: res.data.data.uid
+      },{
+        pageNo: 1,
+        pageSize: 1000,
+      }).success(res => {
+        console.log(res.data.data.list)
+        this.setData({
+          mistakesData: res.data.data.list
+        })
+
+        for(let item of  res.data.data.list) {
+          this.data.flag.push(false);
+        }
+        this.setData({
+          flag: this.data.flag
+        })
+      })
+      //用户答题指数
+      APIClient.getExponentSchedule({
+        uid: res.data.data.uid
+      }).success(res => {
+        console.log(res);
+        this.setData({
+          exponentData: res.data.data
+        })
+      })
+    }, function() {
+      wx.showModal({
+        title: '提示',
+        content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
+        showCancel: false,
+        success: function (res) {
+          if (res.confirm) {
+            console.log('用户点击确定')
+          } else if (res.cancel) {
+            console.log('用户点击取消')
+          }
+        }
+      })
+    });
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  }
+})

+ 6 - 0
pages/mistakes/mistakes.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+      "tarbar": "/compontents/tarbar/tarbar"
+    }
+  }

+ 51 - 0
pages/mistakes/mistakes.wxml

@@ -0,0 +1,51 @@
+<!--pages/mistakes/mistakes.wxml-->
+<view class="container">
+  <!-- 标题 -->
+  <tarbar id="tarbar" />
+  <!-- 内容 -->
+  <view class="content">
+      <scroll-view scroll-y="true"  scroll-with-animation="true" scroll-with-animation="true" enable-back-to-top="true">
+        <view class="recommend">
+           <view class="answer-number">
+            <view class="gross">
+                <text>答题总量</text>
+                <text>{{exponentData.sumAnswer}}</text>
+            </view>
+            <view class="error">
+                <text>错误</text>
+                <text>{{exponentData.sumWrongAnswer}}</text>
+            </view>
+            <view class="correct">
+                <text>准确率</text>
+                <text>{{exponentData.accuracy}}</text>
+            </view>
+           </view>
+           <view class="course">
+            <view class="course-head">
+                <view class="subject select">
+                    语文
+                </view>
+                <view class="subject">
+                    数学
+                </view>
+            </view>
+            <view class="course-content">
+                <view class="error answer-content" wx:for="{{mistakesData}}" wx:key="index">
+                    <image class="questions" src="{{item.questions.img}}"></image>
+                    <view class="answer {{flag[index] ? 'unfold' : ''}}" animation="{{flag[index]? animationData : ''}}">
+                        <view class="answer-txt">
+                            <text>你的答案:{{item.userQuestionResult.answer === "" ? '不知道' : userQuestionResult.answer}}</text>
+                            <text>{{item.questions.answer == item.userQuestionResult.answer ? "" : "(错误)"}}</text>
+                        </view>
+                        <view class="analysis" bindtap="particulars" data-flag="{{flag[index]}}" data-index="{{index}}">
+                            <image class="analysis-img" src="../image/analysis_bottom.png" wx:if="{{!(flag[index])}}"></image>
+                            <image class="analysis-img-top" src="../image/analysis_top.png" wx:else></image>
+                        </view>
+                    </view>
+                </view>
+            </view>
+           </view>
+        </view> 
+      </scroll-view>
+  </view>
+</view>

+ 102 - 0
pages/mistakes/mistakes.wxss

@@ -0,0 +1,102 @@
+/* pages/mistakes/mistakes.wxss */
+.recommend {
+  width: 100%;
+  padding: 0 15rpx;
+  box-sizing: border-box;
+}
+
+.answer-number {
+  width: 100%;
+  margin: 20rpx 0;
+  border-radius: 25rpx;
+  padding: 32rpx 24rpx;
+  box-sizing: border-box;
+  background: #fff;
+  display: flex;
+  justify-content: space-around;
+}
+
+.answer-number view {
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    font-size: 32rpx;
+    color: #444;
+}
+
+.gross text:nth-child(2) {
+    color: #10A1F0;
+    font-size: 36rpx;
+    font-weight: 600;
+}
+
+.error text:nth-child(2) {
+    color: #EA3433;
+    font-size: 36rpx;
+    font-weight: 600;
+}
+
+.correct text:nth-child(2) {
+    color: #444;
+    font-size: 36rpx;
+    font-weight: 600;
+}
+
+.course-head {
+    display: flex;
+    justify-content: center;   
+}
+
+.subject {
+    background: #A3E0F3;
+    padding: 20rpx 70rpx;
+    font-size: 36rpx;
+    font-weight: 600;
+    border-radius: 30rpx 30rpx 0 0;
+}
+
+.select {
+    background: #fff;
+}
+
+.answer-content {
+    margin-bottom: 20rpx;
+}
+
+.answer-content .questions {
+    width: 100%;
+    height: 405rpx;
+    border-radius: 20rpx;
+}
+
+.answer {
+    position: relative;
+    display: flex;
+    justify-content: space-evenly;
+    margin:-8rpx 20rpx 0 20rpx;
+    border-radius: 10rpx;
+    
+}
+
+.unfold {
+    background: #fff;
+}
+
+.analysis {
+
+}
+
+.analysis .analysis-img {
+    width: 103rpx;
+    height: 60rpx;
+}
+
+.analysis .analysis-img-top {
+    position: absolute;
+    bottom: 0;
+    left: 50%;
+    transform: translate(-50%, 0);
+    width: 99rpx;
+    height: 22rpx;
+}

+ 12 - 1
pages/science/science.js

@@ -19,7 +19,8 @@ Page({
     previewHeight: '',
     productionMore: '',
     questionsMore: '',
-    wxObjectives: []
+    wxObjectives: [],
+    canvasHeight: ''
   },
   /* 区分答疑和分享 */
   distinction: function(type, columnId, pageNo, pageSize, success) {
@@ -48,6 +49,16 @@ Page({
       })
     });
   },
+
+  /*点击获取canvas高度*/
+  onGetHeight: function (e) {
+    const canvasHeight = this.selectComponent("#chat").data.canvasHeight;
+    console.log(canvasHeight)
+    this.setData({
+      canvasHeight,
+    })
+  },
+
   /*点击查看更多*/
   onMyEvent: function(e){
     let type = e.currentTarget.dataset.type;

+ 7 - 1
pages/science/science.wxml

@@ -18,11 +18,13 @@
             height="{{previewHeight}}"/>
 
             <chat id="upload"
+                id="chat"
                 productionData="{{productionData}}" 
                 title="作品展示"
                 query="上传作品"
                 type="2"
                 columnType="5"
+                bind:getHeight="onGetHeight"
                 bind:myevent="onMyEvent"
                 data-type="2"
                 more="{{productionMore}}"/>
@@ -45,7 +47,11 @@
 
             <view class="upload-one" data-id="upload" bindtap="location">
                 <image src="../image/works.png" ></image>
-            </view>  
+            </view>
+
+            <view class="canvas-box">
+                <canvas canvas-id="myCanvas" style="width:100%; height: {{canvasHeight}}px;"></canvas>
+            </view> 
           </view>
       </scroll-view>
   </view>

+ 8 - 0
pages/science/science.wxss

@@ -306,4 +306,12 @@
     background: #F73861;
     font-size: 24rpx;
     border-radius: 50%;
+}
+
+.canvas-box {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    z-index: -2;
 }

+ 10 - 0
utils/APIClient.js

@@ -62,5 +62,15 @@ module.exports = {
 	cancelDian(header, data) {
 		let url = genAPIUrl('wx/posts/readCount');
 		return request.getInstance().url(url).header(header).data(data).method('GET').send();
+	},
+	//获取错题本
+	getErrorsSchedule(header, data) {
+		let url = genAPIUrl('wx/question/wrong');
+		return request.getInstance().url(url).header(header).data(data).method('GET').send();
+	},
+	//获取用户答题指数
+	getExponentSchedule(header) {
+		let url = genAPIUrl('wx/question/exponent');
+		return request.getInstance().url(url).header(header).method('GET').send();
 	}
 }

+ 2 - 2
utils/const.js

@@ -6,7 +6,7 @@ module.exports = {
 	// apiUrl: 'https://weixin.ai160.com/',
 	// host: 'wss://weixin.ai160.com/wx/websocket'
 	// ----测试环境-----
-  // apiUrl: 'https://weixin.efunbox.cn/',
-  apiUrl: 'https://schedule.api.ai160.com/'
+  apiUrl: 'https://weixin.efunbox.cn/',
+  // apiUrl: 'https://schedule.api.ai160.com/'
 
 }

+ 48 - 30
utils/loginSchedule.js

@@ -42,7 +42,7 @@ function getOpenidSessionKey(successcallback, failcallback) {
   }
     wxLogin(function(res) {
         //console.log('获取sessionKey等内容'+JSON.stringify(res.data));
-        let sessionKey = res.data.session_key;
+        let sessionKey = JSON.parse(res.data).session_key;
         //登录
         getLoginSchedule(sessionKey, successcallback, failcallback);
     },function(res) {
@@ -52,36 +52,54 @@ function getOpenidSessionKey(successcallback, failcallback) {
 
 //登录
 function getLoginSchedule(sessionKey, successcallback, failcallback) {
-    //获取个人信息
-    wx.getUserInfo({
-        success: function (res) {
-            let userInfo = res.userInfo
-            let url = genAPIUrl('wx/ucenter/user/loginRegist');
-            const userData = {
-                encryptedData: res.encryptedData,
-                sessionKey: sessionKey,
-                iv: res.iv,
-                dist: '1133',
-                headimgurl: userInfo.avatarUrl
-            }          
-            request.getInstance().url(url).data(userData).method('GET').send().success(res => {
-                wx.hideToast()
-                wx.showToast({
-                    title: '登录成功',
-                    icon: 'success',
-                    duration: 1500
-                })
-                wx.setStorageSync('uid', res.data.data.uid)
-                wx.setStorageSync('user', res)
-                successcallback(res)
-            });
-        },
-        fail: function(res) {
-            failcallback(res)
+    wx.getSetting({
+        success: function(res) {
+          if (res.authSetting['scope.userInfo']) {
+            // 已经授权,可以直接调用 getUserInfo 获取头像昵称
+            wx.getUserInfo({
+                success: function (res) {
+                    let userInfo = res.userInfo
+                    let url = genAPIUrl('wx/ucenter/user/loginRegist');
+                    const userData = {
+                        encryptedData: res.encryptedData,
+                        sessionKey: sessionKey,
+                        iv: res.iv,
+                        dist: '1133',
+                        headimgurl: userInfo.avatarUrl
+                    }          
+                    request.getInstance().url(url).data(userData).method('GET').send().success(res => {
+                        wx.hideToast()
+                        wx.showToast({
+                            title: '登录成功',
+                            icon: 'success',
+                            duration: 1500
+                        })
+                        wx.setStorageSync('uid', res.data.data.uid)
+                        wx.setStorageSync('user', res)
+                        successcallback(res)
+                    });
+                },
+                fail: function(res) {
+                    failcallback(res)
+                }
+            })
+          } else {
+            //没有授权提示用户进行授权
+            wx.showModal({
+                title: '提示',
+                content: '需要获取您的公开信息(昵称、头像等),请从点击授权按钮,允许授权后可正常使用',
+                showCancel: false,
+                success: function (res) {
+                  if (res.confirm) {
+                    console.log('用户点击确定')
+                  } else if (res.cancel) {
+                    console.log('用户点击取消')
+                  }
+                }
+            })
+          }  
         }
-    })
-
-    //
+      })
     
 }