faultItem.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // component/faultItem/faultItem.ts
  2. import { httpUtil } from '../../utils/restful';
  3. import { TimeUtil } from '../../utils/TimeUtil'
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. //0=待维修 1=维修中 2=已完成
  10. itemData: null
  11. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. status: 0,
  17. statusText: "",
  18. faultTime: '',
  19. myItemData: null,
  20. },
  21. lifetimes: {
  22. attached: function () {
  23. // 在组件实例被从页面节点树添加时执行
  24. let text = "";
  25. switch (Number(this.properties.itemData.processType)) {
  26. case 0:
  27. text = "待维修";
  28. break;
  29. case 1:
  30. text = "维修中";
  31. break;
  32. case 2:
  33. text = "已完成";
  34. break;
  35. }
  36. this.setData({
  37. status: this.properties.itemData.processType,
  38. statusText: text,
  39. faultTime: TimeUtil.dateFormat(parseInt(this.properties.itemData.reportTime), "yyyy-MM-dd HH:mm"),
  40. myItemData: this.properties.itemData
  41. })
  42. console.log("myItemData:", this.data.myItemData)
  43. },
  44. detached: function () {
  45. // 在组件实例被从页面节点树移除时执行
  46. },
  47. },
  48. /**
  49. * 组件的方法列表
  50. */
  51. methods: {
  52. toFaultInfoPage: function () {
  53. console.log("去故障详情界面")
  54. httpUtil.wxGet(httpUtil.interfaces.getFaultInfoByDevId + this.data.itemData.id, null).then((res: any) => {
  55. console.log("获取故障详情成功:", res)
  56. let item = JSON.stringify(res.data.data)
  57. wx.navigateTo({
  58. url: '../../faultInfo/faultInfo?item=' + item
  59. })
  60. }).catch((res: any) => {
  61. console.log("获取故障详情失败:", res)
  62. })
  63. }
  64. }
  65. })