graceSpread.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template name="graceSpread">
  2. <view class="grace-spread" :style="{height:reHeight}">
  3. <slot></slot>
  4. <view v-if="isBtn" class="btn" @tap="spreadContent" :style="{color:btnColor}">{{btnTxt}}<text :style="{color:btnColor}" class="gsd-arrow-down"></text></view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. props: {
  10. height:{
  11. type : String,
  12. default : "600rpx"
  13. },
  14. btnTxt:{
  15. type : String,
  16. default : "展开阅读全文"
  17. },
  18. btnColor:{
  19. type : String,
  20. default : "#999999"
  21. }
  22. },
  23. data() {
  24. return {
  25. reHeight: "600px",
  26. isBtn : true
  27. }
  28. },
  29. created:function(){
  30. this.reHeight = this.height;
  31. },
  32. methods: {
  33. spreadContent : function () {
  34. // #ifdef MP-BAIDU
  35. this.reHeight = '';
  36. // #endif
  37. // #ifndef MP-BAIDU
  38. this.reHeight = 'auto';
  39. // #endif
  40. this.isBtn = false;
  41. }
  42. },
  43. }
  44. </script>
  45. <style scoped>
  46. .grace-spread{overflow:hidden; position:relative;}
  47. .grace-spread > .btn{
  48. width:100%; height:38px;
  49. line-height:38px; padding-top:15px;
  50. background:linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.8) 25%, rgba(255,255,255,1) 40%, rgba(255,255,255,1) 100%);
  51. position:absolute;
  52. z-index:999999;
  53. left:0; bottom:0;
  54. text-align:center;
  55. }
  56. @font-face {font-family:"gFont"; src:url('https://at.alicdn.com/t/font_1348754_ac85tokgewg.ttf') format('truetype');}
  57. .gsd-arrow-down{margin-left:5px; font-size:28rpx;}
  58. .gsd-arrow-down text{font-size:28rpx;}
  59. .gsd-arrow-down:before{font-family:"gFont"; content: "\e638";}
  60. </style>