|
|
|
@ -93,27 +93,38 @@ Page({ |
|
|
|
return false |
|
|
|
}, |
|
|
|
/************************************** 获取用户信息,进行登录 ********************************************/ |
|
|
|
toIndex: function(){ |
|
|
|
var factoryId = storage.get('X-FACTORY-ID' + app.userInfo.userId) |
|
|
|
if(factoryId){ |
|
|
|
app.userInfo.factoryId = factoryId |
|
|
|
} else { |
|
|
|
for (let mIndex = app.userInfo.enterpriseInfos.length - 1; mIndex >= 0; mIndex--) { |
|
|
|
if(factoryId){ |
|
|
|
break |
|
|
|
} |
|
|
|
const element = app.userInfo.enterpriseInfos[mIndex] |
|
|
|
for (let nIndex = element.factoryInfos.length - 1; nIndex >= 0; nIndex--) { |
|
|
|
const item = element.factoryInfos[nIndex] |
|
|
|
checkFactoryId: function(storageFactoryId){ |
|
|
|
for (let mIndex = app.userInfo.enterpriseInfos.length - 1; mIndex >= 0; mIndex--) { |
|
|
|
const element = app.userInfo.enterpriseInfos[mIndex] |
|
|
|
for (let nIndex = element.factoryInfos.length - 1; nIndex >= 0; nIndex--) { |
|
|
|
const item = element.factoryInfos[nIndex] |
|
|
|
if(storageFactoryId){ |
|
|
|
if(item.factoryId == storageFactoryId){ |
|
|
|
return item.factoryId |
|
|
|
} |
|
|
|
} else { |
|
|
|
if(item.factoryId){ |
|
|
|
factoryId = item.factoryId |
|
|
|
break |
|
|
|
return item.factoryId |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
app.userInfo.factoryId = factoryId |
|
|
|
} |
|
|
|
return null |
|
|
|
}, |
|
|
|
toIndex: function(){ |
|
|
|
var factoryId = storage.get('X-FACTORY-ID' + app.userInfo.userId) |
|
|
|
if(factoryId){ |
|
|
|
// 有可能被移除了,缓存的factoryId还在,那要进行处理
|
|
|
|
factoryId = this.checkFactoryId(factoryId) |
|
|
|
} |
|
|
|
if(!factoryId){ |
|
|
|
factoryId = this.checkFactoryId() |
|
|
|
if(factoryId){ |
|
|
|
storage.put('X-FACTORY-ID' + app.userInfo.userId, factoryId) |
|
|
|
} |
|
|
|
} |
|
|
|
if(factoryId){ |
|
|
|
app.userInfo.factoryId = factoryId |
|
|
|
headerFactoryId(app.userInfo.factoryId) |
|
|
|
if(this.data.url) { |
|
|
|
wx.redirectTo({ url: '/pages/index/index?url=' + this.data.url }) |
|
|
|
|