<template>
  <view class="position-container">
    <u-card :show-head="false" margin="0">
      <template #body>
        <view class="position-header">
          {{ positionItem.courseName }}
        </view>
        <view class="item">
          <text>上课地点：{{ positionItem.classArea }}</text>
        </view>
        <view class="item">
          <text
            >考勤定位：{{
              positionItem.StateType ? positionItem.hitArea : "未设置"
            }}</text
          >
        </view>
        <view class="item">
          <text v-show="current"
            >应用范围：{{
              positionItem.type === "1"
                ? "同步班级所有课程的考勤定位"
                : "仅当前课程考勤定位"
            }}
          </text>
          <text v-show="!current">应用范围：未设置</text>
        </view>
        <view class="item">
          <text
            >距离范围：{{
              positionItem.Scope && positionItem.Scope !== " "
                ? positionItem.Scope + "米"
                : "未设置"
            }}</text
          >
        </view>
      </template>
      <template #foot>
        <view class="position-footer">
          <text>所属班级：{{ positionItem.className }}</text>
          <u-button type="primary" @tap="openMap">{{
            current ? "修改定位" : "设置定位"
          }}</u-button>
        </view>
      </template>
    </u-card>
  </view>
</template>

<script setup lang="ts">
import { useMapStore } from "@/stores/modules/mapStore";

const props = defineProps({
  positionItem: {
    type: Array,
    default: () => [],
  } as any,
  current: {
    type: Number,
    default: 0,
  },
});

const mapStore = useMapStore();

const openMap = () => {
  mapStore.setMapData(props.positionItem);
  uni.navigateTo({
    url: "/pagesTeach/setPositioning/map",
  });
};
</script>

<style lang="scss" scoped>
.position-container {
  margin-bottom: 20rpx;

  :deep(.u-card__body) {
    padding: 40rpx 32rpx 8rpx !important;
  }

  .position-header {
    margin-bottom: 32rpx;
    height: 48rpx;
    font-size: 34rpx;
    font-weight: 500;
    color: #222222;
    line-height: 40rpx;
  }

  .item {
    margin-bottom: 24rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(34, 34, 34, 0.9);
  }

  .position-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 24rpx;
    font-weight: 400;
    color: rgba(34, 34, 34, 0.5);
    line-height: 28rpx;
    .u-btn {
      margin: 0;
      height: 58rpx;
      background: #04a7ff;
      border-radius: 12rpx;
      font-size: 24rpx;
    }
  }
}
</style>
