Browse Source

feat: 企微助手 - 群活码 - H5相关接口联调

zhengxy 2 years ago
parent
commit
b5a39d6771
2 changed files with 79 additions and 12 deletions
  1. 1 4
      project/src/components/groupCode/index.vue
  2. 78 8
      qwh5/src/views/groupCodeH5.vue

+ 1 - 4
project/src/components/groupCode/index.vue

@@ -129,7 +129,6 @@ export default {
129 129
   methods: {
130 130
     // 获取群活码列表
131 131
     async handleGetCodeList() {
132
-      console.log('handleGetCodeList => ')
133 132
       try {
134 133
         this.loading = true
135 134
         const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.groupCode_ruleList, {
@@ -226,8 +225,7 @@ export default {
226 225
       let corpid = JSON.parse(sessionStorage.getItem('company_session_defaultCorp') || '{}').corpid
227 226
       if (!corpid) corpid = JSON.parse(this.$localSelfStore.getLocal('defaultCorp') || '{}').corpid || ''
228 227
 
229
-      return `http://192.168.1.123:8081/#/groupCodeH5?corpid=${corpid}&ruleid=${rule_id}` // mock
230
-      // return `http://${window.location.host}/playlet/qwh5/dist/index.html#/groupCodeH5?corpid=${corpid}&ruleid=${rule_id}`
228
+      return `http://${window.location.host}/playlet/qwh5/dist/index.html#/groupCodeH5?corpid=${corpid}&ruleid=${rule_id}`
231 229
     },
232 230
     // 生成二维码
233 231
     handleGetQRCode(text) {
@@ -237,7 +235,6 @@ export default {
237 235
         height: 200,
238 236
         text,
239 237
       });
240
-      console.log('qrcode => ', qrcode)
241 238
       return qrcode || ''
242 239
     },
243 240
     // 保存二维码至本地(下载二维码)

+ 78 - 8
qwh5/src/views/groupCodeH5.vue

@@ -6,7 +6,7 @@
6 6
     </div>
7 7
 
8 8
     <div class="group-wrap">
9
-      <img src="https://wework.qpic.cn/wwpic/657529_fEoKPXoSSYaWeBX_1661508588/0" />
9
+      <img v-if="groupQrcode" :src="groupQrcode" />
10 10
     </div>
11 11
 
12 12
     <div class="btm-tips-wrap">
@@ -23,38 +23,108 @@
23 23
     <van-popup v-model:show="isShowPopup" round>
24 24
       <div class="customer-wrap">
25 25
         <div class="title">客服</div>
26
-        <img src="https://open.work.weixin.qq.com/wwopen/userQRCode?vcode=vce41e90ec5a4364eb" />
27
-        <div class="tips">有问题联系客服</div>
26
+        <img :src="customerInfo.qrcode" />
27
+        <div class="tips">{{ customerInfo.leading_words }}</div>
28 28
       </div>
29 29
     </van-popup>
30 30
   </div>
31 31
 </template>
32 32
 
33 33
 <script lang="ts" setup>
34
-import { ref, reactive } from 'vue'
34
+import { ref, reactive, onMounted } from 'vue'
35 35
 import type { Ref } from 'vue'
36
-import { Icon as vanIcon, Popup as vanPopup } from 'vant';
36
+import { Icon as vanIcon, Popup as vanPopup, Toast } from 'vant';
37 37
 import { getQueryString } from '@/utils/common'
38
+import $axios from '@/utils/axios'
38 39
 
39 40
 interface IParams {
40 41
   corpid: string
41 42
   rule_id: string
42 43
 }
43 44
 
45
+interface IRes<T = any> {
46
+  errno: string | number
47
+  rst: T
48
+  [index: string]: any
49
+}
50
+
44 51
 // 请求参数
45 52
 const params = reactive<IParams>({
46 53
   corpid: getQueryString('corpid'),
47 54
   rule_id: getQueryString('ruleid'),
48 55
 })
49 56
 
57
+// 群二维码
58
+const groupQrcode: Ref = ref('')
59
+
60
+// 客服信息
61
+const customerInfo = reactive({
62
+  qrcode: '',
63
+  leading_words: '',
64
+})
65
+
50 66
 // 控制"客服"弹层显示
51 67
 const isShowPopup: Ref = ref(false)
52 68
 
53 69
 // 点击"客服"
54
-const onClickCustomer = () => {
55
-  isShowPopup.value = true
70
+const onClickCustomer = async () => {
71
+  try {
72
+    Toast.loading({
73
+      message: '加载中...',
74
+      duration: 0,
75
+      forbidClick: true,
76
+    })
77
+    const { errno, rst } = await $axios.get('/api/h5/chatGroupQrcode/contactQrcode', {...params}) as IRes
78
+    if (errno == 0) {
79
+      customerInfo.qrcode = rst?.qrcode
80
+      customerInfo.leading_words = rst?.leading_words
81
+      isShowPopup.value = true
82
+    } else {
83
+      customerInfo.qrcode = ''
84
+      customerInfo.leading_words = ''
85
+    }
86
+  } catch (error) {
87
+    console.log('error =>', error)
88
+  } finally {
89
+    Toast.clear();
90
+  }
91
+}
92
+
93
+// 扫码数据上报
94
+const handleFetchScanData = async () => {
95
+  try {
96
+    await $axios.get('/api/h5/chatGroupQrcode/scan', {...params}) as IRes
97
+  } catch (error) {
98
+    console.log('error =>', error)
99
+  }
100
+}
101
+
102
+// 获取群活码
103
+const handleGetGroupQrcode = async () => {
104
+  try {
105
+    Toast.loading({
106
+      message: '加载中...',
107
+      duration: 0,
108
+      forbidClick: true,
109
+    })
110
+    const { errno, rst } = await $axios.get('/api/h5/chatGroupQrcode/detail', {...params}) as IRes
111
+    if (errno == 0) {
112
+      groupQrcode.value = rst?.qrcode
113
+    } else {
114
+      groupQrcode.value = ''
115
+    }
116
+  } catch (error) {
117
+    console.log('error =>', error)
118
+  } finally {
119
+    Toast.clear();
120
+  }
56 121
 }
57 122
 
123
+onMounted(() => {
124
+  handleGetGroupQrcode() // 获取群活码
125
+  handleFetchScanData() // 扫码数据上报
126
+})
127
+
58 128
 </script>
59 129
 
60 130
 <style lang="scss" scoped>
@@ -76,9 +146,9 @@ const onClickCustomer = () => {
76 146
     display: flex;
77 147
     justify-content: center;
78 148
     margin-top: 24px;
149
+    height: 80vw;
79 150
     img {
80 151
       width: 80%;
81
-      height: 80%;
82 152
     }
83 153
   }
84 154
   .btm-tips-wrap {