login_html.js 14 KB

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