mirror of
http://36.133.248.69:3088/admin/RentWeAppFront.git
synced 2026-03-08 01:42:28 +08:00
完成大体功能和样式
This commit is contained in:
72
pages-biz/webview/webview.vue
Normal file
72
pages-biz/webview/webview.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<web-view v-if="src" :src="src" bindmessage="handleGetMessage"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
src: '' // WebView URL
|
||||
}
|
||||
},
|
||||
|
||||
// 页面加载
|
||||
onLoad(e) {
|
||||
let url = e.url || ''
|
||||
try {
|
||||
url = decodeURIComponent(url)
|
||||
} catch (err) {
|
||||
console.warn('decode error', url)
|
||||
}
|
||||
console.log("签署链接:" + url)
|
||||
// 强制刷新 WebView
|
||||
this.src = ''
|
||||
this.$nextTick(() => {
|
||||
this.src = url
|
||||
console.log('webview src set:', this.src)
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 刷脸完成后重新加载页面
|
||||
*/
|
||||
reloadPage(redirectUrl) {
|
||||
console.log('---webview reloadPage', redirectUrl)
|
||||
this.src = redirectUrl || this.src
|
||||
},
|
||||
|
||||
/**
|
||||
* 消息通知回调处理
|
||||
* H5 / App / 小程序都可以调用
|
||||
*/
|
||||
handleGetMessage(e) {
|
||||
console.log('handleGetMessage', e)
|
||||
const data = e.detail?.data?.[0]
|
||||
if (data && data.result === 'success') {
|
||||
// 跳转中转页
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.navigateBack()
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
if (window.history.length > 1) {
|
||||
window.history.go(-delta)
|
||||
} else {
|
||||
// 没有上一页就跳首页
|
||||
this.$router.replace('/')
|
||||
}
|
||||
return
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
// 这里根据你 APP 路由跳转方法
|
||||
// plus.webview.open('/redirect/bizpage')
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user