From 6ba84aa80dd9ad2f7c498772da61ebf348e8ff62 Mon Sep 17 00:00:00 2001 From: unknown <331404948@qq.com> Date: Mon, 20 Nov 2023 19:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BD=A6=E8=BE=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/callPhone/callPhone.vue | 60 +++++++++ config/api.js | 8 ++ config/request.js | 60 ++------- pages.json | 11 +- pages/recordEntry/operate/mySchedule/plan/plan.vue | 63 ++++++---- pages/tabbar/mine/index.vue | 2 +- pages/userCenter/examinInfo/comp/examinItem.vue | 43 ++++--- pages/userCenter/examinInfo/examinInfo.vue | 92 +++++++++++--- pages/userCenter/myCar/comp/unbind.vue | 6 + pages/userCenter/myCar/myCar.vue | 43 +++++-- pages/userCenter/myCar/notBound/notBound.vue | 138 +++++++++++++++++++++ pages/userCenter/studentComment/studentComment.vue | 37 +++--- store/modules/user.js | 39 ++++-- 13 files changed, 452 insertions(+), 150 deletions(-) create mode 100644 components/callPhone/callPhone.vue create mode 100644 pages/userCenter/myCar/notBound/notBound.vue diff --git a/components/callPhone/callPhone.vue b/components/callPhone/callPhone.vue new file mode 100644 index 0000000..81e6c62 --- /dev/null +++ b/components/callPhone/callPhone.vue @@ -0,0 +1,60 @@ + + + + + \ No newline at end of file diff --git a/config/api.js b/config/api.js index 3185068..736c70b 100644 --- a/config/api.js +++ b/config/api.js @@ -66,6 +66,14 @@ export const schoolCommentPage = (params) => http.get('business/school-comment/p export const updatePassword = (data) => http.put('system/user/profile/update-password', data) // 获得考场分页 export const simulationPage = (params) => http.get('business/booking/simulation-record/page', {params}) +// 获得考场列分页 +export const businessSitePage = (params) => http.get('business/site/page', {params}) +// 教练绑定教练车 +export const coachBinding = (data) => http.post('business/coach/binding', data) +// 取消绑定教练车 +export const coachUnbinding = (data) => http.put('business/coach/unbinding', data) + + diff --git a/config/request.js b/config/request.js index b9b54bc..2f189ae 100644 --- a/config/request.js +++ b/config/request.js @@ -1,9 +1,6 @@ import { H5_API, WX_API,httpPrefix } from './site.config.js' - -import { checkToken } from './utils' - const ContentType = ['application/json;charset=utf-8', 'application/x-www-form-urlencoded','multipart/form-data', 'application/x-www-form-urlencoded; charset=UTF-8']; @@ -24,7 +21,6 @@ module.exports = (vm) => { // 请求拦截 uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作 - console.log(config) let contentTypeIndex = config.header.contentType if(contentTypeIndex) { // alert(contentTypeIndex) @@ -42,53 +38,23 @@ module.exports = (vm) => { if(noToken&&config.header.Authorization) { delete config.header.Authorization } - - // get请求映射params参数 - // console.log(config.method) - // if (config.method === 'GET' && config.params) { - // // config.params = qs.stringify(config.params, { allowDots: true }) - // let url = config.url + '?'; - // for (const propName of Object.keys(config.params)) { - // const value = config.params[propName]; - // const part = encodeURIComponent(propName) + '=' - // if (value !== null && typeof(value) !== "undefined") { - - // if (typeof value === 'object') { - // for (const key of Object.keys(value)) { - // let params = propName + '[' + key + ']'; - // const subPart = params + '=' - // console.log(qs.stringify(value[key])) - // url += subPart + decodeURIComponent(value[key]) + "&"; - - // } - - // } else { - // url += part + encodeURI(value) + "&"; - // } - // } - // } - // url = url.slice(0, -1); - // // console.log(url) - // config.params = {}; - // config.url = url; - // } 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('请求结果') - // 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!='system/auth/refresh-token') { + await vm.$store.dispatch('refreshToken') + let obj = response.config + let method = obj.method.toLowerCase() + if(method=='get') { + return uni.$u.http[method](obj.url, {params: obj.params}) + }else{ + return uni.$u.http[method](obj.url, obj.data ) + } } if(data.code==401) { vm.$store.commit('goLogin') @@ -110,11 +76,7 @@ module.exports = (vm) => { return new Promise(() => { }) } } - // 如果不需要token就把header里的token删除,并且不需要去刷新token - let noToken = response.config.custom?.noToken - if(!noToken) { - checkToken(vm) - } + return data === undefined ? {} : data }, (response) => { // 对响应错误做点什么 (statusCode !== 200) diff --git a/pages.json b/pages.json index a118bf9..7fce8b7 100644 --- a/pages.json +++ b/pages.json @@ -300,7 +300,7 @@ "style": { "navigationBarTitleText": "考场信息", "navigationStyle": "custom", - "enablePullDownRefresh": false, + "enablePullDownRefresh": true, "backgroundTextStyle": "dark" } }, @@ -314,6 +314,15 @@ } }, { + "path": "myCar/notBound/notBound", + "style": { + "navigationBarTitleText": "未绑定车辆", + "navigationStyle": "custom", + "enablePullDownRefresh": true, + "backgroundTextStyle": "dark" + } + }, + { "path": "teachingData/teachingData", "style": { "navigationBarTitleText": "教学数据", diff --git a/pages/recordEntry/operate/mySchedule/plan/plan.vue b/pages/recordEntry/operate/mySchedule/plan/plan.vue index 39dfb8f..c3170a4 100644 --- a/pages/recordEntry/operate/mySchedule/plan/plan.vue +++ b/pages/recordEntry/operate/mySchedule/plan/plan.vue @@ -55,9 +55,7 @@ {{item.startTime}} - {{item.endTime}} {{item.personCount}}人 - + 训练科目 @@ -65,10 +63,16 @@ + - 教练车 - - + 选择教练车 + + + + + + + @@ -90,11 +94,12 @@ @cancel="show=false" > + \ No newline at end of file diff --git a/pages/userCenter/studentComment/studentComment.vue b/pages/userCenter/studentComment/studentComment.vue index e570631..3c89c08 100644 --- a/pages/userCenter/studentComment/studentComment.vue +++ b/pages/userCenter/studentComment/studentComment.vue @@ -3,10 +3,10 @@ - + - 全部(0) + 全部(缺字段) 匿名(1) 有图(2) 有视频(3) @@ -16,6 +16,11 @@ + + + + + @@ -26,17 +31,12 @@ data() { return { list: [], - tabData: [ - {id: 0, lab: '全部'}, - {id: 1, lab: '有图'}, - {id: 2, lab: '匿名'}, - {id: 3, lab: '有视频'}, - ], params: { pageNo: 1, pageSize: 20, - schoolId: '1590992062959960065', - condition: 0 + schoolId: '', + condition: 0, + studentName: '' }, // 0查全部 1有图 2最新 3有视频 total: 20, @@ -58,6 +58,10 @@ } }, methods: { + searchFn(val) { + this.params.studentName = val + this.initList() + }, changeTab(val) { this.params.condition = val this.initList() @@ -65,13 +69,16 @@ initList() { this.list = [] this.params.pageNo = 1 + this.status = 'loading' this.schoolCommentPageFn() }, async schoolCommentPageFn() { if(this.identity=='校长') { var {data: res} = await schoolCommentPage(this.params) }else { - var {data: res} = await coachCommentPage(this.params) + let obj = Object.assign({},this.params) + obj.coachId = this.vuex_coachId + var {data: res} = await coachCommentPage(obj) } this.params.pageNo ++ let arr = res.list.map(item=>{ @@ -89,13 +96,7 @@ } console.log(res) }, - searchFn(val) { - console.log(val) - this.params.name = val - this.list = [] - this.params.pageNo = 1 - this.schoolCommentPageFn() - } + } } diff --git a/store/modules/user.js b/store/modules/user.js index a2e5d53..b369c0b 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -14,7 +14,8 @@ const user = { coach: '实操教练', examSiteCoach: '考场模拟教练', bookingSimulationTeacher: '模拟器老师' - } + }, + apiOk: true }, mutations: { // 更新用户身份 @@ -42,6 +43,9 @@ const user = { return config }) }, + update_apiOk(state, payload) { + state.apiOk = payload + }, goLogin(state) { uni.clearStorageSync() state.vuex_loginInfo = {} @@ -62,16 +66,29 @@ const user = { }, // 刷新token async refreshToken({state, commit}) { - 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('system/auth/refresh-token?refreshToken='+ refreshToken, config) - console.log('刷新token结果') - console.log(res) - commit('update_vuex_loginInfo',res.data) - uni.$u.http.setConfig((config) => { - config.header.Authorization = 'Bearer ' + res.data.accessToken - return config + return new Promise(async(resolve, reject)=>{ + if(!state.apiOk) { + return state.refreshTokenFn + } + commit('update_apiOk',false) + state.refreshTokenFn = null + 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 + state.refreshTokenFn = await http.post('system/auth/refresh-token?refreshToken='+ refreshToken, config) + if(state.refreshTokenFn.data||state.refreshTokenFn.data.accessToken) { + 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 + }) + resolve(state.refreshTokenFn) + }else { + commit('update_apiOk',true) + commit('goLogin') + reject('刷新token失败了') + } }) }, getCity({commit}) {