<template>
	<view class="content">
		<!-- 搜索 -->
		<view class="serachBox">
			<view class="serach-box">
				<view class="searchInput">
					<input placeholder="请输入..." class="city-serach-input" v-model="search_value" />
					<icon v-if="search_value" class="iconfont icon-error" @click="handlecolse"></icon>
					<view class="voice" v-if="!search_value">
						<uni-icons class="mic" type="mic-filled" size="26" @click="onShowSearchType(1)"></uni-icons>
						<uni-icons class="camera" type="camera-filled" size="26"
							@click="onShowSearchType(2)"></uni-icons>
					</view>
				</view>
				<view class="searchBtn">
					<view @click="handleSerach">搜索</view>
				</view>
			</view>
		</view>
		<!-- 历史搜索 -->
		<view class="content-box" v-if="!search_list.length">
			<view v-if="history_food.length" class="search-history">
				<view class="title">
					<view class="quan"></view>历史搜索
				</view>
				<view class="button-container" @click="showAll =! showAll" v-if="history_food.length>10">
					<image :src="showAll?'/static/arrow-up.png':'/static/arrow-down.png'"></image>
				</view>
				<view class="history-list">
					<view class="history-list-item"
						v-for="(item,index) in showAll?history_food:history_food.slice(0, 10)"
						@click="handleSearchHistory(item.keyword)">
						{{item.keyword}}
					</view>
				</view>
			</view>
			<view class="popular-container">
				<view class="title">
					<view class="quan"></view>猜你想搜
				</view>
				<view class="popular-food-item" v-for="(ite,index) in popular_food" :key="index">
					<view class="food-title">{{ite.title}}</view>
					<view class="popular-food-inner">
						<text class="popular-food-subitem" v-for="(sub_item,sub_index) in ite.list"
							@click="handleSearchHistory(sub_item.name)" :key="sub_index">{{sub_item.name}}
						</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 搜索列表 -->
		<view class="search_list" v-if="search_list.length">
			<view class="search_list_item" v-for="(ite,ind) in search_list" @click="handleDetail(ite)">
				<image :src="ite.pic_url"></image>
				<view>
					<text>{{ite.name}}</text>
					<text>100g/{{ite.kcal}}kcal</text>
				</view>
			</view>
			<view class="endtext" v-if="!lastPage || page >= lastPage">—— 到底了，看看别的吧 ——</view>
		</view>
		<!-- 语音描述 -->
		<view class="auto-search-dialog" v-if="showAutoSearchDlg">
			<view class="auto-search-inner">
				<text>{{autoSearchContent != '' ? `识别到你描述的食材为“${autoSearchContent}”,是否查找食材“${autoSearchContent}”` : "长安麦克风图标开始说话，松开后结束"}}</text>
				<view class="mic-icon" :style="{'border-color':mic_touch ? '#18bc37' : '#777777'}"
					@touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd"
					v-if=" autoSearchType == 1 && autoSearchContent == ''">
					<uni-icons type="mic-filled" size="80" :color="mic_touch ? '#18bc37' : '#777777'"></uni-icons>
				</view>
				<view class="btn-wrap" v-else>
					<view class="retry" @click="retrySearch">重试</view>
					<view class="confirm" @click="handleSearchHistory(autoSearchContent)">确定</view>
				</view>
				<uni-icons class="close" type="close" color="#ffffff" size="45"
					@click="showAutoSearchDlg=false"></uni-icons>
			</view>
		</view>
		<!-- 底部购物车 -->
		<view class="groupbtn" v-if="ActiveList.length">
			<view class="che" @click="isShop =! isShop">
				<text v-if="ActiveList.length">{{ActiveList.length}}</text>
				<icon class="t-icon t-icon-canpan"></icon>
			</view>
			<view class="subbtn" @click="handlesubbtn"> 确定</view>
		</view>
		<!-- 购物车列表 -->
		<view class="wrapper activeList" v-if="isShop">
			<view class="bg" @click='isShop=false'>
				<view class="box2" @click.stop>
					<view class="title">
						<view>{{typename}}</view>
						<text>共{{ActiveList.length}}条记录</text>
					</view>
					<view class="list" v-if="ActiveList.length">
						<view class="item" v-for="(ite,ind) in ActiveList" :key="ind">
							<view class="">
								<text class="name">{{ite.name}}</text>
								<text>（{{ite.weight}}{{ite.unit}}）</text>
							</view>
							<icon class="iconfont icon-ashbin" color="red" size="26" @click="handledelactive(ite)">
							</icon>
						</view>
					</view>
					<view v-else class="nolist list">
						<icon class="iconfont icon-wancan"></icon>
						<text>还没有记录哦</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 测量区 -->
		<view class="wrapper" v-if="IsWeight">
			<view class="bg" @click='IsWeight=false'>
				<view class="box" @click.stop>
					<icon class="iconfont icon-error" @click="IsWeight=false" size="30"></icon>
					<scroll-view style="height: 100%;margin-top: 10px;" scroll-y="true">
						<view class="box-info">
							<view class="foodItem">
								<view class="left">
									<image :src="activeType.pic_url" mode="aspectFill"></image>
									<view class="info">
										<view class="name">{{activeType.name}}</view>
										<view class="kcal">{{activeType.kcal}}千卡/100克</view>
									</view>
								</view>
								<view class="more" @click="isBle=!isBle">
									<image class="keybordIcon"
										:src="isBle?'/static/chengIcon.png':'/static/keybordIcon.png'" mode="widthFix">
									</image>
								</view>
							</view>
							<view class="foodInfo">
								<view class="foodInfoItem" v-for="(item,index) in activeType.nutrients_four"
									:key="index">
									<view class="name">
										<view class="color" :style="{'background-color':item.color}"
											v-if="item.color != ''"></view>
										<text>{{item.name}}({{unitConversion(item.unit)}})</text>
									</view>
									<view class="value">{{ Number(activeType.weight/100 * item.value).toFixed(1) }}
									</view>
								</view>
							</view>
							<!-- 蓝牙称重 -->
							<view class="blue-tooth" v-if="isBle">
								<blue-tooth @handleBle="handleBle" :weightType="'2'" :weightKcal="weightKcal"
									@realTimeWeight="realTimeWeight"></blue-tooth>
							</view>
							<!-- 手动输入 -->
							<view v-else>
								<view class="val">
									<input type="digit" v-model="activeType.weight" placeholder="请输入"
										@focus="activeType.weight=0" />
									<text class="unit">克</text>
								</view>
								<view class="btn" @click="Next()">确认添加</view>
							</view>
						</view>
						<!-- 营养分析 -->
						<view class="foodDetail">
							<view class="foodContent">
								<view class="title">热量和营养</view>
								<view class="progress">
									<div class="chart-wrap">
										<qiun-data-charts type="ring" :opts="opts" :canvas2d="true"
											canvasId="foodCharts" :chartData="chartData" :cHeight="250" :cWidth="250" />
										<view class="uchart-kcal">{{Math.floor(activeType.kcal*activeType.weight/100)}}
										</view>
									</div>
									<view class="info" v-if="activeType.nutrients_four">
										<view class="info-item"
											v-for="(item,index) in activeType.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>{{activeType.weight}}克含量</text>
								</view>
								<view class="foodDetailList">
									<view class="foodDetailItem" v-for="(item,index) in activeType.nutrients_list"
										:key="index">
										<view class="name">{{item.name_ch}}</view>
										<view class="value">
											{{Number(item.value*activeType.weight/100).toFixed(2)}}{{item.unit}}
										</view>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	const plugin = requirePlugin("WechatSI")
	import search from "../../components/search.vue"
	import blueTooth from "../../components/bluetooth_food.vue"
	import qiunDataCharts from '@/uni_modules/qiun-data-charts/components/qiun-data-charts.vue';
	export default {
		data() {
			return {
				opts: {
					dataLabel: false,
					color: ["#5180D8", "#ED7886", "#FFB169"],
					background: "transparent",
					canvas: {
						background: "transparent"
					},
					legend: {
						show: false // 这个设置将隐藏图例
					},
					title: {
						name: "",
						fontSize: 20,
						offsetY: -3,
						color: "#333333"
					},
					subtitle: {
						name: "千卡",
						fontSize: 14,
						offsetY: 12,
						color: "#888888"
					},
					extra: {
						ring: {
							ringWidth: 10,
							labelWidth: 0,
							border: false,
							// customRadius: 50
						}
					}
				},
				index: 0,
				page: 1,
				typename: "",
				showAll: false,
				IsWeight: false,
				search_list: [],
				isShop: false,
				lastPage: "",
				isBle: true,
				weightKcal: "",
				search_value: '',
				ActiveList: [],
				activeType: {},
				mic_touch: false,
				voiceManager: null,
				autoSearchContent: "",
				showAutoSearchDlg: false
			};
		},
		computed: {
			...mapState(["configInfo", "user"]),
			popular_food() {
				return this.configInfo.search_guess.food_data
			},
			history_food() {
				return this.configInfo.search_history.food
			},
			getKcal() {
				if (this.activeType) {
					return this.activeType.kcal
				}
				return 0
			}
		},
		components: {
			search,
			blueTooth,
			qiunDataCharts
		},
		onLoad(options) {
			let that = this
			that.typename = options.name
		},
		watch: {
			activeType: {
				handler(newVal, oldVal) {
					console.log(newVal)
				},
				deep: true
			}
		},
		mounted() {
			let that = this
			that.voiceManager = plugin.getRecordRecognitionManager()
			that.voiceManager.onStop = function(res) {
				that.autoSearchContent = res.result.replace('。', '')
			}
			that.voiceManager.onError = function(res) {
				console.error("error msg", res.retcode)
			}
			that.voiceManager.stop()
		},
		onReachBottom() {
			let that = this
			if (!this.lastPage || this.page >= this.lastPage) {
				uni.showToast({
					title: '没有更多数据！',
					icon: 'none'
				})
				return
			}
			this.page++
			this.handleSerach()
		},
		methods: {
			//测量返回
			handleBle(weight, unit, kcal) {
				let that = this
				that.isBle = false
				that.activeType.weight = weight
				that.activeType.unit = unit
				that.activeType.kcal = kcal
				that.Next()
				console.log("返回", that.activeType, weight, unit, kcal)
			},
			//实时重量
			realTimeWeight(weight, unit) {
				this.activeType = Object.assign({}, this.activeType, {
					weight: this.convertToGrams(weight, unit)
				})
			},
			unitConversion(unit) {
				if (unit == 'kcal') {
					return '千卡'
				} else if (unit == 'g') {
					return '克'
				}
				return unit
			},
			convertToGrams(value, fromUnit) {
				const conversionFactors = {
					'lb': 453.59237, // 1磅 = 453.59237克
					'oz': 28.349523125, // 1盎司 = 28.349523125克
					'kg': 1000, // 1公斤 = 1000克
					'g': 1
				};

				if (!conversionFactors.hasOwnProperty(fromUnit)) {
					return ''
				}

				return value * conversionFactors[fromUnit];
			},
			// 食物选择
			handleDetail(ite) {
				let that = this
				that.isBle = true
				that.isShop = false
				that.IsWeight = true
				that.activeType = ite
				that.activeType.weight = 0
				that.weightKcal = that.activeType.kcal
				let chart_data = []
				that.opts.color = []
				for (let i = 1; i < ite.nutrients_four.length; ++i) {
					that.opts.color.push(ite.nutrients_four[i].color)
					chart_data.push({
						name: ite.nutrients_four[i].name,
						value: Number(ite.nutrients_four[i].proportion),
					})
				}

				that.chartData = JSON.parse(JSON.stringify({
					series: [{
						data: chart_data
					}]
				}));
			},
			getKcal() {
				this.opts.title.name = this.activeType.nutrients_four[0].value * this.activeType.weight
			},
			// 保存
			Next() {
				let that = this
				let ite = that.activeType
				that.IsWeight = false
				if (that.ActiveList.indexOf(ite) == -1) {
					that.ActiveList.push(ite);
				} else {
					let index = that.ActiveList.indexOf(ite)
					that.ActiveList[index].weight = that.activeType.weight;
					that.ActiveList[index].unit = that.activeType.unit;
				}
				console.log("保存", that.ActiveList)
			},
			// 搜索
			handleSerach() {
				let that = this
				that.search_list = []
				that.$model.getFoodSearch({
					page: that.page,
					search_data: that.search_value
				}).then(res => {
					if (res.code != 0) {
						uni.showToast({
							title: res.msg,
							icon: 'error'
						})
						return
					}
					that.search_list = that.search_list.concat(res.data.content_list)
				})
			},
			// 取消搜索
			handlecolse() {
				this.search_value = ""
				this.search_list = []
			},
			// 历史搜索
			handleSearchHistory(text) {
				let that = this
				that.search_value = text
				that.showAutoSearchDlg = false
				that.autoSearchContent = ''
				that.handleSerach()
			},
			// 重试
			retrySearch() {
				let that = this
				that.autoSearchContent = ''
				if (that.autoSearchType == 2) {
					that.showAutoSearchDlg = false
					that.selectPhoto()
				}
			},
			// 开始说话
			onVoiceTouchStart() {
				let that = this
				that.mic_touch = true
				that.voiceManager.start({
					duration: 60000,
					lang: "zh_CN"
				})
			},
			// 语音结束
			onVoiceTouchEnd() {
				let that = this
				that.mic_touch = false
				that.voiceManager.stop()
			},
			// 
			onShowSearchType(type) {
				let that = this
				this.autoSearchType = type

				if (type == 1) {
					that.showAutoSearchDlg = true
				} else if (type == 2) {
					that.selectPhoto()
				}
			},
			selectPhoto() {
				let that = this
				uni.chooseMedia({
					count: 1,
					mediaType: ['image'],
					sourceType: ['album', 'camera'],
					sizeType: ['compressed'],
					camera: 'back',
					success(res) {
						const tempFilePath = res.tempFiles[0].tempFilePath
						uni.getFileSystemManager().readFile({
							filePath: tempFilePath,
							encoding: 'base64',
							success: (res) => {
								const base64 = 'data:image/jpeg;base64,' + res.data

								uni.showLoading({
									title: '图片识别中...',
									mask: true
								})

								that.$model.getPhotoSearch({
									img_str: base64,
								}).then(res => {
									uni.hideLoading()
									if (res.code != 0) return
									that.autoSearchContent = res.data.name
									that.showAutoSearchDlg = true
								})
							},
							fail: (err) => {
								console.error('读取文件失败:', err)
							}
						})
					},
					fail(err) {
						console.error('拍照失败:', err)
					}
				})
			},
			// 购物车提交
			handlesubbtn() {
				let that = this
				if (that.ActiveList.length <= 0) return
				that.$model.getAddIntakeFood({
					aud_id: that.user.aud_id,
					meals_type: that.typename,
					food_list: that.ActiveList
				}).then(res => {
					if (res.code != 0) return
					uni.navigateBack({
						delta: 1
					})
				})
			},
			//删除购物车食材
			handledelactive(ite) {
				let that = this
				that.ActiveList.splice(that.ActiveList.indexOf(ite), 1);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.serachBox {
		height: 40px;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		padding: 15px 10px;
		z-index: 9;
		background-color: #efefef;

		.serach-box {
			height: 40px;
			border-radius: 10px;
			position: relative;
			background-color: #fff;
		}

		.searchInput {
			position: absolute;
			left: 0;
			right: 60px;
			height: 40px;

			icon {
				position: absolute;
				right: 10px;
				top: 10px;
				display: flex;
				z-index: 9;
			}

			.voice {
				display: flex;
				justify-content: flex-end;
				align-items: center;
				position: absolute;
				right: 10px;
				top: 0;
				bottom: 0;
				width: 150rpx;
				display: flex;
				z-index: 9;

				.mic {
					margin-right: 10rpx;
				}
			}
		}

		.searchBtn {
			position: absolute;
			width: 60px;
			right: 0px;
			height: 40px;
			line-height: 40px;
			background: $maincolor;
			border-radius: 0 10px 10px 0;
			text-align: center;
			color: #fff;
		}

		input {
			height: 40px;
			padding: 0 5px;
			text-align: center;
			position: absolute;
			left: 0px;
			right: 0px;
			border-radius: 10px;

		}

		.icon {
			width: 50px;
			height: 40px;
			position: absolute;
			right: 15px;
			display: flex;
			align-items: center;
			justify-content: center;
		}

	}

	.content-box {
		border-radius: 10px 10px 0 0;
		position: relative;
		z-index: 99;
		width: 100%;
		margin: 65px 0 15px;
		background: #fff;
	}

	.search-history {
		width: 100%;
		height: auto;
		overflow: hidden;

		uni-icons {
			color: #333333;
			font-size: 30px;
			position: absolute;
			top: 13px;
			right: 15px;
		}
	}

	.history-list {
		width: calc(100% - 20px);
		margin: 10px 10px 0;
		height: auto;
		display: flex;
		flex-wrap: wrap;

		.history-list-item {
			border: 1px solid #dfdfdf;
			padding: 3px 12px;
			border-radius: 10px;
			margin-bottom: 10px;
			margin-right: 10px;
		}
	}

	.title {
		width: 90%;
		font-size: 30rpx;
		font-weight: bold;
		color: #000;
		margin-top: 15px;
		margin-left: 15px;
		display: flex;
		align-items: center;
	}

	.popular-container {
		width: 100%;
		margin-top: 30rpx;

		.popular-food-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			margin: 20rpx;
			padding: 20rpx;
			box-sizing: border-box;
			border-radius: 20rpx;
			background: linear-gradient(#EDFFF4, #ffffff 80%);

			.food-title {
				font-size: 34rpx;
				font-weight: 700;
			}

			.popular-food-inner {
				display: flex;
				flex-wrap: wrap;
				justify-content: flex-start;
				width: 100%;
				margin-top: 20rpx;

				.popular-food-subitem {
					display: flex;
					align-items: center;
					margin-bottom: 20rpx;
					padding: 10rpx 20rpx;
					background-color: #fff;
					margin-right: 20rpx;
					border-radius: 20rpx;
					border: 1px solid #f7f7f7;
				}
			}
		}
	}

	.search_list {
		display: flex;
		padding: 0 10px;
		flex-wrap: wrap;
		margin: 75px 10px 90px;
		width: calc(100% - 40px);
		justify-content: space-between;
		background: #fff;
		border-radius: 10px;

		.search_list_item {
			width: 100%;
			display: flex;
			align-items: center;
			border-bottom: 1px solid #f7f7f7;
			padding: 10px 0;

			image {
				width: 80rpx;
				height: 80rpx;
				margin-right: 10px;
				border-radius: 10px;
			}

			text {
				width: 100%;
				display: inline-block;
			}

			:nth-child(2) text {
				margin-top: 5px;
			}
		}
	}

	.activeList {
		z-index: 12;
		bottom: 50px;

		.title {
			font-weight: bold;
			margin: 5px 0;
		}

		.list {
			padding-bottom: 55px;

			.name {
				margin-right: 5px;
			}


		}
	}

	.auto-search-dialog {
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 999;

		.auto-search-inner {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: center;
			position: relative;
			width: 70%;
			height: 350rpx;
			padding: 80rpx 0;
			background-color: #fff;
			border-radius: 20rpx;
			box-shadow: 0 0 20rpx #ccc;

			.close {
				position: absolute;
				left: 0;
				right: 0;
				bottom: -140rpx;
				width: 90rpx;
				margin: 0 auto;
			}
		}

		text {
			font-size: 32rpx;
			width: 80%;
		}

		.mic-icon {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 150rpx;
			height: 150rpx;
			border-radius: 50%;
			border: 8rpx solid #777777;
		}

		.btn-wrap {
			display: flex;
			justify-content: space-around;
			width: 90%;

			.retry,
			.confirm {
				width: 190rpx;
				height: 60rpx;
				line-height: 60rpx;
				text-align: center;
				font-size: 28rpx;
				border: 2rpx solid #777;
				border-radius: 15rpx;
			}
		}
	}


	.footBtn {
		position: fixed;
		width: 100%;
		bottom: 0;
		padding-top: 15px;
		background: #fff;
		display: flex;
		justify-content: space-around;

		view {
			color: #fff;
			width: auto;
			padding: 5px 20px;
			background: $maincolor;
			margin-bottom: 15px;
			display: flex;
			align-items: center;
			border-radius: 10px;
		}
	}

	.groupbtn {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 10px 20px;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 55px;
		z-index: 15;
		background-color: #fff;
		overflow: hidden;
		box-shadow: 0px 1px 5px 2px #dfe2e1fc;

		.subbtn {
			color: #fff;
			width: 40%;
			text-align: center;
			border-radius: 10px;
			height: 35px;
			line-height: 35px;
			background-color: #f0ae43;
		}

		.che {
			width: 60px;
			height: 60px;
			position: relative;

			text {
				position: absolute;
				height: 15px;
				background: red;
				width: 15px;
				border-radius: 50%;
				display: inline-block;
				color: #fff;
				line-height: 15px;
				text-align: center;
				font-size: 12px;
				right: 0;
				top: 5px;
			}

			image,
			.t-icon {
				width: 60px;
				height: 60px;
				border-radius: 50%;
			}
		}
	}

	.wrapper {
		.box {
			height: 85%;
			background-color: #dfdfdf;
		}

		.box-info {
			border-radius: 10px;
			padding: 10px;
			background-color: #fff;

			.val {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 70%;
				padding: 30rpx 0;
				border-radius: 20rpx;
				background-color: #F8F8F8;
				margin: 15px auto;

				input {
					border-bottom: 1px soild #fff;
				}

				.unit {
					width: auto;
					display: inline-block;
					padding: 10rpx;
					margin-left: 30rpx;
					font-size: 28rpx;
					color: #fff;
					border-radius: 8rpx;
					background-color: #F0AE43;
				}
			}
		}

		.foodItem {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 10rpx;

			.more {
				padding: 6rpx 10rpx;
				border-radius: 12rpx;
				color: #fff;
				background-color: #f0ae43;

				image {
					width: 50rpx;
					height: 50rpx;
				}
			}



			.left {
				width: 65%;
				display: flex;
				align-items: center;

				image {
					width: 90rpx;
					height: 90rpx;
					border-radius: 15rpx;
				}

				.info {
					display: flex;
					flex-direction: column;
					justify-content: center;
					margin-left: 30rpx;

					.name {
						font-size: 26rpx;
						color: #333;
						text-align: left;
						margin-bottom: 10rpx;
					}

					.kcal {
						font-size: 24rpx;
						color: #666;
					}
				}
			}
		}

		.foodInfo {
			display: flex;
			justify-content: space-around;
			margin-top: 30rpx;
			box-sizing: border-box;

			.foodInfoItem {
				display: flex;
				flex-direction: column;
				align-items: center;

				.name {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					color: #8F8F8F;

					.color {
						width: 6rpx;
						height: 20rpx;
						margin-right: 10rpx;
						border-radius: 3rpx;
					}
				}

				.value {
					font-size: 28rpx;
					margin-top: 10rpx;
				}
			}
		}

		.blue-tooth {
			margin-top: 10rpx;
		}

		.foodDetail {
			background: #fff;
			border-radius: 10px;
			margin-top: 10px;
		}

		.foodContent {
			width: 100%;
			padding: 30rpx;
			margin-top: 16rpx;
			box-sizing: border-box;
			border-radius: 20rpx;
			box-sizing: border-box;
			background-color: #fff;
			box-sizing: 0 0 20rpx #f1f1f1;

			.title {
				font-size: 28rpx;
				font-weight: 600;
				margin-left: 0;
			}

			.progress {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.chart-wrap {
					position: relative;
					width: 250rpx;
					height: 250rpx;
					margin-top: -30rpx;

					.uchart-kcal {
						position: absolute;
						left: 60rpx;
						top: 120rpx;
						width: 130rpx;
						font-size: 40rpx;
						text-align: center;
						z-index: 9;
					}
				}

				.info {
					display: flex;
					flex-direction: column;
					justify-content: center;
					font-size: 24rpx;

					.info-item {
						display: flex;
						align-items: center;
						margin-top: 20rpx;

						.color {
							width: 6rpx;
							height: 20rpx;
							margin-right: 10rpx;
							border-radius: 3rpx;
						}
					}
				}
			}

			.tips {
				display: flex;
				justify-content: space-between;
				border-bottom: 1px solid #f1f1f1;
				padding: 16rpx 0;
				font-size: 24rpx;
				margin-top: 10rpx;
			}

			.foodDetailList {
				margin-top: 10rpx;

				.foodDetailItem {
					display: flex;
					justify-content: space-between;
					padding: 20rpx 0;
					box-sizing: border-box;

					.name {
						width: 70%;
						font-size: 24rpx;
						color: #777;
						text-align: left;
					}

					.val {
						width: 30%;
						font-size: 24rpx;
						font-weight: 700;
						color: #333;
						text-align: right;
					}
				}
			}
		}

		.icon-error {
			position: absolute;
			right: 10px;
			top: -17px;
			background: #fff;
			font-size: 35px;
			border-radius: 50%;
		}

		.icon-ashbin {
			color: red !important;
			font-size: 24px !important;
		}

		.box2 {
			left: 0;
			right: 0;
			height: 55%;
			bottom: 0;
			background-color: #fff;
			overflow: scroll;
			position: absolute;
			padding: 10px;

			.title {
				width: 100%;
				justify-content: space-between;

				view {
					font-size: 16px;
					margin-right: 5px;
					color: red;
				}
			}

			.name {
				margin-left: 0;
				font-size: 14px;
				font-weight: 500;
			}

			.list {
				margin-bottom: 90px;
			}
		}
	}

	.btn {
		color: #fff;
		width: 60%;
		margin: auto;
		background-color: #f0ae43;
	}

	.button-container {
		position: absolute;
		top: 10px;
		right: 15px;
		font-size: 20px;

		image {
			width: 25px;
			height: 25px;
		}
	}
</style>