a.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. easyMDEOpts: {
  24. sideBySideFullscreen: false,
  25. renderingConfig: { codeSyntaxHighlighting: true },
  26. },
  27. },
  28. methods: {
  29. getTempURL: function() {
  30. $('#enurl').loading({
  31. message: '加载中...',
  32. onStop: function(loading) {
  33. loading.overlay.fadeOut(650)
  34. }
  35. });
  36. axios.post('/api/get-temp', {
  37. text: app.text
  38. }).then(function(response) {
  39. $('#enurl').loading('stop');
  40. var data = response.data;
  41. if (data.status == 1) {
  42. var newURL = window.location.protocol + '//' + window.location.host + window.location.pathname;
  43. app.enurl = newURL + data.guid;
  44. } else {
  45. throw 'failure to get the tmp url!';
  46. modal.show('操作失败!<br>', '错误')
  47. }
  48. console.log(response);
  49. }).catch(function(error) {
  50. console.warn(error.response);
  51. $('#enurl').loading('stop');
  52. modal.show('操作失败!<br>' + error.response.data.message, '错误')
  53. })
  54. }
  55. }
  56. })