From b5264ffd6c1b4394fd13e3a6ee95f8e511bb9f64 Mon Sep 17 00:00:00 2001
From: unknown <331404948@qq.com>
Date: Tue, 14 Nov 2023 18:58:38 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E6=93=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/nodata/nodata.vue | 4 +-
config/api.js | 5 +-
config/request.js | 38 ++---
config/utils.js | 4 +-
pages/carEntry/operaAppointment/comp/coachInfo.vue | 17 ++-
pages/carEntry/operaAppointment/comp/pickDate.vue | 35 ++---
pages/carEntry/operaAppointment/comp/step1.vue | 45 +++---
pages/carEntry/operaAppointment/comp/step2.vue | 12 +-
.../carEntry/operaAppointment/operaAppointment.vue | 53 +++++--
pages/tabbar/index/index.vue | 2 +-
pages/tabbar/learnCar/index - 副本.vue | 165 +++++++++++++++++++++
store/modules/user.js | 27 ++--
12 files changed, 326 insertions(+), 81 deletions(-)
create mode 100644 pages/tabbar/learnCar/index - 副本.vue
diff --git a/components/nodata/nodata.vue b/components/nodata/nodata.vue
index 9d911da..4a6c766 100644
--- a/components/nodata/nodata.vue
+++ b/components/nodata/nodata.vue
@@ -4,7 +4,9 @@
- 暂无数据
+
+ 暂无数据
+
diff --git a/config/api.js b/config/api.js
index dd56ea0..088a4c4 100644
--- a/config/api.js
+++ b/config/api.js
@@ -112,8 +112,6 @@ export const simulationPage = (params) => http.get('business/booking/simulation-
export const simulationDetail = (params) => http.get('business/booking/simulation-record/get', {params})
// 7取消模拟预约
export const cancelSimulationDevice = (params) => http.put('business/booking/simulation-record/cancelSimulation?id='+ params.id,)
-// 1新增实操预约记录
-export const masterCreate = (data) => http.post('business/booking/master/create', data)
// 1获得考场
export const examSitePage = (params) => http.get('business/exam-site/list', {params})
// 2获得车辆
@@ -130,6 +128,9 @@ export const examSimulationGet = (params) => http.get('business/exam-simulation-
export const cancelSimulation = (data) => http.put(`business/exam-simulation-record/cancelSimulation?id=${data.id}`)
// 1获得实操预约排课
export const scheduleClass = (params) => http.get('business/booking/schedule-class/get', {params})
+// 2,创建预约记录
+export const masterCreate = (data) => http.post('business/booking/master/create', data)
+
diff --git a/config/request.js b/config/request.js
index 85785b6..b31d288 100644
--- a/config/request.js
+++ b/config/request.js
@@ -16,7 +16,8 @@ module.exports = (vm) => {
config.baseURL = H5_API+ WX_API + prefix; /* 根域名 */
console.log(config.baseURL)
// config.header['content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
- config.header['tenant-id'] = vm.$store.state.user.vuex_userInfo.tenantId || 1
+ config.header['tenant-id'] = '1704459882232553474'
+ // config.header['tenant-id'] = vm.$store.state.user.vuex_userInfo.tenantId || '1704459882232553474'
return config
})
@@ -35,23 +36,33 @@ module.exports = (vm) => {
if(noToken&&config.header.Authorization) {
delete config.header.Authorization
}
+ console.log(config)
return config
}, config => { // 可使用async await 做异步操作
return Promise.reject(config)
})
// 响应拦截
- uni.$u.http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/
+ uni.$u.http.interceptors.response.use(async (response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/
const data = response.data
+ console.log(response.config)
console.log('请求结果')
console.log(data)
- if(data.code==406) {
- // vm.$store.dispatch('refreshToken')
- uni.$u.toast('登录过期,请重新登录')
- setTimeout(()=>{
- vm.$store.commit('goLogin')
- },1500)
- return false
+ if(data.code==406&&response.config.url!='member/auth/refresh-token'&&response.config.url!=='member/auth/logout') {
+ await vm.$store.dispatch('refreshToken')
+ // uni.$u.toast('登录过期,请重新登录')
+ // setTimeout(()=>{
+ // vm.$store.commit('goLogin')
+ // },1500)
+ // console.log(response.config)
+ let obj = response.config
+ if(obj.method=='GET') {
+ return uni.$u.http.get(obj.url, {params: obj.params})
+ }else if(obj.method=='PUT'){
+ return uni.$u.http.put(obj.url, obj.data )
+ }else if(obj.method=='POST'){
+ return uni.$u.http.post(obj.url, obj.data )
+ }
}
if(data.code==401) {
vm.$store.commit('goLogin')
@@ -73,14 +84,7 @@ module.exports = (vm) => {
return new Promise(() => { })
}
}
- // 如果不需要token就把header里的token删除,并且不需要去刷新token
- let noToken = response.config.custom?.noToken
- console.log(response.config.url)
- if(!noToken&&response.config.url!=='member/auth/logout') {
- checkToken(vm)
- }else {
- vm.$store.commit('update_apiOk', true)
- }
+
return data === undefined ? {} : data
}, (response) => {
// 对响应错误做点什么 (statusCode !== 200)
diff --git a/config/utils.js b/config/utils.js
index c129232..b2f7837 100644
--- a/config/utils.js
+++ b/config/utils.js
@@ -134,4 +134,6 @@ export function uploadImgApi(filePath, imgName) {
}
})
})
- }
\ No newline at end of file
+ }
+
+
\ No newline at end of file
diff --git a/pages/carEntry/operaAppointment/comp/coachInfo.vue b/pages/carEntry/operaAppointment/comp/coachInfo.vue
index f77fd12..dbd8e32 100644
--- a/pages/carEntry/operaAppointment/comp/coachInfo.vue
+++ b/pages/carEntry/operaAppointment/comp/coachInfo.vue
@@ -2,12 +2,13 @@
-
+
- 张三三
- 未绑定
+ {{ FormData.coachName }}
+ 已绑定
+ 未绑定
@@ -16,6 +17,15 @@
diff --git a/store/modules/user.js b/store/modules/user.js
index cb69f78..01984c1 100644
--- a/store/modules/user.js
+++ b/store/modules/user.js
@@ -88,19 +88,28 @@ const user = {
},
// 刷新token
async refreshToken({state, commit}) {
+ if(!state.apiOk) {
+ return state.refreshTokenFn
+ }
commit('update_apiOk',false)
const http = uni.$u.http
let config = { header: {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}, custom: { noToken: true } }
let refreshToken = state.vuex_loginInfo.refreshToken
- const res = await http.post('member/auth/refresh-token',{refreshToken}, config)
- console.log('刷新token结果')
- console.log(res)
- commit('update_apiOk',true)
- commit('update_vuex_loginInfo',res.data)
- uni.$u.http.setConfig((config) => {
- config.header.Authorization = 'Bearer ' + res.data.accessToken
- return config
- })
+ state.refreshTokenFn = await http.post('member/auth/refresh-token',{refreshToken}, config)
+ if(state.refreshTokenFn.data||state.refreshTokenFn.data.accessToken) {
+ console.log('刷新token结果')
+ console.log(state.refreshTokenFn)
+ commit('update_apiOk',true)
+ commit('update_vuex_loginInfo',state.refreshTokenFn.data)
+ uni.$u.http.setConfig((config) => {
+ config.header.Authorization = 'Bearer ' + state.refreshTokenFn.data.accessToken
+ return config
+ })
+ }else {
+ commit('goLogin')
+ return false
+ }
+
}
}
}