webview.vue 1.2 KB
<template>
	<page-meta>
		<navigation-bar :title="nbTitle" :front-color="nbFrontColor" :background-color="nbBackgroundColor" />
	</page-meta>
	<view>
		<view v-if="url">
			<web-view :webview-styles="webviewStyles" :src="url" @message="handleGetMessage"></web-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nbTitle: '',
				nbFrontColor: '#000000',
				nbBackgroundColor: '#ffffff',
				url: "",
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				}
			}
		},

		onLoad(option) {
			console.log(option, new Date().getTime());
			if (option.type == 'treary') {
				this.url = decodeURIComponent(option.url);
				console.log('123',this.url);
			} else if (option.type == 'cc') {
				
			} else {
				this.url = `${option.url}?time=${new Date().getTime()}`;
			}
			this.nbTitle = option.navtitle;
		},

		methods: {
			reloadPage(redirectUrl) {
				console.log('---webview reloadPage', redirectUrl)
				this.url = redirectUrl
			},
		
			handleGetMessage(e) {
				console.log('ddd', e)
				if (e.detail.data[0].result == 'success') {
					wx.navigateTo({
						url: '/pages/redirect/bizpage'
					})
				}
			},
			
		}
	}
</script>

<style lang="scss" scoped>

</style>