Dining_Hall/pages/review/index.vue

279 lines
6.4 KiB
Vue
Raw Normal View History

<template>
<view class="rating-page">
2025-02-19 09:34:34 +08:00
<view style="width: 98%;margin: 0px auto;background-color: #ffffff;padding: 10px 20px;border-radius: 10rpx;display: flex;justify-content: space-between;">
<view style="width: 100rpx;height: 100rpx;background: #ffa361;margin: 10px;">
<u-icon name="home-fill" color="#fff" size="50"></u-icon>
</view>
<view style="width: 70%;">
<view style="width: 100%;height: 30px;display: flex;align-items: center;border-bottom: 1px solid #CCC;padding-bottom: 10px;">
<text>食堂</text>
<view @click="showCarteen=true" style="width: 80%;height: 30px;margin-left: 10px;line-height: 30px;">
{{canteenName}}
</view>
</view>
<view style="width: 100%;height: 30px;display: flex;align-items: center;padding-top: 10px;">
<text>档口</text>
2025-03-14 15:15:54 +08:00
<view @click="showStall=true" style="width: 80%;height: 30px;margin-left: 10px;line-height: 30px; overflow: hidden;">
2025-02-19 09:34:34 +08:00
{{stallName}}
</view>
</view>
</view>
</view>
<u-action-sheet
:show="showCarteen"
:actions="actions"
title="请选择食堂"
@close="showCarteen = false"
@select="carteenSelect"
></u-action-sheet>
<u-action-sheet
:show="showStall"
:actions="actions2"
title="请选择档口"
@close="showStall = false"
@select="stallSelect"
></u-action-sheet>
<!-- 分项评分 -->
<view class="detail-rating">
2025-02-19 09:34:34 +08:00
<view class="rating-item" v-for="(item, index) in decorationList" :key="index">
<text class="item-label">{{ item.functionName }}</text>
<view class="hearts-row">
2025-02-19 09:34:34 +08:00
<u-icon v-for="n in 5" :key="n" :name="n <= item.value ? 'star-fill' : 'star'" :color="n <= item.value ? '#ffa361' : '#e5e5e5'"
size="32" @click="changStar(item,n)"
></u-icon>
</view>
</view>
</view>
<!-- 评价输入 -->
<view class="comment-box">
2025-02-19 09:34:34 +08:00
<view class="">您的意见和建议</view>
<u--textarea
v-model="comment"
placeholder="口味、服务、环境如何?有哪些想要提的建议?"
2025-02-19 09:34:34 +08:00
height="120"
></u--textarea>
</view>
<!-- 提交按钮 -->
<view class="submit-btn">
<u-button
text="提交"
2025-02-19 09:34:34 +08:00
shape="squrd"
@click="sumbitCartennnEvaluate"
:customStyle="{
width: '100%',
height: '88rpx',
2025-02-19 09:34:34 +08:00
background: '#ffa361',
color: '#ffffff',
border: 'none'
}"
></u-button>
</view>
</view>
</template>
<script>
2025-02-19 09:34:34 +08:00
import { getAllCanteenStallApi } from "@/api/mine/index.js"
import { queryPageDecorationApi,addCartennnEvaluateApi } from "@/api/mine/review.js"
export default {
2025-02-19 09:34:34 +08:00
data() {
return {
allCanteenData:[],
showCarteen:false,
actions:[],
canteenId:"",
canteenName:"",
showStall:false,
actions2:[],
stallId:"",
stallName:"",
decorationList:[],
overallRating: 5,
ratingTexts: ['非常差', '较差', '一般', '推荐', '超赞'],
ratingItems: [
{ label: '口味', value: 5 },
{ label: '环境', value: 0 },
{ label: '服务', value: 0 }
],
comment: ''
}
},
onLoad() {
this.getAllCanteenStall()
this.queryPageDecoration()
},
methods: {
async queryPageDecoration() {
const res = await queryPageDecorationApi({})
console.log(res)
this.decorationList=res;
this.decorationList.forEach(item=>{
item.value=1
})
console.log(this.decorationList)
},
changStar(item,n){
item.value = n
this.$forceUpdate()
},
//提交按钮
async sumbitCartennnEvaluate(){
if(this.canteenId==""){
uni.$u.toast('请选择食堂')
return
}
if(this.stallId==""){
uni.$u.toast('请选择档口')
return
}
if(this.comment==""){
uni.$u.toast('请认真填写建议')
return
}
console.log(this.decorationList)
let arr= []
this.decorationList.forEach(item=>{
let obj = {
content:item.value,
functionId:item.functionId,
}
arr.push(obj)
})
let param = {
"canteenId": this.canteenId,
"custId": uni.getStorageSync('custId'),
"evaluateDetailList": arr,
"proposal": this.comment,
"shopstallId": this.stallId
}
const res = await addCartennnEvaluateApi(param)
if(res.code==200){
uni.showToast({
title: '提交成功',
icon: 'none'
});
setTimeout(()=>{
uni.navigateBack()
},800)
}
},
//获取食堂列表
async getAllCanteenStall() {
const res = await getAllCanteenStallApi({})
console.log(res)
this.allCanteenData = res
let arr=[]
if(res.length>0){
res.forEach(item=>{
let obj={
id:item.canteenId,
name:item.canteenName
}
arr.push(obj)
})
}
this.actions = arr
},
carteenSelect(e){
this.canteenId = e.id
this.canteenName = e.name;
let arr=[]
this.allCanteenData.forEach(item=>{
if(item.canteenId==e.id){
arr=item.stallList
}
})
arr.forEach(item=>{
let obj={
id:item.stallId,
name:item.stallName
}
this.actions2.push(obj)
})
},
stallSelect(e){
this.stallId = e.id
this.stallName = e.name;
}
}
}
</script>
<style lang="scss" scoped>
.rating-page {
2025-02-19 09:34:34 +08:00
height: 94vh;
// background-color: #ffffff;
padding: 20rpx;
padding-bottom: 120rpx;
.rating-box {
margin-bottom: 60rpx;
.rating-row {
display: flex;
justify-content: space-between;
padding: 0 20rpx;
}
.rating-item {
display: flex;
flex-direction: column;
align-items: center;
.rating-text {
font-size: 24rpx;
color: #999999;
margin-top: 10rpx;
&.active {
color: #333333;
}
}
}
}
.detail-rating {
2025-02-19 09:34:34 +08:00
width: 98%;margin: 10px auto;background-color: #ffffff;padding: 10px 20px;border-radius: 10rpx;
.rating-item {
display: flex;
align-items: center;
margin-bottom: 30rpx;
2025-02-19 09:34:34 +08:00
background-color: #FFF;
.item-label {
2025-02-19 09:34:34 +08:00
width: 240rpx;
font-size: 28rpx;
color: #333333;
}
.hearts-row {
display: flex;
2025-02-19 09:34:34 +08:00
gap: 0rpx;
}
}
}
.comment-box {
2025-02-19 09:34:34 +08:00
width: 98%;margin: 0px auto;background-color: #ffffff;padding: 10px 20px;border-radius: 10rpx;
}
.submit-btn {
2025-02-19 09:34:34 +08:00
// position: fixed;
// left: 30rpx;
// right: 30rpx;
// bottom: 40rpx;
}
}
::v-deep .u-textarea {
background-color: #f7f8fa;
border-radius: 8rpx;
padding: 20rpx;
}
</style>