graceNvueActionSheet.vue 2.8 KB

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