//赛事报名申请
var bbeFlag = "0";
//获取子赛事列表
function childList(id){
var sendData = {};
sendData["mainShowId"] = id;
util.sendAjax({
url:'show/child',
data:sendData,
async:false,
loadFlag:true,
type:'GET',
cache:false,
success:function(data){
if(data.rc==0){
if(data.list!=null&&data.list.length>0){
$("#childList").html("");
$.each(data.list,function(index,item){
$("#childList").append("")
})
var showCode = [];
$(".childMatch").on("click",function(){
if(!$(this).attr("flag")){
$(this).attr("flag","true");
showCode.push($(this).val())
}else{
$(this).removeAttr("flag");
var val = $(this).val();
if(showCode.indexOf(val)!="-1"){
var index = showCode.indexOf(val);
showCode.splice(index,1);
}
}
var showCodes = showCode.join();
getPrice(showCodes);
});
$("#SendInfo").on("click",function(){
var showCodes = showCode.join();
applyMatch(showCodes);
})
}
}
}
});
}
//获取价格
function getPrice(showCodes){
var sendData = {};
sendData["showCodes"] = showCodes;
util.sendAjax({
url:'show/apply/getPrice',
data:sendData,
async:true,
loadFlag:true,
type:'GET',
cache:false,
success:function(json){
if(json.rc==0){
$("#price").html(json.data.price);
}else{
layer.open({
content:"价格获取失败:"+json.msg,
skin:'msg',
time:2
});
}
}
});
}//我的狗列表
function getMyDog(){
util.sendAjax({
url:'dog/dog',
data:{},
async:false,
loadFlag:true,
type:'GET',
cache:false,
success:function(json){
if(json.rc==0){
$.each(json.list,function(index,item){
$("#dogList").append("
"+item.pedigreeCertifiedCode+"")
})
$("#dogList").children("dd").on("click",function(){
$("#dogList").removeAttr("flag");
$("#dogList").hide();
var val = $(this).text();
$("#zsid").val(val);
})
}else{
layer.open({
content:"狗列表获取失败:"+json.msg,
skin:"msg",
time:2
});
}
}
});
}
//显示狗列表
function showDog(){
if($("#dogList").attr("flag")){
$("#dogList").removeAttr("flag");
$("#dogList").hide();
}else{
$("#dogList").attr("flag","true");
$("#dogList").show();
}
}
var localPedigreeCertifiedCode = "";
//获取狗信息
function getDogMsg(){
if($("#zsid").val()==""){
layer.open({
content:"证书号不能为空!",
skin:'msg',
time:2
})
}else {
var sendData = {};
var pedigreeCertified = $("#zsid").val().trim();
sendData["pedigreeCertifiedCode"] = pedigreeCertified;
util.sendAjax({
url: 'dog/dog/getOneByPedigreeCertified',
data: sendData,
async: true,
loadFlag: true,
type: 'GET',
cache: false,
success: function (json) {
if (json.rc == 0) {
if (json.data != null) {
$("#emptyDogInfo").hide();
localPedigreeCertifiedCode = json.data.pedigreeCertifiedCode
$("#showDogInfo").html("犬种:"+json.data.dogBreedName+""
+"犬名:"+json.data.nameEn+""
+"犬主人:"+json.data.dogOwner+""
+"出生日期:"+json.data.birthdate+""
+" 芯片号:"+json.data.identificationFlag+""
+"毛色:"+json.data.colorFlag+"");
getGroup(pedigreeCertified);
} else {
layer.open({
content:"查询信息失败,没有找到相关记录!",
skin:'msg',
time:2
});
$("#showDogInfo").html("");
$("#emptyDogInfo").show();
$("#dogAgeClassList").html("");
$("#dogAgeRemind").show();
}
} else {
layer.open({
content:"证书号有误:" + json.msg,
skin:'msg',
time:2
});
$("#showDogInfo").html("");
$("#emptyDogInfo").show();
$("#dogAgeClassList").html("");
$("#dogAgeRemind").show();
}
}
})
}
}
function bbecheckFunc(){
if($("#bbecheckbox").attr("checked")==undefined){
$("#bbecheckbox").attr("checked","true");
bbeFlag = "1";
}else{
$("#bbecheckbox").removeAttr("checked");
bbeFlag = "0";
}
}
//获取年龄组别
function getGroup(){
var agegroupData = {};
var data = util.getQueryString();
var id = data.id;
agegroupData["mainShowId"] = id;
agegroupData["pedigreeCertified"] = localPedigreeCertifiedCode;
util.sendAjax({
url:'show/agegroup',
data:agegroupData,
async:true,
loadFlag:true,
type:'GET',
cache:false,
success:function(json){
if(json.rc==0){
$("#dogAgeClassList").html("");
$("#dogAgeRemind").hide();
$.each(json.list,function(index,item){
$("#dogAgeClassList").append("")
});
//查询初始化
$("#bbespan").css("display","none");
bbeFlag = "0";
if(json.bbeFlag=="1"){
$("#bbespan").css("display","block");
}
}else{
layer.open({
content:"年龄组别获取失败:"+json.msg,
skin:'msg',
time:2
});
$("#dogAgeClassList").html("");
$("#dogAgeRemind").show();
}
}
});
}
//检测牵犬师会员号
function showUser(){
var sendData = {};
var memberCode = $("#lx_userid").val().trim();
sendData["memberCode"] = memberCode;
if(memberCode!=""){
util.sendAjax({
url:'member',
data:sendData,
async:true,
loadFlag:true,
type:'GET',
cache:false,
success:function(json){
if(json.rc==0){
$("#lx_name").html(json.data.name);
$("#lx_tel").html(json.data.mobile);
}else{
layer.open({
content:"牵犬师会员号查询失败:"+json.msg,
skin:"msg",
time:2
});
$("#lx_name").html("");
$("#lx_tel").html("");
}
}
});
}else{
layer.open({
content:"牵犬师会员号不能为空!",
skin:"msg",
time:2
})
}
}
//赛事申请
function applyMatch(showCode){
var sendData = {};
sendData["showCode"] = showCode;
if(util.isVal(showCode)==""){
layer.open({
content:"场次不能为空!",
skin:"msg",
time:2
});
return;
}
var ageGroup = $(":radio[name='ageclass']:checked").val();
if(util.isVal(ageGroup)==""){
layer.open({
content:"冠军组别不能为空!",
skin:"msg",
time:2
});
return;
}
sendData["ageGroup"] = ageGroup;
var pedigreeCertified = $("#zsid").val();
if(util.isVal(pedigreeCertified)==""){
layer.open({
content:"血统证书号不能为空!",
skin:"msg",
time:2
});
return;
}
sendData["bbeFlag"] = bbeFlag;
sendData["pedigreeCertified"] = localPedigreeCertifiedCode;
var handlerMemberCode = $("#lx_userid").val();
if(util.isVal(handlerMemberCode)==""){
layer.open({
content:"牵犬师会员号不能为空!",
skin:"msg",
time:2
});
return;
}
sendData["handlerMemberCode"] = $("#lx_userid").val().trim();
util.sendAjax({
url:'show/apply',
data: JSON.stringify(sendData),
async:true,
loadFlag:true,
type:'POST',
cache:false,
success:function(json){
if(json.rc==0){
layer.open({
content: '业务添加成功,是否跳转到业务核对页面进行支付!'
,btn: ['确定', '取消']
,yes: function(index){
window.location.href="orderList.html"
}
});
}else{
layer.open({
content:"报名申请失败:"+json.msg,
skin:"msg",
time:2
});
}
}
});
}
//初始化
$(function(){
var data = util.getQueryString();
var id = data.id;
childList(id);
getMyDog();
})