index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. var _page = _interopRequireDefault(require("../../common/page"));
  3. var _toast = _interopRequireDefault(require("../../dist/toast/toast"));
  4. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5. (0, _page["default"])({
  6. showToast: function showToast() {
  7. (0, _toast["default"])("提示内容");
  8. },
  9. showLongToast: function showLongToast() {
  10. (0, _toast["default"])("这是一条长文字提示,超过一定字数就会换行");
  11. },
  12. showLoadingToast: function showLoadingToast() {
  13. _toast["default"].loading({
  14. message: "加载中...",
  15. forbidClick: true
  16. });
  17. },
  18. showCustomLoadingToast: function showCustomLoadingToast() {
  19. _toast["default"].loading({
  20. message: "加载中...",
  21. forbidClick: true,
  22. loadingType: "spinner"
  23. });
  24. },
  25. showSuccessToast: function showSuccessToast() {
  26. _toast["default"].success("成功文案");
  27. },
  28. showFailToast: function showFailToast() {
  29. _toast["default"].fail("失败提示");
  30. },
  31. showCustomizedToast: function showCustomizedToast() {
  32. var text = function text(second) {
  33. return "\u5012\u8BA1\u65F6 ".concat(second, " \u79D2");
  34. };
  35. var toast = _toast["default"].loading({
  36. duration: 0,
  37. forbidClick: true,
  38. message: text(3)
  39. });
  40. var second = 3;
  41. var timer = setInterval(function () {
  42. second--;
  43. if (second) {
  44. toast.setData({
  45. message: text(second)
  46. });
  47. } else {
  48. clearInterval(timer);
  49. _toast["default"].clear();
  50. }
  51. }, 1000);
  52. }
  53. });