CargoNormal.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div @click="handleClick">
  3. <el-card :body-style="{ padding: '0px' }" shadow="hover">
  4. <el-image lazy class="image" :src="img">
  5. <div slot="error" class="image-slot">
  6. <i class="el-icon-picture-outline"></i>
  7. </div>
  8. </el-image>
  9. <div class="cargo-wrap">
  10. <div class="title clearfix">{{title}}</div>
  11. <div class="subtitle clearfix">{{subtitle}}</div>
  12. </div>
  13. </el-card>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. props: {
  19. // 图片地址
  20. img: {
  21. type: String,
  22. default: "https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png",
  23. required: true
  24. },
  25. // 商品标题
  26. title: {
  27. type: String,
  28. default: "商品标题",
  29. required: true
  30. },
  31. // 商品子标题
  32. subTitle: {
  33. type: String,
  34. default: ""
  35. },
  36. // 跳转路径
  37. path: {
  38. type: String,
  39. default: "",
  40. required: true
  41. },
  42. // 是否打开新窗口
  43. newWindow: {
  44. type: Boolean,
  45. default: true
  46. }
  47. },
  48. data() {
  49. return {}
  50. },
  51. methods: {
  52. // 处理点击跳转
  53. handleClick: () => {
  54. // 在新窗口打开页面
  55. if (this.newWindow) {
  56. this.$util.pushToTab(this.path)
  57. } else {
  58. this.$router.push(this.path)
  59. }
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .image {
  66. width: 100%;
  67. display: block;
  68. }
  69. .title {
  70. font-size: 14px;
  71. color: #ff6900;
  72. }
  73. .subtitle {
  74. font-size: 14px;
  75. color: #999999;
  76. }
  77. .cargo-wrap {
  78. padding: 14px;
  79. }
  80. .clearfix:before,
  81. .clearfix:after {
  82. display: table;
  83. content: "";
  84. }
  85. .clearfix:after {
  86. clear: both;
  87. }
  88. </style>