index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { myBtn } from "../../utils/dict";
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '我的', leftArrow: false, useBar: true },
  9. user: {
  10. },
  11. btnList: [],
  12. },
  13. // 跳转菜单
  14. tabPath(e) {
  15. let { route } = e.detail.detail;
  16. if (route) wx.redirectTo({ url: `/${route}` })
  17. },
  18. toCommon: function (e) {
  19. const { route, type } = e.currentTarget.dataset;
  20. // 自定义路径
  21. if (type == '0') { wx.navigateTo({ url: `${route}` }) }
  22. // 默认路径
  23. else if (type == '1') { wx.navigateTo({ url: `/pages/${route}/index` }) };
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. const that = this;
  30. that.watchLogin();
  31. },
  32. watchLogin: function () {
  33. const that = this;
  34. wx.getStorage({
  35. key: 'user',
  36. success: async (res) => {
  37. console.log('已登陆');
  38. },
  39. fail: async (res) => {
  40. console.log('未登陆');
  41. let user = { icon: '/image/icon.jpg', name: '顾红伟', phone: '12345678901', type: '1' }
  42. that.setData({ user: user })
  43. console.log(user);
  44. },
  45. });
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady: function () {
  51. },
  52. /**
  53. * 生命周期函数--监听页面显示
  54. */
  55. onShow: function () {
  56. },
  57. /**
  58. * 生命周期函数--监听页面隐藏
  59. */
  60. onHide: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面卸载
  64. */
  65. onUnload: function () {
  66. },
  67. /**
  68. * 页面相关事件处理函数--监听用户下拉动作
  69. */
  70. onPullDownRefresh: function () {
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom: function () {
  76. },
  77. /**
  78. * 用户点击右上角分享
  79. */
  80. onShareAppMessage: function () {
  81. }
  82. })