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: "", violationsCount: 0, isConReview: false }, 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.trim('')) { 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, isConReview: this.data.isConReview } wx.showLoading({ title: "加载中..." }) let that = this satisfyEvaluation(para).then(res => { wx.hideLoading() console.log("满意度评价", res) if (res.code == 0) { this.setData({ evaluationCallbackVisible: !this.data.evaluationCallbackVisible }) } else if (res.code == 533) { this.data.violationsCount++ console.log(this.data.violationsCount) if (this.data.violationsCount == 1){ wx.showToast({ title: res.msg, icon: "none", duration: 2000 }) } else if (this.data.violationsCount == 2) { wx.showModal({ title: '提示', content: '您提交的内容再次被判定为违规,您确定是否要提交?', success (res) { if (res.confirm) { console.log('用户点击确定') that.data.isConReview = true that.publishEvaluation() } else if (res.cancel) { console.log('用户点击取消') that.setData({ violationsCount: 0, isConReview: false }) } } }) } } }).catch(err => { wx.hideLoading() console.log(err) }) }, // 选择 满意度 chooseSatisifyType (e) { this.setData({ satisifyType: e.currentTarget.dataset.type }) } })