index.vue 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <uni-shadow-root class="vant-share-sheet-index"><van-popup round class="van-share-sheet" :show="show" position="bottom" :overlay="overlay" :duration="duration" :z-index="zIndex" :overlay-style="overlayStyle" :close-on-click-overlay="closeOnClickOverlay" :safe-area-inset-bottom="safeAreaInsetBottom" :root-portal="rootPortal" @close="onClose" @click-overlay="onClickOverlay">
  3. <view class="van-share-sheet__header">
  4. <view class="van-share-sheet__title">
  5. <slot name="title"></slot>
  6. </view>
  7. <view v-if="title" class="van-share-sheet__title">{{ title }}</view>
  8. <view class="van-share-sheet__description">
  9. <slot name="description"></slot>
  10. </view>
  11. <view v-if="description" class="van-share-sheet__description">
  12. {{ description }}
  13. </view>
  14. </view>
  15. <block v-if="computed.isMulti(options)">
  16. <options v-for="(item,index) in (options)" :key="item.index" :show-border="index !== 0" :options="item" @select="onSelect"></options>
  17. </block>
  18. <options v-else :options="options" @select="onSelect"></options>
  19. <button type="button" class="van-share-sheet__cancel" @click="onCancel">
  20. {{ cancelText }}
  21. </button>
  22. </van-popup></uni-shadow-root>
  23. </template>
  24. <wxs src="./index.wxs" module="computed"></wxs>
  25. <script>
  26. import VanPopup from '../popup/index.vue'
  27. import Options from './options.vue'
  28. global['__wxVueOptions'] = {components:{'van-popup': VanPopup,'options': Options}}
  29. global['__wxRoute'] = 'vant/share-sheet/index'
  30. import { VantComponent } from '../common/component';
  31. VantComponent({
  32. props: {
  33. // whether to show popup
  34. show: Boolean,
  35. // overlay custom style
  36. overlayStyle: String,
  37. // z-index
  38. zIndex: {
  39. type: Number,
  40. value: 100,
  41. },
  42. title: String,
  43. cancelText: {
  44. type: String,
  45. value: '取消',
  46. },
  47. description: String,
  48. options: {
  49. type: Array,
  50. value: [],
  51. },
  52. overlay: {
  53. type: Boolean,
  54. value: true,
  55. },
  56. safeAreaInsetBottom: {
  57. type: Boolean,
  58. value: true,
  59. },
  60. closeOnClickOverlay: {
  61. type: Boolean,
  62. value: true,
  63. },
  64. duration: {
  65. type: null,
  66. value: 300,
  67. },
  68. rootPortal: {
  69. type: Boolean,
  70. value: false,
  71. },
  72. },
  73. methods: {
  74. onClickOverlay() {
  75. this.$emit('click-overlay');
  76. },
  77. onCancel() {
  78. this.onClose();
  79. this.$emit('cancel');
  80. },
  81. onSelect(event) {
  82. this.$emit('select', event.detail);
  83. },
  84. onClose() {
  85. this.$emit('close');
  86. },
  87. },
  88. });
  89. export default global['__wxComponents']['vant/share-sheet/index']
  90. </script>
  91. <style platform="mp-weixin">
  92. @import '../common/index.css';.van-share-sheet__header{padding:12px 16px 4px;text-align:center}.van-share-sheet__title{color:#323233;font-size:14px;font-weight:400;line-height:20px;margin-top:8px}.van-share-sheet__title:empty,.van-share-sheet__title:not(:empty)+.van-share-sheet__title{display:none}.van-share-sheet__description{color:#969799;display:block;font-size:12px;line-height:16px;margin-top:8px}.van-share-sheet__description:empty,.van-share-sheet__description:not(:empty)+.van-share-sheet__description{display:none}.van-share-sheet__cancel{background:#fff;border:none;box-sizing:initial;display:block;font-size:16px;height:auto;line-height:48px;padding:0;text-align:center;width:100%}.van-share-sheet__cancel:before{background-color:#f7f8fa;content:" ";display:block;height:8px}.van-share-sheet__cancel:after{display:none}.van-share-sheet__cancel:active{background-color:#f2f3f5}
  93. </style>