list.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="list">
  3. <uni-card padding="0" spacing="0" type="line">
  4. <view v-if="!titleImg">
  5. <template v-slot:title>
  6. <uni-list>
  7. <uni-list-item :title="name"/>
  8. </uni-list>
  9. </template>
  10. </view>
  11. <view v-if="titleImg">
  12. <template v-slot:cover>
  13. <view class="custom-cover">
  14. <image class="cover-image" mode="aspectFill" :src="cover">
  15. </image>
  16. <view class="cover-content">
  17. <text class="uni-subtitle uni-white">{{ name }}</text>
  18. </view>
  19. </view>
  20. </template>
  21. </view>
  22. <uni-list>
  23. <uni-list-item v-for="(item, index) in data" :key="index" :title="item.title" showArrow
  24. @click="onClick"
  25. :thumb="`${baseurl}${item.thumbnail}`"
  26. thumb-size="lg" rightText="详情" />
  27. </uni-list>
  28. </uni-card>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. props: {
  34. // 数据内容
  35. data: { type: Array, default: () => [] },
  36. name: { type: String, default: '默认title' },
  37. // 是否启用图片卡片
  38. titleImg: { type: Boolean, default: false },
  39. // 图片地址
  40. cover: { type: String, default: '' }
  41. },
  42. computed: {},
  43. data() {
  44. return {
  45. baseurl: 'http://192.168.3.45:9002',
  46. };
  47. },
  48. async mounted() {},
  49. methods: {
  50. async onClick(e) {
  51. console.log(e);
  52. }
  53. },
  54. };
  55. </script>
  56. <style lang="scss" scoped>
  57. .cover-image {
  58. width: 100%;
  59. height: 150px;
  60. }
  61. .cover-content {
  62. position: absolute;
  63. top: 35%;
  64. width: 100%;
  65. background: #000;
  66. opacity: 0.5;
  67. }
  68. .uni-subtitle {
  69. line-height: 30px;
  70. margin-left: 10px;
  71. }
  72. .list {
  73. margin-top: 15px;
  74. }
  75. </style>