question-setting.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <uv-popup ref="popup" mode="bottom" round="16" :close-on-click-overlay="false">
  3. <view class="py-23 bg-white rounded-16 overflow-hidden">
  4. <view class="flex items-center justify-between">
  5. <view class="px-46 py-20 text-28 text-fore-light" @click="handleCancel">取消</view>
  6. <text class="text-30 text-fore-title font-bold">题库练习</text>
  7. <view class="px-46 py-20 text-28 text-fore-title" @click="handleConfirm">确认</view>
  8. </view>
  9. <view class="pt-50 px-42 py-20 pb-100">
  10. <view class="mt-30 px-20 h-104 rounded-10 bg-back flex items-center">
  11. <text class="ml-20 flex-1 text-26 text-fore-title">计划每日答题</text>
  12. <input type="number" class="w-134 h-72 bg-white rounded-4 text-center px-10" v-model.number="questionCount" />
  13. <text class="ml-20 text-26 text-fore-title">道题</text>
  14. </view>
  15. <view class="mt-20 flex gap-x-20">
  16. <view class="flex-1 py-20 text-center rounded-6 text-28 text-fore-subcontnt"
  17. :class="questionCount === item ? 'bg-[#E5F7FF] text-primary' : 'bg-back'" v-for="item in quickOptions"
  18. @click="questionCount = item">{{ item }}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </uv-popup>
  23. </template>
  24. <script lang="ts" setup>
  25. const quickOptions = ref([90, 120, 150, 300, 450]);
  26. const questionCount = ref();
  27. const popup = ref();
  28. const globalCallback = ref();
  29. const handleCancel = () => {
  30. close();
  31. }
  32. const handleConfirm = () => {
  33. if (questionCount.value < 1) {
  34. uni.$ie.showToast('请输入合理的题数');
  35. return;
  36. }
  37. globalCallback.value(questionCount.value || 0);
  38. close();
  39. }
  40. const open = (time: number, callback: (time: number) => void) => {
  41. globalCallback.value = callback;
  42. questionCount.value = time || '';
  43. popup.value.open();
  44. }
  45. const close = () => {
  46. popup.value.close();
  47. }
  48. defineExpose({ open, close });
  49. </script>
  50. <style lang="scss" scoped></style>