index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="rf-floor-index">
  3. <!--广告图-->
  4. <view
  5. class="banner"
  6. v-if="bannerShow"
  7. @tap="toBanner(banner)"
  8. >
  9. <image :src="banner.cover" mode="aspectFill" />
  10. </view>
  11. <!--列表-->
  12. <view class="f-header" @tap="toList">
  13. <text class="iconfont" :class="[icon, 'text-'+themeColor.name]" />
  14. <view class="tit-box">
  15. <text class="tit">{{ header.title }}</text>
  16. <text class="tit2">{{ header.desc }}</text>
  17. </view>
  18. <text v-if="isLink" class="iconfont iconyou"></text>
  19. </view>
  20. <rf-product-list :bottom="bottom" :list="list.length > 0 ? list : [0, 0]"></rf-product-list>
  21. </view>
  22. </template>
  23. <script>/**
  24. *@des 首页楼层组件
  25. *@author stav stavyan@qq.com
  26. *@blog https://stavtop.club
  27. *@date 2020/01/08 11:28:39
  28. */
  29. import $mAssetsPath from '@/config/assets.config';
  30. import rfProductList from '@/components/rf-product-list';
  31. export default {
  32. name: 'rfFloorIndex',
  33. components: { rfProductList },
  34. props: {
  35. // 列表
  36. list: {
  37. type: Array,
  38. default() {
  39. return [];
  40. }
  41. },
  42. // 广告图
  43. banner: {
  44. type: Object,
  45. default() {
  46. return {};
  47. }
  48. },
  49. // 标题 例: 新品上市
  50. header: {
  51. type: Object,
  52. default() {
  53. return {};
  54. }
  55. },
  56. // 是否显示banner图
  57. bannerShow: {
  58. type: Boolean,
  59. default: true
  60. },
  61. // 是否可点击
  62. isLink: {
  63. type: Boolean,
  64. default: true
  65. },
  66. // icon
  67. icon: {
  68. type: String,
  69. default: ''
  70. }
  71. },
  72. data() {
  73. return {
  74. };
  75. },
  76. computed: {
  77. bottom () {
  78. let bottom = 0;
  79. /* #ifdef H5 */
  80. bottom = 90;
  81. /* #endif */
  82. return bottom;
  83. }
  84. },
  85. filters: {
  86. filterTotalSales (val) {
  87. if (val > 10000) {
  88. val = `${(val / 10000).toFixed(2)}w`;
  89. }
  90. return val;
  91. },
  92. filterTagName (val) {
  93. if (val.commissionRate) { // 分销礼品
  94. return $mAssetsPath.distribution;
  95. } else if (val.is_virtual === '1') { // 虚拟产品
  96. return $mAssetsPath.virtual;
  97. } else if (val.shopping_type === '1') { // 包邮产品
  98. return $mAssetsPath.pinkage;
  99. }
  100. }
  101. },
  102. methods: {
  103. // 跳转详情页
  104. detail(id) {
  105. if (!id) return;
  106. this.$emit('detail', {
  107. id
  108. });
  109. },
  110. // banner 跳转页
  111. toBanner(item) {
  112. this.$emit('toBanner', item);
  113. },
  114. // 列表 跳转页
  115. toList() {
  116. this.$emit('toList');
  117. }
  118. }
  119. };
  120. </script>
  121. <style scoped lang="scss">
  122. .rf-floor-index {
  123. .banner {
  124. width: 92%;
  125. margin: 20upx 4% 0;
  126. image {
  127. width: 100%;
  128. height: 25vw;
  129. border-radius: 20upx;
  130. box-shadow: 0upx 5upx 25upx rgba(0, 0, 0, 0.05);
  131. }
  132. }
  133. .f-header {
  134. display: flex;
  135. align-items: center;
  136. height: 120upx;
  137. padding: 6upx 20upx;
  138. margin: 0 0 20upx;
  139. background: #fff;
  140. border-bottom: 1upx solid rgba(0, 0, 0, 0.05);
  141. .iconfont {
  142. font-size: $font-lg + 24upx;
  143. margin-right: 20upx;
  144. }
  145. .tit-box {
  146. flex: 1;
  147. display: flex;
  148. flex-direction: column;
  149. }
  150. .tit {
  151. font-size: $font-lg + 2upx;
  152. color: #font-color-dark;
  153. line-height: 1.3;
  154. }
  155. .tit2 {
  156. font-size: $font-sm;
  157. color: $font-color-light;
  158. }
  159. .iconyou {
  160. font-size: $font-lg + 4upx;
  161. color: $font-color-light;
  162. }
  163. }
  164. }
  165. </style>