Browse Source

修复头像问题

bayi 2 years ago
parent
commit
dfff248a56

+ 0 - 6
components/uploadFile/index.js

@@ -52,12 +52,6 @@ Component({
           uid: wx.getStorageSync('uid')
         },
         success: (res) => {
-          // const formateRes = JSON.parse(res.data);
-          // let audioPath = formateRes.data;
-          // this.setReadDetail({
-          //   audioPath,
-          //   ...this.data.readDetail
-          // })
           this.setData({
             uploadSuccess: true,
           })

+ 133 - 118
pages/editUser/index.js

@@ -1,135 +1,150 @@
 import {
-    createStoreBindings
+  createStoreBindings
 } from 'mobx-miniprogram-bindings'
 import {
-    store
+  store
 } from '~/store/index'
 import {
-    setUserInfo
+  setUserInfo
 } from '~/api/user'
 let storeBindings
 Page({
-    data: {
-        gradeIndex: 0,
-        gradeArray: [{
-                value: 'PRESCHOOL',
-                key: '学前班'
-            }, {
-                value: 'PRIMARY_FIRST_GRADE',
-                key: '一年级'
-            },
-            {
-                value: 'PRIMARY_SECOND_GRADE',
-                key: '二年级'
-            },
-            {
-                value: 'PRIMARY_THREE_GRADE',
-                key: '三年级'
-            },
-            {
-                value: 'PRIMARY_SENIOR_GRADE',
-                key: '四年级'
-            },
-        ],
-    },
-    onLoad(options) {
-        // 手工绑定 
-        this.storeBindings = createStoreBindings(this, {
-            store,
-            fields: {
-                userInfo: 'userInfo'
-            },
-            actions: {
-                setUser: 'setUser'
-            }
-        })
-        // 立刻更新
-        this.storeBindings.updateStoreBindings()
-        let {
-            grade
-        } = this.data.userInfo
-        let gradeIndex = this.data.gradeArray.findIndex(item => {
-            return item.value == grade
-        })
+  data: {
+    gradeIndex: 0,
+    gradeArray: [{
+        value: 'PRESCHOOL',
+        key: '学前班'
+      }, {
+        value: 'PRIMARY_FIRST_GRADE',
+        key: '一年级'
+      },
+      {
+        value: 'PRIMARY_SECOND_GRADE',
+        key: '二年级'
+      },
+      {
+        value: 'PRIMARY_THREE_GRADE',
+        key: '三年级'
+      },
+      {
+        value: 'PRIMARY_SENIOR_GRADE',
+        key: '四年级'
+      },
+    ],
+  },
+  onLoad(options) {
+    // 手工绑定 
+    this.storeBindings = createStoreBindings(this, {
+      store,
+      fields: {
+        userInfo: 'userInfo'
+      },
+      actions: {
+        setUser: 'setUser'
+      }
+    })
+    // 立刻更新
+    this.storeBindings.updateStoreBindings()
+    let {
+      grade
+    } = this.data.userInfo
+    let gradeIndex = this.data.gradeArray.findIndex(item => {
+      return item.value == grade
+    })
+    this.setData({
+      gradeIndex
+    })
+  },
+  // 调用清理函数
+  onUnload() {
+    this.storeBindings.destroyStoreBindings()
+  },
+  changeAvatar(e) {
+    const {
+      avatarUrl
+    } = e.detail
+    wx.uploadFile({
+      url: 'https://reader-api.ai160.com/file/upload',
+      filePath: avatarUrl,
+      name: '头像',
+      header: {
+        uid: wx.getStorageSync('uid')
+      },
+      success: (res) => {
+        const newAvatar = JSON.parse(res.data).data;
+        const str = 'userInfo.avatar'
         this.setData({
-            gradeIndex
+          [str]: newAvatar
         })
-    },
-    // 调用清理函数
-    onUnload() {
-        this.storeBindings.destroyStoreBindings()
-    },
-    onChooseAvatar(e) {
-        const {
-            avatarUrl
-        } = e.detail
         this.setUserInfo({
-            avatar: avatarUrl
+          avatar: newAvatar
         })
-    },
-    saveNickName(e) {
-        let nickName = e.detail.value;
-        if (nickName == this.data.userInfo.nickName) {
-            return
+      }
+    })
+  },
+  saveNickName(e) {
+    let nickName = e.detail.value;
+    if (nickName == this.data.userInfo.nickName) {
+      return
+    }
+    this.setUserInfo({
+      nickName
+    })
+  },
+  selectProfession() {
+    wx.showActionSheet({
+      itemList: ['学生', '家长', '老师'],
+      success: (res) => {
+        /*   if (res.tapIndex == this.data.userInfo.gender) {
+              return
+          }
+          this.setUserInfo({
+              gender: res.tapIndex
+          }) */
+      },
+    })
+  },
+  selectGender() {
+    wx.showActionSheet({
+      itemList: ['女', '男'],
+      success: (res) => {
+        if (res.tapIndex == this.data.userInfo.gender) {
+          return
         }
         this.setUserInfo({
-            nickName
-        })
-    },
-    selectProfession() {
-        wx.showActionSheet({
-            itemList: ['学生', '家长','老师'],
-            success: (res) => {
-                /*   if (res.tapIndex == this.data.userInfo.gender) {
-                      return
-                  }
-                  this.setUserInfo({
-                      gender: res.tapIndex
-                  }) */
-            },
-        })
-    },
-    selectGender() {
-        wx.showActionSheet({
-            itemList: ['女', '男'],
-            success: (res) => {
-                if (res.tapIndex == this.data.userInfo.gender) {
-                    return
-                }
-                this.setUserInfo({
-                    gender: res.tapIndex
-                })
-            },
-        })
-    },
-    bindDateChange(e) {
-        this.setUserInfo({
-            birthday: e.detail.value
-        })
-    },
-    bindGradeChange(e) {
-        let grade = this.data.gradeArray[e.detail.value].value
-        this.setUserInfo({
-            grade
-        })
-    },
-    saveSchool(e) {
-        let schoolName = e.detail.value;
-        if (schoolName == this.data.userInfo.schoolName) {
-            return
-        }
-        this.setUserInfo({
-            schoolName
-        })
-    },
-    async setUserInfo(data) {
-        wx.showLoading({
-            title: '提交中',
-        })
-        let res = await setUserInfo(data, 'put').finally(() => {
-            wx.hideLoading()
+          gender: res.tapIndex
         })
-        this.setUser(res)
-    },
+      },
+    })
+  },
+  bindDateChange(e) {
+    this.setUserInfo({
+      birthday: e.detail.value
+    })
+  },
+  bindGradeChange(e) {
+    let grade = this.data.gradeArray[e.detail.value].value
+    this.setUserInfo({
+      grade
+    })
+  },
+  saveSchool(e) {
+    let schoolName = e.detail.value;
+    if (schoolName == this.data.userInfo.schoolName) {
+      return
+    }
+    this.setUserInfo({
+      schoolName
+    })
+  },
+  async setUserInfo(data) {
+    wx.showLoading({
+      title: '提交中',
+    })
+    let res = await setUserInfo(data, 'put').finally(() => {
+      wx.hideLoading()
+    })
+    this.setUser(res)
+  },
 
 })

+ 1 - 1
pages/editUser/index.wxml

@@ -1,6 +1,6 @@
 <wxs src="../../utils/filter.wxs" module="filters" />
 <view class="editBox">
-    <button class="resetBtn editRow" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
+    <button class="resetBtn editRow" open-type="chooseAvatar" bind:chooseavatar="changeAvatar">
         <view class="name">头像</view>
         <view class="right">
             <image class='avatar' src='{{ userInfo.avatar}}'></image>

+ 19 - 9
pages/reading/index.js

@@ -91,15 +91,7 @@ Page({
       }
     })
     if (!options.reset) {
-      var query = wx.createSelectorQuery();
-      query.select('.content').boundingClientRect((rect) => {
-        this.setData({
-          contentH: rect.height
-        })
-      }).exec()
-      query.select('.row').boundingClientRect((rect) => {
-        this.rowH = rect.height
-      }).exec()
+      this.getHeight()
     }
     this.videoContext = wx.createVideoContext('myVideo')
     // 录音授权
@@ -135,6 +127,12 @@ Page({
   },
   // 开始录制
   setCountDown() {
+    if (this.data.readingReset) {
+      this.setData({
+        readingReset: false
+      })
+      this.getHeight()
+    }
     if (this.data.state) {
       this.finishRecord()
       return
@@ -314,6 +312,18 @@ Page({
     clearTimeout(this.setTimeoutObj)
     clearInterval(this.stl)
   },
+  // 获取设备高度与行高度
+  getHeight() {
+    var query = wx.createSelectorQuery();
+    query.select('.content').boundingClientRect((rect) => {
+      this.setData({
+        contentH: rect.height
+      })
+    }).exec()
+    query.select('.row').boundingClientRect((rect) => {
+      this.rowH = rect.height
+    }).exec()
+  },
   onShareAppMessage() {
 
   }

+ 133 - 0
pages/reading/index.less

@@ -141,4 +141,137 @@
       }
     }
   }
+}
+
+.xxx {
+  flex: 1;
+  width: 100%;
+  overflow: auto;
+  position: relative;
+  padding-bottom: calc(170rpx + env(safe-area-inset-bottom));
+
+  .scoreBox {
+    width: 610rpx;
+    margin: 80rpx auto 0rpx;
+
+    .lightBox {
+      position: relative;
+      height: 180rpx;
+
+      .light {
+        position: absolute;
+        width: 360rpx;
+        height: 180rpx;
+        left: 0px;
+        right: 0px;
+        margin: auto;
+      }
+
+      .stars {
+        position: absolute;
+        width: 62rpx;
+        height: 62rpx;
+      }
+
+      .stars-1 {
+        top: 64rpx;
+        left: 132rpx;
+      }
+
+      .stars-2 {
+        top: 25rpx;
+        left: 198rpx;
+      }
+
+      .stars-3 {
+        top: 6rpx;
+        left: 276rpx;
+      }
+
+      .stars-4 {
+        top: 25rpx;
+        right: 198rpx;
+      }
+
+      .stars-5 {
+        top: 62rpx;
+        right: 132rpx;
+      }
+    }
+
+    .score {
+      position: relative;
+      width: 100%;
+      box-sizing: border-box;
+      padding: 70rpx 40rpx 32rpx;
+      border-radius: 18rpx;
+      background-color: white;
+      box-shadow: rgba(255, 255, 255, 0.15) 0px 6px 12px -2px, rgba(255, 255, 255, 0.1) 0px 3px 7px -3px;
+
+      .avatarBox {
+        position: absolute;
+        top: -72rpx;
+        left: 0px;
+        right: 0px;
+        margin: 0 auto;
+        width: 100rpx;
+        height: 100rpx;
+        padding: 16rpx;
+        border-radius: 50%;
+        background-color: white;
+        font-size: 0px;
+
+        .avatar {
+          width: 100%;
+          height: 100%;
+          border-radius: 50%;
+        }
+      }
+
+      .nickName {
+        font-size: 36rpx;
+        text-align: center;
+      }
+
+      .totalScore {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        margin-top: 26rpx;
+        font-size: 42rpx;
+
+        .num {
+          color: #58C5FF;
+          font-size: 42rpx;
+        }
+      }
+
+      .progressBox {
+        margin-top: 50rpx;
+
+        .row {
+          display: flex;
+          align-items: center;
+          justify-content: space-between;
+          margin-bottom: 42rpx;
+
+          .name {
+            font-size: 32rpx;
+            width: 96rpx;
+          }
+
+          .progress {
+            width: 306rpx;
+            border-radius: 20rpx;
+            overflow: hidden;
+          }
+
+          .scoreInfo {
+            font-size: 27rpx;
+            color: #666666;
+          }
+        }
+      }
+    }
+  }
 }

+ 60 - 4
pages/reading/index.wxml

@@ -1,7 +1,7 @@
 <view class="readingBox">
-  <image src="{{videoInfo.userRead.coverImg}}" class='poster' wx:if="{{!state}}" />
-  <video id="myVideo" src="{{videoInfo.userRead.originVideo}}" bindended='videoEnd' controls="{{false}}"
-    show-center-play-btn="{{false}}" poster="{{videoInfoCopy.userRead.coverImg}}"></video>
+  <image src="{{videoInfo.userRead.coverImg}}" class='poster' wx:if="{{!state&&!readingReset}}" />
+  <video id="myVideo" src="{{videoInfo.userRead.originVideo}}" bindended='videoEnd' controls="{{readingReset}}"
+    show-center-play-btn="{{readingReset}}"></video>
   <view class="contentBox" wx:if="{{!readingReset}}">
     <view class="articleMask"></view>
     <scroll-view class="content" scroll-y enhanced show-scrollbar="{{false}}" scroll-top="{{scrollTop}}"
@@ -12,10 +12,66 @@
       <view style="height: {{contentH}}rpx;"></view>
     </scroll-view>
   </view>
+  <view class="xxx" wx:elif="{{readingReset}}">
+    <view class="scoreBox">
+      <!-- 星星区域 -->
+      <view class="lightBox">
+        <image src="/static/{{readDetail.myOverall>=10?'stars-1.png':'stars-2.png'}}" class="stars stars-1" mode="" />
+        <image src="/static/{{readDetail.myOverall>=30?'stars-1.png':'stars-2.png'}}" class="stars stars-2" mode="" />
+        <image src="/static/{{readDetail.myOverall>=50?'stars-1.png':'stars-2.png'}}" class="stars stars-3" mode="" />
+        <image src="/static/{{readDetail.myOverall>=70?'stars-1.png':'stars-2.png'}}" class="stars stars-4" mode="" />
+        <image src="/static/{{readDetail.myOverall>=90?'stars-1.png':'stars-2.png'}}" class="stars stars-5" mode="" />
+        <image src="/static/light.png" class="light" mode="" />
+      </view>
+      <!-- 主体得分区域 -->
+      <view class="score">
+        <view class="avatarBox">
+          <image src="{{userInfo.avatar}}" class="avatar" mode="" />
+        </view>
+        <view class="nickName">
+          {{userInfo.nickName||userInfo.eid}}
+        </view>
+        <view class="totalScore">
+          <text>综合得分:</text>
+          <text class="num">{{readDetail.myOverall}}</text>
+        </view>
+        <view class="progressBox">
+          <view class="row">
+            <view class="name">完整度</view>
+            <progress class="progress" active percent='{{readDetail.integrity}}' stroke-width="18" activeColor="#70D9FF" />
+            <view class="scoreInfo">
+              {{readDetail.integrity}}/100
+            </view>
+          </view>
+          <view class="row">
+            <view class="name">正确率</view>
+            <progress class="progress" active percent='{{readDetail.accuracy}}' stroke-width="18" activeColor="#918EFD" />
+            <view class="scoreInfo">
+              {{readDetail.accuracy}}/100
+            </view>
+          </view>
+          <view class="row">
+            <view class="name">流利度</view>
+            <progress class="progress" active percent='{{readDetail.fluency}}' stroke-width="18" activeColor="#FE9500" />
+            <view class="scoreInfo">
+              {{readDetail.fluency}}/100
+            </view>
+          </view>
+          <view class="row">
+            <view class="name">语调</view>
+            <progress class="progress" active percent='{{readDetail.tone}}' stroke-width="18" activeColor="#9BE74B " />
+            <view class="scoreInfo">
+              {{readDetail.tone}}/100
+            </view>
+          </view>
+        </view>
+      </view>
+    </view>
+  </view>
   <view class="controller">
     <image src="{{state?'/static/readingNow.gif':'/static/work.png'}}" class="playImg" bindtap="setCountDown" />
     <view class="text">{{state?'完成录制':readingReset?'点击重录':'开始挑战'}}</view>
-    <uploadFile wx:if="{{readingReset}}" class="btnPosition"/>
+    <uploadFile wx:if="{{readingReset}}" class="btnPosition" />
   </view>
   <view class="playImgBg"></view>
   <!-- 倒计时 -->

+ 112 - 0
pages/reading/index.wxss

@@ -124,3 +124,115 @@
   font-size: 124rpx;
   margin-bottom: 6rpx;
 }
+.xxx {
+  flex: 1;
+  width: 100%;
+  overflow: auto;
+  position: relative;
+  padding-bottom: calc(170rpx + env(safe-area-inset-bottom));
+}
+.xxx .scoreBox {
+  width: 610rpx;
+  margin: 80rpx auto 0rpx;
+}
+.xxx .scoreBox .lightBox {
+  position: relative;
+  height: 180rpx;
+}
+.xxx .scoreBox .lightBox .light {
+  position: absolute;
+  width: 360rpx;
+  height: 180rpx;
+  left: 0px;
+  right: 0px;
+  margin: auto;
+}
+.xxx .scoreBox .lightBox .stars {
+  position: absolute;
+  width: 62rpx;
+  height: 62rpx;
+}
+.xxx .scoreBox .lightBox .stars-1 {
+  top: 64rpx;
+  left: 132rpx;
+}
+.xxx .scoreBox .lightBox .stars-2 {
+  top: 25rpx;
+  left: 198rpx;
+}
+.xxx .scoreBox .lightBox .stars-3 {
+  top: 6rpx;
+  left: 276rpx;
+}
+.xxx .scoreBox .lightBox .stars-4 {
+  top: 25rpx;
+  right: 198rpx;
+}
+.xxx .scoreBox .lightBox .stars-5 {
+  top: 62rpx;
+  right: 132rpx;
+}
+.xxx .scoreBox .score {
+  position: relative;
+  width: 100%;
+  box-sizing: border-box;
+  padding: 70rpx 40rpx 32rpx;
+  border-radius: 18rpx;
+  background-color: white;
+  box-shadow: rgba(255, 255, 255, 0.15) 0px 6px 12px -2px, rgba(255, 255, 255, 0.1) 0px 3px 7px -3px;
+}
+.xxx .scoreBox .score .avatarBox {
+  position: absolute;
+  top: -72rpx;
+  left: 0px;
+  right: 0px;
+  margin: 0 auto;
+  width: 100rpx;
+  height: 100rpx;
+  padding: 16rpx;
+  border-radius: 50%;
+  background-color: white;
+  font-size: 0px;
+}
+.xxx .scoreBox .score .avatarBox .avatar {
+  width: 100%;
+  height: 100%;
+  border-radius: 50%;
+}
+.xxx .scoreBox .score .nickName {
+  font-size: 36rpx;
+  text-align: center;
+}
+.xxx .scoreBox .score .totalScore {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  margin-top: 26rpx;
+  font-size: 42rpx;
+}
+.xxx .scoreBox .score .totalScore .num {
+  color: #58C5FF;
+  font-size: 42rpx;
+}
+.xxx .scoreBox .score .progressBox {
+  margin-top: 50rpx;
+}
+.xxx .scoreBox .score .progressBox .row {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  margin-bottom: 42rpx;
+}
+.xxx .scoreBox .score .progressBox .row .name {
+  font-size: 32rpx;
+  width: 96rpx;
+}
+.xxx .scoreBox .score .progressBox .row .progress {
+  width: 306rpx;
+  border-radius: 20rpx;
+  overflow: hidden;
+}
+.xxx .scoreBox .score .progressBox .row .scoreInfo {
+  font-size: 27rpx;
+  color: #666666;
+}

+ 1 - 1
project.private.config.json

@@ -12,7 +12,7 @@
         {
           "name": "",
           "pathName": "pages/reading/index",
-          "query": "videoId=10312700101&",
+          "query": "videoId=10312700101&reset=true",
           "launchMode": "default",
           "scene": null
         },