会员+驾校联调
This commit is contained in:
@@ -353,6 +353,6 @@
|
||||
}
|
||||
}
|
||||
.actived {
|
||||
color: #05C341;
|
||||
color: #05C341 !important;
|
||||
}
|
||||
</style>
|
||||
@@ -27,7 +27,15 @@ export function logout() {
|
||||
|
||||
export function getInfo() {
|
||||
return request({
|
||||
url: 'driver-api/tdSysUser/info',
|
||||
url: 'driver-api/tdSysUser/queryUserMessage',
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
export function bindSchool(data) {
|
||||
return request({
|
||||
url: 'driver-api/tdSysUser/bindSchool',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
@@ -26,7 +26,7 @@ function service(options = {}) {
|
||||
if (res.data.code == 'E403') {
|
||||
// 未登录
|
||||
uni.showToast({
|
||||
title: res.data.message,
|
||||
title: res?.data?.message || '请重新登录',
|
||||
icon: 'none'
|
||||
});
|
||||
useUserStore().logout()
|
||||
@@ -34,7 +34,7 @@ function service(options = {}) {
|
||||
resolved(res.data);
|
||||
} else if(res.data.code != '0000') {
|
||||
uni.showToast({
|
||||
title: res.data.message,
|
||||
title: res?.data?.message || '访问出错',
|
||||
icon: 'none'
|
||||
})
|
||||
resolved(res.data)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<text class="mr10">{{ user.userName }}{{user.userId}}</text>
|
||||
<image v-if="vipOn.length" src="/static/image/mine/vip.png" mode="widthFix" style="width: 18px;"></image>
|
||||
</view>
|
||||
<view class="mt5 fs14 cor-666">陪您学车 第{{ user.count }}天</view>
|
||||
<view class="mt5 fs14 cor-666">陪您学车 第{{ user.days }}天</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="info flex ai-c" v-else @tap="toLogin">
|
||||
@@ -98,8 +98,7 @@ export default {
|
||||
return useUserStore().isLogin
|
||||
},
|
||||
user() {
|
||||
let userInfo = useUserStore().userInfo
|
||||
return { ...userInfo, count: this.dateDiff(userInfo.createTime) }
|
||||
return useUserStore().userInfo
|
||||
},
|
||||
vipOn() {
|
||||
return useUserStore().vipOnList
|
||||
@@ -192,19 +191,6 @@ export default {
|
||||
handleLogout() {
|
||||
useUserStore().logout()
|
||||
},
|
||||
dateDiff(end){
|
||||
if(!end) {
|
||||
return 1
|
||||
}
|
||||
today = new Date();
|
||||
end = new Date(end);
|
||||
if(end > today){
|
||||
days = parseInt(Math.abs(end - today) / 1000 / 60 / 60 / 24);
|
||||
}else{
|
||||
days = parseInt(Math.abs(end - today) / 1000 / 60 / 60 / 24); // 如果不限制对比时间和当前时间大小可以不用if
|
||||
}
|
||||
return days + 1;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,45 +1,53 @@
|
||||
<template>
|
||||
<view>
|
||||
<IndexList :dataList="dataList" nameKey="schoolName" v-model:current="current" @click="click"></IndexList>
|
||||
<IndexList :dataList="dataList" nameKey="schoolName" idKey="schoolId" v-model:current="current" @click="click"></IndexList>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import IndexList from '@/components/liu-indexed-list/liu-indexed-list.vue'
|
||||
import { bindSchool } from '@/jtools/api/login.js'
|
||||
import useUserStore from '@/jtools/store/user.js'
|
||||
export default {
|
||||
components: {
|
||||
IndexList
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
current: '1',
|
||||
dataList: [{
|
||||
id: '1',
|
||||
schoolName: '爱尚学车驾校长安分校',
|
||||
},{
|
||||
id: '2',
|
||||
schoolName: '八一驾校',
|
||||
},{
|
||||
id: '3',
|
||||
schoolName: '八零驾校',
|
||||
},{
|
||||
id: '4',
|
||||
schoolName: '畅通驾校',
|
||||
},{
|
||||
id: '5',
|
||||
schoolName: '金灵驾校',
|
||||
},{
|
||||
id: '6',
|
||||
schoolName: '通顺驾校',
|
||||
}]
|
||||
current: useUserStore().userInfo.schoolId,
|
||||
dataList: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this._getSchoolOptions()
|
||||
},
|
||||
methods: {
|
||||
_getSchoolOptions() {
|
||||
uni.request({
|
||||
url: 'https://xueche.ahduima.com/duima/applet/school/list'
|
||||
}).then(resp => {
|
||||
if(resp.data.code == 200) {
|
||||
this.dataList = resp.data.data
|
||||
}
|
||||
})
|
||||
},
|
||||
click() {
|
||||
// 设置用户驾校
|
||||
|
||||
// 然后返回
|
||||
uni.navigateBack()
|
||||
const {schoolId,schoolName,phone } = this.dataList.find(it=>it.schoolId == this.current)
|
||||
const params = {schoolId, schoolName, schoolPhone: phone}
|
||||
bindSchool(params).then(resp => {
|
||||
if(resp.code == '0000') {
|
||||
useUserStore().userInfo.schoolId = schoolId
|
||||
useUserStore().userInfo.schoolName = schoolName
|
||||
useUserStore().userInfo.schoolPhone = phone
|
||||
uni.showToast({
|
||||
title: '绑定驾校成功!',
|
||||
icon: 'none'
|
||||
})
|
||||
// 然后返回
|
||||
uni.navigateBack()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,34 +2,37 @@
|
||||
<view class="flex fld-c p15">
|
||||
<u-sticky>
|
||||
<view class="flex ai-c">
|
||||
<view v-for="(item,index) in list" :key="index" class="km-item" :class="{ actived: index==current }"
|
||||
<view v-for="(item,index) in vipAllList" :key="index" class="km-item" :class="{ actived: index==current }"
|
||||
@click="current=index">
|
||||
{{ item.name }}
|
||||
{{ getKmTitle(item.subjects) }}
|
||||
</view>
|
||||
</view>
|
||||
</u-sticky>
|
||||
<view class="mt15">
|
||||
<swiper class="swiper" :current="current" style="height: 120px;" :autoplay="false" :display-multiple-items="1.45"
|
||||
:disable-programmatic-animation="true" @change="onChange">
|
||||
<swiper-item v-for="(item,index) in list" :key="index">
|
||||
<swiper-item v-for="(item,index) in vipAllList" :key="index">
|
||||
<view class="relative">
|
||||
<image src="../../static/image/mine/vip_card.png" mode="widthFix" style="width:95%;"></image>
|
||||
<view class="vip-info">
|
||||
<u-avatar class="br-p50 overflow-h" style="border: 3px solid #873E1D;" :size="35" mp-avatar></u-avatar>
|
||||
<view class="ml10">
|
||||
<view class="fs16 fwb" style="color: #7E4012;line-height: 16px;">
|
||||
{{item.name}}尊享VIP
|
||||
{{item.memberName}}
|
||||
</view>
|
||||
<view class="mt5 fs12" style="color: #7E4012;line-height: 12px;">
|
||||
2024-12-12到期
|
||||
{{getExpireText(item)}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="corner">
|
||||
<view v-if="vipHasOpened(item)" class="corner">
|
||||
VIP已开通
|
||||
</view>
|
||||
<view class="renew">
|
||||
98元立即续费
|
||||
<view v-if="vipHasOpened(item)" class="renew">
|
||||
{{item.price}}元立即续费
|
||||
</view>
|
||||
<view v-else class="buy">
|
||||
立即充值
|
||||
</view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
@@ -40,10 +43,10 @@
|
||||
<view class="mt20">
|
||||
<swiper class="swiper" :current="current" style="height: 300px;" :autoplay="false"
|
||||
:disable-programmatic-animation="true" @change="onChange">
|
||||
<swiper-item v-for="(item,index) in list" :key="index">
|
||||
<swiper-item v-for="(item,index) in vipAllList" :key="index">
|
||||
<view v-if="index == 0 || index == 3" class="p15 br8 cor-fff">
|
||||
<view class="fs18 cor-000 fwb">
|
||||
3步轻松学{{item.name}}
|
||||
3步轻松学{{getKmTitle(item.subjects)}}
|
||||
</view>
|
||||
<view class="mt25 flex ai-c jc-sb">
|
||||
<view class="flex ai-c">
|
||||
@@ -57,7 +60,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="study">
|
||||
<view class="study" @tap="to500(item)">
|
||||
去学习
|
||||
</view>
|
||||
</view>
|
||||
@@ -73,7 +76,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="study">
|
||||
<view class="study" @tap="toRealExam(item)">
|
||||
去学习
|
||||
</view>
|
||||
</view>
|
||||
@@ -89,7 +92,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="study">
|
||||
<view class="study" @tap="toSpecExam(item)">
|
||||
去学习
|
||||
</view>
|
||||
</view>
|
||||
@@ -104,7 +107,7 @@
|
||||
<image src="../../static/image/index/index_bg.png" mode="widthFix" style="flex: 1;border-radius: 33rpx;"></image>
|
||||
<view class="ml18 text-center">
|
||||
<u-button :customStyle="{width:'200rpx',height:'66rpx',borderRadius: '33rpx'}" iconColor="#fff"
|
||||
text="去看视频" color="linear-gradient(90deg, #E66501 0%, #F8A42C 100%)" icon="play-circle">
|
||||
text="去看视频" color="linear-gradient(90deg, #E66501 0%, #F8A42C 100%)" icon="play-circle" @click="toPlaceLive(item)">
|
||||
</u-button>
|
||||
<view class="cor-333 fs15 mt17">真实考场模拟</view>
|
||||
</view>
|
||||
@@ -120,24 +123,92 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import useUserStore from '@/jtools/store/user'
|
||||
export default {
|
||||
computed: {
|
||||
vipAllList() {
|
||||
return useUserStore().vipAllList.filter(it=>[1,2,3,4].includes(Number(it.subjects)))
|
||||
},
|
||||
vipOnList() {
|
||||
return useUserStore().vipOnList
|
||||
},
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: [{
|
||||
name: '科一'
|
||||
}, {
|
||||
name: '科二'
|
||||
}, {
|
||||
name: '科三'
|
||||
}, {
|
||||
name: '科四'
|
||||
}],
|
||||
current: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onChange(e) {
|
||||
this.current = e.detail.current
|
||||
},
|
||||
getKmTitle(km) {
|
||||
return {
|
||||
'1': '科一',
|
||||
'2': '科二',
|
||||
'3': '科三',
|
||||
'4': '科四',
|
||||
}[km]
|
||||
},
|
||||
getExpireText(item) {
|
||||
const vipOn = this.vipOnList.find(it => it.memberId == item.memberId)
|
||||
if(vipOn) {
|
||||
return `${vipOn.endDate.split(' ')[0]}到期`
|
||||
} else {
|
||||
return '开通vip助您快速拿证'
|
||||
}
|
||||
},
|
||||
vipHasOpened(item) {
|
||||
return !!this.vipOnList.find(it => it.memberId == item.memberId)
|
||||
},
|
||||
// 去精选500题 item=> 当前科目vip信息
|
||||
to500(item) {
|
||||
// 当前vip是否已开通
|
||||
if(this.vipHasOpened(item)) {
|
||||
// 跳转
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: `请先充值${this.getKmTitle(item.subjects)}vip`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
// 去真实考场 item=> 当前科目vip信息
|
||||
toRealExam(item) {
|
||||
// 当前vip是否已开通
|
||||
if(this.vipHasOpened(item)) {
|
||||
// 跳转
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: `请先充值${this.getKmTitle(item.subjects)}vip`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
// 去秘卷 item=> 当前科目vip信息
|
||||
toSpecExam(item) {
|
||||
// 当前vip是否已开通
|
||||
if(this.vipHasOpened(item)) {
|
||||
// 跳转
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: `请先充值${this.getKmTitle(item.subjects)}vip`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
// 去考场实况 item=> 当前科目vip信息
|
||||
toPlaceLive(item) {
|
||||
// 当前vip是否已开通
|
||||
if(this.vipHasOpened(item)) {
|
||||
// 跳转
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: `请先充值${this.getKmTitle(item.subjects)}vip`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,6 +274,21 @@
|
||||
font-size: 12px;
|
||||
color: #F6E99F;
|
||||
}
|
||||
.buy {
|
||||
position: absolute;
|
||||
left: 45%;
|
||||
transform: translateX(-50%);
|
||||
bottom: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 200rpx;
|
||||
height: 60rpx;
|
||||
background: #873E1D;
|
||||
border-radius: 30rpx;
|
||||
font-size: 14px;
|
||||
color: #F6E99F;
|
||||
}
|
||||
|
||||
.study {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user