me.js
4.3 KB
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
// index/me.js
const App = getApp();
import basicApi from '../api/basic.js'
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
navHeight: App.globalData.navHeight,
windowHeight: App.globalData.windowHeight,
accountName: '',
name: '',
menuItems: [{
name: '切换服务器地址',
icon: 'position',
}],
userForm: {},
rolesList: []
},
pageLifetimes: {
show() {
const name = wx.getStorageSync('name');
const accountName = wx.getStorageSync('accountName');
this.setData({
name: name,
accountName: accountName
})
this.getUserInfo()
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
// 当前页面的 tabBar 索引
curClick: 3
})
}
}
},
/**
* 组件的方法列表
*/
methods: {
All(e) {
console.log(e)
},
inputBlur(e) {
this.data.userForm.realName = e.detail
},
inputBlur2(e) {
this.data.userForm.tel = e.detail
},
inputBlur3(e) {
this.data.userForm.email = e.detail
},
getUserInfo() {
basicApi.singleUser(wx.getStorageSync('uid')).then(res => {
this.getRolePermission(res.data)
})
},
getRolePermission(resData) {
basicApi.getPermission(resData.unid).then(res => {
let roles = []
res.roles.forEach(item => {
roles.push(item.name)
})
resData.roles = roles.toString()
this.setData({
userForm: resData
})
})
},
onSubmit(e) {
basicApi.editUserInfo({
userId: this.data.userForm.id,
email: this.data.userForm.email,
loginName: this.data.userForm.loginName,
realName: this.data.userForm.realName,
tel: this.data.userForm.tel,
}).then(res => {
if (res.code == 200) {
wx.showToast({
title: '修改成功',
icon: 'success'
})
this.getUserInfo()
}
})
},
undatePwd() {
wx.navigateTo({
url: '/pages/editPwd/editPwd'
})
},
logout: () => {
wx.getStorageInfo({
success: (res) => {
res.keys.forEach(item => {
if (item !== 'name' && item !== 'password' && item !== 'requestUrl' && item !== 'baseUrl' && item !== 'deploymentType') {
wx.removeStorage({
key: item,
success: function (res) {}
})
}
})
}
})
wx.reLaunch({
url: '/pages/login/index'
})
},
goOtherPage: async function (e) {
const {
value
} = e.target.dataset
if (value.name === '切换服务器地址') {
await wx.setStorage({
data: 'success',
key: 'modalShow',
})
wx.getStorageInfo({
success: (res) => {
res.keys.forEach(item => {
if (item !== 'name' && item !== 'password' && item !== 'requestUrl' && item !== 'baseUrl' && item !== 'deploymentType' && item !== 'modalShow') {
wx.removeStorage({
key: item,
success: function (res) {}
})
}
})
}
})
wx.reLaunch({
url: '/pages/login/index'
})
}
}
}
})