angular.module('push') .controller('sendMessageCtrl', function ($scope, $ionicPopup, ResourceLibraryService, $stateParams, CommentService, UtilService, $timeout, CommonService,$ionicHistory,UserService,$ionicLoading) { $scope.sixresourcelist = []; $scope.job = $stateParams.job; $scope.resrole = $stateParams.resrole; angular.forEach($scope.job.items, function (val) { if (val.selected) { $scope.rolename = val.name; } }) $scope.esIdList = []; angular.forEach($stateParams.resourcelist, function (val) { $scope.esIdList.push(val.unique); }) console.log($scope.esIdList, $scope.rolename) // ResourceLibraryService.getResourceListByESList($scope.esIdList, $scope.rolename).then(function (res) { ResourceLibraryService.getResourceListByESList($scope.esIdList, '全部').then(function (res) { if (res.code == 3350) { console.log(res) $scope.sendPeopleNum = 0; $scope.datalist = res.data; angular.forEach($scope.datalist, function(val1){ angular.forEach(val1.userInfoList, function(val2){ if(val2.tel){ $scope.sendPeopleNum ++; } }) }) angular.forEach($scope.datalist, function(val, index){ if(index < 6){ $scope.sixresourcelist.push(val); } }) if($scope.sendPeopleNum > 6){ $scope.showSixListFlag = true; $scope.showshouqiFlag = true; }else{ $scope.showSixListFlag = false; $scope.showshouqiFlag = false; } } $scope.hideLoadingToast(); }) $scope.showMorePeople = function(){ $scope.showSixListFlag = !$scope.showSixListFlag; } $scope.notice = {}; $scope.notice.templateid=1584977 $scope.showLoadingToast = function () { $ionicLoading.show({ template: '


努力加载中···

', content: '努力加载中', animation: 'fade-in', showBackdrop: true,//是否显示蒙层 maxWidth: 150, showDelay: 0 }); // $timeout(function () { // $ionicLoading.hide(); // }, 15000); }; $scope.send = function () { if(!$scope.notice.templateid){ $ionicPopup.alert({ title: '提示', template: "请输入模板id" }) return; } if(!$scope.notice.templatetext){ $ionicPopup.alert({ title: '提示', template: "请输入短信内容" }) return; } $scope.telList = []; var templateid = $scope.notice.templateid; angular.forEach($scope.datalist, function (data) { angular.forEach(data.userInfoList, function (user) { if (user.tel) { var userinfo = data.resid; userinfo += "," + user.job + "," + user.name + "," + user.tel; $scope.telList.push(userinfo); } }) }) if($scope.telList.length ==0){ $ionicPopup.alert({ title: '提示', template: '您所选择的企业没有收件人,请重新选择!' }) return; } if($scope.telList.length > 200){ $ionicPopup.alert({ title: '提示', template: '最多只能发送200个联系人!' }) return; } ResourceLibraryService.sendMessageToUsers($scope.telList, templateid, $scope.notice.templatetext, $scope.resrole,UserService.node,UserService.id).then(function (res) { $scope.hideLoadingToast(); if (res.code == 3350) { if (res.data == "全部发送成功") { $ionicPopup.alert({ title: '提示', template: '全部发送成功' }) $scope.showLoadingToast(); ResourceLibraryService.getSmsList().then(function (res) { if (res.code == 3350) { if (res.data.length > 0) { $scope.go("noticeHelper", {list: res.data}); } else { $scope.hideLoadingToast(); $scope.go("tab.account"); } } }) } if (res.data == "部分发送失败") { $ionicPopup.alert({ title: '提示', template: '部分发送失败,请检查发送号码' }) $scope.showLoadingToast(); ResourceLibraryService.getSmsList().then(function (res) { if (res.code == 3350) { if (res.data.length > 0) { $scope.go("noticeHelper", {list: res.data}); } else { $scope.hideLoadingToast(); $scope.go("tab.account"); } } }) } if (res.data == "全部发送失败") { $ionicPopup.alert({ title: '提示', template: '全部发送失败,请检查发送号码和发送内容' }) } } else { $ionicPopup.alert({ title: '提示', template: '请检查发送号码和发送内容' }) } }) } });