提交 e3867c0d 作者: wk

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

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