index.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { httpInfo } from "../../../api/serverOrder";
  2. import {
  3. statusType,
  4. status_options
  5. } from "../../../utils/statusTypeOptions";
  6. import { convertTime } from "../../../utils/util"
  7. import {
  8. createStoreBindings
  9. } from 'mobx-miniprogram-bindings'
  10. import {
  11. store
  12. } from "../../../store/index";
  13. Page({
  14. data: {
  15. loading: true,
  16. id: "",
  17. status_options,
  18. statusType,
  19. items: null,
  20. },
  21. onLoad(options: object) {
  22. this.storeBindings = createStoreBindings(this, {
  23. store,
  24. fields: ["token"],
  25. actions: ["setStore"],
  26. });
  27. const {
  28. id
  29. } = options
  30. this.setData({
  31. id
  32. })
  33. this.getResourceDetails()
  34. },
  35. onUnload() {
  36. this.storeBindings.destroyStoreBindings();
  37. },
  38. phoneOpen() {
  39. wx.makePhoneCall({
  40. phoneNumber: '400-9121-211' //仅为示例,并非真实的电话号码
  41. })
  42. },
  43. async getResourceDetails() {
  44. const {
  45. id,
  46. status_options
  47. } = this.data
  48. const {
  49. code,
  50. data
  51. } = await httpInfo({
  52. reqCode: id
  53. })
  54. if (code === 1) {
  55. let str = ""
  56. const {
  57. req_demand_name
  58. } = data
  59. req_demand_name.forEach((s, i) => {
  60. str += i === 0 ? s.name : '+' + s.name
  61. })
  62. this.setData({
  63. items: {
  64. ...data,
  65. status_name: (status_options.find((item) => item.value == String(data.status)) || {}).label ||
  66. '--',
  67. act_time_day: convertTime(data.act_time, 'MM.DD'),
  68. act_time_end_day: convertTime(data.req_endtime, 'MM.DD'),
  69. req_demand_name_label: str,
  70. },
  71. loading: false
  72. })
  73. } else {
  74. await this.setStore("", "")
  75. this.setData({
  76. loading: false,
  77. })
  78. }
  79. },
  80. })