graceBottomDialog.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view class="grace-btdialog-shade" v-if="realShow" @tap.stop="closeDialog" @touchmove.stop.prevent="stopFun"
  3. :style="{backgroundColor:background, zIndex:zIndex}">
  4. <view :class="['dialog', 'gdIn', isIpx ? 'grace-ipx-bottom' : '', isOut ? 'gdOut' : '']"
  5. :style="{width:width,left:left,borderTopLeftRadius:borderRadius,borderTopRightRadius:borderRadius}"
  6. @tap.stop="stopFun">
  7. <view><slot name="btns"></slot></view>
  8. <view @tap.stop="stopFun"><slot name="content"></slot></view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. width:{type:String,default:'750rpx'},
  16. left:{type:String,default:'0rpx'},
  17. show : {type : Boolean,default : false},
  18. background:{type : String,default : 'rgba(0, 0, 0, 0.5)'},
  19. borderRadius : {type : String,default : '0rpx'},
  20. zIndex:{type : Number,default : 99}
  21. },
  22. data() {
  23. return {
  24. realShow:false,
  25. isIpx:false,
  26. isOut : false
  27. }
  28. },
  29. watch:{
  30. show : function (vn, vo) {
  31. if(vn){
  32. this.realShow = vn;
  33. }else{
  34. this.isOut = true;
  35. setTimeout(()=>{this.realShow = false;}, 120);
  36. setTimeout(()=>{this.isOut = false;}, 150);
  37. }
  38. }
  39. },
  40. created : function(){
  41. this.realShow = this.show;
  42. // #ifndef APP-PLUS
  43. try {
  44. var res = uni.getSystemInfoSync();
  45. res.model = res.model.replace(' ', '');
  46. res.model = res.model.toLowerCase();
  47. if(res.model.indexOf('iphonex') != -1 || res.model.indexOf('iphone11') != -1){
  48. this.isIpx = true;
  49. }
  50. } catch (e){return null;}
  51. // #endif
  52. },
  53. methods:{
  54. closeDialog : function(){
  55. this.$emit('closeDialog');
  56. },
  57. stopFun : function(){}
  58. }
  59. }
  60. </script>
  61. <style scoped>
  62. @keyframes gdIn{ from {bottom:-1000px; } 100% { bottom: 0px; }}
  63. .gdIn {animation:gdIn 200ms ease-in forwards;}
  64. @keyframes gdOut{ from {bottom:0px;} 100% { bottom:-1000px; }}
  65. .gdOut {animation:gdOut 200ms ease-out forwards;}
  66. .grace-btdialog-shade{position:fixed; width:100%; height:100%; left:0; top:0; z-index:9; background:rgba(0, 0, 0, 0.5);}
  67. .grace-btdialog-shade .dialog{width:100%; height:auto; background:#FFFFFF; position:absolute; bottom:0; left:0;}
  68. .grace-ipx-bottom{padding-bottom:50rpx !important;}
  69. </style>