store.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="store">
  3. <view class="list">
  4. <view class="item" v-for="(item,index) in list" @click="lookmore(item)">
  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. import {
  31. mapState,
  32. mapMutations
  33. } from 'vuex';
  34. export default {
  35. data(){
  36. return {
  37. latitude:'',
  38. longitude:'',
  39. list:[],
  40. showStore: {}
  41. }
  42. },
  43. onLoad() {
  44. this.getaddress();
  45. },
  46. methods:{
  47. ...mapMutations('user',['setShowStore']),
  48. lookmore(item) {
  49. this.showStore = item
  50. console.log(item)
  51. // this.setShowStore(item)
  52. uni.setStorage({
  53. key: 'showStore',
  54. data: item,
  55. success() {
  56. console.log(item,'item++++')
  57. uni.navigateTo({
  58. url: '/pages/category/fillTable?type=look'
  59. })
  60. }
  61. })
  62. },
  63. loadData(){
  64. const obj = this;
  65. console.log(obj.longitude)
  66. storeList({
  67. longitude:obj.longitude,//经度
  68. latitude:obj.latitude,//纬度
  69. }).then(function({ data }) {
  70. obj.list = data.list.map(e => {
  71. e.show = true;
  72. return e;
  73. });
  74. })
  75. .catch(e => {
  76. console.log(e);
  77. });
  78. },
  79. //获取定位信息
  80. getaddress() {
  81. let obj = this;
  82. uni.getLocation({
  83. type: 'gcj02',
  84. success: res => {
  85. obj.latitude = res.latitude;
  86. obj.longitude = res.longitude;
  87. this.loadData()
  88. },
  89. fail: err => {
  90. openMap().then(e => {
  91. this.getaddress();
  92. });
  93. }
  94. });
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. $grey: #95A0B1;
  101. $text: #333333;
  102. $red: #FF4C4C;
  103. .store {
  104. .list {
  105. .item {
  106. box-shadow: 2rpx 2rpx 10rpx #e1e1e1;
  107. height: 220rpx;
  108. border-radius: 20rpx;
  109. background-color: #fff;
  110. margin: 20rpx;
  111. padding: 20rpx;
  112. display: flex;
  113. justify-content: space-between;
  114. .left {
  115. display: flex;
  116. .img {
  117. margin-right: 20rpx;
  118. image {
  119. border-radius: 20rpx;
  120. width: 180rpx;
  121. height: 180rpx;
  122. }
  123. }
  124. .middle {
  125. display: grid;
  126. align-content: space-between;
  127. .name {
  128. .storeName {
  129. font-weight: bold;
  130. font-size: 32rpx;
  131. color: #333333;
  132. }
  133. .address {
  134. font-size: 20rpx;
  135. color: #6c6c6c;
  136. }
  137. }
  138. .distance {
  139. font-size: 26rpx;
  140. color: $grey;
  141. image {
  142. width: 20rpx;
  143. height: 25rpx;
  144. margin-right: 10rpx;
  145. }
  146. }
  147. }
  148. }
  149. .about {
  150. font-size: 26rpx;
  151. padding: 0 10rpx;
  152. border-radius: 10rpx;
  153. height: 50rpx;
  154. line-height: 50rpx;
  155. color: #fff;
  156. background: linear-gradient(90deg, #FFBD70 0%, #FF8F44 100%);
  157. }
  158. }
  159. }
  160. }
  161. </style>