You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
canteen/subpkg/dishDetail/dishDetail.vue

123 lines
2.5 KiB

<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>
<text>{{"菜品类别:" + dish_label + '\n'}}</text>
<text>{{"菜品评分:" + dish_avg_score + '\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" 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: '',
dish_avg_score: 5.0
};
},
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
that.dish_avg_score = res.result.data[0].avg_score
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(e) {
let that = this
uniCloud.callFunction({
name: 'scoreUpdate',
data: {
score: that.value,
dish_id: that.dish_id
}
})
},
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>