riku
2022-10-28 b45a01a8bee4a9bff5f9c248ead301b8675d1099
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// pages/mine/mine.js
import userservice from '../../../service/userservice'
 
const app = getApp()
 
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    version: app.globalData.version,
    //认证状态,[企业, 场景, 个人]
    authStatus:[],
    //场景类型
    sceneType: app.globalData.userInfo.extension2
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      userRealName: app.globalData.userInfo.realname,
      sceneType: app.globalData.userInfo.extension2
    })
    this.getBaseInfo()
  },
 
  onShow() {
    this.getAuthStatus()
  },
 
  //获取用户认证状态
  getAuthStatus() {
    var that = this
    userservice.getAuthStatus(app.globalData.accessToken.openId, app.globalData.accessToken.userId, {
      success(res) {
        if (res.success) {
          that.setData({
            authStatus: res.data
          })
        }else{
          wx.showToast({
            title: res.message,
            duration: 2000,
            icon: 'error',
          })
        }
      }
    })
  },
 
  getBaseInfo() {
    var that = this
    userservice.getBaseInfo(app.globalData.accessToken.userId, {
      success(data) {
        if (data.company != null) {
          that.setData({
            companyName: data.company.ciName
          }) 
        }
      }
    }, app.globalData.accessToken.openId)
  },
 
  logout() {
    wx.reLaunch({
      url: '/pages/m_user/userlogin/userlogin',
    })
  },
 
  goto(e) {
    var url = ""
    var index = e.currentTarget.dataset.index
    switch (index) {
      case "1":
        //工作提醒
        url = "/pages/m_notice/notice/notice"
        break;
      case "2":
        //技术支持
        url = "/pages/m_user/p_support/p_support"
        break;
      case "3":
        //我的收藏
        url = ""
        break;
      case "4":
        //我要咨询
        url = "/pages/m_consult/consultonline/consultonline"
        break;
      case "5":
        //环保日程
        url = "/pages/m_service/p_schedule/p_schedule"
        break;
      case "6":
        //关于
        url = "/pages/m_user/p_about/p_about"
        break;
      case "7":
        //操作指引
        url = "/pages/m_user/p_instructions/p_instructions"
        break;
    }
    if (url != "") {
      wx.navigateTo({
        url: url
      })
    } else {
      wx.showToast({
        title: '功能敬请期待',
        duration: 1000,
        icon: 'none',
        mask: true,
      })
    }
  },
 
  //认证
  gotoAuthentication(e) {
    //等待认证状态加载完毕
    if (this.data.authStatus.length == 0) return
    var url = ""
    var index = e.currentTarget.dataset.index
    switch (index) {
      //企业认证
      case "0":
        url = "/pages/m_user/companyauthentication/companyauthentication"
        break;
      //场景认证
      case "1":
        url = "/pages/m_user/sceneauthentication/sceneauthentication"
        break;
      //个人认证
      case "2":
        url = "/pages/m_user/personalauthentication/personalauthentication"
        break;
    }
    if (url != "") {
      wx.navigateTo({
        url: url,
        success: (res) => {
          res.eventChannel.emit('acceptDataFromOpenerPage', {
            authStatus: this.data.authStatus[parseInt(index)]
          })
        },
      })
    } else {
      wx.showToast({
        title: '功能敬请期待',
        duration: 1000,
        icon: 'none',
        mask: true,
      })
    }
  }
})