Commit e208a022 by 施宇

111

parent df97bbc9
...@@ -263,16 +263,19 @@ ...@@ -263,16 +263,19 @@
}); });
$('.input_btn').click(function () { $('.input_btn').click(function () {
var key = $.trim($('.search-input').val()); var val = $.trim($('.search-input').val());
if (key.length < 3) { if(!val.length){
layer.msg('搜索内容太短') layer.msg('搜索内容不能为空')
}else
if (val.length < 3) {
layer.msg('请至少输入3个字符')
} else { } else {
var token = Util.getCookie('token') || ""; var token = Util.getCookie('token') || "";
if (token) { if (token) {
window.location.href = home_url + '/search?key=' + key + '&type=1&time=1'; window.location.href = home_url + '/search?key=' + val + '&type=1&time=1';
} else { } else {
window.location.href = search_url + '/indexsearch?key=' + key + '&type=1&time=1'; window.location.href = search_url + '/indexsearch?key=' + val + '&type=1&time=1';
} }
} }
......
...@@ -82,20 +82,23 @@ $(function () { ...@@ -82,20 +82,23 @@ $(function () {
}, },
addUser: function (obj, isDefault, isFirst) { addUser: function (obj, isDefault, isFirst) {
var id, name, img; var id, name, img,touserid;
if (isDefault) { if (isDefault) {
id = this.defaultName; id = this.defaultName;
name = this.defaultName; name = this.defaultName;
touserid = "";
img = dist + "/images/default.jpg"; img = dist + "/images/default.jpg";
} else { } else {
if (isFirst) { if (isFirst) {
console.log(this.templateObj)
id = this.templateObj.userId; id = this.templateObj.userId;
touserid = this.templateObj.touserid;
name = this.templateObj.userName; name = this.templateObj.userName;
img = this.templateObj.userImg || (dist + "/images/default.jpg") img = this.templateObj.userImg || (dist + "/images/default.jpg");
} else { } else {
id = obj.im_username; id = obj.im_username;
name = obj.company_name || '--'; name = obj.company_name || '--';
touserid = obj.user_id;
img = obj.avatar || (dist + "/images/default.jpg") img = obj.avatar || (dist + "/images/default.jpg")
} }
...@@ -104,7 +107,7 @@ $(function () { ...@@ -104,7 +107,7 @@ $(function () {
if (userLen) { //用户存在 if (userLen) { //用户存在
return; return;
} else { //用户不存在 } else { //用户不存在
var lefthtml = '<div class="notice_classify" userid="' + id + '" firstClick="true">' + this.userHtml(0, { var lefthtml = '<div class="notice_classify" userid="' + id + '" firstClick="true" touserid='+touserid+'>' + this.userHtml(0, {
name: name, name: name,
id: id, id: id,
img: img img: img
...@@ -359,7 +362,7 @@ $(function () { ...@@ -359,7 +362,7 @@ $(function () {
if (Util.getCookie('templateBoolean')) { if (Util.getCookie('templateBoolean')) {
Util.delCookie('templateBoolean', cookieHostname); Util.delCookie('templateBoolean', cookieHostname);
} }
var userStr = '<div class="notice_classify active" userid="' + message.from + '" firstClick="true" newMember="true">' + var userStr = '<div class="notice_classify active" userid="' + message.from + '" firstClick="true" newMember="true" touserid='+message.touserid+'>' +
self.userHtml(0, message, regContent) + '</div>'; self.userHtml(0, message, regContent) + '</div>';
var messageStr = '<div class="chat_item active" id="' + message.from + '">' + var messageStr = '<div class="chat_item active" id="' + message.from + '">' +
messageSigleStr + '</div>' messageSigleStr + '</div>'
...@@ -423,7 +426,7 @@ $(function () { ...@@ -423,7 +426,7 @@ $(function () {
Util.delCookie('templateBoolean', cookieHostname); Util.delCookie('templateBoolean', cookieHostname);
} }
var userStr = '<div class="notice_classify" userid="' + var userStr = '<div class="notice_classify" userid="' +
message.from + '" newMember="true">' + message.from + '" newMember="true" touserid='+ message.touserid+'>' +
self.userHtml(1, message, regContent) + '</div>'; self.userHtml(1, message, regContent) + '</div>';
var messageStr = '<div class="chat_item" id="' + var messageStr = '<div class="chat_item" id="' +
message.from + '">' + message.from + '">' +
...@@ -450,7 +453,8 @@ $(function () { ...@@ -450,7 +453,8 @@ $(function () {
id: message.ext.id, id: message.ext.id,
img: message.ext.img || (dist + "/images/default.jpg"), img: message.ext.img || (dist + "/images/default.jpg"),
message: message.data, message: message.data,
from: message.from from: message.from,
touserid:message.ext.touserid
}, false) }, false)
}, //收到文本消息; }, //收到文本消息;
onEmojiMessage: function (message) { onEmojiMessage: function (message) {
...@@ -460,6 +464,7 @@ $(function () { ...@@ -460,6 +464,7 @@ $(function () {
img: message.ext.img || (dist + "/images/default.jpg"), img: message.ext.img || (dist + "/images/default.jpg"),
message: message.data, message: message.data,
from: message.from, from: message.from,
touserid:message.ext.touserid
}, false) }, false)
}, //收到表情消息; }, //收到表情消息;
...@@ -477,7 +482,8 @@ $(function () { ...@@ -477,7 +482,8 @@ $(function () {
hq: message.ext.hq, hq: message.ext.hq,
num: message.ext.num, num: message.ext.num,
hq: message.ext.hq, hq: message.ext.hq,
time: message.ext.time time: message.ext.time,
touserid:message.ext.touserid
}, true); }, true);
self.addChatMember(message.ext.id) self.addChatMember(message.ext.id)
}, //收到命令消息; }, //收到命令消息;
...@@ -492,7 +498,8 @@ $(function () { ...@@ -492,7 +498,8 @@ $(function () {
id: message.ext.id, id: message.ext.id,
img: message.ext.img || (dist + "/images/default.jpg"), img: message.ext.img || (dist + "/images/default.jpg"),
from: message.from, from: message.from,
url: message.url url: message.url,
touserid:message.ext.touserid
}, false) }, false)
...@@ -541,6 +548,7 @@ $(function () { ...@@ -541,6 +548,7 @@ $(function () {
var self = this; var self = this;
// 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片; // 私聊发送文本消息,发送表情同发送文本消息,只是会在对方客户端将表情文本进行解析成图片;
var userId = $('.notice_left ').find('.active').attr('userid'); var userId = $('.notice_left ').find('.active').attr('userid');
var touserid = $('.notice_left ').find('.active').attr('touserid');
var id = this.conn.getUniqueId(); var id = this.conn.getUniqueId();
var msg = new WebIM.default.message('txt', id); var msg = new WebIM.default.message('txt', id);
var emojiMessage = WebIM.default.utils.parseEmoji(content); //表情解析工具 var emojiMessage = WebIM.default.utils.parseEmoji(content); //表情解析工具
...@@ -548,7 +556,8 @@ $(function () { ...@@ -548,7 +556,8 @@ $(function () {
timer: self.curentTime(), timer: self.curentTime(),
id: self.id, id: self.id,
name: self.name, name: self.name,
img: self.img img: self.img,
touserid:touserid
}; };
msg.set({ msg.set({
msg: content, // 消息内容; msg: content, // 消息内容;
...@@ -586,19 +595,22 @@ $(function () { ...@@ -586,19 +595,22 @@ $(function () {
layer.msg('消息发送失败'); layer.msg('消息发送失败');
} }
}); });
console.log(msg.body)
this.conn.send(msg.body); this.conn.send(msg.body);
}, },
sendCmd: function (templateObj) { sendCmd: function (templateObj) {
console.log('发送模板') console.log('发送模板')
var self = this; var self = this;
var userId = $('.notice_left ').find('.active').attr('userid'); var userId = $('.notice_left ').find('.active').attr('userid');
var touserid = $('.notice_left ').find('.active').attr('touserid');
var id = this.conn.getUniqueId(); var id = this.conn.getUniqueId();
var msg = new WebIM.default.message('cmd', id); var msg = new WebIM.default.message('cmd', id);
var params = $.extend({}, templateObj, { var params = $.extend({}, templateObj, {
timer: self.curentTime(), timer: self.curentTime(),
name: self.name, name: self.name,
id: self.id, id: self.id,
img: self.img img: self.img,
touserid:touserid
}); });
msg.set({ msg.set({
msg: 'template', msg: 'template',
...@@ -644,6 +656,8 @@ $(function () { ...@@ -644,6 +656,8 @@ $(function () {
var input = $('#img_upload')[0]; // 选择图片的input; var input = $('#img_upload')[0]; // 选择图片的input;
var file = WebIM.default.utils.getFileUrl(input); // 将图片转化为二进制文件; var file = WebIM.default.utils.getFileUrl(input); // 将图片转化为二进制文件;
var userId = $('.notice_left').find('.active').attr('userid'); var userId = $('.notice_left').find('.active').attr('userid');
var touserid = $('.notice_left ').find('.active').attr('touserid');
var option = { var option = {
apiUrl: WebIM.config.apiURL, apiUrl: WebIM.config.apiURL,
file: file, file: file,
...@@ -652,7 +666,8 @@ $(function () { ...@@ -652,7 +666,8 @@ $(function () {
timer: self.curentTime(), timer: self.curentTime(),
id: self.id, id: self.id,
name: self.name, name: self.name,
img: self.img img: self.img,
touserid:touserid
}, },
flashUpload: WebIM.flashUpload, flashUpload: WebIM.flashUpload,
onFileUploadError: function () { onFileUploadError: function () {
......
...@@ -89,7 +89,8 @@ $(function () { ...@@ -89,7 +89,8 @@ $(function () {
goodImage: img, goodImage: img,
userName: name, userName: name,
targetId: id, targetId: id,
userImg: userImg userImg: userImg,
touserid: Util.getCookie('user_id') || ""
}; };
Util.setCookie('templateBoolean', '1', 1, cookieHostname) Util.setCookie('templateBoolean', '1', 1, cookieHostname)
Util.setCookie('template', JSON.stringify(obj), 1, cookieHostname) Util.setCookie('template', JSON.stringify(obj), 1, cookieHostname)
......
...@@ -76,7 +76,7 @@ $(function () { ...@@ -76,7 +76,7 @@ $(function () {
if (!val.length) { if (!val.length) {
layer.msg('搜索内容不能为空') layer.msg('搜索内容不能为空')
} else if (val.length < 3) { } else if (val.length < 3) {
layer.msg('搜索内容太短') layer.msg('请至少输入3个字符')
} else { } else {
window.location.href = "/search?key=" + val+'&type=1&time=1'; window.location.href = "/search?key=" + val+'&type=1&time=1';
} }
......
...@@ -105,7 +105,8 @@ $(function () { ...@@ -105,7 +105,8 @@ $(function () {
goodImage: img, goodImage: img,
userName: name, userName: name,
targetId:id, targetId:id,
userImg:userImg userImg:userImg,
touserid: Util.getCookie('user_id') || ""
}; };
Util.setCookie('templateBoolean', '1', 1, cookieHostname) Util.setCookie('templateBoolean', '1', 1, cookieHostname)
Util.setCookie('template', JSON.stringify(obj), 1, cookieHostname) Util.setCookie('template', JSON.stringify(obj), 1, cookieHostname)
......
...@@ -97,7 +97,7 @@ $(function () { ...@@ -97,7 +97,7 @@ $(function () {
if (!val.length) { if (!val.length) {
layer.msg('搜索内容不能为空') layer.msg('搜索内容不能为空')
} else if (val.length < 3) { } else if (val.length < 3) {
layer.msg('搜索内容太短'); layer.msg('请至少输入3个字符');
} else { } else {
window.location.replace("/search?key=" + val + '&type=' + self.type + '&time=' + self.time); window.location.replace("/search?key=" + val + '&type=' + self.type + '&time=' + self.time);
} }
......
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