diff --git a/config/api.js b/config/api.js index 2e74830..f5a2c26 100644 --- a/config/api.js +++ b/config/api.js @@ -11,7 +11,7 @@ export const getLoginCode = (data) => http.post('member/auth/send-sms-code', dat // 获取个人信息 export const getUserInfo = (data) => http.post('member/user/get', {header: {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}}) // 退出登录 -export const logOut = (data={}) => http.post('member/auth/logout', data, { custom: { noToken: true }}) +export const logOut = (data={}) => http.post('member/auth/logout', data,) // 驾校列表分页 export const schoolPage = (params) => http.get('business/school/page', {params: params}) // 教练列表分页 @@ -26,6 +26,12 @@ export const getarticleList = (params) => http.get('business/video/article', {pa export const getarticlezcList = (params) => http.get('business/video/articlezc', {params: params}) // 行业资讯,行业政策 详情 export const getarticle = (params) => http.get('business/video/getarticle', {params: params}) +// 驾照类型 +export const licenseType = () => http.get('system/dict/licenseType', ) +// 区域 +export const nachangList = () => http.get('system/area/nachangList', ) + + diff --git a/config/request.js b/config/request.js index 77fe272..69cf8f3 100644 --- a/config/request.js +++ b/config/request.js @@ -76,7 +76,8 @@ module.exports = (vm) => { } // 如果不需要token就把header里的token删除,并且不需要去刷新token let noToken = response.config.custom?.noToken - if(!noToken) { + console.log(response.config.url) + if(!noToken&&response.config.url!=='member/auth/logout') { checkToken(vm) } return data === undefined ? {} : data diff --git a/index.html b/index.html index c3ff205..dedf438 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,8 @@ '') + + diff --git a/pages/indexEntry/findShcool/findShcool.vue b/pages/indexEntry/findShcool/findShcool.vue index ee2f068..144ea2c 100644 --- a/pages/indexEntry/findShcool/findShcool.vue +++ b/pages/indexEntry/findShcool/findShcool.vue @@ -6,7 +6,7 @@ - + {{ item.text }} 筛选 @@ -38,26 +38,27 @@ currentTab: 0, tabData: [{ text: '全部', - id: 0 + id: 1 }, { text: '场地优先', - id: 1 + id: 2 }, { text: '距离优先', - id: 2 + id: 3 }, { text: '好评优先', - id: 3 + id: 4 }, ], params: { pageNo: 1, pageSize: 20, - lat: 30.27419537786047, - lng: 120.20633397715788, + lat: '', + lng: '', + sercheType: 1, }, total: 20, listData: [], @@ -65,7 +66,19 @@ } }, onLoad() { - this.schoolPageFn() + let vuex_cityInfo = this.$store.state.user.vuex_cityInfo + if(!vuex_cityInfo.lat) { + this.$store.dispatch('getCity') + return + }else { + this.params.lat = vuex_cityInfo.lat + this.params.lng = vuex_cityInfo.lng + this.schoolPageFn() + } + uni.$on('screenConfirm',(obj)=>{ + this.params = Object.assign(this.params, obj) + this.listInit() + }) }, onPullDownRefresh() { this.listInit() @@ -80,9 +93,11 @@ this.$goPage('/pages/indexEntry/findShcool/shcoolDetail/shcoolDetail?schoolId='+ item.id) }, tabClick(item) { - this.currentTab = item.id + this.params.sercheType = item.id + this.listInit() }, async listInit() { + this.listData = [] this.params.pageNo = 1 await this.schoolPageFn() diff --git a/pages/indexEntry/findShcool/screen/screen.vue b/pages/indexEntry/findShcool/screen/screen.vue index 6b54b84..7a31d41 100644 --- a/pages/indexEntry/findShcool/screen/screen.vue +++ b/pages/indexEntry/findShcool/screen/screen.vue @@ -4,17 +4,20 @@ 驾照类型 - {{ item.text }} + {{ item.label }} 区域 + + {{ item.areaName }} + 重置 - 确定 + 确定 @@ -22,30 +25,60 @@ + + \ No newline at end of file diff --git a/pages/tabbar/index/index.vue b/pages/tabbar/index/index.vue index 4952182..7df73d5 100644 --- a/pages/tabbar/index/index.vue +++ b/pages/tabbar/index/index.vue @@ -276,9 +276,9 @@ } }, async onLoad() { - // await this.$store.dispatch('getCity') + await this.$store.dispatch('getCity') // console.log('有 啦') - // console.log(this.$store.state.user.vuex_cityInfo.city) + // console.log(this.$store.state.user.vuex_cityInfo) }, onShow() { diff --git a/store/modules/user.js b/store/modules/user.js index d5c3f45..ec63add 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -1,4 +1,5 @@ import qqmapWx from '../../common/sdk/qqmap-wx-jssdk.min.js'; // 引入 +import { httpPrefix } from '../../config/site.config.js'; const user = { @@ -89,49 +90,94 @@ const user = { export default user -function getCityInfo(resolve, reject, commit) { - uni.showLoading({ - title: '加载中...' + +// h5高德地图 +function gaoDeFn(longitude,latitude,commit,resolve, reject,) { + uni.request({ + method: 'GET', + url: 'https://restapi.amap.com/v3/geocode/regeo?parameters', + data: { + key: 'a0dde4c05390e689ea2c19d8ec447f62', + location: `${longitude},${latitude}`, + output: 'JSON' + }, + success: (res) => { + console.log(res) // 数据结构见下方 + let result = res.data.regeocode.addressComponent + let obj = { + lat: latitude, + lng: longitude, + city: result.city, + cityCode: result.adcode, + province: result.province, + district: result.district + } + commit('update_vuex_cityInfo', obj) + resolve(obj) + uni.hideLoading() + }, + fail: res => { + reject(new Error('获取地理位置信息失败')) + uni.hideLoading() + } }) +} + +function wxAdsFn(longitude,latitude, commit,resolve, reject,) { var qqmapKey = new qqmapWx({ key: '2BTBZ-6BQRB-ZG4UG-NOYYG-KZMH7-B4BYN' }) + qqmapKey.reverseGeocoder({ + location: { + latitude: latitude, + longitude:longitude + }, + success(res2) { + // console.log('城市信息') + // console.log(res2.result) + let result = res2.result + let obj = { + lat: latitude, + lng: longitude, + city: result.address_component.city, + cityCode: result.ad_info.adcode, + province: result.address_component.province, + district: result.address_component.district + } + commit('update_vuex_cityInfo', obj) + resolve(obj) + uni.hideLoading(); + + }, + fail: function(res3) { + reject(res3) + uni.hideLoading(); + }, + }) +} + +function getCityInfo(resolve, reject, commit) { + uni.showLoading({ + title: '加载中...' + }) + uni.getLocation({ type: 'wgs84', // type: 'gcj02', success: function(res) { console.log('当前位置的经度:' + res.longitude); - console.log('当前位置的纬度:' + res.latitude); - qqmapKey.reverseGeocoder({ - location: { - latitude: res.latitude, - longitude: res.longitude - }, - success(res2) { - // console.log('城市信息') - // console.log(res2.result) - let result = res2.result - let obj = { - latitude: res.latitude, - longitude: res.longitude, - city: result.address_component.city, - cityCode: result.ad_info.adcode, - province: result.address_component.province, - district: result.address_component.district - } - commit('update_vuex_cityInfo', obj) - resolve(obj) - uni.hideLoading(); - - }, - fail: function(res3) { - reject(res3) - uni.hideLoading(); - }, - }) + console.log('当前位置的纬度:' + res); + // #ifdef APP-PLUS||H5 + gaoDeFn(res.longitude,res.latitude, commit, resolve, reject,); + // #endif + // #ifdef MP-WEIXIN + wxAdsFn(res.longitude,res.latitude, commit,resolve, reject,) + // #endif + }, fail(e) { console.log(e) + uni.hideLoading() } }) } \ No newline at end of file