login_html.js 13 KB

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