Alert.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <popup ref="Message" :show="show">
  3. <div class="ui-message ui-message-alert" :class="{'message-material':isMaterial,'message-mobile':isMobile}">
  4. <div class="ui-message-header" :class="{'header-material':isMaterial}">
  5. <span>{{title}}</span>
  6. <span @click="onClose">
  7. <i class="iconfont icon_close"></i>
  8. </span>
  9. </div>
  10. <div class="ui-message-main" :class="{'main-material':isMaterial}">
  11. <div class="ui-message-icon" :class="[icon?icon:null]"></div>
  12. <div class="ui-message-title">{{tips}}</div>
  13. <div class="ui-message-content" v-html="content"></div>
  14. </div>
  15. <div class="ui-message-footer" :class="{'footer-material':isMaterial}">
  16. <button class="ui-button submit" @click="onOk">{{okText}}</button>
  17. </div>
  18. </div>
  19. </popup>
  20. </template>
  21. <script>
  22. import {i18n} from "@/lang"
  23. import Popup from "../popup";
  24. import config from '@/config'
  25. export default {
  26. name: "ui-alert",
  27. components: {
  28. Popup
  29. },
  30. data() {
  31. return {
  32. isMaterial: window.location.pathname.indexOf('material.html')>-1,
  33. isMobile:config.isMobile(),
  34. show: false,
  35. forceOK:false,
  36. duration: 0,
  37. title: i18n.t("tips.title"),
  38. icon: null,
  39. tips: "",
  40. content: "",
  41. okText: i18n.t("common.set"),
  42. ok: null
  43. };
  44. },
  45. methods: {
  46. onOk() {
  47. if (this.ok && this.ok(this) === false) {
  48. return;
  49. }
  50. setTimeout(() => {
  51. this.show = false;
  52. document.body.removeChild(this.$el);
  53. this.$destroy();
  54. }, this.duration);
  55. },
  56. onClose() {
  57. this.forceOK && (this.ok && this.ok(this) === false)
  58. setTimeout(() => {
  59. this.show = false;
  60. document.body.removeChild(this.$el);
  61. this.$destroy();
  62. }, this.duration);
  63. }
  64. }
  65. };
  66. </script>