Commit e75acfb6 by 施宇

111

parent 75425bcc
Showing with 39 additions and 8 deletions
...@@ -5,6 +5,7 @@ $(function () { ...@@ -5,6 +5,7 @@ $(function () {
appName: "icsales", appName: "icsales",
defaultName: "001", defaultName: "001",
customerNum: "", customerNum: "",
customerP: "",
templateObj: JSON.parse(Util.getCookie('template') || "{}"), templateObj: JSON.parse(Util.getCookie('template') || "{}"),
customerText: Util.getCookie('customer') || "", customerText: Util.getCookie('customer') || "",
isLoginSuccess: false, isLoginSuccess: false,
...@@ -12,6 +13,7 @@ $(function () { ...@@ -12,6 +13,7 @@ $(function () {
img: "", img: "",
name: "", name: "",
id: "", id: "",
isRelogin: true,
init: function () { init: function () {
if (this.ieFun()) { if (this.ieFun()) {
this.getUserInfo(); this.getUserInfo();
...@@ -32,6 +34,12 @@ $(function () { ...@@ -32,6 +34,12 @@ $(function () {
}, },
getUserInfo: function () { //获取用户的基本信息 getUserInfo: function () { //获取用户的基本信息
var self = this; var self = this;
var imN = self.customerNum;
var imP = self.customerP;
if (imN && imP) {
self.getHistoryUsers(imN, imP);
return;
}
IcController.getData(apis.authme, 'GET', { IcController.getData(apis.authme, 'GET', {
"token": Util.getCookie('token') || '', "token": Util.getCookie('token') || '',
}, function (res) { }, function (res) {
...@@ -40,6 +48,7 @@ $(function () { ...@@ -40,6 +48,7 @@ $(function () {
self.name = res.data.company_name || '--'; self.name = res.data.company_name || '--';
self.id = res.data.user_id + ''; self.id = res.data.user_id + '';
self.customerNum = res.data.im_username || ''; self.customerNum = res.data.im_username || '';
self.customerP = res.data.im_password || '';
self.getHistoryUsers(res.data.im_username, res.data.im_password); self.getHistoryUsers(res.data.im_username, res.data.im_password);
} else { } else {
...@@ -594,12 +603,17 @@ $(function () { ...@@ -594,12 +603,17 @@ $(function () {
title: '提示', title: '提示',
content: '您的聊天账号被迫下线!' content: '您的聊天账号被迫下线!'
}); });
} else { } else if (message.type == 1) {
if (self.isRelogin) {
// layer.open({ self.isRelogin = false;
// title: '提示', // self.registerIm();
// content: '聊天系统出现异常!' self.registerIm();
// }); } else {
layer.open({
title: '提示',
content: '聊天系统登录失败'
});
}
} }
// layer.msg('聊天系统出错'); // layer.msg('聊天系统出错');
}, //失败回调; }, //失败回调;
...@@ -631,11 +645,24 @@ $(function () { ...@@ -631,11 +645,24 @@ $(function () {
try { try {
this.conn.open(options); this.conn.open(options);
} catch (e) { } catch (e) {
console.log(e);
layer.msg('登入失败');
this.deleteCookie(); this.deleteCookie();
} }
}, },
registerIm: function () {
var me = this;
IcController.getData(apis.authregistim, 'post', {
"token": Util.getCookie('token') || ''
}, function (res) {
if (res.errcode == 0) {
me.getUserInfo();
} else {
layer.open({
title: '提示',
content: '聊天系统出现异常'
});
}
}, false)
},
scrollToTop: function (userId) { scrollToTop: function (userId) {
var imgLen = $('#' + userId).find('img').length; var imgLen = $('#' + userId).find('img').length;
if (!imgLen) { if (!imgLen) {
......
...@@ -166,6 +166,10 @@ ...@@ -166,6 +166,10 @@
* 环信通讯记录列表(最多显示30条最新的聊天记录) * 环信通讯记录列表(最多显示30条最新的聊天记录)
*/ */
listrecord: user_url + '/im/list/record', listrecord: user_url + '/im/list/record',
/***
* 手动注册im账号
*/
authregistim: auth_url + '/auth/registIMUser',
/** /**
* 批量上传商品列表 * 批量上传商品列表
*/ */
......
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