Component({ data: { visible: true, state: 'loading', message: '' }, lifetimes: { attached: function() { this._startedAt = Date.now(); this._unobserve = getApp().observeAuth((state, message) => { clearTimeout(this._exitTimer); if (state === 'ready' && !this._waiting) { this.setData({ visible: false }); } else if (state === 'ready') { this._exitTimer = setTimeout(() => { this.setData({ visible: false }); }, Math.max(0, 350 - (Date.now() - this._startedAt))); } else { this._waiting = true; this.setData({ visible: true, state: state, message: message }); } }); }, detached: function() { clearTimeout(this._exitTimer); if (this._unobserve) this._unobserve(); } }, methods: { preventMove: function() {}, retry: async function() { try { await getApp().silentLogin(); // 重新加载失败的页面,保留分享链接、相册 id 等原始入口参数。 var pages = getCurrentPages(); var page = pages[pages.length - 1]; if (!page) return; var query = Object.keys(page.options || {}).map(function(key) { return encodeURIComponent(key) + '=' + encodeURIComponent(page.options[key]); }).join('&'); wx.reLaunch({ url: '/' + page.route + (query ? '?' + query : '') }); } catch (error) { // App 已发布失败状态,保留重试画面。 } } } });