graceHeaderAlert.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template name="graceHeaderAlert">
  2. <view :class="[show ? 'ganimate-show grace-alert' : 'grace-alert']" :style="{background:background, top : topReal + 'px'}" v-if="showIn">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. name: "graceHeaderAlert",
  9. props: {
  10. show : {
  11. type : Boolean,
  12. default : false
  13. },
  14. background : {
  15. type : String,
  16. default : '#F1F2F3'
  17. },
  18. top:{
  19. type : Number,
  20. default: 5
  21. }
  22. },
  23. data() {
  24. return {
  25. showIn : false,
  26. topReal : 0
  27. }
  28. },
  29. created:function(){
  30. this.topReal = this.top;
  31. // #ifdef H5
  32. this.topReal += 46;
  33. // #endif
  34. },
  35. watch: {
  36. show : function(n , o){
  37. this.showIn = true;
  38. setTimeout(function(){this.showIn = false}.bind(this), 2000);
  39. }
  40. }
  41. }
  42. </script>
  43. <style scoped>
  44. @keyframes g-show{from {opacity:0; transform:scale3d(0.1, 0.1, 0.1);} to {opacity:1;}}
  45. .ganimate-show{animation:g-show 200ms linear;}
  46. .grace-alert{display:flex; width:580rpx; padding:25rpx; border-radius:10rpx; flex-wrap:nowrap; justify-content:center; align-items:center; background:#FFF; position:fixed; z-index:99999; left:60rpx; top:50px;}
  47. .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);}
  48. </style>