<template>
  <view class="container-ficc-report-item" @click="goDetail(list)">
    <view class="content-img">
      <image :src="list.ImgUrl"></image>
    </view>
    <view class="content-test">
      <text>{{ list.Title }}</text>
      <text>{{ list.SecondTitle }}</text>
    </view>
    <u-modal
      v-model="showhasPermission"
      :content-style="{ fontSize: '32rpx' }"
      @confirm="showhasPermissionBtn"
      :show-cancel-button="true"
      confirm-text="提交申请"
      @cancel="showhasPermissionCancel"
      :show-title="false"
      :cancel-style="{ borderRight: '1rpx solid #EBEBEB' }"
      :confirm-style="{ fontWeight: '700' }"
    >
      <view class="slot-content">
        <text class="noauth-title">暂无权限</text>
        <text>{{ list.HasPermission == 6 || list.HasPermission == 7 ? "您可申请开通试用" : "点击提交申请，提醒对口销售为你开通试用" }}</text>
      </view>
    </u-modal>
  </view>
</template>

<script>
import { User, Reports } from "@/config/api.js";

export default {
  name: "",
  components: {},
  props: {
    list: {
      type: Object,
      default: {},
      required: true,
    },
  },
  data() {
    return { showhasPermission: false, reportId: 0, hasPermission: 0 };
  },
  methods: {
    async goDetail(item) {
      if (!this.isUserBindingPhoneNumber) {
        this.pleaseGoLogin();
        return;
      }
      if (item.HasPermission == 1) {
        const res = await Reports.postFiccXCXHistory();
        if (res.Ret !== 200) return;
        uni.navigateToMiniProgram({
          appId: item.Appid,
          path: item.SourceUrl + item.ThirdCode,
        });
      } else {
        this.showhasPermission = true;
        this.reportId = item.ReportId;
        this.hasPermission = item.HasPermission;
      }
    },
    async showhasPermissionBtn() {
      if (this.hasPermission == 3 || this.hasPermission == 5) {
        const res = await User.applyTry({
          ApplyMethod: 3,
          TryType: "ficcreportxcx",
          DetailId: 0,
        });
        if (res.Ret === 200) {
          uni.showModal({
            title: "",
            content: "申请已提交,请等待销售人员与您联系",
            showCancel: false,
            confirmColor: "#365595",
            success: function (res) {},
          });
        }
      } else if (this.hasPermission == 7) {
        uni.navigateTo({
          url: "/pageMy/applyTrial/applyTrial?tryType=ficcreportxcx&detailId=" + 0,
        });
      } else {
        uni.showModal({
          title: "",
          content: "您已经提交过申请了，请耐心等待",
          showCancel: false,
          confirmColor: "#365595",
          success: function (res) {},
        });
      }
    },
    showhasPermissionCancel() {
      this.showhasPermission = false;
    },
  },
};
</script>
<style scoped lang="scss">
.container-ficc-report-item {
  min-height: 220rpx;
  width: 100%;
  border-radius: 8rpx;
  overflow: hidden;
  margin-bottom: 20rpx;
  box-shadow: 0rpx 3rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
  .content-img {
    width: 100%;
    height: 60rpx;
    image {
      width: 100%;
      height: 100%;
    }
  }
  .content-test {
    width: 100%;
    padding: 12rpx;
    text {
      font-size: 24rpx;
      line-height: 36rpx;
      color: #333;
      margin-bottom: 10rpx;
    }
  }
  .noauth-title {
    font-size: 32rpx;
    font-weight: 600;
    margin-bottom: 15rpx;
  }
}
</style>
