z-slide-card.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="z-slide-card" @touchmove.stop.prevent="moveHandle">
  3. <view class="scroll-area" :class="[{'animate_show':visible}]">
  4. <view class="top_bar flex-n fac fjb plr-30">
  5. <view class="iconfanhui iconfont go_back" style="text-align: left;" @click="back"></view>
  6. <view class="title">
  7. {{title}}
  8. </view>
  9. <view class="rightbtn" @click="rightBtnClick">{{rightBtnText}}</view>
  10. </view>
  11. <scroll-view scroll-y class="scroll-content">
  12. <!-- <view class="scroll-content">
  13. -->
  14. <slot></slot>
  15. <!-- </view> -->
  16. </scroll-view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'z-slide-card',
  23. props: {
  24. visible: {
  25. type: Boolean,
  26. default: false
  27. },
  28. title: String,
  29. rightBtnText: String,
  30. },
  31. data() {
  32. return {
  33. visiblehide: true,
  34. }
  35. },
  36. watch: {
  37. visible(newValue, oldValue) {
  38. if (newValue) {
  39. this.visiblehide = false;
  40. }
  41. },
  42. },
  43. methods: {
  44. //禁止触发后面移动
  45. moveHandle() {},
  46. rightBtnClick() {
  47. // this.visiblehide = true;
  48. this.$emit('rightClick');
  49. // this.$emit('update:visible', false)
  50. },
  51. close() {
  52. this.visiblehide = true;
  53. this.$emit('update:visible', false);
  54. },
  55. back() {
  56. this.visiblehide = true;
  57. this.$emit('beforeClose');
  58. this.$emit('update:visible', false)
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. @keyframes show {
  65. 0% {
  66. left: 100%;
  67. }
  68. 100% {
  69. left: 0;
  70. }
  71. }
  72. @keyframes hide {
  73. 0% {
  74. left: 0;
  75. }
  76. 100% {
  77. left: 100%;
  78. }
  79. }
  80. .z-slide-card {
  81. text-align: left !important;
  82. position: relative;
  83. .scroll-area {
  84. width: 100vw;
  85. height: 100vh;
  86. position: fixed;
  87. // overflow-y: scroll;
  88. background: white;
  89. z-index: 501;
  90. left: 100%;
  91. top: 0;
  92. }
  93. .animate_show {
  94. animation: show .5s;
  95. animation-fill-mode: forwards;
  96. }
  97. .animate_hide {
  98. animation: hide .5s;
  99. animation-fill-mode: forwards;
  100. }
  101. .scroll-content {
  102. height: calc(100% - 98rpx);
  103. position: relative;
  104. }
  105. }
  106. .top_bar {
  107. height: 98rpx;
  108. background: #354054;
  109. color: white;
  110. font-size: 36rpx;
  111. .go_back {
  112. color: white;
  113. width: 30rpx;
  114. font-size: 30rpx;
  115. height: 30rpx;
  116. }
  117. .rightbtn {
  118. font-size: 28rpx;
  119. }
  120. }
  121. </style>