Compare commits

...

3 Commits

Author SHA1 Message Date
cansnow 941464c330 group mangage 2026-01-10 15:40:38 +08:00
cansnow 825ac3457d deletemsg 2026-01-09 20:22:25 +08:00
cansnow 7913a63a39 20 2026-01-09 09:15:59 +08:00
66 changed files with 1634 additions and 743 deletions
+522 -12
View File
@@ -1,5 +1,11 @@
<script> <script>
import IMSDK from "openim-uniapp-polyfill"; import {mapGetters,mapActions} from "vuex";
import IMSDK, {IMMethods,MessageType,SessionType,} from "openim-uniapp-polyfill";
import config from "@/common/config";
import {getDbDir,toastWithCallback} from "@/util/common.js";
import {getConversationContent,conversationSort,prepareConversationState} from "@/util/imCommon";
import {PageEvents,UpdateMessageTypes} from "@/constant";
import {checkUpgrade} from "@/api/login.js"
export default { export default {
onLaunch: function() { onLaunch: function() {
// #ifndef APP // #ifndef APP
@@ -8,18 +14,15 @@
); );
return ; return ;
// #endif // #endif
this.$store.dispatch("system/getConfig");
this.init(); this.init();
}, },
onShow: function() { onShow: function() {
var args= plus.runtime.arguments;
if(args){
// 处理args参数,如直达到某新页面等
console.log(args);
}
//console.log("App Show"); //console.log("App Show");
// #ifdef APP // #ifdef APP
IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), false); IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), false);
// #endif // #endif
this.handleArguments();
//console.log(this.$store.state.contact); //console.log(this.$store.state.contact);
}, },
onHide: function() { onHide: function() {
@@ -28,19 +31,526 @@
IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), true); IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), true);
// #endif // #endif
}, },
computed: {
...mapGetters([
"storeConversationList",
"storeCurrentConversation",
"storeCurrentUserID",
"storeSelfInfo",
"storeRecvFriendApplications",
"storeRecvGroupApplications",
"storeHistoryMessageList",
"storeIsSyncing",
"storeGroupList",
"config",
]),
},
methods: { methods: {
...mapActions("message", ["pushNewMessage", "updateOneMessage"]),
...mapActions("conversation", ["updateCurrentMemberInGroup"]),
...mapActions("circle", ["getFriendCircleInfo"]),
...mapActions("contact", [
"updateFriendInfo",
"pushNewFriend",
"updateBlackInfo",
"pushNewBlack",
"pushNewGroup",
"updateGroupInfo",
"pushNewRecvFriendApplition",
"updateRecvFriendApplition",
"pushNewSentFriendApplition",
"updateSentFriendApplition",
"pushNewRecvGroupApplition",
"updateRecvGroupApplition",
"pushNewSentGroupApplition",
"updateSentGroupApplition",
]),
init(){ init(){
this.$store.dispatch("system/getConfig");
const IMToken = uni.getStorageSync("IMToken"); const IMToken = uni.getStorageSync("IMToken");
const IMUserID = uni.getStorageSync("IMUserID")+''; const IMUserID = uni.getStorageSync("IMUserID")+'';
if (IMToken && IMUserID) { if (IMToken && IMUserID) {
uni.navigateTo({ // #ifdef APP
url: "/pages/index/launch" this.tryLogin();
}); // #endif
}else{ }else{
uni.navigateTo({ plus.navigator.closeSplashscreen();
url: "/pages/common/login/index" uni.$u.route("/pages/common/login/index");
}
},
setGlobalIMlistener() {
//console.log("setGlobalIMlistener");
// init
const kickHander = (message) => {
toastWithCallback(message, () => {
uni.removeStorage({
key: "IMToken",
}); });
uni.removeStorage({
key: "BusinessToken",
});
uni.$u.route("/pages/common/login/index");
});
};
//由于 APP 管理员强制用户下线,或由于登录策略导致用户被踢下线
IMSDK.subscribe(IMSDK.IMEvents.OnKickedOffline, (data) => {
kickHander("您的账号在其他设备登录,请重新登陆!");
});
//token无效回调。
IMSDK.subscribe(IMSDK.IMEvents.OnUserTokenExpired, (data) => {
kickHander("您的登录已过期,请重新登陆!");
});
IMSDK.subscribe(IMSDK.IMEvents.OnUserTokenInvalid, (data) => {
kickHander("您的登录已无效,请重新登陆!");
});
// sync
//向服务器同步会话开始时的回调。
const syncStartHandler = ({data}) => {
this.$store.commit("user/SET_IS_SYNCING", true);
this.$store.commit("user/SET_REINSTALL", data);
};
//同步中
const syncProgressHandler = ({data}) => {
this.$store.commit("user/SET_PROGRESS", data);
};
//向服务器同步会话成功时的回调。
const syncFinishHandler = () => {
uni.hideLoading();
this.$store.dispatch("conversation/getConversationList");
this.$store.dispatch("contact/getFriendList");
this.$store.dispatch("contact/getGrouplist");
this.$store.dispatch("conversation/getUnReadCount");
this.$store.commit("user/SET_IS_SYNCING", false);
};
//向服务器同步会话失败时的回调。
const syncFailedHandler = () => {
uni.hideLoading();
uni.$u.toast("同步消息失败");
this.$store.dispatch("conversation/getConversationList");
this.$store.dispatch("conversation/getUnReadCount");
this.$store.commit("user/SET_IS_SYNCING", false);
};
//向服务器同步会话开始时的回调。
IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerStart, syncStartHandler);
//向服务器同步会话成功时的回调。
IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerFinish, syncFinishHandler);
//向服务器同步会话失败时的回调。
IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerFailed, syncFailedHandler);
//同步中
IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerProgress, syncProgressHandler);
// 当前登录用户个人信息改变时会收到此回调。
IMSDK.subscribe(IMSDK.IMEvents.OnSelfInfoUpdated, ({data}) => {
this.$store.commit("user/SET_SELF_INFO", {
...this.storeSelfInfo,
...data,
});
});
// message
//接收到新消息时会收到此回调,回调中只会携带一条消息。
//设置了批量消息监听setBatchMsgListener时,此回调不会触发。
//IMSDK.subscribe(IMSDK.IMEvents.OnRecvNewMessage, ({data}) =>{});
IMSDK.subscribe(IMSDK.IMEvents.OnRecvNewMessages, ({data}) => {
if (this.storeIsSyncing) {
return;
}
data.forEach(this.handleNewMessage);
});
//好友个人信息(包括备注)改变时会收到此回调。
IMSDK.subscribe(IMSDK.IMEvents.OnFriendInfoChanged,({data}) => {
console.log('friendInfoChangeHandler',data);
uni.$emit(IMSDK.IMEvents.OnFriendInfoChanged, {data});
this.updateFriendInfo({friendInfo: data,});
});
//两个用户成功建立好友关系后双方都会收到该回调。
IMSDK.subscribe(IMSDK.IMEvents.OnFriendAdded, ({data}) => {
this.pushNewFriend(data);
});
//某个用户的好友列表减少时会收到该回调。
IMSDK.subscribe(IMSDK.IMEvents.OnFriendDeleted, ({data}) => {
this.updateFriendInfo({
friendInfo: data,
isRemove: true,
});
});
// blacklist
//某个用户的黑名单列表增加时会收到该回调。
IMSDK.subscribe(IMSDK.IMEvents.OnBlackAdded, ({data}) => {
this.pushNewBlack(data);
});
//某个用户的黑名单列表减少时会收到该回调。
IMSDK.subscribe(IMSDK.IMEvents.OnBlackDeleted, ({data}) => {
this.updateBlackInfo({
blackInfo: data,
isRemove: true,
});
});
// group
const joinedGroupAddedHandler = ({data}) => {
this.pushNewGroup(data);
};
const joinedGroupDeletedHandler = ({data}) => {
this.updateGroupInfo({
groupInfo: data,
isRemove: true,
});
};
const groupInfoChangedHandler = ({data}) => {
this.updateGroupInfo({
groupInfo: data,
});
};
const groupMemberInfoChangedHandler = ({data}) => {
uni.$emit(IMSDK.IMEvents.OnGroupMemberInfoChanged, {data});
if (data.groupID === this.storeCurrentConversation?.groupID) {
this.updateCurrentMemberInGroup(data);
}
};
//用户所在群组的数量增加时(被邀请入群、入群申请被同意等),会收到此回调。
IMSDK.subscribe(IMSDK.IMEvents.OnJoinedGroupAdded,joinedGroupAddedHandler);
//用户所在群组的数量减少时(主动退群、群被解散等),会收到此回调。
IMSDK.subscribe(IMSDK.IMEvents.OnJoinedGroupDeleted,joinedGroupDeletedHandler);
//群组信息(头像、群名称等,也包括群主变化)改变时,该群所有群成员会收到此回调。
IMSDK.subscribe(IMSDK.IMEvents.OnGroupInfoChanged,groupInfoChangedHandler);
//群成员信息改变(群昵称、头像等)后回调,该群所有群成员会收到此回调。
IMSDK.subscribe(IMSDK.IMEvents.OnGroupMemberInfoChanged,groupMemberInfoChangedHandler);
// application
const friendApplicationNumHandler = ({data}) => {
const isRecv = data.toUserID === this.storeCurrentUserID;
if (isRecv) {
this.pushNewRecvFriendApplition(data);
} else {
this.pushNewSentFriendApplition(data);
}
};
const friendApplicationAccessHandler = ({data}) => {
const isRecv = data.toUserID === this.storeCurrentUserID;
if (isRecv) {
this.updateRecvFriendApplition({
application: data,
});
} else {
this.updateSentFriendApplition({
application: data,
});
}
};
const groupApplicationNumHandler = ({data}) => {
const isRecv = data.userID !== this.storeCurrentUserID;
if (isRecv) {
this.pushNewRecvGroupApplition(data);
} else {
this.pushNewSentGroupApplition(data);
}
};
const groupApplicationAccessHandler = ({data}) => {
const isRecv = data.userID !== this.storeCurrentUserID;
if (isRecv) {
this.updateRecvGroupApplition({
application: data,
});
} else {
this.updateSentGroupApplition({
application: data,
});
}
};
//用户发起好友申请后,申请发起者和接收者都会收到此回调,接收者可以选择同意或拒绝好友申请。
IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationAdded,friendApplicationNumHandler);
//好友申请被同意时,申请发起方和接收方都会收到该回调,双方成功建立好友关系。
IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationAccepted,friendApplicationAccessHandler);
//好友申请被拒绝时,申请发起方和接收方都会收到该回调。
IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationRejected,friendApplicationAccessHandler);
//用户发起好友申请后,申请发起者和接收者都会收到此回调,接收者可以选择同意或拒绝好友申请。
IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationAdded,groupApplicationNumHandler);
//好友申请被同意时,申请发起方和接收方都会收到该回调,双方成功建立好友关系。
IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationAccepted,groupApplicationAccessHandler);
//好友申请被拒绝时,申请发起方和接收方都会收到该回调。
IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationRejected,groupApplicationAccessHandler);
//群组被解散时,该群所有群成员会收到此回调。
//IMSDK.subscribe(IMSDK.IMEvents.OnGroupDismissed,({ data })=>{});
//群成员增加(如用户被邀请进群),其他群成员会收到此回调。
//IMSDK.subscribe(IMSDK.IMEvents.onGroupMemberAdded,({ data })=>{});
//群成员增加(如用户被邀请进群),群成员减少(如群成员退群), 其他群成员会收到此回调。。
//IMSDK.subscribe(IMSDK.IMEvents.onGroupMemberDeleted,({ data })=>{});
//收到的消息被撤回或自己发出的消息被撤回时,会收到此回调。
//IMSDK.subscribe(IMSDK.IMEvents.onNewRecvMessageRevoked,({ data })=>{});
//自己发出的单聊消息被对方标记为已读后,消息发送者会收到此回调。
//IMSDK.subscribe(IMSDK.IMEvents.onRecvC2CReadReceipt,({ data })=>{});
//自己发出的群聊消息被群成员标记为已读后,消息发送者和标记者均会收到此回调。
//IMSDK.subscribe(IMSDK.IMEvents.onRecvGroupReadReceipt,({ data })=>{});
//当应用在后台运行,接收到新消息时,会收到该回调,回调中只会携带一条消息。
//设置了批量消息监听setBatchMsgListener时,此回调不会触发。
//IMSDK.subscribe(IMSDK.IMEvents.onRecvOfflineNewMessage,({ data })=>{});
//当应用在后台运行,接收到新消息时,会收到该回调,回调中可能会携带多条消息。
IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessages,({data})=>{
data.forEach(this.handleOfflineNewMessages);
});
//已订阅用户的在线状态发生变化时,会触发此回调。
//IMSDK.subscribe(IMSDK.IMEvents.onUserStatusChanged,({ data })=>{});
//建立WebSocket连接失败返回后,触发此回调
//IMSDK.subscribe(IMSDK.IMEvents.onConnectFailed,({ data })=>{});
//建立WebSocket连接成功返回后,触发此回调
//IMSDK.subscribe(IMSDK.IMEvents.onConnectSuccess,({ data })=>{});
//建立WebSocket连接中,触发此回调
//IMSDK.subscribe(IMSDK.IMEvents.onConnecting,({ data })=>{});
//正在输入状态回调。
//IMSDK.subscribe(IMSDK.IMEvents.onInputStatusChanged,({ data })=>{});
// conversation
const totalUnreadCountChangedHandler = ({data}) => {
if (this.storeIsSyncing) {
return;
}
this.$store.commit("conversation/SET_UNREAD_COUNT", data);
};
const newConversationHandler = ({data}) => {
if (this.storeIsSyncing) {
return;
}
const result = [...data, ...this.storeConversationList];
this.$store.commit(
"conversation/SET_CONVERSATION_LIST",
conversationSort(result)
);
};
const conversationChangedHandler = ({data}) => {
//console.log('conversationChangedHandler',data);
if (this.storeIsSyncing) {
return;
}
let filterArr = [];
//console.log(data);
const chids = data.map((ch) => ch.conversationID);
filterArr = this.storeConversationList.filter((tc) => !chids.includes(tc.conversationID));
const idx = data.findIndex((c) =>c.conversationID === this.storeCurrentConversation.conversationID);
if (idx !== -1){
this.$store.commit("conversation/SET_CURRENT_CONVERSATION",data[idx]);
}
const result = [...data, ...filterArr];
this.$store.commit("conversation/SET_CONVERSATION_LIST",conversationSort(result));
};
//会话总未读发生变化时的回调。
IMSDK.subscribe(IMSDK.IMEvents.OnTotalUnreadMessageCountChanged,totalUnreadCountChangedHandler);
//有新会话产生时,会收到此回调。
IMSDK.subscribe(IMSDK.IMEvents.OnNewConversation, newConversationHandler);
//某些会话的关键信息发生变化时,会触发该回调,例如会话的未读数发生变化,会话的最后一条消息发生变化等。
IMSDK.subscribe(IMSDK.IMEvents.OnConversationChanged,conversationChangedHandler);
},
async tryLogin() {
const _this = this;
const IMToken = uni.getStorageSync("IMToken");
const IMUserID = uni.getStorageSync("IMUserID")+'';
//console.log('IMToken:',IMToken);
//console.log('IMUserID:',IMUserID);
const path = await getDbDir();
//console.log('path:',path);
const IMConfig = {
systemType: "uni-app",
apiAddr: config.getApiUrl(), // SDK的API接口地址。如:http://xxx:10002
wsAddr: config.getWsUrl(), // SDK的websocket地址。如: ws://xxx:10001
dataDir: path, // 数据存储路径
logLevel: 6,
logFilePath: path,
isLogStandardOutput: true,
isExternalExtensions: false,
};
//console.log('IMConfig:',IMConfig);
const flag = await IMSDK.asyncApi(IMMethods.InitSDK, IMSDK.uuid(), IMConfig);
//console.log('flag:',flag);
if (!flag) {
plus.navigator.closeSplashscreen();
console.log('初始化IMSDK失败!');
uni.$u.toast("初始化IMSDK失败!");
return;
}
_this.setGlobalIMlistener();
// setTimeout(()=>{
// },1000);
let status;
do{
status = await IMSDK.asyncApi(IMSDK.IMMethods.GetLoginStatus,IMSDK.uuid());
//console.log(status);
}while(status == -1001);
if (status === 3) {
console.log('初始化status === 3失败!');
_this.initStore();
return;
}
if (status === 1) {
IMSDK.asyncApi(IMSDK.IMMethods.Login, IMSDK.uuid(), {
userID: IMUserID,
token: IMToken,
})
.then(_this.initStore)
.catch((err) => {
console.log(err);
uni.removeStorage({
key: "IMToken",
});
uni.removeStorage({
key: "BusinessToken",
});
plus.navigator.closeSplashscreen();
});
}
},
handleOfflineNewMessages(newServerMsg) {
console.log(newServerMsg);
console.log( getConversationContent(newServerMsg));
uni.createPushMessage({
title:"您的朋友发来新的消息",
content:getConversationContent(newServerMsg),
payload:{
type:"msg",
data:newServerMsg
},
//icon:'',
//sound:'',
//cover:'false',
//delay:0,
//when:0,//消息上显示的提示时间
//channelId:"",
//category:"",
success(res){
//console.log(res);
},
fail(res){
//console.log(res);
},
complete(res){
//console.log(res);
}
});
},
handleNewMessage(newServerMsg) {
if (this.inCurrentConversation(newServerMsg)) {
if (
newServerMsg.contentType !== MessageType.TypingMessage &&
newServerMsg.contentType !== MessageType.RevokeMessage
) {
newServerMsg.isAppend = true;
this.pushNewMessage(newServerMsg);
setTimeout(() => uni.$emit(PageEvents.ScrollToBottom, true));
uni.$u.debounce(this.markConversationAsRead, 2000);
}
}else{
this.handleOfflineNewMessages(newServerMsg);
}
},
inCurrentConversation(newServerMsg) {
switch (newServerMsg.sessionType) {
case SessionType.Single:
return (
newServerMsg.sendID === this.storeCurrentConversation.userID ||
(newServerMsg.sendID === this.storeCurrentUserID &&
newServerMsg.recvID === this.storeCurrentConversation.userID)
);
case SessionType.WorkingGroup:
return newServerMsg.groupID === this.storeCurrentConversation.groupID;
case SessionType.Notification:
return newServerMsg.sendID === this.storeCurrentConversation.userID;
default:
return false;
}
},
markConversationAsRead() {
IMSDK.asyncApi(
IMSDK.IMMethods.MarkConversationMessageAsRead,
IMSDK.uuid(),
this.storeCurrentConversation.conversationID
);
},
initStore() {
const _this = this;
this.$store.dispatch("user/getSelfInfo");
this.$store.dispatch("conversation/getConversationList");
this.$store.dispatch("conversation/getUnReadCount");
this.$store.dispatch("contact/getBlacklist");
this.$store.dispatch("contact/getRecvFriendApplications");
this.$store.dispatch("contact/getSentFriendApplications");
this.$store.dispatch("contact/getRecvGroupApplications");
this.$store.dispatch("contact/getSentGroupApplications");
this.$store.dispatch("contact/getFriendList");
this.$store.dispatch("circle/getFriendCircleInfo");
if(true !== this.handleArguments()){
uni.switchTab({
url: "/pages/conversation/conversationList/index?isRedirect=true",
complete() {
_this.keppAlive();
plus.navigator.closeSplashscreen();
_this.checkUpdate();
},
fail(e){
console.log(e);
}
});
}
},
// 验证是否升级
checkUpdate() {
const _this = this;
checkUpgrade();
},
keppAlive(){
// #ifdef APP-NVUE
uni.requestPermissions(['android.permission.RECEIVE_BOOT_COMPLETED'], (result) => {
if (result.granted) {
console.log('权限已获得');
} else {
console.log('权限被拒绝');
uni.showModal({
title: '权限申请',
content: '您需要授权后台运行权限才能正常使用该功能',
showCancel: false
});
}
});
// #endif
},
handleArguments(){
var args= plus.runtime.arguments;
if(args){
if(args.startsWith('shunliao://')){
console.log(args);
return ;
}
if(args.startsWith('{')){
const json = JSON.parse(args);
if(json.type == 'msg'){
if(this.inCurrentConversation(json.data)){
}else{
let conversation = this.storeConversationList.find((item) => item === json.data);
if(conversation){
plus.navigator.closeSplashscreen();
prepareConversationState(conversation);
return true;
}
}
}
return ;
}
// 处理args参数,如直达到某新页面等
console.log(args);
} }
} }
} }
+35 -2
View File
@@ -4,8 +4,41 @@ import config from "@/common/config";
export const businessConfig = (params) => export const businessConfig = (params) =>
uni.$u?.http.post("/common/init", JSON.stringify(params)); uni.$u?.http.post("/common/init", JSON.stringify(params));
// 验证是否升级 // 验证是否升级
export const checkUpgrade = (params) => export const checkUpgrade = (params) =>{
uni.$u?.http.post("/common/checkUpgrade", JSON.stringify(params)); const _this = this;
return new Promise((resolve,reject)=>{
let system = uni.getSystemInfoSync()
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
uni.$u?.http.post("/common/checkUpgrade", JSON.stringify({
version:system.appVersion,
platform:system.platform,
version_wgt:inf.versionCode,
})).then(res=>{
console.log(res);
if(!res || !res.version){
return reject(true);
}
let skip_version = uni.getStorageSync('skip_version')
//console.log(res.version,skip_version);
if(res && res.version!=skip_version){
uni.$emit('closeWebview')
uni.setStorageSync('upgrade_model',res)
uni.navigateTo({
url: '/pages/common/upgrade',
animationType:"fade-in",
complete(res1) {
//console.log(res1);
return resolve();
}
});
}
reject();
}).catch(e=>{
reject(e);
})
});
});
};
export const businessLogin = (params) => export const businessLogin = (params) =>
uni.$u?.http.post("/common/login", JSON.stringify(params)); uni.$u?.http.post("/common/login", JSON.stringify(params));
export const businessSendSms = (params) => export const businessSendSms = (params) =>
+1 -1
View File
@@ -3,7 +3,7 @@
// const API_URL = `http://${BASE_HOST}:10002` // const API_URL = `http://${BASE_HOST}:10002`
// const WS_URL = `ws://${BASE_HOST}:10001` // const WS_URL = `ws://${BASE_HOST}:10001`
const BASE_DOMAIN = 'www.axzc.xyz' const BASE_DOMAIN = 'www.shun777.com'
// const CHAT_URL = `https://${BASE_DOMAIN}/chat` // const CHAT_URL = `https://${BASE_DOMAIN}/chat`
// const API_URL = `https://${BASE_DOMAIN}/api` // const API_URL = `https://${BASE_DOMAIN}/api`
// const WS_URL = `wss://${BASE_DOMAIN}/msg_gateway` // const WS_URL = `wss://${BASE_DOMAIN}/msg_gateway`
+16 -20
View File
@@ -44,11 +44,23 @@
return this.isGroup ? defaultGroupIcon : defaultUserIcon; return this.isGroup ? defaultGroupIcon : defaultUserIcon;
}, },
}, },
watch:{
src(nv,ov){
this.init(nv);
},
desc() {
//this.redirectShow();
}
},
created() { created() {
//_this.cachesrc = plus.io.convertAbsoluteFileSystem(); this.init(this.src);
},
methods: {
init(nv){
const _this = this; const _this = this;
if (this.src) { //console.log(nv);
util.cacheFile(util.cdn(this.src),'avatar').then(res=>{ if (nv) {
util.cacheFile(util.cdn(nv),'avatar').then(res=>{
_this.avatarText="" _this.avatarText=""
_this.cachesrc = res; _this.cachesrc = res;
//_this.cachesrc = plus.io.convertAbsoluteFileSystem(res); //_this.cachesrc = plus.io.convertAbsoluteFileSystem(res);
@@ -65,33 +77,17 @@
return ; return ;
} }
this.avatarText = this.desc ? this.desc.slice(0, 1) : "未知"; this.avatarText = this.desc ? this.desc.slice(0, 1) : "未知";
return "";
}, },
methods: {
errorHandle() { errorHandle() {
this.avatarText = this.desc ? this.desc.slice(0, 1) : "未知"; this.avatarText = this.desc ? this.desc.slice(0, 1) : "未知";
}, },
redirectShow() {
if (this.avatarText) {
this.avatarText = undefined;
}
},
click() { click() {
this.$emit("click"); this.$emit("click");
}, },
longpress() { longpress() {
this.$emit("longpress"); this.$emit("longpress");
}, },
}, }
watch: {
src(nv,ov) {
this.redirectShow();
},
desc() {
this.redirectShow();
},
},
}; };
</script> </script>
+10 -4
View File
@@ -1,5 +1,5 @@
<template> <template>
<view @click="clickItem" class="user_item"> <view @longtap.stop.prevent="longtap" @tap="clickItem" class="user_item">
<view v-if="checkVisible" class="check_wrap" <view v-if="checkVisible" class="check_wrap"
:class="{ check_wrap_active: checked, check_wrap_disabled: disabled }"> :class="{ check_wrap_active: checked, check_wrap_disabled: disabled }">
<u-icon v-show="checked" name="checkbox-mark" size="12" color="#fff" /> <u-icon v-show="checked" name="checkbox-mark" size="12" color="#fff" />
@@ -8,9 +8,10 @@
<my-avatar :src="item.faceURL" :desc="item.remark || item.nickname || item.showName" <my-avatar :src="item.faceURL" :desc="item.remark || item.nickname || item.showName"
:isGroup="item.groupName !== undefined || isGroupConversation" size="42" /> :isGroup="item.groupName !== undefined || isGroupConversation" size="42" />
<view class="user_item_details"> <view class="user_item_details">
<text class="user_name">{{item.remark || item.nickname || item.groupName || item.showName}}</text> <view class="user_name">{{item.remark || item.nickname || item.groupName || item.showName}}</view>
<text v-if="item.roleLevel === 100" class="user_role">群主</text> <view v-if="item.roleLevel === 100" class="user_role">群主</view>
<text v-if="item.roleLevel === 60" class="user_role admin_role">管理员</text> <view v-else-if="item.roleLevel === 60" class="user_role admin_role">管理员<u-icon v-if="item.muteEndTime>0" size="24" name="volume-off"></u-icon></view>
<view v-else class="user_role"><u-icon v-if="item.muteEndTime>0" size="24" name="volume-off"></u-icon></view>
<!-- <view class="bottom_line" /> --> <!-- <view class="bottom_line" /> -->
</view> </view>
@@ -55,6 +56,9 @@
this.$emit(this.checkVisible ? "updateCheck" : "itemClick", this.item); this.$emit(this.checkVisible ? "updateCheck" : "itemClick", this.item);
} }
}, },
longtap(){
this.$emit("longtapEvent", this.item);
}
}, },
}; };
</script> </script>
@@ -119,6 +123,8 @@
padding: 8rpx 24rpx; padding: 8rpx 24rpx;
border-radius: 24rpx; border-radius: 24rpx;
margin-left: 24rpx; margin-left: 24rpx;
display: flex;
align-items: center;
color: $u-tips-color; color: $u-tips-color;
} }
+2
View File
@@ -19,6 +19,8 @@ export const GroupMemberListTypes = {
Preview: "Preview", Preview: "Preview",
Transfer: "Transfer", Transfer: "Transfer",
Kickout: "Kickout", Kickout: "Kickout",
setAdmin: "setAdmin",
Mute: "Mute",
}; };
export const ContactChooseTypes = { export const ContactChooseTypes = {
+6 -6
View File
@@ -2,8 +2,8 @@
"name" : "瞬聊", "name" : "瞬聊",
"appid" : "__UNI__E41111F", "appid" : "__UNI__E41111F",
"description" : "一款即时聊天软件", "description" : "一款即时聊天软件",
"versionName" : "3.3.5", "versionName" : "3.3.6",
"versionCode" : 335, "versionCode" : 336,
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
"bounce" : "none", "bounce" : "none",
@@ -11,7 +11,7 @@
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3, "compilerVersion" : 3,
"splashscreen" : { "splashscreen" : {
"alwaysShowBeforeRender" : false, "alwaysShowBeforeRender" : true,
"waiting" : true, "waiting" : true,
"autoclose" : false, "autoclose" : false,
"delay" : 0 "delay" : 0
@@ -54,7 +54,7 @@
], ],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ], "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
"minSdkVersion" : 21, "minSdkVersion" : 21,
"targetSdkVersion" : 26, "targetSdkVersion" : 36,
"schemes" : "shunliao" "schemes" : "shunliao"
}, },
"ios" : { "ios" : {
@@ -97,7 +97,7 @@
"push" : { "push" : {
"unipush" : { "unipush" : {
"version" : "2", "version" : "2",
"offline" : true, "offline" : false,
"icons" : { "icons" : {
"small" : { "small" : {
"ldpi" : "static/images/about_logo.png", "ldpi" : "static/images/about_logo.png",
@@ -111,7 +111,7 @@
} }
}, },
"splashscreen" : { "splashscreen" : {
"androidStyle" : "default", "androidStyle" : "common",
"iosStyle" : "common", "iosStyle" : "common",
"android" : { "android" : {
"hdpi" : "unpackage/res/cover/480_762.9.png", "hdpi" : "unpackage/res/cover/480_762.9.png",
+11 -7
View File
@@ -1,10 +1,8 @@
{ {
"pages": [ "pages": [
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/guide", "path": "pages/common/login/index"
"style": {
"navigationBarTitleText": ""
}
}, },
{ {
"path": "pages/index/launch", "path": "pages/index/launch",
@@ -12,9 +10,11 @@
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
}, },
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/common/login/index" "path": "pages/index/guide",
"style": {
"navigationBarTitleText": ""
}
}, },
{ {
"path": "pages/common/registerOrForget/index" "path": "pages/common/registerOrForget/index"
@@ -277,7 +277,11 @@
{ {
"path": "pages/common/upgrade", "path": "pages/common/upgrade",
"style": { "style": {
"navigationBarTitleText": "" "navigationStyle": "custom",
"backgroundColor": "transparent",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "系统更新",
"enablePullDownRefresh": false
} }
}, },
{ {
+9 -4
View File
@@ -235,6 +235,7 @@
} }
}, },
confirm() { confirm() {
const _this = this;
//console.log(this.checkedUserIDList,this.checkedGroupIDList); //console.log(this.checkedUserIDList,this.checkedGroupIDList);
//return false; //return false;
// if (this.activeTab) { // if (this.activeTab) {
@@ -262,16 +263,20 @@
return; return;
} }
if (this.type === ContactChooseTypes.Invite) { if (this.type === ContactChooseTypes.Invite) {
console.log(_this.getCheckedUserInfo,_this.groupID);
IMSDK.asyncApi(IMSDK.IMMethods.InviteUserToGroup, IMSDK.uuid(), { IMSDK.asyncApi(IMSDK.IMMethods.InviteUserToGroup, IMSDK.uuid(), {
groupID: this.groupID, groupID: _this.groupID,
reason: "", reason: "",
userIDList: this.getCheckedUserInfo.map((user) => user.userID), userIDList: _this.getCheckedUserInfo.map((user) => user.userID),
}) })
.then(() => { .then(() => {
toastWithCallback("操作成功", () => uni.navigateBack()); toastWithCallback("操作成功", () => uni.navigateBack());
this.comfirmLoading = false; _this.comfirmLoading = false;
}) })
.catch(() => toastWithCallback("操作失败")); .catch((e) => {
console.log(e);
toastWithCallback("操作失败")
});
return; return;
} }
@@ -66,8 +66,6 @@
return true; return true;
} }
return false; return false;
console.log(friend.nickname);
return friend.nickname.indexOf(this.keyword) !==-1 || friend?.remark.indexOf(this.keyword) !==-1
} }
), ),
], ],
+6 -7
View File
@@ -32,8 +32,7 @@
</u-form-item> </u-form-item>
<u-form-item v-if="active <= 1 && !isPwdLogin" label="" prop="verificationCode"> <u-form-item v-if="active <= 1 && !isPwdLogin" label="" prop="verificationCode">
<u-input v-model="loginInfo.verificationCode" border="surround" placeholder="请输入验证码"> <u-input v-model="loginInfo.verificationCode" border="surround" placeholder="请输入验证码">
<view class="code_btn" slot="suffix" @click="getCode"> <view class="code_btn" slot="suffix" @click="getCode">{{ count !== 0 ? `${count} s` : "获取验证码" }}
{{ count !== 0 ? `${count} s` : "获取验证码" }}
</view> </view>
</u-input> </u-input>
</u-form-item> </u-form-item>
@@ -158,7 +157,6 @@ export default {
}); });
}, },
async startLogin() { async startLogin() {
this.$refs.loginForm.validate().then(async (valid) => {
this.loading = true; this.loading = true;
this.saveLoginInfo(); this.saveLoginInfo();
let data = {}; let data = {};
@@ -188,7 +186,6 @@ export default {
uni.$u.toast(checkLoginError(err)); uni.$u.toast(checkLoginError(err));
} }
this.loading = false; this.loading = false;
});
}, },
saveLoginProfile(data) { saveLoginProfile(data) {
const { imToken, token, userID } = data; const { imToken, token, userID } = data;
@@ -221,10 +218,11 @@ export default {
} }
const options = { const options = {
phoneNumber: this.loginInfo.phoneNumber, mobile: this.loginInfo.phoneNumber,
email: this.loginInfo.email,
region: `+${this.loginInfo.region}`, region: `+${this.loginInfo.region}`,
usedFor: SmsUserFor.Login, event: "login",
operationID: Date.now() + "", type:"mobile"
}; };
businessSendSms(options) businessSendSms(options)
.then(() => { .then(() => {
@@ -275,6 +273,7 @@ export default {
align-items: center; align-items: center;
img { img {
border-radius: 32rpx;
width: 160rpx; width: 160rpx;
height: 160rpx; height: 160rpx;
} }
+1 -1
View File
@@ -60,7 +60,7 @@
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
return value.length >= 6; return value.length >= 6;
}, },
message: "密码太", message: "密码太过于简单",
trigger: ["change", "blur"], trigger: ["change", "blur"],
}, },
], ],
+30 -19
View File
@@ -37,8 +37,8 @@
import md5 from "md5"; import md5 from "md5";
import MyAvatar from "@/components/MyAvatar/index.vue"; import MyAvatar from "@/components/MyAvatar/index.vue";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import { businessRegister } from "@/api/login"; import {businessRegister} from "@/api/login";
import { checkLoginError } from "@/util/common"; import {checkLoginError } from "@/util/common";
import util from "@/util/index.js" import util from "@/util/index.js"
export default { export default {
components: { components: {
@@ -62,10 +62,11 @@
nickname: [{ nickname: [{
type: "string", type: "string",
required: true, required: true,
message: "请填写真实姓名", message: "请填写您的昵称",
trigger: ["blur", "change"], trigger: ["blur", "change"],
}, ], }, ],
password: [{ password: [
{
type: "string", type: "string",
required: true, required: true,
message: "请输入密码", message: "请输入密码",
@@ -76,20 +77,20 @@
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
return value.length >= 6; return value.length >= 6;
}, },
message: "密码太", message: "密码太过于简单",
trigger: ["change", "blur"], trigger: ["change", "blur"],
}, },
], ],
confirmPassword: [{ confirmPassword: [{
type: "string", type: "string",
required: true, required: true,
message: "请输入确认密码", message: "请再次输入密码",
trigger: ["blur", "change"], trigger: ["blur", "change"],
pattern: /^(?=.*\d)(?=.*[a-zA-Z]).{6,}$/, pattern: /^(?=.*\d)(?=.*[a-zA-Z]).{6,}$/,
}, },
{ {
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
return value === this.formData.password; return value === this.userInfo.password;
}, },
message: "两次密码不一致", message: "两次密码不一致",
trigger: ["change", "blur"], trigger: ["change", "blur"],
@@ -103,15 +104,17 @@
}, },
onLoad(options) { onLoad(options) {
const {userInfo,codeValue} = options; const {userInfo,codeValue} = options;
if(userInfo){
this.userInfo = { this.userInfo = {
...this.userInfo, ...this.userInfo,
...util.aesdecode(userInfo), ...util.aesdecode(userInfo),
}; };
}
this.codeValue = codeValue; this.codeValue = codeValue;
if(process.env.NODE_ENV == 'development'){ if(process.env.NODE_ENV == 'development'){
//this.userInfo.email = "commiu@outlook.com"; //this.userInfo.email = "commiu@outlook.com";
this.userInfo.nickname = ""; this.userInfo.nickname = "";
this.userInfo.password = "qwe123"; this.userInfo.password = "qwe1231";
this.userInfo.confirmPassword = "qwe123"; this.userInfo.confirmPassword = "qwe123";
} }
}, },
@@ -129,26 +132,29 @@
} }
}); });
}, },
async doRegister() { doRegister() {
this.loading = true; const _this = this;
this.$refs.loginForm.validate().then(async (res) => {
_this.loading = true;
console.log(res);
const options = { const options = {
code: this.codeValue, code: _this.codeValue,
platform: uni.$u.os(), platform: uni.$u.os(),
autoLogin: true, autoLogin: true,
...this.userInfo, ..._this.userInfo,
region: `+${this.userInfo.region}`, region: `+${_this.userInfo.region}`,
password: md5(this.userInfo.password), password: md5(_this.userInfo.password),
mobile: this.userInfo.mobile mobile: _this.userInfo.mobile
}; };
try { try {
await businessRegister(options); await businessRegister(options);
this.saveLoginInfo(); _this.saveLoginInfo();
uni.$u.toast('注册成功') uni.$u.toast('注册成功')
uni.$u.route("/pages/common/login/index") uni.$u.route("/pages/common/login/index")
} catch (err) { } catch (err) {
console.log(err); console.log(err);
if(err.msg=="验证码过期" || err.msg=="验证码错误"){ if(err.msg=="验证码过期" || err.msg=="验证码错误"){
const s = util.aesencode(this.userInfo); const s = util.aesencode(_this.userInfo);
uni.$u.route("/pages/common/verifyCode/index", { uni.$u.route("/pages/common/verifyCode/index", {
userInfo: s, userInfo: s,
isRegister: true, isRegister: true,
@@ -158,8 +164,14 @@
} }
// uni.$u.toast('注册失败') // uni.$u.toast('注册失败')
} finally { } finally {
this.loading = false; _this.loading = false;
} }
uni.$u.toast('校验通过')
}).catch(errors => {
console.log(errors);
uni.$u.toast('校验失败')
});
return ;
}, },
saveLoginInfo() { saveLoginInfo() {
uni.setStorage({ uni.setStorage({
@@ -176,7 +188,6 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.set_info_container { .set_info_container {
margin-top: var(--status-bar-height);
background: linear-gradient(180deg, background: linear-gradient(180deg,
rgba(0, 137, 255, 0.1) 0%, rgba(0, 137, 255, 0.1) 0%,
rgba(255, 255, 255, 0) 100%); rgba(255, 255, 255, 0) 100%);
+97 -27
View File
@@ -1,24 +1,32 @@
<template> <template>
<view class="m-shade n-flex-1 n-align-center n-justify-center"> <view class="upgrade_page">
<view :style="{width:'580rpx'}"> <uni-nav-bar left-icon="back"
<image src="/static/image/upgrade.png" mode="widthFix"></image> @clickLeft="back"
<view class="n-ps-all-ll n-ms-top-ll n-position-absolute"> title="系统更新"
<text class="n-size-mm n-weight-7 n-color-inverse">发现新版本</text> backgroundColor="#FFF"
<text class="n-size-base n-ms-top-ss n-color-inverse">V{{model.version}}</text> fixed
statusBar>
</uni-nav-bar>
<view style="flex:1;display: flex;align-items: center;justify-content: center;">
<view :style="{width:'580rpx',position:'relative'}">
<image src="/static/images/upgrade.png" :style="{width:'580rpx'}" mode="widthFix"></image>
<view class="version_info">
<text class="title">发现新版本</text>
<text class="code">V{{model.version}}</text>
</view> </view>
<view class="n-ps-all-l n-radius-lb-base" :style="{backgroundColor:'#f3f3f3',borderRadius:'0 0 16rpx 16rpx'}"> <view class="detail">
<view :style="{height:'300rpx'}"> <scroll-view :show-scrollbar="false" scroll-y>
<scroll-view class="n-flex-1" :show-scrollbar="false" scroll-y> <rich-text :nodes="model.content"></rich-text>
<rich-text class="n-size-s" :nodes="model.content" :style="{lineHeight:'26rpx'}"></rich-text>
</scroll-view> </scroll-view>
</view> <view class="footer">
<view class="n-height-base n-justify-center">
<view v-if="progress"> <view v-if="progress">
<uv-line-progress :percentage="value" activeColor="#fc3463"></uv-line-progress> <u-line-progress :percentage="value" activeColor="#fc3463"></u-line-progress>
</view>
<view class="buttons" v-else>
<u-button v-if="model.force==0" @click="cancel" :customStyle="{backgroundColor:'#f3f3f3'}" text="暂不更新" color="#fc3463" shape="circle" throttleTime="1000" plain></u-button>
<u-button @click="upgrade" text="立即更新" color="#fc3463" shape="circle" throttleTime="1000"></u-button>
</view> </view>
<view class="n-flex-row" v-else>
<uv-button class="n-flex-1 n-ms-right-ll" v-if="model.force==0" @click="cancel" :customStyle="{backgroundColor:'#f3f3f3'}" text="暂不更新" color="#fc3463" shape="circle" throttleTime="1000" plain></uv-button>
<uv-button class="n-flex-1" @click="upgrade" text="立即更新" color="#fc3463" shape="circle" throttleTime="1000"></uv-button>
</view> </view>
</view> </view>
</view> </view>
@@ -27,7 +35,7 @@
</template> </template>
<script> <script>
import util from "@/util/index.js"
export default { export default {
data() { data() {
return { return {
@@ -42,9 +50,23 @@
} }
}, },
onLoad(evt) { onLoad(evt) {
if(evt.model){ // if(evt.model){
this.model = {...this.model, ...JSON.parse(evt.model)} // this.model = {...this.model, ...JSON.parse(evt.model)}
// }
var model = uni.getStorageSync('upgrade_model');
console.log(model);
if(model){
this.model = {...this.model, ...model};
} }
// this.model = {
// "id": 1,
// "type": 1,
// "force": 1,
// "source": "https://shunliao.oss-accelerate.aliyuncs.com/files/150016c51d8672fde3d1cc6945a95089_695d97b6c0162.wgt",
// "version": "3.3.6",
// "content": "修复了一些bug",
// "source_text": null
// };
}, },
onBackPress() { onBackPress() {
if(this.model.force==1){ if(this.model.force==1){
@@ -52,6 +74,11 @@
} }
}, },
methods: { methods: {
back(){
if(this.model.force!=1){
uni.navigateBack()
}
},
// 取消更新 // 取消更新
cancel() { cancel() {
uni.navigateBack() uni.navigateBack()
@@ -80,17 +107,14 @@
// 防止强制更新无法关闭界面 // 防止强制更新无法关闭界面
this.model.force = 0 this.model.force = 0
if(this.model.type==1){ if(this.model.type==1){
uni.showToast({ util.showToast('更新成功,软件重启')
title:'更新成功,软件重启'
})
setTimeout(()=>{ plus.runtime.restart() }, 1500) setTimeout(()=>{ plus.runtime.restart() }, 1500)
} }
}) })
}, },
fail: error=>{ fail: error=>{
uni.showToast({ util.showToast('下载失败,请检查您的网络情况')
title:'下载失败,请检查您的网络情况' this.model.force = 0;
})
} }
}) })
// 监听下载进度 // 监听下载进度
@@ -103,8 +127,54 @@
} }
</script> </script>
<style> <style lang="scss" scoped>
.m-shade{ .upgrade_page{
display: flex;
justify-content: center;
background-color: rgba(0, 0, 0, 0.1); background-color: rgba(0, 0, 0, 0.1);
height: 100vh;
width: 100vw;
.version_info{
position: absolute;
top:120rpx;
display: flex;
align-items: center;
justify-content: flex-start;
margin-left: 20rpx;
width: 100%;
.title{
color: #fff;
}
.code{
color: #fff;
}
}
.detail{
margin-top: -10rpx;
background-color:#f3f3f3;
border-radius:0 0 16rpx 16rpx;
padding: 10rpx 20rpx 30rpx;
display: flex;
flex-direction: column;
scroll-view{
flex: 1;
min-height: 300rpx;
rich-text{
font-size:32rpx;
line-height: 1.5;
}
}
.footer{
display: flex;
flex-direction: column;
justify-content: center;
gap: 20rpx;
.buttons{
width: 100%;
display: flex;
justify-content: space-around;
}
}
}
} }
</style> </style>
+21 -43
View File
@@ -1,34 +1,16 @@
<template> <template>
<view class="group_list_container"> <view class="group_list_container">
<custom-nav-bar title="我的群组"> <custom-nav-bar title="我的群组"></custom-nav-bar>
</custom-nav-bar>
<view class="search_bar_wrap"> <view class="search_bar_wrap">
<u-search <u-search class="search_bar" shape="square" placeholder="搜索" disabled :showAction="false" />
class="search_bar"
shape="square"
placeholder="搜索"
disabled
:showAction="false"
/>
</view> </view>
<u-tabs :scrollable="false" :list="tabList" @click="clickTab"></u-tabs> <u-tabs :scrollable="false" :list="tabList" @click="clickTab"></u-tabs>
<view <view class="pane_row" :style="{ transform: `translateX(${isMyCreate ? '0' : '-100%'})` }">
class="pane_row"
:style="{ transform: `translateX(${isMyCreate ? '0' : '-100%'})` }"
>
<view class="pane_content"> <view class="pane_content">
<u-list <u-list v-if="getMyCreateGroupList.length > 0" class="group_list" :height="`${getListHeight}px`">
v-if="getMyCreateGroupList.length > 0" <u-list-item v-for="group in getMyCreateGroupList" :key="group.groupID">
class="group_list"
:height="`${getListHeight}px`"
>
<u-list-item
v-for="group in getMyCreateGroupList"
:key="group.groupID"
>
<group-item :groupInfo="group" /> <group-item :groupInfo="group" />
</u-list-item> </u-list-item>
</u-list> </u-list>
@@ -36,15 +18,8 @@
</view> </view>
<view class="pane_content"> <view class="pane_content">
<u-list <u-list v-if="getMyJoinedGroupList.length > 0" class="group_list" :height="`${getListHeight}px`">
v-if="getMyJoinedGroupList.length > 0" <u-list-item v-for="group in getMyJoinedGroupList" :key="group.groupID">
class="group_list"
:height="`${getListHeight}px`"
>
<u-list-item
v-for="group in getMyJoinedGroupList"
:key="group.groupID"
>
<group-item :groupInfo="group" /> <group-item :groupInfo="group" />
</u-list-item> </u-list-item>
</u-list> </u-list>
@@ -55,10 +30,12 @@
</template> </template>
<script> <script>
import { mapGetters } from "vuex"; import {
import CustomNavBar from "@/components/CustomNavBar/index.vue"; mapGetters
import GroupItem from "./GroupItem.vue"; } from "vuex";
export default { import CustomNavBar from "@/components/CustomNavBar/index.vue";
import GroupItem from "./GroupItem.vue";
export default {
components: { components: {
CustomNavBar, CustomNavBar,
GroupItem, GroupItem,
@@ -66,8 +43,7 @@ export default {
data() { data() {
return { return {
keyword: "", keyword: "",
tabList: [ tabList: [{
{
name: "我创建的", name: "我创建的",
}, },
{ {
@@ -98,7 +74,7 @@ export default {
); );
}, },
getMyJoinedGroupList() { getMyJoinedGroupList() {
// console.log(this.storeGroupList.filter(group => group.ownerUserID !== this.storeCurrentUserID)); //console.log(this.storeGroupList);
return this.storeGroupList.filter( return this.storeGroupList.filter(
(group) => group.ownerUserID !== this.storeCurrentUserID, (group) => group.ownerUserID !== this.storeCurrentUserID,
); );
@@ -106,7 +82,9 @@ export default {
}, },
mounted() {}, mounted() {},
methods: { methods: {
clickTab({ index }) { clickTab({
index
}) {
this.isMyCreate = index === 0; this.isMyCreate = index === 0;
}, },
toCreateGroup() { toCreateGroup() {
@@ -115,11 +93,11 @@ export default {
}); });
} }
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.group_list_container { .group_list_container {
@include colBox(false); @include colBox(false);
height: 100vh; height: 100vh;
overflow: hidden; overflow: hidden;
@@ -153,5 +131,5 @@ export default {
} }
} }
} }
} }
</style> </style>
@@ -1,5 +1,5 @@
<template> <template>
<view> <view v-if="storeCurrentMemberInGroup.muteEndTime===0">
<view class="chat_footer"> <view class="chat_footer">
<!-- 语音信息 --> <!-- 语音信息 -->
<image class="action_btn" v-show="inputType == 'keyboard'" @click.prevent="swtichInputType('record')" mode="heightFix" src="@/static/images/chating_footer_audio.png" alt="" srcset="" /> <image class="action_btn" v-show="inputType == 'keyboard'" @click.prevent="swtichInputType('record')" mode="heightFix" src="@/static/images/chating_footer_audio.png" alt="" srcset="" />
@@ -43,12 +43,17 @@
</view> </view>
<!-- #endif --> <!-- #endif -->
</view> </view>
<view v-else>
<view class="forbidden_footer">
<view class="mute_tip">您被禁言至{{date(storeCurrentMemberInGroup.muteEndTime)}}</view>
</view>
</view>
</template> </template>
<script> <script>
import {mapGetters,mapActions} from "vuex"; import {mapGetters,mapActions} from "vuex";
import {getPurePath,html2Text,getVideoCover,getVideoInfo} from "@/util/common"; import {getPurePath,html2Text,getVideoCover,getVideoInfo} from "@/util/common";
import {offlinePushInfo} from "@/util/imCommon"; import {offlinePushInfo,date} from "@/util/imCommon";
import {ChatingFooterActionTypes,UpdateMessageTypes,} from "@/constant"; import {ChatingFooterActionTypes,UpdateMessageTypes,} from "@/constant";
import IMSDK, {IMMethods,MessageStatus,MessageType,} from "openim-uniapp-polyfill"; import IMSDK, {IMMethods,MessageStatus,MessageType,} from "openim-uniapp-polyfill";
import CustomEditor from "./CustomEditor"; import CustomEditor from "./CustomEditor";
@@ -101,7 +106,8 @@
"storeCurrentConversation", "storeCurrentConversation",
"storeCurrentGroup", "storeCurrentGroup",
"storeBlackList", "storeBlackList",
"storeCurrentUserID" "storeCurrentUserID",
"storeCurrentMemberInGroup"
]), ]),
hasContent() { hasContent() {
return html2Text(this.inputHtml) !== ""; return html2Text(this.inputHtml) !== "";
@@ -113,6 +119,8 @@
}, },
}, },
mounted() { mounted() {
console.log(this.storeCurrentGroup)
console.log(this.storeCurrentMemberInGroup)
this.setKeyboardListener(); this.setKeyboardListener();
}, },
beforeDestroy() { beforeDestroy() {
@@ -120,6 +128,7 @@
}, },
methods: { methods: {
...mapActions("message", ["pushNewMessage", "updateOneMessage"]), ...mapActions("message", ["pushNewMessage", "updateOneMessage"]),
date,
async createTextMessage() { async createTextMessage() {
let message = ""; let message = "";
const text = html2Text(this.inputHtml); const text = html2Text(this.inputHtml);
@@ -510,6 +519,9 @@
max-height: 120px; max-height: 120px;
padding: 10rpx 20rpx; padding: 10rpx 20rpx;
gap: 20rpx; gap: 20rpx;
.mute_tip{
}
.input_content { .input_content {
flex: 1; flex: 1;
@@ -8,9 +8,16 @@
export default { export default {
name: "ErrorMessagegRender", name: "ErrorMessagegRender",
components: {}, components: {},
props: {
message: Object,
conversationID:String,
},
data() { data() {
return {}; return {};
}, },
created(){
console.log(this.message);
}
}; };
</script> </script>
@@ -33,7 +33,7 @@
conversationID:String, conversationID:String,
}, },
data() { data() {
console.log(this.message); //console.log(this.message);
return { return {
loadingWidth: "120px", loadingWidth: "120px",
src:"", src:"",
@@ -64,7 +64,7 @@
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{ util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
self.coverDownloading = false; self.coverDownloading = false;
self.src = fn; self.src = fn;
console.log(fn); //console.log(fn);
}); });
}, },
clickMediaItem() { clickMediaItem() {
@@ -1,6 +1,6 @@
<template> <template>
<view class="text_message_container bg_container"> <view class="text_message_container bg_container">
<u-parse :content="getContent" :previewImg="false" :showImgMenu="false" selectable></u-parse> <u-parse :content="getContent" :previewImg="false" :showImgMenu="false"></u-parse>
</view> </view>
</template> </template>
@@ -117,10 +117,10 @@
methods: { methods: {
async init(){ async init(){
const self = this; const self = this;
console.log(this.message?.videoElem); //console.log(this.message?.videoElem);
const snapshotUrl = this.message?.videoElem?.snapshotPath || this.message?.videoElem?.snapshotUrl; const snapshotUrl = this.message?.videoElem?.snapshotUrl;
self.coverDownloading = true; self.coverDownloading = true;
console.log(snapshotUrl); //console.log(snapshotUrl);
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{ util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
self.coverDownloading = false; self.coverDownloading = false;
self.src = fn; self.src = fn;
@@ -2,6 +2,9 @@
<view v-if="isNoticeMessage" class="notice_message_container" style="margin: 0 auto;" :id="`auchor${source.clientMsgID}`"> <view v-if="isNoticeMessage" class="notice_message_container" style="margin: 0 auto;" :id="`auchor${source.clientMsgID}`">
<text>{{ getNoticeContent }}</text> <text>{{ getNoticeContent }}</text>
</view> </view>
<view v-else-if="source.contentType == 1519" class="notice_message_container" style="margin: 0 auto;" :id="`auchor${source.clientMsgID}`">
<text @click="toAnnouncement">{{ announcementElem.opUser.nickname }}更新了群公告</text>
</view>
<view v-else class="message_wrapper"> <view v-else class="message_wrapper">
<template v-if="selectFlag"> <template v-if="selectFlag">
<uni-icons class="selectedIcon" size="30" color="#07c160" type="checkbox-filled" v-if="selectClientMsgIDItems.indexOf(source.clientMsgID)>-1"></uni-icons> <uni-icons class="selectedIcon" size="30" color="#07c160" type="checkbox-filled" v-if="selectClientMsgIDItems.indexOf(source.clientMsgID)>-1"></uni-icons>
@@ -24,7 +27,7 @@
</view> </view>
</view> </view>
<view class="message_content_wrap message_content_wrap_shadow" :id="`message_content_wrap_${source.clientMsgID}`" @longtap.stop.prevent="longtapEvent($event)"> <view class="message_content_wrap message_content_wrap_shadow" :id="`message_content_wrap_${source.clientMsgID}`" @longtap.stop.prevent="longtapEvent($event)">
<component :is="component" <component v-if="component" :is="component"
@messageEvent="onMessageEvent" @messageEvent="onMessageEvent"
:isSender="isSender" :isSender="isSender"
:message="source" :message="source"
@@ -34,6 +37,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="selected_overlay" v-if="selectFlag"></view>
</view> </view>
</template> </template>
@@ -113,7 +117,8 @@
toolTipFlag: false, toolTipFlag: false,
popPostion:"default", popPostion:"default",
toolTipData: [], toolTipData: [],
component:"ErrorMessageRender" component:"",
announcementElem:{opUser:{nickname:""}}
}; };
}, },
computed: { computed: {
@@ -159,6 +164,9 @@
} }
}, },
mounted() { mounted() {
if(this.source.contentType == MessageType.GroupAnnouncementUpdated){
this.announcementElem = JSON.parse(this.source.notificationElem.detail)
}else{
const MsgType2Components = { const MsgType2Components = {
['type_'+MessageType.TextMessage] : "TextMessageRender", ['type_'+MessageType.TextMessage] : "TextMessageRender",
['type_'+MessageType.PictureMessage] : "PictureMessageRender", ['type_'+MessageType.PictureMessage] : "PictureMessageRender",
@@ -179,6 +187,7 @@
'type_2001' : "NotificationRender" 'type_2001' : "NotificationRender"
}; };
this.component = MsgType2Components['type_'+this.source.contentType] || "ErrorMessageRender"; this.component = MsgType2Components['type_'+this.source.contentType] || "ErrorMessageRender";
}
this.$emit('userEvent',{type:"messageItemRender"},this.source.clientMsgID); this.$emit('userEvent',{type:"messageItemRender"},this.source.clientMsgID);
this.setSendingDelay(); this.setSendingDelay();
}, },
@@ -191,6 +200,11 @@
}) })
} }
}, },
toAnnouncement(){
uni.navigateTo({
url:"/pages/conversation/groupSettings/announcement"
})
},
setSendingDelay() { setSendingDelay() {
if (this.source.status === MessageStatus.Sending) { if (this.source.status === MessageStatus.Sending) {
setTimeout(() => { setTimeout(() => {
@@ -201,8 +215,8 @@
longtapEvent(e){ longtapEvent(e){
this.$emit('userEvent',{type:"longtapMsgContent"},this.source); this.$emit('userEvent',{type:"longtapMsgContent"},this.source);
}, },
onMessageEvent(e){ onMessageEvent(e,data){
this.$emit('userEvent',e); this.$emit('userEvent',e,data);
}, },
}, },
}; };
@@ -214,6 +228,15 @@
flex-direction: row; flex-direction: row;
align-items: flex-start; align-items: flex-start;
width: 100%; width: 100%;
position: relative;
.selected_overlay{
position: absolute;
left:0;
top:0;
bottom: 0;
right: 0;
z-index: 10;
}
} }
.message_item { .message_item {
display: flex; display: flex;
+47 -27
View File
@@ -26,7 +26,7 @@
import SelectHeader from "./components/SelectHeader"; import SelectHeader from "./components/SelectHeader";
import SelectFooter from "./components/SelectFooter"; import SelectFooter from "./components/SelectFooter";
import {markConversationAsRead} from "@/util/imCommon"; import {markConversationAsRead} from "@/util/imCommon";
import IMSDK, {MessageType} from "openim-uniapp-polyfill"; import IMSDK, {MessageType,GroupMemberRole} from "openim-uniapp-polyfill";
export default { export default {
components: { components: {
ChatingHeader, ChatingHeader,
@@ -50,8 +50,20 @@
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
"storeCurrentConversation","storeCurrentMsg",'storeCurrentMsgID' "storeHistoryMessageList",
"storeCurrentUserID",
"storeCurrentConversation",
"storeCurrentMsg",
'storeCurrentMsgID',
"storeCurrentGroup",
"storeCurrentMemberInGroup"
]), ]),
isOwner() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
},
isAdmin() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
},
}, },
created() { created() {
this.Audio = uni.createInnerAudioContext(); //音频 this.Audio = uni.createInnerAudioContext(); //音频
@@ -91,8 +103,17 @@
if (options?.back2Tab) { if (options?.back2Tab) {
this.back2Tab = JSON.parse(options.back2Tab); this.back2Tab = JSON.parse(options.back2Tab);
} }
IMSDK.subscribe(IMSDK.IMEvents.OnMsgDeleted,({data})=>{
let list = this.storeHistoryMessageList;
//console.log(data);
list = list.filter((item)=>{
return item.serverMsgID != data.serverMsgID;
})
this.$store.commit('message/SET_HISTORY_MESSAGE_LIST',list);
})
}, },
onUnload() { onUnload() {
IMSDK.unsubscribe(IMSDK.IMEvents.OnMsgDeleted);
//console.log("unload"); //console.log("unload");
this.disposePageListener(); this.disposePageListener();
markConversationAsRead({...this.$store.getters.storeCurrentConversation,},true); markConversationAsRead({...this.$store.getters.storeCurrentConversation,},true);
@@ -163,7 +184,7 @@
this.onUserMessageEvent({type: 'cancelSelect'}); this.onUserMessageEvent({type: 'cancelSelect'});
}, },
async doForwarMsg(userList, groupList, msgiem) async doForwarMsg(userList, groupList, msgiem)
{ {b
//console.log(userList,groupList); //console.log(userList,groupList);
const _this = this; const _this = this;
for (var i = 0; i < userList.length; i++) { for (var i = 0; i < userList.length; i++) {
@@ -215,24 +236,19 @@
if(noticeMessageTypes.includes(data.contentType)){ if(noticeMessageTypes.includes(data.contentType)){
return ; return ;
} }
let founded = false; let arr = this.selectItems.filter((item)=>item.clientMsgID != data.clientMsgID);
let arr = []; if(arr.length === this.selectItems.length){
for (var index = 0; index < this.selectItems.length; index++) { arr.push(data)
var v = this.selectItems[index];
if (v.clientMsgID == data.clientMsgID) {
founded = true;
} else {
arr.push(v);
}
}
if (!founded) {
arr.push(data);
} }
this.selectItems = [...arr]; this.selectItems = [...arr];
} }
return; return;
} }
if (e.type == 'deleteMsg') { if (e.type == 'deleteMsg' || e.type == 'deleteServerMsg') {
let method = IMSDK.IMMethods.DeleteMessageFromLocalStorage;
if(e.type == 'deleteServerMsg'){
method = IMSDK.IMMethods.DeleteMessage
}
let deleteMsgs = []; let deleteMsgs = [];
if (!data) { if (!data) {
deleteMsgs = [...this.selectItems]; deleteMsgs = [...this.selectItems];
@@ -241,16 +257,10 @@
} }
for (let i = 0; i < deleteMsgs.length; i++) { for (let i = 0; i < deleteMsgs.length; i++) {
let element = deleteMsgs[i]; let element = deleteMsgs[i];
IMSDK.asyncApi('deleteMessageFromLocalStorage', IMSDK.uuid(), { IMSDK.asyncApi(method, IMSDK.uuid(), {
conversationID: _this.storeCurrentConversation.conversationID, conversationID: _this.storeCurrentConversation.conversationID,
clientMsgID: element.clientMsgID clientMsgID: element.clientMsgID
}).then(res => { });
//console.log(res);
}).catch(res => {
//console.log(res);
}).finally(() => {
//console.log(arguments);
})
} }
this.selectItems = []; this.selectItems = [];
this.$refs.chatingListRef.loadMessageList(); this.$refs.chatingListRef.loadMessageList();
@@ -300,7 +310,11 @@
conversationID: _this.storeCurrentConversation.conversationID, conversationID: _this.storeCurrentConversation.conversationID,
clientMsgID: data.clientMsgID clientMsgID: data.clientMsgID
}).then(res => { }).then(res => {
console.log(res); let list = _this.storeHistoryMessageList;
list = list.filter((item)=>{
return item.clientMsgID != data.clientMsgID;
});
_this.$store.commit('message/SET_HISTORY_MESSAGE_LIST',list);
}).catch(res => { }).catch(res => {
console.log(res); console.log(res);
}).finally(() => { }).finally(() => {
@@ -308,7 +322,7 @@
}) })
return; return;
} }
if(e.type == 'audio_msg_click'){ if (e.type == 'audio_msg_click'){
if(_this.storeCurrentMsgID){ if(_this.storeCurrentMsgID){
_this.updateCurrentMsg({clientMsgID:""}); _this.updateCurrentMsg({clientMsgID:""});
}else{ }else{
@@ -327,9 +341,12 @@
let nowTime = new Date().getTime(); let nowTime = new Date().getTime();
let msgTime = data.createTime; let msgTime = data.createTime;
let diff = nowTime - msgTime; let diff = nowTime - msgTime;
if (this.isSender && diff < 120000) { if (_this.storeCurrentUserID == data.sendID && diff < 120000) {
menu.push('撤回') menu.push('撤回')
} }
if(_this.isAdmin | _this.isOwner){
menu.push('删除(管理员功能)')
}
uni.showActionSheet({ uni.showActionSheet({
itemList: menu, itemList: menu,
success({tapIndex}) { success({tapIndex}) {
@@ -369,6 +386,9 @@
case "删除": case "删除":
_this.onUserMessageEvent({type: 'deleteMsg'}, data); _this.onUserMessageEvent({type: 'deleteMsg'}, data);
break; break;
case "删除(管理员功能)":
_this.onUserMessageEvent({type: 'deleteServerMsg'}, data);
break;
default: default:
break; break;
} }
@@ -24,7 +24,7 @@
<uni-icons size="24" color="#FFF" type="personadd"></uni-icons> <uni-icons size="24" color="#FFF" type="personadd"></uni-icons>
<text>添加好友</text> <text>添加好友</text>
</view> </view>
<view @click="clickMenu({name:'createGroup'})" class="menu_item"> <view @click="clickMenu({name:'scan'})" class="menu_item">
<uni-icons size="24" color="#FFF" type="scan"></uni-icons> <uni-icons size="24" color="#FFF" type="scan"></uni-icons>
<text>扫一扫</text> <text>扫一扫</text>
</view> </view>
@@ -191,6 +191,45 @@
padding: 0 24rpx 10rpx; padding: 0 24rpx 10rpx;
//margin-top: var(--status-bar-height); //margin-top: var(--status-bar-height);
background: #f4f4f4; background: #f4f4f4;
.status_notice{
.err-tag {
display: flex;
justify-content: center;
align-items: center;
height: 44rpx;
background: #ffe1dd;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin-left: 8rpx;
.status {
font-size: 24rpx;
margin-left: 8rpx;
font-weight: 400;
color: #ff381f;
}
}
.tag {
display: flex;
justify-content: center;
align-items: center;
height: 44rpx;
background: #f2f8ff;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin-left: 8rpx;
.loading {
animation: loading 1.5s infinite;
}
.status {
font-size: 24rpx;
margin-left: 8rpx;
font-weight: 400;
color: #0089ff;
}
}
}
.self_info { .self_info {
@include btwBox(); @include btwBox();
@@ -216,46 +255,6 @@
max-width: 240rpx; max-width: 240rpx;
} }
.err-tag {
display: flex;
justify-content: center;
align-items: center;
width: 152rpx;
height: 44rpx;
background: #ffe1dd;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin-left: 8rpx;
.status {
font-size: 24rpx;
margin-left: 8rpx;
font-weight: 400;
color: #ff381f;
}
}
.tag {
display: flex;
justify-content: center;
align-items: center;
width: 152rpx;
height: 44rpx;
background: #f2f8ff;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin-left: 8rpx;
.loading {
animation: loading 1.5s infinite;
}
.status {
font-size: 24rpx;
margin-left: 8rpx;
font-weight: 400;
color: #0089ff;
}
}
.online_state { .online_state {
@include vCenterBox(); @include vCenterBox();
margin-left: 24rpx; margin-left: 24rpx;
@@ -1,7 +1,10 @@
<template> <template>
<view @longtap.prevent="longtapConversationItem" @tap.prevent="clickConversationItem" :class="['conversation_item',source.isPinned?'pinned' : '']"> <view @longtap.prevent="longtapConversationItem" @tap.prevent="clickConversationItem" :class="['conversation_item',source.isPinned?'pinned' : '']">
<view class="left_info"> <view class="left_info">
<view class="avatar">
<my-avatar :isGroup="isGroup" :isNotify="isNotify" :src="source.faceURL" :desc="source.showName" size="46" /> <my-avatar :isGroup="isGroup" :isNotify="isNotify" :src="source.faceURL" :desc="source.showName" size="46" />
<u-badge max="99" :value="source.unreadCount"></u-badge>
</view>
<view class="details"> <view class="details">
<view class="title"> <view class="title">
<text class="conversation_name"> <text class="conversation_name">
@@ -9,7 +12,6 @@
</text> </text>
<view class="right_desc"> <view class="right_desc">
<text class="send_time">{{ latestMessageTime }}</text> <text class="send_time">{{ latestMessageTime }}</text>
<u-badge max="99" :value="source.unreadCount"></u-badge>
</view> </view>
</view> </view>
<view class="lastest_msg_wrap"> <view class="lastest_msg_wrap">
@@ -101,7 +103,14 @@
box-sizing: border-box; box-sizing: border-box;
padding: 12rpx 44rpx 20rpx; padding: 12rpx 44rpx 20rpx;
flex:1; flex:1;
.avatar{
position: relative;
.u-badge{
position: absolute;
right: -6rpx;
top: -6rpx;
}
}
.details { .details {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -161,5 +170,6 @@
} }
} }
} }
} }
</style> </style>
+18 -5
View File
@@ -1,11 +1,22 @@
<template> <template>
<view class="conversation_container"> <view class="conversation_container">
<chat-header ref="chatHeaderRef" /> <chat-header ref="chatHeaderRef" />
<scroll-view class="scroll-view" scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered" <scroll-view class="scroll-view"
:scroll-top="scrollTop" :scroll-with-animation="true" @scroll="scroll" @refresherrefresh="onRefresh" scroll-y="true"
@refresherrestore="onRestore" @scrolltolower="scrolltolower"> refresher-enabled="true"
:refresher-triggered="triggered"
:scroll-top="scrollTop"
:scroll-with-animation="true"
@scroll="scroll"
@refresherrefresh="onRefresh"
@refresherrestore="onRestore"
@scrolltolower="scrolltolower">
<uni-swipe-action ref="swipe_action"> <uni-swipe-action ref="swipe_action">
<uni-swipe-action-item :right-options="swipe_actions" @click="actionClick($event,item)" v-for="item in storeConversationList" :key="item.conversationID" > <uni-swipe-action-item
:right-options="swipe_actions"
@click="actionClick($event,item)"
v-for="item in storeConversationList"
:key="item.conversationID" >
<conversation-item @longtapEvent="showExtendMenu(item)" :source="item"/> <conversation-item @longtapEvent="showExtendMenu(item)" :source="item"/>
</uni-swipe-action-item> </uni-swipe-action-item>
</uni-swipe-action> </uni-swipe-action>
@@ -78,7 +89,7 @@
// uni.navigateTo({ // uni.navigateTo({
// url:"/pages/user/vip/vip" // url:"/pages/user/vip/vip"
// }); // });
//prepareConversationState(this.storeConversationList[2]); prepareConversationState(this.storeConversationList[0]);
},1000) },1000)
}, },
methods: { methods: {
@@ -178,7 +189,9 @@
this.queryList(); this.queryList();
}, },
async queryList(isFirstPage = false) { async queryList(isFirstPage = false) {
//console.log(1);
await this.$store.dispatch("conversation/getConversationList",isFirstPage); await this.$store.dispatch("conversation/getConversationList",isFirstPage);
//console.log(2);
this.triggered = false; this.triggered = false;
this._freshing = false; this._freshing = false;
}, },
+32 -1
View File
@@ -3,10 +3,12 @@
<u-navbar :autoBack="true" bgColor="#ECECEC" title="群管理" safeAreaInsetTop placeholder fixed></u-navbar> <u-navbar :autoBack="true" bgColor="#ECECEC" title="群管理" safeAreaInsetTop placeholder fixed></u-navbar>
<uni-list> <uni-list>
<uni-list-item title="群主管理权转让" @click="toTransfer" showArrow clickable></uni-list-item> <uni-list-item title="群主管理权转让" @click="toTransfer" showArrow clickable></uni-list-item>
<uni-list-item title="设置管理员" @click="setAdmin" showArrow clickable></uni-list-item>
<uni-list-item title="进群验证" @switchChange="updateGroupInfo('needVerification',storeCurrentGroup.needVerification==1 ? 2: 1)" showSwitch :switchChecked="!(storeCurrentGroup.needVerification != 1)"></uni-list-item> <uni-list-item title="进群验证" @switchChange="updateGroupInfo('needVerification',storeCurrentGroup.needVerification==1 ? 2: 1)" showSwitch :switchChecked="!(storeCurrentGroup.needVerification != 1)"></uni-list-item>
<!-- <uni-list-item title="进群验证" :rightText="verifyTypeText" @click="changeVerify" clickable></uni-list-item> -->
<uni-list-item title="允许查看成员资料" @switchChange="updateGroupInfo('lookMemberInfo',storeCurrentGroup.applyMemberFriend == 1 ? 0 : 1)" showSwitch :switchChecked="storeCurrentGroup.applyMemberFriend==0"></uni-list-item> <uni-list-item title="允许查看成员资料" @switchChange="updateGroupInfo('lookMemberInfo',storeCurrentGroup.applyMemberFriend == 1 ? 0 : 1)" showSwitch :switchChecked="storeCurrentGroup.applyMemberFriend==0"></uni-list-item>
<uni-list-item title="允许群内添加好友" @switchChange="updateGroupInfo('applyMemberFriend',storeCurrentGroup.applyMemberFriend == 1 ? 0 : 1)" showSwitch :switchChecked="storeCurrentGroup.applyMemberFriend==0"></uni-list-item> <uni-list-item title="允许群内添加好友" @switchChange="updateGroupInfo('applyMemberFriend',storeCurrentGroup.applyMemberFriend == 1 ? 0 : 1)" showSwitch :switchChecked="storeCurrentGroup.applyMemberFriend==0"></uni-list-item>
<uni-list-item :title="isMute ? '解除禁言':'全员禁言'" @switchChange="updateMute" showSwitch :switchChecked="isMute"></uni-list-item> <uni-list-item title="全员禁言" @switchChange="updateMute" showSwitch :switchChecked="isMute"></uni-list-item>
</uni-list> </uni-list>
</view> </view>
@@ -28,8 +30,19 @@
"storeCurrentMemberInGroup", "storeCurrentMemberInGroup",
"storeCurrentGroup", "storeCurrentGroup",
]), ]),
verifyTypeText(){
if(this.storeCurrentGroup.needVerification === 0){
return '0'
}
if(this.storeCurrentGroup.needVerification === 1){
return '1'
}
return '2';
}
}, },
onLoad() { onLoad() {
this.isMute = this.storeCurrentGroup.status == 3;
//console.log(this.storeCurrentGroup);
// IMSDK.asyncApi('getSpecifiedGroupsInfo', IMSDK.uuid(), [this.storeCurrentGroup.groupID]).then(res=>{ // IMSDK.asyncApi('getSpecifiedGroupsInfo', IMSDK.uuid(), [this.storeCurrentGroup.groupID]).then(res=>{
// console.log(res); // console.log(res);
// }).catch(e=>{ // }).catch(e=>{
@@ -42,7 +55,13 @@
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Transfer}&groupID=${this.storeCurrentGroup.groupID}`, url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Transfer}&groupID=${this.storeCurrentGroup.groupID}`,
}); });
}, },
setAdmin(){
uni.navigateTo({
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.setAdmin}&groupID=${this.storeCurrentGroup.groupID}`,
});
},
updateMute(){ updateMute(){
this.isMute = !this.isMute;
IMSDK.asyncApi('changeGroupMute', IMSDK.uuid(), { IMSDK.asyncApi('changeGroupMute', IMSDK.uuid(), {
groupID: this.storeCurrentGroup.groupID, groupID: this.storeCurrentGroup.groupID,
isMute: this.isMute isMute: this.isMute
@@ -61,6 +80,18 @@
console.log(e); console.log(e);
}) })
}, },
changeVerify(){
uni.showActionSheet({
itemList:[
'申请进群需要群主或管理员同意;群成员邀请可以直接进群',
'申请进群需要群主或管理员同意;群主和管理员邀请可以直接进群;普通成员邀请进群需群主或管理员同意',
'直接进群'
],
success(res){
console.log(res);
}
})
}
}, },
}; };
</script> </script>
@@ -4,9 +4,11 @@
</template> </template>
<script> <script>
import CustomNavBar from "@/components/CustomNavBar/index.vue"; import CustomNavBar from "@/components/CustomNavBar/index.vue";
import { ContactChooseTypes } from "@/constant"; import {
export default { ContactChooseTypes
} from "@/constant";
export default {
name: "", name: "",
components: { components: {
CustomNavBar, CustomNavBar,
@@ -90,11 +92,11 @@ export default {
this.$emit("removeMember"); this.$emit("removeMember");
}, },
}, },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
.more_container { .more_container {
position: relative; position: relative;
.more_dot { .more_dot {
@@ -122,5 +124,5 @@ export default {
// } // }
} }
} }
} }
</style> </style>
+166 -19
View File
@@ -1,7 +1,14 @@
<template> <template>
<view @click="pageClick" class="group_members_container"> <view @click="pageClick" class="group_members_container">
<group-member-list-header ref="navHeaderRef" :checkVisible.sync="showCheck" :isTransfer="isTransfer" <group-member-list-header
:isNomal="!isOwner && !isAdmin" :groupID="groupID" @removeMember="showMemberCheck" /> ref="navHeaderRef"
:checkVisible.sync="showCheck"
:isTransfer="isTransfer"
:isSetAdmin="isSetAdmin"
:isNomal="!isOwner && !isAdmin"
:groupID="groupID"
@removeMember="showMemberCheck"
/>
<view class="search_bar_wrap"> <view class="search_bar_wrap">
<u-search disabled class="search_bar" shape="square" placeholder="搜索" :showAction="false" <u-search disabled class="search_bar" shape="square" placeholder="搜索" :showAction="false"
@@ -10,22 +17,35 @@
<u-list class="member_list" @scrolltolower="loadMore" lowerThreshold="100" height="1"> <u-list class="member_list" @scrolltolower="loadMore" lowerThreshold="100" height="1">
<u-list-item v-for="member in groupMemberList" :key="member.userID"> <u-list-item v-for="member in groupMemberList" :key="member.userID">
<user-item @itemClick="userClick" @updateCheck="updateCheck" :checked="isChecked(member.userID)" <user-item
:checkVisible="showCheck" :disabled="!canCheck(member) && showCheck" :item="member" /> @itemClick="userClick"
@updateCheck="updateCheck"
@longtapEvent="longtap"
:checked="isChecked(member.userID)"
:checkVisible="showCheck"
:disabled="!canCheck(member) && showCheck" :item="member"
/>
</u-list-item> </u-list-item>
<view v-show="loadState.loading" class="member_loading"> <view v-show="loadState.loading" class="member_loading">
<u-loading-icon></u-loading-icon> <u-loading-icon></u-loading-icon>
</view> </view>
</u-list> </u-list>
<choose-index-footer v-if="showCheck" :comfirmLoading="comfirmLoading" @removeItem="updateCheck" <choose-index-footer
@confirm="confirm" :choosedData="getChoosedData" :isRemove="isRemove" :maxLength="groupMemberLength" /> v-if="showCheck"
:comfirmLoading="comfirmLoading"
@removeItem="updateCheck"
@confirm="confirm"
:choosedData="getChoosedData"
:isRemove="isRemove"
:maxLength="groupMemberLength" />
<u-modal :show="showConfirmModal" asyncClose showCancelButton @confirm="modalConfirm" <u-modal
@cancel="() => (showConfirmModal = false)" :content=" :show="showConfirmModal"
isRemove asyncClose
? '确定移除已选群成员?' showCancelButton
: `确定要把群主转移给${choosedTransferMember.nickname}吗?` @confirm="modalConfirm"
@cancel="() => (showConfirmModal = false)" :content="isRemove? '确定移除已选群成员?': `确定要把群主转移给${choosedTransferMember.nickname}吗?`
" /> " />
<u-toast ref="uToast"></u-toast> <u-toast ref="uToast"></u-toast>
</view> </view>
@@ -61,6 +81,7 @@
hasMore: true, hasMore: true,
loading: false, loading: false,
}, },
adminUserIdList:[]
}; };
}, },
computed: { computed: {
@@ -82,6 +103,9 @@
isTransfer() { isTransfer() {
return this.type === GroupMemberListTypes.Transfer; return this.type === GroupMemberListTypes.Transfer;
}, },
isSetAdmin() {
return this.type === GroupMemberListTypes.setAdmin;
},
isChecked() { isChecked() {
return (userID) => this.choosedMemberIDList.includes(userID); return (userID) => this.choosedMemberIDList.includes(userID);
}, },
@@ -93,8 +117,7 @@
}, },
isAdmin() { isAdmin() {
return ( return (
this.$store.getters.storeCurrentMemberInGroup.roleLevel === this.$store.getters.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin
GroupMemberRole.Admin
); );
}, },
canCheck() { canCheck() {
@@ -125,12 +148,29 @@
this.loadMemberList(groupID); this.loadMemberList(groupID);
this.type = type; this.type = type;
this.groupID = groupID; this.groupID = groupID;
this.isRightKick = type === GroupMemberListTypes.Kickout; this.isRightKick = (type == GroupMemberListTypes.setAdmin|| type === GroupMemberListTypes.Kickout);
if ( if (this.isRightKick) {
this.isRightKick
) {
this.showCheck = true; this.showCheck = true;
} }
if(type == GroupMemberListTypes.setAdmin){
IMSDK.asyncApi('getGroupMemberOwnerAndAdmin', IMSDK.uuid(), this.groupID).then(({data}) => {
let arr = [];
data.forEach((item)=>{
if(item.roleLevel == GroupMemberRole.Admin){
arr.push(item.userID);
}
});
this.adminUserIdList = arr;
this.choosedMemberIDList = arr;
console.log(arr);
// 调用成功
})
.catch(({ errCode, errMsg }) => {
console.log(errCode, errMsg );
// 调用失败
})
}
}, },
methods: { methods: {
async pageClick(e) { async pageClick(e) {
@@ -146,8 +186,36 @@
this.$refs.navHeaderRef.checkMenu(); this.$refs.navHeaderRef.checkMenu();
} }
}, },
confirm() { async confirm() {
if(this.isSetAdmin){
uni.showLoading({mask:true})
const remveUserIds = this.adminUserIdList.filter(userID=>{
return !this.choosedMemberIDList.includes(userID);
});
const addUserIds = this.choosedMemberIDList.filter(userID=>{
return !this.adminUserIdList.includes(userID);
});
remveUserIds.forEach(async (userID)=>{
await IMSDK.asyncApi(IMSDK.IMMethods.SetGroupMemberInfo,IMSDK.uuid(),{
roleLevel:GroupMemberRole.Normal,
groupID:this.groupID,
userID:userID
});
})
addUserIds.forEach(async (userID)=>{
await IMSDK.asyncApi(IMSDK.IMMethods.SetGroupMemberInfo,IMSDK.uuid(),{
roleLevel:GroupMemberRole.Admin,
groupID:this.groupID,
userID:userID
});
})
uni.hideLoading();
this.groupMemberList = [];
this.loadMemberList(this.groupID);
uni.navigateBack();
}else{
this.showConfirmModal = true; this.showConfirmModal = true;
}
}, },
modalConfirm() { modalConfirm() {
let func = () => {}; let func = () => {};
@@ -182,7 +250,6 @@
} else { } else {
this.choosedMemberIDList = [...this.choosedMemberIDList, userID]; this.choosedMemberIDList = [...this.choosedMemberIDList, userID];
} }
console.log(this.choosedMemberIDList);
}, },
userClick(member) { userClick(member) {
if (this.type === GroupMemberListTypes.Transfer) { if (this.type === GroupMemberListTypes.Transfer) {
@@ -227,6 +294,86 @@
}) })
.finally(() => (this.loadState.loading = false)); .finally(() => (this.loadState.loading = false));
}, },
longtap(member){
const _this = this;
if(this.isRightKick){
return ;
}
if(!this.isOwner&&!this.isAdmin){
return ;
}
if(this.$store.getters.storeCurrentMemberInGroup.roleLevel == member.roleLevel ){
return ;
}
let itemList = [];
if(this.isOwner){
itemList.push(member.roleLevel == GroupMemberRole.Admin ? '取消管理员' : '设为管理员');
}
if(this.isOwner || this.isAdmin){
itemList.push(member.muteEndTime > 0 ? '取消禁言':'设置禁言');
itemList.push('踢出群聊');
}
uni.showActionSheet({
itemList:itemList,
async success({tapIndex}) {
if(tapIndex == 0){
let roleId = itemList[tapIndex]=='设为管理员' ? GroupMemberRole.Admin : GroupMemberRole.Normal;
await IMSDK.asyncApi(IMSDK.IMMethods.SetGroupMemberInfo,IMSDK.uuid(),{
roleLevel:roleId,
groupID:_this.groupID,
userID:member.userID
});
_this.groupMemberList = _this.groupMemberList.map((item)=>{
if(item.userID == member.userID){
item.roleLevel = roleId
}
return item;
});
return ;
}
if(tapIndex == 1){
if(itemList[tapIndex]=='取消禁言'){
_this.setMute(member.userID,0)
return ;
}
uni.showActionSheet({
itemList:['2小时','8小时','1天','3天','7天','15天','30天','1年'],
async success(res){
const secs = [3600*2,3600*8,3600*24,3600*72,3600*24*7,3600*24*15,3600*24*30,3600*24*365];
_this.setMute(member.userID,secs[res.tapIndex])
}
});
return ;
}
if(tapIndex == 2){
await IMSDK.asyncApi(IMSDK.IMMethods.KickGroupMember,IMSDK.uuid(),{
groupID:_this.groupID,
reason:"",
userIDList:[member.userID]
});
_this.groupMemberList = _this.groupMemberList.filter((item)=>{
return item.userID != member.userID;
});
return ;
}
}
})
},
async setMute(userID,mutedSeconds){
const _this = this;
await IMSDK.asyncApi(IMSDK.IMMethods.ChangeGroupMemberMute,IMSDK.uuid(),{
mutedSeconds:mutedSeconds,
groupID:_this.groupID,
userID:userID
});
this.groupMemberList = this.groupMemberList.map((item)=>{
if(item.userID == userID){
item.muteEndTime = mutedSeconds===0 ? 0 : (new Date().getTime())+mutedSeconds*1000
}
return item;
});
},
showToast(message, complete = null) { showToast(message, complete = null) {
this.$refs.uToast.show({ this.$refs.uToast.show({
message, message,
@@ -1,17 +1,29 @@
<template> <template>
<view style="display: flex;flex-direction: column;width: 100vw;height: 100vh;"> <view>
<u-navbar <u-navbar
:autoBack="true"
title="群公告" title="群公告"
safeAreaInsetTop
placeholder placeholder
fixed :autoBack="true"
> >
<view class="u-nav-slot" slot="right" v-if="isOwner || isAdmin"> <view class="u-nav-slot" slot="right" v-if="isOwner || isAdmin">
<u-button type="primary" size="mini" @click="save">确定</u-button> <u-button type="primary" size="mini" @click="save">保存</u-button>
</view> </view>
</u-navbar> </u-navbar>
<u--textarea :disabled="!isOwner && !isAdmin" count confirmType="done" focus autoHeight maxlength="-1" border="none" v-model="announcement"></u--textarea > <u-parse v-if="!isOwner && !isAdmin" :content="announcement"></u-parse>
<u--textarea v-else
count
confirmType="done"
focus
autoHeight
height="500"
maxlength="-1"
border="none"
:adjustPosition="false"
class="textarea"
placeholder="暂无公告"
v-model="announcement"
>
</u--textarea>
</view> </view>
</template> </template>
@@ -45,7 +57,7 @@
uni.navigateBack(); uni.navigateBack();
}, },
save(){ save(){
if(!isOwner && !isAdmin){ if(!this.isOwner && !this.isAdmin){
return ; return ;
} }
IMSDK.asyncApi(IMSDK.IMMethods.SetGroupInfo, IMSDK.uuid(), { IMSDK.asyncApi(IMSDK.IMMethods.SetGroupInfo, IMSDK.uuid(), {
@@ -62,6 +74,7 @@
} }
</script> </script>
<style> <style scoped lang="scss">
.textarea{
}
</style> </style>
@@ -11,6 +11,7 @@
<view class="member_item" v-for="(member, index) in groupMemberList" :key="member.userID"> <view class="member_item" v-for="(member, index) in groupMemberList" :key="member.userID">
<my-avatar :src="member.faceURL" :desc="member.nickname" :key="member.userID" size="48" /> <my-avatar :src="member.faceURL" :desc="member.nickname" :key="member.userID" size="48" />
<view class="ower" v-if="member.roleLevel === 100">群主</view> <view class="ower" v-if="member.roleLevel === 100">群主</view>
<view class="ower" v-if="member.roleLevel === 60">管理员</view>
<text class="member_item_name">{{ member.nickname }}</text> <text class="member_item_name">{{ member.nickname }}</text>
</view> </view>
<view class="member_item"> <view class="member_item">
+7 -17
View File
@@ -3,26 +3,16 @@
<u-navbar :autoBack="true" bgColor="#ECECEC" :title="'群聊设置('+storeCurrentGroup.memberCount+')'" safeAreaInsetTop placeholder fixed></u-navbar> <u-navbar :autoBack="true" bgColor="#ECECEC" :title="'群聊设置('+storeCurrentGroup.memberCount+')'" safeAreaInsetTop placeholder fixed></u-navbar>
<view class="group_settings_content"> <view class="group_settings_content">
<view class="setting_row info_row" v-if="1==2">
<view class="group_avatar" @click="updateGroupAvatar">
<my-avatar :src="storeCurrentConversation.faceURL" :isGroup="true" size="46" />
<image v-if="isOwner" class="edit_icon" src="@/static/images/group_setting_edit.png" alt="" />
</view>
<view class="group_info">
<view class="group_info_name">
<text class="group_name">{{ storeCurrentConversation.showName }}({{storeCurrentGroup.memberCount}})</text>
<image v-if="isOwner || isAdmin" @click="toUpdateGroupName" style="width: 24rpx; height: 24rpx" src="@/static/images/group_edit.png" alt="" />
</view>
<text @click="copyGroupID" class="sub_title">{{storeCurrentConversation.groupID}}</text>
</view>
</view>
<group-member-row v-if="isJoinGroup" :isNomal="!isAdmin && !isOwner" <group-member-row v-if="isJoinGroup" :isNomal="!isAdmin && !isOwner"
:groupID="storeCurrentConversation.groupID" :memberCount="storeCurrentGroup.memberCount" :groupID="storeCurrentConversation.groupID" :memberCount="storeCurrentGroup.memberCount"
:groupMemberList="groupMemberList" /> :groupMemberList="groupMemberList" />
<uni-list> <uni-list>
<uni-list-item title="群图标" @click="updateGroupAvatar" clickable showArrow>
<template v-slot:footer>
<my-avatar :src="storeCurrentConversation.faceURL" :isGroup="true" size="46" />
</template>
</uni-list-item>
<uni-list-item title="群聊名称" :rightText="storeCurrentConversation.showName" @click="editGroupName" :clickable="isOwner || isAdmin" :showArrow="isOwner || isAdmin"></uni-list-item> <uni-list-item title="群聊名称" :rightText="storeCurrentConversation.showName" @click="editGroupName" :clickable="isOwner || isAdmin" :showArrow="isOwner || isAdmin"></uni-list-item>
<uni-list-item title="群公告" to="/pages/conversation/groupSettings/announcement" clickable showArrow></uni-list-item> <uni-list-item title="群公告" to="/pages/conversation/groupSettings/announcement" clickable showArrow></uni-list-item>
<uni-list-item title="群二维码" :to="getGroupQrcdeUrl" clickable showArrow></uni-list-item> <uni-list-item title="群二维码" :to="getGroupQrcdeUrl" clickable showArrow></uni-list-item>
@@ -95,7 +85,7 @@
}; };
}, },
onShow() { onShow() {
console.log(this.storeCurrentConversation); //console.log(this.storeCurrentConversation);
/* /*
this.$store.commit("conversation/SET_CURRENT_CONVERSATION", { this.$store.commit("conversation/SET_CURRENT_CONVERSATION", {
"conversationID": "sg_1793688611", "conversationID": "sg_1793688611",
@@ -194,7 +184,7 @@
faceURL : this.storeCurrentConversation.faceURL, faceURL : this.storeCurrentConversation.faceURL,
type : "group", type : "group",
}); });
return `/pages/common/userOrGroupQrCode?sourceInfo=${s}`; return `/pages/common/userOrGroupQrCode?sourceInfo=${info}`;
}, },
getGroupVerStr() { getGroupVerStr() {
if ( if (
+3 -31
View File
@@ -24,13 +24,14 @@
<uni-list-item v-if="1==2" title="看一看" thumb="/static/images/find/06.png" :thumbSize="thumbSize" to="/pages/find/friend-circle/friend-circle" showArrow></uni-list-item> <uni-list-item v-if="1==2" title="看一看" thumb="/static/images/find/06.png" :thumbSize="thumbSize" to="/pages/find/friend-circle/friend-circle" showArrow></uni-list-item>
<uni-list-item v-if="1==2" title="听一听" thumb="/static/images/find/06.png" :thumbSize="thumbSize" to="/pages/find/friend-circle/friend-circle" showArrow></uni-list-item> <uni-list-item v-if="1==2" title="听一听" thumb="/static/images/find/06.png" :thumbSize="thumbSize" to="/pages/find/friend-circle/friend-circle" showArrow></uni-list-item>
<uni-list-item v-if="config.near_user_open == '1'" title="附近" thumb="/static/images/find/08.png" :thumbSize="thumbSize" to="/pages/find/near/near" showArrow></uni-list-item> <uni-list-item v-if="config.near_user_open == '1'" title="附近" thumb="/static/images/find/08.png" :thumbSize="thumbSize" to="/pages/find/near/near" showArrow></uni-list-item>
<uni-list-item title="购物" thumb="/static/images/find/09.png" :thumbSize="thumbSize" :to="'/pages/common/webview?url='+encodeURI('http://pinduoduo.com')" showArrow></uni-list-item> <uni-list-item v-if="1===2" title="购物" thumb="/static/images/find/09.png" :thumbSize="thumbSize" :to="'/pages/common/webview?url='+encodeURI('http://pinduoduo.com')" showArrow></uni-list-item>
</uni-list> </uni-list>
</view> </view>
</template> </template>
<script> <script>
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import util from "@/util";
export default { export default {
data() { data() {
return { return {
@@ -51,36 +52,7 @@
this.$store.dispatch('circle/getFriendCircleInfo'); this.$store.dispatch('circle/getFriendCircleInfo');
}, },
methods: { methods: {
scan(){ scan:util.scan
uni.scanCode({
success(res) {
if(res.scanType == "QR_CODE"){
if(res.result.startsWith("http")){
uni.navigateTo({
url:"/pages/common/webview?url="+encodeURIComponent(res.result)
});
//res.result;
return ;
}
const user_prefix = `${this.config.website}/u/`;
if(res.result.startsWith(user_prefix)){
return uni.navigateTo({
url:"/pages/common/userCard/index?sourceID="+res.result.replace(user_prefix,'')
});
}
const group_prefix = `${this.config.website}/g/`;
if(res.result.startsWith(group_prefix)){
return uni.navigateTo({
url:"/pages/common/groupCard/index?sourceID="+res.result.replace(group_prefix,'')
});
}
}
}
})
// uni.navigateTo({
// url:"/pages/common/scan"
// })
}
} }
}; };
</script> </script>
+39 -28
View File
@@ -36,6 +36,10 @@
}, },
onReady() { onReady() {
//console.log('onReady'); //console.log('onReady');
// uni.navigateTo({
// url:"/pages/common/upgrade"
// });
// return ;
// #ifdef APP // #ifdef APP
this.checkUpdate(); this.checkUpdate();
this.tryLogin(); this.tryLogin();
@@ -148,7 +152,6 @@
if (this.storeIsSyncing) { if (this.storeIsSyncing) {
return; return;
} }
console.log(data);
data.forEach(this.handleNewMessage); data.forEach(this.handleNewMessage);
}); });
@@ -282,8 +285,8 @@
//设置了批量消息监听setBatchMsgListener时,此回调不会触发。 //设置了批量消息监听setBatchMsgListener时,此回调不会触发。
//IMSDK.subscribe(IMSDK.IMEvents.onRecvOfflineNewMessage,({ data })=>{}); //IMSDK.subscribe(IMSDK.IMEvents.onRecvOfflineNewMessage,({ data })=>{});
//当应用在后台运行,接收到新消息时,会收到该回调,回调中可能会携带多条消息。 //当应用在后台运行,接收到新消息时,会收到该回调,回调中可能会携带多条消息。
IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessages,(res)=>{ IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessages,({data})=>{
console.log(res); data.forEach(this.handleOfflineNewMessages);
}); });
//已订阅用户的在线状态发生变化时,会触发此回调。 //已订阅用户的在线状态发生变化时,会触发此回调。
//IMSDK.subscribe(IMSDK.IMEvents.onUserStatusChanged,({ data })=>{}); //IMSDK.subscribe(IMSDK.IMEvents.onUserStatusChanged,({ data })=>{});
@@ -404,6 +407,35 @@
} }
}, },
handleOfflineNewMessages(newServerMsg) {
console.log(newServerMsg);
console.log( getConversationContent(newServerMsg));
uni.createPushMessage({
title:"您的朋友发来新的消息",
content:getConversationContent(newServerMsg),
payload:{
type:"msg",
data:newServerMsg
},
//icon:'',
//sound:'',
//cover:'false',
//delay:0,
//when:0,//消息上显示的提示时间
//channelId:"",
//category:"",
success(res){
//console.log(res);
},
fail(res){
//console.log(res);
},
complete(res){
//console.log(res);
}
});
},
handleNewMessage(newServerMsg) { handleNewMessage(newServerMsg) {
if (this.inCurrentConversation(newServerMsg)) { if (this.inCurrentConversation(newServerMsg)) {
if ( if (
@@ -416,30 +448,7 @@
uni.$u.debounce(this.markConversationAsRead, 2000); uni.$u.debounce(this.markConversationAsRead, 2000);
} }
}else{ }else{
console.log(newServerMsg); this.handleOfflineNewMessages(newServerMsg);
console.log( getConversationContent(newServerMsg));
uni.createPushMessage({
title:"您的朋友发来新的消息",
content:getConversationContent(newServerMsg),
payload:newServerMsg,
//icon:'',
//sound:'',
//cover:'false',
//delay:0,
//when:0,//消息上显示的提示时间
//channelId:"",
//category:"",
success(res){
console.log(res);
},
fail(res){
console.log(res);
},
complete(res){
console.log(res);
}
});
} }
}, },
@@ -497,10 +506,10 @@
let system = uni.getSystemInfoSync() let system = uni.getSystemInfoSync()
plus.runtime.getProperty(plus.runtime.appid, function(inf) { plus.runtime.getProperty(plus.runtime.appid, function(inf) {
checkUpgrade({version:system.appVersion,platform:system.platform,version_wgt:inf.versionCode}).then(res=>{ checkUpgrade({version:system.appVersion,platform:system.platform,version_wgt:inf.versionCode}).then(res=>{
console.log(res.version,skip_version);
let skip_version = uni.getStorageSync('skip_version') let skip_version = uni.getStorageSync('skip_version')
if(res && res.version!=skip_version){ if(res && res.version!=skip_version){
uni.$emit('closeWebview') uni.$emit('closeWebview')
this.setShow(this.current, false)
router('/pages/common/upgrade?model=' + JSON.stringify(res), '', 'fade-in') router('/pages/common/upgrade?model=' + JSON.stringify(res), '', 'fade-in')
} }
}) })
@@ -523,6 +532,7 @@
}); });
// #endif // #endif
} }
} }
} }
</script> </script>
@@ -537,5 +547,6 @@
.gif-image { .gif-image {
width: 50%; width: 50%;
border-radius: 10%;
} }
</style> </style>
+15 -25
View File
@@ -2,19 +2,19 @@
<view class="page_container"> <view class="page_container">
<custom-nav-bar title="关于我们" /> <custom-nav-bar title="关于我们" />
<view class="logo_area"> <view class="logo_area">
<image :src="cdn(config.app_logo)" mode=""></image> <image class="logo" :src="cdn(config.app_logo)" mode="aspectFit"></image>
<view>{{ appversion }}</view> <view>{{ appversion }}</view>
<info-item @click="checkUpdate" class="check" title="检测更新" /> <info-item @click="checkUpdate" class="check" title="检测更新" />
<info-item @click="openurl(config.website)" class="check" title="官方网站" /> <info-item @click="openurl(config.website)" class="check" title="官方网站" />
<info-item @click="goto('/pages/common/article?type=spage&name=cooperation&title=商务合作')" class="check" title="商务合作" /> <info-item v-if="1==2" @click="goto('/pages/common/article?type=spage&name=cooperation&title=商务合作')" class="check" title="商务合作" />
<info-item @click="goto('/pages/common/article?type=spage&name=terms_of_service&title=用户协议')" class="check" title="用户协议" /> <info-item @click="goto('/pages/common/article?type=spage&name=terms_of_service&title=用户协议')" class="check" title="用户协议" />
<info-item @click="goto('/pages/common/article?type=spage&name=privacy_policy&title=隐私政策')" class="check" title="隐私政策" /> <info-item @click="goto('/pages/common/article?type=spage&name=privacy_policy&title=隐私政策')" class="check" title="隐私政策" />
<info-item @click="goto('/pages/common/article?type=spage&name=aboutus&title=关于我们')" class="check" title="关于我们" /> <info-item @click="goto('/pages/common/article?type=spage&name=aboutus&title=关于我们')" class="check" title="关于我们" />
<info-item @click="clearcache" class="check" title="清除缓存" /> <info-item @click="clearcache" class="check" title="清除缓存" />
<info-item @click="show = true" class="check" title="上传调试日志" /> <info-item v-if="1==2" @click="show = true" class="check" title="上传调试日志" />
<u-modal showCancelButton :show="show" title="上传日志" @confirm="uploadLog" @cancel="show = false"> <u-modal v-if="1==2" showCancelButton :show="show" title="上传日志" @confirm="uploadLog" @cancel="show = false">
<view class="slot-content"> <view class="slot-content">
<u--input placeholder="日志数量" border="surround" v-model="line"></u--input> <u--input placeholder="日志数量" border="surround" v-model="line"></u--input>
</view> </view>
@@ -31,7 +31,7 @@
import InfoItem from "../selfInfo/InfoItem.vue"; import InfoItem from "../selfInfo/InfoItem.vue";
import {checkUpgrade} from "@/api/login.js" import {checkUpgrade} from "@/api/login.js"
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import util from "@/util/index.js" import util from "@/util/index.js"
export default { export default {
components: { components: {
CustomNavBar, CustomNavBar,
@@ -113,27 +113,16 @@ import util from "@/util/index.js"
checkUpdate() { checkUpdate() {
this.loading = true; this.loading = true;
const _this = this; const _this = this;
let system = uni.getSystemInfoSync(); checkUpgrade().then(res=>{
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
checkUpgrade({version:system.appVersion,platform:system.platform,version_wgt:inf.versionCode}).then(res=>{
_this.loading = false; _this.loading = false;
if(!res.data){ }).catch(e=>{
uni.showToast({ console.log(e);
title:"已经是最新版本" if(e === true){
}) uni.showToast({title:'已经是最新版本'})
return ; return ;
} }
let skip_version = uni.getStorageSync('skip_version') _this.loading = false;
if(res && res.version!=skip_version){
uni.$emit('closeWebview')
_this.setShow(_this.current, false)
uni.navigateTo({
url: '/pages/common/upgrade?model=' + JSON.stringify(res),
animationType:"fade-in"
}); });
}
})
})
}, },
}, },
}; };
@@ -153,9 +142,10 @@ import util from "@/util/index.js"
padding: 48rpx 0 16rpx 0; padding: 48rpx 0 16rpx 0;
color: $uni-text-color; color: $uni-text-color;
image { .logo{
width: 72px; border-radius: 32rpx;
height: 72px; width: 160rpx;
height: 160rpx;
margin-bottom: 24rpx; margin-bottom: 24rpx;
} }
} }
+1 -1
View File
@@ -9,7 +9,7 @@
<view class="id_row"> <view class="id_row">
<text class="nickname">{{ selfInfo.nickname }}</text> <text class="nickname">{{ selfInfo.nickname }}</text>
<view class="id_row_copy" @click="copy"> <view class="id_row_copy" @click="copy">
<text class="id">{{ selfInfo.userID }}</text> <text class="id">瞬聊号{{ selfInfo.userID }}</text>
<image style="width: 32rpx; height: 32rpx" src="@/static/images/id_copy.png" mode="" /> <image style="width: 32rpx; height: 32rpx" src="@/static/images/id_copy.png" mode="" />
</view> </view>
</view> </view>
+3 -3
View File
@@ -55,16 +55,15 @@
return this.$store.getters.storeSelfInfo; return this.$store.getters.storeSelfInfo;
}, },
getGender() { getGender() {
if (this.selfInfo.sex === 0) { if (this.selfInfo.sex == 0) {
return "保密"; return "保密";
} }
if (this.selfInfo.sex === 1) { if (this.selfInfo.sex == 1) {
return "男"; return "男";
} }
return "女"; return "女";
}, },
getBirth() { getBirth() {
console.log(this.selfInfo);
const birth = this.selfInfo.birthday ?? 0; const birth = this.selfInfo.birthday ?? 0;
return dayjs(birth).format("YYYY-MM-DD"); return dayjs(birth).format("YYYY-MM-DD");
}, },
@@ -153,6 +152,7 @@
}, },
confirmDate({value}) { confirmDate({value}) {
this.loadingState.birth = true; this.loadingState.birth = true;
console.log(this.$store.getters.storeSelfInfo.faceURL);
this.updateSelfInfo({birth: value,},"birth",); this.updateSelfInfo({birth: value,},"birth",);
this.showDatePicker = false; this.showDatePicker = false;
}, },
Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

+2 -6
View File
@@ -53,9 +53,6 @@ const mutations = {
const actions = { const actions = {
async getFriendList({commit }) { async getFriendList({commit }) {
//#ifndef APP
return [];
//#endif
let offset = 0; let offset = 0;
let friendInfoList = []; let friendInfoList = [];
let initialFetch = true; let initialFetch = true;
@@ -73,14 +70,12 @@ const actions = {
initialFetch = false; initialFetch = false;
} catch (error) { } catch (error) {
console.error("getFriendListPage error",error); console.error("getFriendListPage error",error);
break;
} }
} }
commit("SET_FRIEND_LIST", friendInfoList); commit("SET_FRIEND_LIST", friendInfoList);
}, },
async getGrouplist({commit}) { async getGrouplist({commit}) {
//#ifndef APP
return [];
//#endif
let offset = 0; let offset = 0;
let groupList = []; let groupList = [];
while (true) { while (true) {
@@ -101,6 +96,7 @@ const actions = {
console.error("getGrouplist error"); console.error("getGrouplist error");
} }
} }
//console.log(groupList);
commit("SET_GROUP_LIST", groupList); commit("SET_GROUP_LIST", groupList);
}, },
getBlacklist({commit}) { getBlacklist({commit}) {
+2 -2
View File
@@ -19,7 +19,7 @@ const mutations = {
}; };
}, },
SET_UNREAD_COUNT(state, count) { SET_UNREAD_COUNT(state, count) {
if (count) { if (count>0) {
uni.setTabBarBadge({ uni.setTabBarBadge({
index: 0, index: 0,
text: count < 99 ? count + "" : "99+", text: count < 99 ? count + "" : "99+",
@@ -104,7 +104,7 @@ const actions = {
); );
}, },
updateCurrentMemberInGroup({commit,state}, memberInfo) { updateCurrentMemberInGroup({commit,state}, memberInfo) {
console.log(memberInfo); //console.log(memberInfo);
if ( if (
memberInfo.groupID === state.currentMemberInGroup.groupID && memberInfo.groupID === state.currentMemberInGroup.groupID &&
memberInfo.userID === state.currentMemberInGroup.userID memberInfo.userID === state.currentMemberInGroup.userID
@@ -1,12 +1,12 @@
<template> <template>
<view class="ly-map-wrapper"> <view class="ly-map-wrapper">
<view style="background: transparent;position: absolute;z-index:1998;top:10px;left: 10px;right:10px;display: flex;align-items: center;justify-content: space-between;"> <view style="background: transparent;position: absolute;z-index:1998;top:54px;left: 10px;right:10px;display: flex;align-items: center;justify-content: space-between;">
<uni-icons type="left" size="26" color="#333" @click="back"></uni-icons> <uni-icons type="left" size="26" color="#333" @click="back"></uni-icons>
<u-button <u-button
@click="confirm" @click="confirm"
type="primary" type="primary"
v-if="type == 'chooselocation'" v-if="type == 'chooselocation'"
style="font-size: 15px;width: 100rpx;margin: 0;">确定</u-button> style="font-size: 15px;width: 150rpx;margin: 0;">确定</u-button>
</view> </view>
<!-- <uni-nav-bar <!-- <uni-nav-bar
left-icon="back" left-icon="back"
Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 532 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

+41 -18
View File
@@ -1,5 +1,5 @@
import store from "@/store"; import store from "@/store";
import {CustomType,GroupSystemMessageTypes,AddFriendQrCodePrefix,AddGroupQrCodePrefix} from "@/constant"; import {CustomType,GroupSystemMessageTypes,noticeMessageTypes} from "@/constant";
import IMSDK, {GroupAtType,MessageType,SessionType} from "openim-uniapp-polyfill"; import IMSDK, {GroupAtType,MessageType,SessionType} from "openim-uniapp-polyfill";
import dayjs from "dayjs"; import dayjs from "dayjs";
import {isThisYear} from "date-fns"; import {isThisYear} from "date-fns";
@@ -30,6 +30,10 @@ dayjs.updateLocale("zh-cn", {
}, },
}); });
export const date = (timestemp, fmt = 'YYYY-MM-DD HH:mm:ss') => {
if (!timestemp) return "";
return dayjs(timestemp).format(fmt)
};
export const formatMessageTime = (timestemp, keepSameYear = false) => { export const formatMessageTime = (timestemp, keepSameYear = false) => {
if (!timestemp) return ""; if (!timestemp) return "";
const isRecent = dayjs().diff(timestemp, "day") < 7; const isRecent = dayjs().diff(timestemp, "day") < 7;
@@ -174,11 +178,21 @@ export const parseMessageByType = (pmsg) => {
kickStr = kickStr.slice(0, -1); kickStr = kickStr.slice(0, -1);
return `${getName(kickOpUser)}踢出了${kickStr}${kickdUserList.length > 3 ? "..." : ""}`; return `${getName(kickOpUser)}踢出了${kickStr}${kickdUserList.length > 3 ? "..." : ""}`;
case MessageType.GroupMemberMuted: case MessageType.GroupMemberMuted:
return `[GroupMemberMuted]`; //群成员禁言通知
const groupMemberMutedDetail = JSON.parse(pmsg.notificationElem.detail);
return `${getName(groupMemberMutedDetail.opUser)}取消了${getName(groupMemberMutedDetail.mutedUser)}的禁言`;
case MessageType.GroupMemberCancelMuted: case MessageType.GroupMemberCancelMuted:
return `[GroupMemberCancelMuted]`; //取消群成员禁言通知
const groupMemberCancelMutedDetail = JSON.parse(pmsg.notificationElem.detail);
return `${getName(groupMemberCancelMutedDetail.opUser)}禁言了${getName(groupMemberCancelMutedDetail.mutedUser)}`;
case MessageType.GroupMuted: case MessageType.GroupMuted:
return `[GroupMuted]`; //群禁言通知
const groupGroupMutedDetail = JSON.parse(pmsg.notificationElem.detail);
return `${getName(groupGroupMutedDetail.opUser)}设置了全员禁言`;
case MessageType.GroupCancelMuted:
//取消群禁言通知
const groupGroupCancelMutedDetail = JSON.parse(pmsg.notificationElem.detail);
return `${getName(groupGroupCancelMutedDetail.opUser)}取消了全员禁言`;
case MessageType.MemberQuit: case MessageType.MemberQuit:
const quitDetails = JSON.parse(pmsg.notificationElem.detail); const quitDetails = JSON.parse(pmsg.notificationElem.detail);
const quitUser = quitDetails.quitUser; const quitUser = quitDetails.quitUser;
@@ -200,15 +214,19 @@ export const parseMessageByType = (pmsg) => {
const groupNameUpdateDetail = JSON.parse(pmsg.notificationElem.detail); const groupNameUpdateDetail = JSON.parse(pmsg.notificationElem.detail);
const groupNameUpdateUser = groupNameUpdateDetail.opUser; const groupNameUpdateUser = groupNameUpdateDetail.opUser;
return `${getName(groupNameUpdateUser)}修改了群名称为${groupNameUpdateDetail.group.groupName}`; return `${getName(groupNameUpdateUser)}修改了群名称为${groupNameUpdateDetail.group.groupName}`;
case MessageType.GroupCancelMuted:
return `[GroupCancelMuted]`;
case MessageType.GroupAnnouncementUpdated: case MessageType.GroupAnnouncementUpdated:
return `[GroupAnnouncementUpdated]`; //群公告更新
const groupAnnouncementUpdatedDetail = JSON.parse(pmsg.notificationElem.detail);
return `${getName(groupAnnouncementUpdatedDetail.opUser)}更新了群公告`;
case MessageType.BurnMessageChange: case MessageType.BurnMessageChange:
//阅后即焚开启或关闭通知
//console.log(pmsg);
return `[BurnMessageChange]`; return `[BurnMessageChange]`;
case MessageType.RevokeMessage: case MessageType.RevokeMessage:
return `[RevokeMessage]`; let notificationElem = JSON.parse(pmsg.notificationElem.detail);
return `${notificationElem.revokerNickname}撤回了一条消息`;
case MessageType.MsgPinned: case MessageType.MsgPinned:
//消息置顶
return `[MsgPinned]`; return `[MsgPinned]`;
case 2001: case 2001:
const body = JSON.parse(pmsg.notificationElem.detail); const body = JSON.parse(pmsg.notificationElem.detail);
@@ -253,7 +271,6 @@ export const bytesToSize = (bytes) => {
return (bytes / Math.pow(k, i)).toPrecision(3) + " " + sizes[i]; return (bytes / Math.pow(k, i)).toPrecision(3) + " " + sizes[i];
}; };
export const tipMessaggeFormat = (msg, currentUserID) => { export const tipMessaggeFormat = (msg, currentUserID) => {
const getName = (user) => const getName = (user) =>
@@ -269,43 +286,43 @@ export const tipMessaggeFormat = (msg, currentUserID) => {
case MessageType.GroupInfoUpdated: case MessageType.GroupInfoUpdated:
const groupUpdateDetail = JSON.parse(msg.notificationElem.detail); const groupUpdateDetail = JSON.parse(msg.notificationElem.detail);
const groupUpdateUser = groupUpdateDetail.opUser; const groupUpdateUser = groupUpdateDetail.opUser;
return `${parseInfo(groupUpdateUser)}修改了群信息`; return `${getName(groupUpdateUser)}修改了群信息`;
case MessageType.GroupOwnerTransferred: case MessageType.GroupOwnerTransferred:
const transferDetails = JSON.parse(msg.notificationElem.detail); const transferDetails = JSON.parse(msg.notificationElem.detail);
const transferOpUser = transferDetails.opUser; const transferOpUser = transferDetails.opUser;
const newOwner = transferDetails.newGroupOwner; const newOwner = transferDetails.newGroupOwner;
return `${parseInfo(transferOpUser)}转让群主给${parseInfo(newOwner)}`; return `${getName(transferOpUser)}转让群主给${getName(newOwner)}`;
case MessageType.MemberQuit: case MessageType.MemberQuit:
const quitDetails = JSON.parse(msg.notificationElem.detail); const quitDetails = JSON.parse(msg.notificationElem.detail);
const quitUser = quitDetails.quitUser; const quitUser = quitDetails.quitUser;
return `${parseInfo(quitUser)}退出了群组`; return `${getName(quitUser)}退出了群组`;
case MessageType.MemberInvited: case MessageType.MemberInvited:
const inviteDetails = JSON.parse(msg.notificationElem.detail); const inviteDetails = JSON.parse(msg.notificationElem.detail);
const inviteOpUser = inviteDetails.opUser; const inviteOpUser = inviteDetails.opUser;
const invitedUserList = inviteDetails.invitedUserList ?? []; const invitedUserList = inviteDetails.invitedUserList ?? [];
let inviteStr = ""; let inviteStr = "";
invitedUserList.find( invitedUserList.find(
(user, idx) => (inviteStr += parseInfo(user) + "、") && idx > 3, (user, idx) => (inviteStr += getName(user) + "、") && idx > 3,
); );
inviteStr = inviteStr.slice(0, -1); inviteStr = inviteStr.slice(0, -1);
return `${parseInfo(inviteOpUser)} 邀请了${inviteStr}${invitedUserList.length > 3 ? "..." : ""}加入群聊`; case MessageType.MemberKicked: return `${getName(inviteOpUser)} 邀请了${inviteStr}${invitedUserList.length > 3 ? "..." : ""}加入群聊`; case MessageType.MemberKicked:
const kickDetails = JSON.parse(msg.notificationElem.detail); const kickDetails = JSON.parse(msg.notificationElem.detail);
const kickOpUser = kickDetails.opUser; const kickOpUser = kickDetails.opUser;
const kickdUserList = kickDetails.kickedUserList ?? []; const kickdUserList = kickDetails.kickedUserList ?? [];
let kickStr = ""; let kickStr = "";
kickdUserList.find( kickdUserList.find(
(user, idx) => (kickStr += parseInfo(user) + "、") && idx > 3, (user, idx) => (kickStr += getName(user) + "、") && idx > 3,
); );
kickStr = kickStr.slice(0, -1); kickStr = kickStr.slice(0, -1);
return `${parseInfo(kickOpUser)} 踢出了${kickStr}${kickdUserList.length > 3 ? "..." : ""}`; return `${getName(kickOpUser)} 踢出了${kickStr}${kickdUserList.length > 3 ? "..." : ""}`;
case MessageType.MemberEnter: case MessageType.MemberEnter:
const enterDetails = JSON.parse(msg.notificationElem.detail); const enterDetails = JSON.parse(msg.notificationElem.detail);
const enterUser = enterDetails.entrantUser; const enterUser = enterDetails.entrantUser;
return `${parseInfo(enterUser)}加入了群聊`; return `${getName(enterUser)}加入了群聊`;
case MessageType.GroupDismissed: case MessageType.GroupDismissed:
const dismissDetails = JSON.parse(msg.notificationElem.detail); const dismissDetails = JSON.parse(msg.notificationElem.detail);
const dismissUser = dismissDetails.opUser; const dismissUser = dismissDetails.opUser;
return `${parseInfo(dismissUser)}解散了群聊`; return `${getName(dismissUser)}解散了群聊`;
default: default:
return ""; return "";
} }
@@ -371,11 +388,17 @@ export const offlinePushInfo = {
}; };
export const getConversationContent = (message) => { export const getConversationContent = (message) => {
if(noticeMessageTypes.includes(message.contentType)){
return `${parseMessageByType(message)}`;
}
if ( if (
!message.groupID || !message.groupID ||
message.sendID === store.getters.storeCurrentUserID message.sendID === store.getters.storeCurrentUserID
) { ) {
return parseMessageByType(message); return parseMessageByType(message);
} }
if(message.senderNickname){
return `${message.senderNickname}${parseMessageByType(message)}`; return `${message.senderNickname}${parseMessageByType(message)}`;
}
return parseMessageByType(message);
}; };
+30 -11
View File
@@ -1,13 +1,14 @@
//import i18n from '@/locales' //import i18n from '@/locales'
import base from '@/common/config'; import base from '@/common/config';
//import store from "@/store"; import store from "@/store";
import IMSDK from "openim-uniapp-polyfill"; import IMSDK from "openim-uniapp-polyfill";
import CryptoJS from 'crypto-js'; import CryptoJS from 'crypto-js';
import md5 from "md5"; import md5 from "md5";
// #ifdef APP
import {downloadFile} from "@/uni_modules/network-manage"; import {downloadFile} from "@/uni_modules/network-manage";
// #endif
const isString = (v)=> { const isString = (v)=> {
return typeof v === 'string' || v instanceof String; return typeof v === 'string' || v instanceof String;
}, },
@@ -144,20 +145,31 @@ const scan = ()=>{
barCode 扫描条形码时返回条形码数据 支付宝小程序 barCode 扫描条形码时返回条形码数据 支付宝小程序
imageChannel 来源 支付宝小程序 imageChannel 来源 支付宝小程序
*/ */
if(res.result){ if(res.scanType == "QR_CODE"){
if(res.result.indexOf('blackcatp:/')){ const user_prefix = `${store.getters.config.website}/u/`;
console.log(res.result,user_prefix)
if(res.result.startsWith(user_prefix)){
return uni.navigateTo({
url:"/pages/common/userCard/index?sourceID="+res.result.replace(user_prefix,'')
});
}
const group_prefix = `${store.getters.config.website}/g/`;
console.log(res.result,group_prefix)
if(res.result.startsWith(group_prefix)){
return uni.navigateTo({
url:"/pages/common/groupCard/index?sourceID="+res.result.replace(group_prefix,'')
});
}
if(res.result.startsWith("http")){
uni.navigateTo({ uni.navigateTo({
url:res.result.substring(11) url:"/pages/common/webview?url="+encodeURIComponent(res.result)
}) });
}else{ //res.result;
success(res.result) return ;
} }
} }
}, },
fail(res){ fail(res){
},
complete(res){
console.log(res) console.log(res)
} }
}); });
@@ -234,6 +246,11 @@ const get_absolute_path = (fn)=>{
} }
const pendingDownloads = new Map(); const pendingDownloads = new Map();
const cacheFile = (url, saveDir,progressCallback) => { const cacheFile = (url, saveDir,progressCallback) => {
// #ifndef APP
return new Promise(async (resolve, reject) => {
resolve(url);
});
// #endif
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
if(!url || !url.startsWith('http')){ if(!url || !url.startsWith('http')){
@@ -443,7 +460,9 @@ export default{
cacheFile, cacheFile,
fileExsit, fileExsit,
get_absolute_path, get_absolute_path,
// #ifdef APP
downloadFile, downloadFile,
// #endif
isString :isString, isString :isString,
isNumber :isNumber, isNumber :isNumber,
isInteger :isInteger, isInteger :isInteger,