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