<script>
export default {
  data() {
    return {
      src: '',
      hasBack: false,
      options: {}
    }
  },
  onLoad(options) {
    console.log('webview page', options)
    uni.hideLoading()
    this.options = options
    const { url, hasBack } = options
    this.src = decodeURIComponent(url)

    if (hasBack === '1') {
      this.hasBack = true
    }
  },
  methods: {
    goBack() {
      uni.navigateBack()
    },
    goHome() {
      uni.reLaunch({ url: '/pages/index/index' })
    }
  }
}
</script>

<template>
  <view class="web_view">
    <web-view :src="src" />

    <cover-view
      v-if="hasBack"
      class="fixed top-30 left-30 color-white"
      @tap="goBack"
    >
      返回
    </cover-view>
  </view>
</template>

<style lang="scss" scoped>
.web_view {
  width: 100%;
  height: 100vh;
  position: relative;
}
</style>
