PageSourceSearch

https://www.swufe.edu.cn/system/resource/vue/static/public.js

js swufe.edu.cn collected 2026-10-01 12:05:33 UTC 6,842 bytes, 214 lines download raw bytes

1Vue.config.devtools = "development";
2var MyPlugin = {};
3
4/**
5 * 错误码处理定义
6 */
7
8MyPlugin["filters"] = {
9    //异常
10    "9999" : function(result) {
11        layer.msg(result.msg, {icon: 0,time:2000});
12    },
13    //配置统一未登录错误码处理
14    "-1" : function(result) {
15        //未登录,跳转登陆页
16        top.window.location.href = fsConfig["global"]["loginUrl"];
17    }
18};
19
20/**
21 * 项目中需要调用到的常量、变量这里配置
22 */
23MyPlugin["global"] = {
24    "servletUrl":"", //使用网关请求地址,本地工程可以不填
25    "port":18201,
26    "token": sessionStorage.getItem("token"),//后台的token 
27    "appId": sessionStorage.getItem("appId"),
28    "result" : { //响应结果配置
29        "statusName": "code", //数据状态的字段名称,默认:errorNo
30        "msgName": "msg", //状态信息的字段名称,默认:errorInfo
31        "successNo" : "0000", //执行成功错误码统一配置
32        "dataName" : "data" //非表格数据的字段名称,默认:results.data
33    },
34    "page" : { //分页配置
35        "request": {//请求配置
36            "pageName": "current", //页码的参数名称,默认:pageNum
37            "limitName": "size" //每页数据量的参数名,默认:pageSize
38        },
39        "response": {//响应配置
40            "countName": "data.total", //数据总数的字段名称,默认:results.data.total
41            "dataNamePage": "data.records" //分页数据列表的字段名称,默认:results.data.list
42        },
43        "limit":10,//每页分页数量。默认20
44        "limits":[10,20,30,50,100]//每页数据选择项,默认[10,20,30,50,100]
45    }
46};
47
48
49MyPlugin.install = function (Vue, options) {
50    // 1. 添加全局方法或属性
51    Vue.myGlobalMethod = function () {
52      // 逻辑...
53    }
54  
55    //非空判断
56    Vue.isEmpty=function(value) {
57        if (value === null || value == undefined || value === '') {
58            return true;
59        }
60        return false;
61    }
62    //获取对象指
63    Vue.result=function(object, path, defaultValue) {
64        var value = "";
65        if(!$.isEmpty(object) && $.isObject(object) && !Vue.isEmpty(path)){
66            var paths = path.split('.');
67            var length = paths.length;
68            $.each(paths,function(i,v){
69                object = object[v];
70                if(length-1 == i){
71                    value = object;
72                }
73                if(!$.isObject(object)){
74                    return false;
75                }
76            })
77
78        }
79
80        if(Vue.isEmpty(value) && !Vue.isEmpty(defaultValue)){
81            value = defaultValue;
82        }
83        return value;
84    }
85    Vue.getQueryString= function (name) {
86        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
87        var r = window.location.search.substr(1).match(reg);
88        if (r != null) {
89            return unescape(r[2]);
90        }
91        return null;
92    }
93    Vue.formatDate=function(date,fmt){
94        if(arguments.length<2){
95            fmt = "yyyy-MM-dd HH:mm:ss";
96        }
97        var _this = date;
98        var o = {
99            "M+" : _this.getMonth()+1, //月份
100            "d+" : _this.getDate(), //日
101            "h+" : _this.getHours()%12 == 0 ? 12 : _this.getHours()%12, //小时
102            "H+" : _this.getHours(), //小时
103            "m+" : _this.getMinutes(), //分
104            "s+" : _this.getSeconds(), //秒
105            "q+" : Math.floor((_this.getMonth()+3)/3), //季度
106            "S" : _this.getMilliseconds() //毫秒
107        };
108        if(/(y+)/.test(fmt)){
109            fmt=fmt.replace(RegExp.$1, (_this.getFullYear()+"").substr(4 - RegExp.$1.length));
110        }
111        for(var k in o){
112            if(new RegExp("("+ k +")").test(fmt)){
113                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
114            }
115        }
116        return fmt;
117    }
118    // 2. 添加全局资源
119    Vue.directive('my-directive', {
120      // bind (el, binding, vnode, oldVnode) {
121        // 逻辑...
122      // }
123    })
124  
125    // 3. 注入组件
126    Vue.mixin({
127      created: function () {
128        // 逻辑...
129      }
130    })
131    Vue.prototype.getQueryString = Vue.getQueryString;
132    Vue.prototype.formatDate = Vue.formatDate;
133    // 4. 添加事例方法
134    Vue.prototype.invoke = function(url,param,callBackFunc,method,async){
135      // 逻辑...
136		if(!Vue.isEmpty(url)){
137			url = Vue.result(MyPlugin,"global.servletUrl")+ url;
138		}
139		if(Vue.isEmpty(async)){
140			async = true;
141		}
142		if(Vue.isEmpty(method)){
143			method = "post";
144		}
145		var token = Vue.result(aliConfig,"global.token");
146		var appId = Vue.result(aliConfig,"global.appId");
147		$.ajaxSetup({
148			beforeSend:function(request, settings) {
149				if (token) {
150					request.setRequestHeader("Authorization", token);
151				}
152				if (appId) {
153					request.setRequestHeader("appId", appId);
154				}
155			}
156		});
157        $.ajax({
158            url: url,
159            type: method,
160            async: async,
161            timeout: 10000,
162            data: param,
163            dataType : "json",
164            // contentType:'application/json;charset=utf-8',
165            success: function(result){
166            if(result[statusName] != successNo){
167                var filters = MyPlugin["filters"];
168                if(!Vue.isEmpty(filters)){
169                var otherFunction = filters[result[statusName]];
170                if($.isFunction(otherFunction)){
171                    otherFunction(result);
172                    return;
173                }
174                }
175            }
176            callBackFunc(result);
177            },
178            error : function (XMLHttpRequest, textStatus, errorThrown)
179            {
180                var status = XMLHttpRequest.status;
181                if(status==404){
182                    fsCommon.errorMsg("请求地址出错!");
183            }else if(status==302){
184                fsCommon.errorMsg('连接网页出错!');
185            }else if(textStatus=="timeout"){
186                fsCommon.errorMsg("请求超时!");
187            }else{
188                fsCommon.errorMsg('请求异常!');
189            }
190            },
191            complete : function(XMLHttpRequest, textStatus)
192            {
193                //关闭加载层
194            }
195        });
196    };
197  }
198
199// 调用 `MyPlugin.install(Vue)`
200Vue.use(MyPlugin);
201
202
203// var appOwner = ${owner};
204// var token =gettoken(${mode});
205var owner = "1581564523";
206var token ="preview";
207$.ajaxSetup({
208beforeSend:function(request, settings) {
209    request.setRequestHeader("Authorization", token);
210    request.setRequestHeader("owner", owner);
211}
212});
213
214

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.