storeList.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="reachBottom" @scroll="scroll">
  4. <view class="list" @click="intoDetail" v-for="item in storeList" :key="item.id">
  5. <u-image width="160rpx" height="160rpx" :border-radius="10" :src="item.icon?item.icon:'/static/img/mddef.jpg'"></u-image>
  6. <view class="store-info">
  7. <view class="name">
  8. {{item.name}}
  9. </view>
  10. <view class="address">
  11. {{item.addrDetail}}
  12. </view>
  13. <view class="location">
  14. <view class="left">
  15. <uni-icons class="icon" size="16" type="paperplane"></uni-icons>
  16. <text>{{item.distance}} km</text>
  17. </view>
  18. <view class="right">
  19. <u-icon class="icon" size="32" name="clock"></u-icon>
  20. <text>{{item.time}} 营业</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="list-right">
  25. <u-image width="110rpx" height="110rpx" :border-radius="10" :src="getStoreStatus(item)"></u-image>
  26. </view>
  27. </view>
  28. <u-empty :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  29. <view style="padding: 20upx;">
  30. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  31. </view>
  32. </scroll-view>
  33. </view>
  34. </template>
  35. <script>
  36. import uniIcons from "@/components/uni-icons/uni-icons.vue"
  37. export default {
  38. components: {
  39. uniIcons
  40. },
  41. data() {
  42. return {
  43. noDataText: '暂无数据',
  44. status: 'loadmore',
  45. storeList: [{
  46. id: 1,
  47. icon: '',
  48. addrDetail: '陕西省西安市未央区北二环贞观路',
  49. name: '贞观路站',
  50. distance: 0.1,
  51. time: '8:00-22:00',
  52. status: 1
  53. },
  54. {
  55. id: 10,
  56. icon: '',
  57. addrDetail: '陕西省西安市未央区北二环贞观路二环贞观路',
  58. name: '贞观路站',
  59. distance: 0.1,
  60. time: '8:00-22:00',
  61. status: 0
  62. },
  63. {
  64. id: 11,
  65. icon: '',
  66. addrDetail: '陕西省西安市未央区北二环贞观路',
  67. name: '贞观路站',
  68. distance: 0.1,
  69. time: '8:00-22:00',
  70. status: 2
  71. }
  72. ],
  73. currentPosition: {
  74. lat: '0',
  75. lng: '0'
  76. },
  77. pageNo: 1,
  78. pageSize: 10,
  79. total: 0
  80. }
  81. },
  82. onShow() {
  83. },
  84. onLoad() {
  85. // 获取当前经纬度
  86. let _this = this
  87. uni.getLocation({
  88. type: 'wgs84', // 默认wgs84
  89. success: function(res) {
  90. _this.currentPosition.lat = res.latitude;
  91. _this.currentPosition.lng = res.longitude;
  92. _this.gpsCompletion = true;
  93. // 查询门店信息
  94. // _this.getStoresList()
  95. },
  96. fail: function(res) {
  97. console.log(res)
  98. // 查询门店信息
  99. // _this.getStoresList()
  100. },
  101. });
  102. },
  103. computed: {},
  104. methods: {
  105. getStoresList() {
  106. this.status = "loading"
  107. let lat = this.currentPosition.lat
  108. let lng = this.currentPosition.lng
  109. getStoresList({
  110. pageNo: this.pageNo,
  111. pageSize: this.pageSize,
  112. lat: lat,
  113. lng: lng
  114. }).then(res => {
  115. console.log(res)
  116. uni.hideLoading()
  117. if (res.status == 200) {
  118. let list = res.data.list
  119. list.map(item => {
  120. if (item.addrDetail.indexOf("省") > 0 && item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") >
  121. 0) {
  122. item.addrDetail = item.addrDetail
  123. } else {
  124. if (item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") > 0) {
  125. item.addrDetail = item.addrProvinceName + item.addrDetail
  126. } else if (item.addrDetail.indexOf("区") > 0) {
  127. item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDetail
  128. } else {
  129. item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDistrictName + item.addrDetail
  130. }
  131. }
  132. item.distance = item.distance ? Math.round(item.distance / 1000) : ''
  133. })
  134. this.storeList = this.storeList.concat(list)
  135. this.total = res.data.count || 0
  136. } else {
  137. this.storeList = []
  138. this.total = 0
  139. this.noDataText = res.message
  140. }
  141. })
  142. },
  143. // 获取网点营业状态
  144. getStoreStatus(item) {
  145. switch (item.status) {
  146. case 0:
  147. return '/static/img/ygb.png'
  148. break;
  149. case 1:
  150. return '/static/img/yyz.png'
  151. break;
  152. case 2:
  153. return '/static/img/dky.png'
  154. break;
  155. default:
  156. break;
  157. }
  158. },
  159. // 进入网点详情
  160. intoDetail (item) {
  161. uni.navigateTo({
  162. url: `/pages/store/storeDetail?id=${item.id}`
  163. })
  164. },
  165. // 到达底部
  166. reachBottom() {
  167. if(this.storeList.length < this.total){
  168. this.pageNo += 1
  169. this.getStoresList()
  170. }else{
  171. this.status = "nomore"
  172. }
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .content {
  179. padding: 0 20rpx;
  180. .scroll-Y {
  181. width: 100%;
  182. height: 100%;
  183. .list {
  184. padding: 20rpx 0;
  185. display: flex;
  186. border-bottom: 1px solid #eee;
  187. .store-info {
  188. display: flex;
  189. flex: 1;
  190. flex-direction: column;
  191. justify-content: space-between;
  192. padding: 0 20rpx;
  193. .name {
  194. font-size: 32rpx;
  195. color: #000;
  196. }
  197. .address{
  198. font-size: 26rpx;
  199. padding: 10rpx 0;
  200. }
  201. .location {
  202. display: flex;
  203. align-items: center;
  204. font-size: 24rpx;
  205. .left {
  206. margin-right: 20rpx;
  207. }
  208. .icon {
  209. color: #999;
  210. margin-right: 5rpx;
  211. }
  212. }
  213. }
  214. .list-right {
  215. display: flex;
  216. justify-content: center;
  217. align-items: center;
  218. }
  219. }
  220. }
  221. }
  222. </style>