driverSchool/newPages/my/index.vue
2025-04-09 14:36:38 +08:00

322 lines
9.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page flex-col">
<view class="box_1 flex-col justify-end">
<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
class="image_2"
referrerpolicy="no-referrer"
:src="selfInfo && selfInfo.avatar ? imageUrl + '/' + selfInfo.avatar : '/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG185e54e3ffd47170ac4e6e5108c9a54f.png'"
/>
</view>
</view>
<view class="text-group_1 flex-col justify-between">
<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>
</view>
</view>
<view class="image-text_2 flex-col justify-between">
<image
class="label_1"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG7e67772393591f7c5436c0b59f7b3b17.png"
/>
<text class="text-group_2">学车码</text>
</view>
</view>
<view class="box_8 flex-row">
<view class="image-wrapper_3 flex-col justify-center">
<image
class="label_2"
referrerpolicy="no-referrer"
:src="coachDetails && coachDetails.image ? imageUrl + '/' + coachDetails.image : '/static/lanhu_gerenzhongxin/FigmaDDSSlicePNGa95a4d1d98d08b238a3082514eefafd0.png'"
/>
</view>
<view class="text-group_3 flex-col justify-between">
<text class="text_4" v-if="coachDetails.name != null">{{ coachDetails.name }}</text>
<text class="text_111" v-else> 暂无教练信息</text>
<view class="text-wrapper_1" v-if="coachDetails.seniority != null">
<text class="text_5">教龄:</text>
<text class="text_6">{{ coachDetails.seniority }}</text>
<text class="text_7">年</text>
</view>
</view>
<!-- <view class="text-wrapper_2" v-if="coachDetails">
<text class="text_8">学员数:</text>
<text class="text_9">{{}}</text>
</view>
<view class="text-wrapper_2" v-else>
<text class="text_8">暂无数据</text>
</view> -->
</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
class="image-text_3 flex-col justify-between"
v-for="(item, index) in loopData"
:key="index"
@click="toOrderPage(item.orderType,item.type)"
>
<image
class="label_3"
referrerpolicy="no-referrer"
:src="item.url"
/>
<text class="text-group_4" v-text="item.text"></text>
</view>
</view>
</view>
<view class="block_2 flex-row" @click="goMyInDetails()">
<view class="image-wrapper_4 flex-col">
<image
class="thumbnail_2"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG1bb0cdc369203c305a42d848736e8f01.png"
/>
</view>
<text class="text_11">个人信息</text>
<image
class="thumbnail_3"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG4f20daae79bb7c60189f8702897465d1.png"
/>
</view>
<view class="block_3 flex-row">
<view class="image-wrapper_5 flex-col">
<image
class="thumbnail_4"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNGb5e90b5b4c1f154eb4e27313164118a4.png"
/>
</view>
<text class="text_12">在线客服</text>
<image
class="thumbnail_5"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG4f20daae79bb7c60189f8702897465d1.png"
/>
</view>
<view class="block_4 flex-row">
<view class="image-wrapper_6 flex-col">
<image
class="thumbnail_6"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNGa728895586dafec1bde5f90c89d05c48.png"
/>
</view>
<text class="text_13">建议反馈</text>
<image
class="thumbnail_7"
referrerpolicy="no-referrer"
src="/static/lanhu_gerenzhongxin/FigmaDDSSlicePNG4f20daae79bb7c60189f8702897465d1.png"
/>
</view>
</view>
<tabbar :msg='msg'></tabbar>
</view>
</template>
<script>
import headers from '../../components/header/headers.vue'
import tabbar from '../../components/tabbar/tabbar.vue'
import request from '@/utils/request.js'
import {
getLocalUserInfo,
getToken,
setLocalUserInfo
} from '@/utils/auth'
export default {
data() {
return {
msg: "3",
selfInfo: {},
selfInfoLocal: {},
coachDetails: {},
userDetails: {},
orderList: {},
processList: {},
loopData: [
{
url: '/static/myImgs/alreadyPaid.png',
text: '已付款',
orderType: '2',
type: '2',
},
{
url: '/static/myImgs/alreadyInterviewed.png',
text: '已面签',
orderType: '4',
type: '3',
},
{
url: '/static/myImgs/registered.png',
text: '已报名',
orderType: '2',
type: '4',
},
{
url: '/static/myImgs/allOrder.png',
text: '全部订单',
orderType: '',
type: '1',
}
],
constants: {},
imageUrl: this.$imagesUrl,
};
},
onLoad() {
this.selfInfoLocal = getLocalUserInfo()
console.log("用户信息", this.selfInfoLocal)
this.getUserInfo()
},
onShow() {
if (getToken()) {
// this.findSelfInfo()
}
},
onPullDownRefresh() {
console.log("刷新");
uni.stopPullDownRefresh()
this.getUserInfo()
},
onReachBottom() {
// this.show = true
setTimeout(() => {
console.log("加载执行");
}, 2000)
},
components: {
headers,
tabbar
},
methods: {
goback() {
uni.navigateBack()
},
toLogin() {
uni.navigateTo({
url: "/pages/login/login"
})
},
/*async findSelfInfo() {
let res = await request({
url: `/app-api/small/driving/findSelfInfo`,
method: 'get',
})
console.log(res, 138);
this.selfInfo = res
},*/
toOrderPage(orderType, type) {
uni.navigateTo({
url: `/newPages/orderList/index?orderType=${orderType}&type=${type}&userId=${this.selfInfo.id}`
})
},
goMyInDetails() {
uni.navigateTo({
url: `/newPages/information/index?userId=${this.selfInfo.id}`
})
},
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()
console.log('userDetails', this.selfInfo)
})
},
getCoachDetails(coachId) {
request({
url: '/app-api/dl-drive-school-coach-small/getCoachByUserId',
method: 'GET',
params: {
userId: coachId
}
}).then(res => {
this.coachDetails = res.data
console.log('coachDetails', this.coachDetails);
})
},
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)
this.getProcess(this.orderList[0].courseId)
}
})
},
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];
this.getCoachDetails(result.coachId)
} else if (statusOneItems.length > 1) {
// 3. 如果有多条,按 subjectint 类型降序排序取第一条subject 最大的)
const sortedItems = [...statusOneItems].sort((a, b) => b.subject - a.subject);
result = sortedItems[0];
this.getCoachDetails(result.coachId)
}
// 如果没有数据result 保持 null
}
console.log('最终结果:', result); // 调试用,可删除
return result; // 如果需要返回结果,可以加上 return
}).catch(error => {
console.error('请求出错:', error);
return null; // 出错时也返回 null
});
}
}
};
</script>
<style lang='scss'>
@import '../common/common.scss';
@import './assets/style/index.rpx.scss';
</style>