Commit b87d188e by qiaomu

two

parent 871d5ae2
Showing with 181 additions and 97 deletions
......@@ -289,34 +289,14 @@
<div class="charBoxS" id="charBoxS">
<p class="notice">您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="time">2017年1月28日 17:45</p>
<div class="userLine">
<p class="user">您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="clearfix"></p>
</div>
<div class="userLine">
<!-- <div class="userLine">
<p class="user">您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="clearfix"></p>
</div>
<div class="serverLine">
<p class="server">您好,蒲公英chrisline,请问有什么可以帮到您?您好,蒲公英chrisline,请问有什么可以帮到您?您好,蒲公英chrisline,请问有什么可以帮到您?您好,蒲公英chrisline,请问有什么可以帮到您?您好,蒲公英chrisline,请问有什么可以帮到您?您好,蒲公英chrisline,请问有什么可以帮到您?您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="clearfix"></p>
</div>
<div class="userLine">
<p class="user">您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="clearfix"></p>
</div>
<div class="userLine">
<p class="user">您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="clearfix"></p>
</div>
<div class="userLine">
<p class="user">您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="clearfix"></p>
</div>
<div class="userLine">
<p class="user">您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="clearfix"></p>
</div>
</div> -->
<div class="userLine" id="zmbottom" style="visibility: hidden;"> <!-- 占位 -->
<p class="user">您好,蒲公英chrisline,请问有什么可以帮到您?</p>
<p class="clearfix"></p>
......@@ -874,11 +854,11 @@
}
html += '<div class="avatar-box">';
html += '<img class="avatar" src="https://zhibocdn.ishuaji.cn/comm'+lickList[i].face+'?x-oss-process=image/resize,w_178" alt="">';
html += '<div class="online-num-box">';
html += '<img class="online-icon" src="../images/animate-img/online-icon1.png" alt="">';
html += '<span class="online-num">'+lickList[i].visit+'</span>';
html += '</div>';
if (lickList[i].haveMC == 1) {
html += '<div class="online-num-box">';
html += '<img class="online-icon" src="../images/animate-img/online-icon1.png" alt="">';
html += '<span class="online-num">'+lickList[i].visit+'</span>';
html += '</div>';
html += '</a>';
}
html += '</div>';
......@@ -916,40 +896,181 @@
}
});
}
var fristAskServer = true;
var isScoll = true;
var sellObj = {};
var contentObj={};
function get32(){
var chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var nums="";
for(var i=0;i<32;i++){
var id = parseInt(Math.random()*61);
nums+=chars[id];
}
return nums;
}
function askServer () {
var oMyBar1 = new MyScrollBar({ //聊天记录滚动条
selId: 'charBox123',
width: 5,
bgColor: '',
barColor: '#999',
enterColor: '#056FD8',
enterShow: false,
borderRadius: 10,
});
oMyBar1.jump({
id: 'zmbottom',
})
console.log(/\[开心\]/.test("[开心]"));
$(".sell").click(function () {
if ($("#editor").val() == '') {
alert("不能发送空消息!");
return;
if (fristAskServer) {
fristAskServer = false;
oMyBar1 = new MyScrollBar({ //聊天记录滚动条
selId: 'charBox123',
width: 5,
bgColor: '',
barColor: '#999',
enterColor: '#056FD8',
enterShow: false,
borderRadius: 10,
});
var ws;
function WebSocketTest(){
if ("WebSocket" in window){
// 打开一个 web socket
var url="ws://121.41.50.83:21901/ws?uid="+$.cookie("ukk")+"&token="+$.cookie("tbb")+"&type=0";
ws = new WebSocket(url);
ws.onopen = function(){
console.log("链接打开"+url);
};
ws.onmessage = function (evt) {
console.log("数据已接收...");
var received_msg = evt.data;
var obj=JSON.parse( received_msg );
if (obj.cid == 2500) {
var cont = JSON.parse(JSON.parse(obj.content).data).content;
var link = $('<div class="userLine"><p class="user">' + cont + '</p><p class="clearfix"></p></div>').appendTo($('#zmbottom'));
$(link).insertBefore($('#zmbottom'));
if (isScoll && $(".charBoxS").height() > 380) {
isScoll = false;
oMyBar1 = new MyScrollBar({ //聊天记录滚动条
selId: 'charBox123',
width: 5,
bgColor: '',
barColor: '#999',
enterColor: '#056FD8',
enterShow: false,
borderRadius: 10,
});
}
oMyBar1.setSize();
oMyBar1.jump({
id: 'zmbottom',
})
}
};
ws.onclose = function(){
// 关闭 websocket
console.log("连接已关闭...");
};
}else{
// 浏览器不支持 WebSocket
console.log("您的浏览器不支持 WebSocket!");
}
}
var info = $("#editor").val();
var faces = ["开心","大笑","调皮","呲牙","色","流口水","害羞","无聊","囧","抓狂","困","委屈","斜眼","惊讶","哭","吐","晕","鼓掌","流汗","愤怒","赞"];
// info = info + '<img src="../images/face-c/1.gif">';
for (var i = 0; i < faces.length; i++) {
var reg = new RegExp("\[开心\]","g");
info = info.replace(/\[开心\]/,'<img src="../images/face-c/'+(i+1)+'.gif">');
function send(message) {
if (!window.WebSocket) { return; }
if (ws.readyState == WebSocket.OPEN) {
ws.send(message);
} else {
alert("The socket is not open.");
}
}
var link = $('<div class="userLine"><p class="user">' + info + '</p><p class="clearfix"></p></div>').appendTo($('#zmbottom'));
$("#editor").html('');
$(link).insertBefore($('#zmbottom'));
oMyBar1.setSize();
oMyBar1.jump({
id: 'zmbottom',
})
});
WebSocketTest()
setInterval(function () {
sellObj.uid = $.cookie("ukk");
sellObj.touid = '1000';
sellObj.time = (new Date).getTime();
sellObj.cid = 1000;
sellObj.msgid = get32();
sellObj.version = 1;
sellObj.extend = '';
contentObj.msg = ' ';
sellObj.content = '';
console.log(JSON.stringify(sellObj));
send(JSON.stringify(sellObj));
},3000);
$(".sell").click(function () {
if (isScoll && $(".charBoxS").height() > 380) {
isScoll = false;
oMyBar1 = new MyScrollBar({ //聊天记录滚动条
selId: 'charBox123',
width: 5,
bgColor: '',
barColor: '#999',
enterColor: '#056FD8',
enterShow: false,
borderRadius: 10,
});
}
if ($("#editor").val() == '') {
alert("不能发送空消息!");
return;
}
var info = $("#editor").val();
sellObj.uid = $.cookie("ukk");
sellObj.touid = '1000';
sellObj.time = (new Date).getTime();
sellObj.cid = 2001;
sellObj.msgid = get32();
sellObj.version = 1;
sellObj.extend = '';
contentObj.msg=info;
sellObj.content = contentObj;
console.log(JSON.stringify(sellObj));
send(JSON.stringify(sellObj));
var faces = ["开心","大笑","调皮","呲牙","色","流口水","害羞","无聊","囧","抓狂","困","委屈","斜眼","惊讶","哭","吐","晕","鼓掌","流汗","愤怒","赞"];
// info = info + '<img src="../images/face-c/1.gif">';
for (var i = 0; i < faces.length; i++) {
var reg = new RegExp("\\["+faces[i]+"\\]","g");
info = info.replace(reg,'<img src="../images/face-c/'+(i+1)+'.gif">');
}
var link = $('<div class="serverLine"><p class="server">' + info + '</p><p class="clearfix"></p></div>').appendTo($('#zmbottom'));
$("#editor").val(' ');
$("#editor").focus();
$(link).insertBefore($('#zmbottom'));
oMyBar1.setSize();
oMyBar1.jump({
id: 'zmbottom',
})
});
$("#editor").emoji({
button: "#btn123",
showTab: false,
animation: 'slide',
position: 'topLeft',
icons: [{
name: "QQ表情",
path: "../images/face-c/",
maxNum: 21,
excludeNums: [],
file: ".gif",
alias: {
1: "开心",
2: "大笑",
3: "调皮",
4: "呲牙",
5: "色",
6: "流口水",
7: "害羞",
8: "无聊",
9: "囧",
10: "抓狂",
11: "困",
12: "委屈",
13: "斜眼",
14: "惊讶",
15: "哭",
16: "吐",
17: "晕",
18: "鼓掌",
19: "流汗",
20: "愤怒",
21: "赞",
},
placeholder: "[{alias}]"
}]
});
}
// var rangeIndex;
// $("#editor").click(function () {
// rangeIndex = window.getSelection().getRangeAt(0);//找到焦点位置
......@@ -964,43 +1085,6 @@
// $('.sell').click();
// }
// });
$("#editor").emoji({
button: "#btn123",
showTab: false,
animation: 'slide',
position: 'topLeft',
icons: [{
name: "QQ表情",
path: "../images/face-c/",
maxNum: 21,
excludeNums: [],
file: ".gif",
alias: {
1: "开心",
2: "大笑",
3: "调皮",
4: "呲牙",
5: "色",
6: "流口水",
7: "害羞",
8: "无聊",
9: "囧",
10: "抓狂",
11: "困",
12: "委屈",
13: "斜眼",
14: "惊讶",
15: "哭",
16: "吐",
17: "晕",
18: "鼓掌",
19: "流汗",
20: "愤怒",
21: "赞",
},
placeholder: "[{alias}]"
}]
});
}
$(function () {
meData();
......@@ -1009,9 +1093,6 @@
$(".main .meData-cont").show();
$(".side-nav-li").click(function () {
$(".main .content").hide();
$(".side-nav .side-nav-li").removeClass("active");
$(this).addClass("active");
if ($(this).index() == 0) {
meData();
}
......@@ -1030,6 +1111,9 @@
},300);
}
if ($(this).index() != 5) {
$(".main .content").hide();
$(".side-nav .side-nav-li").removeClass("active");
$(this).addClass("active");
$(".main .content").eq($(this).index()).show();
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment