Commit f64b62bf by 施宇

111

parent 3122b539
......@@ -133,8 +133,17 @@
</div>
<include file="public/foot" />
<script>
$('.gt_div ').on('click', function () {
Util.setCookie('test', '1', 1)
$('.gt_div ').on('click', function () {
var obj = {
userId: '18271408717',
type: "STM32F103ZET6",
price: "67.9800",
brand: "Texas Instruments",
fz: "LQFP-144",
num: "100,000",
hq: "现货",
};
Util.setCookie('template', JSON.stringify(obj), 1)
window.location.href = '/chat'
})
</script>
......
......@@ -24,7 +24,7 @@
<span class="li_right icon iconfont">
</a>
<dl <if condition="(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail') || (ACTION_NAME eq 'quote') || (ACTION_NAME eq 'quotedetail')">style="display:block"</if>>
<dd <if condition="(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail')">class="active"</if>><a href="homeicsales/inquiry">我的询价</a></dd>
<dd <if condition="(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail')">class="active"</if>><a href="/inquiry">我的询价</a></dd>
<dd <if condition="(ACTION_NAME eq 'quote') || (ACTION_NAME eq 'quotedetail')">class="active"</if>><a href="homeicsales/quote">我的报价</a></dd>
</dl>
</li>
......
......@@ -822,4 +822,3 @@ body {
color: #ADB6BF;
cursor: pointer;
}
/*# sourceMappingURL=base.css.map */
\ No newline at end of file
......@@ -48,45 +48,26 @@ $(function () {
from: "18664936975",
data: ''
}
this.receiveData(1, message);
this.receiveData(1, message, false);
},
singleChat: function () {
var type = Util.getCookie('test');
if (type) {
var id = '18589050841';
var templateStr = Util.getCookie('template');
var templateObj = {};
if (templateStr) {
templateObj = JSON.parse(templateStr)
}
if (JSON.stringify(templateObj) !== '{}') {
var message = {
from: "18589050841",
from: templateObj.userId,
data: ''
};
var content = '<div class="template lineBlock boxsiz">' +
'<img src="http://resic.liexin.com/images/test.jpg" alt="">' +
'<div class="template_right">' +
'<div class="template_right_top clr">' +
'<h3 class="bold fl">STM32F103ZE</h3>' +
'<div class="price bold fr">¥67.9800</div>' +
'</div>' +
'<div class="template_right_bottom">' +
'<div class="desc1 clr">' +
'<div class="brand fl">品牌:<i>TexasInstruments</i></div>' +
'<div class="hq fl">货期:<i> 现货</i></div>' +
'</div>' +
'<div class="desc2 clr">' +
'<div class="num fl">数量:<i class="bold">100,000PCS</i></div>' +
'<div class="time fl">时间:<i>2019-05-23 15:57 </i></div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
this.receiveData(1, message);
$(".notice_classify[userid=" + id + "]").click();
this.sendPrivateText(content, {
test: 1
});
Util.delCookie('test');
this.receiveData(1, message, false);
$(".notice_classify[userid=" + templateObj.userId + "]").click();
this.sendCmd(templateObj);
Util.delCookie('template');
}
......@@ -185,22 +166,15 @@ $(function () {
clock += ss;
return (clock);
},
userHtml: function (num, user, message, isTest) {
userHtml: function (num, user, message) {
//左边用户的dom拼接
var messageContent = '';
if (isTest) {
messageContent = '100,000PCS ¥67.9800';
} else {
messageContent = message;
}
if (num == 0) {
return '<img src="' + dist + '/images/test.jpg" alt="" class="user_logo">' +
'<div class="user_right">' +
'<div class="clr">' +
'<h3 class="boxsiz ellipsis">' + user + '</h3>' +
'</div>' +
'<div class="message ellipsis">' + messageContent + '</div>' +
'<div class="message ellipsis">' + message + '</div>' +
'</div>'
} else {
return '<img src="' + dist + '/images/test.jpg" alt="" class="user_logo">' +
......@@ -209,26 +183,41 @@ $(function () {
'<span class="num fr">' + num + '</span>' +
'<h3 class="boxsiz ellipsis">' + user + '</h3>' +
'</div>' +
'<div class="message ellipsis">' + messageContent + '</div>' +
'<div class="message ellipsis">' + message + '</div>' +
'</div>'
}
},
messageHtml: function (leftOrRight, html, obj) {
//右边消息的dom拼接
var htmlp = ''
if (obj.test) {
htmlp = html;
} else {
htmlp = '<p>' + html + '</p>'
messageHtml: function (leftOrRight, html, isTemplate) {
//右边消息的dom拼接 isTemplate 是否是模板
var htmlp = '<p>' + html + '</p>';
if (isTemplate) {
var htmlp = '<div class="template lineBlock boxsiz">' +
'<img src="http://resic.liexin.com/images/test.jpg" alt="">' +
'<div class="template_right">' +
'<div class="template_right_top clr">' +
'<h3 class="bold fl">'+html.type+'</h3>' +
'<div class="price bold fr">'+html.price+'</div>' +
'</div>' +
'<div class="template_right_bottom">' +
'<div class="desc1 clr">' +
'<div class="brand fl">品牌:<i>'+html.brand+'</i></div>' +
'<div class="hq fl">货期:<i>'+html.hq+'</i></div>' +
'</div>' +
'<div class="desc2 clr">' +
'<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>' +
'</div>' +
'</div>' +
'</div>';
}
if (leftOrRight == 1) { //右边
if (html) {
return '<div class="notice_item right clr">' +
'<img src="' + dist + '/images/test.jpg" alt="" class="fr user_logo">' +
'<div class="notice_content">' +
// '<p>' +
htmlp +
// '</p>' +
'<div>' + this.curentTime() + '</div>' +
'</div>'
} else {
......@@ -240,9 +229,7 @@ $(function () {
return '<div class = "notice_item left clr" > ' +
'<img src="' + dist + '/images/test.jpg" alt="" class="fl user_logo">' +
'<div class="notice_content">' +
// '<p>' +
htmlp +
// '</p>' +
'<div>' + this.curentTime() + '</div>' +
'</div>'
} else {
......@@ -251,26 +238,19 @@ $(function () {
}
},
receiveData: function (type, message) {
//接收到消息后处理数据 1 文字 2 图片 3 表情
receiveData: function (type, message, isTemplate) {
//接收到消息后处理数据 1 文字 2 图片 3 表情 isTemplate 是否是模板
var regContent = "";
var htmlStr = "";
var self = this;
var isTest = '';
try {
isTest = message.ext.test
} catch (e) {
}
var obj = {};
if (isTest) {
obj = {
test: 1
}
}
if (type == 1) {
regContent = message.data;
htmlStr = message.data;
if (isTemplate) {
regContent = message.ext.type + ' ' + message.ext.price;
htmlStr = message.ext;
} else {
regContent = message.data;
htmlStr = message.data;
}
} else if (type == 2) {
regContent = '[图片]';
htmlStr = '<img src ="' + message.url + '" class="edit_img"/>';
......@@ -297,7 +277,7 @@ $(function () {
'</div>' +
'<div class="notice_list boxsiz">' +
'<div class="notice_item_content">' +
self.messageHtml(2, htmlStr, obj) +
self.messageHtml(2, htmlStr, isTemplate) +
'</div>' +
'</div>' +
'</div>';
......@@ -305,7 +285,7 @@ $(function () {
if (!len) {
//新用户
var userStr = '<div class="notice_classify active" userid="' + message.from + '">' +
self.userHtml(0, message.from, regContent, isTest) + '</div>';
self.userHtml(0, message.from, regContent) + '</div>';
var messageStr = '<div class="chat_item active" id="' + message.from + '">' +
messageSigleStr + '</div>'
$('.notice_left_content').append(userStr);
......@@ -318,9 +298,9 @@ $(function () {
//已有用户
if (isNowChat) {
//当前用户
$(this).html(self.userHtml(0, message.from, regContent, isTest));
$(this).html(self.userHtml(0, message.from, regContent));
$('#' + userId).find('.notice_item_content').append(self.messageHtml(2,
htmlStr, obj));
htmlStr, isTemplate));
var contentHeight = $('#' + userId).find('.notice_item_content')
.height();
$('#' + userId).find('.notice_list').scrollTop(contentHeight);
......@@ -328,9 +308,9 @@ $(function () {
} else {
//非当前用户
var num = Number($(this).find('.num').text());
$(this).html(self.userHtml(num + 1, message.from, regContent, isTest));
$(this).html(self.userHtml(num + 1, message.from, regContent));
$('#' + userId).find('.notice_item_content').append(self.messageHtml(2,
htmlStr, obj));
htmlStr, isTemplate));
}
return false;
......@@ -339,7 +319,7 @@ $(function () {
//新用户
var userStr = '<div class="notice_classify" userid="' +
message.from + '">' +
self.userHtml(1, message.from, regContent, isTest) + '</div>';
self.userHtml(1, message.from, regContent) + '</div>';
var messageStr = '<div class="chat_item" id="' +
message.from + '">' +
messageSigleStr + '</div>'
......@@ -359,19 +339,23 @@ $(function () {
self.singleChat();
},
onTextMessage: function (message) {
self.receiveData(1, message)
self.receiveData(1, message, false)
}, //收到文本消息;
onEmojiMessage: function (message) {
self.receiveData(3, message)
self.receiveData(3, message, false)
}, //收到表情消息;
onCmdMessage: function (message) {
// console.log('CMD');
self.receiveData(1, message, true)
}, //收到命令消息;
onPictureMessage: function (message) {
var options = {
url: message.url
};
options.onFileDownloadComplete = function () {
// 图片下载成功;
self.receiveData(2, message)
self.receiveData(2, message, false)
};
......@@ -397,43 +381,35 @@ $(function () {
},
login: function () {
// open,登录;
let self = this;
var options = {
apiUrl: WebIM.config.apiURL,
user: "18271408717",
user: "18589050841",
pwd: "123456",
appKey: WebIM.config.appkey
};
try {
this.conn.open(options);
} catch (e) {
console.log(WebIM.config.apiURL)
// alert('open fail' + e.message)
}
},
sendPrivateText: function (content, obj) {
sendPrivateText: function (content) {
var self = this;
// 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片;
var userId = $('.notice_left ').find('.active').attr('userid');
var id = this.conn.getUniqueId();
var msg = new WebIM.message('txt', id);
var emojiMessage = WebIM.utils.parseEmoji(content); //表情解析工具
var ext = {};
if (obj.test) {
ext = {
'test': '1'
}
};
console.log(ext)
msg.set({
msg: content, // 消息内容;
to: userId, // 接收消息对象;
roomType: false,
ext: ext, //用户自扩展的消息内容
success: function (id, serverMsgId) {
$('#' + userId).find('.notice_item_content').append(self.messageHtml(1,
emojiMessage, obj));
emojiMessage, false));
var contentHeight = $('#' + userId).find('.notice_item_content')
.height();
$('#' + userId).find('.notice_list').scrollTop(contentHeight);
......@@ -446,6 +422,31 @@ $(function () {
});
this.conn.send(msg.body);
},
sendCmd: function (templateObj) {
var self = this;
var userId = $('.notice_left ').find('.active').attr('userid');
var id = this.conn.getUniqueId();
var msg = new WebIM.message('cmd', id);
msg.set({
msg: 'template',
to: userId,
roomType: false,
action: "template",
ext: templateObj,
success: function (id, serverMsgId) {
$('#' + userId).find('.notice_item_content').append(self.messageHtml(1,
templateObj, true));
var contentHeight = $('#' + userId).find('.notice_item_content')
.height();
$('#' + userId).find('.notice_list').scrollTop(contentHeight);
},
fail: function () {
console.log("Send Cmd failed");
}
});
this.conn.send(msg.body);
},
sendPrivateImg: function () {
// 私聊发送图片消息;
var self = this;
......@@ -459,7 +460,7 @@ $(function () {
file: file,
to: '18664936975',
roomType: false,
chatType: 'singleChat',
// chatType: 'singleChat',
flashUpload: WebIM.flashUpload,
onFileUploadError: function () {
console.log(file);
......@@ -469,7 +470,7 @@ $(function () {
success: function () {
var htmlStr = '<img src ="' + file.url + '" class="edit_img"/>';
$('#' + userId).find('.notice_item_content').append(self.messageHtml(1,
htmlStr, {}));
htmlStr, false));
var contentHeight = $('#' + userId).find('.notice_item_content')
.height();
$('#' + userId).find('.notice_list').scrollTop(contentHeight);
......
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