<template>
  <section @click="jumpToCardList" class="card-banner-wrapper">
    <article class="left">
      <img :class="{'is-android': isAndroid}" src="../../images/cme/phrase2/what.png" alt />
      <span>学习课程必须使用学习卡哦~</span>
    </article>
    <span class="right">购买学习卡</span>
  </section>
</template>
<script>
import { getHactiveUrl } from "@/utils/index";
import { mapGetters } from "vuex";
import { Toast  } from 'vant';
export default {
  data() {
    return {
      isAndroid: window.__isAndroid,
    }
  },
  props: {
    hasLogin: {
      type: Boolean | Number,
      default: false
    }
  },
  computed: {
    ...mapGetters(["userInfo"])
  },
  methods: {
    // 跳转到学习卡列表页面
    jumpToCardList() {
      // 如果没有登录，则要去登录页面
      // 打开页面埋点
      this.$sendBuriedData({
        component_tag: "886#8865"
      });
      let appVersion = this.userInfo.appVersion;
      let appVersionNum = appVersion.split('.').join('');
      console.log('appVersionNum', appVersionNum);
      if(appVersionNum < 341) {
        Toast('请您下载新版本App');
        return;
      }
      // if (!this.hasLogin) {
      //   rocNative.gotoLogin();
      //   return;
      // }
      if (window.__isWeb) {
        console.log("in jumpToCardList");
        return;
      } else {
        let pageUrl = getHactiveUrl("/message_push/#/study-card?origin=1");
        let paramList = [
          {
            key: "pageUrl",
            value: pageUrl,
            type: 4,
            seqNo: 1
          }
        ];
        rocNative.dispatchEventByModuleCode({
          modeCode: "M300",
          jsonString: paramList
        });
      }
    }
  }
};
</script>
<style lang="less" scoped>
.card-banner-wrapper {
  width: 100%;
  height: 40px;
  display: flex;
  flex-direction: row;
  padding: 0 15px;
  justify-content: space-between;
  align-items: center;
  background: #fefaf5;
  .left {
    display: flex;
    height: 40px;
    flex-direction: row;
    align-items: center;
    img {
      width: 13px;
      height: 13px;
      margin-right: 4px;
      &.is-android {
        width: 12px;
        height: 13px;
        margin-bottom: 2px;
      }
    }
    span {
      font-size: 13px;
      color: #e6a23c;
    }
  }
  .right {
    height: 25px;
    line-height: 25px;
    font-size: 12px;
    padding: 0 10px;
    background: rgba(230, 162, 60, 1);
    border-radius: 25px;
    border: 1px solid rgba(230, 162, 60, 1);
    color: #ffffff;
  }
}
</style>
