var myVar;
var myTime;
var intDiff = parseInt(300);//倒计时总秒数量
$(document).ready(function () {
$("#refesh").click(function () {
LoadQrCode();
});
$(".close-icon").on("click", function () {
$(".popup-wrap").hide();
});
$("input.code").on('input propertychange', function () {
if ($(this).val().length == 4) {
$(".code-btn").addClass("active").removeAttr("disabled");
} else {
$(".code-btn").removeClass("active").attr("disabled", "disabled");
}
});
//首页创建qq咨询
createDefaultQidian()
});
function createDefaultQidian() {
var params = window.location.href.split('?')[1]
var flag = false
if (params) {
var paramList = params.split('&')
for (var i = 0; i < paramList.length; i++) {
if (paramList[i].indexOf('Source')>=0) {
flag = true
setCookie('Source', paramList[i].split('=')[1], 1)
//window.localStorage.setItem('Source', paramList[i].split('=')[1])
}
}
}
//if (!flag && !getCookie('Source')) {
// var dom= $('')
// console.log('没有sourcea', $('.ditu')[0])
// //$('.ditu')[0].append(dom)
// //$('body').append('')
//} else {
// $($('.qidian-script')[0]).attr('id','qd28521078101f260694dd00e2aa45484dc6a44f9975')
// $($('.qidian-script')[0]).attr('src', 'https://wp.qiye.qq.com/qidian/2852107810/1f260694dd00e2aa45484dc6a44f9975')
// console.log('有source', $('.qidian-script')[0])
// // $('.ditu').append('')
//}
}
// 设置cookies
function setCookie(name, value, Days) {
if (!Days) {
var Days = 30;
}
var exp = new Date();
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}
//读取cookies
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg)) return unescape(arr[2]);
else return null;
}
function OpenDemoWindow(index) {
var id = JSON.parse(window.localStorage.getItem("users"));
var client = { id: encodeURIComponent(id) };
$.ajax({
type: "POST",
url: "/Handler/demos/CheckIsValidById.ashx?t=" + Math.random(),
async: false,
data: client,
success: function (code) {
//code = 2;//测试用
if (code == 1) {
ShowDIV();
} else {
if (index == 1) {
//首页,云ERP,供应链
$(".popup-wrap").show();
$("#js_auth_popup").hide();
$("#js_code_popup").hide();
$("#productdemobox").show();
} else if (index == 2) {
//网店ERP/供应链
var productid = $("#hf_productid").val();
if (productid == 30) {
enterDemo(productid, 0, 0, 3, "");
} else {
$(".popup-wrap").show();
$("#js_auth_popup").hide();
$("#js_code_popup").hide();
$("#productdemobox").show();
}
} else if (index == 3) {
//云财务
var productid = 27;
var verid = 0;
var industry = 0;
var position = 5;
var loginurl = "https://peethewmain.wsgjp.com/Login.gspx?demo=true";
enterDemo(productid, verid, industry, position, loginurl);
} else if (index == 4) {
//云宝
var productid = 31;
var verid = 0;
var industry = 0;
var position = 6;
var loginurl = "https://pangu.wsgjp.com/demo.html";
enterDemo(productid, verid, industry, position, loginurl);
}
else if (index == 5) {
//进销存
enterDemo(37, 0, 4, 3, "");
} else if (index == 0) {
$(".popup-wrap").show();
$("#js_auth_popup").hide();
$("#js_code_popup").hide();
$("#productdemobox").hide();
$("#js_product_popup").show();
}
}
}
});
}
function ShowDIV() {
$(".popup-wrap").show();
$("#js_auth_popup").show();
$("#js_code_popup").hide();
LoadQrCode();
}
//function OpenDiv() {
// $(".popup-wrap").show();
// $("#js_auth_popup").show();
// $("#js_code_popup").hide();
// $("#productdemobox").hide();
// LoadQrCode();
//}
function LoadQrCode() {
var item = window.localStorage.getItem("users");
if (item != null) {
var id = JSON.parse(item);
$('#WxQrCode').attr('src', "/WebChat/Handler/QrCodeImage.ashx?id=" + id + "&t=" + Math.random());
$("#tishi").text("微信扫描");
$("#refesh").hide();
timer(intDiff);
}
}
function myStopFunction() {
clearInterval(myVar);
}
//计时器
function timer(intDiff) {
myVar = setInterval(function () { CheckWeChat() }, 2000);
myTime = window.setInterval(function () {
var minute = 0,
second = 0;//时间默认值
if (intDiff > 0) {
minute = Math.floor(intDiff / 60);
second = Math.floor(intDiff) - (minute * 60);
}
intDiff--;
if (intDiff == 0) {
clearInterval(myTime); //定时器清除;
myStopFunction();
$("#tishi").text("二维码已失效!");
$("#refesh").show();
}
}, 1000);
}
function enterDemo(productid, verid, industry, position, loginurl) {
var id = 0;
var item = window.localStorage.getItem("users");
if (item != null) {
var id = JSON.parse(item);
}
var client = { id: encodeURIComponent(id), product: encodeURIComponent(productid), verid: verid, trade: encodeURIComponent(industry), position: position };
$.ajax({
type: "POST",
url: "/Handler/demos/AddInfo.ashx?t=" + Math.random(),
async: false,
dataType: "json",
data: client,
success: function (data) {
var code = data.Code;
if (code == 0) {
alert(data.msg);
return;
}
if (productid == 21 || productid == 27 || productid == 31) {
// location.href = loginurl;
window.open(loginurl);
return;
}
if (productid == 14) {
var param = data.msg;
var obj = eval('(' + param + ')');
loginurl = data.loginUrl;
post(loginurl, obj[0]);
} else {
window.open(data.loginUrl);
}
}
});
}
function ValidYzmCode(productId, showid) {
var yzmCode = $("#txt_weCharYzm").val();
if (yzmCode.length == 0) { alert("请填写短信验证码"); return; }
var id = 0;
var item = window.localStorage.getItem("users");
if (item != null) {
var id = JSON.parse(item);
}
var uid = getCookie('uid');
console.log('--------------------')
console.log(getCookie('uid'))
console.log(getCookie('Qs_lvt_212161'))
console.log('--------------------')
if (!uid||uid.length == 0) {
uid = '';
}
var client = { id: encodeURIComponent(id), code: yzmCode,clientId:uid};
$.ajax({
type: "POST",
url: "/Handler/demos/ValidYzm.ashx?t=" + Math.random(),
async: false,
dataType: "json",
data: client,
success: function (data) {
var code = data.Code;
if (code == 0) {
alert(data.msg);
return;
}
if (productId == 27) {
var verid = 0;
var industry = 0;
var position = 5;
var loginurl = "https://peethewmain.wsgjp.com/Login.gspx?demo=true";
enterDemo(productId, verid, industry, position, loginurl);
} else if (productId == 31) {
var verid = 0;
var industry = 0;
var position = 6;
var loginurl = "https://pangu.wsgjp.com/demo.html";
enterDemo(productId, verid, industry, position, loginurl);
}
else if (productId == 30) {
var verid = 0;
var industry = 0;
var position = 3;
var loginurl = "";
enterDemo(productId, verid, industry, position, loginurl);
}
else {
$("#js_auth_popup").hide();
$("#js_code_popup").hide();
$("#" + showid).show();
}
}
});
}