Commit 5db7d1a3 by 施宇

1111

parent ac5c7a50
......@@ -12,14 +12,14 @@ import {
App({
globalData: {
auth: wx.getStorageSync('auth'),
auth: wx.getStorageSync('auth'),//是否授权
token: wx.getStorageSync('access_token'),
isIPX: false, //是否为iphone X
customerNum: "001",//客服
customerName: "芯掌柜客服",//客服名称
isRelogin: true, //登入环信失败后是否重新登入,只允许重新登入一次
bus: bus,
imBoolean: false,
bus: bus,//页面之间的监听
imBoolean: false,//是否是被异地登入的状态
},
getImUser: chat.getImUser,
conn: chat.conn,
......@@ -45,7 +45,7 @@ App({
wx.setStorageSync("member", member)
},
onLaunch() {
wx.removeStorageSync('im');
// wx.removeStorageSync('im');
this.versionUpdate();
//验证是否授权
if (this.globalData.auth) {
......
const http = require('../../../utils/util.js');
const WebIM = require("../../../utils/WebIM")["default"];
import {
apis
} from '../../../utils/api.js';
......@@ -85,7 +86,7 @@ Page({
http.getData(apis.authLogout, 'POST', null, (res) => {
if (res.errcode === 0) {
WebIM.conn.close();
wx.removeStorageSync('access_token');
wx.removeStorageSync('user_id');
wx.removeStorageSync('company_name');
......@@ -93,6 +94,7 @@ Page({
wx.removeStorageSync('myUsername');
wx.removeStorageSync('myPassword');
wx.removeStorageSync('auth');
wx.removeStorageSync('is_ShowModal')
// wx.removeStorageSync('imNick');
wx.reLaunch({
url: '/pages/person/auth/index',
......
......@@ -24,7 +24,7 @@ Page({
isCustomer: true,
isShowTip: true,
count: 0,
sysObj: {}
sysObj: {},
},
/**
......@@ -156,6 +156,7 @@ Page({
onShow: function () {
let my = wx.getStorageSync("myUsername");
let token = wx.getStorageSync('access_token') || '';
let isShowModal = wx.getStorageSync('is_ShowModal')||''
this.getSys(token) //获取系统消息
if (getApp().globalData.customerNum != my) {
this.getCustom();
......@@ -171,7 +172,7 @@ Page({
arr: this.getChatList(),
userId: wx.getStorageSync('user_id'),
});
if (getApp().globalData.imBoolean) {
if (getApp().globalData.imBoolean && isShowModal) {
reloginIm()
}
......@@ -181,6 +182,8 @@ Page({
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
console.log(wx)
wx.removeStorageSync('is_ShowModal')
},
/**
......
// const auth_url = 'https://authapi.icsales.com';
// const so_url = 'https://soapi.icsales.com';
// const offer_url = "https://offerapi.icsales.com";
// const user_url = 'https://userapi.icsales.com';
// const goods_url = 'https://goodsapi.icsales.com';
// const home_url = 'https://home.icsales.com';
// const welfare_url = 'https://welfareapi.icsales.com'
const auth_url = 'http://authapi.icsales.cc';
const so_url = 'http://soapi.icsales.cc';
const offer_url = "http://offerapi.icsales.cc";
const user_url = 'http://userapi.icsales.cc';
const goods_url = 'http://goodsapi.icsales.cc';
const home_url = 'http://home.icsales.cc';
const welfare_url = 'http://welfareapi.icsales.cc';
const auth_url = 'https://authapi.icsales.com';
const so_url = 'https://soapi.icsales.com';
const offer_url = "https://offerapi.icsales.com";
const user_url = 'https://userapi.icsales.com';
const goods_url = 'https://goodsapi.icsales.com';
const home_url = 'https://home.icsales.com';
const welfare_url = 'https://welfareapi.icsales.com'
// const auth_url = 'http://authapi.icsales.cc';
// const so_url = 'http://soapi.icsales.cc';
// const offer_url = "http://offerapi.icsales.cc";
// const user_url = 'http://userapi.icsales.cc';
// const goods_url = 'http://goodsapi.icsales.cc';
// const home_url = 'http://home.icsales.cc';
// const welfare_url = 'http://welfareapi.icsales.cc';
const apis = {
......
......@@ -5,7 +5,7 @@ import {
import {
apis
} from '../utils/api.js';
const WebIM = require("./WebIM")["default"];
const WebIM = require("../utils/WebIM")["default"];
let msgStorage = require("../components/chat/msgstorage");
let msgType = require("../components/chat/msgtype");
let disp = require("./broadcast");
......@@ -38,7 +38,6 @@ const onMessageError = (err) => {
}
const getImUser = () => {
let token = wx.getStorageSync('access_token') || '';
let reg = /(\d{3})\d{4}(\d{4})/;
getData(apis.userInfo, 'get', {
"token": token,
}, function(res) {
......@@ -124,12 +123,12 @@ const webimListen = () => {
let im = getApp().globalData.imBoolean;
if (im) {
getApp().globalData.imBoolean = false;
wx.removeStorageSync('is_ShowModal')//由于小程序的show切后台时会执行,导致异地登入弹窗会重复弹起,所以设置一个缓存进行转换
wx.showToast({
title: "登录成功",
duration: 2000
});
}
// WebIM.conn.setPresence();
},
onReconnect() {
// wx.showToast({
......@@ -152,15 +151,6 @@ const webimListen = () => {
conn.closed = true;
WebIM.conn.close();
},
// onCmdMessage(message) {
// if (message) {
// if (onMessageError(message)) {
// addImUser(message)
// msgStorage.saveReceiveMsg(message, msgType.CMD);
// }
// calcUnReadSpot(message);
// }
// },
onTextMessage(message) {
if(isBlack(message.from)){
return;
......@@ -199,17 +189,15 @@ const webimListen = () => {
calcUnReadSpot(message);
}
},
onBlacklistUpdate: function(list) { //黑名单变动
// 查询黑名单,将好友拉黑,将好友从黑名单移除都会回调这个函数,list则是黑名单现有的所有好友信息
console.log(list);
},
// 各种异常
onError(error) {
console.log(error)
if (error.type == 8) { //异地登录
WebIM.conn.close();
let pages = getCurrentPages();
let curPage = pages[pages.length - 1];
getApp().globalData.imBoolean = true;
wx.setStorageSync('is_ShowModal',true)
if (curPage.route == "pages/detail/chat/index" || curPage.route == 'pages/tab/message/message') {
reloginIm()
}
......@@ -224,10 +212,10 @@ const webimListen = () => {
showCancel: false
})
}
} else {
} else{
wx.showModal({
title: '提示',
content: '聊天系统出现异常!',
content: '聊天系统异常,需要重新登入账号!',
showCancel: false
})
disp.fire("em.xmpp.error.sendMsgErr", error);
......
const WebIM = require("./WebIM")["default"];
//数据请求(get,post)
const getData = (url, type, param, callBack, loading, isheader, istoken) => {
......@@ -76,6 +77,8 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
wx.removeStorageSync('myUsername');
wx.removeStorageSync('myPassword');
wx.removeStorageSync('auth');
wx.removeStorageSync('is_ShowModal');
WebIM.conn.close();
// wx.removeStorageSync('imNick');
wx.reLaunch({
url: '/pages/person/auth/index',
......@@ -343,7 +346,7 @@ const matchReg = (str) => {
const reloginIm = () => {
wx.showModal({
title: '提示',
content: '您的聊天账号被迫下线!',
content: '您的聊天账号掉线啦!',
confirmText: "重新登录",
success: function(res) {
if (res.confirm) {
......
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