Commit ff02480c by 施宇

聊天系统修复及搜索导航条件去掉时间搜索

parent 1c04a4ed
...@@ -32,14 +32,14 @@ ...@@ -32,14 +32,14 @@
<li class="search_sp fl">商品</li> <li class="search_sp fl">商品</li>
<li class="search_xj fl">询价</li> <li class="search_xj fl">询价</li>
</ul> </ul>
<div class="zz condition_content"> <!-- <div class="zz condition_content">
<span class="bold">时间:</span> <span class="bold">时间:</span>
<div class="condition_right_content clr"> <div class="condition_right_content clr">
<div class="fl jt">今天 </div> <div class="fl jt">今天 </div>
<div class="fl st">三天之内</div> <div class="fl st">三天之内</div>
<div class="fl qt">七天之内</div> <div class="fl qt">七天之内</div>
</div> </div>
</div> </div> -->
<!-- <div class="fz condition_content "> <!-- <div class="fz condition_content ">
<span class="bold">封装:</span> <span class="bold">封装:</span>
<div class="condition_right_content clr"> <div class="condition_right_content clr">
......
...@@ -348,9 +348,9 @@ ...@@ -348,9 +348,9 @@
} else { } else {
var token = Util.getCookie('token') || ""; var token = Util.getCookie('token') || "";
if (token) { if (token) {
window.location.href = home_url + '/search?key=' + val + '&type=1&time=1'; window.location.href = home_url + '/search?key=' + val + '&type=1';
} else { } else {
window.location.href = search_url + '/' + decodeURIComponent(val) + '_1_1'; window.location.href = search_url + '/' + decodeURIComponent(val) + '_1';
} }
} }
......
<?php <?php
return array( return array(
'URL_ROUTE_RULES' => array(//动态路由 'URL_ROUTE_RULES' => array(//动态路由
'/^(\w+)_(\d+)_(\d+)$/' => 'Index/index?key=:1&type=:2&time=:3', '/^(\w+)_(\d+)$/' => 'Index/index?key=:1&type=:2',
) )
); );
...@@ -30,14 +30,14 @@ ...@@ -30,14 +30,14 @@
<li class="search_sp fl ">商品</li> <li class="search_sp fl ">商品</li>
<li class="search_xj fl">询价</li> <li class="search_xj fl">询价</li>
</ul> </ul>
<div class="zz condition_content"> <!-- <div class="zz condition_content">
<span class="bold">时间:</span> <span class="bold">时间:</span>
<div class="condition_right_content clr"> <div class="condition_right_content clr">
<div class="fl jt">今天</div> <div class="fl jt">今天</div>
<div class="fl st">三天之内</div> <div class="fl st">三天之内</div>
<div class="fl qt">七天之内</div> <div class="fl qt">七天之内</div>
</div> </div>
</div> </div> -->
<!-- <div class="fz condition_content "> <!-- <div class="fz condition_content ">
<span class="bold">封装:</span> <span class="bold">封装:</span>
<div class="condition_right_content clr"> <div class="condition_right_content clr">
......
...@@ -3,9 +3,11 @@ $(function () { ...@@ -3,9 +3,11 @@ $(function () {
conn: {}, conn: {},
orgName: "1113190618181018", orgName: "1113190618181018",
appName: "icsales", appName: "icsales",
defaultName: "001", defaultName: "001",//客服im账号
defaultUserId:"36",//客服ID
customerNum: "", customerNum: "",
customerP: "", customerP: "",
isAddCustomer:false,
templateObj: JSON.parse(Util.getCookie('template') || "{}"), templateObj: JSON.parse(Util.getCookie('template') || "{}"),
customerText: Util.getCookie('customer') || "", customerText: Util.getCookie('customer') || "",
isLoginSuccess: false, isLoginSuccess: false,
...@@ -76,24 +78,31 @@ $(function () { ...@@ -76,24 +78,31 @@ $(function () {
} }
}); });
}, },
addChatMember: function (id) { addChatMember: function (id,isCustomer) {
var self = this;
IcController.getData(apis.addrecord, 'GET', { IcController.getData(apis.addrecord, 'GET', {
"token": Util.getCookie('token') || '', "token": Util.getCookie('token') || '',
"user_id": id "user_id": id
}, function (res) { }, function (res) {
if (res.errcode === 0) { if (res.errcode === 0) {
if(isCustomer){
self.isAddCustomer = true
}
} else { } else {
// console.log('添加聊天成员失败') // console.log('添加聊天成员失败')
} }
}, false); }, false);
}, },
rendChatSection: function (data) { rendChatSection: function (data) {
if (this.customerNum !== this.defaultName) { if (this.customerNum !== this.defaultName) {//加客服
this.addUser({}, true); this.addUser({}, true);
} }
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
this.addUser(data[i]) if(data[i].im_username !== this.defaultName){
this.addUser(data[i])
}else{
this.isAddCustomer = true;
}
} }
}, },
singleChat: function () { singleChat: function () {
...@@ -130,7 +139,7 @@ $(function () { ...@@ -130,7 +139,7 @@ $(function () {
if (isDefault) { if (isDefault) {
id = this.defaultName; id = this.defaultName;
name = '芯掌柜客服'; name = '芯掌柜客服';
touserid = ""; touserid = this.defaultUserId;
img = dist + "/images/timg.jpg"; img = dist + "/images/timg.jpg";
img1 = dist + "/images/timg.jpg"; img1 = dist + "/images/timg.jpg";
} else { } else {
...@@ -526,10 +535,10 @@ $(function () { ...@@ -526,10 +535,10 @@ $(function () {
time: message.ext.time, time: message.ext.time,
touserid: message.ext.touserid touserid: message.ext.touserid
}, true); }, true);
var index = self.chatList.indexOf(message.from); // var index = self.chatList.indexOf(message.from);
if (index == -1) { // if (index == -1) {
self.addChatMember(message.ext.id) // self.addChatMember(message.ext.id)
} // }
} else { //普通消息 } else { //普通消息
self.receiveData(1, { self.receiveData(1, {
...@@ -540,12 +549,12 @@ $(function () { ...@@ -540,12 +549,12 @@ $(function () {
from: message.from, from: message.from,
touserid: message.ext.touserid touserid: message.ext.touserid
}, false); }, false);
if (self.customerNum == self.defaultName) { // if (self.customerNum == self.defaultName) {
var index = self.chatList.indexOf(message.from); // var index = self.chatList.indexOf(message.from);
if (index == -1) { // if (index == -1) {
self.addChatMember(message.ext.id) // self.addChatMember(message.ext.id)
} // }
} // }
} }
}, //收到文本消息; }, //收到文本消息;
...@@ -558,12 +567,12 @@ $(function () { ...@@ -558,12 +567,12 @@ $(function () {
from: message.from, from: message.from,
touserid: message.ext.touserid touserid: message.ext.touserid
}, false); }, false);
if (self.customerNum == self.defaultName) { // if (self.customerNum == self.defaultName) {
var index = self.chatList.indexOf(message.from); // var index = self.chatList.indexOf(message.from);
if (index == -1) { // if (index == -1) {
self.addChatMember(message.ext.id) // self.addChatMember(message.ext.id)
} // }
} // }
}, //收到表情消息; }, //收到表情消息;
// onCmdMessage: function (message) { // onCmdMessage: function (message) {
...@@ -598,12 +607,12 @@ $(function () { ...@@ -598,12 +607,12 @@ $(function () {
url: message.url, url: message.url,
touserid: message.ext.touserid touserid: message.ext.touserid
}, false); }, false);
if (self.customerNum == self.defaultName) { // if (self.customerNum == self.defaultName) {
var index = self.chatList.indexOf(message.from); // var index = self.chatList.indexOf(message.from);
if (index == -1) { // if (index == -1) {
self.addChatMember(message.ext.id) // self.addChatMember(message.ext.id)
} // }
} // }
}; };
options.onFileDownloadError = function () { options.onFileDownloadError = function () {
// 图片下载失败 // 图片下载失败
...@@ -748,6 +757,9 @@ $(function () { ...@@ -748,6 +757,9 @@ $(function () {
}, false)); }, false));
self.scrollToTop(userId) self.scrollToTop(userId)
$('#chat_textarea').val(''); $('#chat_textarea').val('');
if(userId == self.defaultName && !self.isAddCustomer){
self.addChatMember(touserid,true)
}
}, },
fail: function (e) { fail: function (e) {
......
...@@ -117,7 +117,8 @@ $(function () { ...@@ -117,7 +117,8 @@ $(function () {
} else if (val.length < 3) { } else if (val.length < 3) {
layer.msg('请至少输入3个字符') 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';
window.location.href = "/search?key=" + val + '&type=1';
} }
}); });
...@@ -139,7 +140,8 @@ $(function () { ...@@ -139,7 +140,8 @@ $(function () {
}); });
$('.search_command').on('click', '.hot_item', function () { $('.search_command').on('click', '.hot_item', function () {
var title = $(this).attr('title'); var title = $(this).attr('title');
window.location.href = "/search?key=" + title + '&type=1&time=1'; // window.location.href = "/search?key=" + title + '&type=1&time=1';
window.location.href = "/search?key=" + title + '&type=1';
}); });
......
...@@ -11,27 +11,29 @@ $(function () { ...@@ -11,27 +11,29 @@ $(function () {
}, },
renderPage: function () { renderPage: function () {
if (this.type == 2) { if (this.type == 2) {
$('.search_nav ').find('.search_xj').addClass('active').siblings().removeClass('active'); $('.search_nav').find('.search_xj').click()
// $('.search_nav ').find('.search_xj').addClass('active').siblings().removeClass('active');
} else { } else {
$('.search_nav ').find('.search_sp').addClass('active').siblings().removeClass('active'); $('.search_nav').find('.search_sp').click()
// $('.search_nav ').find('.search_sp').addClass('active').siblings().removeClass('active');
} }
if (this.time == 2) { // if (this.time == 2) {
$('.condition_right_content').find('.st').click() // $('.condition_right_content').find('.st').click()
} else if (this.time == 3) { // } else if (this.time == 3) {
$('.condition_right_content').find('.qt').click() // $('.condition_right_content').find('.qt').click()
} else { // } else {
$('.condition_right_content').find('.jt').click() // $('.condition_right_content').find('.jt').click()
}; // };
$('.input-search').val(this.key); $('.input-search').val(this.key);
}, },
getData: function (type, time) { getData: function (type) {
var self = this; var self = this;
var url = type == 1 ? apis.goodsSearch : apis.inquirySearch; var url = type == 1 ? apis.goodsSearch : apis.inquirySearch;
IcController.getData(url, 'GET', { IcController.getData(url, 'GET', {
"offset": 8, "offset": 8,
"p": 1, "p": 1,
"goods_name/like": self.key, "goods_name/like": self.key,
"start_time": time // "start_time": time
}, function (res) { }, function (res) {
var getTpl = ""; var getTpl = "";
if (type == 1) { if (type == 1) {
...@@ -74,7 +76,7 @@ $(function () { ...@@ -74,7 +76,7 @@ $(function () {
} else { } else {
self.type = 2 self.type = 2
} }
$('.jt').click(); self.getData(self.type)
}); });
$('.input_btn').on('click', function () { $('.input_btn').on('click', function () {
var val = $.trim($('.input-search').val()); var val = $.trim($('.input-search').val());
...@@ -84,7 +86,7 @@ $(function () { ...@@ -84,7 +86,7 @@ $(function () {
layer.msg('搜索内容太短') layer.msg('搜索内容太短')
} else { } else {
console.log(self.type, self.time) console.log(self.type, self.time)
window.location.replace("/" + decodeURIComponent(val) + '_' + self.type + '_' + self.time); window.location.replace("/" + decodeURIComponent(val) + '_' + self.type);
} }
}); });
$('.zz').on('click', '.fl', function () { $('.zz').on('click', '.fl', function () {
......
...@@ -9,28 +9,30 @@ $(function () { ...@@ -9,28 +9,30 @@ $(function () {
}, },
renderPage: function () { renderPage: function () {
if (this.type == 2) { if (this.type == 2) {
$('.search_nav ').find('.search_xj').addClass('active').siblings().removeClass('active'); // $('.search_nav ').find('.search_xj').addClass('active').siblings().removeClass('active');
$('.search_nav').find('.search_xj').click()
} else { } else {
$('.search_nav ').find('.search_sp').addClass('active').siblings().removeClass('active'); $('.search_nav').find('.search_sp').click()
// $('.search_nav ').find('.search_sp').addClass('active').siblings().removeClass('active');
} }
if (this.time == 2) { // if (this.time == 2) {
$('.condition_right_content').find('.st').click() // $('.condition_right_content').find('.st').click()
} else if (this.time == 3) { // } else if (this.time == 3) {
$('.condition_right_content').find('.qt').click() // $('.condition_right_content').find('.qt').click()
} else { // } else {
$('.condition_right_content').find('.jt').click() // $('.condition_right_content').find('.jt').click()
}; // };
$('.input-search').val(this.key); $('.input-search').val(this.key);
}, },
getData: function (type, p, time) { getData: function (type, p) {
var self = this; var self = this;
var url = type == 1 ? apis.goodsSearch : apis.inquirySearch; var url = type == 1 ? apis.goodsSearch : apis.inquirySearch;
IcController.getData(url, 'GET', { IcController.getData(url, 'GET', {
"offset": 10, "offset": 10,
"p": p, "p": p,
"goods_name/like": self.key, "goods_name/like": self.key,
"start_time": time, // "start_time": time,
"token": Util.getCookie('token') || "" "token": Util.getCookie('token') || ""
}, function (res) { }, function (res) {
var getTpl = ""; var getTpl = "";
...@@ -59,7 +61,8 @@ $(function () { ...@@ -59,7 +61,8 @@ $(function () {
jump: function (obj, first) { jump: function (obj, first) {
if (!first) { if (!first) {
//分页回调调用 //分页回调调用
self.getData(type, obj.curr, self.key, time) // self.getData(type, obj.curr, self.key, time)
self.getData(type, obj.curr)
} }
} }
}); });
...@@ -88,9 +91,9 @@ $(function () { ...@@ -88,9 +91,9 @@ $(function () {
if (index == 0) { if (index == 0) {
self.type = 1 self.type = 1
} else { } else {
self.type = 2 self.type = 2;
} }
$('.jt').click(); self.getData(self.type, 1)
}); });
$('.input_btn').on('click', function () { $('.input_btn').on('click', function () {
var val = $.trim($('.input-search').val()); var val = $.trim($('.input-search').val());
...@@ -99,7 +102,7 @@ $(function () { ...@@ -99,7 +102,7 @@ $(function () {
} else if (val.length < 3) { } else if (val.length < 3) {
layer.msg('请至少输入3个字符'); 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);
} }
}); });
$('.zz').on('click', '.fl', function () { $('.zz').on('click', '.fl', function () {
......
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