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

<script>
export default {
  props: {
    username: {
      type: String,
      default: 'gh_512687a191f5'
    },
    path: {
      type: String,
      default: '/pages/index/index'
    },
    content: {
      type: String,
      default: '<div class="btn" style="width:100%; min-height:50px; display:block; font-size:14px;color: #ffffff;">打开app</div>'
    }
  },
  data() {
    return {}
  },

  onLoad() {
  },

  onShow() {},

  methods: {
    handleErrorFn(e) {
      if (e.isTrusted == false) {
        this.$mHelper.toast('打开失败');
      }
    },
    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>
