Browse Source

地铁h5 indexjs 增加自动登录代码非空判断

yanshi
liangkun 3 years ago
parent
commit
7678c00b65
1 changed files with 41 additions and 16 deletions
  1. +41
    -16
      Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/scripts/index.js

+ 41
- 16
Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/scripts/index.js View File

@@ -37,23 +37,48 @@
document.addEventListener('pause', onPause.bind(this), false);
document.addEventListener('resume', onResume.bind(this), false);
learun.tab.init(tabdata);

var logininfo = learun.storage.get('logininfo');
if (logininfo) {// 有登录的token
learun.tab.go('workspace');
$.ajax({
url: config.webapi + "weixinapi/weixinconfig",
type: "get",
success: function (res) {
learun.storage.set('weixinappid', res.data.appid );
learun.storage.set('weixinappsecret', res.data.secret );
}
});
}
else {
learun.nav.go({ path: 'login', isBack: false, isHead: false });
//直接登录
var data = {
username: '',
password: $.md5('www.qj.com')
};
if (window.location.href.split('?')[1]) {
data.username = window.location.href.split('?')[1].split('username=')[1]
}
learun.splashscreen.hide();
var postdata = {
token: '',
loginMark: learun.deviceId(),// 正式请换用设备号
data: JSON.stringify(data)
};
learun.http.post(config.webapi + "learun/adms/user/logindt", postdata, (res) => {
console.log(res);
var logininfo = {};
if (res.data.username) {
logininfo = {
account: data.username,
token: res.data.baseinfo.token,
date: learun.date.format(new Date(), 'yyyy-MM-dd hh:mm:ss')
};
learun.storage.set('logininfo', logininfo);
learun.storage.set('userinfo', res.data);
}
var logininfo = learun.storage.get('logininfo');
if (logininfo) {// 有登录的token
learun.tab.go('workspace');
// $.ajax({
// url: config.webapi + "weixinapi/weixinconfig",
// type: "get",
// success: function (res) {
// learun.storage.set('weixinappid', res.data.appid );
// learun.storage.set('weixinappsecret', res.data.secret );
// }
// });
}
else {
learun.nav.go({ path: 'login', isBack: false, isHead: false });
}
learun.splashscreen.hide();
});
});

function onPause() {


Loading…
Cancel
Save