app.controller('StdRegCtrl', ['$rootScope', '$scope', '$http', '$timeout', '$state', '$stateParams', function ($rootScope, $scope, $http, $timeout, $state, $stateParams) { $scope.curStep = 'start'; $scope.StdReg = {}; 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.stdType = []; $scope.artArr = []; $scope.artArr = response.entity.art_science_status.split(","); for (const art of $scope.artArr) { for (const st of $rootScope.StdTypeArray) { if (art == st.dict_value) { $scope.stdType.push(st); break; } } } } }); } 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'; //开启高考科类 if ($rootScope.getParamValue('EnrolReg_StdType', 'InActive') == 'Active' && $scope.StdReg.std_province < 70) { $scope.findProvinceArtScience(); } } } $rootScope.ajaxRequest({ url: '../enrol/reg/province/list.htm' }, function (response) { $scope.provinceArray = response.array; }); //alert($rootScope.checkParamValue('EnrolVerifyStdIdentity', 'InActive', 'Active')); // alert($rootScope.getParamValue('EnrolVerifyStdIdentity', 'InActive')); // console.log($rootScope.FrameParam); /*************************************************************************** * 选择生源地 */ $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 + '') == '81' || (p.province_id + '') == '82') { // 澳门,香港 港澳居民来往内地通行证 $scope.curStep = 'HongKongMacaoPass'; $scope.StdReg.cert_type = 'TaiWanPass'; } else if ((p.province_id + '') == '91') { //永久居留证 $scope.curStep = 'IdCard91Warning'; $scope.StdReg.cert_type = 'JuZhuZhengPass'; } else { if (p.ksh_status == 'Active') { // 必须有高考报名号 $scope.curStep = 'ExamIdWarning'; } else { // 大陆,需要上传身份证 $scope.curStep = 'IdCardWarning'; $scope.StdReg.cert_type = 'IdCard'; } } //开启高考科类 if ($rootScope.getParamValue('EnrolReg_StdType', 'InActive') == 'Active' && $scope.StdReg.std_province < 70) { $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.saveIdCard = function () { $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); if ($scope.StdReg.cert_id == undefined || $scope.StdReg.cert_id.length == 0) { $.alert('请输入证件号码信息!'); return false; } if ($scope.StdReg.std_name == undefined || $scope.StdReg.std_name.length == 0) { $.alert('请输入考生姓名信息!'); return false; } if ($scope.StdReg.std_name_verify == undefined || $scope.StdReg.std_name_verify.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 == 0 || ($scope.StdReg.std_province < 70 && $scope.StdReg.std_mobile.length != 11)) { $.alert('请输入正确的手机号码!'); return false; } if ($scope.StdReg.std_mobile_verify == undefined || $scope.StdReg.std_mobile_verify.length == 0 || ($scope.StdReg.std_province < 70 && $scope.StdReg.std_mobile_verify.length != 11)) { $.alert('请输入正确的确认手机号码!'); return false; } if ($scope.StdReg.std_mobile !== $scope.StdReg.std_mobile_verify) { $.alert('手机号码2次输入不一致,请检查!'); return false; } if ($scope.StdReg.std_name !== $scope.StdReg.std_name_verify) { $.confirm('系统识别的姓名和你输入的姓名不一致,系统将以你的的输入为准,确认吗?', function () { $.showLoading("正在提交考生信息,请稍后...") $scope.StdReg.std_name = $scope.StdReg.std_name_verify; $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'; } }); }, function () { }); } else { $.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.saveIdCardJuZhuZheng = function () { $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); if ($scope.StdReg.cert_id == undefined || $scope.StdReg.cert_id.length == 0) { $.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_param2 == undefined || $scope.StdReg.std_param2.length == 0) { $.alert('请输入高考所在省份!'); return false; }*/ if ($scope.StdReg.exam_id == undefined || $scope.StdReg.exam_id.length == 0) { $.alert('请输入高考报名号!'); return false; } //港澳台的考生-手机号码-不做限制 if ($scope.StdReg.std_mobile == undefined || $scope.StdReg.std_mobile.length == 0 || ($scope.StdReg.std_province < 70 && $scope.StdReg.std_mobile.length != 11)) { $.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.saveExtendInfo = function () { $.showLoading("正在提交考生信息,请稍后...") $rootScope.ajaxRequest({ url: '../enrol/std/info/save.htm', data: $scope.StdReg }, function (response) { $.hideLoading(); // 显示注册成功 $scope.curStep = 'RegSuccess'; }); } /*************************************************************************** * 上传免冠证件照 */ $scope.uploadNoCrownPhoto = function () { wx.chooseImage({ count: 1, // 默认9 sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有'original', sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 success: function (res) { $scope.localIds = res.localIds; //$scope.curStep = 'NoCrownPhotoConfirm'; // 返回图片下载后的本地ID wx.getLocalImgData({ localId: res.localIds[0], // 图片的localID success: function (res) { $timeout(function () { $scope.localData = res.localData; // localData是图片的base64数据,可以用img标签显示 //$scope.curStep = 'NoCrownPhotoConfirm'; $scope.goStep('NoCrownPhotoConfirm'); }, 200); } }); } }); // $rootScope.uploadStdMaterial('NoCrownPhoto', function() { // // $scope.curStep = 'StdExtendInfo'; // //if ($rootScope.checkParamValue('EnrolVerifyStdIdentity', 'InActive', 'Active')) { // // $scope.curStep = 'VerifySuccess'; // //} else { // $scope.curStep = 'StdExtendInfo'; // //} // }); } $scope.confirmCrownPhoto= function (step) { wx.uploadImage({ localId : $scope.localIds[0], // 需要上传的图片的本地ID,由chooseImage接口获得 isShowProgressTips : 1, // 默认为1,显示进度提示 success : function(serverRes) { const serverId = serverRes.serverId; // 返回图片的服务器端ID $.showLoading("考生材料上传中,请稍候...") // 上传成功,去服务器取图片 $timeout(function () { const vData = { std_id : $rootScope.ArtStdReg.std_id, media_id: serverId, material_type: 'NoCrownPhoto' }; $rootScope.ajaxRequest({ url : '../enrol/std/material/upload.htm', method : 'post', data : vData }, function(data) { $.hideLoading(); $rootScope[material_type] = data.entity; $rootScope.ArtStdReg.std_image = data.entity.material_file; $scope.goStep('StdExtendInfo'); }); }, 200); }, fail : function(error) { $.alert('图片服务器暂时无法访问,请稍侯再试', '错误提示'); } }); } $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("证件照片上传中,请稍后...") // 上传成功,去服务器取图片 var url = '../enrol/wx/reg/idcard/' + ($scope.StdReg.std_province < '70' ? '' : 'other/') + 'upload.htm'; if ($rootScope.getParamValue('SchoolCode') == '51065') { url = '../enrol/wx/reg/idcard/other/upload.htm'; } $rootScope.ajaxRequest({ url: url, data: { media_id: serverId } }, function (response) { $.hideLoading(); if ($rootScope.getParamValue('SchoolCode') == '51065') { $scope.curStep = 'IdCardOther'; } else { 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 if ($scope.StdReg.std_province == '91') { $scope.curStep = 'IdCardJuZhuZhengOther'; } else { $scope.curStep = 'IdCardOther'; } } $scope.StdReg.idcard_file_name = response.map.IdCardFileName; }); }, fail: function (error) { $.hideLoading(); $.alert('图片服务器暂时无法访问,请稍侯再试', '错误提示'); } }); } }); } //上传永久居留证 $scope.openIdJzzCard = 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("证件照片上传中,请稍后...") // 上传成功,去服务器取图片 var url = '../enrol/wx/reg/idcard/other/upload.htm'; $rootScope.ajaxRequest({ url: url, data: { media_id: serverId } }, function (response) { $.hideLoading(); $scope.curStep = 'IdCardJuZhuZhengOther'; $scope.StdReg.idcard_file_name = response.map.IdCardFileName; }); }, fail: function (error) { $.hideLoading(); $.alert('图片服务器暂时无法访问,请稍侯再试', '错误提示'); } }); } }); } //切换永久居留证 $scope.changeJzz = function () { $.confirm("确定切换到上传永久居留证吗?(针对没有身份证,只有永久居留证的考生)", function () { // 点击确认后的回调函数 $timeout(function () { $scope.curStep = 'IdCard91Warning'; $scope.StdReg.cert_type = 'JuZhuZhengPass'; }, 200); }, function () { // 点击取消后的回调函数 }); } }])