siteInspection.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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: 'loadmore', // 加载中状态
  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. fail: function(error){
  74. console.log(error)
  75. _this.searchHandle()
  76. if(JSON.parse(error.errMsg.replace('getLocation:fail ','')).message){
  77. uni.showToast({
  78. icon: 'none',
  79. title: JSON.parse(error.errMsg.replace('getLocation:fail ','')).message
  80. })
  81. }
  82. }
  83. })
  84. },
  85. //查询门店列表
  86. searchHandle(){
  87. this.status = "loading"
  88. findStoreList({
  89. lng: this.lng,
  90. lat: this.lat,
  91. name: this.queryValue
  92. }).then(res => {
  93. console.log(res)
  94. if (res.status == 200) {
  95. this.listdata = res.data || []
  96. this.noDataText = this.listdata.length == 0 && this.queryValue != '' ? '没有搜索到相关结果' : '未查找到附近门店'
  97. } else {
  98. this.listdata = []
  99. this.noDataText = res.message
  100. }
  101. this.status = "loadmore"
  102. })
  103. },
  104. // 选择门店
  105. chooseStore(item){
  106. uni.navigateTo({
  107. url:"/pages/signIn/signIn?item=" + encodeURIComponent(JSON.stringify(item))
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .siteInspection-wrap{
  115. background-color: #f8f8f8;
  116. .search-con{
  117. padding: 30upx 30upx;
  118. }
  119. // 定位
  120. .location-con{
  121. padding: 0 30upx;
  122. .location-main{
  123. margin-top: 14upx;
  124. padding: 20upx;
  125. border-radius: 12upx;
  126. background-color: #fff;
  127. .location-icon{
  128. padding-left: 10upx;
  129. vertical-align: bottom;
  130. }
  131. }
  132. }
  133. // 附近的门店
  134. .store-con{
  135. .store-tit{
  136. display: block;
  137. padding: 30upx 30upx 20upx;
  138. }
  139. // 列表 44 62
  140. .scroll-con{
  141. height: calc(100vh - 215px);
  142. width: 100%;
  143. overflow: auto;
  144. .list-con{
  145. padding: 0 30upx;
  146. .list-item{
  147. background-color: #fff;
  148. padding: 20upx;
  149. display: flex;
  150. justify-content: space-between;
  151. align-items: center;
  152. border-bottom: 1px solid #F8F8F8;
  153. .item-main{
  154. font-size: 15px;
  155. color: rgb(48, 49, 51);
  156. display: flex;
  157. align-items: center;
  158. .company-icon{
  159. margin-right: 6upx;
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. </style>