searchArea.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="categoryOne">
  3. <view class="head">
  4. 请选择楼栋
  5. </view>
  6. <view class="body" v-if="dataInfo.list.length">
  7. <view class="body_item ellipsis" v-for="data in dataInfo.list" :key="data.id" @click="toPlace(data)">
  8. {{data.buildingName}}
  9. </view>
  10. </view>
  11. <view class="zanwu" v-else>
  12. <text class="newicon newicon-zanwu"></text>
  13. </view>
  14. <view class="foot_common_btns">
  15. <button @click="goBack" type="default" class="primaryButton btn">返回</button>
  16. </view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { ref, reactive} from 'vue'
  21. import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  22. import { api_area, getFetchDataList } from "@/http/api.js"
  23. import { defaultColor } from '@/static/js/theme.js'
  24. import { useSetTitle } from '@/share/useSetTitle.js'
  25. import { useLoginUserStore } from '@/stores/loginUser'
  26. import { useIncidentBuildStore } from '@/stores/incidentBuild'
  27. import { useGoBack } from '@/share/useGoBack.js'
  28. useSetTitle();
  29. const loginUserStore = useLoginUserStore();
  30. const incidentBuildStore = useIncidentBuildStore();
  31. const { goBack } = useGoBack();
  32. // 主题颜色
  33. const primaryColor = ref(defaultColor)
  34. // 数据
  35. const dataInfo = reactive({
  36. list: [],//列表
  37. idx: 0,//页码
  38. hasMore: true,//是否有更多数据
  39. incidentId: undefined,//事件ID
  40. })
  41. // 跳转地点列表
  42. function toPlace(data){
  43. uni.navigateTo({
  44. url: `/pages/searchPlace/searchPlace?incidentId=${dataInfo.incidentId}&parentId=${data.id}&parentName=${data.buildingName}`
  45. })
  46. }
  47. // 获取列表信息
  48. function getList(idx){
  49. // if(!incidentBuildStore.incidentBuild.data.branch){
  50. // dataInfo.list = [];
  51. // uni.stopPullDownRefresh();
  52. // dataInfo.hasMore = false;
  53. // return;
  54. // }
  55. uni.showLoading({
  56. title: "加载中",
  57. mask: true,
  58. });
  59. // dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  60. // if(dataInfo.idx === 0){
  61. // dataInfo.list = [];
  62. // }
  63. let postData = {
  64. idx: 0,
  65. sum: 9999,
  66. building:{
  67. hosId: loginUserStore.loginUser.user.currentHospital.id,
  68. }
  69. };
  70. getFetchDataList("simple/data", "building", postData)
  71. .then((res) => {
  72. uni.hideLoading();
  73. dataInfo.list = res.list
  74. });
  75. // api_area(postData).then(res => {
  76. // uni.hideLoading();
  77. // uni.stopPullDownRefresh();
  78. // if(res.status == 200){
  79. // let list = res.list || [];
  80. // if(list.length){
  81. // dataInfo.hasMore = true;
  82. // dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  83. // }else{
  84. // dataInfo.hasMore = false;
  85. // }
  86. // }else{
  87. // uni.showToast({
  88. // icon: 'none',
  89. // title: res.msg || '请求数据失败!'
  90. // });
  91. // }
  92. // })
  93. }
  94. onLoad((option) => {
  95. dataInfo.incidentId = option.incidentId;
  96. getList(0);
  97. })
  98. onPullDownRefresh(() => {
  99. // getList(0)
  100. })
  101. onReachBottom(() => {
  102. // dataInfo.idx += 1;
  103. // if (dataInfo.hasMore) {
  104. // getList(); // 当触底时加载更多数据
  105. // }
  106. })
  107. </script>
  108. <style lang="scss" scoped>
  109. .categoryOne{
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: space-between;
  113. .head{
  114. height: 88rpx;
  115. display: flex;
  116. align-items: center;
  117. padding: 0 24rpx;
  118. position: fixed;
  119. z-index: 99;
  120. width: 100%;
  121. box-sizing: border-box;
  122. background: #fff;
  123. font-size: 26rpx;
  124. color: $uni-primary;
  125. }
  126. .body{
  127. border-top: 1rpx solid #DEDEDE;
  128. margin-bottom: 140rpx;
  129. margin-top: 88rpx;
  130. font-size: 26rpx;
  131. .body_item{
  132. border-bottom: 1rpx solid #DEDEDE;
  133. padding: 24rpx;
  134. }
  135. }
  136. .zanwu{
  137. margin-bottom: 140rpx;
  138. margin-top: 88rpx;
  139. display: flex;
  140. justify-content: center;
  141. .newicon-zanwu{
  142. font-size: 256rpx;
  143. color: #D6D6D6;
  144. margin-top: 140rpx;
  145. }
  146. }
  147. .foot_common_btns{
  148. position: fixed;
  149. left: 0;
  150. bottom: 0;
  151. background-color: #fff;
  152. }
  153. }
  154. </style>