Commit a10fd7ea by 施宇

1

parent 4c8d4c49
{"tinyType":"dingtalk","tinyCnName":"钉钉","tinyProjectType":"dingtalk-biz","dingtalk:dingtalk-biz-isv:tinyIcon":"https://gw.alipayobjects.com/zos/rmsportal/mAzWuEDGpTlpugsPXgzf.svg","dingtalk:dingtalk-biz-isv:compilePreviewTime":"","dingtalk:dingtalk-biz-isv:compilePreviewWholePackSize":"","dingtalk:dingtalk-biz-isv:compilePreviewSubpackSizes":"","dingtalk:dingtalk-biz-isv:_appIdList":[],"dingtalk:dingtalk-biz-isv:preAuditLimit":10,"dingtalk:dingtalk-biz-isv:preAuditUsed":0,"dingtalk:dingtalk-biz-isv:uploadTime":"","dingtalk:dingtalk-biz-isv:packageSize":"","dingtalk:dingtalk-biz-isv:auditLink":null,"dingtalk:dingtalk-biz-isv:whiteListLink":null,"dingtalk:dingtalk-biz-isv:_enableAutoPush":true,"dingtalk:dingtalk-biz-isv:lastDeviceName":"Nexus 6","SimulatorMode":"WINDOW","isSimulatorOpen":false,"isNotFirstToggleSimulator":true,"isSimulatorDefaultSticky":false,"dingtalk:dingtalk-biz:tinyIcon":"https://gw.alipayobjects.com/zos/rmsportal/mAzWuEDGpTlpugsPXgzf.svg","dingtalk:dingtalk-biz:compilePreviewTime":"2020-04-10 15:19:09","dingtalk:dingtalk-biz:compilePreviewWholePackSize":"70.5 KB","dingtalk:dingtalk-biz:compilePreviewSubpackSizes":"","dingtalk:dingtalk-biz:_appIdList":[{"orgName":"深圳市猎芯科技有限公司","corpId":"dinga60eaa15e871b53535c2f4657eb6378f","orgLogo":"@lALOiBEIWs0BOM0CgA","orgId":12488944,"apps":[{"miniAppName":"猎芯云仓","bizType":2,"miniAppId":"2021001152657489","icon":"https://static.dingtalk.com/media/lALPDfJ6OzgcKq5NTQ_77_77.png"}]},{"orgName":"创宇天下科技有限公司","corpId":"ding93fe2dfb8cef1afd","orgId":9213150,"apps":[{"miniAppName":"DEMO","bizType":2,"miniAppId":"2018102261820458","icon":"https://static.dingtalk.com/media/lADPBY0V4-e-L6TNAZDNAbU_437_400.jpg"}]}],"dingtalk:dingtalk-biz:preAuditLimit":10,"dingtalk:dingtalk-biz:preAuditUsed":0,"dingtalk:dingtalk-biz:uploadTime":"","dingtalk:dingtalk-biz:packageSize":"","dingtalk:dingtalk-biz:auditLink":null,"dingtalk:dingtalk-biz:whiteListLink":null,"dingtalk:dingtalk-biz:_enableAutoPush":false,"dingtalk:dingtalk-biz:_appId":"2018102261820458","dingtalk:dingtalk-biz:_appName":"DEMO","dingtalk:dingtalk-biz:_orgId":9213150,"dingtalk:dingtalk-biz:_corpId":"ding93fe2dfb8cef1afd","dingtalk:dingtalk-biz:remoteVersion":"0.0.1","dingtalk:dingtalk-biz:currentVersion":"0.0.2","dingtalk:dingtalk-biz:whiteList":["dd.yemxing.com","user.liexin.net","user.liexin.com"],"dingtalk:dingtalk-biz:h5WhiteList":[],"taobao:taobao-mini:tinyIcon":"https://gw.alicdn.com/tfs/TB1as1idqSs3KVjSZPiXXcsiVXa-21-21.svg","dingtalk:dingtalk-biz:lastDeviceName":"iPhone 6","dingtalk:dingtalk-biz:MockStore":{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91c2VyLmxpZXhpbi5uZXRcL2Rpbmd0YWxrXC9sb2dpbiIsImlhdCI6MTU4NjUwNjE5NiwiZXhwIjoxNTg2NTA2MjU2LCJuYmYiOjE1ODY1MDYxOTYsImp0aSI6ImJaaHdGN2t3bFN2YTRWOHEiLCJzdWIiOjE1NzgsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.fz27OSKUzUGj_ofhz3p2QyMK0TyhzypZR9n9c8f-Hc4"},"compilerList":[{"title":"普通编译","query":"","page":""},{"title":"1","page":"pages/search/search","pageQuery":"type=3"},{"title":"2","page":"pages/screen/screen"},{"title":"3","page":"pages/detail/other/other","pageQuery":"id=228"},{"title":"4","page":"pages/pdf/pdf"},{"title":"5","page":"pages/detail/accountLimit/accountLimit","pageQuery":"id=217"},{"title":"6","page":"pages/detail/reimbursement/reimbursement","pageQuery":"id=204"},{"title":"7","page":"pages/detail/payment/payment","pageQuery":"id=191"},{"title":"8","page":"pages/pdf/pdf"}],"compilerIndex":0,"storageVersion":"1.5.10"}
\ No newline at end of file
{"tinyType":"dingtalk","tinyCnName":"钉钉","tinyProjectType":"dingtalk-biz","dingtalk:dingtalk-biz-isv:tinyIcon":"https://gw.alipayobjects.com/zos/rmsportal/mAzWuEDGpTlpugsPXgzf.svg","dingtalk:dingtalk-biz-isv:compilePreviewTime":"","dingtalk:dingtalk-biz-isv:compilePreviewWholePackSize":"","dingtalk:dingtalk-biz-isv:compilePreviewSubpackSizes":"","dingtalk:dingtalk-biz-isv:_appIdList":[],"dingtalk:dingtalk-biz-isv:preAuditLimit":10,"dingtalk:dingtalk-biz-isv:preAuditUsed":0,"dingtalk:dingtalk-biz-isv:uploadTime":"","dingtalk:dingtalk-biz-isv:packageSize":"","dingtalk:dingtalk-biz-isv:auditLink":null,"dingtalk:dingtalk-biz-isv:whiteListLink":null,"dingtalk:dingtalk-biz-isv:_enableAutoPush":true,"dingtalk:dingtalk-biz-isv:lastDeviceName":"Nexus 6","SimulatorMode":"WINDOW","isSimulatorOpen":true,"isNotFirstToggleSimulator":true,"isSimulatorDefaultSticky":false,"dingtalk:dingtalk-biz:tinyIcon":"https://gw.alipayobjects.com/zos/rmsportal/mAzWuEDGpTlpugsPXgzf.svg","dingtalk:dingtalk-biz:compilePreviewTime":"2020-04-10 15:19:09","dingtalk:dingtalk-biz:compilePreviewWholePackSize":"70.5 KB","dingtalk:dingtalk-biz:compilePreviewSubpackSizes":"","dingtalk:dingtalk-biz:_appIdList":[{"orgName":"深圳市猎芯科技有限公司","corpId":"dinga60eaa15e871b53535c2f4657eb6378f","orgLogo":"@lALOiBEIWs0BOM0CgA","orgId":12488944,"apps":[{"miniAppName":"猎芯云仓","bizType":2,"miniAppId":"2021001152657489","icon":"https://static.dingtalk.com/media/lALPDfJ6OzgcKq5NTQ_77_77.png"}]},{"orgName":"创宇天下科技有限公司","corpId":"ding93fe2dfb8cef1afd","orgId":9213150,"apps":[{"miniAppName":"DEMO","bizType":2,"miniAppId":"2018102261820458","icon":"https://static.dingtalk.com/media/lADPBY0V4-e-L6TNAZDNAbU_437_400.jpg"}]}],"dingtalk:dingtalk-biz:preAuditLimit":10,"dingtalk:dingtalk-biz:preAuditUsed":0,"dingtalk:dingtalk-biz:uploadTime":"","dingtalk:dingtalk-biz:packageSize":"","dingtalk:dingtalk-biz:auditLink":null,"dingtalk:dingtalk-biz:whiteListLink":null,"dingtalk:dingtalk-biz:_enableAutoPush":false,"dingtalk:dingtalk-biz:_appId":"2018102261820458","dingtalk:dingtalk-biz:_appName":"DEMO","dingtalk:dingtalk-biz:_orgId":9213150,"dingtalk:dingtalk-biz:_corpId":"ding93fe2dfb8cef1afd","dingtalk:dingtalk-biz:remoteVersion":"0.0.1","dingtalk:dingtalk-biz:currentVersion":"0.0.2","dingtalk:dingtalk-biz:whiteList":["dd.yemxing.com","user.liexin.net","user.liexin.com"],"dingtalk:dingtalk-biz:h5WhiteList":[],"taobao:taobao-mini:tinyIcon":"https://gw.alicdn.com/tfs/TB1as1idqSs3KVjSZPiXXcsiVXa-21-21.svg","dingtalk:dingtalk-biz:lastDeviceName":"iPhone 6","dingtalk:dingtalk-biz:MockStore":{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91c2VyLmxpZXhpbi5uZXRcL2Rpbmd0YWxrXC9sb2dpbiIsImlhdCI6MTU4NjUxMzkxNywiZXhwIjoxNTg2NTEzOTc3LCJuYmYiOjE1ODY1MTM5MTcsImp0aSI6Inlsd1VhdFVVUVZxNEtUMU0iLCJzdWIiOjE1NzgsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.OlmVGUnaLFqBsUKUm6Z_Ey6sT2AzTN0TDd_QdpmA4qo"},"compilerList":[{"title":"普通编译","query":"","page":""},{"title":"1","page":"pages/search/search","pageQuery":"type=3"},{"title":"2","page":"pages/screen/screen"},{"title":"3","page":"pages/detail/other/other","pageQuery":"id=228"},{"title":"4","page":"pages/pdf/pdf"},{"title":"5","page":"pages/detail/accountLimit/accountLimit","pageQuery":"id=217"},{"title":"6","page":"pages/detail/reimbursement/reimbursement","pageQuery":"id=204"},{"title":"7","page":"pages/detail/payment/payment","pageQuery":"id=191"},{"title":"8","page":"pages/pdf/pdf"},{"title":"9","page":"pages/tabs/alreadyApproval/alreadyApproval"}],"compilerIndex":0,"storageVersion":"1.5.10"}
\ No newline at end of file
{"layout":{"left":{"currentId":"explorer","size":310},"right":{"currentId":""},"bottom":{"currentId":"devtools","size":501}},"storageVersion":"1.5.10"}
\ No newline at end of file
{"layout":{"left":{"currentId":"search","size":310},"right":{"currentId":""},"bottom":{"currentId":"devtools","size":501}},"storageVersion":"1.5.10"}
\ No newline at end of file
{"OPENED_FILE":["file:///e%3A/DingProgram/blank/pages/search/search.js","file:///e%3A/DingProgram/blank/pages/search/search.acss","file:///e%3A/DingProgram/blank/pages/tabs/waitApproval/waitApproval.js","file:///e%3A/DingProgram/blank/res/css/tab.acss","file:///e%3A/DingProgram/blank/pages/tabs/waitApproval/waitApproval.axml","file:///e%3A/DingProgram/blank/pages/tabs/launchApproval/launchApproval.axml","file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.js","file:///e%3A/DingProgram/blank/pages/tabs/launchApproval/launchApproval.js","file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.axml","file:///e%3A/DingProgram/blank/pages/search/search.axml","file:///e%3A/DingProgram/blank/pages/detail/payment/payment.js","file:///e%3A/DingProgram/blank/pages/detail/payment/payment.axml","file:///e%3A/DingProgram/blank/app.json","file:///e%3A/DingProgram/blank/pages/detail/other/other.js","file:///e%3A/DingProgram/blank/pages/detail/accountLimit/accountLimit.js","file:///e%3A/DingProgram/blank/pages/detail/payment/payment.json","file:///e%3A/DingProgram/blank/pages/detail/reimbursement/reimbursement.js","file:///e%3A/DingProgram/blank/pages/pdf/pdf.axml","file:///e%3A/DingProgram/blank/pages/pdf/pdf.json","file:///e%3A/DingProgram/blank/pages/pdf/pdf.js","file:///e%3A/DingProgram/blank/res/js/axios.js","file:///e%3A/DingProgram/blank/pages/detail/reimbursement/reimbursement.json","file:///e%3A/DingProgram/blank/pages/detail/other/other.json","file:///e%3A/DingProgram/blank/pages/detail/accountLimit/accountLimit.axml","file:///e%3A/DingProgram/blank/pages/detail/reimbursement/reimbursement.axml","file:///e%3A/DingProgram/blank/pages/detail/other/other.axml","file:///e%3A/DingProgram/blank/res/css/detail.acss","file:///e%3A/DingProgram/blank/pages/nav/nav.js","file:///e%3A/DingProgram/blank/pages/screen/screen.js","file:///e%3A/DingProgram/blank/res/js/apis.js","file:///e%3A/DingProgram/blank/pages/screen/screen.axml","file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.acss","file:///e%3A/DingProgram/blank/pages/tabs/waitApproval/waitApproval.json","file:///e%3A/DingProgram/blank/pages/tabs/launchApproval/launchApproval.json","file:///e%3A/DingProgram/blank/app.js","file:///e%3A/DingProgram/blank/pages/nav/nav.axml","file:///e%3A/DingProgram/blank/app.acss","file:///e%3A/DingProgram/blank/res/js/aixos.js","file:///e%3A/DingProgram/blank/debug.log","file:///e%3A/DingProgram/blank/snapshot.png","file:///e%3A/DingProgram/blank/pages/screen/screen.acss","file:///e%3A/DingProgram/blank/pages/search/search.json","file:///e%3A/DingProgram/blank/pages/screen/screen.json","file:///e%3A/DingProgram/blank/pages/login/login.js","file:///e%3A/DingProgram/blank/pages/detail/payment/payment.acss","file:///e%3A/DingProgram/blank/pages/login/login.json","file:///e%3A/DingProgram/blank/pages/detail/accountLimit/accountLimit.json","file:///e%3A/DingProgram/blank/pages/detail/accountLimit/accountLimit.acss","file:///e%3A/DingProgram/blank/pages/detail/reimbursement/reimbursement.acss","file:///e%3A/DingProgram/blank/pages/detail/other/other.acss"],"storageVersion":"1.5.10"}
\ No newline at end of file
{"OPENED_FILE":["file:///e%3A/DingProgram/blank/res/js/axios.js","file:///e%3A/DingProgram/blank/pages/nav/nav.js","file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.js","file:///e%3A/DingProgram/blank/pages/tabs/waitApproval/waitApproval.js","file:///e%3A/DingProgram/blank/pages/search/search.js","file:///e%3A/DingProgram/blank/pages/search/search.acss","file:///e%3A/DingProgram/blank/res/css/tab.acss","file:///e%3A/DingProgram/blank/pages/tabs/waitApproval/waitApproval.axml","file:///e%3A/DingProgram/blank/pages/tabs/launchApproval/launchApproval.axml","file:///e%3A/DingProgram/blank/pages/tabs/launchApproval/launchApproval.js","file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.axml","file:///e%3A/DingProgram/blank/pages/search/search.axml","file:///e%3A/DingProgram/blank/pages/detail/payment/payment.js","file:///e%3A/DingProgram/blank/pages/detail/payment/payment.axml","file:///e%3A/DingProgram/blank/app.json","file:///e%3A/DingProgram/blank/pages/detail/other/other.js","file:///e%3A/DingProgram/blank/pages/detail/accountLimit/accountLimit.js","file:///e%3A/DingProgram/blank/pages/detail/payment/payment.json","file:///e%3A/DingProgram/blank/pages/detail/reimbursement/reimbursement.js","file:///e%3A/DingProgram/blank/pages/pdf/pdf.axml","file:///e%3A/DingProgram/blank/pages/pdf/pdf.json","file:///e%3A/DingProgram/blank/pages/pdf/pdf.js","file:///e%3A/DingProgram/blank/pages/detail/reimbursement/reimbursement.json","file:///e%3A/DingProgram/blank/pages/detail/other/other.json","file:///e%3A/DingProgram/blank/pages/detail/accountLimit/accountLimit.axml","file:///e%3A/DingProgram/blank/pages/detail/reimbursement/reimbursement.axml","file:///e%3A/DingProgram/blank/pages/detail/other/other.axml","file:///e%3A/DingProgram/blank/res/css/detail.acss","file:///e%3A/DingProgram/blank/pages/screen/screen.js","file:///e%3A/DingProgram/blank/res/js/apis.js","file:///e%3A/DingProgram/blank/pages/screen/screen.axml","file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.acss","file:///e%3A/DingProgram/blank/pages/tabs/waitApproval/waitApproval.json","file:///e%3A/DingProgram/blank/pages/tabs/launchApproval/launchApproval.json","file:///e%3A/DingProgram/blank/app.js","file:///e%3A/DingProgram/blank/pages/nav/nav.axml","file:///e%3A/DingProgram/blank/app.acss","file:///e%3A/DingProgram/blank/res/js/aixos.js","file:///e%3A/DingProgram/blank/debug.log","file:///e%3A/DingProgram/blank/snapshot.png","file:///e%3A/DingProgram/blank/pages/screen/screen.acss","file:///e%3A/DingProgram/blank/pages/search/search.json","file:///e%3A/DingProgram/blank/pages/screen/screen.json","file:///e%3A/DingProgram/blank/pages/login/login.js","file:///e%3A/DingProgram/blank/pages/detail/payment/payment.acss","file:///e%3A/DingProgram/blank/pages/login/login.json","file:///e%3A/DingProgram/blank/pages/detail/accountLimit/accountLimit.json","file:///e%3A/DingProgram/blank/pages/detail/accountLimit/accountLimit.acss","file:///e%3A/DingProgram/blank/pages/detail/reimbursement/reimbursement.acss","file:///e%3A/DingProgram/blank/pages/detail/other/other.acss"],"SEARCH_WORD":["catch","1"],"storageVersion":"1.5.10"}
\ No newline at end of file
{"grid":{"editorGroup":{"uris":[],"previewIndex":-1}},"storageVersion":"1.5.10"}
\ No newline at end of file
{"grid":{"splitDirection":1,"children":[{"editorGroup":{"uris":["file:///e%3A/DingProgram/blank/res/js/axios.js","file:///e%3A/DingProgram/blank/pages/nav/nav.js","file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.js"],"current":"file:///e%3A/DingProgram/blank/res/js/axios.js","previewIndex":-1}},{"editorGroup":{"uris":["file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.js"],"current":"file:///e%3A/DingProgram/blank/pages/tabs/alreadyApproval/alreadyApproval.js","previewIndex":-1}}]},"storageVersion":"1.5.10"}
\ No newline at end of file
This diff could not be displayed because it is too large.
......@@ -2,7 +2,9 @@ import axios from '/res/js/axios';
Page({
data: {},
onLoad() {
axios.checkToken({isCallBack:false})
axios.checkToken({isCallBack:false})
// axios.getToken()
},
});
......@@ -31,10 +31,15 @@ const axios = ({ method = 'GET', url1, url2, data = {}, isLoading = true }) => {
}
// 获取token
const getToken = () => {
let token = dd.getStorageSync({ key: 'token' });
if (token.data) {
return
}
return new Promise((resolve, reject) => {
dd.getAuthCode({
success: function (res) {
axios({ url2: apis.login, data: { authCode: res.authCode }, isLoading: false }).then((res) => {
// axiosSy({ url2: apis.login, data: { authCode: res.authCode }, isLoading: false, isGetToken: true }).then((res) => {
axios({ url2: apis.login, data: { authCode: res.authCode }, isLoading: false}).then((res) => {
if (res.data.errcode == 0) {
console.log('重新获取')
dd.setStorageSync({
......@@ -54,15 +59,16 @@ const getToken = () => {
//校验token是否失效
const checkToken = ({ url, data, isLoading = true, isCallBack = true, method = 'GET' } = {}) => {
let token = dd.getStorageSync({ key: 'token' });
if (token.data) {
//如果token存在
return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
if (token.data) {
//如果token存在
axios({ url2: apis.me, data: { token: token.data }, isLoading: false }).then((res) => {
if (res.data.errcode == 0) {
//token未失效
if (isCallBack) {
axios({ url1: url, data: { ...data, token: token.data }, isLoading: isLoading, method: method }).then(res => { resolve(res) }).catch(err => { reject(err) })
}
} else if (res.data.errcode == 501) {
//token失效
......@@ -88,13 +94,23 @@ const checkToken = ({ url, data, isLoading = true, isCallBack = true, method = '
});
}
})
})
} else {
//如果token不存在
console.log('token不存在')
if (isCallBack) {
getToken().then(() => {
let token = dd.getStorageSync({ key: 'token' });
axios({ url1: url, data: { ...data, token: token.data }, isLoading: isLoading, method: method }).then(res => {
resolve(res)
}).catch(err => { reject(err) })
})
} else {
getToken()
}
}
})
} else {
//如果token不存在
console.log('token不存在')
getToken()
}
}
//根据type值去判断页面跳转的详情页面
const toDetail = (type, id) => {
......@@ -159,9 +175,72 @@ const toSee = (src) => {
})
}
}
//不通过接口校验token失效,通过接口的返回值校验
const axiosSy = ({ method = 'GET', url1, url2, data = {}, isLoading = true, isGetToken = false }) => {
let url = url1 ? (host1 + url1) : (host2 + url2);
let token = dd.getStorageSync({ key: 'token' });
let params = data;
if (!isGetToken) {
params = { ...data, token: token.data }
}
return new Promise((resolve, reject) => {
if (!token.data) {
//token不存在
if (!isGetToken) {
getToken().then(() => {
axiosSy({ method, url1, url2, data, isLoading }).then((res) => {
resolve(res)
})
})
return
} else {
console.log('单独获取token')
}
}
isLoading &&
dd.showLoading({
content: '加载中...',
});
dd.httpRequest({
url: url,
method: method,
data: params,
success: function (res) {
isLoading && dd.hideLoading();
if (res.data.errcode == 501) {
//token过期
dd.removeStorageSync({
key: 'token',
})
getToken().then(() => {
axiosSy({ method, url1, url2, data, isLoading }).then((res) => {
resolve(res)
})
})
} else {
resolve(res)
}
},
fail: function (err) {
isLoading && dd.hideLoading();
dd.showToast({
type: 'fail',
content: '服务器异常'
});
reject('服务器异常')
}
});
})
}
export default {
checkToken,
toDetail,
toDeal,
toSee
toSee,
axiosSy,
getToken
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment