login_html.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. $(document).ready(function () {
  2. Vue.component('login',{
  3. template:`
  4. <div type="login" v-on:click="on.button.exit()" v-bind:style="style.box" align="center">
  5. <div v-bind:style="style.frame">
  6. <label v-bind:style="style.label">
  7. <span v-bind:style="style.head">登录</span>
  8. </label>
  9. <label v-bind:style="style.label">
  10. <span v-bind:style="style.i">*</span>
  11. <span v-bind:style="style.title">账号</span>
  12. <input maxlength="9" v-on:focus="on.input.focus()" v-on:blur="on.input.blur()" v-bind:style="style.input"/>
  13. </label>
  14. <span v-bind:style="style.info"></span>
  15. <label v-bind:style="style.label">
  16. <span v-bind:style="style.i">*</span>
  17. <span v-bind:style="style.title">密码</span>
  18. <input maxlength="16" v-on:focus="on.input.focus()" v-on:blur="on.input.blur()" v-bind:style="style.input"/>
  19. </label>
  20. <span v-bind:style="style.info"></span>
  21. <label v-bind:style="style.label">
  22. <button v-on:click="on.button.QR_code()" v-bind:style="[style.button,style.button[2]]">扫码</button>
  23. <button v-on:click="on.button.login()" v-bind:style="[style.button,style.button[2]]">登录</button>
  24. <button v-on:click="on.button.exit()" type="quit" v-bind:style="[style.button,style.button[1]]">关闭</button>
  25. </label>
  26. <label v-bind:style="style.qr.box">
  27. <img v-bind:style="style.qr.img" width="100" height="100" alt=""/>
  28. <br/>
  29. <button v-on:click="on.button.account_login()" v-bind:style="style.qr.button" >账号登录</button>
  30. </label>
  31. </div>
  32. </div>`,
  33. data:function () {
  34. return {
  35. style:{
  36. box:{
  37. width:'100%',
  38. height:'100%',
  39. position:'fixed',
  40. zIndex:$('*').length * 2,
  41. background:'rgba(0,0,0,.2)'
  42. },
  43. frame:{
  44. display:'inline-grid',
  45. position: 'absolute',
  46. top:0,
  47. bottom:0,
  48. left:0,
  49. right:0,
  50. margin:'auto',
  51. width:'300px',
  52. height:'200px',
  53. borderRadius:'2.5px',
  54. padding:'20px 50px',
  55. background: '#FFF',
  56. },
  57. label:{
  58. height:'30px',
  59. },
  60. head:{
  61. lineHeight: '24px',
  62. fontSize: '18px',
  63. color: '#303133',
  64. },
  65. i:{
  66. color:'red',
  67. },
  68. title:{
  69. letterSpacing: '2.5px',
  70. marginRight:'5px',
  71. fontSize:'14px',
  72. color: '#606266',
  73. height:'30px',
  74. lineHeight:'30px',
  75. },
  76. input:{
  77. padding: '5px 10px',
  78. width: '200px',
  79. height: '20px',
  80. border:'1px solid #c3c3c3',
  81. borderRadius: '2.5px',
  82. outline:'none',
  83. },
  84. button:{
  85. cursor:'pointer',
  86. marginRight: '15px',
  87. float:'right',
  88. height:'30px',
  89. width:'70px',
  90. border:'none',
  91. borderRadius:'2.5px',
  92. outline: 'none',
  93. 1:{
  94. border:'1px solid #c3c3c3',
  95. background:'#FFF',
  96. color:'black'
  97. },
  98. 2:{
  99. border:'1px solid #409EFF',
  100. background:'#409EFF',
  101. color:'#FFF'
  102. }
  103. },
  104. info:{
  105. textAlign:'left',
  106. margin:'0 70px',
  107. height:'15px',
  108. letterSpacing:'2px',
  109. lineHeight: '15px',
  110. color:'red',
  111. fontSize: '10px',
  112. },
  113. qr:{
  114. box:{
  115. display:'none',
  116. height:'150px',
  117. },
  118. img:{
  119. borderRadius:'2.5px',
  120. },
  121. button:{
  122. cursor: 'pointer',
  123. marginTop:'15px',
  124. height:'30px',
  125. background:'#FFF',
  126. border:'1px solid #c3c3c3',
  127. outline:'none',
  128. width:'150px',
  129. }
  130. }
  131. },
  132. on:{
  133. input:{
  134. focus:function () {
  135. event.target.style.borderColor = '#409EFF';
  136. },
  137. blur:function () {
  138. var input = event.target;
  139. var info = $(input).parent('label').next('span')[0];
  140. var title = $(input).prev('span')[0].innerText;
  141. if ($(input).val() === defaultStatus||$(input).val()===null){
  142. info.innerText = title+'不能为空';
  143. } else if ($(input).val().indexOf(' ') !== -1){
  144. info.innerText = title+'不能包含空格';
  145. } else {
  146. info.innerText = '';
  147. }
  148. input.style.borderColor = '#c3c3c3';
  149. }
  150. },
  151. button:{
  152. exit:function () {
  153. if ($("div[type='login']").is(event.target) || $("button[type='quit']").is(event.target)){
  154. $("div[type='login']").css('display','none');
  155. }
  156. },
  157. login:function () {
  158. var message = $(event.target).parent('label').prevAll('label');
  159. var account = $(message[1]).find('input').val();
  160. var password = $(message[0]).find('input').val();
  161. var account_info = $(message[1]).next('span')[0];
  162. var password_info = $(message[0]).next('span')[0];
  163. var account_title = $(message[1]).find('span').eq(1).text();
  164. var password_title = $(message[0]).find('span').eq(1).text();
  165. if (account === defaultStatus||account===null){
  166. account_info.innerText = account_title+'不能为空';
  167. } else if (account.indexOf(' ') !== -1){
  168. account_info.innerText = password_title+'不能包含空格';
  169. }
  170. if (password === defaultStatus||password ===null){
  171. password_info.innerText = password_title+'不能为空';
  172. } else if (password.indexOf(' ') !== -1){
  173. password_info.innerText = password_title+'不能包含空格';
  174. }
  175. if (account !== defaultStatus
  176. &&account!==null
  177. &&account.indexOf(' ') === -1
  178. &&password !== defaultStatus
  179. &&password !==null
  180. &&password.indexOf(' ') === -1){
  181. $.post('http://127.0.0.1:13141/login',{
  182. account:account,
  183. password:password,
  184. },function (data) {
  185. alert_s(data.msg);
  186. if (data.error === 1){
  187. $.cookie('uuid',data.uuid,{exports:15});
  188. document.location.href = document.location.href;
  189. }
  190. })
  191. }
  192. },
  193. QR_code:function(){
  194. let qr_info = {
  195. time:new Date(),
  196. }
  197. $(event.target).parent('label').next('label').find('img').attr('src','http://qrs.kegood.com/?url='+JSON.stringify(qr_info))
  198. $(event.target).parent('label').parent('div').find('label').css('display','none')
  199. $(event.target).parent('label').parent('div').find('label')[0].style.display = 'block';
  200. $(event.target).parent('label').parent('div').find('label')[4].style.display = 'block';
  201. },
  202. account_login:function () {
  203. $(event.target).parent('label').parent('div').find('label').css('display','block')
  204. $(event.target).parent('label').parent('div').find('label')[4].style.display = 'none';
  205. }
  206. }
  207. }
  208. };
  209. }
  210. });
  211. new Vue({
  212. el:'#ifame'
  213. })
  214. })