select.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. :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. :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. :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. methods: {
  100. // 点击楼栋区域回调
  101. handleBuild() {
  102. if (this.disabled_build) {
  103. uni.showToast({
  104. title: "请先选择校区",
  105. icon: 'none'
  106. })
  107. }
  108. },
  109. // 点击楼层区域回调
  110. handleFloor() {
  111. if (this.disabled_build) {
  112. uni.showToast({
  113. title: "请先选择校区",
  114. icon: 'none'
  115. })
  116. } else if (this.disabled_floor) {
  117. uni.showToast({
  118. title: "请先选择楼栋",
  119. icon: 'none'
  120. })
  121. }
  122. },
  123. // 点击房间区域回调
  124. handleRoom() {
  125. if (this.disabled_build) {
  126. uni.showToast({
  127. title: "请先选择校区",
  128. icon: 'none'
  129. })
  130. } else if (this.disabled_floor) {
  131. uni.showToast({
  132. title: "请先选择楼栋",
  133. icon: 'none'
  134. })
  135. } else if (this.disabled_room) {
  136. uni.showToast({
  137. title: "请先选择楼层",
  138. icon: 'none'
  139. })
  140. }
  141. },
  142. // 校区筛选框change回调
  143. changeSelect(e) {
  144. let index = e.detail.value
  145. this.value = this.array[index]
  146. this.disabled_build = false
  147. },
  148. // 楼栋筛选框change回调
  149. changeSelect_build(e) {
  150. let index = e.detail.value
  151. this.value_build = this.array_build[index]
  152. this.disabled_floor = false
  153. },
  154. // 楼层筛选框change回调
  155. changeSelect_floor(e) {
  156. let index = e.detail.value
  157. this.value_floor = this.array_floor[index]
  158. this.disabled_room = false
  159. },
  160. // 房间筛选框change回调
  161. changeSelect_room(e) {
  162. let index = e.detail.value
  163. this.value_room = this.array_room[index]
  164. },
  165. // 完成按钮点击回调
  166. handleSubmit() {
  167. if (!this.disabled_build && !this.disabled_floor && !this.disabled_room) {
  168. let temRoom = this.value + this.value_build + this.value_floor + this.value_room
  169. localStorage.room = temRoom
  170. uni.reLaunch({
  171. url: "/pages/home/home"
  172. })
  173. } else {
  174. uni.showToast({
  175. title: "请选择完整地址",
  176. icon: 'none'
  177. })
  178. }
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .container {
  185. height: 100vh;
  186. background-image: url(../../static/bg.png);
  187. background-size: 100% 100%;
  188. .picker-item {
  189. padding: 19rpx 0 10rpx 0;
  190. .select-item {
  191. display: flex;
  192. background-color: #ffffff;
  193. height: 139rpx;
  194. .picker-item-logol {
  195. width: 88rpx;
  196. display: flex;
  197. justify-content: flex-end;
  198. .picker-item-logo-left {
  199. width: 58rpx;
  200. height: 58rpx;
  201. margin: 41rpx 0rpx 40rpx 0rpx;
  202. }
  203. }
  204. .picker-item-label {
  205. font-size: 30rpx;
  206. width: 99rpx;
  207. margin: 52rpx 0rpx 52rpx 0rpx;
  208. display: flex;
  209. justify-content: center;
  210. }
  211. .picker-item-content {
  212. display: flex;
  213. justify-content: flex-start;
  214. width: 360rpx;
  215. height: 26rpx;
  216. font-size: 32rpx;
  217. margin: 46rpx 0rpx 46rpx 120rpx;
  218. color: #999999;
  219. }
  220. .color {
  221. color: #000;
  222. }
  223. .picker-item-logor {
  224. width: 91rpx;
  225. display: flex;
  226. justify-content: center;
  227. margin: 57rpx 0rpx 51rpx 0rpx;
  228. .picker-item-logo-right {
  229. width: 20rpx;
  230. height: 31rpx;
  231. }
  232. }
  233. }
  234. }
  235. .submit-item {
  236. margin: 112rpx 30rpx;
  237. width: 690rpx;
  238. height: 96rpx;
  239. .submit {
  240. border-radius: 47.5rpx;
  241. }
  242. }
  243. }
  244. </style>