123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- angular.module('push')
- .controller('personIdentifyCtrl', function ($scope, $stateParams, $ionicActionSheet, UtilService, AccountService, $timeout, accountModel) {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- $scope.authenstatus = -1;// 认证状态:0未认证 1认证中 2已认证 3认证失败
- var ditypelist = [];//证件类型
- var oldimageidlist = [0, 0];//旧附件di集合
- // 证件图片信息
- $scope.imagelist = [
- {
- id: 0,
- doctype: 6,//正面
- title: "",
- photo_name: ""
- }, {
- id: 0,
- doctype: 7,//反面
- title: "",
- photo_name: ""
- }
- ];
- var getAuthInfo = function () {
- $scope.showLoadingToast();
- AccountService.getAuthInfo(0).then(function (response) {
- console.log(1);
- console.log(response);
- ditypelist = response.idtype;
- accountModel.setOrgtypeList(response.orgtype);
- accountModel.setPositionalTitles(response.titles);//保存职称集合
- if (angular.isDefined(response.info)) {
- $scope.person = {
- type: response.info.type,
- name: response.info.name,
- idtype: response.info.idtype,
- idtypename: response.info.idtypename,
- cardno: response.info.cardno
- };
- accountModel.setOldUserAuthInfo(response.info);
- // 遍历找出证件类型名称
- angular.forEach(ditypelist, function (val, ind) {
- if (val.itemvalue == response.info.idtype) {
- $scope.person.idtypename = val.itemkey;
- }
- });
- $scope.authenstatus = response.info.authenstatus;
- $scope.postscript = response.info.postscript;
- // 遍历找出身份证正反面
- if (angular.isDefined(response.info.imagelist) && response.info.imagelist.length > 0) {
- angular.forEach(response.info.imagelist, function (val, ind) {
- if (val.doctype == 6) {
- $scope.imagelist[0] = val;
- oldimageidlist[0] = val.id;
- }
- if (val.doctype == 7) {
- $scope.imagelist[1] = val;
- oldimageidlist[1] = val.id;
- }
- })
- }
- accountModel.setSaveFlg(1);
- } else {
- initInfo();
- accountModel.setSaveFlg(0);
- }
- $scope.hideLoadingToast();
- }, function () {
- initInfo();
- $scope.hideLoadingToast();
- })
- };
- if(UtilService.isDefined(accountModel.getUserAuthInfo().name)){
- console.log(2);
- $scope.person = accountModel.getUserAuthInfo();
- $scope.imagelist = accountModel.getInfoImageList();
- }else {
- getAuthInfo();
- }
- // 初始化空信息
- var initInfo = function () {
- // 个人信息
- $scope.person = {
- name: "",
- type: 1,
- idtype: "",
- idtypename: "",
- cardno: ""
- };
- accountModel.setOldUserAuthInfo("");
- };
- //删除图片
- $scope.delectImg = function (imgind) {
- $scope.imagelist[imgind] = {};
- };
- // 选取身份证
- $scope.show_identify = function (imgind) {
- // 选取身份证弹框
- $ionicActionSheet.show({
- buttons: [
- {text: '<a class="action-sheet-push">拍照</a>'},
- {text: '<a class="action-sheet-push">从相册中添加</a>'}
- ],
- cancelText: '取消',
- buttonClicked: function (index) {
- if (index == 0) {
- openCamera(imgind);
- } else if (index == 1) {
- getPictures(imgind);
- }
- return true;
- }
- });
- };
- //拍照
- var openCamera = function (imgind) {
- UtilService.getPicture(1).then(function (results) {
- // console.log(results);
- $scope.imagelist[imgind].id = oldimageidlist[imgind];
- $scope.imagelist[imgind].photo_name = results;
- $scope.imagelist[imgind].original_name = results;
- $scope.imagelist[imgind].source_name = results;
- }, function (err) {
- });
- };
- //检测权限
- var verifyStorage = function (imgind) {
- window.imagePicker.verifyStorage(
- function (results) {
- if (results == "1") {
- getPic(imgind);
- }
- }, function (error) {
- }
- );
- };
- //打开相册
- var getPic = function (imgind) {
- var count = 1;
- if (imgind == 0) {
- count = 2;
- }
- UtilService.getPictureList(count).then(function (results) {
- // console.log(results);
- if (imgind == 0) {
- if (results.length == 1) {
- $scope.imagelist[0].id = oldimageidlist[0];
- $scope.imagelist[0].photo_name = results[0];
- $scope.imagelist[0].original_name = results[0];
- $scope.imagelist[0].source_name = results[0];
- }
- if (results.length == 2) {
- $scope.imagelist[0].id = oldimageidlist[0];
- $scope.imagelist[0].photo_name = results[0];
- $scope.imagelist[0].original_name = results[0];
- $scope.imagelist[0].source_name = results[0];
- $scope.imagelist[1].id = oldimageidlist[1];
- $scope.imagelist[1].photo_name = results[1];
- $scope.imagelist[1].original_name = results[1];
- $scope.imagelist[1].source_name = results[1];
- }
- } else {
- $scope.imagelist[1].id = oldimageidlist[1];
- $scope.imagelist[1].photo_name = results[0];
- $scope.imagelist[1].original_name = results[0];
- $scope.imagelist[1].source_name = results[0];
- }
- }, function (err) {
- });
- };
- var getPictures = function (imgind) {
- if (device.platform == "Android") {
- verifyStorage(imgind);
- } else {
- getPic(imgind);
- }
- };
- // 下一步
- $scope.nextStep = function () {
- if (!UtilService.isDefined($scope.person.name)) {
- UtilService.showMess("姓名不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.person.idtype)) {
- UtilService.showMess("证件类型不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.person.cardno)) {
- UtilService.showMess("证件号码不能为空");
- return;
- }
- /*if (!UtilService.isIdentityNumber($scope.person.cardno)) {
- UtilService.showMess("请输入正确的身份证号");
- return;
- }*/
- if (UtilService.isDefined($scope.person.orgemail) && (!UtilService.isEmail($scope.person.orgemail))) {
- UtilService.showMess("请输入正确的邮箱");
- return;
- }
- if ($scope.imagelist[0].photo_name == "" || $scope.imagelist[1].photo_name == "") {
- UtilService.showMess("请上传本人二代身份证正反照");
- return;
- }
- // console.log($scope.person);
- accountModel.setUserAuthInfo($scope.person);
- accountModel.setInfoImageList($scope.imagelist);
- $scope.go("chooseUnitType");
- };
- //证件类型
- $scope.showCardType = function () {
- var buttons = [];
- angular.forEach(ditypelist, function (value, index) {
- buttons.push({
- text: '<a class="action-sheet-push">' + value.itemkey + '</a>',
- type: value.itemvalue,
- name: value.itemkey
- })
- });
- $ionicActionSheet.show({
- buttons: buttons,
- cancelText: '取消',
- buttonClicked: function (index) {
- $scope.person.idtype = buttons[index].type;
- $scope.person.idtypename = buttons[index].name;
- return true;
- }
- });
- };
- $scope.againAuth = function () {
- $scope.authenstatus = -1;
- }
- });
|