// 全局变量
var contextPath = $("link[rel=stylesheet]").first().attr("href");
contextPath = contextPath.substring(0,contextPath.indexOf("/", 1));
var loadedScroll,iScroll;
$(function(){
//创建蒙版告知竖屏查看
var tipWatch = null;
// 横屏监听
var updateOrientation = function(){
if(tipWatch == null) {
tipWatch = $('
< img src="images/index.png" class="tip_rotate" />
为了更好的浏览体验,请将手机竖屏浏览
');
}
if(window.orientation=='-90' || window.orientation=='90'){
//alert('为了更好的体验,请将手机/平板竖过来!')
tipWatch.css("display","block");
//$(".custom").css({"transform":"rotate(90deg)","-webkit-transform":"rotate(90deg)"});
$("body").append(tipWatch);
}else{
console.log('竖屏状态');
//$(".custom").css({"transform":"rotate(0)","-webkit-transform":"rotate(0)"});
// tipWatch.css("display","none");
tipWatch.remove();
}
};
//手机端判断各个平台浏览器及操作系统平台
// function checkPlatform(){
// if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)){
// //这是iOS平台下浏览器
// swiperForIOS();
// }else{
// //这是Android及其他平台下浏览器
// swiperForAndroid();
// }
// if(/MicroMessenger/i.test(navigator.userAgent)){
// //这是微信平台下浏览器
// }
// };
// checkPlatform();
$(".tea").click(function(){
$(".liquor").show();
$(".sort").show();
$(".revise").css("margin-top","1rem");
// iScroll.refresh();
})
$(".notea").click(function(){
$(".liquor").hide();
$(".sort").hide();
$(".revise").css("margin-top","8rem");
// iScroll.refresh();
})
//滚动条事件
loadedScroll = function(id,bleX,bleY) {
iScroll = new IScroll(id, {
scrollbars: true,
click:true,
interactiveScrollbars: true,
shrinkScrollbars: 'scale',
fadeScrollbars: true,
scrollX: bleX,
scrollY: bleY,
scrollbars: 'custom'
});
};
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
// 返回历史记录上一页
$('.return').on("touchend",function(){
if(window.location.href.indexOf("/mental/practice")!=-1){
window.location.href=contextPath+"/wx/core/index";
}else if(window.location.href.indexOf("/mental/healthRecord")!=-1){
window.location.href=contextPath+"/wx/core/index";
}else if(window.location.href.indexOf("/mental/nextweekLast")!=-1){
window.location.href=contextPath+"/wx/core/index";
}else if(window.location.href.indexOf("/mental/mentalResult")!=-1 && window.location.href.refer.indexOf("/mental/practice")!=-1){
window.location.href=contextPath+"/wx/core/index";
}else{
window.history.go(-1);
}
});
/*发送验证码*/
//$(".getcode").click(function(){
// var $this = $(this),
// $time = 60;
// if(!$this.hasClass("gray")){
// $this.addClass("gray").html("重新获取(60)");
//
// showTime();
// }
// function showTime(){
// if($time ==0){
// $this.removeClass("gray").html("获取验证码");
// }else{
// $this.text("重新获取("+$time+")");
// setTimeout(showTime,1000);
// $time--;
// }
// }
//
// })
$(".cancel").click(function(){
$(this).parent().parent().parent().fadeOut();
})
$(".basicinfo li").click(function(){
$(".basicinfo li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".hotdog li").click(function(){
$(".hotdog li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".information label .right span").click(function(){
$(".information label .right span").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".span").click(function(){
if ($(this).hasClass("active")) {
$(this).removeClass("active");
$(this).prev("input").attr({'disabled':false});
$(this).prev("input").css({'background':"#fff"});
}else{
$(this).addClass("active");
$(this).prev("input").attr({'disabled':true});
$(this).prev("input").val("");
$(this).prev("input").css({'background':"#e8e8e8"});
}
})
$(".nonetest").click(function(){
$(this).addClass("active");
$(this).siblings().removeClass("active");
$(".testjuage label").find("input").attr({'disabled':true});
$(".testjuage label").find("input").css({'background':"#e8e8e8"});
});
$(".readytest").click(function(){
$(this).addClass("active");
$(this).siblings().removeClass("active");
$(".testjuage label").find("input").attr({'disabled':false});
$(".testjuage label").find("input").attr({'style':""});
});
$(".message label .right span").click(function(){
$(".message label .right span").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".job li").click(function(){
$(".job li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".degree li").click(function(){
$(".degree li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".inplay li").click(function(){
$(".inplay li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".diagnosis li").click(function(){
$(".diagnosis li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".highlow li").click(function(){
$(".highlow li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".ApoE li").click(function(){
$(".ApoE li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".disease li").click(function(){
if ($(this).hasClass("active")) {
$(this).removeClass("active");
}else{
$(this).addClass("active");
}
})
$(".familydisease li").click(function(){
if ($(this).hasClass("active")) {
$(this).removeClass("active");
}else{
$(this).addClass("active");
}
})
$(".liquor li").click(function(){
$(".liquor li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".sort li").click(function(){
$(".sort li").eq($(this).index()).addClass("active").siblings().removeClass('active');
});
$(".follow .add").click(function(){
var $goodsCount= parseInt($(this).prev().val());
$(this).prev().val($goodsCount+1);
});
$(".follow .minus").click(function(){
var $goodsCount= parseInt($(this).next().val());
$(this).next().val($goodsCount<=0?0:$goodsCount-1);
});
$(".answer").click(function(){
$(".question").hide();
$(".answer").hide();
$(".resulttip").show();
$(".nextquestion").show();
})
$(".yes").click(function(){
$(".yesmes").show();
})
$(".no").click(function(){
$(".yesmes").hide();
})
$(".radio .ohter").click(function(){
var that=$(this);
$(that).siblings(".othercon").show();
// iScroll.refresh();
});
$(".radio .both").click(function(){
var that=$(this);
$(that).siblings(".othercon").hide();
// iScroll.refresh();
});
$(".checkbox .ohter").click(function(){
var that=$(this);
if($(that).hasClass("active")){
$(that).siblings(".othercon").show();
}else{
$(that).siblings(".othercon").hide();
$(that).siblings(".othercon").val("");
}
// iScroll.refresh();
});
});
/*发送验证码*/
$(".getcode").click(function(){
var mobile=$("input[name=mobile]").val().trim();
console.log($("input[name=mobile]"));
if (!isMobile(mobile)) {
alert("手机号码不正确");
return false;
}
var $this = $(this),
$time = 60;
if(!$this.hasClass("gray")){
$this.addClass("gray").html("重新获取(60)");
//发送验证码操作
$.ajax({
url:contextPath+"/wx/account/code",
type:'post',
data:{"mobile":mobile},
success:function(result){
if (result.code==0) {
// window.location.href="${contextPath}/wx/user/secondBasic";
alert("短信已发送,注意查收");
}else{
alert(result.message);
}
},
error:function(){
alert("系统异常");
}
});
showTime();
}
function showTime(){
if($time ==0){
$this.removeClass("gray").html("获取验证码");
}else{
$this.text("重新获取("+$time+")");
setTimeout(showTime,1000);
$time--;
}
}
});
/**
* 判断是否是手机号
* @param str
* @returns
*/
function isMobile(str){
var reg = /^1\d{10}$/;
return reg.test(str);
}
//移除数组指定元素
function removeArr(array,index)
{
if(index<=(array.length-1))
{
for(var i=index;i