This commit is contained in:
2025-11-21 01:20:28 +08:00
parent d9d7ddc05d
commit ff026c6f32
7 changed files with 822 additions and 824 deletions
+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 = '110.42.52.196' const BASE_DOMAIN = '156.238.245.175'
// 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`
+288 -289
View File
@@ -1,290 +1,289 @@
{ {
"pages": [ "pages": [
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/login/index" "path": "pages/login/index"
}, },
{ {
"path": "pages/login/registerOrForget/index" "path": "pages/login/registerOrForget/index"
}, },
{ {
"path": "pages/login/setSelfInfo/index" "path": "pages/login/setSelfInfo/index"
}, },
{ {
"path": "pages/login/setPassword/index" "path": "pages/login/setPassword/index"
}, },
{ {
"path": "pages/login/verifyCode/index" "path": "pages/login/verifyCode/index"
}, },
{ {
"path": "pages/profile/index/index" "path": "pages/profile/index/index"
}, },
{ {
"path": "pages/conversation/conversationList/index", "path": "pages/conversation/conversationList/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"disableScroll": true, "disableScroll": true,
"app-plus": { "app-plus": {
"bounce": "none" "bounce": "none"
} }
} }
}, },
{ {
"path": "pages/contact/index/index", "path": "pages/contact/index/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"disableScroll": true, "disableScroll": true,
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/conversation/chating/index", "path": "pages/conversation/chating/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"disableScroll": true, "disableScroll": true,
"app-plus": { "app-plus": {
"softinputMode": "adjustResize" "softinputMode": "adjustResize"
} }
} }
}, },
{ {
"path": "pages/conversation/singleSettings/index", "path": "pages/conversation/singleSettings/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/conversation/groupSettings/index", "path": "pages/conversation/groupSettings/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/conversation/groupManage/index", "path": "pages/conversation/groupManage/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/conversation/groupMemberList/index", "path": "pages/conversation/groupMemberList/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/userCard/index", "path": "pages/common/userCard/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/searchUserOrGroup/index", "path": "pages/common/searchUserOrGroup/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/groupCard/index", "path": "pages/common/groupCard/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/userCardMore/index", "path": "pages/common/userCardMore/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/markOrIDPage/index", "path": "pages/common/markOrIDPage/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/detailsFileds/index", "path": "pages/common/detailsFileds/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/contactChoose/index", "path": "pages/common/contactChoose/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"disableScroll": true "disableScroll": true
} }
}, },
{ {
"path": "pages/common/createGroup/index", "path": "pages/common/createGroup/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/contact/contactAdd/index", "path": "pages/contact/contactAdd/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/contact/switchJoinGroup/index", "path": "pages/contact/switchJoinGroup/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/contact/friendList/index", "path": "pages/contact/friendList/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/contact/groupList/index", "path": "pages/contact/groupList/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/contact/searchUserOrGroup/index", "path": "pages/contact/searchUserOrGroup/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/contact/applicationList/index", "path": "pages/contact/applicationList/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/contact/applicationListDetails/index", "path": "pages/contact/applicationListDetails/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/contact/applicationDetails/index", "path": "pages/contact/applicationDetails/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/profile/selfInfo/index", "path": "pages/profile/selfInfo/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/profile/accountSetting/index", "path": "pages/profile/accountSetting/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/profile/blockList/index", "path": "pages/profile/blockList/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/conversation/updateGroupOrNickname/index", "path": "pages/conversation/updateGroupOrNickname/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/sendAddRequest/index", "path": "pages/common/sendAddRequest/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/common/webviewWrapper/index", "path": "pages/common/webviewWrapper/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/profile/about/index", "path": "pages/profile/about/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ {
"path": "pages/workbench/index/index", "path": "pages/workbench/index/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
} }
], ],
"tabBar": { "tabBar": {
"color": "#8E9AB0", "color": "#8E9AB0",
"selectedColor": "#0089FF", "selectedColor": "#0089FF",
"borderStyle": "black", "borderStyle": "black",
"backgroundColor": "#ffffff", "backgroundColor": "#ffffff",
"height": "55px", "height": "55px",
"list": [ "list": [{
{ "pagePath": "pages/conversation/conversationList/index",
"pagePath": "pages/conversation/conversationList/index", "iconPath": "./static/images/tabbar_conversation.png",
"iconPath": "./static/images/tabbar_conversation.png", "selectedIconPath": "static/images/tabbar_conversation_active.png",
"selectedIconPath": "static/images/tabbar_conversation_active.png", "text": "OpenIM"
"text": "OpenIM" },
}, {
{ "pagePath": "pages/contact/index/index",
"pagePath": "pages/contact/index/index", "iconPath": "./static/images/tabbar_contacts.png",
"iconPath": "./static/images/tabbar_contacts.png", "selectedIconPath": "static/images/tabbar_contacts_active.png",
"selectedIconPath": "static/images/tabbar_contacts_active.png", "text": "通讯录"
"text": "通讯录" },
}, {
{ "pagePath": "pages/workbench/index/index",
"pagePath": "pages/workbench/index/index", "iconPath": "./static/images/tabbar_workbench.png",
"iconPath": "./static/images/tabbar_workbench.png", "selectedIconPath": "static/images/tabbar_workbench_active.png",
"selectedIconPath": "static/images/tabbar_workbench_active.png", "text": "发现"
"text": "发现" },
}, {
{ "pagePath": "pages/profile/index/index",
"pagePath": "pages/profile/index/index", "iconPath": "./static/images/tabbar_profile.png",
"iconPath": "./static/images/tabbar_profile.png", "selectedIconPath": "static/images/tabbar_profile_active.png",
"selectedIconPath": "static/images/tabbar_profile_active.png", "text": "我的"
"text": "我的" }
} ]
] },
}, "globalStyle": {
"globalStyle": { "navigationStyle": "custom",
"navigationStyle": "custom", "navigationBarTextStyle": "black",
"navigationBarTextStyle": "black", "app-plus": {
"app-plus": { "bounce": "none"
"bounce": "none" }
} }
} }
}
+146 -155
View File
@@ -1,172 +1,163 @@
<template> <template>
<view class="search_container"> <view class="search_container">
<custom-nav-bar :route="false"> <custom-nav-bar :route="false">
<view slot="left"> </view> <view slot="left"> </view>
<view class="search_bar" slot="center"> <view class="search_bar" slot="center">
<u-search <u-search actionText="取消" @change="keywordChange" @custom="cancel" @search="startSearch" shape="square"
actionText="取消" :placeholder="getPlaceholder" v-model="keyword" />
@change="keywordChange" </view>
@custom="cancel" </custom-nav-bar>
@search="startSearch"
shape="square"
:placeholder="getPlaceholder"
v-model="keyword"
/>
</view>
</custom-nav-bar>
<view v-show="!empty && !searching" @click="startSearch(keyword)" class="result_row"> <view v-show="!empty && !searching" @click="startSearch(keyword)" class="result_row">
<image class="icon" :src="getIcon" alt="" /> <image class="icon" :src="getIcon" alt="" />
<view class=""> <view class="">
<text>查找</text> <text>查找</text>
<text>{{ keyword }}</text> <text>{{ keyword }}</text>
</view> </view>
</view> </view>
<view v-show="searching && !empty" class="result_row result_row_empty"> <view v-show="searching && !empty" class="result_row result_row_empty">
<u-loading-icon></u-loading-icon> <u-loading-icon></u-loading-icon>
</view> </view>
<view v-show="empty" class="result_row result_row_empty"> <view v-show="empty" class="result_row result_row_empty">
<text>未搜索到相关结果</text> <text>未搜索到相关结果</text>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import IMSDK from "openim-uniapp-polyfill"; import IMSDK from "openim-uniapp-polyfill";
import CustomNavBar from "@/components/CustomNavBar/index.vue"; import CustomNavBar from "@/components/CustomNavBar/index.vue";
import searchGroup from "static/images/contact_add_join_group_fill.png"; import searchGroup from "static/images/contact_add_join_group_fill.png";
import searchUser from "static/images/contact_add_search_user_fill.png"; import searchUser from "static/images/contact_add_search_user_fill.png";
import { businessSearchUserInfo } from "@/api/login"; import {
businessSearchUserInfo
} from "@/api/login";
export default { export default {
components: { components: {
CustomNavBar, CustomNavBar,
}, },
data() { data() {
return { return {
keyword: "", keyword: "",
searching: false, searching: false,
empty: false, empty: false,
isSearchGroup: false, isSearchGroup: false,
}; };
}, },
computed: { computed: {
getIcon() { getIcon() {
return this.isSearchGroup ? searchGroup : searchUser; return this.isSearchGroup ? searchGroup : searchUser;
}, },
getPlaceholder() { getPlaceholder() {
return this.isSearchGroup ? "请输入群聊ID" : "搜索ID或手机号添加好友"; return this.isSearchGroup ? "请输入群聊ID" : "搜索ID或手机号添加好友";
}, },
}, },
onLoad(options) { onLoad(options) {
const { isSearchGroup } = options; const {isSearchGroup} = options;
this.isSearchGroup = JSON.parse(isSearchGroup); this.isSearchGroup = JSON.parse(isSearchGroup);
}, },
methods: { methods: {
cancel() { cancel() {
console.log("cancel"); console.log("cancel");
uni.navigateBack(); uni.navigateBack();
}, },
keywordChange() { keywordChange() {
if (this.empty) { if (this.empty) {
this.empty = !this.empty; this.empty = !this.empty;
} }
}, },
async startSearch(value) { async startSearch(value) {
if (!value) return; if (!value) return;
this.searching = true; this.searching = true;
try { try {
if (this.isSearchGroup) { if (this.isSearchGroup) {
let info = this.$store.getters.storeGroupList.find( let info = this.$store.getters.storeGroupList.find(
(item) => item.groupID === value, (item) => item.groupID === value,
); );
if (!info) { if (!info) {
const { data } = await IMSDK.asyncApi( const {data} = await IMSDK.asyncApi(
IMSDK.IMMethods.GetSpecifiedGroupsInfo, IMSDK.IMMethods.GetSpecifiedGroupsInfo,
IMSDK.uuid(), IMSDK.uuid(),
[value], [value],
); );
info = data[0]; info = data[0];
} }
if (info) { if (info) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/groupCard/index?sourceInfo=${JSON.stringify( url: `/pages/common/groupCard/index?sourceInfo=${JSON.stringify(info,)}`,
info, });
)}`, } else {
}); this.empty = true;
} else { }
this.empty = true; } else {
} let info = this.$store.getters.storeFriendList.find(
} else { (item) => item.userID === value,
let info = this.$store.getters.storeFriendList.find( );
(item) => item.userID === value, if (!info) {
); const {total,users} = await businessSearchUserInfo(value);
if (!info) { if (total > 0) {
const { total, users } = await businessSearchUserInfo(value); const {data} = await IMSDK.asyncApi(
if (total > 0) { IMSDK.IMMethods.GetUsersInfo,
const { data } = await IMSDK.asyncApi( IMSDK.uuid(),
IMSDK.IMMethods.GetUsersInfo, [users[0].userID],
IMSDK.uuid(), );
[users[0].userID], const imData = data[0];
);
const imData = data[0];
info = { info = {
...imData, ...imData,
...users[0], ...users[0],
}; };
} }
} }
if (info) { if (info) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/userCard/index?sourceInfo=${JSON.stringify( url: `/pages/common/userCard/index?sourceInfo=${JSON.stringify(info,)}`,
info, });
)}`, } else {
}); this.empty = true;
} else { }
this.empty = true; }
} } catch (e) {
} //TODO handle the exception
} catch (e) { }
//TODO handle the exception this.searching = false;
} },
this.searching = false; },
}, };
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.search_container { .search_container {
height: 100vh; height: 100vh;
background-color: #f8f8f8; background-color: #f8f8f8;
.search_bar { .search_bar {
width: 100%; width: 100%;
padding: 0 44rpx; padding: 0 44rpx;
} }
.result_row { .result_row {
@include vCenterBox(); @include vCenterBox();
padding: 24rpx 44rpx; padding: 24rpx 44rpx;
font-size: 28rpx; font-size: 28rpx;
color: $uni-text-color; color: $uni-text-color;
background-color: #fff; background-color: #fff;
.icon { .icon {
width: 20px; width: 20px;
height: 20px; height: 20px;
margin-right: 24rpx; margin-right: 24rpx;
} }
&_empty { &_empty {
display: flex; display: flex;
justify-content: center; justify-content: center;
color: #999; color: #999;
} }
} }
} }
</style> </style>
+2 -1
View File
@@ -5,7 +5,8 @@
<view v-if="!isLoading" style="flex: 1;display: flex;flex-direction: column;"> <view v-if="!isLoading" style="flex: 1;display: flex;flex-direction: column;">
<view class="base_info"> <view class="base_info">
<my-avatar :desc="sourceUserInfo.remark || sourceUserInfo.nickname" :src="sourceUserInfo.faceURL" size="46" /> <my-avatar :desc="sourceUserInfo.remark || sourceUserInfo.nickname" :src="sourceUserInfo.faceURL"
size="46" />
<view class="user_name"> <view class="user_name">
<text class="text">{{ getShowName }}</text> <text class="text">{{ getShowName }}</text>
<text class="id" @click="copy(sourceUserInfo.userID)">{{sourceUserInfo.userID}}</text> <text class="id" @click="copy(sourceUserInfo.userID)">{{sourceUserInfo.userID}}</text>
+207 -215
View File
@@ -1,238 +1,230 @@
<template> <template>
<view class="page_container"> <view class="page_container">
<view class="self_info_row"></view> <view class="self_info_row"></view>
<view class="info_card"> <view class="info_card">
<my-avatar :src="selfInfo.faceURL" :desc="selfInfo.nickname" size="46" /> <my-avatar :src="selfInfo.faceURL" :desc="selfInfo.nickname" size="46" />
<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 <image style="width: 32rpx; height: 32rpx" src="@/static/images/id_copy.png" mode="" />
style="width: 32rpx; height: 32rpx" </view>
src="@/static/images/id_copy.png" </view>
mode=""
/>
</view>
</view>
<view class="qr" @click="toSelfQr"> <view class="qr" @click="toSelfQr">
<img src="static/images/self_info_qr.png" alt="" /> <img src="static/images/self_info_qr.png" alt="" />
<img src="static/images/common_right.png" alt="" /> <img src="static/images/common_right.png" alt="" />
</view> </view>
</view> </view>
<view class="action_box"> <view class="action_box">
<view <view @click="profileMenuClick(item)" class="profile_menu_item" v-for="item in profileMenus"
@click="profileMenuClick(item)" :key="item.idx">
class="profile_menu_item" <view class="menu_left">
v-for="item in profileMenus" <image style="width: 48rpx; height: 48rpx" :src="item.icon" mode="" />
:key="item.idx" <text>{{ item.title }}</text>
> </view>
<view class="menu_left"> <u-icon name="arrow-right" size="16" color="#999"></u-icon>
<image style="width: 48rpx; height: 48rpx" :src="item.icon" mode="" /> </view>
<text>{{ item.title }}</text> </view>
</view>
<u-icon name="arrow-right" size="16" color="#999"></u-icon>
</view>
</view>
<u-toast ref="uToast"></u-toast> <u-toast ref="uToast"></u-toast>
</view> </view>
</template> </template>
<script> <script>
import IMSDK from "openim-uniapp-polyfill"; import IMSDK from "openim-uniapp-polyfill";
import MyAvatar from "@/components/MyAvatar/index.vue"; import MyAvatar from "@/components/MyAvatar/index.vue";
export default { export default {
components: { components: {
MyAvatar, MyAvatar,
}, },
data() { data() {
return { return {
profileMenus: [ profileMenus: [{
{ idx: 0,
idx: 0, title: "我的信息",
title: "我的信息", icon: require("static/images/profile_menu_info.png"),
icon: require("static/images/profile_menu_info.png"), },
}, {
{ idx: 2,
idx: 2, title: "账号设置",
title: "账号设置", icon: require("static/images/profile_menu_account.png"),
icon: require("static/images/profile_menu_account.png"), },
}, {
{ idx: 3,
idx: 3, title: "关于我们",
title: "关于我们", icon: require("static/images/profile_menu_about.png"),
icon: require("static/images/profile_menu_about.png"), },
}, {
{ idx: 4,
idx: 4, title: "退出登录",
title: "退出登录", icon: require("static/images/profile_menu_logout.png"),
icon: require("static/images/profile_menu_logout.png"), },
}, ],
], };
}; },
}, computed: {
computed: { selfInfo() {
selfInfo() { return this.$store.getters.storeSelfInfo;
return this.$store.getters.storeSelfInfo; },
}, },
}, methods: {
methods: { copy() {
copy() { console.log(this.selfInfo)
uni.setClipboardData({ uni.setClipboardData({
showToast: false, showToast: false,
data: this.selfInfo.userID, data: this.selfInfo.userID,
success: function () { success: function() {
uni.showToast({ uni.showToast({
icon: "none", icon: "none",
title: "复制成功", title: "复制成功",
}); });
}, },
}); });
}, },
logoutConfirm() { logoutConfirm() {
IMSDK.asyncApi(IMSDK.IMMethods.Logout, IMSDK.uuid()) IMSDK.asyncApi(IMSDK.IMMethods.Logout, IMSDK.uuid())
.then(() => { .then(() => {
uni.removeStorage({ uni.removeStorage({
key: "IMToken", key: "IMToken",
}); });
uni.removeStorage({ uni.removeStorage({
key: "BusinessToken", key: "BusinessToken",
}); });
}) })
.catch((err) => console.log(err)) .catch((err) => console.log(err))
.finally(() => { .finally(() => {
uni.$u.route("/pages/login/index"); uni.$u.route("/pages/login/index");
}); });
}, },
profileMenuClick({ idx }) { profileMenuClick({idx}) {
switch (idx) { switch (idx) {
case 0: case 0:
uni.navigateTo({ uni.navigateTo({
url: "/pages/profile/selfInfo/index", url: "/pages/profile/selfInfo/index",
}); });
break; break;
case 1: case 1:
uni.navigateTo({ uni.navigateTo({
url: "/pages/profile/messageNotification/index", url: "/pages/profile/messageNotification/index",
}); });
break; break;
case 2: case 2:
uni.navigateTo({ uni.navigateTo({
url: "/pages/profile/accountSetting/index", url: "/pages/profile/accountSetting/index",
}); });
break; break;
case 3: case 3:
uni.navigateTo({ uni.navigateTo({
url: "/pages/profile/about/index", url: "/pages/profile/about/index",
}); });
break; break;
case 4: case 4:
uni.showModal({ uni.showModal({
title: "提示", title: "提示",
content: "确定要退出当前账号吗?", content: "确定要退出当前账号吗?",
confirmText: "确认", confirmText: "确认",
cancelText: "取消", cancelText: "取消",
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
this.logoutConfirm(); this.logoutConfirm();
} }
}, },
}); });
break; break;
default: default:
break; break;
} }
}, },
toSelfQr() { toSelfQr() {
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/userOrGroupQrCode/index`, url: `/pages/common/userOrGroupQrCode/index`,
}); });
}, },
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.page_container { .page_container {
background-color: #f8f9fa; background-color: #f8f9fa;
.self_info_row { .self_info_row {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
width: 100%; width: 100%;
height: 276rpx; height: 276rpx;
background-image: url("@/static/images/profile_top_bg.png"); background-image: url("@/static/images/profile_top_bg.png");
background-repeat: round; background-repeat: round;
} }
.info_card { .info_card {
width: 640rpx; width: 640rpx;
height: 196rpx; height: 196rpx;
border-radius: 6px; border-radius: 6px;
background: #fff; background: #fff;
margin: -120rpx auto 0 auto; margin: -120rpx auto 0 auto;
padding: 0 36rpx; padding: 0 36rpx;
color: #0c1c33; color: #0c1c33;
display: flex; display: flex;
align-items: center; align-items: center;
.id_row { .id_row {
@include vCenterBox(); @include vCenterBox();
display: flex; display: flex;
height: 46px; height: 46px;
margin-left: 16rpx; margin-left: 16rpx;
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: flex-start;
justify-content: space-between; justify-content: space-between;
flex: 1; flex: 1;
font-size: 28rpx; font-size: 28rpx;
&_copy { &_copy {
@include vCenterBox(); @include vCenterBox();
} }
.nickname { .nickname {
@include nomalEllipsis(); @include nomalEllipsis();
max-width: 400rpx; max-width: 400rpx;
font-weight: 500; font-weight: 500;
font-size: 34rpx; font-size: 34rpx;
} }
.id { .id {
color: #8e9ab0; color: #8e9ab0;
} }
} }
img { img {
width: 18px; width: 18px;
height: 18px; height: 18px;
} }
} }
.action_box { .action_box {
margin: 24rpx 24rpx 0 24rpx; margin: 24rpx 24rpx 0 24rpx;
background: #fff; background: #fff;
border-radius: 6px; border-radius: 6px;
} }
.profile_menu_item { .profile_menu_item {
@include btwBox(); @include btwBox();
padding: 24rpx 36rpx; padding: 24rpx 36rpx;
.menu_left { .menu_left {
@include vCenterBox(); @include vCenterBox();
color: $uni-text-color; color: $uni-text-color;
image { image {
margin-right: 24rpx; margin-right: 24rpx;
} }
} }
} }
} }
</style> </style>
+107 -100
View File
@@ -1,112 +1,119 @@
import { v4 as uuidv4 } from "uuid"; import {
v4 as uuidv4
} from "uuid";
import IMSDK from "openim-uniapp-polyfill"; import IMSDK from "openim-uniapp-polyfill";
const state = { const state = {
conversationList: [], conversationList: [],
currentConversation: {}, currentConversation: {},
unReadCount: 0, unReadCount: 0,
currentGroup: {}, currentGroup: {},
currentMemberInGroup: {}, currentMemberInGroup: {},
}; };
const mutations = { const mutations = {
SET_CONVERSATION_LIST(state, list) { SET_CONVERSATION_LIST(state, list) {
state.conversationList = [...list]; state.conversationList = [...list];
}, },
SET_CURRENT_CONVERSATION(state, conversation) { SET_CURRENT_CONVERSATION(state, conversation) {
state.currentConversation = { state.currentConversation = {
...conversation, ...conversation,
}; };
}, },
SET_UNREAD_COUNT(state, count) { SET_UNREAD_COUNT(state, count) {
if (count) { if (count) {
uni.setTabBarBadge({ uni.setTabBarBadge({
index: 0, index: 0,
text: count < 99 ? count + "" : "99+", text: count < 99 ? count + "" : "99+",
}); });
} else { } else {
uni.removeTabBarBadge({ uni.removeTabBarBadge({
index: 0, index: 0,
}); });
} }
state.unReadCount = count; state.unReadCount = count;
}, },
SET_CURRENT_GROUP(state, group) { SET_CURRENT_GROUP(state, group) {
state.currentGroup = { state.currentGroup = {
...group, ...group,
}; };
}, },
SET_CURRENT_MEMBER_IN_GROUP(state, member) { SET_CURRENT_MEMBER_IN_GROUP(state, member) {
state.currentMemberInGroup = { state.currentMemberInGroup = {
...member, ...member,
}; };
}, },
}; };
const actions = { const actions = {
async getConversationList({ state, commit }, isFirstPage = true) { async getConversationList({ state, commit }, isFirstPage = true) {
try { try {
const { data } = await IMSDK.asyncApi( const {
IMSDK.IMMethods.GetConversationListSplit, data
uuidv4(), } = await IMSDK.asyncApi(
{ IMSDK.IMMethods.GetConversationListSplit,
offset: isFirstPage ? 0 : state.conversationList.length, uuidv4(), {
count: 500, offset: isFirstPage ? 0 : state.conversationList.length,
}, count: 500,
); },
commit("SET_CONVERSATION_LIST", [ );
...(isFirstPage ? [] : state.conversationList), commit("SET_CONVERSATION_LIST", [
...data, ...(isFirstPage ? [] : state.conversationList),
]); ...data,
return [...data]; ]);
} catch (e) { return [...data];
console.log(e); } catch (e) {
commit("SET_CONVERSATION_LIST", []); console.log(e);
return []; commit("SET_CONVERSATION_LIST", []);
} return [];
}, }
getCurrentGroup({ commit }, groupID) { },
IMSDK.asyncApi(IMSDK.IMMethods.GetSpecifiedGroupsInfo, uuidv4(), [ getCurrentGroup({ commit }, groupID) {
groupID, IMSDK.asyncApi(IMSDK.IMMethods.GetSpecifiedGroupsInfo, uuidv4(), [
]).then(({ data }) => { groupID,
commit("SET_CURRENT_GROUP", data[0] ?? {}); ]).then(({
}); data
}, }) => {
getCurrentMemberInGroup({ commit, rootState }, groupID) { commit("SET_CURRENT_GROUP", data[0] ?? {});
IMSDK.asyncApi(IMSDK.IMMethods.GetSpecifiedGroupMembersInfo, uuidv4(), { });
groupID, },
userIDList: [rootState.user.selfInfo.userID], getCurrentMemberInGroup({ commit, rootState }, groupID) {
}).then(({ data }) => { IMSDK.asyncApi(IMSDK.IMMethods.GetSpecifiedGroupMembersInfo, uuidv4(), {
commit("SET_CURRENT_MEMBER_IN_GROUP", data[0] ?? {}); groupID,
}); userIDList: [rootState.user.selfInfo.userID],
}, }).then(({
getUnReadCount({ commit }) { data
IMSDK.asyncApi(IMSDK.IMMethods.GetTotalUnreadMsgCount, uuidv4()).then( }) => {
(res) => { commit("SET_CURRENT_MEMBER_IN_GROUP", data[0] ?? {});
console.log(res); });
commit("SET_UNREAD_COUNT", res.data); },
}, getUnReadCount({ commit }) {
); IMSDK.asyncApi(IMSDK.IMMethods.GetTotalUnreadMsgCount, uuidv4()).then(
}, (res) => {
updateCurrentMemberInGroup({ commit, state }, memberInfo) { console.log(res);
console.log(memberInfo); commit("SET_UNREAD_COUNT", res.data);
if ( },
memberInfo.groupID === state.currentMemberInGroup.groupID && );
memberInfo.userID === state.currentMemberInGroup.userID },
) { updateCurrentMemberInGroup({ commit, state }, memberInfo) {
commit("SET_CURRENT_MEMBER_IN_GROUP", memberInfo); console.log(memberInfo);
} if (
}, memberInfo.groupID === state.currentMemberInGroup.groupID &&
resetConversationState({ commit }) { memberInfo.userID === state.currentMemberInGroup.userID
commit("SET_CURRENT_MEMBER_IN_GROUP", {}); ) {
commit("SET_CURRENT_GROUP", {}); commit("SET_CURRENT_MEMBER_IN_GROUP", memberInfo);
commit("SET_CURRENT_CONVERSATION", {}); }
}, },
resetConversationState({ commit }) {
commit("SET_CURRENT_MEMBER_IN_GROUP", {});
commit("SET_CURRENT_GROUP", {});
commit("SET_CURRENT_CONVERSATION", {});
},
}; };
export default { export default {
namespaced: true, namespaced: true,
state, state,
mutations, mutations,
actions, actions,
}; };
+71 -63
View File
@@ -1,75 +1,83 @@
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4} from "uuid";
import IMSDK from "openim-uniapp-polyfill"; import IMSDK from "openim-uniapp-polyfill";
import { businessGetUserInfo } from "@/api/login"; import { businessGetUserInfo} from "@/api/login";
import { filterEmptyValue } from "@/util/common"; import { filterEmptyValue} from "@/util/common";
const state = { const state = {
selfInfo: {}, selfInfo: {},
authData: {}, authData: {},
isSyncing: false, isSyncing: false,
reinstall: false, reinstall: false,
progress: 0, progress: 0,
}; };
const mutations = { const mutations = {
SET_SELF_INFO(state, info) { SET_SELF_INFO(state, info) {
state.selfInfo = { state.selfInfo = {
...info, ...info,
}; };
}, },
SET_AUTH_DATA(state, data) { SET_AUTH_DATA(state, data) {
state.authData = { state.authData = {
...data, ...data,
}; };
}, },
SET_IS_SYNCING(state, data) { SET_IS_SYNCING(state, data) {
state.isSyncing = data; state.isSyncing = data;
}, },
SET_REINSTALL(state, data) { SET_REINSTALL(state, data) {
state.reinstall = data; state.reinstall = data;
}, },
SET_PROGRESS(state, data) { SET_PROGRESS(state, data) {
state.progress = data; state.progress = data;
}, },
}; };
const actions = { const actions = {
async getSelfInfo({ commit }) { async getSelfInfo({ commit }) {
try { try {
const { data } = await IMSDK.asyncApi( const {
IMSDK.IMMethods.GetSelfUserInfo, data
uuidv4(), } = await IMSDK.asyncApi(
); IMSDK.IMMethods.GetSelfUserInfo,
const { users } = await businessGetUserInfo(data.userID); uuidv4(),
const businessData = users[0] ?? {}; );
filterEmptyValue(businessData); const {users} = await businessGetUserInfo(data.userID);
commit("SET_SELF_INFO", { console.log(users);
...data, const businessData = users[0] ?? {};
...businessData, filterEmptyValue(businessData);
}); commit("SET_SELF_INFO", {
} catch (e) { ...data,
console.log(e); ...businessData,
uni.$u.toast("获取个人信息失败"); });
} } catch (e) {
}, console.log(e);
async updateBusinessInfo({ commit, state }) { uni.$u.toast("获取个人信息失败");
try { }
const { users } = await businessGetUserInfo(state.selfInfo.userID); },
const businessData = users[0] ?? {}; async updateBusinessInfo({
filterEmptyValue(businessData); commit,
commit("SET_SELF_INFO", { state
...state.selfInfo, }) {
...businessData, try {
}); const {
} catch (e) { users
console.log(e); } = await businessGetUserInfo(state.selfInfo.userID);
} const businessData = users[0] ?? {};
}, filterEmptyValue(businessData);
commit("SET_SELF_INFO", {
...state.selfInfo,
...businessData,
});
} catch (e) {
console.log(e);
}
},
}; };
export default { export default {
namespaced: true, namespaced: true,
state, state,
mutations, mutations,
actions, actions,
}; };