<template>
  <page-theme :theme="theme">
    <template>
      <view class="f-30 p-40 flex-dir-column flex-x-center">
        <view class="col-info-d t-c m-b-30">欢迎使用</view>
      </view>
    </template>
  </page-theme>
</template>

<script>
  import themeMixins from '@/pages/yuecai/mixins/themeMixins.js';
  export default {
    mixins: [themeMixins],
    data() {
      return {
        isForcelogin: false, //是否强制重新登录
        checkeds: [],
        btnEnabled: false,
        isScaned: false,
        content: '<p>创建您的账户，您必须同意我们的' +
          '<a name="userAgreement" style="text-decoration:none"><strong><span style="color: black;">《用户协议》</span></strong></a>' +
          '和' +
          '<a name="privacyPolicy" style="text-decoration:none"><strong><span style="color: black;">《隐私协议》</span></strong></a></p>',
      }
    },
    methods: {
      gotoHome() {
        if (!this.btnEnabled) {
          return
        }
        if (this.isForcelogin || !this.$u.func.checkLogin()) {
          //强制重登或未登录，就登录一次
          console.log('强制重登或未登录，就登录一次')
          this.$u.func.wxLogin()
        } else {
          this.$u.func.toHome()
        }
      },
      gotoFollow() {
        uni.navigateTo({
          url: "./blocktime/follow"
        })
      },
      change(e) {
        this.btnEnabled = e.length > 0
      },
      clickLink(e) {
        if (e.name == 'userAgreement') {
          this.openUserAgreement()
        } else {
          this.openPrivacyPolicy()
        }
      },
      openUserAgreement() {
        uni.navigateTo({
          url: './blocktime/protocol'
        })
      },
      openPrivacyPolicy() {
        uni.navigateTo({
          url: './blocktime/privacy'
        })
      },

      sceneInfo() {
        let options = uni.getLaunchOptionsSync()

        console.log("options：" + JSON.stringify(options))
        let scanScene = [
          1011, //扫描二维码
          1047 //扫描小程序码
        ]
        if (scanScene.indexOf(options.scene) > -1) {
          this.isScaned = true
        }
      },
    },
    onLoad(options) {
      wx.showLoading();
      /** 扫码进入 */
      this.sceneInfo()
      this.isForcelogin = options.f == 1
      console.log("index onload")
      uni.$u.sleep(500).then(() => {
        if (this.$u.func.checkLogin()) {
          this.$u.func.toHome()
        } else {
          this.$u.func.wxLogin()
        }
      })
    },
  }
</script>

<style scoped lang="scss">
  .u-checkbox-group {
    justify-content: center !important;
  }
</style>