examTeamApp/pages/body/body.vue

239 lines
6.4 KiB
Vue
Raw Normal View History

2024-05-02 15:59:36 +08:00
<template>
<view class="content">
<!-- tabbar -->
<!-- 曲线 -->
<view class="charts">
2024-07-08 10:50:07 +08:00
<view class="TrendPage">
<!-- 时间选择 -->
<view class="boxTime">
<view class="one">
2024-10-11 10:04:19 +08:00
<picker mode="date" :end="endDate" @change="handStartTimeH" :fields="fields"
2024-07-22 14:13:19 +08:00
:value="startTime?startTime:startDate">
2024-10-11 10:04:19 +08:00
<view class="uni-input mr-10">{{startTime?startTime:startDate}}
<icon class="iconfont icon-arrow-down-bold"></icon>
</view>
2024-07-22 14:13:19 +08:00
</picker>
<view class="center">~</view>
2024-10-11 10:04:19 +08:00
<picker mode="date" :end="endDate" @change="handEndTimeH" :fields="fields"
2024-07-22 14:13:19 +08:00
:value="endTime?endTime:endDate">
2024-10-11 10:04:19 +08:00
<view class="uni-input mr-10">{{endTime?endTime:endDate}}
<icon class="iconfont icon-arrow-down-bold"></icon>
</view>
2024-07-22 14:13:19 +08:00
</picker>
2024-07-08 10:50:07 +08:00
</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"
2024-10-11 10:04:19 +08:00
:animation="false" :Width="340" :Height="250"
2024-07-08 10:50:07 +08:00
: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>
2025-04-18 14:53:38 +08:00
<text>{{$t("index.none")}}</text>
2024-07-08 10:50:07 +08:00
</view>
</view>
</view>
<!-- 目标-->
<view class="gridList">
<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>
2025-04-18 14:53:38 +08:00
<view class="name">{{$t("body.target_weight")}}<uni-icons class="iconfont icon-bianji" color="#FEC407"></uni-icons>
2024-07-08 10:50:07 +08:00
</view>
</view>
<view class="item">
<view class="val">
{{userInfo.target_current?Math.abs(userInfo.target_current.cumulative_weight):0}}<text>kg</text>
</view>
2025-04-18 14:53:38 +08:00
<view class="name" v-if="Number(userInfo.target_current.cumulative_weight)>0">{{$t("body.Gain_weight")}}</view>
<view class="name" v-else>{{$t("body.cumulative_weight")}}</view>
2024-07-08 10:50:07 +08:00
</view>
<view class="item" @click="handleClick(2)">
<view class="val">
{{userInfo.target_current?userInfo.target_current.initial_weight:0}}<text>kg</text>
</view>
2025-04-18 14:53:38 +08:00
<view class="name">{{$t("body.initial_weight")}}<uni-icons class="iconfont icon-bianji" color="#FEC407"></uni-icons>
2024-07-08 10:50:07 +08:00
</view>
</view>
<view class="item">
<view class="val">
2025-04-18 14:53:38 +08:00
{{userInfo.target_current?userInfo.target_current.cumulative_day:0}}<text></text>
2024-07-08 10:50:07 +08:00
</view>
2025-04-18 14:53:38 +08:00
<view class="name">{{$t("body.cumulative_day")}}</view>
2024-07-08 10:50:07 +08:00
</view>
</view>
</view>
<!-- 初始 -->
<firstweight :type="ind"></firstweight>
2024-05-02 15:59:36 +08:00
</view>
</view>
</template>
<script>
2024-05-29 16:35:45 +08:00
import {
mapState
} from "vuex";
import firstweight from '@/element/target/firstweight.vue';
2024-10-11 10:04:19 +08:00
import qiunDataCharts from '@/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue'
2024-05-02 15:59:36 +08:00
export default {
data() {
return {
2024-10-11 10:04:19 +08:00
fields: "",
2024-05-29 16:35:45 +08:00
active: 1,
2024-07-08 10:50:07 +08:00
acd_id: 2,
ind: 0,
active1: 0,
startTime: "",
endTime: "",
lineData: {},
handTrue: true,
2024-05-02 15:59:36 +08:00
}
},
2024-05-29 16:35:45 +08:00
computed: {
2024-07-08 10:50:07 +08:00
...mapState(['user', "MeasureResult", "Trend"]),
weightList() {
let that = this
that.showbox(0)
return that.Trend
},
userInfo() {
return this.MeasureResult
2024-07-08 10:50:07 +08:00
},
2024-05-29 16:35:45 +08:00
endDate() {
return this.$tools.getDate("start")
},
startDate() {
return this.$tools.GetDateStr(-90);
},
},
2024-05-02 15:59:36 +08:00
components: {
2024-07-08 10:50:07 +08:00
firstweight,
qiunDataCharts,
2024-05-02 15:59:36 +08:00
},
2025-04-26 13:35:30 +08:00
onReady() {
uni.setNavigationBarTitle({
title: this.$t('common.titleBody'),
})
},
2024-07-08 10:50:07 +08:00
onLoad(options) {
2024-05-29 16:35:45 +08:00
let that = this
2024-07-08 10:50:07 +08:00
that.acd_id = options.acd_id
2024-05-29 16:35:45 +08:00
that.$store.dispatch("GetBodyTrendList", {
aud_id: uni.getStorageSync('userid'),
s_time: that.startDate,
e_time: that.endDate
})
2024-10-11 10:04:19 +08:00
// #ifdef APP-PLUS
that.fields = "time"
// #endif
// #ifndef APP-PLUS
that.fields = "day"
// #endif
2024-05-29 16:35:45 +08:00
},
// 下拉刷新
2024-07-26 16:43:31 +08:00
onPullDownRefresh() {
let that = this
that.$store.dispatch("GetBodyTrendList", {
aud_id: uni.getStorageSync('userid'),
s_time: that.startDate,
e_time: that.endDate
})
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1000);
},
2024-05-02 15:59:36 +08:00
methods: {
2024-07-08 10:50:07 +08:00
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) {
2024-07-22 14:13:19 +08:00
if (Date.parse(e.detail.value) > Date.parse(that.endTime)) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t('tips.verifyBodyDate'))
2024-07-08 10:50:07 +08:00
return
}
} else {
2024-07-22 14:13:19 +08:00
if (Date.parse(e.detail.value) > Date.parse(that.endDate)) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t('tips.verifyBodyDate'))
2024-07-08 10:50:07 +08:00
return
}
}
2024-07-22 14:13:19 +08:00
that.startTime = e.detail.value
2024-07-08 10:50:07 +08:00
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) {
2024-07-22 14:13:19 +08:00
if (Date.parse(e.detail.value) < Date.parse(that.startTime)) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t('tips.verifyBodyDate'))
2024-07-08 10:50:07 +08:00
return
}
} else {
2024-07-22 14:13:19 +08:00
if (Date.parse(e.detail.value) < Date.parse(that.startDate)) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t('tips.verifyBodyDate'))
2024-07-08 10:50:07 +08:00
return
}
}
2024-07-22 14:13:19 +08:00
that.endTime = e.detail.value
2024-07-08 10:50:07 +08:00
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);
},
2024-05-02 15:59:36 +08:00
}
}
</script>
<style scoped lang="scss">
@import "@/scss/body.scss";
2024-05-02 15:59:36 +08:00
.content {
padding: 15px;
2024-08-05 10:01:06 +08:00
font-size: 32rpx;
width: calc(100% - 30px);
2024-05-02 15:59:36 +08:00
background-color: #F5F6FA;
min-height: 100vh;
}
2024-10-11 10:04:19 +08:00
.listC {
margin: 0;
width: 100%;
}
2024-05-02 15:59:36 +08:00
</style>