riku
2024-11-14 00a96d6881dd10ae7d3c4f5437bfceaabe677723
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { menuData } from './menu';
import { useLoading } from '../../behaviors/loading';
import { basePicUrl } from '../../config/index';
import Toast from 'tdesign-miniprogram/toast/index';
 
const app = getApp();
 
Page({
  behaviors: [useLoading],
  data: {
    userInfo: {
      avatarUrl: '',
      nickName: '正在登录...',
      phoneNumber: '',
      usertypeid: 2,
    },
    menuData,
  },
 
  onLoad(options) {
    this.getVersionInfo();
  },
 
  onShow() {
    this.getTabBar().init();
    this.init();
  },
 
  onPullDownRefresh() {
    this.init();
  },
 
  init() {
    // this._startLoad();
    this.fetchUserInfo();
  },
 
  _fetchData(page) {},
 
  fetchUserInfo() {
    const u = app.globalData.userInfo;
    this.setData({
      userInfo: {
        avatarUrl: u.headIconUrl.length == 0 ? '' : basePicUrl + u.headIconUrl,
        nickName: u.realname,
        usertypeid: u.usertypeid,
      },
    });
  },
 
  onClickCell({ currentTarget }) {
    const { type } = currentTarget.dataset;
 
    switch (type) {
      case 'supervision': {
        wx.navigateTo({ url: '/pages/inspection/scene/index' });
        break;
      }
      case 'notice': {
        wx.navigateTo({ url: '/pages/usercenter/notice/index' });
        break;
      }
      case 'info': {
        wx.navigateTo({ url: '/pages/news/law-enforcement/index' });
        break;
      }
      case 'patrol': {
        wx.navigateTo({ url: '/pages/selfpatrol/index' });
        break;
      }
      case 'support': {
        wx.navigateTo({ url: '/pages/usercenter/support/index' });
        break;
      }
      case 'about': {
        wx.navigateTo({ url: '/pages/usercenter/about/index' });
        break;
      }
      default: {
        Toast({
          context: this,
          selector: '#t-toast',
          message: '未知跳转',
          icon: '',
          duration: 1000,
        });
        break;
      }
    }
  },
 
  logout() {
    app.globalData.onLaunch.forEach(fun => {
      if (typeof fun === 'function') {
        fun();
      }
    });
    wx.reLaunch({
      url: '/pages/usercenter/login/login-home/index',
    });
  },
 
  getVersionInfo() {
    const versionInfo = wx.getAccountInfoSync();
    const { version, envVersion = __wxConfig } = versionInfo.miniProgram;
    this.setData({
      versionNo: envVersion === 'release' ? version : envVersion,
    });
  },
});