login_html.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. })
  66. $('head').after(`
  67. <style>
  68. #ifame{
  69. position: absolute;
  70. min-width: 1200px;
  71. width: 100%;
  72. height: 100%;
  73. background-color: transparent;
  74. background-size: cover;
  75. background-position: center center;
  76. background-repeat: no-repeat;
  77. overflow-y:scroll;
  78. overflow-x:hidden;
  79. }
  80. </style>
  81. `)
  82. //----------------------------------------------------------------------------------------------
  83. Vue.component('login',{
  84. template:`
  85. <div type="login" v-on:click="on.button.exit()" v-bind:style="style.box" align="center">
  86. <div v-bind:style="style.frame">
  87. <label v-bind:style="style.label">
  88. <span v-bind:style="style.head">登录</span>
  89. </label>
  90. <label v-bind:style="style.label">
  91. <span v-bind:style="style.i">*</span>
  92. <span v-bind:style="style.title">账号</span>
  93. <input maxlength="9" v-on:focus="on.input.focus()" v-on:blur="on.input.blur()" v-bind:style="style.input"/>
  94. </label>
  95. <span v-bind:style="style.info"></span>
  96. <label v-bind:style="style.label">
  97. <span v-bind:style="style.i">*</span>
  98. <span v-bind:style="style.title">密码</span>
  99. <input maxlength="16" v-on:focus="on.input.focus()" v-on:blur="on.input.blur()" v-bind:style="style.input"/>
  100. </label>
  101. <span v-bind:style="style.info"></span>
  102. <label v-bind:style="style.label">
  103. <button v-on:click="on.button.QR_code()" v-bind:style="[style.button,style.button[2]]">扫码</button>
  104. <button v-on:click="on.button.login()" v-bind:style="[style.button,style.button[2]]">登录</button>
  105. <button v-on:click="on.button.exit()" type="quit" v-bind:style="[style.button,style.button[1]]">关闭</button>
  106. </label>
  107. <label v-bind:style="style.qr.box">
  108. <img v-bind:style="style.qr.img" width="100" height="100" alt=""/>
  109. <br/>
  110. <button v-on:click="on.button.account_login()" v-bind:style="style.qr.button" >账号登录</button>
  111. </label>
  112. </div>
  113. </div>`,
  114. data:function () {
  115. return {
  116. style:{
  117. box:{
  118. width:'100%',
  119. height:'100%',
  120. position:'fixed',
  121. zIndex:$('*').length * 2,
  122. background:'rgba(0,0,0,.2)'
  123. },
  124. frame:{
  125. display:'inline-grid',
  126. position: 'absolute',
  127. top:0,
  128. bottom:0,
  129. left:0,
  130. right:0,
  131. margin:'auto',
  132. width:'300px',
  133. height:'200px',
  134. borderRadius:'2.5px',
  135. padding:'20px 50px',
  136. background: '#FFF',
  137. },
  138. label:{
  139. height:'30px',
  140. },
  141. head:{
  142. lineHeight: '24px',
  143. fontSize: '18px',
  144. color: '#303133',
  145. },
  146. i:{
  147. color:'red',
  148. },
  149. title:{
  150. letterSpacing: '2.5px',
  151. marginRight:'5px',
  152. fontSize:'14px',
  153. color: '#606266',
  154. height:'30px',
  155. lineHeight:'30px',
  156. },
  157. input:{
  158. padding: '5px 10px',
  159. width: '200px',
  160. height: '20px',
  161. border:'1px solid #c3c3c3',
  162. borderRadius: '2.5px',
  163. outline:'none',
  164. },
  165. button:{
  166. cursor:'pointer',
  167. marginRight: '15px',
  168. float:'right',
  169. height:'30px',
  170. width:'70px',
  171. border:'none',
  172. borderRadius:'2.5px',
  173. outline: 'none',
  174. 1:{
  175. border:'1px solid #c3c3c3',
  176. background:'#FFF',
  177. color:'black'
  178. },
  179. 2:{
  180. border:'1px solid #409EFF',
  181. background:'#409EFF',
  182. color:'#FFF'
  183. }
  184. },
  185. info:{
  186. textAlign:'left',
  187. margin:'0 70px',
  188. height:'15px',
  189. letterSpacing:'2px',
  190. lineHeight: '15px',
  191. color:'red',
  192. fontSize: '10px',
  193. },
  194. qr:{
  195. box:{
  196. display:'none',
  197. height:'150px',
  198. },
  199. img:{
  200. borderRadius:'2.5px',
  201. },
  202. button:{
  203. cursor: 'pointer',
  204. marginTop:'15px',
  205. height:'30px',
  206. background:'#FFF',
  207. border:'1px solid #c3c3c3',
  208. outline:'none',
  209. width:'150px',
  210. }
  211. }
  212. },
  213. on:{
  214. input:{
  215. focus:function () {
  216. event.target.style.borderColor = '#409EFF';
  217. },
  218. blur:function () {
  219. var input = event.target;
  220. var info = $(input).parent('label').next('span')[0];
  221. var title = $(input).prev('span')[0].innerText;
  222. if ($(input).val() === defaultStatus||$(input).val()===null){
  223. info.innerText = title+'不能为空';
  224. } else if ($(input).val().indexOf(' ') !== -1){
  225. info.innerText = title+'不能包含空格';
  226. } else {
  227. info.innerText = '';
  228. }
  229. input.style.borderColor = '#c3c3c3';
  230. }
  231. },
  232. button:{
  233. exit:function () {
  234. if ($("div[type='login']").is(event.target) || $("button[type='quit']").is(event.target)){
  235. $("div[type='login']").css('display','none');
  236. }
  237. },
  238. login:function () {
  239. var message = $(event.target).parent('label').prevAll('label');
  240. var account = $(message[1]).find('input').val();
  241. var password = $(message[0]).find('input').val();
  242. var account_info = $(message[1]).next('span')[0];
  243. var password_info = $(message[0]).next('span')[0];
  244. var account_title = $(message[1]).find('span').eq(1).text();
  245. var password_title = $(message[0]).find('span').eq(1).text();
  246. if (account === defaultStatus||account===null){
  247. account_info.innerText = account_title+'不能为空';
  248. } else if (account.indexOf(' ') !== -1){
  249. account_info.innerText = password_title+'不能包含空格';
  250. }
  251. if (password === defaultStatus||password ===null){
  252. password_info.innerText = password_title+'不能为空';
  253. } else if (password.indexOf(' ') !== -1){
  254. password_info.innerText = password_title+'不能包含空格';
  255. }
  256. if (account !== defaultStatus
  257. &&account!==null
  258. &&account.indexOf(' ') === -1
  259. &&password !== defaultStatus
  260. &&password !==null
  261. &&password.indexOf(' ') === -1){
  262. $.post('http://127.0.0.1:13141/login',{
  263. account:account,
  264. password:password,
  265. },function (data) {
  266. alert_s(data.msg);
  267. if (data.error === 1){
  268. $.cookie('uuid',data.uuid,{exports:15});
  269. document.location.href = document.location.href;
  270. }
  271. })
  272. }
  273. },
  274. QR_code:function(){
  275. let qr_info = {
  276. time:new Date(),
  277. }
  278. $(event.target).parent('label').next('label').find('img').attr('src','http://qrs.kegood.com/?url='+JSON.stringify(qr_info))
  279. $(event.target).parent('label').parent('div').find('label').css('display','none')
  280. $(event.target).parent('label').parent('div').find('label')[0].style.display = 'block';
  281. $(event.target).parent('label').parent('div').find('label')[4].style.display = 'block';
  282. },
  283. account_login:function () {
  284. $(event.target).parent('label').parent('div').find('label').css('display','block')
  285. $(event.target).parent('label').parent('div').find('label')[4].style.display = 'none';
  286. }
  287. }
  288. }
  289. };
  290. }
  291. });
  292. new Vue({
  293. el:'#ifame'
  294. })
  295. })