function FillReturnMsg(o, t, msg) {
var tip = $("span.formcolumn-item-tipstxt", $(o).parent());
if ($("span.formcolumn-item-errtipstxt", $(o).parent()).length > 0) {
tip = $("span.formcolumn-item-errtipstxt", $(o).parent());
}
tip.html(msg);
if (t == 1) {
$(o).removeClass("needFill");
tip.css("color", "green");
}
else if (t == 0) {
$(o).addClass("needFill");
tip.css("color", "red");
}
else if (t == 2) {
$(o).removeClass("needFill");
tip.css("color", "#999999");
}
}
var InitExRequiredSpanFunc = {};
var FormVerifyFunc = {
email: {
reg: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
}
};
function InitFormVerify(cfg) {
if (typeof (InitExtCountry) == "function") {
InitExtCountry();
}
if (InitExRequiredSpanFunc[cfg.el] != null) {
InitExRequiredSpanFunc[cfg.el]($("input[exrequired='true'],select[exrequired='true'],span[addresstype][exrequired='true'],textarea[exrequired='true']", cfg.el));
}
else {
$("input[exrequired='true'],textarea[exrequired='true']", cfg.el).after(" *");
}
$("input[exrequired='true'],textarea[exrequired='true']", cfg.el).each(function () {
if ($(this).attr("onblur") == undefined) {
$(this).on("blur", function () {
var v = $(this).val();
if (v != "") {
var suc = true;
if ($(this).attr("validtype") != undefined && $(this).attr("validtype") != "") {
var vtype = $(this).attr("validtype");
if (FormVerifyFunc[vtype] != null) {
var reg = FormVerifyFunc[vtype].reg;
if (!reg.test(v)) {
suc = false;
$(this).val("");
FillReturnMsg(this, 0, " ");
}
}
else {
console.log("verifytype=" + vtype + " not exist");
}
}
if (suc) {
FillReturnMsg(this, 1, " ");
}
}
else {
if ($(this).attr("title")) {
FillReturnMsg(this, 0, GetLangTxt(rclng.itemrequired, [{ title: "title", text: $(this).attr("title") }]));
}
else {
FillReturnMsg(this, 0, "");
}
}
});
}
});
$(".formcom-verifybox", cfg.el).each(function () {
var _box = this;
var btn = $(".formcom-verifycode-btn", this);
btn.click(function () {
var o = this;
var relel = $(this).attr("relinput");
var verifynum = $("#" + relel).val();
var verifytype = $(this).attr("verifytype");
if (verifytype == "email") {
if (!web960.verify.email(verifynum)) {
alert(rclng.erroremailformat);
$("#" + relel).focus();
return;
}
}
else {
if (!web960.verify.mobile(verifynum)) {
alert(rclng.errorphonenum);
$("#" + relel).focus();
return;
}
}
$(o).prop("disabled", true);
var downcountsecond = 120;
var downcount = function () {
if (downcountsecond == 0 || ($(o).attr("stopdowncount") != null && $(o).attr("stopdowncount") == "1")) {
$(o).prop("disabled", false).html(rclng.sendsmsverify);
$(o).removeAttr("stopdowncount");
}
else {
$(o).prop("disabled", true).html(downcountsecond);
setTimeout(function () {
downcountsecond--;
downcount();
}, 1000);
}
};
var html = '
';
if ($(".smsverifydialog", _box).length > 0) {
$(".smsverifydialog", _box).remove();
}
$(".verifycodeviewbox", _box).html(html);
web960InitGeetest({
el: $(".smsverifycaptchdiv", _box), width: "100%", success: function (capresult) {
var data = {
geetest_challenge: capresult.geetest_challenge,
geetest_validate: capresult.geetest_validate,
geetest_seccode: capresult.geetest_seccode,
phonenum: verifynum
};
var url = "/index.aspx?a=sendmobileverifycode_common";
if (verifytype == "email") {
url = "/index.aspx?a=sendemailverifycode_common";
data = {
geetest_challenge: capresult.geetest_challenge,
geetest_validate: capresult.geetest_validate,
geetest_seccode: capresult.geetest_seccode,
email: verifynum
};
}
$.post(url, data, function (ret) {
if (ret.result == "1") {
$(".formcom-verifycode", _box).attr("verifyid", ret.verifyid);
$(".geetest_success_radar_tip_content").html("验证码发送成功,请注意查收");
downcount();
}
else {
$(".smsverifycaptchdiv", _box).css({ "color": "red", "height": "44px", "line-height": "44px", "border": "1px solid #ec8888", "background-color": "#ffeaea", "text-indent": "20px", "border-radius": "3px" }).html("无法发送:" + ret.message);
$(".formcom-verifycode", _box).attr("verifyid", "");
$(o).prop("disabled", false);
}
}, "json")
}
});
});
});
}
function InitFormVerify_V2(cfg) {
if (typeof (InitExtCountry) == "function") {
InitExtCountry();
}
// $("input[exrequired='true'],textarea[exrequired='true']", cfg.el).after(" *");
$("input[exrequired='true'],textarea[exrequired='true']", cfg.el).each(function () {
if ($(this).attr("onblur") == undefined) {
$(this).on("blur", function () {
$(".help-block", $(this).parents(".form-group")).remove();
var v = $(this).val();
if (v != "") {
$(this).parents(".form-group").removeClass("has-error");
}
else {
$(this).parents(".form-group").addClass("has-error");
if ($(this).attr("title") && $(this).attr("show-help") == "true") {
$(this).parents(".form-group").append('' + GetLangTxt(rclng.itemrequired, [{ title: "title", text: $(this).attr("title") }]) + '');
}
}
});
}
});
}
function AjaxReturn(ret, callback) {
var rc = ret.value;
if (rc) {
callback();
}
else {
alert(ret.error.Message);
}
}
function OpenDialog(cfg) {
if ($.fn.dialog != undefined) {
$(cfg.el).dialog({
title: cfg.title,
autoOpen: true,
modal: true,
width: cfg.width,
height: cfg.height,
resizable: false,
close: function () {
$("body").css("overflow", "auto");
NowOpenDialogEl = '';
},
open: function () {
$("body").css("overflow", "hidden");
if (cfg.opencallback != undefined) {
cfg.opencallback();
}
}
});
}
else {
try {
var modalel = cfg.el + "_modal";
var modalelstr = modalel.replace("#", "").replace(".", "");
if ($(modalel).length == 0) {
var html = '';
$("body").append(html);
$(cfg.el).show();
$(".modal-body", modalel).append($(cfg.el));
$(modalel).modal({
backdrop: false,
keyboard: false,
show: true
});
$(modalel).on('shown.bs.modal', function (e) {
if (cfg.opencallback != undefined) {
cfg.opencallback();
}
});
$(modalel).on('hidden.bs.modal', function (e) {
if (cfg.onclose != undefined) {
cfg.onclose();
}
});
}
else {
$(".modal-body", modalel).append($(cfg.el));
$(".modal-title", modalel).html(cfg.title);
$(modalel).modal("show");
}
}
catch(e){ }
}
}
function Alert(msg, title, width) {
if (title == undefined) {
title = "" + rclng.sysalert;
}
if (width == undefined) {
width = 400;
}
if ($("#AlertDialog").length == 0) {
$("body").append(' ');
}
OpenDialog({
el: "#AlertDialog",
width: width,
title: title,
buttons: [
{
text: "" + rclng.sysok,
icons: {
primary: "ui-icon-heart"
},
click: function () {
$(this).dialog("close");
}
}
],
opencallback: function () {
$("#AlertMsgBox").html(msg);
}
});
}
function CloseDialog(el) {
if ($.fn.dialog != undefined) {
$(el).dialog("close");
}
else {
try {
var modalel = el + "_modal";
$(modalel).modal("hide");
}
catch (e) {
}
}
}
function AutoCenterDialog(el) {
if ($.fn.dialog != undefined) {
$(el).dialog("option", "position", "center");
}
}
function initCloseBtn(o) {
if (o != undefined) {
$("input[closebtn='true']", o).bind("click", function () {
var el = $(this).attr("reel");
CloseDialog("#" + el);
})
}
else {
$("input[closebtn='true']").bind("click", function () {
var el = $(this).attr("reel");
CloseDialog("#" + el);
})
}
}
function GetExtAttrValues(cfg) {
var extv = {};
$("input[dataref='true'],textarea[dataref='true'],select[dataref='true'],span[addresstype],span[countrytype]", $(cfg.el)).each(function () {
if (extv[$(this).attr("classname")] == undefined) {
extv[$(this).attr("classname")] = {};
}
if ($(this).hasClass("address_extipt")) {
var vxv = "";
if ($(this).attr("areacode") != "") {
vxv = $(this).attr("areacode") + "|" + $(this).attr("areatitle");
}
extv[$(this).attr("classname")][$(this).attr("relkey")] = vxv;
}
else if ($(this).hasClass("country_extipt")) {
var vxv = "";
if ($(this).attr("countrycode") != "") {
vxv = $(this).attr("countrytitle") + "|" + $(this).attr("countrycode");
}
extv[$(this).attr("classname")][$(this).attr("relkey")] = vxv;
}
else {
extv[$(this).attr("classname")][$(this).attr("relkey")] = $(this).val();
}
});
var r = {};
r.str = JSON2.stringify(extv);
r.json = extv;
return r;
}
function ClearFormData(cfg, callback) {
var nodeName = "";
var isForm = false;
if ($(cfg.el).length > 0) {
if ($(cfg.el).prop("tagName") != undefined) {
nodeName = $(cfg.el).prop("tagName");
}
else if ($(cfg.el).prop("nodeName") != undefined) {
nodeName = $(cfg.el).prop("nodeName");
}
if (nodeName == "FORM") {
isForm = true;
}
}
if (isForm) {
$(cfg.el)[0].reset();
}
else {
$("input[dataref='true'][type!='checkbox'],textarea[dataref='true'],input[data-ref][type!='checkbox'],textarea[data-ref]", $(cfg.el)).val("");
}
$(".smsverifycaptchdiv", $(cfg.el)).html("");
$("input[verifyid]", $(cfg.el)).removeAttr("verifyid");
$("button.formcom-verifycode-btn", $(cfg.el)).each(function () {
if ($(this).attr("stopdowncount") == null) {
$(this).attr("stopdowncount", "1");
}
});
if (callback != undefined) {
callback();
}
}
var VerifyFormDataFunc = {};
function VerifyFormData(cfg, callback) {
var checkallfield = false;
if (cfg["checkallfield"] != undefined) {
checkallfield = cfg["checkallfield"];
}
var success = true;
var postdata = {};
var needverifycode = false;
var verifycodes = [];
$("input[dataref='true'],textarea[dataref='true'],select[dataref='true'],input[data-ref],textarea[data-ref],span[addresstype],span[countrytype]", $(cfg.el)).each(function () {
FillReturnMsg(this, 1, " ");
var v = "";
if ($(this).attr("addresstype") != undefined && $(this).attr("areacode") != undefined) {
v = $(this).attr("areacode");
}
else if ($(this).attr("countrytype") != undefined && $(this).attr("countrycode") != undefined) {
v = $(this).attr("countrycode");
}
else {
v = $(this).val();
}
if ($(this).attr("exrequired") == "true" && v == "") {
success = false;
if (!checkallfield) {
alert(GetLangTxt(rclng.itemrequired, [{ title: "title", text: $(this).attr("title") }]));
$(this).focus();
return false;
}
else {
FillReturnMsg(this, 0, " ");
}
}
var validtype = $(this).attr("validtype");
if (validtype != null && v != "") {
if (validtype == "mobile") {
if (!web960.verify.mobile(v)) {
alert(rclng.errorphonenum);
success = false;
$(this).focus();
return false;
}
}
else if (validtype == "email") {
if (!web960.verify.email(v)) {
alert(rclng.erroremailformat);
success = false;
$(this).focus();
return false;
}
}
}
if ($(this).hasClass("formcom-verifycode")) {
var verifyid = $(this).attr("verifyid");
if (verifyid == null) {
alert(GetLangTxt(rclng.itemrequired, [{ title: "title", text: $(this).attr("title") }]));
success = false;
$(this).focus();
return false;
}
else {
verifycodes.push({ verifyid: verifyid, code: v });
needverifycode = true;
}
}
if ($(this).attr("data-ref") != undefined) {
if ($(this).attr("type") != undefined) {
if ($(this).attr("type") == "checkbox") {
if ($(this).is(":checked")) {
postdata[$(this).attr("data-ref")] = v;
}
else {
postdata[$(this).attr("data-ref")] = "";
}
}
else if ($(this).attr("type") == "radio") {
if ($(this).is(":checked")) {
postdata[$(this).attr("data-ref")] = v;
}
}
else {
postdata[$(this).attr("data-ref")] = v;
}
}
else {
postdata[$(this).attr("data-ref")] = v;
}
}
});
if (success) {
if (needverifycode) {
$.post("/index.aspx?a=verifycodes", { verifycodes: JSON.stringify(verifycodes) }, function (data) {
if (data.result != "1") {
alert(data.message);
}
else {
var extdata = GetExtAttrValues(cfg);
if (VerifyFormDataFunc[cfg.el] != null) {
VerifyFormDataFunc[cfg.el](postdata, extdata, function (_postdata, _extdata) {
callback(_postdata, _extdata.str, _extdata.json);
});
}
else {
callback(postdata, extdata.str, extdata.json);
}
}
}, "json");
} else {
var extdata = GetExtAttrValues(cfg);
if (VerifyFormDataFunc[cfg.el] != null) {
VerifyFormDataFunc[cfg.el](postdata, extdata, function (_postdata, _extdata) {
callback(_postdata, _extdata.str, _extdata.json);
});
}
else {
callback(postdata, extdata.str, extdata.json);
}
}
}
else if (checkallfield) {
alert(rclng.please_fix_below_errors);
}
}
function JsonToDict(data) {
var dict = new Ajax.Web.Dictionary("Dictionary");
for (var jd in data) {
dict.add(jd, data[jd]);
}
return dict;
}
function InitUserLoginStatus(cfg) {
$.get("/index.aspx?a=checkuserlogin&mfrsh=" + Math.random(), {}, function (data) {
if (cfg.callback == undefined) {
if (data.result == "1") {
$(cfg.el).html(rclng.hello + '!' + data.username + ' ' + rclng.membercenter + ' ' + rclng.loginout + ' ');
}
else if (data.result == "-1") {
$(cfg.el).html('' + rclng.login + ' ' + rclng.register + ' ');
}
if (cfg.ondone != undefined) {
cfg.ondone(data);
}
}
else {
cfg.callback(data);
}
}, "json");
}
function ViewVerifyImage(cfg) {
$(cfg.el).html('
');
}
function ReFreashVerifyImg(o) {
var verifytype = $(o).attr("verifytype");
var veid = $(o).attr("vref");
$(o).attr("src", "/index.aspx?a=verifycode&verifytype=" + verifytype + "&r=" + Math.random());
$(veid).val("");
}
function VerifyCodeCheck(o) {
var v = $(o).val();
Web960.Web.index.verifyRegCode(v, "userlogin", function (res) {
AjaxReturn(res, function () {
var rv = res.value;
if (rv.Status == "1") {
}
else {
// rv.ClientMsg
}
});
});
}
function InitDataMapping() {
$.get("/index.aspx?a=getuserinfo", {}, function (data) {
if (data.IntResult == 1) {
//logined;
var comment = eval("(" + data.ObjResult.comment + ");");
$("input[data-mapping],textarea[data-mapping],select[data-mapping]").each(function () {
var mapping = $.trim($(this).attr("data-mapping"));
if (mapping != "") {
try {
var v = eval("(comment." + mapping + ");");
$(this).val(v);
}
catch (e) { }
}
})
}
}, "json");
}
function GetGuestExtSettings(callback) {
$.get("/index.aspx?a=g&getmethod=getsettings", {}, function (data) {
if (data.IntResult == 1) {
var json = eval('(' + data.StrResult + ')');
callback(json);
}
}, "json");
}
function GetExtForms(formid, callback) {
$.get("/index.aspx?a=g&getmethod=getextforms&formid=" + formid, {}, function (data) {
if (data.IntResult == 1) {
callback(data.StrResult);
}
}, "json");
}
function Guid(callback) {
$.get("/index.aspx?a=guid&rnd=" + Math.random(1), {}, function (data) {
callback(data.guid);
}, "json");
}
function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
function GoToPage(o) {
var v = $.trim($(o).val());
var patrn = /^[1-9]*[1-9][0-9]*$/;
if (patrn.exec(v)) {
var page = parseInt(v);
var url = $(o).attr("pageurl");
var pagecount = parseInt($(o).attr("pagecount"));
if (page <= 1) {
url = url.replace("-{0}", "").replace("_{0}", "");
}
else if (page > pagecount) {
page = pagecount;
url = url.replace("{0}", page);
}
else {
url = url.replace("{0}", page);
}
location.href = url;
}
}
function jumppropage(o) {
var v = $.trim($(o).val());
var url = $("#wpagenavgotuipt").attr("pageurl");
var pagecount = parseInt($(o).attr("pagecount"));
url = url.replace("-{0}", "").replace("_{0}", "").replace("page={0}", "page=").replace("&psize", "&apsizeq").replace("?psize", "?apsizeq");
if (url.indexOf("?") == -1) {
location.href = url + "?psize=" + v;
} else {
location.href = url + "&psize=" + v;
}
}
function GetSimpMoneyUnit(m) {
switch (m) {
case "CNY":
case "元":
return "¥";
case "USD":
return "$";
case "HKD":
return "HK$";
case "EUR":
return "€";
}
}
function InitBrowseHistoryCookie(cookiename, cookievalue, savetime) {
var str = cookiename + "=" + escape(cookievalue);
var date = new Date();
var ms = savetime * 60 * 1000;
date.setTime(date.getTime() + ms);
str += ";expires=" + date.toGMTString();
document.cookie = str;
}
var nowExtUploadRefId = "";
var BFCallBack = null;
function ExtUpload(t, elid, callback) {
BFCallBack = callback;
var dialoghtml = '';
if ($("#ExtUploadDialog").length == 0) {
$("body").append(dialoghtml);
ExtUpload(t, elid);
}
else {
$("#uploadnoticediv").html("");
nowExtUploadRefId = elid;
if (t == 1) {
title = rclng.uploadimage;
$("#ExtUploadForm").attr("action", "/admin/filehandler.aspx?t=100&dir=image&id=0&n=0&cb=ExtUploadCallBack");
} else if (t == 2) {
title = rclng.uploadfile;
$("#ExtUploadForm").attr("action", "/admin/filehandler.aspx?t=110&dir=file&id=0&n=0&cb=ExtUploadCallBack");
}
OpenDialog({ el: "#ExtUploadDialog", width: 410, title: title });
}
}
function ExtUploadCallBack(res) {
if (res.error == "1") {
alert(res.message);
}
else {
var fileName = res.filename;
$("input[id$='" + nowExtUploadRefId + "'").val(fileName);
if (BFCallBack) {
BFCallBack(fileName);
}
CloseDialog("#ExtUploadDialog");
}
}
function GetShopChatCountForNowUser(cfg) {
$.get("/index.aspx?a=ajax&plu=goodsmanage&ajaxmethod=shopcharcount&rnd=" + Math.random(), {}, function (data) {
if (cfg.callback == undefined) {
}
else {
cfg.callback(data);
}
}, "json");
}
///获取待确认订单的数量
function GetCountorderwating() {
$.get("/index.aspx?a=getorderwatingcount", {}, function (data) {
var res = data;
if (data.result == 1) {
var ct = data.count;
if ($(".ordermanage_orderwating").length > 0) {
var sphtm = "" + ct + "";
$(".ordermanage_orderwating a").append(sphtm);
}
}
}, "json");
}
function RequestLoginAuthInfo(callback) {
var html = '';
html = '';
if ($("#loginauthinfobox").length == 0) {
$("body").append(html);
}
$('#loginauthinfobox').modal('show');
$("#loginauthinfotext").on("keypress", function () {
if (event.keyCode == 13) {
var v = $("#loginauthinfotext").val();
if (v != "") {
$("#loginauthinfotext").val("");
$('#loginauthinfobox').modal('hide')
callback(v);
}
}
});
$("#loginauthinfobutton").unbind("click").click(function () {
var v = $("#loginauthinfotext").val();
if (v != "") {
$("#loginauthinfotext").val("");
$('#loginauthinfobox').modal('hide')
callback(v);
}
});
//OpenDialog({
// el: "#loginauthinfobox", width: 300, title: rclng.loginpassword, opencallback: function () {
// $("#loginauthinfobutton").unbind("click").click(function () {
// var v = $("#loginauthinfotext").val();
// if (v != "") {
// $("#loginauthinfotext").val("");
// CloseDialog("#loginauthinfobox");
// callback(v);
// }
// });
// }
//});
}
function GetFields(target) {
///
/// 根据属性field 从指定的页面区域获取内容 , 返回实体 :{NavId="...",NavName=".."}
/// 多实体格式 {entity1:{field1:123,field2:234},entity2:{fiel:123,fiel2:123},otherField:"abc"}
/// 对选支持:格式[]
///
///
/// 页面区域
///
///
/// 实体内容
///
var entity = {};
if (target == undefined)
target = this._container;
var allfileds = $("[field]", target);
allfileds.each(function (i) {
var tagName = this.tagName;
var element = $(this);
var key = element.attr("field");
var tokens = key.toString().split('.');
var tokevalue = function (v) {
///
/// 实体赋值
///
if (tokens != undefined && tokens.length && tokens.length > 1) {
if (entity[tokens[0]] == undefined)
entity[tokens[0]] = {};
entity[tokens[0]][tokens[1]] = v;
}
else {
entity[key] = v;
}
};
//根据元素不同做不同处理
if (element.attr("type") == "radio") {
$("[name='" + element.attr("name") + "']", target).each(function () {
var r = $(this);
if (r.prop("checked")) {
tokevalue($.trim(r.val()));
}
});
} else if (element.attr("type") == "checkbox") {
if (element.attr("name") == undefined) {
if (element.is(":checked")) {
tokevalue($.trim(element.val()));
}
}
else {
var last = [];
$("[name='" + element.attr("name") + "']", target).each(function () {
var r = $(this);
if (r.attr("checked")) {
last.push($.trim(r.val()));
}
});
tokevalue(last);
}
} else if (tagName == "DIV") {
tokevalue($(this).html());
}
else {
//tokevalue($.trim($(this).val()));
tokevalue($(this).val());
}
});
return entity;
}
function SetFields(data, target) {
///
/// 初始化页面
/// 多实体格式 {entity1:{field1:123,field2:234},entity2:{fiel:123,fiel2:123},otherField:"abc"}
/// HTML:...
/// 支持多选,多选返回[]
///
///
/// 实体内容
///
///
/// 页面区域
///
var entity = data;
if (entity == null) {
return;
}
if (entity == undefined)
return;
if (target == undefined)
target = this._container;
var allfileds = $("[field]", target);
var a = "";
allfileds.each(function (i) {
var element = $(this);
var key = element.attr("field");
var tokens = key.toString().split('.');
var val;
if (tokens != undefined && tokens.length && tokens.length > 1) {
var ent = entity[tokens[0]];
if (ent != undefined)
val = ent[tokens[1]];
}
else {
val = entity[key];
}
if (val != undefined) {
if (val == null) {
val = "";
}
if (element.attr("type") == "radio") {
$("[name='" + element.attr("name") + "']", target).each(function () {
if ($(this).val() == val)
$(this).attr("checked", "checked");
else
$(this).removeAttr("checked");
});
} else if (element.attr("type") == "checkbox") {
$.each(val, function (index) {
var thatelemetn = $("[name='" + element.attr("name") + "'][value='" + val[index] + "']", target);
thatelemetn.attr("checked", "checked");
});
}
else {
if (this.nodeName == "TD" || this.nodeName == "DIV") {
element.html(val);
} else {
element.val(val);
}
}
}
});
}
function JSONtoURLPath(json) {
var r = "";
for (var key in json) {
r += "&" + key + "=" + escape(json[key]);
}
r = r.length > 0 ? r.substr(1) : r;
return r;
}