index.js 1.44 KB
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),r.forEach(function(t){_defineProperty(e,t,o[t])})}return e}function _defineProperty(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function formatParameter(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return"object"===_typeof(t)?t:{title:t,timeout:e}}module.exports={showZanToast:function(t,e){var o=this,r=formatParameter(t,e),n=(this.data.zanToast||{}).timer;clearTimeout(void 0===n?0:n);var a={show:!0,icon:r.icon,image:r.image,title:r.title,success:r.success};if(this.setData({zanToast:a}),!(e<0)){var i=setTimeout(function(){a.success(),o.clearZanToast()},e||3e3);this.setData({"zanToast.timer":i})}},clearZanToast:function(){var t=(this.data.zanToast||{}).timer;clearTimeout(void 0===t?0:t),this.setData({"zanToast.show":!1})},showZanLoading:function(t){var e=formatParameter(t);this.showZanToast(_objectSpread({},e,{icon:"loading"}))}};