graceHeaderAlert.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template name="graceHeaderAlert">
  2. <view :class="['grace-alert',showIn ? 'ganimate-show' : 'ganimate-hide']"
  3. :style="{background:background, top : topReal + 'px', width:width+'rpx', left:((750-width)/2)+'rpx'}" v-if="showIn">
  4. <slot></slot>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. name: "graceHeaderAlert",
  10. props: {
  11. show : { type : Boolean, default : false },
  12. background : { type : String, default : '#F1F2F3' },
  13. top : { type : Number, default : 20 },
  14. width : { type : Number, default : 580},
  15. duration : { type : Number, default : 2500}
  16. },
  17. data() {
  18. return {
  19. showIn : false,
  20. topReal : 0
  21. }
  22. },
  23. created:function(){
  24. this.topReal = this.top;
  25. // #ifdef H5
  26. this.topReal += 46;
  27. // #endif
  28. this.showIn = this.show;
  29. },
  30. watch: {
  31. show : function(n , o){
  32. if(n){
  33. this.showIn = n;
  34. setTimeout(()=>{this.showIn = false;}, this.duration);
  35. }
  36. }
  37. },
  38. methods:{
  39. open:function(){
  40. this.showIn = true;
  41. setTimeout(()=>{this.showIn = false;}, this.duration);
  42. },
  43. close:function(){
  44. this.showIn = false;
  45. }
  46. }
  47. }
  48. </script>
  49. <style scoped>
  50. @keyframes g-show{from {opacity:0; transform:scale3d(0.1, 0.1, 0.1);} to {opacity:1; transform:scale3d(1, 1, 1);}}
  51. .ganimate-show{animation:g-show 250ms linear;}
  52. .grace-alert{display:flex; box-sizing:border-box; padding:25rpx; border-radius:10rpx; flex-wrap:nowrap; justify-content:center; align-items:center; background:#FFF; position:fixed; z-index:99999; top:50px;}
  53. .grace-alert::before{content:""; display:block; background:inherit; filter:blur(6rpx); position:absolute; width:100%; height:100%; top:8rpx; left:8rpx; z-index:-1; opacity:0.38; transform-origin:0 0; border-radius:inherit; transform:scale(1, 1);}
  54. </style>