PreStudyPopup.vue 5.19 KB
<template>
  <view class="exam-submit-popup-wrapper">
    <view class="content-box">
      <scroll-view class="course-list" scroll-y>
        <view
          class="course-item"
          v-for="(item, index) in displayCourseList"
          :key="item.activityProductId || index"
        >
          <view class="course-item-title">
            <view class="course-item-title-text">{{ item.packageName }}</view>
            <text class="course-item-desc">{{ formatIncludes(item.includes) }}</text>
          </view>
          <view
            class="course-item-btn"
            v-if="item.learnStatus  ===  'NOT_STUDY'"
            @click.stop="handleStartStudy(item, index)"
          >开启学习</view>
          <view class="course-item-btn course-item-btn--learned" v-else>
            <image class="course-item-btn-icon" :src="require('@/assets/images/common/icon-study-right.png')" mode="aspectFit"></image>
            <text>已学习</text>
          </view>
        </view>
      </scroll-view>
    </view>
    <!-- 按钮组(始终显示) -->
    <view class="button-group">
      <view
        class="confirm-button"
        :class="{ 'confirm-button--disabled': confirmDisabled }"
        @click="handleConfirm"
      >
        {{ confirmText }}
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'PreStudyPopup',
  props: {
    confirmText: {
      type: String,
      default: '跳过'
    },
    confirmDisabled: {
      type: Boolean,
      default: false
    },
    prelearnData: {
      type: Object,
      default: () => ({})
    }
  },
  computed: {
    displayCourseList() {
      return this.prelearnData?.packages || []
    }
  },
  methods: {
    formatIncludes(includes) {
      if (!includes?.length) return ''
      return `包含:${includes.join(' + ')}`
    },
    handleStartStudy(item, index) {
      if (item.learnStatus !== 'NOT_STUDY') return

      this.$emit('start-study', item, index)
      console.log('预学习桥接页跳转***', item);
      console.log('预学习桥接页跳转***', this.prelearnData);
      this.prelearnData.activityProductId = item.activityProductId
      const prelearnDataStr = encodeURIComponent(JSON.stringify(this.prelearnData))
      uni.navigateTo({
        url: `/pages/common/prelearnBridge?prelearnData=${prelearnDataStr}&entrySource=home_popup`,
        fail: (err) => {
          console.error('预学习桥接页跳转失败:', err)
        }
      })
    },
    handleCancel() {
      this.$emit('cancel')
    },
    handleConfirm() {
      if (this.confirmDisabled) return
      this.$emit('confirm')
    }
  }
}
</script>

<style lang="scss" scoped>
.exam-submit-popup-wrapper {
  position: relative;
  width: 100%;
  min-height: toRpx(400);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: toRpx(48);
}

.content-box {
  width: toRpx(720);
  box-sizing: border-box;
}

.course-list {
  width: 100%;
  height: toRpx(440);
  box-sizing: border-box;
}

.course-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: toRpx(16);
  width: 100%;
  padding: toRpx(16);
  border-radius: toRpx(16);
  border: toRpx(2) solid #e4e9f7;
  background: #f5f7fa;
  box-sizing: border-box;
  margin-bottom: toRpx(48);
}

.course-item-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: toRpx(16);
}

.course-item-title-text {
  width: 100%;
  color: #333333;
  font-size: toRpx(40);
  font-weight: 500;
  font-family: "HarmonyOSSansSC";
  line-height: toRpx(60);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-item-desc {
  display: block;
  width: 100%;
  min-width: 0;
  color: #999999;
  font-size: toRpx(28);
  font-weight: 400;
  font-family: "HarmonyOSSansSC";
  line-height: toRpx(48);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-item-btn {
  flex-shrink: 0;
  height: toRpx(56);
  padding: 0 toRpx(16);
  border-radius: toRpx(8);
  border: toRpx(2) solid rgba(44, 102, 247, 0.1);
  background: #2c66f7;
  color: #ffffff;
  font-size: toRpx(26);
  font-weight: 400;
  font-family: "HarmonyOSSansSC";
  line-height: toRpx(56);
  text-align: center;
  white-space: nowrap;

  &--learned {
    display: flex;
    align-items: center;
    gap: toRpx(8);
    border: 1px solid rgba(44, 102, 247, 0.10);
    background: rgba(44, 102, 247, 0.05);
    color: #2c66f7;
  }
}

.course-item-btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.button-group {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: toRpx(16);
  margin-top: toRpx(8);
}

.confirm-button {
  width: 100%;
  height: toRpx(80);
  margin: 0 auto;
  padding: 0 toRpx(24);
  box-sizing: border-box;
  border-radius: toRpx(48);
  border: toRpx(2) solid #979797;
  background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
  color: #ffffff;
  font-size: toRpx(28);
  font-weight: 500;
  font-family: "HarmonyOSSansSC";
  text-align: center;
  line-height: toRpx(80);

  &:active {
    opacity: 0.8;
  }

  &--disabled {
    border-color: #d9d9d9;
    background-image: linear-gradient(0deg, #2c66f799 0%, #48a6ff99 100%);
    color: #ffffff;
    pointer-events: none;

    &:active {
      opacity: 1;
    }
  }
}
</style>