
var layset = {
  icon: 7,
  title: "提醒",
  // skin: 'jm-class'
};
//替换.为_
function thym2(ym) {
  return ym.replace(/\./g, "_").toLowerCase();
}
//表单验证
function yz(div) {
  var x = 0;
  $("#" + div + " input[required='required']").each(function () {
    if ($(this).val() == "") {
      var msg = $(this).attr("placeholder");
      if (!msg) {
        msg = $(this).attr("msg");
      }
      if (msg && msg.length > 0) {
        layer.msg(msg);
        // $("#" + div + ">" + ".tip").html(
        //   '<p><i class="iconfont">&#xe62a;</i> <span>' + msg + "</span></p>"
        // );
        $("#" + div + " input[required='required']")
      }
      // $(this).addClass('has-error').focus();
      x = 1;
      return false;
    } else {
      // $("#" + div + ">" + ".tip").html("");
      // $(this).removeClass('has-error');
    }
  });
  if (x == 1) {
    return false;
  }
  return true;
}
//登录验证
function islogin(txt) {
  if (uid != 1) {
    if (typeof txt === "undefined") {
      txt = "继续操作";
    }
    layset.icon = "7";
    txt = "<font color=red>对不起，您需要登录本站帐户，才能继续操作。</font>";
    // layset.end = function () {
    //     login();
    // };
    layer.alert(txt, function () {
      loginPop();
    });
    return false;
  }
  return true;
}
//完善信息验证
function iswsxx(txt) {
  if (xxws != 1) {
    txt = "<font color=red>您好，需要先完善个人信息，才能免费发布合作。</font>";
    layer.alert(txt, {
      title: "提示",
      icon: '7',
      btn: ["完善信息"], //按钮
      end: function () {
        window.open("/wsxx");
      }
    });
    return false;
  }
  return true;
}
//会员验证
function iskthy(txt) {
  if (ishy != 1) {
    txt = "<font color=red>对不起，您需要开通会员，才能继续操作。</font>";
    layer.alert(txt, {
      title: "提示",
      skin: "jm_jhy", //样式类名  自定义样式
      icon: '7',
      area: ["480px"],
      btn: ["成为会员"], //按钮
      end: function () {
        window.open("/hytq");
      }
    });
    return false;
  }
  return true;
}

//登录框框
function loginPop() {
  layer.closeAll();
  layer.open({
    type: 1,
    skin: "jm-class",
    title: false,
    area: ["440px", ""],
    content: loginhtml,
    success: function () {
      $('.login_wrap .yzm_img').attr('src', '/qtmain/g_getcode?t=' + new Date().getTime());
      $(".jm-class .cancel-btn").click(function () {
        layer.closeAll();
      });
      $(".jm-class .tc_logbtn").click(function () {
        var lx = $(this).attr("lx");
        loginSubmitPop(lx);
      });

      $("#bdlog_box1 input").keyup(function (e) {
        if (e.keyCode == 13) {
          loginSubmitPop(1);
        }
      });
      $("#bdlog_box2 input").keyup(function (e) {
        if (e.keyCode == 13) {
          loginSubmitPop(2);
        }
      });

    },
  });
}
//url参数获取
function getQueryVariable(name) {
  // 获取参数
  var url = window.location.search;
  // 正则筛选地址栏
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  // 匹配目标参数
  var result = url.substr(1).match(reg);
  //返回参数值
  return result ? escape(decodeURIComponent(result[2])) : null;
}
//对参数值进行过滤
function escape(str) {
  str = str.replace(/&/g, '&amp;');
  str = str.replace(/</g, '&lt;');
  str = str.replace(/>/g, '&gt;');
  str = str.replace(/"/g, '&quto;');
  str = str.replace(/'/g, '&#39;');
  str = str.replace(/`/g, '&#96;');
  str = str.replace(/\//g, '&#x2F;');
  return str;
}

//弹窗登录刷新当前页面一次
function loginSubmitPop(lx) {
  if (!yz("bdlog_box" + lx)) {
    return false;
  }
  if (lx == 1) {
    var datas = {
      lx: lx,
      sjh: $('#bdlog_box1 input[name="re_phone"]').val(),
      mm: $('#bdlog_box1 input[name="re_mm"]').val(),
      p_yzm: $('#bdlog_box1 input[name="p_yzm"]').val(),
      remember: '1', //功能去掉,默认传0
    };
  } else {
    var datas = {
      lx: lx,
      sjh: $('#bdlog_box2 input[name="re_phone"]').val(),
      yzm: $('#bdlog_box2 input[name="re_yzm"]').val(),
      p_yzm: $('#bdlog_box2 input[name="p_yzm"]').val(),
      remember: '1', //功能去掉,默认传0
    };
  }
  $.ajax({
    type: "POST",
    data: datas,
    url: "/yh/login",
    success: function (res) {
      if (res.code == 1) {
        layer.msg(res.msg, {
          shift: -1,
          time: 1000
        }, function () {
          localStorage.setItem('remember', '1');
          location.reload();
        })
      } else {
        layer.msg(res.msg);
        $('.login_wrap .yzm_img').attr('src', '/qtmain/g_getcode?t=' + new Date().getTime());
      }
    },
  });
}
// 注册   1表示注册3表示手机号找回密码4表示邮箱找回密码
function regSubmit(lx) {
  if (!yz("login_reg")) {
    return false;
  }
  if (lx == 1) {
    if (!$("#xieyicheck").is(":checked")) {
      return layer.msg('请先阅读并同意注册协议！');
    }
  }

  var datas = {
    // sjh手机号码
    // yzm验证码
    // mm密码
    // qrmm确认密码
    // 1表示注册3表示手机号找回密码4表示邮箱找回密码
    sjh: $("#reg_phone").val(),
    yzm: $("#reg_yzm").val(),
    mm: $("#reg_mm").val(),
    qrmm: $("#reg_mm2").val(),
    p_yzm: $("#p_yzm2").val(),
    invite_code: $("#invite_code").val(),
    lx: lx,
  };
  $.ajax({
    type: "POST",
    data: datas,
    url: "/yh/register",
    success: function (res) {
      if (res.code == 1) {
        layer.msg(res.msg, {
          shift: -1,
          time: 1000
        }, function () {
          window.location.href = "/wsxx";
        })
      } else {
        $('.login_box .yzm_img').attr('src', '/qtmain/g_getcode?t=' + new Date().getTime());
        return layer.msg(res.msg);
      }
    },
  });
}
//发送短信
function send_sms(datas, callback) {
  $.ajax({
    url: "/yh/get_smsyz",
    dataType: "json",
    type: "post",
    data: datas,
    success: function (res) {
      if (typeof callback == "function") {
        callback(res);
      }
    },
  });
}
// 发送邮箱
function send_email(datas, callback) {
  $.ajax({
    url: "/rmqb/send_yj",
    dataType: "json",
    type: "post",
    data: datas,
    success: function (res) {
      if (typeof callback == "function") {
        callback(res);
      }
    },
  });
}
// 倒计时
var countdown = 60;

function settimeReg(obj) {
  if (countdown == 0) {
    obj.removeAttribute("disabled");
    obj.value = "重发";
    countdown = 60;
    return;
  } else {
    obj.setAttribute("disabled", true);
    obj.value = countdown + "s";
    countdown--;
  }
  setTimeout(function () {
    settimeReg(obj);
  }, 1000);
}

var cxdown = 60;

function settimeLogin(obj) {
  if (cxdown == 0) {
    obj.removeAttribute("disabled");
    obj.value = "重发";
    cxdown = 10;
    return;
  } else {
    obj.setAttribute("disabled", true);
    obj.value = cxdown + "s";
    cxdown--;
  }
  setTimeout(function () {
    settimeLogin(obj);
  }, 1000);
}

// 评价弹窗
function evalpop(data) {
  var evalHtml =
    '<div class="evaluate_pop">' +
    '                <div class="tit">真实度评价</div>' +
    '                <div class="zan_cont clear">' +
    '                    <span class="zan_t fl">' +
    '                        <i class="iconfont">&#xe613;</i>' +
    "                        <b>点赞</b>" +
    '                        <em class="num">' +
    data.zan_cs +
    "</em>" +
    '                        <span class="icon icon1">+1</span>' +
    "                    </span>" +
    '                    <span class="zan_b fr">' +
    '                        <i class="iconfont">&#xe612;</i>' +
    "                        <b>倒赞</b>" +
    '                        <em class="num">' +
    data.cai_cs +
    "</em>" +
    '                        <span class="icon icon2">+1</span>' +
    "                    </span>" +
    "                </div>" +
    '                <div class="evaluate_box">' +
    '                    <div class="tips"> <i class="iconfont">&#xe62d;</i> 感谢您的神力，因您的正面评价，我的排名将立即飞升</div>' +
    '                    <div class="zsd_lis">' +
    "                        <span>印象标签：</span>" +
    '                        <ul class="yx_ul1 clear">' +
    '                            <li data-pjlx = "1"  data-mc = "资源不错">资源不错</li>' +
    '                            <li data-pjlx = "1"  data-mc = "反馈及时">反馈及时</li>' +
    '                            <li data-pjlx = "1"  data-mc = "需求明确">需求明确</li>' +
    '                            <li data-pjlx = "1"  data-mc = "态度好">态度好</li>' +
    '                            <li data-pjlx = "1"  data-mc = "已达成合作">已达成合作</li>' +
    "                        </ul>" +
    '                        <ul class="yx_ul2 clear">' +
    '                            <li data-pjlx = "2"  data-mc = "资源不好">资源不好</li>' +
    '                            <li data-pjlx = "2"  data-mc = "反馈不及时">反馈不及时</li>' +
    '                            <li data-pjlx = "2"  data-mc = "不是主品牌">不是主品牌</li>' +
    '                            <li data-pjlx = "2"  data-mc = "需求不明确">需求不明确</li>' +
    '                            <li data-pjlx = "2"  data-mc = "未达成合作">未达成合作</li>' +
    "                        </ul>" +
    "                    </div>" +
    "                </div>" +
    '                <div class="eval_btn_box">' +
    '                    <button class="qx">取 消</button>' +
    '                    <button class="sure zan_sure">确 定</button>' +
    "                </div>" +
    "            </div>";
  layer.closeAll();
  layer.open({
    type: 1,
    skin: "jm-class",
    title: false,
    area: ["480px", ""],
    content: evalHtml,
    success: function () {
      $(".evaluate_pop .qx").click(function () {
        layer.closeAll();
      });
    },
  });
}
// 头部发布弹窗
function fabuSubmit() {
  if (!islogin()) {
    return false;
  }
  if (!iswsxx()) {
    return false;
  }
  layer.closeAll();
  layer.open({
    type: 1,
    skin: "jm-class",
    title: false,
    area: "932px",
    content: fbTpl
  });
}

//表单验证
function checkInput(id, msg, type) {
  if (type == 1) {
    msg = msg + "不能为空";
  } else {
    msg = "请选择" + msg;
  }
  if ($("#" + id).val() == "") {
    $("#" + id).addClass("border_red");
    $("#" + id)
      .parent()
      .next(".warning")
      .removeClass("hide");
    $("#" + id)
      .parent()
      .next(".warning")
      .html('<i class="iconfont">&#xe62a;</i>' + msg);
  } else {
    $("#" + id)
      .parent()
      .next(".warning")
      .addClass("hide");
    $("#" + id).removeClass("border_red");
  }
}
// 加好友
function addfriend(id, nr) {
  var datas = {
    to_uid: id,
    nr: nr,
  };
  $.ajax({
    type: "POST",
    data: datas,
    url: "/gzsc/tj_hy",
    success: function (res) {
      if (res.code == 1) {
        layer.msg(res.msg);
      } else if (res.code == -3) {
        layer.alert(res.msg, {
          title: "提示",
          skin: "jm_jhy", //样式类名  自定义样式
          area: ["480px"],
          btn: ["成为会员"], //按钮
          yes: function () {
            window.open("/hytq");
          },
        });
      } else {
        layer.msg(res.msg);
      }
    },
  });
}
// 发消息
function fxxFriend(id, nr) {
  var datas = {
    to_uid: id,
    nr: nr,
  };
  $.ajax({
    type: "POST",
    data: datas,
    url: "/gzsc/send_msg",
    success: function (res) {
      if (res.code == 1) {
        layer.msg(res.msg);
      } else {
        layer.msg(res.msg);
      }
    },
  });
}


// 判断是否能点赞
function is_zan(datas, callback) {
  $.ajax({
    url: "/xqlb/is_pj",
    dataType: "json",
    type: "post",
    data: datas,
    success: function (res) {
      if (typeof callback == "function") {
        callback(res);
      }
    },
  });
}
// 判断是否过期 合作（lx: 1）:0已结束 1正常 , 活动（lx：2）:0已结束 1正常  2未开始
function is_time() {
  var is_valid = $("#is_valid").val();
  var lx = $("#lx").val();

  if (lx == 1) {
    if (is_valid == 0) {

      layer.alert("该合作已过期！", {
        title: "提示",
        skin: "jm_jhy", //样式类名  自定义样式
        btn: ["确认", "取消"], //按钮
      });
      return false;
    }
    return true;
  } else if (lx == 2) {
    if (is_valid == 0) {
      layer.alert("该活动已结束！", {
        title: "提示",
        skin: "jm_jhy", //样式类名  自定义样式
        btn: ["确认", "取消"], //按钮
      });
      return false;
    }
    return true;
  }
}
// 获取随机颜色
function bqcolor() {
  var lis = $(".my_result .bq a");
  for (var i = 0; i < lis.length; i++) {
    var num = getRandomInt(1, 5);
    $(lis[i]).addClass("color" + num);
  }
}

function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

//检查登录
function checkLogin() {
  $.ajax({
    type: "POST",
    data: {},
    url: "/yh/checklogin",
    success: function (res) {
      if (res.code == 1) {
        location.reload();
      } else {
        return false;
      }
    },
  });
}
//wow动画效果调用函数
function browserRedirect() {
  var sUserAgent = navigator.userAgent.toLowerCase();
  var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
  var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
  var bIsMidp = sUserAgent.match(/midp/i) == "midp";
  var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
  var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
  var bIsAndroid = sUserAgent.match(/android/i) == "android";
  var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
  var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
  if (
    !/msie [6|7|8|9]/i.test(navigator.userAgent) &&
    !(
      bIsIpad ||
      bIsIphoneOs ||
      bIsMidp ||
      bIsUc7 ||
      bIsUc ||
      bIsAndroid ||
      bIsCE ||
      bIsWM
    )
  ) {
    new WOW().init();
  }
}
//表单focus验证
function formyz(div) {
  var x = 0;
  $("#" + div + " input[required='required']").each(function () {
    if ($(this).val() == "") {
      var msg = $(this).attr("placeholder");
      if (!msg) {
        msg = $(this).attr("msg");
      }
      // if (msg && msg.length > 0) {
      // 	layer.msg(msg);
      // }
      $(this).addClass("has-error").focus();
      x = 1;
      return false;
    } else {
      $(this).removeClass("has-error");
    }
  });
  if (x == 1) {
    return false;
  }
  return true;
}

// 验证用户类型，传不同验证码类型  簡易發佈中使用
function yzUser(datas, callback) {
  $.ajax({
    url: "/yh/check_has_registered",
    dataType: "json",
    type: "post",
    data: datas,
    success: function (res) {
      if (typeof callback == "function") {
        callback(res);
      }
    },
    error: function (res) {
      layer.msg("网络连接失败！请稍候重试~");
    },
  });
}

// 防抖函数
function debounce(func, wait) {
  let timeout;
  return function () {
    const context = this, args = arguments;
    clearTimeout(timeout);
    timeout = setTimeout(() => func.apply(context, args), wait);
  };
}
// 微信快捷登录
var timer;
var wx_flag;

$(document).on("click", ".dsf_wx", function () {
  layer.closeAll();
  getWxewm(1)
});
function getWxewm(type) {

  $.ajax({
    type: "POST",
    data: {},
    url: "/wx/get_wxdl_ewm",
    success: function (res) {
      if (res.code == 1) {
        $('#wxkj_pop .code_mask_wrapper').addClass('hide');
        var url = res.url;
        wx_flag = res.wx_flag;
        $("#wxkj_pop img").attr("src", url);
        if (type == 1) {
          layer.open({
            type: 1,
            skin: "jm-class",
            title: false,
            area: "360px",
            content: $("#wxkj_pop"),
            success: function () {
              timer = setInterval(chawxLogin, 2000); //定时器，2,秒查一下是否登录微信
            },
            end: function () {
              window.clearInterval(timer);
            },
          });
        } else {
          timer = setInterval(chawxLogin, 2000); //定时器，2,秒查一下是否登录微信
        }
      } else {
        return false;
      }
    },
  });
}
// 微信快捷登录
function chawxLogin() {
  var datas = {
    wx_flag: wx_flag,
    url: window.location.href,
  };
  $.ajax({
    type: "POST",
    data: datas,
    url: "/wx/is_sm",
    success: function (res) {
      if (res.code == 1) {
        window.location.href = res.url;
        window.clearInterval(timer);
      } else if (res.code == 2) {
        window.clearInterval(timer);
        if (res.url == "") {
          layer.closeAll();
          $("#bdlog_box1 .tip").html(
            '<p><i class="iconfont">&#xe62a;</i> <span>' +
            res.bz +
            "</span></p>"
          );
        } else {
          window.location.href = "/login";
          localStorage.setItem("tiao_url", res.url);
        }
      } else if (res.code == -101) {
        window.clearInterval(timer);
        $('#wxkj_pop .code_mask_wrapper').removeClass('hide');
      }
    },
  });
}






$(function () {
  // 合作大厅分类
  var qcloud = {};
  $('[data-fl]').on("mouseover", function () {
    var _this = $(this);
    var _index = $(this).attr("data-fl");
    clearTimeout(qcloud[_index + '_timer']);

    qcloud[_index + '_timer'] = setTimeout(function () {
      $("#" + _index).stop(true, true).show();
      _this.addClass('on').siblings().removeClass('on');
    }, 200);
  }).on("mouseleave", function () {
    var _index = $(this).attr("data-fl");
    clearTimeout(qcloud[_index + '_timer']);
    qcloud[_index + '_timer'] = setTimeout(function () {
      $("#" + _index).stop(true, true).hide();
    }, 400)
  });

  // 导航悬停效果
  $(".header_top .item_hover").hover(function () {
    if ($(this).hasClass('hzdt')) {
      $('.hzdt_left li').eq(0).addClass('on').siblings('.hzdt_left li').removeClass('on')
      $('.drop_son').eq(0).show().siblings('.drop_son').hide()
    }
    $(this).addClass('on');
    $(this).find(".item_child").css("display", "block")
      .animate({
        top: "40px",
        opacity: "1",
      }, 100);
  }, function () {
    $(this).removeClass('on');
    $(this).find(".item_child")
      .animate({
        top: "120px",
        opacity: "0",
      }, 100).css("display", "none");
  });

  //发布判断
  $(document).on("click", ".fb_pop ul a", function () {
    window.location.href = $(this).attr("data-href");
  });







  // 切换登录方式
  $("body").on("click", ".login_type", function (e) {
    e.stopPropagation();
    $(this)
      .parents(".login_log")
      .addClass("hide")
      .siblings(".login_log")
      .removeClass("hide");
  });
  // 获取登录验证码    lx类型1表示注册2表示登录3表示找回密码
  $(document).on("click", ".get_login_yzm", function (e) {
    e.stopPropagation();
    var _this = this;
    var lx = $(this).attr("lx");
    var re_phone2 = $("#re_phone2").val();
    var p_yzm_val = $("#p_yzm").val();
    if (!re_phone2) {
      return layer.msg('请输入手机号');
    }
    if (!p_yzm_val) {
      return layer.msg('请输入图像验证码');
    }
    var datas = {
      sjh: $("#re_phone2").val(),
      p_yzm: p_yzm_val,
      lx: lx,
    };
    send_sms(datas, function (res) {
      if (res.code == 1) {

        layer.msg(res.msg);
        settimeLogin(_this);
      } else {
        layer.msg(res.msg);
        $(".yzm_img").attr("src", "/qtmain/g_getcode?t=" + new Date().getTime());
      }
    });
    return false;
  });
  // 获取注册验证码
  $(".get_reg_yzm").on("click", function (e) {
    // sjh手机号码
    // lx类型1表示注册2表示登录3表示找回密码
    e.stopPropagation();
    var _this = this;
    var reg_phone = $("#reg_phone").val();
    var p_yzm_val = $("#p_yzm2").val();
    if (!reg_phone) {
      return layer.msg("请输入手机号");
    }
    if (!p_yzm_val) {
      return layer.msg("请输入图像验证码");
    }
    var datas = {
      sjh: $("#reg_phone").val(),
      p_yzm: p_yzm_val,
      lx: $(this).attr("lx"),
    };
    send_sms(datas, function (res) {
      if (res.code == 1) {
        layer.msg(res.msg);
        settimeReg(_this);
      } else {
        layer.msg(res.msg);
        $(".yzm_img").attr("src", "/qtmain/g_getcode?t=" + new Date().getTime());
      }
    });
    return false;
  });

  // 获取邮箱验证码
  $(".get_yx_yzm").on("click", function (e) {
    // email邮箱
    // lx类型1绑定邮箱使用2找回密码使用
    e.stopPropagation();
    var _this = this;
    var reg_phone = $("#reg_phone").val();

    if (!reg_phone) {
      return layer.msg('请输入邮箱');
    }
    var p_yzm_val = $("#p_yzm2").val();
    var datas = {
      email: $("#reg_phone").val(),
      lx: $(this).attr("lx"),
      p_yzm: p_yzm_val,
    };
    send_email(datas, function (res) {
      if (res.code == 1) {
        layer.msg(res.msg);
        settimeReg(_this);
      } else {
        layer.msg(res.msg);
        $(".yzm_img").attr(
          "src",
          "/qtmain/g_getcode?t=" + new Date().getTime()
        );
      }
    });
    return false;
  });

  // 职业认证  手机  邮箱绑定  去会员
  $(document).on("click", ".icon_zy", function () {
    var type = $(this).attr("data-cnm");
    if (type == 1) {
      layer.alert("职业已认证");
    } else {
      window.open("/mp_rz");
    }
  });

  $(document).on("click", ".icon_sj", function () {
    var type = $(this).attr("data-cnm");
    if (type == 1) {
      layer.alert("手机已绑定");
    }
  });

  $(document).on("click", ".icon_yx", function () {
    var type = $(this).attr("data-cnm");
    if (type == 1) {
      layer.alert("邮箱已绑定");
    } else {
      window.open("/yx_bd");
    }
  });


  $(".slide_r .item")
    .hover(function (event) {
      $(this).find(".item_box").show();
    })
    .mouseleave(function (event) {
      $(this).find(".item_box").hide();
    });

  if ($('.header_top').length > 0) {
    var s_top = $('.header_top').offset().top;
    getScroll();
  }


  $(window).scroll(function () {
    getScroll()
  });

  function getScroll() {
    if ($(window).scrollTop() >= s_top) {
      $('.header_top').addClass('fixed')
      $('.header_zw').show()
    } else {
      $('.header_top').removeClass('fixed')
      $('.header_zw').hide()
    }
    if ($(window).scrollTop() >= ($('.header_top').height() + $('.header_main').height())) {
      $(".header_main").addClass('fixed');
    } else {
      $(".header_main").removeClass('fixed');
    }

    // 页面滚动隐藏return_top按钮
    if ($(window).scrollTop() > 500) {
      $(".return_top").slideDown();
    } else {
      $(".return_top").slideUp();
    }
  }
  // 向上
  $(document).on("click", ".return_top", function () {
    $("body,html").animate(
      {
        scrollTop: 0,
      },
      300
    );
  });


  // 优质渠道页面跳转判断
  $(document).on("click", ".nav_uqd", function () {
    var datas = {
      lx: 2,
    };
    $.ajax({
      type: "POST",
      data: datas,
      url: "/grzx/get_is_ndhy",
      success: function (res) {
        if (res.code == 1) {
          window.location.href = "/uqd/ux_dpsy";
        } else {
          layer.alert("请开通优质渠道", {
            title: "提示",
            icon: 7,
            skin: "jm_jhy", //样式类名  自定义样式
            btn: ["去开通", "取消"], //按钮
            yes: function () {
              window.location.href = "/zt/uxzt";
            },
          });
        }
      },
    });
  });


  // 图片验证码点击刷新
  $(document).on("click", ".logcont .yzm_img", function () {
    this.src = "/qtmain/g_getcode?t=" + new Date().getTime();
  });


  // 换一批品牌甲方
  var deg = 0;
  var pp_page = 1;
  var zlock = false;
  $(document).on('click', '.common_result_right .ruzhu_box .huan', function () {
    if (!zlock) {
      zlock = true;// 设置为已点击状态
      deg += 360;
      pp_page++;
      var ly = $(this).attr('data-ly');
      $(this).find('i').css('transform', 'rotate(' + deg + 'deg)');
      $.ajax({
        type: "POST",
        data: {
          page: pp_page,
          limit: 20,
          ly: ly
        },
        url: "/gslb/get_gs",
        success: function (res) {

          if (res.code == 1) {
            var html = '';
            var d = res.data;
            var allpage = Math.ceil(res.count / 10);
            if (pp_page >= allpage) {
              pp_page = 1
            }
            if (d.length > 0) {
              for (var i = 0; i < d.length; i++) {
                html +=
                  ` <li>
                                    <a href="/gsxq/${d[i].id}.html" target="_blank">
                                        <img src="${d[i].gs_logo}" alt="${d[i].gsmc}">
                                        <span>${d[i].gsmc}</span>
                                    </a>
                                </li>`;
              }

              $('.common_result_right .ruzhu_box ul').html(html);
            } else {
              return layer.msg('暂无数据');
            }
          } else {
            return layer.msg(res.msg);
          }
        },
      });
      // 延迟1秒重置按钮状态
      setTimeout(function () {
        zlock = false;
      }, 1000);
    }
  });

  // 换一批用户
  var yh_page = 1;
  var clock = false;
  $(document).on('click', '.common_result_right .huoyue_box .huan', function () {
    if (!clock) {
      clock = true;
      deg += 360;
      yh_page++;
      var ly = $(this).attr('data-ly');
      $(this).find('i').css('transform', 'rotate(' + deg + 'deg)');
      $.ajax({
        type: "POST",
        data: {
          page: yh_page,
          limit: 20,
          ly: ly
        },
        url: "/xzrm/get_rmlb",
        success: function (res) {
          if (res.code == 1) {
            var html = '';
            var d = res.data;
            var allpage = Math.ceil(res.count / 10);
            if (pp_page >= allpage) {
              pp_page = 1
            }
            if (d.length > 0) {
              for (var i = 0; i < d.length; i++) {
                html += `
                        <li class="clear" data-id="${d[i].id}" data-friend="${d[i].is_friend}">
                            <a href="/grxq/${d[i].id}.html" target="_blank" class="logo">
                                <img src="${d[i].tx}" alt="${d[i].nickname}" class="tx">
                                ${d[i].tb_lx ? '<img src="/p/style/web/img/vip_tx.png" alt="" class="vip_tx">' : ''}
                            </a>
                            <div class="infor">
                                <div class="tr1 clear">
                                    <span class="name">${d[i].nickname}</span>
                                    ${d[i].is_friend ? '<a href="/grxq/${d[i].id}.html" target="_blank" class="ckmp">查看名片&gt;</a>' : '<span class="jhy">加好友</span>'}
                                </div>
                                <p>${d[i].gsmc}</p>
                            </div>
                        </li>`;

              }

              $('.common_result_right .huoyue_box ul').html(html);
            } else {
              return layer.msg('暂无数据');
            }
          } else {
            return layer.msg(res.msg);
          }
        },
      });
      // 延迟1秒重置按钮状态
      setTimeout(function () {
        clock = false;
      }, 1000);
    }
  });

  // 加好友
  $(document).on("click", '.jhy', function (event) {
    // 阻止默认的链接点击行为
    event.preventDefault();
    if ($(this).parents('li').attr("data-id")) {
      var id = $(this).parents('li').attr("data-id");
      var friend = $(this).parents('li').attr("data-friend");
    } else {
      var id = $('#get_uid').val();
      var friend = $('#is_friend').val();
    }
    // 验证登录
    if (!islogin()) {
      return false;
    }
    // 验证完善信息
    if (!iswsxx()) {
      return false;
    }
    // 验证是否会员
    if (!iskthy()) {
      return false;
    }
    if (friend == 1) {
      layer.alert('已是您的好友');
      return false;
    }
    layer.open({
      skin: 'jm_fxx',
      title: '申请好友可留言',
      area: ['480px'],
      content: '<input type="text" class="xxnr_input" placeholder="请输入" name="nr" value="">',
      btn: ['确认', '取消'],
      yes: function () {
        var nr = $('.jm_fxx .xxnr_input').val();
        addfriend(id, nr);
      }
    });
  })
  // 发消息
  $(document).on("click", '.fxx', function (event) {
    // 阻止默认的链接点击行为
    event.preventDefault();
    //区分公司详情下人脉
    if ($(this).parents('li').attr("data-id")) {
      var id = $(this).parents('li').attr("data-id");
      var friend = $(this).parents('li').attr("data-friend");
    } else {
      var id = $('#get_uid').val();
      var friend = $('#is_friend').val();
    }
    // 验证登录
    if (!islogin()) {
      return false;
    }
    // 验证完善信息
    if (!iswsxx()) {
      return false;
    }
    if (friend == 0) {
      layer.msg('您需要先添加好友才能发送消息');
      return false;
    }
    layer.open({
      skin: 'jm_fxx',
      title: '发消息',
      area: ['480px'],
      content: "<textarea class='xxnr_textarea' placeholder='请输入' name='nr'></textarea>",
      btn: ['确认', '取消'],
      yes: function () {
        var nr = $('.jm_fxx .xxnr_textarea').val();
        if (nr == '') {
          layer.msg('请输入消息');
          return false;
        }
        fxxFriend(id, nr);
      }
    });
  })
  // 签到
  $(document).on("click", '#qiandao', function () {
    // 验证登录
    if (!islogin()) {
      return false;
    }
    // 验证完善信息
    if (!iswsxx()) {
      return false;
    }
    $.ajax({
      type: "POST",
      data: {},
      url: "/yh/yh_qd",
      success: function (res) {
        if (res.code == 1) {
          layer.msg(res.msg)
          setTimeout(function () {
            location.reload();
          }, 500);
        } else {
          return layer.msg(res.msg);
        }
      },
    });
  })
  $(document).on("click", '#yqiandao', function () {
    return layer.msg('您今日已签到，明天再来吧~');
  })
  //信息流广告移除
  $(document).on("click", '.hz_ul .hz_ggt .close_icon', function (event) {
    // 阻止默认的链接点击行为
    event.preventDefault();
    $(this).parents('.hz_ggt').fadeOut();
  })
  //合作，活动，公司收藏
  $(document).on("click", '#common_sc', function () {
    var _this = $(this);
    // 验证登录
    if (!islogin()) {
      return false;
    }
    var datas = {
      lx: _this.attr('data-lx'),// 收藏类型 lx 1合作 2活动 3公司
      id: $('#xq_id').val(),
    };
    var is_sc = _this.attr('data-issc');
    if (is_sc == 1) {
      datas.status = -1
    } else {
      datas.status = 1
    }
    $.ajax({
      type: "POST",
      data: datas,
      url: '/gzsc/sc_hz',
      success: function (res) {

        if (res.code == 1) {
          layer.msg(res.msg);
          if (is_sc == 1) {
            $('#common_sc').removeClass("on");
            $('#common_sc em').html("收藏");
            _this.attr('data-issc', 0);
          } else {
            $('#common_sc').addClass("on");
            $('#common_sc em').html("已收藏");
            _this.attr('data-issc', 1);
          }

        } else {
          layer.msg(res.msg);
        }
      },
    });
  })

});
