Fix subscription renewal and partner notification delivery

This commit is contained in:
2026-10-11 10:32:30 +08:00
parent c5cab1b945
commit 31eae87a63
13 changed files with 282 additions and 115 deletions
+1 -1
View File
@@ -311,7 +311,7 @@ Page(withDataCache(withListPagination({
var failReasons = [];
// ★ 在用户点击手势上下文中提前请求订阅消息(符合微信规范)
requestSubscribeAfterAction('photo');
await requestSubscribeAfterAction('photo');
try {
// 上传前先预热 session,确保认证状态有效
+6 -5
View File
@@ -171,12 +171,12 @@ Page(withDataCache({
submitCheck: async function() {
var item = this.data.item;
if (!item) return;
// ★ 在用户点击手势上下文中提前请求订阅消息(符合微信规范)
requestSubscribeAfterAction('checkin');
if (!item || this._submittingCheck) return;
this._submittingCheck = true;
try {
// 为本人接收TA的提醒补充授权。
await requestSubscribeAfterAction('checkin');
var photoPath = '';
if (this.data.checkPhoto) {
wx.showLoading({ title: '上传中...' });
@@ -206,7 +206,8 @@ Page(withDataCache({
wx.showToast({ title: toast, icon: 'success' });
// 刷新详情数据
this.loadDetail(item.id);
} catch(e) { wx.showToast({ title: e.error || '打卡失败', icon: 'none' }); }
} catch(e) { wx.hideLoading(); wx.showToast({ title: e.error || '打卡失败', icon: 'none' }); }
finally { this._submittingCheck = false; }
},
hideCheckModal: function() { this.setData({ showCheckModal: false }); },
+1 -1
View File
@@ -886,7 +886,7 @@ Page(withDataCache({
if (!inviteTargetId) { wx.showToast({ title: '请输入对方ID', icon: 'none' }); return; }
if (!/^[0-9]{6}$/.test(inviteTargetId)) { wx.showToast({ title: 'ID为6位数字', icon: 'none' }); return; }
// 邀请成功且对方接受时,需要通知邀请人,提前申请一次性订阅授权
setTimeout(function() { requestSubscribe('notify').catch(function() {}); }, 1500);
requestSubscribe('notify').catch(function() {});
try {
wx.showLoading({ title: '发送中...' });
const res = await api.invitePartner({ target_user_id: inviteTargetId, message: inviteMessage });
+2 -2
View File
@@ -353,14 +353,14 @@ Page({
}
// ★ 在用户点击手势上下文中提前请求订阅消息(符合微信规范)
// 订阅弹窗不阻塞后续异步操作,用户拒绝也不影响发布
// 为本人接收TA的提醒补充授权,拒绝或保存失败也不影响发布
var sceneMap = {
diary: 'diary', album: 'photo', checkin: 'checkin',
timeline: 'timeline', song: 'song'
};
var scene = sceneMap[type];
if (scene) {
requestSubscribeAfterAction(scene);
await requestSubscribeAfterAction(scene);
}
// 再执行异步操作(上传/API调用)
+18
View File
@@ -154,6 +154,24 @@ Page({
this._subscribing = false;
},
renewSubscribe: async function() {
if (this._subscribing) return;
this._subscribing = true;
try {
const results = await requestSubscribe('notify');
if (results.notify) {
this.setData({ subscribeChecked: true });
wx.showToast({ title: '已订阅一次提醒', icon: 'success' });
} else {
wx.showToast({ title: '本次未授权提醒', icon: 'none' });
}
} catch (e) {
wx.showToast({ title: '订阅失败,请重试', icon: 'none' });
} finally {
this._subscribing = false;
}
},
// ===== 背景图 =====
showBgModal: async function() {
this.setData({ showBgModal: true, bgPreview: '', bgFilePath: '' });
+7 -4
View File
@@ -144,20 +144,23 @@
<view class="subscribe-tip {{subscribeChecked ? 'on' : 'off'}}">
<block wx:if="{{subscribeChecked}}">
<text class="tip-icon">✅</text>
<text class="tip-text">通知已开启,TA的操作会第一时间通知你</text>
<text class="tip-text">已开启接收提醒,订阅次数用完后需要再次授权</text>
</block>
<block wx:else>
<text class="tip-icon">💡</text>
<text class="tip-text">开启后即可收到TA的操作通知</text>
<text class="tip-text">开启并授权后,可接收一次TA的操作提醒</text>
</block>
</view>
<button wx:if="{{subscribeChecked}}" class="btn btn-primary" bindtap="renewSubscribe">订阅一次 TA 的提醒</button>
<!-- 说明 -->
<view class="subscribe-note">
<text class="note-title">📌 温馨提示</text>
<text class="note-item">• 通知通过微信「服务通知」推送</text>
<text class="note-item">• 每次操作后可能会请求一次订阅授权</text>
<text class="note-item">• 若收不到通知,可重新开启此开关</text>
<text class="note-item">• 你授权的是自己接收TA提醒的次数,不能替TA授权</text>
<text class="note-item">• 每次授权可接收一次提醒,用完后可点击上方按钮续订</text>
<text class="note-item">• 勾选「总是保持以上选择」后,后续点击授权可免重复弹窗,仍需逐次申请</text>
</view>
</view>
</view>