siteInspection.vue 4.2 KB

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