app.controller("StdRegCtrl", [ "$rootScope", "$scope", "$http", "$timeout", "$state", "$stateParams", function ($rootScope, $scope, $http, $timeout, $state, $stateParams) { $scope.showLiveCheckLoading = false; $scope.curStep = "start"; $scope.StdReg = {}; $scope.YmStdCategoryArray = []; if (!$rootScope.loginSuccess) return; /**************************** * 根据省份-查找该省份的文理区分 */ $scope.findProvinceArtScience = function () { $rootScope.ajaxRequest( { url: "../conf/std/reg/get/province.htm", data: { province_id: $scope.StdReg.std_province }, }, function (response) { if (response.entity) { $scope.artArr = []; $scope.artArr = response.entity.art_science_status.split(","); for (const art of $scope.artArr) { for (const st of $rootScope.StdCategoryArray) { if (art == st.dict_value) { $scope.YmStdCategoryArray.push(st); break; } } } if ($scope.YmStdCategoryArray.length == 1) { $scope.StdReg.std_param3 = $scope.YmStdCategoryArray[0].dict_value; } $scope.YmStdCategoryArray.unshift({ dict_text: "请选择", dict_value: null, }); } } ); }; if ($rootScope.ArtStdReg !== undefined) { $scope.StdReg = angular.extend({}, $rootScope.ArtStdReg); if ($scope.StdReg.reg_status == "IdCard") { $scope.curStep = "NoCrownPhotoWarning"; } else if ($scope.StdReg.reg_status == "NoCrownPhoto") { $scope.curStep = "StdExtendInfo"; $scope.findProvinceArtScience(); } } $scope.getCategory = function () { if ($scope.YmStdCategoryArray.length < 1) { $scope.findProvinceArtScience(); } }; //生源地 $rootScope.ajaxRequest( { url: "../enrol/reg/province/list.htm", }, function (response) { $scope.provinceArray = response.array; } ); //邮寄省份 /* $rootScope.ajaxRequest( { url: "../enrol/std/reg/province/list.htm", }, function (response) { $scope.provArray = response.array; } );*/ /*//邮寄城市初始列表 $rootScope.ajaxRequest({ url : '../enrol/std/reg/city/alllist.htm' }, function(response) { $scope.cityArray = response.array; }); */ //过滤城市 /* $scope.freshCity = function () { $rootScope.ajaxRequest( { url: "../enrol/std/reg/city/list.htm?province_id=" + $scope.StdReg.link_province, }, function (response) { $scope.cityArray = response.array; } ); };*/ //选择考生类型 $scope.chooseStdType = function (d) { $rootScope.ajaxRequest( { url: "../enrol/province/list/stdType.htm", data: { std_type: d.dict_value }, }, function (response) { $scope.provinceArray = response.array; $scope.curStep = "province"; } ); }; /*************************************************************************** * 选择生源地 */ $scope.chooseProvince = function (p) { if (p.reg_status == "InActive") { var msg = "未开放【" + p.province_name + "】考生注册!"; if (p.reg_fetch_param != undefined) msg = p.reg_fetch_param; $.alert(msg); return; } $scope.currentProvince = p; $scope.StdReg.std_province = p.province_id; $scope.StdReg.province_name = p.province_name; if (p.province_id + "" == "90") { // 外国,护照 $scope.curStep = "PassportWarning"; $scope.StdReg.cert_type = "Passport"; } else if (p.province_id + "" == "71") { // 台湾,台湾居民往来大陆通行证,澳门,香港 港澳居民来往内地通行证 $scope.curStep = "IdCard71Warning"; $scope.StdReg.cert_type = "TaiWanPass"; } else if ( p.province_id + "" == "80" || p.province_id + "" == "81" || p.province_id + "" == "82" ) { // 澳门,香港 港澳居民来往内地通行证 $scope.curStep = "HongKongMacaoPass"; $scope.StdReg.cert_type = "TaiWanPass"; } else if (p.ksh_status == "Active") { // 必须有高考报名号 $scope.curStep = "ExamIdWarning"; } else { // 大陆,需要上传身份证 $scope.curStep = "IdCardWarning"; $scope.StdReg.cert_type = "IdCard"; } $scope.findProvinceArtScience(); }; $scope.checkExamId = function () { $scope.StdReg.exam_id = $.trim($scope.StdReg.exam_id); if ( $scope.StdReg.exam_id == undefined || $scope.StdReg.exam_id.length == 0 ) { $.alert("高考报名号必须填写!"); return false; } $.showLoading("正在提交考生信息,请稍后..."); $rootScope.ajaxRequest( { url: "../enrol/reg/province/check.htm", data: $scope.StdReg, }, function (response) { $.hideLoading(); // 大陆,需要上传身份证 $scope.curStep = "IdCardWarning"; $scope.StdReg.cert_type = "IdCard"; } ); }; //非大陆考生通行证和证件号码判断 $scope.isCert = function (str) { var pat = /^[a-zA-Z0-9()]+$/; return pat.test(str); }; /*************************************************************************** * 识别正确,保存用户信息 */ $scope.saveIdCard = function (flag) { $scope.StdReg.cert_id = $.trim($scope.StdReg.cert_id); $scope.StdReg.std_name = $.trim($scope.StdReg.std_name); $scope.StdReg.std_sex = $.trim($scope.StdReg.std_sex); $scope.StdReg.std_mobile = $.trim($scope.StdReg.std_mobile); $scope.StdReg.std_name_confirm = $.trim($scope.StdReg.std_name_confirm); if ( $scope.StdReg.cert_id === undefined || $scope.StdReg.cert_id.length === 0 ) { $.alert("请输入证件号码!"); return false; } if (flag === 2) { if ( $scope.StdReg.std_param2 === undefined || $scope.StdReg.std_param2.length === 0 ) { $.alert("请输入身份证号码!"); return false; } if ( $scope.StdReg.cert_id.indexOf("(") !== -1 || $scope.StdReg.cert_id.indexOf(")") !== -1 ) { $.alert("证件号码请输入半角括号!"); return false; } if ( $scope.StdReg.std_param2.indexOf("(") !== -1 || $scope.StdReg.std_param2.indexOf(")") !== -1 ) { $.alert("身份证号码请输入半角括号!"); return false; } if (!$scope.isCert($scope.StdReg.cert_id)) { if ($scope.StdReg.std_province === "90") { $.alert("护照号只能为数字、字母、半角括号!"); return false; } else { $.alert("证件号码只能为数字、字母、半角括号!"); return false; } } if (!$scope.isCert($scope.StdReg.std_param2)) { $.alert("居民身份证只能为数字、字母、半角括号!"); return false; } } if ( $scope.StdReg.std_name === undefined || $scope.StdReg.std_name.length === 0 ) { $.alert("请输入考生姓名!"); return false; } if ( $scope.StdReg.std_sex === undefined || $scope.StdReg.std_sex.length === 0 ) { $.alert("请选择考生性别!"); return false; } if ( $scope.StdReg.std_mobile === undefined || $scope.StdReg.std_mobile.length !== 11 ) { $.alert("请输入正确的手机号码!"); return false; } // 识别姓名和自输入姓名不相等 if ($scope.StdReg.std_name_confirm !== $scope.StdReg.std_name) { $.alert("自动识别的姓名和考生确认的姓名不一致,请修改为正确的姓名!"); return false; } $.showLoading("正在提交考生信息,请稍后..."); $rootScope.ajaxRequest( { url: "../enrol/reg/save.htm", data: $scope.StdReg, }, function (response) { $.hideLoading(); $scope.StdReg = response.entity; $rootScope.ArtStdReg = $scope.StdReg; // 上传免冠证件照 if ($scope.StdReg.std_image) { $scope.curStep = "StdExtendInfo"; } else { // 上传免冠证件照 $scope.curStep = "NoCrownPhotoWarning"; } } ); }; //是否是中文 $scope.isChinese = function (str) { var reg = /^[\u4e00-\u9fa5]+$/; return reg.test(str); }; /*************************************************************************** * 完善个人信息 */ $scope.saveExtendInfo = function () { // 考生 if ($rootScope.getParamValue("SchoolCode") === "51065") { if ( $scope.StdReg.std_type === undefined || $scope.StdReg.std_type === "" ) { $.alert("请选择考生类型!"); return false; } } if ( $scope.StdReg.link_mobile && $scope.StdReg.std_mobile === $scope.StdReg.link_mobile ) { $.alert("紧急联系电话与本人手机号码不能相同!"); return false; } //政治面貌 if ( $scope.StdReg.std_political === undefined || $scope.StdReg.std_political === "" ) { $.alert("请选择政治面貌!"); return false; } //科类 if ( $scope.StdReg.std_param3 === undefined || $scope.StdReg.std_param3 === "" || $scope.StdReg.std_param3.length === 0 ) { $.alert("请选择科类!"); return false; } //科类 if ( $scope.StdReg.std_param4 === undefined || $scope.StdReg.std_param4 === "" || $scope.StdReg.std_param4.length === 0 ) { $.alert("请选择毕业类型!"); return false; } //毕业学校 if ( $rootScope.getParamValue("EnrolReg_ShowStdSchool", "Active") === "Active" && ($scope.StdReg.std_school === undefined || $scope.StdReg.std_school === "") ) { $.alert("请填写毕业学校!"); return false; } //考生类别 if ( $scope.StdReg.std_param5 === undefined || $scope.StdReg.std_param5 === "" ) { $.alert("请选择考生类别!"); return false; } /**毕业时间**/ if ( $scope.StdReg.end_date === undefined || $scope.StdReg.end_date === "" ) { $.alert("请填写毕业时间!"); return false; } //紧急联系人 if ( $scope.StdReg.link_man === undefined || $scope.StdReg.link_man === "" ) { $.alert("请填写紧急联系人!"); return false; } else if (!$scope.isChinese($scope.StdReg.link_man)) { $.alert("紧急联系人必须是汉字!"); return false; } //家长手机号 if ( $scope.StdReg.link_mobile === undefined || $scope.StdReg.link_mobile === "" ) { $.alert("请填写联系人手机号!"); return false; } //通信地址 if ( $rootScope.getParamValue("EnrolReg_LinkAddr", "Active") === "Active" && ($scope.StdReg.link_addr === undefined || $scope.StdReg.link_addr === "") ) { $.alert("请填写通讯地址!"); return false; } //邮政编码 if ( $scope.StdReg.link_postal === undefined || $scope.StdReg.link_postal === "" || $scope.StdReg.link_postal.length === 0 ) { $.alert("请填写邮政编码!"); return false; } if ( $scope.StdReg.link_postal.length !== 6 || $scope.isChinese($scope.StdReg.link_postal) ) { $.alert("请输入6位的邮政编码!"); return false; } //电子邮箱 if ($rootScope.getParamValue("EnrolReg_email", "Active") === "Active") { if ($scope.StdReg.email === undefined || $scope.StdReg.email === "") { $.alert("请填写电子邮箱!"); return false; } } $.showLoading("正在提交考生信息,请稍后..."); $rootScope.ajaxRequest( { url: "../enrol/std/info/save.htm", data: $scope.StdReg, }, function (response) { $.hideLoading(); // 显示注册成功 $scope.curStep = "RegSuccess"; } ); }; /*************************************************************************** * 上传免冠证件照 */ // $scope.uploadNoCrownPhoto = function () { // $rootScope.uploadStdMaterialPhoto("NoCrownPhoto", function () { // // $scope.curStep = 'StdExtendInfo'; // if ( // $rootScope.checkParamValue( // "EnrolVerifyStdIdentity", // "InActive", // "Active" // ) // ) { // $scope.curStep = "VerifySuccess"; // } else { // $scope.curStep = "StdExtendInfo"; // } // }); // }; let bizToken = sessionStorage.getItem("biz_token"); if (bizToken) { $scope.showLiveCheckLoading = true; $rootScope.ajaxRequest( { url: "../std/register/live/result.htm", data: { bizToken: bizToken, }, }, function (res) { $scope.showLiveCheckLoading = false; // location.reload(); $.hideLoading(); if (res && res.result == 1) { $scope.curStep = "StdExtendInfo"; } } ); sessionStorage.removeItem("biz_token"); } $scope.uploadNoCrownPhoto = function () { $rootScope.ajaxRequest( { url: "../std/register/live/token.htm", data: { stdName: $scope.StdReg.std_name, certId: $scope.StdReg.cert_id, }, }, function (res) { $.hideLoading(); if (res && res.url && res.bizToken) { sessionStorage.setItem("biz_token", res.bizToken); location.href = res.url; } } ); }; $scope.goStep = function (step) { $scope.curStep = step; }; $scope.openIdCard = function () { wx.chooseImage({ count: 1, // 默认9 sizeType: ["compressed"], // 可以指定是原图还是压缩图,默认二者都有'original', sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有 success: function (res) { var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片 wx.uploadImage({ localId: localIds[0], // 需要上传的图片的本地ID,由chooseImage接口获得 isShowProgressTips: 1, // 默认为1,显示进度提示 success: function (serverRes) { var serverId = serverRes.serverId; // 返回图片的服务器端ID $.showLoading("证件照片上传中,请稍后..."); // 上传成功,去服务器取图片 $rootScope.ajaxRequest( { url: "../enrol/wx/reg/idcard/" + ($scope.StdReg.std_province < "70" ? "" : "other/") + "upload.htm", data: { media_id: serverId, }, }, function (response) { $.hideLoading(); if ($scope.StdReg.std_province < "70") { $scope.StdReg.cert_id = response.map.IdCardInfo.person_code; $scope.StdReg.std_name = response.map.IdCardInfo.person_name; $scope.StdReg.std_sex = response.map.IdCardInfo.person_sex; $scope.StdReg.std_nation = response.map.IdCardInfo.person_nation; $scope.StdReg.cert_addr = response.map.IdCardInfo.person_addr; $scope.curStep = "IdCardResult"; } else { $scope.curStep = "IdCardOther"; } $scope.StdReg.idcard_file_name = response.map.IdCardFileName; } ); }, fail: function (error) { $.hideLoading(); $.alert("图片服务器暂时无法访问,请稍侯再试", "错误提示"); }, }); }, }); }; //选择毕业日期 $scope.getGraduateDate = function () { weui.datePicker({ start: 1990, end: new Date().getFullYear(), defaultValue: [ new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate(), ], depth: 2, onChange: function (result) { //console.log(result); }, onConfirm: function (result) { $scope.$apply(function () { $scope.StdReg.end_date = result[0].label + result[1].label; }); }, title: "日期选择", }); }; }, ]);