StoreList.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="content">
  3. <view>
  4. <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="reachBottom"
  5. @scroll="scroll">
  6. <view class="">
  7. </view>
  8. </scroll-view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. components: {},
  15. data() {
  16. return {
  17. storeList: [],
  18. currentPosition: {
  19. lat: '0',
  20. lng: '0'
  21. },
  22. pageNo: 1,
  23. pageSize: 10
  24. }
  25. },
  26. onShow() {
  27. },
  28. onLoad() {
  29. // 获取当前经纬度
  30. let _this = this
  31. uni.getLocation({
  32. type: 'wgs84', // 默认wgs84
  33. success: function(res) {
  34. _this.currentPosition.lat = res.latitude;
  35. _this.currentPosition.lng = res.longitude;
  36. _this.gpsCompletion = true;
  37. // 查询门店信息
  38. // _this.getStoresList()
  39. },
  40. fail: function(res) {
  41. console.log(res)
  42. // 查询门店信息
  43. // _this.getStoresList()
  44. },
  45. });
  46. },
  47. computed: {
  48. },
  49. methods:{
  50. getStoresList () {
  51. uni.showLoading({
  52. title: '正在加载...'
  53. })
  54. let lat = this.currentPosition.lat
  55. let lng = this.currentPosition.lng
  56. getStoresList({pageNo:this.pageNo,pageSize:this.pageSize,lat:lat,lng:lng}).then(res => {
  57. console.log(res)
  58. if(res.status == 200){
  59. let list = res.data.list
  60. if(list&&list.length){
  61. list.map(item => {
  62. if (item.addrDetail.indexOf("省")>0 && item.addrDetail.indexOf("市")>0 && item.addrDetail.indexOf("区")>0){
  63. item.addrDetail = item.addrDetail
  64. } else {
  65. if (item.addrDetail.indexOf("市")>0 && item.addrDetail.indexOf("区")>0){
  66. item.addrDetail = item.addrProvinceName + item.addrDetail
  67. } else if (item.addrDetail.indexOf("区")>0) {
  68. item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDetail
  69. } else {
  70. item.addrDetail = item.addrProvinceName + item.addrCityName + item.addrDistrictName + item.addrDetail
  71. }
  72. }
  73. item.distance = item.distance ? Math.round(item.distance/1000) : ''
  74. item.star = getStarNum(item.level)
  75. })
  76. this.storeList = this.storeList.concat(list)
  77. }else{
  78. if(this.pageNo!=1){
  79. uni.showToast({
  80. title: '已经是最后一页'
  81. })
  82. this.isLastPage = true
  83. }
  84. }
  85. }
  86. uni.hideLoading()
  87. })
  88. },
  89. // 到达底部
  90. reachBottom () {
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. </style>