<template>
  <view>
    <sudoku
      ref="sudoku"
      :detail="detail"
      :sa_awardid="sa_awardid"
      :shareuserid="shareuserid"
    />
  </view>
</template>

<script>
import sudoku from "./modules/sudoku";
import { winTheCustomer } from "../../utils/share";
export default {
  components: { sudoku },
  data() {
    return {
      sa_awardid: 0,
      shareuserid: 0,
      detail: {},
      initialize: true,
    };
  },
  onLoad(options) {
    console.log("options", options);
    this.sa_awardid = options.sa_awardid || 0;
    this.isInitializeLogin(render.bind(this));
    function render() {
      this.getDetail();
      this.shareUserid = winTheCustomer(options.shareUserid || 0, "活动抽奖");
    }

    uni.setNavigationBarTitle({
      title: "活动抽奖",
    });
  },
  onShow() {
    if (!this.initialize) this.getDetail();
  },
  methods: {
    getDetail() {
      this.$Http
        .basic({
          id: 20240514101502,
          content: {
            sa_awardid: this.sa_awardid,
          },
        })
        .then((res) => {
          console.log("抽奖详情", res);
          if (this.cutoff(res.msg)) return;
          this.initialize = false;
          this.detail = res.data;
          this.$refs.sudoku.init();
        });
    },
    getSheraDate() {
      let detail = this.detail;
      return {
        title: detail.name, // 标题
        path:
          "/store/lottery/shareable?sa_awardid=" +
          detail.sa_awardid +
          "&shareUserid=" +
          this.shareUserid, // 分享路径
        imageUrl: "", // 分享图
      };
    },
  },
  onShareAppMessage() {
    return this.getSheraDate();
  },
  onShareTimeline() {
    return this.getSheraDate();
  },
};
</script>

<style lang="scss" scoped></style>