storeList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 class="noData" :text="noDataText" img-width="120" v-if="storeList.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. },
  77. computed: {},
  78. methods: {
  79. getStoresList() {
  80. this.status = "loading"
  81. let lat = this.currentPosition.lat
  82. let lng = this.currentPosition.lng
  83. getStoreList({
  84. lat: lat,
  85. lng: lng
  86. }).then(res => {
  87. console.log(res)
  88. uni.hideLoading()
  89. this.status = "loadmore"
  90. if (res.status == 200) {
  91. let list = res.data
  92. list.map(item => {
  93. if (item.addrDetail.indexOf("省") > 0 && item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") >
  94. 0) {
  95. item.addrDetail = item.addrDetail
  96. } else {
  97. if (item.addrDetail.indexOf("市") > 0 && item.addrDetail.indexOf("区") > 0) {
  98. item.addrDetail = item.addrProvinceName + item.addrDetail
  99. } else if (item.addrDetail.indexOf("区") > 0) {
  100. item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDetail
  101. } else {
  102. item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDistrictName + item.addrDetail
  103. }
  104. }
  105. item.distance = item.distanct && item.distanct.distance ? Math.round(item.distanct.distance / 1000) : ''
  106. })
  107. this.storeList = this.storeList.concat(list)
  108. this.total = res.data.count || 0
  109. } else {
  110. this.storeList = []
  111. this.total = 0
  112. this.noDataText = res.message
  113. }
  114. })
  115. },
  116. // 获取网点营业状态
  117. getStoreStatus(item) {
  118. switch (item.businessStatus) {
  119. case 'CLOSED':
  120. return '/static/img/ygb.png'
  121. break;
  122. case 'OPEN':
  123. return '/static/img/yyz.png'
  124. break;
  125. case 'TO_BE_OPENED':
  126. return '/static/img/dky.png'
  127. break;
  128. default:
  129. break;
  130. }
  131. },
  132. // 进入网点详情
  133. intoDetail (item) {
  134. uni.navigateTo({
  135. url: `/pages/store/storeDetail?id=${item.id}`
  136. })
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. page{
  143. height: 100%;
  144. }
  145. .content {
  146. padding: 0 20rpx;
  147. width: 100%;
  148. height: 100%;
  149. .scroll-Y {
  150. width: 100%;
  151. height: 100%;
  152. padding: 20rpx 0;
  153. .list {
  154. display: flex;
  155. border-bottom: 1px solid #eee;
  156. .store-info {
  157. display: flex;
  158. flex: 1;
  159. flex-direction: column;
  160. justify-content: space-between;
  161. padding: 0 20rpx;
  162. .name {
  163. font-size: 32rpx;
  164. color: #000;
  165. }
  166. .address{
  167. font-size: 26rpx;
  168. padding: 10rpx 0;
  169. }
  170. .location {
  171. display: flex;
  172. align-items: center;
  173. font-size: 24rpx;
  174. .left {
  175. margin-right: 20rpx;
  176. }
  177. .icon {
  178. color: #999;
  179. margin-right: 5rpx;
  180. }
  181. }
  182. }
  183. .list-right {
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. }
  188. }
  189. }
  190. }
  191. </style>