lanan-repair/pages/myCar/myCar.vue

171 lines
3.6 KiB
Vue
Raw Normal View History

2024-09-22 15:07:01 +08:00
<template>
2024-09-24 19:46:55 +08:00
<view class="container">
<VNavigationBar titleColor="rgba(0,0,0,0.9)" backgroundColor="#fff" title="我的车辆"></VNavigationBar>
<view class="body">
<scroll-view style="height: 100%" scroll-y="true">
<view class="carList">
<view v-for="(item, index) in carList" :key="index" class="carItem" @click="gotoDetail(item)">
<image class="carImage" :src="config.baseImageUrl+item.logoImg" mode="aspectFit"></image>
<view class="carInfo">
<view class="carNum">{{ item.licenseNumber}}</view>
<view class="name">品牌{{ item.brandName }}</view>
<view class="phone">型号{{ item.carModelInput }}</view>
</view>
</view>
</view>
</scroll-view>
</view>
<view class="addCarBtn" @click="gotoDetail()">
<uni-icons color="#0174F6" type="plusempty"></uni-icons>
添加车辆
</view>
</view>
2024-09-22 15:07:01 +08:00
</template>
<script>
2024-09-24 19:46:55 +08:00
import VNavigationBar from '@/components/VNavigationBar.vue';
import request from "../../utils/request";
import config from "config";
2024-09-27 17:57:20 +08:00
import {getUserInfoRequest} from "@/utils/common.js";
2024-09-27 17:21:10 +08:00
import {getToken,setUserInfo} from '@/utils/auth.js'
2024-09-24 19:46:55 +08:00
export default {
computed: {
config() {
return config
}
},
components: {
VNavigationBar
},
data() {
return {
carList: [
{
carNum: '鲁A 781NB',
name: '魏书豪',
phone: '15726786903',
image: ''
}
]
};
},
onLoad() {
// 页面初始化
this.getList();
},
onShow() {
2024-09-27 17:21:10 +08:00
if(!getToken()){
uni.reLaunch({
url: '/pages/login/login'
})
}else{
console.log("已登录")
this.getUserInfos()
}
2024-09-24 19:46:55 +08:00
// 页面显示时执行初始化操作
this.getList();
},
methods: {
2024-09-27 17:21:10 +08:00
//获取当前登录用户信息
async getUserInfos() {
console.log("获取用户信息")
2024-09-27 17:57:20 +08:00
getUserInfoRequest()
2024-09-27 17:21:10 +08:00
},
2024-09-24 19:46:55 +08:00
getList(){
request({
url: '/userClient/base/myCar/get',
method: 'GET',
}).then(res => {
console.log(res);
this.carList = res.data;
console.log('图片路径', config.baseImageUrl+this.carList[0].logoImg)
})
},
gotoDetail(item) {
if (item){
uni.navigateTo({
url: `/pages/myCar/carDetail?car=${encodeURIComponent(JSON.stringify(item))}`
});
}
else {
uni.navigateTo({
url: '/pages/myCar/carDetail'
});
}
}
}
};
2024-09-22 15:07:01 +08:00
</script>
<style scoped lang="less">
2024-09-24 19:46:55 +08:00
.container {
height: 100%;
display: flex;
flex-direction: column;
padding-bottom: env(safe-area-inset-bottom);
.body {
flex: 1;
height: 0;
background-color: #f3f5f7;
}
.carList {
display: flex;
flex-direction: column;
}
.carItem {
box-sizing: border-box;
width: 686rpx;
margin: 20rpx auto;
display: flex;
align-items: center;
padding: 30rpx;
background: #ffffff;
border-radius: 12rpx 12rpx 12rpx 12rpx;
column-gap: 20rpx;
}
.carImage {
width: 240rpx;
height: 150rpx;
border-radius: 8rpx 8rpx 8rpx 8rpx;
}
.carNum {
font-weight: bold;
font-size: 36rpx;
color: #333333;
margin-bottom: 20rpx;
}
.name,
.phone {
font-weight: 500;
font-size: 28rpx;
color: #858ba0;
}
.addCarBtn {
padding: 34rpx 0;
background: #ffffff;
border-radius: 0rpx 0rpx 0rpx 0rpx;
display: flex;
align-items: center;
justify-content: center;
column-gap: 12rpx;
font-weight: 500;
font-size: 32rpx;
color: #0174f6;
}
}
</style>