This commit is contained in:
@@ -15,7 +15,7 @@ export async function initWxConfig() {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
wx.config({
|
wx.config({
|
||||||
debug: true,
|
debug: false,
|
||||||
appId: app_id,
|
appId: app_id,
|
||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
nonceStr: nonce_str,
|
nonceStr: nonce_str,
|
||||||
@@ -42,16 +42,7 @@ export async function initWxConfig() {
|
|||||||
* @returns {Promise<string>} 扫码结果字符串
|
* @returns {Promise<string>} 扫码结果字符串
|
||||||
*/
|
*/
|
||||||
export function wxScan() {
|
export function wxScan() {
|
||||||
console.log('wx 对象:', wx)
|
|
||||||
console.log('window.wx:', window.wx)
|
|
||||||
console.log('window.jWeixin:', window.jWeixin)
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!wx) {
|
|
||||||
const msg = 'wx 对象不存在,请在微信环境中使用'
|
|
||||||
console.error(msg)
|
|
||||||
reject(new Error(msg))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
wx.scanQRCode({
|
wx.scanQRCode({
|
||||||
needResult: 1,
|
needResult: 1,
|
||||||
scanType: ['qrCode', 'barCode'],
|
scanType: ['qrCode', 'barCode'],
|
||||||
@@ -61,7 +52,7 @@ export function wxScan() {
|
|||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
console.error('扫码失败:', err)
|
console.error('扫码失败:', err)
|
||||||
reject(new Error(err?.errMsg || JSON.stringify(err) || '扫码失败'))
|
reject(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user