123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- 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 () => (
- <div class={styles['student-register']}>
- <div class={styles.studentRegisterContainer}>
- <div class={[styles.studentSection]}>
- <Form labelAlign="left" class={styles.registerForm}>
- <Field
- clearable={false}
- required
- inputAlign="right"
- label="学生姓名"
- placeholder="请输入学生姓名"
- autocomplete="off"
- readonly
- maxlength={14}
- v-model={studentInfo.nickname}>
- {{
- extra: () =>
- forms.studentList.length > 1 && (
- <div
- class={[styles.selectStudentGroup]}
- onClick={() => (forms.showSelectStudent = true)}>
- <span>切换学生</span>
- </div>
- )
- }}
- </Field>
- <Field
- clearable={false}
- required
- inputAlign="right"
- label="学生性别"
- placeholder="请选择性别"
- autocomplete="off">
- {{
- input: () => (
- <RadioGroup
- checked-color="linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)"
- v-model={studentInfo.gender}
- direction="horizontal"
- disabled>
- <Tag
- size="large"
- type="primary"
- color={
- !(studentInfo.gender === 1)
- ? '#F5F6FA'
- : 'linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)'
- }
- textColor={
- !(studentInfo.gender === 1) ? '#626264' : '#fff'
- }
- class={styles.radioSection}>
- <Radio class={styles.radioItem} name={1}></Radio>男
- </Tag>
- <Tag
- size="large"
- type="primary"
- color={
- !(studentInfo.gender === 0)
- ? '#F5F6FA'
- : 'linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)'
- }
- textColor={
- !(studentInfo.gender === 0) ? '#626264' : '#fff'
- }
- class={styles.radioSection}>
- <Radio class={styles.radioItem} name={0}></Radio>女
- </Tag>
- </RadioGroup>
- )
- }}
- </Field>
- <Field
- clearable={false}
- required
- inputAlign="right"
- label="所在地区"
- placeholder="请选择地区"
- readonly
- clickable={false}
- modelValue={studentInfo.areaName}
- />
- <Field
- clearable={false}
- required
- inputAlign="right"
- label="互通学校"
- placeholder="请选择互通学校"
- readonly
- clickable={false}
- modelValue={studentInfo.schoolName}
- />
- <Field
- clearable={false}
- required
- inputAlign="right"
- label="所在班级"
- placeholder="请选择班级"
- readonly
- clickable={false}
- modelValue={studentInfo.currentGradeNum}
- />
- </Form>
- </div>
- <MSticky position="bottom">
- <div class={styles.paymentContainer}>
- <Button
- onClick={() => {
- onSubmit();
- }}
- round
- block
- disabled={
- forms.submitLoading ||
- forms.registerAllFlag ||
- forms.studentItem.registerFlag
- }
- loading={forms.submitLoading}>
- {btnText.value}
- </Button>
- </div>
- </MSticky>
- </div>
- <Popup
- v-model:show={forms.showSelectStudent}
- round
- position="bottom"
- safeAreaInsetBottom
- closeable>
- <SelectStudent
- showAdd={false}
- studentItem={forms.studentItem}
- list={forms.studentList}
- onClose={() => (forms.showSelectStudent = false)}
- onConfirm={(val: any) => {
- console.log(val, 'val');
- formatData(val);
- forms.studentItem = val;
- }}
- />
- </Popup>
- <Popup
- show={forms.statusShow}
- style={{
- background: 'transparent',
- overflow: 'visible !important'
- }}>
- <div class={styles.popupContainer}>
- <img class={styles.title} src={loginSuccess} />
- <div class={styles.content}>
- <span>{forms.studentItem.nickname}</span>
- 已登记成功,乐器将在开课时发至学生
- </div>
- <div class={styles.pBtnGroup}>
- <Button
- round
- block
- onClick={() => {
- forms.statusShow = false;
- forms.studentItem.registerFlag = true;
- forms.studentList.forEach((item: any) => {
- if (item.userId === forms.studentItem?.userId) {
- item.registerFlag = true;
- }
- });
- }}
- color="linear-gradient( 305deg, #007AFE 0%, #31C7FF 100%)">
- 我知道了
- </Button>
- </div>
- </div>
- </Popup>
- </div>
- );
- }
- });
|