			//弹出框水平垂直居中
			function selectImg(file) {
				if (!file.files || !file.files[0]) {
					return;
				}
				var reader = new FileReader();
				reader.onload = function(evt) {
					var replaceSrc = evt.target.result;
					//更换cropper的图片
					$('#tailoringImg').cropper('replace', replaceSrc, false); //默认false，适应高度，不失真
				}
				reader.readAsDataURL(file.files[0]);
			}
			//关闭裁剪框
			function closeTailor() {
				$(".tailoring-container").toggle();
			}
			$(function() {
				(window.onresize = function() {
					var win_height = $(window).height();
					var win_width = $(window).width();
					if (win_width <= 768) {
						$(".tailoring-content").css({
							"top": (win_height - $(".tailoring-content").outerHeight()) / 2,
							"left": 0
						});
					} else {
						$(".tailoring-content").css({
							"top": (win_height - $(".tailoring-content").outerHeight()) / 2,
							"left": (win_width - $(".tailoring-content").outerWidth()) / 2
						});
					}
				})();
				//弹出图片裁剪框
				$("#replaceImg").on("click", function() {
					$(".tailoring-container").toggle();
				});
				//图像上传
				//cropper图片裁剪
				$('#tailoringImg').cropper({
					aspectRatio: 1 / 1, //默认比例
					preview: '.previewImg', //预览视图
					guides: false, //裁剪框的虚线(九宫格)
					autoCropArea: 0.5, //0-1之间的数值，定义自动剪裁区域的大小，默认0.8
					movable: false, //是否允许移动图片
					dragCrop: true, //是否允许移除当前的剪裁框，并通过拖动来新建一个剪裁框区域
					movable: true, //是否允许移动剪裁框
					resizable: true, //是否允许改变裁剪框的大小
					zoomable: false, //是否允许缩放图片大小
					mouseWheelZoom: false, //是否允许通过鼠标滚轮来缩放图片
					touchDragZoom: true, //是否允许通过触摸移动来缩放图片
					rotatable: true, //是否允许旋转图片
					crop: function(e) {
						// 输出结果数据裁剪图像。
					}
				});
				//旋转
				$(".cropper-rotate-btn").on("click", function() {
					$('#tailoringImg').cropper("rotate", 45);
				});
				//复位
				$(".cropper-reset-btn").on("click", function() {
					$('#tailoringImg').cropper("reset");
				});
				//换向
				var flagX = true;
				$(".cropper-scaleX-btn").on("click", function() {
					if (flagX) {
						$('#tailoringImg').cropper("scaleX", -1);
						flagX = false;
					} else {
						$('#tailoringImg').cropper("scaleX", 1);
						flagX = true;
					}
					flagX != flagX;
				});

				//裁剪后的处理
				$("#sureCut").on("click", function() {
					if ($("#tailoringImg").attr("src") == null) {
						return false;
					} else {
						var cas = $('#tailoringImg').cropper('getCroppedCanvas'); //获取被裁剪后的canvas
						var base64url = cas.toDataURL('image/png'); //转换为base64地址形式
						console.log(base64url);
						$('#imgUpdate').val(base64url);
						$("#finalImg").prop("src", base64url); //显示为图片的形式
						//关闭裁剪框
						closeTailor();
					}
				});
			})
			$(function() {
				//默认永久
				var now = new Date();
				var time = now.getFullYear() + "-" + ((now.getMonth() + 1) < 10 ? "0" : "") + (now.getMonth() + 1) + "-" + (now.getDate() < 10 ? "0" : "") + now.getDate();
				var times = time + ' 23:59';
				var inputVal = $('#datetimepicker').val();
				var flags = 1;
				if (inputVal == '永久有效') {
					$('#datetimepicker').attr("disabled", "disabled");
					$('#datetimepicker').val('永久有效');
					flags = 1;
				} else {
					$('#datetimepicker').removeAttr("disabled");
					$('#datetimepicker').val(times);
					flags = 0;
				}
				$('#switch').click(function() {
					if (flags) {
						console.log(inputVal);
						$('#datetimepicker').removeAttr("disabled");
						$('#datetimepicker').val(times);
					} else {
						console.log(inputVal);
						$('#datetimepicker').attr("disabled", "disabled");
						$('#datetimepicker').val('永久有效');
					}
					flags = !flags;
				})
				$('.am-icon-times').click(function() {
					$('#erro-box').hide();
				})
				// 检测表单
				//电话号码的正则
				function isTelCode(str) {
					var reg = /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/;
					return reg.test(str);
				}
				//邮箱的正则
				function IsEmail(str) {
					var reg = /^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/;
					return reg.test(str);
				}
				// 检测密码
				function IsPwd(str) {
					var reg = /^[0-9a-zA-Z_]{5,19}$/;
					return reg.test(str);
				}
				$('#submit').click(function() {
					if ($('#user-name').val() != '') {
						if ($('#user-name').val().length >= 5 && $('#user-name').val().length <= 20) {
							var reg = /^[a-zA-Z][0-9a-zA-Z_]{4,19}$/;
							var r = reg.test($('#user-name').val());
							if (!r) {
								confirm('用户名必须以字母开头');
								return false;
							}
						} else {
							confirm('用户名长度必须为5-20');
							return false;
						}
					}
					if ($('#phone').val() != '') {
						if (!isTelCode($('#phone').val())) {
							confirm('您输入的手机号不合法');
							return false;
						}
					}
					if ($('#email').val() != '') {
						if (!IsEmail($.trim($('#email').val()))) {
							confirm('您输入的邮箱不合法');
							return false;
						}
					}
					if ($('#password').val() != $('#password_').val()) {
						confirm('两次输入的密码不一致');
						return false;
					}
					if ($('#user-name').val() == '' && $('#phone').val() == '' && $('#email').val() == '') {
						confirm('用户名,手机号,邮箱至少填写一项');
						return false;
					}
					return true;
				})
				var userParent = $('#user-name').parent().parent('.am-form-group');
				var userNext = $('#user-name').next('span');
				var phoneParent = $('#phone').parent().parent('.am-form-group');
				var phoneNext = $('#phone').next('span');
				var emailParent = $('#email').parent().parent('.am-form-group');
				var emailNext = $('#email').next('span');
				var pwdParent = $('#password').parent().parent('.am-form-group');
				var pwdNext = $('#password').next('span');
				var pwd_Parent = $('#password_').parent().parent('.am-form-group');
				var pwd_Next = $('#password_').next('span');
				$('#user-name').blur(function() {
					if ($('#user-name').val() != '') {
						if ($('#user-name').val().length >= 5 && $('#user-name').val().length <= 20) {
							var reg = /^[a-zA-Z][0-9a-zA-Z_]{4,19}$/;
							var r = reg.test($('#user-name').val());
							if (!r) {
								$(userParent).removeClass('am-form-success');
								$(userParent).addClass('am-form-error');
								$(userNext).removeClass('am-icon-check');
								$(userNext).addClass('am-icon-times');
							} else {
								$(userParent).removeClass('am-form-error');
								$(userParent).addClass('am-form-success')
								$(userNext).removeClass('am-icon-times');
								$(userNext).addClass('am-icon-check');
							}
						} else {
							$(userParent).removeClass('am-form-success');
							$(userParent).addClass('am-form-error');
							$(userNext).removeClass('am-icon-check');
							$(userNext).addClass('am-icon-times');
						}
					}
					if ($('#user-name').val() == '') {
						$(userParent).removeClass('am-form-success am-form-error');
						$(userNext).removeClass('am-icon-check am-icon-times');
					}
				})
				// 手机号
				$('#phone').blur(function() {
					if ($('#phone').val() != '') {
						if (!isTelCode($('#phone').val())) {
							$(phoneParent).removeClass('am-form-success');
							$(phoneParent).addClass('am-form-error');
							$(phoneNext).removeClass('am-icon-check');
							$(phoneNext).addClass('am-icon-times');
						} else {
							$(phoneParent).removeClass('am-form-error');
							$(phoneParent).addClass('am-form-success');
							$(phoneNext).removeClass('am-icon-times');
							$(phoneNext).addClass('am-icon-check');
						}
					}
					if ($('#phone').val() == '') {
						$(phoneParent).removeClass('am-form-success am-form-error');
						$(phoneNext).removeClass('am-icon-check am-icon-times');
					}
				})
				//邮箱
				$('#email').blur(function() {
					if ($('#email').val() != '') {
						if (!IsEmail($('#email').val())) {
							$(emailParent).removeClass('am-form-success');
							$(emailParent).addClass('am-form-error');
							$(emailNext).removeClass('am-icon-check');
							$(emailNext).addClass('am-icon-times');
						} else {
							$(emailParent).removeClass('am-form-error');
							$(emailParent).addClass('am-form-success');
							$(emailNext).removeClass('am-icon-times');
							$(emailNext).addClass('am-icon-check');
						}
					}
					if ($('#email').val() == '') {
						$(emailParent).removeClass('am-form-success am-form-error');
						$(emailNext).removeClass('am-icon-check am-icon-times');
					}
				})
				// 密码
				$('#password').blur(function() {
					if ($('#password').val() != '') {
						if (!IsPwd($('#password').val())) {
							$(pwdParent).removeClass('am-form-success');
							$(pwdParent).addClass('am-form-error');
							$(pwdNext).removeClass('am-icon-check');
							$(pwdNext).addClass('am-icon-times');
						} else {
							$(pwdParent).removeClass('am-form-error');
							$(pwdParent).addClass('am-form-success');
							$(pwdNext).removeClass('am-icon-times');
							$(pwdNext).addClass('am-icon-check');
						}
						if ($('#password_').val() != '') {
							//两次不一致
							if ($('#password_').val() != $('#password').val()) {
								$(pwd_Parent).removeClass('am-form-success');
								$(pwd_Parent).addClass('am-form-error');
								$(pwd_Next).removeClass('am-icon-check');
								$(pwd_Next).addClass('am-icon-times');
							} else {
								$(pwd_Parent).removeClass('am-form-error');
								$(pwd_Parent).addClass('am-form-success');
								$(pwd_Next).removeClass('am-icon-times');
								$(pwd_Next).addClass('am-icon-check');
							}
						}
					}
					if ($('#password').val() == '') {
						$(pwdParent).removeClass('am-form-success am-form-error');
						$(pwdNext).removeClass('am-icon-check am-icon-times');
					}
				})
				//二次密码
				$('#password_').blur(function() {
					if ($('#password_').val() != '') {
						if (!IsPwd($('#password_').val())) {
							$(pwd_Parent).removeClass('am-form-success');
							$(pwd_Parent).addClass('am-form-error');
							$(pwd_Next).removeClass('am-icon-check');
							$(pwd_Next).addClass('am-icon-times');
						} else {
							$(pwd_Parent).removeClass('am-form-error');
							$(pwd_Parent).addClass('am-form-success');
							$(pwd_Next).removeClass('am-icon-times');
							$(pwd_Next).addClass('am-icon-check');
						}
						//两次不一致
						if ($('#password_').val() != $('#password').val()) {
							$(pwd_Parent).removeClass('am-form-success');
							$(pwd_Parent).addClass('am-form-error');
							$(pwd_Next).removeClass('am-icon-check');
							$(pwd_Next).addClass('am-icon-times');
						}
					}
					if ($('#password_').val() == '') {
						$(pwd_Parent).removeClass('am-form-success am-form-error');
						$(pwd_Next).removeClass('am-icon-check am-icon-times');
					}
				})
				$.fn.datetimepicker.dates['zh-CN'] = {
					days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
					daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
					daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
					months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
					monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
					today: "今日",
					suffix: [],
					meridiem: ["上午", "下午"]
				};
				var $dpInput = $('.form-datetime-lang').datetimepicker({
					container: '#dateBox',
					language: 'zh-CN',
					format: 'yyyy-mm-dd hh:ii'
				});
				//页面中的input按钮事件
				$('.tpl-switch').find('.tpl-switch-btn-view').on('click', function() {
					$(this).prev('.tpl-switch-btn').prop("checked", function() {
						if ($(this).is(':checked')) {
							return false;
						} else {
							return true;
						}
					})
				})
				//底部调整
				var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null; 
				if (!isChrome) {
					$(".tpl-page-container .tpl-content-wrapper").addClass("R-wra");
					$(".tpl-page-container .tpl-left-nav").addClass("L-tpl");
				}
			})