瀏覽代碼

with house

zizhong.wang 2 年之前
父節點
當前提交
e89f3abcc7
共有 1 個文件被更改,包括 37 次插入21 次删除
  1. 37 21
      pages/selfCenter/with_house.vue

+ 37 - 21
pages/selfCenter/with_house.vue

@@ -153,6 +153,7 @@ export default {
   methods: {
 	searchHood(){
 		let that = this;
+		this.hoodList = [];
 		// let result = e.detail.value;
 		let md5Sign = md5(
 		  "method=" +
@@ -265,11 +266,6 @@ export default {
 					       title: "暂无数据",
 					       icon: "error",
 					     });
-						 that.buildList = [];
-						 that.unitList = [];
-						 that.numList = [];
-						 that.house.master = '';
-						 that.house.area = '';
 				   }else{
 					   that.makeHouseData(searchType,res.data.data)
 				   } 	
@@ -280,16 +276,43 @@ export default {
 		  },
 		});		
 	},
+	resetLevels(level){
+		//重置下一层
+		let that = this;
+		
+		switch (level){
+			case 1:
+				that.buildList = [];
+				let a = {
+					name : '请选择楼栋'
+				};
+				that.buildList.push(a);
+				that.buildIndex = 0;
+			case 2:
+				that.unitList = [];
+				let b = {
+					name : '请选择单元'
+				};
+				that.unitList.push(b);
+				that.unitIndex = 0;
+			case 3:
+				that.numList = [];
+				let c = {
+					name : '请选择房号'
+				};
+				that.numList.push(c);
+				that.numIndex = 0;
+			case 4:
+				that.house.master = '';
+				that.house.area = '';
+				
+		}
+	},
 	makeHouseData(type,dataList){
 		let that = this , obj = dataList;	
 		switch (type){
 			case 'houseBuilding':
-				that.buildList = [];
-				
-				let c = {
-					name:'请选择楼栋'
-				}
-				that.buildList.push(c);
+				this.resetLevels(1);
 
 				for (let key in obj) {
 					let child = {
@@ -300,11 +323,7 @@ export default {
 				//that.searchDetail(that.hoodName,that.buildList[0].name)
 				break;
 			case 'houseUnit':
-				that.unitList = [];
-				let uc = {
-					name:'请选择单元'
-				}
-				that.unitList.push(uc);
+				this.resetLevels(2);
 				for (let key in obj) {
 					let child = {
 						name:obj[key]
@@ -314,11 +333,7 @@ export default {
 				//that.searchDetail(that.hoodName,that.buildList[that.buildIndex].name,that.unitList[0].name)
 				break;
 			case 'houseNumber':
-				that.numList = [];
-				let nc = {
-					name:'请选择房号'
-				}
-				that.numList.push(nc);
+				this.resetLevels(3);
 				for (let key in obj) {
 						let child = {
 							name:obj[key]
@@ -339,6 +354,7 @@ export default {
 	  this.open()
 	},
 	hoodChange(e){
+	  console.log("e.pickerVal="+e.pickerVal);
 	  this.hoodName = e.pickerVal;
 	  this.searchDetail(this.hoodName)
 	},