123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- var _uuid = "",_yzuuid = null;
- var ylToken = {}, _pwskey;
- $(document).ready(function(){
- _pwskey = `rueigao-${getTime(new Date())[0].replace(/-/g,'')}`;
- let query = window.location.search;
- if(query!=""){
- localStorage.setItem("ptType",query.split("=")[1]);
- }
- if (localStorage.getItem("_yz_TT") != "null" && localStorage.getItem("_yz_TT") != null) {
- top.location.href = IsPC()?"./view/Main.html?sn=P0":"./view/MainPh.html?sn=0";
- return;
- } else {
- getCode();
- // getYzCode();
- }
- })
- function getCode(){
- $.ajax({
- url: "https://eims.bds100.com/auth/code?v="+(new Date().getTime()),
- type: "GET",
- dataType: "JSON",
- async: true, //同步请求
- data:{},
- error: function(XMLHttpRequest) {
- console.log(11111)
- },
- success:function (res) {
- _uuid = res.uuid;
- $("#codeImg").attr("src",res.img);
- }
- })
- }
- function getYzCode(){
- $.ajax({
- url: vipUrl+"/captchaImage",
- type: "GET",
- dataType: "JSON",
- async: true, //同步请求
- data:{},
- error: function(XMLHttpRequest) {
- console.log(11111)
- },
- success:function (res) {
- _yzuuid = res.uuid;
- $("#yzcodeImg").attr("src","data:image/jpg;base64,"+res.img);
- }
- })
- }
- $('input').bind('keyup', function(event) {
- if (event.keyCode == "13") {
- loginYZ();
- }
- });
- $(".logBtn").on("click","",function(){
- loginYZ();
- })
- function loginErr(){
- $(".logBtn i").css("display","none");
- $(".logBtn").removeAttr("disabled").removeClass("btnds");
- }
- function loginYZ(){
- let _user = $("input[name='user']").val();
- let _password = $("input[name='pwd']").val();
- let _codepwd = $("input[name='codepwd']").val();
- let _cyzodepwd = $("input[name='yzcodepwd']").val();
- if(_password!=""&&_user!=""&&_codepwd!=""){
- $(".logBtn i").css("display","inline-block");
- $(".logBtn").attr("disabled","disabled").addClass("btnds");
- setTimeout(()=>{
- $.ajax({
- url: vipUrl +"/login",
- type: "POST",
- dataType: "JSON",
- async: false, //同步请求
- data:JSON.stringify({
- username: encrypt(_user, _pwskey),
- password: encrypt(_password, _pwskey),
- code:_cyzodepwd,
- uuid:"f53582934d844429a52be829a9291789"
- }),
- headers: {
- "Content-Type": "application/json"
- },
- success:function (json) {
- let data = eval(json);
- if (data.code == 200){
- ylToken["yzTok"] = data.token;
- loginYL(_codepwd);
- // loginYSY();
- }else{
- // getYzCode();
- loginErr();
- ShowLoading("错误原因:"+data.msg+"!",1)
- }
- },
- error:function(err){
- loginErr();
- // getYzCode();
- ShowLoading("登录失败",1)
- $("input[name='yzcodepwd']").val("");
- },
- })
- },100)
- }else{
- ShowLoading("请填写完信息再登录!",1);
- }
- }
- // 易聊登录
- function loginYL(_key){
- $.ajax({
- url: "https://eims.bds100.com/auth/login",
- type: "POST",
- dataType: "JSON",
- async: false,
- headers:{
- "Content-Type": "application/json"
- },
- data:JSON.stringify({
- code: _key,
- password: "I8zZGBdzG+YloVHgTyjdZ3wox0oUU1xr5UpG0oSS5jrGOXGAZBUnAlSvD/eGzjzy+vnz6rWu4rVLkNcRc/o1x57FT0YO8Ak9OSdTcgzycE7kz3ZhK//taMCxnmGEBPiZmM4IUz5JxU9LGb5r0mnNEii4lTRFo7Nvn3zTqMTgfMU=",
- username: "yq",
- uuid: _uuid
- }),
- error:function(err){
- ShowLoading(err.responseJSON.message,1);
- loginErr()
- getCode();
- $("input[name='codepwd']").val("");
- },
- success:function (res) {
- ylToken["ylId"] = res.jwtUserDto.user.id;
- ylToken["ylTok"] = res.token;
- loginYSY();
- }
- })
- }
- // ysy设备列表登录
- function loginYSY(){
- $.ajax({
- url: "https://open.ys7.com/api/lapp/token/get",
- type: "POST",
- dataType: "JSON",
- async: false, //同步请求
- data:{
- appKey:"443b2b196905436dbdf1ad6f30b0ac0d",
- appSecret:"08d8c3401a809115d442108883735c70"
- },
- success:function (json) {
- if(json.code==200){
- ylToken["ysyTok"] = json.data.accessToken;
- getHTok();
- // top.location.href =IsPC()?"./view/Main.html?sn=P0":"./view/MainPh.html?sn=0";
- }else{
- loginErr();
- }
- }
- })
- }
- function getHTok(){
- $.ajax({
- url: "https://caps.runde.pro/api/index.php?ctl=tool&act=get_token",
- type: "POST",
- dataType: "JSON",
- async: false,
- data:{
- user_name: "易站智联",
- pkey: "e7d7cbe91171c493e8022a418d16bb7d"
- },
- success:function (res) {
- if(res.status){
- ShowLoading("登录成功!",1);
- ylToken["hemlTok"] = res.token;
- ylToken["hemlId"] = "2f503fe26d3278f89e593612c12e68d2";
- localStorage.removeItem("_yz_TT");
- localStorage.setItem("_yz_TT",JSON.stringify(ylToken));
- top.location.href =IsPC()?"./view/Main.html?sn=P0":"./view/MainPh.html?sn=0";
- }else{
- ShowLoading(res.msg,1);
- loginErr();
- }
- }
- })
- }
- // 判断是PC端还是移动端
- function IsPC() {
- var userAgentInfo = navigator.userAgent;
- var Agents = ["Android", "iPhone",
- "SymbianOS", "Windows Phone",
- "iPad", "iPod"];
- var flag = true;
- for (var v = 0; v < Agents.length; v++) {
- if (userAgentInfo.indexOf(Agents[v]) > 0) {
- flag = false;
- break;
- }
- }
- return flag;
- }
- function encrypt(word, keyStr) {
- keyStr = keyStr ? keyStr : 'abc';
- var key = CryptoJS.enc.Utf8.parse(keyStr);
- var srcs = CryptoJS.enc.Utf8.parse(word);
- var encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
- return encrypted.toString();
- };
|