123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- 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: '<p><ion-spinner icon="bubbles" class="spinner-calm"></ion-spinner><br><span style="color: #3B8BD0;font-size: 18px;font-weight: bold">努力加载中···</span></p>',
- 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: '请检查发送号码和发送内容'
- })
- }
- })
- }
- });
|