diff --git a/packages/localLife/pay/index.vue b/packages/localLife/pay/index.vue index ee670212..817f4515 100644 --- a/packages/localLife/pay/index.vue +++ b/packages/localLife/pay/index.vue @@ -180,7 +180,25 @@ export default { // 'custom-header': 'hello' //自定义请求头信息 }, success: (res) => { - this.createQrcode2(res.data.access_token) + // 检查是否成功获取到access_token + if (res.data && res.data.access_token) { + this.createQrcode2(res.data.access_token) + } else { + uni.hideLoading(); + uni.showToast({ + title: '获取二维码失败,请重试', + icon: 'none' + }); + console.error('获取微信access_token失败:', res); + } + }, + fail: (err) => { + console.error('获取微信access_token失败:', err); + uni.hideLoading(); + uni.showToast({ + title: '获取二维码失败,请重试', + icon: 'none' + }); } }); },