import { Image, Cell, Tag, Button, Popup, showToast, Form, Field, CountDown, RadioGroup, Radio, Picker, closeToast, Popover, Area, CellGroup, showConfirmDialog } from 'vant'; import { computed, defineComponent, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue'; import styles from './detail.module.less'; import MSticky from '@/components/m-sticky'; // import MVideo from '@/components/m-video'; import { useRoute, useRouter } from 'vue-router'; import request from '@/helpers/request'; import loginSuccess from './images/login-success.png'; import SelectStudent from '@/views/student-register/modal/select-student'; const classList: any = []; for (let i = 1; i <= 40; i++) { classList.push({ text: i + '班', value: i }); } const GRADE_ENUM = { '1': '一年级', '2': '二年级', '3': '三年级', '4': '四年级', '5': '五年级', '6': '六年级', '7': '七年级', '8': '八年级', '9': '九年级' } as any; const getGradeList = (gradeYear?: string, instrumentCode?: string) => { let tempList: any = []; const five = [ { text: '一年级', value: 1, instrumentCode }, { text: '二年级', value: 2, instrumentCode }, { text: '三年级', value: 3, instrumentCode }, { text: '四年级', value: 4, instrumentCode }, { text: '五年级', value: 5, instrumentCode } ]; const one = [{ text: '六年级', value: 6, instrumentCode }]; const three = [ { text: '七年级', value: 7, instrumentCode }, { text: '八年级', value: 8, instrumentCode }, { text: '九年级', value: 9, instrumentCode } ]; if (gradeYear === 'FIVE_YEAR_SYSTEM') { tempList.push(...[...five]); } else if (gradeYear === 'SIX_YEAR_SYSTEM') { tempList.push(...[...five, ...one]); } else if (gradeYear === 'THREE_YEAR_SYSTEM') { tempList.push(...[...three]); } else if (gradeYear === 'FORE_YEAR_SYSTEM') { tempList.push(...[...one, ...three]); } else { tempList.push(...[...five, ...one, ...three]); } return tempList; }; export default defineComponent({ name: 'activation-register', setup() { const route = useRoute(); const forms = reactive({ activationCodeRecordId: route.query.activationCodeRecordId, statusShow: false, schoolId: null as any, schoolAreaId: null, // 学校区域编号 activationCode: route.query.code as any, // 互通码 paymentType: '', // 支付类型 paymentChannel: '', multi_user_limit: 1, // 限制注册学生数量 // popupShow: false, registerDetails: {} as any, details: [] as any[], // schoolType: '', // 学校类型 gradeYear: '', // 学制 schoolInstrumentSetType: null as any, submitLoading: false, showSelectStudent: false, // 选择学生 studentList: [], // 手机号关联学生列表 studentItem: {} as any, // 选择的学生 registerAllFlag: false // 是否全部登记 }); const studentInfo = reactive({ nickname: '', areaName: '', schoolName: '', currentGradeNum: '' as any, gender: 1 as any, registerType: null as any // 报名类型 }); const btnText = computed(() => { if (forms.registerAllFlag) { return '该账号学生已全部登记'; } if (forms.studentItem?.registerFlag) { return '该学生已登记'; } return '登记'; }); const getDetail = async () => { try { const { data } = await request.post( '/edu-app/open/instrumentRegister/getStudentActivationRecord', { requestType: 'form', data: { mobile: route.query.mobile } } ); const result = data || []; result.forEach((item: any) => { item.userId = item.activationCodeRecordId; }); forms.studentList = result; let count = 0; forms.studentList.forEach((item: any) => { if (!item.registerFlag && !forms.studentItem?.userId) { forms.studentItem = item; } if (item.registerFlag) { count++; } }); if (forms.studentList.length === count) { forms.registerAllFlag = true; forms.studentItem = forms.studentList[0]; } formatData(forms.studentItem); } catch { // } }; const formatData = (item: any) => { studentInfo.nickname = item.nickname; studentInfo.gender = item.gender; const tempArea = [] as any; if (item.provinceName) { tempArea.push(item.provinceName); } if (item.cityName) { tempArea.push(item.cityName); } if (item.regionName) { tempArea.push(item.regionName); } studentInfo.areaName = tempArea.join(' '); studentInfo.schoolName = item.schoolName; studentInfo.currentGradeNum = item.currentGradeNum + '年级' + item.currentClass + '班'; }; const onSubmit = async () => { forms.submitLoading = true; try { const { data } = await request.post( '/edu-app/open/instrumentRegister/instrumentUseRegister', { requestType: 'form', data: { activationCodeRecordId: forms.studentItem.activationCodeRecordId } } ); forms.statusShow = true; } catch {} forms.submitLoading = false; }; onMounted(() => { getDetail(); }); return () => (
{{ extra: () => forms.studentList.length > 1 && (
(forms.showSelectStudent = true)}> 切换学生
) }}
{{ input: () => ( ) }}
(forms.showSelectStudent = false)} onConfirm={(val: any) => { console.log(val, 'val'); formatData(val); forms.studentItem = val; }} />
{forms.studentItem.nickname} 已登记成功,乐器将在开课时发至学生
); } });