/** * Copyright (c) OpenSpug Organization. https://github.com/openspug/spug * Copyright (c) * Released under the AGPL-3.0 License. */ import React, {useEffect, useState} from 'react'; import {observer} from 'mobx-react'; import {Form, Input, Button, Spin, message} from 'antd'; import {Link} from 'components'; import css from './index.module.css'; import {http, clsNames} from 'libs'; import store from './store'; export default observer(function () { const [loading, setLoading] = useState(false); const [fetching, setFetching] = useState(false); const [balance, setBalance] = useState({}); const [pushKey, setPushKey] = useState(store.settings.spug_push_key); useEffect(() => { if (pushKey) { fetchBalance() } }, []); function fetchBalance() { setFetching(true) http.get('/api/setting/push/balance/') .then(res => setBalance(res)) .finally(() => { setLoading(false) setFetching(false) }) } function handleBind() { if (!pushKey) return message.error('请输入要绑定的推送助手用户ID') setLoading(true); http.post('/api/setting/push/bind/', {spug_push_key: pushKey}) .then(res => { message.success('绑定成功'); store.fetchSettings(); setBalance(res) }) .finally(() => setLoading(false)) } function handleUnbind() { setLoading(true); http.post('/api/setting/push/bind/', {spug_push_key: ''}) .then(() => { message.success('解绑成功'); store.fetchSettings(); setBalance({}) setPushKey('') }) .finally(() => setLoading(false)) } const isVip = balance.is_vip const spugPushKey = store.settings.spug_push_key return (
推送服务设置
请登录 ,至个人中心 / 个人设置查看用户ID,注意保密该ID请勿泄漏给第三方。
}> {spugPushKey ? (
{spugPushKey}
) : ( setPushKey(e.target.value)} style={{width: 'calc(100% - 100px)'}} placeholder="请输入要绑定的推送助手用户ID"/> )} {spugPushKey ? ( 如需充值请至 ,具体计费规则及说明请查看推送助手官网。 }>
短信余额
{balance.sms_balance}
语音余额
{balance.voice_balance}
邮件余额
{balance.mail_balance}
{isVip ? (
+ 会员免费20封 / 天
) : (
会员免费20封 / 天
)}
微信公众号余额
{balance.wx_mp_balance}
{isVip ? (
+ 会员免费100条 / 天
) : (
会员免费20封 / 天
)}
) : null}
) })