sinfo.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. const app = getApp();
  2. Page({
  3. data: {
  4. frameStyle: { useTop: true, name: '详细信息', leftArrow: true, useBar: false },
  5. id: '',
  6. info: {},
  7. statusList: []
  8. },
  9. // 返回
  10. back: function () { wx.navigateBack({ delta: 1 }) },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: async function (options) {
  15. const that = this;
  16. await that.setData({ id: options.id || null })
  17. // 查询其他信息
  18. await that.searchOther();
  19. // 监听用户是否登录
  20. await that.watchLogin();
  21. },
  22. searchOther: async function () {
  23. const that = this;
  24. let arr;
  25. arr = await app.$get(`/dict`, { code: "schedule_status" });
  26. if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
  27. },
  28. // 监听用户是否登录
  29. watchLogin: async function () {
  30. const that = this;
  31. wx.getStorage({
  32. key: 'user',
  33. success: async res => {
  34. if (that.data.id) {
  35. const arr = await app.$get(`/msgs/${that.data.id}`, {}, 'race');
  36. if (arr.errcode == '0') {
  37. arr.data.zhStatus = that.searchStatus(arr.data.status);
  38. that.setData({ info: arr.data })
  39. } else {
  40. wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  41. }
  42. }
  43. },
  44. fail: async res => {
  45. wx.redirectTo({ url: '/pages/index/index' })
  46. }
  47. })
  48. },
  49. // 查询状态
  50. searchStatus: function (e) {
  51. const that = this;
  52. let data = that.data.statusList.find(i => i.value == e);
  53. if (data) return data.label;
  54. else return '暂无';
  55. },
  56. /**
  57. * 生命周期函数--监听页面初次渲染完成
  58. */
  59. onReady: function () { },
  60. /**
  61. * 生命周期函数--监听页面显示
  62. */
  63. onShow: function () {
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function () {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh: function () {
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage: function () {
  87. }
  88. })