forked from nsjcy/frontEnd/nsjcy

LAPTOP-RI7D261L\Mr Ke
2020-02-13 a2789abb73725738127b03d95c95081b66954916
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"use strict";
var _baseComponent = _interopRequireDefault(require("../helpers/baseComponent")),
  _classNames2 = _interopRequireDefault(require("../helpers/classNames"));
 
const app = getApp();
 
function _interopRequireDefault(e) {
  return e && e.__esModule ? e : {
    default: e
  }
}
 
function ownKeys(t, e) {
  var n = Object.keys(t);
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(t);
    e && (o = o.filter(function(e) {
      return Object.getOwnPropertyDescriptor(t, e).enumerable
    })), n.push.apply(n, o)
  }
  return n
}
 
function _objectSpread(t) {
  for (var e = 1; e < arguments.length; e++) {
    var n = null != arguments[e] ? arguments[e] : {};
    e % 2 ? ownKeys(n, !0).forEach(function(e) {
      _defineProperty(t, e, n[e])
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : ownKeys(n).forEach(function(e) {
      Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e))
    })
  }
  return t
}
 
function _defineProperty(e, t, n) {
  return t in e ? Object.defineProperty(e, t, {
    value: n,
    enumerable: !0,
    configurable: !0,
    writable: !0,
  }) : e[t] = n, e
}
var defaults = {
    prefixCls: "wux-toptips",
    classNames: "wux-animate--slideInDown",
    icon: "cancel",
    hidden: !1,
    text: "",
    duration: 3e3,
    top: app.globalData.CustomBar,
    success: function() {}
  },
  _toptips = null;
(0, _baseComponent.default)({
  useFunc: !0,
  data: defaults,
  computed: {
    classes: ["prefixCls, icon", function(e, t) {
      var n = t || "cancel";
      return {
        wrap: (0, _classNames2.default)(e),
        content: (0, _classNames2.default)("".concat(e, "__content"), _defineProperty({}, "".concat(e, "__content--").concat(n), n)),
        icon: "".concat(e, "__icon")
      }
    }]
  },
  methods: {
    hide: function() {
      if (this.removed) return !1;
      this.removed = !0, _toptips && (clearTimeout(_toptips.timeout), _toptips = null), this.$$setData({ in: !1
      }), "function" == typeof this.fns.success && this.fns.success()
    },
    show: function(e) {
      function t() {
        _toptips && _toptips.hide.call(n)
      }
      var n = this,
        o = 0 < arguments.length && void 0 !== e ? e : {},
        r = new Promise(function(e) {
          var t = n.$$mergeOptionsAndBindMethods(Object.assign({}, defaults, o));
          n.removed = !1, n.$$setData(_objectSpread({ in: !0
          }, t)), _toptips && (clearTimeout(_toptips.timeout), _toptips = null), (_toptips = {
            hide: n.hide
          }).timeout = setTimeout(function() {
            return n.hide(), e(!0)
          }, t.duration)
        });
      return t.then = function(e, t) {
        return r.then(e, t)
      }, t.promise = r, t
    },
    success: function(e) {
      var t = 0 < arguments.length && void 0 !== e ? e : {};
      return this.show(Object.assign({
        icon: "success"
      }, t))
    },
    info: function(e) {
      var t = 0 < arguments.length && void 0 !== e ? e : {};
      return this.show(Object.assign({
        icon: "info"
      }, t))
    },
    warn: function(e) {
      var t = 0 < arguments.length && void 0 !== e ? e : {};
      return this.show(Object.assign({
        icon: "warn"
      }, t))
    },
    error: function(e) {
      var t = 0 < arguments.length && void 0 !== e ? e : {};
      return this.show(Object.assign({
        icon: "cancel"
      }, t))
    }
  }
});