|
@@ -1,29 +1,65 @@
|
|
|
<script lang="ts">
|
|
|
import { ref, defineComponent, onMounted } from 'vue';
|
|
|
import QRCode from 'qrcodejs2-fixes';
|
|
|
+import * as ww from '@wecom/jssdk'
|
|
|
+import { WeComLogin } from '../api'
|
|
|
|
|
|
-export default defineComponent({
|
|
|
- name: 'loginScan',
|
|
|
- setup() {
|
|
|
- const qrcodeRef = ref<HTMLElement | null>(null);
|
|
|
- // 初始化生成二维码
|
|
|
- const initQrcode = () => {
|
|
|
- (qrcodeRef.value as HTMLElement).innerHTML = '';
|
|
|
- new QRCode(qrcodeRef.value, {
|
|
|
- text: `https://jq.qq.com/?_wv=1027&k=hUu2GeU1`,
|
|
|
- width: 260,
|
|
|
- height: 260,
|
|
|
- colorDark: '#000000',
|
|
|
- colorLight: '#ffffff',
|
|
|
- });
|
|
|
- };
|
|
|
- // 页面加载时
|
|
|
- onMounted(() => {
|
|
|
- initQrcode();
|
|
|
- });
|
|
|
- return { qrcodeRef };
|
|
|
- },
|
|
|
-});
|
|
|
+function createWXQRCode() {
|
|
|
+ ww.createWWLoginPanel({
|
|
|
+ el: '#wx_qrcode',
|
|
|
+ params: {
|
|
|
+ login_type: 'CorpApp',
|
|
|
+ appid: 'ww467ec1685e8262e6',
|
|
|
+ agentid: '1000065',
|
|
|
+ redirect_uri: 'http://amzads.zositechc.cn/web/',
|
|
|
+ state: 'Wechat',
|
|
|
+ scope: 'snsapi_privateinfo',
|
|
|
+ redirect_type: 'callback',
|
|
|
+ },
|
|
|
+ onCheckWeComLogin({ isWeComLogin }) {
|
|
|
+ console.log(isWeComLogin)
|
|
|
+ },
|
|
|
+ onLoginSuccess({ code }) {
|
|
|
+ // console.log({ code })
|
|
|
+ handleWeComLogin({ code: code, state: 'Wechat' })
|
|
|
+ },
|
|
|
+ onLoginFail(err) {
|
|
|
+ console.log(err)
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+async function handleWeComLogin(query) {
|
|
|
+ try {
|
|
|
+ const res = await WeComLogin(query)
|
|
|
+ console.log('res', res)
|
|
|
+ } catch (error) {
|
|
|
+ console.log('error:', error)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// export default defineComponent({
|
|
|
+// name: 'loginScan',
|
|
|
+// setup() {
|
|
|
+// const qrcodeRef = ref<HTMLElement | null>(null);
|
|
|
+// // 初始化生成二维码
|
|
|
+// const initQrcode = () => {
|
|
|
+// (qrcodeRef.value as HTMLElement).innerHTML = '';
|
|
|
+// new QRCode(qrcodeRef.value, {
|
|
|
+// text: `https://jq.qq.com/?_wv=1027&k=hUu2GeU1`,
|
|
|
+// width: 260,
|
|
|
+// height: 260,
|
|
|
+// colorDark: '#000000',
|
|
|
+// colorLight: '#ffffff',
|
|
|
+// });
|
|
|
+// };
|
|
|
+// // 页面加载时
|
|
|
+// onMounted(() => {
|
|
|
+// initQrcode();
|
|
|
+// });
|
|
|
+// return { qrcodeRef };
|
|
|
+// },
|
|
|
+// });
|
|
|
</script>
|
|
|
|
|
|
<template>
|