123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- $(function(){
- //导航
- if($('.carousel-inner div').length<=1){
- $('#myCarousel').removeClass('slide');
- }
- $(".index_blur").html("×");
- $(".pub_fix").after("<div class='right_cebian'>侧边导航</div>");
- $(".index_blur").click(function(){
- $(".pub_fix").animate({right:"-70px"},"fast",function(){
- $(".right_cebian").show("fast");
- });
- });
- $(".right_cebian").click(function(){
- $(".right_cebian").hide("fast");
- $(".pub_fix").animate({right:"20px"},"fast",function(){
- });
- });
- //二级导航
- $('.nav ul li').mouseenter(function(){
- $(this).find('.subnavigation').slideDown(100);
- });
- $('.nav ul li').mouseleave(function(){
- $(this).find('.subnavigation').slideUp(100);
- $('.nav ul li').stop(false,true);
- });
- //挂件
- $(window).scroll(function(){
- // 滚动条距离顶部的距离 大于 200px时
- if($(window).scrollTop() >= 200){
- $('.pub_fix ul li:eq(0)').addClass('active'); // 开始淡入
- } else{
- $('.pub_fix ul li:eq(0)').removeClass('active'); // 如果小于等于 200 淡出
- }
- });
- $('.pendent_box').click(function(e){
- e.preventDefault();
- $("body,html").animate({scrollTop:0},500)
- });
- //登陆页面
- var hht=$(window).height();
- $('.login').height(hht);
- //点击x
- $('.log_del').click(function(){
- $('#Lo_user').val('');
- $('#Lo_user').focus();
- $('#Lo_user').css({color:'#333333'});
- })
- // 登陆事件
- $('.head_login').click(function(e){
- e.preventDefault();
- $('.login').fadeIn(800)
- $('#form_register').fadeOut(800)
- })
- $('.login_close').click(function(){
- $('.login').fadeOut(800)
- $('#form_register').fadeIn(800)
- })
- $('#form_login').submit(function(e){
- e.preventDefault();
- var Suser=$('#Lo_user').val();
- var Spass=$('#Lo_pass').val();
- var type=$(".login_pass>#customerType").val();
- var check_experts=$('#checks').prop('checked');
- if(Suser==''||Spass==''){
- msg('请填写用户名/密码.');
- return false;
- }else{
- $('.loading').show();
- let txt = "登录中,请稍后...",htmls=[],i=0,
- txtArr = txt.split('');
- txtArr.map(item=>{
- htmls.push(`
- <span>${item}</span>
- `)
- });
- $('.loading div p').html(htmls);
- $.ajax({
- method: "POST",
- dataType: "json",
- url: globalConfig.context + "/signin",
- data: {
- "mobile": Suser,
- "password": Spass,
- 'type':type
- },
- success: function (rest) {
- $('.loading').hide();
- if (rest.error && rest.error.length) {
- msg(rest.error[0].message);
- } else {
- var data = rest.data;
- if (data && data.requestURI) {
- var path = globalConfig.context + data.requestURI;
- if (data.queryString) {
- path += '?' + data.queryString;
- }
- if (window.location.hash) {
- path += window.location.hash;
- }
- window.location.href = path;
- } else {
- msg('登录成功,2秒后跳转个人中心');
- setTimeout(()=>{
- window.location.href = globalConfig.context + "/user/account/index.html";
- },2000)
- }
- }
- }
- })
-
- }
- })
- //提示框渐隐函数
- function msg(mess) {
- if($('.smg').hasClass('active')){
- return ;
- }
- $('.smg').addClass('active');
- $('#msg').val(mess);
- setTimeout(function () {
- $('.smg').removeClass('active')
- $('#msg').val('');
- }, 2000)
- }
-
- // //在线客服
- // (function(m, ei, q, i, a, j, s) {
- // m[i] = m[i] || function() {
- // (m[i].a = m[i].a || []).push(arguments)
- // };
- // j = ei.createElement(q),
- // s = ei.getElementsByTagName(q)[0];
- // j.async = true;
- // j.charset = 'UTF-8';
- // j.src = 'https://static.meiqia.com/dist/meiqia.js?_=t';
- // s.parentNode.insertBefore(j, s);
- // })(window, document, 'script', '_MEIQIA');
- // _MEIQIA('entId', 77931);
- // _MEIQIA('withoutBtn');
- //点击登录界面的忘记密码 ,将会弹出忘记密码界面
- $('.login_check a').click(function(e){
- e.preventDefault();
- $('#forget_user').val('');
- $('#forget_phone').val('');
- $('#photo_n').val('');
- $('.login').fadeOut(800);
- $('#form_register').fadeOut(800);
- $("#forget").fadeIn(800);
- });
- //点击忘记密码右上角的×,将会关闭界面并清空里面的内容
- $('#forget .login_close').click(function(){
- $('#forget').fadeOut(800);
- $('#form_register').fadeIn(800);
- $("#forget_phone").val("");
- $("#forget_yanzheng").val("");
- $("#photo_n").val("");
- });
- //点击取消,相当于点击×
- $("#forget .fastener_right").click(function(){
- $('#forget .login_close').click();
- });
- //点击重置密码右上角的×,将会关闭界面并清空里面的内容
- $('#new_password .login_close').click(function(){
- $('#new_password').fadeOut(800)
- $('#form_register').fadeIn(800)
- });
- //点击取消,相当于点击×
- $("#new_password .fastener_right").click(function(){
- $('#new_password .login_close').click();
- });
- let use_forget,phone_forget;
- //点击忘记密码里面的确认,则发送一个请求,并跳转到重置密码界面
- $('#forget_form').submit(function(e){
- e.preventDefault();
- use_forget = $('#forget_user').val();
- phone_forget=$("#forget_phone").val();
- var phone_n_forget=$("#photo_n").val();
- var type=$(".login_pa>#customerTy").val();
- if(!(phone_forget).trim()){
- msg('亲,请填写正确的手机号码')
- return;
- };
- if(!(phone_n_forget).trim()){
- msg('亲,请填写手机验证码')
- return;
- };
- $.ajax({
- type: "POST",
- dataType: "json",
- url: globalConfig.context + "/open/checkMNCode",
- data: {
- 'mobile':phone_forget,
- 'mobileCode': phone_n_forget,
- 'type':type
- },
- success: function (rest) {
- if (rest.error && rest.error.length) {
- msg(rest.error[0].message);
- } else {
- $('#forget').fadeOut(800);
- $('#form_register').fadeOut(800);
- $("#new_password").fadeIn(800);
- $(".password_top>h4").attr("val",rest.data);
- $('#new_pass').val();
- $('#new_pass_again').val();
- }
- }
- })
- });
- //点击重置密码里面的确认,则发送一个请求,并关闭重置密码界面
- $('#new_password_form').submit(function(e){
- e.preventDefault();
- var pass_pattern=/^[a-zA-Z0-9]{6,12}$/;
- var new_pass=$("#new_pass").val();
- var new_pass_again=$("#new_pass_again").val();
- var reset_code=$(".password_top>h4").attr("val");
- var type=$(".login_pa>#customerTy").val();
- if(!new_pass||!new_pass_again){
- msg('亲,新旧密码必填!')
- return;
- }
- if(new_pass!==new_pass_again){
- msg('亲,两次密码不一致')
- return;
- }
- if(!pass_pattern.test(new_pass)){
- msg('亲,密码格式不正确')
- return ;
- }
- $.ajax({
- type: "post",
- dataType: "json",
- url: globalConfig.context + "/open/resetPassword",
- data: {
- 'type':type,
- "newPwd": new_pass,
- 'mobile':phone_forget,
- 'resetCode':reset_code
- },
- success: function (rest) {
- if (rest.error && rest.error.length) {
- msg(rest.error[0].message);
- } else {
- $('.login').fadeIn(800);
- $('#form_register').fadeOut(800);
- $("#new_password").fadeOut(800);
- msg('修改成功!');
- }
- }
- })
- });
- //手机号码的验证
- function photoyanzheng(){
- var pho_pattern=/^1[3|4|5|7|8][0-9]{9}$/;
- $("#forget_phone").keyup(function(){
- var phol= $(this).val();
- if(pho_pattern.test(phol)){
- $('#photo_m').attr('disabled', false);
- $("#photo_m").css("color","#F18101");
- }else if(!pho_pattern.test(phol)){
- $('#photo_m').attr('disabled', true);
- $("#photo_m").css("color","#ccc");
- }
- });
- $('#forget_phone').blur(function () {
- var pho= $(this).val();
- if (pho==''||!pho_pattern.test(pho)) {
- $(this).val('');
- $(this).attr('placeholder', '请输入正确的号码')
- } else{
- $('#photo_m').attr('disabled', false);
- $("#photo_m").css("color","#F18101");
- }
- })
- }
- photoyanzheng();
- //点击刷新图片验证码
- $('.yanzhengma_cont_').click(function () {
- $('.yanzhengma_cont_ img').attr('src', (globalConfig.context + "/open/getVCode?t=" + Math.random()))
- });
- var tt = 30;
- $('#photo_m').click(function () {
- //手机验证功能
- var ophoto = $('#forget_phone').val();
- var types = $('#forget_checks').prop("checked") ? '0' : '1';
- var phott = $('#forget_yanzheng').val();
- //验证码倒计时
- $('#photo_m').attr('disabled', true);
- $(this).attr('disabled', true);
- var timer = setInterval(function () {
- tt -= 1;
- $('#photo_m').attr('disabled', true);
- $(this).val("发送"+'('+tt+'s'+')');
- $(this).css({color:'#cccccc'})
- if (tt == 0) {
- clearInterval(timer);
- $('#photo_m').attr('disabled', false);
- $(this).attr('disabled', false);
- tt=30;
- $(this).css({color:'rgb(241, 129, 1)'})
- $(this).val('重新发送');
- }
- }.bind(this), 1000);
- $.ajax({
- type: "GET",
- url: globalConfig.context + "/open/getMCode",
- data: {
- "mobile": ophoto,
- "sign": false,
- "verificationCode": phott
- },
- success: function (data) {
- if (data.error && data.error.length) {
- msg(data.error[0].message);
- } else {
- msg('发送成功');
- }
- return true;
- }
- });
- });
- //loading
- loading();
- function loading(){
- clearInterval(setTime)
- let txt = "努力加载中...",htmls=[],i=0,
- txtArr = txt.split('');
- let ps = document.createElement('p');
- txtArr.map(item=>{
- htmls.push(`
- <span>${item}</span>
- `)
- });
- ps.innerHTML=htmls.join('');
- $('.loading div').html(ps);
- function active(){
- i++;
- if(i>txtArr.length){
- i=0;
- };
- $('.loading p span').eq(i).addClass('active').siblings().removeClass('active');
- }
- var setTime =setInterval(()=>{active()},100);
- }
- //网站导航
- $('.navigationList').mouseenter(function(){
- $('.navWrapper').slideDown(100)
- })
- $('.navWrapper').mouseleave(function(){
- $('.navWrapper').slideUp(100)
- $('.navWrapper').stop(false,true);
- })
-
- /* 购物车部分 */
- //获取购物车商品位置
- tint();
- function tint(){
- if($('a').hasClass('shopCar')){
- let shopH = $('.shopCar').offset().top,
- shopCH = $('.shopIcon').offset().top,
- shopL = $('.shopCar').offset().left,
- shopC = $('.shopIcon').offset().left;
- $('.shopIcon .tint').css({'top':(shopH-shopCH)+'px','left':-(shopC-shopL)+'px'})
- }
- }
- //购物车
- {
- //数量
- $('#number').keyup(function(){
- if($(this).val()>99){
- $(this).val('99');
- }
- if($(this).val()<1){
- $(this).val('1');
- }
- })
- //购物动作
- $('.shopIcon .tint').hide();
- $('.shopCar').click(function(){
- if( $('.shopIcon .tint').hasClass('active')){
- return false;
- }else{
- btnFn();
- getLoc();
- $('.shopIcon .tint').show();
- $('.shopIcon .tint').css({'opacity':1})
- $('.shopIcon .tint').addClass('active');
- setTimeout(()=>{
- $('.shopIcon .tint').removeClass('active');
- $('.shopIcon .tint').hide();
- },800)
- }
- })
- //本地存储
- var shopList = [],
- preShop,
- state = false;
- init();
- function init() {
- getLoc();
- }
- //初始判断是否有存储
- function getLoc(){
- let oldlist = localStorage.getItem('shopList');
- if(oldlist){
- preShop = JSON.parse(oldlist);
- shopList=preShop.data;
- let nubTotal =0;
- shopList.map(item=>{
- nubTotal+=parseInt(item.number)
- })
- $('.numberTotal').text(nubTotal)
- };
- };
- //点击加入商品
- var hash = window.location.search,ids='',idList=[];
- if(hash.indexOf('&')){
- idList=hash.split('&');
- ids=idList[0].split('=')[1];
- }else{
- ids= hash.split('=')[1];
- }
- function btnFn() {
- //每次点击时获取上次存储的数据累加
- getLoc();
- state = true;
- var name = escape($('.cname').text()), //中文进行编译
- id=ids,
- companyName=$('.companyName').text(),
- type=$('.cname').attr('data'),
- img = $('.serviceDetailsImg>img').attr('src'),
- number = parseInt($('#number').val()),
- type=$('.orderType').attr('type'),
- price = $('.price').text();
- // 商品信息对象
- let pro = new Object();
- pro.id = id;
- pro.type=type;
- pro.name = name;
- pro.img = img;
- pro.companyName=companyName;
- pro.number = number;
- pro.price = price;
- //初始加入
- if(shopList.length < 1) {
- shopList.push(pro);
- local(shopList)
- return;
- };
- //判断是否重复加入
- shopList.map((item, index) => {
- if(item.id === ids) {
- shopList[index].number = parseInt(shopList[index].number) + parseInt(number);
- state = false;
- }
- });
- if(state) {
- shopList.push(pro);
- };
- local(shopList);
- };
- function local (shopList){
- let data=new Object();
- data.data=shopList;
- let setData = JSON.stringify(data);
- //本地存储
- localStorage.setItem('shopList',setData);
- };
- //title处理
- titleLen();
- function titleLen(){
- $('.RecommendTitle h2,.patentTitle h2').mouseenter(function(){
- let h2Len = $(this).text(),
- lenW = (h2Len.length)*30;
- $(this).siblings().css({
- width:lenW+'px',
- transition: 'all .5s ease-in-out'
- })
- })
- $('.RecommendTitle h2,.patentTitle h2').mouseout(function(){
- let h2Len = $(this).text(),
- lenW = (h2Len.length)*30;
- $(this).siblings().css({
- width:'54px'
- })
- })
- }
-
- }
- });
|