login_html.js 16 KB

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