<template>
  <div class='weapp' id="launch-btn">
    <wx-open-launch-app
      id="launch-btn"
      ref="launchBtn"
      :appid="appid"
      :extinfo="extinfo"
      @error="handleErrorFn"
      @launch="handleLaunchFn"
      @ready="handleReadyFn">
      <script type="text/wxtag-template">
        {{ content }}
      </script>
    </wx-open-launch-app>
  </div>
</template>

<script>
export default {
  props: {
    appid: {
      type: String,
      default: 'wxeb44a864bdd935be'
    },
    apkName: {
      type: String,
      default: 'com.zaojiao.app'
    },
    extinfo: {
      type: String,
      default: ''
    },
    content: {
      type: String,
      default: ''
    }
  },
  data() {
    return {}
  },

  onLoad() {
  },

  onShow() {},

  methods: {
    handleErrorFn(e) {
      if (e.isTrusted == false) {
        const that = this;
        setTimeout(function () {
          window.location.href = `https://android.myapp.com/myapp/detail.htm?apkName=${that.apkName}`;
        }, 500);
      }
    },
    handleLaunchFn(e) {

    },
    handleReadyFn() {

    },
  }

}
</script>

<style lang="scss" scoped>
.weapp {
  text-align: center;
  height: 100%;
  width: 100%;
  #launch-btn {
    display: block;
    width: 100%;
    height: 100%;
  }
}
</style>
