graceBottomDialog.vue 2.1 KB

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