login_html.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. $(document).ready(function () {
  2. 数据提交 = function(name = '地址',json = '数据',result = '回调') {
  3. $.post('http://localhost:13131/'+name,json,function(data){
  4. result(data);
  5. })
  6. }
  7. 滑动显示 = function (table1 = '标签一',time = '时间') {
  8. $(table1).css({
  9. overflow:'hidden',
  10. cursor:'pointer',
  11. }).find('div').css({
  12. width:$(table1).width(),
  13. height:$(table1).height(),
  14. background:'rgba(44,62,80,.4)',
  15. marginTop:$(table1).height()-$(table1).find('span').height(),
  16. cursor:'pointer',
  17. }).find('*').css({
  18. width:$(table1).width(),
  19. color:'#FFF',
  20. margin:'5px',
  21. textAlign:'left',
  22. });
  23. $(table1).hover(function(){
  24. $(this).find('div').animate({
  25. marginTop:'0px',
  26. },time)
  27. },function(){
  28. $(this).find('div').animate({
  29. marginTop:$(this).height()-$(this).find('span').height(),
  30. },time);
  31. });
  32. }
  33. text_each_add = function (id,value) {
  34. function add_text(table){
  35. let i = 0;
  36. let interval = setInterval(function () {
  37. if (i === value.length){
  38. table.innerText = ' ';
  39. i=0;
  40. }
  41. table.append(value[i])
  42. i++;
  43. },100)
  44. }
  45. let if_id = setInterval(function(){
  46. if(document.getElementById(id) !== null){
  47. add_text(document.getElementById(id));
  48. clearInterval(if_id);
  49. }
  50. },100)
  51. }
  52. alert_s = function(value = '类容'){
  53. $('body').append(`
  54. <div id="alert" style="background:transparent;
  55. left:0px;
  56. right:0px;
  57. top:0px;
  58. bottom:0px;
  59. margin:auto;
  60. text-align: center;
  61. position:fixed;
  62. z-index:999999;">
  63. <div style="text-align: center;position:absolute;
  64. left:0px;right:0px;top:0px;bottom:0px;margin:auto;
  65. width:150px;height:35px;border-radius:5px;background: rgba(0,0,0,0.3)">
  66. <span style="height:35px;line-height:35px;color: #ffffff;font-size: 13px">${value}</span>
  67. </div>
  68. </div>`);
  69. setTimeout(function () {
  70. $('#alert').remove();
  71. },500)
  72. }
  73. //----------------------------------------------------------------------------------------------
  74. Vue.component('login',{
  75. template:`
  76. <div type="login" v-on:click="on.button.exit()" v-bind:style="style.box" align="center">
  77. <div v-bind:style="style.frame">
  78. <label v-bind:style="style.label">
  79. <span v-bind:style="style.head">登录</span>
  80. </label>
  81. <label v-bind:style="style.label">
  82. <span v-bind:style="style.i">*</span>
  83. <span v-bind:style="style.title">账号</span>
  84. <input maxlength="9" v-on:focus="on.input.focus()" v-on:blur="on.input.blur()" v-bind:style="style.input"/>
  85. </label>
  86. <span v-bind:style="style.info"></span>
  87. <label v-bind:style="style.label">
  88. <span v-bind:style="style.i">*</span>
  89. <span v-bind:style="style.title">密码</span>
  90. <input maxlength="16" v-on:focus="on.input.focus()" v-on:blur="on.input.blur()" v-bind:style="style.input"/>
  91. </label>
  92. <span v-bind:style="style.info"></span>
  93. <label v-bind:style="style.label">
  94. <button v-on:click="on.button.QR_code()" v-bind:style="[style.button,style.button[2]]">扫码</button>
  95. <button v-on:click="on.button.login()" v-bind:style="[style.button,style.button[2]]">登录</button>
  96. <button v-on:click="on.button.exit()" type="quit" v-bind:style="[style.button,style.button[1]]">关闭</button>
  97. </label>
  98. <label v-bind:style="style.qr.box">
  99. <img v-bind:style="style.qr.img" width="100" height="100" alt=""/>
  100. <br/>
  101. <button v-on:click="on.button.account_login()" v-bind:style="style.qr.button" >账号登录</button>
  102. </label>
  103. </div>
  104. </div>`,
  105. data:function () {
  106. return {
  107. style:{
  108. box:{
  109. width:'100%',
  110. height:'100%',
  111. position:'fixed',
  112. zIndex:$('*').length * 2,
  113. background:'rgba(0,0,0,.2)'
  114. },
  115. frame:{
  116. display:'inline-grid',
  117. position: 'absolute',
  118. top:0,
  119. bottom:0,
  120. left:0,
  121. right:0,
  122. margin:'auto',
  123. width:'300px',
  124. height:'200px',
  125. borderRadius:'2.5px',
  126. padding:'20px 50px',
  127. background: '#FFF',
  128. },
  129. label:{
  130. height:'30px',
  131. },
  132. head:{
  133. lineHeight: '24px',
  134. fontSize: '18px',
  135. color: '#303133',
  136. },
  137. i:{
  138. color:'red',
  139. },
  140. title:{
  141. letterSpacing: '2.5px',
  142. marginRight:'5px',
  143. fontSize:'14px',
  144. color: '#606266',
  145. height:'30px',
  146. lineHeight:'30px',
  147. },
  148. input:{
  149. padding: '5px 10px',
  150. width: '200px',
  151. height: '20px',
  152. border:'1px solid #c3c3c3',
  153. borderRadius: '2.5px',
  154. outline:'none',
  155. },
  156. button:{
  157. cursor:'pointer',
  158. marginRight: '15px',
  159. float:'right',
  160. height:'30px',
  161. width:'70px',
  162. border:'none',
  163. borderRadius:'2.5px',
  164. outline: 'none',
  165. 1:{
  166. border:'1px solid #c3c3c3',
  167. background:'#FFF',
  168. color:'black'
  169. },
  170. 2:{
  171. border:'1px solid #409EFF',
  172. background:'#409EFF',
  173. color:'#FFF'
  174. }
  175. },
  176. info:{
  177. textAlign:'left',
  178. margin:'0 70px',
  179. height:'15px',
  180. letterSpacing:'2px',
  181. lineHeight: '15px',
  182. color:'red',
  183. fontSize: '10px',
  184. },
  185. qr:{
  186. box:{
  187. display:'none',
  188. height:'150px',
  189. },
  190. img:{
  191. borderRadius:'2.5px',
  192. },
  193. button:{
  194. cursor: 'pointer',
  195. marginTop:'15px',
  196. height:'30px',
  197. background:'#FFF',
  198. border:'1px solid #c3c3c3',
  199. outline:'none',
  200. width:'150px',
  201. }
  202. }
  203. },
  204. on:{
  205. input:{
  206. focus:function () {
  207. event.target.style.borderColor = '#409EFF';
  208. },
  209. blur:function () {
  210. var input = event.target;
  211. var info = $(input).parent('label').next('span')[0];
  212. var title = $(input).prev('span')[0].innerText;
  213. if ($(input).val() === defaultStatus||$(input).val()===null){
  214. info.innerText = title+'不能为空';
  215. } else if ($(input).val().indexOf(' ') !== -1){
  216. info.innerText = title+'不能包含空格';
  217. } else {
  218. info.innerText = '';
  219. }
  220. input.style.borderColor = '#c3c3c3';
  221. }
  222. },
  223. button:{
  224. exit:function () {
  225. if ($("div[type='login']").is(event.target) || $("button[type='quit']").is(event.target)){
  226. $("div[type='login']").css('display','none');
  227. }
  228. },
  229. login:function () {
  230. var message = $(event.target).parent('label').prevAll('label');
  231. var account = $(message[1]).find('input').val();
  232. var password = $(message[0]).find('input').val();
  233. var account_info = $(message[1]).next('span')[0];
  234. var password_info = $(message[0]).next('span')[0];
  235. var account_title = $(message[1]).find('span').eq(1).text();
  236. var password_title = $(message[0]).find('span').eq(1).text();
  237. if (account === defaultStatus||account===null){
  238. account_info.innerText = account_title+'不能为空';
  239. } else if (account.indexOf(' ') !== -1){
  240. account_info.innerText = password_title+'不能包含空格';
  241. }
  242. if (password === defaultStatus||password ===null){
  243. password_info.innerText = password_title+'不能为空';
  244. } else if (password.indexOf(' ') !== -1){
  245. password_info.innerText = password_title+'不能包含空格';
  246. }
  247. if (account !== defaultStatus
  248. &&account!==null
  249. &&account.indexOf(' ') === -1
  250. &&password !== defaultStatus
  251. &&password !==null
  252. &&password.indexOf(' ') === -1){
  253. $.post('http://127.0.0.1:13141/login',{
  254. account:account,
  255. password:password,
  256. },function (data) {
  257. alert_s(data.msg);
  258. if (data.error === 1){
  259. $.cookie('uuid',data.uuid,{exports:15});
  260. document.location.href = document.location.href;
  261. }
  262. })
  263. }
  264. },
  265. QR_code:function(){
  266. let qr_info = {
  267. time:new Date(),
  268. }
  269. $(event.target).parent('label').next('label').find('img').attr('src','http://qrs.kegood.com/?url='+JSON.stringify(qr_info))
  270. $(event.target).parent('label').parent('div').find('label').css('display','none')
  271. $(event.target).parent('label').parent('div').find('label')[0].style.display = 'block';
  272. $(event.target).parent('label').parent('div').find('label')[4].style.display = 'block';
  273. },
  274. account_login:function () {
  275. $(event.target).parent('label').parent('div').find('label').css('display','block')
  276. $(event.target).parent('label').parent('div').find('label')[4].style.display = 'none';
  277. }
  278. }
  279. }
  280. };
  281. }
  282. });
  283. new Vue({
  284. el:'#ifame'
  285. })
  286. })