storeList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-y="true" class="scroll-Y">
  4. <view class="list" @click="intoDetail(item)" 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.beginTime}}-{{item.endTime}} 营业</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. import {getStoreList} from '@/api/store.js'
  38. export default {
  39. components: {
  40. uniIcons
  41. },
  42. data() {
  43. return {
  44. noDataText: '暂无数据',
  45. status: 'loadmore',
  46. storeList: [],
  47. // 用户拒绝授权位置信息时默认展示青海西宁位置地图
  48. currentPosition: {
  49. lat: '36.636193',
  50. lng: '101.760521'
  51. },
  52. pageNo: 1,
  53. pageSize: 10,
  54. total: 0
  55. }
  56. },
  57. onShow() {
  58. },
  59. onLoad() {
  60. // 获取当前经纬度
  61. let _this = this
  62. uni.getLocation({
  63. type: 'wgs84', // 默认wgs84
  64. success: function(res) {
  65. _this.currentPosition.lat = res.latitude;
  66. _this.currentPosition.lng = res.longitude;
  67. // 查询门店信息
  68. // _this.getStoresList()
  69. },
  70. fail: function(res) {
  71. console.log(res)
  72. // 查询门店信息
  73. // _this.getStoresList()
  74. },
  75. });
  76. this.getStoresList()
  77. },
  78. computed: {},
  79. methods: {
  80. getStoresList() {
  81. this.status = "loading"
  82. let lat = this.currentPosition.lat
  83. let lng = this.currentPosition.lng
  84. getStoreList({
  85. lat: '39.848974',
  86. lng: '116.510229'
  87. }).then(res => {
  88. console.log(res)
  89. uni.hideLoading()
  90. this.status = "loadmore"
  91. if (res.status == 200) {
  92. let list = res.data
  93. list.map(item => {
  94. if (item.addrDetail.indexOf("省") > 0 && item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") >
  95. 0) {
  96. item.addrDetail = item.addrDetail
  97. } else {
  98. if (item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") > 0) {
  99. item.addrDetail = item.addrProvinceName + item.addrDetail
  100. } else if (item.addrDetail.indexOf("区") > 0) {
  101. item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDetail
  102. } else {
  103. item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDistrictName + item.addrDetail
  104. }
  105. }
  106. item.distance = item.distanct && item.distanct.distance ? Math.round(item.distanct.distance / 1000) : ''
  107. })
  108. this.storeList = this.storeList.concat(list)
  109. this.total = res.data.count || 0
  110. } else {
  111. this.storeList = []
  112. this.total = 0
  113. this.noDataText = res.message
  114. }
  115. })
  116. },
  117. // 获取网点营业状态
  118. getStoreStatus(item) {
  119. switch (item.businessStatus) {
  120. case 'CLOSED':
  121. return '/static/img/ygb.png'
  122. break;
  123. case 'OPEN':
  124. return '/static/img/yyz.png'
  125. break;
  126. case 'TO_BE_OPENED':
  127. return '/static/img/dky.png'
  128. break;
  129. default:
  130. break;
  131. }
  132. },
  133. // 进入网点详情
  134. intoDetail (item) {
  135. uni.navigateTo({
  136. url: `/pages/store/storeDetail?id=${item.id}`
  137. })
  138. },
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. .content {
  144. padding: 0 20rpx;
  145. .scroll-Y {
  146. width: 100%;
  147. height: 100%;
  148. .list {
  149. padding: 20rpx 0;
  150. display: flex;
  151. border-bottom: 1px solid #eee;
  152. .store-info {
  153. display: flex;
  154. flex: 1;
  155. flex-direction: column;
  156. justify-content: space-between;
  157. padding: 0 20rpx;
  158. .name {
  159. font-size: 32rpx;
  160. color: #000;
  161. }
  162. .address{
  163. font-size: 26rpx;
  164. padding: 10rpx 0;
  165. }
  166. .location {
  167. display: flex;
  168. align-items: center;
  169. font-size: 24rpx;
  170. .left {
  171. margin-right: 20rpx;
  172. }
  173. .icon {
  174. color: #999;
  175. margin-right: 5rpx;
  176. }
  177. }
  178. }
  179. .list-right {
  180. display: flex;
  181. justify-content: center;
  182. align-items: center;
  183. }
  184. }
  185. }
  186. }
  187. </style>