<template>
  <view>
    <up-popup
      :show="show"
      @close="close"
      mode="center"
      :safe-area-inset-bottom="false"
    >
      <view class="u-flex top justify-between u-p-32">
        <text class="title">{{ tipsType }}</text>
        <up-icon name="close" @click="close"></up-icon>
      </view>
      <scroll-view style="width: 500rpx; max-height: 60vh">
        <view class="u-p-30 font-14" style="width: 500rpx">
          <template v-if="tipsType == '等级分成比例'">
            <view class="u-flex justify-between font-bold u-m-b-20">
              <view>等级</view>
              <view>分成比例</view>
            </view>
            <view
              class="u-m-b-10"
              v-for="(item, index) in props.levelConfigList"
              :key="index"
            >
              <view class="u-flex justify-between">
                <view> {{ item.level }}({{ item.name }}) </view>
                <view class="color-666"> {{ item.levelOneCommission }}% </view>
              </view>
            </view>
          </template>
          <template v-if="tipsType == '等级升级条件'">
            <view class="u-flex justify-between font-bold u-m-b-20">
              <view>等级</view>
              <view v-if="config.upgradeType != 'not_upgrade'">升级条件</view>
            </view>
            <view
              class="u-m-b-10"
              v-for="(item, index) in props.levelConfigList"
              :key="index"
            >
              <view class="u-flex justify-between">
                <view>
                  <text>
                    {{ item.level }}
                  </text>
                  <text>({{ item.name }}) </text>
                </view>
                <view v-if="config.upgradeType != 'not_upgrade'"
                  >{{ returnTiaojain(item) }}
                </view>
              </view>
            </view>
          </template>
        </view>
      </scroll-view>
    </up-popup>
  </view>
</template>


<script setup>
import { ref, computed } from "vue";

const show = defineModel({
  type: Boolean,
  default: false,
});
const props = defineProps({
  tipsType: {
    type: String,
    default: "",
  },
  config: {
    type: Object,
    default: () => {},
  },
  levelConfigList: {
    type: Array,
    default: () => [],
  },
});
function close() {
  show.value = false;
}
function returnTiaojain(item) {
  if (props.config.upgradeType === "not_upgrade") {
    return "";
  }
  if (props.config.upgradeType == "cost") {
    return `订单金额满${item.costAmount}元`;
  }
  if (props.config.upgradeType == "invite") {
    return `邀请${item.inviteCount}人`;
  }
}
</script>

<style  lang="scss">
.title {
  color: #000000;
  font-size: 32rpx;
  font-weight: 700;
}
.top {
  border-bottom: 2rpx solid #ededed;
}
</style>