index.js 1.7 KB

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