angular.module('push') .controller('rewardCtrl', ['$scope', 'activitiesModuleService', '$timeout', '$q', 'UserService', 'ConfigService', '$ionicScrollDelegate', 'CommonService', '$ionicPopup', 'UtilService', 'dataToolsService', '$stateParams', 'taskModuleService', 'ResourceLibraryService', 'AccountService', function ($scope, activitiesModuleService, $timeout, $q, UserService, ConfigService, $ionicScrollDelegate, CommonService, $ionicPopup, UtilService, dataToolsService, $stateParams, taskModuleService, ResourceLibraryService, AccountService) { //虚拟搜索框 $scope.isShowSearchButton = true; $scope.keyfilter = { key: '' } $scope.pagenum = 1; $scope.pagesize = 6; $scope.noData = false; $scope.activitiytype = 0; $scope.node = UserService.node; $scope.allData = []; $scope.index = 0; $scope.initData = []; $scope.userid = UserService.id; if ($scope.app) { if (device.platform != "Android") { $scope.isIos = true; } else { $scope.isIos = false; } } //获取全部兑现数据 var getPayCashList = function () { dataToolsService.getPayCashList().then(function (res) { console.log(res) if (res.code == 3350) { $scope.paycashlist = res.data; $scope.allData = $scope.paycashlist; } }) }; getPayCashList(); $scope.goBackWhere = function () { if ($stateParams.comfrom == 'homepageOfNode') { $scope.go('homepageOfNode'); } else if ($stateParams.comfrom == 'tab.account') { $scope.go('tab.account'); } else { $scope.go('tab.activityIndex'); } }; $scope.rewardHollList = [ {title: '奖补类别', selected: true, type: 0}, {title: '申报记录', selected: false, type: 1}, {title: '退回情况', selected: false, type: 2}, ] $scope.rewardHollLists = [ {title: '产学研合作补助', selected: true, type: 0}, {title: '研发后补助', selected: false, type: 1}, ] $scope.addrKey = ''; $scope.tasktype = 0; var policyRewardhistoryList = function (restType,demandType) { $scope.showLoadingToast(); if (UserService.id) { dataToolsService.policyRewardhistoryList(restType,demandType).then(function (res) { console.log(res); $scope.hideLoadingToast(); if (res.code == 3350) { $scope.initData = res.data; $scope.allData = $scope.paycashlist; } }); } } policyRewardhistoryList(2,1111); $scope.policySetting = function (list) { $scope.go("policySetting", {list: list}); } $scope.toDeclare = function (list) { /*$scope.go("toDeclare", {list:list});*/ if(!UserService.id || UserService.id == 0){ $scope.go('login'); return; } AccountService.getAuthorizationLetterList(UserService.id,UserService.node).then(function (res) { console.log(res) if (res.data.length == 0) { var confirmPopup = $ionicPopup.confirm({ title: '认证提醒', template: '请先认证企业身份再进行产学研合作补助申报!', cancelText: '取消', okText: '去认证', }); confirmPopup.then(function (res) { if (res) { $scope.go("identifyForm", {pageTitle: "企业认证", code: 4803, type: "", id: "", action: 'submit'}); } }) } else { $scope.go("toDeclare", {list: JSON.stringify(list)}); } }) } ResourceLibraryService.judgeManager(UserService.id, 10501).then(function (res) { $scope.hasAuth = res.data; }) $scope.changeSelecteds=function(index){ console.log(index); angular.forEach($scope.rewardHollLists, function (val) { val.selected = false; }) $scope.rewardHollLists[index].selected = true; if($scope.rewardHollList[2].selected == true){ if(index==0){ policyRewardhistoryList(2,-1); }else { policyRewardhistoryList(1611726857 ,-2); } }else { if(index==0){ policyRewardhistoryList(2,1111); }else { policyRewardhistoryList(1611726857 ,1111); } } } //进入详情 $scope.goSubsidyauditafteDetail = function (list) { console.log(list) if((list.demandstatus==-2||list.demandstatus==-1)&&$scope.rewardHollList[2].selected == true){ $scope.go("toDeclare", {list: JSON.stringify(list)}); }else { if(list.restype==2){ $scope.go("cooperateDetail", {list: list, id: list.technicalcontractid}); }else { $scope.go("SubsidyauditafteDetail", {list: list, id: list.researchCostId}); } } } $scope.changeSelected = function (index) { $scope.index = index; $scope.pagenum = 1; $scope.showLoadMore = true; if ((index == 1 || index == 2) && !ConfigService.islogin) { if (localStorage.wxFlag == "true") { if (localStorage.isUserFocusXW == 0) { var title = localStorage.appidStr; $ionicPopup.alert({ title: '提示', template: '请先关注微信公众号"' + title + '"!' }); return; } else { if (localStorage.isUserBindWx == 0) { var wxFlag = JSON.parse(localStorage.params); if (wxFlag.weChatModel) { $scope.go('bindPhone', { params: localStorage.params, comfrom: 'maincontroller', url: window.location.href.split('#/')[1] }); } else { $scope.go('login'); return; } } else { $scope.go('login'); return; } } } else { $scope.go('login'); return; } return; } angular.forEach($scope.rewardHollList, function (val) { val.selected = false; }) $scope.rewardHollList[index].selected = true; //待申请 if (index == 1) { $scope.allData = []; angular.forEach($scope.initData, function (value, index) { if (value.demandstatus == -4) { $scope.allData.push(value); } }) policyRewardhistoryList(2 ,1111); $scope.rewardHollLists[1].selected = false; $scope.rewardHollLists[0].selected = true; } //已申请 if (index == 2) { $scope.allData = []; angular.forEach($scope.initData, function (value, index) { if (value.demandstatus != -4) { $scope.allData.push(value); } }) policyRewardhistoryList(2 ,-2); $scope.rewardHollLists[1].selected = false; $scope.rewardHollLists[0].selected = true; } //全部兑现 if (index == 0) { $scope.allData = []; $scope.allData = $scope.paycashlist; } $ionicScrollDelegate.$getByHandle('privateContent').scrollTop(true); } $scope.showSearchButtonLeft = function () { // console.log('aaa'); $scope.isShowSearchButton = false; $timeout(function () { $(".showSearchInput").focus(); }, 300) }; $scope.clearSearch = function () { $scope.isShowSearchButton = true; $scope.keyfilter.key = ""; $scope.getData(); } $scope.rewardgoback = function(){ $scope.go('tab.activityIndex'); } $scope.goToReward = function (list) { if ($scope.index != 0) { if (!ConfigService.islogin) { if (localStorage.wxFlag == "true") { if (localStorage.isUserFocusXW == 0) { var title = localStorage.appidStr; $ionicPopup.alert({ title: '提示', template: '请先关注微信公众号"' + title + '"!' }); return; } else { if (localStorage.isUserBindWx == 0) { var wxFlag = JSON.parse(localStorage.params); if (wxFlag.weChatModel) { $scope.go('bindPhone', { params: localStorage.params, comfrom: 'maincontroller', url: window.location.href.split('#/')[1] }); } else { $scope.go('login'); return; } } else { $scope.go('login'); return; } } } else { $scope.go('login'); return; } } else { ResourceLibraryService.getResourceByID(list.resid).then(function (resvalue) { if (resvalue.code == 3350) { var resource = resvalue.data; if(!resource){ $scope.go('cooperateDetail', {list: list, id: list.id}); }else { taskModuleService.getUserPermissionCheck(resource.otherid, list.creator, UserService.id).then(function (res) { if (res.code == 3350) { $scope.isVisiableFlag = res.data; if (!$scope.isVisiableFlag) { AccountService.getUserCheckInfo(UserService.id).then(function (userres) { if (userres.code == 3350) { var user = userres.data; //技术经纪人正在审核中 if (user.authenstatus == 5101) { $ionicPopup.confirm({ title: '提示', template: '需先认证为技术经纪人,方可申请技术合作类奖励', okText: '去认证', cancelText: '取消' }).then(function (result) { if (result) { $scope.go('identifyStatus', { pageTitle: '技术经纪人', code: 4801, type: 5101, id: user.id, action: 'submit', comfrom: 'resubmit' }); } }) } else //技术经纪人认证失败或是退回 if (user.authenstatus == 5103 || user.authenstatus == 5104) { if (list.restype == 4801) { $ionicPopup.confirm({ title: '提示', template: '需先认证为技术经纪人,方可申请技术合作类奖励', okText: '去认证', cancelText: '取消' }).then(function (result) { if (result) { $scope.go('identifyStatus', { pageTitle: '技术经纪人', code: 4801, type: user.authenstatus, id: user.id, action: 'submit', comfrom: 'resubmit' }); } }) } if (list.restype == 1) { $ionicPopup.confirm({ title: '提示', template: '需先认证为技术经纪人,方可申请技术需求类奖励', okText: '去认证', cancelText: '取消' }).then(function (result) { if (result) { if ($scope.node == '330122000') { $scope.go('identifyFormForTongLu', { code: 4801, type: user.authenstatus, action: 'submit', id: user.id, comfrom: 'resubmit', pageTitle: '技术经纪人认证' }) } else { $scope.go('identifyForm', { code: 4801, type: user.authenstatus, action: 'submit', id: user.id, comfrom: 'resubmit', pageTitle: '技术经纪人认证' }) } } }) } } else { //没有进行过技术经纪人认证信息提交的 if (user == null || user.authenstatus == null) { if (list.restype == 4801) { $ionicPopup.confirm({ title: '提示', template: '需先认证为技术经纪人,方可申请技术合作类奖励', okText: '去认证', cancelText: '取消' }).then(function (result) { if (result) { if (UserService.node == '330122000') { $scope.go('identifyFormForTongLu', { pageTitle: '技术经纪人认证', type: 5100, code: 4801, action: 'submit' }); } else { $scope.go('identifyForm', { pageTitle: '技术经纪人认证', type: 5100, code: 4801, action: 'submit' }); } } }) } if (list.restype == 1) { $ionicPopup.confirm({ title: '提示', template: '需先认证为技术经纪人,方可申请技术需求类奖励', okText: '去认证', cancelText: '取消' }).then(function (result) { if (result) { if ($scope.node == "330122000") { $scope.go('identifyFormForTongLu', { pageTitle: '技术经纪人认证', type: 5100, code: 4801, action: 'submit' }); } else { $scope.go('identifyForm', { pageTitle: '技术经纪人认证', type: 5100, code: 4801, action: 'submit' }); } } }) } } else { if (list.restype == 4801) { $scope.go('technicalawardapplication', { pageTitle: "技术经纪人技术合作类奖励", code: 4801, type: 5100, action: 'submit', resid: list.resid, restype: list.restype, list: list }); } if (list.restype == 1) { $scope.go("demandRewardDetail", { resid: list.resid, comefrom: 'reward', list: list }); } } } } }) } else { if (list.restype == 4801) { $scope.go('technicalawardapplication', { pageTitle: "技术经纪人技术合作类奖励", code: 4801, type: 5100, action: 'submit', resid: list.resid, restype: list.restype, list: list }); } if (list.restype == 1) { $scope.go("demandRewardDetail", { resid: list.resid, comefrom: 'reward', list: list }); } } } }) } } }) } } } }]);