修改群信息
This commit is contained in:
@@ -27,9 +27,9 @@
|
|||||||
</u-cell-group>
|
</u-cell-group>
|
||||||
|
|
||||||
<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="group.name" @click="onGroupName"></u-cell>
|
<u-cell isLink title="修改群聊名称" :value="groupName" @click="onGroupName"></u-cell>
|
||||||
<u-cell isLink title="修改群头像">
|
<u-cell isLink title="修改群头像">
|
||||||
<u-avatar slot="value" size="24" shape="square" :src="group.cover"></u-avatar>
|
<u-avatar slot="value" size="24" shape="square" @click="onGroupAvatar" :src="group.cover"></u-avatar>
|
||||||
</u-cell>
|
</u-cell>
|
||||||
</u-cell-group>
|
</u-cell-group>
|
||||||
|
|
||||||
@@ -39,13 +39,22 @@
|
|||||||
<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 :show="modalShow" title="修改群名称" showCancelButton @cancel="onHideModal" @confirm="onChangeGroupName">
|
||||||
|
<view class="slot-content">
|
||||||
|
<u--input placeholder="群名称" border="surround" v-model="groupName"></u--input>
|
||||||
|
</view>
|
||||||
|
</u-modal>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
getGroupInfo
|
getGroupInfo,
|
||||||
|
updateGroup
|
||||||
} from '@/apis/interfaces/im.js'
|
} from '@/apis/interfaces/im.js'
|
||||||
|
import {
|
||||||
|
uploads
|
||||||
|
} 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'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -58,7 +67,9 @@
|
|||||||
members: [],
|
members: [],
|
||||||
status: false,
|
status: false,
|
||||||
isTop: false,
|
isTop: false,
|
||||||
loaded: false
|
loaded: false,
|
||||||
|
modalShow: false,
|
||||||
|
groupName: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
@@ -75,7 +86,7 @@
|
|||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
this.isTop = conversation.isTop
|
this.isTop = conversation.isTop
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.initData()
|
this.initData()
|
||||||
uni.$on('groupAnnouncementCreated', this.initData)
|
uni.$on('groupAnnouncementCreated', this.initData)
|
||||||
},
|
},
|
||||||
@@ -86,6 +97,7 @@
|
|||||||
initData() {
|
initData() {
|
||||||
getGroupInfo(this.targetId).then(res => {
|
getGroupInfo(this.targetId).then(res => {
|
||||||
this.group = res.group
|
this.group = res.group
|
||||||
|
this.groupName = res.group.name
|
||||||
this.announcement = res.announcement
|
this.announcement = res.announcement
|
||||||
this.members = res.members
|
this.members = res.members
|
||||||
this.loaded = true
|
this.loaded = true
|
||||||
@@ -127,7 +139,22 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onGroupName() {
|
onGroupName() {
|
||||||
|
this.modalShow = true
|
||||||
|
},
|
||||||
|
onChangeGroupName() {
|
||||||
|
updateGroup(this.targetId, {
|
||||||
|
name: this.groupName
|
||||||
|
}).then(res => {
|
||||||
|
this.modalShow = false
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '群名称修改成功'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onHideModal() {
|
||||||
|
this.modalShow = false
|
||||||
|
this.groupName = this.group.name
|
||||||
},
|
},
|
||||||
onClean() {
|
onClean() {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
@@ -157,6 +184,46 @@
|
|||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '开发中'
|
title: '开发中'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
// 修改群头像
|
||||||
|
onGroupAvatar() {
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sizeType: ['original'],
|
||||||
|
sourceType: ['album'],
|
||||||
|
crop: {
|
||||||
|
quality: 100,
|
||||||
|
width: 128,
|
||||||
|
height: 128,
|
||||||
|
resize: true
|
||||||
|
},
|
||||||
|
success: res => {
|
||||||
|
console.log(res);
|
||||||
|
let path = res.tempFiles.map((val, index) => {
|
||||||
|
return {
|
||||||
|
name: 'uploads' + index,
|
||||||
|
uri: val.path
|
||||||
|
}
|
||||||
|
})
|
||||||
|
uploads(path).then(path => {
|
||||||
|
updateGroup(this.targetId, {
|
||||||
|
cover: path.path[0]
|
||||||
|
}).then(res => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '群头像修改成功'
|
||||||
|
})
|
||||||
|
this.modalShow = false
|
||||||
|
this.group.cover = path.url[0]
|
||||||
|
})
|
||||||
|
}).catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
title: err.message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ export default {
|
|||||||
contactInfo: (state) => (targetId) => {
|
contactInfo: (state) => (targetId) => {
|
||||||
if (state.contacts[targetId]) {
|
if (state.contacts[targetId]) {
|
||||||
const info = state.contacts[targetId]
|
const info = state.contacts[targetId]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: info.name,
|
name: info.name,
|
||||||
hash: info.hash,
|
hash: info.hash,
|
||||||
@@ -79,7 +78,10 @@ export default {
|
|||||||
portraitUrl: contactInfo.portraitUrl,
|
portraitUrl: contactInfo.portraitUrl,
|
||||||
localAvatar: savedFilePath
|
localAvatar: savedFilePath
|
||||||
}
|
}
|
||||||
model.update('targetId=' + contactInfo.targetId, info, (err, res) => {})
|
model.update('targetId="' + contactInfo.targetId + '"', info, (err,
|
||||||
|
res) => {
|
||||||
|
console.log('UPDATE AVATAR, ERR', err);
|
||||||
|
})
|
||||||
commit('updateContactInfo', info)
|
commit('updateContactInfo', info)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -90,9 +92,13 @@ export default {
|
|||||||
portraitUrl: contactInfo.portraitUrl,
|
portraitUrl: contactInfo.portraitUrl,
|
||||||
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);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {}
|
} else {
|
||||||
|
console.log('updateContact, 无操作');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 初始化好友信息
|
// 初始化好友信息
|
||||||
|
|||||||
Reference in New Issue
Block a user