store.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="store">
  3. <view class="list">
  4. <view class="item" v-for="(item,index) in list">
  5. <view class="left">
  6. <view class="img">
  7. <image :src="item.image" mode=""></image>
  8. </view>
  9. <view class="middle">
  10. <view class="name">
  11. <text class="storeName">{{item.name}}</text><br>
  12. <text class="address">{{ item.detailed_address }}</text>
  13. </view>
  14. <view class="distance">
  15. <image src="@/static/icon/img01.png" mode=""></image>
  16. 距离{{item.range}}KM
  17. </view>
  18. </view>
  19. </view>
  20. <view class="about">
  21. 门店
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { openMap } from '@/utils/rocessor.js';
  29. import { storeList } from '@/api/index.js'
  30. export default {
  31. data(){
  32. return {
  33. latitude:'',
  34. longitude:'',
  35. list:[],
  36. }
  37. },
  38. onLoad() {
  39. this.getaddress();
  40. },
  41. methods:{
  42. loadData(){
  43. const obj = this;
  44. console.log(obj.longitude)
  45. storeList({
  46. longitude:obj.longitude,//经度
  47. latitude:obj.latitude,//纬度
  48. }).then(function({ data }) {
  49. obj.list = data.list.map(e => {
  50. e.show = true;
  51. return e;
  52. });
  53. })
  54. .catch(e => {
  55. console.log(e);
  56. });
  57. },
  58. //获取定位信息
  59. getaddress() {
  60. let obj = this;
  61. uni.getLocation({
  62. type: 'gcj02',
  63. success: res => {
  64. obj.latitude = res.latitude;
  65. obj.longitude = res.longitude;
  66. this.loadData()
  67. },
  68. fail: err => {
  69. openMap().then(e => {
  70. this.getaddress();
  71. });
  72. }
  73. });
  74. },
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. $grey: #95A0B1;
  80. $text: #333333;
  81. $red: #FF4C4C;
  82. .store {
  83. .list {
  84. .item {
  85. box-shadow: 2rpx 2rpx 10rpx #e1e1e1;
  86. height: 220rpx;
  87. border-radius: 20rpx;
  88. background-color: #fff;
  89. margin: 20rpx;
  90. padding: 20rpx;
  91. display: flex;
  92. justify-content: space-between;
  93. .left {
  94. display: flex;
  95. .img {
  96. margin-right: 20rpx;
  97. image {
  98. border-radius: 20rpx;
  99. width: 180rpx;
  100. height: 180rpx;
  101. }
  102. }
  103. .middle {
  104. display: grid;
  105. align-content: space-between;
  106. .name {
  107. .storeName {
  108. font-weight: bold;
  109. font-size: 32rpx;
  110. color: #333333;
  111. }
  112. .address {
  113. font-size: 20rpx;
  114. color: #6c6c6c;
  115. }
  116. }
  117. .distance {
  118. font-size: 26rpx;
  119. color: $grey;
  120. image {
  121. width: 20rpx;
  122. height: 25rpx;
  123. margin-right: 10rpx;
  124. }
  125. }
  126. }
  127. }
  128. .about {
  129. font-size: 26rpx;
  130. padding: 0 10rpx;
  131. border-radius: 10rpx;
  132. height: 50rpx;
  133. line-height: 50rpx;
  134. color: #fff;
  135. background: linear-gradient(90deg, #FFBD70 0%, #FF8F44 100%);
  136. }
  137. }
  138. }
  139. }
  140. </style>