card1.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="filter">
  3. <view class="flex justify-around">
  4. <view :class="{active:activeIndex==index}" class="con" :key="index"
  5. v-for="(item,index) in tagsList" @click="filter(index)">
  6. <text class="title">{{item.title}}</text>
  7. <view class="tag">
  8. <text>{{item.desc}}</text>
  9. </view>
  10. </view>
  11. </view>
  12. <view class="item">
  13. <view class="card" @click="goDetail(item.id)" v-for="(item,index) in list" :key="index">
  14. <view class="left">
  15. <image :src="item.cover" mode=""></image>
  16. </view>
  17. <view class="right">
  18. <view class="title text-cut-1">
  19. <text class="">{{item.name}}</text>
  20. </view>
  21. <view class="data">
  22. <view class="">
  23. <block>
  24. <u-icon name="star-fill" color="#ff7001" size="30"></u-icon>
  25. <text
  26. style="margin-left: 4rpx;margin-right: 20rpx;color: #ff7001;font-size: 26rpx;">{{item.score}}</text>
  27. </block>
  28. <block>
  29. <text>月售</text>
  30. <text class="margin-left-10">{{item.sales==-1?0:item.sales}}</text>
  31. </block>
  32. </view>
  33. <view>
  34. <u-icon name="map-fill" color="#FF9447"></u-icon>
  35. <text class="margin-left-10">{{distance(item.latitude,item.longitude)}} 米</text>
  36. </view>
  37. </view>
  38. <view class="text-cut-2" style="width: 100%;height: 32rpx;margin-top: 14rpx;">
  39. <view v-for="(item1,index1) in item.labelKey.split(',')" :key="index1" class="cu-tag sm "
  40. style="background-color: #fff0d9;color: #ffa353;">
  41. {{item1}}
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default{
  51. props:{
  52. list:Array
  53. },
  54. data(){
  55. return {
  56. activeIndex: 0,
  57. tagsList: [{
  58. title: '智能筛选',
  59. desc: '大数据优选'
  60. },
  61. {
  62. title: '销量最好',
  63. desc: '销量最好'
  64. }, {
  65. title: '评分最高',
  66. desc: '好评如潮'
  67. },
  68. {
  69. title: '距离最近',
  70. desc: '由近到远'
  71. }]
  72. }
  73. },
  74. computed:{
  75. distance() {
  76. return (lat1,lng1) => {
  77. if (this.vuex_location!=null) {
  78. let distance=this.$util.calculateDistance(lat1,lng1,this.vuex_location.latitude,this.vuex_location.longitude)
  79. console.log(distance);
  80. return distance
  81. }else{
  82. return 0
  83. }
  84. };
  85. },
  86. },
  87. methods:{
  88. goDetail(id){
  89. uni.navigateTo({
  90. url:"/pages/consume/detail/shop-detail?id="+id,
  91. fail(err) {
  92. console.log(err);
  93. }
  94. })
  95. },
  96. filter(index){
  97. this.activeIndex=index
  98. console.log(this.activeIndex);
  99. this.$emit('filter',index)
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss">
  105. .filter {
  106. padding: 10rpx;
  107. display: flex;
  108. flex-direction: column;
  109. .con {
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: center;
  113. align-items: center;
  114. .title {
  115. font-size: 28rpx;
  116. font-weight: 800;
  117. }
  118. .tag {
  119. color: #888888;
  120. padding: 4rpx;
  121. margin-top: 10rpx;
  122. font-size: 22rpx;
  123. }
  124. }
  125. .active {
  126. color: #fd5d4a;
  127. .title {
  128. color: fd5d4a;
  129. }
  130. .tag {
  131. border-radius: 20rpx 0 20rpx 0;
  132. background-color: #ffddd5;
  133. color: #fd5d4a;
  134. }
  135. }
  136. }
  137. .item {
  138. display: flex;
  139. flex-direction: column;
  140. margin-top: 50rpx;
  141. .card {
  142. margin-bottom: 20rpx;
  143. display: flex;
  144. border-bottom: 1rpx solid #ececec;
  145. padding-bottom: 20rpx;
  146. .left {
  147. width: 30%;
  148. image {
  149. width: 100%;
  150. border-radius: 12rpx;
  151. height: 180rpx;
  152. }
  153. }
  154. .right {
  155. margin-left: 20rpx;
  156. display: flex;
  157. width: 70%;
  158. flex-direction: column;
  159. .title {
  160. font-size: 30rpx;
  161. font-weight: 800;
  162. margin-bottom: 30rpx;
  163. }
  164. .data {
  165. margin-top: 20rpx;
  166. display: flex;
  167. justify-content: space-between;
  168. font-size: 24rpx;
  169. color: #666666;
  170. }
  171. .label {
  172. margin-top: 10rpx;
  173. }
  174. }
  175. }
  176. .card:last-child {
  177. border: none;
  178. margin-bottom: 0;
  179. padding-bottom: 0;
  180. }
  181. }
  182. </style>