index.vue 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <uni-shadow-root class="vant-dist-toast-index"><van-overlay v-if="mask || forbidClick" :show="show" :z-index="zIndex" :custom-style="mask ? '' : 'background-color: transparent;'"></van-overlay>
  3. <van-transition :show="show" :custom-style="'z-index: '+(zIndex)" custom-class="van-toast__container">
  4. <view :class="'van-toast van-toast--'+(type === 'text' ? 'text' : 'icon')+' van-toast--'+(position)" @touchmove.stop.prevent="noop">
  5. <text v-if="type === 'text'">{{ message }}</text>
  6. <block v-else>
  7. <van-loading v-if="type === 'loading'" color="white" :type="loadingType" custom-class="van-toast__loading"></van-loading>
  8. <van-icon v-else class="van-toast__icon" :name="type"></van-icon>
  9. <text v-if="message" class="van-toast__text">{{ message }}</text>
  10. </block>
  11. <slot></slot>
  12. </view>
  13. </van-transition></uni-shadow-root>
  14. </template>
  15. <script>
  16. import VanIcon from '../icon/index.vue'
  17. import VanLoading from '../loading/index.vue'
  18. import VanOverlay from '../overlay/index.vue'
  19. import VanTransition from '../transition/index.vue'
  20. global['__wxVueOptions'] = {components:{'van-icon': VanIcon,'van-loading': VanLoading,'van-overlay': VanOverlay,'van-transition': VanTransition}}
  21. global['__wxRoute'] = 'vant/dist/toast/index'
  22. import { VantComponent } from '../common/component';
  23. VantComponent({
  24. props: {
  25. show: Boolean,
  26. mask: Boolean,
  27. message: String,
  28. forbidClick: Boolean,
  29. zIndex: {
  30. type: Number,
  31. value: 1000,
  32. },
  33. type: {
  34. type: String,
  35. value: 'text',
  36. },
  37. loadingType: {
  38. type: String,
  39. value: 'circular',
  40. },
  41. position: {
  42. type: String,
  43. value: 'middle',
  44. },
  45. },
  46. methods: {
  47. // for prevent touchmove
  48. noop() { },
  49. },
  50. });
  51. export default global['__wxComponents']['vant/dist/toast/index']
  52. </script>
  53. <style platform="mp-weixin">
  54. @import '../common/index.css';.van-toast{display:flex;flex-direction:column;align-items:center;justify-content:center;box-sizing:initial;color:#fff;color:var(--toast-text-color,#fff);font-size:14px;font-size:var(--toast-font-size,14px);line-height:20px;line-height:var(--toast-line-height,20px);white-space:pre-wrap;word-wrap:break-word;background-color:rgba(0,0,0,.7);background-color:var(--toast-background-color,rgba(0,0,0,.7));border-radius:8px;border-radius:var(--toast-border-radius,8px)}.van-toast__container{position:fixed;top:50%;left:50%;width:-webkit-fit-content;width:fit-content;transform:translate(-50%,-50%);max-width:70%;max-width:var(--toast-max-width,70%)}.van-toast--text{min-width:96px;min-width:var(--toast-text-min-width,96px);padding:8px 12px;padding:var(--toast-text-padding,8px 12px)}.van-toast--icon{width:88px;width:var(--toast-default-width,88px);min-height:88px;min-height:var(--toast-default-min-height,88px);padding:16px;padding:var(--toast-default-padding,16px)}.van-toast--icon .van-toast__icon{font-size:36px;font-size:var(--toast-icon-size,36px)}.van-toast--icon .van-toast__text{padding-top:8px}.van-toast__loading{margin:10px 0}.van-toast--top{transform:translateY(-30vh)}.van-toast--bottom{transform:translateY(30vh)}
  55. </style>