// pages/comment/comment.ts import { httpUtil } from "../../utils/restful" Page({ /** * 页面的初始数据 */ data: { veryGoodStatus: true, veryGoodUrls: '../../image/comment/comment_verygood_true.png', goodStatus: false, goodUrls: "../../image/comment/comment_good_false.png", notGoodStatus: false, notGoodUrl: "../../image/comment/comment_notgood_false.png", postFaultId: '', describe: '' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ postFaultId: options.faultId }) }, commitComment: function (e: any) { let content = e.detail.value['send - input'] ? e.detail.value['send - input'] : e.detail.value console.log("1====", content) this.setData({ describe: content }) this.postComment() }, clickVeryGood() { this.setData({ veryGoodStatus: true, veryGoodUrls: '../../image/comment/comment_verygood_true.png', goodStatus: false, goodUrls: "../../image/comment/comment_good_false.png", notGoodStatus: false, notGoodUrl: "../../image/comment/comment_notgood_false.png" }) }, clickGood() { this.setData({ veryGoodStatus: false, veryGoodUrls: '../../image/comment/comment_verygood_false.png', goodStatus: true, goodUrls: "../../image/comment/comment_good_true.png", notGoodStatus: false, notGoodUrl: "../../image/comment/comment_notgood_false.png" }) }, clickNotGood() { this.setData({ veryGoodStatus: false, veryGoodUrls: '../../image/comment/comment_verygood_false.png', goodStatus: false, goodUrls: "../../image/comment/comment_good_false.png", notGoodStatus: true, notGoodUrl: "../../image/comment/comment_notgood_true.png" }) }, postComment: function () { let params = { faultId: this.data.postFaultId, describe: this.data.describe } httpUtil.wxPost(httpUtil.interfaces.postComment, params).then((res => { console.log("提交评论成功:", res) wx.showToast({ title: '提交成功', duration: 1000 }) setTimeout(function () { wx.navigateBack() }, 1000) })).catch((res) => { console.log("提交评论失败:", res) wx.showToast({ title: '提交失败', duration: 1000 }) }) } })