examTeamApp/pages/body/body.vue

792 lines
18 KiB
Vue

<template>
<view class="content">
<!-- tabbar -->
<view class="tabbar">
<view @click="active=1" :class="[active==1?'active':'']">报告</view>
<view @click="active=2" :class="[active==2?'active':'']">曲线</view>
</view>
<!--报告 -->
<view v-if="active==1" class="report">
<view class="box" v-if="info&&info.top_list.length">
<view class="time">{{info?info.record_time:''}}</view>
<view class="item2">
<view class="item2_data" v-for="(item,index) in info.top_list" @click="handleToggleTop(item)">
<view class="data ">
<view class="c666 mb-5">{{item.name}}</view>
<view><text>{{item.value}}</text>{{item.unit}}</view>
</view>
</view>
<view class="myinfoPage" v-if="infoListTop">
<view class="desc">
<view v-if="infoListTop.desc" class="ming">{{infoListTop.desc}}</view>
<view :class="[infoListTop.list.length?'statuevue':'']" v-if="infoListTop.list">
<view class="bi">
<view :style="'left:'+infoListTop.offset+'%'" class="peobox">
<view class="xx"></view>
</view>
<view class="item" v-for="(ite , ind) in infoListTop.list" :key="ind"
:style="{backgroundColor:ite.color}">
<view class="span1">{{ite.text}}</view>
<view class="span" v-if="ind<infoListTop.list.length-1">{{ite.max_val}}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="nolist" v-if="!info">
<image src="@/static/none.png"></image>
<text>暂无数据,请手动添加~</text>
</view>
<!-- -->
<view class="box2" v-if="info">
<view>身体得分:{{info?info.score_value:0}}分</view>
<view>身体类型:{{info?info.body_type_value:'无'}}</view>
</view>
<!-- -->
<view class="info">
<view class="item" @click="handlerRecord">
<text class="t-icon-jilu1 t-icon"></text>
<view>手动记录</view>
</view>
<view class="item" @click="handleisSdevice()">
<text class="t-icon-wulianjie t-icon"></text>
<view>连接设备</view>
</view>
</view>
<!-- -->
<view class="bold mt-10" v-if="info&&info.bottom_list">其他数据</view>
<view class="myinfoPage" v-if="info&&info.bottom_list">
<view class="box1">
<uni-collapse accordion>
<uni-collapse-item class="list" v-for="(item,index) in info.bottom_list" :key="index">
<template v-slot:title>
<uni-list-item class="block">
<view class="name">
<icon class="t-icon iconfont" :class="'t-icon-'+item.key_name"></icon>
{{item.name}}
</view>
<view class="val" v-if="item.title=='肥胖等级'||item.title=='体型'"> - </view>
<view class="val" v-else>{{item.value?item.value:'0'}}{{item.unit}}</view>
<view class="level">
<view class="btnf"
:style="{backgroundColor:(item.standard=='异常'?'#FFF':item.color)}"
:class="[item.standard=='异常'?'btnC':'']">
{{item.standard=='异常'?'-':item.standard}}
</view>
</view>
</uni-list-item>
</template>
<view class="desc">
<view v-if="item.desc" class="ming">{{item.desc}}</view>
<view :class="[item.list.length?'statuevue':'']" v-if="item.list">
<view class="bi" v-if="item.title!='基础代谢'">
<view :style="'left:'+item.offset+'%'" class="peobox">
<view class="xx"></view>
</view>
<view class="item" v-for="(ite , ind) in item.list" :key="ind"
:style="{backgroundColor:ite.color}">
<view class="span1">{{ite.text}}</view>
<view class="span" v-if="ind<item.list.length-1">{{ite.max_val}}</view>
</view>
</view>
<view v-else>
<view class="kcalClass" v-if="item.list&&item.list.length">
标准值:{{item.list[0].max_val}}kcal
</view>
</view>
</view>
</view>
</uni-collapse-item>
</uni-collapse>
</view>
<view class="tips c999 ml-15">
<uni-icons type="info-filled" color="red"></uni-icons>
此测量数据仅供参考,不可代替医学专业测试!
</view>
</view>
<!-- 手动记录 -->
<record :rtype="acd_id"></record>
</view>
<!-- 曲线 -->
<view v-if="active==2" class="charts">
<view class="TrendPage">
<!-- 时间选择 -->
<view class="boxTime">
<view class="one">
<!-- <uni-datetime-picker type="date" :end="startDate" :clear-icon="false"
:value="startTime?startTime:startDate" @change="handStartTimeH" :border="false" /> -->
<picker mode="date" :end="endDate" @change="handStartTimeH" fields="time"
:value="startTime?startTime:startDate">
<view class="uni-input">{{startTime?startTime:startDate}}</view>
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker>
<view class="center">~</view>
<!-- <uni-datetime-picker type="date" :end="endDate" :clear-icon="false"
:value="endTime?endTime:endDate" @change="handEndTimeH" :border="false" /> -->
<picker mode="date" :end="endDate" @change="handEndTimeH" fields="time"
:value="endTime?endTime:endDate">
<view class="uni-input">{{endTime?endTime:endDate}}</view>
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker>
</view>
</view>
<!-- 曲线图 -->
<view class="box" v-if="weightList.length">
<view class="listC">
<view :class="{active2:index==active1}" class="name" v-for="(item,index) in weightList"
:key="index" @click="showbox(index)">
{{item.title}}
</view>
</view>
<view class="blockC">
<view v-if="handTrue">
<qiunDataCharts type="area" :chartData="lineData" :canvas2d="true" canvasId="charts09"
:cHeight="480" :cWidth="680" :animation="false"
:opts="{enableScroll:true,xAxis:{scrollShow:false,itemCount:3}}" :ontouch="true" />
</view>
</view>
</view>
<view class="box" v-else>
<view class="nolist">
<image src="@/static/none.png"></image>
<text>暂无数据,请手动添加~</text>
</view>
</view>
</view>
<!-- 目标-->
<view class="gridList">
<view class="info">
<view class="item" @click="navTo('/pages/history/history?acd_id='+ acd_id)">
<text class="t-icon-lishi t-icon"></text>
<view>历史记录</view>
</view>
<view class="item" @click="navTo('/pages/compk/contrast?acd_id='+ acd_id)">
<text class="t-icon-renshiduibifenxi t-icon"></text>
<view>数据对比</view>
</view>
</view>
<view class="data">
<view class="item" @click="handleClick(1)">
<view class="val">
{{userInfo.target_current?userInfo.target_current.target_weight:0}}<text>kg</text>
</view>
<view class="name">目标体重<uni-icons class="iconfont icon-bianji" color="#FEC407"></uni-icons>
</view>
</view>
<view class="item">
<view class="val">
{{userInfo.target_current?Math.abs(userInfo.target_current.cumulative_weight):0}}<text>kg</text>
</view>
<view class="name" v-if="Number(userInfo.target_current.cumulative_weight)>0">累计增重</view>
<view class="name" v-else>累计减重</view>
</view>
<view class="item" @click="handleClick(2)">
<view class="val">
{{userInfo.target_current?userInfo.target_current.initial_weight:0}}<text>kg</text>
</view>
<view class="name">初始体重<uni-icons class="iconfont icon-bianji" color="#FEC407"></uni-icons>
</view>
</view>
<view class="item">
<view class="val">
{{userInfo.target_current?userInfo.target_current.cumulative_day:0}}<text>天</text>
</view>
<view class="name">减重天数</view>
</view>
</view>
</view>
<!-- 初始 -->
<firstweight :type="ind"></firstweight>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
import record from '@/components/manuallyAdd/record.vue';
import firstweight from '@/components/target/firstweight.vue';
import qiunDataCharts from '@/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue';
export default {
data() {
return {
active: 1,
acd_id: 2,
isdevice: false,
infoList: [],
infoListTop: {},
ind: 0,
active1: 0,
startTime: "",
endTime: "",
lineData: {},
handTrue: true,
}
},
computed: {
...mapState(['user', "MeasureResult", "Trend"]),
weightList() {
let that = this
that.showbox(0)
return that.Trend
},
userInfo() {
return this.user
},
info() {
let that = this
that.infoListTop = that.MeasureResult ? that.MeasureResult.top_list[0] : {}
return that.MeasureResult
},
endDate() {
return this.$tools.getDate("start")
},
startDate() {
return this.$tools.GetDateStr(-90);
},
},
components: {
record,
firstweight,
qiunDataCharts,
},
onLoad(options) {
let that = this
that.acd_id = options.acd_id
that.isdevice = options.device
that.$store.dispatch("getResult", {
aud_id: uni.getStorageSync('userid')
})
that.$store.dispatch("GetBodyTrendList", {
aud_id: uni.getStorageSync('userid'),
s_time: that.startDate,
e_time: that.endDate
})
console.log("11111", options)
},
methods: {
handleisSdevice() {
let that = this
console.log("isDevice", that.isdevice)
if (that.isdevice == 'true' || that.isdevice) {
uni.openBluetoothAdapter({
success: e => {
that.$store.commit("changeBluetooth", true);
uni.navigateTo({
url: "/pages/devices/search?id=" + that.acd_id
})
console.log('初始化蓝牙成功:' + e.errMsg);
},
fail: err => {
console.log('初始化蓝牙失败:' + err.errMsg);
return that.$Bluetooth.getBluetoothAdapter(err)
}
});
} else {
that.$tools.msg("请先添加设备!")
setTimeout(function() {
uni.switchTab({
url: "/pages/business/business"
})
}, 500)
}
},
// 历史数据删除时重新加载接口
reload() {
let that = this
console.log('重新加载');
this.$nextTick(() => {
that.$store.dispatch("getResult", {
aud_id: uni.getStorageSync('userid')
})
that.$store.dispatch("GetBodyTrendList", {
aud_id: uni.getStorageSync('userid'),
s_time: that.startDate,
e_time: that.endDate
})
})
},
showbox(index) {
let that = this
that.handTrue = false
that.$nextTick(function() {
that.handTrue = true
that.lineData = that.weightList.length ? that.weightList[index].line : {}
})
that.active1 = index
},
//开始
handStartTimeH(e) {
let that = this
if (that.endTime) {
if (Date.parse(e.detail.value) > Date.parse(that.endTime)) {
that.$tools.msg("请选择正确的时间")
return
}
} else {
if (Date.parse(e.detail.value) > Date.parse(that.endDate)) {
that.$tools.msg("请选择正确的时间")
return
}
}
that.startTime = e.detail.value
let endtime = that.endTime ? that.endTime : that.endDate
that.$store.dispatch("GetBodyTrendList", {
aud_id: that.user.id,
s_time: that.startTime,
e_time: that.endTime ? that.endTime : that.endDate
})
that.showbox(0)
},
// 结束
handEndTimeH(e) {
let that = this
if (that.startTime) {
if (Date.parse(e.detail.value) < Date.parse(that.startTime)) {
that.$tools.msg("请选择正确的时间")
return
}
} else {
if (Date.parse(e.detail.value) < Date.parse(that.startDate)) {
that.$tools.msg("请选择正确的时间")
return
}
}
that.endTime = e.detail.value
let startTime = that.startTime ? that.startTime : that.startDate
that.$store.dispatch("GetBodyTrendList", {
aud_id: uni.getStorageSync('userid'),
s_time: startTime,
e_time: that.endTime
})
that.showbox(0)
},
handleClick(ind) {
this.ind = ind
this.$store.commit("changeFirst", true);
},
// 报告
handlerRecord() {
this.$store.commit('changeRecord', true)
},
handleToggleTop(item) {
this.infoListTop = item
},
navTo(url) {
uni.navigateTo({
url: url
})
},
}
}
</script>
<style scoped lang="scss">
.content {
padding: 15px;
font-size: 14px;
background-color: #F5F6FA;
min-height: 100vh;
}
.tabbar {
width: 100%;
padding: 15px;
display: flex;
align-items: center;
justify-content: space-around;
view {
position: relative;
}
.active:after {
content: "";
height: 3px;
width: 100%;
position: absolute;
bottom: -5px;
left: 0;
border-radius: 5px;
background: $maincolor;
}
}
// 曲线
.charts {
.boxTime {
display: flex;
justify-content: center;
align-items: center;
background-color: #fff;
border-radius: 10px 10px 0 0;
.one {
width: 80%;
display: flex;
line-height: 25px;
justify-content: space-between;
align-items: center;
}
.center{
margin: 0 15px;
}
picker {
width:100%;
border: none;
text-align: center;
position: relative;
}
.iconfont {
color: #333333;
font-size: 16px;
position: absolute;
right: 0px;
top: 0;
}
}
.box {
width: 100%;
padding: 0;
margin: 0;
display: flex;
flex-wrap: wrap;
border-radius: 0 0 10px 10px;
justify-content: space-between;
.listC {
background-color: #fff;
.name {
width: 20%;
padding: 0 15px;
font-size: 14px;
text-align: center;
border-radius: 5px;
height: 30px;
line-height: 30px;
}
.active2 {
color: #fff;
background: $maincolor;
}
}
.blockC {
clear: both;
width: 100%;
height: 250px;
background-color: #fff;
border-radius: 0 0 10px 10px;
padding-bottom: 15px;
}
}
.gridList {
margin: 0px !important;
width: 100% !important;
.data {
.item {
display: block !important
}
}
}
}
// 报告
.report {
.box {
padding: 10px;
background-color: #fff;
border-radius: 10px;
margin-bottom: 10px;
.time {
color: #999;
padding-bottom: 15px;
width: 100%;
}
.item2 {
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.item2_data {
width: 33%;
.data {
width: 100%;
text-align: center;
border-right: 1PX solid #f7f7f7;
}
text {
font-size: 20px !important;
font-weight: bold;
}
}
}
}
.box2 {
height: 50px;
line-height: 50px;
border-radius: 10px;
display: flex;
padding: 0 10px;
justify-content: space-between;
margin-bottom: 10px;
background-color: #fff;
}
.info {
width: 100%;
display: flex;
justify-content: space-between;
.item {
color: #fff;
width: 45%;
height: 50px;
background: $maincolor;
text-align: center;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
text {
width: 30px;
height: 30px;
border-radius: 50%;
margin-right: 10px;
display: inline-block;
background-color: #fff;
}
}
}
.myinfoPage {
width: 100%;
background: #fff;
margin-top: 10px;
padding-bottom: 15px;
border-radius: 10px;
.box1 {
display: flex;
flex-wrap: wrap;
border-radius: 10px;
font-size: 14px;
position: relative;
margin: 0px 15px 0;
padding-bottom: 10px;
.list {
width: 100%;
color: #666;
padding: 0;
line-height: 50px;
// display: flex;
// justify-content: space-between;
// align-items: center;
// flex-wrap: wrap;
image,
.t-icon {
width: 18px !important;
height: 18px;
border: 2px solid #c7c7c7;
background-color: #c7c7c7;
border-radius: 50%;
margin-right: 5px;
}
.block {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
color: #666;
position: relative;
.level,
.val {
width: 25%;
}
.name {
width: 40%;
display: flex;
align-items: center;
}
.icon {
width: 20px;
text-align: right;
display: flex;
image {
width: 20px;
height: 20px;
}
}
}
}
}
}
.desc {
line-height: 20px;
text-align: left;
width: calc(100%-20px);
height: auto;
border-radius: 5px;
font-size: 12px;
color: #999;
padding: 10px;
background: #f7f7f7;
.statuevue {
height: 35px;
position: relative;
width: 100% !important;
margin: 20px auto 10px;
.bi {
display: flex;
justify-content: space-between;
width: auto;
padding-top: 10px;
.peobox {
position: absolute;
right: 0;
top: -1px;
.xx {
width: 5px;
height: 5px;
border-radius: 50%;
background: #fff;
position: absolute;
z-index: 9;
border: 2px solid #1b2086;
top: 9px;
}
}
}
.item {
position: relative;
margin: 0;
flex: 1;
height: 5px;
color: #666;
font-size: 12px;
.span1 {
width: 100%;
text-align: center;
position: absolute;
top: -23px;
}
.span {
margin-top: 8px;
position: absolute;
right: -8px;
}
}
}
}
.yuanxing {
display: inline-block;
background: #f19601;
width: 8px;
height: 12px;
margin-right: 5px;
font-size: 32rpx;
}
.btnf {
font-size: 13px;
border-radius: 5px;
height: 22px;
margin: 0 10px 0 0;
line-height: 22px;
color: #fff;
font-weight: 400;
width: 44px !important;
text-align: center !important;
float: right;
}
.tivon {
display: flex;
justify-content: center;
align-content: center;
align-items: center;
.bianji {
width: 20px;
height: 20px;
margin-left: 5px;
}
}
.box1 :last-child.list {
.val {
width: 25% !important;
}
}
.kcalClass {
width: 100%;
text-align: center;
font-size: 16px;
line-height: 55px;
margin: -20px auto;
}
.yichang {
background: #ffe4be;
color: #ff4239;
padding: 5px;
text-align: center;
border-radius: 5px;
margin: 0 15px 10px;
}
/deep/.uni-collapse-item {
width: 100% !important;
}
/deep/.uni-collapse-item__title-arrow {
margin-right: 0 !important;
}
/deep/.uni-collapse-item__wrap-content.uni-collapse-item--border {
border-bottom-width: 0
}
}
</style>