kitchendDevice/pageTwo/count/everyDay.vue

381 lines
8.8 KiB
Vue

<template>
<view class="content">
<view class="content_box">
<view class="date"></view>
<!-- 早午晚餐 -->
<view class="everyDay">
<view class="title">
<view><text class="quan"></text>{{$t("countCalorieAnalysis")}}</view>
</view>
<div class="chart-wrap">
<qiun-data-charts type="ring" :opts="opts" :chartData="chartData" :cHeight="320" :cWidth="320" />
</div>
<view class="foodtools">
<view class="type" v-for="(item,index) in foodInfo.list">
<view class="name">
<text :style="{background:item.color}"></text>
<view>{{item.name}}</view>
</view>
<view>{{item.val||0}}{{item.unit}}<text>|</text>{{item.kcal_proportion}}%</view>
</view>
</view>
</view>
<!--营养元素分析 -->
<view class="everyDay">
<view class="title">
<view><text class="quan"></text>{{$t("countNutrientElementEnergyProportion")}}</view>
</view>
<div class="chart-wrap">
<qiun-data-charts type="ring" :opts="opts2" :chartData="chartData2" :cHeight="320" :cWidth="320" />
</div>
<view class="foodtools">
<view class="top">
<view>{{$t("countNutritionClassification")}}</view>
<view>{{$t("countIntake")}}</view>
</view>
<view class="type">
<view class="name">
<text :style="{background:details.carbohydrate.color}"></text>
<image :src="details.carbohydrate.icon"></image>
<view>{{details.carbohydrate.name}}</view>
</view>
<view>
{{details.carbohydrate.val}}{{details.carbohydrate.unit}}<text>|</text>{{details.carbohydrate.proportion}}%
</view>
</view>
<view class="type">
<view class="name">
<text :style="{background:details.fat.color}"></text>
<image :src="details.fat.icon"></image>
<view>{{details.fat.name}}</view>
</view>
<view>{{details.fat.val}}{{details.fat.unit}}<text>|</text>{{details.fat.proportion}}%</view>
</view>
<view class="type">
<view class="name">
<text :style="{background:details.protein.color}"></text>
<image :src="details.protein.icon"></image>
<view>{{details.protein.name}}</view>
</view>
<view>
{{details.protein.val}}{{details.protein.unit}}<text>|</text>{{details.protein.proportion}}%
</view>
</view>
</view>
</view>
<!--营养元素排行榜 -->
<view class="everyDay">
<view class="title">
<view><text class="quan"></text>{{$t("countNutritionElementRankingList")}}</view>
</view>
<view class="foodtools rank_list">
<view class="topname">{{details.carbohydrate.name}}</view>
<view class="type" v-for="(item,index) in details.carbohydrate.rank_list">
<view class="name">
<image :src="item.icon"></image>
<image :src="item.pic_url" class="pic" v-if="item.pic_url"></image>
<view>{{item.name?item.name:'--'}}</view>
</view>
<view>{{item.weight||0}}g</view>
</view>
<view class="topname">{{details.fat.name}}</view>
<view class="type" v-for="(item,index) in details.fat.rank_list">
<view class="name">
<image :src="item.icon"></image>
<image :src="item.pic_url" class="pic" v-if="item.pic_url"></image>
<view>{{item.name?item.name:'--'}}</view>
</view>
<view>{{item.weight||0}}g</view>
</view>
<view class="topname">{{details.protein.name}}</view>
<view class="type" v-for="(item,index) in details.protein.rank_list">
<view class="name">
<image :src="item.icon"></image>
<image :src="item.pic_url" class="pic" v-if="item.pic_url"></image>
<view>{{item.name?item.name:'--'}}</view>
</view>
<view>{{item.weight||0}}g</view>
</view>
</view>
</view>
<!-- 营养元素 -->
<view class="jishiqi">
<view class="right">
<view class="item" v-for="(ite,ind) in foodInfo.nutrients_four">
<view class="left-icon">
<view class="name">
<image :src="ite.icon"></image>
<text class="name">{{ite.name}}</text>
</view>
<view>
<text class="weight">{{ite.today_intake||0}}{{ite.unit}}</text> / {{ite.suggestion||0}}g
</view>
</view>
<view class="right-info">
<view class="right-info-bottom">
<view class="val" :style="{ width: ite.proportion + '%',background:ite.color}"></view>
</view>
</view>
</view>
<view class="item" v-for="(ite,ind) in foodInfo.trace_elements_all_day">
<view class="left-icon">
<view class="name">
<text class="name">{{ite.name_ch}}</text>
</view>
<view>
{{ite.value||0}}{{ite.unit}}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
import qiunDataCharts from '@/uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue';
export default {
data() {
return {
page: "",
opts: {
color: [],
title: {
name: "",
}
},
opts2: {
color: [],
subtitle: {
name: "",
}
},
chartData: {},
chartData2: {},
foodInfo: {},
details: {}
}
},
components: {
qiunDataCharts
},
computed: {
...mapState(["user", "countFoodInfo"]),
},
onLoad(options) {
let that = this
that.page = options.page
uni.setNavigationBarTitle({
title: this.$t('titleeveryDay')
})
that.handleList()
},
methods: {
handleList() {
let that = this
let chart_data = []
let chart_data2 = []
that.opts.color = []
that.opts2.color = []
that.foodInfo = that.page == 'home' ? that.user.food_count : that.countFoodInfo
that.details = that.page == 'home' ? that.user.food_count.details : that.countFoodInfo.details
for (let i = 0; i < that.foodInfo.list.length; ++i) {
that.opts.color.push(that.foodInfo.list[i].color)
chart_data.push({
name: that.foodInfo.list[i].name,
value: Number(that.foodInfo.list[i].kcal_proportion),
})
}
that.opts.title.name = that.foodInfo.nutrients_four[0].today_intake
that.chartData = JSON.parse(JSON.stringify({
series: [{
data: chart_data
}]
}));
for (let key in that.details) {
if (that.details.hasOwnProperty(key)) {
that.opts2.color.push(that.details[key].color)
chart_data2.push({
name: that.details[key].name,
value: Number(that.details[key].proportion),
})
}
}
that.chartData2 = JSON.parse(JSON.stringify({
series: [{
data: chart_data2
}]
}));
},
}
}
</script>
<style scoped lang="scss">
.content {
padding: 0 20rpx;
}
.content_box {
width: 100%;
}
.chart-wrap {
position: relative;
width: 320rpx;
height: 320rpx;
margin: -30rpx auto 0;
.uchart-val {
margin-top: 70rpx;
position: absolute;
left: 0;
top: 48rpx;
width: 320rpx;
font-size: 46rpx;
text-align: center;
z-index: 9;
}
}
.everyDay {
background: #fff;
padding: 10px 10px 0;
border-radius: 10px;
margin-top: 15px;
height: auto;
overflow: hidden;
.title {
display: flex;
justify-content: space-between;
font-weight: bold;
font-size: 15px;
.quan {
margin-right: 70rpx;
}
}
.foodtools {
text {
margin: 0 15rpx;
color: #ccc;
}
.type {
display: flex;
line-height: 45px;
justify-content: space-between;
border-bottom: 1px solid #f7f7f7;
.name {
width: 80%;
display: flex;
align-items: center;
.pic {
border: 1px solid #f7f7f7;
border-radius: 10px;
}
text {
width: 7px;
height: 7px;
margin-right: 10px;
border-radius: 15px;
}
}
image {
width: 20px;
height: 20px;
margin-right: 10px;
}
}
}
.rank_list {
.topname {
position: relative;
padding-left: 15px;
margin-top: 5px;
}
.topname::after {
width: 5px;
height: 5px;
content: "";
position: absolute;
left: 0;
top: 7px;
background-color: #666;
border-radius: 50%;
}
.type {
border-bottom: none;
line-height: 40px;
}
}
.top {
display: flex;
justify-content: space-between;
}
}
.jishiqi {
.right {
width: 100%;
margin-left: 0;
height: auto;
margin-bottom: 20px;
}
.item {
width: auto;
background: #fff;
padding: 2px 15px;
border-radius: 10px;
display: flex;
flex-wrap: wrap;
font-size: 28rpx;
margin-bottom: 10px;
.left-icon {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
flex-direction: inherit;
image {
margin-right: 5px;
}
.name {
display: flex;
align-items: center;
}
.weight {
margin-right: 5px;
color: $maincolor;
}
}
.right-info {
width: 100%;
height: auto;
margin-bottom: 8px;
}
}
}
</style>