This commit is contained in:
cansnow
2025-12-05 16:10:52 +08:00
parent 29be534f22
commit 69a61178e1
64 changed files with 2575 additions and 1141 deletions
+16 -27
View File
@@ -10,25 +10,30 @@
export default {
onLaunch: function() {
console.log("App Launch");
this.checkUpdate();
this.setGlobalIMlistener();
this.tryLogin();
// #ifdef H5
console.error(
`暂时不支持运行到 Web,如果需要移动端的 Web 项目,参考 [H5 demo](https://github.com/openimsdk/openim-h5-demo)`
);
return ;
// #endif
// #ifdef MP-WEIXIN
console.error(`暂时不支持运行到小程序端`);
// #endif
this.checkUpdate();
this.setGlobalIMlistener();
this.tryLogin();
},
onShow: function() {
console.log("App Show");
// #ifdef APP
IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), false);
// #endif
},
onHide: function() {
console.log("App Hide");
// #ifdef APP
IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), true);
// #endif
},
computed: {
...mapGetters([
@@ -269,25 +274,15 @@
return;
}
let filterArr = [];
console.log(data);
//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]
);
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)
);
this.$store.commit("conversation/SET_CONVERSATION_LIST",conversationSort(result));
};
IMSDK.subscribe(IMSDK.IMEvents.OnTotalUnreadMessageCountChanged,totalUnreadCountChangedHandler);
@@ -308,13 +303,7 @@
this.$store.dispatch("contact/getFriendList");
this.$store.dispatch("circle/getFriendCircleInfo");
uni.switchTab({
url: "/pages/conversation/conversationList/index?isRedirect=true",
success() {
// uni.navigateTo({
// url:'/pages/workbench/friend-circle/friend-circle'
// })
}
url: "/pages/conversation/conversationList/index?isRedirect=true"
});
};
getDbDir()
+119 -248
View File
@@ -1,248 +1,119 @@
<p align="center">
<a href="https://openim.io">
<img n1e5a6s6m7 src="./docs/images/logo.jpg" width="60%" height="30%"/>
</a>
</p>
# OpenIM Uniapp 💬💻
<p>
<a href="https://docs.openim.io/">OpenIM Docs</a>
<a href="https://github.com/openimsdk/open-im-server">OpenIM Server</a>
<a href="https://github.com/openimsdk/open-im-sdk-uniapp">open-im-sdk-uniapp</a>
<a href="https://github.com/openimsdk/openim-sdk-core">openim-sdk-core</a>
</p>
OpenIM 为开发者提供开源即时通讯 SDK,作为 Twilio、Sendbird 等云服务的替代方案。借助 OpenIM,开发者可以构建安全可靠的即时通讯应用,如 WeChat、Zoom、Slack 等。
本仓库基于开源版 OpenIM SDK 开发,提供了一款基于 uniapp 的即时通讯应用。您可以使用此应用程序作为 OpenIM SDK 的参考实现。本项目引用了 `openim-uniapp-polyfill`,可以构建安卓程序和 iOS 程序。
<p align="center">
<img src="./docs/images/preview1.png" alt="Preview" width="32%"/>
<span style="display: inline-block; width: 16px;"></span>
<img src="./docs/images/preview2.png" alt="Preview" width="32%"/>
</p>
## 授权许可 :page_facing_up:
本仓库采用 GNU Affero 通用公共许可证第 3 版 (AGPL-3.0) 进行许可,并受以下附加条款的约束。**不允许用于商业用途**。详情请参阅 [此处](./LICENSE)。
## 开发环境
在开始开发之前,请确保您的系统已安装以下软件:
- **HBuilderX**:最新版本
- **Node.js**:版本 ≥ 16.x[手动安装](https://nodejs.org/dist/latest-v20.x/) 或使用 [nvm](https://github.com/nvm-sh/nvm) 进行版本管理)
- **npm**:版本 ≥ 6.x(随 Node.js 一起安装)
- **Git**:用于代码版本控制
同时,您需要确保已经[部署](https://docs.openim.io/zh-Hans/guides/gettingStarted/dockerCompose)了最新版本的 OpenIM Server。接下来,您可以编译项目并连接自己的服务端进行测试。
## 运行环境
本应用支持以下操作系统版本:
| 浏览器/操作系统 | 版本 | 状态 |
| --------------- | ----------------- | ---- |
| **iOS** | 13.0 及以上 | ✅ |
| **Android** | 24 及以上 | ✅ |
### 说明
- `只支持` Uniapp 打包成 Android/iOS 应用。并且 SDK 也暂未支持 UniappX (开发中)。
- 暂时 `不支持` 运行到 Web,如果需要移动端的 Web 项目,参考 [H5 demo](https://github.com/openimsdk/openim-h5-demo)。
- 暂时 `不支持` 运行到小程序端。
- 暂时 `不支持` 一对一音视频。如果需要使用,可以运行其他仓库的项目。
## 快速开始
按照以下步骤设置本地开发环境:
1. 拉取代码
```bash
git clone https://github.com/openimsdk/open-im-uniapp-demo.git
cd open-im-uniapp-demo
```
2. 安装依赖
```bash
npm install
```
3. 修改配置
- `common/config.js`
> 如果没有修改过服务端默认端口,则只需要修改`BASE_HOST`为您的服务器 ip 即可,如需配置域名和 https 访问,可以参考[nginx 配置](https://docs.openim.io/zh-Hans/guides/gettingStarted/nginxDomainConfig),并采用最下方的配置项,并修改`BASE_DOMAIN`为您的域名。
```javascript
const BASE_HOST = 'your-server-ip'
const CHAT_URL = `http://${BASE_HOST}:10008`
const API_URL = `http://${BASE_HOST}:10002`
const WS_URL = `ws://${BASE_HOST}:10001`
// const BASE_DOMAIN = 'your-server-domain'
// const CHAT_URL = `http://${BASE_DOMAIN}/chat`
// const API_URL = `http://${BASE_DOMAIN}/api`
// const WS_URL = `ws://${BASE_DOMAIN}/msg_gateway`
```
4. 修改为您自己的 AppID
- 使用 Hbuilder 打开 manifest.json
![](./docs/images/appid.png)
5. 导入原生插件
- 使用 Hbuilder 打开 manifest.json
![](./docs/images/plugin.png)
- 选择云插件需要选择您的项目 Appid 和输入 Android 包名称
![](./docs/images/download.png)
6. 云打包自定义调试基座
- 菜单 -> 运行 -> 运行到手机或模拟器 -> 制作自定义调试基座 (使用自己的包名)
![](./docs/images/dev.png)
7. 在真实的机器或模拟器上运行 ( iOS 仅支持在真机调试 )
- 菜单 -> 运行 -> 运行到手机或模拟器 -> 运行到Android App基座
![](./docs/images/run_dev.png)
8. 开始开发测试! 🎉
## 音视频通话
一对一音视频通话,多人音视频通话、视频会议请联系邮箱 [contact@openim.io](mailto:contact@openim.io)
## 构建 🚀
### 使用原生App 云打包
- 菜单 -> 发行 -> 原生App-云打包
![](./docs/images/build.png)
## 功能列表
### 说明
| 功能模块 | 功能项 | 状态 |
| ------------------ | --------------------------------------------------------- | ---- |
| **账号功能** | 手机号注册\邮箱注册\验证码登录 | ✅ |
| | 个人信息查看\修改 | ✅ |
| | 修改密码\忘记密码 | ✅ |
| **好友功能** | 查找\申请\搜索\添加\删除好友 | ✅ |
| | 同意\拒绝好友申请 | ✅ |
| | 好友备注 | ✅ |
| | 是否允许添加好友 | ✅ |
| | 好友列表\好友资料实时同步 | ✅ |
| **黑名单功能** | 限制消息 | ✅ |
| | 黑名单列表实时同步 | ✅ |
| | 添加\移出黑名单 | ✅ |
| **群组功能** | 创建\解散群组 | ✅ |
| | 申请加群\邀请加群\退出群组\移除群成员 | ✅ |
| | 群名/群头像更改/群资料变更通知和实时同步 | ✅ |
| | 群成员邀请进群 | ✅ |
| | 群主转让 | ✅ |
| | 群主、管理员同意进群申请 | ✅ |
| | 搜索群成员 | ✅ |
| **消息功能** | 离线消息 | ✅ |
| | 漫游消息 | ✅ |
| | 多端消息 | ✅ |
| | 历史消息 | ✅ |
| | 消息删除 | ✅ |
| | 消息清空 | ✅ |
| | 消息复制 | ✅ |
| | 单聊正在输入 | ✅ |
| | 新消息勿扰 | ✅ |
| | 清空聊天记录 | ✅ |
| | 新成员查看群聊历史消息 | ✅ |
| | 新消息提示 | ✅ |
| | 文本消息 | ✅ |
| | 图片消息 | ✅ |
| | 视频消息 | ✅ |
| | 表情消息 | ✅ |
| | 文件消息 | ✅ |
| | 语音消息 | ✅ |
| | 名片消息 | ✅ |
| | 地理位置消息 | ✅ |
| | 自定义消息 | ✅ |
| **会话功能** | 置顶会话 | ✅ |
| | 会话已读 | ✅ |
| | 会话免打扰 | ✅ |
| **REST API** | 认证管理 | ✅ |
| | 用户管理 | ✅ |
| | 关系链管理 | ✅ |
| | 群组管理 | ✅ |
| | 会话管理 | ✅ |
| | 消息管理 | ✅ |
| **Webhook** | 群组回调 | ✅ |
| | 消息回调 | ✅ |
| | 推送回调 | ✅ |
| | 关系链回调 | ✅ |
| | 用户回调 | ✅ |
| **容量和性能** | 1 万好友 | ✅ |
| | 10 万人大群 | ✅ |
| | 秒级同步 | ✅ |
| | 集群部署 | ✅ |
| | 互踢策略 | ✅ |
| **在线状态** | 所有平台不互踢 | ✅ |
| | 每个平台各只能登录一个设备 | ✅ |
| | PC 端、移动端、Pad 端、Web 端、小程序端各只能登录一个设备 | ✅ |
| | PC 端不互踢,其他平台总计一个设备 | ✅ |
| **文件类对象存储** | 支持私有化部署 minio | ✅ |
| | 支持 COS、OSS、Kodo、S3 公有云 | ✅ |
| **推送** | 消息在线实时推送 | ✅ |
| | 消息离线推送,支持个推,Firebase | ✅ |
更多高级功能、音视频通话、视频会议 请联系邮箱 [contact@openim.io](mailto:contact@openim.io)
## 加入社区 :busts_in_silhouette:
- 🚀 [加入我们的 Slack 社区](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q)
- :eyes: [加入我们的微信群](https://openim-1253691595.cos.ap-nanjing.myqcloud.com/WechatIMG20.jpeg)
## 常见问题
1. 直接运行无法使用?
答:必须严格按照文档操作,导入原生插件和制作自定义基座才能运行。
2. iOS 制作自定义基座失败?
答:插件源码不能经过其他操作系统。只能在 MacOS 环境下载插件、制作自定义基座和云打包。
3. 如何使用地图、定位?
答: [参考文档](CONFIGKEY.md)
4. 如何使用离线推送?
答: [参考文档](CONFIGKEY.md)
## WeUI 风格样式覆盖(新增)
为了让 `uni-ui` / `uView` 的组件样式更接近 WeChat / WeUI 风格,项目中新增了一个覆盖样式文件:
- `styles/weui-overrides.scss`:放置了一组全局覆盖规则(主要调整按钮、列表、导航栏、输入框、标签等)。
如何启用/禁用:
- 本覆盖样式已在 `uni.scss` 中通过 `@import "@/styles/weui-overrides.scss";` 引入,默认启用。
- 若要还原原样,只需从 `uni.scss` 中移除或注释该 import 行,然后重新编译项目。
如何微调:
- 直接修改 `styles/weui-overrides.scss` 中的规则或颜色变量(顶部使用 `--weui-primary`),保存后重新编译即可生效。
后续建议:如果你希望更深入地定制(例如把主题色变量传递到 uView 的主题编译阶段),我可以帮你把变量提前并修改 `@/uni_modules/uview-ui/theme.scss` 的引入顺序,以在编译时替换主题变量。
```
conversation详情
{
"conversationID": "si_100003_100004",
"conversationType": 1,
"userID": "100004",
"groupID": "",
"showName": "1111",
"faceURL": "/static/img/avatar.png",
"recvMsgOpt": 2,
"unreadCount": 0,
"groupAtType": 0,
"latestMsg": "{\"clientMsgID\":\"748ac3ce532afd7dc6638ee13154d5f4\",\"serverMsgID\":\"00ba977273b73af7ae8be68e70b24100\",\"createTime\":1764798647940,\"sendTime\":1764798644531,\"sessionType\":1,\"sendID\":\"100004\",\"recvID\":\"100003\",\"msgFrom\":100,\"contentType\":101,\"senderPlatformID\":2,\"senderNickname\":\"131****1111\",\"senderFaceUrl\":\"/static/img/avatar.png\",\"seq\":17,\"isRead\":true,\"status\":2,\"attachedInfo\":\"null\",\"textElem\":{\"content\":\"馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆馃槆\"},\"attachedInfoElem\":{\"groupHasReadInfo\":{\"hasReadCount\":0,\"groupMemberCount\":0},\"isPrivateChat\":false,\"burnDuration\":0,\"hasReadTime\":0,\"isEncryption\":false,\"inEncryptStatus\":false}}",
"latestMsgSendTime": 1764798644531,
"draftText": "",
"draftTextTime": 0,
"isPinned": true,
"isPrivateChat": false,
"burnDuration": 0,
"isNotInGroup": false,
"updateUnreadCountTime": 0,
"attachedInfo": "",
"ex": "",
"maxSeq": 0,
"minSeq": 0,
"msgDestructTime": 0,
"isMsgDestruct": false
}
```
```
group detail
{
"groupID": "1793688611",
"groupName": "5676uy",
"notification": "",
"introduction": "",
"faceURL": "",
"createTime": 1764103081757,
"status": 0,
"creatorUserID": "100003",
"groupType": 2,
"ownerUserID": "100003",
"memberCount": 3,
"ex": "",
"attachedInfo": "",
"needVerification": 0,
"lookMemberInfo": 0,
"applyMemberFriend": 0,
"notificationUpdateTime": 0,
"notificationUserID": ""
}
```
```
group member
{
"groupID": "1793688611",
"userID": "100004",
"nickname": "131****1111",
"faceURL": "/static/img/avatar.png",
"roleLevel": 20,
"joinTime": 1764103081761,
"joinSource": 2,
"inviterUserID": "100003",
"muteEndTime": 0,
"operatorUserID": "100003",
"ex": "",
"attachedInfo": ""
}
```
```
user detail
{
"userID": "100003",
"nickname": "131****2222",
"faceURL": "/static/img/avatar.png",
"createTime": 1764100199726,
"ex": "",
"attachedInfo": "",
"globalRecvMsgOpt": 0,
"id": 100003,
"role_id": 0,
"parent_id": null,
"group_id": 0,
"username": "13122222222",
"sex": "1",
"email": null,
"region": "86",
"mobile": "13122222222",
"level": 1,
"birthday": null,
"bio": null,
"money": "0.0000000000",
"score": 0,
"currency1": "0.0000000000",
"currency2": "0.0000000000",
"currency3": "0.0000000000",
"currency4": "0.0000000000",
"currency5": "0.0000000000",
"currency6": "0.0000000000",
"currency7": "0.0000000000",
"currency8": "0.0000000000",
"currency9": "0.0000000000",
"maxsuccessions": 0,
"successions": 0,
"loginfailure": 0,
"prev_time": null,
"last_time": 1764833943,
"last_ip": "139.202.159.214",
"join_time": 1764100199,
"join_ip": "139.202.158.3",
"token": null,
"invite_code": "WBDFAQSL",
"online": 0,
"status": 1,
"created_at": 1764100199,
"updated_at": 1764833943,
"deleted_at": null
}
```
-1
View File
@@ -1,4 +1,3 @@
import { reject } from "lodash";
import config from "@/common/config";
// 登录
+1 -1
View File
@@ -1,6 +1,6 @@
<template>
<u-avatar @longpress="longpress" @click="click" @onError="errorHandle" :src="getAvatarUrl" :text="avatarText"
bgColor="#0089FF" :defaultUrl="getDdefaultUrl" :shape="shape" :size="size" mode="aspectFill" font-size="14">
bg-color="#cdcdcd" :defaultUrl="getDdefaultUrl" :shape="shape" :size="size" mode="aspectFill" font-size="14">
</u-avatar>
</template>
+62 -75
View File
@@ -1,84 +1,71 @@
<template>
<view
@click="onClick"
class="setting_item"
:class="{ setting_item_border: border }"
>
<text :style="{ color: danger ? '#FF381F' : '$uni-text-color' }">{{
title
}}</text>
<u-switch
:loading="loading"
@change="onChange"
:asyncChange="true"
v-if="is_switch"
size="20"
:value="switchValue"
/>
<view v-else class="setting_right">
<slot></slot>
<u-icon v-if="arrow" name="arrow-right" color="#999" size="18" />
</view>
</view>
<view @click="onClick" class="setting_item" :class="{ setting_item_border: border }">
<text :style="{ color: danger ? '#FF381F' : '$uni-text-color' }">{{title}}</text>
<u-switch :loading="loading" @change="onChange" :asyncChange="true" v-if="is_switch" size="20" :value="switchValue" />
<view v-else class="setting_right">
<slot></slot>
<u-icon v-if="arrow" name="arrow-right" color="#999" size="18" />
</view>
</view>
</template>
<script>
export default {
name: "",
components: {},
props: {
title: String,
danger: {
type: Boolean,
default: false,
},
is_switch: {
type: Boolean,
default: false,
},
switchValue: {
type: Boolean,
default: false,
},
loading: {
type: Boolean,
default: false,
},
border: {
type: Boolean,
default: true,
},
arrow: {
type: Boolean,
default: true,
},
},
data() {
return {};
},
methods: {
onClick() {
this.$emit("click");
},
onChange(value) {
this.$emit("switch", value);
},
},
};
export default {
name: "",
components: {},
props: {
title: String,
danger: {
type: Boolean,
default: false,
},
is_switch: {
type: Boolean,
default: false,
},
switchValue: {
type: Boolean,
default: false,
},
loading: {
type: Boolean,
default: false,
},
border: {
type: Boolean,
default: true,
},
arrow: {
type: Boolean,
default: true,
},
},
data() {
return {};
},
methods: {
onClick() {
this.$emit("click");
},
onChange(value) {
this.$emit("switch", value);
},
},
};
</script>
<style lang="scss" scoped>
.setting_item {
@include btwBox();
padding: 24rpx 36rpx;
color: $uni-text-color;
.setting_item {
@include btwBox();
padding: 24rpx 36rpx;
color: $uni-text-color;
.setting_right {
@include vCenterBox();
}
.setting_right {
@include vCenterBox();
}
&_border {
border-bottom: 1px solid rgba(153, 153, 153, 0.2);
}
}
</style>
&_border {
border-bottom: 1px solid rgba(153, 153, 153, 0.2);
}
}
</style>
+2 -2
View File
@@ -2,9 +2,9 @@
<view class="mask" :class="!show?'':'mask-show'" :style="{backgroundColor:show?maskBg:'rgba(0,0,0,0)'}" @tap="tapMask">
<view class="popups" :class="[theme]"
:style="{top: popupsTop ,left: popupsLeft,flexDirection:direction}">
<text :class="dynPlace" :style="{width:'0px',height:'0px'}" v-if="triangle"></text>
<text :class="dynPlace" :style="{width:'0px',height:'0px'}" v-show="triangle"></text>
<template v-for="(item,index) in popData">
<view @tap.stop="tapItem(item)" v-if="item.disabled==false"
<view @tap.stop="tapItem(item)" v-show="item.disabled==false"
class="itemChild view" :class="[direction=='row'?'solid-right':'solid-bottom',item.disabled?'disabledColor':'']">
<u-icon :color="item.disabled?'#c8c9cc':'#ffffff'" :name="item.icon" size="20" v-if="item.icon"></u-icon>
<text>{{item.title}}</text>
+1
View File
@@ -22,6 +22,7 @@ export const GroupMemberListTypes = {
export const ContactChooseTypes = {
Invite: "Invite",
GetList: "GetList",
ShareCard: "ShareCard",
};
export const UpdateMessageTypes = {
+5
View File
@@ -195,6 +195,11 @@
"secure" : true // 设置支持https协议的代理
}
}
},
"optimization" : {
"treeShaking" : {
"enable" : true
}
}
}
}
-1
View File
@@ -4,7 +4,6 @@
"date-fns": "^2.30.0",
"dayjs": "^1.11.6",
"image-tools": "^1.4.0",
"lodash": "^4.17.21",
"md5": "^2.3.0",
"openim-uniapp-polyfill": "^1.4.1",
"uuid": "^9.0.0"
+26
View File
@@ -127,6 +127,14 @@
"disableScroll": true
}
},
{
"path": "pages/common/contactChoose/choose",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "pages/common/createGroup/index",
"style": {
@@ -299,6 +307,24 @@
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/conversation/groupSettings/announcement",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/conversation/groupSettings/qrcode",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/conversation/groupSettings/manage",
"style": {
"navigationBarTitleText": ""
}
}
],
"tabBar": {
+367
View File
@@ -0,0 +1,367 @@
<template>
<view class="contact_choose_container">
<custom-nav-bar title="联系人">
<view slot="more" style="margin-right: 10rpx;">
<u-button type="primary" @click="confirm" :disabled="!isConfirmEnable">确定</u-button>
</view>
</custom-nav-bar>
<view class="search_bar_wrap">
<u-search shape="square" placeholder="搜索" :showAction="false" v-model="keyword" />
</view>
<view class="tab_container">
<template v-if="activeTab === 0">
<setting-item @click="tabChange(tabs[0].idx)" :title="tabs[0].title" :border="false" />
<view class="tab_pane">
<template v-for="cell in conversationList">
<template v-if="cell.groupID">
<user-item
v-if="allowGroup"
@itemClick="updateCheckedUserOrGroup"
@updateCheck="updateCheckedUserOrGroup"
:checked="checkedGroupIDList.includes(cell.groupID)"
:disabled="disabledGroupIDList.includes(cell.groupID)"
:checkVisible="muitple"
:item="cell" :key="cell.groupID" />
</template>
<template v-if="cell.userID">
<user-item
@itemClick="updateCheckedUserOrGroup"
@updateCheck="updateCheckedUserOrGroup"
:checked="checkedUserIDList.includes(cell.userID)"
:disabled="disabledUserIDList.includes(cell.userID)"
:checkVisible="muitple"
:item="cell" :key="cell.userID" />
</template>
</template>
</view>
</template>
<template v-else>
<view class="tab_pane" v-show="activeTab === 1">
<choose-index-list
@updateCheck="updateCheckedUser"
:indexList="getChooseData.indexList"
:itemArr="getChooseData.dataList"
:checkedIDList="checkedUserIDList"
:disabledIDList="disabledUserIDList"
:showCheck="muitple" />
</view>
</template>
</view>
</view>
</template>
<script>
import {mapGetters} from "vuex";
import {ContactChooseTypes} from "@/constant";
import {formatChooseData,toastWithCallback} from "@/util/common";
import IMSDK from "openim-uniapp-polyfill";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import UserItem from "@/components/UserItem/index.vue";
import ChooseIndexList from "@/components/ChooseIndexList/index.vue";
import ChooseIndexFooter from "@/components/ChooseIndexFooter/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
export default {
components: {
CustomNavBar,
UserItem,
ChooseIndexList,
ChooseIndexFooter,
SettingItem,
},
data() {
return {
keyword: "",
type: ContactChooseTypes.Card,
activeTab: 0,
groupID: "",
checkedUserIDList: [],
disabledUserIDList: [],
checkedGroupIDList: [],
disabledGroupIDList: [],
comfirmLoading: false,
tabs: [
{
idx: 1,
title: "我的好友",
},
],
muitple:true,
allowGroup:true,
};
},
computed: {
...mapGetters([
"storeFriendList",
"storeCurrentConversation",
"storeCurrentUserID",
"storeConversationList",
]),
getChooseData() {
if (this.keyword) {
return {
indexList: ["#"],
dataList: [
this.storeFriendList.filter(
(friend) =>
friend.nickname.includes(this.keyword) ||
friend.remark.includes(this.keyword)
),
],
};
}
return formatChooseData(this.storeFriendList);
},
conversationList(){
const _this = this;
let list = [...this.storeConversationList];
if(this.keyword){
list = list.filter((item)=>{77
return item.showName.indexOf(_this.kw)>-1 || item.userID.indexOf(_this.kw)>-1 || item.groupID.indexOf(_this.kw)>-1
})
}
return list;
},
getCheckedUserInfo() {
const tmpUserIDList = [...this.checkedUserIDList];
const checkedFriends = this.storeFriendList.filter((friend) => {
const idx = tmpUserIDList.findIndex(
(userID) => userID === friend.userID
);
if (idx > -1) {
tmpUserIDList.splice(idx, 1);
}
return idx > -1;
});
return [...checkedFriends];
},
getCheckedGroupInfo() {
const tmpGroupIDList = [...this.checkedGroupIDList];
const checkedGroups = this.storeConversationList.filter((item) => {
const idx = tmpGroupIDList.findIndex(
(groupID) => groupID === item.groupID
);
if (idx > -1) {
tmpGroupIDList.splice(idx, 1);
}
return idx > -1;
});
return [...checkedGroups];
},
isConfirmEnable(){
if(this.checkedUserIDList.length){
return true;
}
if(this.allowGroup){
if(this.checkedGroupIDList.length){
return true;
}
}
return false;
}
},
onLoad(options) {
const {groupID,type,checkedUserIDList,muitple} = options;
this.type = type;
this.groupID = groupID;
if(muitple){
this.muitple = muitple;
}
//this.muitple = true;
this.checkedUserIDList = checkedUserIDList ? JSON.parse(checkedUserIDList) : [];
//console.log(this.checkedUserIDList);
//console.log(this.groupID);
//console.log(this.muitple);
//console.log(this.type);
if (this.type === ContactChooseTypes.Invite) {
this.allowGroup = false;
this.checkDisabledUser();
}
},
methods: {
checkDisabledUser() {
const friendIDList = this.storeFriendList.map((friend) => friend.userID);
IMSDK.asyncApi("getUsersInGroup", IMSDK.uuid(), {
groupID: this.groupID,
userIDList: friendIDList,
}).then(({data}) => {
this.disabledUserIDList = data;
});
},
tabChange(idx) {
this.keyword = "";
this.activeTab = idx;
},
updateCheckedUserOrGroup(item) {
if (item.userID) {
this.updateCheckedUser(item);
}
if (item.groupID) {
this.updateCheckedGroup(item);
}
},
updateCheckedGroup({groupID}) {
if(!this.muitple){
this.checkedGroupIDList = [groupID];
this.confirm();
}else{
if (this.checkedGroupIDList.includes(groupID)) {
const idx = this.checkedGroupIDList.findIndex((item) => item === groupID);
const tmpArr = [...this.checkedGroupIDList];
tmpArr.splice(idx, 1);
this.checkedGroupIDList = [...tmpArr];
} else {
this.checkedGroupIDList = [...this.checkedGroupIDList, groupID];
}
}
},
updateCheckedUser({userID}) {
if(!this.muitple){
this.checkedUserIDList = [userID];
this.confirm();
}else{
if (this.checkedUserIDList.includes(userID)) {
const idx = this.checkedUserIDList.findIndex((item) => item === userID);
const tmpArr = [...this.checkedUserIDList];
tmpArr.splice(idx, 1);
this.checkedUserIDList = [...tmpArr];
} else {
this.checkedUserIDList = [...this.checkedUserIDList, userID];
}
}
},
confirm() {
//console.log(this.checkedUserIDList,this.checkedGroupIDList);
//return false;
// if (this.activeTab) {
// this.activeTab = 0;
// return;
// }
this.comfirmLoading = true;
if (this.type === ContactChooseTypes.GetList || this.type === ContactChooseTypes.ShareCard) {
try{
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2];
if(prevPage.$vm.getCheckedUsers){
prevPage.$vm.getCheckedUsers(this.getCheckedUserInfo,this.getCheckedGroupInfo);
}else{
const eventChannel = this.getOpenerEventChannel();
eventChannel.emit('onSelectedConfirm', this.getCheckedUserInfo,this.getCheckedGroupInfo);
}
}catch(e){
}
this.comfirmLoading = false;
uni.navigateBack({
delta: 1,
});
return;
}
if (this.type === ContactChooseTypes.Invite) {
IMSDK.asyncApi(IMSDK.IMMethods.InviteUserToGroup, IMSDK.uuid(), {
groupID: this.groupID,
reason: "",
userIDList: this.getCheckedUserInfo.map((user) => user.userID),
})
.then(() => {
toastWithCallback("操作成功", () => uni.navigateBack());
this.comfirmLoading = false;
})
.catch(() => toastWithCallback("操作失败"));
return;
}
this.comfirmLoading = false;
},
},
onBackPress() {
if (this.activeTab) {
this.activeTab = 0;
return true;
}
return false;
},
};
</script>
<style lang="scss" scoped>
::v-deep.u-popup {
flex: none;
}
.contact_choose_container {
height: 100vh;
display: flex;
flex-direction: column;
.search_bar_wrap {
height: 34px;
padding: 12px 22px;
}
.tab_container {
@include colBox(false);
flex: 1;
overflow: hidden;
.setting_item {
padding: 32rpx 36rpx;
}
.title {
height: 60rpx;
display: flex;
justify-content: flex-start;
align-items: center;
// padding: 16rpx 8rpx;
background: #f8f9fa;
color: #8e9ab0;
font-size: 24rpx;
}
.tabs_bar {
@include vCenterBox();
justify-content: space-evenly;
.tab_item {
@include colBox(false);
align-items: center;
image {
width: 50px;
height: 50px;
}
}
}
.tab_pane {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
.member_list {
flex: 1;
height: 80% !important;
::v-deepuni-scroll-view {
max-height: 100% !important;
}
}
.user_list {
height: 100% !important;
}
.member_anchor {
background-color: #f8f8f8 !important;
border: none !important;
}
}
}
}
</style>
+30 -19
View File
@@ -9,8 +9,14 @@
<view class="tab_container">
<template v-if="activeTab === 0">
<setting-item @click="tabChange(tabs[0].idx)" :title="tabs[0].title" :border="false" />
<view class="tab_pane"></view>
<view class="tab_pane">
<user-item
@updateCheck="updateCheckedUser"
:checked="checkedUserIDList.includes(cell.userID)"
:disabled="disabledUserIDList.includes(cell.userID)"
:checkVisible="true"
v-for="cell in storeConversationList" :item="cell" :key="cell.userID" />
</view>
</template>
<template v-else>
@@ -21,7 +27,7 @@
</view>
</template>
</view>
<choose-index-footer :comfirmLoading="comfirmLoading" @removeItem="updateCheckedUserOrGroup" @confirm="confirm"
<choose-index-footer v-show="limit != 1" :comfirmLoading="comfirmLoading" @removeItem="updateCheckedUserOrGroup" @confirm="confirm"
:choosedData="getCheckedInfo" />
</view>
</template>
@@ -60,6 +66,7 @@
title: "我的好友",
},
],
limit:0,
};
},
computed: {
@@ -99,16 +106,17 @@
},
},
onLoad(options) {
const {groupID,type,checkedUserIDList,} = options;
console.log(this.storeFriendList);
const {groupID,type,checkedUserIDList,limit} = options;
//console.log(this.storeFriendList);
this.type = type;
this.groupID = groupID;
this.checkedUserIDList = checkedUserIDList ?
JSON.parse(checkedUserIDList) :
[];
this.checkedUserIDList = checkedUserIDList ? JSON.parse(checkedUserIDList) : [];
if (this.type === ContactChooseTypes.Invite) {
this.checkDisabledUser();
}
if(limit){
this.limit = limit;
}
},
methods: {
checkDisabledUser() {
@@ -131,16 +139,19 @@
this.updateCheckedUser(item);
}
},
updateCheckedUser({
userID
}) {
if (this.checkedUserIDList.includes(userID)) {
const idx = this.checkedUserIDList.findIndex((item) => item === userID);
const tmpArr = [...this.checkedUserIDList];
tmpArr.splice(idx, 1);
this.checkedUserIDList = [...tmpArr];
} else {
this.checkedUserIDList = [...this.checkedUserIDList, userID];
updateCheckedUser({userID}) {
if(this.limit == 1){
this.checkedUserIDList = [userID];
this.confirm();
}else{
if (this.checkedUserIDList.includes(userID)) {
const idx = this.checkedUserIDList.findIndex((item) => item === userID);
const tmpArr = [...this.checkedUserIDList];
tmpArr.splice(idx, 1);
this.checkedUserIDList = [...tmpArr];
} else {
this.checkedUserIDList = [...this.checkedUserIDList, userID];
}
}
},
confirm() {
@@ -215,7 +226,7 @@
.title {
height: 60rpx;
display: flex;
justify-content: start;
justify-content: flex-start;
align-items: center;
// padding: 16rpx 8rpx;
background: #f8f9fa;
+1 -3
View File
@@ -88,9 +88,7 @@ export default {
(member) => member.userID,
);
uni.navigateTo({
url: `/pages/common/contactChoose/index?type=${
ContactChooseTypes.GetList
}&checkedUserIDList=${JSON.stringify(checkedIDList)}`,
url: `/pages/common/contactChoose/index?type=${ContactChooseTypes.GetList}&checkedUserIDList=${JSON.stringify(checkedIDList)}`,
});
},
complateCreate() {
+1
View File
@@ -109,6 +109,7 @@
const info = JSON.parse(sourceInfo);
this.sourceID = info.userID;
}
//console.log(this.storeSelfInfo);
this.getSourceUserInfo();
},
methods: {
+1 -1
View File
@@ -86,7 +86,7 @@ export default {
}
::v-deep .action_item {
align-items: start;
align-items: flex-start;
}
.action_item:last-child {
@@ -3,10 +3,8 @@
<view>
<view class="chat_footer">
<!-- 语音信息 -->
<image v-if="1==2" v-show="!isAudio" @click.prevent="isAudio=!isAudio"
src="@/static/images/chating_footer_audio.png" alt="" srcset="" />
<image v-if="1==2" v-show="isAudio" @click.prevent="isAudio=!isAudio"
src="@/static/images/chating_footer_audio_recording.png" alt="" srcset="" />
<image v-if="1==2" v-show="!isAudio" @click.prevent="isAudio=!isAudio" src="@/static/images/chating_footer_audio.png" alt="" srcset="" />
<image v-if="1==2" v-show="isAudio" @click.prevent="isAudio=!isAudio" src="@/static/images/chating_footer_audio_recording.png" alt="" srcset="" />
<view class="input_content">
<!-- #ifdef APP-PLUS -->
<view v-if="isAudio" class="voice_title" @touchstart.stop.prevent="startVoice"
@@ -20,14 +18,12 @@
</view>
<view class="footer_action_area" v-show="!isAudio">
<image class="emoji_action" @click.prevent="updateActionBar(true)"
src="@/static/images/chating_footer_emoji.png" alt="" srcset="" />
<image v-show="!hasContent" @click.prevent="updateActionBar"
src="@/static/images/chating_footer_add.png" alt="" srcset="" />
<image class="emoji_action" @click.prevent="updateActionBar(true)" src="@/static/images/chating_footer_emoji.png" alt="" srcset="" />
<image v-show="!hasContent" @click.prevent="updateActionBar(false)" src="@/static/images/chating_footer_add.png" alt="" srcset="" />
<button class="send_btn" type="primary" v-show="hasContent" @touchend.prevent="sendTextMessage">发送</button>
</view>
</view>
<chating-action-bar :isEmoji="isEmoji" @sendMessage="sendMessage" @prepareMediaMessage="prepareMediaMessage"
<chating-action-bar :isEmoji="isEmoji" @sendMessage="sendMessage($event,storeCurrentConversation.userID,storeCurrentConversation.groupID)" @prepareMediaMessage="prepareMediaMessage"
v-show="actionBarVisible" />
<u-action-sheet :safeAreaInsetBottom="true" round="12" :actions="actionSheetMenu" @select="selectClick"
:closeOnClickOverlay="true" :closeOnClickAction="true" :show="showActionSheet"
@@ -142,17 +138,17 @@
async sendTextMessage() {
if (!this.hasContent) return;
const message = await this.createTextMessage();
this.sendMessage(message);
this.sendMessage(message,this.storeCurrentConversation.userID,this.storeCurrentConversation.groupID);
},
sendMessage(message) {
sendMessage(message,user_id,group_id) {
this.pushNewMessage(message);
if (needClearTypes.includes(message.contentType)) {
this.customEditorCtx.clear();
}
this.$emit("scrollToBottom");
IMSDK.asyncApi(IMMethods.SendMessage, IMSDK.uuid(), {
recvID: this.storeCurrentConversation.userID,
groupID: this.storeCurrentConversation.groupID,
recvID: user_id,
groupID: group_id,
message,
offlinePushInfo,
})
@@ -289,7 +285,7 @@
IMSDK.uuid(),
getPurePath(path)
);
this.sendMessage(message);
this.sendMessage(message,this.storeCurrentConversation.userID,this.storeCurrentConversation.groupID);
});
},
selectClick({idx}) {
@@ -5,13 +5,18 @@
upper-threshold="250" @scrolltoupper="scrolltoupper">
<view id="scroll_wrap">
<u-loadmore nomoreText="" :status="loadMoreStatus" />
<view v-for="item in storeHistoryMessageList" :key="item.clientMsgID">
<view class="msg_item" v-for="item in storeHistoryMessageList" :key="item.clientMsgID" @click="onUserMessageEvent({type:'selected'},item)">
<template v-if="selectFlag">
<uni-icons class="selectedIcon" size="30" color="#07c160" type="checkbox-filled" v-if="selectClientMsgIDItems.indexOf(item.clientMsgID)>-1"></uni-icons>
<uni-icons class="selectedIcon" size="30" color="#ccc" type="circle" v-else></uni-icons>
</template>
<message-item-render
@messageItemRender="messageItemRender"
@longpress="onLongPressMessageItem(item)"
@userEvent="onUserMessageEvent"
:source="item"
:isSender="item.sendID === storeCurrentUserID"
/>
<!-- :isActive="selectClientMsgIDItems.indexOf(item.clientMsgID)>-1" -->
</view>
<view style="visibility: hidden; height: 12px" id="auchormessage_bottom_item"></view>
</view>
@@ -19,10 +24,7 @@
</template>
<script>
import {
mapGetters,
mapActions
} from "vuex";
import {mapGetters,mapActions} from "vuex";
import MessageItemRender from "./MessageItem/index.vue";
export default {
@@ -30,7 +32,18 @@
components: {
MessageItemRender,
},
props: {},
props: {
selectFlag:{
type:Boolean,
default:false
},
selectItems:{
type:Array,
default(){
return [];
}
}
},
data() {
return {
scrollIntoView: "",
@@ -45,7 +58,7 @@
withAnimation: false,
messageLoadState: {
loading: false,
},
}
};
},
computed: {
@@ -62,6 +75,13 @@
}
return this.messageLoadState.loading ? "loading" : "loadmore";
},
selectClientMsgIDItems(){
let arr = [];
this.selectItems.forEach((v,k)=>{
arr.push(v.clientMsgID);
});
return arr;
}
},
mounted() {
this.loadMessageList();
@@ -90,10 +110,7 @@
viewType: 0,
};
try {
const {
emptyFlag
} =
await this.getHistoryMesageList(options);
const {emptyFlag} =await this.getHistoryMesageList(options);
if (emptyFlag) {
this.$emit("initSuccess");
}
@@ -112,10 +129,7 @@
this.$emit("click", e);
},
onScroll(event) {
const {
scrollHeight,
scrollTop
} = event.target;
const {scrollHeight,scrollTop} = event.target;
this.old.scrollTop = scrollTop
this.needScoll =
scrollHeight - scrollTop < uni.getWindowInfo().windowHeight * 1.2;
@@ -162,9 +176,7 @@
});
},
checkInitHeight() {
this.getEl("#scroll_view").then(({
height
}) => {
this.getEl("#scroll_view").then(({height}) => {
this.bgHeight = `${height}px`;
});
},
@@ -179,9 +191,10 @@
.exec();
});
},
onLongPressMessageItem(msg){
}
onUserMessageEvent(e,data){
this.$emit('userEvent',e,data)
},
empty(){}
},
};
</script>
@@ -255,4 +268,16 @@
.fade-enter {
opacity: 0;
}
.msg_item{
display: flex;
flex-direction: row;
align-items: flex-start;
width: 100%;
.message_item{
flex:1;
}
.selectedIcon{
margin-top: 20rpx;
}
}
</style>
@@ -15,7 +15,7 @@
<image v-if="isFailedMessage && !isPreview" src="@/static/images/chating_message_failed.png" />
</view>
</view>
<view class="message_content_wrap message_content_wrap_shadow" @longtap="longtap($event)">
<view class="message_content_wrap message_content_wrap_shadow" :id="`message_content_wrap_${source.clientMsgID}`" @longtap.stop.prevent="longtapEvent($event)">
<text-message-render v-if="showTextRender" :message="source" />
<media-message-render v-else-if="showMediaRender" :message="source" />
<error-message-render v-else />
@@ -26,11 +26,12 @@
<!-- 长按菜单 -->
<chunLei-popups v-model="toolTipFlag" :popData="toolTipData" @tapPopup="tapPopup"
:x="toolTipX" :y="toolTipY" :placement="popPostion"
:triangle="false"
direction="row" theme="dark" :dynamic="true">
</chunLei-popups>
</view>
<view v-else class="notice_message_container" :id="`auchor${source.clientMsgID}`">
<view v-else class="notice_message_container" style="margin: 0 auto;" :id="`auchor${source.clientMsgID}`">
<text>{{ getNoticeContent }}</text>
</view>
</template>
@@ -74,7 +75,6 @@
toolTipFlag: false,
popPostion:"default",
toolTipData: [],
};
},
computed: {
@@ -137,9 +137,17 @@
}, 2000);
}
},
longtap(e){
console.log(e.target,e.currentTarget);
this.showToolTip(e);
longtapEvent(e){
console.log('longtapEvent');
// console.log("#"+e.currentTarget.id,e);
// let view = uni.createSelectorQuery().in(this).select("#"+e.currentTarget.id.replace('message_content_wrap_','auchor'));
// console.log(e.touches[0].clientX,e.touches[0].clientY);
// view.boundingClientRect((data) => {
// console.log(data.left,data.top);
// //console.log("得到布局位置信息" + JSON.stringify(data));
// }).exec();
this.$emit('userEvent',{type:"longtapMsgContent"},this.source);
//this.showToolTip(e);
},
//操作项
showToolTip: function(e) {
@@ -158,11 +166,23 @@
disabled: false
},
{
id: 5,
icon: '/static/images/chat/longTipIcon/tag.png',
title: '编辑',
id: 6,
icon: '/static/images/chat/longTipIcon/select.png',
title: '多选',
disabled: false
}
},
{
id: 7,
icon: '/static/images/chat/longTipIcon/delete.png',
title: '删除',
disabled: false
},
// {
// id: 5,
// icon: '/static/images/chat/longTipIcon/tag.png',
// title: '编辑',
// disabled: false
// }
];
that.toolTipX =e.touches[0].clientX;
that.toolTipY = e.touches[0].clientY-20;
@@ -184,18 +204,19 @@
tapPopup(e) {
let that = this;
let currentHandleMsg=that.source;
console.log(currentHandleMsg);
if (e.title == "撤回") {
let editMessage=JSON.parse(JSON.stringify(currentHandleMsg));
that.$emit("revertMsg",editMessage)
that.toolTipFlag = false;
that.$emit('userEvent',{type:'revokeMessage'},that.source);
}
if (e.title == "复制") {
let content = currentHandleMsg.content;
let content = currentHandleMsg.textElem?.content;
if (content) {
let copyContent =content.text;
let formatStr = this.replaceReseverEmoji(copyContent);
that.globalUtil.uniCopy({
content: formatStr,
let formatStr = copyContent;
//let formatStr = this.replaceReseverEmoji(copyContent);
uni.setClipboardData({
data:formatStr,
success: (res) => {
uni.showToast({
title: res,
@@ -215,15 +236,8 @@
return;
}
if (e.title == "转发") {
that.$emit('userEvent',{type:'forward'},that.source);
that.toolTipFlag = false;
/* that.$u.route({
url: '/pages/chat/chatGroup/msgForward',
params: {
msgList:encodeURIComponent(JSON.stringify([currentHandleMsg])),
sendType: 1, //1 单条转发 2多条转发
fromChatGroupId: currentHandleMsg.groupId
}
}) */
return
}
if(e.title=="调换"){
@@ -231,24 +245,16 @@
return;
}
if (e.title == "多选") {
that.$emit('userEvent',{type:'select'},that.source);
that.toolTipFlag = false;
/* that.$u.route({
url: '/pages/chat/chatting/chatting-checkbox',
params: {
groupId:currentHandleMsg.groupId,
pageNum:1,
selectMsgId: currentHandleMsg.id,
}
}) */
return
}
if(e.title=="编辑"){
let editMessage=JSON.parse(JSON.stringify(currentHandleMsg));
editMessage.formatTimeStr=currentHandleMsg.createTime;
that.$emit("showUpdateMsg",editMessage)
if (e.title == "删除") {
that.toolTipFlag = false;
return;
that.$emit('userEvent',{type:'deleteMsg'},that.source);
return
}
},
},
};
@@ -289,7 +295,7 @@
flex-direction: column;
align-items: flex-start;
margin-left: 20rpx;
// text-align: start;
// text-align: flex-start;
max-width: 80%;
position: relative;
@@ -307,7 +313,7 @@
}
.message_content_wrap {
@include vCenterBox();
text-align: start;
text-align: flex-start;
// font-size: 14px;
color: $uni-text-color;
width: fit-content;
@@ -316,7 +322,7 @@
.bg_container {
padding: 16rpx 24rpx;
border-radius: 0rpx 12rpx 12rpx 12rpx;
border-radius: 12rpx;
background-color: #fff;
}
}
@@ -0,0 +1,39 @@
<template>
<view class="chat_footer">
<uni-icons type="redo" size="30" color="#000" @click.prevent="forwardMsg"></uni-icons>
<uni-icons type="trash" size="30" color="#000" @click.prevent="deleteMsg"></uni-icons>
</view>
</template>
<script>
export default {
data() {
return {
};
},
methods: {
forwardMsg() {
this.$emit('userEvent',{type:'forward'});
},
deleteMsg(e) {
this.$emit('userEvent',{type:'deleteMsg'});
},
},
};
</script>
<style lang="scss" scoped>
.chat_footer {
display: flex;
align-items: center;
justify-content: space-evenly;
background: #f6f6f6;
// height: 50px;
max-height: 120px;
padding: 24rpx 20rpx;
image {
width: 26px;
height: 26px;
}
}
</style>
@@ -0,0 +1,64 @@
<template>
<u-navbar placeholder class="chating_header" bgColor="transparent">
<view @click="leftClick" class="u-nav-slot" slot="left">
取消
</view>
<view class="u-nav-slot" slot="center">
<view class="chating_info">
<view class="conversation_info">
<view class="title">已选择{{ count }}条消息</view>
</view>
</view>
</view>
</view>
<view class="u-nav-slot" slot="right">
</view>
</u-navbar>
</template>
<script>
export default {
name: "SelectHeader",
props: {
count:{
type:Number,
default(){
return 0;
}
}
},
computed: {
},
methods: {
leftClick(e) {
this.$emit("leftClick", e);
},
},
};
</script>
<style lang="scss" scoped>
.chating_header {
border: 2rpx solid #e1e1e1;
.u-nav-slot {
padding: 24rpx;
}
.chating_info {
@include vCenterBox();
flex-direction: column;
.conversation_info {
flex-direction: row;
justify-content: center;
@include vCenterBox();
.title {
@include nomalEllipsis();
max-width: 280rpx;
font-size: 30rpx;
font-weight: 500;
}
}
}
}
</style>
+262 -16
View File
@@ -1,32 +1,40 @@
<template>
<view class="chating_container">
<chating-header @click="pageClick" ref="chatingHeaderRef" />
<chating-list @click="pageClick" ref="chatingListRef" @initSuccess="initSuccess" />
<chating-footer ref="chatingFooterRef" :footerOutsideFlag="footerOutsideFlag"
<SelectHeader v-if="selectFlag" :count="selectItems.length" @leftClick="onUserMessageEvent({type:'cancelSelect'})" ref="selectHeaderRef" />
<chating-header v-else @click="pageClick" ref="chatingHeaderRef" />
<chating-list
@userEvent="onUserMessageEvent"
@click="pageClick"
:selectItems="selectItems"
:selectFlag="selectFlag"
ref="chatingListRef"
@initSuccess="initSuccess" />
<SelectFooter v-if="selectFlag" ref="selectFooterRef" @userEvent="onUserMessageEvent" />
<chating-footer v-else ref="chatingFooterRef" :footerOutsideFlag="footerOutsideFlag"
@scrollToBottom="scrollToBottom" />
<u-loading-page :loading="initLoading"></u-loading-page>
</view>
</template>
<script>
import {
mapActions
} from "vuex";
import {
PageEvents,
} from "@/constant";
import {mapActions,mapGetters} from "vuex";
import {offlinePushInfo} from "@/util/imCommon";
import {PageEvents,ContactChooseTypes} from "@/constant";
import ChatingHeader from "./components/ChatingHeader.vue";
import ChatingFooter from "./components/ChatingFooter/index.vue";
import ChatingList from "./components/ChatingList.vue";
import {
markConversationAsRead
} from "@/util/imCommon";
import SelectHeader from "./components/SelectHeader.vue";
import SelectFooter from "./components/SelectFooter.vue";
import {markConversationAsRead} from "@/util/imCommon";
import IMSDK,{MessageType} from "openim-uniapp-polyfill";
export default {
components: {
ChatingHeader,
ChatingFooter,
ChatingList,
SelectHeader,
SelectFooter
},
data() {
return {
@@ -34,17 +42,26 @@
footerOutsideFlag: 0,
initLoading: true,
back2Tab: false,
selectFlag:false,
selectItems:[],
forwardItems:[],
forwardMerge:false
};
},
computed:{
...mapGetters([
"storeCurrentConversation",
]),
},
onLoad(options) {
console.log("onload");
//console.log("onload");
this.setPageListener();
if (options?.back2Tab) {
this.back2Tab = JSON.parse(options.back2Tab);
}
},
onUnload() {
console.log("unload");
//console.log("unload");
this.disposePageListener();
markConversationAsRead({
...this.$store.getters.storeCurrentConversation,
@@ -55,7 +72,7 @@
this.resetMessageState();
},
methods: {
...mapActions("message", ["resetMessageState", "deleteMessages"]),
...mapActions("message", ["resetMessageState", "deleteMessages","pushNewMessage", "updateOneMessage"]),
...mapActions("conversation", ["resetConversationState"]),
scrollToBottom(isRecv = false) {
this.$refs.chatingListRef.scrollToBottom(false, isRecv);
@@ -64,7 +81,6 @@
this.footerOutsideFlag += 1;
},
initSuccess() {
console.log("initSuccess");
this.initLoading = false;
},
@@ -75,6 +91,236 @@
disposePageListener() {
uni.$off(PageEvents.ScrollToBottom, this.scrollToBottom);
},
//选择会话列表的回调
async onForwardTargetSelected(userList,groupList){
const _this = this;
//console.log(userList,groupList);
if(this.forwardItems.length === 0){
return false;
}
if(this.forwardMerge && this.forwardItems.length>1){
const res = await IMSDK.asyncApi(IMSDK.IMMethods.CreateMergerMessage, IMSDK.uuid(), {
messageList: _this.forwardItems,
title: "转发的消息",
summaryList: ["summaryList","summaryList"]
});
//console.log(res );
if(res){
await _this.doForwarMsg(userList,groupList,res);
}
}else{
for (var mi = 0; mi < this.forwardItems.length; mi++) {
var msg = this.forwardItems[mi];
const res = await IMSDK.asyncApi(IMSDK.IMMethods.CreateForwardMessage, IMSDK.uuid(), msg);
//console.log(res );
if(res){
await _this.doForwarMsg(userList,groupList,res);
}
}
}
this.onUserMessageEvent({type:'cancelSelect'});
},
async doForwarMsg(userList,groupList,msgiem)
{
//console.log(userList,groupList);
const _this = this;
for (var i = 0; i < userList.length; i++) {
this.sendMessage(msgiem,userList[i].userID,"");
}
for (var i = 0; i < groupList.length; i++) {
this.sendMessage(msgiem,"",groupList[i].groupID);
}
},
sendMessage(message,user_id,group_id) {
//this.scrollToBottom();
//console.log(message);
//console.log(user_id,group_id);
IMSDK.asyncApi(IMSDK.IMMethods.SendMessage, IMSDK.uuid(), {
recvID: user_id,
groupID: group_id,
message,
offlinePushInfo,
})
.then(({data}) => {
console.log(data);
this.pushNewMessage(message);
})
.catch((res={data,errCode,errMsg}) => {
console.log(res);
uni.$u.toast(errMsg);
});
},
onUserMessageEvent(e,data){
const _this = this;
if(e.type == 'select'){
this.selectFlag = true;
this.selectItems = [data];
this.$refs.chatingListRef.scrollToAnchor(`auchor${data.clientMsgID}`);
return ;
}
if(e.type == 'cancelSelect'){
this.selectFlag = false;
this.selectItems = [];
return ;
}
if(e.type == 'selected'){
if(this.selectFlag == true){
let founded = false;
let arr = [];
for (var index = 0; index < this.selectItems.length; index++) {
var v = this.selectItems[index];
if(v.clientMsgID == data.clientMsgID){
founded = true;
}else{
arr.push(v);
}
}
if(!founded){
arr.push(data);
}
console.log(arr.length);
this.selectItems = [...arr];
}
return ;
}
if(e.type == 'deleteMsg'){
let deleteMsgs = [];
if(!data){
deleteMsgs = [...this.selectItems];
}else{
deleteMsgs = [{...data}];
}
for (let i = 0; i < deleteMsgs.length; i++) {
let element = deleteMsgs[i];
IMSDK.asyncApi('deleteMessageFromLocalStorage',IMSDK.uuid(), {
conversationID: _this.storeCurrentConversation.conversationID,
clientMsgID: element.clientMsgID
}).then(res=>{
//console.log(res);
}).catch(res=>{
//console.log(res);
}).finally(()=>{
//console.log(arguments);
})
}
this.selectItems = [];
this.$refs.chatingListRef.loadMessageList();
return ;
}
if(e.type == 'forward'){
if(!data){
this.forwardItems = [...this.selectItems];
let menu = ['逐条转发','合并转发'];
uni.showActionSheet({
itemList:menu,
success({tapIndex}){
if(menu[tapIndex] == '逐条转发'){
this.forwardMerge = false;
}
if(menu[tapIndex] == '合并转发'){
this.forwardMerge = true;
}
uni.navigateTo({
url: `/pages/common/contactChoose/choose?type=${ContactChooseTypes.GetList}&checkedUserIDList=[]`,
events:{
onSelectedConfirm(userList,groupList){
//console.log(userList,groupList);
_this.onForwardTargetSelected(userList,groupList)
}
}
});
}
});
}else{
this.forwardItems = [{...data}];
this.forwardMerge = false;
uni.navigateTo({
url: `/pages/common/contactChoose/choose?type=${ContactChooseTypes.GetList}&checkedUserIDList=[]`,
events:{
onSelectedConfirm(userList,groupList){
//console.log(userList,groupList);
_this.onForwardTargetSelected(userList,groupList)
}
}
});
}
return ;
}
if(e.type == 'revokeMessage'){
IMSDK.asyncApi('revokeMessage', IMSDK.uuid(), {
conversationID: _this.storeCurrentConversation.conversationID,
clientMsgID: data.clientMsgID
}).then(res=>{
console.log(res);
}).catch(res=>{
console.log(res);
}).finally(()=>{
console.log(arguments);
})
return ;
}
if(e.type == 'longtapMsgContent'){
let menu = [];
if(data.contentType == MessageType.TextMessage){
menu.push('复制')
}
menu.push('转发');
menu.push('多选');
menu.push('删除');
let nowTime=new Date().getTime();
let msgTime=data.createTime;
let diff= nowTime-msgTime;
if(this.isSender&&diff<120000){
menu.push('撤回')
}
uni.showActionSheet({
itemList:menu,
success({tapIndex}){
const title = menu[tapIndex];
switch (title) {
case "撤回":
_this.onUserMessageEvent({type:'revokeMessage'},data);
break;
case "复制":
let content = data.textElem?.content;
if (content) {
//let formatStr = this.replaceReseverEmoji(copyContent);
uni.setClipboardData({
data:content,
success: (res) => {
uni.showToast({
title: res,
icon: 'none'
})
},
error: (e) => {
uni.showToast({
title: e,
icon: 'none',
duration: 3000,
})
}
})
}
break;
case "转发":
_this.onUserMessageEvent({type:'forward'},data);
break;
case "多选":
_this.onUserMessageEvent({type:'select'},data);
break;
case "删除":
_this.onUserMessageEvent({type:'deleteMsg'},data);
break;
default:
break;
}
}
})
return ;
}
}
},
onBackPress() {
uni.switchTab({
@@ -8,7 +8,7 @@
backgroundColor="transparent"
>
<template #right>
<uni-icons type="plus" size="26" class="more_icon"></uni-icons>
<uni-icons @click="showMore" type="plus" size="26" class="more_icon"></uni-icons>
</template>
</uni-nav-bar>
<view class="right_action">
@@ -147,7 +147,7 @@
break;
case 'addFriend':
uni.navigateTo({
url: `/pages/common/searchUserOrGroup/index?isSearchGroup=${idx === 2}`,
url: `/pages/common/searchUserOrGroup/index?isSearchGroup=false`,
});
break;
case 'scan':
@@ -1,8 +1,7 @@
<template>
<view @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">
<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" />
<view class="details">
<view class="title">
<text class="conversation_name">
@@ -38,9 +37,6 @@
default: () => {},
},
},
created() {
console.log(this.source)
},
computed: {
latestMessage() {
if (this.source.latestMsg === "") return "";
@@ -71,6 +67,10 @@
//console.log(this.source);
prepareConversationState(this.source);
},
longtapConversationItem() {
//console.log(this.source);
this.$emit('longtapEvent',this.source);
},
},
};
</script>
@@ -78,9 +78,17 @@
<style lang="scss" scoped>
.conversation_item {
@include btwBox();
flex-direction: row;
padding: 12rpx 44rpx 20rpx;
flex-direction: column;
position: relative;
&::after {
content: " ";
border-bottom: 1px solid #eee;
display: inline-block;
position: absolute;
left: 140rpx;
bottom: 0;
right: 0;
}
&.pinned{
background-color: #ededed;
}
@@ -91,6 +99,9 @@
.left_info {
@include btwBox();
width: 100%;
box-sizing: border-box;
padding: 12rpx 44rpx 20rpx;
flex:1;
.details {
@@ -99,7 +110,6 @@
margin-left: 24rpx;
height: 46px;
color: $uni-text-color;
border-bottom: 1px solid #eee;
padding-bottom:20rpx;
.title{
@include btwBox();
+116 -10
View File
@@ -4,8 +4,11 @@
<scroll-view class="scroll-view" scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered"
:scroll-top="scrollTop" :scroll-with-animation="true" @scroll="scroll" @refresherrefresh="onRefresh"
@refresherrestore="onRestore" @scrolltolower="scrolltolower">
<conversation-item v-for="item in storeConversationList" :key="item.conversationID" :source="item"
ref="conversationItem" />
<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" >
<conversation-item @longtapEvent="showExtendMenu(item)" :source="item"/>
</uni-swipe-action-item>
</uni-swipe-action>
</scroll-view>
<view class="loading_wrap" v-if="storeProgress > 0 && storeProgress < 100">
<u-loading-icon :vertical="true" :text="storeProgress + '%'"></u-loading-icon>
@@ -14,9 +17,8 @@
</template>
<script>
import {
mapGetters
} from "vuex";
import {mapGetters} from "vuex";
import IMSDK from "openim-uniapp-polyfill";
import ChatHeader from "./components/ChatHeader.vue";
import ConversationItem from "./components/ConversationItem.vue";
@@ -31,7 +33,26 @@
old: {
scrollTop: 0,
},
doubleClick: 0,
swipe_actions: [
{
text: '取消',
style: {
backgroundColor: '#1184ed'
}
},
{
text: '隐藏',
style: {
backgroundColor: '#fa9d3a'
}
},
{
text: '删除',
style: {
backgroundColor: '#f85050'
}
}
],
triggered: false,
refreshing: false,
};
@@ -40,13 +61,101 @@
...mapGetters(["storeConversationList", "storeIsSyncing", "storeProgress"]),
},
onReady() {
// #ifdef APP
this.$nextTick(() => plus.navigator.closeSplashscreen());
// #endif
},
onLoad() {
//console.log(this.storeConversationList);
this._freshing = false;
this.triggered = true;
setTimeout(()=>{
uni.navigateTo({
url:'/pages/workbench/friend-circle/friend-circle',
})
},1000)
},
methods: {
test(){
console.log(11);
},
showExtendMenu(item){
const _this = this;
const menu = [item.recvMsgOpt===0 ? '关闭免打扰':'免打扰',item.isPrivateChat? '关闭阅后即焚':'开启阅后即焚','隐藏',item.isPinned ? '取消置顶':'置顶','删除'];
uni.showActionSheet({
itemList:menu,
success(e) {
switch(menu[e.tapIndex]){
case '免打扰':
IMSDK.asyncApi('setConversation', IMSDK.uuid(), {
conversationID: conversationId,
recvMsgOpt: 2
})
break;
case '关闭免打扰':
IMSDK.asyncApi('setConversation', IMSDK.uuid(), {
conversationID: conversationId,
recvMsgOpt: 0
})
break;
case '开启阅后即焚':
IMSDK.asyncApi('setConversation', IMSDK.uuid(), {
conversationID: conversationId,
isPrivateChat: true,
burnDuration:60
})
break;
case '关闭阅后即焚':
IMSDK.asyncApi('setConversation', IMSDK.uuid(), {
conversationID: conversationId,
isPrivateChat: false
})
break;
case '隐藏':
IMSDK.asyncApi('hideConversation', IMSDK.uuid(), item.conversationID)
break;
case '置顶':
_this.setPinConversation(item.conversationID,true);
break;
case '取消置顶':
_this.setPinConversation(item.conversationID,false);
break;
case '删除':
_this.deleteConversation(item.conversationID);
break;
}
}
});
},
actionClick(e,item){
const _this = this;
this.$refs.swipe_action.closeAll();
switch(e.index){
case 0:
break;
case 1:
IMSDK.asyncApi('hideConversation', IMSDK.uuid(), item.conversationID)
break;
case 2:
_this.deleteConversation(item.conversationID);
break;
}
},
deleteConversation(conversationID){
IMSDK.asyncApi(IMSDK.IMMethods.DeleteConversationAndDeleteAllMsg, IMSDK.uuid(), conversationID).then(res=>{
console.log('删除成功');
}).catch(e=>{
})
},
setPinConversation(conversationId,status){
IMSDK.asyncApi('setConversation', IMSDK.uuid(), {
conversationID: conversationId,
isPinned: status
})
},
scroll(e) {
this.old.scrollTop = e.detail.scrollTop;
},
@@ -63,10 +172,7 @@
this.queryList();
},
async queryList(isFirstPage = false) {
await this.$store.dispatch(
"conversation/getConversationList",
isFirstPage
);
await this.$store.dispatch("conversation/getConversationList",isFirstPage);
this.triggered = false;
this._freshing = false;
},
+79 -49
View File
@@ -1,57 +1,87 @@
<template>
<view class="group_settings_container">
<custom-nav-bar title="群管理" />
<view class="setting_row">
<setting-item
@click="toTransfer"
title="群主管理权转让"
:border="false"
/>
</view>
</view>
<view class="group_settings_container">
<u-navbar :autoBack="true" bgColor="#ECECEC" title="群管理" safeAreaInsetTop placeholder fixed></u-navbar>
<uni-list>
<uni-list-item title="群主管理权转让" @click="toTransfer" 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('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="isMute ? '解除禁言':'全员禁言'" @switchChange="updateMute" showSwitch :switchChecked="isMute"></uni-list-item>
</uni-list>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import { GroupMemberListTypes } from "@/constant";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
export default {
components: {
CustomNavBar,
SettingItem,
},
data() {
return {};
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentMemberInGroup",
"storeCurrentGroup",
]),
},
methods: {
toTransfer() {
uni.navigateTo({
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Transfer}&groupID=${this.storeCurrentGroup.groupID}`,
});
},
},
};
import {mapGetters} from "vuex";
import IMSDK, {
GroupMemberRole,
GroupStatus,
GroupVerificationType,
IMMethods,
MessageReceiveOptType,
} from "openim-uniapp-polyfill";
import {GroupMemberListTypes} from "@/constant";
export default {
data() {
return {
isMute:false,
};
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentMemberInGroup",
"storeCurrentGroup",
]),
},
onLoad() {
// IMSDK.asyncApi('getSpecifiedGroupsInfo', IMSDK.uuid(), [this.storeCurrentGroup.groupID]).then(res=>{
// console.log(res);
// }).catch(e=>{
// console.log(e);
// })
},
methods: {
toTransfer() {
uni.navigateTo({
url: `/pages/conversation/groupMemberList/index?type=${GroupMemberListTypes.Transfer}&groupID=${this.storeCurrentGroup.groupID}`,
});
},
updateMute(){
IMSDK.asyncApi('changeGroupMute', IMSDK.uuid(), {
groupID: this.storeCurrentGroup.groupID,
isMute: this.isMute
}).then(res=>{
console.log(res);
}).catch(e=>{
console.log(e);
})
},
updateGroupInfo(field,value1){
const data = {groupID:this.storeCurrentGroup.groupID};
data[field] = value1;
IMSDK.asyncApi('setGroupInfo', IMSDK.uuid(),data).then(res=>{
console.log(res);
}).catch(e=>{
console.log(e);
})
},
},
};
</script>
<style lang="scss" scoped>
.group_settings_container {
@include colBox(false);
height: 100vh;
background-color: #f6f6f6;
.group_settings_container {
@include colBox(false);
height: 100vh;
background-color: #f6f6f6;
.setting_row {
background-color: #fff;
margin: 24rpx 24rpx 0;
border-radius: 6px;
overflow: hidden;
}
}
</style>
.setting_row {
background-color: #fff;
margin: 24rpx 24rpx 0;
border-radius: 6px;
overflow: hidden;
}
}
</style>
@@ -0,0 +1,67 @@
<template>
<view style="display: flex;flex-direction: column;width: 100vw;height: 100vh;">
<u-navbar
:autoBack="true"
title="群公告"
safeAreaInsetTop
placeholder
fixed
>
<view class="u-nav-slot" slot="right" v-if="isOwner || isAdmin">
<u-button type="primary" size="mini" @click="save">确定</u-button>
</view>
</u-navbar>
<u--textarea :disabled="!isOwner && !isAdmin" count confirmType="done" focus autoHeight maxlength="-1" border="none" v-model="announcement"></u--textarea >
</view>
</template>
<script>
import {mapGetters} from "vuex";
import IMSDK,{GroupMemberRole,} from "openim-uniapp-polyfill";
export default {
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentMemberInGroup",
"storeCurrentGroup",
]),
isOwner() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
},
isAdmin() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
},
},
data() {
return {
announcement:"",
}
},
onLoad() {
this.announcement = this.storeCurrentGroup.notification;
},
methods: {
back(){
uni.navigateBack();
},
save(){
if(!isOwner && !isAdmin){
return ;
}
IMSDK.asyncApi(IMSDK.IMMethods.SetGroupInfo, IMSDK.uuid(), {
groupID: this.storeCurrentGroup.groupID,
notification: this.announcement
}).then(res=>{
console.log(res);
uni.navigateBack();
}).catch(e=>{
console.log(e);
})
}
}
}
</script>
<style>
</style>
@@ -1,12 +1,12 @@
<template>
<view @click="toMemberList" class="member_row">
<!-- <view class="member_title">
<text>群成员</text>
<view class="member_desc">
<text>{{ `${memberCount}` }}</text>
<u-icon name="arrow-right" color="#999" size="16" />
</view>
</view> -->
<text>群成员</text>
<view class="member_desc">
<text>{{ `${memberCount}` }}</text>
<u-icon name="arrow-right" color="#999" size="16" />
</view>
</view> -->
<view class="member_list">
<view class="member_item" v-for="(member, index) in groupMemberList">
<my-avatar :src="member.faceURL" :desc="member.nickname" :key="member.userID" size="48" />
@@ -34,18 +34,11 @@
</template>
<script>
import {
mapGetters
} from "vuex";
import IMSDK, {
GroupMemberRole
} from "openim-uniapp-polyfill";
import {mapGetters} from "vuex";
import IMSDK, {GroupMemberRole} from "openim-uniapp-polyfill";
import MyAvatar from "@/components/MyAvatar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
import {
ContactChooseTypes,
GroupMemberListTypes
} from "@/constant";
import {ContactChooseTypes,GroupMemberListTypes} from "@/constant";
export default {
name: "",
components: {
@@ -82,7 +75,7 @@
},
inviteMember() {
uni.navigateTo({
url: `/pages/common/contactChoose/index?type=${ContactChooseTypes.Invite}&groupID=${this.groupID}`,
url: `/pages/common/contactChoose/choose?type=${ContactChooseTypes.Invite}&groupID=${this.groupID}`,
});
},
kickMember() {
@@ -98,7 +91,7 @@
.member_row {
@include colBox(false);
padding: 36rpx 36rpx 0;
margin: 24rpx;
margin-bottom: 24rpx;
background-color: #fff;
color: $uni-text-color;
border-radius: 6px;
@@ -154,7 +147,7 @@
.more {
@include btwBox();
margin-top: 20rpx;
padding: 20rpx 0rpx 20rpx;
padding: 30rpx 0rpx 30rpx;
border-top: 1px solid rgba(153, 153, 153, 0.2);
.more_right {
+398 -333
View File
@@ -1,357 +1,422 @@
<template>
<view class="group_settings_container">
<custom-nav-bar title="群聊设置" />
<view class="group_settings_content">
<view class="setting_row info_row">
<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>
<view class="group_settings_container">
<u-navbar :autoBack="true" bgColor="#ECECEC" :title="'群聊设置('+storeCurrentGroup.memberCount+')'" safeAreaInsetTop placeholder fixed></u-navbar>
<text @click="copyGroupID" class="sub_title">{{
storeCurrentConversation.groupID
}}</text>
</view>
</view>
<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>
<group-member-row
v-if="isJoinGroup"
:isNomal="!isAdmin && !isOwner"
:groupID="storeCurrentConversation.groupID"
:memberCount="storeCurrentGroup.memberCount"
:groupMemberList="groupMemberList"
/>
<view v-if="isJoinGroup" class="setting_row">
<setting-item
v-if="isOwner || isAdmin"
@click="toGroupManage"
title="群管理"
:border="false"
/>
</view>
<text @click="copyGroupID" class="sub_title">{{storeCurrentConversation.groupID}}</text>
</view>
</view>
<view class="setting_row">
<setting-item
v-if="isJoinGroup"
danger
@click="() => (confirmType = isOwner ? 'Dismiss' : 'Quit')"
:title="isOwner ? '解散群聊' : '退出群聊'"
:border="false"
/>
</view>
<group-member-row v-if="isJoinGroup" :isNomal="!isAdmin && !isOwner"
:groupID="storeCurrentConversation.groupID" :memberCount="storeCurrentGroup.memberCount"
:groupMemberList="groupMemberList" />
<uni-list>
<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/common/userOrGroupQrCode?groupID='+storeCurrentConversation.groupID" clickable showArrow></uni-list-item>
<uni-list-item v-if="isOwner || isAdmin" title="群管理" to="/pages/conversation/groupManage/index" clickable showArrow></uni-list-item>
<uni-list-item v-if="1==2" title="备注" :rightText="storeCurrentConversation.showName" @click="editGroupName" :clickable="isOwner || isAdmin" :showArrow="isOwner || isAdmin"></uni-list-item>
</uni-list>
<u-gap></u-gap>
<uni-list>
<uni-list-item title="查找聊天内容" to=""></uni-list-item>
</uni-list>
<u-gap></u-gap>
<uni-list>
<uni-list-item title="消息免打扰" @switchChange="updateCoversation('recvMsgOpt',storeCurrentConversation.recvMsgOpt==0 ? 2: 0)" showSwitch :switchChecked="storeCurrentConversation.recvMsgOpt !== 0"></uni-list-item>
<uni-list-item title="置顶聊天" @switchChange="updateCoversation('isPinned',!storeCurrentConversation.isPinned)" showSwitch :switchChecked="storeCurrentConversation.isPinned"></uni-list-item>
</uni-list>
<u-gap></u-gap>
<uni-list>
<uni-list-item v-if="1==2" title="我在本群的昵称"></uni-list-item>
<uni-list-item title="删除聊天记录" @click="clearMsg" clickable></uni-list-item>
</uni-list>
<u-gap></u-gap>
<uni-list v-if="isJoinGroup">
<uni-list-item :border="false">
<view slot="body" class="uni-list-item__content" @click="confirm">
<text class="uni-list-item__content-title" style="color: red;">{{isOwner ? '解散群聊' : '退出群聊'}}</text>
</view>
</uni-list-item>
</uni-list>
<u-gap></u-gap>
<u-gap></u-gap>
</view>
<u-modal
:content="getConfirmContent"
asyncClose
:show="confirmType !== null"
showCancelButton
@confirm="confirm"
@cancel="() => (confirmType = null)"
></u-modal>
</view>
<u-toast ref="uToast"></u-toast>
<action-sheet
:groupID="storeCurrentConversation.groupID"
:visible.sync="actionSheetVisible"
/>
</view>
<u-toast ref="uToast"></u-toast>
</view>
</template>
<script>
import { mapGetters } from "vuex";
import { GroupMemberListTypes } from "@/constant";
import IMSDK, {
GroupMemberRole,
GroupStatus,
GroupVerificationType,
IMMethods,
MessageReceiveOptType,
} from "openim-uniapp-polyfill";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import MyAvatar from "@/components/MyAvatar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
import GroupMemberRow from "./components/GroupMemberRow.vue";
import ActionSheet from "./components/ActionSheet.vue";
import { getPurePath } from "@/util/common";
import {mapGetters} from "vuex";
import {GroupMemberListTypes} from "@/constant";
import IMSDK, {
GroupMemberRole,
GroupStatus,
GroupVerificationType,
IMMethods,
MessageReceiveOptType,
} from "openim-uniapp-polyfill";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import MyAvatar from "@/components/MyAvatar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
import GroupMemberRow from "./components/GroupMemberRow.vue";
import {getPurePath} from "@/util/common";
const ConfirmTypes = {
Dismiss: "Dismiss",
Quit: "Quit",
};
const ConfirmTypes = {
Dismiss: "Dismiss",
Quit: "Quit",
};
export default {
components: {
CustomNavBar,
MyAvatar,
SettingItem,
GroupMemberRow,
ActionSheet,
},
props: {},
data() {
return {
actionSheetVisible: false,
confirmType: null,
switchLoading: {
pin: false,
opt: false,
mute: false,
},
groupMemberList: [],
isJoinGroup: true
};
},
onShow() {
this.getGroupMemberList();
if (this.storeCurrentConversation.groupID) {
IMSDK.asyncApi(
IMMethods.IsJoinGroup,
IMSDK.uuid(),
this.storeCurrentConversation.groupID
).then((res) => {
this.isJoinGroup = res.data
});
}
},
watch: {
"storeCurrentGroup.memberCount"() {
this.getGroupMemberList();
},
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentMemberInGroup",
"storeCurrentGroup",
]),
getConfirmContent() {
if (this.confirmType === ConfirmTypes.Quit) {
return "确定要退出当前群聊吗?";
}
if (this.confirmType === ConfirmTypes.Dismiss) {
return "确定要解散当前群聊吗?";
}
return "";
},
isOwner() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
},
isAdmin() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
},
getGroupVerStr() {
if (
this.storeCurrentGroup.needVerification ===
GroupVerificationType.ApplyNeedInviteNot
) {
return "群成员邀请无需验证";
}
if (
this.storeCurrentGroup.needVerification === GroupVerificationType.AllNot
) {
return "允许所有人加群";
}
return "需要发送验证消息";
},
isAllMuted() {
return this.storeCurrentGroup.status === GroupStatus.Muted;
},
},
methods: {
getGroupMemberList() {
IMSDK.asyncApi(IMSDK.IMMethods.GetGroupMemberList, IMSDK.uuid(), {
groupID: this.storeCurrentConversation.groupID,
filter: 0,
offset: 0,
count: !this.isAdmin && !this.isOwner ? 9 : 8,
})
.then(({ data }) => {
console.log(data);
this.groupMemberList = [...data];
})
.catch((err) => {
console.log(err);
});
},
toGroupManage() {
uni.navigateTo({
url: "/pages/conversation/groupManage/index",
});
},
toUpdateGroupName() {
if (!this.isAdmin && !this.isOwner) {
return;
}
export default {
components: {
CustomNavBar,
MyAvatar,
SettingItem,
GroupMemberRow
},
props: {},
data() {
return {
switchLoading: {
pin: false,
opt: false,
mute: false,
},
groupMemberList: [],
isJoinGroup: true
};
},
onShow() {
console.log(this.storeCurrentConversation);
/*
this.$store.commit("conversation/SET_CURRENT_CONVERSATION", {
"conversationID": "sg_1793688611",
"conversationType": 3,
"userID": "",
"groupID": "1793688611",
"showName": "5676uy",
"faceURL": "",
"recvMsgOpt": 0,
"unreadCount": 0,
"groupAtType": 0,
"latestMsg": "{\"clientMsgID\":\"e6274af29366f9097615cc373bc9139d\",\"serverMsgID\":\"ba783d50f2853d5588c913529c08b790\",\"createTime\":1764803528981,\"sendTime\":1764803525434,\"sessionType\":3,\"sendID\":\"100004\",\"recvID\":\"100003\",\"msgFrom\":100,\"contentType\":101,\"senderPlatformID\":2,\"senderNickname\":\"131****1111\",\"senderFaceUrl\":\"/static/img/avatar.png\",\"groupID\":\"1793688611\",\"seq\":10,\"isRead\":false,\"status\":2,\"textElem\":{\"content\":\"2222222222222222222222222222222222\"},\"attachedInfoElem\":{\"groupHasReadInfo\":{\"hasReadCount\":0,\"groupMemberCount\":3},\"isPrivateChat\":false,\"burnDuration\":0,\"hasReadTime\":0,\"isEncryption\":false,\"inEncryptStatus\":false}}",
"latestMsgSendTime": 1764803525434,
"draftText": "",
"draftTextTime": 0,
"isPinned": false,
"isPrivateChat": false,
"burnDuration": 0,
"isNotInGroup": false,
"updateUnreadCountTime": 0,
"attachedInfo": "",
"ex": "",
"maxSeq": 0,
"minSeq": 0,
"msgDestructTime": 0,
"isMsgDestruct": false
});
this.$store.commit("conversation/SET_CURRENT_MEMBER_IN_GROUP", {
"groupID": "1793688611",
"userID": "100004",
"nickname": "131****1111",
"faceURL": "/static/img/avatar.png",
"roleLevel": 20,
"joinTime": 1764103081761,
"joinSource": 2,
"inviterUserID": "100003",
"muteEndTime": 0,
"operatorUserID": "100003",
"ex": "",
"attachedInfo": ""
});
this.$store.commit("conversation/SET_CURRENT_GROUP", {
"groupID": "1793688611",
"groupName": "5676uy",
"notification": "",
"introduction": "",
"faceURL": "",
"createTime": 1764103081757,
"status": 0,
"creatorUserID": "100003",
"groupType": 2,
"ownerUserID": "100003",
"memberCount": 3,
"ex": "",
"attachedInfo": "",
"needVerification": 0,
"lookMemberInfo": 0,
"applyMemberFriend": 0,
"notificationUpdateTime": 0,
"notificationUserID": ""
});
*/
//console.log(this.storeCurrentGroup,this.storeCurrentConversation,this.storeCurrentMemberInGroup)
this.getGroupMemberList();
if (this.storeCurrentConversation.groupID) {
IMSDK.asyncApi(
IMMethods.IsJoinGroup,
IMSDK.uuid(),
this.storeCurrentConversation.groupID
).then((res) => {
this.isJoinGroup = res.data
});
}
},
watch: {
"storeCurrentGroup.memberCount"() {
this.getGroupMemberList();
},
},
computed: {
...mapGetters([
"storeCurrentConversation",
"storeCurrentMemberInGroup",
"storeCurrentGroup",
]),
isOwner() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Owner;
},
isAdmin() {
return this.storeCurrentMemberInGroup.roleLevel === GroupMemberRole.Admin;
},
getGroupVerStr() {
if (
this.storeCurrentGroup.needVerification ===
GroupVerificationType.ApplyNeedInviteNot
) {
return "群成员邀请无需验证";
}
if (
this.storeCurrentGroup.needVerification === GroupVerificationType.AllNot
) {
return "允许所有人加群";
}
return "需要发送验证消息";
},
isAllMuted() {
return this.storeCurrentGroup.status === GroupStatus.Muted;
},
},
methods: {
editGroupName(){
if(this.isOwner || this.isAdmin){
this.toUpdateGroupName();
}
},
getGroupMemberList() {
IMSDK.asyncApi(IMSDK.IMMethods.GetGroupMemberList, IMSDK.uuid(), {
groupID: this.storeCurrentConversation.groupID,
filter: 0,
offset: 0,
count: !this.isAdmin && !this.isOwner ? 9 : 8,
})
.then(({
data
}) => {
//console.log(data);
this.groupMemberList = [...data];
})
.catch((err) => {
console.log(err);
});
},
toGroupManage() {
uni.navigateTo({
url: "/pages/conversation/groupManage/index",
});
},
toUpdateGroupName() {
if (!this.isAdmin && !this.isOwner) {
return;
}
uni.navigateTo({
url: `/pages/conversation/updateGroupOrNickname/index?sourceInfo=${JSON.stringify(
this.storeCurrentGroup,
)}`,
});
},
copyGroupID() {
uni.setClipboardData({
data: this.storeCurrentGroup.groupID,
success: () => {
uni.hideToast();
this.$nextTick(() => {
uni.$u.toast("复制成功");
});
},
});
},
showActionSheet() {
if (!this.isAdmin && !this.isOwner) {
return;
}
uni.navigateTo({
url: `/pages/conversation/updateGroupOrNickname/index?sourceInfo=${JSON.stringify(this.storeCurrentGroup,)}`,
});
},
copyGroupID() {
uni.setClipboardData({
data: this.storeCurrentGroup.groupID,
success: () => {
uni.hideToast();
this.$nextTick(() => {
uni.$u.toast("复制成功");
});
},
});
},
updateGroupInfo(field,value1){
const data = {groupID:this.storeCurrentGroup.groupID};
data[field] = value1;
IMSDK.asyncApi('setGroupInfo', IMSDK.uuid(),data).then(res=>{
console.log(res);
}).catch(e=>{
console.log(e);
})
},
updateCoversation(field,value1){
const data = {conversationID:this.storeCurrentConversation.conversationID};
data[field] = value1;
IMSDK.asyncApi('setConversation', IMSDK.uuid(),data).then(res=>{
console.log(res);
}).catch(e=>{
console.log(e);
})
},
updateGroupAvatar() {
if (!this.isAdmin && !this.isOwner) {
return;
}
this.actionSheetVisible = true;
},
updateGroupAvatar() {
if (!this.isAdmin && !this.isOwner) {
return;
}
uni.chooseImage({
count: 1,
sizeType: ["compressed"],
success: async ({ tempFilePaths }) => {
const path = tempFilePaths[0];
const nameIdx = path.lastIndexOf("/") + 1;
const typeIdx = path.lastIndexOf(".") + 1;
const fileName = path.slice(nameIdx);
const fileType = path.slice(typeIdx);
try {
const {
data: { url },
} = await IMSDK.asyncApi(IMMethods.UploadFile, IMSDK.uuid(), {
filepath: getPurePath(tempFilePaths[0]),
name: fileName,
contentType: fileType,
uuid: IMSDK.uuid(),
});
await IMSDK.asyncApi(IMSDK.IMMethods.SetGroupInfo, IMSDK.uuid(), {
groupID: this.storeCurrentConversation.groupID,
faceURL: url,
});
uni.$u.toast("修改成功");
} catch (error) {
uni.$u.toast("修改失败");
}
},
});
},
confirm() {
let funcName = "";
let sourceID = this.storeCurrentConversation.groupID;
if (this.confirmType === ConfirmTypes.Quit) {
funcName = IMSDK.IMMethods.QuitGroup;
}
if (this.confirmType === ConfirmTypes.Dismiss) {
funcName = IMSDK.IMMethods.DismissGroup;
}
IMSDK.asyncApi(funcName, IMSDK.uuid(), sourceID)
.then(() => {
uni.$u.toast("操作成功");
setTimeout(
() =>
uni.switchTab({
url: "/pages/conversation/conversationList/index",
}),
250,
);
})
.catch(() => uni.$u.toast("操作失败"))
.finally(() => (this.confirmType = null));
},
},
};
uni.chooseImage({
count: 1,
sizeType: ["compressed"],
success: async ({
tempFilePaths
}) => {
const path = tempFilePaths[0];
const nameIdx = path.lastIndexOf("/") + 1;
const typeIdx = path.lastIndexOf(".") + 1;
const fileName = path.slice(nameIdx);
const fileType = path.slice(typeIdx);
try {
const {
data: {
url
},
} = await IMSDK.asyncApi(IMMethods.UploadFile, IMSDK.uuid(), {
filepath: getPurePath(tempFilePaths[0]),
name: fileName,
contentType: fileType,
uuid: IMSDK.uuid(),
});
await IMSDK.asyncApi(IMSDK.IMMethods.SetGroupInfo, IMSDK.uuid(), {
groupID: this.storeCurrentConversation.groupID,
faceURL: url,
});
uni.$u.toast("修改成功");
} catch (error) {
uni.$u.toast("修改失败");
}
},
});
},
confirm() {
const _this = this;
uni.showModal({
content:this.isOwner ? '确定要解散当前群聊吗?' : '确定要退出当前群聊吗?',
success(res){
if (res.confirm) {
let funcName = "";
let sourceID = _this.storeCurrentConversation.groupID;
if (this.isOwner) {
funcName = IMSDK.IMMethods.DismissGroup;
}else{
funcName = IMSDK.IMMethods.QuitGroup;
}
IMSDK.asyncApi(funcName, IMSDK.uuid(), sourceID)
.then(() => {
uni.$u.toast("操作成功");
setTimeout(
() =>
uni.switchTab({
url: "/pages/conversation/conversationList/index",
}),
250,
);
})
.catch(() => uni.$u.toast("操作失败"));
}
}
})
},
clearMsg(){
IMSDK.asyncApi('clearConversationAndDeleteAllMsg',IMSDK.uuid(), this.storeCurrentConversation.conversationID).then(res=>{
uni.navigateBack();
}).catch(e=>{
console.log(e);
})
}
},
};
</script>
<style lang="scss" scoped>
.group_settings_container {
@include colBox(false);
height: 100vh;
background-color: #f6f6f6;
.group_settings_container {
@include colBox(false);
height: 100vh;
background-color: #f6f6f6;
.group_settings_content {
overflow-y: auto;
}
.group_settings_content {
overflow-y: auto;
}
.setting_row {
background-color: #fff;
margin: 24rpx;
border-radius: 6px;
overflow: hidden;
}
.setting_row {
background-color: #fff;
margin: 24rpx;
border-radius: 6px;
overflow: hidden;
}
.info_row {
@include vCenterBox();
padding: 36rpx 44rpx;
.info_row {
@include vCenterBox();
padding: 36rpx 44rpx;
.group_avatar {
margin-right: 16rpx;
position: relative;
.group_avatar {
margin-right: 16rpx;
position: relative;
.edit_icon {
position: absolute;
right: -6rpx;
bottom: -6rpx;
width: 11px;
height: 11px;
}
}
.edit_icon {
position: absolute;
right: -6rpx;
bottom: -6rpx;
width: 11px;
height: 11px;
}
}
.group_info {
min-height: 46px;
display: flex;
flex: 1;
flex-direction: column;
align-items: flex-start;
justify-content: space-between;
.group_info {
min-height: 46px;
display: flex;
flex: 1;
flex-direction: column;
align-items: flex-start;
justify-content: space-between;
&_name {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
&_name {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
.group_name {
// @include nomalEllipsis();
font-size: 34rpx;
max-width: 380rpx;
margin-right: 24rpx;
}
}
.group_name {
// @include nomalEllipsis();
font-size: 34rpx;
max-width: 380rpx;
margin-right: 24rpx;
}
}
.sub_title {
@include nomalEllipsis();
margin-bottom: 0;
font-size: 28rpx;
color: #999;
}
}
}
}
</style>
.sub_title {
@include nomalEllipsis();
margin-bottom: 0;
font-size: 28rpx;
color: #999;
}
}
}
}
</style>
@@ -0,0 +1,22 @@
<template>
<view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
@@ -0,0 +1,22 @@
<template>
<view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
+38 -12
View File
@@ -2,27 +2,37 @@
<view class="single_settings_container">
<custom-nav-bar title="好友设置" />
<view class="row_wrap">
<view class="setting_row info_row">
<view @click="toUserCard" class="user_info">
<my-avatar :src="storeCurrentConversation.faceURL" :desc="storeCurrentConversation.showName"
size="46" />
</view>
<view @click="invite2group" class="action">
<image style="width: 46px; height: 46px" src="@/static/images/single_setting_add.png" alt="" />
</view>
<view class="setting_row info_row">
<view @click="toUserCard" class="user_info">
<my-avatar :src="storeCurrentConversation.faceURL" :desc="storeCurrentConversation.showName"
size="46" />
</view>
<view @click="invite2group" class="action">
<image style="width: 46px; height: 46px" src="@/static/images/single_setting_add.png" alt="" />
</view>
</view>
<uni-list>
<uni-list-item title="查找聊天内容" to=""></uni-list-item>
</uni-list>
<u-gap></u-gap>
<uni-list>
<uni-list-item title="消息免打扰" @switchChange="updateCoversation('recvMsgOpt',storeCurrentConversation.recvMsgOpt==0 ? 2: 0)" showSwitch :switchChecked="storeCurrentConversation.recvMsgOpt !== 0"></uni-list-item>
<uni-list-item title="置顶聊天" @switchChange="updateCoversation('isPinned',!storeCurrentConversation.isPinned)" showSwitch :switchChecked="storeCurrentConversation.isPinned"></uni-list-item>
</uni-list>
<u-gap></u-gap>
<uni-list>
<uni-list-item title="删除聊天记录" @click="clearMsg" clickable></uni-list-item>
</uni-list>
</view>
</template>
<script>
import {
mapGetters
} from "vuex";
import {mapGetters} from "vuex";
import CustomNavBar from "@/components/CustomNavBar/index.vue";
import MyAvatar from "@/components/MyAvatar/index.vue";
import SettingItem from "@/components/SettingItem/index.vue";
import IMSDK from "openim-uniapp-polyfill";
export default {
components: {
CustomNavBar,
@@ -61,6 +71,22 @@
url: `/pages/common/createGroup/index?checkedMemberList=${checkedMemberList}`,
});
},
clearMsg(){
IMSDK.asyncApi('clearConversationAndDeleteAllMsg',IMSDK.uuid(), this.storeCurrentConversation.conversationID).then(res=>{
uni.navigateBack();
}).catch(e=>{
console.log(e);
})
},
updateCoversation(field,value1){
const data = {conversationID:this.storeCurrentConversation.conversationID};
data[field] = value1;
IMSDK.asyncApi('setConversation', IMSDK.uuid(),data).then(res=>{
console.log(res);
}).catch(e=>{
console.log(e);
})
},
},
};
</script>
@@ -2,7 +2,7 @@
<view class="page_container">
<custom-nav-bar :title="getTitle">
<view class="nav_right_action" slot="more">
<text v-show="!updateLoading" @click="comfirmUpdate">保存</text>
<u-button type="primary" v-show="!updateLoading" @click="comfirmUpdate">保存</u-button>
<u-loading-icon v-show="updateLoading" />
</view>
</custom-nav-bar>
+6 -2
View File
@@ -107,6 +107,7 @@ export default {
},
onLoad(options) {
const _this = this;
// #ifdef APP
plus.runtime.getProperty(plus.runtime.appid, (inf) => {
console.log(inf);
_this.appversion = inf.version
@@ -114,6 +115,7 @@ export default {
// if(options.isRedirect){
// plus.navigator.closeSplashscreen();
// }
// #endif
this.init();
},
methods: {
@@ -166,10 +168,12 @@ export default {
code: this.loginInfo.verificationCode,
});
const { imToken, userID } = data;
// #ifdef APP
await IMSDK.asyncApi(IMSDK.IMMethods.Login, uuidv4(), {
userID,
token: imToken,
});
// #endif
this.saveLoginProfile(data);
this.$store.commit("user/SET_AUTH_DATA", data);
this.$store.dispatch("user/getSelfInfo");
@@ -274,8 +278,8 @@ export default {
.logo {
display: flex;
flex-direction: column;
justify-content: start;
align-items: start;
justify-content: flex-start;
align-items: flex-start;
img {
width: 160rpx;
@@ -0,0 +1,289 @@
<template>
<view class="content-circle-box" :index="index">
<view @tap="linkToBusinessCard(item.user_id)">
<MyAvatar :src="item.user.avatar" :desc="item.user.nickname || item.user.id" :isGroup="false" size="66"></MyAvatar>
</view>
<view class="content">
<view class="content-name" @tap="linkToBusinessCard(item.user_id)">{{ item.user.nickname || item.user.remark }}</view>
<view class="content-desc">{{ item.body }}</view>
<!-- 图片,视频 -->
<view class="content-img" v-if="item.files!=null&&item.files.length>0">
<!-- //只有一张图时候 -->
<view v-if="item.files.length==1&&item.releaseType==1" class="u-flex u-row-left u-col-center"
style="width:100%;min-height: 200rpx;">
<u-image width="280rpx" :src="cdn(item.files[0])" mode="widthFix"
@tap="previewImg(0, item)">
<u-loading slot="loading"></u-loading>
<view slot="error" class="u-flex u-row-left u-col-center"
style="font-size: 24rpx;width: 200rpx;height: 100rpx;margin-top: -50rpx;">
<u-icon name="photo" size="100" label="加载失败" label-pos="bottom"></u-icon>
</view>
</u-image>
</view>
<!-- 有多张图的时候 -->
<view v-if="item.files.length > 1&&item.releaseType==1">
<view class="content-img-more u-m-b-20">
<u-grid :col="3" :border="false" hover-class="none">
<u-grid-item v-for="(src, index) in item.files" :index="index" :custom-style="girdItemCustomStyle">
<view @tap="previewImg(index, item)" class="slot-btn">
<u-image :src="cdn(src)" width="180rpx" height="180rpx" mode="aspectFill" border-radius="10"></u-image>
</view>
</u-grid-item>
</u-grid>
</view>
</view>
<!-- 视频 -->
<view class="u-m-b-30 u-m-t-30 u-flex u-row-left u-col-center"
v-if="item.fileList.length > 0&&item.releaseType==2" @tap="previewImg(0, item)">
<view v-if="vuex_OSPlat=='ios'">
<u-image width="280rpx" :src="getVideoPoster(item.fileList[0])" mode="widthFix">
<u-loading slot="loading"></u-loading>
</u-image>
</view>
<view v-else class="u-flex u-row-center u-col-center"
style="border: 1rpx solid #36648b;width:280rpx;height:120rpx;border-radius: 16rpx;">
<u-icon name="play-circle" size="48" color="#36648b"
label="点击查看视频" label-pos="bottom"></u-icon>
</view>
</view>
</view>
<!-- 地点 -->
<view v-if="(item.address&&item.address.chooseFlag)==true" class="u-line-2 u-m-t-10 u-m-b-10" style="font-size: 30rpx;color: #36648b;">
<u-icon name="map" color="#36648b" size="30" :custom-style="{marginLeft:'-4rpx'}"></u-icon>
<text> {{ item.address.name}}</text>
</view>
<!-- 相对时间 点赞按钮等 -->
<view class="relavivetime" :id="`comment-${'null'}-${index}`">
<view class="time u-flex u-col-center">
<view>{{ item.created_at }}</view>
<view @click="deleteCircle(item,index)" style="color:#36648b;margin-left: 20rpx;" v-if="item.user_id==selfInfo.userID">删除</view>
</view>
<view class="icon-box u-flex u-row-between u-col-center">
<view @tap="clickThumb(item,index)" class="u-m-r-6 u-p-t-4">
<u-icon v-if="item.isPraise==false" size="38" name="heart" color="#36648b"></u-icon>
<u-icon v-if="item.isPraise==true" size="38" name="heart-fill" color="#36648b"></u-icon>
</view>
<view @tap="handleComment(item.id, null, index)" class="u-m-l-6 u-p-t-2">
<u-icon size="40" name="chat" color="#36648b"></u-icon>
</view>
</view>
</view>
<!-- 点赞人 评论 -->
<view class="msg-box">
<view class="thumbinfo u-border-bottom" v-if="item.praise!=null&&item.praise.length">
<uni-icons size="30" type="heart" color="#36648b" class="u-m-r-10"></uni-icons>
<text class="thumbinfo-name" v-for="(userInfo, pindex) in item.praise" :index="pindex"
:key="pindex" @tap="linkToBusinessCard(userInfo.userId)">
{{ userInfo.nickame }}{{ pindex != item.praise.length - 1 ? '' : '' }}
</text>
</view>
<view class="comment" v-if="item.comments!=null&&item.comments.length">
<view class="comment-box" v-for="(comment, commentIndex) in item.comments" :index="commentIndex"
:key="commentIndex" hover-class="comment-hover-class"
:id="`comment-${item.id}-${index}`"
@tap="handleComment(item.id, comment, index)">
<text class="comment-box-name" v-if="!comment.reply_user_id">{{ comment.replyUser.nickname }}</text>
<text class="comment-box-name" v-if="comment.reply_user_id">
{{ comment.replyUser.nickname }}
<text class="callback u-m-l-4 u-m-r-4">回复</text>
</text>
<text v-if="comment.reply_user_id" class="comment-box-name">{{ comment.replyUser.nickname }}</text>
<text class="comment-box-content">{{ comment.content }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import MyAvatar from "@/components/MyAvatar/index.vue";
import videoPlayer from '@/components/videoPlayer.vue';
export default{
components:{videoPlayer ,MyAvatar},
props:{
index:{
type:Number,
default:0
},
item:{
type:Object,
default(){
return {};
}
}
},
computed:{
selfInfo() {
return this.$store.getters.storeSelfInfo;
},
},
data(){
console.log(this.item);
return {
}
},
methods:{
}
}
</script>
<style scoped lang="scss">
.content-circle-box {
padding: 18rpx 30rpx;
border-bottom: 1rpx solid #f2eeee;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
.headimg {
width: 80rpx;
height: 80rpx;
.img {
width: 100%;
height: 100%;
border-radius: 10rpx;
}
}
.content {
flex: 1;
padding-left: 18rpx;
font-size: 32rpx;
&-name {
color: #36648b;
font-weight: bold;
font-size: 32rpx;
}
&-desc {
color: #000000;
padding-top: 4rpx;
//line-height: 36rpx;
font-size: 32rpx;
}
&-img {
margin-top: 10rpx;
.img-1 {
will-change: transform;
width: 280rpx;
height: auto;
max-height: 400rpx;
}
&-more {
display: flex;
flex-wrap: wrap;
.img-more {
display: block;
width: 160rpx;
height: 160rpx;
margin: 4rpx;
}
.img-3 {
margin: 4rpx 4rpx 4rpx 0;
}
}
}
.msg-box {
width: 100%;
background-color: #FFF;
margin-top: 15rpx;
border-radius: 4rpx;
.thumbinfo {
// border-bottom: 1rpx solid gray;
padding: 6rpx;
display: flex;
align-items: center;
flex-wrap: wrap;
&-icon {
width: 28rpx;
height: 28rpx;
line-height: 28rpx;
margin-right: 15rpx;
text-align: center;
vertical-align: middle;
padding-left: 10rpx;
}
&-name {
font-size: 28rpx;
color: #36648b;
}
}
.comment {
padding: 6rpx 8rpx;
color: $uni-text-color;
font-size: 28rpx;
&-box {
padding: 4rpx 0;
&-name {
color: #36648b;
.callback {
color: $uni-text-color;
}
}
&-content {
word-break: break-all;
}
}
}
}
}
.relavivetime {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 26rpx;
.time {
color: $uni-text-color-grey;
}
.icon-box {
display: flex;
align-items: center;
&-item {
//background-color: #F8F8F8;
padding: 4rpx 12rpx;
border-radius: 6rpx;
&.thumb {
margin-right: 10rpx;
}
}
.img {
width: 34rpx;
height: 34rpx;
}
}
}
}
</style>
@@ -0,0 +1,8 @@
<template>
</template>
<script>
</script>
<style>
</style>
+38 -173
View File
@@ -1,7 +1,14 @@
<template>
<view class="content" id="content">
<u-navbar bgColor="transparent" title="朋友圈" title-size="36" leftIconColor="#fff"
:titleStyle ="{color:'#fff'}" :title-bold="true" :border-bottom="false">
<u-navbar
@leftClick="goto('/pages/workbench/index/index')"
bgColor="transparent"
title="朋友圈"
title-size="36"
leftIconColor="#fff"
:titleStyle ="{color:'#fff'}"
:title-bold="true"
:border-bottom="false">
<view slot="right" class="u-margin-right-20" @click="showTypeSheet"
@longpress="linkToRelease({releaseType:0})">
<u-icon name="camera" color="#fff" size="32"></u-icon>
@@ -18,22 +25,21 @@
<MyAvatar class="headimg" :src="selfInfo.faceURL" :desc="selfInfo.nickname || selfInfo.remark"
:isGroup="Boolean(selfInfo.groupID)" size="66" @tap="linkToBusinessCard(selfInfo.userID)" />
<text class="nickname">{{ selfInfo.nickname || self.remark }}</text>
<text class="nickname">{{ selfInfo.nickname || selfInfo.remark }}</text>
</view>
<!-- 个性签名 -->
<view class="signature">
<view class="">{{ selfInfo.bio }}</view>
</view>
<view class="u-m-t-20 u-m-b-30 u-flex u-row-center u-col-center" v-if="vuex_friendCircleUnreadCount>0">
<view class="u-flex u-row-left u-col-center" @click="clearUnReadCount()"
style="width: 300rpx;height:70rpx;background-color: #333333;color: #ffffff;border-radius:10rpx;">
<view v-if="vuex_friendCircleUnreadCount>0" style="display: flex;justify-content: center;">
<view @click="clearUnReadCount()"
style="width: 300rpx;height:70rpx;line-height:70rpx;background-color: #333333;color: #ffffff;border-radius:10rpx;display: flex;align-items: center;">
<view style="width:80rpx;padding:0 10rpx;">
<MyAvatar class="headimg" :src="selfInfo.faceURL" :desc="selfInfo.nickname || selfInfo.remark"
:isGroup="Boolean(selfInfo.groupID)" size="66"/>
<MyAvatar :src="selfInfo.faceURL" class="headimg" desc=" " size="24"/>
</view>
<view style="width:220rpx;text-align: center;">
<text>{{vuex_friendCircleUnreadCount}}条新信息</text>
<view style="flex:1;">
{{vuex_friendCircleUnreadCount}}条新信息
</view>
</view>
</view>
@@ -42,107 +48,9 @@
<view class="content-circle">
<!-- circleData是vuex变量不在本页面定义 -->
<template v-if="circleData!=null&&circleData.length>0">
<view class="content-circle-box" v-for="(item, index) in circleData" :key="index" :index="index">
<view @tap="linkToBusinessCard(item.user_id)">
<MyAvatar :src="item.user.avatar" :desc="item.user.nickname || item.user.id" :isGroup="false" size="66"></MyAvatar>
</view>
<view class="content">
<view class="content-name" @tap="linkToBusinessCard(item.user_id)">{{ item.user.nickname || item.user.remark }}</view>
<view class="content-desc">{{ item.body }}</view>
<!-- 图片,视频 -->
<view class="content-img" v-if="item.files!=null&&item.files.length>0">
<!-- //只有一张图时候 -->
<view v-if="item.files.length==1&&item.releaseType==1" class="u-flex u-row-left u-col-center"
style="width:100%;min-height: 200rpx;">
<u-image width="280rpx" :src="cdn(item.files[0])" mode="widthFix"
@tap="previewImg(0, item)">
<u-loading slot="loading"></u-loading>
<view slot="error" class="u-flex u-row-left u-col-center"
style="font-size: 24rpx;width: 200rpx;height: 100rpx;margin-top: -50rpx;">
<u-icon name="photo" size="100" label="加载失败" label-pos="bottom"></u-icon>
</view>
</u-image>
</view>
<!-- 有多张图的时候 -->
<view v-if="item.files.length > 1&&item.releaseType==1">
<view class="content-img-more u-m-b-20">
<u-grid :col="3" :border="false" hover-class="none">
<u-grid-item v-for="(src, index) in item.files" :index="index" :custom-style="girdItemCustomStyle">
<view @tap="previewImg(index, item)" class="slot-btn">
<u-image :src="cdn(src)" width="180rpx" height="180rpx" mode="aspectFill" border-radius="10"></u-image>
</view>
</u-grid-item>
</u-grid>
</view>
</view>
<!-- 视频 -->
<view class="u-m-b-30 u-m-t-30 u-flex u-row-left u-col-center"
v-if="item.fileList.length > 0&&item.releaseType==2" @tap="previewImg(0, item)">
<view v-if="vuex_OSPlat=='ios'">
<u-image width="280rpx" :src="getVideoPoster(item.fileList[0])" mode="widthFix">
<u-loading slot="loading"></u-loading>
</u-image>
</view>
<view v-else class="u-flex u-row-center u-col-center"
style="border: 1rpx solid #36648b;width:280rpx;height:120rpx;border-radius: 16rpx;">
<u-icon name="play-circle" size="48" color="#36648b"
label="点击查看视频" label-pos="bottom"></u-icon>
</view>
</view>
</view>
<!-- 地点 -->
<view v-if="(item.address&&item.address.chooseFlag)==true" class="u-line-2 u-m-t-10 u-m-b-10" style="font-size: 30rpx;color: #36648b;">
<u-icon name="map" color="#36648b" size="30" :custom-style="{marginLeft:'-4rpx'}"></u-icon>
<text> {{ item.address.name}}</text>
</view>
<!-- 相对时间 点赞按钮等 -->
<view class="relavivetime" :id="`comment-${'null'}-${index}`">
<view class="time u-flex u-col-center">
<view>{{ item.created_at }}</view>
<view @click="deleteCircle(item,index)" style="color:#36648b;margin-left: 20rpx;" v-if="item.user_id==selfInfo.userID">删除</view>
</view>
<view class="icon-box u-flex u-row-between u-col-center">
<view @tap="clickThumb(item,index)" class="u-m-r-6 u-p-t-4">
<u-icon v-if="item.isPraise==false" size="38" name="heart" color="#36648b"></u-icon>
<u-icon v-if="item.isPraise==true" size="38" name="heart-fill" color="#36648b"></u-icon>
</view>
<view @tap="handleComment(item.id, null, index)" class="u-m-l-6 u-p-t-2">
<u-icon size="40" name="chat" color="#36648b"></u-icon>
</view>
</view>
</view>
<!-- 点赞人 评论 -->
<view class="msg-box">
<view class="thumbinfo u-border-bottom" v-if="item.praise!=null&&item.praise.length">
<uni-icons size="30" type="heart" color="#36648b" class="u-m-r-10"></uni-icons>
<text class="thumbinfo-name" v-for="(userInfo, pindex) in item.praise" :index="pindex"
:key="pindex" @tap="linkToBusinessCard(userInfo.userId)">
{{ userInfo.nickame }}{{ pindex != item.praise.length - 1 ? '' : '' }}
</text>
</view>
<view class="comment" v-if="item.comments!=null&&item.comments.length">
<view class="comment-box" v-for="(comment, commentIndex) in item.comments" :index="commentIndex"
:key="commentIndex" hover-class="comment-hover-class"
:id="`comment-${item.id}-${index}`"
@tap="handleComment(item.id, comment, index)">
<text class="comment-box-name" v-if="!comment.reply_user_id">{{ comment.replyUser.nickname }}</text>
<text class="comment-box-name" v-if="comment.reply_user_id">
{{ comment.replyUser.nickname }}
<text class="callback u-m-l-4 u-m-r-4">回复</text>
</text>
<text v-if="comment.reply_user_id" class="comment-box-name">{{ comment.replyUser.nickname }}</text>
<text class="comment-box-content">{{ comment.content }}</text>
</view>
</view>
</view>
</view>
</view>
<template v-for="(item, index) in circleData" >
<CircleItem :key="index" :index="index" :item="item"></CircleItem>
</template>
</template>
<template v-else>
<view style="margin-top: 30%;">
@@ -259,11 +167,12 @@
import {getFriendCircle} from "@/api/login.js"
import UserBase from "@/components/User.vue"
import MyAvatar from "@/components/MyAvatar/index.vue";
import util from "@/util/index.js"
import util from "@/util/index.js";
import CircleItem from "./components/circleItem.vue"
export default {
name: 'firendCircle',
mixins:[UserBase],
components:{videoPlayer ,MyAvatar},
components:{videoPlayer ,MyAvatar,CircleItem},
computed: {
selfInfo() {
return this.$store.getters.storeSelfInfo;
@@ -382,6 +291,7 @@
},
methods: {
goto:util.goto,
clearUnReadCount(){
this.$store.dispatch('circle/updateUnreadCount',0-this.vuex_friendCircleUnreadCount);
},
@@ -389,60 +299,6 @@
getCircleDataList:function(param){
let that=this;
this.$store.dispatch('circle/getFriendCircleList',param);
return ;
getFriendCircle(param).then(res => {
//console.log("朋友圈列表",res);
let circleDataList=res.data;
//console.log("朋友圈列表",circleDataList);
if(circleDataList.length>0){
that.loadMoreFlag=true;
for (var i = 0; i < circleDataList.length; i++) {
let item= circleDataList[i];
if(item.userId==this.selfInfo.userID){
item.userName="我";
}
if(item.address!=null&&item.address.length>0){
item.address=JSON.parse(item.address);
}
if(item.fileList!=null&&item.fileList.length>0){
item.fileList=JSON.parse(item.fileList);
if(item.releaseType==2){
}
}
if(item.praise!=null){
item.praise=JSON.parse(item.praise);
}else{
item.praise=[];
}
if(item.comment!=null&&item.comment.length>0){
item.comment=JSON.parse(item.comment);
}
else{
item.comment=[];
}
}
}else{
if(param.moreFlag==true){
that.loadMoreFlag=false;
}
return;
}
//初始化列表
if(param.moreFlag==false){
console.log("初始化朋友圈列表",circleDataList.length);
that.circleData = circleDataList;
//that.$u.vuex('circleData', circleDataList);
}
//加载更多
else{
let oldList=that.circleData;
let newList=oldList.concat(circleDataList);
that.circleData = circleDataList;
//that.$u.vuex('circleData', newList);
console.log("加载更多朋友圈列表",newList);
}
})
},
//滚动事件
@@ -680,7 +536,7 @@
tempFilePaths = res.tempFilePaths;
let param = {
releaseType: 1,
tempFilePaths: JSON.stringify(tempFilePaths)
tempFilePaths: tempFilePaths
}
that.linkToRelease(param);
return;
@@ -698,7 +554,7 @@
tempFilePaths.push(filePath);
let param = {
releaseType: 2,
tempFilePaths: JSON.stringify(tempFilePaths)
tempFilePaths: tempFilePaths
}
that.linkToRelease(param);
return;
@@ -709,10 +565,19 @@
},
//点击自定义组件相机按钮
linkToRelease(params) {
uni.$u.route({
url: '/pages/workbench/friend-circle/releaseFriendCircle',
params: params
});
console.log(params);
let url = "/pages/workbench/friend-circle/releaseFriendCircle?";
for(let key in params){
if(key!="tempFilePaths"){
url+=key+"="+params[key]+"&";
}
}
uni.navigateTo({
url:url,
success(res) {
res.eventChannel.emit('successEvent',params);
}
})
},
getVideoPoster(videoSrc){
console.log("video",videoSrc);
@@ -53,15 +53,15 @@
<!-- :value="address.name" :value-style="customValueStyle" :label="address.address" -->
<u-cell bg-color="#ffffff"
:title="address.chooseFlag?(address.name):'所在位置'" :title-style="customTitleStyle"
:label="address.chooseFlag?(address.address):'请选择'"
:value="address.chooseFlag?(address.address):'请选择'" isLink
@click="toChooseLocation()">
<view slot="icon" class="u-flex u-row-center u-col-center">
<u-icon name="map" size="32" :color="address.chooseFlag?'#19be6b':'#606266'"></u-icon>
</view>
</u-cell>
<u-cell bg-color="#ffffff" title="提醒谁看" :title-style="customTitleStyle" @click="toRemind()">
<u-cell bg-color="#ffffff" title="提醒谁看" :title-style="customTitleStyle" @click="toRemind">
<view slot="icon" class="u-flex u-row-center u-col-center">
<u-icon name="/static/images/friendCircle/at.png" width="32" height="32" color="#606266"></u-icon>
<u-icon name="/static/images/friendCircle/at.png" width="24" height="24" color="#606266"></u-icon>
</view>
</u-cell>
<u-cell bg-color="#ffffff" @click="toSetPromission()"
@@ -90,6 +90,11 @@
components:{
videoPlayer
},
computed: {
circleData() {
return this.$store.getters.storeCircleData;
}
},
data() {
return {
winWidth:0,
@@ -173,18 +178,24 @@
if (this.releaseType == 2) {
this.navbarTitle = "发表视频";
}
if (option.tempFilePaths != null && option.tempFilePaths != undefined && option.tempFilePaths.length > 0) {
this.tempFilePaths = JSON.parse(option.tempFilePaths);
if(this.releaseType!=0){
//console.log("不是纯文字")
this.submitFlag=false; //可以直接发布
const _this = this;
const eventChannel = this.getOpenerEventChannel();
// 注意在 onUnload 取消监听,避免监听常驻内存
eventChannel.on('successEvent', function(data) {
console.log(data)
if (data.tempFilePaths != null && data.tempFilePaths != undefined && data.tempFilePaths.length > 0) {
_this.tempFilePaths = data.tempFilePaths;
if(_this.releaseType!=0){
//console.log("不是纯文字")
_this.submitFlag=false; //可以直接发布
}
for (var i = 0; i < _this.tempFilePaths.length; i++) {
let url= _this.tempFilePaths[i];
_this.tempUploadFilePath.push({url:url});
}
//console.log("准备发朋友圈的临时文件", _this.tempUploadFilePath);
}
for (var i = 0; i < this.tempFilePaths.length; i++) {
let url= this.tempFilePaths[i];
this.tempUploadFilePath.push({url:url});
}
//console.log("准备发朋友圈的临时文件", this.tempUploadFilePath);
}
})
},
@@ -202,6 +213,14 @@
}
});
},
onUnload() {
try {
const eventChannel = this.getOpenerEventChannel();
eventChannel.off('successEvent');
} catch (error) {
//TODO handle the exception
}
},
methods: {
cdn:util.cdn,
@@ -214,7 +233,7 @@
//监听输入
inputing:function(e){
let content=e.detail.value.trim();
//console.log("content",content);
console.log("content",content);
if(content.length>0){
this.submitFlag=false;
}else{
@@ -225,11 +244,7 @@
//如果不是纯文字
else{
//附件列表没有
if(this.tempFilePaths.length<1){
this.submitFlag=true;
}else{
this.submitFlag=false;
}
this.submitFlag = this.tempFilePaths.length<1;
}
}
},
@@ -247,11 +262,7 @@
//如果不是纯文字
else{
//附件列表没有
if(this.tempFilePaths.length<1){
this.submitFlag=true;
}else{
this.submitFlag=false;
}
this.submitFlag = this.tempFilePaths.length<1;
}
}
},
@@ -432,7 +443,7 @@
else{
newCircle.comment=[];
}
let circleDataList=this.circleData;
let circleDataList=[...this.circleData];
circleDataList.unshift(newCircle);
that.$u.vuex('circleData', circleDataList);
that.btnLoading = false;
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

+4 -3
View File
@@ -6,7 +6,7 @@ const state = {
};
const mutations = {
SET_LIST(state, info) {
SET_LIST(state, list) {
state.list = [...list];
},
SET_UNREAD_COUNT(state, count) {
@@ -35,7 +35,8 @@ const actions = {
uni.$u.http.get('/friendcircle/list',params).then(res=>{
commit("SET_LIST", res.data);
}).catch(e=>{
uni.$u.toast("获取个人信息失败");
console.log(e);
uni.$u.toast("获取信息失败");
})
},
async getFriendCircleInfo({ commit, state}) {
@@ -44,7 +45,7 @@ const actions = {
commit("SET_LAST_UNREAD", data.last_unread_item);
commit("SET_SETTINGS", data.settings);
}).catch(e=>{
uni.$u.toast("获取个人信息失败");
uni.$u.toast("获取信息失败");
})
},
async updateUnreadCount({commit,state},v) {
+7 -26
View File
@@ -24,22 +24,16 @@ const mutations = {
};
const actions = {
async getHistoryMesageList({
commit,
state
}, params) {
async getHistoryMesageList({commit,state}, params) {
let emptyFlag = true;
try {
console.log("getHistoryMesageList:::");
console.log(params);
const {
data
} = await IMSDK.asyncApi(
//console.log(params);
const {data} = await IMSDK.asyncApi(
IMSDK.IMMethods.GetAdvancedHistoryMessageList,
uuidv4(),
params,
);
console.log(data);
//console.log(data);
const isFistPage = !params.startClientMsgID
const messages = data.messageList ?? [];
emptyFlag = messages.length === 0;
@@ -55,21 +49,10 @@ const actions = {
emptyFlag,
};
},
pushNewMessage({
commit,
state
}, message) {
pushNewMessage({commit,state}, message) {
commit("SET_HISTORY_MESSAGE_LIST", [...state.historyMessageList, message]);
},
updateOneMessage({
commit,
state
}, {
message,
type = UpdateMessageTypes.Overall,
keyWords = [],
isSuccess = false,
}, ) {
updateOneMessage({commit,state}, {message,type = UpdateMessageTypes.Overall,keyWords = [],isSuccess = false,}, ) {
const tmpList = state.historyMessageList;
const idx = tmpList.findIndex(
(msg) => msg.clientMsgID === message.clientMsgID,
@@ -88,9 +71,7 @@ const actions = {
commit("SET_HISTORY_MESSAGE_LIST", tmpList);
}
},
resetMessageState({
commit
}) {
resetMessageState({commit}) {
commit("SET_HISTORY_MESSAGE_LIST", []);
commit("SET_HAS_MORE_MESSAGE", true);
},
+17
View File
@@ -11,3 +11,20 @@ image {
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor;
}
uni-switch .uni-switch-input.uni-switch-input-checked{
border-color: #07c160;
background-color: #07c160;
}
uni-button{
}
.uni-list-item__content-title{
font-size: 34rpx !important;
font-weight: 500;
line-height: 70rpx;
height: 70rpx;
}
.uni-list-item__extra-text{
font-size: 32rpx !important;
}
+5
View File
@@ -0,0 +1,5 @@
interface AtUserInfo {
atUserID:string; // at 成员的 ID
groupNickname:string; // at 成员的昵称
}
export default AtUserInfo;
+9
View File
@@ -0,0 +1,9 @@
import GroupHasReadInfo from "./GroupHasReadInfo";
interface AttachedInfoElem {
groupHasReadInfo:GroupHasReadInfo; // 群消息已读信息
isPrivateChat:boolean; // 标识是否为阅后即焚消息,仅支持单聊
burnDuration:number; // 阅后即焚销毁时间, 客户端自行计时, 到达时间后调用 api 删除消息
hasReadTime:number; // 消息已读时间戳
messageEntityList:string[]; // 暂未使用
}
export default AttachedInfoElem ;
+7
View File
@@ -0,0 +1,7 @@
interface CardElem {
userID:string; // 用户 ID
nickname:string; // 昵称
faceURL:string; // 头像
ex:string; // 拓展字段
}
export default CardElem;
+6
View File
@@ -0,0 +1,6 @@
interface CustomElem {
data:string; // 自定义 json string
extension:string; // 拓展信息
description:string; // 描述信息
}
export default CustomElem;
+5
View File
@@ -0,0 +1,5 @@
interface FaceElem {
index:number; // 表情下标,用户端对端自定义内嵌的表情包
data:string; // 其他表情,如 URL 表情直接返回 url
}
export default FaceElem;
+8
View File
@@ -0,0 +1,8 @@
interface FileElem {
uuID:string; // 唯一 ID
filePath:string; // 本地资源地址
fileSize:number; // 大小
fileName:string; // 文件名字
sourceUrl:string; // 文件远程地址
}
export default FileElem;
+6
View File
@@ -0,0 +1,6 @@
interface GroupHasReadInfo {
hasReadUserIDList:string[]; // 已读的用户 ID 列表
hasReadCount:number; // 已读总数
groupMemberCount:number; // 发送此条消息时的群内人数
}
export default GroupHasReadInfo;
+6
View File
@@ -0,0 +1,6 @@
interface LocationElem {
desc:string; // 描述信息
longitude:number; // 经度
latitude:number; // 纬度
}
export default LocationElem;
+7
View File
@@ -0,0 +1,7 @@
import MessageItem from "./MessageItem";
interface MergeElem {
title:string; // 标题
abstractList:string[]; // 摘要列表
multiMessage:MessageItem[]; // 具体选择合并的消息列表
}
export default MergeElem;
+62
View File
@@ -0,0 +1,62 @@
import { SessionType, MessageType, Platform, MessageStatus } from "openim-uniapp-polyfill";
import OfflinePushInfo from "./OfflinePushInfo";
import PictureElem from "./PictureElem";
import SoundElem from "./SoundElem";
import VideoElem from "./VideoElem";
import FileElem from "./FileElem";
import MergeElem from "./MergeElem";
import atTextElem from "./atTextElem";
import LocationElem from "./LocationElem";
import QuoteElem from "./QuoteElem";
import CustomElem from "./CustomElem";
import NotificationElem from "./NotificationElem";
import FaceElem from "./FaceElem";
import AttachedInfoElem from "./AttachedInfoElem";
import TextElem from "./TextElem";
import CardElem from "./CardElem";
import TypingElem from "./TypingElem";
interface MessageItem {
id: number; // 用户 ID
name: string; // 用户名
isAdmin?: boolean; // 可选属性,是否为管理员clientMsgID string 客户端消息唯一 ID,推荐使用
serverMsgID: string; // 服务端消息唯一 ID,内部使用
createTime: number; // 创建时间
sendTime: number; // 发送时间
sessionType: SessionType; // 会话类型
sendID: string; // 发送者 ID
recvID: string; // 接收者 ID,为群聊会话时无需关注
msgFrom: number; // 内部字段
contentType: MessageType; // 消息类型
platformID: Platform; // 平台号
senderNickname: string; // 发送者昵称
senderFaceUrl: string; // 发送者头像
groupID: string; // 群 ID
content: string; // 内部字段
seq: number; // 消息的 seq
isRead: boolean; // 是否已读
status: MessageStatus; // 消息发送状态
attachedInfo?: string; // 内部字段
ex?: string; // 扩展信息
offlinePush?: OfflinePushInfo; // 离线推送详情
pictureElem?: PictureElem;//图片消息详情
soundElem?: SoundElem; // 语音消息详情
videoElem?: VideoElem; // 视频消息详情
fileElem?: FileElem; // 文件消息详情
mergeElem?: MergeElem; // 合并消息详情
atTextElem?: atTextElem; // @消息详情
locationElem?: LocationElem; // 位置消息详情
quoteElem?: QuoteElem; // 引用消息详情
customElem?: CustomElem; // 自定义消息详情
notificationElem?: NotificationElem; // 通知消息详情
faceElem?: FaceElem; // 自定义表情详情
attachedInfoElem?: AttachedInfoElem; // 附加信息详情
textElem?: TextElem; // 文本内容详情
cardElem?: CardElem; // 名片内容详情
advancedTextElem?: string; // 暂未使用
typingElem?: TypingElem; // 正在输入详情
hasReadTime?: number; // 单聊已读时间戳
isReact: boolean; // 暂未使用
isExternalExtensions: boolean; // 暂未使用
};
export default MessageItem;
+4
View File
@@ -0,0 +1,4 @@
interface NotificationElem {
detail:string; // 通知详情json
}
export default NotificationElem;
+9
View File
@@ -0,0 +1,9 @@
interface OfflinePushInfo {
title:string; // 推送标题
desc:string; // 推送描述
iOSPushSound:string; // ios 推送声音文件的名称
iOSBadgeCount:boolean; // ios 是否展示角标
operatorUserID:string; // 操作员用户 ID
ex:string; // 扩展内容
}
export default OfflinePushInfo;
+8
View File
@@ -0,0 +1,8 @@
import PictureInfo from "./PictureInfo";
interface PictureElem {
sourcePath:string; // 本地资源地址
sourcePicture:PictureInfo; // 原图片详情
bigPicture:PictureInfo; // 大图片详情
snapshotPicture:PictureInfo; // 缩略图片详情
}
export default PictureElem;
+9
View File
@@ -0,0 +1,9 @@
interface PictureInfo {
uuID:string; // 唯一 ID
type:string; // 类型
size:number; // 大小
width:number; // 宽度
height:number; // 高度
url:string; // 图片地址
}
export default PictureInfo;
+7
View File
@@ -0,0 +1,7 @@
import MessageItem from "./MessageItem";
interface QuoteElem {
text:string; // 回复的消息内容
quoteMessage:MessageItem; // 被引用的消息
messageEntityList:string[]; // 暂未使用
}
export default QuoteElem;
+8
View File
@@ -0,0 +1,8 @@
interface SoundElem {
uuID:string; // 唯一 ID
soundPath:string; // 本地资源地址
dataSize:number; // 大小
duration:number; // 时长
sourceUrl:string; // 语音远程地址
}
export default SoundElem;
+4
View File
@@ -0,0 +1,4 @@
interface TextElem {
content:string; // 文字消息
}
export default TextElem;
+4
View File
@@ -0,0 +1,4 @@
interface TypingElem {
msgTips:string; // 提示
}
export default TypingElem;
+15
View File
@@ -0,0 +1,15 @@
interface VideoElem {
videoUUID:string; // 唯一 ID
videoPath:string; // 本地资源地址
videoType:string; // 资源类型
videoSize:number; // 大小
duration:number; // 时长
videoUrl:string; // 图片地址
snapshotUUID:string; // 唯一 ID
snapshotPath:string; // 类型
snapshotSize:number; // 大小
snapshotWidth:number; // 宽度
snapshotHeight:number; // 高度
snapshotUrl:string; // 视频缩略图地址
}
export default VideoElem;
+10
View File
@@ -0,0 +1,10 @@
import AtUserInfo from "./AtUserInfo";
import MessageItem from "./MessageItem";
interface atTextElem {
text:string; // 消息内容
atUserList:string[]; // 被@的用户 userID 列表
atUsersInfo:AtUserInfo[]; // 被@的用户信息列表
quoteMessage:MessageItem; // 引用消息
isAtSelf:boolean; // 自己是否被@了
}
export default atTextElem;
+15
View File
@@ -0,0 +1,15 @@
export * from "./atTextElem";
export * from "./AtUserInfo";
export * from "./CardElem";
export * from "./CustomElem";
export * from "./FileElem";
export * from "./LocationElem";
export * from "./MergeElem";
export * from "./MessageItem";
export * from "./NotificationElem";
export * from "./OfflinePushInfo";
export * from "./PictureElem";
export * from "./SoundElem";
export * from "./TextElem";
export * from "./TypingElem";
export * from "./VideoElem";
+79 -6
View File
@@ -1,16 +1,88 @@
import _ from "lodash";
//import i18n from '@/locales'
import base from '@/common/config';
//import store from "@/store";
const isString = (v)=> {
return typeof v === 'string' || v instanceof String;
},
isNumber=(v) =>{
return typeof v === 'number' && !isNaN(v);
},
isInteger=(v) =>{
return typeof v === 'number' && isFinite(v) && Math.floor(v) === v;
},
isBoolean=(v) =>{
return typeof v === 'boolean';
},
isArray=(v) =>{
return Array.isArray(v);
},
isObject=(v) =>{
return v !== null && typeof v === 'object' && !Array.isArray(v);
},
isFunction=(v) =>{
return typeof v === 'function';
},
isNull=(v) =>{
return v === null;
},
isUndefined=(v) =>{
return typeof v === 'undefined';
},
isSymbol=(v) =>{
return typeof v === 'symbol';
},
isDate=(v) =>{
return Object.prototype.toString.call(v) === '[object Date]';
},
isRegExp=(v) =>{
return Object.prototype.toString.call(v) === '[object RegExp]';
},
isError=(v) =>{
return v instanceof Error;
},
isMap=(v) =>{
return v instanceof Map;
},
isSet=(v) =>{
return v instanceof Set;
},
isWeakMap=(v) =>{
return v instanceof WeakMap;
},
isWeakSet=(v) =>{
return v instanceof WeakSet;
};
export default{
isString :isString,
isNumber :isNumber,
isInteger :isInteger,
isBoolean :isBoolean,
isArray :isArray,
isObject :isObject,
isFunction :isFunction,
isNull :isNull,
isUndefined :isUndefined,
isSymbol :isSymbol,
isDate :isDate,
isRegExp :isRegExp,
isError :isError,
isMap :isMap,
isSet :isSet,
isWeakMap :isWeakMap,
isWeakSet :isWeakSet,
cdn(v){
v= v || "";
v = v.replace(/\\/ig,"/").replace('/\/\/ig',"/");
if(_.isString(v)){
if(v.substr(0,5) == 'blob:'){
console.log(v);
if(isString(v)){
if(v.startsWith('blob:')){
return v;
}
v= v.substring(0,1) == '/' ? v : '/'+v;
if(v.startsWith('file://')){
return v;
}
v= v.startsWith('/') ? v : '/'+v;
return base.cdnUrl+''+v;
}
return "";
@@ -19,7 +91,7 @@ export default{
console.log(url);
type = type || '0'; //0 navigateTo 1 redirectTo
if(url){
if(_.isInteger(url)){
if(isInteger(url)){
uni.navigateBack({
delta:url,
})
@@ -144,5 +216,6 @@ export default{
v=v+"";
v = parseFloat(v).toFixed(wei || 2);
return parseFloat(v);
}
},
}