index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. var _page = _interopRequireDefault(require("../../common/page"));
  3. var _dialog = _interopRequireDefault(require("../../dist/dialog/dialog"));
  4. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5. var message = "代码是写出来给人看的,附带能在机器上运行";
  6. (0, _page["default"])({
  7. data: {
  8. show: false
  9. },
  10. showCustomDialog: function showCustomDialog() {
  11. this.setData({
  12. show: true
  13. });
  14. },
  15. getUserInfo: function getUserInfo(event) {
  16. console.log(event.detail);
  17. },
  18. onClickThemeAlert: function onClickThemeAlert() {
  19. _dialog["default"].alert({
  20. title: "标题",
  21. theme: "round-button",
  22. message: message
  23. });
  24. },
  25. onClickThemeAlert2: function onClickThemeAlert2() {
  26. _dialog["default"].alert({
  27. theme: "round-button",
  28. message: message
  29. });
  30. },
  31. onClickAlert: function onClickAlert() {
  32. _dialog["default"].alert({
  33. title: "标题",
  34. message: message
  35. });
  36. },
  37. onClickAlert2: function onClickAlert2() {
  38. _dialog["default"].alert({
  39. message: message
  40. });
  41. },
  42. onClickConfirm: function onClickConfirm() {
  43. _dialog["default"].confirm({
  44. title: "标题",
  45. message: message
  46. });
  47. },
  48. onClickAsyncClose: function onClickAsyncClose() {
  49. var beforeClose = function beforeClose(action) {
  50. return new Promise(function (resolve) {
  51. setTimeout(function () {
  52. if (action === "confirm") {
  53. resolve(true);
  54. } else {
  55. // 拦截取消操作
  56. resolve(false);
  57. }
  58. }, 1000);
  59. });
  60. };
  61. _dialog["default"].confirm({
  62. title: "标题",
  63. message: message,
  64. beforeClose: beforeClose
  65. });
  66. },
  67. onClose: function onClose() {
  68. this.setData({
  69. show: false
  70. });
  71. }
  72. });