(function () { var page = { headColor:'#ffffff', init: function ($page) { var url = 'http://www.learun.cn/webapi'; /*var getSecurityCode = function () { var moblieCode = $.trim($page.find('#account').val()).split('/')[0]; var reg = /^(\+\d{2,3}\-)?\d{11}$/; if (reg.test(moblieCode)) { function request(d) { for (var c = location.search.slice(1).split("&"), a = 0; a < c.length; a++) { var b = c[a].split("="); if (b[0] == d) if ("undefined" == unescape(b[1])) break; else return unescape(b[1]) } return "" }; var _fuid = request('fuid'); var _data = { mobileCode: moblieCode, sourceUrl: "移动端" + _fuid }; setPasswordTime(); learun.http.get(url + '/securitycode', { loginMark: learun.deviceId(), data: JSON.stringify(_data) }, function (res) { if (res.code !== 200) { learun.layer.warning(res.info, function () { }, '提示', '关闭'); } }); } else { learun.layer.warning("请输入正确手机号码!", function () { }, '提示', '关闭'); } };*/ /*var _time = 60; function setPasswordTime() { var $this = $page.find('#login_password_btn'); $this.text(_time + 's重新获取验证码'); $this.unbind('tap'); if (_time === 0) { $this.html('获取短信验证码'); $this.on('tap', getSecurityCode); _time = 60; } else { _time--; setTimeout(setPasswordTime, 1000); } $this = null; } // 点击获取短信验证码 $page.find('#login_password_btn').on('tap', getSecurityCode); */ $page.find('#loginBtn').on('tap', function () { var account = $('#account').val(); var password = $('#password').val(); if(account == 'a'){ learun.nav.go({ path: 'amap', title: '地图', type: 'right', isBack: false }); } if (account === "") { learun.layer.warning('手机号不能为空!', function () { }, '提示', '关闭'); } else if (password === "") { learun.layer.warning('密码不能为空!', function () { }, '提示', '关闭'); } else { var data = { username: account, password: $.md5(password) }; var postdata = { token: '', loginMark: learun.deviceId(),// 正式请换用设备号 data: data }; //console.log(postdata); var path = config.webapi; learun.layer.loading(true, "正在登录,请稍后"); learun.http.post(config.webapi + "/?s=api/login", postdata, function(res) { //learun.http.post("/php/user/login.php", postdata, function(res) { learun.layer.loading(false); if (res === null) { learun.layer.warning('无法连接服务器,请检测网络!', function () { }, '提示', '关闭'); return; } if (res.success === true) { var logininfo = { account: account, 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); learun.nav.go({ path: 'amap', title: '地图', type: 'right', isBack: false }); //learun.http.get("http://www.learun.cn/webapi/info", { data: account.split('/')[0] }, function (_res) { /*learun.http.get("/php/webapi/info.php", { data: account.split('/')[0] }, function (_res) { $('#account').val(''); $('#password').val(''); if (_res.code === 200 && _res.data.EnabledMark == -1) { learun.nav.go({ path: 'info', isBack: false, title: '填写信息', param: account.split('/')[0]}); } else { learun.tab.go('workspace'); } });*/ } else { learun.layer.warning(res.message, function () { }, '提示', '关闭'); } }); } }); } }; return page; })();