|
@@ -0,0 +1,106 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="user-sop-wrap">
|
|
3
|
+ <div class="title-1">群发消息到客户群</div>
|
|
4
|
+ </div>
|
|
5
|
+</template>
|
|
6
|
+
|
|
7
|
+<script lang="ts" setup>
|
|
8
|
+import { ref, reactive, onBeforeMount } from 'vue'
|
|
9
|
+import { Toast } from 'vant';
|
|
10
|
+import { getQueryString, isJSON } from '@/utils/common'
|
|
11
|
+import $axios from '@/utils/axios'
|
|
12
|
+import getWxConfig from '@/utils/getWxConfig';
|
|
13
|
+
|
|
14
|
+interface IRes<T = any> {
|
|
15
|
+ errno: string | number
|
|
16
|
+ rst: T
|
|
17
|
+ [index: string]: any
|
|
18
|
+}
|
|
19
|
+
|
|
20
|
+// 请求参数
|
|
21
|
+const params = reactive({
|
|
22
|
+ corpid: getQueryString('corpid'),
|
|
23
|
+ rule_id: getQueryString('rule_id'),
|
|
24
|
+ user_id: getQueryString('user_id'),
|
|
25
|
+})
|
|
26
|
+
|
|
27
|
+onBeforeMount(() => {//组件挂载之前
|
|
28
|
+ if (getQueryString('againJump')) {
|
|
29
|
+ params.corpid = getQueryString('corpid')
|
|
30
|
+ params.rule_id = getQueryString('rule_id')
|
|
31
|
+ params.user_id = getQueryString('user_id')
|
|
32
|
+ getWxConfig(() => {
|
|
33
|
+ handleGetSendContent()
|
|
34
|
+ });
|
|
35
|
+ } else {//获取用户信息
|
|
36
|
+ getWxConfig('', (authInfo) => {
|
|
37
|
+ let redirect_uri = encodeURIComponent(window.location.href + '&againJump=true')
|
|
38
|
+ let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${authInfo.corpid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=1&agentid=${authInfo.agent_id}#wechat_redirect`;
|
|
39
|
+ let link = document.createElement("a");
|
|
40
|
+ link.href = url;
|
|
41
|
+ document.body.appendChild(link);
|
|
42
|
+ link.click();
|
|
43
|
+ document.body.removeChild(link);
|
|
44
|
+ });
|
|
45
|
+ }
|
|
46
|
+});
|
|
47
|
+
|
|
48
|
+// 获取SOP规则详情
|
|
49
|
+const handleGetSendContent = async () => {
|
|
50
|
+ try {
|
|
51
|
+ Toast.loading({
|
|
52
|
+ message: '加载中...',
|
|
53
|
+ duration: 0,
|
|
54
|
+ forbidClick: true,
|
|
55
|
+ })
|
|
56
|
+ // const { errno, rst } = await $axios.get('/api/h5/userSop/detail', {
|
|
57
|
+ // corpid: params.corpid,
|
|
58
|
+ // rule_id: params.rule_id,
|
|
59
|
+ // }) as IRes
|
|
60
|
+ // if (errno == 0) {
|
|
61
|
+ // console.log('rst => ', rst)
|
|
62
|
+ // }
|
|
63
|
+
|
|
64
|
+ // 发送消息到群聊
|
|
65
|
+ handleShareToExternalChat()
|
|
66
|
+
|
|
67
|
+ } catch (error) {
|
|
68
|
+ console.log('error =>', error)
|
|
69
|
+ } finally {
|
|
70
|
+ Toast.clear();
|
|
71
|
+ }
|
|
72
|
+}
|
|
73
|
+
|
|
74
|
+const handleShareToExternalChat = () => {
|
|
75
|
+ Toast('执行 shareToExternalChat => ')
|
|
76
|
+ setTimeout(() => {
|
|
77
|
+ wx.invoke("shareToExternalChat", {
|
|
78
|
+ text: {
|
|
79
|
+ content: "测试发送消息到客户群",
|
|
80
|
+ },
|
|
81
|
+ attachments: []
|
|
82
|
+ }, function(res) {
|
|
83
|
+ if (res.err_msg == "shareToExternalChat:ok") {
|
|
84
|
+ Toast('发送成功!')
|
|
85
|
+ }
|
|
86
|
+ });
|
|
87
|
+ }, 1000);
|
|
88
|
+}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+</script>
|
|
92
|
+
|
|
93
|
+<style lang="scss" scoped>
|
|
94
|
+.user-sop-wrap {
|
|
95
|
+ box-sizing: border-box;
|
|
96
|
+ min-height: 100vh;
|
|
97
|
+ background-color: #FFF;
|
|
98
|
+ padding: 20px;
|
|
99
|
+ .title-1 {
|
|
100
|
+ margin-top: 20px;
|
|
101
|
+ font-size: 16px;
|
|
102
|
+ font-weight: 600;
|
|
103
|
+ color: #333;
|
|
104
|
+ }
|
|
105
|
+}
|
|
106
|
+</style>
|