selectArea.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="container">
  3. <!-- 顶部选择校区区域 -->
  4. <view class="top">
  5. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text" activeColor="#6FB6B8"></uni-segmented-control>
  6. </view>
  7. <view class="gap"></view>
  8. <!-- 主体内容区域 -->
  9. <view class="body">
  10. <!-- 左边区域 -->
  11. <view class="body_left">
  12. <view class="body_left_item" :class="{ active: active_left === index }" v-for="(item, index) in leftList" :key="index" @click="handleChange(index)">
  13. {{ item }}
  14. </view>
  15. </view>
  16. <!-- 右边区域 -->
  17. <view class="body_right">
  18. <view class="body_right_item" :class="{ active: active_right === index }" v-for="(item, index) in rightList" :key="index" @click="handleChange2(index)">
  19. {{ item }}
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. // 顶部分段器选项数组
  30. items: ['黄家湖校区', '墨轩湖校区'],
  31. // 分段器当前索引
  32. current: 0,
  33. // 左边分类数组
  34. leftList: ['教学楼', '行政楼', '综合楼', '科技楼', '学生宿舍', '其他'],
  35. // 左边分类数组当前索引
  36. active_left: 0,
  37. // 右边分类数组
  38. rightList: ['1栋', '2栋', '3栋', '4栋', '5栋', '6栋', '7栋', '8栋', '体育场', '篮球场', '其他'],
  39. // 右边分类数组当前索引
  40. active_right: 0
  41. }
  42. },
  43. methods: {
  44. // 顶部分段器切换选项回调
  45. onClickItem(e) {
  46. if (this.current != e.currentIndex) {
  47. this.current = e.currentIndex
  48. }
  49. },
  50. // 左边数组切换回调
  51. handleChange(index) {
  52. this.active_left = index
  53. },
  54. // 右边数组切换回调
  55. handleChange2(index) {
  56. this.active_right = index
  57. const repairsArea = this.items[this.current] + this.leftList[this.active_left] + this.rightList[this.active_right]
  58. uni.$emit('addRepairsArea', {
  59. data: repairsArea
  60. })
  61. uni.navigateBack(1)
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .container {
  68. width: 100vw;
  69. height: 100vh;
  70. .top {
  71. height: 100rpx;
  72. }
  73. .gap {
  74. height: 10rpx;
  75. background-color: #f2f2f2;
  76. }
  77. .body {
  78. display: flex;
  79. height: calc(100vh - 110rpx);
  80. .body_left {
  81. box-sizing: border-box;
  82. padding: 15rpx;
  83. width: 198rpx;
  84. border-right: 1rpx solid #ccc;
  85. overflow-y: auto;
  86. .body_left_item {
  87. width: 100%;
  88. height: 80rpx;
  89. line-height: 80rpx;
  90. text-align: center;
  91. font-size: 28rpx;
  92. overflow: hidden;
  93. white-space: nowrap;
  94. text-overflow: ellipsis;
  95. }
  96. .active {
  97. color: #6fb6b8;
  98. }
  99. }
  100. .body_right {
  101. box-sizing: border-box;
  102. padding: 30rpx 40rpx;
  103. width: 552rpx;
  104. overflow-y: auto;
  105. .body_right_item {
  106. float: left;
  107. box-sizing: border-box;
  108. margin: 0 12rpx 28rpx 0;
  109. padding: 10rpx 30rpx;
  110. height: 50rpx;
  111. line-height: 30rpx;
  112. text-align: center;
  113. color: #808080;
  114. font-size: 28rpx;
  115. border-radius: 53rpx;
  116. background-color: #e6e6e6;
  117. overflow: hidden;
  118. white-space: nowrap;
  119. text-overflow: ellipsis;
  120. }
  121. .active {
  122. color: #fff;
  123. background-color: #6fb6b8;
  124. }
  125. }
  126. }
  127. }
  128. ::v-deep .segmented-control {
  129. height: 100rpx;
  130. }
  131. </style>