1
This commit is contained in:
parent
0e7c021c3d
commit
45c7476128
@ -4,11 +4,13 @@ export function toLogin(params) {
|
|||||||
const { username, password,device,version,versions } = params
|
const { username, password,device,version,versions } = params
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
request.post("/Token/Gen", params, false).then((result)=>{
|
request.post("/Token/Gen", params, false).then((result)=>{
|
||||||
const { access_token, refreshToken, orgId, Tenant } = result
|
const { access_token, refreshToken, orgId, Tenant,userid ,userName} = result
|
||||||
uni.setStorageSync('accessToken', access_token)
|
uni.setStorageSync('accessToken', access_token)
|
||||||
uni.setStorageSync('refreshToken', refreshToken)
|
uni.setStorageSync('refreshToken', refreshToken)
|
||||||
uni.setStorageSync('orgId', orgId)
|
uni.setStorageSync('orgId', orgId)
|
||||||
uni.setStorageSync('Tenant', Tenant)
|
uni.setStorageSync('Tenant', Tenant)
|
||||||
|
uni.setStorageSync('Userid', userid)
|
||||||
|
uni.setStorageSync('Username', userName)
|
||||||
request.post('/PF/Login/Login', {
|
request.post('/PF/Login/Login', {
|
||||||
Parameter1: username,
|
Parameter1: username,
|
||||||
Parameter2: password,
|
Parameter2: password,
|
||||||
|
|||||||
@ -13,16 +13,18 @@ export default {
|
|||||||
// const RootOrgId = uni.getStorageSync('RootOrgId')
|
// const RootOrgId = uni.getStorageSync('RootOrgId')
|
||||||
const appInfoData = uni.getStorageSync('appInfo')
|
const appInfoData = uni.getStorageSync('appInfo')
|
||||||
const tenant = uni.getStorageSync('Tenant') || ''
|
const tenant = uni.getStorageSync('Tenant') || ''
|
||||||
const userId = appInfoData?.User?.ID || ''
|
const userId = uni.getStorageSync('Userid')||''
|
||||||
|
// const userId = appInfoData?.User?.ID || ''
|
||||||
const userName = appInfoData?.User?.NAME || ''
|
const userName = appInfoData?.User?.NAME || ''
|
||||||
const orgId = appInfoData?.User?.ORG_ID || ''
|
const orgId= uni.getStorageSync('orgId')||''
|
||||||
|
// const orgId = appInfoData?.User?.ORG_ID || ''
|
||||||
const dataRule = appInfoData?.DataRule ? appInfoData?.DataRule.join(',') : ''
|
const dataRule = appInfoData?.DataRule ? appInfoData?.DataRule.join(',') : ''
|
||||||
const departmentId = appInfoData?.User?.DEPARTMENT_ID || ''
|
const departmentId = appInfoData?.User?.DEPARTMENT_ID || ''
|
||||||
const mineType = appInfoData?.User?.MineType || ''
|
const mineType = appInfoData?.User?.MineType || ''
|
||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': type === 'post' ? 'application/json' : 'application/x-www-form-urlencoded',
|
'Content-Type': type === 'post' ? 'application/json' : 'application/x-www-form-urlencoded',
|
||||||
Authorization: auth,
|
Authorization: auth,
|
||||||
Tenant: tenant,
|
// Tenant: tenant,
|
||||||
userid: userId,
|
userid: userId,
|
||||||
// username: userName, // username不能使用中文放在header
|
// username: userName, // username不能使用中文放在header
|
||||||
departmentId,
|
departmentId,
|
||||||
@ -34,6 +36,34 @@ export default {
|
|||||||
// 非 OP 路径接口,header 需要添加 Tenant
|
// 非 OP 路径接口,header 需要添加 Tenant
|
||||||
// const Tenant = uni.getStorageSync('Tenant')
|
// const Tenant = uni.getStorageSync('Tenant')
|
||||||
// url.indexOf('OP') != 0 && !isIgnoreTenant && (headers.Tenant = Tenant)
|
// url.indexOf('OP') != 0 && !isIgnoreTenant && (headers.Tenant = Tenant)
|
||||||
|
const Tenant = uni.getStorageSync('Tenant') || ''
|
||||||
|
if (url.indexOf('PF/Login/Login') !== -1) {
|
||||||
|
// Login接口使用最新的Tenant、Orgid、userid、Username值
|
||||||
|
const latestTenant = uni.getStorageSync('Tenant') || ''
|
||||||
|
const latestOrgid = uni.getStorageSync('orgId')
|
||||||
|
const latestUserid = uni.getStorageSync('Userid')
|
||||||
|
const latestUsername = uni.getStorageSync('Username')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (latestTenant) {
|
||||||
|
headers.Tenant = latestTenant
|
||||||
|
}
|
||||||
|
if (latestOrgid) {
|
||||||
|
// 覆盖原有的orgId字段,使用最新值
|
||||||
|
headers.orgId = latestOrgid
|
||||||
|
}
|
||||||
|
if (latestUserid) {
|
||||||
|
// 覆盖原有的userid字段,使用最新值
|
||||||
|
headers.userid = latestUserid
|
||||||
|
}
|
||||||
|
// if (latestUsername) {
|
||||||
|
// // 覆盖原有的username字段,使用最新值
|
||||||
|
// headers.username = latestUsername
|
||||||
|
// }
|
||||||
|
} else if (url.indexOf('OP') != 0 && !isIgnoreTenant) {
|
||||||
|
headers.Tenant = Tenant
|
||||||
|
}
|
||||||
return headers
|
return headers
|
||||||
},
|
},
|
||||||
send(options = {}, onlyData, isShowLoading) {
|
send(options = {}, onlyData, isShowLoading) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user