select.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="container">
  3. <!-- 选择校区区域 -->
  4. <picker class="picker-item" @change="changeSelect" :range="array" :value="index">
  5. <view class="select-item">
  6. <view class="picker-item-logol">
  7. <image class="picker-item-logo-left" src="../../static/school.png"></image>
  8. </view>
  9. <view class="picker-item-label">校区</view>
  10. <view class="picker-item-content" :class="value!='请选择校区'?'color':''">{{value}}</view>
  11. <view class="picker-item-logor">
  12. <image class="picker-item-logo-right" src="../../static/right.png"></image>
  13. </view>
  14. </view>
  15. </picker>
  16. <!-- 选择楼栋区域 -->
  17. <picker class="picker-item" @click="handleBuild" @change="changeSelect_build" :range="array_build"
  18. range-key="buildName" :value="index_build" :disabled="disabled_build">
  19. <view class="select-item">
  20. <view class="picker-item-logol">
  21. <image class="picker-item-logo-left" src="../../static/building.png"></image>
  22. </view>
  23. <view class="picker-item-label">楼栋</view>
  24. <view class="picker-item-content" :class="value_build!='请选择楼栋'?'color':''">{{value_build}}</view>
  25. <view class="picker-item-logor">
  26. <image class="picker-item-logo-right" src="../../static/right.png"></image>
  27. </view>
  28. </view>
  29. </picker>
  30. <!-- 选择楼层区域 -->
  31. <picker class="picker-item" @click="handleFloor" @change="changeSelect_floor" :range="array_floor"
  32. range-key="floorName" :value="index_floor" :disabled="disabled_floor">
  33. <view class="select-item">
  34. <view class="picker-item-logol">
  35. <image class="picker-item-logo-left" src="../../static/floor.png"></image>
  36. </view>
  37. <view class="picker-item-label">楼层</view>
  38. <view class="picker-item-content" :class="value_floor!='请选择楼层'?'color':''">{{value_floor}}</view>
  39. <view class="picker-item-logor">
  40. <image class="picker-item-logo-right" src="../../static/right.png"></image>
  41. </view>
  42. </view>
  43. </picker>
  44. <!-- 选择房间区域 -->
  45. <picker class="picker-item" @click="handleRoom" @change="changeSelect_room" :range="array_room"
  46. range-key="roomName" :value="index_room" :disabled="disabled_room">
  47. <view class="select-item">
  48. <view class="picker-item-logol">
  49. <image class="picker-item-logo-left" src="../../static/room.png"></image>
  50. </view>
  51. <view class="picker-item-label">房间</view>
  52. <view class="picker-item-content" :class="value_room!='请选择房间'?'color':''">{{value_room}}</view>
  53. <view class="picker-item-logor">
  54. <image class="picker-item-logo-right" src="../../static/right.png"></image>
  55. </view>
  56. </view>
  57. </picker>
  58. <view class="submit-item">
  59. <button class="submit" type="primary" @click="handleSubmit">完成</button>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. data() {
  66. return {
  67. // 校区筛选框绑定数组
  68. array: ["黄家湖"],
  69. // 校区筛选框数组绑定下标
  70. index: 0,
  71. // 校区筛选框选中数据
  72. value: "请选择校区",
  73. // 楼栋筛选框绑定数组
  74. array_build: ["1栋", "2栋"],
  75. // 楼栋筛选框数组绑定下标
  76. index_build: 0,
  77. // 楼栋筛选框选中数据
  78. value_build: "请选择楼栋",
  79. // 楼栋筛选框禁用
  80. disabled_build: true,
  81. // 楼层筛选框绑定数组
  82. array_floor: ["1层", "2层"],
  83. // 楼层筛选框数组绑定下标
  84. index_floor: 0,
  85. // 楼层筛选框选中数据
  86. value_floor: "请选择楼层",
  87. // 楼层筛选框禁用
  88. disabled_floor: true,
  89. // 房间筛选框绑定数组
  90. array_room: ["101", "102"],
  91. // 房间筛选框数组绑定下标
  92. index_room: 0,
  93. // 房间筛选框选中数据
  94. value_room: "请选择房间",
  95. // 房间筛选框禁用
  96. disabled_room: true,
  97. };
  98. },
  99. mounted() {
  100. this.getBuild()
  101. },
  102. methods: {
  103. // 获取楼栋数据
  104. async getBuild() {
  105. let res = await this.$myRequest({
  106. url: "/room/queryAllBuild",
  107. })
  108. // console.log(res);
  109. if (res.success) {
  110. this.array_build = res.data
  111. }
  112. },
  113. // 点击楼栋区域回调
  114. handleBuild() {
  115. if (this.disabled_build) {
  116. uni.showToast({
  117. title: "请先选择校区",
  118. icon: 'none'
  119. })
  120. }
  121. },
  122. // 点击楼层区域回调
  123. handleFloor() {
  124. if (this.disabled_build) {
  125. uni.showToast({
  126. title: "请先选择校区",
  127. icon: 'none'
  128. })
  129. } else if (this.disabled_floor) {
  130. uni.showToast({
  131. title: "请先选择楼栋",
  132. icon: 'none'
  133. })
  134. }
  135. },
  136. // 点击房间区域回调
  137. handleRoom() {
  138. if (this.disabled_build) {
  139. uni.showToast({
  140. title: "请先选择校区",
  141. icon: 'none'
  142. })
  143. } else if (this.disabled_floor) {
  144. uni.showToast({
  145. title: "请先选择楼栋",
  146. icon: 'none'
  147. })
  148. } else if (this.disabled_room) {
  149. uni.showToast({
  150. title: "请先选择楼层",
  151. icon: 'none'
  152. })
  153. }
  154. },
  155. // 校区筛选框change回调
  156. changeSelect(e) {
  157. let index = e.detail.value
  158. this.value = this.array[index]
  159. this.disabled_build = false
  160. },
  161. // 楼栋筛选框change回调
  162. async changeSelect_build(e) {
  163. let index = e.detail.value
  164. this.value_build = this.array_build[index].buildName
  165. this.disabled_floor = false
  166. let data = {
  167. buildId: this.array_build[index].buildId
  168. }
  169. let res = await this.$myRequest({
  170. url: "/room/queryAllFloor",
  171. data
  172. })
  173. // console.log(res);
  174. if (res.success) {
  175. this.array_floor = res.data
  176. }
  177. },
  178. // 楼层筛选框change回调
  179. async changeSelect_floor(e) {
  180. let index = e.detail.value
  181. this.value_floor = this.array_floor[index].floorName
  182. this.disabled_room = false
  183. let data = {
  184. floorId: this.array_floor[index].floorId
  185. }
  186. let res = await this.$myRequest({
  187. url: "/room/queryAllRoom",
  188. data
  189. })
  190. // console.log(res);
  191. if (res.success) {
  192. this.array_room = res.data
  193. }
  194. },
  195. // 房间筛选框change回调
  196. changeSelect_room(e) {
  197. let index = e.detail.value
  198. this.value_room = this.array_room[index].roomName
  199. },
  200. // 完成按钮点击回调
  201. handleSubmit() {
  202. if (!this.disabled_build && !this.disabled_floor && !this.disabled_room) {
  203. let temRoom = this.value_build + this.value_floor + this.value_room
  204. localStorage.room = temRoom
  205. uni.reLaunch({
  206. url: "/pages/home/home"
  207. })
  208. } else {
  209. uni.showToast({
  210. title: "请选择完整地址",
  211. icon: 'none'
  212. })
  213. }
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .container {
  220. height: 100vh;
  221. background-image: url(../../static/bg.png);
  222. background-size: 100% 100%;
  223. .picker-item {
  224. padding: 19rpx 0 10rpx 0;
  225. .select-item {
  226. display: flex;
  227. background-color: #ffffff;
  228. height: 139rpx;
  229. .picker-item-logol {
  230. width: 88rpx;
  231. display: flex;
  232. justify-content: flex-end;
  233. .picker-item-logo-left {
  234. width: 58rpx;
  235. height: 58rpx;
  236. margin: 41rpx 0rpx 40rpx 0rpx;
  237. }
  238. }
  239. .picker-item-label {
  240. font-size: 30rpx;
  241. width: 99rpx;
  242. margin: 52rpx 0rpx 52rpx 0rpx;
  243. display: flex;
  244. justify-content: center;
  245. }
  246. .picker-item-content {
  247. display: flex;
  248. justify-content: flex-start;
  249. width: 360rpx;
  250. height: 26rpx;
  251. font-size: 32rpx;
  252. margin: 46rpx 0rpx 46rpx 120rpx;
  253. color: #999999;
  254. }
  255. .color {
  256. color: #000;
  257. }
  258. .picker-item-logor {
  259. width: 91rpx;
  260. display: flex;
  261. justify-content: center;
  262. margin: 57rpx 0rpx 51rpx 0rpx;
  263. .picker-item-logo-right {
  264. width: 20rpx;
  265. height: 31rpx;
  266. }
  267. }
  268. }
  269. }
  270. .submit-item {
  271. margin: 112rpx 30rpx;
  272. width: 690rpx;
  273. height: 96rpx;
  274. .submit {
  275. border-radius: 47.5rpx;
  276. }
  277. }
  278. }
  279. </style>