|
|
@@ -1,6 +1,7 @@
|
|
|
<template>
|
|
|
<view class="container">
|
|
|
- <picker class="picker-item1" @change="changeSelect1" :range="array1" :value="index1" :disabled="dis_num1">
|
|
|
+ <picker class="picker-item1" @tap="clickSelect1" @change="changeSelect1" :range="array1" :value="index1"
|
|
|
+ :disabled="dis_num1">
|
|
|
<view class="select-item">
|
|
|
<view class="picker-item-logol">
|
|
|
<image class="picker-item-logo-left" src="../static/images/school.png"></image>
|
|
|
@@ -12,7 +13,8 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</picker>
|
|
|
- <picker class="picker-item2" @change="changeSelect2" :range="array2" :value="index2" :disabled="dis_num2">
|
|
|
+ <picker class="picker-item2" @tap="clickSelect2" @change="changeSelect2" :range="array2" :value="index2"
|
|
|
+ :disabled="dis_num2">
|
|
|
<view class="select-item">
|
|
|
<view class="picker-item-logol">
|
|
|
<image class="picker-item-logo-left" src="../static/images/building.png"></image>
|
|
|
@@ -24,7 +26,8 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</picker>
|
|
|
- <picker class="picker-item2" @change="changeSelect3" :range="array3" :value="index3" :disabled="dis_num3">
|
|
|
+ <picker class="picker-item2" @tap="clickSelect3" @change="changeSelect3" :range="array3" :value="index3"
|
|
|
+ :disabled="dis_num3">
|
|
|
<view class="select-item">
|
|
|
<view class="picker-item-logol">
|
|
|
<image class="picker-item-logo-left" src="../static/images/floor.png"></image>
|
|
|
@@ -36,7 +39,8 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</picker>
|
|
|
- <picker class="picker-item2" @change="changeSelect4" :range="array4" :value="index4" :disabled="dis_num4">
|
|
|
+ <picker class="picker-item2" @tap="clickSelect4" @change="changeSelect4" :range="array4" :value="index4"
|
|
|
+ :disabled="dis_num4">
|
|
|
<view class="select-item">
|
|
|
<view class="picker-item-logol">
|
|
|
<image class="picker-item-logo-left" src="../static/images/room.png"></image>
|
|
|
@@ -92,41 +96,38 @@
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
- // 请求校区、楼栋、层好、宿舍号等数据
|
|
|
- this.requestAllData()
|
|
|
+ // 获取校区
|
|
|
+ this.getCampus()
|
|
|
},
|
|
|
-
|
|
|
methods: {
|
|
|
/**
|
|
|
- * 请求楼栋、楼层、宿舍等信息
|
|
|
+ * 获取校区
|
|
|
*/
|
|
|
- async requestAllData() {
|
|
|
- uni.showLoading({
|
|
|
- title: '数据加载中……',
|
|
|
- mask: true
|
|
|
- });
|
|
|
+ async getCampus() {
|
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
|
- url: '/HotWaters/buildelec.action',
|
|
|
+ url: '/HotWaters/buildschools.action',
|
|
|
method: 'POST',
|
|
|
header: {
|
|
|
'content-type': 'application/json'
|
|
|
}
|
|
|
})
|
|
|
- // console.log(res.data.data);
|
|
|
- let rooms = JSON.parse('[{"data":' + res.data.data + '}]')[0]
|
|
|
- // console.log(rooms);
|
|
|
- if (typeof(rooms) != 'undefined') {
|
|
|
- this.allData = rooms
|
|
|
- this.nschool = rooms.data.length
|
|
|
+ // console.log(res.data);
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ let tmpData = res.data.data;
|
|
|
+ this.nschool = tmpData.length
|
|
|
this.array1 = []
|
|
|
|
|
|
for (var i = 0; i < this.nschool; i++) {
|
|
|
- this.array1.push(rooms.data[i].school)
|
|
|
+ this.array1.push(tmpData[i].school)
|
|
|
}
|
|
|
|
|
|
this.dis_num1 = 0
|
|
|
- uni.hideLoading()
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得校区',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
if (this.$store.state.building.roomSelect != '') {
|
|
|
@@ -170,10 +171,7 @@
|
|
|
this.arr4 = [arr[2]]
|
|
|
}
|
|
|
|
|
|
- this.sel1(this.arr1)
|
|
|
- this.sel2(this.arr2)
|
|
|
- this.sel3(this.arr3)
|
|
|
- this.sel4(this.arr4)
|
|
|
+ this.sel1(this.arr1, true);
|
|
|
|
|
|
this.add_class1 = 1
|
|
|
this.add_class2 = 1
|
|
|
@@ -185,148 +183,272 @@
|
|
|
this.dis_num4 = 0
|
|
|
}
|
|
|
},
|
|
|
+ clickSelect1() {
|
|
|
+ if (this.array1.length == 0) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得校区,可能网络异常',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
/**
|
|
|
* 选择校区
|
|
|
*/
|
|
|
changeSelect1(e) {
|
|
|
- this.sel1(e.detail.value)
|
|
|
+ this.array2 = []
|
|
|
+ this.array3 = []
|
|
|
+ this.array4 = []
|
|
|
+ this.sel1(e.detail.value, false)
|
|
|
},
|
|
|
// 根据参数的值选中
|
|
|
- sel1(index) {
|
|
|
+ sel1(index, theRoomIsExist) {
|
|
|
// console.log(index)
|
|
|
// console.log(typeof(index))
|
|
|
this.arr1 = this.array1;
|
|
|
//获取选择器1的值
|
|
|
- for (var i = 0; i < this.nschool; i++) {
|
|
|
- // this.array1.push(this.allData.data[i].school)
|
|
|
- // console.log(this.allData.data[i].school)
|
|
|
- if (typeof(index) == 'string') {
|
|
|
- this.index1 = index;
|
|
|
- } else if (this.allData.data[i].school == index[0]) {
|
|
|
- this.index1 = i
|
|
|
- }
|
|
|
- //判断是否为空,不为空则继续
|
|
|
- if (!this.allData.data[i].builds) {
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
- //获取选择器二中的值
|
|
|
- if (i == this.index1) {
|
|
|
- //得到选择器二中值的个数
|
|
|
- this.nbuilds = this.allData.data[i].builds.length
|
|
|
- this.array2 = []
|
|
|
- //将数据加入选择器二中
|
|
|
- for (var j = 0; j < this.nbuilds; j++) {
|
|
|
- this.array2.push(this.allData.data[i].builds[j].building)
|
|
|
+ if (typeof(index) == 'string') {
|
|
|
+ this.index1 = index;
|
|
|
+ } else {
|
|
|
+ for (var i = 0; i < this.nschool; i++) {
|
|
|
+ if (index[0] == this.array1[i]) {
|
|
|
+ this.index1 = i
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (typeof(index) == 'string') {
|
|
|
- this.arr2 = ['请选择楼栋']
|
|
|
- this.arr3 = ['请选择楼层']
|
|
|
- this.arr4 = ['请选择房间']
|
|
|
- this.index2 = 0
|
|
|
- this.index3 = 0
|
|
|
- this.index4 = 0
|
|
|
+ //获取选择器二中的值
|
|
|
+ this.getBuilds(this.array1[this.index1], theRoomIsExist)
|
|
|
|
|
|
- this.room = ''
|
|
|
- }
|
|
|
+ if (typeof(index) == 'string') {
|
|
|
+ this.arr2 = ['请选择楼栋']
|
|
|
+ this.arr3 = ['请选择楼层']
|
|
|
+ this.arr4 = ['请选择房间']
|
|
|
+ this.index2 = 0
|
|
|
+ this.index3 = 0
|
|
|
+ this.index4 = 0
|
|
|
+
|
|
|
+ this.room = ''
|
|
|
}
|
|
|
- // this.room = this.room.concat(this.array1[this.index1]);
|
|
|
+
|
|
|
this.add_class1 = 1;
|
|
|
this.dis_num2 = 0;
|
|
|
- // console.log(this.array2)
|
|
|
- // console.log(this.room)
|
|
|
+
|
|
|
+ this.chgDisable()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取楼栋
|
|
|
+ * @param {Object} campus
|
|
|
+ */
|
|
|
+ async getBuilds(campus, theRoomIsExist) {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ url: '/HotWaters/buildbuilds.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ school: campus
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // console.log('楼栋:', res.data);
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ let tmpData = res.data.data;
|
|
|
+ // this.allData = rooms
|
|
|
+ //得到选择器二中值的个数
|
|
|
+ this.nbuilds = tmpData.length
|
|
|
+ this.array2 = []
|
|
|
+ //将数据加入选择器二中
|
|
|
+ for (var j = 0; j < this.nbuilds; j++) {
|
|
|
+ this.array2.push(tmpData[j].build)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (theRoomIsExist == true) {
|
|
|
+ this.sel2(this.arr2, true)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.array2 = []
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得楼栋',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clickSelect2() {
|
|
|
+ if (this.array2.length == 0) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得楼栋,该校区没有楼栋',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
changeSelect2(e) {
|
|
|
- this.sel2(e.detail.value)
|
|
|
+ this.array3 = []
|
|
|
+ this.array4 = []
|
|
|
+ this.sel2(e.detail.value, false)
|
|
|
},
|
|
|
- sel2(index) {
|
|
|
+ sel2(index, theRoomIsExist) {
|
|
|
// console.log(index);
|
|
|
+ // console.log(typeof index);
|
|
|
this.arr2 = this.array2;
|
|
|
|
|
|
- for (var i = 0; i < this.nbuilds; i++) {
|
|
|
- // this.array1.push(this.allData.data[i].school)
|
|
|
- // console.log(this.allData.data[i].school)
|
|
|
- if (typeof(index) == 'string') {
|
|
|
- this.index2 = index;
|
|
|
- } else if (this.allData.data[this.index1].builds[i].building == index[0]) {
|
|
|
- this.index2 = i
|
|
|
- }
|
|
|
-
|
|
|
- if (!this.allData.data[this.index1].builds[i].floors) {
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
- if (i == this.index2) {
|
|
|
- this.floors = this.allData.data[this.index1].builds[i].floors.length
|
|
|
- this.array3 = []
|
|
|
- // console.log(this.floors)
|
|
|
- for (var j = 0; j < this.floors; j++) {
|
|
|
- this.array3.push(this.allData.data[this.index1].builds[i].floors[j].floor)
|
|
|
+ if (typeof(index) == 'string') {
|
|
|
+ this.index2 = index;
|
|
|
+ } else {
|
|
|
+ for (var i = 0; i < this.nbuilds; i++) {
|
|
|
+ if (index[0] == this.array2[i]) {
|
|
|
+ this.index2 = i
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (typeof(index) == 'string') {
|
|
|
- this.arr3 = ['请选择楼层']
|
|
|
- this.arr4 = ['请选择房间']
|
|
|
- this.index3 = 0
|
|
|
- this.index4 = 0
|
|
|
+ this.getFloors(this.array1[this.index1], this.array2[this.index2], theRoomIsExist)
|
|
|
|
|
|
- this.room = ''
|
|
|
- }
|
|
|
+ if (typeof(index) == 'string') {
|
|
|
+ this.arr3 = ['请选择楼层']
|
|
|
+ this.arr4 = ['请选择房间']
|
|
|
+ this.index3 = 0
|
|
|
+ this.index4 = 0
|
|
|
+
|
|
|
+ this.room = ''
|
|
|
}
|
|
|
|
|
|
- // this.room = this.room.concat(this.array2[this.index2]);
|
|
|
this.add_class2 = 1;
|
|
|
this.dis_num3 = 0;
|
|
|
- // console.log(this.room)
|
|
|
- },
|
|
|
- changeSelect3(e) {
|
|
|
- this.sel3(e.detail.value)
|
|
|
+
|
|
|
+ this.chgDisable()
|
|
|
},
|
|
|
- sel3(index) {
|
|
|
- // console.log(index)
|
|
|
- this.arr3 = this.array3;
|
|
|
+ /**
|
|
|
+ * 获取楼层
|
|
|
+ * @param {Object} campus
|
|
|
+ * @param {Object} build
|
|
|
+ */
|
|
|
+ async getFloors(campus, build, theRoomIsExist) {
|
|
|
+ // console.log(campus, build);
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ url: '/HotWaters/buildFloors.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ school: campus,
|
|
|
+ build: build
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // console.log('楼层:', res.data);
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ let tmpData = res.data.data;
|
|
|
+ this.floors = tmpData.length
|
|
|
+ this.array3 = []
|
|
|
|
|
|
- for (var i = 0; i < this.floors; i++) {
|
|
|
- // this.array1.push(this.allData.data[i].school)
|
|
|
- // console.log(this.allData.data[i].school)
|
|
|
- if (typeof(index) == 'string') {
|
|
|
- this.index3 = index;
|
|
|
- } else if (this.allData.data[this.index1].builds[this.index2].floors[i].floor == index[0]) {
|
|
|
- this.index3 = i
|
|
|
+ for (var j = 0; j < this.floors; j++) {
|
|
|
+ this.array3.push(tmpData[j].floors)
|
|
|
}
|
|
|
|
|
|
- if (!this.allData.data[this.index1].builds[this.index2].floors[i].rooms) {
|
|
|
- continue
|
|
|
+ if (theRoomIsExist == true) {
|
|
|
+ this.sel3(this.arr3, true)
|
|
|
}
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得楼层',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clickSelect3() {
|
|
|
+ if (this.array3.length == 0) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得楼层,请选择楼栋',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ changeSelect3(e) {
|
|
|
+ this.array4 = []
|
|
|
+ this.sel3(e.detail.value, false)
|
|
|
+ },
|
|
|
+ sel3(index, theRoomIsExit) {
|
|
|
+ // console.log(index)
|
|
|
+ this.arr3 = this.array3;
|
|
|
|
|
|
- if (i == this.index3) {
|
|
|
- this.rooms = this.allData.data[this.index1].builds[this.index2].floors[i].rooms.length
|
|
|
- this.array4 = []
|
|
|
- // console.log(this.rooms)
|
|
|
- for (var j = 0; j < this.rooms; j++) {
|
|
|
- this.array4.push(this.allData.data[this.index1].builds[this.index2].floors[i].rooms[j])
|
|
|
+ if (typeof(index) == 'string') {
|
|
|
+ this.index3 = index;
|
|
|
+ } else {
|
|
|
+ for (var i = 0; i < this.floors; i++) {
|
|
|
+ if (index[0] == this.array3[i]) {
|
|
|
+ this.index3 = i
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (typeof(index) == 'string') {
|
|
|
- this.arr4 = ['请选择房间']
|
|
|
- this.index4 = 0
|
|
|
+ this.getDoms(this.array1[this.index1], this.array2[this.index2], this.array3[this.index3], theRoomIsExit)
|
|
|
|
|
|
- this.room = ''
|
|
|
- }
|
|
|
+ if (typeof(index) == 'string') {
|
|
|
+ this.arr4 = ['请选择房间']
|
|
|
+ this.index4 = 0
|
|
|
+
|
|
|
+ this.room = ''
|
|
|
}
|
|
|
- // this.room = this.room.concat(this.array3[this.index3]);
|
|
|
+
|
|
|
this.add_class3 = 1;
|
|
|
this.dis_num4 = 0;
|
|
|
- // console.log(this.room)
|
|
|
+
|
|
|
+ this.chgDisable()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取房间
|
|
|
+ * @param {Object} campus
|
|
|
+ * @param {Object} build
|
|
|
+ * @param {Object} floors
|
|
|
+ */
|
|
|
+ async getDoms(campus, build, floors, theRoomIsExist) {
|
|
|
+ // console.log(campus, build, floors);
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ url: '/HotWaters/builddoms.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ school: campus,
|
|
|
+ build: build,
|
|
|
+ floors: floors
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // console.log('房间:', res.data);
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ let tmpData = res.data.data;
|
|
|
+ this.rooms = tmpData.length
|
|
|
+ this.array4 = []
|
|
|
+ for (var j = 0; j < this.rooms; j++) {
|
|
|
+ this.array4.push(tmpData[j].dom)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (theRoomIsExist == true) {
|
|
|
+ this.sel4(this.arr4, true)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得房间',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clickSelect4() {
|
|
|
+ if (this.array4.length == 0) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得房间,请选择楼层',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
changeSelect4(e) {
|
|
|
- this.sel4(e.detail.value)
|
|
|
+ this.sel4(e.detail.value, false)
|
|
|
},
|
|
|
- sel4(index) {
|
|
|
+ sel4(index, theRoomIsExist) {
|
|
|
// console.log(index)
|
|
|
this.arr4 = this.array4;
|
|
|
|
|
|
@@ -335,16 +457,43 @@
|
|
|
if (this.room) {
|
|
|
this.room = ''
|
|
|
}
|
|
|
- for (var i = 0; i < this.rooms; i++) {
|
|
|
- if (typeof(index) == 'string')
|
|
|
- this.index4 = index;
|
|
|
- else if (this.allData.data[this.index1].builds[this.index2].floors[this.index3].rooms[i] == index[0]) {
|
|
|
- this.index4 = i
|
|
|
+
|
|
|
+
|
|
|
+ if (typeof(index) == 'string') {
|
|
|
+ this.index4 = index;
|
|
|
+ } else {
|
|
|
+ for (var i = 0; i < this.rooms; i++) {
|
|
|
+ if (this.array4[i] == index[0]) {
|
|
|
+ this.index4 = i
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- this.room = this.room.concat(this.array1[this.index1], this.array4[this.index4]);
|
|
|
+
|
|
|
+ this.room = this.array1[this.index1] + this.array4[this.index4];
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 下拉框变量数组为空,就禁用
|
|
|
+ */
|
|
|
+ chgDisable() {
|
|
|
+ setTimeout(() => {
|
|
|
+ if (this.array1.length == 0) {
|
|
|
+ this.dis_num1 = 1
|
|
|
+ }
|
|
|
+ if (this.array2.length == 0) {
|
|
|
+ this.dis_num2 = 1
|
|
|
+ }
|
|
|
+ if (this.array3.length == 0) {
|
|
|
+ this.dis_num3 = 1
|
|
|
+ }
|
|
|
+ if (this.array4.length == 0) {
|
|
|
+ this.dis_num4 = 1
|
|
|
+ }
|
|
|
+ }, 300)
|
|
|
},
|
|
|
- //跳转缴费页面
|
|
|
+ /**
|
|
|
+ * 跳转缴费页面
|
|
|
+ * @param {Object} e
|
|
|
+ */
|
|
|
navigateToIndex(e) {
|
|
|
// console.log(e)
|
|
|
var roomSelect = e.currentTarget.dataset.room;
|
|
|
@@ -353,7 +502,7 @@
|
|
|
if (this.room != '') {
|
|
|
this.$store.state.building.roomSelect = this.storage.roomSelect;
|
|
|
this.$store.state.building.add_class = 1;
|
|
|
- this.$store.state.building.dom = this.storage.dom;
|
|
|
+ this.$store.state.building.dorm_number = this.storage.dom;
|
|
|
uni.navigateBack({
|
|
|
delta: 1
|
|
|
})
|