wkyy 3 tahun lalu
induk
melakukan
51e52e0678
3 mengubah file dengan 52 tambahan dan 9 penghapusan
  1. 16 3
      components/Ucarkeyboard.vue
  2. 18 3
      pages/user/car/carAdd.vue
  3. 18 3
      pages/user/car/carDet.vue

+ 16 - 3
components/Ucarkeyboard.vue

@@ -1,6 +1,14 @@
 <template>
-	<u-popup class="" :mask="mask" :maskCloseAble="maskCloseAble" mode="bottom" :popup="false" v-model="value" length="auto"
-	 :safeAreaInsetBottom="safeAreaInsetBottom" @close="popupClose" :zIndex="uZIndex">
+	<view
+	style="    bottom: 0;
+    left: 0;
+    right: 0;
+    background-color: #ffffff;
+
+    display: block;
+    position: absolute;"
+	
+	>
 		<slot />
 		<view class="u-tooltip" v-if="tooltip">
 			<view class="u-tooltip-item u-tooltip-cancel" hover-class="u-tooltip-cancel-hover" @tap="onCancel">
@@ -19,7 +27,7 @@
 		<block v-else>
 			<u-car-keyboard :random="random" @backspace="backspace" ref="thiscar" @change="change"></u-car-keyboard>
 		</block>
-	</u-popup>
+	</view>
 </template>
 
 <script>
@@ -136,8 +144,13 @@
 			}
 		},
 		methods: {
+		changeCarInputValue(){
+
+			return this.$refs.thiscar.abc
+		},
 			changeCarInputMode(){
 				this.$refs.thiscar.changeCarInputMode()
+				return this.$refs.thiscar.abc
 			},
 			change(e) {
 				this.$emit('change', e);

+ 18 - 3
pages/user/car/carAdd.vue

@@ -10,9 +10,9 @@
 		</view>
 		<view class="carDet">
 			<u-form :model="form" ref="uForm">
-				<ucarkeyboard ref="uKeyboard" mode="car" v-model="keyShow" @change="valChange" @backspace="backspace"></ucarkeyboard>
+				<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="keyShow = true"></view>
+					<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>
 				<u-form-item label="设为默认车辆" label-width="180rpx"><u-switch slot="right" v-model="form.defaultFlag"></u-switch></u-form-item>
@@ -50,19 +50,32 @@
 				this.getCarList();
 			}
 		},
+		onReady() {
+			this.$refs.uKeyboard.changeCarInputMode();
+		},
 		methods: {
+			keyClick() {
+				this.keyShow = true;
+			},
 			// 按键被点击(点击退格键不会触发此事件)
 			valChange(val) {
 				// 将每次按键的值拼接到form.carNum变量中,注意+=写法
 				this.form.carNum += val;
 				console.log(this.form.carNum);
-				//	this.$refs.uKeyboard.changeCarInputMode()
+				if(this.form.carNum.length == 1) {
+					this.$refs.uKeyboard.changeCarInputMode();
+				}
 			},
 			// 退格键被点击
 			backspace() {
 				// 删除form.carNum的最后一个字符
 				if(this.form.carNum.length) this.form.carNum = this.form.carNum.substr(0, this.form.carNum.length - 1);
 				console.log(this.form.carNum);
+				
+				var aaa =	this.$refs.uKeyboard.changeCarInputValue();
+				if(this.form.carNum.length == 0 && aaa) {
+					this.$refs.uKeyboard.changeCarInputMode();
+				}
 			},
 			getCarList() {	
 				uni.showLoading({
@@ -89,6 +102,7 @@
 			},
 			showDelete() {
 				this.show = true;
+				this.keyShow = false;
 			},
 			confirmDelete() {
 				uni.showLoading({
@@ -112,6 +126,7 @@
 				})
 			},
 			keepCar() {
+				this.keyShow = false;
 				uni.showLoading({
 					title: "加载中",
 					mask: true,

+ 18 - 3
pages/user/car/carDet.vue

@@ -4,13 +4,13 @@
 		<view class="key-input">
 			<u-message-input :focus="true" :value="form.carNum" :maxlength="maxlength" :disabled-keyboard="true"></u-message-input>
 		</view>
-		<ucarkeyboard ref="uKeyboard" mode="car" :showTips="true" :confirmBtn="false" :tooltip="false" v-model="keyShow" @change="valChange" @backspace="backspace"></ucarkeyboard>
+		<ucarkeyboard ref="uKeyboard" mode="car" :showTips="true" :confirmBtn="false" :mask-close-able="false" :tooltip="false" v-model="keyShow" @change="valChange" @backspace="backspace"></ucarkeyboard>
 		<view class="default">
 			<u-checkbox-group>
 				<u-checkbox class="tips" v-model="form.defaultFlag" shape="circle" @change="checkboxChange()">设为默认车辆</u-checkbox>
 			</u-checkbox-group>
 		</view>
-		<u-button class="login-btn" type="success" shape="circle" @click="sure">保存</u-button>
+		<u-button class="login-btn" type="success" shape="circle" @click="keepCar">保存</u-button>
 	</view>
 </template>
 
@@ -46,6 +46,9 @@
 				}
 			}
 		},
+		onReady() {
+			this.$refs.uKeyboard.changeCarInputMode();
+		},
 		methods: {
 			checkboxChange() {
 				this.form.defaultFlag = !this.form.defaultFlag;
@@ -55,15 +58,24 @@
 				// 将每次按键的值拼接到form.carNum变量中,注意+=写法
 				this.form.carNum += val;
 				console.log(this.form.carNum);
-				// this.$refs.uKeyboard.changeCarInputMode()
+				
+				if(this.form.carNum.length == 1) {
+					this.$refs.uKeyboard.changeCarInputMode();
+				}
 			},
 			// 退格键被点击
 			backspace() {
 				// 删除form.carNum的最后一个字符
 				if (this.form.carNum.length) this.form.carNum = this.form.carNum.substr(0, this.form.carNum.length - 1);
 				console.log(this.form.carNum);
+				
+				var aaa =	this.$refs.uKeyboard.changeCarInputValue();
+				if(this.form.carNum.length == 0 && aaa) {
+					this.$refs.uKeyboard.changeCarInputMode();
+				}
 			},
 			keepCar() {
+				console.log(this.form)
 				uni.showLoading({
 					title: "加载中",
 					mask: true,
@@ -96,6 +108,9 @@
 	}
 </style>
 <style lang="scss" scoped>
+	.u-drawer{
+		z-index: -1 !important;
+	}
 	/deep/.u-char-item {
 		width: 32px !important;
 		height: 40px !important;