43 lines
785 B
JavaScript
43 lines
785 B
JavaScript
// 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'
|
|
});
|
|
}
|
|
});
|
|
|