perf: 增加获取 WA 二维码 Action

dev/supplier-email-drawer
LiaoYijun 9 months ago
parent 7fc40dc8e0
commit 07a78f7dee

@ -13,3 +13,9 @@ export const postSendMsg = async (body) => {
const { result } = await postJSON(`${WAI_HOST}/messages/text`, body);
return result;
};
export const fetchQRCode = (phone) => {
return fetchJSON(
`${WAI_HOST}/channels/qrcode`,
{ phone })
}

@ -6,6 +6,8 @@ import { fetchJSON } from '@/utils/request'
import { Conditional } from '@/components/Conditional'
import { PERM_USE_WHATSAPP } from '@/stores/AuthStore'
import { WAI_HOST } from '@/config'
import { fetchQRCode } from '@/actions/WaiAction'
function Profile() {
const { notification } = App.useApp()
@ -46,10 +48,7 @@ function Profile() {
const handelGernaterQR = useCallback(() => {
const phone = loginUser.whatsAppNo
fetchJSON(
`${WAI_HOST}/channels/qrcode`,
{ phone })
fetchQRCode(phone)
.then(r => {
setQRCode(r.result.qr)
setQRStatus('active')

Loading…
Cancel
Save