z-slide.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="z-slide" :class="visible?'mask':'mask1'" @click.self="close">
  3. <view class="slidecard shadow-2" :animation="animationData">
  4. <view class="slidecard_top flex-n fjb">
  5. <view class="slidecard_title">{{title}}</view>
  6. <view class="slidecard_close" @click="close">×</view>
  7. </view>
  8. <view class="slidecard_content">
  9. <slot></slot>
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default{
  16. name:'z-slide',
  17. props:{
  18. title:{
  19. type:String,
  20. default:'数据筛选'
  21. },
  22. visible:Boolean
  23. },
  24. data(){
  25. return{
  26. animationData: {},
  27. }
  28. },
  29. watch:{
  30. visible(newval,oldval){
  31. if(newval){
  32. this.open();
  33. }
  34. }
  35. },
  36. methods:{
  37. open(){
  38. var animation = uni.createAnimation({
  39. duration: 500,
  40. timingFunction: 'ease',
  41. })
  42. animation.right('0').step();
  43. this.animationData = animation.export();
  44. },
  45. close(){
  46. var animation = uni.createAnimation({
  47. duration: 500,
  48. timingFunction: 'ease',
  49. })
  50. animation.right('-80vw').step();
  51. this.animationData = animation.export();
  52. setTimeout(()=>{
  53. this.$emit('update:visible', false);
  54. },500)
  55. }
  56. }
  57. }
  58. </script>
  59. <style scoped lang="scss">
  60. .mask1{
  61. // width: 0;
  62. // height: 0;
  63. // z-index: 600;
  64. }
  65. .mask{
  66. background: rgba(0,0,0,0.1);
  67. position: fixed;
  68. width: 100vw;
  69. height: 100vh;
  70. top: 0;
  71. left: 0;
  72. z-index: 600;
  73. }
  74. .z-slide{
  75. .slidecard{
  76. width: 80vw;
  77. height: 100vh;
  78. position: fixed;
  79. right: -80vw;
  80. background: white;
  81. .slidecard_top{
  82. line-height: 100rpx;
  83. padding: 0 40rpx;
  84. .slidecard_title{
  85. font-size: 36rpx;
  86. color: #555555;
  87. font-weight: bold;
  88. }
  89. border-bottom: 1px solid #ccc;
  90. .slidecard_close{
  91. font-size: 80rpx;
  92. color: #ccc;
  93. }
  94. }
  95. }
  96. }
  97. </style>