Compare commits

76 Commits

Author SHA1 Message Date
e9184b90c1 群通知,更新群消息页面 2022-02-25 15:05:11 +08:00
748ff74731 Merge branch 'master' of https://git.yuzhankeji.cn/TmOct5/ZhHealth 2022-02-25 15:03:51 +08:00
d3b33e3c26 permission 2022-02-25 15:03:47 +08:00
唐明明
d9f379d489 merge 2022-02-25 14:50:21 +08:00
唐明明
92d43c50bc 新增表情包组件 2022-02-25 14:50:02 +08:00
013c030963 群重复邀请处理 2022-02-25 14:45:38 +08:00
7b204e4a50 merge 2022-02-25 13:56:55 +08:00
3a28e34c3d tongbug 2022-02-25 13:56:17 +08:00
ab3d5933a8 用户的本地备注信息,暂时不链接网络 2022-02-25 12:05:48 +08:00
2a1590172e uni-modules组件升级,u-icon组件替换uni-icons,前面的那个网络不好的时候加载不出来 2022-02-25 11:17:16 +08:00
9bba6e4ef4 测试开启定位,正式打包是否可用 2022-02-25 10:05:08 +08:00
9d9c0cdaf8 登录成功后,刷新会话列表 2022-02-24 17:59:44 +08:00
e0185e589d SQLITE 数据库优化,创建时机调整 2022-02-24 17:51:59 +08:00
90584f1101 撤回消息优化 2022-02-24 16:01:51 +08:00
唐明明
31846e54a7 微调 2022-02-24 15:44:43 +08:00
唐明明
75d73e9c87 新增发送语音消息成功提示音 2022-02-24 15:40:59 +08:00
唐明明
81543cdcdc merge 2022-02-24 15:21:44 +08:00
唐明明
3ea3a2decd 新增语音时长0秒提示信息,调整取消后仍然调用发送语音的bug 2022-02-24 15:21:20 +08:00
eae895f181 最低一秒钟的消息 2022-02-24 15:11:10 +08:00
3cd11c5863 Merge branch 'master' of https://git.yuzhankeji.cn/TmOct5/ZhHealth 2022-02-24 15:04:39 +08:00
f5da4e7a2c 消息操作弹窗,删除、撤回、 2022-02-24 15:04:30 +08:00
唐明明
da6b60131d merge 2022-02-24 14:19:39 +08:00
唐明明
ae0fa1bde3 删除 'pages/im/.DS_Store' 2022-02-24 14:19:22 +08:00
唐明明
8b888e250f 优化语音录制取消功能 2022-02-24 14:15:59 +08:00
4888cf2ad1 消息撤回修复 2022-02-24 13:19:59 +08:00
0eb6be37be 好友关系解除,从会话页返回主页 2022-02-24 13:03:41 +08:00
831776f7dd 删除好友的时候,对方也删除会话 2022-02-24 12:10:06 +08:00
519caab9e5 ... 2022-02-24 11:55:00 +08:00
aead0f5ed1 .. 2022-02-24 11:53:19 +08:00
fb6f5697c7 进入到群会话的时候,更新群信息 2022-02-24 11:52:24 +08:00
4760adc504 个人中信头像可预览 2022-02-24 11:50:33 +08:00
b8291a4222 长按群主,不展示菜单 2022-02-24 11:34:28 +08:00
唐明明
33eacb2a5b merge 2022-02-24 11:28:37 +08:00
唐明明
5c5445d630 merge 2022-02-24 11:27:20 +08:00
056224881e 移除成员 2022-02-24 11:27:06 +08:00
唐明明
f77a91eafe 删除 'pages/im/.DS_Store' 2022-02-24 11:26:14 +08:00
唐明明
54cf21f211 语音播放组件新增取消发送,试听 2022-02-24 11:21:00 +08:00
唐明明
da78a3ac11 merge 2022-02-24 11:19:02 +08:00
7c4874a5e1 marge 2022-02-24 11:12:13 +08:00
6f508d906d marge 2022-02-24 11:11:38 +08:00
08ffc0fa53 修复会话列表弹出层,隐藏的问题 2022-02-24 11:06:11 +08:00
e72d6b3a91 删除公告,消息撤回优化 2022-02-24 10:56:16 +08:00
8b7a259c00 merge 2022-02-24 10:18:11 +08:00
4a31ba32f7 查看消息调准 2022-02-24 10:17:54 +08:00
32e3e0ef30 组件整理 2022-02-24 10:06:33 +08:00
a7dccde63a 组件合并,群公告指向修复 2022-02-24 10:01:22 +08:00
9c7a8c8ee1 聊天样式调整 2022-02-24 09:48:57 +08:00
18173995ab merge 2022-02-24 09:43:32 +08:00
07f707f94a voice-bug 2022-02-24 09:38:11 +08:00
d1f5f75355 ... 2022-02-24 09:36:18 +08:00
2d97294c9d 优化搜索 2022-02-24 09:35:37 +08:00
78d4611fb2 mixins优化 2022-02-24 09:28:59 +08:00
358372cdba 调整目录结构 2022-02-24 09:25:35 +08:00
ef785ab05f ... 2022-02-24 09:15:24 +08:00
8f3c741ad1 同步数据 2022-02-24 09:14:30 +08:00
f4e44de777 im-MIXINS 2022-02-23 17:28:42 +08:00
853c4611ef ... 2022-02-23 17:09:26 +08:00
1d648f2dc1 ... 2022-02-23 17:08:28 +08:00
d9748d0827 图片预览优化 2022-02-23 17:07:14 +08:00
103679c372 好友申请通知优化 2022-02-23 17:01:26 +08:00
唐明明
8c32758e37 merge 2022-02-23 16:50:38 +08:00
唐明明
29757fadeb merge 2022-02-23 16:50:26 +08:00
8a8e55600f uview新版本,search高度修复 2022-02-23 16:49:15 +08:00
768edb8e87 format 2022-02-23 16:38:14 +08:00
2ce4bb827f 消息免打扰消息同步 2022-02-23 16:35:33 +08:00
f68e5fa1fd 同步 2022-02-23 16:31:14 +08:00
8bb646a520 我的群聊+人数+默认头像四个小人 2022-02-23 16:30:35 +08:00
20317cc1df 群公告的群内提醒,链接跳转 2022-02-23 16:29:06 +08:00
a5bd5a898c 资料修改的事件通知 2022-02-23 16:06:41 +08:00
唐明明
00836ac209 合并 2022-02-23 15:54:27 +08:00
c840e9ee6b 限制群名称长度14 2022-02-23 15:46:02 +08:00
18f0ee457c 同步 2022-02-23 15:32:31 +08:00
a12d8a2c40 申请加好友认证信息优化,好友列表无好友状态处理 2022-02-23 15:30:09 +08:00
1407d677de 群解散时,无论在群组中的哪个页面,都退回到会话列表页面 2022-02-23 14:13:38 +08:00
8b10fd95fe Merge branch 'master' of https://git.yuzhankeji.cn/TmOct5/ZhHealth 2022-02-23 11:36:23 +08:00
3b3dda18ca 图片预览,版本更新的版本号调整 2022-02-23 11:36:18 +08:00
84 changed files with 3445 additions and 1640 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -12,7 +12,7 @@
// 获取系统版本号 // 获取系统版本号
getVersions({ getVersions({
platform: plus.os.name, platform: plus.os.name,
version: plus.runtime.versionCode version: plus.runtime.version
}).then(res => { }).then(res => {
if (res.update) { if (res.update) {
uni.showModal({ uni.showModal({

View File

@@ -1,3 +1,6 @@
# ZhHealth # ZhHealth
ZH健康 ZH健康
## uni-icons图标组件
[图标组件](https://hellouniapp.dcloud.net.cn/pages/extUI/icons/icons)

View File

@@ -323,6 +323,7 @@ export {
dismissGroup, dismissGroup,
inviteGroupUser, inviteGroupUser,
removeGroupUser, removeGroupUser,
transferGroupOwner,
setGroupAdmin, setGroupAdmin,
removeGroupAdmin, removeGroupAdmin,
groupMakeSure, // 通过审核 groupMakeSure, // 通过审核

25
main.js
View File

@@ -10,15 +10,16 @@ import Vue from 'vue'
import store from './store' import store from './store'
import uView from 'uview-ui' import uView from 'uview-ui'
import filters from './utils/filters.js' import filters from './utils/filters.js'
import {
usqlite
} from '@/uni_modules/onemue-USQLite/js_sdk/usqlite.js'
import model from '@/utils/im/models.js'
import { import {
router, router,
RouterMount RouterMount
} from 'router' } from 'router'
import {
usqlite
} from '@/uni_modules/onemue-USQLite/js_sdk/usqlite.js'
import {
contactModel
} from '@/utils/im/models.js'
Object.keys(filters).forEach(key => { Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key]) Vue.filter(key, filters[key])
@@ -29,12 +30,20 @@ Vue.use(router)
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$store = store Vue.prototype.$store = store
uni.$sql = usqlite
uni.model = model
uni.$sql.connect({ usqlite.connect({
name: 'zh-health', // 数据库名称 name: 'zh-health', // 数据库名称
path: '_doc/health.db', // 路径 path: '_doc/health.db', // 路径
}, (err, res) => {
uni.getStorage({
key: 'FIRST_RUN',
fail: () => {
contactModel.create((err, res) => {
console.error('SQLITE 创建表格', err, res)
uni.setStorageSync('FIRST_RUN', 'X')
})
}
})
}) })
App.mpType = 'app' App.mpType = 'app'

View File

@@ -2,8 +2,8 @@
"name" : "ZH-HEALTH", "name" : "ZH-HEALTH",
"appid" : "__UNI__C29473D", "appid" : "__UNI__C29473D",
"description" : "ZH-HEALTH您手上的健康管理专家", "description" : "ZH-HEALTH您手上的健康管理专家",
"versionName" : "1.0.13", "versionName" : "1.0.20",
"versionCode" : 113, "versionCode" : 100,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {
@@ -59,7 +59,15 @@
"autoSdkPermissions" : true "autoSdkPermissions" : true
}, },
/* ios */ /* ios */
"ios" : {}, "ios" : {
"privacyDescription" : {
"NSMicrophoneUsageDescription" : "发送语音消息以及音视频通话",
"NSCameraUsageDescription" : "发送图文消息以及视频通话",
"NSPhotoLibraryUsageDescription" : "发送图文消息",
"NSPhotoLibraryAddUsageDescription" : "保存图片消息",
"NSLocationWhenInUseUsageDescription" : "发送当前位置信息"
}
},
/* SDK */ /* SDK */
"sdkConfigs" : { "sdkConfigs" : {
"oauth" : { "oauth" : {
@@ -89,7 +97,7 @@
"amap" : { "amap" : {
"__platform__" : [ "android" ], "__platform__" : [ "android" ],
"appkey_ios" : "", "appkey_ios" : "",
"appkey_android" : "05b7f32ca9c897c8b63c505d92cd654b" "appkey_android" : "1dfbe526a37dcb1f13263e0b5871ca4d"
}, },
"system" : { "system" : {
"__platform__" : [ "android" ] "__platform__" : [ "android" ]
@@ -98,41 +106,44 @@
"maps" : { "maps" : {
"amap" : { "amap" : {
"appkey_ios" : "", "appkey_ios" : "",
"appkey_android" : "05b7f32ca9c897c8b63c505d92cd654b" "appkey_android" : "1dfbe526a37dcb1f13263e0b5871ca4d"
} }
} }
}, },
"icons" : { "icons" : {
"android" : { "android" : {
"hdpi" : "unpackage/res/icons/72x72.png", "hdpi" : "",
"xhdpi" : "unpackage/res/icons/96x96.png", "xhdpi" : "",
"xxhdpi" : "unpackage/res/icons/144x144.png", "xxhdpi" : "",
"xxxhdpi" : "unpackage/res/icons/192x192.png" "xxxhdpi" : ""
}, },
"ios" : { "ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png", "appstore" : "",
"ipad" : { "ipad" : {
"app" : "unpackage/res/icons/76x76.png", "app" : "",
"app@2x" : "unpackage/res/icons/152x152.png", "app@2x" : "",
"notification" : "unpackage/res/icons/20x20.png", "notification" : "",
"notification@2x" : "unpackage/res/icons/40x40.png", "notification@2x" : "",
"proapp@2x" : "unpackage/res/icons/167x167.png", "proapp@2x" : "",
"settings" : "unpackage/res/icons/29x29.png", "settings" : "",
"settings@2x" : "unpackage/res/icons/58x58.png", "settings@2x" : "",
"spotlight" : "unpackage/res/icons/40x40.png", "spotlight" : "",
"spotlight@2x" : "unpackage/res/icons/80x80.png" "spotlight@2x" : ""
}, },
"iphone" : { "iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png", "app@2x" : "",
"app@3x" : "unpackage/res/icons/180x180.png", "app@3x" : "",
"notification@2x" : "unpackage/res/icons/40x40.png", "notification@2x" : "",
"notification@3x" : "unpackage/res/icons/60x60.png", "notification@3x" : "",
"settings@2x" : "unpackage/res/icons/58x58.png", "settings@2x" : "",
"settings@3x" : "unpackage/res/icons/87x87.png", "settings@3x" : "",
"spotlight@2x" : "unpackage/res/icons/80x80.png", "spotlight@2x" : "",
"spotlight@3x" : "unpackage/res/icons/120x120.png" "spotlight@3x" : ""
} }
} }
},
"splashscreen" : {
"androidStyle" : "common"
} }
}, },
"nativePlugins" : { "nativePlugins" : {

BIN
pages/.DS_Store vendored

Binary file not shown.

View File

@@ -6,8 +6,10 @@
</view> </view>
<view class="content"> <view class="content">
<view class="header"> <view class="header">
<view class="name">{{ contact(item.targetId).name }} <text v-if="item.conversationType === 3" <view class="name">
class='qun'>[]</text></view> {{ contact(item.targetId).name }}
<text v-if="item.conversationType === 3" class='group'>[]</text>
</view>
<view class="time">{{ item.sentTime|timeCustomCN }}</view> <view class="time">{{ item.sentTime|timeCustomCN }}</view>
</view> </view>
<message-preview class="preview" :msg="item.latestMessage" :draft="item.draft" <message-preview class="preview" :msg="item.latestMessage" :draft="item.draft"
@@ -19,8 +21,12 @@
<script> <script>
import messagePreview from './messagePreview' import messagePreview from './messagePreview'
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import imBase from '../../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
props: { props: {
item: { item: {
type: Object, type: Object,
@@ -29,21 +35,6 @@
} }
} }
}, },
data() {
return {
avatarRpx: 84
}
},
computed: {
avatarSize() {
return utils.rpx2px(this.avatarRpx)
},
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
}
},
components: { components: {
messagePreview messagePreview
} }
@@ -80,10 +71,8 @@
.name { .name {
font-size: $title-size + 2; font-size: $title-size + 2;
color: #454545; color: #454545;
display: flex;
align-items: center;
.qun { .group {
color: $main-color; color: $main-color;
font-size: $title-size-m - 4; font-size: $title-size-m - 4;
margin-left: 4px; margin-left: 4px;

View File

@@ -1,23 +1,24 @@
<template> <template>
<view> <view>
<view v-for="(item, index) in conversations" :key="index" :class="['message', { 'is-top': item.isTop, 'is-active': pickedItem.targetId == item.targetId }]" <view class="shade" @click="hidePop" @touchmove="hidePop" v-show="showPop">
:data-item="item" @longpress="onLongPress" @click="toDetail(item)">
<message-cell :item="item" />
</view>
<view class="shade" @click="hidePop" v-show="showPop">
<view class="pop" :style="popStyle" :class="{'show':showPop}"> <view class="pop" :style="popStyle" :class="{'show':showPop}">
<view v-for="(item, index) in popButton" :key="index" @click="pickerMenu" :data-index="index"> <view v-for="(item, index) in popButton" :key="index" @click="pickerMenu(index)">
{{ item }} {{ item }}
</view> </view>
</view> </view>
</view> </view>
<view v-for="(item, index) in conversations" :key="index"
:class="['message', { 'is-top': item.isTop, 'is-active': pickedItem.targetId == item.targetId }]"
:data-item="item" @longpress="onLongPress" @click="toDetail(item)">
<message-cell :item="item" />
</view>
</view> </view>
</template> </template>
<script> <script>
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import im from '@/utils/im/index.js' import im from '@/utils/im/index.js'
import messageCell from './messageCell' import messageCell from './conversation/messageCell'
export default { export default {
props: { props: {
@@ -65,9 +66,7 @@
}, 250) }, 250)
}, },
// 点击会话功能菜单 // 点击会话功能菜单
pickerMenu(e) { pickerMenu(index) {
const index = Number(e.currentTarget.dataset.index)
if (index == 0) { if (index == 0) {
RongIMLib.setConversationToTop(this.pickedItem.conversationType, this.pickedItem.targetId, !this RongIMLib.setConversationToTop(this.pickedItem.conversationType, this.pickedItem.targetId, !this
.pickedItem.isTop) .pickedItem.isTop)
@@ -142,8 +141,10 @@
position: fixed; position: fixed;
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 999;
.pop { .pop {
border-radius: 10rpx;
position: fixed; position: fixed;
z-index: 101; z-index: 101;
width: 200rpx; width: 200rpx;

View File

@@ -1,7 +1,7 @@
<template> <template>
<view class="apply--cell"> <view class="apply--cell">
<view class="avatar"> <view class="avatar">
<u-avatar :src="user.portraitUrl || require('@/static/user/cover.png')" shape="square" size="46" /> <u-avatar :src="user.portraitUrl || require('@/static/user/cover.png')" shape="square" :size="avatarSize" />
</view> </view>
<view class="info"> <view class="info">
<view class="name"> {{ user.name }}</view> <view class="name"> {{ user.name }}</view>
@@ -20,8 +20,12 @@
resolveFriend, resolveFriend,
rejectFriend rejectFriend
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
props: { props: {
message: { message: {
type: Object, type: Object,
@@ -36,7 +40,6 @@
methods: { methods: {
resolve() { resolve() {
resolveFriend(this.message.sourceUserId).then(res => { resolveFriend(this.message.sourceUserId).then(res => {
this.clearMessages()
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '通过好友申请' title: '通过好友申请'
@@ -47,6 +50,8 @@
icon: 'none', icon: 'none',
title: err.message title: err.message
}) })
}).finally(() => {
this.clearMessages()
}) })
}, },
reject() { reject() {
@@ -70,7 +75,9 @@
clearMessages() { clearMessages() {
RongIMLib.deleteMessages(RongIMLib.ConversationType.SYSTEM, this.message.sourceUserId) RongIMLib.deleteMessages(RongIMLib.ConversationType.SYSTEM, this.message.sourceUserId)
this.$emit('success') this.$emit('success')
uni.$emit('onContactNotification') uni.$emit('onNewContactConversation')
uni.$emit('onNewContactFriends')
uni.$emit('onNewContactPendings')
} }
} }
} }

View File

@@ -3,7 +3,7 @@
<block v-for="(item, index) in lists" v-if="lists.length > 0" :key="index"> <block v-for="(item, index) in lists" v-if="lists.length > 0" :key="index">
<view class="lists"> <view class="lists">
<view class="" style="width: 100rpx;height: 100rpx;"> <view class="" style="width: 100rpx;height: 100rpx;">
<u-avatar :src="JSON.parse(item.latestMessage.extra).portraitUrl" shape="square" size="44" /> <u-avatar :src="JSON.parse(item.latestMessage.extra).portraitUrl" shape="square" :size="avatarSize" />
</view> </view>
<view class="right"> <view class="right">
<view class="title"> <view class="title">
@@ -14,7 +14,8 @@
<span v-if="isAgree" @click="action('agree', item)">通过</span> <span v-if="isAgree" @click="action('agree', item)">通过</span>
<span v-if="isAgree" @click="action('reject', item)">拒绝</span> <span v-if="isAgree" @click="action('reject', item)">拒绝</span>
<span v-if="isApply && !item.is_friend" @click="action('apply', item)">查看</span> <span v-if="isApply && !item.is_friend" @click="action('apply', item)">查看</span>
<span class="isFri" v-if="isApply && item.is_friend" @click="action('isFriend', item)">已是好友</span> <span class="isFri" v-if="isApply && item.is_friend"
@click="action('isFriend', item)">已是好友</span>
</view> </view>
</view> </view>
</view> </view>
@@ -23,7 +24,12 @@
</template> </template>
<script> <script>
import imBase from '../mixins/imBase.js'
export default { export default {
mixins:[
imBase
],
name: 'friend-apply-reject-agree', name: 'friend-apply-reject-agree',
props: { props: {
lists: { lists: {
@@ -50,9 +56,16 @@ export default {
action(type, item) { action(type, item) {
if (type === 'isFriend') { if (type === 'isFriend') {
// ,后期可以跳转到信息介绍页面,先留在这里 // ,后期可以跳转到信息介绍页面,先留在这里
return uni.showToast({ title: '已是好友,无需重复添加', icon: 'none', duration:2000}); return uni.showToast({
title: '已是好友,无需重复添加',
icon: 'none',
duration: 2000
});
} }
this.$emit('action', { type, item }); this.$emit('action', {
type,
item
});
} }
} }
}; };
@@ -72,6 +85,7 @@ export default {
.cover { .cover {
background-color: #ffffff; background-color: #ffffff;
} }
.right { .right {
width: 570rpx; width: 570rpx;
margin-left: $margin - 10; margin-left: $margin - 10;
@@ -81,8 +95,10 @@ export default {
justify-content: space-between; justify-content: space-between;
padding: $padding 0; padding: $padding 0;
border-bottom: solid 1rpx #f9f9f9; border-bottom: solid 1rpx #f9f9f9;
.title { .title {
width: 370rpx; width: 370rpx;
.name { .name {
width: 100%; width: 100%;
color: $text-color; color: $text-color;
@@ -91,6 +107,7 @@ export default {
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.des { .des {
width: 100%; width: 100%;
flex: 1; flex: 1;
@@ -102,20 +119,24 @@ export default {
color: $text-gray-m; color: $text-gray-m;
} }
} }
.agress-btn { .agress-btn {
display: flex; display: flex;
color: #fff; color: #fff;
font-size: $title-size-m; font-size: $title-size-m;
span { span {
display: inline-block; display: inline-block;
padding: 6rpx 14rpx; padding: 6rpx 14rpx;
background-color: $text-price; background-color: $text-price;
border-radius: 10rpx; border-radius: 10rpx;
} }
span:nth-child(1) { span:nth-child(1) {
background-color: $main-color; background-color: $main-color;
margin-right: 10rpx; margin-right: 10rpx;
} }
.isFri { .isFri {
background-color: #f9f9f9 !important; background-color: #f9f9f9 !important;
color: #666; color: #666;

View File

@@ -3,7 +3,7 @@
<block v-for="(item, index) in lists" v-if="lists.length > 0" :key="index"> <block v-for="(item, index) in lists" v-if="lists.length > 0" :key="index">
<view class="lists"> <view class="lists">
<view class="" style="width: 100rpx;height: 100rpx;"> <view class="" style="width: 100rpx;height: 100rpx;">
<u-avatar :src="item.portraitUrl || require('@/static/user/cover.png')" shape="square" size="44" /> <u-avatar :src="item.portraitUrl || require('@/static/user/cover.png')" shape="square" :size="avatarSize" />
</view> </view>
<view class="right"> <view class="right">
<view class="title"> <view class="title">
@@ -21,7 +21,12 @@
</template> </template>
<script> <script>
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
name: 'friend-apply-reject-agree', name: 'friend-apply-reject-agree',
props: { props: {
lists: { lists: {

View File

@@ -18,9 +18,8 @@
</view> </view>
</view> </view>
<view class="loadmore"> <view class="loadmore" @click="loadMore" v-if="members > users.length">
<u-icon name="arrow-right" @click="loadMore" v-if="members > users.length" color="#999" labelColor="#999" 查看更多群成员 <uni-icons size="30rpx" type="right"></uni-icons>
label="查看更多群成员" labelPos="left" :labelSize="labelSize" :size="iconSize" />
</view> </view>
<u-action-sheet :actions="actionMap" :title="actionTitle" cancelText="取消" @close="hideAction" <u-action-sheet :actions="actionMap" :title="actionTitle" cancelText="取消" @close="hideAction"
@@ -38,8 +37,12 @@
transferGroupOwner transferGroupOwner
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
props: { props: {
targetId: { targetId: {
type: String, type: String,
@@ -62,28 +65,16 @@
actionMap: [], actionMap: [],
actionTitle: '', actionTitle: '',
currentUser: {}, currentUser: {},
avatarSize: 45,
labelSize: 14, labelSize: 14,
iconSize: 14 iconSize: 14
}
},
computed: {
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
} }
}, },
created() { created() {
this.avatarSize = utils.rpx2px(90)
this.labelSize = utils.rpx2px(24)
this.iconSize = utils.rpx2px(26) this.iconSize = utils.rpx2px(26)
}, },
mounted() { mounted() {
this.initGroupInfo() this.initGroupInfo()
getGroupUsers(this.targetId, this.count).then(res => { getGroupUsers(this.targetId, this.count).then(res => {
console.log("res..",res)
this.users = res this.users = res
res.map(item => { res.map(item => {
this.$store.dispatch('updateContact', item) this.$store.dispatch('updateContact', item)
@@ -110,6 +101,9 @@
this.actionShow = false this.actionShow = false
}, },
showAction(item) { showAction(item) {
if (item.is_admin == 2) {
return
}
this.currentUser = item this.currentUser = item
this.actionTitle = item.name this.actionTitle = item.name
// 只有管理员以上才会弹窗 // 只有管理员以上才会弹窗
@@ -278,7 +272,6 @@
border-radius: 0 8rpx 0 0; border-radius: 0 8rpx 0 0;
position: relative; position: relative;
width: 84rpx; width: 84rpx;
height: 84rpx;
overflow: hidden; overflow: hidden;
.admin { .admin {
@@ -327,12 +320,16 @@
.loadmore { .loadmore {
font-size: 26rpx; font-size: 26rpx;
color: $text-gray-m; color: $text-gray-m !important;
text-align: center; text-align: center;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-sizing: border-box; box-sizing: border-box;
.uni-icons {
color: $text-gray-m !important;
}
} }
</style> </style>

View File

@@ -0,0 +1,79 @@
<template>
<view class="emoji--lay" v-show="show">
<scroll-view class="scroll" :scroll-y="true">
<view class="emoji-flex">
<view class="item" v-for="(item, index) in emojiArr" :key="index" @click="$emit('onEmoji', item)">{{item.emoji}}</view>
</view>
</scroll-view>
<view class="tool">
<!-- <view class="item" @click="$emit('delete')">删除</view> -->
<view class="item sent" @click="$emit('sent')">发送</view>
</view>
</view>
</template>
<script>
import emoji from '@/static/im/emoji'
export default{
props:{
show: {
type: Boolean,
default: () => {
return false
}
}
},
data(){
return {
emojiArr: emoji
}
}
}
</script>
<style lang="scss" scoped>
.emoji--lay{
height: 600rpx;
position: relative;
.scroll{
height: 600rpx;
.emoji-flex{
padding: 15rpx 15rpx 120rpx;
display: flex;
flex-wrap: wrap;
.item{
margin: 10rpx 15rpx;
font-size: 52rpx;
width: calc(12.5% - 30rpx);
box-sizing: border-box;
}
}
}
.tool{
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-image: linear-gradient(to top, #FFF, rgba(255, 255, 255, .0));
display: flex;
justify-content: flex-end;
padding: 20rpx 30rpx 30rpx;
.item{
line-height: 70rpx;
border-radius: 35rpx;
width: 140rpx;
text-align: center;
font-size: 28rpx;
margin-left: 20rpx;
background: white;
border: solid 1rpx #f5f5f5;
box-sizing: border-box;
&.sent{
border-color: #34CE98;
background: #34CE98;
color: white;
}
}
}
}
</style>

View File

@@ -33,9 +33,12 @@
<script> <script>
import im from '@/utils/im/index.js' import im from '@/utils/im/index.js'
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index' import imBase from '../../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
data() { data() {
return { return {
callActions: [{ callActions: [{
@@ -64,15 +67,11 @@
default: '' default: ''
} }
}, },
computed: {
sender() {
return this.$store.getters.sender
}
},
methods: { methods: {
singleCall(e) { singleCall(e) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type + '&isCall=true' url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type +
'&isCall=true'
}) })
}, },
onPopupsItem(type) { onPopupsItem(type) {
@@ -104,16 +103,11 @@
this.callShow = true this.callShow = true
break; break;
case 'location': case 'location':
// uni.showToast({ uni.chooseLocation({
// icon: 'none', success: (c) => {
// title: '' console.log(c);
// }) }
// uni.chooseLocation({ })
// success: res => {
// console.log(res);
// // this.success()
// }
// })
break; break;
case 'redpacket': case 'redpacket':
uni.showToast({ uni.showToast({
@@ -144,6 +138,7 @@
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row; flex-direction: row;
.item { .item {
width: 150rpx; width: 150rpx;
margin: 15rpx; margin: 15rpx;

View File

@@ -1,15 +1,29 @@
<template> <template>
<view class="sent--text"> <view class="sent--text">
<input class="input" type="text" :auto-blur="true" @focus="focus" @blur="blur" :focus="focusState" <input
v-model="inputTxt" confirm-type="send" @confirm="sent" cursor-spacing="10" /> class="input"
type="text"
:auto-blur="true"
:focus="focusState"
v-model="inputTxt"
confirm-type="send"
cursor-spacing="10"
@focus="focus"
@blur="blur"
@confirm="sent"
/>
</view> </view>
</template> </template>
<script> <script>
import im from '@/utils/im/index.js' import im from '@/utils/im/index.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import imBase from '../../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
props: { props: {
conversationType: { conversationType: {
type: Number, type: Number,
@@ -24,9 +38,6 @@
disabled() { disabled() {
return this.inputTxt.length === 0 return this.inputTxt.length === 0
}, },
sender() {
return this.$store.getters.sender
}
}, },
mounted() { mounted() {
RongIMLib.getTextMessageDraft(this.conversationType, this.targetId, ({ RongIMLib.getTextMessageDraft(this.conversationType, this.targetId, ({
@@ -45,6 +56,12 @@
inputTxt: '' inputTxt: ''
} }
}, },
created(){
uni.$on('emojiValue', res => {
this.inputTxt = res.value
})
},
methods: { methods: {
sent() { sent() {
if (!this.disabled) { if (!this.disabled) {
@@ -58,10 +75,13 @@
focus() { focus() {
this.$emit('focus') this.$emit('focus')
}, },
blur() { blur(e) {
uni.hideKeyboard() uni.hideKeyboard()
this.$emit('blur') this.$emit('blur', e.detail)
} }
},
destroyed() {
uni.$off('emojiValue')
} }
} }
</script> </script>
@@ -71,11 +91,10 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
.input { .input {
background: #F3F6FB; background: #F3F6FB;
height: 70rpx; height: 70rpx;
width: 500rpx; width: 400rpx;
border-radius: 10rpx; border-radius: 10rpx;
margin-right: 15rpx; margin-right: 15rpx;
padding: 0 20rpx; padding: 0 20rpx;

View File

@@ -0,0 +1,301 @@
<template>
<view class="send--voice">
<view class="voice" hover-class="chat-hover" @touchstart="startRecord" @touchend="stopRecord" @touchmove="touchmove">
<text class="button">按住 说话</text>
</view>
<!-- 录音层 -->
<view class="lay" v-if="showRecordTip">
<view class="lay-header">
<view class="modal">
<image class="icon" src="@/static/icon/record-icon.png" mode="widthFix"></image>
<text class="text">录音中 {{recordTime}} s</text>
</view>
</view>
<view class="lay-toast">上滑取消</view>
<view class="lay-footer">
<image class="lay-footer-icon videoFlicker" src="@/static/icon/audio_green.png" mode="widthFix"></image>
<view class="lay-footer-text">松开发送</view>
</view>
</view>
</view>
</template>
<script>
import im from '@/utils/im/index.js'
import permision from '@/utils/permission.js'
import imBase from '../../mixins/imBase.js'
export default {
mixins: [
imBase
],
props: {
conversationType: {
type: Number,
default: 0
},
targetId: {
type: String,
default: ''
}
},
data() {
return {
showRecordTip: false,
recordTime: 60,
interval: 0,
maxRecordTime: 60,
recorderManager: null,
mp3AudioSrc: null,
isMoveCancel: false,
isBetaPlay: false, // 暂时无用
startOffsetTop: 0
}
},
computed: {
sender() {
return this.$store.getters.sender
}
},
created() {
this.recorderManager = uni.getRecorderManager()
},
methods: {
// 检查安卓录制权限
async getAndroidPermission() {
return await permision.requestAndroidPermission('android.permission.RECORD_AUDIO')
},
// 录制语音消息
startRecord(e) {
this.getAndroidPermission().then(code => {
switch (code) {
case 1:
this.startOffsetTop = e.target.offsetTop
this.showRecordTip = true
this.recorderManager.start()
this.interval = setInterval(() => {
this.recordTime -= 1
if (this.recordTime === 0) {
this.stopRecord()
}
}, 1000)
break;
case 0:
uni.showToast({
title: '暂无麦克风权限,请前往应用设置开启麦克风',
icon: 'none'
})
break;
case -1:
uni.showToast({
title: '应用权限错误',
icon: 'none'
})
break;
}
})
},
// 结束录音
stopRecord(e) {
if (!this.showRecordTip) return
// 延迟500毫秒结束录音
setTimeout(()=> {
this.recorderManager.stop()
clearInterval(this.interval)
// 监听录音结束
this.recorderManager.onStop(res => {
if(this.isMoveCancel) {
this.isMoveCancel = false
return
}
if((this.maxRecordTime - this.recordTime) <= 0){
uni.showToast({
title: '说话时间太短',
icon : 'none',
})
this.showRecordTip = false
return
}
this.mp3AudioSrc = res.tempFilePath
this.showRecordTip = false
this.senVoice()
})
},500)
},
// 发送语音消息
senVoice(){
if(this.mp3AudioSrc === null) {
uni.showToast({
title: '发送失败, 暂无音频信息',
icon : 'none'
})
return
}
im.sentVoice(this.conversationType, this.targetId, this.mp3AudioSrc, (this.maxRecordTime -
this.recordTime), this.sender, () => {
this.recordTime = this.maxRecordTime
this.mp3AudioSrc = null
setTimeout(() => {
this.$emit('success')
this.toastAudiMp3()
}, 500)
})
},
// 移动按钮
touchmove(e){
if(this.startOffsetTop - e.changedTouches[0].pageY > 100){
if(this.showRecordTip){
this.isMoveCancel = true
this.showRecordTip = false
this.recorderManager.stop()
clearInterval(this.interval)
this.recordTime = this.maxRecordTime
this.mp3AudioSrc = null
return
}
}
},
// 试听语音
startPlay() {
let betaAudio = uni.createInnerAudioContext()
betaAudio.src = this.mp3AudioSrc;
// 在播放中
if(this.isBetaPlay){
betaAudio.stop()
betaAudio.onStop(() => {
this.isBetaPlay = false;
betaAudio.destroy()
})
return
}
// 监听音频播放中
betaAudio.play()
betaAudio.onPlay(() => {
this.isBetaPlay = true;
})
// 监听音频结束
betaAudio.onEnded(() => {
this.isBetaPlay = false;
betaAudio.destroy()
})
},
// 播放提示音乐
toastAudiMp3(){
let toastAudio = uni.createInnerAudioContext()
toastAudio.src = require('@/static/im/toast/sentVoice.mp3')
toastAudio.autoplay = true
toastAudio.volume = .1
toastAudio.onEnded(() => {
toastAudio.destroy()
})
}
}
}
</script>
<style>
@keyframes playFlicker {
0% {
opacity: 1;
}
50% {
opacity: .5;
}
100% {
opacity: 1;
}
}
.videoFlicker {
animation: playFlicker 1s infinite;
}
</style>
<style scoped lang="scss">
.send--voice {
.voice {
display: flex;
background: $window-color;
height: 70rpx;
line-height: 70rpx;
justify-content: center;
align-items: center;
width: 400rpx;
border-radius: 10rpx;
margin-right: 15rpx;
padding: 0 20rpx;
font-weight: bold;
.button {
font-size: 30rpx;
color: #333;
}
}
.lay{
position: absolute;
left: 0;
top: 0;
z-index: 9;
background: rgba($color: #000000, $alpha: .5);
height: 100vh;
width: 100vw;
box-sizing: border-box;
.lay-header{
height: calc(100vh - 140px);
display: flex;
justify-content: center;
align-items: center;
.modal {
display: flex;
background: rgba(0, 0, 0, .6);
position: fixed;
height: 200rpx;
width: 300rpx;
border-radius: 10rpx;
z-index: 99;
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
width: 88rpx;
height: 88rpx;
}
.text {
font-size: 28rpx;
color: #FFFFFF;
}
}
}
.lay-toast{
text-align: center;
color: rgba($color: #fff, $alpha: .8);
font-size: 28rpx;
}
.lay-footer{
background-color: white;
height: 100px;
border-radius: 50% 50% 0 0;
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
.lay-footer-icon{
width: 58rpx;
height: 58rpx;
}
.lay-footer-text{
line-height: 40rpx;
color: gray;
font-size: 28rpx;
}
}
}
}
</style>

View File

@@ -7,18 +7,27 @@
<image class="icon" src="@/static/icon/msg-icon.png" v-if="chatType === 1" mode="widthFix" /> <image class="icon" src="@/static/icon/msg-icon.png" v-if="chatType === 1" mode="widthFix" />
</view> </view>
<sent-voice v-if="chatType === 0" :conversationType="conversationType" :targetId="targetId" @success="onSuccess" /> <sent-voice v-if="chatType === 0" :conversationType="conversationType" :targetId="targetId" @success="onSuccess" />
<sent-text v-if="chatType === 1" :conversationType="conversationType" :targetId="targetId" @success="onSuccess" /> <sent-text ref="textView" v-if="chatType === 1" :conversationType="conversationType" :targetId="targetId" @success="onSuccess" @blur="onBlur" />
<view class="msg-type msg-popups" @click="showPopups = !showPopups"> <image class="icon" src="@/static/icon/popups-icon.png" /> </view> <view class="msg-type msg-popups" @click="onShowEmoji">
<image class="icon" src="@/static/icon/emoji-icon.png" />
<!-- 考虑唤起键盘暂时保留v-show -->
<!-- <image v-show="!showEmoji" class="icon" src="@/static/icon/emoji-icon.png" /> -->
<!-- <image v-show="showEmoji" class="icon" src="@/static/icon/key-icon.png" /> -->
</view>
<view class="msg-type msg-popups" @click="() => {showPopups = !showPopups, showEmoji = false}"> <image class="icon" src="@/static/icon/popups-icon.png" /> </view>
</view> </view>
<!-- 弹出层 --> <!-- 弹出层 -->
<sent-popups :show="showPopups" :conversationType="conversationType" :targetId="targetId" @success="() => {showPopups = false, onSuccess()}" /> <sent-popups :show="showPopups" :conversationType="conversationType" :targetId="targetId" @success="() => {showPopups = false, onSuccess()}" />
<!-- 表情包 -->
<sent-emoji :show="showEmoji" @onEmoji="onEmoji" @delete="onDelete" @sent="onSent"></sent-emoji>
</view> </view>
</template> </template>
<script> <script>
import sentText from './sentText' import sentText from './sent/sentText'
import sentVoice from './sentVoice' import sentVoice from './sent/sentVoice'
import sentPopups from './sentPopups' import sentPopups from './sent/sentPopups'
import sentEmoji from './sent/sentEmoji'
export default { export default {
props: { props: {
@@ -34,18 +43,26 @@
components: { components: {
sentText, sentText,
sentVoice, sentVoice,
sentPopups sentPopups,
sentEmoji
}, },
data() { data() {
return { return {
chatType : 1, // 0 语音1 文本 chatType : 1, // 0 语音1 文本
showPopups: false showPopups : false,
showEmoji : false,
chatText : {
value : "",
cursor : 0
}
} }
}, },
methods: { methods: {
// 切换聊天类型,语音/文本 // 切换聊天类型,语音/文本
changeMessageType() { changeMessageType() {
this.chatType = this.chatType === 1 ? 0 : 1 this.chatType = this.chatType === 1 ? 0 : 1
if(this.showEmoji) this.showEmoji = false
if(this.showPopups) this.showPopups = false
}, },
onSuccess() { onSuccess() {
this.$emit('onSuccess') this.$emit('onSuccess')
@@ -55,6 +72,39 @@
if(this.showPopups){ if(this.showPopups){
this.showPopups = false this.showPopups = false
} }
},
// 输入表情
onEmoji(e){
let atMsg = this.chatText
let newMsg = () => {
return atMsg.value.slice(0, atMsg.cursor) + e.emoji + atMsg.value.slice(atMsg.cursor)
}
atMsg.value = newMsg()
atMsg.cursor += 2
// 全局通讯
uni.$emit('emojiValue', atMsg)
},
// 删除表情
onDelete(){
console.log('删除')
},
// 发送消息
onSent(){
this.$refs.textView.sent()
this.chatText = {
value : "",
cursor : 0
}
},
// 获取输入框文字最新状态
onBlur(e){
this.chatText = e
},
// 显示emoji表情
onShowEmoji(){
this.showEmoji = !this.showEmoji
this.chatType = 1
if(this.showPopups) this.showPopups = false
} }
} }
} }

View File

@@ -1,143 +0,0 @@
<template>
<view class="send--voice">
<view class="voice" hover-class="chat-hover" @touchstart="startRecord" @touchend="stopRecord">
<text class="button">按住说话</text>
</view>
<!-- 录音中提示 -->
<view class="modal" v-if="showRecordTip">
<image class="icon" src="@/static/icon/record-icon.png" mode="widthFix"></image>
<text class="text">录音中 {{recordTime}} s</text>
</view>
</view>
</template>
<script>
import im from '@/utils/im/index.js'
import permision from '@/utils/permission.js'
export default {
props: {
conversationType: {
type: Number,
default: 0
},
targetId: {
type: String,
default: ''
}
},
data() {
return {
showRecordTip: false,
recordTime: 60,
interval: 0,
maxRecordTime: 60,
recorderManager: null
}
},
computed: {
sender() {
return this.$store.getters.sender
}
},
created() {
this.recorderManager = uni.getRecorderManager()
},
methods: {
// 检查安卓录制权限
async getAndroidPermission() {
return await permision.requestAndroidPermission('android.permission.RECORD_AUDIO')
},
// 录制语音消息
startRecord() {
this.getAndroidPermission().then(code => {
switch (code) {
case 1:
this.showRecordTip = true
this.recorderManager.start()
this.interval = setInterval(() => {
this.recordTime -= 1
if (this.recordTime === 0) {
this.stopRecord()
}
}, 1000)
break;
case 0:
uni.showToast({
title: '暂无麦克风权限,请前往应用设置开启麦克风',
icon: 'none'
})
break;
case -1:
uni.showToast({
title: '应用权限错误',
icon: 'none'
})
break;
}
})
},
// 结束录音
stopRecord(e) {
if (!this.showRecordTip) return
this.recorderManager.stop()
clearInterval(this.interval)
// 监听录音结束
this.recorderManager.onStop(res => {
im.sentVoice(this.conversationType, this.targetId, res.tempFilePath, (this.maxRecordTime -
this.recordTime), this.sender, () => {
setTimeout(() => {
this.$emit('success')
}, 500)
})
this.recordTime = this.maxRecordTime
this.showRecordTip = false
})
},
}
}
</script>
<style scoped lang="scss">
.send--voice {
.voice {
display: flex;
background: $window-color;
height: 70rpx;
line-height: 70rpx;
justify-content: center;
align-items: center;
width: 500rpx;
border-radius: 10rpx;
margin-right: 15rpx;
.button {
font-size: 30rpx;
color: #333;
}
}
.modal {
display: flex;
background: rgba(0, 0, 0, .6);
position: fixed;
height: 200rpx;
width: 300rpx;
border-radius: 10rpx;
z-index: 99;
top: 550rpx;
left: 225rpx;
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
width: 88rpx;
height: 88rpx;
}
.text {
font-size: 28rpx;
color: #FFFFFF;
}
}
}
</style>

View File

@@ -2,18 +2,12 @@
<view v-if="!isRemote"> <view v-if="!isRemote">
<view class="state" v-if="isGroup"> <view class="state" v-if="isGroup">
<!-- 已发送 --> <!-- 已发送 -->
<u-icon name="checkbox-mark" :size="iconSize" class="sent" <uni-icons class="sent" type="checkmarkempty" size="28rpx" :color="message.sentStatus >= 30 ? '#34CE98' : '#999999'" />
:color="message.sentStatus >= 30 ? '#34CE98' : '#999999' " />
<!-- 已阅读 -->
<text class="readers">{{ readers }}</text> <text class="readers">{{ readers }}</text>
</view> </view>
<view class="state" v-else> <view class="state" v-else>
<!-- 已发送 --> <uni-icons class="sent" type="checkmarkempty" size="28rpx" :color="message.sentStatus >= 30 ? '#34CE98' : '#999999'" />
<u-icon name="checkbox-mark" :size="iconSize" class="sent" <uni-icons class="receive" type="checkmarkempty" size="28rpx" :color="message.sentStatus >= 50 ? '#34CE98' : '#999999'" />
:color="message.sentStatus >= 30 ? '#34CE98' : '#999999' " />
<!-- 已阅读 -->
<u-icon name="checkbox-mark" :size="iconSize" class="receive"
:color="message.sentStatus >= 50 ? '#34CE98' : '#999999' " />
</view> </view>
</view> </view>
</template> </template>

View File

@@ -2,8 +2,9 @@
<view class="msg--call"> <view class="msg--call">
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view> <view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
<view class="im--text" :class="isRemote ? 'left': 'right'"> <view class="im--text" :class="isRemote ? 'left': 'right'">
<u-icon name="camera" size="22" v-if="msg.mediaType == 1" :label="label" /> <uni-icons type="videocam" size="44rpx" v-if="msg.mediaType == 1" />
<u-icon name="phone" size="22" v-else :label="label" /> <uni-icons type="phone" size="40rpx" v-else />
{{ label }}
</view> </view>
</view> </view>
</template> </template>
@@ -11,8 +12,12 @@
<script> <script>
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import moment from 'moment' import moment from 'moment'
import imBase from '../../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
name: 'showText', name: 'showText',
props: { props: {
message: { message: {
@@ -38,11 +43,6 @@
isRemote() { isRemote() {
return this.message.messageDirection == 2 return this.message.messageDirection == 2
}, },
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
},
duration() { duration() {
if (this.message.duration > 3600) { if (this.message.duration > 3600) {
return moment.utc(this.message.duration * 1000).format('HH:mm:ss') return moment.utc(this.message.duration * 1000).format('HH:mm:ss')
@@ -70,6 +70,7 @@
color: $text-color; color: $text-color;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center;
&.left { &.left {
border-radius: 0 20rpx 20rpx 20rpx; border-radius: 0 20rpx 20rpx 20rpx;
@@ -81,8 +82,8 @@
background: $main-color; background: $main-color;
color: white; color: white;
.u-icon { .uni-icons {
color: white; color: white !important;
} }
} }
} }

View File

@@ -14,8 +14,12 @@
<script> <script>
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import messageState from './messageState' import messageState from './messageState'
import imBase from '../../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
name: 'showImage', name: 'showImage',
props: { props: {
message: { message: {
@@ -38,51 +42,30 @@
}, },
content() { content() {
return this.message.content return this.message.content
},
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
} }
}, },
methods: { methods: {
previewImage() { showImage(path) {
if (this.content.local) {
uni.previewImage({
urls: [
this.content.local
],
success: (e) => {
console.log(e);
},
fail: (er) => {
console.log(er);
}
})
} else {
RongIMLib.downloadMediaMessage(this.messageId, {
success: (path) => {
this.content.local = path
uni.previewImage({ uni.previewImage({
urls: [ urls: [
path path
], ]
success: (e) => {
console.log(e);
},
fail: (er) => {
console.log(er);
}
}) })
}, },
progress: (progress, messageId) => { previewImage() {
console.log('progress', progress); if (this.content.local && this.content.local.indexOf('///data/user/') < 0) {
}, this.showImage(this.content.local)
cancel: (messageId) => { } else {
console.log('cancel', messageId); this.showImage(this.content.remote)
RongIMLib.downloadMediaMessage(this.message.messageId, {
success: (path) => {
this.content.local = path
}, },
error: (errorCode, messageId) => { error: (errorCode, messageId) => {
console.log('errorCode', errorCode); uni.showToast({
icon: 'none',
title: errorCode
})
} }
}) })
} }

View File

@@ -11,9 +11,13 @@
<script> <script>
import messageState from './messageState' import messageState from './messageState'
import imBase from '../../mixins/imBase.js'
export default { export default {
name: 'showText', name: 'showText',
mixins: [
imBase,
],
props: { props: {
message: { message: {
type: Object, type: Object,
@@ -35,11 +39,6 @@
}, },
content() { content() {
return this.message.content.content return this.message.content.content
},
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
} }
} }
} }
@@ -58,7 +57,7 @@
.text { .text {
box-sizing: border-box; box-sizing: border-box;
max-width: 502rpx; max-width: 502rpx;
padding: 20rpx; padding: 20rpx 24rpx;
line-height: 46rpx; line-height: 46rpx;
font-size: 32rpx; font-size: 32rpx;
color: $text-color; color: $text-color;

View File

@@ -23,8 +23,12 @@
<script> <script>
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import messageState from './messageState' import messageState from './messageState'
import imBase from '../../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
props: { props: {
message: { message: {
type: Object, type: Object,
@@ -54,11 +58,6 @@
isRemote() { isRemote() {
return this.message.messageDirection == 2 return this.message.messageDirection == 2
}, },
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
},
width() { width() {
if (this.duration > 3) { if (this.duration > 3) {
return (this.duration * 5) + 150 return (this.duration * 5) + 150
@@ -75,11 +74,6 @@
} }
}) })
}, },
created() {
console.log(this.message.messageId)
},
methods: { methods: {
// 播放语音消息 // 播放语音消息
startPlay() { startPlay() {

View File

@@ -1,13 +1,17 @@
<template> <template>
<view class=""> <view class="">
<view class="notify" v-if="message.objectName === 'RC:GrpNtf'">{{ message.content.message }}</view> <view class="notify" v-if="message.objectName === 'RC:GrpNtf'">
{{ message.content.message }}
<text class="link" @click="toAnnounce(message)" v-if="message.content.operation == 'ANNOUNCEMENT'">点击查看
</text>
</view>
<view class="notify" v-else-if="message.objectName === 'RC:RcNtf'"> <view class="notify" v-else-if="message.objectName === 'RC:RcNtf'">
{{ contact(message.senderUserId).name }} 撤回了一条消息 {{ contact(message.senderUserId).name }} 撤回了一条消息
</view> </view>
<view v-else :class="['cell-item', message.messageDirection == 1 ? 'right' : 'left']"> <view v-else :class="['cell-item', message.messageDirection == 1 ? 'right' : 'left']">
<u-avatar class="avatar" @click="toUser(message)" :size="avatarSize" shape="square" <u-avatar class="avatar" @click="toUser(message)" :size="avatarSize" shape="square"
:src="contact(message.senderUserId).portraitUrl" /> :src="contact(message.senderUserId).portraitUrl" />
<view class="msg" @longpress="backMessage"> <view class="msg" @longpress="messageAction($event, message)">
<show-text v-if="message.objectName === 'RC:TxtMsg'" :message="message" :isGroup="isGroup" /> <show-text v-if="message.objectName === 'RC:TxtMsg'" :message="message" :isGroup="isGroup" />
<show-voice v-else-if="message.objectName === 'RC:HQVCMsg'" :message="message" :isGroup="isGroup" /> <show-voice v-else-if="message.objectName === 'RC:HQVCMsg'" :message="message" :isGroup="isGroup" />
<show-image v-else-if="message.objectName === 'RC:ImgMsg'" :message="message" :isGroup="isGroup" /> <show-image v-else-if="message.objectName === 'RC:ImgMsg'" :message="message" :isGroup="isGroup" />
@@ -22,14 +26,21 @@
</template> </template>
<script> <script>
import {
getGroupAnnouncement
} from '@/apis/interfaces/im.js'
import * as IMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as IMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import showVoice from './show/showVoice' import showVoice from './show/showVoice'
import showImage from './show/showImage' import showImage from './show/showImage'
import showText from './show/showText' import showText from './show/showText'
import showCall from './show/showCall' import showCall from './show/showCall'
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
components: { components: {
showCall, showCall,
showVoice, showVoice,
@@ -48,22 +59,13 @@
default: false default: false
} }
}, },
data() {
return {
avatarRpx: 84
}
},
computed: {
avatarSize() {
return utils.rpx2px(this.avatarRpx)
},
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
}
},
methods: { methods: {
messageAction(event, message) {
this.$emit('messageAction', {
event,
message
})
},
toUser(item) { toUser(item) {
if (item.messageDirection == 1) { if (item.messageDirection == 1) {
uni.navigateTo({ uni.navigateTo({
@@ -75,40 +77,34 @@
}) })
} }
}, },
// 撤回消息测试 // 跳转群公告
backMessage() { toAnnounce(message) {
if (this.$store.getters.sender.userId != this.message.senderUserId) { if (message.content.extra) {
uni.showToast({ getGroupAnnouncement(message.targetId, message.content.extra).then(res => {
icon: 'none', uni.navigateTo({
title: '不能撤回别人的消息' url: '/pages/im/group/announceCreate?type=check&targetId=' + message
.targetId + '&aId=' + message.content.extra
}) })
return }).catch(err => {
} IMLib.deleteMessagesByIds([message.messageId], ({
// 判断时间超过了多久 就不能撤回 TODO code
// this.message.sentTime
const pushContent = this.$store.getters.sender.name + '撤回了一条消息'
IMLib.recallMessage(this.message.messageId, pushContent,
({
code,
message
}) => { }) => {
if (code === 0) { if (code === 0) {
uni.showToast({ uni.$emit('remove_message_' + message.targetId, message.messageId)
icon: 'none', }
title: '消息撤回成功' })
uni.showToast({
title: '公告不存在或已删除',
icon: 'none',
}) })
IMLib.getMessage(this.message.messageId, res => {
uni.$emit('onRecallMessage', res.message)
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '撤回失败' + code title: '旧版本,无链接'
}) })
} }
} }
)
}
} }
} }
</script> </script>
@@ -118,6 +114,11 @@
text-align: center; text-align: center;
font-size: 24rpx; font-size: 24rpx;
color: #666; color: #666;
.link {
color: $main-color;
margin-left: 10rpx;
}
} }
.cell-item { .cell-item {

View File

@@ -2,12 +2,12 @@
<view> <view>
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98"> <u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<view class="friend-flex" @click="toPending"> <view class="friend-flex" @click="toPending">
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_01.png')"></u-avatar> <u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_01.png')" />
<u-badge max="99" absolute :offset="[23, 20]" :value="pendingCount" /> <u-badge max="99" absolute :offset="[23, 20]" :value="pendingCount" />
<view class="info">新的朋友</view> <view class="info">新的朋友</view>
</view> </view>
<view class="friend-flex" @click="toGroup"> <view class="friend-flex" @click="toGroup">
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')"></u-avatar> <u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')" />
<view class="info">我的群聊</view> <view class="info">我的群聊</view>
</view> </view>
<block v-if="friends.length > 0"> <block v-if="friends.length > 0">
@@ -20,14 +20,15 @@
:src="contact(friendItem.targetId).portraitUrl" /> :src="contact(friendItem.targetId).portraitUrl" />
<view class="info"> <view class="info">
<view class="name">{{ contact(friendItem.targetId).name }}</view> <view class="name">{{ contact(friendItem.targetId).name }}</view>
<!-- <view class="address">地址:{{ friendItem.address }}</view> -->
</view> </view>
</view> </view>
</u-index-item> </u-index-item>
</block> </block>
<block v-else> <view class="no-lists" v-else>
<u-empty class="pages-null" mode="data" text="暂无好友" /> <u-image class="cover" radius="4" width="400rpx" height="400rpx"
</block> :src=" require('@/static/imgs/no-friend.png')" :lazy-load="true" />
<span>暂无好友列表~</span>
</view>
</u-index-list> </u-index-list>
</view> </view>
</template> </template>
@@ -38,8 +39,12 @@
} from '@/apis/interfaces/im'; } from '@/apis/interfaces/im';
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import im from '@/utils/im/index.js' import im from '@/utils/im/index.js'
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase
],
data() { data() {
return { return {
indexs: [], indexs: [],
@@ -55,9 +60,14 @@
} }
}, },
onLoad() { onLoad() {
uni.$on('onNewContactFriends', this.checkNewFriendPending)
},
onShow() {
this.getFriendList() this.getFriendList()
this.checkNewFriendPending() this.checkNewFriendPending()
uni.$on('onContactNotification', this.checkNewFriendPending) },
onUnload() {
uni.$off("onNewContactFriends")
}, },
methods: { methods: {
getFriendList() { getFriendList() {
@@ -73,10 +83,7 @@
}, },
toGroup() { toGroup() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/group/index', url: '/pages/im/group/index'
fail(err) {
console.log(err);
}
}) })
}, },
toFriend(targetId) { toFriend(targetId) {
@@ -86,24 +93,15 @@
}, },
// 新朋友 // 新朋友
toPending() { toPending() {
// if (this.pendingCount > 0) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/friends/pending' url: '/pages/im/friends/pending'
}); })
// } else {
// uni.showToast({
// title: ` 暂无好友申请 ~ `,
// icon: "none",
// mask: true,
// duration: 3000
// })
// }
} }
}, },
onNavigationBarButtonTap(e) { onNavigationBarButtonTap(e) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/friends/search' url: '/pages/im/friends/search'
}); })
} }
}; };
</script> </script>
@@ -172,4 +170,19 @@
line-height: 24px; line-height: 24px;
background-color: #fff; background-color: #fff;
} }
.no-lists {
padding-top: $padding * 3;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m;
color: $text-gray-m;
span {
padding-top: $padding;
}
}
</style> </style>

View File

@@ -2,10 +2,10 @@
<view class="content"> <view class="content">
<!-- 用户信息 --> <!-- 用户信息 -->
<view class="info-flex"> <view class="info-flex">
<u-avatar :src="userInfo.portraitUrl || require('@/static/user/cover.png')" shape="square" size="50" <u-avatar :src="userInfo.portraitUrl || require('@/static/user/cover.png')" shape="square"
bg-color="#fff"></u-avatar> :size="rpx2px(100)" bg-color="#fff"></u-avatar>
<view class="info-text"> <view class="info-text">
<view class="nickname">{{ userInfo.name }}</view> <view class="nickname">{{ contact(targetId).name }} ({{ userInfo.name }})</view>
<view class="address" @longpress="copyAddress">地址{{ userInfo.address }}</view> <view class="address" @longpress="copyAddress">地址{{ userInfo.address }}</view>
</view> </view>
</view> </view>
@@ -14,23 +14,19 @@
<view class="item"> <view class="item">
<label>性别</label> <label>性别</label>
<view class="text" v-if="userInfo.gender === 0">保密</view> <view class="text" v-if="userInfo.gender === 0">保密</view>
<view class="text" v-if="userInfo.gender === 1"></view> <view class="text" v-else-if="userInfo.gender === 1"></view>
<view class="text" v-if="userInfo.gender === 2"></view> <view class="text" v-else></view>
</view> </view>
</view> </view>
<!-- 如果是好友 -->
<block v-if="userInfo.friendship ==='accepted'"> <block v-if="userInfo.friendship ==='accepted'">
<view class="info-btns"> <view class="info-btns">
<view class="item u-border-bottom" @click="setRemark"> <view class="item u-border-bottom" @click="setRemark">
<label>设置备注</label> <label>设置备注</label>
<u-icon name="arrow-right" color="#eee" size="16" /> <uni-icons type="right" size="32rpx" />
</view>
<view class="item u-border-bottom" @click="setRemark">
<label>设置标签</label>
<u-icon name="arrow-right" color="#eee" size="16" />
</view> </view>
<view class="item u-border-bottom"> <view class="item u-border-bottom">
<label>聊天免打扰</label> <label>消息免打扰</label>
<u-switch size="22" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch> <u-switch size="22" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch>
</view> </view>
<view class="item"> <view class="item">
@@ -69,6 +65,14 @@
</view> </view>
</view> </view>
</block> </block>
<u-modal negativeTop="300" :show="modalShow" title="修改备注" showCancelButton @cancel="onHideModal"
@confirm="onChangeRemark">
<view class="slot-content">
<u--input placeholder="好友备注" border="surround" focus v-model="contactRemark" maxlength="12" />
</view>
</u-modal>
<u-action-sheet :actions="callActions" cancelText="取消" @close="callShow = false" @select="singleCall" <u-action-sheet :actions="callActions" cancelText="取消" @close="callShow = false" @select="singleCall"
:show="callShow"> :show="callShow">
</u-action-sheet> </u-action-sheet>
@@ -83,12 +87,17 @@
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index' import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
import imBase from '../mixins/imBase.js'
// friendship: '' 没有好友关系 // friendship: '' 没有好友关系
// accepted 好友 // accepted 好友
// pending 申请中 // pending 申请中
// denied 拒绝 // denied 拒绝
// blocked 黑名单 // blocked 黑名单
export default { export default {
mixins: [
imBase
],
data() { data() {
return { return {
targetId: '', targetId: '',
@@ -107,13 +116,14 @@
} }
], ],
callShow: false, callShow: false,
hasPeding: false hasPeding: false,
modalShow: false,
contactRemark: ''
} }
}, },
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
getFriendInfo(e.targetId).then(res => { getFriendInfo(e.targetId).then(res => {
console.log(res, "获取朋友的信息")
this.userInfo = res this.userInfo = res
// 获取到用户信息之后,去检查一下要不要更新 // 获取到用户信息之后,去检查一下要不要更新
this.$store.dispatch('updateContact', res) this.$store.dispatch('updateContact', res)
@@ -148,11 +158,30 @@
}) })
}, },
toPrivate() { toPrivate() {
uni.redirectTo({ uni.navigateTo({
url: '/pages/im/private/chat?targetId=' + this.targetId url: '/pages/im/private/chat?targetId=' + this.targetId
}); });
}, },
// 设置好友备注操作
setRemark() { setRemark() {
this.modalShow = true
this.contactRemark = this.$store.getters.contactInfo(this.targetId).name
},
onHideModal() {
this.modalShow = false
},
onChangeRemark() {
this.$store.dispatch('setContactRemark', {
targetId: this.targetId,
remark: this.contactRemark
})
uni.showToast({
icon: 'none',
title: '备注设置成功'
})
this.onHideModal()
},
setTag() {
uni.showToast({ uni.showToast({
title: '开发中', title: '开发中',
icon: 'none' icon: 'none'
@@ -209,7 +238,7 @@
}) })
return return
} }
pedingFriend(this.targetId, 'message').then(res => { pedingFriend(this.targetId, '').then(res => {
uni.showToast({ uni.showToast({
title: ` 申请成功,等待审核 `, title: ` 申请成功,等待审核 `,
icon: 'none', icon: 'none',
@@ -228,8 +257,9 @@
}) })
}, },
singleCall(e) { singleCall(e) {
uni.redirectTo({ uni.navigateTo({
url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type + '&isCall=true' url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type +
'&isCall=true'
}) })
} }
} }
@@ -344,6 +374,10 @@
width: 200rpx; width: 200rpx;
} }
.uni-icons {
color: $text-gray-m !important;
}
.text { .text {
width: calc(100% - 200rpx); width: calc(100% - 200rpx);
color: $text-gray-m; color: $text-gray-m;

View File

@@ -4,7 +4,7 @@
<!-- 用户信息 --> <!-- 用户信息 -->
<view class="info-flex"> <view class="info-flex">
<view class="info-flex-item"> <view class="info-flex-item">
<u-avatar :src="infoObj.portraitUrl" shape="square" size="210rpx" bg-color="#fff" class="avatar" /> <u-avatar :src="infoObj.portraitUrl" @click='previewImg(infoObj.portraitUrl)' shape="square" size="210rpx" bg-color="#fff" class="avatar" />
<view class="nickname">{{infoObj.name}}</view> <view class="nickname">{{infoObj.name}}</view>
<view class="address">{{infoObj.address}}</view> <view class="address">{{infoObj.address}}</view>
<view class="info-code"> <view class="info-code">
@@ -23,7 +23,8 @@
<script> <script>
import { import {
getUserInfo getUserInfo
} from '@/apis/interfaces/im' } from '@/apis/interfaces/im.js'
export default { export default {
data() { data() {
return { return {
@@ -47,6 +48,12 @@
}) })
}, },
methods: { methods: {
previewImg(item){
console.log(item)
uni.previewImage({
urls:[item]
})
},
copy() { copy() {
uni.setClipboardData({ uni.setClipboardData({
data: this.downUrl, data: this.downUrl,
@@ -99,7 +106,7 @@
.avatar { .avatar {
// padding: 14rpx; // padding: 14rpx;
border-radius: 10rpx; border-radius: 20rpx;
background-color: #fff; background-color: #fff;
border: solid 14rpx rgba($color: #fff, $alpha:1); border: solid 14rpx rgba($color: #fff, $alpha:1);
} }

View File

@@ -2,7 +2,7 @@
<view class="pending"> <view class="pending">
<u-sticky> <u-sticky>
<view class="header-search" @click="$Router.push({ name: 'SearchFriend' })"> <view class="header-search" @click="$Router.push({ name: 'SearchFriend' })">
<u-search placeholder="输入手机号码搜索" height="74" searchIcon="search" inputAlign="center" bgColor="white" <u-search placeholder="输入手机号码搜索" searchIcon="search" inputAlign="center" bgColor="white"
:disabled="true" :show-action="false" /> :disabled="true" :show-action="false" />
</view> </view>
</u-sticky> </u-sticky>
@@ -33,13 +33,17 @@
bg: '#fff' bg: '#fff'
} }
}, },
onLoad() { onShow() {
this.getPendingList() this.getPendingList()
uni.$on('onContactNotification', this.getPendingList) uni.$on('onNewContactPendings', this.getPendingList)
},
onUnload() {
uni.$off('onNewContactPendings')
}, },
methods: { methods: {
getPendingList() { getPendingList() {
im.getPendingList((pendings) => { im.getPendingList((pendings) => {
console.log(pendings, 'res......')
if (pendings.length > 0) { if (pendings.length > 0) {
this.bg = '#f9f9f9' this.bg = '#f9f9f9'
} else { } else {

View File

@@ -8,17 +8,19 @@
<template> <template>
<view class="search"> <view class="search">
<!-- 搜索 --> <!-- 搜索 -->
<u-sticky> <u-sticky>
<view class="header-search"> <view class="header-search">
<u-search placeholder="输入用户账号、手机号" height="74" searchIcon="search" @custom="search" v-model="searchValue" @search="search" bgColor="#f9f9f9" :focus="focused" /> <u-search placeholder="输入用户账号、手机号" searchIcon="search" @custom="search" v-model="searchValue"
@search="search" bgColor="#F3F6FB" :focus="focused" />
</view> </view>
</u-sticky> </u-sticky>
<block v-if="searchResult.length > 0"> <block v-if="searchResult.length > 0">
<applyFriend :lists="searchResult" :isApply="true" @action="action" /> <applyFriend :lists="searchResult" :isApply="true" @action="action" />
</block> </block>
<view class="no-lists" v-else> <view class="no-lists" v-if="searchResult.length === 0 && searchValue.length > 1">
<u-image class="cover" radius="4" width="400rpx" height="400rpx" :src="require('@/static/imgs/no-search.png')" :lazy-load="true" /> <u-image class="cover" radius="4" width="400rpx" height="400rpx"
:src="require('@/static/imgs/no-search.png')" :lazy-load="true" />
<span>暂无匹配内容~</span> <span>暂无匹配内容~</span>
</view> </view>
</view> </view>
@@ -30,6 +32,7 @@
pedingFriend pedingFriend
} from '@/apis/interfaces/im.js'; } from '@/apis/interfaces/im.js';
import applyFriend from '../components/friendSearchList.vue'; import applyFriend from '../components/friendSearchList.vue';
export default { export default {
components: { components: {
applyFriend applyFriend
@@ -41,6 +44,20 @@
focused: true focused: true
}; };
}, },
watch: {
searchValue(value) {
console.log(value.length, 'length...')
if (value.length > 1) {
this.searchResult = []
this.search()
return
}
if(value.length === 0){
this.searchResult = []
return
}
}
},
methods: { methods: {
search() { search() {
// friendship: '' 没有好友关系 // friendship: '' 没有好友关系

View File

@@ -1,13 +1,15 @@
<template> <template>
<view class="create"> <view class="create">
<view class="create-title">公告内容</view> <view class="create-title">公告内容</view>
<block v-if="type !== 'cheack'">
<block v-if="type === 'check'">
<view class="content"> {{content}} </view>
</block>
<block v-else>
<u--textarea v-model="content" count height="240" maxlength="240" placeholder="请输入公告内容" /> <u--textarea v-model="content" count height="240" maxlength="240" placeholder="请输入公告内容" />
<u-button type="primary" text="发布" :disabled="disabled" @click="onCreate" color="#34CE98" /> <u-button type="primary" text="发布" :disabled="disabled" @click="onCreate" color="#34CE98" />
</block> </block>
<block v-if="type === 'cheack'">
<view class="content-a"> {{content}} </view>
</block>
</view> </view>
</template> </template>
@@ -16,32 +18,42 @@
createGroupAnnouncement, createGroupAnnouncement,
getGroupAnnouncement getGroupAnnouncement
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import onGroupDismiss from '../mixins/onGroupDismiss.js'
export default { export default {
mixins: [
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',
content: '', content: '',
aId: '', aId: '',
type: '' // check ' 查看详情' type: '' // cheack ' 查看详情'
} }
}, },
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
if (e.type) {
this.type = e.type
}
if (e.aId) { if (e.aId) {
this.type = e.type
uni.setNavigationBarTitle({
title: '群公告'
})
this.aId = e.aId this.aId = e.aId
getGroupAnnouncement(this.targetId, this.aId).then(res => { getGroupAnnouncement(this.targetId, this.aId).then(res => {
console.log(res.content)
this.content = res.content this.content = res.content
}).catch(err => { }).catch(err => {
if (err.status_code == 404) {
this.$nextTick(() => {
uni.navigateBack()
})
} else {
uni.showToast({ uni.showToast({
title: err.message, title: err.message,
icon: 'none', icon: 'none',
mask: true mask: true
}) })
}
}) })
} }
}, },
@@ -95,7 +107,7 @@
} }
} }
.content-a { .content {
color: $text-color; color: $text-color;
font-size: $title-size; font-size: $title-size;
line-height: 1.7; line-height: 1.7;

View File

@@ -35,8 +35,14 @@
deleteGroupAnnouncement, deleteGroupAnnouncement,
topGroupAnnouncement topGroupAnnouncement
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import onGroupDismiss from '../mixins/onGroupDismiss.js'
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase,
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',
@@ -115,7 +121,7 @@
}, },
tabA(id) { tabA(id) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/group/announceCreate?type=cheack&targetId=' + this.targetId + '&aId=' + id url: '/pages/im/group/announceCreate?type=check&targetId=' + this.targetId + '&aId=' + id
}) })
}, },
onTop(aId) { onTop(aId) {
@@ -128,14 +134,6 @@
uni.$emit('updateAnnouncement') uni.$emit('updateAnnouncement')
this.initData() this.initData()
}) })
// uni.showModal({
// title: ' 置顶该公告',
// success: (res) => {
// if (res.confirm) {
// }
// }
// })
}, },
// 删除公告 // 删除公告
onDelete(aId) { onDelete(aId) {
@@ -148,14 +146,6 @@
uni.$emit('updateAnnouncement') uni.$emit('updateAnnouncement')
this.initData() this.initData()
}) })
// uni.showModal({
// title: '删除该公告',
// success: (res) => {
// if (res.confirm) {
// }
// }
// })
} }
} }
} }
@@ -194,7 +184,8 @@
box-sizing: border-box; box-sizing: border-box;
font-size: $title-size-m; font-size: $title-size-m;
color: $text-gray-m; color: $text-gray-m;
padding: 10rpx; padding: 20rpx 10rpx 10rpx 10rpx;
border-top: solid 1rpx #F9F9F9;
.name { .name {
padding-left: 10rpx; padding-left: 10rpx;
@@ -215,8 +206,6 @@
-webkit-line-clamp: 3; -webkit-line-clamp: 3;
overflow: hidden; overflow: hidden;
line-height: 1.5; line-height: 1.5;
border-bottom: solid 1rpx #F9F9F9;
padding-bottom: 20rpx;
span { span {
color: #fff; color: #fff;

View File

@@ -20,8 +20,14 @@
joinGroupPre, joinGroupPre,
joinGroup joinGroup
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import onGroupDismiss from '../mixins/onGroupDismiss.js'
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase,
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',

View File

@@ -2,10 +2,18 @@
<view class="chat"> <view class="chat">
<sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" /> <sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
<view class="shade" @click="hidePop" v-show="showPop">
<view class="pop" :style="popStyle" :class="{'show':showPop}">
<view v-for="(item, index) in popButton" :key="index" @click="pickerMenu(item)">
{{ item }}
</view>
</view>
</view>
<view class="body"> <view class="body">
<view class="scroll"> <view class="scroll">
<view class="cell" v-for="(message, index) in messages" :key="index"> <view class="cell" v-for="(message, index) in messages" :key="index">
<show-message-cell :message="message" isGroup /> <show-message-cell :message="message" isGroup @messageAction="messageAction" />
</view> </view>
</view> </view>
</view> </view>
@@ -21,8 +29,16 @@
import sentMessageBar from '../components/sentMessageBar' import sentMessageBar from '../components/sentMessageBar'
import showMessageCell from '../components/showMessageCell' import showMessageCell from '../components/showMessageCell'
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import onGroupDismiss from '../mixins/onGroupDismiss.js'
import imBase from '../mixins/imBase.js'
import messageActions from '../mixins/messageActions.js'
export default { export default {
mixins: [
imBase,
onGroupDismiss,
messageActions
],
components: { components: {
sentMessageBar, sentMessageBar,
showMessageCell showMessageCell
@@ -49,21 +65,16 @@
} }
} }
}, },
onShow() {
this.initGroupInfo()
},
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
// 获取群成员数量
getGroupBase(this.targetId).then(res => {
uni.setNavigationBarTitle({
title: res.name + `(${res.members})`
})
})
// 获取历史消息列表 // 获取历史消息列表
this.getMessageList() this.getMessageList()
// 监听收到本群的消息,追加消息 // 监听消息
uni.$on('onReceiveMessage', (msg) => { uni.$on('onReceiveMessage_' + this.targetId, (message) => {
if (msg.targetId == this.targetId) {
this.getNewMessage() this.getNewMessage()
}
}) })
uni.$on('onReceiptRequest', (msg) => { uni.$on('onReceiptRequest', (msg) => {
if (msg.targetId == this.targetId) { if (msg.targetId == this.targetId) {
@@ -88,20 +99,24 @@
}) })
// 清理聊天记录 // 清理聊天记录
uni.$once('cleanGroupMessage', this.getMessageList) uni.$once('cleanGroupMessage', this.getMessageList)
uni.$on('onRecallMessage', (res) => { uni.$on('onRecallMessage_' + this.targetId, (message) => {
if (res.targetId == this.targetId) {
this.messages = this.messages.map(item => { this.messages = this.messages.map(item => {
if (res.messageId == item.messageId) { if (message.messageId == item.messageId) {
return res return message
} else { } else {
return item return item
} }
}) })
} })
uni.$on('onRemoveMessage_' + this.targetId, (messageId) => {
this.messages = this.messages.filter(item => item.messageId != messageId)
}) })
}, },
onUnload() { onUnload() {
uni.$off('onRecallMessage') uni.$off('onRemoveMessage_' + this.targetId)
uni.$off('onReceiveMessage_' + this.targetId)
uni.$off('onUpdateProfile_' + this.targetId)
uni.$off('onRecallMessage_' + this.targetId)
uni.$off('onReceiptRequest') uni.$off('onReceiptRequest')
uni.$off('onReceiptResponse') uni.$off('onReceiptResponse')
}, },
@@ -111,6 +126,14 @@
}) })
}, },
methods: { methods: {
initGroupInfo() {
// 获取群信息,成员数量,设置标题
getGroupBase(this.targetId).then(res => {
uni.setNavigationBarTitle({
title: res.name + `(${res.members})`
})
})
},
onScroll(e) { onScroll(e) {
this.$refs.messageBar.onHidePopus() this.$refs.messageBar.onHidePopus()
}, },
@@ -164,7 +187,7 @@
}, },
onHide() { onHide() {
// console.log(JSON.stringify(this.$refs)) // console.log(JSON.stringify(this.$refs))
this.$refs.voice.stopPlay() // this.$refs.voice.stopPlay()
} }
} }
</script> </script>
@@ -197,4 +220,47 @@
} }
} }
} }
/* 遮罩 */
.shade {
position: fixed;
width: 100%;
height: 100%;
z-index: 999;
.pop {
border-radius: 10rpx;
position: fixed;
z-index: 101;
width: 200rpx;
box-sizing: border-box;
font-size: 28rpx;
text-align: left;
color: #333;
background-color: #fff;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
line-height: 80rpx;
transition: transform 0.15s ease-in-out 0s;
user-select: none;
-webkit-touch-callout: none;
transform: scale(0, 0);
&.show {
transform: scale(1, 1);
}
&>view {
padding: 0 20rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
user-select: none;
-webkit-touch-callout: none;
&:active {
background-color: #f3f3f3;
}
}
}
}
</style> </style>

View File

@@ -3,16 +3,15 @@
<block v-if="groups.length > 0"> <block v-if="groups.length > 0">
<view class="title"> 群聊 </view> <view class="title"> 群聊 </view>
<view v-for="(item, index) in groups" :key="index" class="friend-flex" @click="toGroup(item.targetId)"> <view v-for="(item, index) in groups" :key="index" class="friend-flex" @click="toGroup(item.targetId)">
<u-avatar size="38" shape="square" :src="contact(item.targetId).portraitUrl" /> <u-avatar size="36" shape="square" :src="contact(item.targetId).portraitUrl" />
<view class="info"> <view class="info">
<view class="name">{{ item.name }}</view> <view class="name">{{ item.name }} <span class="total">{{ item.members }} 成员</span></view>
</view> </view>
</view> </view>
<view class="group-count"> {{ groups.length }}个群聊 </view> <view class="group-count"> {{ groups.length }}个群聊 </view>
</block> </block>
<view class="no-lists" v-else> <view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx" <u-image class="cover" radius="4" width="400rpx" height="400rpx" :src="require('@/static/imgs/no-friend.png')" :lazy-load="true" />
:src="require('@/static/imgs/no-friend.png')" :lazy-load="true" />
<span>空空如也~</span> <span>空空如也~</span>
</view> </view>
<u-modal negativeTop="300" :show="createModal" title="创建群聊" showCancelButton @cancel="onHideModal" <u-modal negativeTop="300" :show="createModal" title="创建群聊" showCancelButton @cancel="onHideModal"
@@ -49,13 +48,14 @@
onNavigationBarButtonTap() { onNavigationBarButtonTap() {
this.createModal = true this.createModal = true
}, },
onLoad() { onShow() {
this.initData() this.initData()
uni.$on('onGroupDismiss', this.initData) uni.$on('onGroupDismiss', this.initData)
}, },
methods: { methods: {
initData() { initData() {
getMyGroups().then((res) => { getMyGroups().then((res) => {
console.log(res,'res...')
if (res.length > 0) { if (res.length > 0) {
this.bg = '#f9f9f9' this.bg = '#f9f9f9'
} else { } else {
@@ -138,6 +138,11 @@
font-size: $title-size + 1; font-size: $title-size + 1;
color: #454545 !important; color: #454545 !important;
} }
.total{
color: $text-gray-m;
font-size: $title-size-m - 5;
padding-left: 10rpx;
}
.address { .address {
color: $text-gray-m; color: $text-gray-m;

View File

@@ -9,12 +9,11 @@
<view slot="label" class="announcement-label "> {{announcement}} </view> <view slot="label" class="announcement-label "> {{announcement}} </view>
</u-cell> </u-cell>
<u-cell :border="false" class="u-border-bottom" isLink title="二维码" @click="showGroupQrCode" /> <u-cell :border="false" class="u-border-bottom" isLink title="二维码" @click="showGroupQrCode" />
<u-cell :border="false" class="u-border-bottom" v-if="group.can_makesure" isLink title="群聊邀请确认" <u-cell :border="false" class="u-border-bottom" v-if="group.can_makesure" isLink title="群聊邀请确认" @click="showGroupsSure" />
@click="showGroupsSure" />
<u-cell :border="false" class="u-border-bottom" title="聊天置顶"> <u-cell :border="false" class="u-border-bottom" title="聊天置顶">
<u-switch slot="value" size="20" v-model="isTop" activeColor="#34CE98" @change="setTop" /> <u-switch slot="value" size="20" v-model="isTop" activeColor="#34CE98" @change="setTop" />
</u-cell> </u-cell>
<u-cell class="u-border-bottom" :border="false" title="免打扰"> <u-cell class="u-border-bottom" :border="false" title="消息免打扰">
<u-switch slot="value" size="20" v-model="status" activeColor="#34CE98" @change="setStatus" /> <u-switch slot="value" size="20" v-model="status" activeColor="#34CE98" @change="setStatus" />
</u-cell> </u-cell>
</u-cell-group> </u-cell-group>
@@ -22,11 +21,10 @@
<u-cell-group class="cells" v-if="group.is_admin" :border="false"> <u-cell-group class="cells" v-if="group.is_admin" :border="false">
<u-cell :border="false" class="u-border-bottom" isLink title="修改群聊名称" :value="groupName" <u-cell :border="false" class="u-border-bottom" isLink title="修改群聊名称" :value="groupName"
@click="onGroupName" /> @click="onGroupName" />
<u-cell :border="false" class="u-border-bottom" isLink title="修改群头像" @click="onGroupAvatar"> <!-- <u-cell :border="false" class="u-border-bottom" isLink title="修改群头像" @click="onGroupAvatar">
<u-avatar slot="value" size="25" shape="square" :src="group.cover" /> <u-avatar slot="value" size="25" shape="square" :src="group.cover" />
</u-cell> </u-cell> -->
<u-cell :border="false" class="u-border-bottom" isLink v-if="group.is_owner" title="准入方式" :value="joinType" <u-cell :border="false" class="u-border-bottom" isLink v-if="group.is_owner" title="准入方式" :value="joinType" @click="onChangeJoinType" />
@click="onChangeJoinType" />
</u-cell-group> </u-cell-group>
<view class="cells actions" v-if="loaded"> <view class="cells actions" v-if="loaded">
@@ -35,21 +33,15 @@
<view class="action u-border-bottom" v-else @click="onQuite">删除并退出</view> <view class="action u-border-bottom" v-else @click="onQuite">删除并退出</view>
</view> </view>
<u-modal negativeTop="300" :show="modalShow" title="修改群名称" showCancelButton @cancel="onHideModal" <u-modal negativeTop="300" :show="modalShow" title="修改群名称" showCancelButton @cancel="onHideModal" @confirm="onChangeGroupName">
@confirm="onChangeGroupName"> <view class="slot-content"> <u--input placeholder="群名称" border="surround" focus v-model="groupName" maxlength="12" /> </view>
<view class="slot-content">
<u--input placeholder="群名称" border="surround" focus v-model="groupName" />
</view>
</u-modal> </u-modal>
<u-modal :show="qrCodeShow" :title="group.name" @confirm="qrCodeShow = false"> <u-modal :show="qrCodeShow" :title="group.name" @confirm="qrCodeShow = false">
<view class="slot-content"> <view class="slot-content"> <uqrcode class="info-code-src" :size="198" :text="qrContent" /> </view>
<uqrcode class="info-code-src" :size="198" :text="qrContent" />
</view>
</u-modal> </u-modal>
<u-action-sheet @select="doAction" :actions="joinTypeMap" cancelText="取消" :show="showActions" <u-action-sheet @select="doAction" :actions="joinTypeMap" cancelText="取消" :show="showActions" @close="showActions=false" />
@close="showActions=false" />
</view> </view>
</template> </template>
@@ -65,11 +57,17 @@
} from '@/apis/interfaces/uploading' } from '@/apis/interfaces/uploading'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import groupUserList from '../components/groupUserList' import groupUserList from '../components/groupUserList'
import onGroupDismiss from '../mixins/onGroupDismiss.js'
import imBase from '../mixins/imBase.js'
export default { export default {
components: { components: {
groupUserList groupUserList
}, },
mixins: [
imBase,
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',
@@ -133,7 +131,6 @@
return item.key == res.join_type return item.key == res.join_type
})[0].name })[0].name
}).catch(err => { }).catch(err => {
console.log('getGroupInfo ERR', err);
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '群不存在' title: '群不存在'

View File

@@ -8,8 +8,9 @@
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98"> <u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column"> <u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column">
<u-index-item v-for="(item, fkey) in friends" :key="fkey"> <u-index-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#f9f9f9f" height="20" size="12" <u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#f9f9f9f" height="20"
color="#666" style="border:none !important;padding: 10rpx 30rpx;background-color: #f9f9f9 !important;" /> size="12" color="#666"
style="border:none !important;padding: 10rpx 30rpx;background-color: #f9f9f9 !important;" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex" <view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="addContact(friendItem.targetId)"> @click="addContact(friendItem.targetId)">
<u-checkbox :name="friendItem.targetId" shape="circle" activeColor="#34ce98" <u-checkbox :name="friendItem.targetId" shape="circle" activeColor="#34ce98"
@@ -25,7 +26,8 @@
</u-checkbox-group> </u-checkbox-group>
</u-index-list> </u-index-list>
<view class="bottom"> <view class="bottom">
<span class="onInvite" @click="onInvite">完成<span>{{`(${checkboxValue.length})` || ''}}</span></span> <span class="onInvite" v-if="canInvite"> 添加中<span>{{`(${checkboxValue.length})` || ''}}</span></span>
<span class="onInvite" v-else @click="onInvite">完成<span>{{`(${checkboxValue.length})` || ''}}</span></span>
</view> </view>
</block> </block>
<view class="no-lists" v-else> <view class="no-lists" v-else>
@@ -44,10 +46,15 @@
getGroupUsers getGroupUsers
} from '@/apis/interfaces/im'; } from '@/apis/interfaces/im';
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import onGroupDismiss from '../mixins/onGroupDismiss.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase,
onGroupDismiss
],
data() { data() {
return { return {
searchTxt: '', searchTxt: '',
@@ -57,16 +64,10 @@
friends: [], friends: [],
orignalFriends: [], orignalFriends: [],
checkboxValue: [], checkboxValue: [],
selectValue: [] selectValue: [],
canInvite:false
}; };
}, },
computed: {
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
}
},
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
this.getFriendList() this.getFriendList()
@@ -125,6 +126,7 @@
onInvite() { onInvite() {
console.log(this.checkboxValue, 'userIds.....') console.log(this.checkboxValue, 'userIds.....')
console.log(this.selectValue, 'userIds.....') console.log(this.selectValue, 'userIds.....')
this.canInvite = true
let userIds = [] let userIds = []
this.checkboxValue.filter(item => { this.checkboxValue.filter(item => {
if (!utils.inArray(item, this.selectValue)) { if (!utils.inArray(item, this.selectValue)) {
@@ -138,8 +140,10 @@
animationType: 'pop-out', animationType: 'pop-out',
animationDuration: 200 animationDuration: 200
}); });
this.canInvite = false
uni.$emit('groupInvitedUser') uni.$emit('groupInvitedUser')
}).catch(err => { }).catch(err => {
this.canInvite = false
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: err.message title: err.message

View File

@@ -22,7 +22,7 @@
<view class="no-lists" v-else> <view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx" <u-image class="cover" radius="4" width="400rpx" height="400rpx"
:src="require('@/static/imgs/no-friend.png')" :lazy-load="true" /> :src="require('@/static/imgs/no-friend.png')" :lazy-load="true" />
<span> 暂无群聊申请数据~</span> <span>暂无群聊申请数据</span>
</view> </view>
</view> </view>
</template> </template>
@@ -34,9 +34,14 @@
} from "@/apis/interfaces/im.js" } from "@/apis/interfaces/im.js"
import im from '@/utils/im/message.js' import im from '@/utils/im/message.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import onGroupDismiss from '../mixins/onGroupDismiss.js'
import imBase from '../mixins/imBase.js'
export default { export default {
mixins: [
imBase,
onGroupDismiss
],
data() { data() {
return { return {
targetId: '', targetId: '',
@@ -79,7 +84,6 @@
uni.$emit('groupInvitedUser') uni.$emit('groupInvitedUser')
} }
}) })
}).catch(err => { }).catch(err => {
// uni.showToast({ // uni.showToast({
// title: err.message, // title: err.message,
@@ -153,6 +157,7 @@
} }
} }
.no-lists { .no-lists {
padding-top: $padding * 5; padding-top: $padding * 5;
display: flex; display: flex;

View File

@@ -4,7 +4,12 @@
<script> <script>
import groupUserList from '../components/groupUserList' import groupUserList from '../components/groupUserList'
import onGroupDismiss from '../mixins/onGroupDismiss.js'
export default { export default {
mixins: [
onGroupDismiss
],
components: { components: {
groupUserList groupUserList
}, },

View File

@@ -46,7 +46,8 @@
return { return {
conversations: [], // 会话列表 conversations: [], // 会话列表
connection: 0, connection: 0,
hasNewFriends: 0 hasNewFriends: 0,
perPage: 200
} }
}, },
components: { components: {
@@ -54,27 +55,35 @@
connectionStatus connectionStatus
}, },
onLoad() { onLoad() {
// 好友申请数量
this.checkNewFriendPending()
// 监听新的好友申请 // 监听新的好友申请
uni.$on('onContactNotification', () => { uni.$on('onNewContactConversation', () => {
console.log('更新好友申请数量');
// 更新好友申请数量
this.checkNewFriendPending() this.checkNewFriendPending()
}) })
}, },
onShow() { onShow() {
// 好友申请数量
this.checkNewFriendPending()
if (this.$store.state.token !== '') { if (this.$store.state.token !== '') {
this.getConversationList() this.getConversationList()
} }
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
})
// 监听新消息 // 监听新消息
uni.$on('onReceiveMessage', (msg) => { uni.$on('onReceiveMessage', (msg) => {
this.getConversationList() this.getConversationList()
}) })
// 监听网络状态变化
uni.$on('onConnectionStatusChange', (status) => {
this.connection = status
if (status == 0) {
this.getConversationList()
}
})
}, },
onHide() { onHide() {
uni.$off('onReceiveMessage') uni.$off('onReceiveMessage')
uni.$off('onConnectionStatusChange')
}, },
methods: { methods: {
checkNewFriendPending() { checkNewFriendPending() {
@@ -91,15 +100,14 @@
} }
return true return true
}, },
// 获取私聊的会话列表 // 获取会话列表,最新的一千条
getConversationList() { getConversationList() {
const count = 1000 RongIMLib.getConversationList([1, 3], this.perPage, 0, ({
const timestamp = 0
RongIMLib.getConversationList([1, 3], count, timestamp, ({
code, code,
conversations conversations
}) => { }) => {
if (code === 0) { if (code === 0) {
console.log(conversations,',,,,,')
this.conversations = conversations this.conversations = conversations
} }
}) })

22
pages/im/mixins/imBase.js Normal file
View File

@@ -0,0 +1,22 @@
import utils from '@/utils/index.js'
export default {
computed: {
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
},
avatarSize() {
return utils.rpx2px(84)
},
sender() {
return this.$store.getters.sender
}
},
methods: {
rpx2px(size) {
return utils.rpx2px(size)
}
}
}

View File

@@ -0,0 +1,133 @@
import * as IMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
export default {
data() {
return {
winSize: {},
showPop: false,
/* 弹窗按钮列表 */
popButton: ['复制', '删除', '撤回'],
/* 弹窗定位样式 */
popStyle: "",
pickedItem: {}
}
},
onLoad() {
uni.getSystemInfo({
success: (e) => {
this.winSize = {
width: e.windowWidth,
height: e.windowHeight
}
}
})
},
methods: {
// 隐藏功能菜单
hidePop() {
this.showPop = false
this.pickedItem = {}
setTimeout(() => {
this.showShade = false
}, 250)
},
// 点击会话功能菜单
pickerMenu(e) {
const msg = this.pickedItem
console.log(msg);
switch (e) {
case '复制':
uni.setClipboardData({
data: msg.content.content
})
uni.showToast({
icon: 'none',
title: '复制成功'
})
break;
case '删除':
IMLib.deleteMessagesByIds([msg.messageId], ({
code
}) => {
if (code === 0) {
uni.$emit('onRemoveMessage_' + msg.targetId, msg.messageId)
uni.showToast({
title: '消息删除成功',
icon: 'none',
})
}
})
break;
case '撤回':
const pushContent = this.$store.getters.sender.name + '撤回了一条消息'
IMLib.recallMessage(msg.messageId, pushContent,
({
code,
message
}) => {
if (code === 0) {
uni.showToast({
icon: 'none',
title: '消息撤回成功'
})
msg.objectName = 'RC:RcNtf'
uni.$emit('onRecallMessage_' + msg.targetId, msg)
} else {
uni.showToast({
icon: 'none',
title: '撤回失败' + code
})
}
}
)
break;
}
this.hidePop()
},
messageAction(e) {
let [touches, style, item] = [e.event.touches[0], "", e.message]
if (touches.clientY > (this.winSize.height / 2)) {
style = `bottom:${this.winSize.height-touches.clientY}px;`
} else {
style = `top:${touches.clientY}px;`
}
if (touches.clientX > (this.winSize.width / 2)) {
style += `right:${this.winSize.width-touches.clientX}px`
} else {
style += `left:${touches.clientX}px`
}
if (item.messageDirection == 2) {
if (item.objectName == 'RC:TxtMsg') {
this.popButton = ['复制', '删除']
} else {
this.popButton = ['删除']
}
} else {
if ((new Date()).getTime() - item.sentTime > 120 * 1000) {
if (item.objectName == 'RC:TxtMsg') {
this.popButton = ['复制', '删除']
} else {
this.popButton = ['删除']
}
} else {
if (item.objectName == 'RC:TxtMsg') {
this.popButton = ['复制', '撤回']
} else {
this.popButton = ['删除']
}
}
}
this.popStyle = style
this.pickedItem = item
this.$nextTick(() => {
setTimeout(() => {
this.showPop = true;
}, 10)
})
},
}
}

View File

@@ -0,0 +1,34 @@
// 监听群解散的消息,直接跳转到会话列表页面
export default {
data() {
return {
currentTargetId: ''
}
},
onLoad(e) {
this.currentTargetId = e.targetId
uni.$once('onGroupDismiss_' + e.targetId, () => {
uni.showToast({
icon: 'none',
title: '当前群已解散'
})
uni.switchTab({
url: '/pages/im/index'
})
})
uni.$once('onGroupRemoveYou_' + e.targetId, () => {
uni.showToast({
icon: 'none',
title: '您已被移出群聊'
})
uni.switchTab({
url: '/pages/im/index'
})
})
},
onUnload() {
uni.$off('onGroupDismiss_' + this.currentTargetId)
uni.$off('onGroupRemoveYou_' + this.currentTargetId)
}
}

View File

@@ -150,7 +150,7 @@
} else { } else {
IMLib.insertIncomingMessage(1, targetId, targetId, sentStatus, messageContent, sentTime) IMLib.insertIncomingMessage(1, targetId, targetId, sentStatus, messageContent, sentTime)
} }
uni.$emit('onReceiveMessage', { uni.$emit('onReceiveMessage_' + this.targetId, {
targetId: this.targetId targetId: this.targetId
}) })
}, },

View File

@@ -1,11 +1,18 @@
<template> <template>
<view class="chat"> <view class="chat">
<sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" /> <sent-message-bar :conversationType="conversationType" :targetId="targetId" @onSuccess="getNewMessage()" />
<view class="shade" @click="hidePop" v-show="showPop">
<view class="pop" :style="popStyle" :class="{'show':showPop}">
<view v-for="(item, index) in popButton" :key="index" @click="pickerMenu(item)">
{{ item }}
</view>
</view>
</view>
<!-- chat --> <!-- chat -->
<view class="body"> <view class="body">
<view class="scroll"> <view class="scroll">
<view class="cell" v-for="(message, index) in messages" :key="index"> <view class="cell" v-for="(message, index) in messages" :key="index">
<show-message-cell :message="message" /> <show-message-cell :message="message" @messageAction="messageAction" />
</view> </view>
</view> </view>
</view> </view>
@@ -18,8 +25,14 @@
import sentMessageBar from '../components/sentMessageBar' import sentMessageBar from '../components/sentMessageBar'
import showMessageCell from '../components/showMessageCell' import showMessageCell from '../components/showMessageCell'
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import imBase from '../mixins/imBase.js'
import messageActions from '../mixins/messageActions.js'
export default { export default {
mixins: [
imBase,
messageActions
],
components: { components: {
sentMessageBar, sentMessageBar,
showMessageCell showMessageCell
@@ -45,11 +58,6 @@
sentTime: 0 sentTime: 0
} }
} }
},
contact() {
return function(targetId) {
return this.$store.getters.contactInfo(targetId)
}
} }
}, },
onLoad(e) { onLoad(e) {
@@ -60,6 +68,10 @@
}) })
// 获取消息列表 // 获取消息列表
this.getMessageList() this.getMessageList()
// 监听新消息
uni.$on('onReceiveMessage_' + this.targetId, (message) => {
this.getNewMessage()
})
// 监听消息已读状态 // 监听消息已读状态
uni.$on('onReadReceiptReceived', (data) => { uni.$on('onReadReceiptReceived', (data) => {
if (data.targetId == this.targetId) { if (data.targetId == this.targetId) {
@@ -72,25 +84,29 @@
}) })
} }
}) })
// 监听收到新消息,判断是否是当前会话,更新会话内容 uni.$on('onRecallMessage_' + this.targetId, (message) => {
uni.$on('onReceiveMessage', (msg) => {
if (msg.targetId == this.targetId) {
this.getNewMessage()
}
})
uni.$on('onRecallMessage', (res) => {
if (res.targetId == this.targetId) {
this.messages = this.messages.map(item => { this.messages = this.messages.map(item => {
if (res.messageId == item.messageId) { if (message.messageId == item.messageId) {
return res return message
} else { } else {
return item return item
} }
}) })
} })
uni.$once('onUserDelete_' + this.targetId, () => {
uni.showToast({
icon: 'none',
title: '好友关系已解除'
})
uni.switchTab({
url: '/pages/im/index'
})
}) })
}, },
onUnload() { onUnload() {
uni.$off('onUserDelete_' + this.targetId)
uni.$off('onReceiveMessage_' + this.targetId)
uni.$off('onRecallMessage_' + this.targetId)
uni.$off('onRecallMessage') uni.$off('onRecallMessage')
uni.$off('onReadReceiptReceived') uni.$off('onReadReceiptReceived')
}, },
@@ -195,4 +211,47 @@
} }
} }
} }
/* 遮罩 */
.shade {
position: fixed;
width: 100%;
height: 100%;
z-index: 999;
.pop {
border-radius: 10rpx;
position: fixed;
z-index: 101;
width: 200rpx;
box-sizing: border-box;
font-size: 28rpx;
text-align: left;
color: #333;
background-color: #fff;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
line-height: 80rpx;
transition: transform 0.15s ease-in-out 0s;
user-select: none;
-webkit-touch-callout: none;
transform: scale(0, 0);
&.show {
transform: scale(1, 1);
}
&>view {
padding: 0 20rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
user-select: none;
-webkit-touch-callout: none;
&:active {
background-color: #f3f3f3;
}
}
}
}
</style> </style>

BIN
static/.DS_Store vendored

Binary file not shown.

BIN
static/icon/emoji-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

795
static/im/emoji.js Normal file
View File

@@ -0,0 +1,795 @@
var EmojiFactory = {
"u1F603": {
"en": "Smiley Face",
"zh": "绗戣劯",
"tag": "\uD83D\uDE03",
"position": "-75px 0px"
},
"u1F600": {
"en": "Grinning Face",
"zh": "绗戝樆鍢<E6A886>",
"tag": "\uD83D\uDE00",
"position": "0px 0px"
},
"u1F60A": {
"en": "Smiley",
"zh": "寰瑧",
"tag": "\uD83D\uDE0A",
"position": "-1725px 0px"
},
"u263A": {
"en": "Cute",
"zh": "钀岃悓鍝<E68293>",
"tag": "\u263A",
"position": "-2950px 0px"
},
"u1F609": {
"en": "Winking Face",
"zh": "鐪ㄧ溂",
"tag": "\uD83D\uDE09",
"position": "-200px 0px"
},
"u1F60D": {
"en": "Heart Eyes",
"zh": "鑹茶糠杩<E7B3A0>",
"tag": "\uD83D\uDE0D",
"position": "-1800px 0px"
},
"u1F618": {
"en": "Blowing Kiss",
"zh": "椋炲惢",
"tag": "\uD83D\uDE18",
"position": "-375px 0px"
},
"u1F61A": {
"en": "Kiss Face",
"zh": "涔堜箞鍝<E7AE9E>",
"tag": "\uD83D\uDE1A",
"position": "-1875px 0px"
},
"u1F61C": {
"en": "Crazy Face",
"zh": "璋冪毊",
"tag": "\uD83D\uDE1C",
"position": "-1900px 0px"
},
"u1F61D": {
"en": "Tongue Out",
"zh": "鍚愯垖澶<E59E96>",
"tag": "\uD83D\uDE1D",
"position": "-1925px 0px"
},
"u1F633": {
"en": "Flushed Face",
"zh": "鑴哥孩",
"tag": "\uD83D\uDE33",
"position": "-625px 0px"
},
"u1F601": {
"en": "Grinning With Smiling",
"zh": "闇查娇鑰岀瑧",
"tag": "\uD83D\uDE01",
"position": "-25px 0px"
},
"u1F614": {
"en": "Pensive",
"zh": "娌夋€<E5A48B>",
"tag": "\uD83D\uDE14",
"position": "-300px 0px"
},
"u1F60C": {
"en": "Pleased",
"zh": "婊℃剰",
"tag": "\uD83D\uDE0C",
"position": "-1775px 0px"
},
"u1F612": {
"en": "Dissatisfied",
"zh": "涓嶆弧",
"tag": "\uD83D\uDE12",
"position": "-250px 0px"
},
"u1F61F": {
"en": "Worried Face",
"zh": "鑻︾摐鑴<E69190>",
"tag": "\uD83D\uDE1F",
"position": "-1975px 0px"
},
"u1F61E": {
"en": "Disappointed Face",
"zh": "澶辨湜",
"tag": "\uD83D\uDE1E",
"position": "-1950px 0px"
},
"u1F623": {
"en": "Helpless Face",
"zh": "鏃犲姪",
"tag": "\uD83D\uDE23",
"position": "-450px 0px"
},
"u1F62D": {
"en": "Crying",
"zh": "浼ゅ績",
"tag": "\uD83D\uDE22",
"position": "-425px 0px"
},
"u1F602": {
"en": "Laughing Tears",
"zh": "鍠滄瀬鑰屾常",
"tag": "\uD83D\uDE02",
"position": "-50px 0px"
},
"u1F622": {
"en": "Sobbing",
"zh": "鍝常",
"tag": "\uD83D\uDE2D",
"position": "-2075px 0px"
},
"u1F62A": {
"en": "Sleepy Face",
"zh": "鍥<>",
"tag": "\uD83D\uDE2A",
"position": "-2000px 0px"
},
"u1F630": {
"en": "Cold Sweat",
"zh": "鍐锋睏",
"tag": "\uD83D\uDE30",
"position": "-550px 0px"
},
"u1F605": {
"en": "Happy Sweat",
"zh": "灏村艾",
"tag": "\uD83D\uDE05",
"position": "-100px 0px"
},
"u1F613": {
"en": "Sweat",
"zh": "姹<>",
"tag": "\uD83D\uDE13",
"position": "-275px 0px"
},
"u1F62B": {
"en": "Tired Face",
"zh": "鎶撶媯",
"tag": "\uD83D\uDE2B",
"position": "-2025px 0px"
},
"u1F629": {
"en": "Weary Face",
"zh": "鐤叉儷",
"tag": "\uD83D\uDE29",
"position": "-525px 0px"
},
"u1F628": {
"en": "Fearful Face",
"zh": "鍙€<EE889B>",
"tag": "\uD83D\uDE28",
"position": "-500px 0px"
},
"u1F631": {
"en": "Scream",
"zh": "灏栧彨",
"tag": "\uD83D\uDE31",
"position": "-575px 0px"
},
"u1F621": {
"en": "Angry Face",
"zh": "鐢熸皵",
"tag": "\uD83D\uDE21",
"position": "-400px 0px"
},
"u1F624": {
"en": "Mad Face",
"zh": "鎬掓皵鍐插啿",
"tag": "\uD83D\uDE24",
"position": "-475px 0px"
},
"u1F616": {
"en": "Confounded Face",
"zh": "钂欑緸",
"tag": "\uD83D\uDE16",
"position": "-350px 0px"
},
"u1F606": {
"en": "Big Grin",
"zh": "澶х瑧",
"tag": "\uD83D\uDE06",
"position": "-125px 0px"
},
"u1F60B": {
"en": "Hungry",
"zh": "棣<>",
"tag": "\uD83D\uDE0B",
"position": "-1750px 0px"
},
"u1F637": {
"en": "Mask Face",
"zh": "鍙g僵",
"tag": "\uD83D\uDE37",
"position": "-725px 0px"
},
"u1F60E": {
"en": "Sunglasses",
"zh": "澧ㄩ暅",
"tag": "\uD83D\uDE0E",
"position": "-1825px 0px"
},
"u1F634": {
"en": "Sleeping",
"zh": "鐫$湢",
"tag": "\uD83D\uDE34",
"position": "-650px 0px"
},
"u1F635": {
"en": "Dizzy Face",
"zh": "澶存檿鐪艰姳",
"tag": "\uD83D\uDE35",
"position": "-675px 0px"
},
"u1F632": {
"en": "Shocked Face",
"zh": "闇囨儕",
"tag": "\uD83D\uDE32",
"position": "-600px 0px"
},
"u1F608": {
"en": "Purple Devil",
"zh": "灏忔伓榄<E4BC93>",
"tag": "\uD83D\uDE08",
"position": "-175px 0px"
},
"u1F47F": {
"en": "Devil",
"zh": "鎭堕瓟",
"tag": "\uD83D\uDC7F",
"position": "-1600px 0px"
},
"u1F62F": {
"en": "Surprised Face",
"zh": "鎯婂憜",
"tag": "\uD83D\uDE2F",
"position": "-2100px 0px"
},
"u1F62C": {
"en": "Grimacing Face",
"zh": "鎵鑴<EE8397>",
"tag": "\uD83D\uDE2C",
"position": "-2050px 0px"
},
"u1F615": {
"en": "Confused",
"zh": "鍥版儜",
"tag": "\uD83D\uDE15",
"position": "-325px 0px"
},
"u1F636": {
"en": "Mouthless",
"zh": "鏃犲彛",
"tag": "\uD83D\uDE36",
"position": "-700px 0px"
},
"u1F607": {
"en": "Halo",
"zh": "澶╀娇鍏夌幆",
"tag": "\uD83D\uDE07",
"position": "-150px 0px"
},
"u1F60F": {
"en": "Smirking Face",
"zh": "鍌荤瑧",
"tag": "\uD83D\uDE0F",
"position": "-1850px 0px"
},
"u1F611": {
"en": "Expressionless Face",
"zh": "闈㈡棤琛ㄦ儏",
"tag": "\uD83D\uDE11",
"position": "-225px 0px"
},
"u1F648": {
"en": "See No Monkey",
"zh": "涓嶇湅",
"tag": "\uD83D\uDE48",
"position": "-2675px 0px"
},
"u1F649": {
"en": "Hear No Monkey",
"zh": "涓嶅惉",
"tag": "\uD83D\uDE49",
"position": "-2700px 0px"
},
"u1F64A": {
"en": "No Speaking",
"zh": "闂槾",
"tag": "\uD83D\uDE4A",
"position": "-2125px 0px"
},
"u1F47D": {
"en": "Alien",
"zh": "澶栨槦浜<E6A7A6>",
"tag": "\uD83D\uDC7D",
"position": "-1575px 0px"
},
"u1F4A9": {
"en": "Pile Of Poo",
"zh": "渚夸究",
"tag": "\uD83D\uDCA9",
"position": "-1025px 0px"
},
"u1F494": {
"en": "Broken Heart",
"zh": "蹇冪",
"tag": "\uD83D\uDC94",
"position": "-2600px 0px"
},
"u1F525": {
"en": "Fire",
"zh": "鐏<>",
"tag": "\uD83D\uDD25",
"position": "-2625px 0px"
},
"u1F4A2": {
"en": "Anger",
"zh": "鎰ゆ€<E38286>",
"tag": "\uD83D\uDCA2",
"position": "-950px 0px"
},
"u1F4A4": {
"en": "Zzz",
"zh": "ZZZ",
"tag": "\uD83D\uDCA4",
"position": "-1000px 0px"
},
"u1F6AB": {
"en": "Prohibited",
"zh": "绂佹",
"tag": "\uD83D\uDEAB",
"position": "-1175px 0px"
},
"u2B50": {
"en": "Star",
"zh": "鏄熸槦",
"tag": "\u2B50",
"position": "-2750px 0px"
},
"u26A1": {
"en": "Lightning Bolt",
"zh": "闂數",
"tag": "\u26A1",
"position": "-2825px 0px"
},
"u1F319": {
"en": "Drescent Moon",
"zh": "寮湀",
"tag": "\uD83C\uDF19",
"position": "-2175px 0px"
},
"u2600": {
"en": "Sunny",
"zh": "鏅存湕",
"tag": "\u2600",
"position": "-3075px 0px"
},
"u26C5": {
"en": "Cloudy",
"zh": "澶氫簯",
"tag": "\u26C5",
"position": "-2900px 0px"
},
"u2601": {
"en": "Cloud",
"zh": "浜戝僵",
"tag": "\u2601",
"position": "-3100px 0px"
},
"u2744": {
"en": "Snowflake",
"zh": "闆姳",
"tag": "\u2744",
"position": "-3175px 0px"
},
"u2614": {
"en": "Umbrella",
"zh": "闆ㄤ紴",
"tag": "\u2614",
"position": "-3125px 0px"
},
"u26C4": {
"en": "Snowman",
"zh": "闆汉",
"tag": "\u26C4",
"position": "-2875px 0px"
},
"u1F44D": {
"en": "Thumbs Up",
"zh": "璧<>",
"tag": "\uD83D\uDC4D",
"position": "-1400px 0px"
},
"u1F44E": {
"en": "Thumbs Down",
"zh": "鍠濆€掑僵",
"tag": "\uD83D\uDC4E",
"position": "-1425px 0px"
},
"u1F91D": {
"en": "Handshake",
"zh": "鎻℃墜",
"tag": "\uD83E\uDD1D",
"position": "-3200px 0px"
},
"u1F44C": {
"en": "Ok Hand",
"zh": "娌¢棶棰<E6A3B6>",
"tag": "\uD83D\uDC4C",
"position": "-1375px 0px"
},
"u1F44A": {
"en": "Raised Fist",
"zh": "涓捐捣鎷冲ご",
"tag": "\u270A",
"position": "-2975px 0px"
},
"u270A": {
"en": "Oncoming Fist",
"zh": "鍑绘嫵",
"tag": "\uD83D\uDC4A",
"position": "-1350px 0px"
},
"u270C": {
"en": "Victory Hand",
"zh": "鑰<>",
"tag": "\u270C",
"position": "-3025px 0px"
},
"u270B": {
"en": "Raised Hand",
"zh": "涓炬墜",
"tag": "\u270B",
"position": "-3000px 0px"
},
"u1F64F": {
"en": "Folded Hands",
"zh": "绁堢シ",
"tag": "\uD83D\uDE4F",
"position": "-2150px 0px"
},
"u261D": {
"en": "Pointing Up",
"zh": "绗竴",
"tag": "\u261D",
"position": "-2925px 0px"
},
"u1F44F": {
"en": "Clapping Hands",
"zh": "榧撴帉",
"tag": "\uD83D\uDC4F",
"position": "-1450px 0px"
},
"u1F4AA": {
"en": "Flexed Biceps",
"zh": "鑲岃倝",
"tag": "\uD83D\uDCAA",
"position": "-1050px 0px"
},
"u1F46A": {
"en": "Family",
"zh": "瀹跺涵",
"tag": "\uD83D\uDC6A",
"position": "-1475px 0px"
},
"u1F46B": {
"en": "Couple",
"zh": "鎯呬荆",
"tag": "\uD83D\uDC6B",
"position": "-1500px 0px"
},
"u1F47C": {
"en": "Baby Angel",
"zh": "瀹濊礉澶╀娇",
"tag": "\uD83D\uDC7C",
"position": "-1550px 0px"
},
"u1F434": {
"en": "Horse",
"zh": "椹<>",
"tag": "\uD83D\uDC34",
"position": "-2475px 0px"
},
"u1F436": {
"en": "Dog",
"zh": "鐙<>",
"tag": "\uD83D\uDC36",
"position": "-2500px 0px"
},
"u1F437": {
"en": "Pig",
"zh": "鐚<>",
"tag": "\uD83D\uDC37",
"position": "-2525px 0px"
},
"u1F47B": {
"en": "Ghost",
"zh": "楝<>",
"tag": "\uD83D\uDC7B",
"position": "-1525px 0px"
},
"u1F339": {
"en": "Rose",
"zh": "鐜懓",
"tag": "\uD83C\uDF39",
"position": "-2225px 0px"
},
"u1F33B": {
"en": "Sunflower",
"zh": "鍚戞棩钁<E6A3A9>",
"tag": "\uD83C\uDF3B",
"position": "-1250px 0px"
},
"u1F332": {
"en": "Pine Tree",
"zh": "鏉炬爲",
"tag": "\uD83C\uDF32",
"position": "-2200px 0px"
},
"u1F384": {
"en": "Christmas Tree",
"zh": "鍦癁鏍<E79981>",
"tag": "\uD83C\uDF84",
"position": "-2400px 0px"
},
"u1F381": {
"en": "Wrapped Gift",
"zh": "绀肩墿",
"tag": "\uD83C\uDF81",
"position": "-2350px 0px"
},
"u1F389": {
"en": "Party Popper",
"zh": "鑱氫細绀艰姳",
"tag": "\uD83C\uDF89",
"position": "-2425px 0px"
},
"u1F4B0": {
"en": "Money Bag",
"zh": "閽辫",
"tag": "\uD83D\uDCB0",
"position": "-1075px 0px"
},
"u1F382": {
"en": "Birthday Cake",
"zh": "鐢熸棩铔嬬硶",
"tag": "\uD83C\uDF82",
"position": "-2375px 0px"
},
"u1F356": {
"en": "Barbecue",
"zh": "BBQ",
"tag": "\uD83C\uDF56",
"position": "-2275px 0px"
},
"u1F35A": {
"en": "Cooked Rice",
"zh": "绫抽キ",
"tag": "\uD83C\uDF5A",
"position": "-1275px 0px"
},
"u1F366": {
"en": "Ice Cream",
"zh": "鍐版穱娣<E7A9B1>",
"tag": "\uD83C\uDF66",
"position": "-2300px 0px"
},
"u1F36B": {
"en": "Chocolate Bar",
"zh": "宸у厠鍔<E58EA0>",
"tag": "\uD83C\uDF6B",
"position": "-1300px 0px"
},
"u1F349": {
"en": "Watermelon",
"zh": "瑗跨摐",
"tag": "\uD83C\uDF49",
"position": "-2250px 0px"
},
"u1F377": {
"en": "Wine Glass",
"zh": "绾㈤厭",
"tag": "\uD83C\uDF77",
"position": "-2325px 0px"
},
"u1F37B": {
"en": "Cheers",
"zh": "骞叉澂",
"tag": "\uD83C\uDF7B",
"position": "-1325px 0px"
},
"u2615": {
"en": "Coffee",
"zh": "鍜栧暋",
"tag": "\u2615",
"position": "-3150px 0px"
},
"u1F3C0": {
"en": "Basketball",
"zh": "绡悆",
"tag": "\uD83C\uDFC0",
"position": "-825px 0px"
},
"u26BD": {
"en": "Soccer Ball",
"zh": "瓒崇悆",
"tag": "\u26BD",
"position": "-2850px 0px"
},
"u1F3C2": {
"en": "Snowboarder",
"zh": "鍗曟澘婊戦洩",
"tag": "\uD83C\uDFC2",
"position": "-850px 0px"
},
"u1F3A4": {
"en": "Microphone",
"zh": "楹﹀厠椋<E58EA0>",
"tag": "\uD83C\uDFA4",
"position": "-750px 0px"
},
"u1F3B5": {
"en": "Musical Note",
"zh": "闊充箰",
"tag": "\uD83C\uDFB5",
"position": "-800px 0px"
},
"u1F3B2": {
"en": "Game Die",
"zh": "楠板瓙",
"tag": "\uD83C\uDFB2",
"position": "-775px 0px"
},
"u1F004": {
"en": "Mahjong Red Dragon",
"zh": "楹诲皢",
"tag": "\uD83C\uDC04",
"position": "-900px 0px"
},
"u1F451": {
"en": "Crown",
"zh": "鐜嬪啝",
"tag": "\uD83D\uDC51",
"position": "-2550px 0px"
},
"u1F484": {
"en": "Lipstick",
"zh": "鍙g孩",
"tag": "\uD83D\uDC84",
"position": "-2575px 0px"
},
"u1F48B": {
"en": "Kiss",
"zh": "鍚<>",
"tag": "\uD83D\uDC8B",
"position": "-1650px 0px"
},
"u1F48D": {
"en": "Ring",
"zh": "鎴掓寚",
"tag": "\uD83D\uDC8D",
"position": "-1675px 0px"
},
"u1F4DA": {
"en": "Books",
"zh": "涔︾睄",
"tag": "\uD83D\uDCDA",
"position": "-1100px 0px"
},
"u1F393": {
"en": "Graduation Cap",
"zh": "姣曚笟甯<E7AC9F>",
"tag": "\uD83C\uDF93",
"position": "-2450px 0px"
},
"u270F": {
"en": "Pencil",
"zh": "閾呯瑪",
"tag": "\u270F",
"position": "-3050px 0px"
},
"u1F3E1": {
"en": "House With Garden",
"zh": "鎴垮瓙",
"tag": "\uD83C\uDFE1",
"position": "-875px 0px"
},
"u1F6BF": {
"en": "Shower",
"zh": "娣嬫荡",
"tag": "\uD83D\uDEBF",
"position": "-1200px 0px"
},
"u1F4A1": {
"en": "Light Bulb",
"zh": "鐏场",
"tag": "\uD83D\uDCA1",
"position": "-925px 0px"
},
"u1F4DE": {
"en": "Telephone Receiver",
"zh": "鐢佃瘽鍚瓛",
"tag": "\uD83D\uDCDE",
"position": "-1125px 0px"
},
"u1F4E2": {
"en": "Loudspeaker",
"zh": "鎵╅煶鍣<E785B6>",
"tag": "\uD83D\uDCE2",
"position": "-1150px 0px"
},
"u1F556": {
"en": "Clock",
"zh": "琛<>",
"tag": "\uD83D\uDD56",
"position": "-2650px 0px"
},
"u23F0": {
"en": "Alarm Clock",
"zh": "闂归挓",
"tag": "\u23F0",
"position": "-2775px 0px"
},
"u23F3": {
"en": "Hourglass",
"zh": "娌欐紡",
"tag": "\u23F3",
"position": "-2800px 0px"
},
"u1F4A3": {
"en": "Bomb",
"zh": "鐐稿脊",
"tag": "\uD83D\uDCA3",
"position": "-975px 0px"
},
"u1F52B": {
"en": "Pistol",
"zh": "鎵嬫灙",
"tag": "\uD83D\uDD2B",
"position": "-1700px 0px"
},
"u1F48A": {
"en": "Capsule",
"zh": "鑽<>",
"tag": "\uD83D\uDC8A",
"position": "-1625px 0px"
},
"u1F680": {
"en": "Rocket",
"zh": "鐏",
"tag": "\uD83D\uDE80",
"position": "-2725px 0px"
},
"u1F30F": {
"en": "Globe",
"zh": "鍦扮悆",
"tag": "\uD83C\uDF0F",
"position": "-1225px 0px"
}
};
let EmojiList = []
function setEmojiList() {
EmojiList.length = 0;
for (var unicode in EmojiFactory) {
var detail = EmojiFactory[unicode];
if (detail.tag) {
var lang = 'en';
var symbol = detail[lang];
EmojiList.push({
unicode: unicode,
symbol: '[' + symbol + ']',
emoji: detail.tag,
});
}
}
}
setEmojiList()
export default EmojiList

BIN
static/im/toast/sentVoice.mp3 Executable file

Binary file not shown.

BIN
static/user/cover-s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -1,4 +1,7 @@
import im from "@/utils/im/index.js" import im from "@/utils/im/index.js"
import {
contactModel
} from '@/utils/im/models.js'
export default { export default {
state: { state: {
@@ -14,7 +17,7 @@ export default {
const info = state.contacts[targetId] const info = state.contacts[targetId]
return { return {
name: info.name, name: info.remark ? info.remark : info.name,
hash: info.hash, hash: info.hash,
portraitUrl: info.localAvatar ? info.localAvatar : require('@/static/user/cover.png') portraitUrl: info.localAvatar ? info.localAvatar : require('@/static/user/cover.png')
} }
@@ -44,9 +47,31 @@ export default {
name: contactInfo.name, name: contactInfo.name,
portraitUrl: contactInfo.portraitUrl portraitUrl: contactInfo.portraitUrl
} }
<<<<<<< HEAD
} }
=======
},
setContactRemark(state, contactInfo) {
Vue.set(state.contacts, contactInfo.targetId, contactInfo)
}
>>>>>>> 013c030963aef06a00ac33d5f767cbd97ef2ceac
}, },
actions: { actions: {
setContactRemark({
commit
}, {
targetId,
remark
}) {
contactModel.find('targetId="' + targetId + '"', (err, result) => {
if (!err && result.length > 0) {
result[0].remark = remark
contactModel.update('targetId="' + targetId + '"', result[0], (err, res) => {
commit('setContactRemark', result[0])
})
}
})
},
setSenderInfo({ setSenderInfo({
commit commit
}, contactInfo) { }, contactInfo) {
@@ -63,8 +88,7 @@ export default {
commit, commit,
dispatch dispatch
}, contactInfo) { }, contactInfo) {
const model = uni.model.contactModel contactModel.find('targetId="' + contactInfo.targetId + '"', (err, result) => {
model.find('targetId="' + contactInfo.targetId + '"', (err, result) => {
if (result.length == 0) { if (result.length == 0) {
// 没有数据,直接新增一条 // 没有数据,直接新增一条
dispatch('initContact', contactInfo) dispatch('initContact', contactInfo)
@@ -75,12 +99,13 @@ export default {
targetId: contactInfo.targetId, targetId: contactInfo.targetId,
name: contactInfo.name, name: contactInfo.name,
hash: contactInfo.hash, hash: contactInfo.hash,
type: contactInfo.type,
portraitUrl: contactInfo.portraitUrl, portraitUrl: contactInfo.portraitUrl,
localAvatar: savedFilePath localAvatar: savedFilePath
} }
model.update('targetId="' + contactInfo.targetId + '"', info, (err, contactModel.update('targetId="' + contactInfo.targetId + '"', info, (err,
res) => { res) => {
console.log('UPDATE AVATAR, ERR', err, info); console.log('UPDATE AVATAR, ERR', err, info)
}) })
commit('updateContactInfo', info) commit('updateContactInfo', info)
}) })
@@ -89,16 +114,17 @@ export default {
targetId: contactInfo.targetId, targetId: contactInfo.targetId,
name: contactInfo.name, name: contactInfo.name,
hash: contactInfo.hash, hash: contactInfo.hash,
type: contactInfo.type,
portraitUrl: contactInfo.portraitUrl, portraitUrl: contactInfo.portraitUrl,
localAvatar: result[0].localAvatar localAvatar: result[0].localAvatar
} }
model.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => { contactModel.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => {
console.log('UPDATE NAME, ERR', err, info); console.log('UPDATE NAME, ERR', err, info);
}) })
commit('updateContactInfo', info) commit('updateContactInfo', info)
} }
} else { } else {
console.log('updateContact, 无操作'); console.log('updateContact, 无操作')
} }
}) })
}, },
@@ -108,7 +134,6 @@ export default {
}, contactInfo) { }, contactInfo) {
// 将好友信息保存到vuex的内存中方便立即使用 // 将好友信息保存到vuex的内存中方便立即使用
commit('updateContactInfo', contactInfo) commit('updateContactInfo', contactInfo)
const model = uni.model.contactModel
// 用户头像,是否需要下载到本地 // 用户头像,是否需要下载到本地
if (contactInfo.portraitUrl) { if (contactInfo.portraitUrl) {
saveAvatar(contactInfo, (savedFilePath) => { saveAvatar(contactInfo, (savedFilePath) => {
@@ -116,10 +141,13 @@ export default {
targetId: contactInfo.targetId, targetId: contactInfo.targetId,
name: contactInfo.name, name: contactInfo.name,
hash: contactInfo.hash, hash: contactInfo.hash,
type: contactInfo.type,
portraitUrl: contactInfo.portraitUrl, portraitUrl: contactInfo.portraitUrl,
localAvatar: savedFilePath localAvatar: savedFilePath
} }
model.insert(info, (err, res) => {}) contactModel.insert(info, (err, res) => {
console.error('保存头像', err, res)
})
// 保存头像后,更新信息 // 保存头像后,更新信息
commit('updateContactInfo', info) commit('updateContactInfo', info)
}) })
@@ -129,10 +157,13 @@ export default {
targetId: contactInfo.targetId, targetId: contactInfo.targetId,
name: contactInfo.name, name: contactInfo.name,
hash: contactInfo.hash, hash: contactInfo.hash,
type: contactInfo.type,
portraitUrl: contactInfo.portraitUrl, portraitUrl: contactInfo.portraitUrl,
localAvatar: '' localAvatar: ''
} }
model.insert(info, (err, res) => {}) contactModel.insert(info, (err, res) => {
console.error('没保存头像', err, res)
})
} }
} }
} }

BIN
uni_modules/onemue-USQLite/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,7 +1,10 @@
## 2.1.02022-01-14 ## 2.2.22022-02-18
1. 新增了添加多个数据的事件选项options, index感谢`@风扬` 1. 解决了自增约束的部分bug
## 2.1.22022-01-14 2. 解决了处理类型的问题
1. 新增了添加多个数据的事件选项options, index感谢`@风扬` ## 2.2.02022-02-16
1. 重新处理了判断类型的方法
2. 解决了`no connect`的问题
3. 新增了自增约束,需要为数字类型
## 2.1.02022-01-14 ## 2.1.02022-01-14
1. 新增了添加多个数据的事件选项options, index感谢`@风扬` 1. 新增了添加多个数据的事件选项options, index感谢`@风扬`
## 2.0.22022-01-05 ## 2.0.22022-01-05

View File

@@ -37,10 +37,13 @@ class Utils {
} }
} }
} }
Utils.log(primaryKeyArr.length); Utils.log(primaryKeyArr.length);
if (primaryKeyArr.length>=1) { if (primaryKeyArr.length>1) {
sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')}, PRIMARY KEY (${primaryKeyArr.join()}))`;
}else{ sql = `CREATE TABLE '${name}' (${sqlArr.join(', ').replaceAll(' PRIMARY KEY','')}, PRIMARY KEY (${primaryKeyArr.join()}))`;
}
else{
sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')})`; sql = `CREATE TABLE '${name}' (${sqlArr.join(', ')})`;
} }
Utils.log(`modelSql :${sql}`); Utils.log(`modelSql :${sql}`);
@@ -59,6 +62,22 @@ class Utils {
} }
restrainArray.push(Utils.toType(options.type)); restrainArray.push(Utils.toType(options.type));
// 主键
if (options.primaryKey == true) {
if(options.autoIncrement != true){
restrainArray.push('PRIMARY KEY');
}
}
// 自增
if (Utils.isNumber(options.type)&&options.autoIncrement == true) {
restrainArray.pop();
restrainArray.push('INTEGER');
restrainArray.push('PRIMARY KEY');
restrainArray.push('AUTOINCREMENT');
}
// 非空 // 非空
if (options.notNull == true) { if (options.notNull == true) {
restrainArray.push('NOT NULL'); restrainArray.push('NOT NULL');
@@ -74,10 +93,6 @@ class Utils {
restrainArray.push('UNIQUE'); restrainArray.push('UNIQUE');
} }
// 主键
// if (options.primaryKey === true) {
// restrainArray.push('PRIMARY KEY');
// }
// 检查 // 检查
if (options.check) { if (options.check) {
@@ -87,27 +102,44 @@ class Utils {
return restrainArray.join(' '); return restrainArray.join(' ');
} }
// 联合主键
static getUnionPrimaryKey() {
}
static toType(jsType) { static toType(jsType) {
let sqliteType = ''; let sqliteType = '';
if (jsType == Number) { if (Utils.isNumber(jsType)) {
sqliteType = 'numeric'; sqliteType = 'numeric';
} else if (jsType == Date) { } else if (Utils.isDate(jsType)) {
sqliteType = 'timestamp'; sqliteType = 'timestamp';
} else { } else {
sqliteType = 'varchar'; sqliteType = 'varchar';
} }
return sqliteType; return sqliteType;
} }
static log() { static log() {
if (config.deBug) { if (config.deBug) {
console.log.apply(null, arguments); console.log.apply(null, arguments);
} }
} }
static warn() {
if (config.deBug) {
console.warn.apply(null, arguments);
}
}
static error() {
console.error.apply(null, arguments);
}
static isArray(value){ return Object.prototype.toString.call(value) === '[object Array]'}
static isObject(value){ return Object.prototype.toString.call(value) === '[object Object]'}
static isString(value){ return Object.prototype.toString.call(value) === '[object String]'}
static isFunction(value){ return (value === Function || Object.prototype.toString.call(value) === '[object Function]')}
static isNumber(value){ return (value === Number || Object.prototype.toString.call(value) === '[object Number]')}
static isNaN(value){ return (Object.prototype.toString.call(value) === '[object Number]' && isNaN(value))}
static isBoolean(value){ return Object.prototype.toString.call(value) === '[object Boolean]'}
static isUndefined(value){ return Object.prototype.toString.call(value) === '[object Undefined]'}
static isModel(value){ return Object.prototype.toString.call(value) === '[object Model]'}
static isDate(value){ return (value === Date||Object.prototype.toString.call(value) === '[object Date]')}
} }
@@ -118,7 +150,7 @@ class Model {
/** /**
* @constructor * @constructor
* @param {String} name 数据库表名 * @param {String} name 数据库表名
* @param {Object} options 数据表列对象 * @param {} options 数据表列对象
* @returns * @returns
*/ */
constructor(name, options) { constructor(name, options) {
@@ -129,7 +161,10 @@ class Model {
if (config.isConnect) { if (config.isConnect) {
self.repair(); self.repair();
} else { } else {
console.error('no connect'); if(!config.name||!config.path){
console.error('"config.name" or "config.path" is empty');
}
usqlite.connect(config);
} }
} }
@@ -138,21 +173,27 @@ class Model {
* @param {String|Array} options * @param {String|Array} options
* - String WHERE 内容 * - String WHERE 内容
* - Array 需要查询的列 * - Array 需要查询的列
* @param {*} callback * @param {Function} callback
* @returns * @returns
*/ */
find(options, callback) { find(options, callback) {
let sql = ''; let sql = '';
let self = this; let self = this;
self.repair(); self.repair();
if (!callback) { if(!(Utils.isString(options)||Utils.isArray(options)||Utils.isFunction(options))) {
Utils.error('The first parameter of Model.find should be "Array", "String" or "Function" (when there is only one parameter).')
}
if(!callback&&!(Utils.isFunction(options))) {
Utils.error('The second parameter of Model.find should be "Function".')
}
if (!callback&&Utils.isFunction(options)) {
sql = `SELECT * FROM '${this.name}'`; // 查找全部 sql = `SELECT * FROM '${this.name}'`; // 查找全部
callback = options; callback = options;
} else if (options.constructor == Array) { } else if (Utils.isArray(options)) {
sql = `SELECT ${options.join()} FROM '${this.name}'`; // 查找制定列 sql = `SELECT ${options.join()} FROM '${this.name}'`; // 查找制定列
} else if (options.constructor == String) { } else if (Utils.isString(options)) {
sql = `SELECT * FROM '${this.name}' WHERE ${options}`; // 制定条件查询 sql = `SELECT * FROM '${this.name}' WHERE ${options}`; // 制定条件查询
}; }
Utils.log(`find: ${sql}`); Utils.log(`find: ${sql}`);
@@ -180,6 +221,12 @@ class Model {
let sql = ''; let sql = '';
let self = this; let self = this;
self.repair(); self.repair();
if(!Utils.isObject(options)){
Utils.error('The first parameter of Model.limit should be "Object".')
}
if(!Utils.isFunction(callback)){
Utils.error('The second parameter of Model.limit should be "Function".')
}
if (!options.where) { if (!options.where) {
// 不存在 where // 不存在 where
@@ -215,12 +262,19 @@ class Model {
let self = this; let self = this;
self.repair(); self.repair();
if(!(Utils.isObject(options)||Util.isArray(options))){
Utils.error('The first parameter of Model.insert should be "Object" or "Array".')
}
if(!Utils.isFunction(callback)){
Utils.error('The second parameter of Model.insert should be "Function".')
}
if (config.isConnect) { if (config.isConnect) {
if (options.constructor == Array) { if (Utils.isArray(options)) {
for (var i = 0; i < options.length; i++) { for (var i = 0; i < options.length; i++) {
this.insert(options[i], callback, i); this.insert(options[i], callback, i);
} }
} else if (options.constructor == Object) { } else if (Utils.isObject(options)) {
let keys = []; let keys = [];
let values = []; let values = [];
let index = arguments[3]??null; let index = arguments[3]??null;
@@ -255,7 +309,7 @@ class Model {
/** /**
* @description 更新数据 * @description 更新数据
* @param {Object} options可选参数 更新条件 * @param {String} options可选参数 更新条件
* @param {Object} obj 修改后的数据 * @param {Object} obj 修改后的数据
* @param {Function} callback :err,results=>{} * @param {Function} callback :err,results=>{}
*/ */
@@ -265,6 +319,13 @@ class Model {
let items = []; let items = [];
self.repair(); self.repair();
if(!(Utils.isObject(options)||Utils.isString(options))){
Utils.error('The first parameter of Model.update should be "Object" or "String".')
}
if(!(Utils.isObject(obj)||Utils.isFunction(obj))){
Utils.error('The second parameter of Model.update should be "Objrct" or "Function".')
}
if (!callback) { if (!callback) {
// 不存在options // 不存在options
callback = obj; callback = obj;
@@ -298,7 +359,7 @@ class Model {
/** /**
* @description 删除数据 * @description 删除数据
* @param {Object} options :可选参数 删除条件 * @param {String} options :可选参数 删除条件
* @param {Function} callback :err,results=>{} * @param {Function} callback :err,results=>{}
*/ */
delete(options, callback) { delete(options, callback) {
@@ -306,6 +367,13 @@ class Model {
let self = this; let self = this;
self.repair(); self.repair();
if(!(Utils.isString(options)||Utils.isFunction(options))){
Utils.error('The first parameter of Model.delete should be "Object" or "Function".')
}
if(callback&&!Utils.isFunction(callback)){
Utils.error('The second parameter of Model.delete should be "Function".')
}
if (!callback) { if (!callback) {
sql = `DELETE FROM '${this.name}'`; sql = `DELETE FROM '${this.name}'`;
callback = options; callback = options;
@@ -330,7 +398,7 @@ class Model {
/** /**
* @description 重命名或者新增列 * @description 重命名或者新增列
* @param {Object} options 参数 数组为新增多列 对象为新增单列{aa} 字符串重命名 * @param {Object|Array|String} options 参数 数组为新增多列 对象为新增单列{aa} 字符串重命名
* @param {Function} callback :err,results=>{} * @param {Function} callback :err,results=>{}
* @return: * @return:
*/ */
@@ -338,12 +406,18 @@ class Model {
let self = this; let self = this;
let sql = ''; let sql = '';
self.repair(); self.repair();
if(!(Utils.isObject(options)||Utils.isArray(options)||Utils.isString(options))){
Utils.error('The first parameter of Model.alter should be "Object", "Array" or "String".')
}
if(!Utils.isFunction(callback)){
Utils.error('The second parameter of Model.alter should be "Function".')
}
if (options.constructor == Array) { // 新增多列 if (Utils.isArray(options)) { // 新增多列
for (let i = 0; i < options.length; i++) { for (let i = 0; i < options.length; i++) {
self.alter(options[i], callback); self.alter(options[i], callback);
} }
} else if (options.constructor == Object) { // 新增单列 } else if (Utils.isObject(options)) { // 新增单列
let column = Utils.restrain(options.name, options.option); let column = Utils.restrain(options.name, options.option);
sql = `ALTER TABLE '${this.name}' ADD COLUMN ${column}` sql = `ALTER TABLE '${this.name}' ADD COLUMN ${column}`
} else if (options.constructor == String) { // 重命名 } else if (options.constructor == String) { // 重命名
@@ -374,13 +448,13 @@ class Model {
*/ */
join(model, options, callback) { join(model, options, callback) {
if (!model) { if (!model) {
console.error('"model" cannot be empty.'); Utils.error('"model" cannot be empty.');
} }
if (options.constructor != Object) { if (!Utils.isObject(options)) {
console.error('The type of "options" is wrong, it should be "Object".'); Utils.error('The type of "options" is wrong, it should be "Object".');
} }
if (!options.type || !options.predicate) { if (!options.type || !options.predicate) {
console.error('Missing required parameters'); Utils.error('Missing required parameters');
} }
let leftName = this.name; let leftName = this.name;
@@ -427,6 +501,13 @@ class Model {
* @param {Function} callback :err,results=>{} * @param {Function} callback :err,results=>{}
*/ */
sql(sql, callback) { sql(sql, callback) {
if (!Utils.isString(sql)) {
Utils.error('"The type of "sql" is wrong, it should be "String".');
}
if (callback&&!Utils.isFunction(callback)) {
Utils.error('The type of "callback" is wrong, it should be "Function".');
}
let self = this; let self = this;
self.repair(); self.repair();
@@ -449,6 +530,10 @@ class Model {
* @param {Function} callback * @param {Function} callback
*/ */
isExist(callback) { isExist(callback) {
if (callback&&!Utils.isFunction(callback)) {
Utils.error('The type of "callback" is wrong, it should be "Function".');
}
let sql = `SELECT count(*) AS isExist FROM sqlite_master WHERE type='table' AND name='${this.name}'`; let sql = `SELECT count(*) AS isExist FROM sqlite_master WHERE type='table' AND name='${this.name}'`;
let self = this; let self = this;
Utils.log(`isExist: ${sql}`); Utils.log(`isExist: ${sql}`);
@@ -470,6 +555,10 @@ class Model {
* @param {Function} callback * @param {Function} callback
*/ */
drop(callback) { drop(callback) {
if (callback&&!Utils.isFunction(callback)) {
Utils.error('The type of "callback" is wrong, it should be "Function".');
}
var sql = `DROP TABLE '${this.name}'`; var sql = `DROP TABLE '${this.name}'`;
let self = this; let self = this;
self.repair(); self.repair();
@@ -493,6 +582,10 @@ class Model {
* @param {Function} callback * @param {Function} callback
*/ */
create(callback) { create(callback) {
if (callback&&!Utils.isFunction(callback)) {
Utils.error('The type of "callback" is wrong, it should be "Function".');
}
let self = this; let self = this;
let sql = Utils.modelSql(self.name, self.options); let sql = Utils.modelSql(self.name, self.options);
Utils.log(`create: ${sql}`); Utils.log(`create: ${sql}`);
@@ -574,6 +667,7 @@ export class usqlite {
} }
}); });
} }
/** /**
* @description 断开数据库 * @description 断开数据库
* @param {*} callback * @param {*} callback
@@ -591,6 +685,19 @@ export class usqlite {
} }
}); });
} }
static closeAsync(options){
plus.sqlite.closeDatabase({
name: config.name, //数据库名称
path: config.path, //数据库地址
success(e) {
config.isConnect = false;
callback(null, e);
},
fail(e) {
callback(e);
}
});
}
/** /**
* @description 创建 Model 对象 * @description 创建 Model 对象
* @example * @example

Binary file not shown.

View File

@@ -1,7 +1,7 @@
{ {
"id": "onemue-USQLite", "id": "onemue-USQLite",
"displayName": "u-SQLite V2", "displayName": "u-SQLite V2",
"version": "2.1.0", "version": "2.2.2",
"description": "基于ORM技术使用对象的方式来操作sqlite数据库而无需编写任何sql语句.", "description": "基于ORM技术使用对象的方式来操作sqlite数据库而无需编写任何sql语句.",
"keywords": [ "keywords": [
"USQLite,数据库操作,缓存,大数据缓存,sqlite,sql,orm" "USQLite,数据库操作,缓存,大数据缓存,sqlite,sql,orm"

View File

@@ -1,5 +1,6 @@
<h2>onemue-USQLite</h2> <h2>onemue-USQLite</h2><h2>onemue-USQLite</h2>
<h2 style="color:red">没有特别说明,均为异步函数</h2>
> u-SQLite 交流群643867519 > u-SQLite 交流群643867519
> 如果觉的当前插件对你有帮助可以前往 [github](https://github.com/onemue/u-sqlite) 点 star! > 如果觉的当前插件对你有帮助可以前往 [github](https://github.com/onemue/u-sqlite) 点 star!
@@ -49,6 +50,7 @@ let studentModel = uni.$sql.model('student',{
- unique UNIQUE 不重复 - unique UNIQUE 不重复
- default DEFAULT 默认值 - default DEFAULT 默认值
- notNull NOT NULL 非空 - notNull NOT NULL 非空
- autoIncrement AUTOINCREMENT 非空
**联合主键** **联合主键**

View File

@@ -1,3 +1,9 @@
## 1.3.52022-01-24
- 优化 size 属性可以传入不带单位的字符串数值
## 1.3.42022-01-24
- 优化 size 支持其他单位
## 1.3.32022-01-17
- 修复 nvue 有些图标不显示的bug兼容老版本图标
## 1.3.22021-12-01 ## 1.3.22021-12-01
- 优化 示例可复制图标名称 - 优化 示例可复制图标名称
## 1.3.12021-11-23 ## 1.3.12021-11-23

View File

@@ -173,6 +173,13 @@ export default {
"unicode": "e6bb", "unicode": "e6bb",
"unicode_decimal": 59067 "unicode_decimal": 59067
}, },
{
"icon_id": "24923353",
"name": "arrowthinright",
"font_class": "arrowthinright",
"unicode": "e6bb",
"unicode_decimal": 59067
},
{ {
"icon_id": "24923354", "icon_id": "24923354",
"name": "arrowthinleft", "name": "arrowthinleft",
@@ -180,6 +187,13 @@ export default {
"unicode": "e6bc", "unicode": "e6bc",
"unicode_decimal": 59068 "unicode_decimal": 59068
}, },
{
"icon_id": "24923354",
"name": "arrowthinleft",
"font_class": "arrowthinleft",
"unicode": "e6bc",
"unicode_decimal": 59068
},
{ {
"icon_id": "24923355", "icon_id": "24923355",
"name": "arrowthinup", "name": "arrowthinup",
@@ -187,12 +201,25 @@ export default {
"unicode": "e6bd", "unicode": "e6bd",
"unicode_decimal": 59069 "unicode_decimal": 59069
}, },
{
"icon_id": "24923355",
"name": "arrowthinup",
"font_class": "arrowthinup",
"unicode": "e6bd",
"unicode_decimal": 59069
},
{ {
"icon_id": "24923356", "icon_id": "24923356",
"name": "arrowthindown", "name": "arrowthindown",
"font_class": "arrow-down", "font_class": "arrow-down",
"unicode": "e6be", "unicode": "e6be",
"unicode_decimal": 59070 "unicode_decimal": 59070
},{
"icon_id": "24923356",
"name": "arrowthindown",
"font_class": "arrowthindown",
"unicode": "e6be",
"unicode_decimal": 59070
}, },
{ {
"icon_id": "24923349", "icon_id": "24923349",
@@ -200,6 +227,12 @@ export default {
"font_class": "bottom", "font_class": "bottom",
"unicode": "e6b8", "unicode": "e6b8",
"unicode_decimal": 59064 "unicode_decimal": 59064
},{
"icon_id": "24923349",
"name": "arrowdown",
"font_class": "arrowdown",
"unicode": "e6b8",
"unicode_decimal": 59064
}, },
{ {
"icon_id": "24923346", "icon_id": "24923346",
@@ -208,6 +241,13 @@ export default {
"unicode": "e6b5", "unicode": "e6b5",
"unicode_decimal": 59061 "unicode_decimal": 59061
}, },
{
"icon_id": "24923346",
"name": "arrowright",
"font_class": "arrowright",
"unicode": "e6b5",
"unicode_decimal": 59061
},
{ {
"icon_id": "24923347", "icon_id": "24923347",
"name": "arrowup", "name": "arrowup",
@@ -215,6 +255,13 @@ export default {
"unicode": "e6b6", "unicode": "e6b6",
"unicode_decimal": 59062 "unicode_decimal": 59062
}, },
{
"icon_id": "24923347",
"name": "arrowup",
"font_class": "arrowup",
"unicode": "e6b6",
"unicode_decimal": 59062
},
{ {
"icon_id": "24923348", "icon_id": "24923348",
"name": "arrowleft", "name": "arrowleft",
@@ -222,6 +269,13 @@ export default {
"unicode": "e6b7", "unicode": "e6b7",
"unicode_decimal": 59063 "unicode_decimal": 59063
}, },
{
"icon_id": "24923348",
"name": "arrowleft",
"font_class": "arrowleft",
"unicode": "e6b7",
"unicode_decimal": 59063
},
{ {
"icon_id": "24923334", "icon_id": "24923334",
"name": "eye", "name": "eye",

View File

@@ -1,14 +1,18 @@
<template> <template>
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<text :style="{ color: color, 'font-size': size + 'px' }" class="uni-icons" @click="_onClick">{{unicode}}</text> <text :style="{ color: color, 'font-size': iconSize }" class="uni-icons" @click="_onClick">{{unicode}}</text>
<!-- #endif --> <!-- #endif -->
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<text :style="{ color: color, 'font-size': size + 'px' }" class="uni-icons" :class="['uniui-'+type,customPrefix,customPrefix?type:'']" @click="_onClick"></text> <text :style="{ color: color, 'font-size': iconSize }" class="uni-icons" :class="['uniui-'+type,customPrefix,customPrefix?type:'']" @click="_onClick"></text>
<!-- #endif --> <!-- #endif -->
</template> </template>
<script> <script>
import icons from './icons.js'; import icons from './icons.js';
const getVal = (val) => {
const reg = /^[0-9]*$/g
return (typeof val === 'number' || reg.test(val) )? val + 'px' : val;
}
// #ifdef APP-NVUE // #ifdef APP-NVUE
var domModule = weex.requireModule('dom'); var domModule = weex.requireModule('dom');
import iconUrl from './uniicons.ttf' import iconUrl from './uniicons.ttf'
@@ -61,6 +65,9 @@
return unescape(`%u${code.unicode}`) return unescape(`%u${code.unicode}`)
} }
return '' return ''
},
iconSize(){
return getVal(this.size)
} }
}, },
methods: { methods: {

View File

@@ -1,7 +1,7 @@
{ {
"id": "uni-icons", "id": "uni-icons",
"displayName": "uni-icons 图标", "displayName": "uni-icons 图标",
"version": "1.3.2", "version": "1.3.5",
"description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。", "description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",

View File

@@ -1,3 +1,13 @@
## 3.3.122022-01-15
- 新增 preferedAppPlatform 配置用于解决uni-app vue2版本vue3版本获取platform不一致的问题 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=prefered-app-platform)
- 修复 checkToken 未返回自定义token内容的Bug
## 3.3.112022-01-11
- 修复用户名密码登录时多个应用出现重复用户名登录报错的Bug
## 3.3.102022-01-07
- 新增 自定义国际化语言支持 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=custom-i8n)
- 修复 一键登录时未校验重复手机号是否已验证的Bug
- 修复 Apple登录时用户邮箱为空时报错的Bug
- 修复 登录接口未传username时错误提示不正确的Bug
## 3.3.92021-11-09 ## 3.3.92021-11-09
- 去除重复的context.xxx未找到的提示语 - 去除重复的context.xxx未找到的提示语
## 3.3.82021-10-28 ## 3.3.82021-10-28

View File

@@ -1,7 +1,7 @@
{ {
"id": "uni-id", "id": "uni-id",
"displayName": "uni-id", "displayName": "uni-id",
"version": "3.3.9", "version": "3.3.12",
"description": "简单、统一、可扩展的用户中心", "description": "简单、统一、可扩展的用户中心",
"keywords": [ "keywords": [
"uniid", "uniid",

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "uni-id", "name": "uni-id",
"version": "3.3.5", "version": "3.3.12",
"description": "uni-id for uniCloud", "description": "uni-id for uniCloud",
"main": "index.js", "main": "index.js",
"homepage": "https://uniapp.dcloud.io/uniCloud/uni-id", "homepage": "https://uniapp.dcloud.io/uniCloud/uni-id",

View File

@@ -1,3 +1,5 @@
## 1.0.32022-01-21
- 优化 组件示例
## 1.0.22021-11-22 ## 1.0.22021-11-22
- 修复 / 符号在 vue 不同版本兼容问题引起的报错问题 - 修复 / 符号在 vue 不同版本兼容问题引起的报错问题
## 1.0.12021-11-22 ## 1.0.12021-11-22

View File

@@ -1,7 +1,7 @@
{ {
"id": "uni-scss", "id": "uni-scss",
"displayName": "uni-scss 辅助样式", "displayName": "uni-scss 辅助样式",
"version": "1.0.2", "version": "1.0.3",
"description": "uni-sass是uni-ui提供的一套全局样式 通过一些简单的类名和sass变量实现简单的页面布局操作比如颜色、边距、圆角等。", "description": "uni-sass是uni-ui提供的一套全局样式 通过一些简单的类名和sass变量实现简单的页面布局操作比如颜色、边距、圆角等。",
"keywords": [ "keywords": [
"uni-scss", "uni-scss",
@@ -14,8 +14,8 @@
}, },
"dcloudext": { "dcloudext": {
"category": [ "category": [
"uni-app前端模板", "JS SDK",
"前端页面模板" "通用 SDK"
], ],
"sale": { "sale": {
"regular": { "regular": {

View File

@@ -9,6 +9,9 @@ import {
getImToken, getImToken,
getMyGroups getMyGroups
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import {
contactModel
} from './models.js'
const initIm = (KEY) => { const initIm = (KEY) => {
RongIMLib.init(KEY) RongIMLib.init(KEY)
@@ -20,6 +23,8 @@ const initIm = (KEY) => {
getImToken().then(res => { getImToken().then(res => {
connect(res.token, res.userInfo, (res) => { connect(res.token, res.userInfo, (res) => {
console.log('IM.CONNECT', res); console.log('IM.CONNECT', res);
// 发布全局事件,有新消息,刷新会话列表
uni.$emit('onReceiveMessage')
}) })
}) })
} }
@@ -62,13 +67,12 @@ const connect = (token, userInfo, callback) => {
// 设置未读消息数量 // 设置未读消息数量
setNotifyBadge() setNotifyBadge()
// 首次运行获取好友列表 // 首次运行获取好友列表
const FK = 'ZHKD_' + userInfo.targetId const FK = 'ZH_CONTACT_' + userInfo.targetId
uni.getStorage({ uni.getStorage({
key: FK, key: FK,
success: () => { success: () => {
const model = uni.model.contactModel contactModel.find((err, results) => {
model.find((err, results) => {
results.map(item => { results.map(item => {
store.dispatch('launchContact', item) store.dispatch('launchContact', item)
}) })

View File

@@ -20,7 +20,30 @@ const onReceiveMessage = (message) => {
} }
}) })
im.setNotifyBadge() im.setNotifyBadge()
// 发布全局事件,有新消息,刷新会话列表
uni.$emit('onReceiveMessage', message) uni.$emit('onReceiveMessage', message)
// 这个是为了更新消息列表页的
uni.$emit('onReceiveMessage_' + message.targetId, message)
}
// 检测联系人信息,不存在的时候,从服务端获取
const checkContactExists = (message) => {
if (!store.getters.contactIsExist(message.targetId)) {
getUserInfo(message.targetId).then(res => {
console.log('targetId', res);
store.dispatch('initContact', res)
}).catch(err => {
console.error('getUserInfo ERR', err)
})
}
if (!store.getters.contactIsExist(message.senderUserId)) {
getUserInfo(message.senderUserId).then(res => {
console.log('senderUserId', message.senderUserId, res);
store.dispatch('initContact', res)
}).catch(err => {
console.error('getUserInfo ERR', err)
})
}
} }
// 允许通知的消息类型,触发更新消息列表操作,提示音 // 允许通知的消息类型,触发更新消息列表操作,提示音
@@ -32,10 +55,7 @@ const notifyMsgTypes = [
IMLib.ObjectName.Location, IMLib.ObjectName.Location,
IMLib.ObjectName.Voice, IMLib.ObjectName.Voice,
IMLib.ObjectName.HQVoice, IMLib.ObjectName.HQVoice,
IMLib.ObjectName.Sight, IMLib.ObjectName.Sight
IMLib.ObjectName.Text,
IMLib.ObjectName.Text,
IMLib.ObjectName.Text
] ]
const imLibListeners = () => { const imLibListeners = () => {
@@ -48,40 +68,56 @@ const imLibListeners = () => {
IMLib.addReceiveMessageListener((res) => { IMLib.addReceiveMessageListener((res) => {
const message = res.data.message const message = res.data.message
console.error('[收到消息]', message) console.error('[收到消息]', message)
checkContactExists(message)
if (utils.inArray(message.objectName, notifyMsgTypes)) { if (utils.inArray(message.objectName, notifyMsgTypes)) {
if (!store.getters.contactIsExist(message.targetId)) {
getUserInfo(message.targetId).then(res => {
store.dispatch('initContact', res)
}).catch(err => {
console.error('getUserInfo ERR', err)
})
}
if (!store.getters.contactIsExist(message.senderUserId)) {
getUserInfo(message.senderUserId).then(res => {
store.dispatch('initContact', res)
}).catch(err => {
console.error('getUserInfo ERR', err)
})
}
onReceiveMessage(message) onReceiveMessage(message)
} else if (message.objectName === IMLib.ObjectName.ProfileNotification) { } else if (message.objectName === IMLib.ObjectName.ProfileNotification) {
// 更新会话信息 uni.$emit('onUpdateProfile_' + message.targetId)
// 更新联系人信息
store.dispatch('updateContact', JSON.parse(message.content.data)) store.dispatch('updateContact', JSON.parse(message.content.data))
// 调用完更新之后,删除这条消息 // 调用完更新之后,删除这条消息
IMLib.deleteMessagesByIds([message.messageId]) IMLib.deleteMessagesByIds([message.messageId])
} else if (message.objectName === IMLib.ObjectName.ContactNotification) { } else if (message.objectName === IMLib.ObjectName.ContactNotification) {
console.error('触发一个新好友的通知事件', message); if (message.content.operation === 'Request') {
// 触发一个新好友的通知事件 // 触发一个新好友的通知事件,【会话列表,通讯录,新朋友】页面
uni.$emit('onContactNotification', message) uni.$emit('onNewContactConversation', message)
uni.$emit('onNewContactFriends', message)
uni.$emit('onNewContactPendings', message)
} else if (message.content.operation === 'Delete') {
IMLib.cleanHistoryMessages(1, message.targetId, message.sentTime, false)
// 解散了就删了吧
IMLib.removeConversation(1, message.targetId)
// 刷新会话列表
uni.$emit('onUserDelete_' + message.targetId)
uni.$emit('onReceiveMessage', message)
}
} else if (message.objectName === IMLib.ObjectName.GroupNotification) { } else if (message.objectName === IMLib.ObjectName.GroupNotification) {
// 这个是为了更新消息列表页的
uni.$emit('onReceiveMessage_' + message.targetId, message)
// 解散群 // 解散群
if (message.content.operation === 'Dismiss') { if (message.content.operation === 'Dismiss') {
IMLib.cleanHistoryMessages(message.conversationType, message.targetId, message.sentTime, IMLib.cleanHistoryMessages(3, message.targetId, message.sentTime,
false) false)
// 解散了就删了吧 // 解散了就删了吧
IMLib.removeConversation(message.conversationType, message.targetId) IMLib.removeConversation(3, message.targetId)
uni.$emit('onGroupDismiss', message.targetId) // 发布群解散的消息
uni.$emit('onGroupDismiss')
uni.$emit('onGroupDismiss_' + message.targetId)
} else if (message.content.operation === 'REMOVE') {
// 要判断是否当前用户,然后把当前用户踢出到主页去, 删除聊天记录,会话列表
if (message.content.extra == store.getters.sender.userId) {
IMLib.cleanHistoryMessages(3, message.targetId, message.sentTime,
false)
// 解散了就删了吧
IMLib.removeConversation(3, message.targetId)
// 为了更新群列表
uni.$emit('onGroupDismiss')
uni.$emit('onGroupRemoveYou_' + message.targetId)
} }
uni.$emit('onReceiveMessage_' + message.targetId, message)
// 这个是为了更新消息列表页的
}
// 触发刷新会话列表
uni.$emit('onReceiveMessage', message) uni.$emit('onReceiveMessage', message)
} }
}) })
@@ -93,10 +129,16 @@ const imLibListeners = () => {
uni.$emit('onReadReceiptReceived', data) uni.$emit('onReadReceiptReceived', data)
}) })
// 监听消息撤回操作 // 监听消息撤回操作
IMLib.addRecallMessageListener((res) => { IMLib.addRecallMessageListener(({
IMLib.getMessage(res.data.messageId, (res) => { data
console.error("消息撤回: ", res.message); }) => {
uni.$emit('onRecallMessage', res.message) IMLib.getMessage(data.messageId, ({
message
}) => {
console.error("消息撤回: ", message);
im.setNotifyBadge()
uni.$emit('onReceiveMessage', message)
uni.$emit('onRecallMessage_' + message.targetId, message)
}) })
}) })
// 监听需要群聊消息回执 // 监听需要群聊消息回执

View File

@@ -127,7 +127,7 @@ const sentVoice = (conversationType, targetId, voiceUrl, time, user, callback) =
content: { content: {
objectName: 'RC:HQVCMsg', objectName: 'RC:HQVCMsg',
local: 'file:///' + plus.io.convertLocalFileSystemURL(voiceUrl), local: 'file:///' + plus.io.convertLocalFileSystemURL(voiceUrl),
duration: time, duration: time == 0 ? 1 : time,
userInfo: user userInfo: user
} }
} }

View File

@@ -9,14 +9,19 @@ const contactModel = usqlite.model('contacts', {
unique: true unique: true
}, },
name: String, name: String,
remark: String,
hash: { hash: {
type: String, type: String,
unique: true unique: true
}, },
type: {
type: Number,
default: 0
},
portraitUrl: String, portraitUrl: String,
localAvatar: String localAvatar: String
}) })
export default { export {
contactModel contactModel
} }