| | |
| | | clearOrderSuccessSubscribeCache();
|
| | | return true;
|
| | | }
|
| | | |
| | | /** |
| | | * 执行订阅弹窗请求。 |
| | | * 用户主动点击场景下可直接调用,避免被本地频控缓存拦截。 |
| | | */ |
| | | async function requestSubscribeMessageDirect(config: SubscribeSceneConfig, bizId?: string | number) { |
| | | const type = buildSubscribeType(config.sceneKey, bizId); |
| | | await new Promise<void>((resolve) => { |
| | | Taro.requestSubscribeMessage({ |
| | | tmplIds: config.tmplIds, |
| | | success: (result) => { |
| | | checkSubscribeStatus(type, config.tmplIds, result, config.limit); |
| | | const acceptedTemplateIds = getAcceptedTemplateIds(config.tmplIds, result as Record<string, string>); |
| | | void saveAcceptedSubscribeTemplates(acceptedTemplateIds); |
| | | resolve(); |
| | | }, |
| | | fail: () => { |
| | | resolve(); |
| | | }, |
| | | complete: () => { |
| | | resolve(); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | |
|
| | | // 执行通用订阅流程(失败/拒绝不影响主流程)
|
| | | export async function runSubscribeScene(config: SubscribeSceneConfig, bizId?: string | number) {
|
| | |
| | | if (consumed) return;
|
| | | await runSubscribeScene(ORDER_SUCCESS_SUBSCRIBE_CONFIG, orderId);
|
| | | }
|
| | | |
| | | // 用户主动点击“去开启”时,直接拉起订阅,不受频控缓存影响 |
| | | export async function subscribeAfterOrderSuccessByTap(orderId: string) { |
| | | if (!orderId) return; |
| | | await requestSubscribeMessageDirect(ORDER_SUCCESS_SUBSCRIBE_CONFIG, orderId); |
| | | } |
| | |
|
| | | // 运营活动 + 券效期 + 券到账三合一模板订阅
|
| | | export async function subscribeOperationCouponGroup(bizId?: string | number) {
|