gui-spread.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view class="gui-spread"
  3. :class="[isShrink ? 'gui-transition-all' : '']"
  4. :style="{height:reHeight}">
  5. <view :style="{
  6. paddingBottom: !isBtn && isShrink ? '80rpx' : '0rpx'
  7. }">
  8. <slot></slot>
  9. </view>
  10. <text
  11. v-if="isBtn"
  12. @tap="spreadContent"
  13. :style="{fontSize:btnTxtSize, zIndex:zIndex, width:width}"
  14. class="gui-primary-text gui-icons gui-block gui-spread-btn gui-bg-white gui-dark-bg-level-1">&#xe69d; {{btnTxt}}</text>
  15. <text
  16. v-if="!isBtn && isShrink"
  17. @tap="shrinkContent"
  18. :style="{fontSize:btnTxtSize, zIndex:zIndex, width:width}"
  19. class="gui-primary-text gui-icons gui-block gui-spread-btn gui-bg-white gui-dark-bg-level-1">&#xe638; {{shrinkBtnTxt}}</text>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. name : "gui-spread",
  25. props : {
  26. width : { type : String, default : "690rpx" },
  27. height : { type : String, default : "600rpx" },
  28. btnTxt : { type : String, default : "展开阅读全文" },
  29. btnTxtSize : { type : String, default : "28rpx" },
  30. zIndex : { type : Number, default : 1 },
  31. isShrink : { type : Boolean,default : false},
  32. shrinkBtnTxt: { type : String, default : "收缩文章"}
  33. },
  34. data() {
  35. return {
  36. reHeight: "600px",
  37. isBtn : true
  38. }
  39. },
  40. created:function(){
  41. this.reHeight = this.height;
  42. },
  43. methods: {
  44. spreadContent : function () {
  45. // #ifdef MP-BAIDU
  46. this.reHeight = '';
  47. // #endif
  48. // #ifndef MP-BAIDU
  49. this.reHeight = 'auto';
  50. // #endif
  51. // #ifdef APP-NVUE
  52. this.reHeight = '';
  53. // #endif
  54. this.isBtn = false;
  55. },
  56. shrinkContent : function () {
  57. this.reHeight = this.height;
  58. this.isBtn = true;
  59. }
  60. },
  61. }
  62. </script>
  63. <style scoped>
  64. .gui-spread{overflow:hidden; position:relative;}
  65. .gui-spread-btn{height:91rpx; line-height:88rpx; position:absolute; z-index:999; left:0; bottom:-3rpx; text-align:center;font-size:28rpx;opacity:0.96;}
  66. </style>