Files
dvcp_v2_wxcp_app/src/apps/AppOpenChat/AppOpenChat.vue

74 lines
1.9 KiB
Vue
Raw Normal View History

2022-09-29 09:41:02 +08:00
<template>
<section class="AppOpenChat">
<AiLoading tips="正在处理..."/>
2022-09-29 09:41:02 +08:00
</section>
</template>
<script>
import {mapActions, mapState} from "vuex"
2022-09-29 09:41:02 +08:00
export default {
name: "AppOpenChat",
appName: "创建群聊",
computed: {
...mapState(['user'])
},
2022-09-29 09:41:02 +08:00
data() {
return {
users: {}
}
2022-09-29 09:41:02 +08:00
},
methods: {
2022-11-22 19:16:02 +08:00
...mapActions(['injectJWeixin', 'getAccount']),
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(";")
}
}),
])
2022-11-22 10:29:49 +08:00
},
handleCreateSuccess() {
const {groupName} = this.$route.query
2022-09-29 09:41:02 +08:00
wx.openEnterpriseChat({
externalUserIds: "wmGBFVDgAAj_krfwaThRm-RRAq9rBeaQ",
2022-11-22 10:29:49 +08:00
groupName,
...this.users,
2022-11-22 10:29:49 +08:00
success: res => {
if (res?.chatId) {
this.handleCreateQrCode(res.chatId)
}
}
2022-09-29 09:41:02 +08:00
})
2022-11-22 10:29:49 +08:00
},
handleCreateQrCode(groupId) {
const {activityType, activityId, groupName} = this.$route.query
this.$http.post("/api/wxcp/wxgroup/createGroupQrCode", null, {
2022-11-22 10:29:49 +08:00
params: {
groupId, activityType, activityId, groupName
}
})
}
},
created() {
2022-11-22 18:51:33 +08:00
this.injectJWeixin("openEnterpriseChat").then(() => this.$confirm(`确定创建${this.$route.query.groupName}?`))
2022-11-22 19:16:02 +08:00
.then(this.getAccount).then(this.getUsers).then(this.handleCreateSuccess).catch(() => 0)
2022-09-29 09:41:02 +08:00
}
}
</script>
<style lang="scss" scoped>
.AppOpenChat {
}
</style>