').removeClass('icon_downarrow'); } else { $(this).parent('h3').siblings('h2').addClass('hShort'); $(this).children('span').text('更多'); $(this).children('i').addClass('icon_downarrow').removeClass('icon_uparrow'); } }); function sendws(data) { if (data.data.res == undefined) { setTimeout(function () { if (data.data && data.data.url) { window.location.href = data.data.url; } else { window.location.href = '/'; } }, 1000) return false; } let [now_subsite_id, login_type, addId] = data.data.res; if (now_subsite_id == undefined) { console.log('get send ws data faild'); } try { var prefix = (window.location.protocol === "https:") ? "wss://" : "ws://"; var prefix_after = (window.location.protocol === "https:") ? '/wss' : ':9492'; var wsUrl = prefix + "www.zhiyanxuan.com" + prefix_after; ws = new WebSocket(wsUrl); ws.onopen = function () { let msgObj = { 'type': login_type, 'from': 'zhiyanxuan.com', 'to': now_subsite_id, 'content': addId, } console.log(JSON.stringify(msgObj)) ws.send(JSON.stringify(msgObj)); }; ws.onmessage = function (e) { console.log("收到服务端的消息:" + e.data); setTimeout(function () { ws.close(); if (data.data && data.data.url) { window.location.href = data.data.url; } else { window.location.href = '/'; } }, 1000) }; } catch (e) { console.log(e); } } $().ready(function () { $("#logout").click(function () { $.ajax({ type: "post", url: "/user_logout.html", data: { token: 'token' }, dataType: "json", success: function (data) { console.log(data) layer.msg(data.msg); if (data.code == 1) { setTimeout(function () { window.location.href = '/'; }, 1000) } }, error: function (e) { layer.msg('网络错误,请重试') } }); }) $("#home_content_add,#banneradd,#banneradd2").click(function () { var dataid = $(this).data('id') var mobile = $("#" + dataid + " input[name='mobile']").val(); var name = $("#" + dataid + " input[name='name']").val(); var weixin = $("#" + dataid + " input[name='weixin']").val(); var classgrades = $("#" + dataid + " select[name='classgrades']").val(); var classsubject = $("#" + dataid + " select[name='classsubject']").val(); if (dataid == 'banner_form') { var type = 'banner' } else { var type = '免费试听'; } if (!phoneFun(mobile)) { layer.msg('手机号格式错误'); return false; } if (name == '') { layer.msg('联系人必填'); return false; } if (classgrades == '' || classgrades == 0 || classsubject == '' || classsubject == 0) { layer.msg('年级科目必选'); return false; } $.ajax({ type: "post", url: "/index_c_submit.html", data: { c_userphone: mobile, name: name, c_classgrades: classgrades, c_classsubject: classsubject, weixin: weixin, type: type }, dataType: "json", success: function (data) { console.log(data) layer.msg(data.msg); // setTimeout(function () { // sendws(data); // }, 1000) // if(data.code == 1){ // setTimeout(function(){ // window.location.href = data.data.url; // },1500) // } }, error: function (e) { layer.msg('网络错误,请重试') } }); }) // $("#captcha").click(function () { // // console.log("2222") // $(this).attr('src', '/captcha/verify.html?s' + Math.random()); // }) // $("#captcha2").click(function () { // // console.log("111111111") // $(this).attr('src', '/captcha/verify.html?s' + Math.random()); // }) $(".banner_fd").hover(function () { $(".banner_lb_div").hover(function () { $(".banner_lb_content").hide() $(this).next('.banner_lb_content').show() }, function () { $('.banner_lb_content').hover(function () { $(this).show() }, function () { $(this).hide() }) }) }, function () { $(".banner_lb_content").hide() }) $("#changeuseravatar").click(function () { var avatarlayer = layer.open({ type: 2, title: '修改头像', content: '/user_change_avatar.html', area: ['900px', '570px'] }); }) $("#home_left .icon_close").click(function () { $("#home_left").toggle() }) })