study-plan-edit.vue 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <ie-page bg-color="#F6F8FA">
  3. <ie-navbar title="定制学习计划" />
  4. <view class="mt-16 bg-white py-30">
  5. <view class="mx-40 text-32 text-fore-title font-bold">每日学习计划</view>
  6. <view class="mt-20">
  7. <uv-cell-group :border="false">
  8. <uv-cell isLink value="去设置" :border="false" :cellStyle="cellStyle" :rightIconStyle="rightIconStyle"
  9. @click="handleCourseStudySetting">
  10. <template #title>
  11. <text class="text-30 text-fore-subtitle">课程学习</text>
  12. </template>
  13. <template #value>
  14. <text v-if="form.videoTime" class="mr-10 text-30 text-fore-title">{{ form.videoTime }}课时</text>
  15. <text v-else class="mr-10 text-30 text-fore-placeholder">去设置</text>
  16. </template>
  17. </uv-cell>
  18. <uv-cell isLink value="去设置" :border="false" :cellStyle="cellStyle" :rightIconStyle="rightIconStyle"
  19. @click="handleQuestionStudySetting">
  20. <template #title>
  21. <text class="text-30 text-fore-subtitle">题库练习</text>
  22. </template>
  23. <template #value>
  24. <text v-if="form.questionCnt" class="mr-10 text-30 text-fore-title">{{ form.questionCnt }}题</text>
  25. <text v-else class="mr-10 text-30 text-fore-placeholder">去设置</text>
  26. </template>
  27. </uv-cell>
  28. </uv-cell-group>
  29. </view>
  30. </view>
  31. <ie-safe-toolbar :height="84" :shadow="false">
  32. <view class="px-46 pt-24">
  33. <ie-button type="primary" @click="handleConfirm">确认保存</ie-button>
  34. </view>
  35. </ie-safe-toolbar>
  36. <course-setting ref="courseStudySetting" />
  37. <question-setting ref="questionStudySetting" />
  38. </ie-page>
  39. </template>
  40. <script lang="ts" setup>
  41. import { StudyPlan } from '@/types/study';
  42. import CourseSetting from './components/course-setting.vue';
  43. import QuestionSetting from './components/question-setting.vue';
  44. import { saveStudyPlan } from '@/api/modules/study';
  45. import { useTransferPage } from '@/hooks/useTransferPage';
  46. const { prevData } = useTransferPage();
  47. const cellStyle = {
  48. padding: '30rpx 40rpx'
  49. }
  50. const rightIconStyle = {
  51. fontSize: '14px'
  52. }
  53. const form = ref({
  54. questionCnt: 0,
  55. videoTime: 0
  56. })
  57. const courseStudySetting = ref();
  58. const questionStudySetting = ref();
  59. const handleCourseStudySetting = () => {
  60. courseStudySetting.value.open(form.value.videoTime, (time: number) => {
  61. form.value.videoTime = time;
  62. });
  63. }
  64. const handleQuestionStudySetting = () => {
  65. questionStudySetting.value.open(form.value.questionCnt, (time: number) => {
  66. form.value.questionCnt = time;
  67. });
  68. }
  69. const handleConfirm = async () => {
  70. const { questionCnt, videoTime } = form.value;
  71. if (!questionCnt) {
  72. uni.$ie.showToast('请设置题库练习计划');
  73. return;
  74. }
  75. uni.$ie.showLoading();
  76. await saveStudyPlan(form.value);
  77. uni.$ie.hideLoading();
  78. uni.$ie.showToast('保存成功');
  79. setTimeout(() => {
  80. uni.navigateBack();
  81. }, 800);
  82. }
  83. onLoad(() => {
  84. form.value = {
  85. ...prevData.value,
  86. questionCnt: prevData.value.questionCnt || 0,
  87. videoTime: prevData.value.videoTime || 0
  88. }
  89. });
  90. </script>
  91. <style lang="scss" scoped></style>