'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination' ]); app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) { var self = this; var s4 = new SM4Util(); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-chineseName"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno"); self.get_type = sp.getUrlName("type"); self.userList = [] // 左侧人员列表 self.list = [] // 全部消息---已分成数组的数组 self.listAll = [] // 全部消息---已分成数组的数组 self.ItemList = [] // 右侧消息---提取数组的数组对应内容 self.onlineList = [] // 在线名单 self.onlineAll = [] // 名单接口所有人 self.isOnlineList = [] // 两个表单中没有重合的人员名单 self.selectTxt = null // 当前选择人 self.contact = null // 当前选择人 --- 右上边文字 self.messageText = '' // 发送的内容 self.noRead = 0 // 未读消息数量 var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } } self.type = self.get_type != "" ? self.get_type : "2"; self.noDataTip = 1;//没有数据时赋变量为0,先默认为1 self.pageno = 1; self.total_count = 0; self.itemsPerPage = 10; self.pageOptions = [10, 20, 30, 40]; // 获取人员 self.getUser = function () { self.onlineList = [] var data = { userid:self.userId } $http.post(apiurljs.login + "g2work/user/queryUserOnline", data, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; self.onlineAll = res.data for(var i = 0; i < res.data.length;i++) { if(res.data[i].LOGINSTATE === '1'){ self.onlineList.push(res.data[i]) } } // console.log('online', self.onlineList) }) } self.isOnline = function(arr) { // console.log('isOnline', arr) if(Array.isArray(arr)){ var names1 = arr.map(item => item.SENDER); var names2 = self.onlineList.map(item => item.USHOWNAME); var commonNames = names1.filter(name => names2.includes(name)); // console.log('panduan:', names1, names2, names1.filter(name => names2.includes(name))) return commonNames.length > 0 ? true : false; } } /*self.onLineList = function (arr) { console.log('arr', arr) const names1 = arr.map(item => item.SENDER); const names2 = self.onlineAll.map(item => item.USHOWNAME); // const commonNames = names1.filter(name => names2.includes(name)); // console.log('panduan:', names1, names2, names1.filter(name => names2.includes(name))) if(!names1.filter(name => names2.includes(name))) { self.isOnlineList.push(names2) } // return commonNames.length > 0 ? true : false; }*/ self.getData = function (type) { // console.log('sp.savemenufile(id, title, src);', JSON.parse(localStorage.getItem('GlWorkPlatform-openfileArray'))) self.list = [] self.selectTxt = null // 右侧 未读 var data = { userid: self.userId, msgkind: "全部", mark: self.type == 1 ? "全部" : "未读" } $http.post(apiurljs.login + "g2work/routeinfo/queryDataMessage", data, postCfg) .success(function (obj) { self.onlineAll = [] self.onlineList = [] var data1 = { userid:self.userId } $http.post(apiurljs.login + "g2work/user/queryUserOnline", data1, postCfg) .success(function (obj1) { //var res1 = strToJson(s4.decryptData_CBC(obj1.data)); var res1 = obj1; self.onlineAll = res1.data for(var i = 0; i < res1.data.length;i++) { if(res1.data[i].LOGINSTATE === '1'){ self.onlineList.push(res1.data[i]) } } // var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj.data; var groupedData = res.data.reverse().reduce((acc, obj) => { var key = obj.SENDER; if (!acc[key]) { acc[key] = []; } acc[key].push(obj); return acc; }, {}); var result = Object.values(groupedData); self.ItemList = res.data.reverse() var array = [] for(var i=0; i { acc[obj.USHOWNAME] = (acc[obj.USHOWNAME] || 0) + 1; return acc; }, {}); var duplicates = array.filter(obj => counts[obj.USHOWNAME] === 1); var tmpArray = [] for(var i=0; i' + '
' + self.convertTimestamp(new Date().getTime()) + '
' + '
' // + '消息:' + txt + '
' // + '回复内容:' + messageText + '
' + '' + '' + ''; chatSection.innerHTML += newMessage; messageInput.value = ""; chatSection.scrollTop = chatSection.scrollHeight; setTimeout(function (){ $("#chatContent").animate({ scrollTop: "10000px" }, 0); },100) } } self.creatRoom=function(){ var data = { cman: self.userId, cname: self.userName + "和" + self.ItemList.SENDER + "—共享沟通", userids: self.ItemList.SENDERID } $http.post(apiurljs.login + "g2work/meetcoop/createMeetcoop", data, postCfg) .success(function (res) { sp.layerhide() if (res.success == true) { } else { sp.dialog(res.message) } }) } // 时间戳转换 self.convertTimestamp = function (timeStamp) { var year = new Date(timeStamp).getFullYear(); var month =new Date(timeStamp).getMonth() + 1 < 10? "0" + (new Date(timeStamp).getMonth() + 1): new Date(timeStamp).getMonth() + 1; var date =new Date(timeStamp).getDate() < 10? "0" + new Date(timeStamp).getDate(): new Date(timeStamp).getDate(); var hh =new Date(timeStamp).getHours() < 10? "0" + new Date(timeStamp).getHours(): new Date(timeStamp).getHours(); var mm =new Date(timeStamp).getMinutes() < 10? "0" + new Date(timeStamp).getMinutes(): new Date(timeStamp).getMinutes(); var ss =new Date(timeStamp).getSeconds() < 10? "0" + new Date(timeStamp).getSeconds(): new Date(timeStamp).getSeconds(); var formattedDate = year + "-" + month + "-" + date + " " + hh + ":" + mm + ":" + ss; return formattedDate; } //头部下滚冻结 $(function () { //页面高度撑满 setTimeout(function () { if ($(".ibox-content").height() < $(window).height() - 31) { $(".ibox-content").css("height", $(window).height() - 31) } }, 1) }) }])