You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.3 KiB

3 years ago
  1. <template>
  2. <view>
  3. <view class="list" :class="{show: showAll}">
  4. <view v-for="item in list" :key="item._id" class="item row b-b" @click="navTo('/pages/product/detail?id='+item.sku.product_id)">
  5. <image class="pic" :src="item.image" mode="aspectFill"></image>
  6. <view class="right column">
  7. <text class="title clamp">{{ item.title }}</text>
  8. <text class="sku">{{ item.sku ? item.sku.name : '' }}</text>
  9. <view class="price-wrap">
  10. <text class="price">{{ item.price }}</text>
  11. <text class="number">x {{ item.number }}</text>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. <view v-if="list.length > 2" class="more-btn center" @click="showMore">
  17. <text>{{ showAll ? '收起' : '查看更多' }}</text>
  18. <text class="mix-icon icon-xia" :class="{active: showAll}"></text>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. showAll: false
  27. }
  28. },
  29. props: {
  30. list: {
  31. type: Array,
  32. default(){
  33. return []
  34. }
  35. }
  36. },
  37. methods: {
  38. showMore(){
  39. this.showAll = !this.showAll;
  40. }
  41. }
  42. }
  43. </script>
  44. <style scoped lang="scss">
  45. .more-btn{
  46. padding: 16rpx 0 12rpx;
  47. margin-top: -4rpx;
  48. font-size: 24rpx;
  49. color: #999;
  50. position: relative;
  51. z-index: 10;
  52. background-color: #fff;
  53. .icon-xia{
  54. margin-left: 4rpx;
  55. font-size: 28rpx;
  56. }
  57. .active{
  58. transform: scale(-1);
  59. }
  60. }
  61. .list{
  62. max-height: 380rpx;
  63. overflow: hidden;
  64. &.show{
  65. max-height: 9999rpx;
  66. }
  67. }
  68. .item{
  69. width: 100%;
  70. height: 190rpx;
  71. padding: 24rpx 0 24rpx 24rpx;
  72. background-color: #fff;
  73. &:after{
  74. border-color: #e5e5e5;
  75. }
  76. }
  77. .pic{
  78. flex-shrink: 0;
  79. width: 140rpx;
  80. height: 140rpx;
  81. margin-right: 20rpx;
  82. border-radius: 6rpx;
  83. }
  84. .right{
  85. flex: 1;
  86. color: #333;
  87. overflow: hidden;
  88. }
  89. .title{
  90. margin-right: 24rpx;
  91. margin-top: 0rpx;
  92. font-size: 30rpx;
  93. line-height: 40rpx;
  94. }
  95. .sku{
  96. height: 40rpx;
  97. margin: 10rpx 0 20rpx;
  98. line-height: 40rpx;
  99. font-size: 24rpx;
  100. color: #888;
  101. }
  102. .price-wrap{
  103. display: flex;
  104. align-items: baseline;
  105. padding-right: 20rpx;
  106. }
  107. .price{
  108. margin-right: 16rpx;
  109. font-size: 28rpx;
  110. line-height: 1;
  111. &:before{
  112. content: "¥";
  113. font-size: 26rpx;
  114. }
  115. }
  116. .number{
  117. font-size: 26rpx;
  118. color: #666;
  119. }
  120. </style>