<template>
  <page-layout class="webview-container">
    <web-view class="webview" :src="url" @bindmessage="message"></web-view>
    <u-share-action-sheet :show.sync="showShare" :show-info="shareInfo" />
  </page-layout>
</template>

<script>
import UShareActionSheet from '@/components/common/u-share-action-sheet'
import PageLayout from "@/components/layout/page-layout";
export default {
  components: {
    PageLayout,
    UShareActionSheet
  },
  data() {
    return {
      url: '',
      showShare: false,
      shareInfo:{}
    }
  },
  onLoad(options) {
    this.url = decodeURIComponent(options.url)
  },
  methods: {
    message(e) {
      if (e && e.event_name === 'collect') {

      }
      if (e && e.event_name === 'share') {
        this.showShare =  true
        this.shareInfo = {
          title: e.title,
          path: url,
          imageUrl: e.image_url
        }
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.webview-container {
  display: flex;
  flex-direction: column;
}

.webview {
  flex: 1;
}
</style>
