list.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. frameStyle: { useTop: true, name: '学员信息', leftArrow: true, useBar: false },
  8. list: [
  9. { _id: '1', icon: [{ url: '/image/beijing.jpeg' }], name: "测试姓名", card: '220581200003302462', phone: '12345678901', age: '18', gender: '0' },
  10. { _id: '2', icon: [{ url: '/image/beijing.jpeg' }], name: "测试姓名", card: '220581200003302462', phone: '12345678901', age: '18', gender: '1' },
  11. { _id: '1', icon: [{ url: '/image/beijing.jpeg' }], name: "测试姓名", card: '220581200003302462', phone: '12345678901', age: '18', gender: '0' },
  12. { _id: '2', icon: [{ url: '/image/beijing.jpeg' }], name: "测试姓名", card: '220581200003302462', phone: '12345678901', age: '18', gender: '1' }
  13. ],
  14. },
  15. // 返回
  16. back: function () {
  17. wx.navigateBack({ delta: 1 })
  18. },
  19. //添加或修改
  20. toCommon: function (e) {
  21. const { route, id } = e.currentTarget.dataset;
  22. if (id) wx.navigateTo({ url: `/pages/sstudent/${route}?id=${id}` })
  23. else wx.navigateTo({ url: `/pages/sstudent/${route}` })
  24. },
  25. // 删除
  26. toDel: async function (e) {
  27. const that = this;
  28. const { id } = e.currentTarget.dataset;
  29. wx.showModal({
  30. title: '提示',
  31. content: '是否确认删除该条数据?',
  32. async success(res) {
  33. if (res.confirm) {
  34. const arr = await app.$delete(`/newCourt/api/student/${id}`);
  35. if (arr.errcode == '0') {
  36. wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
  37. that.watchLogin()
  38. } else {
  39. wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  40. }
  41. }
  42. }
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面加载
  47. */
  48. onLoad: function (options) {
  49. const that = this;
  50. that.watchLogin();
  51. },
  52. // 监听用户是否登录
  53. watchLogin: async function () {
  54. const that = this;
  55. wx.getStorage({
  56. key: 'user',
  57. success: async res => { },
  58. fail: async 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. })