TabMine.js
5.27 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// components/tabMine/TabMine.js
import api from '~/pages/tabMine/api'
const app = getApp()
import constantData from '~/pages/constant/data'
import { withTabRefreshInFlight } from '../../services/tabRefreshService.js'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/mine/'
Component({
/**
* 组件的属性列表
*/
properties: {
navBarHeight: {
type: Number,
value: 0
},
// 是否显示工资绩效
showCollege: {
type: Boolean,
value: false
},
/** Tab4 可见性:true 时刷新我的页银行卡/版本信息 */
show: {
type: Boolean,
observer(n) {
if (n) this.refreshOnShow()
}
}
},
/**
* 组件的初始数据
*/
data: {
IMG_URL,
isYqdSuper: '',
selectedSceneName: '',
userInfo: {},
staffBankFlag: false,
isForbidden: false,
},
lifetimes: {
ready() {
this.applyMineUserInfo()
}
},
/**
* 组件的方法列表
*/
methods: {
/** 从本地 userInfo 同步展示字段(ready 与每次 Tab 显示时调用) */
applyMineUserInfo() {
const userInfo = wx.$util.getUserInfo()
const payload = {
isForbidden: !wx.$hasPermission?.canSelectMultiStore?.(userInfo),
isYqdSuper: app.globalData.isYqdSuper,
selectedSceneName: constantData?.sceneList?.filter(val => val.sceneType == userInfo?.sceneType)[0]?.sceneName,
selectedSceneDesc: constantData?.sceneList?.filter(val => val.sceneType == userInfo?.sceneType)[0]?.sceneDesc,
userInfo
}
if (userInfo.createdDate) {
let date = userInfo.createdDate + ''
date = date.replace(/-/g, '/').split(' ')[0]
payload['userInfo.createdTime'] = date
}
this.setData(payload)
},
/**
* Tab 切到我的时的统一入口;合并同 tick 并发。
* @returns {Promise<void>}
*/
refreshOnShow() {
return withTabRefreshInFlight('mine', () => this.refreshMineTab())
},
/** 刷新用户信息展示 + getStaffBankList + getVersionInfo */
async refreshMineTab() {
this.applyMineUserInfo()
await Promise.all([this.getStaffBankList(), this.getVersionInfo()])
},
/**跳转至银行卡 */
toAddBankAccount(e) {
const {
score,
user
} = this.data
this.setData({
showAccountModal: false
}, () => {
wx.$router.go('integration.detail', {
score
})
})
},
async getStaffBankList() {
let userInfo = wx.$util.getUserInfo(),
res = await api.getStaffBankList({
uuid: userInfo.uuid
})
console.log(res)
if (res.data && res.data.length) {
this.data.staffBankFlag = true
const [staffBankInfo] = res.data
if (staffBankInfo.state == 2 && !this.staffBankInfo) {
this.staffBankInfo = staffBankInfo
this.setData({
showAccountErrorModal: true
})
}
}
},
//我的积分
toPoint() {
console.log(999)
//判断是否添加银行卡
if (!this.data.staffBankFlag) {
this.setData({
showAccountModal: true
})
return
}
// 新的积分兑换页面
wx.$router.go('integration.index')
},
toCloseModal(e) {
const {
name
} = e.currentTarget.dataset
this.setData({
[name]: false
});
},
//收款账户
jumpAccount() {
const {
score,
user
} = wx.$router.getPageInstance()
wx.$router.go('integration.list', {
score,
user
})
},
// 跳转到工资绩效
jump(e) {
let { url } = e.currentTarget.dataset
const baseUrl = 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/html/'
const path = `${baseUrl}${url}.html`
wx.navigateTo({
url: `/pages/webView/webView?url=${encodeURIComponent(path)}`
})
},
// 跳转到商学院
goCollegeScene() {
wx.$router.go('packageEquity.collegeScene')
console.log('跳转到工资绩效')
},
// 获取版本信息
async getVersionInfo() {
const versionData = await getApp().getVersionInfo()
this.setData({
versionData
})
},
// 更新日志
goVersionPage() {
wx.$router.go('tabMine.log')
},
// 切换场景
changeScene() {
wx.$util.pointRecord(31)
wx.$router.go('pages.changeScene')
},
// 切换账号
changeAccount() {
wx.$router.reLaunch('pages.accountItems')
},
// 退出登录
logout() {
let _this = this
wx.showModal({
title: '温馨提示',
content: '是否退出当前账号?',
confirmColor: '#347BFF',
success(res) {
if (res.confirm) {
_this.setData({
flag: true
})
wx.showLoading()
api.logout().then(_res_ => {
let { code, message } = _res_
if (code == 0) {
wx.$storage.rm('abnormalFlowPop')
app.login(false)
} else {
_this.setData({
flag: false
})
wx.showToast(message)
}
})
}
}
})
}
}
})