|
@@ -10,11 +10,9 @@
|
|
</view>
|
|
</view>
|
|
<view class="carDet">
|
|
<view class="carDet">
|
|
<u-form :model="form" ref="uForm">
|
|
<u-form :model="form" ref="uForm">
|
|
- <ucarkeyboard ref="uKeyboard" mode="car" :showTips="true" :confirmBtn="false" :mask-close-able="false" :tooltip="false" v-show="keyShow" @change="valChange" @backspace="backspace"></ucarkeyboard>
|
|
|
|
- <u-form-item label="车牌号码" label-width="150rpx">
|
|
|
|
- <view style="margin-left: auto;" :style="form.carNum ? 'color:black;': 'color: #c0c4cc;'" v-text="form.carNum ? form.carNum : '请输入内容'" @click="keyClick"></view>
|
|
|
|
- </u-form-item>
|
|
|
|
- <u-form-item label="车辆类型" label-width="150rpx"><u-input input-align="right" placeholder="新能源车" placeholder-style="color:black" disabled /></u-form-item>
|
|
|
|
|
|
+ <ucarkeyboard ref="uKeyboard" mode="car" @confirm="confirm" @cancel="cancel" v-show="keyShow" @change="valChange" @backspace="backspace"></ucarkeyboard>
|
|
|
|
+ <u-form-item label="车牌号码" label-width="150rpx"><u-input input-align="right" placeholder="请输入车牌号" v-model="form.carNum" @click="keyClick" /></u-form-item>
|
|
|
|
+ <u-form-item label="车辆类型" label-width="150rpx"><u-input input-align="right" v-model="carName" placeholder="请输入正确车牌号" disabled /></u-form-item>
|
|
<u-form-item label="设为默认车辆" label-width="180rpx"><u-switch slot="right" v-model="form.defaultFlag"></u-switch></u-form-item>
|
|
<u-form-item label="设为默认车辆" label-width="180rpx"><u-switch slot="right" v-model="form.defaultFlag"></u-switch></u-form-item>
|
|
</u-form>
|
|
</u-form>
|
|
</view>
|
|
</view>
|
|
@@ -32,6 +30,7 @@
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ carName: '',
|
|
keyShow: false,
|
|
keyShow: false,
|
|
show: false,
|
|
show: false,
|
|
title: '删除车辆',
|
|
title: '删除车辆',
|
|
@@ -54,17 +53,33 @@
|
|
this.$refs.uKeyboard.changeCarInputMode();
|
|
this.$refs.uKeyboard.changeCarInputMode();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ cancel() {
|
|
|
|
+ this.keyShow = false;
|
|
|
|
+ },
|
|
|
|
+ confirm() {
|
|
|
|
+ this.keyShow = false;
|
|
|
|
+ },
|
|
keyClick() {
|
|
keyClick() {
|
|
this.keyShow = true;
|
|
this.keyShow = true;
|
|
|
|
+ uni.hideKeyboard();
|
|
},
|
|
},
|
|
// 按键被点击(点击退格键不会触发此事件)
|
|
// 按键被点击(点击退格键不会触发此事件)
|
|
valChange(val) {
|
|
valChange(val) {
|
|
// 将每次按键的值拼接到form.carNum变量中,注意+=写法
|
|
// 将每次按键的值拼接到form.carNum变量中,注意+=写法
|
|
- this.form.carNum += val;
|
|
|
|
- console.log(this.form.carNum);
|
|
|
|
- if(this.form.carNum.length == 1) {
|
|
|
|
- this.$refs.uKeyboard.changeCarInputMode();
|
|
|
|
- }
|
|
|
|
|
|
+ if(this.form.carNum.length < 8) {
|
|
|
|
+ this.form.carNum += val;
|
|
|
|
+ console.log(this.form.carNum);
|
|
|
|
+ if(this.form.carNum.length == 1) {
|
|
|
|
+ this.$refs.uKeyboard.changeCarInputMode();
|
|
|
|
+ }
|
|
|
|
+ if(this.form.carNum.length == 8) {
|
|
|
|
+ this.carName = '新能源车';
|
|
|
|
+ } else if (this.form.carNum.length == 7) {
|
|
|
|
+ this.carName = '燃油车';
|
|
|
|
+ } else {
|
|
|
|
+ this.carName = '';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
// 退格键被点击
|
|
// 退格键被点击
|
|
backspace() {
|
|
backspace() {
|
|
@@ -76,6 +91,13 @@
|
|
if(this.form.carNum.length == 0 && aaa) {
|
|
if(this.form.carNum.length == 0 && aaa) {
|
|
this.$refs.uKeyboard.changeCarInputMode();
|
|
this.$refs.uKeyboard.changeCarInputMode();
|
|
}
|
|
}
|
|
|
|
+ if(this.form.carNum.length == 8) {
|
|
|
|
+ this.carName = '新能源车';
|
|
|
|
+ } else if (this.form.carNum.length == 7) {
|
|
|
|
+ this.carName = '燃油车';
|
|
|
|
+ } else {
|
|
|
|
+ this.carName = '';
|
|
|
|
+ }
|
|
},
|
|
},
|
|
getCarList() {
|
|
getCarList() {
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
@@ -91,6 +113,13 @@
|
|
if(this.form.id == carId) {
|
|
if(this.form.id == carId) {
|
|
this.form.carNum = this.carList[i].carNum;
|
|
this.form.carNum = this.carList[i].carNum;
|
|
this.form.defaultFlag = this.carList[i].defaultFlag;
|
|
this.form.defaultFlag = this.carList[i].defaultFlag;
|
|
|
|
+ if(this.form.carNum.length == 8) {
|
|
|
|
+ this.carName = '新能源车';
|
|
|
|
+ } else if (this.form.carNum.length == 7) {
|
|
|
|
+ this.carName = '燃油车';
|
|
|
|
+ } else {
|
|
|
|
+ this.carName = '';
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}).catch(error => {
|
|
}).catch(error => {
|