siteInspection.vue 4.3 KB

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