123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- <template>
- <view class="container">
- <view class="datebox">
- <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
- <view class="datebox-item border-line flex-bt">
- <view>日期</view>
- <view class="datebox-item-right">
- <text :class="date ? '':'default'">{{date ? date : "请选择日期"}}</text>
- <image src="@/static/images/health/right_arrow_right_icon24.png"></image>
- </view>
- </view>
- </picker>
- <picker mode="time" :value="time" @change="bindTimeChange">
- <view class="datebox-item flex-bt">
- <view>测量时间</view>
- <view class="datebox-item-right">
- <text :class="time ? '':'default'">{{time ? time : "请选择测量时间"}}</text>
- <image src="@/static/images/health/right_arrow_right_icon24.png"></image>
- </view>
- </view>
- </picker>
- </view>
- <view class="datebox-detail">
- <view class="datebox-detail-header flex-bt">
- <view>尿酸</view>
- <view class="datebox-detail-header-right">
- <text class="num">{{active}}</text>
- <text>μmol/L</text>
- </view>
- </view>
- <view class="scale">
- <simpleScale ref="simpleScale" :minVal="0" :maxVal="1000" :int="false" :single="10" :h="h" :active="active" :style="style"
- @value="getScroll" />
- </view>
- </view>
- <view class="h40"></view>
- <view class="btn-box">
- <view class="sub-btn" @click="submit()">记录</view>
- </view>
- </view>
- </template>
- <script>
- import {addData,getDataById,getLatest,updateData} from '@/api/healthUser.js'
- import simpleScale from "@/pages_echarts/components/simpleScale/simpleScale.vue"
- // import { bgInfo } from "@/api/pages_watch/healthMonitoring.js"
- export default {
- components: {
- simpleScale
- },
- data() {
- return {
- startDate:this.utils.timeFormat(new Date()) ,
- // 表示有效日期范围的结束,字符串格式为"YYYY-MM-DD"
- endDate: this.utils.timeFormat(new Date()),
- date: this.utils.timeFormat(new Date(),'yyyy-mm-dd'),
- time: this.utils.timeFormat(new Date(),'hh:MM:ss'),
- active: "0",
- loading: false,
- style: {
- line: '#ccc',
- bginner: '#fbfbfb',
- bgoutside: '#ffffff',
- fontColor: '#333',
- fontSize: 16
- },
- h: uni.upx2px(88),
- }
- },
- onLoad(options) {
- console.log(options)
- this.type=options.type;
- this.userId=options.userId
- if(this.type=='edit'){
- this.id=options.id;
- this.getDataById();
- // this.listByIndicator()
- }
-
- // const param = JSON.parse(option.param)
- // this.date = param.createTime && param.createTime.split(' ')[0]
- // this.time = param.createTime && param.createTime.substring(11, 16)
- // this.active = String(param.num || 0)
- this.$nextTick(()=>{
- this.$refs.simpleScale.init()
- })
- },
- methods: {
- bindDateChange(e) {
- this.date = e.detail.value
- this.getList()
- },
- bindTimeChange(e) {
- this.time = e.detail.value
- this.getList()
- },
- getScroll(e) {
- this.active = e
- },
- getDataById(){
- getDataById({id:this.id}).then(
- res => {
- if(res.code==200){
- this.date=res.data.measurementDate
- this.time=res.data.measurementTime
- this.active= String(res.data.value1)
- }else{
- uni.showToast({
- icon:'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
- submit(){
- var data={
- userId:this.userId,
- "measurementType": 4, //测量类型(0-腰围,1-臀围,2-血糖,3-血压,4-尿酸 5-BMI)
- "value1": this.active, //数值1(测量值1 测量值只有一个时默认填写/身高cm/舒张压)
- "measurementDate": this.date, //测量日期 yyyy-MM-dd
- "measurementTime":this.time//测量时间 HH:mm:ss
- }
- if(this.type=="add"){
- this.addData(data)
- }
- else if(this.type=="edit"){
- data.id=this.id
- this.updateData(data)
- }
-
- },
- addData(data){
- addData(data).then(
- res => {
- if(res.code==200){
- uni.showToast({
- icon:'success',
- title: "操作成功",
- });
- setTimeout(function() {
- uni.$emit('refreshAcidList');
- // uni.$emit('refreshAcid');
- uni.navigateBack({
- delta: 1
- })
- }, 500);
- }else{
- uni.showToast({
- icon:'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
- updateData(data){
- updateData(data).then(
- res => {
- if(res.code==200){
- uni.showToast({
- icon:'success',
- title: "更新成功",
- });
- setTimeout(function() {
- uni.$emit('refreshAcidList');
- // uni.$emit('refreshAcid');
- uni.navigateBack({
- delta: 1
- })
- }, 500);
- }else{
- uni.showToast({
- icon:'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
- getLatest(){
- var data={
- userId:this.userId,
- measurementType:2
- }
- getLatest(data).then(
- res => {
- if(res.code==200){
- if(res.data==null){
- this.type='add'
- }else{
- this.type='edit'
- this.form = res.data;
- }
- }else{
- uni.showToast({
- icon:'none',
- title: res.msg,
- });
- }
- },
- rej => {}
- );
- },
- // 查询数据
- getList() {
- this.loading = true
- const param = {
- startTime: this.date.replace(/-/g, '/') +" " +this.time + ":00",
- endTime: this.date.replace(/-/g, '/') +" " + this.time + ":59",
- deviceId: uni.getStorageSync("deviceId"),
- }
- bgInfo(param).then(res => {
- this.loading = false
- if (res.code == 200) {
- if(res.data && res.data.length > 0) {
- this.date = res.data[0].createTime && res.data[0].createTime.split(' ')[0]
- this.time = res.data[0].createTime && res.data[0].createTime.substring(11, 16)
- this.active = String(res.data[0].bloodGlucose || 0)
- } else {
- this.active = "0"
- }
-
- } else {
- this.active = "0"
- }
- this.$nextTick(()=>{
- this.$refs.simpleScale.init()
- })
- }).catch(() => {
- this.loading = false
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @mixin u-flex($flexD, $alignI, $justifyC) {
- display: flex;
- flex-direction: $flexD;
- align-items: $alignI;
- justify-content: $justifyC;
- }
- .flex-bt {
- @include u-flex(row, center, space-between);
- }
- .default {
- font-weight: 400;
- font-size: 28rpx;
- color: #999999;
- }
- .btn-box {
- height: 120upx;
- padding: 0 30upx;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .sub-btn {
- width: 388rpx;
- height: 72rpx;
- line-height: 72upx;
- text-align: center;
- font-size: 32upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- background: #4585F8;
- border-radius: 44upx;
- margin-bottom: 40upx;
- }
- }
- .container {
- padding: 20rpx 24rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- }
- .btn-box {
- height: 120upx;
- padding: 0 30upx;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .sub-btn {
- width: 388rpx;
- height: 72rpx;
- line-height: 72upx;
- text-align: center;
- font-size: 32upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- background: #2CAE5C;
- border-radius: 44upx;
- margin-bottom: 40upx;
- }
- }
- .datebox {
- padding: 0 32rpx;
- margin-bottom: 20rpx;
- background: #FFFFFF;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- &-item {
- height: 120rpx;
- &-right {
- font-weight: 400;
- font-size: 32rpx;
- @include u-flex(row, center, flex-start);
- image {
- width: 48rpx;
- height: 48rpx;
- }
- }
- }
- }
- .datebox-detail {
- background: #FFFFFF;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- padding: 40rpx 32rpx;
- &-header-right {
- flex-shrink: 0;
- font-weight: 400;
- font-size: 28rpx;
- color: #999999;
- .num {
- font-size: 48rpx;
- color: #333333;
- margin-right: 14rpx;
- }
- }
- }
- .scale {
- height: 176rpx;
- margin-top: 36rpx;
- overflow: hidden;
- background: #FFFFFF;
- box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(170,170,170,0.1);
- border-radius: 0rpx 0rpx 0rpx 0rpx;
- border: 2rpx solid #ECECEC;
- // width: 200rpx;
- // height: 600rpx;
- }
- </style>
|