course-setting.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 pt-20">
  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="px-20 h-104 rounded-10 bg-back flex items-center" @click="selected = 0">
  11. <ie-image :src="selected === 0 ? iconCheckActive : iconCheck" custom-class="w-32 h-32" mode="aspectFill" />
  12. <text class="ml-20 text-26 text-fore-title">暂无学习计划</text>
  13. </view>
  14. <view class="mt-30 px-20 h-104 rounded-10 bg-back flex items-center" @click="selected = 1">
  15. <ie-image :src="selected === 1 ? iconCheckActive : iconCheck" custom-class="w-32 h-32" mode="aspectFill" />
  16. <text class="ml-20 flex-1 text-26 text-fore-title">每日计划学习</text>
  17. <input type="number" class="w-134 h-72 bg-white rounded-4 text-center px-10" v-model="courseTime" />
  18. <text class="ml-20 text-26 text-fore-title">课时</text>
  19. </view>
  20. </view>
  21. </view>
  22. </uv-popup>
  23. </template>
  24. <script lang="ts" setup>
  25. import iconCheck from '@/pagesStudy/static/image/icon-check.png';
  26. import iconCheckActive from '@/pagesStudy/static/image/icon-check-active.png';
  27. const selected = ref(0);
  28. const courseTime = ref();
  29. const popup = ref();
  30. const globalCallback = ref();
  31. const handleCancel = () => {
  32. close();
  33. }
  34. const handleConfirm = () => {
  35. if (selected.value === 1 && courseTime.value < 1) {
  36. uni.$ie.showToast('请输入合理的课时');
  37. return;
  38. }
  39. globalCallback.value(courseTime.value || 0);
  40. close();
  41. }
  42. const open = (time: number, callback: (time: number) => void) => {
  43. globalCallback.value = callback;
  44. courseTime.value = time || '';
  45. selected.value = time ? 1 : 0;
  46. popup.value.open();
  47. }
  48. const close = () => {
  49. popup.value.close();
  50. }
  51. defineExpose({ open, close });
  52. </script>
  53. <style lang="scss" scoped></style>