companyShow.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">{{buildingName}}</block>
  6. </cu-custom>
  7. <view class="cu-bar bg-white search fixed" :style="[{top: CustomBar + 'px'}]">
  8. <view class="search-form round">
  9. <text class="cuIcon-search"></text>
  10. <input type="text" placeholder="输入搜索的关键词" confirm-type="search" v-model="companyName"></input>
  11. </view>
  12. <view class="action">
  13. <button class="cu-btn bg-gradual-green shadow-blur round" @click="buildingSearch">搜索</button>
  14. </view>
  15. </view>
  16. <scroll-view scroll-y class="indexes" :scroll-into-view="'indexes-'+ listCurID"
  17. :style="[{height:'calc(100vh - '+ scrollHeight + 'px)', top: '55px'}]" :scroll-with-animation="true"
  18. :enable-back-to-top="true">
  19. <view v-if="companyList.length == 0" class="empty-state">
  20. 暂无企业信息,请稍后再试!
  21. </view>
  22. <view v-else>
  23. <block v-for="(item, index) in companyList" :key="index">
  24. <view :class="'indexItem-' + item.name" :id="'indexes-' + item.name" :data-index="item.name">
  25. <view class="padding">{{item.name}}</view>
  26. <view class="cu-list menu-avatar no-padding">
  27. <view class="cu-item" v-for="(items,sub) in item.companyList" :key="sub" @click="gotoBuildInfo(items.id)">
  28. <view class="cu-avatar round lg">{{items.firstChar}}</view>
  29. <view class="content">
  30. <view class="text-grey">{{items.companyName}}</view>
  31. <view class="text-gray text-sm">
  32. <text>{{"楼层(F):" + items.floor}}</text>
  33. <text style="padding-left: 15px;">{{"房间号:" + items.roomNum}}</text>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </block>
  40. </view>
  41. </scroll-view>
  42. <view class="indexBar" :style="[{height:'calc(100vh - ' + CustomBar + 'px)'}]">
  43. <view class="indexBar-box" @touchstart="tStart" @touchend="tEnd" @touchmove.stop="tMove">
  44. <view class="indexBar-item" v-for="(item,index) in companyList" :key="index" :id="index" @touchstart="getCur"
  45. @touchend="setCur"> {{item.name}}</view>
  46. </view>
  47. </view>
  48. <!--选择显示-->
  49. <view v-show="!hidden" class="indexToast">
  50. {{listCur}}
  51. </view>
  52. </view>
  53. </template>
  54. import { size } from 'lodash';
  55. <script>
  56. import mapVisualizationService from '@/api/map/mapVisualization'
  57. export default {
  58. data() {
  59. return {
  60. buildingId: '',
  61. buildingName: '',
  62. companyName: '',
  63. StatusBar: this.StatusBar,
  64. CustomBar: this.CustomBar,
  65. scrollHeight: this.CustomBar + 55,
  66. hidden: true,
  67. listCurID: '',
  68. companyList: [],
  69. listCur: '',
  70. };
  71. },
  72. onLoad(options) {
  73. if (options.buildingId) {
  74. this.buildingId = options.buildingId;
  75. this.buildingName = options.buildingName;
  76. this.getCompanyList()
  77. }
  78. },
  79. mounted() {
  80. },
  81. onReady() {
  82. // let that = this;
  83. // uni.createSelectorQuery().select('.indexBar-box').boundingClientRect(function(res) {
  84. // that.boxTop = res.top
  85. // }).exec();
  86. // uni.createSelectorQuery().select('.indexes').boundingClientRect(function(res) {
  87. // that.barTop = res.top
  88. // }).exec()
  89. },
  90. methods: {
  91. gotoBuildInfo(id) {
  92. uni.navigateTo({
  93. url: `/pages/comEdit/comEdit?id=${id}&ischeck=1`
  94. })
  95. },
  96. getCompanyList() {
  97. uni.showLoading()
  98. mapVisualizationService.getCompanyList({"buildingId": this.buildingId, "companyName": this.companyName}).then(({
  99. data
  100. }) => {
  101. console.log( data );
  102. this.companyList = data
  103. uni.hideLoading()
  104. }).catch((e) => {
  105. uni.hideLoading()
  106. })
  107. },
  108. buildingSearch() {
  109. console.log( this.companyName );
  110. this.getCompanyList()
  111. },
  112. //获取文字信息
  113. getCur(e) {
  114. this.hidden = false;
  115. this.listCur = this.companyList[e.target.id].name;
  116. },
  117. setCur(e) {
  118. this.hidden = true;
  119. this.listCur = this.listCur
  120. },
  121. //滑动选择Item
  122. tMove(e) {
  123. let y = e.touches[0].clientY,
  124. offsettop = this.boxTop,
  125. that = this;
  126. //判断选择区域,只有在选择区才会生效
  127. if (y > offsettop) {
  128. let num = parseInt((y - offsettop) / 20);
  129. this.listCur = that.companyList[num].name
  130. };
  131. },
  132. //触发全部开始选择
  133. tStart() {
  134. this.hidden = false
  135. },
  136. //触发结束选择
  137. tEnd() {
  138. this.hidden = true;
  139. this.listCurID = this.listCur
  140. },
  141. // indexSelect(e) {
  142. // let that = this;
  143. // let barHeight = this.barHeight;
  144. // let list = this.list;
  145. // let scrollY = Math.ceil(list.length * e.detail.y / barHeight);
  146. // for (let i = 0; i < list.length; i++) {
  147. // if (scrollY < i + 1) {
  148. // that.listCur = list[i].name;
  149. // that.movableY = i * 20
  150. // return false
  151. // }
  152. // }
  153. // }
  154. }
  155. }
  156. </script>
  157. <style>
  158. /* page {
  159. padding-top: 100upx;
  160. } */
  161. .empty-state {
  162. text-align: center;
  163. font-size: 20px;
  164. padding: 20px;
  165. color: #a0a0a0
  166. }
  167. .indexes {
  168. position: relative;
  169. }
  170. .indexBar {
  171. position: fixed;
  172. right: 0px;
  173. bottom: 0px;
  174. padding: 20upx 20upx 20upx 60upx;
  175. display: flex;
  176. align-items: center;
  177. }
  178. .indexBar .indexBar-box {
  179. width: 40upx;
  180. height: auto;
  181. background: #fff;
  182. display: flex;
  183. flex-direction: column;
  184. box-shadow: 0 0 20upx rgba(0, 0, 0, 0.1);
  185. border-radius: 10upx;
  186. }
  187. .indexBar-item {
  188. flex: 1;
  189. width: 40upx;
  190. height: 40upx;
  191. display: flex;
  192. align-items: center;
  193. justify-content: center;
  194. font-size: 24upx;
  195. color: #888;
  196. }
  197. movable-view.indexBar-item {
  198. width: 40upx;
  199. height: 40upx;
  200. z-index: 9;
  201. position: relative;
  202. }
  203. movable-view.indexBar-item::before {
  204. content: "";
  205. display: block;
  206. position: absolute;
  207. left: 0;
  208. top: 10upx;
  209. height: 20upx;
  210. width: 4upx;
  211. background-color: #f37b1d;
  212. }
  213. .indexToast {
  214. position: fixed;
  215. top: 0;
  216. right: 80upx;
  217. bottom: 0;
  218. background: rgba(0, 0, 0, 0.5);
  219. width: 100upx;
  220. height: 100upx;
  221. border-radius: 10upx;
  222. margin: auto;
  223. color: #fff;
  224. line-height: 100upx;
  225. text-align: center;
  226. font-size: 48upx;
  227. }
  228. </style>