var base = localstorage.getitem('base') || ''; function initcookies() { var cookie = document.cookie, items = cookie.split(";"), keys = {}; items.foreach(function(item) { var kv = item.split('='); keys[$.trim(kv[0])] = $.trim(kv[1]); }); return keys; } var mymessage = new mymessage.message({ /*默认参数,下面为默认项*/ iconfontsize: "26px", //图标大小,默认为20px messagefontsize: "20px", //信息字体大小,默认为12px showtime: 2000, //消失时间,默认为3000 align: "center", //显示的位置类型center,right,left positions: { //放置信息距离周边的距离,默认为10px top: "10px", bottom: "10px", right: "10px", left: "10px", }, color:'#333', message: "这是一条消息", //消息内容,默认为"这是一条消息" type: "normal", //消息的类型,还有success,error,warning等,默认为normal }) var geturlarg = function(name) { var url = window.location.search; // 正则筛选地址栏 var reg = new regexp("(^|&)" + name + "=([^&]*)(&|$)") // 匹配目标参数 var result = url.substr(1).match(reg); //返回参数值 return result ? decodeuricomponent(result[2]) : null; } // base = 'http://pengshansheng.51vip.biz' var api = { post:function(url,data,callback,type) { $.ajax({ url: base+url, method: 'post', data:type=='form'?data:json.stringify(data), headers:{ 'jeecms-auth-token':localstorage.getitem('jeecms-auth-token'), 'redirect-header':false, 'x-xsrf-token':initcookies()['x-xsrf-token'] || initcookies()['xsrf-token'], 'content-type':'application/json' }, success: function (data) { callback(data) }, error: function (xhr, textstatus, errorthrown) { mymessage.add(errorthrown, 'error'); } }) }, get:function(url,data,callback) { $.ajax({ url: base+url, method: 'get', data:data, headers:{'jeecms-auth-token':localstorage.getitem('jeecms-auth-token'),'redirect-header':false,'content-type':'application/json'}, success: function (result) { callback(result) }, error: function (xhr, textstatus, errorthrown) { mymessage.add(errorthrown, 'error'); } }) }, put:function(url,data,callback) { $.ajax({ url: base+url, method: 'put', data:json.stringify(data), headers:{'jeecms-auth-token':localstorage.getitem('jeecms-auth-token'),'redirect-header':false,'x-xsrf-token':initcookies()['x-xsrf-token'] || initcookies()['xsrf-token'],'content-type':'application/json'}, success: function (result) { callback(result) }, error: function (xhr, textstatus, errorthrown) { mymessage.add(errorthrown, 'error'); } }) }, delete:function(url,data,callback) { $.ajax({ url: base+url+'/delete', method: 'post', data:json.stringify(data), headers:{'jeecms-auth-token':localstorage.getitem('jeecms-auth-token'),'redirect-header':false,'x-xsrf-token':initcookies()['x-xsrf-token'] || initcookies()['xsrf-token'],'content-type':'application/json'}, success: function (result) { callback(result) }, error: function (xhr, textstatus, errorthrown) { mymessage.add(errorthrown, 'error'); } }) } } var desencrypt = function(str){ var status = true /**服务端定的公钥*/ var pubkeyhex = "04af0fcc45059aa342221352e5268614f2ff7a430497b156c0dee6e751ab44e4957e9e69299e2cd38e25985b7bd34e0e7bba683de4725a6a8cd07e19bff8bef44d"; var encryptdata=''; if(!status){ $.ajax({ url: base+"/cmsmanager/config/global/issmencrypt", async: false, data: {}, success: function (result) { if (result.data === true) { var smutil = new smutil(); encryptdata = smutil.sm2encrypt(str, pubkeyhex); } else { var cryptokey = cryptojs.enc.utf8.parse('wfjtko9s4elkrpz2jkranzdb'); var cryptoiv = cryptojs.enc.utf8.parse('d076d35c'.substr(0, 8)); var encodestr = cryptojs.tripledes.encrypt(str, cryptokey, { iv: cryptoiv, mode: cryptojs.mode.cbc, padding: cryptojs.pad.pkcs7 }); encryptdata = encodestr.tostring(); } } }); } else { var cryptokey = cryptojs.enc.utf8.parse('wfjtko9s4elkrpz2jkranzdb'); var cryptoiv = cryptojs.enc.utf8.parse('d076d35c'.substr(0, 8)); var encodestr = cryptojs.tripledes.encrypt(str, cryptokey, { iv: cryptoiv, mode: cryptojs.mode.cbc, padding: cryptojs.pad.pkcs7 }); encryptdata = encodestr.tostring(); } return encryptdata }