app.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. const app = {
  2. baseUrl: "http://www.tianyunperfect.cn:3000/mock/75",
  3. // baseUrl: "http://127.0.0.1:8089",
  4. };
  5. Date.prototype.format = function (fmt) {
  6. var o = {
  7. "M+": this.getMonth() + 1, //月份
  8. "d+": this.getDate(), //日
  9. "h+": this.getHours(), //小时
  10. "m+": this.getMinutes(), //分
  11. "s+": this.getSeconds(), //秒
  12. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  13. "S": this.getMilliseconds() //毫秒
  14. };
  15. if (/(y+)/.test(fmt)) {
  16. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  17. }
  18. for (var k in o) {
  19. if (new RegExp("(" + k + ")").test(fmt)) {
  20. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  21. }
  22. }
  23. return fmt;
  24. };
  25. // 添加响应拦截器
  26. axios.interceptors.response.use(function (response) {
  27. // 对响应数据做点什么
  28. return response.data;
  29. }, function (error) {
  30. // 对响应错误做点什么
  31. return Promise.reject(error);
  32. });