Browse Source

继续优化界面

wenningning 2 years ago
parent
commit
13e6706336

+ 3 - 4
sleep/api/doctor_advert.js

@@ -5,11 +5,10 @@ import request, { Method } from '@/utils/request'
  * @param params
  * @returns {Promise<any>}
  */
-export function getDoctorAdvertList(params) {
+export function listByGroupId(params) {
   return request({
-    // url: 'care/care_device_member_bind/pageList', // 先写死
-    url: 'care/health_advert/pageList',
-    config: {method: Method.POST, needToken: false, loading: true},
+    url: 'care/health_advert/listByGroupId',
+    config: {method: Method.GET, needToken: false, loading: true},
     params
   })
 }

+ 10 - 1
sleep/pages.json

@@ -67,13 +67,22 @@
                 "navigationBarTitleText": "",
                 "enablePullDownRefresh": false
             }
-        },{
+        },
+		{
 			"path" : "pages/healthAdvert/careHealthAdvertLook",
 			"style" :
 			{
 				"navigationBarTitleText": "内容详情",
 				"enablePullDownRefresh": false
 			}
+		},
+		{
+			"path" : "pages/healthAdvert/webview",
+			"style" :
+			{
+				"navigationBarTitleText": "内容详情",
+				"enablePullDownRefresh": false
+			}
 		}
     ],
 	"globalStyle": {

+ 25 - 0
sleep/pages/healthAdvert/webview.vue

@@ -0,0 +1,25 @@
+<template>
+    <view>
+        <web-view :src="url"></web-view>
+<!--        <txv-video vid="v0030fsz382" playerid="v0030fsz382"></txv-video>-->
+    </view>
+</template>
+
+<script>
+
+    export default {
+        data() {
+            return {
+                url: null
+                // url: 'https://mp.weixin.qq.com/s?__biz=Mzg4OTEzOTU0OQ==&mid=100000517&idx=1&sn=a56ef96193cb46d171f312bf4fa59986&scene=19#wechat_redirect',
+            }
+        },
+        onLoad(e) {
+            this.url = e.url
+        },
+    }
+</script>
+
+<style scoped>
+
+</style>

+ 128 - 34
sleep/pages/home/index.vue

@@ -121,9 +121,9 @@
 							</view>
 						</view>
 
-						<view class="flex-row items-center section_5 space-x-4">
+						<view class="flex-row items-center section_5 space-x-4" @click="modalName = true">
 							<image class="shrink-0 image_8"	src="../../static/home/homeIconChange.png"/>
-							<text class="font_3" @click="modalName = 'RadioModal'">切换</text>
+							<text class="font_3">切换</text>
 						</view>
 					</view>
 
@@ -184,7 +184,7 @@
 		    <text class="self-start font_6 text_16">次/分</text>
 		  </view>
 		  <view class="flex-col flex-auto justify-start shrink-0 relative home-data-chart content">
-			<view class="echarts-wrap">
+			<view class="echarts-wrap" :hidden="modalName">
 			  <mpvue-echarts class="ec-canvas" canvasId="canvasChart-1" ref="xinlvRefChart" @onInit="onInit1"></mpvue-echarts>
 			</view>
 		  </view>
@@ -203,7 +203,7 @@
 		    <text class="self-start font_6 text_16">次/分</text>
 		  </view>
 		  <view class="flex-col flex-auto justify-start shrink-0 relative home-data-chart content">
-			<view class="echarts-wrap">
+			<view class="echarts-wrap" :hidden="modalName">
 			  <mpvue-echarts class="ec-canvas" canvasId="canvasChart-2" ref="huxiRefChart" @onInit="onInit2"></mpvue-echarts>
 			</view>
 		  </view>
@@ -284,16 +284,16 @@
       </view>
     </view>
 
-    <view class="cu-modal" :class="modalName=='RadioModal'?'show':''" @tap="hideModal">
-      <view class="cu-dialog" @tap.stop="">
-        <view class="cu-bar bg-white justify-end">
-          <view style="color: black" class="content">设备切换</view>
+    <view style="z-index: 9999999" class="cu-modal" :class="modalName ?'show':''" @tap="hideModal">
+      <view style="background-image: linear-gradient(45deg, #4d9efa, #156fce);z-index: 9999999" class="cu-dialog" @tap.stop="">
+        <view class="cu-bar justify-end">
+          <view class="content">设备切换</view>
         </view>
         <radio-group class="block" @change="RadioChange">
           <view class="cu-list menu text-left">
-            <view class="cu-item" v-for="(item, index) in deviceList" :key="index">
+            <view style="background-image: linear-gradient(45deg, #4d9efa, #156fce)" class="cu-item" v-for="(item, index) in deviceList" :key="index">
               <label class="flex justify-between align-center flex-sub">
-                <view class="flex-sub">{{ item.imei }}</view>
+                <view class="flex-sub text-white">{{ item.imei }}</view>
                 <radio class="round" :class="homeFrom.nowDevice===item.imei?'checked':''" :checked="homeFrom.nowDevice === item.imei"
                        :value="item.imei"></radio>
               </label>
@@ -356,7 +356,8 @@ export default {
       memberId: '',
       bindSn: '',
       bindShow: false,
-      modalName: false
+      modalName: false,
+      activeBreak: false
 		};
 	},
   // onLoad() {
@@ -375,6 +376,14 @@ export default {
           this.memberId = memberId
           console.log('this.memberId===', this.memberId)
           this.API_getDeviceList()
+          const _this = this
+          setTimeout(() => {
+            console.log('_this.connected====', _this.connected)
+            if (!_this.connected) {
+              console.log('我要登录过...')
+              _this.API_getDeviceList()
+            }
+          }, 1500)
         } else {
           this.checkHasLogin()
           const _this = this
@@ -392,8 +401,17 @@ export default {
 
   },
   beforeDestroy() {
+    this.activeBreak = true
     this.closeWebsocket()
   },
+  watch: {
+    connected() {
+      if (!this.activeBreak && !this.connected) {
+        console.log('监听到webSocket连接断开,现在开始连接')
+        this.init()
+      }
+    }
+  },
   // onShow() {
   //   const imei = Storage.getItem('nowChangeDevice')
   //   if (imei) {
@@ -406,12 +424,14 @@ export default {
       this.homeFrom.nowDevice = imei
       this.deviceAdded = true
       if (!this.connected && this.memberId) {
-        this.init()
+        console.log('重新连接...')
+        this.connect()
       }
     } else {
       this.deviceAdded = false
     }
   },
+
 	methods: {
 		handleShareClick() {
 			uni.navigateTo({
@@ -421,17 +441,21 @@ export default {
     API_getDeviceList() {
       const _this = this
       API_deviceMemberBind.getDeviceByDtypeAndMemberId({dtype: '睡眠床垫', memberId: this.memberId}).then(res => {
-        if (res.length === 0) {
-          _this.deviceAdded = false
-        } else {
-          _this.deviceAdded = true
-          _this.deviceList = res
-          _this.homeFrom.nowDevice = res[0].imei
-          Storage.setItem("nowChangeDevice", _this.homeFrom.nowDevice)
-          Storage.setItem("myBindDevices", res)
-          if (!this.connected) {
-            _this.init()
+        if (res) {
+          if (res.length === 0) {
+            _this.deviceAdded = false
+          } else {
+            _this.deviceAdded = true
+            _this.deviceList = res
+            _this.homeFrom.nowDevice = res[0].imei
+            Storage.setItem("nowChangeDevice", _this.homeFrom.nowDevice)
+            Storage.setItem("myBindDevices", res)
+            if (!this.connected) {
+              _this.init()
+            }
           }
+        } else {
+          console.log('获取床垫错误...')
         }
       })
     },
@@ -476,23 +500,25 @@ export default {
         this.connecting = false
         this.connected = false
         uni.hideLoading()
-        uni.showModal({
-          content: '连接失败,可能是websocket服务不可用,请稍后再试',
-          showCancel: false
-        })
+        console.log('连接失败,可能是websocket服务不可用,请稍后再试!')
+        // uni.showModal({
+        //   content: '连接失败,可能是websocket服务不可用,请稍后再试',
+        //   showCancel: false
+        // })
         console.log('onError', err)
       })
       this.mySocketTask.onMessage(res => {
         let msg = res.data
         // console.log('收到消息:', msg)
-        if (msg.length === 30) {
+        if (msg.length === 234) {
           if (this.homeFrom.nowDevice !== msg.substring(2, 14)) {
             return
           }
           this.homeFrom.status = '在线'
           this.lastMsgTime = Date.parse(new Date())
-          this.getValue1(parseInt(msg.substring(22, 24), 16))
-          this.getValue2(parseInt(msg.substring(24, 26), 16))
+          this.getValue(msg)
+          // this.getValue1(parseInt(msg.substring(22, 24), 16))
+          // this.getValue2(parseInt(msg.substring(24, 26), 16))
           switch (msg.substring(26, 28)) {
             case "03":
               this.sleepStatus = '在床'
@@ -520,6 +546,7 @@ export default {
         }
       })
       this.mySocketTask.onClose(res => {
+        console.log('webSocket关闭了...')
         this.connected = false
         this.msg = false
         clearInterval(this.timer)
@@ -580,6 +607,7 @@ export default {
           axisPointer: {
             animation: false,
           },
+          extraCssText: 'z-index: 2'
         },
         grid: {
           top: '15%',
@@ -597,11 +625,27 @@ export default {
         yAxis: {
           type: 'value',
           boundaryGap: [0, '100%'],
-          min: 0,
-          max: xMax,
+          min: function (value) {
+            if (value === 0) {
+              return 0
+            } else {
+              return value.min - 20
+            }
+          },
+          max: function (value) {
+            return value.max + 20
+          },
+          // min: 0,
+          // min: 'dataMin', // 取数据在该轴上的最大值作为最小刻度
+          // max: xMax,
           // max: 'dataMax', // 取数据在该轴上的最大值作为最大刻度
           splitLine: {
-            show: false, // 是否显示分隔线
+            show: true, // 是否显示分隔线
+            lineStyle: {
+              color: "rgba(168,162,162,0.6)",
+              width: 1,
+              type: 'dotted'
+            }
           },
           axisLine: {
             show: false, // 是否显示坐标轴轴线
@@ -628,6 +672,56 @@ export default {
         ]
       }
     },
+    getValue(msg) {
+		  this.pjxl = parseInt(msg.substring(22, 24), 16)
+      this.pjhx = parseInt(msg.substring(24, 26), 16)
+      const bx = msg.substring(34, msg.length);
+      const size = bx.length / 4
+      const ii = size / 2;
+      if (this.myData1.length > 100) {
+        this.myData1.splice(0, ii)
+      }
+      if (this.myData2.length > 100) {
+        this.myData2.splice(0, ii)
+      }
+      if (this.myCount1 > 300) {
+        this.myCount1 = 0
+      }
+      if (this.myCount2 > 300) {
+        this.myCount2 = 0
+      }
+      for (let i = 0; i < size; i++) {
+        // bx.substring(i * 4, i * 4 + 4)
+        const j = i * 4
+        // console.log(bx.substring(j, j + 2), bx.substring(j + 2, j + 4))
+        const s1 = bx.substring(j, j + 2)
+        const s2 = bx.substring(j + 2, j + 4)
+        let value =  parseInt(s2 + s1 , 16)
+        // if (parseInt(s1, 16) > parseInt(s2, 16)) {
+        //   value = parseInt(s2 + s1, 16)
+        // } else {
+        //   value = parseInt(s1 + s2, 16)
+        // }
+        // if (value === 2) {
+        //   console.log(s1, s2)
+        //   if (parseInt(s1, 16) > parseInt(s2, 16)) {
+        //     console.log('111111111===', parseInt(s1, 16), parseInt(s2, 16), s2 + '' + s1, parseInt(s2 + '' + s1, 16))
+        //   } else {
+        //     console.log('2222222222=====', parseInt(s1, 16), parseInt(s2, 16), s1 + s2, parseInt(s1 + '' + s2, 16))
+        //   }
+        // }
+        // console.log('value=====', value)
+        if (i % 2 === 0) {
+          this.myCount1 ++
+          this.myData1.push([this.myCount1, value])
+        } else {
+          this.myCount2 ++
+          this.myData2.push([this.myCount2, value])
+        }
+      }
+      this.myChart1.setOption(this.options1)
+      this.myChart2.setOption(this.options2)
+    },
     getValue1(value) {
       // console.log("心率是", value)
       this.pjxl = value
@@ -662,7 +756,7 @@ export default {
           this.myData2.push([this.myCount2, value])
         }
       } else {
-        value = parseInt((Math.random(10) * 300 + 100))
+        value = parseInt((Math.random(10) * 200 + 100))
         for (let i = 0; i < 5; i++) {
           this.myCount2 ++;
           value += parseInt(Math.random() * 10 - 5)
@@ -805,7 +899,7 @@ export default {
       }
     },
     hideModal(e) {
-      this.modalName = null
+      this.modalName = false
     },
     RadioChange(e) {
 		  console.log('1111111==', e.detail.value)

+ 5 - 7
sleep/pages/index/index.vue

@@ -67,6 +67,7 @@
 // import musicList from './components/musicList.vue';
 // import { getImage, getName } from '@/utils/index.js';
 import * as API_doctorAdvert from '@/api/doctor_advert'
+import {getDoctorAdvertList} from "../../api/doctor_advert";
 export default {
   // components: {
   //   songList,
@@ -90,13 +91,10 @@ export default {
     // 获取健康宣讲
     getCareHealthAdvert() {
       const data = {
-        pageNo: 1,
-        pageSize: 10,
-        shopId: 486, // 先写死
-        title: ''
+        groupId: 12
       }
-      API_doctorAdvert.getDoctorAdvertList(data).then(res => {
-        this.healthAdvertList = res.data
+      API_doctorAdvert.listByGroupId(data).then(res => {
+        this.healthAdvertList = res
       })
     },
     // 去往健康宣讲详情页
@@ -108,7 +106,7 @@ export default {
         })
       } else {
         uni.navigateTo({
-          url: '/pages/care/part/webview?url=' + url
+          url: '/pages/healthAdvert/webview?url=' + url
         })
       }
 

+ 6 - 6
sleep/pages/login/index.vue

@@ -3,21 +3,21 @@
 		<image src="http://wdklmall.oss-cn-shenzhen.aliyuncs.com/mallgoods/goods/C34A0AB308944EF9A3BB4135827924DF.png" class="background-img"></image>
 		<view class="absolve-wrapper">
 			<!-- <view class="logo"><image src="../../static/logo.png" class="logo-img"></image></view> -->
-			
+
 			<view class="flex-col items-center group_3 space-y-20">
 			  <text class="text_2 text_3">UU睡眠</text>
 			  <text class="font_1 text_2">AI时代,全家人的睡眠健康顾问</text>
 			</view>
-			
+
 			<view class="login-main">
 				<view class="input-wrapper">
 					<i class="iconfont icon-phone icon"></i>
-					<input placeholder="请输入账户名或手机号" v-model="userFrom.username" />
+					<input placeholder="请输入账户名或手机号" class="text-white" v-model="userFrom.username" />
 				</view>
 				<view class="input-wrapper">
 					<i class="iconfont icon-password icon"></i>
-					<input v-if="isText" type="text" placeholder="请输入密码" v-model="userFrom.password" />
-					<input v-else type="password" placeholder="请输入密码" v-model="userFrom.password" />
+					<input v-if="isText" type="text" class="text-white" placeholder="请输入密码" v-model="userFrom.password" />
+					<input v-else type="password" class="text-white" placeholder="请输入密码" v-model="userFrom.password" />
 					<i class="iconfont eye" :class="isText ? 'icon-openEye' : 'icon-closeEye'" @click="isText = !isText"></i>
 				</view>
 				<button style="background: linear-gradient(90deg, rgba(44, 37, 247, 0.6) 0%, rgba(6, 21, 153, 1) 100%);" class="cu-btn round login-button lg cu-load" :class="{ loading: loading }" @click="getUserInfo">登录</button>
@@ -202,7 +202,7 @@ export default {
 	  color: #ffffff;
 	  margin-top: 4rem;
 	}
-}	
+}
 .login-container {
 	width: 100%;
 	height: 100vh;

+ 10 - 2
sleep/pages/report/report.vue

@@ -113,7 +113,7 @@
 
 						<view class="flex-row equal-division space-x-29 pos">
 							<view class="flex-col equal-division-item">
-								<view class="flex-col section_6 space-y-12 bg-gradual-blue">
+								<view class="flex-col section_6 space-y-12">
 									<view class="flex-row space-x-10">
 										<image class="image_7" src="../../static/report/reportIconGreen.png"/>
 										<text class="font_3">上床时间</text>
@@ -466,7 +466,7 @@
 
 		</view>
 		<!-- <tab-bar currentPage="report" /> -->
-    <view class="cu-modal bottom-modal" :class="calendarShow === true?'show':''">
+    <view class="cu-modal bottom-modal" :class="calendarShow === true?'show':''" @tap="hideModal">
       <view class="cu-dialog">
         <uni-calendar
             @change="change"
@@ -635,6 +635,11 @@
             this.params.reportTime = -1
             this.calendarShow = false
             this.getNewSleepReport()
+          } else {
+            uni.showToast({
+              title: e.fulldate + '无睡眠报告',
+              icon: 'none'
+            })
           }
         }
         // this.selected[0].date = e.fulldate
@@ -935,6 +940,9 @@
             }
           })
         }
+      },
+      hideModal(e) {
+        this.calendarShow = null
       }
     }
 	}

+ 35 - 1
sleep/utils/vue-mixin.js

@@ -48,7 +48,41 @@ const mixin = {
 			if (result.autologin === 'yes') {
 				_this.hasAuth = true
 				Storage.setItem('haslogin', { uid: result.uid, loginType: 'auto' })
-				_this.disposeResult(result)
+				const {
+					access_token,
+					refresh_token,
+					access_token_timeout,
+					refresh_token_timeout,
+					uid,
+					no_union_id
+				} = result
+				// 如果登录成功 存储token(access_token refresh_token) uid 获取用户数据
+				if (access_token && refresh_token && uid) {
+					const now=Math.round(new Date()/1000)
+					store.dispatch('setAccessTokenAction', access_token)
+					store.dispatch('setRefreshTokenAction', refresh_token)
+					Storage.setItem('uid', uid)
+					Storage.setItem('access_token_timeout',now+access_token_timeout-60)
+					Storage.setItem('refresh_token_timeout',now+refresh_token_timeout-60)
+					Storage.setItem('haslogin', { uid: result.uid, loginType: 'auto' })
+					// this.autoBindPart()
+					store.dispatch('getUserDataAction').then(()=>{
+						let page = Storage.getItem('goPage')
+						console.log('mixin-goPage===', page);
+						uni.switchTab({
+							url: '/pages/home/index'
+						})
+					})
+				} else if (no_union_id) {
+					Storage.setItem('haslogin', { loginType: 'hand_movement' })
+					uni.reLaunch({
+						url:'/pages/auth/auth'
+					})
+				} else {
+					uni.reLaunch({
+						url:'/pages/login/index'
+					})
+				}
 			} else {
 				uni.showModal({
 					title: '提示',