123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- angular.module('push')
- .controller('jobIdentifyCtrl', function ($scope, $stateParams, $ionicActionSheet, UtilService, AccountService, $timeout, $ionicModal) {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- var doctype = 0;//附件类型:0其他 1工牌 2名片 3在职证明 8企业邮箱
- var saveflg = 0;//提交数据标志:0 新增 1 修改
- var docid;
- if ($stateParams.job == "") {
- saveflg = 0;
- $scope.job = {
- industry: "",
- title: "",
- imagelist: [{photo_name: ""}]
- };
- } else {
- saveflg = 1;
- var tempjob = angular.fromJson($stateParams.job);
- $scope.job = angular.copy(tempjob);
- if (angular.isUndefined(tempjob.imagelist)) {
- $scope.job.imagelist = [{photo_name: ""}]
- } else {
- docid = tempjob.imagelist[0].id;
- }
- }
- //删除图片
- $scope.delectImg = function () {
- $scope.job.imagelist[0] = {};
- };
- // 选取身份证
- $scope.show_identify = function (type) {
- $scope.closeModal();
- doctype = type;
- // 选取身份证弹框
- $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();
- } else if (index == 1) {
- getPictures();
- }
- return true;
- }
- });
- };
- //拍照
- var openCamera = function () {
- UtilService.getPicture(1).then(function (results) {
- // console.log(results);
- $scope.job.imagelist[0] = {
- photo_name: results,
- original_name: results,
- source_name: results
- };
- }, function (err) {
- });
- };
- //检测权限
- var verifyStorage = function () {
- window.imagePicker.verifyStorage(
- function (results) {
- if (results == "1") {
- getPic();
- }
- }, function (error) {
- }
- );
- };
- //打开相册
- var getPic = function () {
- UtilService.getPictureList(1).then(function (results) {
- // console.log(results);
- $scope.job.imagelist[0] = {
- photo_name: results[0],
- original_name: results[0],
- source_name: results[0]
- };
- }, function (err) {
- });
- };
- var getPictures = function () {
- if (device.platform == "Android") {
- verifyStorage();
- } else {
- getPic();
- }
- };
- //上传图片
- var tempimages = [];
- var uploadImages = function () {
- tempimages = [];
- var upimages = [];
- angular.forEach($scope.job.imagelist, function (data) {
- if (data.photo_name.indexOf("file:") != -1) {
- upimages.push(data.photo_name);
- } else {
- tempimages.push(data);
- }
- });
- UtilService.uploadFile(upimages, 0, "image/jpeg").then(function (response) {
- // console.log(response);
- angular.forEach(response, function (value) {
- if (value.status) {
- tempimages.push({
- id: docid,
- doctype: doctype,
- title: "",
- photo_name: value.userPhoto,
- original_name: value.originalPhoto,
- source_name: value.sourcePhoto,
- source_size: value.source_size
- });
- }
- });
- applyI()
- }, function () {
- UtilService.showMess("网络不给力,请重试");
- $scope.hideLoadingToast();
- })
- };
- //接口请求
- var applyI = function () {
- if (saveflg == 0) {
- AccountService.InsertSysUsersAuthen(2, $scope.job, tempimages).then(function (response) {
- UtilService.showMess("认证信息已提交,请您耐心等待……");
- $timeout(function () {
- $scope.goback();
- }, 1000);
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- })
- } else {
- AccountService.updateSysUsersAuthen(2, $scope.job, tempimages).then(function (response) {
- // console.log(response);
- UtilService.showMess("修改认证申请成功");
- $timeout(function () {
- $scope.goback();
- }, 1000);
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- })
- }
- };
- //申请职业认证
- $scope.applyJobAuth = function () {
- if (!UtilService.isDefined($scope.job.industry)) {
- UtilService.showMess("行业不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.job.title)) {
- UtilService.showMess("职位不能为空");
- return;
- }
- if (angular.isUndefined($scope.job.imagelist[0].photo_name) || $scope.job.imagelist[0].photo_name == "") {
- UtilService.showMess("请上传一张职业身份证明");
- return;
- }
- uploadImages();
- $scope.showLoadingToast();
- // console.log($scope.job);
- };
- $ionicModal.fromTemplateUrl('identifyImg.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function (modal) {
- $scope.modal = modal;
- });
- $scope.openModal = function () {
- $scope.modal.show();
- };
- $scope.closeModal = function () {
- $scope.modal.hide();
- };
- //Cleanup the modal when we're done with it!
- $scope.$on('$destroy', function () {
- $scope.modal.remove();
- });
- // Execute action on hide modal
- $scope.$on('modal.hidden', function () {
- // Execute action
- });
- // Execute action on remove modal
- $scope.$on('modal.removed', function () {
- // Execute action
- });
- });
|