!function(ts,$){
	// 对话框
	ts.wxDialog = {
		title: '',			// 弹窗标题
		content: '',		// 弹窗内容
		btn1Txt: '',		// 按钮一文本
		btn2Txt: '',		// 按钮二文本

		// 设置弹窗
		set: function(initData){
			// 还原
			this.title = '';
			this.content = '';
			this.btn1Txt = '';
			this.btn2Txt = '';

			// 设置
			$.extend(this, initData);
			return this;
		},
		
		// 显示弹窗
		show: function(type = 2,btn1Fun,btn2Fun){
			html = '';
			if(type == 1){
				var btn1Txt = this.btn1Txt ? this.btn1Txt : '确定';
				var btn2Txt = this.btn2Txt ? this.btn2Txt : '取消';

				html += '<div class="js_dialog" id="iosDialog1" style="display: none;">';
				html += '<div class="weui-mask"></div>';
				html += '<div class="weui-dialog">';
				html += '<div class="weui-dialog__hd"><strong class="weui-dialog__title">' + this.title + '</strong></div>';
				html += '<div class="weui-dialog__bd">' + this.content + '</div>';
				html += '<div class="weui-dialog__ft">';
				html += '<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default">' + btn2Txt + '</a>';
				html += '<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">' + btn1Txt + '</a>';
				html += '</div>';
				html += '</div>';
				html += '</div>';

				$('body').append(html);
				$('#iosDialog1').fadeIn(200);

				$('.weui-dialog__btn_primary').click(function(){
					typeof(btn1Fun) == "function" && btn1Fun();

					$('#iosDialog1').fadeOut(200);
					var t = setTimeout(function(){
						$('#iosDialog1').remove();
						clearTimeout(t);
					},200);
				});

				$('.weui-dialog__btn_default').click(function(){
					typeof(btn2Fun) == "function" && btn2Fun();

					$('#iosDialog1').fadeOut(200);
					var t = setTimeout(function(){
						$('#iosDialog1').remove();
						clearTimeout(t);
					},200);
				});
			}else if(type == 2){
				var btn1Txt = this.btn1Txt ? this.btn1Txt : '确定';

				html += '<div class="js_dialog" id="iosDialog2" style="display: none;">';
				html += '<div class="weui-mask"></div>';
				html += '<div class="weui-dialog">';
				html += '<div class="weui-dialog__bd">' + this.content + '</div>';
				html += '<div class="weui-dialog__ft">';
				html += '<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">' + btn1Txt + '</a>';
				html += '</div>';
				html += '</div>';
				html += '</div>';

				$('body').append(html);
				$('#iosDialog2').fadeIn(200);

				$('.weui-dialog__btn_primary').click(function(){
					typeof(btn1Fun) == "function" && btn1Fun();

					$('#iosDialog2').fadeOut(200);
					var t = setTimeout(function(){
						$('#iosDialog2').remove();
						clearTimeout(t);
					},200);
				});
			}else if(type == 3){

			}else if(type == 4){
				var btn1Txt = this.btn1Txt ? this.btn1Txt : '确定';
				var btn2Txt = this.btn2Txt ? this.btn2Txt : '取消';

				html += '<div class="js_dialog" id="androidDialog2" style="display: none;">';
				html += '<div class="weui-mask"></div>';
				html += '<div class="weui-dialog weui-skin_android">';
				html += '<div class="weui-dialog__bd">' + this.content + '</div>';
				html += '<div class="weui-dialog__ft">';
				html += '<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default">' + btn2Txt + '</a>';
				html += '<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">' + btn1Txt + '</a>';
				html += '</div>';
				html += '</div>';
				html += '</div>';

				$('body').append(html);
				$('#androidDialog2').fadeIn(200);

				$('.weui-dialog__btn_primary').click(function(){
					typeof(btn1Fun) == "function" && btn1Fun();

					$('#androidDialog2').fadeOut(200);
					var t = setTimeout(function(){
						$('#androidDialog2').remove();
						clearTimeout(t);
					},200);
				});

				$('.weui-dialog__btn_default').click(function(){
					typeof(btn2Fun) == "function" && btn2Fun();

					$('#androidDialog2').fadeOut(200);
					var t = setTimeout(function(){
						$('#androidDialog2').remove();
						clearTimeout(t);
					},200);
				});
			}
		}
	};

	// 弹出式提示
	ts.wxToast = {
		// 显示提示 type = 1 成功提示; type = 2 加载提示
		show: function(type,content = ''){
			switch(type){
				// 成功提示
				case 1:
					var html = '<div id="toast" style="display: none;">';
					html += '<div class="weui-mask_transparent"></div>';
					html += '<div class="weui-toast">';
					html += '<i class="weui-icon-success-no-circle weui-icon_toast"></i>';
					html += '<p class="weui-toast__content">'+content+'</p>';
					html += '</div>';
					html += '</div>';

					$('body').append(html);
					$('#toast').fadeIn(200);
					break;

				// 加载中提示
				case 2:
					var html = '<div id="loadingToast" style="display: none;">';
					html += '<div class="weui-mask_transparent"></div>';
					html += '<div class="weui-toast">';
					html += '<i class="weui-loading weui-icon_toast"></i>';
					html += '<p class="weui-toast__content">'+content+'</p>';
					html += '</div>';
					html += '</div>';

					$('body').append(html);
					$('#loadingToast').fadeIn(200);
					break;

				default:
					console.error('Toast类型无效');
					return false;
			}
		},

		hide: function(){
			$('#toast,#loadingToast').fadeOut(200);
			var t = setTimeout(function(){
				$('#toast,#loadingToast').remove();
				clearTimeout(t);
			},200);
		}
	};
}(this,jQuery);