kitchendDevice/pages/count/count.vue

590 lines
13 KiB
Vue
Raw Normal View History

2023-09-08 15:17:21 +08:00
<template>
<view class="content">
2025-04-02 09:49:39 +08:00
<view v-if="!token" class="list2" @click="handleLogin()">
<view class="nolist">
<icon class="iconfont icon-zanwushuju"></icon>
<text>登录后查看更多哦</text>
2023-09-08 15:17:21 +08:00
</view>
2025-04-02 09:49:39 +08:00
<view class="btn">登录</view>
</view>
<view v-else class="content_box">
2025-11-25 14:21:22 +08:00
<!-- 称重 -->
<view class="blue-tooth">
<blue-tooth :weightType="'2'" :btnType="'1'"></blue-tooth>
2025-11-08 16:50:26 +08:00
</view>
2025-11-25 14:21:22 +08:00
<!-- 每日摄入 -->
2025-11-26 17:32:18 +08:00
<view class="box" v-if="user.aud_id!=''">
2025-11-25 14:21:22 +08:00
<!-- 日期选择 -->
<view class="data">
<picker mode="date" :end="endDate" @change="changeClickDate"
:value="foodInfo.date?foodInfo.date:endDate">
<view>
{{foodInfo.date?foodInfo.date:"请选择"}}
<image src="/static/qie.png"></image>
2023-09-08 15:17:21 +08:00
</view>
2025-11-25 14:21:22 +08:00
</picker>
2023-09-08 15:17:21 +08:00
</view>
2025-11-25 14:21:22 +08:00
<!-- 能量摄入 -->
<view class="everyDay">
<view class="title">
<view>热量摄入</view>
<view class="icon" @click="handleSet">
<icon class="iconfont icon-shezhi1"></icon>
2025-04-02 09:49:39 +08:00
</view>
2023-09-08 15:17:21 +08:00
</view>
2025-11-25 14:21:22 +08:00
<view class="jishiqi">
<view class="left">
<view class="chart-wrap">
<qiun-data-charts type="arcbar" :chartData="chartData" :cHeight="280" :cWidth="280"
:canvas2d="true" canvasId="count1" />
<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>
2025-04-02 09:49:39 +08:00
</view>
2025-11-25 14:21:22 +08:00
<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>
2025-04-02 09:49:39 +08:00
</view>
2023-09-08 15:17:21 +08:00
</view>
</view>
2025-11-25 14:21:22 +08:00
<!-- 早午晚餐 -->
<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>
2025-11-08 16:50:26 +08:00
</view>
2025-11-25 14:21:22 +08:00
</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>
2025-11-08 16:50:26 +08:00
</view>
2025-11-25 14:21:22 +08:00
</view>
</uni-swipe-action-item>
</uni-swipe-action>
<view class="add" @click="handleAddFood(item.name)">
<text>+</text>添加食物
2025-04-02 09:49:39 +08:00
</view>
2023-09-08 15:17:21 +08:00
</view>
</view>
2025-04-02 09:49:39 +08:00
</view>
2023-09-08 15:17:21 +08:00
</view>
2025-04-02 09:49:39 +08:00
<view v-else class="list2" @click="handleEditUser()">
<view class="nolist">
2025-11-08 16:50:26 +08:00
<image src="/static/none.png"></image>
2025-04-02 09:49:39 +08:00
<text>完善资料后记录更准确哦</text>
</view>
<view class="btn">完善资料</view>
2023-09-08 15:17:21 +08:00
</view>
2025-11-25 14:21:22 +08:00
<view class="fenxi" @click="navTo('/pageTwo/count/everyDay?page=count')">
<image src="/static/fenxi.png"></image>
营养分析
2023-09-08 15:17:21 +08:00
</view>
</view>
2025-11-25 14:21:22 +08:00
2025-09-17 14:55:24 +08:00
<!-- 营养含量分析 -->
<uni-drawer ref="showRight" mode="right" width="300">
<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">
2025-11-25 14:21:22 +08:00
<qiun-data-charts type="ring" :opts="opts" :chartData="chartData2" :cHeight="280"
2025-11-26 17:32:18 +08:00
:cWidth="280" :canvas2d="true" canvasId="count2"/>
2025-09-17 14:55:24 +08:00
</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">
2025-11-25 14:21:22 +08:00
<view class="color" :style="{'background-color':`${item.color}`}">
</view>
2025-09-17 14:55:24 +08:00
<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>
</uni-drawer>
2023-09-08 15:17:21 +08:00
</view>
</template>
<script>
import {
mapState
} from "vuex";
2025-11-25 14:21:22 +08:00
import blueTooth from "../../components/bluetooth_food.vue"
2023-09-08 15:17:21 +08:00
import qiunDataCharts from '@/uni_modules/qiun-data-charts/components/qiun-data-charts.vue';
export default {
data() {
return {
2025-04-02 09:49:39 +08:00
token: "",
2025-11-08 16:50:26 +08:00
index: 0,
2025-09-17 14:55:24 +08:00
opts: {
background: "transparent",
title: {
name: "",
},
},
2025-11-25 14:21:22 +08:00
chartData: {
series: [{
data: 0,
color: "#3CB383"
}]
2023-09-08 15:17:21 +08:00
},
2025-11-25 14:21:22 +08:00
isBle: true,
// countWeight: 0,
chartData2: {},
2025-09-17 14:55:24 +08:00
activeFoodDetail: {},
actionOptions: [{
text: '删除',
style: {
backgroundColor: '#dd524d',
borderRadius: '10rpx'
}
}]
2023-09-08 15:17:21 +08:00
}
},
components: {
2025-11-25 14:21:22 +08:00
blueTooth,
2023-09-08 15:17:21 +08:00
qiunDataCharts
},
computed: {
2025-11-08 16:50:26 +08:00
...mapState(["user", "countFoodInfo"]),
foodInfo() {
2025-11-25 14:21:22 +08:00
let that = this
that.chartData.series[0].data = that.countFoodInfo.nutrients_four[0].proportion / 100
return that.countFoodInfo
},
endDate() {
return this.$tools.getDate("start")
},
2023-09-08 15:17:21 +08:00
},
2025-11-25 14:21:22 +08:00
onShow() {
2023-09-08 15:17:21 +08:00
let that = this
2025-04-02 09:49:39 +08:00
that.token = uni.getStorageSync('token')
2023-09-08 15:17:21 +08:00
},
methods: {
2025-11-08 16:50:26 +08:00
// 详情
2025-09-17 14:55:24 +08:00
showFoodDetail(item) {
console.log("item", item)
2025-11-25 14:21:22 +08:00
let that = this
2025-11-08 16:50:26 +08:00
let chart_data = []
2025-09-17 14:55:24 +08:00
this.$refs.showRight.open();
2025-11-25 14:21:22 +08:00
that.opts.color = []
that.activeFoodDetail = item
2025-09-17 14:55:24 +08:00
for (let i = 1; i < item.nutrients_four.length; ++i) {
2025-11-25 14:21:22 +08:00
that.opts.color.push(item.nutrients_four[i].color)
2025-09-17 14:55:24 +08:00
chart_data.push({
name: item.nutrients_four[i].name,
value: Number(item.nutrients_four[i].proportion),
})
}
2025-11-25 14:21:22 +08:00
that.opts.title.name = that.activeFoodDetail.val
that.chartData2 = JSON.parse(JSON.stringify({
2025-09-17 14:55:24 +08:00
series: [{
data: chart_data
}]
}));
},
2025-11-25 14:21:22 +08:00
changeClickDate(e) {
this.$store.dispatch("getCountFoodInfo", {
aud_id: this.user.aud_id,
time: e.detail.value
})
},
// 餐食详情
handledetail(index) {
uni.navigateTo({
url: "/pageTwo/count/everyMeal?page=count&index=" + index
})
2023-09-08 15:17:21 +08:00
},
// 设置
handleSet() {
uni.navigateTo({
url: "/pageTwo/count/setting"
})
},
// 完善资料
handleEditUser() {
uni.navigateTo({
url: "/pageTwo/me/userEdit?type=add"
})
},
// 添加食物
2025-11-25 14:21:22 +08:00
handleAddFood(name) {
2023-09-08 15:17:21 +08:00
this.isShow = false
uni.navigateTo({
2025-11-25 14:21:22 +08:00
url: "/pageTwo/count/search?name=" + name + "&time=" + this.foodInfo.date
2023-09-08 15:17:21 +08:00
})
2025-04-02 09:49:39 +08:00
},
// 去登录
handleLogin() {
uni.reLaunch({
url: "/pageTwo/login/login"
})
2025-09-04 17:33:41 +08:00
},
2025-11-25 14:21:22 +08:00
// 功能页面跳转
navTo(url) {
uni.navigateTo({
url
})
},
// 删除食材
2025-09-17 14:55:24 +08:00
delAcitionItem(item) {
2025-11-25 14:21:22 +08:00
let that = this
2025-09-17 14:55:24 +08:00
uni.showModal({
content: `是否删除[${item.name}]`,
success: (res) => {
if (res.confirm) {
this.$model.delCEatAction({
2025-11-25 14:21:22 +08:00
aud_id: that.user.aud_id,
2025-09-17 14:55:24 +08:00
eat_log_id: item.id
}).then(res => {
2025-11-25 14:21:22 +08:00
that.$store.dispatch("getCountFoodInfo", {
aud_id: that.user.aud_id,
time: that.foodInfo.date
})
// 删除最新一天食物
if (that.foodInfo.date == that.user.food_count.date) {
that.$store.dispatch("getUserInfo")
}
2025-09-17 14:55:24 +08:00
})
}
}
})
}
2023-09-08 15:17:21 +08:00
}
}
</script>
<style scoped lang="scss">
.content {
2025-11-25 14:21:22 +08:00
padding: 0 20rpx;
2023-09-08 15:17:21 +08:00
}
2025-09-17 14:55:24 +08:00
.content_box {
2025-04-02 09:49:39 +08:00
width: 100%;
2025-11-25 14:21:22 +08:00
padding-top: 90rpx;
2025-04-02 09:49:39 +08:00
}
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
.blue-tooth {
padding: 15px;
2023-09-08 15:17:21 +08:00
background: #fff;
2025-11-08 16:50:26 +08:00
border-radius: 10px;
margin-top: 15px;
2025-11-25 14:21:22 +08:00
}
.data {
width: 100%;
background: #fff;
height: 90rpx;
position: fixed;
top: 0;
z-index: 999;
right: 0;
2025-11-08 16:50:26 +08:00
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
picker {
2025-11-08 16:50:26 +08:00
display: flex;
2025-11-25 14:21:22 +08:00
width: 100%;
height: 90rpx;
position: relative;
2025-11-08 16:50:26 +08:00
align-items: center;
2025-11-25 14:21:22 +08:00
justify-content: center;
font-weight: bold;
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
view {
width: 100%;
2023-09-08 15:17:21 +08:00
position: absolute;
2025-11-25 14:21:22 +08:00
left: 0;
top: 0;
2023-09-08 15:17:21 +08:00
display: flex;
2025-11-25 14:21:22 +08:00
bottom: 0;
2025-11-08 16:50:26 +08:00
align-items: center;
justify-content: center;
}
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
image {
width: 30rpx;
height: 30rpx;
margin-left: 10px;
2023-09-08 15:17:21 +08:00
}
}
2025-11-25 14:21:22 +08:00
2023-09-08 15:17:21 +08:00
}
2025-11-25 14:21:22 +08:00
.chart-wrap {
position: relative;
width: 250rpx;
height: 250rpx;
margin-top: -30rpx;
margin-left: -5px;
2023-09-08 15:17:21 +08:00
display: flex;
2025-11-25 14:21:22 +08:00
flex-wrap: wrap;
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
.center {
border: none;
width: 280rpx;
height: 210rpx;
position: absolute;
top: 64rpx;
2023-09-08 15:17:21 +08:00
}
}
2025-11-25 14:21:22 +08:00
.everyDay {
background: #fff;
padding: 20rpx 20rpx 30rpx;
border-radius: 20rpx;
margin-top: 30rpx;
height: auto;
overflow: hidden;
2025-11-08 16:50:26 +08:00
2025-11-25 14:21:22 +08:00
.title {
2025-11-08 16:50:26 +08:00
display: flex;
justify-content: space-between;
2025-11-25 14:21:22 +08:00
font-weight: bold;
font-size: 30rpx;
2025-11-08 16:50:26 +08:00
2025-11-25 14:21:22 +08:00
.quan {
margin-right: 70rpx;
2025-11-08 16:50:26 +08:00
}
}
}
2025-11-25 14:21:22 +08:00
.foodtools {
margin-top: 30rpx;
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
.type {
background: #fff;
margin-bottom: 20rpx;
border-radius: 20rpx;
padding: 20rpx;
2023-09-08 15:17:21 +08:00
.title {
display: flex;
2025-09-17 14:55:24 +08:00
align-items: center;
2025-11-25 14:21:22 +08:00
justify-content: space-between;
2025-09-17 14:55:24 +08:00
image {
width: 60rpx;
height: 60rpx;
}
2025-11-25 14:21:22 +08:00
.text {
width: 50%;
display: flex;
align-items: center;
2025-03-25 10:17:30 +08:00
2025-11-25 14:21:22 +08:00
view {
font-size: 32rpx;
font-weight: bold;
margin: 0 20rpx;
}
2025-09-04 17:33:41 +08:00
}
2025-11-25 14:21:22 +08:00
.detail {
color: #999;
display: flex;
font-size: 24rpx;
align-items: center;
2023-09-08 15:17:21 +08:00
}
}
2025-11-08 16:50:26 +08:00
2025-11-25 14:21:22 +08:00
.list {
width: 100%;
margin-top: 30rpx;
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
.item {
display: flex;
padding: 20rpx 0;
border-bottom: 1px solid #f7f7f7;
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
image {
width: 90rpx;
height: 90rpx;
border-radius: 50%;
border: 1px solid #f7f7f7;
}
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
.weight {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-left: 20rpx;
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
text {
margin: 0 20rpx;
color: #dfdfdf;
}
}
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
}
2023-09-08 15:17:21 +08:00
}
2025-11-25 14:21:22 +08:00
.add {
2023-09-08 15:17:21 +08:00
width: 100%;
2025-11-25 14:21:22 +08:00
margin-top: 20rpx;
2023-09-08 15:17:21 +08:00
text-align: center;
}
2025-11-25 14:21:22 +08:00
}
}
2023-09-08 15:17:21 +08:00
2025-11-25 14:21:22 +08:00
.set {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
font-size: 32rpx;
font-weight: bold;
.icon {
background: #d1f2ed;
border-radius: 50%;
font-size: 56rpx;
color: #66cccc;
text-align: center;
padding: 10rpx;
2023-09-08 15:17:21 +08:00
}
}
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
.tools {
width: 100%;
background: #fff;
border-radius: 20rpx;
padding: 20rpx 0;
display: flex;
margin-bottom: 30rpx;
justify-content: space-between;
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
.type {
width: 20%;
2025-09-17 14:55:24 +08:00
display: flex;
2025-11-25 14:21:22 +08:00
flex-wrap: wrap;
align-items: center;
justify-content: center;
2025-09-17 14:55:24 +08:00
image {
width: 90rpx;
height: 90rpx;
2025-11-25 14:21:22 +08:00
border-radius: 50%;
border: 1px solid #f7f7f7;
2025-09-17 14:55:24 +08:00
}
2025-11-25 14:21:22 +08:00
.text {
width: 100%;
text-align: center;
2025-09-17 14:55:24 +08:00
display: flex;
justify-content: center;
2025-11-25 14:21:22 +08:00
font-weight: bold;
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
icon {
2025-09-17 14:55:24 +08:00
font-size: 28rpx;
}
}
}
2025-11-25 14:21:22 +08:00
}
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
.nolist {
font-size: 24rpx;
color: #999;
padding: 60rpx 20rpx;
text-align: center;
width: auto;
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
image {
width: 100rpx;
height: 100rpx;
color: #999;
display: flex;
justify-content: center;
margin-bottom: 20rpx;
}
}
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
.list2 {
margin-top: 45%;
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
.btn {
color: #fff;
height: 64rpx;
line-height: 64rpx;
}
}
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
.fenxi {
color: $maincolor;
width: 100%;
background: #fff;
border-radius: 10px;
margin-bottom: 30px;
height: 45px;
display: flex;
justify-content: center;
align-items: center;
2025-09-17 14:55:24 +08:00
2025-11-25 14:21:22 +08:00
image {
width: 44rpx;
height: 44rpx;
margin-right: 5px;
2025-09-17 14:55:24 +08:00
}
}
2025-03-25 10:17:30 +08:00
</style>