Commit 9db21323 by 施宇

3123123

parent 5ea1d4b7
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<div class="content_div"> <div class="content_div">
<div class="notice_left boxsiz"> <div class="notice_left boxsiz">
<div class="notice_left_content boxsiz"> <div class="notice_left_content boxsiz">
</div> </div>
</div> </div>
<div class="notice_right boxsiz"> <div class="notice_right boxsiz">
......
...@@ -9,69 +9,85 @@ $(function () { ...@@ -9,69 +9,85 @@ $(function () {
this.connListen(); this.connListen();
this.login(); this.login();
this.bindFunction(); this.bindFunction();
var data = JSON.stringify({ // var data = JSON.stringify({
"grant_type": "client_credentials", // "grant_type": "client_credentials",
"client_id": "YXA6UWJlUJGNEemA0XUSlr6mDA", // "client_id": "YXA6UWJlUJGNEemA0XUSlr6mDA",
"client_secret": "YXA6n8pckF065e7FPtukjJHAoa-4G74" // "client_secret": "YXA6n8pckF065e7FPtukjJHAoa-4G74"
}, ) // }, )
$.ajax({ // $.ajax({
type: 'post', // type: 'post',
url: 'http://a1.easemob.com/1113190618181018/icsales/token', // url: 'http://a1.easemob.com/1113190618181018/icsales/token',
data: data, // data: data,
contentType: "application/json", // contentType: "application/json",
success: function (data) { // success: function (data) {
var token = data.access_token; // var token = data.access_token;
$.ajax({ // $.ajax({
type: 'get', // type: 'get',
url: 'http://a1.easemob.com/1113190618181018/icsales/chatmessages/2019062513', // url: 'http://a1.easemob.com/1113190618181018/icsales/chatmessages/2019062513',
headers: { // headers: {
Authorization: 'Bearer ' + token // Authorization: 'Bearer ' + token
}, // },
success: function (data) { // success: function (data) {
}, // },
error: function () { // error: function () {
layer.msg('网络出现问题,请重试!'); // layer.msg('网络出现问题,请重试!');
} // }
}); // });
}, // },
error: function () { // error: function () {
layer.msg('网络出现问题,请重试!'); // layer.msg('网络出现问题,请重试!');
} // }
}); // });
}, },
defaultUser: function () { defaultUser: function () {
//默认客服 //默认客服
var message = { this.addUser('18664936975',true)
from: "18664936975",
data: ''
}
this.receiveData(1, message, false);
}, },
singleChat: function () { singleChat: function () {
var templateStr = Util.getCookie('template'); var templateObj = JSON.parse(Util.getCookie('template') || "{}")
var templateObj = {};
if (templateStr) {
templateObj = JSON.parse(templateStr)
}
if (JSON.stringify(templateObj) !== '{}') { if (JSON.stringify(templateObj) !== '{}') {
this.addUser(templateObj.userId,false)
var message = {
from: templateObj.userId,
data: ''
};
this.receiveData(1, message, false);
$(".notice_classify[userid=" + templateObj.userId + "]").click();
this.sendCmd(templateObj); this.sendCmd(templateObj);
Util.delCookie('template'); Util.delCookie('template');
} }
}, },
addUser: function (id, isCustom) {
var userLen = $('.chat_item_content').find('#' + id).length;
if (userLen) { //用户存在
$(".notice_classify[userid=" + id + "]").click();
} else { //用户不存在
var lefthtml = '<div class="notice_classify" userid="' + id + '">'+this.userHtml(0, id, '') + '</div>';;
var righthtml = '<div class="chat_item" id="' + id + '">' +
'<div class="title clr">' +
'<div class="fr btn btn_border">' +
'<span class="icon iconfont iconjuxing23"></span>' +
'<i>' + id + '</i>' +
'</div>' +
'<h3 class="bold boxsiz">' + id + '</h3>' +
'</div>' +
'<div class="notice_list boxsiz">' +
'<div class="notice_item_content">' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
if (isCustom) { //是客服
$('.notice_left_content').prepend(lefthtml);
$('.chat_item_content').prepend(righthtml)
} else { //不是客服
$('.notice_left_content').append(lefthtml);
$('.chat_item_content').append(righthtml)
}
$(".notice_classify[userid=" + id + "]").click();
}
},
connection: function () { connection: function () {
//建立聊天链接 //建立聊天链接
this.conn = new WebIM.connection({ this.conn = new WebIM.connection({
...@@ -195,17 +211,17 @@ $(function () { ...@@ -195,17 +211,17 @@ $(function () {
'<img src="http://resic.liexin.com/images/test.jpg" alt="">' + '<img src="http://resic.liexin.com/images/test.jpg" alt="">' +
'<div class="template_right">' + '<div class="template_right">' +
'<div class="template_right_top clr">' + '<div class="template_right_top clr">' +
'<h3 class="bold fl">'+html.type+'</h3>' + '<h3 class="bold fl">' + html.type + '</h3>' +
'<div class="price bold fr">'+html.price+'</div>' + '<div class="price bold fr">' + html.price + '</div>' +
'</div>' + '</div>' +
'<div class="template_right_bottom">' + '<div class="template_right_bottom">' +
'<div class="desc1 clr">' + '<div class="desc1 clr">' +
'<div class="brand fl">品牌:<i>'+html.brand+'</i></div>' + '<div class="brand fl">品牌:<i>' + html.brand + '</i></div>' +
'<div class="hq fl">货期:<i>'+html.hq+'</i></div>' + '<div class="hq fl">货期:<i>' + html.hq + '</i></div>' +
'</div>' + '</div>' +
'<div class="desc2 clr">' + '<div class="desc2 clr">' +
'<div class="num fl">数量:<i class="bold">'+html.num+'PCS</i></div>' + '<div class="num fl">数量:<i class="bold">' + html.num + 'PCS</i></div>' +
'<div class="time fl">时间:<i>2019-05-23 15:57 </i></div>' + '<div class="time fl">时间:<i>2019-05-23 15:57 </i></div>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
......
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