index.tsx 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538
  1. import {
  2. Cell,
  3. Tag,
  4. Button,
  5. Popup,
  6. showToast,
  7. Form,
  8. Field,
  9. CountDown,
  10. RadioGroup,
  11. Radio,
  12. Picker,
  13. Area
  14. } from 'vant';
  15. import {
  16. computed,
  17. defineComponent,
  18. nextTick,
  19. onMounted,
  20. reactive,
  21. ref
  22. } from 'vue';
  23. import { setLogin, setLoginInit, setLogout } from '@/state';
  24. import styles from './index.module.less';
  25. import MSticky from '@/components/m-sticky';
  26. // import MVideo from '@/components/m-video';
  27. import { useRoute, useRouter } from 'vue-router';
  28. import { useStudentRegisterStore } from '@/store/modules/student-register-store';
  29. import request from '@/helpers/request';
  30. import { browser, checkPhone, getUrlCode, moneyFormat } from '@/helpers/utils';
  31. // import deepClone from '@/helpers/deep-clone';
  32. import OWxTip from '@/components/m-wx-tip';
  33. import MImgCode from '@/components/m-img-code';
  34. import MMessageTip from '@/components/m-message-tip';
  35. import SelectStudent from '@/views/student-register/modal/select-student';
  36. import { api_sysAreaQueryAllProvince } from '@/views/school-register/api';
  37. import CodeDialog from '../modal/code-dialog';
  38. import MSearch from '@/components/m-search';
  39. import { removeAuth } from '@/views/student-register/layout/utils';
  40. import { storage } from '@/helpers/storage';
  41. import { ACCESS_TOKEN } from '@/store/mutation-types';
  42. import { api_verification } from '@/views/creation/api';
  43. import bannerBg from './images/banner-bg.png';
  44. const classList: any = [];
  45. for (let i = 1; i <= 40; i++) {
  46. classList.push({ text: i + '班', value: i });
  47. }
  48. const GRADE_ENUM = {
  49. '1': '一年级',
  50. '2': '二年级',
  51. '3': '三年级',
  52. '4': '四年级',
  53. '5': '五年级',
  54. '6': '六年级',
  55. '7': '七年级',
  56. '8': '八年级',
  57. '9': '九年级'
  58. } as any;
  59. const getGradeList = (gradeYear?: string, instrumentCode?: string) => {
  60. let tempList: any = [];
  61. const five = [
  62. { text: '一年级', value: 1, instrumentCode },
  63. { text: '二年级', value: 2, instrumentCode },
  64. { text: '三年级', value: 3, instrumentCode },
  65. { text: '四年级', value: 4, instrumentCode },
  66. { text: '五年级', value: 5, instrumentCode }
  67. ];
  68. const one = [{ text: '六年级', value: 6, instrumentCode }];
  69. const three = [
  70. { text: '七年级', value: 7, instrumentCode },
  71. { text: '八年级', value: 8, instrumentCode },
  72. { text: '九年级', value: 9, instrumentCode }
  73. ];
  74. if (gradeYear === 'FIVE_YEAR_SYSTEM') {
  75. tempList.push(...[...five]);
  76. } else if (gradeYear === 'SIX_YEAR_SYSTEM') {
  77. tempList.push(...[...five, ...one]);
  78. } else if (gradeYear === 'THREE_YEAR_SYSTEM') {
  79. tempList.push(...[...three]);
  80. } else if (gradeYear === 'FORE_YEAR_SYSTEM') {
  81. tempList.push(...[...one, ...three]);
  82. } else {
  83. tempList.push(...[...five, ...one, ...three]);
  84. }
  85. return tempList;
  86. };
  87. export default defineComponent({
  88. name: 'activation-register',
  89. setup() {
  90. const route = useRoute();
  91. const studentRegisterStore = useStudentRegisterStore();
  92. const router = useRouter();
  93. // 初始化学校编号
  94. // studentRegisterStore.setShoolId(route.query.sId as any);
  95. const countDownRef = ref();
  96. const forms = reactive({
  97. isLoginRegister: false, // 是否已经登录或已注册
  98. schoolId: null as any,
  99. schoolAreaId: null, // 学校区域编号
  100. activationCode: null as any, // 互通码
  101. paymentType: '', // 支付类型
  102. paymentChannel: '',
  103. multi_user_limit: 1, // 限制注册学生数量
  104. // popupShow: false,
  105. registerDetails: {} as any,
  106. details: [] as any[],
  107. // schoolType: '', // 学校类型
  108. gradeYear: '', // 学制
  109. schoolInstrumentSetType: null as any,
  110. // bugGoods: false, // 是否购买AI
  111. isRegister: 'create' as 'create' | 'update' | '', // 是否注册学生
  112. isDisabled: false,
  113. isTipRegister: false, // 是否显示名字不一致 - 默认显示
  114. isChangeSchool: false, // 是否切换学校
  115. schoolStatus: false,
  116. schoolPopupShow: false,
  117. schoolLoading: false,
  118. schoolPopupIndex: [] as any,
  119. schoolAreaList: [] as any,
  120. provinceCode: null,
  121. cityCode: null,
  122. regionCode: null,
  123. showResultPopup: false,
  124. reslutPopupType: '' as any,
  125. resultPopupContent: '',
  126. registerType: '', // 报名类型
  127. detailVip: {} as any,
  128. giftVipDay: 0, // 赠送天数
  129. submitLoading: false,
  130. // showMore: true,
  131. showTips: false,
  132. showButton: false,
  133. showMessage: '请使用微信扫描二维码',
  134. countDownStatus: true,
  135. countDownTime: 1000 * 120, // 倒计时时间
  136. // modelValue: false, // 是否选中协议
  137. imgCodeStatus: false,
  138. gradeNumText: '',
  139. currentClassText: '',
  140. schoolName: '',
  141. areaName: '',
  142. gradeStatus: false,
  143. classStatus: false,
  144. loading: false,
  145. showConfirmPopup: false, // 二次确认用户信息
  146. showPicker: false,
  147. areaList: [] as any,
  148. tipStatus: true,
  149. dialogConfirmStatus: false,
  150. contract_sign: false, // 是否实名认证
  151. countDownTimePay: 60 * 1000,
  152. dialogConfig: {} as any,
  153. showSelectStudent: false, // 选择学生
  154. studentList: [], // 手机号关联学生列表
  155. studentItem: {} as any, // 选择的学生
  156. joinType: 'digitalize' as 'digitalize' | 'tradition',
  157. gradeList: [] as any,
  158. classList: [] as any,
  159. saveUserId: null as any,
  160. saveId: null as any,
  161. openId: null as any,
  162. code: null as any,
  163. registerExpireTime: null as any, // 结束时间
  164. instrumentCode: null as any, // 乐器编码
  165. activeOverTime: 0, // 活动结束时间
  166. activeOverStatus: true, // 活动是否结束 默认已结束
  167. gradePopupShow: false,
  168. gradePopupIndex: [] as any, // 年级下拉索引
  169. classPopupShow: false,
  170. classPopupIndex: [] as any // 班级下拉索引
  171. });
  172. const otherParams = reactive({
  173. showOtherSchool: false,
  174. showCloseButton: true, // 是否显示关闭按钮
  175. showOtherMessage: '',
  176. /** limit 超限制,change 更换学生,nickname 名称不一致 member 会员购买, payment 支付方式 */
  177. otherType: '' as 'limit' | 'change' | 'nickname' | 'member' | 'payment',
  178. showCancelButton: true,
  179. cancelButtonColor: '',
  180. cancelButtonText: '取消',
  181. showConfirmButton: true,
  182. confirmButtonColor: '',
  183. confirmButtonText: '确定',
  184. messageAlign: 'left' as 'center' | 'left' | 'right'
  185. });
  186. const state = reactive({
  187. showQrcode: false,
  188. qrCodeUrl: '',
  189. pay_channel: '',
  190. orderInfo: {} as any, // 订单信息
  191. authShow: false,
  192. orderNo: null as any,
  193. config: {} as any,
  194. paymentStatus: false,
  195. orderTimer: null as any
  196. });
  197. /*
  198. 新用户:
  199. autoRegister: true
  200. loginType: 'SMS'
  201. 已存在用户:
  202. autoRegister: false
  203. loginType: 'TOKEN'
  204. password: xxx
  205. */
  206. const studentInfo = reactive({
  207. autoRegister: true,
  208. multiUser: true, // 是否为多用户
  209. client_id: 'cooleshow-student',
  210. client_secret: 'cooleshow-student',
  211. extra: {
  212. nickname: '',
  213. currentGradeNum: '' as any,
  214. currentClass: '' as any,
  215. gender: 1 as any,
  216. registerType: null as any, // 报名类型
  217. giftVipDay: 0 // 赠送会员天数
  218. },
  219. grant_type: 'password',
  220. loginType: 'SMS',
  221. password: '',
  222. username: ''
  223. });
  224. /** 报名结束提示 */
  225. const applyOver = () => {
  226. forms.showTips = true;
  227. // forms.showMessage = '团购时间已截止,感谢您的参与';
  228. forms.showMessage =
  229. '<p style="color: #F44541">报名已截止,感谢您的参与</p>';
  230. forms.showButton = false;
  231. };
  232. const onCodeSend = () => {
  233. forms.countDownStatus = false;
  234. nextTick(() => {
  235. countDownRef.value.start();
  236. });
  237. };
  238. const onSendCode = () => {
  239. // 发送验证码
  240. if (!checkPhone(studentInfo.username)) {
  241. return showToast('请输入正确的手机号码');
  242. }
  243. forms.imgCodeStatus = true;
  244. };
  245. const validatePhone = computed(() => {
  246. return checkPhone(studentInfo.username) ? true : false;
  247. });
  248. const onFinished = () => {
  249. forms.countDownStatus = true;
  250. countDownRef.value.reset();
  251. };
  252. // 格式化提示状态
  253. const changeTipStatus = (register: boolean, school: boolean) => {
  254. forms.isTipRegister = register;
  255. forms.isChangeSchool = school;
  256. };
  257. const checkForm = (status = true) => {
  258. if (!checkPhone(studentInfo.username)) {
  259. status && showToast('请输入正确的手机号码');
  260. return true;
  261. } else if (!studentInfo.password) {
  262. status && showToast('请输入验证码');
  263. return true;
  264. } else if (!studentInfo.extra.nickname) {
  265. status && showToast('请输入学生姓名');
  266. return true;
  267. } else if (![0, 1].includes(studentInfo.extra.gender)) {
  268. status && showToast('请选择性别');
  269. return true;
  270. } else if (!studentInfo.extra.currentGradeNum) {
  271. status && showToast('请选择所在年级');
  272. return true;
  273. } else if (!studentInfo.extra.currentClass) {
  274. status && showToast('请选择所在班级');
  275. return true;
  276. } else if (!forms.activationCode) {
  277. status && showToast('请输入互通码');
  278. return true;
  279. }
  280. return false;
  281. };
  282. //
  283. const checkSubmit = () => {
  284. const { extra } = studentInfo;
  285. if (
  286. forms.studentItem.nickname !== extra.nickname &&
  287. forms.isTipRegister
  288. ) {
  289. otherParams.showOtherMessage =
  290. '学生姓名与上次提交信息不一致,请确认修改学生信息或创建新的学生账号';
  291. otherParams.showOtherSchool = true;
  292. otherParams.showCancelButton = true;
  293. otherParams.showCloseButton = true;
  294. otherParams.cancelButtonColor =
  295. 'linear-gradient( 224deg, #3FE1E6 0%, #00CDD4 100%)';
  296. otherParams.cancelButtonText = '新建学生';
  297. otherParams.confirmButtonColor =
  298. 'linear-gradient( 305deg, #40C8FF 0%, #3192FF 100%)';
  299. otherParams.confirmButtonText = '修改信息';
  300. otherParams.otherType = 'nickname';
  301. otherParams.messageAlign = 'left';
  302. return true;
  303. }
  304. // 判断新建学员是否上限了
  305. if (
  306. forms.isRegister === 'create' &&
  307. forms.studentList.length >= forms.multi_user_limit
  308. ) {
  309. otherParams.showOtherMessage = `同一手机号最多创建${forms.multi_user_limit}个学生`;
  310. otherParams.showOtherSchool = true;
  311. otherParams.showCancelButton = false;
  312. otherParams.showCloseButton = true;
  313. otherParams.confirmButtonColor =
  314. 'linear-gradient( 305deg, #40C8FF 0%, #3192FF 100%)';
  315. otherParams.confirmButtonText = '我知道了';
  316. otherParams.otherType = 'limit';
  317. otherParams.messageAlign = 'center';
  318. return true;
  319. }
  320. return false;
  321. };
  322. /**
  323. * 登记成功之后购买
  324. */
  325. const onSubmit = async () => {
  326. forms.submitLoading = true;
  327. try {
  328. if (checkForm() || checkSubmit()) {
  329. forms.submitLoading = false;
  330. return;
  331. }
  332. const { extra, loginType, autoRegister, password, multiUser, ...res } =
  333. studentInfo;
  334. /*
  335. 新用户:
  336. autoRegister: true
  337. loginType: 'SMS'
  338. 已存在用户:
  339. autoRegister: false
  340. loginType: 'TOKEN'
  341. password: xxx
  342. */
  343. let tLoginType = loginType,
  344. tAutoRegister = autoRegister,
  345. tPassword = password,
  346. tMultiUser = multiUser;
  347. if (forms.isRegister === 'update') {
  348. tLoginType = 'TOKEN';
  349. tAutoRegister = false;
  350. tPassword = forms.studentItem.token;
  351. tMultiUser = false;
  352. }
  353. // 为了处理新注册学员,在次注册
  354. if (forms.isLoginRegister) {
  355. await updateStudentInfo();
  356. } else {
  357. const result = await request.post('/edu-app/userlogin', {
  358. requestType: 'form',
  359. data: {
  360. loginType: tLoginType,
  361. autoRegister: tAutoRegister,
  362. password: tPassword,
  363. multiUser: tMultiUser,
  364. ...res,
  365. extra: JSON.stringify({
  366. ...extra,
  367. activationCode: forms.activationCode,
  368. // giftVipDay:
  369. // forms.detailVip.membershipDays || 0 + forms.giftVipDay || 0,
  370. schoolId: forms.schoolId
  371. })
  372. }
  373. });
  374. if (result.code !== 200) {
  375. if (result.code === 5436) {
  376. forms.showTips = true;
  377. forms.showMessage = '二维码已经失效,详情请咨询学校老师';
  378. forms.showButton = false;
  379. } else if (result.code === 5435) {
  380. forms.showTips = true;
  381. forms.showMessage = result.message;
  382. forms.showButton = true;
  383. }
  384. } else {
  385. forms.isLoginRegister = true;
  386. studentRegisterStore.setToken(
  387. result.data.token_type + ' ' + result.data.access_token
  388. );
  389. setLoginInit();
  390. // 获取用户信息
  391. const res = await request.get('/edu-app/user/getUserInfo', {
  392. requestType: 'form'
  393. });
  394. setLogin(res.data);
  395. await updateStudentInfo();
  396. }
  397. }
  398. } catch {
  399. // 重置信息 - 如果是新建则不提示
  400. changeTipStatus(forms.isRegister === 'create' ? false : true, false);
  401. } finally {
  402. forms.submitLoading = false;
  403. }
  404. };
  405. const checkLogin = async () => {
  406. try {
  407. // 判断是否登录
  408. const Authorization = storage.get(ACCESS_TOKEN) || '';
  409. if (Authorization) {
  410. const res = await api_verification({
  411. token: Authorization
  412. });
  413. if (!res.data) {
  414. removeAuth();
  415. setLogout();
  416. return false;
  417. } else {
  418. return true;
  419. }
  420. } else {
  421. return false;
  422. }
  423. } catch (err) {
  424. //
  425. storage.remove(ACCESS_TOKEN);
  426. removeAuth();
  427. setLogout();
  428. return false;
  429. }
  430. };
  431. const updateStudentInfo = async () => {
  432. try {
  433. if (forms.isLoginRegister) {
  434. const status = await checkLogin();
  435. if (!status) {
  436. studentInfo.username = '';
  437. if (!route.query.code) {
  438. forms.activationCode = '';
  439. }
  440. phoneChangeEmptyInfo();
  441. }
  442. }
  443. const { extra, username } = studentInfo;
  444. const registerResult = await request.post('/edu-app/student/register', {
  445. data: {
  446. clientType: 'STUDENT',
  447. ...extra,
  448. activationCode: forms.activationCode,
  449. schoolId: forms.schoolId,
  450. schoolAreaId: forms.schoolAreaId,
  451. // giftVipFlag: forms.registerDetails.giftVipFlag || false,
  452. // giftVipDay: forms.giftVipDay || 0,
  453. schoolVerify: false,
  454. // firstVipDay: forms.detailVip.membershipDays || 0,
  455. mobile: username,
  456. newRegUser: forms.isRegister === 'create' ? true : false
  457. }
  458. });
  459. if (registerResult.code !== 200) {
  460. if (registerResult.code === 5436) {
  461. forms.showTips = true;
  462. forms.showMessage = '二维码已经失效,详情请咨询学校老师';
  463. forms.showButton = false;
  464. } else if (registerResult.code === 5435) {
  465. forms.showTips = true;
  466. forms.showMessage = registerResult.message;
  467. forms.showButton = true;
  468. } else if (registerResult.code === 5437) {
  469. forms.showTips = true;
  470. forms.showMessage =
  471. '<p style="color: #F44541">报名已截止,感谢您的参与</p>'; //result.message;
  472. forms.showButton = false;
  473. } else if (registerResult.code === 980) {
  474. // 980:激活码不存在
  475. forms.showResultPopup = true;
  476. forms.reslutPopupType = 'INVALID';
  477. forms.resultPopupContent = registerResult.message;
  478. } else if (registerResult.code === 981) {
  479. // 981:激活码被同一人重复使用
  480. forms.showResultPopup = true;
  481. forms.reslutPopupType = 'ACTIVATING-TWO';
  482. forms.resultPopupContent = registerResult.message;
  483. } else if (registerResult.code === 982) {
  484. // 982:激活码已激活
  485. forms.showResultPopup = true;
  486. forms.reslutPopupType = 'EXPIRED';
  487. forms.resultPopupContent = registerResult.message;
  488. } else if (registerResult.code === 983) {
  489. // 983:激活码已作废
  490. forms.showResultPopup = true;
  491. forms.reslutPopupType = 'OVERDUE';
  492. forms.resultPopupContent = registerResult.message;
  493. } else if (registerResult.code === 984) {
  494. // 984:激活码已过期
  495. forms.showResultPopup = true;
  496. forms.reslutPopupType = 'CANCELLED';
  497. forms.resultPopupContent = registerResult.message;
  498. }
  499. return false;
  500. } else {
  501. forms.showResultPopup = true;
  502. forms.reslutPopupType = 'ACTIVATING';
  503. return true;
  504. }
  505. } catch {}
  506. };
  507. const getUserInfos = async () => {
  508. if (
  509. studentInfo.password.length !== 6 ||
  510. !checkPhone(studentInfo.username)
  511. ) {
  512. return;
  513. }
  514. try {
  515. // 15907120131;
  516. const { data } = await request.get(
  517. `/edu-app/open/student/studentInfo?mobile=${studentInfo.username}&code=${studentInfo.password}&type=REGISTER&activationCodeFlag=1`
  518. );
  519. forms.studentList = data || [];
  520. if (forms.studentList.length > 0) {
  521. const firstStudent: any = forms.studentList[0];
  522. forms.studentItem = firstStudent;
  523. studentInfo.extra.nickname = firstStudent.nickname;
  524. const tempArea = [] as any;
  525. if (firstStudent.provinceName) {
  526. tempArea.push(firstStudent.provinceName);
  527. forms.provinceCode = firstStudent.provinceCode;
  528. }
  529. if (firstStudent.cityName) {
  530. tempArea.push(firstStudent.cityName);
  531. forms.cityCode = firstStudent.cityCode;
  532. }
  533. if (firstStudent.regionName) {
  534. tempArea.push(firstStudent.regionName);
  535. forms.regionCode = firstStudent.regionCode;
  536. }
  537. forms.areaName = tempArea.join(' ');
  538. forms.schoolName = firstStudent.schoolName;
  539. forms.schoolId = firstStudent.schoolId;
  540. forms.schoolAreaId = firstStudent.schoolAreaId;
  541. const tempGrade: any = forms.gradeList || [];
  542. tempGrade?.forEach((i: any) => {
  543. if (i.value === firstStudent.currentGradeNum) {
  544. forms.instrumentCode = i.instrumentCode;
  545. forms.gradeNumText = i.text;
  546. studentInfo.extra.currentGradeNum = firstStudent.currentGradeNum;
  547. if (forms.schoolInstrumentSetType === 'CLASS') {
  548. forms.classList = i.classList;
  549. }
  550. }
  551. });
  552. forms.classList.forEach((i: any) => {
  553. if (i.value === firstStudent.currentClass) {
  554. forms.currentClassText = i.text;
  555. studentInfo.extra.currentClass = firstStudent.currentClass;
  556. }
  557. });
  558. studentInfo.extra.gender = firstStudent.gender;
  559. forms.isRegister = 'update';
  560. changeTipStatus(true, false);
  561. } else {
  562. forms.isRegister = 'create';
  563. studentInfo.autoRegister = true;
  564. changeTipStatus(false, false);
  565. forms.studentItem = [];
  566. }
  567. } catch {
  568. //
  569. }
  570. };
  571. /** 手机号变更时清空验证码信息,用户信息 */
  572. const phoneChangeEmptyInfo = () => {
  573. studentInfo.password = '';
  574. studentInfo.extra.nickname = '';
  575. studentInfo.extra.currentGradeNum = '';
  576. studentInfo.extra.currentClass = '';
  577. studentInfo.extra.gender = 1;
  578. forms.areaName = '';
  579. forms.schoolName = '';
  580. forms.currentClassText = '';
  581. forms.gradeNumText = '';
  582. forms.studentList = []; // 手机号关联学生列表
  583. forms.studentItem = {}; // 选择的学生
  584. forms.isRegister = 'create'; // 是否注册学生
  585. studentInfo.autoRegister = true
  586. forms.isTipRegister = false; // 是否显示名字不一致 - 默认显示
  587. forms.isChangeSchool = false; // 是否切换学校
  588. };
  589. const formateArea = (area: any[]) => {
  590. const province_list: { [_: string]: string } = {};
  591. const city_list: { [_: string]: string } = {};
  592. const county_list: { [_: string]: string } = {};
  593. area.forEach((item: any) => {
  594. province_list[item.code] = item.name;
  595. });
  596. area.forEach((item: any) => {
  597. item.areas?.forEach((city: any) => {
  598. city_list[city.code] = city.name;
  599. });
  600. });
  601. area.forEach((item: any) => {
  602. item.areas?.forEach((city: any) => {
  603. city.areas?.forEach((county: any) => {
  604. county_list[county.code] = county.name;
  605. });
  606. });
  607. });
  608. return {
  609. province_list,
  610. city_list,
  611. county_list
  612. };
  613. };
  614. const getAreaList = () => {
  615. api_sysAreaQueryAllProvince().then(res => {
  616. if (res?.code === 200) {
  617. forms.areaList = formateArea(res.data);
  618. }
  619. });
  620. };
  621. const getSchoolAreaList = async (name?: string) => {
  622. forms.schoolLoading = true;
  623. try {
  624. const { data } = await request.post('/edu-app/open/schoolArea/list', {
  625. data: {
  626. name,
  627. testFlag: true,
  628. provinceCode: forms.provinceCode,
  629. cityCode: forms.cityCode,
  630. regionCode: forms.regionCode
  631. }
  632. });
  633. forms.schoolAreaList = data;
  634. } catch {
  635. //
  636. }
  637. forms.schoolLoading = false;
  638. };
  639. // 格式化互通码
  640. const maskMiddleDigits = (str: string) => {
  641. if (!str) {
  642. return '';
  643. }
  644. let numPart = str.match(/\d+/); // 提取数字部分
  645. if (numPart) {
  646. let start = str.indexOf(numPart[0]); // 数字部分的起始索引
  647. let end = start + numPart[0].length; // 数字部分的结束索引
  648. let maskedStr =
  649. str.substring(0, start) +
  650. '*'.repeat(numPart[0].length) +
  651. str.substring(end);
  652. return maskedStr;
  653. }
  654. return str;
  655. };
  656. // 获取地区学校详情
  657. const getSchoolAreaDetail = async () => {
  658. try {
  659. const { data } = await request.get(
  660. '/edu-app/open/schoolArea/detail/' + forms.schoolAreaId
  661. );
  662. console.log(data, 'data');
  663. if (data.school) {
  664. const schoolInfo = data.school || {};
  665. const schoolInstrumentList = schoolInfo.schoolInstrumentList || [];
  666. forms.schoolInstrumentSetType = schoolInfo.instrumentSetType;
  667. if (schoolInfo.instrumentSetType === 'SCHOOL') {
  668. const instrumentCode = schoolInstrumentList[0]?.instrumentCode;
  669. forms.gradeList = getGradeList(
  670. schoolInfo.gradeYear,
  671. instrumentCode
  672. );
  673. forms.classList = classList;
  674. } else if (schoolInfo.instrumentSetType === 'GRADE') {
  675. forms.gradeList = [];
  676. schoolInstrumentList.forEach((item: any) => {
  677. forms.gradeList.push({
  678. text: GRADE_ENUM[item.gradeNum],
  679. value: item.gradeNum,
  680. instrumentId: item.instrumentId,
  681. instrumentCode: item.instrumentCode
  682. });
  683. });
  684. forms.gradeList.sort((a: any, b: any) => a.value - b.value);
  685. forms.classList = classList;
  686. } else if (schoolInfo.instrumentSetType === 'CLASS') {
  687. // 班级
  688. const tempGradeList: any[] = [];
  689. schoolInstrumentList.forEach((item: any) => {
  690. if (!tempGradeList.includes(item.gradeNum)) {
  691. tempGradeList.push(item.gradeNum);
  692. }
  693. });
  694. const lastGradeList: any[] = [];
  695. tempGradeList.forEach((temp: any) => {
  696. const list = {
  697. text: GRADE_ENUM[temp],
  698. value: temp,
  699. instrumentId: '',
  700. instrumentCode: '',
  701. instrumentName: '',
  702. classList: [] as any
  703. };
  704. schoolInstrumentList.forEach((item: any) => {
  705. if (temp === item.gradeNum) {
  706. list.instrumentId = item.instrumentId;
  707. list.instrumentCode = item.instrumentCode;
  708. list.instrumentName = item.instrumentName;
  709. list.classList.push({
  710. text: item.classNum + '班',
  711. value: item.classNum,
  712. instrumentCode: item.instrumentCode
  713. });
  714. }
  715. });
  716. // 排序班级
  717. list.classList.sort((a: any, b: any) => a.value - b.value);
  718. lastGradeList.push(list);
  719. });
  720. lastGradeList.sort((a: any, b: any) => a.value - b.value);
  721. forms.gradeList = lastGradeList;
  722. forms.classList = [];
  723. } else {
  724. forms.gradeList = getGradeList(schoolInfo.gradeYear);
  725. forms.classList = classList;
  726. }
  727. } else {
  728. forms.schoolInstrumentSetType = '';
  729. forms.gradeList = getGradeList();
  730. forms.classList = classList;
  731. }
  732. } catch {
  733. //
  734. }
  735. };
  736. onMounted(async () => {
  737. try {
  738. storage.remove(ACCESS_TOKEN);
  739. removeAuth();
  740. setLogout();
  741. const code: any = route.query.code;
  742. if (code) {
  743. forms.activationCode = window.atob(code);
  744. }
  745. } catch {
  746. //
  747. }
  748. getAreaList();
  749. try {
  750. // 获取支付类型
  751. const { data } = await request.get(
  752. '/edu-app/open/paramConfig/queryByParamNameList',
  753. {
  754. requestType: 'form',
  755. params: {
  756. paramNames: 'multi_user_limit'
  757. }
  758. }
  759. );
  760. if (data && Array.isArray(data)) {
  761. data.forEach((item: any) => {
  762. if (item.paramName === 'multi_user_limit') {
  763. forms.multi_user_limit = item.paramValue
  764. ? Number(item.paramValue)
  765. : 1;
  766. }
  767. });
  768. }
  769. } catch {}
  770. forms.gradeList = getGradeList();
  771. forms.classList = classList;
  772. });
  773. return () => (
  774. <div class={[styles['student-register']]}>
  775. <img src={bannerBg} class={styles.bannerBg} />
  776. <div class={styles.studentRegisterContainer}>
  777. <div class={[styles.studentSection]}>
  778. <Form labelAlign="left" class={styles.registerForm}>
  779. <Field
  780. clearable={false}
  781. label="联系方式"
  782. placeholder="请输入手机号码"
  783. type="digit"
  784. required
  785. autocomplete="off"
  786. inputAlign="right"
  787. v-model={studentInfo.username}
  788. maxlength={11}
  789. onUpdate:modelValue={(val: any) => {
  790. phoneChangeEmptyInfo();
  791. }}></Field>
  792. <Field
  793. center
  794. clearable={false}
  795. required
  796. inputAlign="right"
  797. label="验证码"
  798. placeholder="请输入验证码"
  799. autocomplete="off"
  800. type="number"
  801. v-model={studentInfo.password}
  802. maxlength={6}
  803. onUpdate:modelValue={(val: any) => {
  804. getUserInfos();
  805. }}>
  806. {{
  807. button: () =>
  808. forms.countDownStatus ? (
  809. <span
  810. class={[
  811. styles.codeText,
  812. !validatePhone.value ? styles.codeTextDisabled : ''
  813. ]}
  814. onClick={onSendCode}>
  815. 获取验证码
  816. </span>
  817. ) : (
  818. <CountDown
  819. ref={(el: any) => (countDownRef.value = el)}
  820. auto-start={false}
  821. class={styles.countDown}
  822. time={forms.countDownTime}
  823. onFinish={onFinished}
  824. format="ss秒后重试"
  825. />
  826. )
  827. }}
  828. </Field>
  829. <Field
  830. clearable={false}
  831. required
  832. inputAlign="right"
  833. label="学生姓名"
  834. placeholder="请输入学生姓名"
  835. autocomplete="off"
  836. maxlength={14}
  837. readonly={forms.isRegister === 'update'}
  838. v-model={studentInfo.extra.nickname}>
  839. {{
  840. extra: () =>
  841. forms.studentList.length >= 1 && (
  842. <div
  843. class={[
  844. styles.selectStudentGroup,
  845. forms.showSelectStudent &&
  846. styles.selectStudentGroupChecked
  847. ]}
  848. onClick={() => (forms.showSelectStudent = true)}>
  849. <span>
  850. {forms.studentItem.userId ? '切换' : '新增'}
  851. </span>
  852. </div>
  853. )
  854. }}
  855. </Field>
  856. <Field
  857. clearable={false}
  858. required
  859. inputAlign="right"
  860. label="学生性别"
  861. placeholder="请选择性别"
  862. autocomplete="off">
  863. {{
  864. input: () => (
  865. <RadioGroup
  866. checked-color="linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)"
  867. v-model={studentInfo.extra.gender}
  868. direction="horizontal"
  869. disabled={forms.isRegister === 'update'}>
  870. <Tag
  871. size="large"
  872. type="primary"
  873. color={
  874. !(studentInfo.extra.gender === 1)
  875. ? '#F5F6FA'
  876. : 'linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)'
  877. }
  878. textColor={
  879. !(studentInfo.extra.gender === 1) ? '#626264' : '#fff'
  880. }
  881. class={styles.radioSection}>
  882. <Radio class={styles.radioItem} name={1}></Radio>男
  883. </Tag>
  884. <Tag
  885. size="large"
  886. type="primary"
  887. color={
  888. !(studentInfo.extra.gender === 0)
  889. ? '#F5F6FA'
  890. : 'linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)'
  891. }
  892. textColor={
  893. !(studentInfo.extra.gender === 0) ? '#626264' : '#fff'
  894. }
  895. class={styles.radioSection}>
  896. <Radio class={styles.radioItem} name={0}></Radio>女
  897. </Tag>
  898. </RadioGroup>
  899. )
  900. }}
  901. </Field>
  902. <Field
  903. clearable={false}
  904. required
  905. inputAlign="right"
  906. label="所在地区"
  907. placeholder="请选择地区"
  908. isLink={forms.isRegister !== 'update'}
  909. readonly
  910. clickable={false}
  911. modelValue={forms.areaName}
  912. onClick={() => {
  913. if (forms.isRegister !== 'update') forms.showPicker = true;
  914. // forms.gradePopupIndex = [studentInfo.extra.currentGradeNum];
  915. }}
  916. />
  917. <Field
  918. clearable={false}
  919. required
  920. inputAlign="right"
  921. label="互通学校"
  922. placeholder="请选择学校"
  923. isLink={forms.isRegister !== 'update'}
  924. readonly
  925. clickable={false}
  926. modelValue={forms.schoolName}
  927. onClick={() => {
  928. if (forms.isRegister === 'update') return;
  929. if (!forms.areaName) {
  930. showToast('请选择地区');
  931. return;
  932. }
  933. forms.schoolStatus = true;
  934. if (forms.schoolAreaId) {
  935. forms.schoolPopupIndex = [forms.schoolAreaId];
  936. }
  937. // forms.gradeStatus = true;
  938. // forms.gradePopupIndex = [studentInfo.extra.currentGradeNum];
  939. }}
  940. />
  941. <Field
  942. clearable={false}
  943. required
  944. inputAlign="right"
  945. label="所在年级"
  946. placeholder="请选择年级"
  947. isLink={forms.isRegister !== 'update'}
  948. readonly
  949. clickable={false}
  950. modelValue={forms.gradeNumText}
  951. onClick={() => {
  952. if (forms.isRegister !== 'update') {
  953. forms.gradePopupIndex = [studentInfo.extra.currentGradeNum];
  954. forms.gradeStatus = true;
  955. }
  956. }}
  957. />
  958. <Field
  959. clearable={false}
  960. required
  961. inputAlign="right"
  962. label="所在班级"
  963. placeholder="请选择班级"
  964. isLink={forms.isRegister !== 'update'}
  965. readonly
  966. clickable={false}
  967. modelValue={forms.currentClassText}
  968. onClick={() => {
  969. if (forms.isRegister == 'update') {
  970. return;
  971. }
  972. if (
  973. forms.schoolInstrumentSetType === 'CLASS' &&
  974. forms.classList.length <= 0
  975. ) {
  976. showToast('请先选择年级');
  977. return;
  978. }
  979. forms.classPopupIndex = [studentInfo.extra.currentClass];
  980. forms.classStatus = true;
  981. }}
  982. />
  983. {/* maskMiddleDigits */}
  984. {route.query.code ? (
  985. <Field
  986. clearable={false}
  987. required
  988. inputAlign="right"
  989. label="互通码"
  990. readonly={route.query.code ? true : false}
  991. modelValue={maskMiddleDigits(forms.activationCode)}
  992. />
  993. ) : (
  994. <Field
  995. clearable={false}
  996. required
  997. inputAlign="right"
  998. label="互通码"
  999. placeholder="请输入互通码"
  1000. autocomplete="off"
  1001. v-model={forms.activationCode}
  1002. />
  1003. )}
  1004. </Form>
  1005. </div>
  1006. <MSticky position="bottom">
  1007. <div class={styles.paymentContainer}>
  1008. <Button
  1009. onClick={() => {
  1010. // onSubmit();
  1011. if (checkForm() || checkSubmit()) {
  1012. forms.submitLoading = false;
  1013. return;
  1014. }
  1015. forms.showConfirmPopup = true;
  1016. }}
  1017. round
  1018. block
  1019. disabled={forms.submitLoading}
  1020. loading={forms.submitLoading}>
  1021. 提交
  1022. </Button>
  1023. </div>
  1024. </MSticky>
  1025. </div>
  1026. {forms.imgCodeStatus ? (
  1027. <MImgCode
  1028. v-model:value={forms.imgCodeStatus}
  1029. phone={studentInfo.username}
  1030. type="REGISTER"
  1031. onClose={() => {
  1032. forms.imgCodeStatus = false;
  1033. }}
  1034. onSendCode={onCodeSend}
  1035. />
  1036. ) : null}
  1037. {/* 互通学校 */}
  1038. <Popup
  1039. v-model:show={forms.schoolStatus}
  1040. position="bottom"
  1041. round
  1042. safeAreaInsetBottom
  1043. lazyRender={false}
  1044. class={'popupBottomSearch'}
  1045. onOpen={() => {
  1046. forms.schoolPopupShow = true;
  1047. }}
  1048. onClosed={() => {
  1049. forms.schoolPopupShow = false;
  1050. }}>
  1051. {forms.schoolPopupShow && (
  1052. <div>
  1053. <Picker
  1054. showToolbar
  1055. v-model={forms.schoolPopupIndex}
  1056. columns={forms.schoolAreaList}
  1057. loading={forms.schoolLoading}
  1058. columnsFieldNames={{
  1059. text: 'name',
  1060. value: 'id'
  1061. }}
  1062. onCancel={() => (forms.schoolStatus = false)}
  1063. onConfirm={(val: any) => {
  1064. const selectedOption = val.selectedOptions[0];
  1065. forms.schoolId = selectedOption.schoolId || null;
  1066. forms.schoolAreaId = selectedOption.id;
  1067. forms.schoolName = selectedOption.name;
  1068. forms.schoolStatus = false;
  1069. forms.gradeNumText = '';
  1070. studentInfo.extra.currentGradeNum = null;
  1071. forms.currentClassText = '';
  1072. studentInfo.extra.currentClass = null;
  1073. getSchoolAreaDetail();
  1074. }}>
  1075. {{
  1076. 'columns-top': (
  1077. <MSearch
  1078. placeholder="请输入学校名称"
  1079. onSearch={(val: any) => {
  1080. getSchoolAreaList(val);
  1081. }}
  1082. />
  1083. )
  1084. }}
  1085. </Picker>
  1086. </div>
  1087. )}
  1088. </Popup>
  1089. {/* 年级 */}
  1090. <Popup
  1091. v-model:show={forms.gradeStatus}
  1092. position="bottom"
  1093. round
  1094. safeAreaInsetBottom
  1095. lazyRender={false}
  1096. class={'popupBottomSearch'}
  1097. onOpen={() => {
  1098. forms.gradePopupShow = true;
  1099. }}
  1100. onClosed={() => {
  1101. forms.gradePopupShow = false;
  1102. }}>
  1103. {forms.gradePopupShow && (
  1104. <Picker
  1105. showToolbar
  1106. v-model={forms.gradePopupIndex}
  1107. columns={forms.gradeList}
  1108. onCancel={() => (forms.gradeStatus = false)}
  1109. onConfirm={(val: any) => {
  1110. const selectedOption = val.selectedOptions[0];
  1111. studentInfo.extra.currentGradeNum = selectedOption.value;
  1112. forms.gradeNumText = selectedOption.text;
  1113. forms.gradeStatus = false;
  1114. if (
  1115. ['SCHOOL', 'GRADE'].includes(forms.schoolInstrumentSetType)
  1116. ) {
  1117. forms.instrumentCode = selectedOption.instrumentCode;
  1118. }
  1119. if (forms.schoolInstrumentSetType === 'CLASS') {
  1120. forms.classList = selectedOption.classList || [];
  1121. }
  1122. if (
  1123. ['CLASS', 'GRADE'].includes(forms.schoolInstrumentSetType)
  1124. ) {
  1125. forms.currentClassText = '';
  1126. studentInfo.extra.currentClass = '';
  1127. }
  1128. }}
  1129. />
  1130. )}
  1131. </Popup>
  1132. {/* 班级 */}
  1133. <Popup
  1134. v-model:show={forms.classStatus}
  1135. position="bottom"
  1136. round
  1137. class={'popupBottomSearch'}
  1138. onOpen={() => {
  1139. forms.classPopupShow = true;
  1140. }}
  1141. onClosed={() => {
  1142. forms.classPopupShow = false;
  1143. }}>
  1144. {forms.classPopupShow && (
  1145. <Picker
  1146. showToolbar
  1147. v-model={forms.classPopupIndex}
  1148. columns={forms.classList}
  1149. onCancel={() => (forms.classStatus = false)}
  1150. onConfirm={(val: any) => {
  1151. const selectedOption = val.selectedOptions[0];
  1152. studentInfo.extra.currentClass = selectedOption.value;
  1153. forms.currentClassText = selectedOption.text;
  1154. forms.classStatus = false;
  1155. if (['CLASS'].includes(forms.schoolInstrumentSetType)) {
  1156. forms.instrumentCode = selectedOption.instrumentCode;
  1157. }
  1158. }}
  1159. />
  1160. )}
  1161. </Popup>
  1162. {/* 是否在微信中打开 */}
  1163. <OWxTip
  1164. show={forms.showTips}
  1165. message={forms.showMessage}
  1166. showButton={forms.showButton}
  1167. buttonText="刷新"
  1168. onConfirm={() => window.location.reload()}
  1169. />
  1170. <MMessageTip
  1171. show={otherParams.showOtherSchool}
  1172. // showCloseButton={otherParams.showCloseButton}
  1173. messageAlign={otherParams.messageAlign}
  1174. message={otherParams.showOtherMessage}
  1175. showCancelButton={otherParams.showCancelButton}
  1176. cancelButtonColor={otherParams.cancelButtonColor}
  1177. cancelButtonText={otherParams.cancelButtonText}
  1178. confirmButtonColor={otherParams.confirmButtonColor}
  1179. confirmButtonText={otherParams.confirmButtonText}
  1180. onClose={() => (otherParams.showOtherSchool = false)}
  1181. onCancel={async () => {
  1182. otherParams.showOtherSchool = false;
  1183. if (otherParams.otherType === 'nickname') {
  1184. forms.isRegister = 'create'; // 新建
  1185. studentInfo.autoRegister = true;
  1186. changeTipStatus(false, false);
  1187. onSubmit();
  1188. } else if (otherParams.otherType === 'member') {
  1189. const updateStatus = await updateStudentInfo();
  1190. if (!updateStatus) return;
  1191. //取消支付,判断是否有结束时间,是否已经结束
  1192. if (forms.registerExpireTime && forms.activeOverStatus) {
  1193. applyOver();
  1194. }
  1195. } else if (otherParams.otherType === 'payment') {
  1196. forms.joinType = 'tradition';
  1197. }
  1198. }}
  1199. onConfirm={async () => {
  1200. otherParams.showOtherSchool = false;
  1201. // 名字
  1202. if (otherParams.otherType === 'nickname') {
  1203. forms.isRegister = 'update'; // 修改
  1204. changeTipStatus(false, false);
  1205. // 直接注册
  1206. onSubmit();
  1207. } else if (otherParams.otherType === 'change') {
  1208. // 学校更换
  1209. forms.isChangeSchool = true;
  1210. // 直接注册
  1211. onSubmit();
  1212. } else if (otherParams.otherType === 'limit') {
  1213. // 人数超限制
  1214. changeTipStatus(
  1215. forms.isRegister === 'create' && !forms.studentItem.userId
  1216. ? false
  1217. : true,
  1218. false
  1219. );
  1220. } else if (otherParams.otherType === 'member') {
  1221. // await paymentContinue();
  1222. }
  1223. }}
  1224. />
  1225. <Popup
  1226. v-model:show={forms.showSelectStudent}
  1227. round
  1228. position="bottom"
  1229. safeAreaInsetBottom
  1230. closeable>
  1231. <SelectStudent
  1232. studentItem={forms.studentItem}
  1233. list={forms.studentList}
  1234. onClose={() => (forms.showSelectStudent = false)}
  1235. onConfirm={(val: any) => {
  1236. if (val.userId) {
  1237. forms.studentItem = val;
  1238. const firstStudent = val;
  1239. studentInfo.extra.nickname = firstStudent.nickname;
  1240. const tempGrade: any = forms.gradeList || [];
  1241. const tempArea = [] as any;
  1242. if (firstStudent.provinceName) {
  1243. tempArea.push(firstStudent.provinceName);
  1244. forms.provinceCode = firstStudent.provinceCode;
  1245. }
  1246. if (firstStudent.cityName) {
  1247. tempArea.push(firstStudent.cityName);
  1248. forms.cityCode = firstStudent.cityCode;
  1249. }
  1250. if (firstStudent.regionName) {
  1251. tempArea.push(firstStudent.regionName);
  1252. forms.regionCode = firstStudent.regionCode;
  1253. }
  1254. forms.areaName = tempArea.join(' ');
  1255. forms.schoolName = firstStudent.schoolName;
  1256. forms.schoolId = firstStudent.schoolId;
  1257. forms.schoolAreaId = firstStudent.schoolAreaId;
  1258. studentInfo.extra.currentGradeNum = null;
  1259. forms.gradeNumText = '';
  1260. forms.instrumentCode = '';
  1261. tempGrade?.forEach((i: any) => {
  1262. if (i.value === firstStudent.currentGradeNum) {
  1263. forms.instrumentCode = i.instrumentCode;
  1264. forms.gradeNumText = i.text;
  1265. studentInfo.extra.currentGradeNum =
  1266. firstStudent.currentGradeNum;
  1267. if (forms.schoolInstrumentSetType === 'CLASS') {
  1268. forms.classList = i.classList;
  1269. }
  1270. }
  1271. });
  1272. studentInfo.extra.currentClass = null;
  1273. forms.currentClassText = '';
  1274. forms.classList.forEach((i: any) => {
  1275. if (i.value === firstStudent.currentClass) {
  1276. forms.currentClassText = i.text;
  1277. studentInfo.extra.currentClass = firstStudent.currentClass;
  1278. }
  1279. });
  1280. studentInfo.extra.gender = firstStudent.gender;
  1281. forms.isRegister = 'update';
  1282. changeTipStatus(true, false);
  1283. forms.showSelectStudent = false;
  1284. } else {
  1285. // 判断新建学员是否上限了
  1286. if (forms.studentList.length >= forms.multi_user_limit) {
  1287. otherParams.showOtherMessage = `同一手机号最多创建${forms.multi_user_limit}个学生`;
  1288. otherParams.showOtherSchool = true;
  1289. otherParams.showCancelButton = false;
  1290. otherParams.showCloseButton = true;
  1291. otherParams.confirmButtonColor =
  1292. 'linear-gradient( 305deg, #40C8FF 0%, #3192FF 100%)';
  1293. otherParams.confirmButtonText = '我知道了';
  1294. otherParams.otherType = 'limit';
  1295. otherParams.messageAlign = 'center';
  1296. return true;
  1297. } else {
  1298. forms.studentItem = val;
  1299. forms.isRegister = 'create';
  1300. studentInfo.autoRegister = true;
  1301. changeTipStatus(false, false);
  1302. forms.areaName = '';
  1303. forms.schoolName = '';
  1304. forms.schoolAreaId = null;
  1305. forms.schoolId = null;
  1306. studentInfo.extra.nickname = '';
  1307. studentInfo.extra.currentGradeNum = '';
  1308. studentInfo.extra.currentClass = '';
  1309. studentInfo.extra.gender = 1;
  1310. forms.currentClassText = '';
  1311. forms.gradeNumText = '';
  1312. forms.showSelectStudent = false;
  1313. }
  1314. }
  1315. }}
  1316. />
  1317. </Popup>
  1318. <Popup
  1319. v-model:show={forms.showPicker}
  1320. position="bottom"
  1321. round
  1322. class={'popupBottomSearch'}>
  1323. <Area
  1324. areaList={forms.areaList}
  1325. onCancel={() => (forms.showPicker = false)}
  1326. onConfirm={({ selectedOptions }) => {
  1327. forms.provinceCode = selectedOptions[0].value;
  1328. forms.cityCode = selectedOptions[1].value;
  1329. forms.regionCode = selectedOptions[2]?.value;
  1330. forms.areaName = selectedOptions
  1331. .map((item: any) => item.text)
  1332. .join(' ');
  1333. forms.showPicker = false;
  1334. forms.schoolId = null;
  1335. forms.schoolAreaId = null;
  1336. forms.schoolName = '';
  1337. forms.gradeNumText = '';
  1338. studentInfo.extra.currentGradeNum = null;
  1339. forms.currentClassText = '';
  1340. studentInfo.extra.currentClass = null;
  1341. getSchoolAreaList();
  1342. }}
  1343. />
  1344. </Popup>
  1345. <Popup
  1346. show={forms.showConfirmPopup}
  1347. style={{
  1348. background: 'transparent',
  1349. overflow: 'visible !important'
  1350. }}>
  1351. <CodeDialog type="INFO" showButton={false}>
  1352. <div class={styles.studentInfo}>
  1353. <Cell
  1354. border={false}
  1355. title="学生姓名"
  1356. value={studentInfo.extra.nickname}></Cell>
  1357. <Cell
  1358. border={false}
  1359. title="学生性别"
  1360. value={studentInfo.extra.gender === 1 ? '男' : '女'}></Cell>
  1361. <Cell
  1362. border={false}
  1363. title="所在地区"
  1364. value={forms.areaName}></Cell>
  1365. <Cell
  1366. border={false}
  1367. title="互通学校"
  1368. value={forms.schoolName}></Cell>
  1369. <Cell
  1370. border={false}
  1371. title="所在年级"
  1372. value={forms.gradeNumText}></Cell>
  1373. <Cell
  1374. border={false}
  1375. title="所在班级"
  1376. value={forms.currentClassText}></Cell>
  1377. {!route.query.code && (
  1378. <Cell
  1379. border={false}
  1380. title="互通码"
  1381. value={forms.activationCode}></Cell>
  1382. )}
  1383. </div>
  1384. <div class={styles.studentBtnGroup}>
  1385. <Button
  1386. round
  1387. block
  1388. onClick={() => (forms.showConfirmPopup = false)}>
  1389. 取消
  1390. </Button>
  1391. <Button
  1392. round
  1393. block
  1394. disabled={forms.submitLoading}
  1395. loading={forms.submitLoading}
  1396. color="linear-gradient( 305deg, #3192FF 0%, #40C8FF 100%)"
  1397. onClick={() => {
  1398. forms.showConfirmPopup = false;
  1399. onSubmit();
  1400. }}>
  1401. 确认
  1402. </Button>
  1403. </div>
  1404. </CodeDialog>
  1405. </Popup>
  1406. <Popup
  1407. show={forms.showResultPopup}
  1408. style={{
  1409. background: 'transparent',
  1410. overflow: 'visible !important'
  1411. }}>
  1412. <CodeDialog
  1413. type={forms.reslutPopupType}
  1414. btnText={
  1415. forms.reslutPopupType === 'ACTIVATING' ||
  1416. forms.reslutPopupType === 'ACTIVATING-TWO'
  1417. ? '立即下载激活'
  1418. : '我知道了'
  1419. }
  1420. onConfirm={() => {
  1421. //
  1422. if (
  1423. forms.reslutPopupType === 'ACTIVATING' ||
  1424. forms.reslutPopupType === 'ACTIVATING-TWO'
  1425. ) {
  1426. router.push('/download');
  1427. } else {
  1428. forms.showResultPopup = false;
  1429. }
  1430. }}>
  1431. {forms.reslutPopupType === 'ACTIVATING' && (
  1432. <p>
  1433. 请下载
  1434. <span style={{ color: '#2B85FF' }}>【音乐数字课堂App】</span>
  1435. ,使用手机号激活,实现音乐课堂互通互联
  1436. </p>
  1437. )}
  1438. {forms.reslutPopupType === 'ACTIVATING-TWO' && (
  1439. <p>
  1440. 您已使用该互通码,请勿重复提交,请下载
  1441. <span style={{ color: '#2B85FF' }}>【音乐数字课堂】</span>
  1442. 实现互通互联
  1443. </p>
  1444. )}
  1445. {['INVALID', 'EXPIRED', 'CANCELLED', 'OVERDUE'].includes(
  1446. forms.reslutPopupType
  1447. ) && (
  1448. <p style={{ textAlign: 'center', paddingTop: '5px' }}>
  1449. {forms.resultPopupContent}
  1450. </p>
  1451. )}
  1452. </CodeDialog>
  1453. </Popup>
  1454. </div>
  1455. );
  1456. }
  1457. });