// pages/faultInfo/faultInfo.ts // component/faultItem/faultItem.ts import { httpUtil } from '../../utils/restful'; Page({ /** * 页面的初始数据 */ data: { //是否隐藏评价按钮 showAppraise: false, contentLineHeight: 0, itemData: { id: '' }, faultLevText: '', imgList: [], faultId: '', faultProcessList: [] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ faultId: options.faultId }) }, onShow() { console.log("获取的ID:", this.data.faultId) httpUtil.wxGet(httpUtil.interfaces.getFaultInfoByDevId + this.data.faultId, null).then((res: any) => { console.log("获取故障详情成功:", res) let item = res.data.data let showAppraise = true if (item.processType == 2) { showAppraise = false } // 0:普通 1:待查 2:紧急 let faulevText = ''; switch (item.faultLevel) { case 0: faulevText = '普通' break; case 1: faulevText = '待查' break; case 2: faulevText = '紧急' break; } this.setData({ faultProcessList: [], }) this.setData({ itemData: item, showAppraise: showAppraise, faultLevText: faulevText, imgList: item.img.split(','), faultProcessList: item.faultProcessList }) console.log("imgList:", this.data.imgList) }).catch((res: any) => { console.log("获取故障详情失败:", res) }) }, toCommentPage: function () { // console.log("itemData:", this.data.itemData) console.log(" this.data.itemData.id:", this.data.itemData.id) wx.navigateTo({ url: "../../pages/comment/comment?faultId=" + this.data.itemData.id, }) } })