<template>
  <view class="container" :class="[`${themeInfo.theme}-theme`]">
    <navBar class="navBar"></navBar>
    <view class="wrapbox">
      <view class="container-form">
        <view class="cHeader">
          <view class="left"> 人品大爆发 </view>
          <view class="right"> 已邀请人数 {{state.count}}/50 </view>
        </view>
        <view class="content">
          <text class="detail">
            {{ `活动内容：邀请50位小伙伴关注[${projectInfo.name}]公众号，即可获得租仓优惠券！` }}
          </text>
          <view class="info">
            <text> 使用门店：全部门店 </text>
            <text @click="makePhoneCall()">
              {{ `详情咨询：${projectInfo.phone}` }}
            </text>
          </view>
        </view>
        <view class="footer">
          <view class="left">
            <button open-type="share" class="btn">去邀请</button>
            <button class="btn" @click="makePhoneCall()">兑换</button>
          </view>
          <view class="right" @click="state.inviteShow = true"> 查看邀请记录>> </view>
        </view>
      </view>
      <view class="tips">
        {{ `*活动解释权归${projectInfo.name}所有` }}
      </view>
    </view>
	<!-- 邀请详情 -->
	<inviteDetail v-model="state.inviteShow"></inviteDetail>
  </view>
</template>
<script setup>
import navBar from "@/components/navBar.vue";
import { makePhoneCall } from "/utils/common.js";
import { ref } from "vue";
import { useRecommend } from "@/Apis/recommend.js";
import { onLoad, onShareAppMessage,onShow } from "@dcloudio/uni-app";
// 主题色配置
import { useMainStore } from "@/store/index.js";
import { baseImageUrl, projectInfo } from "@/config/index.js";
import inviteDetail from '@/components/inviteDetail.vue';
const { themeInfo } = useMainStore();
const getApi = useRecommend();
const state = ref({
	inviteShow: false,
  count: 0
});
onLoad((params) => {});
onShow(() => {
  getApi.GetRecommendCount().then((res) => {
    console.log(res);
   if(res.code === 200){
     state.count = res.data;
   }
  });
});
onShareAppMessage((res) => {
  if (res.from === "button") {
    let userInfo = uni.getStorageSync("userInfo");
    // 来自页面内分享按钮
    return {
      title: `您的好友(${
        userInfo?.customerName || "微信好友"
      })邀请您一起体验${projectInfo.name}，改变储物方式!`,
      path: "pages/index/index?Pre_ID=" + userInfo?.customerNo, // 路径，传递参数到指定页面。,
      imageUrl: baseImageUrl + "2c5f7950-e842-47e5-a135-86d04f22bab8.png",
    };
  }
  return shareParam;
});
</script>

<style lang="scss" scoped>
@import "@/static/style/theme.scss";
uni-page-body {
  height: 100%;
  background: linear-gradient(0deg, rgb(1, 169, 188), rgb(10, 132, 184));
  overflow: auto;
}
.navBar {
  position: relative;
}
.container {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: start;
  width: 100%;
  overflow-x: hidden;
  height: 100vh;

  background: linear-gradient(0deg, var(--left-linear), var(--right-linear));
  .wrapbox {
    padding: 0 20rpx;
  }
}
.container-form {
  width: 100%;
  box-sizing: border-box;
  background: white;
  border-radius: 18rpx;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 20rpx;
  font-size: 24rpx;
  .cHeader {
    display: flex;
    justify-content: space-between;
    border-bottom: 1rpx solid #e5e5e5;
    padding-bottom: 20rpx;
    width: 100%;
    font-weight: bold;
  }
  .content {
    padding: 0 10rpx;
    padding-top: 20rpx;
    .detail {
      margin: 40rpx 0;
      font-weight: bold;
    }
    .info {
      display: flex;
      flex-direction: column;
      margin-top: 20rpx;
    }
  }
  .footer {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    padding: 10rpx 0;
    padding-top: 40rpx;
    font-weight: bold;
    .left {
      display: flex;
      justify-content: space-between;
      font-size: 22rpx;
      .btn {
        width: 160rpx;
        height: 44rpx;
        line-height: 44rpx;
        padding: 0;
        font-size: 22rpx;
        margin-right: 10rpx;
        border-radius: 999px;
        border: 1rpx solid transparent;
        &:nth-child(2) {
          border-color: #000000;
        }
        &:nth-child(1) {
          background-color: var(--main-color);
        }
      }
    }
    .right {
      font-size: 20rpx;
    }
  }
}
.tips {
  margin-top: 30rpx;
  font-size: 20rpx;
  font-weight: bold;
}
</style>
