material-list.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="material-wrapper">
  3. <view class="material-list">
  4. <view class="material-item" v-for="item in list" :key="item.archiveId" @click="onToDetail(item)">
  5. <view class="cover"><image :src="item.productImage"></image></view>
  6. <view class="content">
  7. <view class="title" v-text="item.productName"></view>
  8. <view class="shop-name">
  9. <text class="label">供应商:</text>
  10. <text class="value" v-text="item.shopName"></text>
  11. </view>
  12. <view class="property">
  13. <text class="label">商品属性:</text>
  14. <text class="value">{{ item.productType === 1 ? '仪器' : '产品' }}</text>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { debounce } from '@/common/config/common'
  23. const myDebounce = fn => debounce(fn, 200, false)
  24. export default {
  25. props: {
  26. list: {
  27. type: Array,
  28. default: () => []
  29. }
  30. },
  31. created() {
  32. console.log('material-list')
  33. },
  34. methods: {
  35. onToDetail: myDebounce(function(item) {
  36. this.$api.navigateTo(`/pages/goods/goods-doc-detail?id=${item.archiveId}`)
  37. })
  38. }
  39. }
  40. </script>
  41. <style lang="scss" scoped>
  42. /* scss中可以用mixin来扩展 */
  43. @mixin ellipsis($line: 1) {
  44. overflow: hidden;
  45. text-overflow: ellipsis;
  46. display: -webkit-box;
  47. -webkit-line-clamp: $line;
  48. -webkit-box-orient: vertical;
  49. }
  50. .material-wrapper {
  51. .material-item {
  52. display: flex;
  53. padding: 32rpx;
  54. border-top: 1rpx solid #e1e1e1;
  55. &:first-child {
  56. border-top: 0;
  57. }
  58. .cover {
  59. width: 220rpx;
  60. height: 220rpx;
  61. flex-shrink: 0;
  62. image {
  63. display: block;
  64. width: 100%;
  65. height: 100%;
  66. }
  67. }
  68. .content {
  69. flex: 1;
  70. margin-left: 24rpx;
  71. .title {
  72. @include ellipsis(2);
  73. font-size: 28rpx;
  74. color: #22272e;
  75. line-height: 40rpx;
  76. height: 80rpx;
  77. }
  78. .shop-name {
  79. margin-top: 24rpx;
  80. }
  81. .property {
  82. margin-top: 16rpx;
  83. }
  84. .shop-name,
  85. .property {
  86. font-size: 24rpx;
  87. @include ellipsis(1);
  88. .label {
  89. color: #999999;
  90. }
  91. .value {
  92. color: #333333;
  93. }
  94. }
  95. }
  96. }
  97. }
  98. </style>