فهرست منبع

展开高度过高

Limengbo 6 سال پیش
والد
کامیت
b4e2959b5e

+ 2 - 1
compontents/chat/chat.js

@@ -80,8 +80,9 @@ Component({
       console.log(e);
       //分享查询单条的时候会用到这个值
       const postId = e.currentTarget.dataset.postsid;
+      const imgUrl = e.currentTarget.dataset.imgurl;
       //分享组件弹窗调用里边方法,在底下会获取
-      this.share.showPopup(postId);
+      this.share.showPopup(postId, imgUrl);
 
     },
     //跳转详情页

+ 5 - 5
compontents/chat/chat.wxml

@@ -40,18 +40,18 @@
                 </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}}">
                 <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 +59,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>

+ 1 - 1
compontents/lesson_list/lessonList.js

@@ -31,7 +31,7 @@ Component({
   methods: {
     onTap (e) {
       let flage = e.target.dataset.flag;
-      const height = this.properties.lessonData.length * 70;
+      const height = this.properties.lessonData.length * 56;
       if(flage){
         this.util(flage, '280rpx');
         this.setData({

+ 3 - 3
compontents/lesson_list/lessonList.wxss

@@ -27,14 +27,13 @@
 }
 
 .lesson-name text:nth-child(1) {
-    height: 38rpx;
     font-size: 36rpx;
     font-weight: 600;
 }
 
 .lesson-name text:nth-child(2) {
     height: 30rpx;
-    margin-top: 10rpx;
+    margin-top: 6rpx;
     font-size: 28rpx;
     color: #bebebe;
 }
@@ -42,7 +41,7 @@
 /* 时间轴 */
 .timer-shaft {
     overflow: hidden;
-    margin: 0 0 30rpx 10rpx;
+    margin: 0 0 50rpx 10rpx;
     padding: 0 25rpx;
 }
 
@@ -63,6 +62,7 @@
     display: flex;
     justify-content: space-between;
     margin-left: 53rpx;
+    height:32rpx;
     font-size: 28rpx;
     color: #878787;
 }

+ 1 - 1
compontents/preview/preview.js

@@ -31,7 +31,7 @@ Component({
   methods: {
     onTap (e) {
       let flage = e.target.dataset.flag;
-      const height = this.properties.materialData.length * 70;
+      const height = this.properties.materialData.length * 56;
       if(flage){
         
         this.util(flage, '280rpx');

+ 3 - 2
compontents/preview/preview.wxml

@@ -11,9 +11,10 @@
     </view>
 
     <view class="material-con" animation="{{animationData}}" style="height: {{height}}rpx">
-        <view wx:if="{{ item.warePath && item.title}}" class="art-img" wx:for="{{materialData}}" wx:key="{{index}}">
+        <view class="art-img" wx:for="{{materialData}}" wx:key="{{index}}">
             <text>{{item.title}}</text>
-            <text data-warePath="{{item.warePath}}" bindtap="preview">点击预览</text>
+            <text wx:if="{{ item.warePath && item.title}}" data-warePath="{{item.warePath}}" bindtap="preview">点击预览</text>
+            <text wx:else>暂无资料</text>
         </view>
     </view>
     

+ 3 - 3
compontents/preview/preview.wxss

@@ -27,21 +27,20 @@
 }
 
 .lesson-name text:nth-child(1) {
-    height: 38rpx;
     font-size: 36rpx;
     font-weight: 600;
 }
 
 .lesson-name text:nth-child(2) {
     height: 30rpx;
-    margin-top: 10rpx;
+    margin-top: 6rpx;
     font-size: 28rpx;
     color: #bebebe;
 }
 
 /* 预览图片 */
 .material-con {
-    margin: 0 0 30rpx 10rpx;
+    margin: 0 0 50rpx 10rpx;
     padding: 0 25rpx;
     overflow: hidden;
 }
@@ -50,6 +49,7 @@
     display: flex;
     justify-content: space-between;
     margin-left: 53rpx;
+    height:32rpx;
     font-size: 28rpx;
     color: #303030;
     margin-top: 24rpx;

+ 66 - 2
compontents/share/share.js

@@ -14,6 +14,7 @@ Component({
   data: {
     flag: true,
     postId: '',
+    imgUrl: []
   },
 
   /**
@@ -27,12 +28,75 @@ Component({
       })
     },
     //展示分享框
-    showPopup (postId) {
+    showPopup (postId, imgUrl) {
       this.setData({
         flag: !this.data.flag,
-        postId
+        postId,
+        imgUrl
       })
     },
+    //保存图片 
+    saveImage (e) {
+      const imgUrl = this.data.imgUrl;
+      //先绘制图片
+      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')
+        //获取屏幕宽度
+        const windowWidth = wx.getSystemInfoSync().windowWidth;
+        ctx.fillRect(0, 0, windowWidth, 1.6 * windowWidth)
+
+        ctx.drawImage(imgPath, 30, 10, 300, 100);
+
+        ctx.setFontSize(18)
+        ctx.setFillStyle('black')
+        ctx.fillText('我画的图片', 50, 140)
+        ctx.draw();
+      }
+      //canvas生成图片
+      wx.canvasToTempFilePath({
+        x: 0,
+        y: 0,
+        width: wx.getSystemInfoSync().windowWidth,
+        height: 0.6 * wx.getSystemInfoSync().windowWidth,
+        destWidth: wx.getSystemInfoSync().windowWidth,
+        destHeight:0.6 * wx.getSystemInfoSync().windowWidth,
+        canvasId: 'myCanvas',
+        success: (res) => {
+            console.log('canvas'+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>

+ 82 - 51
pages/art/art.js

@@ -33,8 +33,7 @@ Page({
     previewHeight: '',
     productionMore: '',
     questionsMore: '',
-    wxObjectives: [],
-    shareImgSrc: ''
+    wxObjectives: []
   },
 
   /* 区分答疑和分享 */
@@ -206,58 +205,11 @@ Page({
   },
 
   onShow: function () {
-    //2. canvas绘制文字和图片
-    const ctx = wx.createCanvasContext('myCanvas');
-    var imgPath = '../image/bg_1.png'
-    ctx.setFillStyle('red')
-    ctx.fillRect(10, 10, 150, 75)
-
-    ctx.drawImage(imgPath, 30, 10, 60, 60);
-
-    ctx.setFontSize(12)
-    ctx.setFillStyle('#6F6F6F')
-    ctx.fillText('妖妖灵', 10, 10)
-    ctx.draw();
+    
   },
   keep: function () {
-    wx.canvasToTempFilePath({
-      x: 0,
-      y: 0,
-      width: 600,
-      height: 800,
-      destWidth: 600,
-      destHeight:800,
-      canvasId: 'myCanvas',
-      success: (res) => {
-          console.log('canvas'+res.tempFilePath);
-          this.setData({
-              shareImgSrc : res.tempFilePath
-          })
 
-      },
-      fail:function (res) {
-          console.log(res)
-      }
-    })
-
-    wx.saveImageToPhotosAlbum({
-      filePath:this.data.shareImgSrc,
-      success(res) {
-          wx.showModal({
-              title: '存图成功',
-              content: '图片成功保存到相册了,去发朋友圈',
-              showCancel:false,
-              confirmText:'好哒',
-              confirmColor:'#72B9C3',
-              success: function(res) {
-                  if (res.confirm) {
-                      console.log('用户点击确定');
-                  }
-                  //that.hideShareImg()
-              }
-          })
-      }
-    })
+    
   },
   /* 转发*/
   onShareAppMessage: function (ops) {
@@ -279,4 +231,83 @@ Page({
       }
     }
   },
+  /*授权后执行的事件*/
+  impower: function (e) {
+    console.log(e)
+    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
+            })
+          }
+        }
+      }
+    });
+    /* 答疑 */
+    this.distinction(1, columnId, 1, 2, res => {
+      if(res.data.success) {
+        console.log(res.data.data)
+        this.setData({
+          questionsData: res.data.data
+        })
+        if(res.data.data) {
+          this.setData({
+            questionsdian: util.replyNo(res.data.data.list)
+          })  
+          if(res.data.data.totalSize > 2) {
+            this.setData({
+              questionsMore: true
+            })
+          }
+        }
+      }
+    });
+    /*科目信息*/
+    login.getOpenidSessionKey((res) => {
+      APIClient.getEachSchedule({
+        uid: res.data.data.uid
+      }, {
+        "category": 6
+      }).success((res) => {
+        const lessonListLength = res.data.data.lessonPage.list.length;
+        const previewLength = util.preview(res.data.data.lessonPage.list).length;
+        if(lessonListLength > 4) {
+          this.setData({
+            lessonListHeight: 280
+          })
+        }
+        if(previewLength > 4){
+          this.setData({
+            previewHeight: 280
+          })
+        } 
+        this.setData({
+          courseData: res.data.data,
+          list: util.studyPageTime(res.data.data.lessonPage.list),
+          wxObjectives: util.strategy(res.data.data.weekCourseConfig.wxObjectives)
+        })
+      })
+    }, function() {
+      wx.showModal({
+        title: '提示',
+        content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
+        showCancel: false,
+        success: function (res) {
+          if (res.confirm) {
+            console.log('用户点击确定')
+          } else if (res.cancel) {
+            console.log('用户点击取消')
+          }
+        }
+      })
+    });
+  }
 })

+ 1 - 2
pages/art/art.wxml

@@ -45,11 +45,10 @@
             <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%;"></canvas>
             </view>
-            <view bindtap="keep">保存</view>
+            <button open-type="getUserInfo" bindgetuserinfo="impower">授权登录</button>
           </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;
 }

+ 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('用户点击取消')
+                  }
+                }
+            })
+          }  
         }
-    })
-
-    //
+      })
     
 }
 

+ 19 - 18
utils/util.js

@@ -23,26 +23,27 @@ const gradeUpper = grade => {
 //将秒转化为 X/XX 比如四小时三十六分 为4/36
 const day = msd => {
   //不到一分钟的情况;
-  let time = Math.floor(msd);//整数秒  
-  time = "0/00";
+  let time = Math.floor(msd) + '秒';//整数秒  
+  //time = "0/00";
   //超过一分钟的情况
-  if( Math.floor(msd )> 60){ 
+  if( Math.floor(msd) > 60){ 
       let min = Math.floor(msd / 60); 
-      let hour = Math.floor(min / 60);
-      let minShow = min % 60;
-      time = hour + "/" + minShow ;  
-      // if( min > 60 ){  
-  //         min = Math.floor(msd / 60) % 60;  
-  //         let hour = Math.floor( msd / 3600 );  
-  //         // time = hour + "小时" + min + "分";
-  //         time = hour + "时";  
-  //         if( hour > 24 ){  
-  //             hour = Math.floor( msd / 3600 ) % 24;  
-  //             let day = Math.floor(msd / 3600 / 24);
-  //             // time = day + "天" + hour + "小时";
-  //             time = day + "天";  
-  //         }  
-      // }    
+      time = min + "分";
+      // let hour = Math.floor(min / 60);
+      // let minShow = min % 60;
+      // time = hour + "/" + minShow ;  
+      if( min > 60 ){  
+          min = Math.floor(msd / 60) % 60;  
+          let hour = Math.floor( msd / 3600 );  
+          time = hour + "小时" + min + "分";
+          // time = hour + "时";  
+          if( hour > 24 ){  
+              hour = Math.floor( msd / 3600 ) % 24;  
+              let day = Math.floor(msd / 3600 / 24);
+              time = day + "天" + hour + "小时";
+              // time = day + "天";  
+          }  
+      }    
   }   
 
   return time;