codelogin.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. console.log(JSON.stringify(datas));
  103. if (datas.result) {
  104. var obj = $(".get-code");
  105. settime(obj);
  106. }
  107. api.toast({ msg: datas.msg });
  108. }
  109. });
  110. return false;
  111. })
  112. function settime(obj) {
  113. if (countdown == 0) {
  114. obj.attr('disabled',false);
  115. obj.val("获取验证码");
  116. countdown = 60;
  117. } else {
  118. obj.attr('disabled',true);
  119. obj.val("重新发送(" + countdown + ")");
  120. countdown--;
  121. setTimeout(function() {
  122. settime(obj)
  123. }, 1000)
  124. }
  125. }
  126. function getRouteData() {
  127. var phone = $("#mobile").val();
  128. if(!(/^1[3456789]\d{9}$/.test(phone))){
  129. api.toast({ msg: '手机号不正确!' });
  130. return false;
  131. }
  132. $.ajax({
  133. url: siteurl + 'v1/entry/account',
  134. data: {
  135. account: phone,
  136. code: $("#code").val()
  137. },
  138. dataType: 'json',
  139. type: 'post',
  140. success: function(datas) {
  141. api.toast({ msg: datas.msg });
  142. if (datas.result) {
  143. $api.setStorage("accesstoken", datas.data.token);
  144. $api.setStorage("memberid", datas.data.member_id);
  145. $api.setStorage("storeid", datas.data.store_id);
  146. $api.setStorage("agent_id", datas.data.agent_id);
  147. dologin(datas);
  148. setTimeCloseWin("codelogin");
  149. } else {
  150. $api.rmStorage("storeid");
  151. $api.rmStorage("agent_id");
  152. $api.rmStorage("accesstoken");
  153. $api.rmStorage("memberid");
  154. }
  155. }
  156. });
  157. }
  158. function dologin(e) {
  159. // body...
  160. if (e.data.is_store == 1) {
  161. $api.rmStorage("memberid");
  162. $api.rmStorage("agent_id");
  163. api.openWin({
  164. name: 'hotelindex',
  165. url: './html/hotel/index.html',
  166. bounces: false
  167. })
  168. return false;
  169. } if (e.data.is_agent == 1) {
  170. $api.rmStorage("storeid");
  171. $api.rmStorage("memberid");
  172. api.openWin({
  173. name: 'agentindex',
  174. url: './html/agent/index.html',
  175. bounces: false
  176. })
  177. return false;
  178. } else {
  179. $api.rmStorage("agent_id");
  180. $api.rmStorage("storeid");
  181. api.openWin({
  182. name: 'index',
  183. url: 'index.html',
  184. bounces: false
  185. })
  186. }
  187. }
  188. $(".more-btn").on("tap", function() {
  189. api.openWin({
  190. name: 'register',
  191. allowEdit: true,
  192. url: 'register.html',
  193. bounces: false
  194. });
  195. setTimeCloseWin("codelogin");
  196. })
  197. $(".pad-login").on("tap", function() {
  198. api.closeWin();
  199. })
  200. ///
  201. function isinwx(){
  202. var wx = api.require('wx');
  203. wx.isInstalled(function(ret, err) {
  204. if (ret.installed) {
  205. $("#wx-login").fadeIn();
  206. } else {
  207. $("#wx-login").fadeOut();
  208. }
  209. })
  210. }
  211. function isinqq(){
  212. var qq = api.require('QQPlus');
  213. qq.installed(function(ret, err) {
  214. if (ret.status) {
  215. $("#qq-login").fadeIn();
  216. } else {
  217. $("#qq-login").fadeOut();
  218. }
  219. })
  220. }
  221. $("#wx-login").on("tap", function() {
  222. var wx = api.require('wx');
  223. wx.isInstalled(function(ret, err) {
  224. if (ret.installed) {
  225. wx.auth({
  226. apiKey: ''
  227. }, function(ret, err) {
  228. if (ret.status) {
  229. wx.getToken({
  230. code: ret.code
  231. }, function(ret, err) {
  232. if (ret.status) {
  233. $.ajax({
  234. url: siteurl + 'v1/entry/account',
  235. data: {
  236. openid: ret.openId,
  237. auth: 'wx'
  238. },
  239. dataType: 'json',
  240. type: 'post',
  241. success: function(datas) {
  242. if (datas.result) {
  243. api.toast({ msg: '登录成功!' });
  244. $api.setStorage("memberid", datas.data.member_id);
  245. $api.setStorage("accesstoken", datas.data.token);
  246. $api.setStorage("storeid", datas.data.store_id);
  247. $api.setStorage("agent_id", datas.data.agent_id);
  248. dologin(datas);
  249. setTimeCloseWin("login");
  250. } else {
  251. api.openWin({
  252. name: 'register',
  253. url: 'register.html',
  254. bounces: false,
  255. pageParam: {
  256. openid: ret.openId,
  257. auth: 'wx'
  258. }
  259. });
  260. $api.rmStorage("agent_id");
  261. $api.rmStorage("storeid");
  262. $api.rmStorage("accesstoken");
  263. $api.rmStorage("memberid");
  264. }
  265. }
  266. });
  267. } else {
  268. api.toast({ msg: '获取授权失败!' });
  269. }
  270. });
  271. } else {
  272. api.toast({ msg: '获取code失败!' });
  273. }
  274. });
  275. } else {
  276. api.toast({ msg: '系统没有安装微信!' });
  277. }
  278. });
  279. })
  280. ///
  281. $("#qq-login").on("tap", function() {
  282. var qq = api.require('QQPlus');
  283. qq.installed(function(ret, err) {
  284. if (ret.status) {
  285. qq.login(function(ret, err) {
  286. if (ret.openId) {
  287. $.ajax({
  288. url: siteurl + 'v1/entry/account',
  289. data: {
  290. openid: ret.openId,
  291. auth: 'qq'
  292. },
  293. dataType: 'json',
  294. type: 'post',
  295. success: function(datas) {
  296. if (datas.result) {
  297. api.toast({ msg: '登录成功!' });
  298. $api.setStorage("memberid", datas.data.member_id);
  299. $api.setStorage("accesstoken", datas.data.token);
  300. $api.setStorage("storeid", datas.data.store_id);
  301. $api.setStorage("agent_id", datas.data.agent_id);
  302. dologin(datas);
  303. setTimeCloseWin("login");
  304. } else {
  305. api.openWin({
  306. name: 'register',
  307. url: 'register.html',
  308. bounces: false,
  309. pageParam: {
  310. openid: ret.openId,
  311. auth: 'qq'
  312. }
  313. });
  314. $api.rmStorage("agent_id");
  315. $api.rmStorage("storeid");
  316. $api.rmStorage("accesstoken");
  317. $api.rmStorage("memberid");
  318. }
  319. }
  320. });
  321. } else {
  322. api.toast({ msg: '获取授权失败!' });
  323. }
  324. });
  325. } else {
  326. api.toast({ msg: "系统没有安装QQ!" });
  327. }
  328. });
  329. })
  330. var windowInnerHeight = window.innerHeight; //获取当前浏览器窗口高度
  331. $(window).resize(function() {
  332. if (window.innerHeight < windowInnerHeight) {
  333. $('.more-landing').css('position', 'static'); //当内部高度变小时
  334. } else {
  335. $('.more-landing').css('position', 'fixed');
  336. }
  337. });
  338. </script>
  339. </html>