Browse Source

驾校列表调用

master
unknown 1 year ago
parent
commit
4f365d7076
  1. 8
      common/js/mixins.js
  2. 25
      components/callPhone/callPhone.vue
  3. 5
      config/api.js
  4. 9
      config/request.js
  5. 42
      config/utils.js
  6. 2
      pages.json
  7. 2
      pages/carEntry/operaAppointment/comp/step2.vue
  8. 4
      pages/carEntry/operaAppointment/comp/step3.vue
  9. 24
      pages/carEntry/operaAppointment/comp/step4.vue
  10. 30
      pages/carEntry/operaAppointment/operaAppointment.vue
  11. 110
      pages/carEntry/simulateAppointment/comp/step1.vue
  12. 8
      pages/indexEntry/enroll/registInfo/registInfo.vue
  13. 18
      pages/indexEntry/findShcool/comp/schoolItem.vue
  14. 48
      pages/indexEntry/findShcool/findShcool.vue
  15. 31
      pages/indexEntry/findShcool/shcoolDetail/comp/tab3.vue
  16. 31
      pages/indexEntry/findShcool/shcoolDetail/shcoolDetail.vue
  17. 2
      pages/tabbar/index/index.vue
  18. 2
      pages/tabbar/learnCar/comp/subject1.vue
  19. BIN
      static/images/index/avatar.png

8
common/js/mixins.js

@ -12,5 +12,11 @@ export default {
data() {
return {
}
}
},
onPullDownRefresh() {
setTimeout(()=>{
uni.stopPullDownRefresh()
},1500)
},
}

25
components/callPhone/callPhone.vue

@ -1,6 +1,6 @@
<template>
<view class="box">
<view class="phoneIcon" @click.stop="show=true">
<view class="phoneIcon" @click.stop="phoneClick">
<slot></slot>
</view>
<u-action-sheet :actions="servicePhone" :show="show" @select="callPhoneClick" :closeOnClickOverlay="true" @close="show=false" cancelText="取消"></u-action-sheet>
@ -10,16 +10,31 @@
<script>
export default {
// props: {
// servicePhone: {
// type: Array,
// default: []
// }
// },
props: ['servicePhone'],
data() {
return {
servicePhone: [
{name: '18267103167'},
{name: '18267103168'},
],
// servicePhone: [
// {name: '18267103167'},
// {name: '18267103168'},
// ],
show: false
}
},
methods: {
phoneClick() {
if(!this.servicePhone) return false
if(this.servicePhone.length==1) {
this.callPhoneClick(this.servicePhone[0])
}else {
show=true
}
},
callPhoneClick(item) {
let phone = item.name

5
config/api.js

@ -12,6 +12,11 @@ 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 schoolPage = (params) => http.get('business/school/page', {params: params})
// 教练列表分页
export const coachPage = (params) => http.get('business/coach/page', {params: params})

9
config/request.js

@ -33,14 +33,10 @@ module.exports = (vm) => {
if(token) {
config.header.Authorization = 'Bearer ' + token
}
// 如果不需要token就把header里的token删除,并且不需要去刷新token
let noToken = config.custom?.noToken
if(noToken&&config.header.Authorization) {
delete config.header.Authorization
}
if(!noToken) {
checkToken(vm)
}
return config
}, config => { // 可使用async await 做异步操作
return Promise.reject(config)
@ -79,6 +75,11 @@ 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)

42
config/utils.js

@ -1,4 +1,3 @@
export function checkToken(vm) {
let expiresTime = vm.$store.state.user.vuex_loginInfo.expiresTime
let nowTime = new Date() * 1
@ -7,7 +6,46 @@ export function checkToken (vm) {
if (nowTime > expiresTime * 1) {
vm.$store.commit('goLogin')
// 如果小于20分钟就刷新一下token &&
}else if((expiresTime*1 - nowTime) / 60000 < 10 ) {
} else if ((expiresTime * 1 - nowTime) / 60000 < 30) {
vm.$store.dispatch('refreshToken')
}
}
function dateRangeFn(dateRange) {
let tmp = []
let dateArr = []
dateRange.forEach((date) => {
let dateStr = date.toISOString().split('T')[0]
let dd = dateStr.split('-')[2]
const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
const dayOfWeek = date.getDay();
const weekName = daysOfWeek[dayOfWeek];
console.log(dateStr)
console.log(weekName)
if (tmp.length == 0) {
dateArr.push(tmp)
}
let obj = {
week: weekName,
num: dd,
date: dateStr
}
tmp.push(obj)
if (tmp.length == 5) {
tmp = []
}
});
console.log(dateArr)
return dateArr
}
export function getDates(startDate, endDate) {
const dates = [];
let currentDate = new Date(startDate);
while (currentDate <= endDate) {
dates.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}
return dateRangeFn(dates)
}

2
pages.json

@ -129,7 +129,7 @@
"style": {
"navigationBarTitleText": "找驾校",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"
}
},

2
pages/carEntry/operaAppointment/comp/step2.vue

@ -1,6 +1,6 @@
<template>
<view class="step2">
<searchBox placeholder="搜索场地名称"></searchBox>
<searchBox placeholder="搜索场地名称" key="step3"></searchBox>
<view class="card" v-for="(item,index) in 10" :key="index" :class="{active: index==2}">
<view class="leftTxt">
<view class="name oneRowText">某某模拟驾驶馆</view>

4
pages/carEntry/operaAppointment/comp/step3.vue

@ -1,6 +1,6 @@
<template>
<view class="step3">
<searchBox placeholder="搜索车辆编号或车牌号"></searchBox>
<searchBox placeholder="搜索车辆编号或车牌号" key="step3"></searchBox>
<view class="card">
<view class="list">
<view class="listItem" v-for="(item,index) in list" :key="index" :class="{active: index==1}">
@ -20,7 +20,9 @@
</template>
<script>
import searchBox from './searchBox'
export default {
components: { searchBox },
data() {
return {
list: [{

24
pages/carEntry/operaAppointment/comp/step4.vue

@ -63,7 +63,7 @@
<view class="poz_btn">
<view class="btn_row" >
<view class="border btn" @click="changeStep(3)">返回上一步</view>
<view class="btn" >确认预约</view>
<view class="btn" @click="show = true">确认预约</view>
</view>
</view>
@ -73,20 +73,25 @@
<view class="content">
<view class="row">
<view class="lab">预约类型</view>
<view class="val">模拟器训练预约</view>
<view class="val">实操训练预约</view>
</view>
<view class="row">
<view class="lab">预约时间</view>
<view class="val">2023/08/08 08:009:00</view>
<view class="lab">预约科目</view>
<view class="val">科目二</view>
</view>
<view class="row">
<view class="lab">模拟驾驶馆</view>
<view class="val">某某模拟驾驶馆</view>
<view class="lab">预约场地</view>
<view class="val">xxx场地</view>
</view>
<view class="row">
<view class="lab">预约模拟器</view>
<view class="val">00002</view>
<view class="lab">预约车辆</view>
<view class="val">02号车</view>
</view>
<view class="row">
<view class="lab">预约时间</view>
<view class="val">2023/08/08 08:009:00</view>
</view>
</view>
<view class="btn_row">
<view class="border btn" @click="show = false">返回修改</view>
@ -108,7 +113,7 @@
{week: '四', num: '11'},
{week: '五', num: '12'},
],
show: true
show: false
}
},
methods: {
@ -279,6 +284,7 @@
line-height: 70rpx;
font-size: 36rpx;
text-align: center;
margin-bottom: 20rpx;
}
.content {

30
pages/carEntry/operaAppointment/operaAppointment.vue

@ -1,27 +1,27 @@
<template>
<view class="pageBgImg">
<topNavbar title="实操训练预约"></topNavbar>
<topNavbar :title="title"></topNavbar>
<view class="pad">
<view class="top_row">
<view class="step_row">
<view class="dian" @click="changeStep(1)">
<!-- <view class="dian" @click="changeStep(1)">
<view class="num" :class="{active: currentStep==1}">1</view>
</view>
<view class="line"></view>
</view> -->
<!-- <view class="line"></view> -->
<view class="dian" @click="changeStep(2)">
<view class="num" :class="{active: currentStep==2}">2</view>
<view class="num" :class="{active: currentStep==2}">1</view>
</view>
<view class="line"></view>
<view class="dian" @click="changeStep(3)">
<view class="num" :class="{active: currentStep==3}">3</view>
<view class="num" :class="{active: currentStep==3}">2</view>
</view>
<view class="line"></view>
<view class="dian" @click="changeStep(4)">
<view class="num" :class="{active: currentStep==4}">4</view>
<view class="num" :class="{active: currentStep==4}">3</view>
</view>
</view>
<view class="step_text">
<view class="txt">选择科目</view>
<!-- <view class="txt">选择科目</view> -->
<view class="txt">选择场地</view>
<view class="txt">选择车辆</view>
<view class="txt">预约时间</view>
@ -45,7 +45,19 @@
components: { step1, step2, step3, step4 },
data() {
return {
currentStep: 1
currentStep: 2,
subject: 2,
title: '实操训练预约'
}
},
onLoad(options) {
this.subject = options.subject
if(this.subject==2) {
this.title = '实操训练科目二预约'
this.currentStep = 2
}else if(this.subject==3) {
this.title = '实操训练科目三预约'
this.currentStep = 2
}
},
methods: {

110
pages/carEntry/simulateAppointment/comp/step1.vue

@ -13,11 +13,13 @@
<u-icon name="arrow-left" :size="12" :color="'#fff'"></u-icon>
</view>
<view class="dateArr" >
<view class="date" v-for="(item,index) in dateArr[currentDay]" :key="index" :class="{active: index==1}">
<view class="dateWidth" v-for="(item,index) in dateArr[currentDay]" :key="index" @click="chooseDate(item)" >
<view class="date" :class="{active: chooseDay==item.date}">
<view class="week">{{ item.week }}</view>
<view class="num">{{ item.num }}</view>
</view>
</view>
</view>
<view class="icon right" @click="changeDateIndex(1)">
<u-icon name="arrow-right" :size="12" :color="'#fff'"></u-icon>
</view>
@ -29,32 +31,20 @@
<view class="timeCon">
<view class="h2">上午</view>
<view class="time_box">
<view class="time_item">
<view class="lab">已过期</view>
<view class="time">06:00-07:00</view>
</view>
<view class="time_item">
<view class="lab">已约满</view>
<view class="time">06:00-07:00</view>
</view>
<view class="time_item">
<view class="lab">可预约</view>
<view class="time">06:00-07:00</view>
<view class="time_item" v-for="(item,index) in timerArr" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId, disable: item.status!==1}">
<view class="lab" v-if="item.status==3">已过期</view>
<view class="lab" v-if="item.status==2">已约满</view>
<view class="lab" v-if="item.status==1">可预约</view>
<view class="time">{{ item.timer }}</view>
</view>
</view>
<view class="h2">下午</view>
<view class="time_box">
<view class="time_item">
<view class="lab">已过期</view>
<view class="time">06:00-07:00</view>
</view>
<view class="time_item">
<view class="lab">已约满</view>
<view class="time">06:00-07:00</view>
</view>
<view class="time_item">
<view class="lab">可预约</view>
<view class="time">06:00-07:00</view>
<view class="time_item" v-for="(item,index) in timerArr2" :key="index" @click="chooseTimerClick(item)" :class="{active: item.id==chooseTimerId,disable: item.status!==1}">
<view class="lab" v-if="item.status==3">已过期</view>
<view class="lab" v-if="item.status==2">已约满</view>
<view class="lab" v-if="item.status==1">可预约</view>
<view class="time">{{ item.timer }}</view>
</view>
</view>
</view>
@ -65,42 +55,44 @@
</template>
<script>
import { getDates } from '@/config/utils.js'
export default {
data() {
return {
dateArr: [],
currentDay: 0
currentDay: 0,
chooseDay: '',
timerArr: [
{status: 1, timer: '06:00-07:00', id: 1},
{status: 2, timer: '06:00-07:00', id: 2},
{status: 3, timer: '06:00-07:00', id: 3},
],
timerArr2: [
{status: 1, timer: '06:00-07:00', id: 4},
{status: 2, timer: '06:00-07:00', id: 5},
{status: 3, timer: '06:00-07:00', id: 6},
],
chooseTimerId: ''
}
},
mounted() {
const startDate = new Date('2023-09-06');
const endDate = new Date('2023-09-19');
const dateRange = this.getDates(startDate, endDate);
console.log(dateRange)
let tmp = []
dateRange.forEach((date) => {
let dateStr = date.toISOString().split('T')[0]
let dd = dateStr.split('-')[2]
const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
const dayOfWeek = date.getDay();
const weekName = daysOfWeek[dayOfWeek];
console.log(dateStr)
console.log(weekName)
if(tmp.length==0) {
this.dateArr.push(tmp)
}
let obj = {
week: weekName,
num: dd
}
tmp.push(obj)
if(tmp.length==5) {
tmp = []
}
});
console.log(this.dateArr)
const endDate = new Date();
this.dateArr = getDates(startDate, endDate);
},
methods: {
//
chooseTimerClick(item) {
if(item.status!=1) return this.$u.toast('请选择可预约时间')
this.chooseTimerId = item.id
},
//
chooseDate(item) {
this.chooseDay = item.date
console.log(this.chooseDay)
},
changeDateIndex(num) {
if(this.currentDay==0&&num==-1) return
if(this.currentDay==this.dateArr.length-1&&num==1) return
@ -110,17 +102,7 @@
changeStep(val) {
this.$emit('changeStep', val)
},
getDates(startDate, endDate) {
const dates = [];
let currentDate = new Date(startDate);
while (currentDate <= endDate) {
dates.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}
return dates;
}
}
}
</script>
@ -174,7 +156,15 @@
.dateArr {
display: flex;
padding: 0 70rpx;
justify-content: space-between;
// justify-content: space-between;
&.oneDate {
justify-content: center;
}
.dateWidth {
width: 20%;
display: flex;
justify-content: center;
}
.date {
width: 74rpx;
height: 100rpx;

8
pages/indexEntry/enroll/registInfo/registInfo.vue

@ -198,14 +198,6 @@
</view>
</view>
<view class="row">
<view class="lab">代收费</view>
<view class="rightCon">
<view class="row">
<view class="val">100</view>
</view>
</view>
</view>
<view class="row">
<view class="lab">合计</view>
<view class="rightCon">
<view class="row">

18
pages/indexEntry/findShcool/comp/schoolItem.vue

@ -4,15 +4,15 @@
<image src="@/static/images/logo.png" mode=""></image>
</view>
<view class="textCon">
<view class="name">江西海正驾校</view>
<view class="name">{{ item.shortName }}</view>
<view class="starBox">
<u-rate active-color="#1989FA" inactive-color="#1989FA" gutter="1" :size="16" :value="4" disabled></u-rate>
<view class="num">4.9</view>
<u-rate active-color="#1989FA" inactive-color="#1989FA" gutter="1" :size="16" :value="item.stars" :readonly="true" style="pointer-events: none;"></u-rate>
<view class="num">{{item.stars}}</view>
</view>
<view class="credit">行业信用AA</view>
<view class="credit">行业信用{{item.creditrating}}</view>
<view class="adr">距您1000.99公里</view>
</view>
<callPhone v-if="showPhone">
<callPhone v-if="showPhone" :servicePhone="[{name: item.phone}]">
<view class="pozPhone">
<image src="@/static/images/index/telephone.png" mode=""></image>
</view>
@ -26,14 +26,20 @@
showPhone: {
type: Boolean,
default: true
},
item: {
type: Object,
default: {}
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.box {
height: 208rpx;
background: #FFFFFF;
border-radius: 16rpx;
padding: 24rpx;

48
pages/indexEntry/findShcool/findShcool.vue

@ -17,16 +17,20 @@
</view>
<view class="ul">
<view class="li" v-for="(item,index) in 10" :key="index" @click="goPage">
<schoolItme/>
<view class="li" v-for="(item,index) in listData" :key="index" >
<schoolItme :item="item" @click.native="goPage(item)"/>
</view>
</view>
</view>
<view style="padding-bottom: 20rpx;">
<u-loadmore :status="status" />
</view>
</view>
</template>
<script>
import schoolItme from './comp/schoolItem.vue'
import { schoolPage } from '@/config/api.js'
export default {
components: { schoolItme },
data() {
@ -48,16 +52,48 @@
text: '好评优先',
id: 3
},
]
],
params: {
pageNo: 1,
pageSize: 20,
lat: 30.27419537786047,
lng: 120.20633397715788,
},
total: 20,
listData: [],
status: 'loading'
}
},
onLoad() {
this.schoolPageFn()
},
onPullDownRefresh() {
this.listInit()
},
onReachBottom() {
if(this.total>this.listData.length) {
this.schoolPageFn()
}
},
methods: {
goPage() {
console.log(this.$goPage)
this.$goPage('/pages/indexEntry/findShcool/shcoolDetail/shcoolDetail')
goPage(item) {
this.$goPage('/pages/indexEntry/findShcool/shcoolDetail/shcoolDetail?schoolId='+ item.id)
},
tabClick(item) {
this.currentTab = item.id
},
async listInit() {
await this.schoolPageFn()
uni.stopPullDownRefresh()
},
//
async schoolPageFn() {
const {data: res} = await schoolPage(this.params)
this.params.pageNo ++
this.listData.push(...res.list)
this.total = res.total
if(this.listData.length>=this.total) this.status = 'nomore'
console.log(res)
}
}
}

31
pages/indexEntry/findShcool/shcoolDetail/comp/tab3.vue

@ -1,19 +1,19 @@
<template>
<view class="tabCon">
<view class="tab1">
<view class="card" @click="$goPage('/pages/indexEntry/findShcool/coachComment/coachComment')">
<view class="card" @click="goPage(item)" v-for="(item,index) in coachList" :key="index">
<view class="avatar">
<image src="@/static/images/logo.png" mode=""></image>
<image :src="item.photoPath" mode="" @error="handleImageError(item)"></image>
</view>
<view class="rightCon">
<view class="flex">
<view class="name">王一宝</view>
<view class="age">10年教龄</view>
<view class="name">{{ item.name }}</view>
<!-- <view class="age">10年教龄</view> -->
</view>
<view class="flex-b">
<view class="starBox">
<u-rate active-color="#1989FA" inactive-color="#1989FA" gutter="1" :size="16" :value="4" disabled></u-rate>
<view class="num">4.9</view>
<u-rate active-color="#1989FA" inactive-color="#1989FA" gutter="1" :size="16" :value="item.stars" disabled style="pointer-events: none;"></u-rate>
<view class="num">{{item.stars}}</view>
</view>
<view class="btn" v-if="showSign">报名</view>
<view class="more" v-else>
@ -24,12 +24,28 @@
</view>
</view>
</view>
<view style="padding-bottom: 20rpx;">
<u-loadmore :status="status" />
</view>
</view>
</template>
<script>
export default {
props: ['showSign']
props: ['showSign', 'coachList', 'status'],
methods: {
goPage(item) {
if(this.showSign) {
}else {
this.$goPage('/pages/indexEntry/findShcool/coachComment/coachComment?coachId='+ item.id)
}
},
handleImageError(item) {
item.photoPath = require('@/static/images/index/avatar.png')
}
}
}
</script>
@ -49,6 +65,7 @@
height: 98rpx;
border-radius: 50%;
margin-right: 34rpx;
background-color: #f6f6f6;
}
.rightCon {
flex: 1;

31
pages/indexEntry/findShcool/shcoolDetail/shcoolDetail.vue

@ -48,7 +48,7 @@
</view>
<tab1 v-show="currentNav==1"></tab1>
<tab2 v-show="currentNav==2"></tab2>
<tab3 v-show="currentNav==3"></tab3>
<tab3 v-show="currentNav==3" :coachList="coachList" :status="tab3Status"></tab3>
<tab4 v-show="currentNav==4"></tab4>
</view>
</view>
@ -59,6 +59,7 @@
import tab2 from './comp/tab2.vue'
import tab3 from './comp/tab3.vue'
import tab4 from './comp/tab4.vue'
import { coachPage } from '@/config/api.js'
export default {
components: { tab1, tab2, tab3, tab4},
data() {
@ -76,16 +77,40 @@
{text: '教练车', id: 4},
],
currentNav: 1,
coachParams: {
pageNo: 1,
pageSize: 20
},
schoolId: '',
coachList: [],
tab3Status: 'loading',
tab3Total: 20
}
},
onLoad() {
onLoad(options) {
this.schoolId = options.schoolId
this.coachParams.schoolId = this.schoolId
this.coachPageFn()
},
onPullDownRefresh() {
},
onReachBottom() {
if(this.currentNav==3&&this.coachList.length<this.tab3Total) {
this.coachPageFn()
}
},
methods: {
changeNav(item) {
this.currentNav = item.id
},
async coachPageFn() {
const {data: res} = await coachPage(this.coachParams)
this.coachParams.pageNo ++
this.coachList.push(...res.list)
this.tab3Total = res.total
if(this.coachList.length>=this.tab3Total) this.tab3Status = 'nomore'
}
}
}
</script>

2
pages/tabbar/index/index.vue

@ -147,7 +147,7 @@
},
{
text: '找驾驶馆',
icon: require('../../../static/images/index/ic_peilian.png'),
icon: require('../../../static/images/index/ic_jsg.png'),
url: '/pages/carEntry/simulateAppointment/simulateAppointment',
click: (item)=>{
this.$goPage(item.url)

2
pages/tabbar/learnCar/comp/subject1.vue

@ -67,7 +67,7 @@
<view class="flex-b bg">
<view class="row">
<view class="text">前往12123APP预约考试</view>
<view class="btn" @click="$goPage('/pages/carEntry/operaAppointment/operaAppointment')">去预约</view>
<view class="btn" @click="$goPage('/pages/carEntry/operaAppointment/operaAppointment?subject=2')">去预约</view>
</view>
</view>
</view>

BIN
static/images/index/avatar.png

After

Width: 50  |  Height: 50  |  Size: 4.5 KiB

Loading…
Cancel
Save