ComplianceServer/oldcode/Core.Web/Views/WxMessage/Index.cshtml

509 lines
23 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Scripts/jquery.highlight.js"></script>
<style>
.noneColor {
color: #666 !important;
}
.noneColor :hover {
}
</style>
<form class="layui-form" action="">
<div class="layui-form-item">
<div class="layui-inline" style="width:98%">
<label class="layui-form-label">时间过滤:</label>
<div class="layui-input-inline" style="width:100px;vertical-align: middle;">
<input type="text" class="layui-input" id="stime" value="@Html.Raw(DateTime.Now.AddYears(-1).ToString("yyyy-MM"))" placeholder="yyyy-MM">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline" style="width:100px;vertical-align: middle;">
<input type="text" class="layui-input" id="etime" value="@Html.Raw(DateTime.Now.ToString("yyyy-MM"))" placeholder="yyyy-MM">
</div>
<div class="layui-input-inline">
<input type="button" class="layui-btn layui-btn-sm" lay-filter="demo2" id="dataGL" value="确定" />
</div>
<div class="layui-input-inline" style="width:200px;vertical-align: middle;float:right;text-align:right;top :10px;right:10px;">
消息数:<span id="msgcountspan">0</span>
<span id="qunfaspanmsg">群发数:<span id="qunfacountspan">0</span></span>
</div>
</div>
</div>
</form>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
<ul class="layui-tab-title">
<li class="layui-this">聊天记录</li>
<li>群发消息</li>
</ul>
<div class="layui-tab-content" style="height: 100px;">
<div class="layui-tab-item layui-show">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend id="msg_title">聊天记录:</legend>
</fieldset>
<ul class="layui-timeline" id="contentBody"></ul>
</div>
<div class="layui-tab-item">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend id="msg_title2">群发记录:</legend>
</fieldset>
<ul class="layui-timeline" id="qunfabody"></ul>
</div>
</div>
</div>
<script type="text/JavaScript" language="javascript">
var face = [{ name: "[微笑]", imgpath: "0.png" }, { name: "[撇嘴]", imgpath: "1.png" }, { name: "[色]", imgpath: "2.png" }, { name: "[发呆]", imgpath: "3.png" },
{ name: "[得意]", imgpath: "4.png" }, { name: "[流泪]", imgpath: "5.png" }, { name: "[害羞]", imgpath: "6.png" }, { name: "[闭嘴]", imgpath: "7.png" }, { name: "[睡]", imgpath: "8.png" },
{ name: "[大哭]", imgpath: "9.png" }, { name: "[尴尬]", imgpath: "10.png" }, { name: "[发怒]", imgpath: "11.png" }, { name: "[调皮]", imgpath: "12.png" },
{ name: "[呲牙]", imgpath: "13.png" }, { name: "[惊讶]", imgpath: "14.png" }, { name: "[难过]", imgpath: "15.png" }, { name: "[酷]", imgpath: "16.png" },
{ name: "[囧]", imgpath: "17.png" }, { name: "[抓狂]", imgpath: "18.png" }, { name: "[吐]", imgpath: "19.png" }, { name: "[偷笑]", imgpath: "20.png" },
{ name: "[愉快]", imgpath: "21.png" }, { name: "[白眼]", imgpath: "22.png" }, { name: "[傲慢]", imgpath: "23.png" },
{ name: "[饿]", imgpath: "24.png" }, { name: "[困]", imgpath: "25.png" }, { name: "[惊恐]", imgpath: "26.png" },
{ name: "[流汗]", imgpath: "27.png" }, { name: "[憨笑]", imgpath: "28.png" }, { name: "[悠闲]", imgpath: "29.png" }, { name: "[奋斗]", imgpath: "30.png" },
{ name: "[咒骂]", imgpath: "31.png" }, { name: "[疑问]", imgpath: "32.png" }, { name: "[嘘]", imgpath: "33.png" }, { name: "[晕]", imgpath: "34.png" },
{ name: "[疯]", imgpath: "35.png" }, { name: "[衰]", imgpath: "36.png" }, { name: "[骷髅]", imgpath: "37.png" },
{ name: "[敲打]", imgpath: "38.png" }, { name: "[再见]", imgpath: "39.png" }, { name: "[擦汗]", imgpath: "40.png" },
{ name: "[抠鼻]", imgpath: "41.png" }, { name: "[鼓掌]", imgpath: "42.png" }, { name: "[糟糕]", imgpath: "43.png" },
{ name: "[坏笑]", imgpath: "44.png" }, { name: "[左哼哼]", imgpath: "45.png" },
{ name: "[右哼哼]", imgpath: "46.png" }, { name: "[哈欠]", imgpath: "47.png" },
{ name: "[鄙视]", imgpath: "48.png" }, { name: "[委屈]", imgpath: "49.png" },
{ name: "[快哭了]", imgpath: "50.png" }, { name: "[阴险]", imgpath: "51.png" },
{ name: "[亲亲]", imgpath: "52.png" }, { name: "[吓]", imgpath: "53.png" },
{ name: "[可怜]", imgpath: "54.png" }, { name: "[菜刀]", imgpath: "55.png" },
{ name: "[西瓜]", imgpath: "56.png" }, { name: "[啤酒]", imgpath: "57.png" },
{ name: "[篮球]", imgpath: "58.png" }, { name: "[乒乓]", imgpath: "59.png" },
{ name: "[咖啡]", imgpath: "60.png" }, { name: "[美食]", imgpath: "61.png" },
{ name: "[猪头]", imgpath: "62.png" }, { name: "[玫瑰]", imgpath: "63.png" },
{ name: "[凋谢]", imgpath: "64.png" }, { name: "[嘴唇]", imgpath: "65.png" },
{ name: "[爱心]", imgpath: "66.png" }, { name: "[心碎]", imgpath: "67.png" },
{ name: "[蛋糕]", imgpath: "68.png" }, { name: "[电]", imgpath: "69.png" }, { name: "[炸弹]", imgpath: "70.gif" }, { name: "[便便]", imgpath: "71.gif" },
{ name: "[月亮]", imgpath: "72.gif" }, { name: "[太阳]", imgpath: "73.gif" }, { name: "[拥抱]", imgpath: "74.png" }, { name: "[强]", imgpath: "75.gif" }, { name: "[弱]", imgpath: "76.gif" },
{ name: "[握手]", imgpath: "77.gif" }, { name: "[胜利]", imgpath: "78.gif" }, { name: "[抱拳]", imgpath: "79.gif" }, { name: "[勾引]", imgpath: "80.gif" },
{ name: "[拳头]", imgpath: "81.gif" }, { name: "[OK]", imgpath: "82.gif" }, { name: "[跳跳]", imgpath: "83.gif" }, { name: "[发抖]", imgpath: "84.gif" },
{ name: "[怄火]", imgpath: "85.png" }, { name: "[转圈]", imgpath: "86.gif" }
];
</script>
<style>
.hgguanjianci {
background-color: #FF9800;
color: white;
}
.hgguanjianci_choose {
background-color: red;
color: white;
}
</style>
<script>
var sortBy = function (filed, rev, primer) {
rev = (rev) ? -1 : 1;
return function (a, b) {
a = a[filed];
b = b[filed];
if (typeof (primer) != 'undefined') {
a = primer(a);
b = primer(b);
}
if (a < b) { return rev * -1; }
if (a > b) { return rev * 1; }
return 1;
}
};
var msgcount = 0;
var qunfacount = 0;
//linux时间格式化
function getNowFormatDate(date) {
//var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
return currentdate;
}
//JavaScript代码区域
layui.use('element', function () {
var element = layui.element;
});
layui.use(['form', 'layedit', 'laydate'], function () {
var form = layui.form
, layer = layui.layer
, layedit = layui.layedit
, laydate = layui.laydate;
//日期
laydate.render({
elem: '#stime'
, type: 'month'
});
//日期
laydate.render({
elem: '#etime'
, type: 'month'
});
});
var jobusername = "@Html.Raw(Request.QueryString["jobusername"])";
var jobnickname = "@Html.Raw(Request.QueryString["nickname"])";
var host = "@Html.Raw(System.Configuration.ConfigurationManager.AppSettings["WxMessage_" + @Request.QueryString["companyCode"]])";
var NasHost = "@Html.Raw(System.Configuration.ConfigurationManager.AppSettings["NasFile_" + @Request.QueryString["companyCode"]])";
var companycode = "@Html.Raw(Request.QueryString["companycode"])";
$(function () {
$(".layui-nav-child a").click(function () {
var username = $(this).attr("nvalue");
$("#msg_title").html($(this).attr("title"));
$("#msg_title2").html($(this).attr("title"));
ShowMessage(username);
});
$("#btnSearch").click(function () {
$(".displayLi").each(function (i, n) {
$(this).removeClass("displayLi");
});
$(".redColor").each(function (i, n) {
$(this).after($(this).attr("ntitle"));
$(this).remove();
});
var txt = $("#findTxt").val();
if (txt == "")
return;
$("#allfriend dd").each(function () {
var html = $(this).children("a").html();
//console.log(html);
html = html.replace(txt, "<b ntitle=\"" + txt + "\" class=\"redColor\">" + txt + "</b>");
$(this).children("a").html(html);
if (html.indexOf("redColor") == -1) {
$(this).addClass("displayLi");
}
});
});
$("#dataGL").click(function () {
ShowMessage(jobnickname);
});
//$("#dataGL").click(function () {
// var choosedd = $("#allfriend .layui-this");
// if (choosedd.length==0) {
// layer.msg('请选择微信好友!');
// } else {
// var username = $(choosedd).children().attr("nvalue")
// ShowMessage(username);
// }
//});
ShowMessage(jobnickname);
var keywork = "承诺;保证;预期;收益;幅度;达到;超过;至少;最少;不低于;必然;涨停;私下;操盘;损失;赔偿;盈利;抱怨;投诉;退;推;荐;比例;收益率;准确率;加仓;减仓;解套";
var keyworkArr = keywork.split(";");
$(this.body).highlight(keyworkArr);
});
var dataMsgSvrIdKey = {};
function ShowMessage(username) {
msgcount = 0;
qunfacount = 0;
dataMsgSvrIdKey = {};
$("#contentBody").html("");
var nomessage = "<li class='layui-timeline-item' id='nomessage'>"+
"<i class='layui-icon layui-timeline-axis'></i >" +
"<div class='layui-timeline-content layui-text'>" +
"<h4 class='layui-timeline-title' style='color:red; '>温馨提示:</h4>" +
"<p>无聊天记录。(时间范围内无聊天记录)</p></div></li >";
var qunfanomessage = "<li class='layui-timeline-item' id='nomessage'>" +
"<i class='layui-icon layui-timeline-axis'></i >" +
"<div class='layui-timeline-content layui-text'>" +
"<h4 class='layui-timeline-title' style='color:red; '>温馨提示:</h4>" +
"<p>无群发记录。</p></div></li >";
$("#contentBody").html(nomessage);
$("#qunfabody").html(qunfanomessage);
var stime = $("#stime").val();
var etime = $("#etime").val();
var arrayObj = new Array(); //创建一个数组
var needrun = true;
var o = 0;
var stime_int = parseInt(stime.replace('-', ''));//起始时间转换成Int
var etime_int = parseInt(etime.replace('-', ''));//结束时间转换成Int
var rawtime_int = stime_int;//中间时间
if (stime_int > etime_int) {
return;
}
else if (stime_int == etime_int) {
arrayObj[0] = stime_int.toString();
} else {
arrayObj[o] = stime_int.toString();
while (needrun) {
o++;
var rawtime_str = rawtime_int.toString();
var year = rawtime_str.substring(0, 4);
var month = rawtime_str.substring(4, 6);
if (month == "12") {//如果是12月份
rawtime_int = parseInt("" + (parseInt(year) + 1) + "01");
} else {
rawtime_int++;
}
arrayObj[o] = rawtime_int.toString();
if (rawtime_int >= etime_int) {
needrun = false;
}
}
}
$(arrayObj).each(function (i, n) {
var yearmonth = n;
var i = n.substr(4, 1);
if (i == "0") {
yearmonth = n.substr(0, 4) + n.substr(5, 1);
}
//console.log(yearmonth)
var url = (NasHost == "" ? host : NasHost) + "/Message/" + jobusername + "/" + username + "_" + yearmonth + ".json?i=" + GetGuid();
GetMessageByUrl(url, "contentBody");
});
var nurl = (NasHost == "" ? host : NasHost) + "/Message/" + jobusername + "/" + username + "_qunfa.json?i=" + GetGuid();
GetMessageByUrl(nurl, "qunfabody");
$("#msgcountspan").html(msgcount);
$("#qunfacountspan").html(qunfacount);
}
var selftemplete ="<li class='layui-timeline-item' msgsvrid='[msgsvrid]'>"+
"<i class='layui-icon layui-timeline-axis'></i>"+
"<div class='layui-timeline-content layui-text'> "+
"<h4 class='layui-timeline-title' style='color:#42B475;'>[title]</h4> "+
"<p>[content]</div></li>";
var outtemplete = "<li class='layui-timeline-item' msgsvrid='[msgsvrid]'>" +
"<i class='layui-icon layui-timeline-axis'></i>" +
"<div class='layui-timeline-content layui-text'> " +
"<h4 class='layui-timeline-title' style='color:#006EFE;'>[title]</h4> " +
"<p>[content]</p></div></li>";
function GetMessageByUrl(url, tabName) {
$.ajax({
type: "GET",
url: url,
dataType: "text",
async: false,
success: function (data) {
var json = JSON.parse("[" + data + "]");
json.sort(sortBy('createTime', false, parseInt));
if (json.length > 0) {
$("#" + tabName).find("#nomessage").remove();
}
$(json).each(function (i, da) {
if (da.msgSvrId && !!dataMsgSvrIdKey[da.msgSvrId]) {
return true;
}
if (tabName == "contentBody")
msgcount++;
else
qunfacount++;
dataMsgSvrIdKey[da.msgSvrId] = 1;
var newDate = new Date();
newDate.setTime(da.createTime);
if (companycode == "SHZZ" && da.createTime < 1606665600000) {
return true;
}
var dataStr = getNowFormatDate(newDate);//聊天时间
var html = "";
if (da.isSend == 1) {
html = selftemplete.replace("[title]", jobnickname + " " + dataStr);
} else {
html = outtemplete.replace("[title]", da.nickname + " " + dataStr);
}
html = html.replace("[msgsvrid]", da.msgSvrId);
if (da.type == 3) {
html = html.replace("[content]", "[图片]<img onclick='javascript: window.open(this.src)' style='max-width:300px; cursor: Pointer;' id='file_" + da.msgSvrId + "' src=''>");
$("#" + tabName).append(html);
GetImage(da);
} else if (da.type == 47) {
if (da.url != "" && da.url != "null") {
html = html.replace("[content]", "<img style='max-width:100px' id='file_" + da.msgSvrId + "' class='noneColor' src='" + da.url + "'>");
$("#" + tabName).append(html);
} else {
html = html.replace("[content]", "<img style='max-width:100px' id='file_" + da.msgSvrId + "' class='noneColor' src=''>");
$("#" + tabName).append(html);
GetImage(da);
}
} else if (da.type == 34) {
html = html.replace("[content]", "<a id='file_" + da.msgSvrId + "' class='noneColor' >[语音]<a>");
$("#" + tabName).append(html);
GetImage(da);
} else if (da.type == 43) {
html = html.replace("[content]", "<a id='file_" + da.msgSvrId + "' class='noneColor'>[视频]<a>");
$("#" + tabName).append(html);
GetImage(da);
} else if (da.type == 49) {
html = html.replace("[content]", "<a id='file_" + da.msgSvrId + "' class='noneColor'>[文件]<a>");
$("#" + tabName).append(html);
GetImage(da);
}
else {//普通文本
html = html.replace("[content]", SetKeyWords(replaceFace(da.content)));
$("#" + tabName).append(html);
}
});
}
});
}
var keywords = "@Html.Raw(ViewBag.KeyWords)";
var HgWords = keywords.split(';');
var alnn = 0;
function SetKeyWords(content) {
$(HgWords).each(function (i, key) {
if (key) {
alnn++;
content = content.replace(key, "<span class='hgguanjianci' id='hgwords_" + alnn + "'>" + key + "</span>");
}
});
return content;
}
var arrHgKey = new Array(); //
var hgNowIndex = -1;
var topac = 0;
function GetAllHgGuanJianCi() {
//if (isShowHg != "1")
// return;
//arrHgKey = new Array(); //
//hgNowIndex - 1;
//topac = 0;
//$(".hgguanjianci").each(function (my, span) {
// arrHgKey[my] = $(span).attr("id");
//});
//console.log(arrHgKey);
//$("#hgallcount").html(arrHgKey.length);
}
function PrvHgWords() {
console.log(hgNowIndex);
if (hgNowIndex - 1 < 0) {
layer.open({
title: '提醒'
, content: '没有了哦!'
, icon: '5'
, time: '1000'
});
return;
}
console.log("上一个:");
hgNowIndex--;
$("#hgnowcount").html(hgNowIndex+1);
var kongjian = $("#" + arrHgKey[hgNowIndex]);
$(".hgguanjianci_choose").removeClass("hgguanjianci_choose");
$(kongjian).addClass("hgguanjianci_choose");
console.log(kongjian.offset());
console.log(kongjian.position());
topac = topac + (kongjian.offset().top + 30) - 200;
if (topac < 0)
topac = 0;
console.log("scrollTop:" + topac);
$("#" + contetndivname).animate({ scrollTop: topac }, 100)
}
function NextHgWords() {
if (arrHgKey.length < hgNowIndex + 2) {
layer.open({
title: '提醒'
, content: '没有了哦!'
, icon: '5'
, time: '1000'
});
return;
}
console.log("下一个:");
hgNowIndex++;
var kongjian = $("#" + arrHgKey[hgNowIndex]);
if (kongjian==null||kongjian.length==0)
return;
$("#hgnowcount").html(hgNowIndex + 1);
$(".hgguanjianci_choose").removeClass("hgguanjianci_choose");
$(kongjian).addClass("hgguanjianci_choose");
console.log(kongjian.offset());
console.log(kongjian.position());
topac += kongjian.offset().top - 180;
$("#" + contetndivname).animate({ scrollTop: topac }, 100)
}
function GetImage(da) {
$.ajax({
url: host + "/FilePath.svc/GetPath/" + da.msgSvrId + "?i=" + GetGuid(),
type: "GET",
dataType: "json",
loading: true,
success: function (data) {
if (data.retmsg != null) {
var index = data.retmsg.indexOf("_");
var msgsId = data.retmsg.substring(0, index);
var path = data.retmsg.substring(index + 1, data.retmsg.length);
path = path.replace(/^http:\/\/[^/]+/, (NasHost == "" ? host : NasHost))
if (da.type == 34) {
$("#file_" + msgsId).attr("href", "javascript:void(0);").attr("onclick", "PalyRecord('" + path + "');");
} else if (da.type == 43) {
$("#file_" + msgsId).attr("href", "javascript:void(0);").attr("onclick", "PalyVideo('" + path + "');");
} else {
$("#file_" + msgsId).attr("src", path);
$("#file_" + msgsId).attr("href", path);
$("#file_" + msgsId).attr("target", "_blank");
}
$("#file_" + msgsId).removeClass("noneColor");
}
}, error: function () {
}
});
}
//替换表情
function replaceFace(cotent) {
var txt = cotent;
$(face).each(function (i, n) {
while (txt.indexOf(n.name) > -1) {
txt = txt.replace(n.name, "<img src=\"/Face/" + n.imgpath + "\">");
}
});
return txt;
}
function findTxt() {
//var reg2 = new RegExp("\\" + escape(txt), "g");
}
function PalyRecord(url) {
$.get(host + "/WxMessageSvr.svc/WxAudio/Get?url=" + url, function (result) {
if (result.result) {
var data = result.retmsg;
if (data != '') {
layui.use('layer', function () {
var layer = layui.layer;
layer.open({
title: '播放语音',
type: 1,
content: '<video src=' + data + ' controls autoplay />',
area: ['300px', '200px']
});
});
}
else {
layer.alert("未能找到文件");
}
} else {
layer.alert("转换失败,请稍后重试!");
}
});
}
function PalyVideo(url) {
layer.open({
title: '播放视频',
type: 1,
content: '<video width="400" height="300" src=' + url + ' controls autoplay />',
resize: true,
maxmin: true,
area: ['410px', '350px']
});
}
</script>