123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503 |
- 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<tempArr.length;i++){
- // switch (Number(tempArr[i])){
- // case 5321:val.action0=true;val.actionNum++;break;
- // case 5322:val.action1=true;val.actionNum++;break;
- // // case 5323:val.action2=true;val.actionNum++;break;
- // case 5324:val.action3=true;val.actionNum++;break;
- // case 5325:val.action4=true;val.actionNum++;break;
- // }
- //
- // }
- // }
- // val.noSuthority=false;
- // if(val.otherObj.creator!=UserService.id&&val.otherObj.taskstatus==5300&&val.actionNum==0){
- // val.noSuthority=true;
- // }
- })
- });
- }
- $scope.getData();
- $scope.changeSelected = function (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;
- }
- }
- angular.forEach($scope.taskHollList, function (val) {
- val.selected = false;
- })
- $scope.taskHollList[index].selected = true;
- type = $scope.taskHollList[index].type;
- $scope.allData = [];
- $scope.getData();
- $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.refreshData = function () {
- $scope.pagenum = 1;
- $scope.showLoadMore = true;
- $scope.getData();
- $scope.$broadcast('scroll.refreshComplete');
- };
- $scope.showLoadMore = true;
- $scope.loadMore = function () {
- if ($scope.showLoadMore) {
- $scope.pagenum++;
- searchList().then(function (data) {
- $scope.allData = $scope.allData.concat(data);
- $scope.$broadcast(
- 'scroll.infiniteScrollComplete'
- );
- });
- }
- // if($scope.pagenum>=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: '<input type="password" ng-model="data.wifi">',
- title: '认证通过方可发布活动',
- // subTitle: '没有权限,请先认证',
- scope: $scope,
- buttons: [
- { text: '取消' },
- {
- text: '<b>去认证</b>',
- 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: '<b>确定</b>',
- 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();
- })
- }
- }
- }]);
|