<template>
  <div class="app-container">
  </div>
</template>

<script>
import {Dialog} from "vant";
const TEST = 0;

export default {
  name: "ChungengUserSSOLogin",
  data() {
    return {
    };
  },
  created() {
    this.Login();
  },
  methods: {
    GetToken() {
      if(TEST)
      {
        if(!this.$route.query.s)
          return this.$route.query.s;
        let phone = '704d238d95b61f8304ce9e9c2d70e0bf';
        //phone = '525e902f509a7147ad92e602139bd267'
        let ts = '1234567890123';
        return phone + '#' + ts;
      }
      else
        return this.$route.query.s;
    },
    ShowToast(content, title) {
      return Dialog.alert({
        title: title,
        message: content,
        theme: 'round-button',
      });
    },
    Login() {
      let code = this.GetToken();
      if(!code)
      {
        this.ShowToast('请从春耕App进入登录').then(() => {
          history.back();
        });
        return false;
      }
      this.$store.dispatch("ChungengLogin", {code})
        .then(() => {
          this.$router.push({ path: "/yinnong/doneCompleted/completed" });
        })
        .catch((error) => {
          this.ShowToast(error || '春耕App用户登录失败').then(() => {
            history.back();
          });
        });
    },
  },
};
</script>

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