var AMing;
(function (AMing) {
var Core;
(function (Core) {
/**
* 常用Ҏc?
* verison:1.1
* date:2015-12-16 14:54
*/
var Helper = /** @class */ (function () {
function Helper() {
}
/**
* 是否是方?
* @param func Ҏ委托对象
*/
Helper.is_func = function (func) {
return func instanceof Function;
};
/**
* 是否为非I的Ҏ
* @param func Ҏ委托对象
*/
Helper.is_not_null_func = function (func) {
return this.is_func(func) && func != null;
};
/**
* 执行非空的方?
* @param func_context Ҏ执行的上下文对象Q也是Ҏ内部this的访问)
* @param func Ҏ对象
* @param args Ҏ的参?
*/
Helper.call_func_context = function (func_context, func) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
if (this.is_not_null_func(func)) {
return func.apply(func_context, args);
}
return null;
};
/**
* 执行非空的方?
* @param func Ҏ对象
* @param args Ҏ的参?
*/
Helper.call_func = function (func) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (this.is_not_null_func(func)) {
return func.apply(this, args);
}
return null;
};
/**
* djs
* @param url js的地址
* @param onload_func 加蝲完js之后onload执行的方?
*/
Helper.append_js = function (url, onload_func) {
if (onload_func === void 0) { onload_func = null; }
var script = document.createElement('script');
script.src = url;
if (this.is_not_null_func(onload_func)) {
script.onload = onload_func;
}
document.body.appendChild(script);
return script;
};
/**
* djqueryQ如果jquery已经存在则直接执行ready事g
* @param ready ready事g
*/
Helper.append_jquery = function (ready) {
var _this = this;
if (ready === void 0) { ready = null; }
var jqload = function () {
jQuery(document).ready(function (jq) { return _this.call_func(ready); });
};
if (!window['jQuery']) {
this.append_js(this.jq_url, jqload);
}
else {
jqload();
}
};
/**
* dcss
* @param url css的地址
* @param onload_func 加蝲完css之后onload执行的方?
*/
Helper.append_css = function (url) {
var link = document.createElement('link');
link.href = url;
link.rel = 'stylesheet';
link.type = 'text/css';
document.head.appendChild(link);
return link;
};
/**
* 对象是否为空
* @param value 判断的对?
*/
Helper.is_null = function (value) {
return value == undefined || value == null;
};
/**
* 字符串是否ؓI或I字W串
* @param value 判断的字W串内容
*/
Helper.is_null_or_empty = function (value) {
return this.is_null(value) || value == '';
};
/**
* 字符串是否ؓI或I白字符?
* @param value 判断的字W串内容
*/
Helper.is_null_or_space = function (value) {
return this.is_null(value) || value.trim() == '';
};
/**
* json旉字符串{成Datecd
* @param date_str
*/
Helper.jsonToDate = function (date_str) {
var index = date_str.indexOf(')');
if (index >= 0) {
date_str = date_str.substr(0, index);
}
index = date_str.indexOf('(');
if (index >= 0) {
date_str = date_str.substr(index + 1);
}
return new Date(parseInt(date_str));
};
Helper.dateToText = function (date_str, fmt) {
if (fmt === void 0) { fmt = "yyyy-MM-dd"; }
var date = Helper.jsonToDate(date_str), now_date = new Date(), time = date.getTime(), now_time = now_date.getTime();
time = parseInt(String((now_time - time) / 1000));
if (time < 60 * 10) { //十分钟内
return "\u521A\u521A";
}
else if ((time < 60 * 60) && (time >= 60 * 10)) {
//过十分钟少?时
var s = Math.floor(time / 60);
return s + "\u5206\u949F\u524D";
}
else if ((time < 60 * 60 * 24) && (time >= 60 * 60)) {
//过1时于24时
var s = Math.floor(time / 60 / 60);
return s + "\u5C0F\u65F6\u524D";
}
else if ((time < 60 * 60 * 24 * 7) && (time >= 60 * 60 * 24)) {
//过1天少?天内
var s = Math.floor(time / 60 / 60 / 24);
return s + "\u5929\u524D";
}
else {
return date.Format(fmt);
}
};
/**
* 路径是否是图?
* @param filePath
*/
Helper.isImageFile = function (filePath) {
var ext = filePath.substr(filePath.lastIndexOf('.')).toLowerCase();
return (ext == ".jpg" || ext == ".png" || ext == ".bmp");
};
Helper.checkImageSize = function (file) {
return file.size <= 2 * 1024 * 1024;
};
Helper.isEmail = function (val) {
var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
return reg.test(val);
};
Helper.isPhone = function (val) {
var reg = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
return reg.test(val);
};
Helper.jq_url = 'http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js';
return Helper;
}());
Core.Helper = Helper;
var TagHelper = /** @class */ (function () {
function TagHelper() {
}
/**
* 创徏新的jquery对象
* @param tag html标签
* @param classnames
*/
TagHelper.createElement = function (tag) {
var classnames = [];
for (var _i = 1; _i < arguments.length; _i++) {
classnames[_i - 1] = arguments[_i];
}
var $item = jQuery("<" + tag + ">" + tag + ">");
classnames.forEach(function (x) { return $item.addClass(x); });
return $item;
};
/**
* 创徏新的jquery对象
* @param url
* @param text
* @param classnames
*/
TagHelper.createLink = function (url, text) {
var classnames = [];
for (var _i = 2; _i < arguments.length; _i++) {
classnames[_i - 2] = arguments[_i];
}
var $a = this.createElement('a').text(text);
classnames.forEach(function (x) { return $a.addClass(x); });
return $a;
};
/**
* 创徏新的img jquery对象
* @param url
* @param load_func
*/
TagHelper.createImage = function (url, load_func) {
var img = new Image();
img.src = url;
img.onload = load_func;
return jQuery(img);
};
return TagHelper;
}());
Core.TagHelper = TagHelper;
})(Core = AMing.Core || (AMing.Core = {}));
})(AMing || (AMing = {}));
var WanchedangGaizhuang;
(function (WanchedangGaizhuang) {
var Helper;
(function (Helper) {
var SwiperEx = /** @class */ (function () {
function SwiperEx(selecter, loop, autoplay, autoplayDisableOnInteraction) {
if (loop === void 0) { loop = true; }
if (autoplay === void 0) { autoplay = 3000; }
if (autoplayDisableOnInteraction === void 0) { autoplayDisableOnInteraction = false; }
this.loop = true;
this._selecter = selecter;
this.loop = loop;
this.autoplay = autoplay;
this.autoplayDisableOnInteraction = autoplayDisableOnInteraction;
this.init();
}
SwiperEx.prototype.init = function () {
this._swiper = new Swiper(this._selecter, {
pagination: this._selecter + " .swiper-pagination",
paginationClickable: this._selecter + " .swiper-pagination",
nextButton: this._selecter + " .swiper-button-next",
prevButton: this._selecter + " .swiper-button-prev",
slidesPerView: 'auto',
loop: this.loop,
autoplay: this.autoplay,
});
};
return SwiperEx;
}());
Helper.SwiperEx = SwiperEx;
})(Helper = WanchedangGaizhuang.Helper || (WanchedangGaizhuang.Helper = {}));
})(WanchedangGaizhuang || (WanchedangGaizhuang = {}));
var Wanche;
(function (Wanche) {
var Timer = /** @class */ (function () {
function Timer(interval) {
if (interval === void 0) { interval = 1000; }
this.interval = interval;
}
Timer.prototype.start = function (max) {
var _this = this;
this.max_num = max;
this.now_num = 0;
this.timer = setInterval(function () {
_this.now_num++;
_this.run();
}, this.interval);
this.run();
};
Timer.prototype.stop = function () {
clearInterval(this.timer);
};
Timer.prototype.run = function () {
if (!!this.change_func) {
this.change_func(this.now_num, this.max_num);
}
if (this.now_num >= this.max_num && !!this.complete_func) {
this.stop();
this.complete_func();
}
};
return Timer;
}());
Wanche.Timer = Timer;
var ValidatePhone = /** @class */ (function () {
function ValidatePhone() {
var _this = this;
this.send_interval = 60;
this.send_phone_code = "/main/phonevalidate";
this.v_user = false;
this.check_has = true;
this.disable = false;
this.btn_text = "发送验证码";
this.vccode_url = "/verifycode/phonevalidateverifycode";
this.now_vc_phone = null;
this.timer = new Timer();
this.timer.complete_func = function () { return _this.phoneCodeComplete(); };
this.timer.change_func = function (now, max) { return _this.phoneCodeInterval(now, max); };
}
ValidatePhone.prototype.init = function () {
this.setPhoneDisable(false);
this.setPhoneButtonText("发送验证码");
};
ValidatePhone.prototype.setPhoneDisable = function (val) {
this.disable = val;
if (!!this.set_phone_disable_func) {
this.set_phone_disable_func(val);
}
};
ValidatePhone.prototype.setPhoneButtonText = function (val) {
this.btn_text = val;
if (!!this.set_phone_button_text_func) {
this.set_phone_button_text_func(val);
}
};
ValidatePhone.prototype.phoneCodeInterval = function (now, max) {
this.setPhoneButtonText("\u5DF2\u53D1\u9001 (" + (max - now) + "s)");
};
ValidatePhone.prototype.phoneCodeComplete = function () {
this.setPhoneDisable(false);
this.setPhoneButtonText("发送验证码");
};
ValidatePhone.prototype.setPhoneCodeTimer = function () {
this.timer.stop();
this.timer.start(this.send_interval);
};
ValidatePhone.prototype.sendPhoneCode = function (phone, vccode, callback) {
if (!this.v_user && !AMing.Core.Helper.isPhone(phone)) {
Wanche.Global.showMsg("误入正的手机L");
return;
}
$.ajax({
url: this.send_phone_code,
data: {
phone: phone,
check_has: this.check_has,
v_user: this.v_user,
vc_code: vccode
},
method: "POST"
}).done(function (x) {
if (!!x.Success) {
Wanche.Global.showMsgAutoHide(x.Message);
}
else {
Wanche.Global.showError(x.Message);
}
callback(!!x.Success);
});
};
ValidatePhone.prototype.showVCCodeDialog = function () {
var _this = this;
Wanche.PhoneValidateDialog.dialog.func_submit = function (x) {
_this.sendVCCode(x);
};
Wanche.PhoneValidateDialog.dialog.func_close = function () {
_this.now_vc_phone = null;
};
this.refreshVCCode();
Wanche.PhoneValidateDialog.dialog.show();
};
ValidatePhone.prototype.refreshVCCode = function () {
Wanche.PhoneValidateDialog.dialog.setVCImage(this.vccode_url);
Wanche.PhoneValidateDialog.dialog.clearContent();
};
ValidatePhone.prototype.sendVCCode = function (vccode) {
var _this = this;
var phone = this.now_vc_phone;
this.sendPhoneCode(phone, vccode, function (r) {
if (!!r) {
_this.setPhoneDisable(true);
_this.setPhoneCodeTimer();
Wanche.PhoneValidateDialog.dialog.hide();
}
else {
_this.refreshVCCode();
}
});
};
ValidatePhone.prototype.phoneValidate = function (phone) {
if (!!this.disable) {
return;
}
this.now_vc_phone = phone;
this.showVCCodeDialog();
};
return ValidatePhone;
}());
Wanche.ValidatePhone = ValidatePhone;
})(Wanche || (Wanche = {}));
òСҳ