z-slide-card.vue 2.2 KB

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