login.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  6. <title>登录界面</title>
  7. <link rel="stylesheet" type="text/css" href="../../../common/cross/css/cross.ui.css" />
  8. <script src="../../../js/mui.min.js"></script>
  9. <link href="../../../css/mui.min.css" rel="stylesheet" />
  10. <link rel="stylesheet" type="text/css" href="../css/login.css" />
  11. <link rel="stylesheet" type="text/css" href="../iconfont/iconfont.css" />
  12. <script src="../../../js/jquery/2.1.3/jquery.js" type="text/javascript" charset="utf-8"></script>
  13. </head>
  14. <body>
  15. <header class="mui-bar mui-bar-nav" style="background: #17b3ec;">
  16. <h1 class="mui-title" style="color: #fff;">登录</h1>
  17. </header>
  18. <div class="mui-content">
  19. <div class="mui-content-padded">
  20. <img src="../images/logo.png" />
  21. </div>
  22. <div id="yzm_login">
  23. <div class="mui-input-group mui-card">
  24. <div class="mui-input-row">
  25. <label><span class="iconfont icon-shouji1" style="font-size: 25px"></span></label>
  26. <input id="tel" type="text" class="mui-input-clear mobile" maxlength="11" placeholder="输入手机号码">
  27. </div>
  28. <div class="mui-input-row ">
  29. <label><span class="iconfont icon-yanzhengma01" style="font-size: 25px"></span></label>
  30. <input id="verity_code" style="padding-right: 100px;" type="text" placeholder="输入短信验证码" maxlength="6">
  31. <button id="btn_getVerity" type="button" class="mui-btn mui-btn-outlined " style="font-size: 14px;">获取验证码</button>
  32. </div>
  33. </div>
  34. <div id="div_tip" class="c-17b3ec c-f14 c-t-center c-hide">
  35. 系统已经发送验证码到您的手机上,请查收
  36. </div>
  37. <div class="mui-content-padded">
  38. <button type="button" class="mui-btn mui-btn-blue mui-btn-block btn_login" style="font-size: 16px;">登 录</button>
  39. </div>
  40. <div class="mui-content-padded">
  41. <a class="btn-rt login-type psw">账号密码登录</a>
  42. </div>
  43. </div>
  44. <div id="psw_login" style="display: none;">
  45. <div class="mui-input-group mui-card">
  46. <div class="mui-input-row">
  47. <label><span class="iconfont icon-shouji1" style="font-size: 25px"></span></label>
  48. <input type="text" class="mui-input-clear mobile" maxlength="11" placeholder="输入手机号码">
  49. </div>
  50. <div class="mui-input-row ">
  51. <label><span class="iconfont icon-yanzhengma01" style="font-size: 25px"></span></label>
  52. <input class="psdipt" type="password" style="padding-right: 50px;" placeholder="初始密码为手机号后六位">
  53. <input class="psdipt" type="text" style="padding-right: 50px; display: none;" placeholder="初始密码为手机号后六位">
  54. <a href="#" class="yanjing" style="">
  55. </a>
  56. </div>
  57. </div>
  58. <div class="mui-content-padded">
  59. <button type="button" class="mui-btn mui-btn-blue mui-btn-block btn_login" style="font-size: 16px;">登 录</button>
  60. </div>
  61. <div class="mui-content-padded">
  62. <a class="btn-lt login-type yzm">验证码快速登录</a>
  63. <a id="login_forget">忘记密码</a>
  64. </div>
  65. </div>
  66. </div>
  67. </body>
  68. <!--<script src="../../../js/app.js" type="text/javascript" charset="utf-8"></script>-->
  69. <script src="../../../js/security.js" type="text/javascript" charset="utf-8"></script>
  70. <script src="../../../js/common_http.js" type="text/javascript" charset="utf-8"></script>
  71. <script src="../../../js/rtcsdk.js" type="text/javascript" charset="utf-8"></script>
  72. <script src="../js/login.js" type="text/javascript" charset="utf-8"></script>
  73. <script src="../../js/common.js" type="text/javascript" charset="utf-8"></script>
  74. <script src="../../../js/im.client.js" type="text/javascript" charset="utf-8"></script>
  75. <script type="text/javascript">
  76. var self;
  77. var mobile = "";
  78. var curTime = 120;
  79. var checkReload = false;
  80. var type = 1;
  81. var beOut;
  82. mui.init({
  83. gestureConfig:{
  84. tap: true,
  85. doubletap: false,
  86. longtap: true
  87. }
  88. });
  89. mui.plusReady(function() {
  90. window.localStorage.removeItem("isLoginOut");
  91. plus.nativeUI.closeWaiting();
  92. self = plus.webview.currentWebview();
  93. if(self.exit) {
  94. beOut = self.beOut;
  95. // mui.later(function() {
  96. exitUser();
  97. // }, 1000);
  98. }
  99. plus.runtime.setBadgeNumber(0);
  100. $('.mui-content').css('height', plus.display.resolutionHeight + "px");
  101. });
  102. /*
  103. * 获取验证码
  104. */
  105. $("#btn_getVerity").click(function() {
  106. mobile = $(".mobile:visible").val();
  107. if(!isphone(mobile)) {
  108. mui.toast("请输入有效的手机号码");
  109. return;
  110. }
  111. plus.nativeUI.showWaiting();
  112. var $this = $(this);
  113. console.log($this)
  114. sendPost("common/captcha", {
  115. mobile: mobile,
  116. type: 5,
  117. captchaToke: ""
  118. }, function(){
  119. plus.nativeUI.closeWaiting();
  120. mui.toast("程序开了点小差, 请稍后重试!");
  121. }, function(res) {
  122. if(res.status == 200) {
  123. $("#div_tip").removeClass("c-hide");
  124. $this.text(curTime + "秒");
  125. $this.attr("disabled", "disabled");
  126. $("#verity_code").attr("autofocus", "autofocus");
  127. plus.nativeUI.closeWaiting();
  128. var timer = setInterval(function() {
  129. curTime--;
  130. $this.text(curTime + "秒");
  131. if(curTime == 0) {
  132. clearInterval(timer);
  133. $this.text("获取验证码");
  134. $this.removeAttr("disabled");
  135. $("#div_tip").addClass("c-hide");
  136. curTime = 120;
  137. }
  138. }, 1000);
  139. } else {
  140. mui.toast(res.msg);
  141. plus.nativeUI.closeWaiting();
  142. }
  143. })
  144. });
  145. $('.btn_login').on("longtap", login).on("click", login);
  146. function login(){
  147. disabledDom("btn_login");
  148. mobile = $(".mobile:visible").val();
  149. if(!isphone(mobile)) {
  150. mui.toast("请输入有效的手机号码");
  151. enabledDom("btn_login");
  152. return;
  153. }
  154. plus.storage.setItem("userMobile", mobile);
  155. if(type == 1){
  156. var verity = $("#verity_code").val().trim();
  157. if(verity.length != 6) {
  158. mui.toast("验证码格式错误,请重新输入");
  159. enabledDom("btn_login");
  160. return;
  161. }
  162. plus.nativeUI.showWaiting();
  163. verifyLogin(mobile, verity);
  164. } else {
  165. var pwd = $(".psdipt:visible").val().trim();
  166. if(pwd == "") {
  167. mui.toast("请输入密码");
  168. enabledDom("btn_login");
  169. return;
  170. }
  171. plus.nativeUI.showWaiting();
  172. RSAUtils.getKeyFromServer("/login/public_key", function(res) {
  173. if (res.status == 200) {
  174. var mod = res.data.modulus;
  175. var exp = res.data.exponent;
  176. key = RSAUtils.getKeyPair(exp, "", mod);
  177. if (key) {
  178. var encryedPwd = RSAUtils.encryStr(key, pwd);
  179. verifyLogin(mobile, "", encryedPwd);
  180. }else {
  181. plus.nativeUI.closeWaiting();
  182. toast("程序开了点小差!");
  183. }
  184. }
  185. });
  186. }
  187. }
  188. function disabledDom() {
  189. $(".btn_login").attr("disabled", true);
  190. }
  191. function enabledDom(id) {
  192. $(".btn_login").removeAttr("disabled");
  193. }
  194. /*
  195. * 验证登录
  196. */
  197. var docType = "";
  198. function verifyLogin(mobile, verity, psd) {
  199. sendPost("login/doctor", {
  200. mobile: mobile,
  201. captcha: verity || "",
  202. password: psd || ""
  203. }, function(){
  204. plus.nativeUI.closeWaiting();
  205. mui.toast("程序开了点小差, 请稍后重试!");
  206. enabledDom("btn_login");
  207. }, function(res) {
  208. if(res.status == 200) {
  209. console.log("1/"+JSON.stringify(res));
  210. var info = res.data;
  211. docType = res.data.doctorType;
  212. plus.storage.setItem("docType", docType+"");
  213. var iMei = plus.device.uuid;
  214. var docId = info.id;
  215. var uId = info.uid;
  216. var token = info.token;
  217. var hospital=info.hospital;
  218. var name = info.name;
  219. var photo = info.photo;
  220. var type = info.doctorType;
  221. var userRole=JSON.stringify([{"code":"350200","name":"厦门","areas":"350200"}]);//级别 省市县区
  222. userRole=JSON.stringify(info.userRole);//级别 省市县区
  223. var hospital = info.hospital;
  224. var platform = 2;
  225. plus.storage.setItem("hospital", hospital);
  226. plus.storage.setItem("userRole", userRole);
  227. var userAgent = plus.storage.getItem("userAgent");
  228. if(userAgent) {
  229. plus.storage.removeItem("userAgent");
  230. }
  231. var oUserAgent = {
  232. "id": docId,
  233. "uid": uId,
  234. "imei": iMei,
  235. "token": token,
  236. "platform": 2,
  237. "hospital":hospital
  238. };
  239. userAgent = JSON.stringify(oUserAgent);
  240. plus.navigator.setUserAgent(userAgent);
  241. plus.storage.setItem("userAgent", userAgent);
  242. plus.storage.setItem("flag", "hello");
  243. mui.later(function() {
  244. mui.toast("登录成功");
  245. mui.openWindow('../../home/html/main.html', 'main', {});
  246. }, 500);
  247. } else {
  248. mui.toast(res.msg);
  249. enabledDom("btn_login");
  250. }
  251. plus.nativeUI.closeWaiting();
  252. })
  253. }
  254. /*
  255. * 注销用户
  256. */
  257. function exitUser() {
  258. var aWv = plus.webview.all();
  259. var lanWv = plus.webview.getLaunchWebview();
  260. for(var i = 0; i < aWv.length; i++) {
  261. if(aWv[i].id == self.id || aWv[i].id == lanWv.id) {
  262. continue;
  263. } else {
  264. aWv[i].close("none");
  265. }
  266. }
  267. var mobile = plus.storage.getItem("userMobile");
  268. if(mobile) {
  269. $(".mobile:visible").val(mobile);
  270. }
  271. var flag = plus.storage.getItem('flag');
  272. if(flag) {
  273. plus.storage.removeItem("flag");
  274. }
  275. var useragent = plus.storage.getItem("userAgent");
  276. if(useragent) {
  277. //不logout IM的用户信息,防止用户在其他设备登录时,IM的登录状态在此被关闭
  278. if(!beOut){
  279. imClient.Users.logout(JSON.parse(useragent).uid);
  280. }
  281. plus.storage.removeItem("userAgent");
  282. }
  283. var docInfo = plus.storage.getItem("docInfo");
  284. if(docInfo) {
  285. plus.storage.removeItem("docInfo");
  286. }
  287. var docType = plus.storage.getItem("docType");
  288. if(docType) {
  289. plus.storage.removeItem("docType");
  290. }
  291. //logout();
  292. plus.nativeUI.closeWaiting();
  293. }
  294. window.addEventListener("exit", function() {
  295. exitUser();
  296. });
  297. /*
  298. * 定义退出方法
  299. */
  300. mui.back = function() {
  301. plus.nativeUI.confirm("确定退出?", function(e) {
  302. if(e.index == "0") {
  303. plus.runtime.quit();
  304. }
  305. }, "", ["确定", "取消"]);
  306. }
  307. /*
  308. * 加密设置:获取public_key
  309. */
  310. // var key;
  311. /**
  312. *登陆事件
  313. */
  314. // document.getElementById("btn_login").addEventListener('tap', function() {
  315. // plus.nativeUI.showWaiting("登录中...");
  316. // var encryURL = "login/public_key";
  317. // RSAUtils.getKeyFromServer(encryURL, handlSucc);
  318. // });
  319. //
  320. // function handlSucc(res) {
  321. // if (res.status == 200) {
  322. // var mod = res.data.modulus;
  323. // var exp = res.data.exponent;
  324. // key = RSAUtils.getKeyPair(exp, "", mod);
  325. // if (key) {
  326. // var account = document.querySelector("#tel").value.trim();
  327. // var pwd = document.querySelector("#pwd").value.trim();
  328. // if (!account || account.length != 11) {
  329. // plus.nativeUI.toast("请输入有效的手机号码");
  330. // plus.nativeUI.closeWaiting();
  331. // return;
  332. // }
  333. // if (!pwd || pwd.length < 6) {
  334. // plus.nativeUI.toast("请输入不少于6位密码");
  335. // plus.nativeUI.closeWaiting();
  336. // return;
  337. // }
  338. //
  339. // var encryedPwd = RSAUtils.encryStr(key, pwd);
  340. // verifyLogin(account, encryedPwd);
  341. // }
  342. //
  343. // }
  344. // }
  345. /*
  346. * 注册事件
  347. */
  348. //document.getElementById("login_reg").addEventListener('tap', function() {
  349. // mui.openWindow('../../register/html/regist-1phone.html', 'regist-1phone', {});
  350. // })
  351. /*
  352. * 忘记密码
  353. */
  354. //document.getElementById("login_forget").addEventListener('tap', function() {
  355. // mui.openWindow('../../forgetpwd/html/forget-1phone.html', 'forget-1phone', {})
  356. //});
  357. //cyc 20160826
  358. // function fixedWatch(el) {
  359. // if(document.activeElement.nodeName == 'INPUT'){
  360. // console.log(1)
  361. // } else {
  362. //
  363. // var html=el.prop("outerHTML")
  364. // if(el.length!=0){
  365. // el.remove();
  366. // }
  367. //
  368. // $("body").prepend(html);
  369. //
  370. //// el.css('position', 'fixed');
  371. // }
  372. // }
  373. //
  374. // setInterval(function () {
  375. //
  376. // fixedWatch($('.mui-bar.mui-bar-nav'));
  377. // }, 1000);
  378. </script>
  379. </html>