<template>
	<view>

		<view class="image_view">
			<image class='dish_image' :src="dish_image_src"></image>
		</view>
		<view>
			<text>{{"菜品名称：" + dish_name + '\n'}}</text>
			<text>{{"菜品位置：" + dish_location + dish_window_name + '\n'}}</text>
		</view>
		<view class="evaluete">
			
			<hb-comment ref="hbComment" @add="add" @del="del" @like="like" :deleteTip="'确认删除？'"
			    :cmData="commentData" v-if="commentData"></hb-comment>
			</view>
			<view>
				<text>{{"评分：\n"}}</text>
				<uni-rate v-model="value" @change="onChange(e.value)" allow-half="true" size="75" />
			</view>
			
	</view>

</template>

<script>
	export default {
		data() {
			return {
				dish_image_src: '',
				dish_name: '',
				dish_label: [],
				dish_location: '',
				dish_window_name: '',
				value: 4,
				comentData:[],
				dish_id:''
			};
		},
		onLoad(option) {
			
			//this.getLabels()
			this.dish_id = JSON.parse(decodeURIComponent(option._id))
			this.getImage()
			console.log(this.dish_id )
		},
		methods: {
			getImage() {
				let that = this
				uniCloud.callFunction({
					name: 'getDishes',
					data: {
						api: 'getByID',
						id: this.dish_id
					},
					success: function(res) {
						that.dish_image_src = res.result.data[0].dish_src
						that.dish_name = res.result.data[0].dish_name
						that.dish_location =res.result.data[0].location
						that.dish_window_name =res.result.data[0].window_name
						console.log(res)
					}
				})
			},

			getLabels() {
				let that = this
				uniCloud.callFunction({
					name: 'getLabels',
					data: {
						id: '650e8610a09a9bd68ba734ed'
					},
					success: function(res) {
						that.dish_label = res.result.data[0].labelList
						console.log(res)
					}
				})
			},
			onChange() {
				this.value = e.value

			},
			updateScore() {
				uniCloud.callFunction({
					name: 'scoreUpdate',
					data: {
						//用户信息和获取的评分
					}
				})
			},
			add(commentReq){
				console.log(commentReq)
			},
			del(commentid){
				console.log(commentid)
			},
			like(commentid){
				console.log(commentid)
			}
		}

	}
</script>

<style lang="scss">
	.image_view {
		height: 400rpx;
		display: flex;
		justify-content: center;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.dish_image {
		display: flex;
		height: 400rpx;
		width: 600rpx;
	}

	
	.evaluete{
	}
</style>