index.js
3.37 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
import {
setSessionId,
setUserInfo
} from '~/utils/cache/storageApi'
import USERAPI from '~/api/usersApi/index'
import ActivityApi from '~/api/activityApi/index'
const setRouteData = targetPath => {
let [url, query] = targetPath.split('?'),
obj = {}
if (query) {
let arr = query.split('&')
arr.forEach(el => {
const [key, val] = el.split('=')
Object.assign(obj, {
[key]: val
})
})
// const [key, val] = query.split('=')
// obj = {
// [key]: val
// }
}
return {
url,
obj
}
}
/**选择账号登录 */
const selectAccountLogin = ({
id,
sessionId,
missionId,
tab,
merchantId,
pages,
tabType,
isGH,
ghPhone
}) => {
let para = {
id,
sessionId,
}
let apiName = 'selectAccountLogin'
if (ghPhone) {
para.phone = ghPhone
apiName = 'selectAccountLoginByPassword'
}
USERAPI[apiName](para).then(({
code,
data,
message
}) => {
if (code == '0') {
const userInfo = wx.$storage.get('userInfo') || {},
[info] = data.loginUserInfoList
if (userInfo.merchantId == info.merchantId && userInfo.uuid == info.uuid && userInfo.boutiqueCoupon_myself_status) info.boutiqueCoupon_myself_status = true
setLoginInfo(info, data.sessionId, missionId, tab, merchantId, pages, tabType, isGH)
} else wx.$api.showToast(message || '系统异常')
})
}
/**设置登录信息 */
const setLoginInfo = (userInfo, sessionId, missionId, tab, merchantId, pages, tabType, isGH) => {
setUserInfo(userInfo)
setSessionId(sessionId)
if (isGH) {
console.log(userInfo);
ActivityApi.findStaff({ staffUuid: userInfo.uuid }).then(res => {
if (res && res.length) {
const roleName = res[0].roleName
const merchantId = res[0].merchantNo
if (roleName === '售后专员') {
wx.navigateTo({
url: '/packageStoreAssistant/packageAuth/pages/GHStaff/StoreNote/index?merchantId='+merchantId,
});
} else if(roleName === '续保专员'){
wx.navigateTo({
url: '/packageStoreAssistant/packageAuth/pages/GHStaff/EquityRegister/index',
});
}else{
wx.$api.showToast('请使用有效账号进行登录')
}
} else {
wx.$api.showToast('请使用有效账号进行登录')
}
})
return
}
loginSuccess(missionId, tab, merchantId, pages, tabType)
}
/**成功跳转 */
const loginSuccess = (missionId, tab, merchantId, pages, tabType) => {
const {
options: {
targetPath
}
} = wx.$router.getPageInstance()
if (targetPath || missionId || pages) {
if (missionId) {
wx.nextTick(() => {
wx.$router.reLaunch('/packageStoreAssistant/packageActivity/pages/taskDetail/taskDetail', {
missionId,
tabType,
isCard:true
})
})
return
}
if (pages == 'addFLG' || pages == 'addFLGStep' || pages == 'myFollow') {
wx.nextTick(() => {
wx.$router.reLaunch(`/packageStoreAssistant/packageActivity/pages/${pages}/index`, {
open: 1
})
})
return
}
const {
url,
obj
} = setRouteData(targetPath)
wx.$router.reLaunch(url, obj)
} else wx.$router.reLaunch('/pages/tab/storeAssistant/index', {
notIntercept: true,
tab,
merchantId
})
}
module.exports = {
selectAccountLogin,
loginSuccess,
setRouteData,
setLoginInfo
}