list.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div>
  3. <van-nav-bar title="商户列表" @click-left="$router.back()" left-arrow fixed placeholder safe-area-inset-top />
  4. <div class="page_list">
  5. <div v-for="(item,index) in merList" :key="index">
  6. <div class="item_bg" @click="detailTap(item.id)">
  7. <div class="top_bg">
  8. <div class="name">{{item.name}}</div>
  9. <div class="distance_bg">
  10. <van-image class="distance_icon" :src="require('../../assets/images/elderly/location.png')" />
  11. <span class="dis_text">{{item.distance| distanceConversion}}</span>
  12. </div>
  13. </div>
  14. <div class="judge_bg">
  15. <div v-for="(starItem,starIndex) in starTotal" :key="starIndex">
  16. <van-image class="star_icon" :src="item.score > starIndex ? require('../../assets/images/elderly/xx.png') : require('../../assets/images/elderly/collection.png')" />
  17. </div>
  18. </div>
  19. <div class="address_bg">
  20. <van-image class="location_icon" :src="require('../../assets/images/elderly/icondistance.png')" />
  21. <div>{{item.detailedAddress}}</div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import {institutions_search} from '../../api/index.js'
  30. export default {
  31. data() {
  32. return {
  33. merList:[],
  34. starTotal:5,
  35. radius:0,
  36. longitude:'',
  37. latitude:'',
  38. categoryId:''
  39. }
  40. },
  41. filters: {
  42. distanceConversion(num) {
  43. var dis
  44. if (num >= 5000) {
  45. dis = '>5km'
  46. } else if (num >= 1000 && num < 10000) {
  47. dis = (num / 1000).toFixed(2) + 'km'
  48. } else {
  49. dis = num + 'm'
  50. }
  51. return dis
  52. }
  53. },
  54. mounted() {
  55. },
  56. created() {
  57. this.longitude = this.$route.query.longitude
  58. this.latitude = this.$route.query.latitude
  59. this.radius = this.$route.query.radius
  60. this.categoryId = this.$route.query.categoryId
  61. this.getInstitutions_search()
  62. },
  63. methods: {
  64. async getInstitutions_search() {
  65. var institutionSearch = await institutions_search({
  66. "radius": this.radius,
  67. "institutionalTypeList":this.categoryId,
  68. "lat": this.latitude,
  69. "lng": this.longitude,
  70. "pageNum":1,
  71. 'pageSize':10
  72. })
  73. let merListTemp=[]
  74. institutionSearch.rows.forEach((e) => {
  75. // e.distance = util.getDistance(this.data.latitude,this.data.longitude,e.lat,e.lng)
  76. e.score = 4
  77. merListTemp.push(e)
  78. });
  79. this.merList =merListTemp
  80. },
  81. detailTap(id) {
  82. console.log('商户id')
  83. console.log(id)
  84. this.$router.push({path:'/detail',query:{institutionsId:id}})
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .page_list {
  91. width: 100%;
  92. height: 100%;
  93. background-color: #f1f1f1;
  94. }
  95. .item_bg {
  96. padding: 10px 15px;
  97. box-sizing: border-box;
  98. width: 96%;
  99. min-height: 220px;
  100. border-radius: 10px;
  101. background-color: white;
  102. margin: 10px auto;
  103. font-size: 32px;
  104. }
  105. .top_bg {
  106. width: 100%;
  107. height: auto;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. }
  112. .name {
  113. flex: .8;
  114. }
  115. .distance_bg {
  116. flex: .2;
  117. }
  118. .distance_icon {
  119. width: 30px;
  120. height: 30px;
  121. margin-right: 10rpx;
  122. }
  123. .dis_text {
  124. color: rgb(243, 99, 80);
  125. font-size: 28px;
  126. }
  127. .judge_bg {
  128. width: 100%;
  129. height: auto;
  130. }
  131. .address_bg {
  132. width: 100%;
  133. height: auto;
  134. color: #3a3939;
  135. font-size: 30px;
  136. display: flex;
  137. justify-content: flex-start;
  138. align-items: flex-start;
  139. }
  140. .location_icon {
  141. width: 30px;
  142. height: 30px;
  143. margin: 7px 10px 0 0;
  144. }
  145. .judge_bg {
  146. display: flex;
  147. justify-content: flex-start;
  148. align-items: center;
  149. margin: 6px 0;
  150. }
  151. .star_icon {
  152. width: 30px;
  153. height: 30px;
  154. margin-right: 6px;
  155. }
  156. </style>