graceActionSheet.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="graceActionSheet" @tap.stop="closeByShade" @touchmove.stop.prevent="stopFun"
  3. :style="{backgroundColor:background, zIndex:zIndex, width:realShow ? '750rpx' : '0rpx'}">
  4. <view :class="['graceActionSheetBody', isIpx ? 'grace-ipx-bottom' : '']"
  5. :style="{
  6. width:realShow?width:'0rpx',left:left,
  7. borderTopLeftRadius:borderRadius,
  8. borderTopRightRadius:borderRadius,
  9. zIndex:zIndex+1}"
  10. @tap.stop="stopFun">
  11. <view class="graceActionSheetTitle" :style="{color:titleColor}">{{title}}</view>
  12. <scroll-view scroll-y :style="{height:height}">
  13. <view class="graceActionSheetList"
  14. v-for="(item, index) in items" :key="index"
  15. @tap.stop="selected" :data-index="index"
  16. :style="{
  17. color:listColor,
  18. lineHeight:listLineHeight,
  19. fontSize:listFontSize}">{{item}}</view>
  20. </scroll-view>
  21. <view class="graceActionSheetList" :style="{border:'none', color:cancelBtnColor}" v-if="isCancelBtn" @tap.stop="cancel">{{cancelBtnName}}</view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. props: {
  28. width:{type:String,default:'720rpx'},
  29. height:{type:String,default:'500rpx'},
  30. left:{type:String,default:'15rpx'},
  31. background:{type : String,default : 'rgba(0, 0, 0, 0.3)'},
  32. borderRadius : {type : String,default : '10rpx'},
  33. zIndex:{type : Number,default : 99},
  34. title:{type:String,default:''},
  35. titleColor:{type:String, default:'#323232'},
  36. items:{type:Array, default:function(){return [];}},
  37. listColor:{type:String, default:'#3688FF'},
  38. listLineHeight:{type:String, default:'100rpx'},
  39. listFontSize:{type:String, default:'30rpx'},
  40. isCancelBtn:{type:Boolean, default:true},
  41. cancelBtnName:{type:String,default:'取消'},
  42. cancelBtnColor:{type:String, default:'#999999'}
  43. },
  44. data() {
  45. return {
  46. realShow : false,
  47. isIpx:false
  48. }
  49. },
  50. created : function(){
  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. cancel:function(){
  64. this.realShow = false;
  65. this.$emit('cancel')
  66. },
  67. closeByShade: function(){this.cancel();},
  68. stopFun : function(){},
  69. selected:function (e) {
  70. this.$emit('selected', e.currentTarget.dataset.index);
  71. this.close();
  72. },
  73. close:function(){this.realShow = false;},
  74. show:function(){this.realShow = true;}
  75. }
  76. }
  77. </script>
  78. <style scoped>
  79. .graceActionSheet{position:fixed; width:100%; height:100%; left:0; top:0;}
  80. .graceActionSheetBody{background:#FFFFFF; position:absolute; bottom:0; left:0; overflow:hidden;}
  81. .graceActionSheetTitle{text-align:center; font-size:26rpx; line-height:120rpx; height:120rpx; font-weight:bold; border-bottom:1px solid #F8F8F8;}
  82. .grace-ipx-bottom{padding-bottom:50rpx !important;}
  83. .graceActionSheetList{line-height:120rpx; font-weight:600; overflow:hidden; text-align:center; margin:0 30rpx; border-bottom:1px solid #F8F8F8;}
  84. </style>