提交 e3867c0d 作者: wk

组织编号获取项目接口调整

访客加入组织审批通过token刷新
新闻banner实时刷新
父级 bbe0a36d
...@@ -881,7 +881,7 @@ ...@@ -881,7 +881,7 @@
url: "/api/v1/project/project_list", url: "/api/v1/project/project_list",
data: { data: {
is_all: 1, is_all: 1,
org_no: uni.getStorageSync("org_no") get_org_no: uni.getStorageSync("org_no")
}, },
header: { header: {
"access_token": this.getToken() "access_token": this.getToken()
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
Api.getProjectList({ Api.getProjectList({
data: { data: {
is_all: 1, is_all: 1,
org_no: uni.getStorageSync("org_no") get_org_no: uni.getStorageSync("org_no")
} }
}).then((result) => { }).then((result) => {
console.log("项目列表:", result); console.log("项目列表:", result);
......
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
this.getRecentlyApp() this.getRecentlyApp()
} }
}) })
uni.$on("refreshOrg", res => { //组织切换了 // uni.$on("refreshOrg", res => { //组织切换了
this.project_id = uni.getStorageSync("project_id") this.project_id = uni.getStorageSync("project_id")
if (!this.project_id) { if (!this.project_id) {
this.getCompanyBanners() this.getCompanyBanners()
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
this.getNews() this.getNews()
this.getBanners() this.getBanners()
} }
}) // })
}, },
onUnload() { onUnload() {
uni.$off("refreshOrg") uni.$off("refreshOrg")
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
url: "/api/v1/project/project_list", url: "/api/v1/project/project_list",
data: { data: {
is_all: 1, is_all: 1,
org_no: uni.getStorageSync("org_no") get_org_no: uni.getStorageSync("org_no")
}, },
header: { header: {
"access_token": this.getToken() "access_token": this.getToken()
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
url: "/api/v1/project/project_list", url: "/api/v1/project/project_list",
data: { data: {
is_all: 1, is_all: 1,
org_no: orgNo get_org_no: orgNo
}, },
header: { header: {
"access_token": this.getToken() "access_token": this.getToken()
...@@ -664,6 +664,30 @@ ...@@ -664,6 +664,30 @@
} }
return false return false
}, },
refreshToken: function() {
this.$http.consoleGet({
url: "/api/v1/access/token/refresh_access_token",
data: {},
header: {
"refresh_token": uni.getStorageSync("refresh_token"),
"Content-Type": "application/json"
}
}).then((res) => {
let result = res.data
console.log("刷新token", result);
if (result.code == 0) {
uni.setStorageSync("token", result.data.access_token)
uni.setStorageSync("refresh_token", result.data.refresh_token)
uni.setStorageSync("short_token", result.data.short_token)
this.loginState()
} else if (result.code == 90001 || result.code == 90201 || result.code == 10204) {
uni.navigateTo({
url: "/pages/login/authLogin/authLogin"
})
uni.clearStorageSync()
}
})
},
getUserInfo() { getUserInfo() {
Api.getUserInfo().then((result) => { Api.getUserInfo().then((result) => {
if (result.code == 0) { if (result.code == 0) {
...@@ -674,14 +698,23 @@ ...@@ -674,14 +698,23 @@
//如果是项目端 获取当前岗位 //如果是项目端 获取当前岗位
//如果是工人 获取工人当前项目 //如果是工人 获取工人当前项目
if (this.role == 'PM') { if (this.role == 'PM') {
//判断是否是访客变换身份
var role = uni.getStorageSync("role")
if (role == 'VISITOR') {
//清空身份
uni.setStorageSync("role", "")
//刷新token
this.refreshToken()
return
}
if (getApp().globalData.isInit) { if (getApp().globalData.isInit) {
if (jobs) { if (jobs) {
let currentJob = jobs[0] let currentJob = jobs[0]
uni.setStorageSync("org_no", currentJob.org_no) uni.setStorageSync("org_no", currentJob.org_no)
uni.setStorageSync("org_id", currentJob.org_id) uni.setStorageSync("org_id", currentJob.org_id)
//当前岗位 判断当前岗位是项目部还是其他 //当前岗位 判断当前岗位是项目部还是其他
if (this.userInfo.user.dept_type == '2') { //项目级 if (this.userInfo.user.dept_type == '2') { //项目级 直接获取项目部下所有项目 默认第一个
uni.setStorageSync("org_name", currentJob.dept_name) // uni.setStorageSync("org_name", currentJob.dept_name)
this.getDeptProject() this.getDeptProject()
} else { } else {
uni.setStorageSync("org_name", currentJob.org_name) uni.setStorageSync("org_name", currentJob.org_name)
...@@ -697,6 +730,9 @@ ...@@ -697,6 +730,9 @@
} }
getApp().globalData.isInit = false getApp().globalData.isInit = false
} }
} else if (this.role == 'VISITOR') { //如果是访客记录当前身份,身份变化需要刷新token
uni.setStorageSync("role", 'VISITOR')
this.initData()
} else { } else {
this.project_id = uni.getStorageSync("project_id") this.project_id = uni.getStorageSync("project_id")
if (!this.project_id) { if (!this.project_id) {
......
...@@ -122,14 +122,10 @@ ...@@ -122,14 +122,10 @@
} }
}, },
loadProject() { loadProject() {
let orgNo = uni.getStorageSync("org_no")
if (orgNo == '001') {
orgNo = ""
}
Api.getProjectList({ Api.getProjectList({
data: { data: {
is_all: 1, is_all: 1,
org_no: orgNo get_org_no: uni.getStorageSync("org_no")
} }
}).then((result) => { }).then((result) => {
console.log("项目列表:", result); console.log("项目列表:", result);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment