siteInspection.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 :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 class="company-icon" name="mendian" custom-prefix="xd-icon" size="40" color="#888"></u-icon>
  24. <text>{{item.name}}</text>
  25. </view>
  26. <u-icon class="listData-item-r-icon" name="xianchangrenwu" custom-prefix="xd-icon" size="40" color="#2b85e4"></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. <u-loadmore bg-color="#f8f8f8" v-if="listdata.length < total || status == 'loading'" :status="status" class="loadmore" />
  31. </scroll-view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { clzConfirm } from '@/libs/tools.js'
  37. import { findStoreList } from '@/api/store.js'
  38. export default{
  39. data(){
  40. return{
  41. queryValue: '',
  42. location: '陕西西安未央区北二环信息机大厦100号',
  43. noDataText: '未查找到附近门店', // 列表请求状态提示语
  44. status: 'loading', // 加载中状态
  45. listdata: [], // 列表数据
  46. pageNo: 1, // 当前页码
  47. pageSize: 10, // 每页条数
  48. total: 0, // 数据总条数
  49. Height: 200, // 滚动区域 元素dom高度
  50. }
  51. },
  52. onReady() {
  53. this.init()
  54. },
  55. methods: {
  56. // 初始化
  57. init(){
  58. this.getLocation()
  59. },
  60. // 获取当前位置
  61. getLocation(){
  62. const _this = this
  63. uni.getLocation({
  64. type: 'gcj02',
  65. geocode: true,
  66. success: function (res) {
  67. console.log(res)
  68. // _this.location = res.address.province + res.address.city + res.address.district + res.address.street + res.address.streetNum +'靠近' + res.address.poiName
  69. setTimeout(()=>{
  70. _this.searchHandle(res)
  71. }, 500)
  72. }
  73. })
  74. },
  75. //查询门店列表
  76. searchHandle(res){
  77. this.listdata = []
  78. this.status = "loading"
  79. findStoreList({
  80. lng:res.longitude,
  81. lat:res.latitude,
  82. queryWord: this.queryValue
  83. }).then(res => {
  84. if (res.status == 200) {
  85. this.listdata = res.data.list || []
  86. this.total = this.listdata.length
  87. this.listdata.length == 0 && this.queryValue != '' ? this.noDataText = '没有搜索到相关结果' : this.noDataText = '暂无数据'
  88. } else {
  89. this.noDataText = res.message
  90. this.listdata = []
  91. this.total = 0
  92. }
  93. this.status = "loadmore"
  94. })
  95. },
  96. // 选择门店
  97. chooseStore(item){
  98. uni.navigateTo({
  99. url:"/pages/signIn/signIn?item="+encodeURIComponent(JSON.stringify(item))
  100. })
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .siteInspection-wrap{
  107. background-color: #f8f8f8;
  108. .search-con{
  109. padding: 30upx 30upx;
  110. }
  111. // 定位
  112. .location-con{
  113. padding: 0 30upx;
  114. .location-main{
  115. margin-top: 14upx;
  116. padding: 20upx;
  117. border-radius: 12upx;
  118. background-color: #fff;
  119. .location-icon{
  120. padding-left: 10upx;
  121. vertical-align: bottom;
  122. }
  123. }
  124. }
  125. // 附近的门店
  126. .store-con{
  127. .store-tit{
  128. display: block;
  129. padding: 30upx 30upx 20upx;
  130. }
  131. // 列表 44 62
  132. .scroll-con{
  133. height: calc(100vh - 215px);
  134. width: 100%;
  135. overflow: auto;
  136. .list-con{
  137. padding: 0 30upx;
  138. .list-item{
  139. background-color: #fff;
  140. padding: 20upx;
  141. display: flex;
  142. justify-content: space-between;
  143. align-items: center;
  144. border-bottom: 1px solid #F8F8F8;
  145. .item-main{
  146. font-size: 15px;
  147. color: rgb(48, 49, 51);
  148. display: flex;
  149. align-items: center;
  150. .company-icon{
  151. margin-right: 6upx;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. </style>