a.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. modal = new Vue({
  2. el: '#modal',
  3. data: {
  4. msg: '么有',
  5. title: '提示'
  6. },
  7. methods: {
  8. show: function(msg, title) {
  9. if (title) {
  10. this.title = title;
  11. }
  12. this.msg = msg;
  13. $('#mmodal').modal();
  14. }
  15. }
  16. })
  17. Vue.component('vue-easymde', VueEasyMDE.VueEasyMDE)
  18. app = new Vue({
  19. el: '#app',
  20. data: {
  21. text: null,
  22. enurl: null,
  23. showtg: false,// is show the tugong ICON
  24. tgstyle: [],
  25. },
  26. watch: {
  27. showtg: function(status) {
  28. status ? this.tgstyle = ['show'] : this.tgstyle = [];
  29. if (status) {
  30. setTimeout(function() {
  31. app.showtg = false;// 显示2秒自动关闭
  32. }, 2700);
  33. }
  34. }
  35. },
  36. methods: {
  37. getTempURL: function() {
  38. $('#enurl').loading({
  39. message: '加载中...',
  40. onStop: function(loading) {
  41. loading.overlay.fadeOut(650)
  42. }
  43. });
  44. axios.post('/api/get-temp', {
  45. text: app.text
  46. }).then(function(response) {
  47. $('#enurl').loading('stop');
  48. var data = response.data;
  49. if (data.status == 1) {
  50. var newURL = window.location.protocol + '//' + window.location.host + window.location.pathname;
  51. app.enurl = newURL + data.guid;
  52. } else {
  53. throw 'failure to get the tmp url!';
  54. modal.show('操作失败!<br>', '错误')
  55. }
  56. console.log(response);
  57. }).catch(function(error) {
  58. console.warn(error.response);
  59. $('#enurl').loading('stop');
  60. modal.show('操作失败!<br>' + error.response.data.message, '错误')
  61. })
  62. }
  63. }
  64. })