| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
- <title>FrozenUI Demo</title>
- <link rel="stylesheet" href="../css/mui.min.css">
- <link rel="stylesheet" type="text/css" href="../css/reset.css" />
- <link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
- <style type="text/css">
- html {
- height: 100%;
- }
-
- body {
- height: 100%;
- background: #fff;
- }
-
- .page {
- height: 100%;
- overflow: hidden;
- }
-
- .logo {
- text-align: center;
- margin: 7rem 0 4.5rem;
- }
- .logo >img{
- width: 40%;
- }
-
- .logoCover {
- width: 80%;
- margin: 0 auto;
- }
-
- .logoItem {
- border-bottom: 1px solid #bbb;
- position: relative;
- height: 40px;
- margin-bottom: 15px;
- }
-
- .logoItem .inputicon {
- font-size: 22px;
- color: #22ace1;
- vertical-align: middle;
- position: absolute;
- left: 0;
- bottom: 8px;
- }
- #recordPwdIcon{
- color: #22ace1;
- }
- .logoItem input {
- background: transparent;
- border: none;
- padding: 0 0 4px 35px;
- position: absolute;
- left: 0;
- bottom: 0;
- margin: 0;
- }
-
- .logoItem .unlock {
- font-size: 29px;
- }
-
- input::-webkit-input-placeholder {
- color: #969696;
- }
-
- input::-moz-placeholder {
- /* Mozilla Firefox 19+ */
- color: #969696;
- }
-
- input:-moz-placeholder {
- /* Mozilla Firefox 4 to 18 */
- color: #969696;
- }
-
- input:-ms-input-placeholder {
- /* Internet Explorer 10-11 */
- color: #969696;
- }
-
- #forgetPwd,
- #registerBtn,
- .recordPwdLabel,
- .logoItem input {
- color: #bbb;
- }
-
- #loginBtn {
- width: 100%;
- /*line-height: 30px;*/
- font-size: 18px;
- letter-spacing: 6px;
- border-radius: 6px;
- margin: 20px 0 13px;
- color: #bbb;
- }
- #loginBtn:enabled:active{
- color: #fff;
- border: 1px solid #39c7fc;
- background-color: #39c7fc !important;
- }
-
- #loginBtn.btn-primary{
- background-color: #05a0db;
- border: 1px solid #12a5dc;
- color: #fff;
- }
- /*记住密码*/
-
- .checkbox {
- display: none;
- }
-
- #addUser {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 10px;
- text-align: center;
- }
- /**/
- .lookpsd{
- position: absolute;
- right: 6px;
- bottom: 8px;
- font-size: 27px;
- color: #c1c1c1;
- }
- #lookpsdBox,#openeye{
- display: none;
- }
- </style>
- </head>
- <body>
- <div class="page">
- <div class="logo">
- <img src="../images/logoTxt.png" alt="云飞智能科技" />
- <!--<h1>云飞智能科技</h1>-->
- </div>
- <div class="logoCover">
- <div class="logoInner">
- <form action="" method="post">
- <ul>
- <li class="logoItem">
- <i class="iconfont inputicon"></i>
- <input type="text" id="username" placeholder="请输入用户名" />
- </li>
- <li class="logoItem">
- <i class="iconfont inputicon"></i>
- <input type="password" id="password" placeholder="请输入密码" />
- <span id="lookpsdBox">
- <i class="iconfont lookpsd" id="openeye" onclick="openpsd()"></i> <!--看-->
- <i class="iconfont lookpsd" id="closeeye" onclick="closepsd()"></i> <!--闭-->
- </span>
-
- </li>
- </ul>
- <input type="button" id="loginBtn" value="登录" />
- </form>
- </div>
- <div class="otherBtns">
- <div class="mui-row">
- <div class="mui-col-xs-6">
- <!--<i class="iconfont" id="recordPwdIcon"></i>-->
- <label class="recordPwdLabel" for="recordPwd">
- <i class="iconfont" id="recordPwdIcon"></i>
- <input type="checkbox" class="checkbox" id="recordPwd" />
- <span>自动登录</span>
- </label>
- </div>
- <div class="mui-col-xs-6" style="text-align: right;">
- <a href="" id="forgetPwd">忘记密码??</a>
- </div>
- </div>
- </div>
- <div id="addUser">
- <!-- <a href="javascript:;" id="registerBtn">创建新账户+</a> -->
- </div>
- </div>
- </div>
- </body>
- <script src="../js/mui.min.js"></script>
- <script>
- mui.init();
- mui.plusReady(function() {
- var all = plus.webview.all();
- var current = plus.webview.currentWebview().id;
- var index = plus.runtime.appid;
- console.log(all)
- for (var i = 0, len = all.length; i < len; i++) {
- if (all[i].id !== current && all[i].id != index) {
- all[i].hide();
- all[i].close();
- }
- }
- autoLogin()
- var windowInnerHeight = window.innerHeight;
- //解决fixed问题
- window.onresize = function() {
- if(window.innerHeight < windowInnerHeight) {
- document.getElementById("addUser").style.position = 'static';
- } else {
- document.getElementById("addUser").style.position = 'fixed';
- }
- }
- var username = document.getElementById('username'),
- password = document.getElementById('password');
- //登录颜色
- password.addEventListener('keyup', function() {
- var passwordVal = this.value;
- var usernameVal = username.value;
- //查看密码
- if(passwordVal.length >= 1) {
- document.getElementById('lookpsdBox').style.display = 'block';
- }else{
- document.getElementById('lookpsdBox').style.display = 'none';
- }
- //是否能登录
- if(passwordVal.length >= 6 && usernameVal != '') {
- document.getElementById("loginBtn").classList.add("btn-primary");
- } else {
- document.getElementById("loginBtn").classList.remove("btn-primary");
- }
- //键盘确定登录
- if(event.keyCode ==13){
- login(usernameVal, passwordVal);
- }
- })
-
- //监听查看密码
- // password.addEventListener('input', function() {
- // alert(1);;
- // })
- //记住密码
- mui(".otherBtns").on('tap', ".recordPwdLabel", function() {
- remFun()
- })
- function remFun() {
- if(!document.getElementById("recordPwd").checked) {
- document.getElementById('recordPwdIcon').innerHTML = '';
- plus.storage.setItem('remState', 'true'); //设置本地存储
- } else {
- document.getElementById('recordPwdIcon').innerHTML = '';
- plus.storage.setItem('remState', 'false'); //设置本地存储
- }
- }
- function autoLogin() {
- var username = plus.storage.getItem('username');
- var password = plus.storage.getItem('password');
- var remState = plus.storage.getItem('remState');
-
- console.log(plus.storage.getItem('username'))
- console.log(plus.storage.getItem('password'))
- console.log(plus.storage.getItem('remState'))
- if(remState == 'true' || remState == true) {
- login(username, password);
- }
- }
- //登录
- document.getElementById("loginBtn").addEventListener('tap', function() {
- if(this.className == 'btn-primary') {
- login(username.value, password.value)
- } else {
- mui.toast('请将信息填写完整');
- }
- })
- function login(name, pwd) {
- if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
- mui.toast("网络异常,请检查网络设置!");
- } else {
- mui.ajax('http://120.27.222.26/app_login', {
- data: {
- 'username': name,
- 'password': pwd
- },
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- timeout: 10000, //超时时间设置为10秒;
- success: function(data) {
- plus.storage.setItem('username', name); //设置本地存储
- plus.storage.setItem('password', pwd); //设置本地存储
- if(data.code == 0) {
- if(data.role == 'user'){
- plus.storage.setItem('isuser', 'user'); //普通用户
- }else if(data.role == 'agency'){
- plus.storage.setItem('isuser', 'agency'); //代理商
- }else{
- plus.storage.setItem('isuser', 'admin'); //管理员
- }
- mui.openWindow({
- url: 'main.html',
- id: 'main',
- extras: {
- name: 'mui' //扩展参数
- },
- })
- } else if(data.code == 1) {
- mui.toast('用户不存在');
- } else if(data.code == 2) {
- mui.toast('用户不可用');
- } else if(data.code == 3) {
- mui.toast('密码错误');
- }
- },
- error: function(xhr, type, errorThrown) {
- // console.log(type)
- console.log(errorThrown)
- mui.toast('登录请求失败');
- }
- });
- }
- }
- })
-
-
- //查看密码
- function openpsd(){
- document.getElementById('openeye').style.display = 'none';
- document.getElementById('closeeye').style.display = 'block';
- document.getElementById('password').setAttribute('type','password');
- }
-
- //隐藏密码
- function closepsd(){
- document.getElementById('openeye').style.display = 'block';
- document.getElementById('closeeye').style.display = 'none';
- document.getElementById('password').setAttribute('type','text');
- }
-
- //注册
- mui('#addUser').on('tap','#registerBtn',function(){
- mui.openWindow({
- url:'register.html',
- id:'register'
- })
- })
- //退出应用
- mui.oldback = mui.back;
- var clickNum = 0;
- mui.back = function(event) {
- clickNum++;
- if(clickNum > 1) {
- plus.runtime.quit();
- } else {
- mui.toast("再按一次退出应用");
- }
- setTimeout(function() {
- clickNum = 0
- }, 1000);
- return false;
- }
- //测试网络
- // document.addEventListener("netchange", networkinfo, false);
- function networkinfo() {
- if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
- mui.toast("网络异常,请检查网络设置!");
- }
- }
- </script>
- </html>
|