Commit e208a022 by 施宇

111

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