Forráskód Böngészése

Merge branch 'main' of http://git.wdklian.com/allen/uni_mattress

dayu 2 éve
szülő
commit
08581ab861

+ 1 - 1
sleep/pages/home/index.vue

@@ -270,7 +270,7 @@
           <form>
             <view class="cu-form-group solid-bottom">
               <view class="title">扫描二维码</view>
-              <input type="text" v-model="bindSn" class="text-left"/>
+              <input type="text" v-model="bindSn" placeholder="输入或扫描IMEI" class="text-left"/>
               <text class="cuIcon-scan text-xxl text-green" style="font-size: 50rpx;"
                     @click="scan"></text>
             </view>

+ 133 - 30
sleep/pages/my/index.vue

@@ -9,37 +9,26 @@
     <view class="flex-col justify-start page">
       <view class="flex-col group_2 space-y-10">
 
-        <view class="flex-col justify-start items-start my_device_header">
-
+        <view v-if="memberId" class="flex-col justify-start items-start my_device_header">
           <view class="flex-col section pos">
-
             <view class="flex-col my_device_profile">
-              <view @click="handleAuth" class="flex-row space-x-19">
-                <image v-if="userInfo.face" class="shrink-0 image_5" :src="userInfo.face"/>
-                <image v-else class="shrink-0 image_5" src="../../static/mine/myAvatar.png"/>
+              <view class="flex-row space-x-19">
+                <image v-if="userInfo.face" class="shrink-0 image_5" :src="userInfo.face" @click="handleUpdateFace"/>
+                <image v-else class="shrink-0 image_5" src="../../static/mine/myAvatar.png" @click="handleUpdateFace"/>
                 <view class="flex-col flex-auto self-center space-y-14">
                   <view class="flex-row space-x-8">
                     <text class="text_2">{{ userInfo.nickname }}</text>
                     <view class="flex-row shrink-0 section_3 space-x-4">
-                      <image
-                          class="shrink-0 image_7"
-                          src="../../static/mine/myIconEdit.png"
-                      />
-                      <text class="font_2">编辑</text>
+                      <image class="shrink-0 image_7" src="../../static/mine/myIconEdit.png"/>
+                      <text class="font_2" @click="handleUpdateName">编辑</text>
                     </view>
                   </view>
                   <view class="flex-row items-center space-x-6">
-                    <image
-                        class="image_8"
-                        src="../../static/mine/myIconPhone.png"
-                    />
+                    <image class="image_8" src="../../static/mine/myIconPhone.png"/>
                     <text class="font_3 text_3">{{ userInfo.mobile }}</text>
                   </view>
                 </view>
-                <image
-                    class="shrink-0 self-start image_6"
-                    src="../../static/mine/myIconAlert.png"
-                />
+                <image class="shrink-0 self-start image_6" src="../../static/mine/myIconAlert.png"/>
               </view>
               <view class="flex-row justify-between relative group_4">
                 <view class="flex-col justify-start items-center self-center text-wrapper">
@@ -56,9 +45,25 @@
             <!--				</view>-->
 
           </view>
+        </view>
 
+        <view v-else class="flex-col justify-start items-start my_device_header">
+          <view class="flex-col section pos">
+            <view class="flex-col my_device_profile">
+              <view @click="handleAuth" class="flex-row space-x-19">
+                <image class="shrink-0 image_5" src="../../static/mine/myAvatar.png"/>
+                <view class="flex-col flex-auto self-center space-y-14">
+                  <view class="flex-row space-x-8">
+                    <text class="text_2">未登录用户</text>
+                  </view>
+                </view>
+                <image class="shrink-0 self-start image_6" src="../../static/mine/myIconAlert.png"/>
+              </view>
+            </view>
+          </view>
         </view>
 
+
         <view class="flex-col group_5 space-y-30">
           <view class="flex-col space-y-10 my_devices">
 
@@ -254,7 +259,7 @@
           <form>
             <view class="cu-form-group solid-bottom">
               <view class="title">扫描二维码</view>
-              <input type="text" v-model="bindSn" class="text-left"/>
+              <input type="text" v-model="bindSn" class="text-left" placeholder="输入或扫描IMEI"/>
               <text class="cuIcon-scan text-xxl text-green" style="font-size: 50rpx;"
                     @click="scan"></text>
             </view>
@@ -268,6 +273,30 @@
       </view>
     </view>
 
+    <view class="cu-modal" :class="updateShow?'show':''">
+      <view class="cu-dialog">
+        <view class="cu-bar bg-white justify-end">
+          <view style="color: black" class="content">编辑昵称</view>
+          <view class="action" @tap="updateShow=false">
+            <text class="cuIcon-close text-red"></text>
+          </view>
+        </view>
+        <view class="">
+          <form>
+            <view class="cu-form-group solid-bottom">
+              <view class="title">昵称</view>
+              <input type="text" v-model="nickname" class="text-left" placeholder="请输入昵称"/>
+            </view>
+          </form>
+        </view>
+        <view class="cu-bar bg-white justify-end">
+          <view class="action">
+            <button class="cu-btn bg-green margin-left" @tap="updateNickName">确定</button>
+          </view>
+        </view>
+      </view>
+    </view>
+
   </view>
 </template>
 
@@ -286,7 +315,9 @@ export default {
       memberId: '',
       bindSn: '',
       bindShow: false,
-      userInfo: null
+      updateShow: false,
+      userInfo: null,
+      nickname: ''
     };
   },
   mounted() {
@@ -343,13 +374,9 @@ export default {
       })
     },
     handleAuth() {
-      if (!this.memberId) {
-        uni.navigateTo({
-          url: '/pages/auth/auth'
-        })
-      } else {
-        console.log('修改...')
-      }
+      uni.navigateTo({
+        url: '/pages/auth/auth'
+      })
     },
     handleShareData() {
       uni.navigateTo({
@@ -377,7 +404,7 @@ export default {
                 uni.showToast({
                   title: '请扫码正确的睡眠床垫二维码',
                   icon: 'none'
-                });
+                })
               }
             } else {
               _this.bindSn = res.result
@@ -497,8 +524,84 @@ export default {
         })
       }
     },
+    /** 头像发生改变 */
+    handleUpdateFace(event) {
+      let that = this
+      wx.showActionSheet({
+        itemList: ['从相册中选择', '拍照'],
+        itemColor: '#CED63A',
+        success(res) {
+          if (!res.cancel) {
+            if (res.tapIndex === 0) {
+              that.chooseWxImage('album')
+            } else if (res.tapIndex === 1) {
+              that.chooseWxImage('camera')
+            }
+          }
+        }
+      })
+    },
+    /** 选择头像 */
+    chooseWxImage(type) {
+      let that = this
+      wx.chooseImage({
+        count: 1,
+        sizeType: ['original', 'compressed'],
+        sourceType: [type],
+        success(res) {
+          const tempFilePaths = res.tempFilePaths
+          wx.uploadFile({
+            url: that.MixinUploadApi,
+            filePath: tempFilePaths[0],
+            name: 'file',
+            header: { uuid: Storage.getItem('uuid') },
+            success(response) {
+              const data = typeof response.data === 'string' ? JSON.parse(response.data) : response.data
+              that.userInfo.face = data.url
+              const params = {
+                face: data.url,
+                nickname: that.userInfo.nickname
+              }
+              that.API_updateUser(params)
+            }
+          })
+        }
+      })
+    },
+    API_updateUser(params) {
+      const _this = this
+      this.saveUserInfo(params).then(() => {
+        uni.showToast({
+          title: '修改成功',
+          icon: 'none'
+        })
+        this.$store.dispatch('getUserDataAction').then((res)=>{
+          _this.userInfo = res
+        })
+      })
+    },
+    handleUpdateName() {
+      this.nickname = this.userInfo.nickname
+      this.updateShow = true
+    },
+    updateNickName() {
+      if (this.nickname.nickname === '') {
+        uni.showToast({
+          title: '请输入昵称',
+          icon: 'none'
+        })
+        return
+      }
+      this.updateShow = false
+      const params = {
+        face: this.userInfo.face,
+        nickname: this.nickname
+      }
+      this.API_updateUser(params)
+    },
   ...mapActions({
-      logout: 'logoutAction'
+      logout: 'logoutAction',
+      saveUserInfo: 'saveUserInfoAction'
     })
   }
 };

+ 62 - 54
sleep/pages/report/report.vue

@@ -255,31 +255,31 @@
 					    </view>
 					  </view>
 					  <view class="flex-col pos_34">
-					      <view class="flex-col group_15">
-					        <view class="flex-row justify-between group_2">
-					          <text class="font_3 text_12">安稳度</text>
-					          <view class="flex-row items-center space-x-30">
-					            <text class="font_10">入睡时长</text>
-					            <view class="flex-row items-baseline shrink-0 space-x-6">
-					              <text class="font_5">{{ formateSeconds(sleepReportFrom.rs_duration) }}</text>
-					            </view>
-					          </view>
-					        </view>
-					      </view>
+<!--					      <view class="flex-col group_15">-->
+<!--					        <view class="flex-row justify-between group_2">-->
+<!--					          <text class="font_3 text_12">安稳度</text>-->
+<!--					          <view class="flex-row items-center space-x-30">-->
+<!--					            <text class="font_10">入睡时长</text>-->
+<!--					            <view class="flex-row items-baseline shrink-0 space-x-6">-->
+<!--					              <text class="font_5">{{ formateSeconds(sleepReportFrom.rs_duration) }}</text>-->
+<!--					            </view>-->
+<!--					          </view>-->
+<!--					        </view>-->
+<!--					      </view>-->
 					      <view class="list-divider"></view>
-						  
+
 						  <view class="flex-col group_15">
 						    <view class="flex-row justify-between group_2">
 						      <text class="font_3 text_12">离床次数</text>
 						      <view class="flex-row items-center space-x-30">
-						        
+
 						        <view class="flex-row items-baseline shrink-0 space-x-6">
 						          <text class="font_5">{{ sleepReportFrom.report_content.outbed_count.value }}</text>
 						          <text class="font_6">次</text>
 						        </view>
 						      </view>
 						    </view>
-							
+
 							<view class="report_breath_chart">
 								<view class="echarts-wrap">
 								  <mpvue-echarts class="ec-canvas" canvasId="canvasChart-1" ref="refChart-1" @onInit="onInit1"></mpvue-echarts>
@@ -287,19 +287,18 @@
 							</view>
 						  </view>
 						  <view class="list-divider"></view>
-						  
+
 						  <view class="flex-col group_15">
 						    <view class="flex-row justify-between group_2">
 						      <text class="font_3 text_12">体动次数</text>
 						      <view class="flex-row items-center space-x-30">
-						        <!-- <text class="font_10">平均呼吸率</text> -->
 						        <view class="flex-row items-baseline shrink-0 space-x-6">
 						          <text class="font_5">{{ sleepReportFrom.report_content.move_count.value }}</text>
 						          <text class="font_6">次</text>
 						        </view>
 						      </view>
 						    </view>
-							
+
 							<view class="report_breath_chart">
 								<view class="echarts-wrap">
 								  <mpvue-echarts class="ec-canvas" canvasId="canvasChart-2" ref="refChart-2" @onInit="onInit1"></mpvue-echarts>
@@ -315,7 +314,7 @@
 				  <view class="flex-col justify-start flex-auto group">
 				    <view class="flex-col justify-start group_3">
 				      <view class="flex-col group_8 space-y-10">
-						
+
 						<view class="flex-col justify-start report_breath">
 							<view class="flex-col justify-start">
 							  <view class="flex-row items-center group_11 space-x-10 pos_33">
@@ -330,13 +329,12 @@
 							    />
 							  </view>
 							</view>
-							
+
 							<view class="flex-col pos_34 report_heart">
 							    <view class="flex-col group_15">
 							      <view class="flex-row justify-between group_2">
-							        <text class="font_3 text_12">心率</text>
+							        <text class="font_3 text_12">平均心率</text>
 							        <view class="flex-row items-center space-x-30">
-							          <text class="font_10">平均心率</text>
 							          <view class="flex-row items-baseline shrink-0 space-x-6">
 							            <text class="font_5">{{ sleepReportFrom.report_content.avg_rh.value }}</text>
 							            <text class="font_6">次/分</text>
@@ -346,12 +344,12 @@
 							    </view>
 								<view class="report_breath_chart">
 									<view class="echarts-wrap">
-									  <mpvue-echarts class="ec-canvas" canvasId="canvasChart-1" ref="refChart-1" @onInit="onInit1"></mpvue-echarts>
+									  <mpvue-echarts class="ec-canvas" canvasId="canvasChart-3" ref="refChart-3" @onInit="onInit1"></mpvue-echarts>
 									</view>
 								</view>
 							</view>
 						</view>
-						
+
 
 				        <view class="flex-col justify-start report_breath">
 				          <view class="flex-col justify-start">
@@ -370,49 +368,59 @@
 				          <view class="flex-col pos_34">
 				              <view class="flex-col group_15">
 				                <view class="flex-row justify-between group_2">
-				                  <text class="font_3 text_12">呼吸率</text>
+				                  <text class="font_3 text_12">平均呼吸率</text>
 				                  <view class="flex-row items-center space-x-30">
-				                    <text class="font_10">平均呼吸率</text>
 				                    <view class="flex-row items-baseline shrink-0 space-x-6">
-				                      <text class="font_5">10</text>
+				                      <text class="font_5">{{ sleepReportFrom.report_content.avg_hx.value }}</text>
 				                      <text class="font_6">次/分</text>
 				                    </view>
 				                  </view>
 				                </view>
-								
-								<view class="report_breath_chart"></view>
+
+								        <view class="report_breath_chart">
+                          <view class="echarts-wrap">
+                            <mpvue-echarts class="ec-canvas" canvasId="canvasChart-4" ref="refChart-4" @onInit="onInit1"></mpvue-echarts>
+                          </view>
+                        </view>
 				              </view>
 				              <view class="list-divider"></view>
-							  
+
 							  <view class="flex-col group_15">
 							    <view class="flex-row justify-between group_2">
 							      <text class="font_3 text_12">打鼾</text>
 							      <view class="flex-row items-center space-x-30">
-							        
+
 							        <view class="flex-row items-baseline shrink-0 space-x-6">
-							          <text class="font_5">73</text>
+							          <text class="font_5">{{ sleepReportFrom.report_content.snoring_count.value }}</text>
 							          <text class="font_6">次</text>
 							        </view>
 							      </view>
 							    </view>
-								
-								<view class="report_breath_chart"></view>
+
+                  <view class="report_breath_chart">
+                    <view class="echarts-wrap">
+                      <mpvue-echarts class="ec-canvas" canvasId="canvasChart-5" ref="refChart-5" @onInit="onInit1"></mpvue-echarts>
+                    </view>
+                  </view>
 							  </view>
 							  <view class="list-divider"></view>
-							  
+
 							  <view class="flex-col group_15">
 							    <view class="flex-row justify-between group_2">
 							      <text class="font_3 text_12">呼吸暂停</text>
-							      <view class="flex-row items-center space-x-30">
-							        <!-- <text class="font_10">平均呼吸率</text> -->
-							        <view class="flex-row items-baseline shrink-0 space-x-6">
-							          <text class="font_5">10</text>
-							          <text class="font_6">次</text>
-							        </view>
-							      </view>
+<!--							      <view class="flex-row items-center space-x-30">-->
+<!--							        <view class="flex-row items-baseline shrink-0 space-x-6">-->
+<!--							          <text class="font_5">{{ sleepReportFrom.report_content.snoring_count.value }}</text>-->
+<!--							          <text class="font_6">次</text>-->
+<!--							        </view>-->
+<!--							      </view>-->
 							    </view>
-								
-								<view class="report_breath_chart"></view>
+
+                  <view class="report_breath_chart">
+                    <view class="echarts-wrap">
+                      <mpvue-echarts class="ec-canvas" canvasId="canvasChart-6" ref="refChart-6" @onInit="onInit1"></mpvue-echarts>
+                    </view>
+                  </view>
 							  </view>
 				          </view>
 				        </view>
@@ -481,7 +489,7 @@
           <form>
             <view class="cu-form-group solid-bottom">
               <view class="title">扫描二维码</view>
-              <input type="text" v-model="bindSn" class="text-left"/>
+              <input type="text" v-model="bindSn" placeholder="输入或扫描IMEI" class="text-left"/>
               <text class="cuIcon-scan text-xxl text-green" style="font-size: 50rpx;"
                     @click="scan"></text>
             </view>
@@ -683,9 +691,9 @@
           _this.nowChart("refChart-1", 1, data.report_content.dt_arr, data.report_content.outbed_arr)
           _this.nowChart("refChart-2", 2, data.report_content.dt_arr, data.report_content.move_arr)
           _this.nowChart("refChart-3", 3, data.report_content.dt_arr, data.report_content.rh_arr)
-          // _this.nowChart("refChart-4", 4, data.report_content.dt_arr, data.report_content.hx_arr)
-          // _this.nowChart("refChart-5", 0, data.report_content.dt_arr, data.report_content.snoring_arr)
-          // _this.nowChart("refChart-6", 6, data.report_content.dt_arr, data.report_content.hxstop_arr)
+          _this.nowChart("refChart-4", 4, data.report_content.dt_arr, data.report_content.hx_arr)
+          _this.nowChart("refChart-5", 0, data.report_content.dt_arr, data.report_content.snoring_arr)
+          _this.nowChart("refChart-6", 6, data.report_content.dt_arr, data.report_content.hxstop_arr)
         }, 800)
       },
       // 将分转化为时分
@@ -784,7 +792,7 @@
             show: false, // 是否显示分隔线
           },
           axisLine: {
-            show: false, // 是否显示坐标轴轴线
+            show: true, // 是否显示坐标轴轴线
             lineStyle:{
               color:'#FFFFFF',
               width:1, //x轴线的宽度
@@ -991,16 +999,16 @@
 			  opacity: 0.8;
 			  background-image: linear-gradient(180deg, #341a4b 0%, #167df2 100%);
 			  border-radius: 0.5rem;
-			  
+
 			  .report_breath_chart {
 				position: relative;
 				height: 7rem;
 			  }
 	          .pos_33 {
-	            
+
 	          }
 	          .pos_34 {
-	            
+
 	            .group_15 {
 	              padding: 1rem 0;
 				  .font_10 {
@@ -1377,7 +1385,7 @@
 	            top: 8.06rem;
 	          }
 	        }
-	        
+
 	        .space-x-6 {
 	          & > view:not(:first-child),
 	          & > text:not(:first-child),
@@ -1413,7 +1421,7 @@
 	            color: #a5b6ca;
 	          }
 	        }
-	        
+
 	        .space-x-4 {
 	          & > view:not(:first-child),
 	          & > text:not(:first-child),
@@ -1580,7 +1588,7 @@
 	          height: 1.41rem;
 	          border: solid 0.031rem #4a315e;
 	        }
-	        
+
 	        .group_11 {
 	          width: 8.25rem;
 	        }

+ 15 - 2
sleep/utils/vue-mixin.js

@@ -1,5 +1,6 @@
 import Vue from 'vue'
 import Storage from '@/utils/storage'
+import { API } from '@/utils/request'
 import * as API_Connect from '@/api/connect'
 import 'wx-promise-pro'
 import store from '@/store'
@@ -10,6 +11,8 @@ const mixin = {
 		return {
 			// 项目名称
 			projectName: 'UU睡眠',
+			// 图片上传API
+			MixinUploadApi: `${API.base}/uploaders`,
 			// 是否已经授权 默认false
 			hasAuth: false,
 
@@ -47,8 +50,18 @@ const mixin = {
 				Storage.setItem('haslogin', { uid: result.uid, loginType: 'auto' })
 				_this.disposeResult(result)
 			} else {
-				uni.reLaunch({
-					url:'/pages/auth/auth'
+				uni.showModal({
+					title: '提示',
+					content: "您还未登录,是否前往登录呢?",
+					confirmText: "确定",
+					showCancel: true,
+					success: function(res) {
+						if (res.confirm) {
+							uni.reLaunch({
+								url:'/pages/auth/auth'
+							})
+						}
+					}
 				})
 			}
 		},