Showing
7 changed files
with
240 additions
and
172 deletions
| @@ -5,27 +5,35 @@ | @@ -5,27 +5,35 @@ | ||
| 5 | <uv-input v-model="state.studentInfo.name" shape="circle" placeholder="请输入学生真实姓名"> | 5 | <uv-input v-model="state.studentInfo.name" shape="circle" placeholder="请输入学生真实姓名"> |
| 6 | </uv-input> | 6 | </uv-input> |
| 7 | </uv-form-item> | 7 | </uv-form-item> |
| 8 | - <uv-form-item prop="sex"> | 8 | + <uv-form-item prop="sex"> |
| 9 | <view style="display: flex;justify-content: space-around;width: 100%;"> | 9 | <view style="display: flex;justify-content: space-around;width: 100%;"> |
| 10 | - <view @click="state.studentInfo.sex = 0" class="select-item" :style="state.studentInfo.sex === 0 ? 'border-color:#6b75f6;' : ''"> | 10 | + <view @click="state.studentInfo.sex = 0" class="select-item" |
| 11 | + :style="state.studentInfo.sex === 0 ? 'border-color:#6b75f6;' : ''"> | ||
| 11 | <uv-icon name="man" color="#7175f0" size="16" style="margin-right: 10rpx;"></uv-icon>男 | 12 | <uv-icon name="man" color="#7175f0" size="16" style="margin-right: 10rpx;"></uv-icon>男 |
| 12 | </view> | 13 | </view> |
| 13 | - <view @click="state.studentInfo.sex = 1" class="select-item" :style="state.studentInfo.sex === 1 ? 'border-color:#6b75f6;' : ''"> | 14 | + <view @click="state.studentInfo.sex = 1" class="select-item" |
| 15 | + :style="state.studentInfo.sex === 1 ? 'border-color:#6b75f6;' : ''"> | ||
| 14 | <uv-icon name="woman" color="#ff5d5c" size="16" style="margin-right: 10rpx;"></uv-icon>女 | 16 | <uv-icon name="woman" color="#ff5d5c" size="16" style="margin-right: 10rpx;"></uv-icon>女 |
| 15 | </view> | 17 | </view> |
| 16 | - <view @click="state.studentInfo.sex = 2" class="select-item" :style="state.studentInfo.sex === 2 ? 'border-color:#6b75f6;' : ''"> | 18 | + <view @click="state.studentInfo.sex = 2" class="select-item" |
| 19 | + :style="state.studentInfo.sex === 2 ? 'border-color:#6b75f6;' : ''"> | ||
| 17 | <uv-icon name="lock" color="#7175f0" size="16" style="margin-right: 10rpx;"></uv-icon>保密 | 20 | <uv-icon name="lock" color="#7175f0" size="16" style="margin-right: 10rpx;"></uv-icon>保密 |
| 18 | </view> | 21 | </view> |
| 19 | </view> | 22 | </view> |
| 20 | </uv-form-item> | 23 | </uv-form-item> |
| 21 | <uv-form-item prop="city"> | 24 | <uv-form-item prop="city"> |
| 22 | - <uv-input v-model="state.studentInfo.city" shape="circle" placeholder="请输入学生所在城市" /> | 25 | + <uv-input v-model="state.studentInfo.city" shape="circle" placeholder="请输入学生所在城市" /> |
| 23 | </uv-form-item> | 26 | </uv-form-item> |
| 24 | <uv-form-item prop="school"> | 27 | <uv-form-item prop="school"> |
| 25 | <uv-input v-model="state.studentInfo.school" shape="circle" placeholder="请输入学生在读学校" /> | 28 | <uv-input v-model="state.studentInfo.school" shape="circle" placeholder="请输入学生在读学校" /> |
| 26 | </uv-form-item> | 29 | </uv-form-item> |
| 27 | - <uv-form-item prop="grade"> | ||
| 28 | - <uv-input v-model="state.studentInfo.grade" shape="circle" placeholder="请输入学生在读年级" /> | 30 | + <uv-form-item prop="grade" @click="showSelect"> |
| 31 | + <uv-input v-model="state.studentInfo.grade" disabled disabledColor="#ffffff" shape="circle" | ||
| 32 | + placeholder="请选择学生在读年级"> | ||
| 33 | + <template v-slot:suffix> | ||
| 34 | + <uv-icon name="arrow-down" color="#6b75f6" size="14"></uv-icon> | ||
| 35 | + </template> | ||
| 36 | + </uv-input> | ||
| 29 | </uv-form-item> | 37 | </uv-form-item> |
| 30 | <uv-form-item> | 38 | <uv-form-item> |
| 31 | <view @click="submit" | 39 | <view @click="submit" |
| @@ -34,6 +42,8 @@ | @@ -34,6 +42,8 @@ | ||
| 34 | </view> | 42 | </view> |
| 35 | </uv-form-item> | 43 | </uv-form-item> |
| 36 | </uv-form> | 44 | </uv-form> |
| 45 | + | ||
| 46 | + <uv-picker ref="pickerRef" :columns="state.columns" @confirm="confirm"></uv-picker> | ||
| 37 | </view> | 47 | </view> |
| 38 | </template> | 48 | </template> |
| 39 | 49 | ||
| @@ -41,10 +51,13 @@ | @@ -41,10 +51,13 @@ | ||
| 41 | import { | 51 | import { |
| 42 | reactive, | 52 | reactive, |
| 43 | ref | 53 | ref |
| 44 | - } from "vue" | ||
| 45 | - import { addStudentsApi } from "@/api/index.js" | 54 | + } from "vue" |
| 55 | + import { | ||
| 56 | + addStudentsApi | ||
| 57 | + } from "@/api/index.js" | ||
| 46 | 58 | ||
| 47 | const formRef = ref(null) | 59 | const formRef = ref(null) |
| 60 | + const pickerRef = ref(null) | ||
| 48 | 61 | ||
| 49 | const state = reactive({ | 62 | const state = reactive({ |
| 50 | studentInfo: { | 63 | studentInfo: { |
| @@ -54,6 +67,9 @@ | @@ -54,6 +67,9 @@ | ||
| 54 | school: "", | 67 | school: "", |
| 55 | grade: "" | 68 | grade: "" |
| 56 | }, | 69 | }, |
| 70 | + columns: [ | ||
| 71 | + ["一年级", "二年级", "三年级", "四年级", "五年级", "六年级", "初一", "初二", "初三", "高一", "高二", "高三"] | ||
| 72 | + ], | ||
| 57 | rules: { | 73 | rules: { |
| 58 | 'name': { | 74 | 'name': { |
| 59 | type: 'string', | 75 | type: 'string', |
| @@ -66,47 +82,55 @@ | @@ -66,47 +82,55 @@ | ||
| 66 | required: true, | 82 | required: true, |
| 67 | message: '请选择性别', | 83 | message: '请选择性别', |
| 68 | trigger: ['blur', 'change'] | 84 | trigger: ['blur', 'change'] |
| 69 | - }, | ||
| 70 | - 'city': { | ||
| 71 | - type: 'string', | ||
| 72 | - required: true, | ||
| 73 | - message: '请输入学生所在城市', | ||
| 74 | - trigger: ['blur', 'change'] | ||
| 75 | - }, | ||
| 76 | - 'school': { | ||
| 77 | - type: 'string', | ||
| 78 | - required: true, | ||
| 79 | - message: '请输入学生在读学校', | ||
| 80 | - trigger: ['blur', 'change'] | ||
| 81 | - }, | ||
| 82 | - 'grade': { | ||
| 83 | - type: 'string', | ||
| 84 | - required: true, | ||
| 85 | - message: '请输入学生在读年级', | ||
| 86 | - trigger: ['blur', 'change'] | 85 | + }, |
| 86 | + 'city': { | ||
| 87 | + type: 'string', | ||
| 88 | + required: true, | ||
| 89 | + message: '请输入学生所在城市', | ||
| 90 | + trigger: ['blur', 'change'] | ||
| 91 | + }, | ||
| 92 | + 'school': { | ||
| 93 | + type: 'string', | ||
| 94 | + required: true, | ||
| 95 | + message: '请输入学生在读学校', | ||
| 96 | + trigger: ['blur', 'change'] | ||
| 97 | + }, | ||
| 98 | + 'grade': { | ||
| 99 | + type: 'string', | ||
| 100 | + required: true, | ||
| 101 | + message: '请选择学生在读年级', | ||
| 102 | + trigger: ['blur', 'change'] | ||
| 87 | }, | 103 | }, |
| 88 | } | 104 | } |
| 89 | }) | 105 | }) |
| 90 | 106 | ||
| 107 | + const showSelect = () => { | ||
| 108 | + pickerRef.value.open() | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + const confirm = e => { | ||
| 112 | + state.studentInfo.grade = e.value[0] | ||
| 113 | + } | ||
| 114 | + | ||
| 91 | const submit = async () => { | 115 | const submit = async () => { |
| 92 | - try { | ||
| 93 | - await formRef.value.validate() | ||
| 94 | - | ||
| 95 | - uni.showLoading({ | ||
| 96 | - title: "提交中", | ||
| 97 | - mask: true | 116 | + try { |
| 117 | + await formRef.value.validate() | ||
| 118 | + | ||
| 119 | + uni.showLoading({ | ||
| 120 | + title: "提交中", | ||
| 121 | + mask: true | ||
| 122 | + }) | ||
| 123 | + | ||
| 124 | + const res = await addStudentsApi(state.studentInfo) | ||
| 125 | + uni.hideLoading() | ||
| 126 | + uni.showToast({ | ||
| 127 | + icon: 'success', | ||
| 128 | + title: '添加成功' | ||
| 98 | }) | 129 | }) |
| 99 | - | ||
| 100 | - const res = await addStudentsApi(state.studentInfo) | ||
| 101 | - uni.hideLoading() | ||
| 102 | - uni.showToast({ | ||
| 103 | - icon: 'success', | ||
| 104 | - title: '添加成功' | ||
| 105 | - }) | ||
| 106 | - formRef.value.resetFields() | 130 | + formRef.value.resetFields() |
| 107 | uni.navigateBack() | 131 | uni.navigateBack() |
| 108 | - } finally { | ||
| 109 | - uni.hideLoading() | 132 | + } finally { |
| 133 | + uni.hideLoading() | ||
| 110 | } | 134 | } |
| 111 | } | 135 | } |
| 112 | </script> | 136 | </script> |
| @@ -135,7 +159,7 @@ | @@ -135,7 +159,7 @@ | ||
| 135 | justify-content: center; | 159 | justify-content: center; |
| 136 | align-items: center; | 160 | align-items: center; |
| 137 | padding: 10rpx 0; | 161 | padding: 10rpx 0; |
| 138 | - border-radius: 9999rpx; | 162 | + border-radius: 9999rpx; |
| 139 | border: 3rpx solid #e8ecfd; | 163 | border: 3rpx solid #e8ecfd; |
| 140 | } | 164 | } |
| 141 | </style> | 165 | </style> |
| @@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
| 3 | <uv-navbar leftIcon="" placeholder bgColor="rgba(255, 255, 255, 0)"> | 3 | <uv-navbar leftIcon="" placeholder bgColor="rgba(255, 255, 255, 0)"> |
| 4 | <template v-slot:left> | 4 | <template v-slot:left> |
| 5 | <view class="uv-nav-slot"> | 5 | <view class="uv-nav-slot"> |
| 6 | - XXXX | ||
| 7 | </view> | 6 | </view> |
| 8 | </template> | 7 | </template> |
| 9 | </uv-navbar> | 8 | </uv-navbar> |
| @@ -15,34 +14,38 @@ | @@ -15,34 +14,38 @@ | ||
| 15 | style="margin-left: 6rpx;"></uv-icon> | 14 | style="margin-left: 6rpx;"></uv-icon> |
| 16 | </view> | 15 | </view> |
| 17 | <view @click="showAccountsPop" class="select-item"> | 16 | <view @click="showAccountsPop" class="select-item"> |
| 18 | - {{ state.accounts }}<uv-icon name="arrow-down-fill" color="#7175f0" size="20" style="margin-left: 6rpx;"></uv-icon> | 17 | + {{ state.accounts }}<uv-icon name="arrow-down-fill" color="#7175f0" size="20" |
| 18 | + style="margin-left: 6rpx;"></uv-icon> | ||
| 19 | + </view> | ||
| 20 | + </view> | ||
| 21 | + | ||
| 22 | + <view class="course-list"> | ||
| 23 | + <view v-for="item in state.courses" class="course-box"> | ||
| 24 | + <image :src="item.img" style="width: 160rpx;height: 160rpx;border-radius: 20rpx;"></image> | ||
| 25 | + <view style="flex: 1;display: flex;"> | ||
| 26 | + <view | ||
| 27 | + style="flex: 1;padding: 0 20rpx;display: flex;flex-direction: column;justify-content: space-between;"> | ||
| 28 | + <view style="font-size: 30rpx;">{{ item.name }} - {{ item.subject }}</view> | ||
| 29 | + <view style="color: #ff3838;font-weight: 600;">¥{{ item.price }}</view> | ||
| 30 | + </view> | ||
| 31 | + <view style="width: 160rpx;display: flex;align-items: center;justify-content: flex-end;"> | ||
| 32 | + <view @click="gotoSignUp(item.id)" | ||
| 33 | + style="width: 100%;;background-color: #f57c28;color: #fff;text-align: center;padding: 10rpx 0;border-radius: 9999rpx;"> | ||
| 34 | + 去报名 | ||
| 35 | + </view> | ||
| 36 | + </view> | ||
| 37 | + </view> | ||
| 19 | </view> | 38 | </view> |
| 20 | - </view> | ||
| 21 | - | ||
| 22 | - <view class="course-list"> | ||
| 23 | - <view v-for="item in state.courses" class="course-box"> | ||
| 24 | - <image :src="item.img" style="width: 160rpx;height: 160rpx;border-radius: 20rpx;"></image> | ||
| 25 | - <view style="flex: 1;display: flex;"> | ||
| 26 | - <view style="flex: 1;padding: 0 20rpx;display: flex;flex-direction: column;justify-content: space-between;"> | ||
| 27 | - <view style="font-size: 30rpx;">{{ item.name }} - {{ item.subject }}</view> | ||
| 28 | - <view style="color: #ff3838;font-weight: 600;">¥{{ item.price }}</view> | ||
| 29 | - </view> | ||
| 30 | - <view style="width: 160rpx;display: flex;align-items: center;justify-content: flex-end;"> | ||
| 31 | - <view @click="gotoSignUp(item.id)" style="width: 100%;;background-color: #f57c28;color: #fff;text-align: center;padding: 10rpx 0;border-radius: 9999rpx;"> | ||
| 32 | - 去报名 | ||
| 33 | - </view> | ||
| 34 | - </view> | ||
| 35 | - </view> | ||
| 36 | - </view> | ||
| 37 | </view> | 39 | </view> |
| 38 | </view> | 40 | </view> |
| 39 | 41 | ||
| 40 | <!-- 年级弹窗 --> | 42 | <!-- 年级弹窗 --> |
| 41 | <uv-popup ref="gradesRef" safeAreaInsetBottom closeable :round="20"> | 43 | <uv-popup ref="gradesRef" safeAreaInsetBottom closeable :round="20"> |
| 42 | <view class="pop-box"> | 44 | <view class="pop-box"> |
| 43 | - <view class="content-pop"> | ||
| 44 | - <view @click="selectGrade('全部年级')" class="pop-inner-item" style="margin: 20rpx 0;" :style="state.grade === '全部年级' ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''"> | ||
| 45 | - 全部年级 | 45 | + <view class="content-pop"> |
| 46 | + <view @click="selectGrade('全部年级')" class="pop-inner-item" style="margin: 20rpx 0;" | ||
| 47 | + :style="state.grade === '全部年级' ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''"> | ||
| 48 | + 全部年级 | ||
| 46 | </view> | 49 | </view> |
| 47 | <view v-for="item in state.gradOptions" style="margin-bottom: 30rpx;"> | 50 | <view v-for="item in state.gradOptions" style="margin-bottom: 30rpx;"> |
| 48 | <view class="pop-title"> | 51 | <view class="pop-title"> |
| @@ -62,15 +65,17 @@ | @@ -62,15 +65,17 @@ | ||
| 62 | <!-- 科目弹窗 --> | 65 | <!-- 科目弹窗 --> |
| 63 | <uv-popup ref="accountsRef" safeAreaInsetBottom closeable :round="20"> | 66 | <uv-popup ref="accountsRef" safeAreaInsetBottom closeable :round="20"> |
| 64 | <view class="pop-box"> | 67 | <view class="pop-box"> |
| 65 | - <view class="content-pop"> | ||
| 66 | - <view @click="selectaccounts('全部科目')" class="pop-inner-item" style="margin: 20rpx 0;" :style="state.accounts === '全部科目' ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''"> | ||
| 67 | - 全部科目 | ||
| 68 | - </view> | ||
| 69 | - <view class="pop-inner"> | ||
| 70 | - <view v-for="item1 in state.accountsOptions" @click="selectaccounts(item1)" class="pop-inner-item" | ||
| 71 | - :style="state.accounts === item1 ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''"> | ||
| 72 | - {{ item1 }} | ||
| 73 | - </view> | 68 | + <view class="content-pop"> |
| 69 | + <view @click="selectaccounts('全部科目')" class="pop-inner-item" style="margin: 20rpx 0;" | ||
| 70 | + :style="state.accounts === '全部科目' ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''"> | ||
| 71 | + 全部科目 | ||
| 72 | + </view> | ||
| 73 | + <view class="pop-inner"> | ||
| 74 | + <view v-for="item1 in state.accountsOptions" @click="selectaccounts(item1)" | ||
| 75 | + class="pop-inner-item" | ||
| 76 | + :style="state.accounts === item1 ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''"> | ||
| 77 | + {{ item1 }} | ||
| 78 | + </view> | ||
| 74 | </view> | 79 | </view> |
| 75 | </view> | 80 | </view> |
| 76 | </view> | 81 | </view> |
| @@ -81,18 +86,22 @@ | @@ -81,18 +86,22 @@ | ||
| 81 | <script setup> | 86 | <script setup> |
| 82 | import { | 87 | import { |
| 83 | reactive, | 88 | reactive, |
| 84 | - ref, | ||
| 85 | - onMounted | ||
| 86 | - } from 'vue'; | ||
| 87 | - import { courseListApi } from "@/api/index.js" | 89 | + ref |
| 90 | + } from 'vue'; | ||
| 91 | + import { | ||
| 92 | + onShow | ||
| 93 | + } from '@dcloudio/uni-app' | ||
| 94 | + import { | ||
| 95 | + courseListApi | ||
| 96 | + } from "@/api/index.js" | ||
| 88 | 97 | ||
| 89 | const gradesRef = ref(null) | 98 | const gradesRef = ref(null) |
| 90 | const accountsRef = ref(null) | 99 | const accountsRef = ref(null) |
| 91 | 100 | ||
| 92 | const state = reactive({ | 101 | const state = reactive({ |
| 93 | - grade: "全部年级", | ||
| 94 | - accounts: "全部科目", | ||
| 95 | - courses: [], | 102 | + grade: "全部年级", |
| 103 | + accounts: "全部科目", | ||
| 104 | + courses: [], | ||
| 96 | subject: [], | 105 | subject: [], |
| 97 | gradOptions: [{ | 106 | gradOptions: [{ |
| 98 | title: "小学", | 107 | title: "小学", |
| @@ -106,31 +115,35 @@ | @@ -106,31 +115,35 @@ | ||
| 106 | title: "高中", | 115 | title: "高中", |
| 107 | content: ["高一", "高二", "高三"] | 116 | content: ["高一", "高二", "高三"] |
| 108 | } | 117 | } |
| 109 | - ], | 118 | + ], |
| 110 | accountsOptions: ["语文", "数学", "英语", "物理", "化学"] | 119 | accountsOptions: ["语文", "数学", "英语", "物理", "化学"] |
| 111 | - }) | ||
| 112 | - | ||
| 113 | - onMounted(() => { | ||
| 114 | - getCourseList() | ||
| 115 | - }) | ||
| 116 | - | ||
| 117 | - const gotoSignUp = id => { | ||
| 118 | - uni.navigateTo({ | ||
| 119 | - url: `/pages/signUp/signUp?id=${id}` | ||
| 120 | - }) | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - const getCourseList = async () => { | ||
| 124 | - try { | ||
| 125 | - uni.showLoading({ title: "加载中" }) | ||
| 126 | - const { data } = await courseListApi({ | ||
| 127 | - grade: state.grade === "全部年级" ? "" : state.grade, | ||
| 128 | - subject: state.accounts === "全部科目" ? "" : state.accounts | ||
| 129 | - }) | ||
| 130 | - state.courses = data.courses | ||
| 131 | - } finally { | ||
| 132 | - uni.hideLoading() | ||
| 133 | - } | 120 | + }) |
| 121 | + | ||
| 122 | + onShow(() => { | ||
| 123 | + getCourseList() | ||
| 124 | + }) | ||
| 125 | + | ||
| 126 | + const gotoSignUp = id => { | ||
| 127 | + uni.navigateTo({ | ||
| 128 | + url: `/pages/signUp/signUp?id=${id}` | ||
| 129 | + }) | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + const getCourseList = async () => { | ||
| 133 | + try { | ||
| 134 | + uni.showLoading({ | ||
| 135 | + title: "加载中" | ||
| 136 | + }) | ||
| 137 | + const { | ||
| 138 | + data | ||
| 139 | + } = await courseListApi({ | ||
| 140 | + grade: state.grade === "全部年级" ? "" : state.grade, | ||
| 141 | + subject: state.accounts === "全部科目" ? "" : state.accounts | ||
| 142 | + }) | ||
| 143 | + state.courses = data.courses | ||
| 144 | + } finally { | ||
| 145 | + uni.hideLoading() | ||
| 146 | + } | ||
| 134 | } | 147 | } |
| 135 | 148 | ||
| 136 | const showGradesPop = () => { | 149 | const showGradesPop = () => { |
| @@ -139,18 +152,18 @@ | @@ -139,18 +152,18 @@ | ||
| 139 | 152 | ||
| 140 | const showAccountsPop = () => { | 153 | const showAccountsPop = () => { |
| 141 | accountsRef.value.open('bottom') | 154 | accountsRef.value.open('bottom') |
| 142 | - } | ||
| 143 | - | ||
| 144 | - const selectGrade = item => { | ||
| 145 | - state.grade = item | ||
| 146 | - gradesRef.value.close() | ||
| 147 | - getCourseList() | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - const selectaccounts = item => { | ||
| 151 | - state.accounts = item | ||
| 152 | - accountsRef.value.close() | ||
| 153 | - getCourseList() | 155 | + } |
| 156 | + | ||
| 157 | + const selectGrade = item => { | ||
| 158 | + state.grade = item | ||
| 159 | + gradesRef.value.close() | ||
| 160 | + getCourseList() | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + const selectaccounts = item => { | ||
| 164 | + state.accounts = item | ||
| 165 | + accountsRef.value.close() | ||
| 166 | + getCourseList() | ||
| 154 | } | 167 | } |
| 155 | </script> | 168 | </script> |
| 156 | 169 | ||
| @@ -166,21 +179,22 @@ | @@ -166,21 +179,22 @@ | ||
| 166 | .content-box { | 179 | .content-box { |
| 167 | flex: 1; | 180 | flex: 1; |
| 168 | overflow-y: auto; | 181 | overflow-y: auto; |
| 169 | - padding: 0 24rpx; | ||
| 170 | - display: flex; | ||
| 171 | - flex-direction: column; | ||
| 172 | - | ||
| 173 | - .course-list { | ||
| 174 | - margin-top: 20rpx; | ||
| 175 | - flex: 1; | ||
| 176 | - .course-box { | ||
| 177 | - display: flex; | ||
| 178 | - justify-content: space-between; | ||
| 179 | - margin-bottom: 30rpx; | ||
| 180 | - background-color: #fff; | ||
| 181 | - padding: 20rpx; | ||
| 182 | - border-radius: 20rpx; | ||
| 183 | - } | 182 | + padding: 0 24rpx; |
| 183 | + display: flex; | ||
| 184 | + flex-direction: column; | ||
| 185 | + | ||
| 186 | + .course-list { | ||
| 187 | + margin-top: 20rpx; | ||
| 188 | + flex: 1; | ||
| 189 | + | ||
| 190 | + .course-box { | ||
| 191 | + display: flex; | ||
| 192 | + justify-content: space-between; | ||
| 193 | + margin-bottom: 30rpx; | ||
| 194 | + background-color: #fff; | ||
| 195 | + padding: 20rpx; | ||
| 196 | + border-radius: 20rpx; | ||
| 197 | + } | ||
| 184 | } | 198 | } |
| 185 | } | 199 | } |
| 186 | 200 |
| 1 | <template> | 1 | <template> |
| 2 | <view class="container"> | 2 | <view class="container"> |
| 3 | + <uv-navbar leftIcon="" placeholder bgColor="rgba(255, 255, 255, 0)"> | ||
| 4 | + <template v-slot:center> | ||
| 5 | + <view class="uv-nav-slot"> | ||
| 6 | + 登录 | ||
| 7 | + </view> | ||
| 8 | + </template> | ||
| 9 | + </uv-navbar> | ||
| 3 | <view class="input-box"> | 10 | <view class="input-box"> |
| 4 | <uv-form labelPosition="left" :model="state.userInfo" :rules="state.rules" labelWidth="60" ref="formRef" | 11 | <uv-form labelPosition="left" :model="state.userInfo" :rules="state.rules" labelWidth="60" ref="formRef" |
| 5 | :labelStyle="{ fontSize: '28rpx' }"> | 12 | :labelStyle="{ fontSize: '28rpx' }"> |
| 6 | <view style="margin-bottom: 60rpx;"> | 13 | <view style="margin-bottom: 60rpx;"> |
| 7 | - 欢迎登录XXXXXXXX! | 14 | + 欢迎登录中科九章选课系统 |
| 8 | </view> | 15 | </view> |
| 9 | <uv-form-item label="姓名" prop="name" borderBottom> | 16 | <uv-form-item label="姓名" prop="name" borderBottom> |
| 10 | <uv-input v-model="state.userInfo.name" placeholder="请输入姓名" border="none"> | 17 | <uv-input v-model="state.userInfo.name" placeholder="请输入姓名" border="none"> |
| @@ -24,7 +31,8 @@ | @@ -24,7 +31,8 @@ | ||
| 24 | <script setup> | 31 | <script setup> |
| 25 | import { | 32 | import { |
| 26 | reactive, | 33 | reactive, |
| 27 | - ref | 34 | + ref, |
| 35 | + onMounted | ||
| 28 | } from 'vue'; | 36 | } from 'vue'; |
| 29 | import { | 37 | import { |
| 30 | loginApi | 38 | loginApi |
| @@ -60,27 +68,37 @@ | @@ -60,27 +68,37 @@ | ||
| 60 | } | 68 | } |
| 61 | }) | 69 | }) |
| 62 | 70 | ||
| 71 | + onMounted(() => { | ||
| 72 | + const token = uni.getStorageSync("token") | ||
| 73 | + if (token) uni.switchTab({ | ||
| 74 | + url: "/pages/index/index" | ||
| 75 | + }) | ||
| 76 | + }) | ||
| 77 | + | ||
| 63 | const loginHandler = async () => { | 78 | const loginHandler = async () => { |
| 64 | try { | 79 | try { |
| 65 | - await formRef.value.validate() | ||
| 66 | - | ||
| 67 | - uni.showLoading({ | ||
| 68 | - title: "登录中", | ||
| 69 | - mask: true | 80 | + await formRef.value.validate() |
| 81 | + | ||
| 82 | + uni.showLoading({ | ||
| 83 | + title: "登录中", | ||
| 84 | + mask: true | ||
| 70 | }) | 85 | }) |
| 71 | 86 | ||
| 72 | const { | 87 | const { |
| 73 | token | 88 | token |
| 74 | - } = await loginApi(state.userInfo) | 89 | + } = await loginApi(state.userInfo) |
| 75 | uni.hideLoading() | 90 | uni.hideLoading() |
| 76 | uni.showToast({ | 91 | uni.showToast({ |
| 77 | icon: 'success', | 92 | icon: 'success', |
| 78 | title: '登录成功' | 93 | title: '登录成功' |
| 79 | }) | 94 | }) |
| 80 | uni.setStorageSync('token', token) | 95 | uni.setStorageSync('token', token) |
| 81 | - uni.navigateBack() | ||
| 82 | - } finally { | ||
| 83 | - uni.hideLoading() | 96 | + // uni.navigateBack() |
| 97 | + uni.switchTab({ | ||
| 98 | + url: "/pages/index/index" | ||
| 99 | + }) | ||
| 100 | + } finally { | ||
| 101 | + uni.hideLoading() | ||
| 84 | } | 102 | } |
| 85 | } | 103 | } |
| 86 | </script> | 104 | </script> |
| @@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
| 12 | {{ state.userInfo?.nickName || "未知" }} | 12 | {{ state.userInfo?.nickName || "未知" }} |
| 13 | </view> | 13 | </view> |
| 14 | <view class=""> | 14 | <view class=""> |
| 15 | - {{ state.userInfo?.phonenumber ? state.userInfo?.phonenumber.slice(0, 8) + '****' : "" }} | 15 | + {{ state.userInfo?.phonenumber ? `${state.userInfo?.phonenumber.slice(0, 3)}****${state.userInfo?.phonenumber.slice(7, 11)}` : "" }} |
| 16 | </view> | 16 | </view> |
| 17 | </view> | 17 | </view> |
| 18 | </view> | 18 | </view> |
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | <view class=""> | 22 | <view class=""> |
| 23 | 我的孩子 | 23 | 我的孩子 |
| 24 | </view> | 24 | </view> |
| 25 | - <view style="display: flex;justify-content: space-between;align-items: center;color: #7175f0;"> | 25 | + <view @click="gotoAdd" style="display: flex;justify-content: space-between;align-items: center;color: #7175f0;"> |
| 26 | 添加<uv-icon name="arrow-right" color="#7175f0" size="14"></uv-icon> | 26 | 添加<uv-icon name="arrow-right" color="#7175f0" size="14"></uv-icon> |
| 27 | </view> | 27 | </view> |
| 28 | </view> | 28 | </view> |
| @@ -48,16 +48,16 @@ | @@ -48,16 +48,16 @@ | ||
| 48 | 我的报名 | 48 | 我的报名 |
| 49 | </view> | 49 | </view> |
| 50 | <template v-if="state.signupList.length"> | 50 | <template v-if="state.signupList.length"> |
| 51 | - <view v-for="item in state.signupList" style="display: flex;justify-content: space-between;border-radius: 20rpx;border: 2rpx solid #bdceff;padding: 10rpx;"> | 51 | + <view v-for="item in state.signupList" style="display: flex;justify-content: space-between;border-radius: 20rpx;border: 2rpx solid #bdceff;padding: 10rpx;margin-bottom: 20rpx;"> |
| 52 | <view style="background-color: #b8cfff;border-radius: 16rpx;flex-shrink: 0;width: 100rpx;height: 100rpx;"> | 52 | <view style="background-color: #b8cfff;border-radius: 16rpx;flex-shrink: 0;width: 100rpx;height: 100rpx;"> |
| 53 | - <image v-if="item.avatar" :src="item.avatar" style="width: 100%;height: 100%;"></image> | 53 | + <image v-if="item.courseImg" :src="item.courseImg" style="width: 100%;height: 100%;"></image> |
| 54 | </view> | 54 | </view> |
| 55 | <view style="flex: 1;display: flex;flex-direction: column;justify-content: space-between;margin-left: 20rpx;"> | 55 | <view style="flex: 1;display: flex;flex-direction: column;justify-content: space-between;margin-left: 20rpx;"> |
| 56 | <view class=""> | 56 | <view class=""> |
| 57 | - 华地校区-四年级-数学-A+班 | 57 | + {{ `${item.schoolName}-${item.courseName}-${item.className}` }} |
| 58 | </view> | 58 | </view> |
| 59 | <view class=""> | 59 | <view class=""> |
| 60 | - 10-01至10-31 19:00-21:00 | 60 | + {{ item.courseDate }} {{ item.courseTime }} |
| 61 | </view> | 61 | </view> |
| 62 | </view> | 62 | </view> |
| 63 | </view> | 63 | </view> |
| @@ -72,9 +72,11 @@ | @@ -72,9 +72,11 @@ | ||
| 72 | 72 | ||
| 73 | <script setup> | 73 | <script setup> |
| 74 | import { | 74 | import { |
| 75 | - reactive, | ||
| 76 | - onMounted | 75 | + reactive |
| 77 | } from 'vue'; | 76 | } from 'vue'; |
| 77 | + import { | ||
| 78 | + onShow | ||
| 79 | + } from '@dcloudio/uni-app' | ||
| 78 | import { userInfoApi, myStudentsApi, userSignUpListApi } from "@/api/index.js" | 80 | import { userInfoApi, myStudentsApi, userSignUpListApi } from "@/api/index.js" |
| 79 | 81 | ||
| 80 | const state = reactive({ | 82 | const state = reactive({ |
| @@ -83,7 +85,7 @@ | @@ -83,7 +85,7 @@ | ||
| 83 | students: [] | 85 | students: [] |
| 84 | }) | 86 | }) |
| 85 | 87 | ||
| 86 | - onMounted(() => { | 88 | + onShow(() => { |
| 87 | getUserInfo() | 89 | getUserInfo() |
| 88 | getMyStudents() | 90 | getMyStudents() |
| 89 | getuserSignUpList() | 91 | getuserSignUpList() |
| @@ -101,8 +103,13 @@ | @@ -101,8 +103,13 @@ | ||
| 101 | 103 | ||
| 102 | const getuserSignUpList = async () => { | 104 | const getuserSignUpList = async () => { |
| 103 | const { data } = await userSignUpListApi() | 105 | const { data } = await userSignUpListApi() |
| 104 | - console.log(data) | ||
| 105 | state.signupList = data.signupList | 106 | state.signupList = data.signupList |
| 107 | + } | ||
| 108 | + | ||
| 109 | + const gotoAdd = () => { | ||
| 110 | + uni.navigateTo({ | ||
| 111 | + url:"/pages/addStudent/addStudent" | ||
| 112 | + }) | ||
| 106 | } | 113 | } |
| 107 | </script> | 114 | </script> |
| 108 | 115 |
| @@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
| 23 | 选择校区 | 23 | 选择校区 |
| 24 | </view> | 24 | </view> |
| 25 | <view style="display: grid;grid-template-columns: repeat(3, 1fr);gap: 20rpx;"> | 25 | <view style="display: grid;grid-template-columns: repeat(3, 1fr);gap: 20rpx;"> |
| 26 | - <view v-for="item in state.selectData.schoolArr" @click="select1(item)" | 26 | + <view v-for="item in state?.selectData?.schoolArr" @click="select1(item)" |
| 27 | :style="state.schoolName === item.text ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''" | 27 | :style="state.schoolName === item.text ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''" |
| 28 | :class="item.status === '可选' ? 'select-item' : 'select-item no-select'"> | 28 | :class="item.status === '可选' ? 'select-item' : 'select-item no-select'"> |
| 29 | {{ item.text }} | 29 | {{ item.text }} |
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | 选择班型 | 36 | 选择班型 |
| 37 | </view> | 37 | </view> |
| 38 | <view style="display: grid;grid-template-columns: repeat(3, 1fr);gap: 20rpx;"> | 38 | <view style="display: grid;grid-template-columns: repeat(3, 1fr);gap: 20rpx;"> |
| 39 | - <view v-for="item in state.selectData.classArr" @click="select2(item)" | 39 | + <view v-for="item in state?.selectData?.classArr" @click="select2(item)" |
| 40 | :style="state.className === item.text ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''" | 40 | :style="state.className === item.text ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''" |
| 41 | :class="item.status === '可选' ? 'select-item' : 'select-item no-select'"> | 41 | :class="item.status === '可选' ? 'select-item' : 'select-item no-select'"> |
| 42 | {{ item.text }} | 42 | {{ item.text }} |
| @@ -49,7 +49,7 @@ | @@ -49,7 +49,7 @@ | ||
| 49 | 选择老师 | 49 | 选择老师 |
| 50 | </view> | 50 | </view> |
| 51 | <view style="display: grid;grid-template-columns: repeat(3, 1fr);gap: 20rpx;"> | 51 | <view style="display: grid;grid-template-columns: repeat(3, 1fr);gap: 20rpx;"> |
| 52 | - <view v-for="item in state.selectData.teacherArr" @click="select3(item)" | 52 | + <view v-for="item in state?.selectData?.teacherArr" @click="select3(item)" |
| 53 | :style="state.teacherName === item.text ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''" | 53 | :style="state.teacherName === item.text ? 'border-color:#7175f0;color:#7175f0;background-color:#f6f7ff;' : ''" |
| 54 | :class="item.status === '可选' ? 'select-item' : 'select-item no-select'"> | 54 | :class="item.status === '可选' ? 'select-item' : 'select-item no-select'"> |
| 55 | {{ item.text }} | 55 | {{ item.text }} |
| @@ -74,12 +74,12 @@ | @@ -74,12 +74,12 @@ | ||
| 74 | </view> | 74 | </view> |
| 75 | </view> | 75 | </view> |
| 76 | <!-- 行 --> | 76 | <!-- 行 --> |
| 77 | - <view v-for="item in state.selectData?.tableData?.y" class="body-row"> | 77 | + <view v-for="item in state?.selectData?.tableData?.y" class="body-row"> |
| 78 | <!-- 列 --> | 78 | <!-- 列 --> |
| 79 | <view class="cell"> | 79 | <view class="cell"> |
| 80 | {{ item }} | 80 | {{ item }} |
| 81 | </view> | 81 | </view> |
| 82 | - <view v-for="item1 in state.selectData?.tableData?.x" @click="selectTable(item, item1)" | 82 | + <view v-for="item1 in state?.selectData?.tableData?.x" @click="selectTable(item, item1)" |
| 83 | :class="(!!state.courseDate && !!state.courseTime && state.courseDate === item1 && state.courseTime === item) ? 'cell select-one' : 'cell'"> | 83 | :class="(!!state.courseDate && !!state.courseTime && state.courseDate === item1 && state.courseTime === item) ? 'cell select-one' : 'cell'"> |
| 84 | {{ filterCell(item, item1) }} | 84 | {{ filterCell(item, item1) }} |
| 85 | </view> | 85 | </view> |
| @@ -107,7 +107,7 @@ | @@ -107,7 +107,7 @@ | ||
| 107 | </view> | 107 | </view> |
| 108 | <view @click="addStudents" class="pop-inner-item" | 108 | <view @click="addStudents" class="pop-inner-item" |
| 109 | style="display: flex;align-items: center;justify-content: center;"> | 109 | style="display: flex;align-items: center;justify-content: center;"> |
| 110 | - <uv-icon name="plus" size="14" style="margin-right: 10rpx;"></uv-icon> 新增学员 | 110 | + <uv-icon name="plus" size="14" style="margin-right: 10rpx;"></uv-icon> 添加孩子 |
| 111 | </view> | 111 | </view> |
| 112 | </view> | 112 | </view> |
| 113 | </view> | 113 | </view> |
| @@ -117,7 +117,6 @@ | @@ -117,7 +117,6 @@ | ||
| 117 | 117 | ||
| 118 | <script setup> | 118 | <script setup> |
| 119 | import { | 119 | import { |
| 120 | - onMounted, | ||
| 121 | reactive, | 120 | reactive, |
| 122 | ref | 121 | ref |
| 123 | } from "vue" | 122 | } from "vue" |
| @@ -127,7 +126,7 @@ | @@ -127,7 +126,7 @@ | ||
| 127 | signUpApi | 126 | signUpApi |
| 128 | } from "@/api/index.js" | 127 | } from "@/api/index.js" |
| 129 | import { | 128 | import { |
| 130 | - onLoad | 129 | + onLoad, onShow |
| 131 | } from '@dcloudio/uni-app' | 130 | } from '@dcloudio/uni-app' |
| 132 | 131 | ||
| 133 | const studentsRef = ref(null) | 132 | const studentsRef = ref(null) |
| @@ -153,7 +152,7 @@ | @@ -153,7 +152,7 @@ | ||
| 153 | state.courseId = option?.id || null | 152 | state.courseId = option?.id || null |
| 154 | }) | 153 | }) |
| 155 | 154 | ||
| 156 | - onMounted(async () => { | 155 | + onShow(async () => { |
| 157 | await getMyStudents() | 156 | await getMyStudents() |
| 158 | getSelectCourseData() | 157 | getSelectCourseData() |
| 159 | }) | 158 | }) |
| @@ -190,10 +189,13 @@ | @@ -190,10 +189,13 @@ | ||
| 190 | courseDate: state.courseDate, | 189 | courseDate: state.courseDate, |
| 191 | courseTime: state.courseTime | 190 | courseTime: state.courseTime |
| 192 | }) | 191 | }) |
| 193 | - uni.showToast({ | ||
| 194 | - icon: 'success', | ||
| 195 | - title: '报名成功' | ||
| 196 | - }) | 192 | + setTimeout(() => { |
| 193 | + uni.showToast({ | ||
| 194 | + icon: 'success', | ||
| 195 | + title: '报名成功', | ||
| 196 | + duration: 3000 | ||
| 197 | + }) | ||
| 198 | + }, 300) | ||
| 197 | resetSelect() | 199 | resetSelect() |
| 198 | } finally { | 200 | } finally { |
| 199 | uni.hideLoading(); | 201 | uni.hideLoading(); |
| @@ -240,9 +242,10 @@ | @@ -240,9 +242,10 @@ | ||
| 240 | if (state.courseTime === item && state.courseDate === item1) { | 242 | if (state.courseTime === item && state.courseDate === item1) { |
| 241 | state.courseTime = "" | 243 | state.courseTime = "" |
| 242 | state.courseDate = "" | 244 | state.courseDate = "" |
| 245 | + getSelectCourseData() | ||
| 243 | return | 246 | return |
| 244 | } | 247 | } |
| 245 | - const arr = state.selectData?.tableData?.selectable.filter(v => (v.x === item && v.y === item1 && v.status === | 248 | + const arr = state.selectData?.tableData?.selectable.filter(v => (v.x === item1 && v.y === item && v.status === |
| 246 | "可选")) | 249 | "可选")) |
| 247 | if (!arr.length) return false | 250 | if (!arr.length) return false |
| 248 | state.courseTime = item | 251 | state.courseTime = item |
| @@ -250,10 +253,10 @@ | @@ -250,10 +253,10 @@ | ||
| 250 | getSelectCourseData() | 253 | getSelectCourseData() |
| 251 | } | 254 | } |
| 252 | 255 | ||
| 253 | - const filterCell = (item, item1) => { | ||
| 254 | - const arr = state.selectData?.tableData?.selectable.filter(v => (v.x === item && v.y === item1 && v.status === | 256 | + const filterCell = (item, item1) => { |
| 257 | + const arr = state.selectData?.tableData?.selectable.filter(v => (v.x === item1 && v.y === item && v.status === | ||
| 255 | "可选")) | 258 | "可选")) |
| 256 | - if (arr.length) return "可选" | 259 | + if (arr.length) return "可报名" |
| 257 | return "" | 260 | return "" |
| 258 | } | 261 | } |
| 259 | 262 |
| @@ -20,6 +20,7 @@ export const request = (options) => { | @@ -20,6 +20,7 @@ export const request = (options) => { | ||
| 20 | }, | 20 | }, |
| 21 | success: (res) => { | 21 | success: (res) => { |
| 22 | if (res?.data.code === 401) { | 22 | if (res?.data.code === 401) { |
| 23 | + uni.setStorageSync('token', "") | ||
| 23 | uni.showToast({ | 24 | uni.showToast({ |
| 24 | title: '登录过期', | 25 | title: '登录过期', |
| 25 | icon: 'none' | 26 | icon: 'none' |
-
Please register or login to post a comment