findme-miniprogram-frontend/pages/webview/webview.js

44 lines
785 B
JavaScript
Raw Permalink Normal View History

2025-12-27 17:16:03 +08:00
// webview 页面
Page({
data: {
url: ''
},
onLoad(options) {
if (options && options.url) {
try {
const decodedUrl = decodeURIComponent(options.url);
this.setData({
url: decodedUrl
});
} catch (e) {
console.error('URL解码失败:', e);
this.setData({
url: options.url
});
}
} else {
wx.showToast({
title: '缺少URL参数',
icon: 'none'
});
setTimeout(() => {
wx.navigateBack();
}, 1500);
}
},
onMessage(e) {
console.log('收到webview消息:', e.detail.data);
},
onError(e) {
console.error('webview加载错误:', e);
wx.showToast({
title: '页面加载失败',
icon: 'none'
});
}
});