记录模块接口对接
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* @Author: Aimee·Zhang
|
||||
* @Date: 2022-01-07 12:32:50
|
||||
* @LastEditors: Aimee·Zhang
|
||||
* @LastEditTime: 2022-01-10 15:00:51
|
||||
* @LastEditTime: 2022-01-14 09:37:42
|
||||
-->
|
||||
|
||||
<template>
|
||||
@@ -13,7 +13,7 @@
|
||||
<view class="unit">
|
||||
<span
|
||||
:class="isJin === 2?'active':''"
|
||||
@click="isJin = 2"
|
||||
@click="isJin = 1"
|
||||
>斤</span>
|
||||
<span
|
||||
:class="isJin === 1?'active':''"
|
||||
@@ -21,11 +21,11 @@
|
||||
>公斤</span>
|
||||
</view>
|
||||
<view class="progress">
|
||||
<view>比原来轻</view>
|
||||
<view>{{weightInfo.text}}</view>
|
||||
<u-count-to
|
||||
class="uCountTo"
|
||||
:startVal="0"
|
||||
:endVal="3.2"
|
||||
:endVal="weightInfo.change"
|
||||
:decimals="1"
|
||||
color="#333"
|
||||
fontSize="36"
|
||||
@@ -35,39 +35,46 @@
|
||||
</view>
|
||||
<view
|
||||
class="add-weight"
|
||||
@click="addWeight"
|
||||
@click="addWeightShow = true"
|
||||
>记录体重</view>
|
||||
<view class="des-title">以最后一次记录为主且每日只能更新一次</view>
|
||||
</view>
|
||||
<!-- 体重列表 -->
|
||||
<view class="weight-list">
|
||||
<view
|
||||
class="weight-list"
|
||||
v-if="lists.length>0"
|
||||
>
|
||||
<view
|
||||
class="list-item"
|
||||
v-for="item in 2"
|
||||
:key="item"
|
||||
v-for="item in lists"
|
||||
:key="item.wight_id"
|
||||
>
|
||||
<view class="list-left">
|
||||
<view class="list-title">
|
||||
<span>64.9</span>公斤
|
||||
<span>{{item.weight}}</span>公斤
|
||||
</view>
|
||||
初始体重
|
||||
测量结果
|
||||
</view>
|
||||
<view class="list-right">
|
||||
<span>开始保持 / 塑性</span>
|
||||
2021-12-22 12:23
|
||||
{{item.created_at}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="no-lists"
|
||||
v-else
|
||||
>还没有体重信息,记录下呗~</view>
|
||||
<!-- 记录体重弹窗 -->
|
||||
<u-popup
|
||||
:show="addWeightShow"
|
||||
:round="10"
|
||||
@close="addWeightShow = false"
|
||||
@open="open"
|
||||
:closeable="true"
|
||||
>
|
||||
<view class="addWeightContent">
|
||||
<view class="date">今天</view>
|
||||
<view class='count'><span>{{horizontaPointVal}}</span>公斤</view>
|
||||
<view class='count'><span>{{weight}}</span>公斤</view>
|
||||
<vue-scale
|
||||
:min="10"
|
||||
:max="100"
|
||||
@@ -76,11 +83,11 @@
|
||||
:h="80"
|
||||
:styles="styles"
|
||||
@scroll="scroll"
|
||||
:scrollLeft="55"
|
||||
:scrollLeft="Number(weight)"
|
||||
/>
|
||||
<view
|
||||
class="addBtn"
|
||||
@click="addWeightShow = false"
|
||||
@click="addWeight"
|
||||
>确认添加</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
@@ -88,6 +95,9 @@
|
||||
</template>
|
||||
<script>
|
||||
import vueScale from "@/components/vueScale";
|
||||
import { weights, addWeight } from "@/apis/interfaces/weight.js";
|
||||
import moment from "moment";
|
||||
import l from "../../uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center";
|
||||
export default {
|
||||
components: {
|
||||
vueScale,
|
||||
@@ -95,9 +105,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
isJin: 1, // 是公斤 2 是斤 所有用到斤的直接乘以这个字段即可
|
||||
addWeightShow: true, // 是否添加体重展示
|
||||
weight: 11,
|
||||
height: 180,
|
||||
addWeightShow: false, // 是否添加体重展示
|
||||
styles: {
|
||||
line: "#dbdbdb",
|
||||
bginner: "#fbfbfb",
|
||||
@@ -106,18 +114,57 @@ export default {
|
||||
fontColor: "#404040",
|
||||
fontSize: 16,
|
||||
},
|
||||
horizontaPointVal: "",
|
||||
weight: "",
|
||||
date: "",
|
||||
weightInfo: {},
|
||||
lists: [],
|
||||
has_more: true,
|
||||
page: 1,
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.getWeights();
|
||||
this.date = moment(new Date()).format("YYYY-MM-DD");
|
||||
},
|
||||
onReachBottom() {
|
||||
if (!this.has_more) {
|
||||
uni.showToast({
|
||||
title: "没有更多啦~",
|
||||
icon: "none",
|
||||
});
|
||||
} else {
|
||||
this.page = this.page + 1;
|
||||
this.getWeights();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
addWeight() {
|
||||
this.addWeightShow = true;
|
||||
//获取体重首页接口
|
||||
getWeights() {
|
||||
weights(this.page).then((res) => {
|
||||
console.log(res);
|
||||
this.lists = this.lists.concat(res.lists.data);
|
||||
this.has_more = res.lists.page.has_more;
|
||||
this.weightInfo = res.weight;
|
||||
this.weight = res.weight.now;
|
||||
});
|
||||
},
|
||||
addWeight() {
|
||||
let data = {
|
||||
weight: this.weight,
|
||||
date: this.date,
|
||||
};
|
||||
addWeight(data).then((res) => {
|
||||
this.addWeightShow = false;
|
||||
this.page = 1;
|
||||
this.has_more = true;
|
||||
this.lists = [];
|
||||
this.getWeights();
|
||||
});
|
||||
},
|
||||
close() {},
|
||||
open() {},
|
||||
// 滚动标尺触发事件
|
||||
scroll(msg) {
|
||||
this.horizontaPointVal = msg;
|
||||
this.weight = msg;
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -189,10 +236,15 @@ export default {
|
||||
border-radius: $radius * 3;
|
||||
border: solid 2rpx $main-color;
|
||||
color: $main-color;
|
||||
padding: $padding * 0.8 $padding * 2.8;
|
||||
padding: $padding * 0.6 $padding * 2.8;
|
||||
margin-top: $margin * 2;
|
||||
font-weight: bold;
|
||||
}
|
||||
.des-title {
|
||||
padding: $padding;
|
||||
color: $text-gray-m;
|
||||
font-size: $title-size-m - 4;
|
||||
}
|
||||
}
|
||||
// 列表
|
||||
.weight-list {
|
||||
@@ -231,6 +283,11 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
.no-lists {
|
||||
padding: $padding;
|
||||
color: $text-gray-m;
|
||||
font-size: $title-size-m;
|
||||
}
|
||||
|
||||
// 弹窗
|
||||
.addWeightContent {
|
||||
@@ -261,7 +318,7 @@ export default {
|
||||
}
|
||||
}
|
||||
.addBtn {
|
||||
background-color: $main-color * 0.8;
|
||||
background-color: $main-color;
|
||||
color: #fff;
|
||||
margin-top: $margin * 2;
|
||||
font-size: $title-size * 1.2;
|
||||
|
||||
Reference in New Issue
Block a user