省志愿者demo根据用户自己抓取外部联系人和用户

This commit is contained in:
aixianling
2022-09-29 10:39:41 +08:00
parent bd30cacaca
commit aeef2bb31a

View File

@@ -1,28 +1,53 @@
<template> <template>
<section class="AppOpenChat"> <section class="AppOpenChat">
<AiLoading tips="正在处理..."/>
</section> </section>
</template> </template>
<script> <script>
import {mapActions} from "vuex" import {mapActions, mapState} from "vuex"
export default { export default {
name: "AppOpenChat", name: "AppOpenChat",
appName: "创建群聊", appName: "创建群聊",
computed: {
...mapState(['user'])
},
data() { data() {
return {} return {
users: {}
}
}, },
methods: { methods: {
...mapActions(['injectJWeixin']), ...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)
}
}),
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?.map(e => e.id)
}
}),
])
}
}, },
created() { created() {
this.injectJWeixin("openEnterpriseChat").then(() => this.$confirm("确定创建省志愿者活动专用群聊?")) this.injectJWeixin("openEnterpriseChat").then(() => this.$confirm("确定创建省志愿者活动专用群聊?"))
.then(() => { .then(this.getUsers).then(() => {
wx.openEnterpriseChat({ wx.openEnterpriseChat({
userIds: "18507227517;AiXianLing", userIds: "18507227517;AiXianLing",
externalUserIds: "wmGBFVDgAAj_krfwaThRm-RRAq9rBeaQ", externalUserIds: "wmGBFVDgAAj_krfwaThRm-RRAq9rBeaQ",
groupName: "省志愿者活动专用群" groupName: "省志愿者活动专用群",
...this.users,
}) })
}).catch(() => 0) }).catch(() => 0)
} }