<template>
  <div class="page">
    <img :src="pic" class="pic" alt="">
    <section class="dui-footer__wrap">
      <div class="dui-footer__btn" @click="onSend">转发</div>
    </section>
  </div>
</template>

<script>
import { get, post } from "@js/request";
import { getUrlParameter, isWeChatApplet } from "@js/tooler";
import { shareConfig, updateLink } from "@js/share";
import ShareFooter from '../../components/shareFooter'

const SCID = getUrlParameter('scid');
const API = {
  h5info: '/kjy/mp/content/h5info'
}

const inMiniprogram = getUrlParameter("mini") == 1;

export default {
  data() {
    return {
      pic: '//yun.dui88.com/h5-mami/webgame/kejiji/img/null.png',
      showShare: false
    };
  },
  components: {ShareFooter},
  methods: {
    async initData(){
      // let a = await get('/kjy/mp/seller/getScId', {contentId: 54});
      // console.log(a);
      // this.tip = window.navigator.userAgent.toLowerCase();
      let res = await get(API.h5info, { scid: SCID });
      console.log(res);
      if (res.success) {
        if(inMiniprogram && res.data.myself){
          this.showShare = true;
        }

        shareConfig({
          link: location.origin + location.pathname + location.search,
          title: window["actTitle"],
          desc: '来自客集集的分享',
          img: window["actImg"],
          debug: false
        });
      } else {
        if (res.code == '100010') {
          this.getH5Authorize();
        } else if (res.code == '100020') {
          
        }
      }
    },
    getH5Authorize(){
      let url = '/kjy/authorize/wxh5base?uri=/kjy/mp/contentview?scid=' + SCID;
      window.location.href = url;
    },
    doshare(){
      console.log(123);
      // updateLink(123);
    },
    onSend(){
      let url = formatUrl('pages/activity/setting/main', {
        scid: SCID
      });
      wx.miniProgram.navigateTo({
        url: url
      });
    }
  },
  created() {
    this.initData();
  }
};
</script>

<style lang="less" scoped src="./index.less">
</style>