gui-spread.vue 1.9 KB

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