index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. frameStyle: { useTop: true, name: '用户管理', leftArrow: true, useBar: false },
  8. //查询条件
  9. searchInfo: {},
  10. list: [],
  11. dialog: { title: '详细信息', show: false, type: '1' },
  12. info: {},
  13. },
  14. // 跳转菜单
  15. back(e) {
  16. wx.navigateBack({ delta: 1 })
  17. },
  18. // 查询
  19. search: function (e) {
  20. const that = this;
  21. that.setData({ 'searchInfo.name': e.detail.value });
  22. that.watchLogin()
  23. },
  24. // 查看
  25. toView: async function (e) {
  26. const that = this;
  27. const { openid } = e.currentTarget.dataset;
  28. const arr = await app.$get(`/newCourt/api/user/${openid}`);
  29. if (arr.errcode == '0') {
  30. that.setData({ info: arr.data })
  31. that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  32. }
  33. },
  34. // 关闭弹框
  35. toClose: function () {
  36. const that = this;
  37. that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
  38. },
  39. /**
  40. * 生命周期函数--监听页面加载
  41. */
  42. onLoad: function (options) {
  43. const that = this;
  44. that.watchLogin();
  45. },
  46. // 监听用户是否登录
  47. watchLogin: async function () {
  48. const that = this;
  49. let searchInfo = that.data.searchInfo;
  50. wx.getStorage({
  51. key: 'user',
  52. success: async res => {
  53. let info = { skip: 0, limit: 1000 };
  54. if (searchInfo && searchInfo.name) info.name = searchInfo.name;
  55. const arr = await app.$get(`/newCourt/api/user/`, { ...info });
  56. if (arr.errcode == '0') { that.setData({ list: arr.data }) }
  57. },
  58. fail: res => {
  59. wx.redirectTo({ url: '/pages/index/index', })
  60. }
  61. })
  62. },
  63. /**
  64. * 生命周期函数--监听页面初次渲染完成
  65. */
  66. onReady: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面显示
  70. */
  71. onShow: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面隐藏
  75. */
  76. onHide: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面卸载
  80. */
  81. onUnload: function () {
  82. },
  83. /**
  84. * 页面相关事件处理函数--监听用户下拉动作
  85. */
  86. onPullDownRefresh: function () {
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom: function () {
  92. },
  93. /**
  94. * 用户点击右上角分享
  95. */
  96. onShareAppMessage: function () {
  97. }
  98. })