gui-action-sheet.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <gui-popup
  3. ref="guipopupforacsheet"
  4. position="bottom"
  5. :zIndex="zIndex"
  6. :isSwitchPage="true"
  7. :canCloseByShade="canCloseByShade">
  8. <view
  9. :style="{
  10. 'margin-bottom':'25rpx',
  11. 'margin-left':((750-width)/2)+'rpx'
  12. }"
  13. @tap.stop.prevent="stopfun">
  14. <view
  15. class="gui-bg-white gui-dark-bg-level-3"
  16. :style="{
  17. width:width+'rpx',
  18. borderRadius:borderRadius
  19. }">
  20. <text
  21. v-if="title != ''"
  22. class="gui-action-sheet-title gui-block-text gui-border-b"
  23. :class="titleClass">{{title}}</text>
  24. <scroll-view
  25. scroll-y="true"
  26. class="gui-border-box"
  27. :style="{
  28. width:width+'rpx',
  29. height:height+'rpx'
  30. }">
  31. <text
  32. class="gui-text-center gui-block gui-border-b gui-primary-text"
  33. :class="listClass"
  34. v-for="(item, index) in items"
  35. :key="index"
  36. @tap.stop="selected"
  37. :data-index="index">{{item}}</text>
  38. </scroll-view>
  39. <text
  40. class="gui-text-center gui-block gui-color-gray"
  41. :class="listClass"
  42. v-if="isCancelBtn"
  43. @tap.stop="cancel">{{cancelBtnName}}</text>
  44. </view>
  45. </view>
  46. </gui-popup>
  47. </template>
  48. <script>
  49. export default{
  50. name : "gui-action-sheet",
  51. props : {
  52. width : { type : Number, default : 680},
  53. height : { type : Number, default : 500},
  54. borderRadius : { type : String, default : '10rpx'},
  55. title : { type : String, default : ''},
  56. titleClass : { type : Array, default : function(){return ['gui-color-gray'];}},
  57. items : { type : Array, default : function(){return [];}},
  58. listClass : { type : Array, default : function(){return ['gui-primary-text', 'gui-action-sheet-item'];}},
  59. isCancelBtn : { type : Boolean, default : true},
  60. cancelBtnName : { type : String, default : '取消'},
  61. canCloseByShade : { type : Boolean, default : false},
  62. zIndex : { type : Number, default : 999}
  63. },
  64. methods:{
  65. open : function(){
  66. this.$refs.guipopupforacsheet.open();
  67. this.$emit('open');
  68. },
  69. close : function(){
  70. this.$refs.guipopupforacsheet.close();
  71. this.$emit('close');
  72. },
  73. stopfun : function(e){
  74. e.stopPropagation();
  75. return null;
  76. },
  77. cancel : function () {
  78. this.$emit('cancel');
  79. this.close();
  80. },
  81. selected:function (e) {
  82. this.$emit('selected', e.currentTarget.dataset.index);
  83. this.close();
  84. },
  85. },
  86. emits : ['open', 'close', 'selected', 'cancel']
  87. }
  88. </script>
  89. <style scoped>
  90. </style>