更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -7,25 +7,15 @@ import (
|
||||
"server/models"
|
||||
)
|
||||
|
||||
// =============================================================
|
||||
// 消息推送(认证后可用):
|
||||
// 未认证服务号微信不允许主动推送(模板消息/订阅通知/客服消息均受限),
|
||||
// 本层只负责在认证后通过模板消息把提醒/公告发给已关注粉丝;
|
||||
// 未认证时返回 ErrNotVerified,由上层给出明确提示。
|
||||
// =============================================================
|
||||
|
||||
// ErrNotVerified 公众号未认证,无法主动推送
|
||||
var ErrNotVerified = errors.New("公众号未认证:模板消息推送需认证后使用(当前仅支持关注与被动回复)")
|
||||
|
||||
// PushMessage 推送内容(对应「标题/内容/备注」通用模板字段)
|
||||
type PushMessage struct {
|
||||
Title string // first:首行说明
|
||||
Content string // keyword1:主体内容
|
||||
Remark string // remark:备注
|
||||
URL string // 点击跳转地址(可选)
|
||||
Title string
|
||||
Content string
|
||||
Remark string
|
||||
URL string
|
||||
}
|
||||
|
||||
// PushToOpenID 向指定粉丝推送一条模板消息
|
||||
func PushToOpenID(cfg *Config, openid string, msg PushMessage) error {
|
||||
if cfg == nil {
|
||||
return ErrNotConfigured
|
||||
@@ -55,21 +45,14 @@ func PushToOpenID(cfg *Config, openid string, msg PushMessage) error {
|
||||
})
|
||||
}
|
||||
|
||||
// PushScope 推送范围
|
||||
type PushScope struct {
|
||||
// BindType 为空表示全部已关注粉丝;platform_user / tenant_user 只推绑定对应类型账号的粉丝
|
||||
BindType string
|
||||
// BindID 非 0 时只推给该绑定账号(与 BindType 组合使用)
|
||||
BindID uint64
|
||||
// Tid 非 0 时只推给绑定该租户的用户(tenant_user 场景)
|
||||
Tid uint64
|
||||
}
|
||||
|
||||
// MaxBatchPush 单次批量推送上限
|
||||
const MaxBatchPush = 500
|
||||
|
||||
// PushToFollowers 按范围批量推送,返回成功/失败数量。
|
||||
// 仅推送给「已关注(subscribe=1)且未删除」的粉丝。
|
||||
func PushToFollowers(cfg *Config, scope PushScope, msg PushMessage) (sent, failed int, err error) {
|
||||
if cfg == nil {
|
||||
return 0, 0, ErrNotConfigured
|
||||
@@ -104,7 +87,6 @@ func PushToFollowers(cfg *Config, scope PushScope, msg PushMessage) (sent, faile
|
||||
continue
|
||||
}
|
||||
sent++
|
||||
// 简单节流,避免触发微信频率限制
|
||||
if i%20 == 19 {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user