driverSchool/newPages/my/index.vue

363 lines
11 KiB
Vue
Raw Normal View History

2025-03-15 17:32:23 +08:00
<template>
<view class="page flex-col">
<view class="box_1 flex-col justify-end">
2025-03-27 15:49:36 +08:00
2025-03-15 17:32:23 +08:00
<view class="box_7 flex-row justify-between">
<view class="image-text_1 flex-row justify-between">
<view class="group_1 flex-col">
<view class="image-wrapper_2 flex-col">
<image
2025-04-07 18:08:13 +08:00
class="image_2"
referrerpolicy="no-referrer"
:src="selfInfo && selfInfo.avatar ? imageUrl + '/' + selfInfo.avatar : '/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG185e54e3ffd47170ac4e6e5108c9a54f.png'"
2025-03-15 17:32:23 +08:00
/>
</view>
</view>
<view class="text-group_1 flex-col justify-between">
2025-04-07 18:08:13 +08:00
<view v-if="selfInfo.nickname" class="text_3">{{ selfInfo.nickname }}</view>
<view v-if="selfInfo.username" class="text_3">{{ selfInfo.username }}</view>
<view v-else @click="toLogin()" class="text_2">登录/注册</view>
<text v-if="!selfInfo.username" class="text_3">登录将开启全部服务</text>
2025-03-15 17:32:23 +08:00
</view>
</view>
2025-04-09 16:01:16 +08:00
<view class="image-text_2 flex-col justify-between" @click="toMyQrCode()">
2025-03-15 17:32:23 +08:00
<image
2025-04-07 18:08:13 +08:00
class="label_1"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG7e67772393591f7c5436c0b59f7b3b17.png"
2025-03-15 17:32:23 +08:00
/>
<text class="text-group_2">学车码</text>
</view>
</view>
<view class="box_8 flex-row">
<view class="image-wrapper_3 flex-col justify-center">
<image
2025-04-07 18:08:13 +08:00
class="label_2"
referrerpolicy="no-referrer"
:src="coachDetails && coachDetails.image ? imageUrl + '/' + coachDetails.image : '/static/lanhu_gerenzhongxin/FigmaDDSSlicePNGa95a4d1d98d08b238a3082514eefafd0.png'"
2025-03-15 17:32:23 +08:00
/>
</view>
<view class="text-group_3 flex-col justify-between">
2025-04-01 17:57:14 +08:00
<text class="text_4" v-if="coachDetails.name != null">{{ coachDetails.name }}</text>
2025-04-07 18:08:13 +08:00
<text class="text_111" v-else> 暂无教练信息</text>
2025-04-01 17:57:14 +08:00
<view class="text-wrapper_1" v-if="coachDetails.seniority != null">
2025-03-15 17:32:23 +08:00
<text class="text_5">教龄</text>
2025-04-01 17:57:14 +08:00
<text class="text_6">{{ coachDetails.seniority }}</text>
2025-03-15 17:32:23 +08:00
<text class="text_7"></text>
</view>
2025-04-07 18:08:13 +08:00
2025-03-15 17:32:23 +08:00
</view>
2025-04-01 17:57:14 +08:00
<!-- <view class="text-wrapper_2" v-if="coachDetails">
2025-03-15 17:32:23 +08:00
<text class="text_8">学员数</text>
2025-04-01 17:57:14 +08:00
<text class="text_9">{{}}</text>
2025-03-15 17:32:23 +08:00
</view>
2025-04-01 17:57:14 +08:00
<view class="text-wrapper_2" v-else>
<text class="text_8">暂无数据</text>
</view> -->
2025-03-15 17:32:23 +08:00
</view>
</view>
<view class="box_9 flex-col">
<view class="block_1 flex-col">
<text class="text_10">我的订单</text>
<view class="list_1 flex-row">
<view
2025-04-07 18:08:13 +08:00
class="image-text_3 flex-col justify-between"
v-for="(item, index) in loopData"
:key="index"
@click="toOrderPage(item.orderType,item.type)"
2025-03-15 17:32:23 +08:00
>
<image
2025-04-07 18:08:13 +08:00
class="label_3"
referrerpolicy="no-referrer"
:src="item.url"
2025-03-15 17:32:23 +08:00
/>
2025-03-27 15:49:36 +08:00
<text class="text-group_4" v-text="item.text"></text>
2025-03-15 17:32:23 +08:00
</view>
</view>
</view>
2025-04-01 17:57:14 +08:00
<view class="block_2 flex-row" @click="goMyInDetails()">
2025-03-15 17:32:23 +08:00
<view class="image-wrapper_4 flex-col">
<image
2025-04-07 18:08:13 +08:00
class="thumbnail_2"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG1bb0cdc369203c305a42d848736e8f01.png"
2025-03-15 17:32:23 +08:00
/>
</view>
<text class="text_11">个人信息</text>
<image
2025-04-07 18:08:13 +08:00
class="thumbnail_3"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG4f20daae79bb7c60189f8702897465d1.png"
2025-03-15 17:32:23 +08:00
/>
</view>
<view class="block_3 flex-row">
<view class="image-wrapper_5 flex-col">
<image
2025-04-07 18:08:13 +08:00
class="thumbnail_4"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNGb5e90b5b4c1f154eb4e27313164118a4.png"
2025-03-15 17:32:23 +08:00
/>
</view>
<text class="text_12">在线客服</text>
<image
2025-04-07 18:08:13 +08:00
class="thumbnail_5"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG4f20daae79bb7c60189f8702897465d1.png"
2025-03-15 17:32:23 +08:00
/>
</view>
<view class="block_4 flex-row">
<view class="image-wrapper_6 flex-col">
<image
2025-04-07 18:08:13 +08:00
class="thumbnail_6"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNGa728895586dafec1bde5f90c89d05c48.png"
2025-03-15 17:32:23 +08:00
/>
</view>
<text class="text_13">建议反馈</text>
<image
2025-04-07 18:08:13 +08:00
class="thumbnail_7"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG4f20daae79bb7c60189f8702897465d1.png"
2025-03-15 17:32:23 +08:00
/>
</view>
</view>
2025-03-27 15:49:36 +08:00
<tabbar :msg='msg'></tabbar>
2025-04-09 16:01:16 +08:00
<u-popup round="20" :show="showQrCode" @close="closeQrCode" mode="center" zoom="false" @open="openQrCode">
<view style="padding: 50rpx">
<canvas id="qrcode" canvas-id="qrcode" style="width: 600rpx;height:600rpx;"/>
</view>
<span style="text-align: center">学车码</span>
</u-popup>
2025-03-15 17:32:23 +08:00
</view>
</template>
<script>
2025-04-07 18:08:13 +08:00
import headers from '../../components/header/headers.vue'
import tabbar from '../../components/tabbar/tabbar.vue'
import request from '@/utils/request.js'
2025-04-09 16:01:16 +08:00
import UQRCode from 'uqrcodejs';
2025-04-07 18:08:13 +08:00
import {
getLocalUserInfo,
2025-04-09 14:36:38 +08:00
getToken,
setLocalUserInfo
2025-04-07 18:08:13 +08:00
} from '@/utils/auth'
2025-03-15 17:32:23 +08:00
export default {
2025-03-27 15:49:36 +08:00
2025-03-15 17:32:23 +08:00
data() {
return {
2025-04-07 18:08:13 +08:00
msg: "3",
selfInfo: {},
2025-04-09 16:01:16 +08:00
selfInfoLocal: {},
2025-04-07 18:08:13 +08:00
coachDetails: {},
userDetails: {},
2025-04-09 10:56:33 +08:00
orderList: {},
processList: {},
2025-04-09 16:01:16 +08:00
showQrCode: false,
isCreateQrCode:true,
2025-03-27 15:49:36 +08:00
loopData: [
2025-03-15 17:32:23 +08:00
{
2025-03-27 15:49:36 +08:00
url: '/static/myImgs/alreadyPaid.png',
text: '已付款',
2025-04-07 18:08:13 +08:00
orderType: '2',
type: '2',
2025-03-15 17:32:23 +08:00
},
{
2025-03-27 15:49:36 +08:00
url: '/static/myImgs/alreadyInterviewed.png',
text: '已面签',
2025-04-07 18:08:13 +08:00
orderType: '4',
type: '3',
2025-03-15 17:32:23 +08:00
},
{
2025-03-27 15:49:36 +08:00
url: '/static/myImgs/registered.png',
text: '已报名',
2025-04-07 18:08:13 +08:00
orderType: '2',
type: '4',
2025-03-15 17:32:23 +08:00
},
{
2025-03-27 15:49:36 +08:00
url: '/static/myImgs/allOrder.png',
text: '全部订单',
2025-04-07 18:08:13 +08:00
orderType: '',
type: '1',
2025-03-15 17:32:23 +08:00
}
],
2025-03-27 15:49:36 +08:00
constants: {},
imageUrl: this.$imagesUrl,
2025-03-15 17:32:23 +08:00
};
},
2025-03-27 15:49:36 +08:00
onLoad() {
2025-04-09 14:36:38 +08:00
this.selfInfoLocal = getLocalUserInfo()
console.log("用户信息", this.selfInfoLocal)
2025-04-07 18:08:13 +08:00
this.getUserInfo()
2025-03-27 15:49:36 +08:00
},
onShow() {
2025-04-07 18:08:13 +08:00
if (getToken()) {
// this.findSelfInfo()
}
2025-03-27 15:49:36 +08:00
},
onPullDownRefresh() {
2025-04-07 18:08:13 +08:00
console.log("刷新");
uni.stopPullDownRefresh()
2025-04-09 16:01:16 +08:00
this.getUserInfo()
2025-03-27 15:49:36 +08:00
},
onReachBottom() {
2025-04-07 18:08:13 +08:00
// this.show = true
setTimeout(() => {
console.log("加载执行");
}, 2000)
2025-03-27 15:49:36 +08:00
},
components: {
2025-04-07 18:08:13 +08:00
headers,
tabbar
2025-03-27 15:49:36 +08:00
},
methods: {
2025-04-07 18:08:13 +08:00
goback() {
uni.navigateBack()
},
toLogin() {
uni.navigateTo({
url: "/pages/login/login"
})
},
2025-04-09 16:01:16 +08:00
createQrCode(data) {
const qr = new UQRCode();
qr.data = data;
qr.size = 300;
qr.make();
const ctx = uni.createCanvasContext('qrcode', this); // 组件内调用需传thisvue3 中 this 为 getCurrentInstance()?.proxy
qr.canvasContext = ctx;
qr.drawCanvas();
this.isCreateQrCode = false
},
closeQrCode() {
this.showQrCode = false
},
openQrCode(){
console.log(this.userDetails,'202222')
// 判断是否有二维码 有了不需要绘制
if (this.isCreateQrCode){
this.createQrCode(this.userDetails.uniqueCode)
}
},
2025-04-07 18:08:13 +08:00
/*async findSelfInfo() {
let res = await request({
url: `/app-api/small/driving/findSelfInfo`,
method: 'get',
})
console.log(res, 138);
this.selfInfo = res
},*/
2025-04-09 16:01:16 +08:00
toMyQrCode() {
this.showQrCode = true
},
2025-03-27 15:49:36 +08:00
2025-04-07 18:08:13 +08:00
toOrderPage(orderType, type) {
uni.navigateTo({
url: `/newPages/orderList/index?orderType=${orderType}&type=${type}&userId=${this.selfInfo.id}`
})
},
goMyInDetails() {
uni.navigateTo({
2025-04-09 10:56:33 +08:00
url: `/newPages/information/index?userId=${this.selfInfo.id}`
2025-04-07 18:08:13 +08:00
})
},
2025-04-09 16:01:16 +08:00
getUserInfo() {
request({
url: '/app-api/small/dl-drive-school-student/getUsersInfo',
method: 'GET',
}).then(res => {
this.selfInfo = res.data
if (this.userInfo != null) {
setLocalUserInfo(this.selfInfo)
}
this.getOrder()
this.getStudentInfo()
console.log('userDetails', this.selfInfo)
})
},
getStudentInfo(){
request({
url: '/app-api/small/dl-drive-school-student/getByUserId',
method: 'GET',
params: { userId: this.selfInfo.id }
}).then(res => {
console.log('userDetailsRes', res)
this.userDetails = { ...res.data };
});
},
2025-04-07 18:08:13 +08:00
2025-04-09 10:56:33 +08:00
getCoachDetails(coachId) {
2025-04-07 18:08:13 +08:00
request({
2025-04-09 14:36:38 +08:00
url: '/app-api/dl-drive-school-coach-small/getCoachByUserId',
2025-04-07 18:08:13 +08:00
method: 'GET',
params: {
2025-04-09 14:36:38 +08:00
userId: coachId
2025-04-07 18:08:13 +08:00
}
}).then(res => {
this.coachDetails = res.data
console.log('coachDetails', this.coachDetails);
})
2025-04-09 10:56:33 +08:00
},
2025-04-09 16:01:16 +08:00
2025-04-09 10:56:33 +08:00
getOrder() {
request({
url: '/app-api/small/drive/school-course-order/getCourseByLoginUser',
method: 'GET',
}).then(res => {
this.orderList = res.data
if (this.orderList.length > 0) {
console.log('orderList', this.orderList)
2025-04-09 16:01:16 +08:00
this.getProcess(this.orderList[0].courseId)
2025-04-09 10:56:33 +08:00
}
})
},
2025-04-09 16:01:16 +08:00
2025-04-09 10:56:33 +08:00
getProcess(courseId) {
request({
url: '/app-api/process/getAllByCourseId',
method: 'GET',
params: {
courseId: courseId
}
}).then(res => {
let result = null; // 默认返回 null如果没有符合条件的数据
if (res.data && Array.isArray(res.data)) {
this.processList = res.data;
// 1. 筛选出所有 status === "1" 的数据(注意是字符串 "1"
const statusOneItems = this.processList.filter(item => item.status === "1");
if (statusOneItems.length === 1) {
// 2. 如果只有一条,直接赋值
result = statusOneItems[0];
2025-04-09 16:01:16 +08:00
this.getCoachDetails(result.coachId)
2025-04-09 10:56:33 +08:00
} else if (statusOneItems.length > 1) {
// 3. 如果有多条,按 subjectint 类型降序排序取第一条subject 最大的)
const sortedItems = [...statusOneItems].sort((a, b) => b.subject - a.subject);
result = sortedItems[0];
2025-04-09 16:01:16 +08:00
this.getCoachDetails(result.coachId)
2025-04-09 10:56:33 +08:00
}
// 如果没有数据result 保持 null
}
console.log('最终结果:', result); // 调试用,可删除
return result; // 如果需要返回结果,可以加上 return
}).catch(error => {
console.error('请求出错:', error);
return null; // 出错时也返回 null
});
2025-04-07 18:08:13 +08:00
}
2025-03-27 15:49:36 +08:00
}
2025-03-15 17:32:23 +08:00
};
</script>
<style lang='scss'>
@import '../common/common.scss';
@import './assets/style/index.rpx.scss';
</style>