<template>
  <view class="container-freecharge" v-if="isShowFreeBtn">
    <image @click="toggle" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/free_icon.png"></image>
    <image @click="removeBton" class="remove-icon" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/free_%20remove.png"></image>
  </view>
</template>

<script>
import { FreeButton } from "@/config/api.js";
export default {
  data() {
    return {};
  },
  props: {
    isShowFreeBtn: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
  },
  methods: {
    //跳转到免费送月卡页面
    toggle() {
      uni.navigateTo({
        url: "/pageMy/freeTrial/freeTrial",
      });
    },
    //隐藏当天的按钮
    async removeBton() {
      const res = await FreeButton.userFreeButtonUpdate();
      if(res.Ret === 200){
        this.$parent.isShowFree = false;
      }
    },
  },
};
</script>
<style scoped lang="scss">
.container-freecharge {
  position: relative;
  image {
    width: 156rpx;
    height: 156rpx;
  }
  .remove-icon {
    width: 31rpx;
    height: 31rpx;
    position: absolute;
    right: 0;
    top: 0;
  }
}
</style>
