Merge branch 'master' of https://git.yuzhankeji.cn/TmOct5/ZhHealth
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="members">
|
<view class="member--list">
|
||||||
<view class="users">
|
<view class="users">
|
||||||
<view :class="['user', {'active': item.targetId == currentUser.targetId}]" @longpress="showAction(item)"
|
<view :class="['user', {'active': item.targetId == currentUser.targetId}]" @longpress="showAction(item)"
|
||||||
v-for="(item, index) in users" :key="index" @click="toUser(item)">
|
v-for="(item, index) in users" :key="index" @click="toUser(item)">
|
||||||
<u-avatar size="44" shape="square" :src="item.portraitUrl"></u-avatar>
|
<u-avatar :size="avatarSize" shape="square" :src="contact(item.targetId).portraitUrl"></u-avatar>
|
||||||
<view class="name">{{ item.name }}</view>
|
<view class="name">{{ item.name }}</view>
|
||||||
<view class="admin" v-if="item.is_admin">管理</view>
|
<view class="admin" v-if="item.is_admin">管理</view>
|
||||||
<view class="owner" v-if="item.targetId === adminUid">群主</view>
|
<view class="owner" v-if="item.targetId === adminUid">群主</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="user" v-if="isAdmin">
|
<view class="user" v-if="isAdmin">
|
||||||
<u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee" color="#999999">
|
<u-avatar @click="inviteUser" shape="square" icon="plus" bg-color="#eeeeee" color="#999999">
|
||||||
</u-avatar>
|
</u-avatar>
|
||||||
<view class="name">邀请好友</view>
|
<view class="name">邀请好友</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -55,9 +55,21 @@
|
|||||||
actionShow: false,
|
actionShow: false,
|
||||||
actionMap: [],
|
actionMap: [],
|
||||||
actionTitle: '',
|
actionTitle: '',
|
||||||
currentUser: {}
|
currentUser: {},
|
||||||
|
avatarSize: 40
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
contact() {
|
||||||
|
return function(targetId) {
|
||||||
|
return this.$store.getters.contactInfo(targetId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.avatarSize = 126 / 750 * wx.getSystemInfoSync().windowWidth
|
||||||
|
console.log(this.avatarSize)
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initGroupInfo()
|
this.initGroupInfo()
|
||||||
this.initUsers()
|
this.initUsers()
|
||||||
@@ -79,8 +91,6 @@
|
|||||||
},
|
},
|
||||||
hideAction(item) {
|
hideAction(item) {
|
||||||
this.actionShow = false
|
this.actionShow = false
|
||||||
this.actionTitle = ''
|
|
||||||
this.currentUser = {}
|
|
||||||
},
|
},
|
||||||
showAction(item) {
|
showAction(item) {
|
||||||
this.currentUser = item
|
this.currentUser = item
|
||||||
@@ -180,6 +190,7 @@
|
|||||||
content: '这个操作不可逆转,确定要转让群主身份么?',
|
content: '这个操作不可逆转,确定要转让群主身份么?',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
|
console.log(this.targetId, this.currentUser.targetId);
|
||||||
transferGroupOwner(this.targetId, this.currentUser.targetId).then(
|
transferGroupOwner(this.targetId, this.currentUser.targetId).then(
|
||||||
res => {
|
res => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -228,8 +239,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.members {
|
|
||||||
|
|
||||||
.users {
|
.users {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@@ -296,5 +305,4 @@
|
|||||||
color: $text-gray-m;
|
color: $text-gray-m;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
sender() {
|
||||||
return this.$store.getters.sender
|
return this.$store.getters.sender
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -87,8 +87,7 @@
|
|||||||
sourceType: ['album'],
|
sourceType: ['album'],
|
||||||
success: res => {
|
success: res => {
|
||||||
im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0],
|
im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0],
|
||||||
this.user, (
|
this.sender, (res) => {
|
||||||
res) => {
|
|
||||||
this.success()
|
this.success()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -99,8 +98,7 @@
|
|||||||
sourceType: ['camera'],
|
sourceType: ['camera'],
|
||||||
success: res => {
|
success: res => {
|
||||||
im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0],
|
im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0],
|
||||||
this.user, (
|
this.sender, (res) => {
|
||||||
res) => {
|
|
||||||
this.success()
|
this.success()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
disabled() {
|
disabled() {
|
||||||
return this.inputTxt.length === 0
|
return this.inputTxt.length === 0
|
||||||
},
|
},
|
||||||
user() {
|
sender() {
|
||||||
return this.$store.getters.sender
|
return this.$store.getters.sender
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
sent() {
|
sent() {
|
||||||
if (!this.disabled) {
|
if (!this.disabled) {
|
||||||
RongIMLib.clearTextMessageDraft(this.conversationType, this.targetId)
|
RongIMLib.clearTextMessageDraft(this.conversationType, this.targetId)
|
||||||
im.sentText(this.conversationType, this.targetId, this.inputTxt, this.user, () => {
|
im.sentText(this.conversationType, this.targetId, this.inputTxt, this.sender, () => {
|
||||||
this.$emit('success')
|
this.$emit('success')
|
||||||
this.inputTxt = ''
|
this.inputTxt = ''
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user() {
|
sender() {
|
||||||
return this.$store.getters.sender
|
return this.$store.getters.sender
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -85,8 +85,7 @@
|
|||||||
// 监听录音结束
|
// 监听录音结束
|
||||||
this.recorderManager.onStop(res => {
|
this.recorderManager.onStop(res => {
|
||||||
im.sentVoice(this.conversationType, this.targetId, res.tempFilePath, (this.maxRecordTime -
|
im.sentVoice(this.conversationType, this.targetId, res.tempFilePath, (this.maxRecordTime -
|
||||||
this
|
this.recordTime), this.sender, () => {
|
||||||
.recordTime), this.user, () => {
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$emit('success')
|
this.$emit('success')
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|||||||
@@ -56,13 +56,7 @@
|
|||||||
onLoad() {
|
onLoad() {
|
||||||
this.getFriendList()
|
this.getFriendList()
|
||||||
this.checkNewFriendPending()
|
this.checkNewFriendPending()
|
||||||
uni.$on('onContactNotification', () => {
|
uni.$on('onContactNotification', this.checkNewFriendPending)
|
||||||
this.checkNewFriendPending()
|
|
||||||
this.getFriendList()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
onUnload() {
|
|
||||||
uni.$off('onContactNotification')
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getFriendList() {
|
getFriendList() {
|
||||||
|
|||||||
@@ -29,9 +29,6 @@
|
|||||||
this.getPendingList()
|
this.getPendingList()
|
||||||
uni.$on('onContactNotification', this.getPendingList)
|
uni.$on('onContactNotification', this.getPendingList)
|
||||||
},
|
},
|
||||||
onUnload() {
|
|
||||||
uni.$off('onContactNotification')
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
getPendingList() {
|
getPendingList() {
|
||||||
im.getPendingList((pendings) => {
|
im.getPendingList((pendings) => {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
||||||
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
|
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
|
||||||
:src="contact(item.senderUserId).portraitUrl" />
|
:src="contact(item.senderUserId).portraitUrl" />
|
||||||
<!-- item.content.userInfo.portraitUrl -->
|
|
||||||
<view class="msg">
|
<view class="msg">
|
||||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
||||||
:msg="item.content" :name="contact(item.senderUserId).name" />
|
:msg="item.content" :name="contact(item.senderUserId).name" />
|
||||||
@@ -54,7 +53,7 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
latestMessage() {
|
latestMessage() {
|
||||||
if (this.messages.length > 1) {
|
if (this.messages.length) {
|
||||||
return this.messages[this.messages.length - 1]
|
return this.messages[this.messages.length - 1]
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
<u-cell-group class="cells" v-if="group.is_admin">
|
<u-cell-group class="cells" v-if="group.is_admin">
|
||||||
<u-cell isLink title="修改群聊名称" :value="groupName" @click="onGroupName"></u-cell>
|
<u-cell isLink title="修改群聊名称" :value="groupName" @click="onGroupName"></u-cell>
|
||||||
<u-cell isLink title="修改群头像">
|
<u-cell isLink title="修改群头像" @click="onGroupAvatar">
|
||||||
<u-avatar slot="value" size="25" shape="square" @click="onGroupAvatar" :src="group.cover"></u-avatar>
|
<u-avatar slot="value" size="25" shape="square" :src="group.cover"></u-avatar>
|
||||||
</u-cell>
|
</u-cell>
|
||||||
<u-cell isLink v-if="group.is_owner" title="准入方式" :value="joinType" @click="onChangeJoinType"></u-cell>
|
<u-cell isLink v-if="group.is_owner" title="准入方式" :value="joinType" @click="onChangeJoinType"></u-cell>
|
||||||
</u-cell-group>
|
</u-cell-group>
|
||||||
|
|||||||
@@ -54,15 +54,19 @@
|
|||||||
onLoad() {
|
onLoad() {
|
||||||
// 好友申请数量
|
// 好友申请数量
|
||||||
this.checkNewFriendPending()
|
this.checkNewFriendPending()
|
||||||
uni.$on('onConnectionStatusChange', (status) => {
|
// 监听新的好友申请
|
||||||
this.connection = status
|
uni.$on('onContactNotification', () => {
|
||||||
|
console.log('监听申请');
|
||||||
|
this.checkNewFriendPending()
|
||||||
})
|
})
|
||||||
uni.$on('onContactNotification', this.checkNewFriendPending)
|
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
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()
|
||||||
@@ -73,7 +77,9 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
checkNewFriendPending() {
|
checkNewFriendPending() {
|
||||||
|
console.log('触发新申请好友事件');
|
||||||
im.getPendingList((pendings) => {
|
im.getPendingList((pendings) => {
|
||||||
|
console.log(pendings);
|
||||||
this.hasNewFriends = pendings.length
|
this.hasNewFriends = pendings.length
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
||||||
<u-avatar class="avatar" size="36" shape="square" @click="showUser(targetId, item.messageDirection)"
|
<u-avatar class="avatar" size="36" shape="square" @click="showUser(targetId, item.messageDirection)"
|
||||||
:src="userInfo.portraitUrl" />
|
:src="contact(item.senderUserId).portraitUrl" />
|
||||||
<view class="msg">
|
<view class="msg">
|
||||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
||||||
:msg="item.content" />
|
:msg="item.content" />
|
||||||
@@ -62,13 +62,18 @@
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
latestMessage() {
|
latestMessage() {
|
||||||
if (this.messages.length > 1) {
|
if (this.messages.length) {
|
||||||
return this.messages[this.messages.length - 1]
|
return this.messages[this.messages.length - 1]
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
sentTime: 0
|
sentTime: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
contact() {
|
||||||
|
return function(targetId) {
|
||||||
|
return this.$store.getters.contactInfo(targetId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
@@ -113,6 +118,7 @@
|
|||||||
1,
|
1,
|
||||||
false,
|
false,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
|
console.log(messages);
|
||||||
this.messages = this.messages.concat(messages)
|
this.messages = this.messages.concat(messages)
|
||||||
this.scrollBottom()
|
this.scrollBottom()
|
||||||
})
|
})
|
||||||
@@ -126,6 +132,7 @@
|
|||||||
100,
|
100,
|
||||||
true,
|
true,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
|
console.log(messages);
|
||||||
this.messages = messages.reverse()
|
this.messages = messages.reverse()
|
||||||
this.scrollBottom()
|
this.scrollBottom()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -109,8 +109,7 @@ class userAuth {
|
|||||||
.access_token)
|
.access_token)
|
||||||
// 在这里,登录成功,链接IM服务
|
// 在这里,登录成功,链接IM服务
|
||||||
getImToken().then(res => {
|
getImToken().then(res => {
|
||||||
console.log('在这获取IM-TOKEN', res);
|
im.connect(res.token, res.userInfo, () => {})
|
||||||
im.connect(res.token, res.userInfo)
|
|
||||||
})
|
})
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
hash: '',
|
hash: '',
|
||||||
portraitUrl: ''
|
portraitUrl: require('@/static/user/cover.png')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -68,7 +68,6 @@ export default {
|
|||||||
// 没有数据,直接新增一条
|
// 没有数据,直接新增一条
|
||||||
dispatch('initContact', contactInfo)
|
dispatch('initContact', contactInfo)
|
||||||
} else if (contactInfo.hash != result[0].hash) {
|
} else if (contactInfo.hash != result[0].hash) {
|
||||||
commit('updateContactInfo', contactInfo)
|
|
||||||
if (contactInfo.portraitUrl && contactInfo.portraitUrl != result[0].portraitUrl) {
|
if (contactInfo.portraitUrl && contactInfo.portraitUrl != result[0].portraitUrl) {
|
||||||
saveAvatar(contactInfo, (savedFilePath) => {
|
saveAvatar(contactInfo, (savedFilePath) => {
|
||||||
const info = {
|
const info = {
|
||||||
@@ -80,7 +79,7 @@ export default {
|
|||||||
}
|
}
|
||||||
model.update('targetId="' + contactInfo.targetId + '"', info, (err,
|
model.update('targetId="' + contactInfo.targetId + '"', info, (err,
|
||||||
res) => {
|
res) => {
|
||||||
console.log('UPDATE AVATAR, ERR', err);
|
console.log('UPDATE AVATAR, ERR', err, info);
|
||||||
})
|
})
|
||||||
commit('updateContactInfo', info)
|
commit('updateContactInfo', info)
|
||||||
})
|
})
|
||||||
@@ -93,8 +92,9 @@ export default {
|
|||||||
localAvatar: result[0].localAvatar
|
localAvatar: result[0].localAvatar
|
||||||
}
|
}
|
||||||
model.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => {
|
model.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => {
|
||||||
console.log('UPDATE NAME, ERR', err);
|
console.log('UPDATE NAME, ERR', err, info);
|
||||||
})
|
})
|
||||||
|
commit('updateContactInfo', info)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('updateContact, 无操作');
|
console.log('updateContact, 无操作');
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ const addListeners = () => {
|
|||||||
}
|
}
|
||||||
newMessage(message)
|
newMessage(message)
|
||||||
} else if (message.objectName === RongIMLib.ObjectName.ProfileNotification) {
|
} else if (message.objectName === RongIMLib.ObjectName.ProfileNotification) {
|
||||||
|
// 更新会话信息
|
||||||
store.dispatch('updateContact', JSON.parse(message.content.data))
|
store.dispatch('updateContact', JSON.parse(message.content.data))
|
||||||
// 调用完更新之后,删除这条消息
|
// 调用完更新之后,删除这条消息
|
||||||
RongIMLib.deleteMessagesByIds([message.messageId], ({
|
RongIMLib.deleteMessagesByIds([message.messageId], ({
|
||||||
@@ -159,6 +160,7 @@ const addListeners = () => {
|
|||||||
console.log('消息删除结果', code)
|
console.log('消息删除结果', code)
|
||||||
})
|
})
|
||||||
} else if (message.objectName === RongIMLib.ObjectName.ContactNotification) {
|
} else if (message.objectName === RongIMLib.ObjectName.ContactNotification) {
|
||||||
|
console.log('onContactNotification');
|
||||||
// 触发一个新好友的通知事件
|
// 触发一个新好友的通知事件
|
||||||
uni.$emit('onContactNotification', message.content)
|
uni.$emit('onContactNotification', message.content)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,14 +151,15 @@ const sentImage = (conversationType, targetId, imageUrl, user, callback) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const sentGif = (conversationType, targetId, gifUrl, time, callback) => {
|
const sentGif = (conversationType, targetId, gifUrl, time, user, callback) => {
|
||||||
const msg = {
|
const msg = {
|
||||||
conversationType: conversationType,
|
conversationType: conversationType,
|
||||||
targetId: String(targetId),
|
targetId: String(targetId),
|
||||||
content: {
|
content: {
|
||||||
objectName: 'RC:GIFMsg',
|
objectName: 'RC:GIFMsg',
|
||||||
local: 'file:///' + plus.io.convertLocalFileSystemURL(gifUrl),
|
local: 'file:///' + plus.io.convertLocalFileSystemURL(gifUrl),
|
||||||
duration: time
|
duration: time,
|
||||||
|
userInfo: user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RongIMLib.sendMediaMessage(msg, {
|
RongIMLib.sendMediaMessage(msg, {
|
||||||
@@ -177,14 +178,15 @@ const sentGif = (conversationType, targetId, gifUrl, time, callback) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendFile = (conversationType, targetId, fileUrl, time, callback) => {
|
const sendFile = (conversationType, targetId, fileUrl, time, user, callback) => {
|
||||||
const msg = {
|
const msg = {
|
||||||
conversationType: conversationType,
|
conversationType: conversationType,
|
||||||
targetId: String(targetId),
|
targetId: String(targetId),
|
||||||
content: {
|
content: {
|
||||||
objectName: 'RC:FileMsg',
|
objectName: 'RC:FileMsg',
|
||||||
local: 'file:///' + plus.io.convertLocalFileSystemURL(fileUrl),
|
local: 'file:///' + plus.io.convertLocalFileSystemURL(fileUrl),
|
||||||
duration: time
|
duration: time,
|
||||||
|
userInfo: user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RongIMLib.sendMediaMessage(msg, {
|
RongIMLib.sendMediaMessage(msg, {
|
||||||
|
|||||||
Reference in New Issue
Block a user