codelogin.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  6. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7. <title></title>
  8. <link rel="stylesheet" type="text/css" href="./css/api.css" />
  9. <link rel="stylesheet" type="text/css" href="./css/style.css" />
  10. <style>
  11. body {
  12. }
  13. </style>
  14. <script>
  15. (function(w, d, m) {
  16. function r() {
  17. var t = 100,
  18. o = 750,
  19. e = d.documentElement.clientWidth || w.innerWidth,
  20. n = m.max(m.min(e, 480), 320),
  21. h = 50;
  22. 320 >= n && (h = m.floor(n / o * t * .99)),
  23. n > 320 && 362 >= n && (h = m.floor(n / o * t * 1)),
  24. n > 362 && 375 >= n && (h = m.floor(n / o * t * 1)),
  25. n > 375 && (h = m.floor(n / o * t * .97)),
  26. d.querySelector("html").style.fontSize = h + "px"
  27. };
  28. r();
  29. w.onresize = function() {
  30. r()
  31. }
  32. })(window, document, Math);
  33. </script>
  34. </head>
  35. <body>
  36. <div class="topbar"></div>
  37. <header class="back-header">
  38. <ul>
  39. <li class="padding-20 back-btn"><img class="back-header-ico" src="image/nav_button_back_default.png" /></li>
  40. <li class="back-header-title">验证码登录</li>
  41. <li class="more-btn">注册</li>
  42. </ul>
  43. </header>
  44. <section class="new-list">
  45. <div class="login-logo"><img src="image/logo2.png" /></div>
  46. <div style="position: relative;">
  47. <input class="bot-input" id="mobile" type="text" placeholder="输入手机号" />
  48. <div class="h5"></div>
  49. <input class="bot-input" id="code" type="text" placeholder="短信验证码" />
  50. <input class="get-code" type="button" value="获取验证码" />
  51. <div class="h20"></div>
  52. <div class="h20"></div>
  53. <div class="m-bottom">登 录</div>
  54. <div class="h20" style="height: 0.5rem;"></div>
  55. <div class="">
  56. <div class="pad-login">使用密码登录</div>
  57. </div>
  58. </div>
  59. <div class="h50"></div>
  60. </section>
  61. <div class="more-landing">
  62. <ul>
  63. <li>&nbsp;</li>
  64. <li style="width:70%;"><img id="qq-login" src="image/qq_login.png" style="margin-right:10px;" />
  65. <img id="wx-login" src="image/wx_login.png" style="margin-left:10px;" /></li>
  66. <li>&nbsp;</li>
  67. </ul>
  68. </div>
  69. </body>
  70. <script type="text/javascript" src="script/api.js"></script>
  71. <script type="text/javascript" src="script/jquery.min.js"></script>
  72. <script type="text/javascript" src="script/jquery.tap.js"></script>
  73. <script type="text/javascript">
  74. var countdown = 60;
  75. apiready = function() {
  76. setFixStatusBar();
  77. isinwx();
  78. isinqq();
  79. };
  80. $(".m-bottom").on("tap", function() {
  81. getRouteData();
  82. return false;
  83. })
  84. $(".get-code").on("tap", function() {
  85. var phone = $("#mobile").val();
  86. if(!(/^1[3456789]\d{9}$/.test(phone))){
  87. api.toast({ msg: '手机号不正确!' });
  88. return false;
  89. }
  90. if (countdown != 60) {
  91. return false;
  92. }
  93. $.ajax({
  94. url: siteurl + 'v1/entry/sms',
  95. data: {
  96. mobile: phone,
  97. scenes: 'login'
  98. },
  99. dataType: 'json',
  100. type: 'post',
  101. success: function(datas) {
  102. if (datas.result) {
  103. var obj = $(".get-code");
  104. settime(obj);
  105. }
  106. api.toast({ msg: datas.msg });
  107. }
  108. });
  109. return false;
  110. })
  111. function settime(obj) {
  112. if (countdown == 0) {
  113. obj.attr('disabled',false);
  114. obj.val("获取验证码");
  115. countdown = 60;
  116. } else {
  117. obj.attr('disabled',true);
  118. obj.val("重新发送(" + countdown + ")");
  119. countdown--;
  120. setTimeout(function() {
  121. settime(obj)
  122. }, 1000)
  123. }
  124. }
  125. function getRouteData() {
  126. var phone = $("#mobile").val();
  127. if(!(/^1[3456789]\d{9}$/.test(phone))){
  128. api.toast({ msg: '手机号不正确!' });
  129. return false;
  130. }
  131. $.ajax({
  132. url: siteurl + 'v1/entry/account',
  133. data: {
  134. account: phone,
  135. code: $("#code").val()
  136. },
  137. dataType: 'json',
  138. type: 'post',
  139. success: function(datas) {
  140. api.toast({ msg: datas.msg });
  141. if (datas.result) {
  142. $api.setStorage("accesstoken", datas.data.token);
  143. $api.setStorage("memberid", datas.data.member_id);
  144. $api.setStorage("storeid", datas.data.store_id);
  145. $api.setStorage("agent_id", datas.data.agent_id);
  146. dologin(datas);
  147. setTimeCloseWin("codelogin");
  148. } else {
  149. $api.rmStorage("storeid");
  150. $api.rmStorage("agent_id");
  151. $api.rmStorage("accesstoken");
  152. $api.rmStorage("memberid");
  153. }
  154. }
  155. });
  156. }
  157. function dologin(e) {
  158. // body...
  159. if (e.data.is_store == 1) {
  160. $api.rmStorage("memberid");
  161. $api.rmStorage("agent_id");
  162. api.openWin({
  163. name: 'hotelindex',
  164. url: './html/hotel/index.html',
  165. bounces: false
  166. })
  167. return false;
  168. } if (e.data.is_agent == 1) {
  169. $api.rmStorage("storeid");
  170. $api.rmStorage("memberid");
  171. api.openWin({
  172. name: 'agentindex',
  173. url: './html/agent/index.html',
  174. bounces: false
  175. })
  176. return false;
  177. } else {
  178. $api.rmStorage("agent_id");
  179. $api.rmStorage("storeid");
  180. api.openWin({
  181. name: 'index',
  182. url: 'index.html',
  183. bounces: false
  184. })
  185. }
  186. }
  187. $(".more-btn").on("tap", function() {
  188. api.openWin({
  189. name: 'register',
  190. allowEdit: true,
  191. url: 'register.html',
  192. bounces: false
  193. });
  194. setTimeCloseWin("codelogin");
  195. })
  196. $(".pad-login").on("tap", function() {
  197. api.closeWin();
  198. })
  199. ///
  200. function isinwx(){
  201. var wx = api.require('wx');
  202. wx.isInstalled(function(ret, err) {
  203. if (ret.installed) {
  204. $("#wx-login").fadeIn();
  205. } else {
  206. $("#wx-login").fadeOut();
  207. }
  208. })
  209. }
  210. function isinqq(){
  211. var qq = api.require('QQPlus');
  212. qq.installed(function(ret, err) {
  213. if (ret.status) {
  214. $("#qq-login").fadeIn();
  215. } else {
  216. $("#qq-login").fadeOut();
  217. }
  218. })
  219. }
  220. $("#wx-login").on("tap", function() {
  221. var wx = api.require('wx');
  222. wx.isInstalled(function(ret, err) {
  223. if (ret.installed) {
  224. wx.auth({
  225. apiKey: ''
  226. }, function(ret, err) {
  227. if (ret.status) {
  228. wx.getToken({
  229. code: ret.code
  230. }, function(ret, err) {
  231. if (ret.status) {
  232. $.ajax({
  233. url: siteurl + 'v1/entry/account',
  234. data: {
  235. openid: ret.openId,
  236. auth: 'wx'
  237. },
  238. dataType: 'json',
  239. type: 'post',
  240. success: function(datas) {
  241. if (datas.result) {
  242. api.toast({ msg: '登录成功!' });
  243. $api.setStorage("memberid", datas.data.member_id);
  244. $api.setStorage("accesstoken", datas.data.token);
  245. $api.setStorage("storeid", datas.data.store_id);
  246. $api.setStorage("agent_id", datas.data.agent_id);
  247. dologin(datas);
  248. setTimeCloseWin("login");
  249. } else {
  250. api.openWin({
  251. name: 'register',
  252. url: 'register.html',
  253. bounces: false,
  254. pageParam: {
  255. openid: ret.openId,
  256. auth: 'wx'
  257. }
  258. });
  259. $api.rmStorage("agent_id");
  260. $api.rmStorage("storeid");
  261. $api.rmStorage("accesstoken");
  262. $api.rmStorage("memberid");
  263. }
  264. }
  265. });
  266. } else {
  267. api.toast({ msg: '获取授权失败!' });
  268. }
  269. });
  270. } else {
  271. api.toast({ msg: '获取code失败!' });
  272. }
  273. });
  274. } else {
  275. api.toast({ msg: '系统没有安装微信!' });
  276. }
  277. });
  278. })
  279. ///
  280. $("#qq-login").on("tap", function() {
  281. var qq = api.require('QQPlus');
  282. qq.installed(function(ret, err) {
  283. if (ret.status) {
  284. qq.login(function(ret, err) {
  285. if (ret.openId) {
  286. $.ajax({
  287. url: siteurl + 'v1/entry/account',
  288. data: {
  289. openid: ret.openId,
  290. auth: 'qq'
  291. },
  292. dataType: 'json',
  293. type: 'post',
  294. success: function(datas) {
  295. if (datas.result) {
  296. api.toast({ msg: '登录成功!' });
  297. $api.setStorage("memberid", datas.data.member_id);
  298. $api.setStorage("accesstoken", datas.data.token);
  299. $api.setStorage("storeid", datas.data.store_id);
  300. $api.setStorage("agent_id", datas.data.agent_id);
  301. dologin(datas);
  302. setTimeCloseWin("login");
  303. } else {
  304. api.openWin({
  305. name: 'register',
  306. url: 'register.html',
  307. bounces: false,
  308. pageParam: {
  309. openid: ret.openId,
  310. auth: 'qq'
  311. }
  312. });
  313. $api.rmStorage("agent_id");
  314. $api.rmStorage("storeid");
  315. $api.rmStorage("accesstoken");
  316. $api.rmStorage("memberid");
  317. }
  318. }
  319. });
  320. } else {
  321. api.toast({ msg: '获取授权失败!' });
  322. }
  323. });
  324. } else {
  325. api.toast({ msg: "系统没有安装QQ!" });
  326. }
  327. });
  328. })
  329. var windowInnerHeight = window.innerHeight; //获取当前浏览器窗口高度
  330. $(window).resize(function() {
  331. if (window.innerHeight < windowInnerHeight) {
  332. $('.more-landing').css('position', 'static'); //当内部高度变小时
  333. } else {
  334. $('.more-landing').css('position', 'fixed');
  335. }
  336. });
  337. </script>
  338. </html>