graceNvueActionSheet.vue 2.6 KB

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