Forráskód Böngészése

添加车辆时增加颜色选项

gcz 4 éve
szülő
commit
3162c4c448
1 módosított fájl, 24 hozzáadás és 1 törlés
  1. 24 1
      pages/myCars/myCars.vue

+ 24 - 1
pages/myCars/myCars.vue

@@ -19,7 +19,7 @@
 				<view class="message-input-wrap" @click="messageInputClick">
 					<u-message-input :maxlength="8" width="70" font-size="50" :disabled-keyboard="true" v-model="newPlateNumber"></u-message-input>
 				</view>				
-				<u-keyboard ref="uKeyboard" mode="car" @change="keyboardChange" @backspace="backspace" v-model="keyboardshow"></u-keyboard>
+				<u-keyboard ref="uKeyboard" mode="car" @change="keyboardChange" @confirm="keyboardConfirm" @backspace="backspace" v-model="keyboardshow"></u-keyboard>
 			</view>
 			<view class="add-car-btn" @click="handleAddCar">添加车辆</view>
 			<view class="mycars">
@@ -36,6 +36,7 @@
 		
 		<u-toast ref="uToast" />
 		<u-modal v-model="delCarshow" :show-cancel-button="true" @confirm="confirmDelCar" :content="delCarContent"></u-modal>
+		<u-action-sheet :list="colorList" @click="confirmColor" v-model="colorShow"></u-action-sheet>
 	</view>
 </template>
 
@@ -51,6 +52,15 @@
 				vehicleColor:0,
 				mycars:[],
 				mycarsTotal:0,
+				colorShow:false,
+				colorList:[
+					{text:'蓝色',colorCode:0}
+					,{text:'黄色',colorCode:1}
+					,{text:'黑色',colorCode:2}
+					,{text:'白色',colorCode:3}
+					,{text:'绿色',colorCode:4}
+					,{text:'其他',colorCode:99}
+				],
 				
 			}
 		},
@@ -76,6 +86,13 @@
 				});
 			},
 			handleAddCar(){
+				if(!this.$u.test.carNo(this.newPlateNumber)){
+					this.$refs.uToast.show({
+						title: '请正确填写车牌号',
+						type: 'error',
+					});
+					return
+				}
 				let param ={
 					vehicleNo: this.newPlateNumber,
 					vehicleColor: this.vehicleColor
@@ -135,6 +152,12 @@
 				if(this.newPlateNumber.length) this.newPlateNumber = this.newPlateNumber.substr(0, this.newPlateNumber.length - 1);
 				console.log(this.newPlateNumber);
 			},
+			keyboardConfirm(){
+				this.colorShow = true;
+			},
+			confirmColor(e){
+				this.vehicleColor = this.colorList[e].colorCode;
+			},
 			// 设置默认车辆
 			handlesetDefault(id){
 				this.$u.api.setDefaultCar({id:id})