oa-recommend.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="oa-floor-index">
  3. <view class="f-header">
  4. <view class="line"></view>
  5. <text class="name">为您推荐</text>
  6. <view class="line"></view>
  7. </view>
  8. <oa-product-list :bottom="bottom" :list="guessYouLikeList"></oa-product-list>
  9. </view>
  10. </template>
  11. <script>
  12. /**
  13. *@des 商品推荐
  14. *@author hjp1011 21931118@qq.com
  15. *@blog http://www.wephp.com
  16. *@date 2020/01/08 11:28:39
  17. */
  18. import { guessYouLikeList } from '@/api/product';
  19. import rfProductList from '@/components/oa-product-list';
  20. export default {
  21. name: 'rfRecommend',
  22. components: { rfProductList },
  23. props: {
  24. list: {
  25. type: Array,
  26. default() {
  27. return [{}, {}];
  28. }
  29. },
  30. bottom: {
  31. type: Number,
  32. default: 0
  33. }
  34. },
  35. data() {
  36. return {
  37. guessYouLikeList: []
  38. };
  39. },
  40. filters: {
  41. filterTotalSales (val) {
  42. if (val > 10000) {
  43. val = `${(val / 10000).toFixed(2)}w`;
  44. }
  45. return val;
  46. }
  47. },
  48. mounted() {
  49. this.initData();
  50. },
  51. methods: {
  52. initData() {
  53. if (this.list.length === 0) {
  54. this.getGuessYouLikeList();
  55. } else {
  56. this.guessYouLikeList = this.list;
  57. }
  58. },
  59. async getGuessYouLikeList() {
  60. await this.$http.get(`${guessYouLikeList}`).then(r => {
  61. this.guessYouLikeList = r.data;
  62. });
  63. },
  64. navTo(id) {
  65. if (!id) return;
  66. uni.navigateTo({
  67. url: `/pages/product/product?id=${id} `
  68. });
  69. }
  70. }
  71. };
  72. </script>
  73. <style scoped lang="scss">
  74. .oa-floor-index {
  75. .oa-product-list {
  76. margin-top: 0;
  77. }
  78. .banner {
  79. width: 92%;
  80. margin: 20upx 4% 0;
  81. image {
  82. width: 100%;
  83. height: 25vw;
  84. border-radius: 20upx;
  85. box-shadow: 0upx 5upx 25upx rgba(0, 0, 0, 0.05);
  86. }
  87. }
  88. .f-header {
  89. display: flex;
  90. align-items: center;
  91. justify-content: center;
  92. padding: 40upx 20% 20upx;
  93. .line {
  94. border-bottom: 1upx solid rgba(0, 0, 0, 0.15); // 边框
  95. width: 120upx;
  96. }
  97. .name {
  98. }
  99. }
  100. }
  101. </style>