<template>
  <view>
		<navbar leftClick @leftClick="$utils.navigateBack" />

    <view class="content">
      <video 
        :src="detail.videoUrl" 
        autoplay
        @timeupdate="onTimeupdate"
      ></video>
    </view>
  </view>
</template>

<script>
	export default {
		data() {
			return {
        detail: {
          id: null,
          title: null,
          videoUrl: null,
          times: 10,
          qrCode: null,
          description: null,
        },
        isLocked: true,
      }
    },
    onLoad(option) {
      console.log('--option', option)
      const { id } = option
      
      this.fetchSharingDetail(id)
    },
    onShareAppMessage(res) {
      const {
        description,
        imageUrl,
      } = this.detail

      // todo: check
      let o = {
        title : description,
        imageUrl: imageUrl,
        // path: `/pages_order/sharing/personal?id=${this.detail.id}`
        query: `id=${this.detail.id}`,
      }

      // todo: check callback? settimeout?

      // todo: get times and check is unlocked

      return o
    },
    methods: {
      async fetchSharingDetail(id) {
        // todo: init data by id

        this.detail = {
          id: '001',
          coverImageUrl: 'http://gips3.baidu.com/it/u=70459541,3412285454&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280',
          videoUrl: '../static/temp-video.mp4',
          times: 10,
          qrCode: '../static/temp-qrcode.png',
          title: '裂变星轻松获客',
          description: '如此好用的赚钱项目，赶快加入吧！',
          auditStatus: 2,
          createTime: '2025年2月1日',
          state: -1,
        }
      },
      onTimeupdate(e) {
        console.log('--onTimeupdate', e)
      },
      openPopup() {
        this.$refs.popup.open();
      },
      closePopup() {
        this.$refs.popup.close();
      },
    },
  }
</script>

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