a.js 1.4 KB

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