angular.module('push') .controller('activitySignUpConfirmCtrl', function ($scope, $stateParams, ActivityService, UtilService, UserService) { /* $scope.setStatusBar(1);*/ // $scope.usertype = $stateParams.usertype; $scope.usertype = UserService.role[0];// 用户角色类型 var orgtype = $scope.usertype == 9 ? 1 : 2;//1企业 2高校 var activityid = $stateParams.activityid; var count = 0; var getSignInfo = function () { $scope.showLoadingToast(); ActivityService.queryIfHasSignupInfo(activityid, orgtype).then(function (response) { //0:未填写报名信息 1: 已填写报名信息 2:已报名 $scope.ifhassignup = response.ifhassignup; $scope.weburl = response.weburl; count++; hideLoading(); }, function () { count++; hideLoading(); }); // 根据不同角色进行查询 if ($scope.usertype == 9) { // 获取企业报名信息 ActivityService.getCompanySignupInfo().then(function (response) { // console.log(response); if (angular.isDefined(response.company) && response.company.length > 0) { $scope.company = response.company[0]; } $scope.product = response.company_product_lk; $scope.techrequirement = response.company_techrequirement_lk; count++; hideLoading(); }, function () { count++; hideLoading(); }); } else { // 获取专家报名信息 ActivityService.getSignupInfo().then(function (response) { // console.log(response); if (angular.isDefined(response.signupdata) && response.signupdata.length > 0) { $scope.signinfo = response.signupdata[0]; } $scope.researchfinding = response.researchfinding; $scope.teammember = response.teammember; count++; hideLoading(); }, function () { count++; hideLoading(); }); } }; getSignInfo(); // 关闭加载动画 var hideLoading = function () { if (count == 2) { $scope.hideLoadingToast(); count = 0; } }; // 报名 $scope.goSignup = function () { $scope.showLoadingToast(); var signupid = $scope.usertype == 9 ? $scope.company.companyid : $scope.signinfo.signupid; ActivityService.signup(activityid, signupid, orgtype).then(function (response) { // console.log(response); UtilService.showMess("您已报名成功"); $scope.ifhassignup = 2; $scope.hideLoadingToast(); }, function () { $scope.hideLoadingToast(); }) }; });