graceSpread.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template name="graceSpread">
  2. <view class="grace-spread" :style="{height:reHeight, width:width}">
  3. <view :style="{paddingBottom: !isBtn && isShrink ? '80rpx' : '0rpx'}"><slot></slot></view>
  4. <view v-if="isBtn" class="grace-spread-btn" @tap.stop="spreadContent"
  5. :style="{color:btnColor, fontSize:btnTxtSize, zIndex:zIndex}">{{btnTxt}}<text :style="{color:btnColor}" class="grace-icons" style="padding-left:12rpx;">&#xe69d;</text></view>
  6. <view v-if="!isBtn && isShrink" class="grace-spread-btn" @tap.stop="shrinkContent"
  7. :style="{color:btnColor, fontSize:btnTxtSize, zIndex:zIndex}">{{shrinkBtnTxt}}<text :style="{color:btnColor}" class="grace-icons" style="padding-left:12rpx;">&#xe638;</text></view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. props: {
  13. width:{
  14. type : String,
  15. default : "700rpx"
  16. },
  17. height:{
  18. type : String,
  19. default : "600rpx"
  20. },
  21. btnTxt:{
  22. type : String,
  23. default : "展开阅读全文"
  24. },
  25. btnColor:{
  26. type : String,
  27. default : "#999999"
  28. },
  29. btnTxtSize:{
  30. type : String,
  31. default : "28rpx"
  32. },
  33. zIndex:{
  34. type:Number,
  35. default:1
  36. },
  37. isShrink:{type:Boolean,default:false},
  38. shrinkBtnTxt:{type : String,default : "收缩展示"}
  39. },
  40. data() {
  41. return {
  42. reHeight: "600px",
  43. isBtn : true
  44. }
  45. },
  46. created:function(){
  47. this.reHeight = this.height;
  48. },
  49. methods: {
  50. spreadContent : function () {
  51. // #ifdef MP-BAIDU
  52. this.reHeight = '';
  53. // #endif
  54. // #ifndef MP-BAIDU
  55. this.reHeight = 'auto';
  56. // #endif
  57. this.isBtn = false;
  58. },
  59. shrinkContent : function () {
  60. this.reHeight = this.height;
  61. this.isBtn = true;
  62. }
  63. },
  64. }
  65. </script>
  66. <style scoped>
  67. .grace-spread{overflow:hidden; position:relative;}
  68. .grace-spread-btn{ width:100%; height:38px; line-height:38px; 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%); position:absolute; z-index:999999; left:0; bottom:0; text-align:center;}
  69. </style>