sunui-grand.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template name="sunui-grand">
  2. <view>
  3. <view v-show="isHide">
  4. <view class="sunui-grand-hide-bg" :style="'background-color:' + bg + ';'">
  5. <view class="sunui-grand-summary" :style="'-webkit-line-clamp:' + clamp + ';'">{{ content }}</view>
  6. <view class="sunui-grand-show-btn" :style="'top:' + (clamp - 1) + 'rem;height:' + clamp / 2 + 'rem;'" v-show="clamp >= 4">
  7. <view @tap.stop="show" :style="{ color: color }">
  8. <text :style="'border-bottom: 1upx solid ' + color + ';'">{{ expandText }}</text>
  9. </view>
  10. </view>
  11. </view>
  12. </view>
  13. <view v-show="!isHide">
  14. <view class="sunui-grand-show-bg" :style="'background-color:' + bg + ';'">
  15. <view>{{ content }}</view>
  16. <view class="sunui-grand-hide-btn" v-show="shinkText != ''">
  17. <view @tap.stop="hide" :style="{ color: color }">{{ shinkText == 'true' || shinkText == true ? '' : shinkText }}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. var _self;
  25. export default {
  26. data() {
  27. return {
  28. isHide: true
  29. };
  30. },
  31. name: 'sunui-grand',
  32. props: {
  33. clamp: {
  34. type: [Number, String],
  35. default: `4`
  36. },
  37. color: {
  38. type: String,
  39. default: `#1D82FE`
  40. },
  41. content: {
  42. type: [String, Object],
  43. default: ``
  44. },
  45. bg: {
  46. type: String,
  47. default: `#E6E6E6`
  48. },
  49. expandText: {
  50. type: String,
  51. default: '展开阅读全文'
  52. },
  53. shinkText: {
  54. type: String,
  55. default: '点击收起全文'
  56. }
  57. },
  58. created() {
  59. _self = this;
  60. },
  61. methods: {
  62. show() {
  63. let _this = this;
  64. _this.isHide = false;
  65. },
  66. hide() {
  67. let _this = this;
  68. _this.isHide = true;
  69. }
  70. }
  71. };
  72. </script>
  73. <style>
  74. .sunui-grand-hide-bg {
  75. background-color: #e9ecef;
  76. padding: 4%;
  77. padding-bottom: 0;
  78. position: relative;
  79. }
  80. .sunui-grand-show-bg {
  81. background-color: #e9ecef;
  82. padding: 4%;
  83. }
  84. .sunui-grand-summary {
  85. overflow: hidden;
  86. text-overflow: clip;
  87. display: -webkit-box;
  88. -webkit-box-orient: vertical;
  89. }
  90. .sunui-grand-show-btn {
  91. width: 100%;
  92. position: absolute;
  93. left: 0;
  94. z-index: 0;
  95. text-align: center;
  96. background-image: linear-gradient(-180deg, rgba(233, 236, 239, 0) 0%, #fff 80%);
  97. padding-top: 3rem;
  98. }
  99. .sunui-grand-hide-btn {
  100. text-align: right;
  101. }
  102. </style>