| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- mui.init();
- mui.plusReady(function() {
- var usercode = localStorage.getItem("user"); //获取本地存储
- var psw = localStorage.getItem("psw"); //获取本地存储s
- if(usercode != null) //如果缓存中有数据,则加载出来
- {
- document.getElementById("account").value = usercode;
- document.getElementById("password").value = localStorage.getItem("psw");
- }
- document.getElementById("login").addEventListener('tap', function() {
- var username = document.getElementById('account').value;
- var password = document.getElementById('password').value;
- var data = {
- "Username": username,
- "Password": password,
- " extensionphone": 1
- };
- if(!username) {
- plus.nativeUI.toast('输入账号');
- } else if(!password) {
- plus.nativeUI.toast('密码不能为空');
- } else {
- if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
- mui.toast("网络连接中断!");
- }
- // 调用ajax
- mui.ajax(huayi.config.callcenter_url + '/WorkorderApp/login', {
- data: data,
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- timeout: 10000, //超时时间设置为10秒
- success: function(data) {
- if(data.state == "success") {
- localStorage.setItem("token", data.data.token);
- localStorage.setItem("user", username);
- localStorage.setItem("psw", password);
- var nwaiting = plus.nativeUI.showWaiting();
- webviewShow = plus.webview.create("Leader-index.html"); //后台创建webview并打开show.html
- document.getElementById('account').value = "";
- document.getElementById('password').value = "";
- } else {
- mui.alert(data.message);
- document.getElementById('account').value = "";
- document.getElementById('password').value = "";
-
- }
- },
- error: function(xhr, type, errorThrown) {}
- });
- }
- });
- //监听系统通知栏消息点击事件
- plus.push.addEventListener('click', function(msg){
- //处理点击消息的业务逻辑代码
- plus.webview.create('personal.html')
- }, false);
- //监听接收透传消息事件
- plus.push.addEventListener('receive', function(msg){
- //处理透传消息的业务逻辑代码
- }, false);
- });
|