storeList.vue 4.9 KB

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