Commit 855e12e6 by 施宇

11111

parent f606157e
......@@ -86,7 +86,7 @@
<script src="__PUBLIC__/js/chat/swfupload.js"></script>
<script src="__PUBLIC__/js/chat/swfupload.cookie.js"></script>
<script src="__PUBLIC__/js/chat/uploadShim.js"></script>
<script src="__PUBLIC__/js/chat/index.js"></script>
<script src="__PUBLIC__/js/chat/index.js"></script>]
</body>
</html>
\ No newline at end of file
......@@ -7,50 +7,84 @@ $(function () {
this.ieFun()
this.connection();
this.connListen();
this.login();
this.bindFunction();
// var data = JSON.stringify({
// "grant_type": "client_credentials",
// "client_id": "YXA6UWJlUJGNEemA0XUSlr6mDA",
// "client_secret": "YXA6n8pckF065e7FPtukjJHAoa-4G74"
// }, )
// $.ajax({
// type: 'post',
// url: 'http://a1.easemob.com/1113190618181018/icsales/token',
// data: data,
// contentType: "application/json",
// success: function (data) {
// var token = data.access_token;
// $.ajax({
// type: 'get',
// url: 'http://a1.easemob.com/1113190618181018/icsales/chatmessages/2019062513',
// headers: {
// Authorization: 'Bearer ' + token
// },
// success: function (data) {
// },
// error: function () {
// layer.msg('网络出现问题,请重试!');
// }
// });
this.bindFunction();
this.getUserInfo();
},
getUserInfo: function () { //获取用户的基本信息
var self = this;
IcController.getData(apis.authme, 'POST', null, function (res) {
if (res.err_code == 0) {
self.testUser(res.data.mobile, res.data.im_password)
} else {
console.log('获取用户名失败')
}
},false,true)
},
registerUser:function(user,password){//给用户注册环信账号
var self = this;
var options = {
username: user,
password: password,
appKey: WebIM.config.appkey,
success: function () {
self.login(user,password)
},
error: function () {
console.log('注册失败')
},
apiUrl: WebIM.config.apiURL
};
conn.registerUser(options);
},
testUser: function (user, password) { //检测用户是否登入
var self = this;
var data = JSON.stringify({
"grant_type": "client_credentials",
"client_id": "YXA6UWJlUJGNEemA0XUSlr6mDA",
"client_secret": "YXA6n8pckF065e7FPtukjJHAoa-4G74"
}, )
$.ajax({
type: 'post',
url: 'http://a1.easemob.com/1113190618181018/icsales/token',
data: data,
contentType: "application/json",
success: function (data) {
var token = data.access_token;
$.ajax({
type: 'get',
url: 'http://a1.easemob.com/1113190618181018/icsales/users/' + user,
headers: {
Authorization: 'Bearer ' + token
},
success: function (data) {//用户已注册,主动帮用户登入
self.login(user,password)
},
error: function (err) {
if (err.status == '404') {//主动帮用户注册
self.registerUser(user,password)
} else {
layer.msg('网络出现问题,请重试!');
}
}
});
// },
// error: function () {
// layer.msg('网络出现问题,请重试!');
// }
// });
},
error: function () {
layer.msg('网络出现问题,请重试!');
}
});
},
defaultUser: function () {
//默认客服
this.addUser('18664936975',true)
this.addUser('18664936975', true)
},
singleChat: function () {
var templateObj = JSON.parse(Util.getCookie('template') || "{}")
if (JSON.stringify(templateObj) !== '{}') {
this.addUser(templateObj.userId,false)
this.addUser(templateObj.userId, false)
this.sendCmd(templateObj);
Util.delCookie('template');
......@@ -62,7 +96,7 @@ $(function () {
if (userLen) { //用户存在
$(".notice_classify[userid=" + id + "]").click();
} else { //用户不存在
var lefthtml = '<div class="notice_classify" userid="' + id + '">'+this.userHtml(0, id, '') + '</div>';;
var lefthtml = '<div class="notice_classify" userid="' + id + '">' + this.userHtml(0, id, '') + '</div>';;
var righthtml = '<div class="chat_item" id="' + id + '">' +
'<div class="title clr">' +
'<div class="fr btn btn_border">' +
......
......@@ -41,6 +41,10 @@
* 注册获取短信验证码接口
*/
getRegistCode: auth_url + '/v1/getRegistCode',
/***
* 获取用户基本信息
*/
authme:auth_url+'/auth/me',
/**
* 商品列表
*/
......
......@@ -3,7 +3,7 @@
init: function () {
this.mounted(this).handleBind(this);
},
getData: function (url, type, param, callback, isload) {
getData: function (url, type, param, callback,isload,isheader) {
//是否启动loadin效果
if(isload == undefined){
......@@ -12,8 +12,6 @@
shade: false
});
}
var platform = {
source: 2
};
......@@ -25,12 +23,19 @@
if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)) {
dataTypeXpx = "jsonp";
}
// if(isheader){
$.ajaxSetup({
headers:{
Authorization:'Bearer '+Util.getCookie('token')
},
});
// };
$.ajax({
type: type,
url: url,
data: params,
dataType: 'json',
xhrFields: {
withCredentials: true
},
......
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