chartItem.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="container-chart-item" @click="goDetail(list)">
  3. <text class="chart-title">
  4. <mp-html :content="richTextClamp(2) + list.Title + '</div>'" />
  5. </text>
  6. <view class="item-content-img">
  7. <image :src="list.BodyHtml" mode=""></image>
  8. </view>
  9. <view class="chart-tag">
  10. <text class="tag-item" v-if="list.PtagName">{{ list.PtagName }}</text>
  11. <text class="tag-item" v-if="list.CtagName">{{ list.CtagName }}</text>
  12. </view>
  13. <view class="chart-collect" v-if="isMyChartCollection">
  14. <text class="cancel" @click.stop="myChartIsTop(list.ChartId)">{{ list.IsTop ? "取消置顶" : "置顶" }}</text>
  15. <text class="remove" @click.stop="myChartCollect(list.ChartId)">移除</text>
  16. </view>
  17. <view class="my-chart-collect" v-if="isMyChartCollection && list.IsTop"></view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: "",
  23. components: {},
  24. props: {
  25. list: {
  26. type: Object,
  27. default: {},
  28. required: true,
  29. },
  30. isMyChartCollection: {
  31. type: Boolean,
  32. default: false,
  33. },
  34. },
  35. data() {
  36. return {};
  37. },
  38. computed: {},
  39. watch: {},
  40. created() {},
  41. mounted() {},
  42. methods: {
  43. goDetail(item) {
  44. if (item.HomeType !== 1) {
  45. /* 无需授权且已绑定 检验是或否有权限 */
  46. uni.navigateTo({ url: "/pageMy/chartPage/chartPage?id=" + item.ChartId });
  47. }
  48. },
  49. myChartIsTop(id) {
  50. this.$emit("myChartIsTop", id);
  51. },
  52. myChartCollect(id) {
  53. this.$emit("myChartCollect", id);
  54. },
  55. richTextClamp(val) {
  56. return `<div style="${
  57. val == 7 ? "min-height: 50px;" : ""
  58. }line-clamp: ${val};-webkit-line-clamp: ${val};text-overflow: -o-ellipsis-lastline;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;word-wrap: break-word;word-break: break-all;">`;
  59. },
  60. },
  61. };
  62. </script>
  63. <style scoped lang="scss">
  64. .container-chart-item {
  65. position: relative;
  66. width: 100%;
  67. padding: 20rpx 20rpx 0;
  68. background: #ffffff;
  69. box-shadow: 0rpx 3rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
  70. border-radius: 8rpx;
  71. margin-bottom: 20rpx;
  72. overflow: hidden;
  73. .chart-title {
  74. height: 90rpx;
  75. font-size: 32rpx;
  76. font-weight: 500;
  77. color: #333333;
  78. line-height: 42rpx;
  79. border-bottom: 1rpx solid #dcdfe6;
  80. }
  81. .item-content-img {
  82. width: 100%;
  83. height: 286rpx;
  84. image {
  85. width: 100%;
  86. height: 100%;
  87. }
  88. }
  89. .chart-collect {
  90. display: flex;
  91. align-items: center;
  92. justify-content: space-between;
  93. padding-bottom: 20rpx;
  94. .cancel {
  95. background: #3385ff;
  96. margin-right: 20rpx;
  97. color: #ffffff;
  98. }
  99. .remove {
  100. border: 1px solid #3385ff;
  101. color: #3385ff;
  102. }
  103. text {
  104. width: 150rpx;
  105. height: 46rpx;
  106. line-height: 46rpx;
  107. border-radius: 4rpx;
  108. text-align: center;
  109. font-size: 24rpx;
  110. }
  111. }
  112. .my-chart-collect {
  113. position: absolute;
  114. top: 0;
  115. left: 0;
  116. width: 0;
  117. height: 0;
  118. border-top: 60rpx solid #3385ff;
  119. border-right: 60rpx solid transparent;
  120. }
  121. .chart-tag {
  122. display: flex;
  123. align-items: center;
  124. justify-content: space-between;
  125. height: 78rpx;
  126. border-top: 1rpx solid #dcdfe6;
  127. .tag-item {
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. width: 150rpx;
  132. height: 38rpx;
  133. border-radius: 28rpx;
  134. border: 2rpx solid #3189ff;
  135. color: #3385ff;
  136. font-size: 24rpx;
  137. }
  138. }
  139. }
  140. </style>