siteInspection.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="siteInspection-wrap">
  3. <!-- 搜索框 -->
  4. <view class="search-con">
  5. <u-search placeholder="查找全部门店" v-model="queryValue" @custom="searchHandle(1)" @search="searchHandle(1)" bg-color="#fff" :action-style="{background: '#2979ff',color: '#fff', borderRadius: '6upx',padding: '6upx 0', fontSize: '26upx'}"></u-search>
  6. </view>
  7. <!-- 定位 -->
  8. <view class="location-con" ref="location">
  9. <text class="location-tit">当前位置:</text>
  10. <view class="location-main" @click="getLocation">
  11. <text class="location-addr">{{location}}</text>
  12. <u-icon name="map" color="#2979ff" size="34" class="location-icon"></u-icon>
  13. </view>
  14. </view>
  15. <!-- 附近的门店 -->
  16. <view class="store-con">
  17. <text class="store-tit">附近的门店:</text>
  18. <scroll-view class="scroll-con" scroll-y @scrolltolower="onreachBottom" :style="{'height': 'calc(100vh - ' + Height + 'px)'}">
  19. <!-- 列表数据 -->
  20. <view class="list-con">
  21. <view class="list-item" v-for="(item,index) in listdata" :key="index" @click="chooseStore(item)">
  22. <view class="item-main">
  23. <u-icon name="home-fill" size="34" color="#2979ff" class="company-icon"></u-icon>
  24. {{item.name}}
  25. </view>
  26. <u-icon name="rewind-right-fill" size="34" color="#2979ff" class="company-icon"></u-icon>
  27. </view>
  28. </view>
  29. <u-empty class="nodata" :text="noDataText" v-if="listdata.length==0 && status!='loading'" mode="list"></u-empty>
  30. <view class="loadmore">
  31. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  32. </view>
  33. </scroll-view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default{
  39. data(){
  40. return{
  41. queryValue: '',
  42. location: '',
  43. noDataText: '未查找到附近门店', // 列表请求状态提示语
  44. status: 'loadmore', // 加载中状态
  45. // status: 'loading', // 加载中状态
  46. listdata: [
  47. {name: '常青二路店'},
  48. {name: '兰州通达街店'},
  49. {name: '科技西路店'},
  50. {name: '常青二路店'},
  51. {name: '常青二路店'},
  52. {name: '兰州通达街店'},
  53. {name: '科技西路店'},
  54. {name: '常青二路店'},
  55. {name: '常青二路店'},
  56. {name: '兰州通达街店'},
  57. {name: '科技西路店'},
  58. {name: '常青二路店'},
  59. ], // 列表数据
  60. pageNo: 1, // 当前页码
  61. pageSize: 10, // 每页条数
  62. total: 0, // 数据总条数
  63. Height: '', // 滚动区域 元素dom高度
  64. }
  65. },
  66. onShow() {
  67. this.init()
  68. },
  69. onReady() {
  70. // console.log(this.$refs.location.$el.offsetHeight)
  71. },
  72. methods: {
  73. // 初始化
  74. init(){
  75. this.getLocation()
  76. },
  77. // 获取当前位置
  78. getLocation(){
  79. const _this = this
  80. uni.getLocation({
  81. type: 'gcj02',
  82. geocode: true,
  83. success: function (res) {
  84. console.log(res)
  85. _this.location = res.address.province + res.address.city + res.address.district + res.address.street + res.address.streetNum +'靠近' + res.address.poiName
  86. setTimeout(()=>{
  87. console.log(_this.$refs.location)
  88. console.log(String(_this.$refs.location))
  89. console.log(_this.$refs.location.$el.offsetHeight)
  90. _this.Height = 44 + 62 + Number(_this.$refs.location.$el.offsetHeight)
  91. // console.log(_this.Height, Number(_this.$refs.location.offsetHeight))
  92. _this.searchHandle(res)
  93. }, 5000)
  94. }
  95. })
  96. },
  97. //
  98. searchHandle(pageNo){
  99. // this.status = "loading"
  100. pageNo ? this.pageNo = pageNo : null
  101. // searchSuppliers({
  102. // pageNo: this.pageNo,
  103. // pageSize: this.pageSize,
  104. // queryWord: this.queryValue
  105. // }).then(res => {
  106. // if (res.status == 200) {
  107. // if(this.pageNo>1){
  108. // this.listdata = this.listdata.concat(res.data.list || [])
  109. // }else{
  110. // this.listdata = res.data.list || []
  111. // }
  112. // this.total = res.data.count || 0
  113. // this.listdata.length == 0 && this.queryValue != '' ? this.noDataText = '没有搜索到相关结果' : this.noDataText = '暂无数据'
  114. // } else {
  115. // this.noDataText = res.message
  116. // this.listdata = []
  117. // this.total = 0
  118. // }
  119. // this.status = "loadmore"
  120. // })
  121. },
  122. // scroll-view到底部加载更多
  123. onreachBottom() {
  124. if(this.listdata.length < this.total){
  125. this.pageNo += 1
  126. this.searchHandle()
  127. }else{
  128. this.status = "nomore"
  129. }
  130. },
  131. // 选择门店
  132. chooseStore(item){
  133. uni.navigateTo({
  134. url:"/pages/signIn/signIn"
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .siteInspection-wrap{
  142. background-color: #f8f8f8;
  143. .search-con{
  144. padding: 30upx 30upx;
  145. }
  146. // 定位
  147. .location-con{
  148. padding: 0 30upx;
  149. .location-main{
  150. margin-top: 14upx;
  151. padding: 20upx;
  152. border-radius: 12upx;
  153. background-color: #fff;
  154. .location-addr{
  155. font-size: 24upx;
  156. }
  157. .location-icon{
  158. padding-left: 10upx;
  159. vertical-align: bottom;
  160. }
  161. }
  162. }
  163. // 附近的门店
  164. .store-con{
  165. .store-tit{
  166. display: block;
  167. padding: 30upx 30upx 20upx;
  168. }
  169. // 列表 44 62
  170. .scroll-con{
  171. height: calc(100vh - 215px);
  172. width: 100%;
  173. overflow: auto;
  174. .list-con{
  175. padding: 0 30upx;
  176. .list-item{
  177. background-color: #fff;
  178. border-radius: 16upx;
  179. padding: 20upx 30upx 18upx;
  180. margin-bottom: 20upx;
  181. display: flex;
  182. justify-content: space-between;
  183. align-items: center;
  184. .item-main{
  185. font-size: 15px;
  186. color: rgb(48, 49, 51);
  187. .company-icon{
  188. margin-right: 6upx;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. }
  196. </style>