470 lines
11 KiB
Vue
470 lines
11 KiB
Vue
|
|
<template>
|
|||
|
|
<view class="content-box">
|
|||
|
|
<!-- 日期选择 -->
|
|||
|
|
<view class="data">
|
|||
|
|
<picker mode="date" :end="endDate" @change="changeClickDate" :value="data?data:endDate">
|
|||
|
|
<view>
|
|||
|
|
{{data?data:"请选择"}}
|
|||
|
|
<image src="/static/qie.png"></image>
|
|||
|
|
</view>
|
|||
|
|
</picker>
|
|||
|
|
</view>
|
|||
|
|
|
|||
|
|
<!-- 称重 -->
|
|||
|
|
<view class="blue-tooth" v-if="user.aud_id!=''">
|
|||
|
|
<blue-tooth :btnType="'1'"></blue-tooth>
|
|||
|
|
</view>
|
|||
|
|
<!-- 能量摄入 -->
|
|||
|
|
<view class="everyDay">
|
|||
|
|
<view class="title">
|
|||
|
|
<view><text class="quan"></text>热量摄入</view>
|
|||
|
|
<view class="icon" @click="handleSet">
|
|||
|
|
<uni-icons type="gear" size="26"></uni-icons>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<view class="jishiqi">
|
|||
|
|
<view class="left">
|
|||
|
|
<view class="chart-wrap">
|
|||
|
|
<qiun-data-charts type="arcbar" :chartData="chartData" :cHeight="280" :cWidth="280"
|
|||
|
|
:canvas2d="true" canvasId="countCharts" v-if="handTrue" />
|
|||
|
|
<view class="center">
|
|||
|
|
摄入
|
|||
|
|
<text>{{foodInfo.nutrients_four[0].today_intake}}</text>
|
|||
|
|
<view class="unit">Kcal</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<view class="mubiao">
|
|||
|
|
目标:<text>{{foodInfo.nutrients_four[0].suggestion}}</text>kcal
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<view class="right">
|
|||
|
|
<view class="item" v-for="(ite,ind) in foodInfo.nutrients_four.slice(1)">
|
|||
|
|
<view class="left-icon">
|
|||
|
|
<image :src="ite.icon"></image>
|
|||
|
|
<view class="val" :style="{color:ite.color}">{{ite.proportion_fp||0}}%</view>
|
|||
|
|
</view>
|
|||
|
|
<view class="right-info">
|
|||
|
|
<view class="right-info-top">
|
|||
|
|
<text class="name">{{ite.name}}</text>
|
|||
|
|
<text class="">
|
|||
|
|
{{ite.today_intake||0}}/{{ite.suggestion||0}}g
|
|||
|
|
</text>
|
|||
|
|
</view>
|
|||
|
|
<view class="right-info-bottom">
|
|||
|
|
<view class="val" :style="{ width: ite.proportion + '%',background:ite.color}">
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<!-- 早午晚餐 -->
|
|||
|
|
<view class="foodtools">
|
|||
|
|
<view class="type" v-for="(item,index) in foodInfo.list">
|
|||
|
|
<view class="title" @click="handledetail(index)">
|
|||
|
|
<view class="text">
|
|||
|
|
<image :src="item.icon"></image>
|
|||
|
|
<view>{{item.name}}</view>
|
|||
|
|
<text>{{item.val}}{{item.unit}}</text>
|
|||
|
|
</view>
|
|||
|
|
<view class="detail">
|
|||
|
|
餐食详情
|
|||
|
|
<uni-icons type="forward" size="20" color="#999"></uni-icons>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<view class="list">
|
|||
|
|
<uni-swipe-action>
|
|||
|
|
<uni-swipe-action-item v-for="(ite,ind) in item.list" :key="ind" :right-options="actionOptions"
|
|||
|
|
@click="delAcitionItem(ite)">
|
|||
|
|
<view class="item" @click="showFoodDetail(ite)">
|
|||
|
|
<image :src="ite.pic_url" mode="aspectFill"></image>
|
|||
|
|
<view class="weight">
|
|||
|
|
<view>{{ite.name}}</view>
|
|||
|
|
<view class="size12 c999">{{ite.weight}}<text>|</text>{{ite.val}}kcal</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</uni-swipe-action-item>
|
|||
|
|
</uni-swipe-action>
|
|||
|
|
<view class="add" @click="handleAddFood(item.name)">
|
|||
|
|
<text>+</text>添加食物
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<view class="fenxi" @click="navTo('/Food/count/everyDay?page=count')">
|
|||
|
|
<image src="/static/fenxi.png"></image>
|
|||
|
|
营养分析
|
|||
|
|
</view>
|
|||
|
|
|
|||
|
|
<!-- 搜索 -->
|
|||
|
|
<view class="serachBox">
|
|||
|
|
<view class="title">
|
|||
|
|
<view class="quan mr-5"></view>教你做
|
|||
|
|
</view>
|
|||
|
|
<view class="searchInput">
|
|||
|
|
<div class="search-wrap" @click="navTo('/Food/search/search')">
|
|||
|
|
<text>输入食材快速搜索菜谱</text>
|
|||
|
|
<image src="/static/28.png"></image>
|
|||
|
|
</div>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<!-- 营养含量分析 -->
|
|||
|
|
<view v-if="drawerVisible" class="drawerVisible">
|
|||
|
|
<view class="bgVisible" @click="handleDrawerClose"></view>
|
|||
|
|
<view class="infoVisible">
|
|||
|
|
<scroll-view style="height: 100%;" scroll-y="true">
|
|||
|
|
<view class="foodDetail">
|
|||
|
|
<view class="foodInfo">
|
|||
|
|
<image :src="activeFoodDetail.pic_url" mode="aspectFill"></image>
|
|||
|
|
<view class="info">
|
|||
|
|
<view class="name">{{activeFoodDetail.name}}</view>
|
|||
|
|
<view class="kcal">{{activeFoodDetail.val}}千卡</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<view class="foodContent">
|
|||
|
|
<view class="title">热量和营养</view>
|
|||
|
|
<view class="progress">
|
|||
|
|
<div class="chart-wrap">
|
|||
|
|
<qiun-data-charts v-if="chartVisible" type="ring" :opts="opts"
|
|||
|
|
:chartData="chartData2" :cHeight="280" :cWidth="280" />
|
|||
|
|
</div>
|
|||
|
|
<view class="info" v-if="activeFoodDetail.nutrients_four">
|
|||
|
|
<view class="info-item"
|
|||
|
|
v-for="(item,index) in activeFoodDetail.nutrients_four.slice(1)" :key="index">
|
|||
|
|
<view class="color" :style="{'background-color':`${item.color}`}">
|
|||
|
|
</view>
|
|||
|
|
<view>{{item.name}}:{{item.proportion}}%</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<view class="tips">
|
|||
|
|
<text>营养素</text>
|
|||
|
|
<text>{{activeFoodDetail.weight}}含量</text>
|
|||
|
|
</view>
|
|||
|
|
<view class="foodDetailList">
|
|||
|
|
<view class="foodDetailItem" v-for="(item,index) in activeFoodDetail.nutrients_list"
|
|||
|
|
:key="index">
|
|||
|
|
<view class="name">{{item.name_ch}}</view>
|
|||
|
|
<view class="value">{{item.value}}{{item.unit}}
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</scroll-view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
<script>
|
|||
|
|
import {
|
|||
|
|
mapState
|
|||
|
|
} from "vuex";
|
|||
|
|
import blueTooth from "@/components/foodIndex/bluetooth_food.vue"
|
|||
|
|
import qiunDataCharts from '@/uni_modules/qiun-data-charts/components/qiun-data-charts.vue';
|
|||
|
|
export default {
|
|||
|
|
name: "food",
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
token: "",
|
|||
|
|
index: 0,
|
|||
|
|
opts: {
|
|||
|
|
background: "transparent",
|
|||
|
|
title: {
|
|||
|
|
name: "",
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
chartData: {
|
|||
|
|
series: [{
|
|||
|
|
data: 0,
|
|||
|
|
color: "#3CB383"
|
|||
|
|
}]
|
|||
|
|
},
|
|||
|
|
data: '',
|
|||
|
|
isBle: true,
|
|||
|
|
handTrue: false,
|
|||
|
|
chartData2: {},
|
|||
|
|
activeFoodDetail: {},
|
|||
|
|
drawerVisible: false,
|
|||
|
|
chartVisible: false, // 单独控制图表显示
|
|||
|
|
actionOptions: [{
|
|||
|
|
text: '删除',
|
|||
|
|
style: {
|
|||
|
|
backgroundColor: '#dd524d',
|
|||
|
|
borderRadius: '10rpx'
|
|||
|
|
}
|
|||
|
|
}]
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
components: {
|
|||
|
|
blueTooth,
|
|||
|
|
qiunDataCharts
|
|||
|
|
},
|
|||
|
|
computed: {
|
|||
|
|
...mapState(["configInfo", "user", "countFoodInfo", "bleValue"]),
|
|||
|
|
info() {
|
|||
|
|
return this.user
|
|||
|
|
},
|
|||
|
|
kcalVal() {
|
|||
|
|
return this.configInfo.kcal_data
|
|||
|
|
},
|
|||
|
|
endDate() {
|
|||
|
|
return this.$tools.getDate("start")
|
|||
|
|
},
|
|||
|
|
foodInfo() {
|
|||
|
|
let that = this
|
|||
|
|
this.handTrue = false
|
|||
|
|
that.$nextTick(() => {
|
|||
|
|
that.handTrue = true
|
|||
|
|
that.chartData.series[0].data = that.user.aud_id ? Number(that.countFoodInfo.nutrients_four[0]
|
|||
|
|
.proportion) / 100 : 0
|
|||
|
|
})
|
|||
|
|
that.data = that.user.aud_id ? that.countFoodInfo.date : that.$tools.getDate("start")
|
|||
|
|
return that.user.aud_id ? that.countFoodInfo : that.configInfo.default_count_foot
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
// 详情
|
|||
|
|
showFoodDetail(item) {
|
|||
|
|
console.log("item", item)
|
|||
|
|
let that = this
|
|||
|
|
let chart_data = []
|
|||
|
|
that.drawerVisible = true;
|
|||
|
|
that.opts.color = []
|
|||
|
|
that.activeFoodDetail = item
|
|||
|
|
for (let i = 1; i < item.nutrients_four.length; ++i) {
|
|||
|
|
that.opts.color.push(item.nutrients_four[i].color)
|
|||
|
|
chart_data.push({
|
|||
|
|
name: item.nutrients_four[i].name,
|
|||
|
|
value: Number(item.nutrients_four[i].proportion),
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
that.opts.title.name = that.activeFoodDetail.val
|
|||
|
|
that.chartData2 = JSON.parse(JSON.stringify({
|
|||
|
|
series: [{
|
|||
|
|
data: chart_data
|
|||
|
|
}]
|
|||
|
|
}));
|
|||
|
|
that.$nextTick(() => {
|
|||
|
|
// 延迟显示图表,确保容器已渲染
|
|||
|
|
setTimeout(() => {
|
|||
|
|
that.chartVisible = true
|
|||
|
|
}, 100)
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
// 餐食详情
|
|||
|
|
handledetail(index) {
|
|||
|
|
uni.navigateTo({
|
|||
|
|
url: "/Food/count/everyMeal?index=" + index
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
// 设置
|
|||
|
|
handleSet() {
|
|||
|
|
uni.navigateTo({
|
|||
|
|
url: "/Food/count/setting"
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
changeClickDate(e) {
|
|||
|
|
this.data = e.detail.value
|
|||
|
|
this.$store.dispatch("getCountFoodInfo", {
|
|||
|
|
aud_id: this.info.aud_id,
|
|||
|
|
time: e.detail.value
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
// 添加食物
|
|||
|
|
handleAddFood(name) {
|
|||
|
|
this.isShow = false
|
|||
|
|
uni.navigateTo({
|
|||
|
|
url: "/Food/count/search?name=" + name + "&time=" + this.date
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
// 功能页面跳转
|
|||
|
|
navTo(url) {
|
|||
|
|
uni.navigateTo({
|
|||
|
|
url
|
|||
|
|
})
|
|||
|
|
},
|
|||
|
|
handleDrawerClose() {
|
|||
|
|
// 先隐藏图表,再隐藏抽屉
|
|||
|
|
this.chartVisible = false
|
|||
|
|
this.drawerVisible = false;
|
|||
|
|
},
|
|||
|
|
// 删除食材
|
|||
|
|
delAcitionItem(item) {
|
|||
|
|
let that = this
|
|||
|
|
uni.showModal({
|
|||
|
|
content: `是否删除[${item.name}]?`,
|
|||
|
|
success: (res) => {
|
|||
|
|
if (res.confirm) {
|
|||
|
|
this.$model.delCEatAction({
|
|||
|
|
aud_id: that.info.aud_id,
|
|||
|
|
eat_log_id: item.id
|
|||
|
|
}).then(res => {
|
|||
|
|
// 删除最新一天食物
|
|||
|
|
if (that.foodInfo.date == that.info.food_count.date) {
|
|||
|
|
that.$store.dispatch("getUserInfoFood")
|
|||
|
|
} else {
|
|||
|
|
that.$store.dispatch("getCountFoodInfo", {
|
|||
|
|
aud_id: that.info.aud_id,
|
|||
|
|
time: that.foodInfo.date
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<style lang="scss" scoped>
|
|||
|
|
.content-box {
|
|||
|
|
padding-top: 15px;
|
|||
|
|
padding-bottom: 15px;
|
|||
|
|
background: #f7f7f7;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.serachBox {
|
|||
|
|
position: initial;
|
|||
|
|
margin-bottom: 10px;
|
|||
|
|
height: auto;
|
|||
|
|
overflow: hidden;
|
|||
|
|
|
|||
|
|
.searchInput {
|
|||
|
|
background: #fff;
|
|||
|
|
padding: 10px;
|
|||
|
|
width: calc(100% - 20px);
|
|||
|
|
position: initial;
|
|||
|
|
margin: 10px 0;
|
|||
|
|
border-radius: 10px;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.data {
|
|||
|
|
width: 100%;
|
|||
|
|
background: #fff;
|
|||
|
|
height: 90rpx;
|
|||
|
|
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
|
|||
|
|
margin: 10px;
|
|||
|
|
width: calc(100% - 20px);
|
|||
|
|
border-radius: 10px;
|
|||
|
|
margin-top: 0;
|
|||
|
|
|
|||
|
|
picker {
|
|||
|
|
display: flex;
|
|||
|
|
width: 100%;
|
|||
|
|
height: 90rpx;
|
|||
|
|
position: relative;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
font-weight: bold;
|
|||
|
|
|
|||
|
|
view {
|
|||
|
|
width: 100%;
|
|||
|
|
position: absolute;
|
|||
|
|
left: 0;
|
|||
|
|
top: 0;
|
|||
|
|
display: flex;
|
|||
|
|
bottom: 0;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
image {
|
|||
|
|
width: 30rpx;
|
|||
|
|
height: 30rpx;
|
|||
|
|
margin-left: 10px;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.blue-tooth {
|
|||
|
|
padding: 10px;
|
|||
|
|
background: #fff;
|
|||
|
|
border-radius: 10px;
|
|||
|
|
margin: 0 10px;
|
|||
|
|
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.foodtools {
|
|||
|
|
margin-top: 30rpx;
|
|||
|
|
|
|||
|
|
.type {
|
|||
|
|
background: #fff;
|
|||
|
|
border-radius: 20rpx;
|
|||
|
|
padding: 20rpx;
|
|||
|
|
margin: 0 20rpx 20rpx;
|
|||
|
|
|
|||
|
|
.title {
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: space-between;
|
|||
|
|
|
|||
|
|
image {
|
|||
|
|
width: 60rpx;
|
|||
|
|
height: 60rpx;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.text {
|
|||
|
|
width: 50%;
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
|
|||
|
|
view {
|
|||
|
|
font-size: 32rpx;
|
|||
|
|
font-weight: bold;
|
|||
|
|
margin: 0 20rpx;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.detail {
|
|||
|
|
color: #999;
|
|||
|
|
display: flex;
|
|||
|
|
font-size: 24rpx;
|
|||
|
|
align-items: center;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.list {
|
|||
|
|
width: 100%;
|
|||
|
|
margin-top: 30rpx;
|
|||
|
|
|
|||
|
|
.item {
|
|||
|
|
display: flex;
|
|||
|
|
padding: 20rpx 0;
|
|||
|
|
border-bottom: 1px solid #f7f7f7;
|
|||
|
|
|
|||
|
|
image {
|
|||
|
|
width: 90rpx;
|
|||
|
|
height: 90rpx;
|
|||
|
|
border-radius: 50%;
|
|||
|
|
border: 1px solid #f7f7f7;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.weight {
|
|||
|
|
display: flex;
|
|||
|
|
flex-direction: column;
|
|||
|
|
justify-content: space-between;
|
|||
|
|
margin-left: 20rpx;
|
|||
|
|
|
|||
|
|
text {
|
|||
|
|
margin: 0 20rpx;
|
|||
|
|
color: #dfdfdf;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.add {
|
|||
|
|
width: 100%;
|
|||
|
|
margin-top: 20rpx;
|
|||
|
|
text-align: center;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
</style>
|