fix(iOS微信真机): 修复扫码核销页空白页
根因:verify/index.vue 在 <script> 顶层调用 getApp().globalData, 与 diy 组件白屏问题相同——iOS 微信真机 subpackage evaluate 阶段早于 App.vue#onLaunch,globalData 未就绪导致 evaluation 失败。 修复: 1. 移除顶层 const app = getApp() 和 var bar_height = ... 2. data() 中 status_bar_height 初始值改为 0 3. onLoad() 中延迟调用 getApp() 读取 statusBarHeight 4. 所有方法内 app.globalData.xxx 改为 getApp().globalData.xxx 5. 加留痕注释 gitnexus detect_changes: risk_level=low, 0 affected_processesmaster
parent
79ca8385d6
commit
0a42be5df6
|
|
@ -240,22 +240,23 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
// ──────────────────────────────────────────────────────────────────────────
|
||||
// [iOS 真机白屏修复 · 方案 A] 2026-06-30
|
||||
// 根因:vr-ticket-wallet 是独立 subpackage,iOS 微信真机的 subpackage
|
||||
// evaluate 阶段早于 App.vue#onLaunch,顶层 getApp().globalData 拿到残缺
|
||||
// globalData,导致页面 <script> evaluation 失败、只渲染静态 header。
|
||||
// 修复:把 getApp() 及 globalData 读取延迟到 onLoad() 生命周期。
|
||||
// 详见 docs/ios-weixin-real-device-white-screen-report.md
|
||||
// ──────────────────────────────────────────────────────────────────────────
|
||||
import componentCommon from '@/components/common/common';
|
||||
|
||||
const app = getApp();
|
||||
// 状态栏高度
|
||||
var bar_height = parseInt(app.globalData.get_system_info('statusBarHeight', 0, true));
|
||||
// #ifdef MP-TOUTIAO || H5
|
||||
bar_height = 0;
|
||||
// #endif
|
||||
|
||||
export default {
|
||||
components: {
|
||||
componentCommon
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
status_bar_height: bar_height,
|
||||
status_bar_height: 0,
|
||||
// 核销员信息
|
||||
verifierName: '',
|
||||
// 统计数据
|
||||
|
|
@ -280,6 +281,15 @@ export default {
|
|||
},
|
||||
|
||||
onLoad(params) {
|
||||
// [iOS 修复] getApp() 及 globalData 读取移到 onLoad(),
|
||||
// 确保 evaluate 阶段不依赖 app.globalData
|
||||
const app = getApp();
|
||||
let bar_height = parseInt(app.globalData.get_system_info('statusBarHeight', 0, true));
|
||||
// #ifdef MP-TOUTIAO || H5
|
||||
bar_height = 0;
|
||||
// #endif
|
||||
this.status_bar_height = bar_height;
|
||||
|
||||
// #ifdef H5
|
||||
this.isH5 = true;
|
||||
// #endif
|
||||
|
|
@ -322,7 +332,7 @@ export default {
|
|||
// 检查核销员权限
|
||||
checkVerifierPermission() {
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url('checkVerifier', 'ticket', 'vr_ticket'),
|
||||
url: getApp().globalData.get_request_url('checkVerifier', 'ticket', 'vr_ticket'),
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
|
|
@ -336,7 +346,7 @@ export default {
|
|||
}
|
||||
} else if (res.data.code == 401) {
|
||||
// 未登录
|
||||
app.globalData.get_user_info(this, 'checkVerifierPermission');
|
||||
getApp().globalData.get_user_info(this, 'checkVerifierPermission');
|
||||
} else {
|
||||
this.showNoPermission = true;
|
||||
}
|
||||
|
|
@ -351,7 +361,7 @@ export default {
|
|||
// 获取统计数据
|
||||
fetchStats() {
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url('myVerifications', 'ticket', 'vr_ticket'),
|
||||
url: getApp().globalData.get_request_url('myVerifications', 'ticket', 'vr_ticket'),
|
||||
method: 'GET',
|
||||
data: { page: 1, page_size: 1 },
|
||||
dataType: 'json',
|
||||
|
|
@ -382,7 +392,7 @@ export default {
|
|||
|
||||
// 粗略估算:请求更多数据来统计今日(生产环境建议后端提供专门接口)
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url('myVerifications', 'ticket', 'vr_ticket'),
|
||||
url: getApp().globalData.get_request_url('myVerifications', 'ticket', 'vr_ticket'),
|
||||
method: 'GET',
|
||||
data: { page: 1, page_size: 100 },
|
||||
dataType: 'json',
|
||||
|
|
@ -407,7 +417,7 @@ export default {
|
|||
|
||||
// #ifdef H5
|
||||
// H5 环境提示使用手动核销(界面上已显示)
|
||||
app.globalData.showToast('H5 环境请使用手动输入核销');
|
||||
getApp().globalData.showToast('H5 环境请使用手动输入核销');
|
||||
return;
|
||||
// #endif
|
||||
|
||||
|
|
@ -425,7 +435,7 @@ export default {
|
|||
self.processScanResult(res.result);
|
||||
} else {
|
||||
self.isScanning = false;
|
||||
app.globalData.showToast('未识别到票码');
|
||||
getApp().globalData.showToast('未识别到票码');
|
||||
}
|
||||
},
|
||||
fail: function(err) {
|
||||
|
|
@ -434,7 +444,7 @@ export default {
|
|||
if (err.errMsg && err.errMsg.indexOf('cancel') !== -1) {
|
||||
// 用户取消,不提示
|
||||
} else {
|
||||
app.globalData.showToast('扫码失败,请重试');
|
||||
getApp().globalData.showToast('扫码失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -450,7 +460,7 @@ export default {
|
|||
// 手动输入提交核销
|
||||
submitManualCode() {
|
||||
if (!this.manualCode || this.manualCode.trim() === '') {
|
||||
app.globalData.showToast('请输入有效的票码');
|
||||
getApp().globalData.showToast('请输入有效的票码');
|
||||
return;
|
||||
}
|
||||
this.processScanResult(this.manualCode.trim());
|
||||
|
|
@ -469,7 +479,7 @@ export default {
|
|||
this.isScanning = true;
|
||||
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url('verify', 'ticket', 'vr_ticket'),
|
||||
url: getApp().globalData.get_request_url('verify', 'ticket', 'vr_ticket'),
|
||||
method: 'POST',
|
||||
data: { ticket_code: ticketCode },
|
||||
dataType: 'json',
|
||||
|
|
|
|||
Loading…
Reference in New Issue