hz-zhhq-app/pages/newfoodComment/new-evaluate.vue

143 lines
3.1 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="main">
<view class="content">
<textarea value="" placeholder="请输入评价内容" maxlength="100" v-model="evContent" />
</view>
<view class="grade">
<text>评分</text>
<uni-rate class="rate" @change='changeGrade' size="28" :value="grade"></uni-rate>
</view>
<view class="footer-btn">
<view class="btn" @click="submit()">提交</view>
</view>
</view>
</template>
<script>
import uniRate from "@/components/uni-rate/uni-rate.vue";
import {submitEvaluate,saveHaircutComment} from '@/common/api.js';
import {callbackRequest,getStorage,alertTip,sureAlterTip} from '@/common/util.js';
 export default {
components: {uniRate},
        data() {
            return {
type:null,//评价类型 1 订单2 食堂3 推荐菜 4理发 5洗车
typeId:null,//评价类型Id
spareId:'',//如果评价订单 id为食堂 , 如果评价食堂 id为订单
userInfo:getStorage('userInfo'),
evContent:'',//评价内容
grade:5,
            };
        },
onLoad(option){
this.type = option.type;
this.typeId = option.typeId;
this.spareId = option.spareId;
},
        methods:{
changeGrade(e){
this.grade = e.value
},
submit(){
if(this.evContent == 0){
alertTip('请输入评价内容');
return false;
}
let data;
if(this.type == 4 || this.type == 5){
data = {
"method":saveHaircutComment,
data:{
detailId:this.typeId,
userId:this.userInfo.id,
commentContent:this.evContent,
satisfiedLevel:this.grade,
type:this.type == 4 ? 1 : 2
}
}
}else{
data = {
"method":submitEvaluate,
data:{
type:this.type,
typeId:this.typeId,
userId:this.userInfo.id,
evContent:this.evContent,
grade:this.grade,
bak1:this.spareId,
}
}
}
alertTip("提交成功");
setTimeout(r =>{
uni.redirectTo({
url:'/pages/newfoodComment/newfood-form'
})
}, 1500)
callbackRequest(data)
.then(res => {
/* if(res.data.returnCode == 1){
sureAlterTip('','评价成功',false)
.then(_ => {
if(this.type == 4){
uni.redirectTo({
url:'/pages/haircut/haircut?currentTabIndex=1'
})
}else if(this.type == 5){
uni.redirectTo({
url:'/pages/washCarReservation/washCarReservation?currentTabIndex=1'
})
}else {
// uni.redirectTo({
// url:'/pages/order-form/order-form'
// })
uni.navigateBack({
delta:1
})
}
})
}else {
alertTip(res.data.returnMsg)
} */
})
}
    }
}
</script>
<style lang="scss">
@import "@/static/css/common.scss";
.main {
min-height:100vh;
background: #f8f8f8;
}
.content {
padding:30rpx;
background: #fff;
textarea{
width:100%;
height:300rpx;
font-size:28rpx;
color:#666;
line-height:40rpx;
}
}
.grade {
font-size: 28upx;
padding:30rpx;
text{
font-size:28rpx;
color:#444;
font-weight:bold;
}
}
.grade .rate {
margin-left: 80upx;
margin-top: -18upx;
}
</style>