123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <view v-if="state.list.length!=0" style="padding-bottom:30rpx ;">
- <view class="car-item" v-for="(item,index) in state.list">
- <image :src="`${$imgUrl}che.png`" class="car-pic" @click="carDetails(item)"></image>
- <view class="car-info" @click="carDetails(item)">
- <view class="car-no"><text class="no">{{item.vehiclePlate}}</text><text class="color"
- :style="{ background: item.showColor}">{{item.color}}</text></view>
- <view class="card-no">卡号:{{item.cardId}}</view>
- <view class="card-no">签号:{{item.obuId}}</view>
- </view>
- <view class="btn-unbind" @click="del(item.vehicleId)">解除绑定</view>
- </view>
- </view>
- <view v-else class="no">暂无车辆信息</view>
- </template>
-
- <script lang="ts" setup>
- import { reactive } from "vue";
- import { request } from "@/utils/network/request.js";
- import { stringToJson } from "@/utils/network/encryption.js";
- import { onLoad } from "@dcloudio/uni-app";
- import { selectCarInfo, delCarInfo } from "@/utils/network/api.js";
- import { getItem } from "@/utils/storage";
- import { vehiclePlateColorPai } from "@/datas/vehiclePlateColor.js";
- const state = reactive({
- list: ''
- })
- onLoad((option : any) => {
- queryCarMsg();
- })
- const carDetails = (item) => {
- const params = encodeURIComponent(JSON.stringify(item))
- uni.navigateTo({
- url: `/subpackage/personal-center/car-details?params=${params}`
- })
- }
- const queryCarMsg = () => {
- const options = {
- type: 2,
- data: {
- "openId": getItem('openId')
- },
- method: "POST",
- showLoading: true,
- };
- //调用方式
- request(selectCarInfo, options).then((res) => {
- console.log("车辆信息:", res)
- const data = stringToJson(res.bizContent).vehicleManages
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < vehiclePlateColorPai.length; j++) {
- if (data[i].vehiclePlateColor == vehiclePlateColorPai[j]['id']) {
- data[i].color = vehiclePlateColorPai[j]['color']
- data[i].showColor = vehiclePlateColorPai[j]['showColor']
- }
- }
- }
- console.log("data", data)
- state.list = data;
- })
- .catch((err) => {
- });
- }
- // 删除
- const del = (id) => {
- uni.showModal({
- title: '提示',
- content: '是否删除该条车辆信息',
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定');
- let data = {
- vehicleId: id,
- openId: getItem('openId')
- }
- const options = {
- type: 2,
- data: data,
- method: "POST",
- showLoading: true,
- };
- request(delCarInfo, options).then((res) => {
- const data = stringToJson(res.bizContent);
- console.log(data)
- state.list = data.vehicleManages
- if (data.info == '成功.') {
- uni.showToast({
- title: "删除成功",
- icon: "none"
- })
- queryCarMsg();
- }
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
-
- }
- </script>
-
- <style scoped>
- .car-item {
- display: flex;
- align-items: center;
- padding: 36rpx 0;
- width: 95%;
- margin: 0 auto;
- background: #f6f6f6;
- border-radius: 16rpx;
- padding: 20rpx;
- box-sizing: border-box;
- margin-top: 30rpx;
- }
-
- .car-item .btn-unbind {
- border: 1px solid #00B38B;
- border-radius: 30rpx;
- height: 56rpx;
- box-sizing: border-box;
- line-height: 56rpx;
- font-size: 24rpx;
- padding: 0 20rpx;
- background: rgba(0, 179, 139, .1);
- color: #00B38B;
- margin-bottom: 10rpx;
- }
-
-
-
- .car-pic {
- width: 120rpx;
- height: 120rpx;
- margin-right: 16rpx;
- }
-
- .car-info {
- display: flex;
- flex-direction: column;
- flex: 1;
- color: #999;
- font-size: 22rpx;
- }
-
- .car-no {
- font-size: 30rpx;
- color: #333;
- }
-
- .card-no {
- margin-top: 14rpx;
- }
-
- .no {
- text-align: center;
- margin: 50rpx auto;
- }
-
- .color {
- padding: 4rpx 8rpx;
- border-radius: 10rpx;
- color: white;
- background-color: rgb(6, 112, 255);
- display: inline-block;
- margin-left: 20rpx;
- font-size: 24rpx;
- }
- </style>
|