Files
dvcp_v2_wxcp_app/src/apps/AppOpenChat/AppOpenChat.vue
2022-11-22 10:29:49 +08:00

75 lines
1.9 KiB
Vue

<template>
<section class="AppOpenChat">
<AiLoading tips="正在处理..."/>
<AiConsole show/>
</section>
</template>
<script>
import {mapActions, mapState} from "vuex"
export default {
name: "AppOpenChat",
appName: "创建群聊",
computed: {
...mapState(['user'])
},
data() {
return {
users: {}
}
},
methods: {
...mapActions(['injectJWeixin']),
getUsers() {
return Promise.all([
// this.$http.post("/app/wxcp/wxuser/list", null, {params: {listType: 0}}).then(res => {
// if (res?.data) {
// return this.users.userIds = res.data.records?.map(e => e.id).join(";")
// }
// }),
this.$http.post("/app/wxcp/wxcustomer/list", null, {
params: {
wxUserId: this.user.wxUserId
}
}).then(res => {
if (res?.data) {
return this.users.externalUserIds = res.data.records?.filter(e => e.type == 1)?.map(e => e.id).join(";")
}
}),
])
},
handleCreateSuccess() {
const {groupName} = this.$route.query
wx.openEnterpriseChat({
externalUserIds: "wmGBFVDgAAj_krfwaThRm-RRAq9rBeaQ",
groupName,
...this.users,
success: res => {
if (res?.chatId) {
this.handleCreateQrCode(res.chatId)
}
}
})
},
handleCreateQrCode(groupId) {
const {activityType, activityId, groupName} = this.$route.query
this.$http.post("/wxcp/wxgroup/createGroupQrCode", null, {
params: {
groupId, activityType, activityId, groupName
}
})
}
},
created() {
this.injectJWeixin("openEnterpriseChat").then(() => this.$confirm("确定创建省志愿者活动专用群聊?"))
.then(this.getUsers).then(this.handleCreateSuccess).catch(() => 0)
}
}
</script>
<style lang="scss" scoped>
.AppOpenChat {
}
</style>