util.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //全局函数/变量
  2. export default{
  3. install(Vue,options)
  4. {
  5. Vue.prototype.getData = function () {
  6. console.log('我是插件中的方法');
  7. }
  8. //Vue.prototype.DocConfig = {
  9. // "server":'http://127.0.0.1/showdoc.cc/server/index.php?s=',
  10. //"server":'../server/index.php?s=',
  11. //}
  12. Vue.prototype.request = function(){
  13. }
  14. Vue.prototype.getRootPath = function(){
  15. return window.location.protocol +'//' +window.location.host + window.location.pathname
  16. }
  17. /*判断是否是移动设备*/
  18. Vue.prototype.isMobile = function (){
  19. return navigator.userAgent.match(/iPhone|iPad|iPod|Android|android|BlackBerry|IEMobile/i) ? true : false;
  20. }
  21. Vue.prototype.get_user_info = function(callback){
  22. var that = this ;
  23. var url = DocConfig.server+'/api/user/info';
  24. var params = new URLSearchParams();
  25. params.append('redirect_login', false);
  26. that.axios.post(url, params)
  27. .then(function (response) {
  28. if (callback) {callback(response);};
  29. });
  30. }
  31. Vue.prototype.get_notice = function(callback){
  32. var that = this ;
  33. var url = DocConfig.server+'/api/notice/getList';
  34. var params = new URLSearchParams();
  35. params.append('notice_type', 'unread');
  36. params.append('count', '1');
  37. that.axios.post(url, params)
  38. .then(function (response) {
  39. if (callback) {callback(response);};
  40. });
  41. }
  42. }
  43. }