diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index 9b842cf..62394e7 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -30,6 +30,10 @@ const useAuthStore = create(devtools((set, get) => ({ isPermitted: (perm) => { const { loginUser } = get() + if (perm === PERM_USE_WHATSAPP) { + return ['404', '383', '227'].includes(loginUser.userId) + } + if (perm === PERM_USE_EMAL) { return true//['501', '466', '599', '495', '143', '370', '639', '513', '654', '404', '383', '227'].includes(loginUser.userId) } @@ -79,6 +83,7 @@ const useAuthStore = create(devtools((set, get) => ({ } }), whatsAppBusiness: json.result.whatsappinfo.length > 0 ? json.result.whatsappinfo[0].whatsapp_waba : '', + whatsAppNo: json.result.whatsappinfo.length > 0 ? json.result.whatsappinfo[0].whatsapp_wa : '', accountName: json.result.opicode, username: json.result.nick, avatarUrl: json.result.avatarUrl, diff --git a/src/views/accounts/Profile.jsx b/src/views/accounts/Profile.jsx index 452c144..e33d750 100644 --- a/src/views/accounts/Profile.jsx +++ b/src/views/accounts/Profile.jsx @@ -2,14 +2,19 @@ import { useEffect, useCallback, useState } from 'react' import { Row, Col, Space, Input, Descriptions, Avatar, Tag, Divider, List, App, Button, Flex, Select, Spin, Form, Typography, QRCode, Tooltip } from 'antd' import { UserOutlined, InfoCircleOutlined, ReloadOutlined, CheckCircleFilled } from '@ant-design/icons' import useAuthStore from '@/stores/AuthStore' +import { fetchJSON } from '@/utils/request' +import { Conditional } from '@/components/Conditional' +import { PERM_USE_WHATSAPP } from '@/stores/AuthStore' function Profile() { const { notification } = App.useApp() const [wabaForm] = Form.useForm() - const [loginUser, setWhatsAppBusiness] = useAuthStore((state) => [state.loginUser, state.setWhatsAppBusiness]) + const [loginUser, setWhatsAppBusiness, isPermitted] = useAuthStore((state) => [ + state.loginUser, state.setWhatsAppBusiness, state.isPermitted + ]) - const [text, setText] = useState('') + const [qrCode, setQRCode] = useState('') useEffect(() => { // 测试错误捕获: @@ -36,6 +41,21 @@ function Profile() { }) }, []) + const handelGernaterQR = useCallback(() => { + const phone = loginUser.whatsAppNo + + fetchJSON( + 'http://localhost:3031/api/v1/whatsapp/channels/qrcode', + { phone }) + .then(r => { + console.info(r) + setQRCode(r.result.qr) + }) + .catch(ex => { + console.error(ex) + }) + }, []) + const customStatusRender = (info) => { switch (info.status) { case 'expired': @@ -107,7 +127,7 @@ function Profile() { 商业号身份 }> -