PreBackPopup.vue 3.21 KB
<template>
  <view class="exam-submit-popup-wrapper">
    <view class="content-box">
        <view class="text-box">
            退出将消耗 <text class="text-red">1</text> 次跳过机会
        </view>
        <view class="sub-text">
            剩余次数 <text class="text-red">{{ prelearnContext.skipCount }}</text> 次,是否确认退出?
        </view>
    </view>
    <view class="button-group">
      <view class="cancel-button" @click="handleCancel">
        取消
      </view>
      <view
        class="confirm-button"
        :class="{ 'confirm-button--disabled': confirmDisabled }"
        @click="deductSkipCount"
      >
        {{ confirmText }}
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'ExamSubmitPopup',
  props: {
    confirmText: {
      type: String,
      default: '确认'
    },
    prelearnContext: {
      type: Object,
      default: () => ({skipCount:0})
    }
  },
  computed: {
    confirmDisabled() {
      return this.prelearnContext?.skipCount === 0
    }
  },
  methods: {
    handleCancel() {
      this.$emit('cancel')
    },
    async deductSkipCount() {
      if (this.confirmDisabled) return
      let requestParams = {
        activityId:this.prelearnContext.activityId
      }
      console.log('deductSkipCountAPI requestParams***', requestParams);
      const res = await uni.$api.commonApi.deductSkipCountAPI(requestParams)
      console.log('deductSkipCountAPI***', res);
      if (res) {
        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);
  height: toRpx(156);
  border-radius: toRpx(16);
  background: #FDECE9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: toRpx(24);
}

.text-box {
  font-size: toRpx(40);
  color: #333;
  text-align: center;
  font-weight: 500;
  line-height: toRpx(60);
}

.sub-text {
  color: #999;
  text-align: center;
  font-size: toRpx(28);
  font-style: normal;
  font-weight: 400;
  line-height: toRpx(48);
}

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

.cancel-button {
  width: toRpx(344);
  height: toRpx(80);
  border-radius: toRpx(64);
  background: #f0f1f5;
  color: #1a1a1a;
  font-size: toRpx(28);
  font-weight: 400;
  font-family: "HarmonyOSSansSC";
  text-align: center;
  line-height: toRpx(80);
}

.confirm-button {
  width: toRpx(360);
  height: toRpx(80);
  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;
    }
  }
}
.text-red {
    color: #F24724;
}
</style>