faultInfo.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // pages/faultInfo/faultInfo.ts
  2. // component/faultItem/faultItem.ts
  3. import { httpUtil } from '../../utils/restful';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. //是否隐藏评价按钮
  10. showAppraise: false,
  11. contentLineHeight: 0,
  12. itemData: {
  13. id: ''
  14. },
  15. faultLevText: '',
  16. imgList: [],
  17. faultId: '',
  18. faultProcessList: []
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad(options) {
  24. this.setData({
  25. faultId: options.faultId
  26. })
  27. },
  28. onShow() {
  29. console.log("获取的ID:", this.data.faultId)
  30. httpUtil.wxGet(httpUtil.interfaces.getFaultInfoByDevId + this.data.faultId, null).then((res: any) => {
  31. console.log("获取故障详情成功:", res)
  32. let item = res.data.data
  33. let showAppraise = true
  34. if (item.processType == 2) {
  35. showAppraise = false
  36. }
  37. // 0:普通 1:待查 2:紧急
  38. let faulevText = '';
  39. switch (item.faultLevel) {
  40. case 0:
  41. faulevText = '普通'
  42. break;
  43. case 1:
  44. faulevText = '待查'
  45. break;
  46. case 2:
  47. faulevText = '紧急'
  48. break;
  49. }
  50. this.setData({
  51. faultProcessList: [],
  52. })
  53. this.setData({
  54. itemData: item,
  55. showAppraise: showAppraise,
  56. faultLevText: faulevText,
  57. imgList: item.img.split(','),
  58. faultProcessList: item.faultProcessList
  59. })
  60. console.log("imgList:", this.data.imgList)
  61. }).catch((res: any) => {
  62. console.log("获取故障详情失败:", res)
  63. })
  64. },
  65. toCommentPage: function () {
  66. // console.log("itemData:", this.data.itemData)
  67. console.log(" this.data.itemData.id:", this.data.itemData.id)
  68. wx.navigateTo({
  69. url: "../../pages/comment/comment?faultId=" + this.data.itemData.id,
  70. })
  71. }
  72. })