|
|
|
import { satisfyEvaluation } from "../../utils/api"
|
|
|
|
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
notSatisify: "../../images/ic_bumanyihuise@2x.png",
|
|
|
|
notSatisifySelected: "../../images/ic_bumanyi@2x.png",
|
|
|
|
normalSatisify: "../../images/ic_jibenmanyihuise@2x.png",
|
|
|
|
normalSatisifySelected: "../../images/ic_jibenmanyi@2x.png",
|
|
|
|
verySatisify: "../../images/feichangmanyihuise@2x.png",
|
|
|
|
verySatisifySelected: "../../images/ic_feichangmanyi@2x.png",
|
|
|
|
textareaValue: "",
|
|
|
|
evaluationCallbackVisible: false,
|
|
|
|
satisifyType: "",
|
|
|
|
itemId: ""
|
|
|
|
},
|
|
|
|
onLoad (options) {
|
|
|
|
if (options.itemId) {
|
|
|
|
this.setData({
|
|
|
|
itemId: options.itemId
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onShow () {
|
|
|
|
|
|
|
|
},
|
|
|
|
// textarea 双向绑定
|
|
|
|
bindTextareaValue (e) {
|
|
|
|
this.setData({
|
|
|
|
textareaValue: e.detail.value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 发表评价
|
|
|
|
publishEvaluation () {
|
|
|
|
if (!this.data.satisifyType) {
|
|
|
|
wx.showToast({
|
|
|
|
title: "请进行满意度评价",
|
|
|
|
icon: "none",
|
|
|
|
duration: 1000
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
} else if (!this.data.textareaValue) {
|
|
|
|
wx.showToast({
|
|
|
|
title: "请填写评价内容",
|
|
|
|
icon: "none",
|
|
|
|
duration: 1000
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
const para = {
|
|
|
|
itemId: this.data.itemId,
|
|
|
|
evaluationScore: this.data.satisifyType === "notSatisify" ? 0 : this.data.satisifyType === "normalSatisify" ? 1 : this.data.satisifyType === "verySatisify" ? 2 : "",
|
|
|
|
evaluationContent: this.data.textareaValue
|
|
|
|
}
|
|
|
|
wx.showLoading({
|
|
|
|
title: "加载中..."
|
|
|
|
})
|
|
|
|
satisfyEvaluation(para).then(res => {
|
|
|
|
wx.hideLoading()
|
|
|
|
console.log("满意度评价", res)
|
|
|
|
this.setData({
|
|
|
|
evaluationCallbackVisible: !this.data.evaluationCallbackVisible
|
|
|
|
})
|
|
|
|
}).catch(err => {
|
|
|
|
wx.hideLoading()
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 选择 满意度
|
|
|
|
chooseSatisifyType (e) {
|
|
|
|
this.setData({
|
|
|
|
satisifyType: e.currentTarget.dataset.type
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|