angular.module('push') .controller('activitiesHollCtrl', ['$scope', 'activitiesModuleService', '$timeout', '$q', 'UserService', 'ConfigService', '$ionicScrollDelegate', 'CommonService', '$ionicPopup', 'UtilService', 'dataToolsService', '$stateParams', function ($scope, activitiesModuleService, $timeout, $q, UserService, ConfigService, $ionicScrollDelegate, CommonService, $ionicPopup, UtilService, dataToolsService, $stateParams) { //虚拟搜索框 $scope.isShowSearchButton = true; $scope.keyfilter = { key: '' } $scope.pagenum = 1; $scope.pagesize = 6; $scope.noData = false; $scope.activitiytype = 0; $scope.defaultLan = UserService.defaultLan; var type = 0; var totalpage = 0; $scope.allData = []; if ($scope.app) { if (device.platform != "Android") { $scope.isIos = true; } else { $scope.isIos = false; } } $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'); } }; // taskModuleService.getAllTaskLable(UserService.node).then(function(res){ // $scope.labelList=[{ // itemvalue:0, // itemkey:'全部', // isSelected:true // }]; // if(res.code==3350){ // angular.forEach(res.data,function(val){ // val.isSelected=false; // }) // $scope.labelList=$scope.labelList.concat(res.data); // } // }); // taskModuleService.getEnterpriseList().then(function(res){ // console.log(res); // }) if ($scope.defaultLan == 'Chinese') { $scope.taskHollList = [ { title: '活动列表', selected: true, type: 0 }, { title: '我发布的', selected: false, type: 1 }, { title: '我参与的', selected: false, type: 2 } ]; } else { $scope.taskHollList = [ { title: 'Activities List', selected: true, type: 0 }, { title: 'My Submission', selected: false, type: 1 }, { title: 'My Participation', selected: false, type: 2 } ]; } if ($stateParams.comfrom == 'tab.account') { $scope.taskHollList = [ { title: '活动列表', selected: false, type: 0 }, { title: '我发布的', selected: false, type: 1 }, { title: '我参与的', selected: true, type: 2 } ] } $scope.addrKey = ''; $scope.tasktype = 0; var searchList = function () { $scope.showLoadingToast(); var deferred = $q.defer(); //查询任务列表 // addr, type,status,keyword,pagenum,pagesize activitiesModuleService.getAllActivitiesList(type, $scope.addrKey, 0, $scope.tasktype, $scope.keyfilter.key, $scope.pagenum, $scope.pagesize).then(function (res) { console.log(res); $scope.hideLoadingToast(); totalpage = res.page.totalPage; if ($scope.pagenum >= totalpage) { // 如果没有数据了 用ng-if彻底结束 $scope.showLoadMore = false; } deferred.resolve(res.data); }) return deferred.promise; } // 获取活动类别 var activityType = []; dataToolsService.getTypeEntryListByTypeName('activity_type').then(function (res) { console.log(res); if (res.code == 3350) { activityType = res.data; } }); var editTime = function (time) { var a = time.split(':'); a.pop(); return a.join(':'); } $scope.getData = function () { searchList().then(function (data) { $scope.allData = data; // $scope.logo=JSON.parse(data.images).photoName; $scope.noData = $scope.allData.length == 0; angular.forEach($scope.allData, function (val) { // console.log(val); val.logo = val.images ? JSON.parse(val.images).originalName : ''; // console.log(JSON.parse(val.images)); // 处理时间 val.begintime = editTime(val.begintime); val.endtime = editTime(val.endtime); var bgTime = val.begintime.split(' '); var edTime = val.endtime.split(' '); val.organizeTime = ''; if (bgTime[0] === edTime[0]) { val.organizeTime = bgTime[0] + ' ' + bgTime[1] + ' ~ ' + edTime[1]; } else { val.organizeTime = val.begintime + ' ~ ' + val.endtime; } // 反查活动类型 for (var i = 0; i < activityType.length; i++) { if (val.type == activityType[i].itemvalue) { val.typename = activityType[i].itemkey; break; } } // if(val) // 事件按钮 // val.action0=false;//对接录入 5322 // val.action1=false;//对接录入 5322 // val.action2=false;//评价 5323 // val.action3=false;//申请奖励 5324 // val.action4=false;//任务完成 5325 // val.actionNum=0; // var tempArr=val.otherObj.actions?val.otherObj.actions.split(','):[]; // // console.log(tempArr); // if(tempArr.length>0){ // for(var i=0;i=totalpage){ // // 如果没有数据了 用ng-if彻底结束 // $scope.showLoadMore=false; // }else{ // searchList().then(function(data){ // $scope.allData=$scope.allData.concat(data); // $scope.$broadcast( // 'scroll.infiniteScrollComplete' // ); // }); // } } // $scope.$on('stateChangeSuccess', function() { // $scope.loadMore(); // }); $scope.releaseActivity = function () { // console.log(1); 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 { activitiesModuleService.hasReleaseAuthority().then(function (res) { console.log(res); if (res.data) { $scope.go('activityRelease'); } else { // if($scope.app){ // UtilService.showMess('没有权限,请先认证'); // }else{ // CommonService.showMessage('没有权限,请先认证',$scope); // } var myPopup = $ionicPopup.show({ // template: '', title: '认证通过方可发布活动', // subTitle: '没有权限,请先认证', scope: $scope, buttons: [ { text: '取消' }, { text: '去认证', type: 'button-positive', onTap: function (e) { $scope.go('identifySystem', { comfrom: 'activitiesHoll' }) } }, ] }); } }); } } $scope.goToTaskDetail = function (list) { 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 { $scope.go('activityDetail', { activityid: list.id, }); } } $scope.goToTaskAction = function (list, action, index) { console.log(list); 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; } } if (action == 5323) { $scope.go('taskEvaluate', { taskRes: JSON.stringify(list) }) } else if (action == 5322) { // 对接录入 $scope.go('dockingInput', { comfrom: 'dockingInput', taskTitle: list.title, taskid: list.otherObj.id, companyName: list.school, companyid: list.otherObj.companyid, }) } else if (action == 5324) { $scope.go('visitModularForm', { companyid: list.otherObj.companyid, pageTitle: '新建录入', pagecode: 1000027, pageid: 15, restype: 0, node: list.source, title: list.school, }) } else if (action == 5325) { var confirmPopup = $ionicPopup.confirm({ title: '提示信息', template: '是否确定结束任务?', buttons: [ { text: '取消' }, { text: '确定', type: 'button-positive', onTap: function () { return 'ok' } }, ] }); confirmPopup.then(function (res) { if (res == 'ok') { var senddata = { data: { resourceid: list.unique, action: 5325, creator: UserService.id }, node: UserService.node } $scope.showLoadingToast(); console.log(senddata); taskModuleService.saveOrupdatetaskAction(senddata).then(function (res) { console.log(res); $scope.getData(); // if(res.code==3350){ // // $scope.go('taskHoll'); // $scope.showDockingButton=true; // $scope.showApplyButton=false; // if($scope.app){ // UtilService.showMess("任务申请成功!"); // }else{ // CommonService.showMessage("任务申请成功!",$scope); // } // getTaskDetail(); // getAllParticipant(); // } $scope.hideLoadingToast(); }) } else { return; } }); } else if (action == 5321) { senddata = { data: { resourceid: list.unique, action: 5321, creator: UserService.id }, node: UserService.node } $scope.showLoadingToast(); console.log(senddata); taskModuleService.saveOrupdatetaskAction(senddata).then(function (res) { console.log(res); if (res.code == 3350) { // $scope.go('taskHoll'); // $scope.showDockingButton=true; // $scope.showApplyButton=false; if ($scope.app) { UtilService.showMess("任务申请成功!"); } else { CommonService.showMessage("任务申请成功!", $scope); } // getTaskDetail(); // getAllParticipant(); // getTaskDetail().then(function(data){ // getAllParticipant(); // }) $scope.allData[index].action1 = true; $scope.allData[index].action0 = false; $scope.allData[index].action3 = true; $scope.allData[index].otherObj.actions = '5322,5324'; // $scope.go('taskDetail',$stateParams,{reload:true}); } $scope.hideLoadingToast(); }) } } }]);