<template>
|
<view class="pages-vehicle-detail">
|
<uni-nav-bar :fixed="true" status-bar right-text="" left-text="" leftWidth="72rpx" rightWidth="72rpx"
|
:title="navigationBarTitle">
|
<view class="uni-navbar-container-inner">
|
<text class="uni-nav-bar-text">{{navigationBarTitle }}</text>
|
</view>
|
<template v-slot:right>
|
<view class="uni-navbar-btn-text">
|
<a @click="clickSave" class="uni-nav-bar-right-text">
|
保存
|
</a>
|
</view>
|
|
</template>
|
<template v-slot:left>
|
<view class="uni-navbar-btn-text">
|
<a @click="clickCancel" class="uni-nav-bar-left-text">
|
取消
|
</a>
|
</view>
|
|
</template>
|
</uni-nav-bar>
|
<view class="content">
|
<view class="group">
|
<view class="item line">
|
<view>名称:</view>
|
<input class="input" v-model="vehicleName"> </input>
|
</view>
|
<view class="item line">
|
<view>ip地址:</view>
|
<view class="text">{{vehicleInfo.ip }} </view>
|
</view>
|
<view class="item line">
|
<view>型号:</view>
|
<view class="text">{{vehicleInfo.model_number|| ""}}</view>
|
</view>
|
<view class="item line">
|
<view>车载版本:</view>
|
<view class="text">{{car_version|| ""}}</view>
|
</view>
|
<view class="item line">
|
<view>授权有效期:</view>
|
<view class="text">{{vehicleInfo.authorization_period|| ""}}</view>
|
</view>
|
<!-- <view class="item" @click="clickUpgrade">
|
<view>固件版本:</view>
|
<view class="text2">{{firmware_version|| ""}}</view>
|
<a>
|
<uni-icons color="#888" type="right" size="24"></uni-icons>
|
</a>
|
</view> -->
|
</view>
|
<view class="group">
|
<view class="item line">
|
<view>无线局域网地址:</view>
|
<!-- <input class="input" v-model="vehicleInfo.wifi.mac"> </input> -->
|
<view class="text">{{vehicleInfo.wifi?.mac|| ""}}</view>
|
</view>
|
<!-- <view class="item">
|
<view>蓝牙:</view>
|
<view class="text">{{vehicleInfo.bluetooth|| ""}}</view>
|
</view> -->
|
</view>
|
<a-button type="ghost" class="button" @click="clickDelete">删除车辆</a-button>
|
</view>
|
|
</view>
|
</template>
|
<script>
|
import {
|
showToast,
|
showModal
|
} from "@/comm/utils.js"
|
import {
|
Button
|
} from 'antd-mobile-vue-next'
|
import {
|
shellVersion,
|
} from "@/api/vehicle.js"
|
export default {
|
name: "PagesVehicleDetail",
|
components: {
|
'a-button': Button
|
},
|
data() {
|
return {
|
vehicleIp: '',
|
navigationBarTitle: '',
|
vehicleInfo: {},
|
car_version: "",
|
vehicleName: "",
|
}
|
},
|
onLoad(option) {
|
if (option.param)
|
this.vehicleInfo = JSON.parse(option.param)
|
|
this.navigationBarTitle = ""
|
this.vehicleName = this.vehicleInfo?.name || ""
|
this.vehicleIp = this.vehicleInfo?.ip || ""
|
this.loadVersion()
|
},
|
methods: {
|
setData(obj) {
|
let that = this;
|
let keys = [];
|
let val, data;
|
|
Object.keys(obj).forEach(function(key) {
|
keys = key.split(".");
|
val = obj[key];
|
data = that.$data;
|
keys.forEach(function(key2, index) {
|
if (index + 1 == keys.length) {
|
that.$set(data, key2, val);
|
} else {
|
if (!data[key2]) {
|
that.$set(data, key2, {});
|
}
|
}
|
data = data[key2];
|
});
|
});
|
},
|
async loadVersion() {
|
try {
|
const info = await shellVersion(this.vehicleIp)
|
this.car_version = info.software_version
|
} catch (ex) {
|
this.showError(ex)
|
}
|
},
|
clickDelete() {
|
showModal(`确定要删除设备“${ this.vehicleInfo.name}”吗`, "警告").then((res) => {
|
if (res) {
|
const eventChannel = this.getOpenerEventChannel();
|
eventChannel.emit('delete_vehicle', this.vehicleInfo);
|
uni.navigateBack({
|
delta: 1, //返回层数,2则上上页
|
})
|
}
|
|
})
|
},
|
clickUpgrade() {
|
uni.navigateTo({
|
url: "/pages/vehicle/upgrade"
|
})
|
},
|
clickSave() {
|
this.vehicleInfo.name = this.vehicleName || this.vehicleInfo.name || this.vehicleInfo.ip
|
|
const eventChannel = this.getOpenerEventChannel();
|
eventChannel.emit('update_vehicle', this.vehicleInfo);
|
|
uni.navigateBack({
|
delta: 1, //返回层数,2则上上页
|
})
|
},
|
clickCancel() {
|
uni.navigateBack({
|
delta: 1
|
})
|
},
|
showError(ex) {
|
let exStr = JSON.stringify(ex)
|
if (exStr == "{}")
|
exStr = ex
|
let tip = typeof ex.msg == "string" ? ex.msg : exStr
|
showModal(tip, "错误", false)
|
},
|
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
.pages-vehicle-detail {
|
display: flex;
|
width: 750rpx;
|
height: 100vh;
|
flex-direction: column;
|
background-color: #F4F4F4;
|
|
// .uni-nav-bar-left-text {
|
// font-size: 32rpx;
|
// }
|
|
// .uni-nav-bar-right-text {
|
// font-size: 32rpx;
|
// }
|
|
.content {
|
width: 750rpx;
|
flex: 1;
|
|
.group {
|
width: calc(100% - 60rpx);
|
border-radius: 20rpx;
|
margin: 20rpx;
|
padding-left: 20rpx;
|
display: flex;
|
flex-direction: column;
|
background-color: #FFF;
|
|
.item {
|
width: 100%;
|
padding: 20rpx 0;
|
display: flex;
|
flex-direction: row;
|
|
.text {
|
flex: 1;
|
text-align: right;
|
color: #ccc;
|
padding-right: 40rpx;
|
}
|
|
.input {
|
flex: 1;
|
text-align: right;
|
padding-right: 40rpx;
|
}
|
|
.text2 {
|
flex: 1;
|
text-align: right;
|
color: #ccc;
|
}
|
|
}
|
|
.line {
|
border-bottom: 1px solid #F5F5F5;
|
}
|
}
|
|
.button {
|
margin: 20rpx !important;
|
width: calc(100% - 40rpx);
|
border-radius: 4rpx;
|
|
color: red;
|
}
|
}
|
}
|
</style>
|