This commit is contained in:
唐明明
2022-01-20 16:14:28 +08:00
7 changed files with 993 additions and 1118 deletions

View File

@@ -35,8 +35,21 @@ const drinkWater = () => {
method: 'POST',
})
}
/**
* @description:删除喝水记录
* @Date: 2022-01-20 15点08分
*/
const delDrinkWater = (id) => {
return request({
url: `health/waters/${id}`,
method: 'DELETE',
})
}
export {
waters,
setWaters,
drinkWater
drinkWater,
delDrinkWater
}

View File

@@ -37,7 +37,7 @@
v-if="selectSports.title === '编辑运动'"
name="trash"
color="#ddd"
size="20"
size="16"
label="删除这条数据"
labelColor="#ddd"
:bold="true"
@@ -49,6 +49,7 @@
placeholder="60"
class="select-time"
v-model="duration"
type="number"
>
<u--text
text="运动时间:"
@@ -132,7 +133,7 @@ export default {
position: relative;
.popup-title {
color: $main-color;
font-size: $title-size + 4;
font-size: $title-size-m;
border-bottom: solid 1rpx #f9f9f9;
display: flex;
flex-direction: row;
@@ -144,6 +145,8 @@ export default {
}
.title {
color: $text-color;
font-size: $title-size;
font-weight: bold;
}
}
@@ -154,7 +157,7 @@ export default {
justify-content: center;
box-sizing: border-box;
padding: $padding * 2 $padding $padding $padding;
font-size: $title-size + 4;
font-size: $title-size-m;
color: $text-color;
border-bottom: solid 1rpx #f9f9f9;
.popup-item-title {

View File

@@ -13,7 +13,7 @@
:lists="menuData.foods"
isType="det"
:btnStyle="{'margin-top': '30rpx'}"
@onMenu="$Router.push({ name: 'menuDetails', params: {id: $event.food_id, title: $event.name }})"
@onMenu="$Router.push({ name: 'rankingDetails', params: {id: $event.food_id, title: $event.name }})"
/>
</view>
<view class="foods">

View File

@@ -7,177 +7,164 @@
-->
<template>
<view class="add-foods">
<!-- 搜索页面 -->
<u-search
:show-action="true"
actionText="搜索"
:animation="true"
:clearabled="true"
placeholder="请输入运动名称"
@custom="searchCustom"
@clear="clearSearch"
v-model="name"
/>
<!-- 运动列表 -->
<sports
type="add"
:lists="lists"
@addSport="addSport"
/>
<!-- 添加弹窗 -->
<addPopup
:selectSports="selectSports"
:addSportsShow="addSportsShow"
@comfirmSport="comfirmSport"
@cancleSport="cancleSport"
/>
</view>
<view class="add-foods">
<!-- 搜索页面 -->
<u-search :show-action="true" actionText="搜索" :animation="true" :clearabled="true" placeholder="请输入运动名称" @custom="searchCustom" @clear="clearSearch" v-model="name" />
<!-- 运动列表 -->
<sports type="add" :lists="lists" @addSport="addSport" />
<!-- 添加弹窗 -->
<addPopup :selectSports="selectSports" :addSportsShow="addSportsShow" @comfirmSport="comfirmSport" @cancleSport="cancleSport" />
</view>
</template>
<script>
import sports from "@/components/sports";
import addPopup from "@/components/sports/addPopup";
import { healthSports, addHealthSports } from "@/apis/interfaces/sport.js";
import moment, { duration } from "moment";
import sports from '@/components/sports';
import addPopup from '@/components/sports/addPopup';
import { healthSports, addHealthSports } from '@/apis/interfaces/sport.js';
import moment, { duration } from 'moment';
export default {
components: { sports, addPopup },
data() {
return {
addSportsShow: false, // 添加运动弹窗显示
selectSports: {}, // 选择新增的运动
lists: [], // 运动列表
page: 1,
has_more: true,
name: "", // 搜索运动名称
today: moment(new Date()).format("YYYY-MM-DD"),
};
},
onLoad() {
this.getExercises();
},
// 触底加载更多
onReachBottom() {
if (!this.has_more) {
uni.showToast({
title: "没有更多啦~",
icon: "none",
});
} else {
this.page = this.page + 1;
this.getExercises();
}
},
methods: {
// 获取运动列表
getExercises() {
let data = {
page: this.page,
name: this.name,
};
healthSports(data).then((res) => {
this.lists = this.lists.concat(res.data);
this.has_more = res.page.has_more;
});
},
// 显示弹窗内容
addSport(item) {
console.log(item);
this.selectSports = item;
this.selectSports.duration = 60;
this.addSportsShow = true;
},
// 弹窗确认按钮新增
comfirmSport(show, duration) {
let params = {
unit: "1", // 时间单位:分钟 1 小时 2
duration: duration, // 时常
sport_id: this.selectSports.sport_id, // 运动id
date: this.today, // 日期
};
addHealthSports(params).then((res) => {
this.addSportsShow = false;
this.selectSports = {};
this.$Router.back();
});
console.log("弹窗确认按钮新增");
},
// 弹窗取消按钮
cancleSport(show) {
this.addSportsShow = show;
this.duration = 60;
console.log("弹窗取消按钮");
},
// 添加运动弹窗显示
//#region 搜索相关方法 start
// 点击搜索左侧按钮
searchCustom(e) {
console.log(e);
this.name = e;
this.reset();
},
// 清空数组重新请求数据
reset() {
this.page = 1;
this.has_more = true;
this.lists = [];
this.getExercises();
},
// 点击搜索后面按钮触发事件事件
clearSearch() {
this.name = "";
this.reset();
},
//#endregion 搜索相关方法 end
},
components: { sports, addPopup },
data() {
return {
addSportsShow: false, // 添加运动弹窗显示
selectSports: {}, // 选择新增的运动
lists: [], // 运动列表
page: 1,
has_more: true,
name: '', // 搜索运动名称
today: moment(new Date()).format('YYYY-MM-DD')
};
},
onLoad() {
this.getExercises();
},
// 触底加载更多
onReachBottom() {
if (!this.has_more) {
uni.showToast({
title: '没有更多啦~',
icon: 'none'
});
} else {
this.page = this.page + 1;
this.getExercises();
}
},
methods: {
// 获取运动列表
getExercises() {
let data = {
page: this.page,
name: this.name
};
healthSports(data).then(res => {
this.lists = this.lists.concat(res.data);
this.has_more = res.page.has_more;
});
},
// 显示弹窗内容
addSport(item) {
console.log(item);
this.selectSports = item;
this.selectSports.duration = 60;
this.addSportsShow = true;
},
// 弹窗确认按钮新增
comfirmSport(show, duration) {
let params = {
unit: '1', // 时间单位:分钟 1 小时 2
duration: duration, // 时常
sport_id: this.selectSports.sport_id, // 运动id
date: this.today // 日期
};
addHealthSports(params)
.then(res => {
this.addSportsShow = false;
this.selectSports = {};
this.$Router.back();
})
.catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
});
});
},
// 弹窗取消按钮
cancleSport(show) {
this.addSportsShow = show;
this.duration = 60;
},
// 添加运动弹窗显示
//#region 搜索相关方法 start
// 点击搜索左侧按钮
searchCustom(e) {
console.log(e);
this.name = e;
this.reset();
},
// 清空数组重新请求数据
reset() {
this.page = 1;
this.has_more = true;
this.lists = [];
this.getExercises();
},
// 点击搜索后面按钮触发事件事件
clearSearch() {
this.name = '';
this.reset();
}
//#endregion 搜索相关方法 end
}
};
</script>
<style lang="scss" scoped>
.add-foods {
padding: $padding;
.lists {
padding: $padding * 0.6 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
.lists-right {
flex: 1;
font-size: $title-size-m - 6;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
color: $text-gray-m;
border-bottom: solid 1rpx #f7f7f7;
margin-left: $margin * 0.8;
padding: $padding 0;
}
.lists-title {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m;
color: $text-color;
.des {
margin-top: 10rpx;
}
span {
color: $text-price;
font-size: $title-size-m - 6;
font-weight: normal;
padding-right: $padding * 0.3;
}
.des {
color: $text-gray-m;
font-size: $title-size-m - 6;
font-weight: normal;
}
}
}
padding: $padding;
.lists {
padding: $padding * 0.6 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
.lists-right {
flex: 1;
font-size: $title-size-m - 6;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
color: $text-gray-m;
border-bottom: solid 1rpx #f7f7f7;
margin-left: $margin * 0.8;
padding: $padding 0;
}
.lists-title {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m;
color: $text-color;
.des {
margin-top: 10rpx;
}
span {
color: $text-price;
font-size: $title-size-m - 6;
font-weight: normal;
padding-right: $padding * 0.3;
}
.des {
color: $text-gray-m;
font-size: $title-size-m - 6;
font-weight: normal;
}
}
}
}
</style>

View File

@@ -7,446 +7,402 @@
-->
<template>
<view
class="drink"
v-if="loaded"
>
<!-- 喝水及水杯文字 -->
<view class="drink-content">
<view
class="title"
v-if="!water.is_complete"
>再喝<span class="num">{{water.lack.cup}}</span><span class="total">{{water.lack.value}}ml</span></view>
<view
class="title"
v-if="water.is_complete"
>已喝<span class="num">{{water.total}}ml</span>
<u-image
class="is_complete"
:src="require('../../static/imgs/target.png')"
:lazy-load="true"
mode="widthFix"
width="140rpx"
/>
</view>
<!-- 水杯动态图片 -->
<view class="wave-content">
<u-image
class="grass"
:src="require('../../static/imgs/gress.png')"
:lazy-load="true"
mode="scaleToFill"
width="320rpx"
height="520rpx"
/>
<view
class="wave"
:style="{'--ballPercent': -ballPercent+40+'%'}"
>
</view>
</view>
<!-- 目标 -->
<view class="water-target">
<view
class="target-item"
@click="targetShow = true"
>今日目标
<u-icon
class="target-icon"
name="arrow-right"
color="#666"
size="14"
:bold="true"
:label="water.target+'ml'"
labelPos="left"
labelSize="16"
labelColor="#666"
space="6"
/>
</view>
<view
class="target-item"
@click="waterCShow = true"
>水杯容量
<u-icon
class="target-icon"
name="arrow-right"
color="#666"
size="14"
:bold="true"
:label="water.ml+'ml'"
labelPos="left"
labelSize="16"
labelColor="#666"
space="6"
/>
</view>
</view>
<!-- 目标弹出层 -->
<view>
<u-picker
:show="targetShow"
:columns="tagerts"
title="每天喝水目标"
keyName="label"
confirmColor="#34ce98"
:closeOnClickOverlay="true"
@close="targetShow = false"
@confirm="targetSure('1',$event)"
:defaultIndex="tagertsDefaultIndex"
/>
<u-picker
:show="waterCShow"
:columns="cup_mls"
title="设置水杯容量"
keyName="label"
confirmColor="#34ce98"
:closeOnClickOverlay="true"
@close="waterCShow = false"
@confirm="targetSure('2',$event)"
:defaultIndex="cupDefaultIndex"
/>
</view>
<!-- 加水 -->
<view
class="add-water"
@click="drinkWater"
>
<u-image
class="grass"
:src="require('../../static/imgs/gress2.png')"
:lazy-load="true"
mode="scaleToFill"
width="60rpx"
height="80rpx"
/>
<span>一杯水</span>
<u-icon
class="add-icon"
name="plus-circle-fill"
color="#34ce98"
size="24"
/>
</view>
</view>
<!-- 喝水记录 -->
<view class="--history">
<view class="title">喝水记录</view>
<template v-if="logs.length>0">
<view
class="lists"
v-for="item in logs"
:key="item.water_log_id"
>
<view class="lists-water">
<u-icon
size="30"
:name="require('../../static/icon/water-icon.png')"
/>
</view>
<view class="list-item">
<view class="list-item-title"><span>{{item.time}}</span></view>
{{item.ml}}ml
</view>
</view>
</template>
<view
v-else
class="no-drink"
> 今天一杯水还没有喝呢来一杯吧~</view>
</view>
</view>
<view class="drink" v-if="loaded">
<!-- 喝水及水杯文字 -->
<view class="drink-content">
<view class="title" v-if="!water.is_complete">
再喝
<span class="num">{{ water.lack.cup }}</span>
<span class="total">{{ water.lack.value }}ml</span>
</view>
<view class="title" v-if="water.is_complete">
已喝
<span class="num">{{ water.total }}ml</span>
<u-image class="is_complete" :src="require('../../static/imgs/target.png')" :lazy-load="true" mode="widthFix" width="140rpx" />
</view>
<!-- 水杯动态图片 -->
<view class="wave-content">
<u-image class="grass" :src="require('../../static/imgs/gress.png')" :lazy-load="true" mode="scaleToFill" width="320rpx" height="520rpx" />
<view class="wave" :style="{ '--ballPercent': -ballPercent + 40 + '%' }"></view>
</view>
<!-- 目标 -->
<view class="water-target">
<view class="target-item" @click="targetShow = true">
今日目标
<u-icon
class="target-icon"
name="arrow-right"
color="#666"
size="14"
:bold="true"
:label="water.target + 'ml'"
labelPos="left"
labelSize="16"
labelColor="#666"
space="6"
/>
</view>
<view class="target-item" @click="waterCShow = true">
水杯容量
<u-icon class="target-icon" name="arrow-right" color="#666" size="14" :bold="true" :label="water.ml + 'ml'" labelPos="left" labelSize="16" labelColor="#666" space="6" />
</view>
</view>
<!-- 目标弹出层 -->
<view>
<u-picker
:show="targetShow"
:columns="tagerts"
title="每天喝水目标"
keyName="label"
confirmColor="#34ce98"
:closeOnClickOverlay="true"
@close="targetShow = false"
@confirm="targetSure('1', $event)"
:defaultIndex="tagertsDefaultIndex"
/>
<u-picker
:show="waterCShow"
:columns="cup_mls"
title="设置水杯容量"
keyName="label"
confirmColor="#34ce98"
:closeOnClickOverlay="true"
@close="waterCShow = false"
@confirm="targetSure('2', $event)"
:defaultIndex="cupDefaultIndex"
/>
</view>
<!-- 加水 -->
<view class="add-water" @click="drinkWater">
<u-image class="grass" :src="require('../../static/imgs/gress2.png')" :lazy-load="true" mode="scaleToFill" width="60rpx" height="80rpx" />
<span>一杯水</span>
<u-icon class="add-icon" name="plus-circle-fill" color="#34ce98" size="24" />
</view>
</view>
<!-- 喝水记录 -->
<view class="--history">
<view class="title">喝水记录</view>
<template v-if="logs.length > 0">
<view class="lists" v-for="item in logs" :key="item.water_log_id" @longpress="delWater(item.water_log_id)">
<view class="lists-water"><u-icon size="30" :name="require('../../static/icon/water-icon.png')" /></view>
<view class="list-item">
<view class="list-item-title">
<span>{{ item.time }}</span>
</view>
{{ item.ml }}ml
</view>
</view>
</template>
<view v-else class="no-drink">今天一杯水还没有喝呢来一杯吧~</view>
</view>
</view>
</template>
<script>
import { waters, setWaters, drinkWater } from "@/apis/interfaces/drink";
import moment from "moment";
import { waters, setWaters, drinkWater, delDrinkWater } from '@/apis/interfaces/drink';
import moment from 'moment';
export default {
data() {
return {
ballPercent: 70, // 喝水比例
logs: [], // 水记录
water: {}, // 水基本信息
targetShow: false,
tagerts: [], // 目标列表
tagertsDefaultIndex: ["1"], // 目标默认index
waterCShow: false,
cup_mls: [], // 水杯列表
cupDefaultIndex: ["2"], // 目标默认index
loaded: false,
};
},
onShow() {
this.getWaters();
},
methods: {
// 获取喝水页面信息
getWaters() {
waters().then((res) => {
this.cup_mls = [res.cup_mls];
this.tagerts = [res.tagerts];
this.water = res.water;
this.logs = res.logs;
this.ballPercent = res.water.lack.ratio;
this.cupDefaultIndex = [
res.cup_mls.findIndex(
(item) => item.number === res.water.ml
),
];
this.tagertsDefaultIndex = [
res.tagerts.findIndex(
(item) => item.number === res.water.target
),
];
this.loaded = true;
});
},
// 确认方法index===1 每日目标 2水杯容量
targetSure(index, e) {
// console.log("触发了targetSure", index, e.value[0]);
// let date = moment(new Date()).format("YYYY--MM--DD");
let params = {};
if (index === "1") {
params = {
type: "target",
ml: e.value[0].number,
date: moment(new Date()).format("YYYY-MM-DD"),
};
} else {
params = {
type: "ml",
ml: e.value[0].number,
date: moment(new Date()).format("YYYY-MM-DD"),
};
}
setWaters(params).then((res) => {
this.getWaters();
this.waterCShow = false;
this.targetShow = false;
});
},
// 喝水
drinkWater() {
drinkWater().then((res) => {
this.getWaters();
});
},
},
data() {
return {
ballPercent: 0, // 喝水比例
logs: [], // 水记录
water: {}, // 水基本信息
targetShow: false,
tagerts: [], // 目标列表
tagertsDefaultIndex: ['1'], // 目标默认index
waterCShow: false,
cup_mls: [], // 水杯列表
cupDefaultIndex: ['2'], // 目标默认index
loaded: false
};
},
onShow() {
this.getWaters();
},
methods: {
// 获取喝水页面信息
getWaters() {
waters().then(res => {
this.cup_mls = [res.cup_mls];
this.tagerts = [res.tagerts];
this.water = res.water;
this.logs = res.logs;
this.ballPercent = res.water.lack.ratio;
this.cupDefaultIndex = [res.cup_mls.findIndex(item => item.number === res.water.ml)];
this.tagertsDefaultIndex = [res.tagerts.findIndex(item => item.number === res.water.target)];
this.loaded = true;
});
},
// 确认方法index===1 每日目标 2水杯容量
targetSure(index, e) {
// console.log("触发了targetSure", index, e.value[0]);
// let date = moment(new Date()).format("YYYY--MM--DD");
let params = {};
if (index === '1') {
params = {
type: 'target',
ml: e.value[0].number,
date: moment(new Date()).format('YYYY-MM-DD')
};
} else {
params = {
type: 'ml',
ml: e.value[0].number,
date: moment(new Date()).format('YYYY-MM-DD')
};
}
setWaters(params).then(res => {
this.getWaters();
this.waterCShow = false;
this.targetShow = false;
});
},
// 喝水
drinkWater() {
drinkWater().then(res => {
this.getWaters();
});
},
// 删除和喝水记录
delWater(id) {
uni.showModal({
content: '确认删除么?',
confirmText: '确认删除',
confirmColor: '#34ce98',
cancelText: '再想想',
cancelColor: '#ddd',
success: res => {
if (res.confirm) {
delDrinkWater(id)
.then(res => {
this.getWaters();
})
.catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
});
});
}
}
});
}
}
};
</script>
<style lang="scss" scoped>
.drink {
// 喝水 水杯及文字
// 喝水 水杯及文字
.drink-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
padding: $padding * 2 0;
position: relative;
// 标题 再喝水
.title {
font-size: $title-size + 4;
color: $main-color;
font-weight: normal;
margin: $margin * 2;
position: relative;
.is_complete {
position: absolute;
top: 30rpx;
right: -120rpx;
}
.num {
font-size: $title-size * 2.3;
padding: 0 $padding * 0.3;
font-weight: bold;
}
.total {
font-size: $title-size;
color: $text-gray-m;
padding-left: $padding * 0.2;
}
}
// 加一杯水
.add-water {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size;
color: $text-color;
margin-top: $margin * 2;
position: relative;
span {
padding-top: $padding * 0.4;
}
.add-icon {
position: absolute;
top: $margin + 8;
right: 0;
}
}
// 目标
.water-target {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
color: $text-gray-m;
font-size: $title-size;
position: absolute;
z-index: 110;
right: $padding * 1.4;
top: 50%;
.target-item {
margin-top: $margin * 1.6;
.target-icon {
padding-top: $padding * 0.5;
}
}
}
}
// 喝水记录
.--history {
padding: $padding;
.no-drink {
color: $text-gray-m;
font-size: $title-size-m;
padding-top: $padding + 10;
}
// 标题
.title {
font-size: $title-size * 1.4;
font-weight: bold;
color: $text-color;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
padding-left: $padding;
padding-bottom: $padding;
&::before {
position: absolute;
content: "";
width: 8rpx;
height: 45rpx;
left: 0;
background-color: $main-color;
border-radius: 10rpx;
}
}
.drink-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
// padding: $padding 0;
position: relative;
// 标题 再喝水
.title {
font-size: $title-size + 4;
color: $main-color;
font-weight: normal;
margin: $margin * 2;
position: relative;
.is_complete {
position: absolute;
top: 30rpx;
right: -120rpx;
}
.num {
font-size: $title-size * 2.3;
padding: 0 $padding * 0.3;
font-weight: bold;
}
.total {
font-size: $title-size;
color: $text-gray-m;
padding-left: $padding * 0.2;
}
}
// 加一杯水
.add-water {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size;
color: $text-color;
margin-top: $margin * 2;
position: relative;
span {
padding-top: $padding * 0.4;
color:$text-gray-m;
font-size: $title-size;
}
.add-icon {
position: absolute;
top: $margin + 8;
right: 0;
}
}
// 目标
.water-target {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
color: $text-gray-m;
font-size: $title-size;
position: absolute;
z-index: 110;
right: $padding * 1.4;
top: 50%;
.target-item {
margin-top: $margin * 1.6;
.target-icon {
padding-top: $padding * 0.5;
}
}
}
}
// 喝水记录
.--history {
padding: $padding;
.no-drink {
color: $text-gray-m;
font-size: $title-size-m;
padding-top: $padding + 10;
}
// 标题
.title {
font-size: $title-size + 4;
font-weight: bold;
color: $text-color;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
padding-left: $padding;
padding-bottom: $padding;
&::before {
position: absolute;
content: '';
width: 8rpx;
height: 45rpx;
left: 0;
background-color: $main-color;
border-radius: 10rpx;
}
}
// 列表
.lists {
// background-color: pink;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
border-bottom: solid 1rpx #f7f7f7;
.lists-water {
background-image: linear-gradient(
to right,
$main-color,
$main-color
);
width: 90rpx;
height: 90rpx;
border-radius: 50%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.list-item {
flex: 1;
margin-left: $margin * 0.7;
font-size: $title-size;
color: $text-gray-m;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
margin: $margin 0 $margin $margin * 0.7;
.list-item-title {
font-size: $title-size + 3;
color: $text-color;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
box-sizing: border-box;
font-weight: bold;
span {
margin-top: $margin * 0.4;
background-color: #f7f7f7;
padding: 4rpx 10rpx;
border-radius: 50rpx;
font-weight: normal;
font-size: $title-size - 3;
}
}
}
}
}
// 列表
.lists {
// background-color: pink;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
border-bottom: solid 1rpx #f7f7f7;
.lists-water {
background-image: linear-gradient(to right, $main-color, $main-color);
width: 90rpx;
height: 90rpx;
border-radius: 50%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.list-item {
flex: 1;
margin-left: $margin * 0.7;
font-size: $title-size;
color: $text-gray-m;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
margin: $margin 0 $margin $margin * 0.7;
.list-item-title {
font-size: $title-size + 3;
color: $text-color;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
box-sizing: border-box;
font-weight: bold;
span {
margin-top: $margin * 0.4;
background-color: #f7f7f7;
padding: 4rpx 10rpx;
border-radius: 50rpx;
font-weight: normal;
font-size: $title-size - 3;
}
}
}
}
}
}
// 水杯动画
.wave-content {
position: relative;
z-index: 110;
.grass {
position: relative;
z-index: 120099;
}
position: relative;
z-index: 110;
.grass {
position: relative;
z-index: 120099;
}
.wave {
position: absolute;
width: 290rpx;
height: 500rpx;
background-color: rgba($color: $main-color, $alpha: 0.6);
background-size: 100%;
overflow: hidden;
top: 10rpx;
left: 20rpx;
z-index: 10;
&::before,
&::after {
content: "";
position: absolute;
width: 1000rpx;
height: 1000rpx;
top: var(--ballPercent);
left: 50%;
background-color: rgba(255, 255, 255, 0.4);
border-radius: 45%;
transform: translate(-50%, -70%) rotate(0);
animation: rotate 4s linear infinite;
z-index: 10;
}
&::after {
border-radius: 47%;
background-color: rgba(255, 255, 255, 0.9);
transform: translate(-50%, -70%) rotate(0);
animation: rotate 6s linear -5s infinite;
z-index: 20;
}
}
.wave {
position: absolute;
width: 290rpx;
height: 500rpx;
background-color: rgba($color: $main-color, $alpha: 0.6);
background-size: 100%;
overflow: hidden;
top: 10rpx;
left: 20rpx;
z-index: 10;
&::before,
&::after {
content: '';
position: absolute;
width: 1000rpx;
height: 1000rpx;
top: var(--ballPercent);
left: 50%;
background-color: rgba(255, 255, 255, 0.4);
border-radius: 45%;
transform: translate(-50%, -70%) rotate(0);
animation: rotate 4s linear infinite;
z-index: 10;
}
&::after {
border-radius: 47%;
background-color: rgba(255, 255, 255, 0.9);
transform: translate(-50%, -70%) rotate(0);
animation: rotate 6s linear -5s infinite;
z-index: 20;
}
}
@keyframes rotate {
50% {
transform: translate(-50%, -73%) rotate(180deg);
}
100% {
transform: translate(-50%, -70%) rotate(360deg);
}
}
@keyframes rotate {
50% {
transform: translate(-50%, -73%) rotate(180deg);
}
100% {
transform: translate(-50%, -70%) rotate(360deg);
}
}
}
</style>

View File

@@ -7,530 +7,446 @@
-->
<template>
<view class="record--foods">
<!-- 饮食进度条 -->
<view class="cricle-content">
<view class="info">
饮食摄入
<span>{{ calorys.intake_total }}</span>
</view>
<arprogress
:percent="calorys.exceeds ? 100 : calorys.ratio"
inactiveColor="#f5f4f9"
:activeColor="calorys.exceeds ? '#f00' : '#34ce98'"
width="300"
class="cricle"
borderWidth="20"
>
<span>{{ calorys.exceeds ? '多吃了' : '还可以吃' }}</span>
<span :class="['num', calorys.exceeds ? 'num1' : '']">{{ calorys.amount }}</span>
<span>推荐预算{{ calorys.goal }}</span>
</arprogress>
<view
class="info"
@click="errToast"
>
运动消耗
<span>{{ calorys.exercise_total }}</span>
</view>
<view class="ic-left">摄入量推荐</view>
<u-icon
class="ic-day"
name="checkmark-circle"
color="#34ce98"
size="10"
:label="`${calorys.days}天`"
labelColor="#34ce98"
labelSize="10"
space="3"
/>
</view>
<view class="record--foods">
<!-- 饮食进度条 -->
<view class="cricle-content">
<view class="info">
饮食摄入
<span>{{ calorys.intake_total }}</span>
</view>
<arprogress
:percent="calorys.exceeds ? 100 : calorys.ratio"
inactiveColor="#f5f4f9"
:activeColor="calorys.exceeds ? '#f00' : '#34ce98'"
width="300"
class="cricle"
borderWidth="20"
>
<span>{{ calorys.exceeds ? '多吃了' : '还可以吃' }}</span>
<span :class="['num', calorys.exceeds ? 'num1' : '']">{{ calorys.amount }}</span>
<span>推荐预算{{ calorys.goal }}</span>
</arprogress>
<view class="info" @click="errToast">
运动消耗
<span>{{ calorys.exercise_total }}</span>
</view>
<view class="ic-left">摄入量推荐</view>
<u-icon class="ic-day" name="checkmark-circle" color="#34ce98" size="10" :label="`${calorys.days}天`" labelColor="#34ce98" labelSize="10" space="3" />
</view>
<!-- 有饮食记录 -->
<template v-if="intakes.length > 0">
<view
class="foods-add"
v-for="(it, index) in intakes"
:key="index"
>
<view class="foods-title">
<view class="title-left">
{{ it.name }}
<span v-if="it.remark">{{ it.remark || '' }}</span>
</view>
<view class="title-right">
{{ it.total }}
<span class="dw">千卡</span>
<u-icon
name="arrow-right"
color="#ddd"
size="13"
:bold="true"
/>
</view>
</view>
<goodsList
:lists="it.intake"
type="no-dian"
@editGoods="editGoods"
@longClickGoods="longClickGoods"
/>
</view>
</template>
<!-- 运动列表 -->
<template v-if="sportsTotal > 0">
<view
class="foods-title"
style="padding-top:50rpx;"
>
<view class="title-left">运动</view>
<view class="title-right">
{{ sportsTotal }}
<span class="dw">千卡</span>
<u-icon
name="arrow-right"
color="#ddd"
size="13"
:bold="true"
/>
</view>
</view>
<!-- 有饮食记录 -->
<template v-if="intakes.length > 0">
<view class="foods-add" v-for="(it, index) in intakes" :key="index">
<view class="foods-title">
<view class="title-left">
{{ it.name }}
<span v-if="it.remark">{{ it.remark || '' }}</span>
</view>
<view class="title-right">
{{ it.total }}
<span class="dw">千卡</span>
<u-icon name="arrow-right" color="#ddd" size="13" :bold="true" />
</view>
</view>
<goodsList :lists="it.intake" type="no-dian" @editGoods="editGoods" @longClickGoods="longClickGoods" />
</view>
</template>
<!-- 运动列表 -->
<template v-if="sportsTotal > 0">
<view class="foods-title" style="padding-top:50rpx;">
<view class="title-left">运动</view>
<view class="title-right">
{{ sportsTotal }}
<span class="dw">千卡</span>
<u-icon name="arrow-right" color="#ddd" size="13" :bold="true" />
</view>
</view>
<sports
type="edit"
:lists="sports"
@editSport="editSport"
@longClick="longClick"
/>
</template>
<sports type="edit" :lists="sports" @editSport="editSport" @longClick="longClick" />
</template>
<!-- 没有饮食记录 -->
<view
class="no-foods"
v-if="sports.length === 0 && intakes.length === 0"
>
<u-image
:src="require('../../static/imgs/no-foods.png')"
:lazy-load="true"
radius="10rpx"
mode="widthFix"
width="300rpx"
class="no-foods-img"
/>
<view>还没有添加今日饮食记录</view>
<view>请点击屏幕下方按钮来添加</view>
</view>
<!-- 没有饮食记录 -->
<view class="no-foods" v-if="sports.length === 0 && intakes.length === 0">
<u-image :src="require('../../static/imgs/no-foods.png')" :lazy-load="true" radius="10rpx" mode="widthFix" width="300rpx" class="no-foods-img" />
<view>还没有添加今日饮食记录</view>
<view>请点击屏幕下方按钮来添加</view>
</view>
<!-- 加餐模块 -->
<u-action-sheet
:actions="addEatList"
title="加餐模块"
:closeOnClickOverlay="true"
:closeOnClickAction="true"
@select="selectClick"
cancelText="取消"
:show="addEatShow"
@close="addEatShow = false"
></u-action-sheet>
<!-- 底部 早餐等菜单 -->
<u-tabbar
:fixed="true"
:placeholder="true"
:safeAreaInsetBottom="true"
inactiveColor="#333"
@click="tabbarClick"
>
<u-tabbar-item
text="+早餐"
@click="tabbarClick"
:icon="require('../../static/imgs/foods-1.png')"
/>
<u-tabbar-item
text="+午餐"
@click="tabbarClick"
:icon="require('../../static/imgs/foods-2.png')"
/>
<u-tabbar-item
text="+晚餐"
@click="tabbarClick"
:icon="require('../../static/imgs/foods-3.png')"
/>
<u-tabbar-item
text="+加餐"
@click="tabbarClick"
:icon="require('../../static/imgs/foods-4.png')"
/>
<u-tabbar-item
text="+运动"
@click="tabbarClick"
:icon="require('../../static/imgs/foods-5.png')"
/>
</u-tabbar>
<!-- 加餐模块 -->
<u-action-sheet
:actions="addEatList"
title="加餐模块"
:closeOnClickOverlay="true"
:closeOnClickAction="true"
@select="selectClick"
cancelText="取消"
:show="addEatShow"
@close="addEatShow = false"
></u-action-sheet>
<!-- 底部 早餐等菜单 -->
<u-tabbar :fixed="true" :placeholder="true" :safeAreaInsetBottom="true" inactiveColor="#333" @click="tabbarClick">
<u-tabbar-item text="+早餐" @click="tabbarClick" :icon="require('../../static/imgs/foods-1.png')" />
<u-tabbar-item text="+午餐" @click="tabbarClick" :icon="require('../../static/imgs/foods-2.png')" />
<u-tabbar-item text="+晚餐" @click="tabbarClick" :icon="require('../../static/imgs/foods-3.png')" />
<u-tabbar-item text="+加餐" @click="tabbarClick" :icon="require('../../static/imgs/foods-4.png')" />
<u-tabbar-item text="+运动" @click="tabbarClick" :icon="require('../../static/imgs/foods-5.png')" />
</u-tabbar>
<!-- 修改食品弹窗 -->
<!-- 添加食谱弹窗 -->
<addFoods
v-if="addShow"
:addShow="addShow"
:selectGoods="selectGoods"
:decimals="true"
@confirm="confirmHandle"
@close="closeHandle"
@delThis="delThis"
@tabGoodsInfo="tabGoodsInfo"
max="999"
/>
<!-- 修改食品弹窗 -->
<!-- 添加食谱弹窗 -->
<addFoods
v-if="addShow"
:addShow="addShow"
:selectGoods="selectGoods"
:decimals="true"
@confirm="confirmHandle"
@close="closeHandle"
@delThis="delThis"
@tabGoodsInfo="tabGoodsInfo"
max="999"
/>
<!-- 修改运动弹窗 -->
<addPopup
:selectSports="selectSports"
:addSportsShow="addSportsShow"
@comfirmSport="comfirmSport"
@cancleSport="cancleSport"
@delSport="delSport"
/>
</view>
<!-- 修改运动弹窗 -->
<addPopup :selectSports="selectSports" :addSportsShow="addSportsShow" @comfirmSport="comfirmSport" @cancleSport="cancleSport" @delSport="delSport" />
</view>
</template>
<script>
import arprogress from "@/components/ar-circle-progress/index.vue";
import goodsList from "@/components/foods";
import {
plans,
editHealthFoods,
delHealthFoods,
} from "@/apis/interfaces/foods.js";
import moment from "moment";
import addFoods from "@/components/add-goods-template/add-goods-template";
import addPopup from "@/components/sports/addPopup";
import sports from "@/components/sports";
import { editHealthSports, delHealthSports } from "@/apis/interfaces/sport.js";
import arprogress from '@/components/ar-circle-progress/index.vue';
import goodsList from '@/components/foods';
import { plans, editHealthFoods, delHealthFoods } from '@/apis/interfaces/foods.js';
import moment from 'moment';
import addFoods from '@/components/add-goods-template/add-goods-template';
import addPopup from '@/components/sports/addPopup';
import sports from '@/components/sports';
import { editHealthSports, delHealthSports } from '@/apis/interfaces/sport.js';
export default {
components: {
arprogress,
goodsList,
addFoods,
addPopup,
sports,
},
data() {
return {
lists: [],
addShow: false, // 添加食品显示
selectGoods: [], // 选择新增的食品
addEatShow: false, // 加餐弹窗默认不显示
addEatList: [
{
name: "上午加餐",
type: 2,
},
{
name: "下午加餐",
type: 4,
},
{
name: "晚上加餐",
type: 6,
},
],
today: moment(new Date()).format("YYYY-MM-DD"),
calorys: {}, // 当日食谱推荐页面的信息
intakes: [], // 当日摄入列表
sports: [], // 运动列表
sportsTotal: 0,
addSportsShow: false, // 添加运动弹窗显示
selectSports: {}, // 选择新增的运动
};
},
onShow() {
this.getList();
},
methods: {
// 编辑运动
editSport(item) {
this.selectSports = {
name: item.sport.name,
calory: item.sport.calory,
cover: item.sport.cover,
duration: item.duration,
sport_id: item.sport.sport_id,
exercise_id: item.exercise_id,
title: "编辑运动",
};
// console.log(this.selectSports);
console.log("编辑运动", item);
this.addSportsShow = true;
},
components: {
arprogress,
goodsList,
addFoods,
addPopup,
sports
},
data() {
return {
lists: [],
addShow: false, // 添加食品显示
selectGoods: [], // 选择新增的食品
addEatShow: false, // 加餐弹窗默认不显示
addEatList: [
{
name: '上午加餐',
type: 2
},
{
name: '下午加餐',
type: 4
},
{
name: '晚上加餐',
type: 6
}
],
today: moment(new Date()).format('YYYY-MM-DD'),
calorys: {}, // 当日食谱推荐页面的信息
intakes: [], // 当日摄入列表
sports: [], // 运动列表
sportsTotal: 0,
addSportsShow: false, // 添加运动弹窗显示
selectSports: {} // 选择新增的运动
};
},
onShow() {
this.getList();
},
methods: {
// 编辑运动
editSport(item) {
this.selectSports = {
name: item.sport.name,
calory: item.sport.calory,
cover: item.sport.cover,
duration: item.duration,
sport_id: item.sport.sport_id,
exercise_id: item.exercise_id,
title: '编辑运动'
};
// console.log(this.selectSports);
console.log('编辑运动', item);
this.addSportsShow = true;
},
// 弹窗确认按钮新增 这里接口报错了
comfirmSport(show, duration) {
let params = {
unit: "1", // 时间单位:分钟 1 小时 2
duration: duration, // 时常
exercise_id: this.selectSports.exercise_id, //
sport_id: this.selectSports.sport_id, // 运动id
date: this.today, // 日期
};
console.log(params);
editHealthSports(params).then((res) => {
this.addSportsShow = false;
this.selectSports = {};
this.getList();
});
console.log("弹窗确认按钮新增");
},
// 弹窗确认按钮新增 这里接口报错了
comfirmSport(show, duration) {
let params = {
unit: '1', // 时间单位:分钟 1 小时 2
duration: duration, // 时常
exercise_id: this.selectSports.exercise_id, //
sport_id: this.selectSports.sport_id, // 运动id
date: this.today // 日期
};
console.log(params);
editHealthSports(params).then(res => {
this.addSportsShow = false;
this.selectSports = {};
this.getList();
}).catch(err=>{
uni.showToast({
title:err.message,
icon:'none'
})
});
},
// 弹窗取消按钮
cancleSport(show) {
this.addSportsShow = show;
console.log("弹窗取消按钮");
},
// 删除运动
delSport() {
let params = {
exercise_id: this.selectSports.exercise_id, //
};
console.log(params);
delHealthSports(params).then((res) => {
this.addSportsShow = false;
this.selectSports = {};
this.getList();
});
},
// 长按删除触发事件运动
longClick(item) {
this.selectSports = item;
uni.showModal({
content: "确认删除么?",
confirmText: "确认删除",
confirmColor: "#34ce98",
cancelText: "再想想",
cancelColor: "#ddd",
success: (res) => {
if (res.confirm) {
this.delSport();
}
},
});
},
// 长按删除食品
longClickGoods(e) {
this.selectGoods = [e];
uni.showModal({
content: "确认删除么?",
confirmText: "确认删除",
confirmColor: "#34ce98",
cancelText: "再想想",
cancelColor: "#ddd",
success: (res) => {
if (res.confirm) {
this.delThis();
}
},
});
},
// 错误提示
errToast() {
uni.showToast({
title: "努力开发中~",
icon: "none",
});
},
getList() {
plans(this.today).then((res) => {
this.calorys = res.calorys;
this.calorys.ratio = Number(this.calorys.ratio);
this.intakes = res.intakes;
this.sports = res.exercises.lists;
this.sportsTotal = res.exercises.total;
});
},
// 底部按钮点击触发的事件 早餐1 午餐3 晚餐5 加餐(早2中4晚6)
tabbarClick(e) {
console.log(e);
this.tabarIndex = e;
if (e === 3) {
this.addEatShow = true;
} else {
if (e === 4) {
// 新增运动
uni.navigateTo({
url: `/pages/record/addExercises`,
});
} else {
uni.navigateTo({
url: `/pages/record/addFoods?type=${
e === 0 ? 1 : e === 1 ? 3 : 5
}`,
});
}
}
},
// 选择了加餐跳转
selectClick(e) {
uni.navigateTo({
url: `/pages/record/addFoods?type=${e.type}`,
});
// 选择加餐
},
// 编辑食品
editGoods(e) {
this.selectGoods = [e];
this.addShow = true;
},
closeHandle() {
//键盘关闭的回调函数
this.addShow = false;
},
// 监听点击键盘触发返回值新增食品
confirmHandle(value) {
// 新添加食物
let data = {
ser: 1,
weight: value,
food_id: this.selectGoods[0].food_id,
intake_id: this.selectGoods[0].intake_id,
};
this.editHealthFoods(data);
},
// 添加食物
editHealthFoods(data) {
editHealthFoods(data).then((res) => {
console.log(res);
this.addShow = false;
this.getList();
});
},
// 删除该食物
delThis(e) {
delHealthFoods(this.selectGoods[0].intake_id).then((res) => {
this.addShow = false;
this.getList();
});
},
// 跳转到食品详情
tabGoodsInfo(e) {
this.$Router.push({
name: "rankingDetails",
params: e,
});
},
},
// 弹窗取消按钮
cancleSport(show) {
this.addSportsShow = show;
},
// 删除运动
delSport() {
let params = {
exercise_id: this.selectSports.exercise_id //
};
console.log(params);
delHealthSports(params).then(res => {
this.addSportsShow = false;
this.selectSports = {};
this.getList();
});
},
// 长按删除触发事件运动
longClick(item) {
this.selectSports = item;
uni.showModal({
content: '确认删除么?',
confirmText: '确认删除',
confirmColor: '#34ce98',
cancelText: '再想想',
cancelColor: '#ddd',
success: res => {
if (res.confirm) {
this.delSport();
}
}
});
},
// 长按删除食品
longClickGoods(e) {
this.selectGoods = [e];
uni.showModal({
content: '确认删除么?',
confirmText: '确认删除',
confirmColor: '#34ce98',
cancelText: '再想想',
cancelColor: '#ddd',
success: res => {
if (res.confirm) {
this.delThis();
}
}
});
},
// 错误提示
errToast() {
uni.showToast({
title: '努力开发中~',
icon: 'none'
});
},
getList() {
plans(this.today).then(res => {
this.calorys = res.calorys;
this.calorys.ratio = Number(this.calorys.ratio);
this.intakes = res.intakes;
this.sports = res.exercises.lists;
this.sportsTotal = res.exercises.total;
});
},
// 底部按钮点击触发的事件 早餐1 午餐3 晚餐5 加餐(早2中4晚6)
tabbarClick(e) {
console.log(e);
this.tabarIndex = e;
if (e === 3) {
this.addEatShow = true;
} else {
if (e === 4) {
// 新增运动
uni.navigateTo({
url: `/pages/record/addExercises`
});
} else {
uni.navigateTo({
url: `/pages/record/addFoods?type=${e === 0 ? 1 : e === 1 ? 3 : 5}`
});
}
}
},
// 选择了加餐跳转
selectClick(e) {
uni.navigateTo({
url: `/pages/record/addFoods?type=${e.type}`
});
// 选择加餐
},
// 编辑食品
editGoods(e) {
this.selectGoods = [e];
this.addShow = true;
},
closeHandle() {
//键盘关闭的回调函数
this.addShow = false;
},
// 监听点击键盘触发返回值新增食品
confirmHandle(value) {
// 新添加食物
let data = {
ser: 1,
weight: value,
food_id: this.selectGoods[0].food_id,
intake_id: this.selectGoods[0].intake_id
};
this.editHealthFoods(data);
},
// 添加食物
editHealthFoods(data) {
editHealthFoods(data).then(res => {
console.log(res);
this.addShow = false;
this.getList();
});
},
// 删除该食物
delThis(e) {
delHealthFoods(this.selectGoods[0].intake_id).then(res => {
this.addShow = false;
this.getList();
});
},
// 跳转到食品详情
tabGoodsInfo(e) {
this.$Router.push({
name: 'rankingDetails',
params: e
});
}
}
};
</script>
<style lang="scss" scoped>
.record--foods {
padding: $padding $padding $padding * 7 $padding;
// background: green;
padding: $padding $padding $padding * 7 $padding;
// background: green;
}
// 饮食进度条
.cricle-content {
box-shadow: 0 0 4rpx 4rpx rgba($color: $main-color, $alpha: 0.1);
font-size: $title-size-m - 6;
padding: $padding * 1.8 $padding;
border-radius: $radius;
color: $text-gray-m;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
box-sizing: border-box;
position: relative;
.cricle {
.num {
color: $text-color;
font-size: $title-size * 1.8;
font-weight: bold;
padding: $padding * 0.2;
}
.num1 {
color: #f00;
}
}
.info {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
span {
font-size: $title-size + 10;
font-weight: bold;
color: $text-color;
padding-top: $padding * 0.5;
}
}
.ic-left {
position: absolute;
left: 0;
top: 0;
background-image: linear-gradient(to right, #ffebb9, #fbd57b);
color: #664710;
padding: 10rpx $padding * 0.6;
border-radius: 0 0 $radius 0;
}
.ic-day {
position: absolute;
right: $padding;
top: $padding;
}
box-shadow: 0 0 4rpx 4rpx rgba($color: $main-color, $alpha: 0.1);
font-size: $title-size-m - 6;
padding: $padding * 1.8 $padding;
border-radius: $radius;
color: $text-gray-m;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
box-sizing: border-box;
position: relative;
.cricle {
.num {
color: $text-color;
font-size: $title-size * 1.8;
font-weight: bold;
padding: $padding * 0.2;
}
.num1 {
color: #f00;
}
}
.info {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
span {
font-size: $title-size + 10;
font-weight: bold;
color: $text-color;
padding-top: $padding * 0.5;
}
}
.ic-left {
position: absolute;
left: 0;
top: 0;
background-image: linear-gradient(to right, #ffebb9, #fbd57b);
color: #664710;
padding: 10rpx $padding * 0.6;
border-radius: 0 0 $radius 0;
}
.ic-day {
position: absolute;
right: $padding;
top: $padding;
}
}
// 没有饮食记录
.no-foods {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m - 4;
color: $text-gray-m;
min-height: 40vh;
// background: pink;
.no-foods-img {
opacity: 0.5;
}
view {
padding: $padding * 0.2;
}
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m - 4;
color: $text-gray-m;
min-height: 40vh;
// background: pink;
.no-foods-img {
opacity: 0.5;
}
view {
padding: $padding * 0.2;
}
}
// 饮食记录 早中晚加餐等
.foods-add {
border-bottom: solid 1rpx #f7f7f7;
margin-top: $margin;
border-bottom: solid 1rpx #f7f7f7;
margin-top: $margin;
}
// 主标题
.foods-title {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
color: $text-color;
padding: $padding * 0.5 0;
.title-left {
font-size: $title-size;
color: $text-color;
font-weight: bold;
span {
font-weight: normal;
font-size: $title-size-m - 6;
color: $text-gray-m;
margin-left: $margin - 10;
}
}
.title-right {
font-size: $title-size-m - 6;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
color: $main-color;
.dw {
margin: 0 $margin * 0.6 0 $margin * 0.4;
color: $text-gray;
}
}
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
color: $text-color;
padding: $padding * 0.5 0;
.title-left {
font-size: $title-size;
color: $text-color;
font-weight: bold;
span {
font-weight: normal;
font-size: $title-size-m - 6;
color: $text-gray-m;
margin-left: $margin - 10;
}
}
.title-right {
font-size: $title-size-m - 6;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
color: $main-color;
.dw {
margin: 0 $margin * 0.6 0 $margin * 0.4;
color: $text-gray;
}
}
}
</style>

View File

@@ -38,9 +38,9 @@ class Utils {
}
}
Utils.log(primaryKeyArr.length);
if (primaryKeyArr.length >= 1) {
if (primaryKeyArr.length>=1) {
sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')}, PRIMARY KEY (${primaryKeyArr.join()}))`;
} else {
}else{
sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')})`;
}
Utils.log(`modelSql :${sql}`);
@@ -223,7 +223,7 @@ class Model {
} else if (options.constructor == Object) {
let keys = [];
let values = [];
let index = arguments[3] ?? null;
let index = arguments[3]??null;
for (var key in options) {
keys.push(key);
values.push(`'${options[key]}'`);
@@ -236,13 +236,13 @@ class Model {
name: config.name,
sql: sql,
success(e) {
if (index) {
if(index){
callback(null, e, options, index);
}
callback(null, e, options);
},
fail(e) {
if (index) {
if(index){
callback(e, null, options, index);
}
callback(e, null, options);