login_html.js 11 KB

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