index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <uni-shadow-root class="weapp-lib-notify-index"><van-transition name="slide-down" :show="show" custom-class="van-notify__container" :custom-style="computed.rootStyle({ zIndex, top })" @click.native="onTap">
  3. <view :class="'van-notify van-notify--'+(type)" :style="computed.notifyStyle({ background, color })">
  4. <view v-if="safeAreaInsetTop" :style="'height: '+(statusBarHeight)+'px'"></view>
  5. <text>{{ message }}</text>
  6. </view>
  7. </van-transition></uni-shadow-root>
  8. </template>
  9. <wxs src="../wxs/utils.wxs" module="utils"></wxs><wxs src="./index.wxs" module="computed"></wxs>
  10. <script>
  11. import VanTransition from '../transition/index.vue'
  12. global['__wxVueOptions'] = {components:{'van-transition': VanTransition}}
  13. global['__wxRoute'] = 'weapp/lib/notify/index'
  14. "use strict";
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var component_1 = require("../common/component");
  17. var color_1 = require("../common/color");
  18. var utils_1 = require("../common/utils");
  19. (0, component_1.VantComponent)({
  20. props: {
  21. message: String,
  22. background: String,
  23. type: {
  24. type: String,
  25. value: 'danger',
  26. },
  27. color: {
  28. type: String,
  29. value: color_1.WHITE,
  30. },
  31. duration: {
  32. type: Number,
  33. value: 3000,
  34. },
  35. zIndex: {
  36. type: Number,
  37. value: 110,
  38. },
  39. safeAreaInsetTop: {
  40. type: Boolean,
  41. value: false,
  42. },
  43. top: null,
  44. },
  45. data: {
  46. show: false,
  47. onOpened: null,
  48. onClose: null,
  49. onClick: null,
  50. },
  51. created: function () {
  52. var statusBarHeight = (0, utils_1.getSystemInfoSync)().statusBarHeight;
  53. this.setData({ statusBarHeight: statusBarHeight });
  54. },
  55. methods: {
  56. show: function () {
  57. var _this = this;
  58. var _a = this.data, duration = _a.duration, onOpened = _a.onOpened;
  59. clearTimeout(this.timer);
  60. this.setData({ show: true });
  61. wx.nextTick(onOpened);
  62. if (duration > 0 && duration !== Infinity) {
  63. this.timer = setTimeout(function () {
  64. _this.hide();
  65. }, duration);
  66. }
  67. },
  68. hide: function () {
  69. var onClose = this.data.onClose;
  70. clearTimeout(this.timer);
  71. this.setData({ show: false });
  72. wx.nextTick(onClose);
  73. },
  74. onTap: function (event) {
  75. var onClick = this.data.onClick;
  76. if (onClick) {
  77. onClick(event.detail);
  78. }
  79. },
  80. },
  81. });
  82. export default global['__wxComponents']['weapp/lib/notify/index']
  83. </script>
  84. <style platform="mp-weixin">
  85. @import '../common/index.css';.van-notify{word-wrap:break-word;font-size:var(--notify-font-size,14px);line-height:var(--notify-line-height,20px);padding:var(--notify-padding,6px 15px);text-align:center}.van-notify__container{box-sizing:border-box;left:0;position:fixed;top:0;width:100%}.van-notify--primary{background-color:var(--notify-primary-background-color,#1989fa)}.van-notify--success{background-color:var(--notify-success-background-color,#07c160)}.van-notify--danger{background-color:var(--notify-danger-background-color,#ee0a24)}.van-notify--warning{background-color:var(--notify-warning-background-color,#ff976a)}
  86. </style>