index.tsx 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485
  1. import {
  2. Image,
  3. Cell,
  4. Tag,
  5. Button,
  6. Popup,
  7. showToast,
  8. Form,
  9. Field,
  10. CountDown,
  11. RadioGroup,
  12. Radio,
  13. Picker,
  14. closeToast
  15. } from 'vant';
  16. import {
  17. computed,
  18. defineComponent,
  19. nextTick,
  20. onMounted,
  21. onUnmounted,
  22. reactive,
  23. ref,
  24. watch
  25. } from 'vue';
  26. import TCPlayer from 'tcplayer.js';
  27. import 'tcplayer.js/dist/tcplayer.css';
  28. import qs from 'query-string';
  29. import {
  30. state as baseState,
  31. goWechatAuth,
  32. setLogin,
  33. setLoginInit
  34. } from '@/state';
  35. import styles from './index.module.less';
  36. import MSticky from '@/components/m-sticky';
  37. // import MVideo from '@/components/m-video';
  38. import { useRoute, useRouter } from 'vue-router';
  39. import { useStudentRegisterStore } from '@/store/modules/student-register-store';
  40. import request from '@/helpers/request';
  41. import requestStudent from './request';
  42. import { browser, checkPhone, getHttpOrigin, getUrlCode, moneyFormat } from '@/helpers/utils';
  43. import deepClone from '@/helpers/deep-clone';
  44. import OWxTip from '@/components/m-wx-tip';
  45. import MDialog from '@/components/m-dialog';
  46. // import f1 from './images/new/f-1.png';
  47. // import f2 from './images/new/f-2.png';
  48. // import f3 from './images/new/f-3.png';
  49. // import iconTip2 from './images/new/icon-tip2.png';
  50. // import functionBg from './images/new/function-bg.png';
  51. // import tuangou from './images/new/tuangou.png';
  52. import icon3 from './images/new/icon-3.png';
  53. // import icon5 from './images/new/icon-7.png';
  54. // import icon6 from './images/new/icon-6.png';
  55. import giftTip from './images/new/icon-9.png';
  56. import iconGift from './images/new/icon-gift.png';
  57. import vipGiftTIps from './images/new/vip_gift_tips.png';
  58. import icon10 from './images/new/icon-n-10.png';
  59. import icon11 from './images/new/icon-n-11.png';
  60. import dayjs from 'dayjs';
  61. // import MMessageTip from '@/components/m-message-tip';
  62. import { CurrentTime, useCountDown, usePageVisibility } from '@vant/use';
  63. import Payment from '../adapay/payment';
  64. import QrcodePayment from './qrcode-payment';
  65. import MImgCode from '@/components/m-img-code';
  66. import { beforeSubmit } from './order-state';
  67. import { useInterval, useIntervalFn } from '@vueuse/core';
  68. import MPopup from '@/components/m-popup';
  69. import UserAuth from './component/user-auth';
  70. import MMessageTip from '@/components/m-message-tip';
  71. import SelectStudent from './modal/select-student';
  72. import { Timer } from './timer';
  73. const classList: any = [];
  74. for (let i = 1; i <= 40; i++) {
  75. classList.push({ text: i + '班', value: i });
  76. }
  77. const GRADE_ENUM = {
  78. '1': '一年级',
  79. '2': '二年级',
  80. '3': '三年级',
  81. '4': '四年级',
  82. '5': '五年级',
  83. '6': '六年级',
  84. '7': '七年级',
  85. '8': '八年级',
  86. '9': '九年级'
  87. } as any;
  88. const getGradeList = (gradeYear: string, instrumentCode?: string) => {
  89. let tempList: any = [];
  90. const five = [
  91. { text: '一年级', value: 1, instrumentCode },
  92. { text: '二年级', value: 2, instrumentCode },
  93. { text: '三年级', value: 3, instrumentCode },
  94. { text: '四年级', value: 4, instrumentCode },
  95. { text: '五年级', value: 5, instrumentCode }
  96. ];
  97. const one = [{ text: '六年级', value: 6, instrumentCode }];
  98. const three = [
  99. { text: '七年级', value: 7, instrumentCode },
  100. { text: '八年级', value: 8, instrumentCode },
  101. { text: '九年级', value: 9, instrumentCode }
  102. ];
  103. if (gradeYear === 'FIVE_YEAR_SYSTEM') {
  104. tempList.push(...[...five]);
  105. } else if (gradeYear === 'SIX_YEAR_SYSTEM') {
  106. tempList.push(...[...five, ...one]);
  107. } else if (gradeYear === 'THREE_YEAR_SYSTEM') {
  108. tempList.push(...[...three]);
  109. } else if (gradeYear === 'FORE_YEAR_SYSTEM') {
  110. tempList.push(...[...one, ...three]);
  111. } else {
  112. tempList.push(...[...five, ...one, ...three]);
  113. }
  114. return tempList;
  115. };
  116. export const vipGiftPeriodType = {
  117. DAY: '天',
  118. MONTH: '个月',
  119. YEAR: '年'
  120. } as any;
  121. export default defineComponent({
  122. name: 'student-register',
  123. setup() {
  124. const route = useRoute();
  125. const pageVisibility = usePageVisibility();
  126. const studentRegisterStore = useStudentRegisterStore();
  127. const router = useRouter();
  128. // 初始化学校编号
  129. studentRegisterStore.setShoolId(route.query.sId as any);
  130. const countDownRef = ref();
  131. const mstickyRef = ref();
  132. const forms = reactive({
  133. schoolId: route.query.sId as any,
  134. paymentType: '', // 支付类型
  135. paymentChannel: '',
  136. multi_user_limit: 1, // 限制注册学生数量
  137. // popupShow: false,
  138. registerDetails: {} as any,
  139. details: [] as any,
  140. // schoolType: '', // 学校类型
  141. gradeYear: '', // 学制
  142. schoolInstrumentSetType: null as any,
  143. // bugGoods: false, // 是否购买AI
  144. isRegister: 'create' as 'create' | 'update' | '', // 是否注册学生
  145. isTipRegister: false, // 是否显示名字不一致 - 默认显示
  146. isChangeSchool: false, // 是否切换学校
  147. registerType: '', // 报名类型
  148. detailVip: {} as any,
  149. giftVipDay: 0, // 赠送天数
  150. submitLoading: false,
  151. // showMore: true,
  152. showTips: false,
  153. showButton: false,
  154. showMessage: '请使用微信扫描二维码',
  155. countDownStatus: true,
  156. countDownTime: 1000 * 120, // 倒计时时间
  157. // modelValue: false, // 是否选中协议
  158. imgCodeStatus: false,
  159. gradeNumText: '',
  160. currentClassText: '',
  161. gradeStatus: false,
  162. classStatus: false,
  163. loading: false,
  164. dialogStatus: false,
  165. dialogMessage: '',
  166. confirmButtonText: '确定',
  167. cancelButtonText: '取消',
  168. messageAlign: 'center' as 'left' | 'center' | 'right',
  169. showDuration: true,
  170. dialogConfirmStatus: false,
  171. contract_sign: false, // 是否实名认证
  172. countDownTimePay: 60 * 1000,
  173. dialogConfig: {} as any,
  174. showSelectStudent: false, // 选择学生
  175. studentList: [], // 手机号关联学生列表
  176. studentItem: {} as any, // 选择的学生
  177. joinType: '' as 'digitalize' | 'tradition',
  178. gradeList: [] as any,
  179. classList: [] as any,
  180. saveUserId: null as any,
  181. saveId: null as any,
  182. openId: null as any,
  183. code: null as any,
  184. intervalFnRef: null as any, // 页面订时器
  185. registerExpireTime: null as any, // 结束时间
  186. instrumentCode: null as any, // 乐器编码
  187. activeOverTime: 0, // 活动结束时间
  188. activeOverStatus: true, // 活动是否结束 默认已结束
  189. gradePopupShow: false,
  190. gradePopupIndex: [] as any, // 年级下拉索引
  191. classPopupShow: false,
  192. classPopupIndex: [] as any // 班级下拉索引
  193. });
  194. const otherParams = reactive({
  195. showOtherSchool: false,
  196. showCloseButton: true, // 是否显示关闭按钮
  197. showOtherMessage: '',
  198. /** limit 超限制,change 更换学生,nickname 名称不一致 */
  199. otherType: '' as 'limit' | 'change' | 'nickname' | 'member',
  200. showCancelButton: true,
  201. cancelButtonColor: '',
  202. cancelButtonText: '取消',
  203. showConfirmButton: true,
  204. confirmButtonColor: '',
  205. confirmButtonText: '确定',
  206. messageAlign: 'left' as 'center' | 'left' | 'right'
  207. });
  208. const state = reactive({
  209. showQrcode: false,
  210. qrCodeUrl: '',
  211. pay_channel: '',
  212. orderInfo: {} as any, // 订单信息
  213. authShow: false,
  214. orderNo: null as any,
  215. config: {} as any,
  216. paymentStatus: false,
  217. orderTimer: null as any
  218. });
  219. const studentInfo = reactive({
  220. autoRegister: true,
  221. multiUser: true, // 是否为多用户
  222. client_id: 'cooleshow-student',
  223. client_secret: 'cooleshow-student',
  224. extra: {
  225. nickname: '',
  226. currentGradeNum: '' as any,
  227. currentClass: '' as any,
  228. gender: 1 as any,
  229. registerType: null as any, // 报名类型
  230. giftVipDay: 0 // 赠送会员天数
  231. },
  232. grant_type: 'password',
  233. loginType: 'SMS',
  234. password: '',
  235. username: ''
  236. });
  237. const videoForms = reactive({
  238. introductionVideo: '',
  239. introductionVideoTime: 0, // 视频总时长
  240. videoBrowsePoint: 0, // 视频最后观看点
  241. player: null as any,
  242. playerSpeed: 1,
  243. intervalFnRef: null as any,
  244. videoDetails: [] as any, // 节点列表
  245. pointVideo: {} as any, // 需要处理有效的时间段
  246. pointVideoTime: 0 // 有效时长
  247. });
  248. // 播放视频总时长
  249. const videoIntervalRef = useInterval(1000, {
  250. controls: true
  251. });
  252. videoIntervalRef.pause();
  253. const timer = new Timer();
  254. // 页面定时
  255. const pageTimer = useInterval(1000, { controls: true });
  256. pageTimer.pause();
  257. /**
  258. * 格式化视屏播放有效时间 - 合并区间
  259. * @param intervals [[], []]
  260. * @example [[4, 8],[0, 4],[10, 30]]
  261. * @returns [[0, 8], [10, 30]]
  262. */
  263. const formatEffectiveTime = (intervals: any[]) => {
  264. const res: any = [];
  265. intervals.sort((a, b) => a[0] - b[0]);
  266. let prev = intervals[0];
  267. for (let i = 1; i < intervals.length; i++) {
  268. const cur = intervals[i];
  269. if (prev[1] >= cur[0]) {
  270. // 有重合
  271. prev[1] = Math.max(cur[1], prev[1]);
  272. } else {
  273. // 不重合,prev推入res数组
  274. res.push(prev);
  275. prev = cur; // 更新 prev
  276. }
  277. }
  278. res.push(prev);
  279. return res;
  280. };
  281. /**
  282. * 获取数据有效期
  283. * @param intervals [[], []]
  284. * @returns 0s
  285. */
  286. const formatTimer = (intervals: any[]) => {
  287. const afterIntervals = formatEffectiveTime(intervals);
  288. // console.log(afterIntervals, 'afterIntervals')
  289. let time = 0;
  290. afterIntervals.forEach((t: any) => {
  291. time += t[1] - t[0];
  292. });
  293. return time;
  294. };
  295. const overCountDown = useCountDown({
  296. time: forms.activeOverTime,
  297. onFinish() {
  298. forms.activeOverStatus = true;
  299. if (forms.submitLoading) return;
  300. applyOver();
  301. }
  302. });
  303. /** 报名结束提示 */
  304. const applyOver = () => {
  305. forms.showTips = true;
  306. forms.showMessage = `<p style="color: #F44541">报名已截止,感谢您的参与</p>`;
  307. forms.showButton = false;
  308. forms.intervalFnRef?.pause();
  309. };
  310. const onCodeSend = () => {
  311. forms.countDownStatus = false;
  312. nextTick(() => {
  313. countDownRef.value.start();
  314. });
  315. };
  316. const onSendCode = () => {
  317. // 发送验证码
  318. if (!checkPhone(studentInfo.username)) {
  319. return showToast('请输入正确的手机号码');
  320. }
  321. forms.imgCodeStatus = true;
  322. };
  323. const validatePhone = computed(() => {
  324. return checkPhone(studentInfo.username) ? true : false;
  325. });
  326. const onFinished = () => {
  327. forms.countDownStatus = true;
  328. countDownRef.value.reset();
  329. };
  330. const orderType = computed(() => {
  331. return state.orderInfo.orderType;
  332. });
  333. const getRegisterGoods = async () => {
  334. try {
  335. const { data } = await request.get(
  336. '/edu-app/open/userOrder/registerGoods/' + forms.schoolId,
  337. {
  338. noAuthorization: true // 是否请求接口的时候添加toekn
  339. }
  340. );
  341. // 默认选中商品
  342. studentRegisterStore.setVip(data.details || []);
  343. forms.details = deepClone(data.details || []);
  344. forms.registerDetails = data;
  345. forms.registerExpireTime = data.registerExpireTime; // '2024-03-27 17:33:52'; //
  346. if (forms.registerExpireTime) {
  347. if (dayjs(new Date()).isBefore(forms.registerExpireTime)) {
  348. // 活动没有结束
  349. forms.activeOverStatus = false;
  350. // 默认返回毫秒
  351. forms.activeOverTime = dayjs(forms.registerExpireTime).diff(
  352. dayjs(new Date())
  353. );
  354. overCountDown.reset(forms.activeOverTime);
  355. overCountDown.start();
  356. } else {
  357. applyOver();
  358. forms.activeOverStatus = true;
  359. }
  360. }
  361. if (forms.details.length > 0) {
  362. forms.detailVip = forms.details[0];
  363. // forms.giftVipDay = forms.details[0].membershipDays;
  364. }
  365. forms.giftVipDay = data.giftVipDay || 0;
  366. forms.gradeYear = data.gradeYear;
  367. forms.schoolInstrumentSetType = data.schoolInstrumentSetType;
  368. forms.registerType = data.registerType;
  369. studentInfo.extra.registerType = data.registerType;
  370. const schoolInstrumentList = data.schoolInstrumentList || [];
  371. if (data.schoolInstrumentSetType === 'SCHOOL') {
  372. const instrumentCode = schoolInstrumentList[0]?.instrumentCode;
  373. forms.gradeList = getGradeList(data.gradeYear, instrumentCode);
  374. forms.classList = classList;
  375. } else if (data.schoolInstrumentSetType === 'GRADE') {
  376. schoolInstrumentList.forEach((item: any) => {
  377. forms.gradeList.push({
  378. text: GRADE_ENUM[item.gradeNum],
  379. value: item.gradeNum,
  380. instrumentId: item.instrumentId,
  381. instrumentCode: item.instrumentCode
  382. });
  383. });
  384. forms.gradeList.sort((a: any, b: any) => a.value - b.value);
  385. forms.classList = classList;
  386. } else if (data.schoolInstrumentSetType === 'CLASS') {
  387. // 班级
  388. const tempGradeList: any[] = [];
  389. schoolInstrumentList.forEach((item: any) => {
  390. if (!tempGradeList.includes(item.gradeNum)) {
  391. tempGradeList.push(item.gradeNum);
  392. }
  393. });
  394. const lastGradeList: any[] = [];
  395. tempGradeList.forEach((temp: any) => {
  396. const list = {
  397. text: GRADE_ENUM[temp],
  398. value: temp,
  399. instrumentId: '',
  400. instrumentCode: '',
  401. instrumentName: '',
  402. classList: [] as any
  403. };
  404. schoolInstrumentList.forEach((item: any) => {
  405. if (temp === item.gradeNum) {
  406. list.instrumentId = item.instrumentId;
  407. list.instrumentCode = item.instrumentCode;
  408. list.instrumentName = item.instrumentName;
  409. list.classList.push({
  410. text: item.classNum + '班',
  411. value: item.classNum,
  412. instrumentCode: item.instrumentCode
  413. });
  414. }
  415. });
  416. // 排序班级
  417. list.classList.sort((a: any, b: any) => a.value - b.value);
  418. lastGradeList.push(list);
  419. });
  420. lastGradeList.sort((a: any, b: any) => a.value - b.value);
  421. forms.gradeList = lastGradeList;
  422. forms.classList = [];
  423. } else {
  424. forms.gradeList = getGradeList(data.gradeYear);
  425. forms.classList = classList;
  426. }
  427. if (browser().weixin) {
  428. // if (
  429. // data.schoolStatus === 0 &&
  430. // forms.schoolId == '1770035687490105346'
  431. // ) {
  432. // forms.showTips = true;
  433. // forms.showMessage = `<p style="color: #F44541">报名已截止,感谢您的参与</p>`;
  434. // forms.showButton = false;
  435. // return;
  436. // }
  437. if (data.registerType !== 'BUG_GOODS' || data.schoolStatus === 0) {
  438. forms.showTips = true;
  439. forms.showMessage = '二维码已经失效,详情请咨询学校老师';
  440. forms.showButton = false;
  441. return;
  442. }
  443. } else {
  444. forms.showTips = true;
  445. return;
  446. }
  447. // 判断是否有倒计时,倒计时是滞结束
  448. if (!forms.registerExpireTime || !forms.activeOverStatus) {
  449. pagePointInit();
  450. }
  451. } catch {}
  452. };
  453. // 计算金额
  454. const calcPrice = computed(() => {
  455. let amount: number = 0; //现价
  456. let originAmount: number = 0; // 原价
  457. const vipList: any[] = studentRegisterStore.getVip;
  458. vipList.forEach((vip: any) => {
  459. amount += Number(vip.currentPrice);
  460. originAmount += Number(vip.originalPrice);
  461. });
  462. // const goodsList: any[] = studentRegisterStore.getGoods;
  463. // goodsList.forEach((good: any) => {
  464. // amount += Number(good.price) * good.quantity;
  465. // originAmount += Number(good.originalPrice) * good.quantity;
  466. // });
  467. return {
  468. amount,
  469. originAmount
  470. };
  471. });
  472. // 格式化提示状态
  473. const changeTipStatus = (register: boolean, school: boolean) => {
  474. forms.isTipRegister = register;
  475. forms.isChangeSchool = school;
  476. };
  477. const checkForm = (status = true) => {
  478. if (!checkPhone(studentInfo.username)) {
  479. status && showToast('请输入正确的手机号码');
  480. return true;
  481. } else if (!studentInfo.password) {
  482. status && showToast('请输入验证码');
  483. return true;
  484. } else if (!studentInfo.extra.nickname) {
  485. status && showToast('请输入学生姓名');
  486. return true;
  487. } else if (![0, 1].includes(studentInfo.extra.gender)) {
  488. status && showToast('请选择性别');
  489. return true;
  490. } else if (!studentInfo.extra.currentGradeNum) {
  491. status && showToast('请选择所在年级');
  492. return true;
  493. } else if (!studentInfo.extra.currentClass) {
  494. status && showToast('请选择所在班级');
  495. return true;
  496. }
  497. return false;
  498. };
  499. //
  500. const checkSubmit = () => {
  501. const { extra } = studentInfo;
  502. // console.log(
  503. // forms.studentItem.nickname,
  504. // extra.nickname,
  505. // forms.isRegister,
  506. // forms.isTipRegister,
  507. // 'isRegister'
  508. // );
  509. if (
  510. forms.studentItem.nickname !== extra.nickname &&
  511. forms.isTipRegister
  512. ) {
  513. otherParams.showOtherMessage =
  514. '学生姓名与上次提交信息不一致,请确认修改学生信息或创建新的学生账号';
  515. otherParams.showOtherSchool = true;
  516. otherParams.showCancelButton = true;
  517. otherParams.showCloseButton = true;
  518. otherParams.cancelButtonColor =
  519. 'linear-gradient( 224deg, #3FE1E6 0%, #00CDD4 100%)';
  520. otherParams.cancelButtonText = '新建学生';
  521. otherParams.confirmButtonColor =
  522. 'linear-gradient( 305deg, #40C8FF 0%, #3192FF 100%)';
  523. otherParams.confirmButtonText = '修改信息';
  524. otherParams.otherType = 'nickname';
  525. otherParams.messageAlign = 'left';
  526. return true;
  527. }
  528. // 判断新建学员是否上限了
  529. if (
  530. forms.isRegister === 'create' &&
  531. forms.studentList.length >= forms.multi_user_limit
  532. ) {
  533. otherParams.showOtherMessage = `同一手机号最多创建${forms.multi_user_limit}个学生`;
  534. otherParams.showOtherSchool = true;
  535. otherParams.showCancelButton = false;
  536. otherParams.showCloseButton = true;
  537. otherParams.confirmButtonColor =
  538. 'linear-gradient( 305deg, #40C8FF 0%, #3192FF 100%)';
  539. otherParams.confirmButtonText = '我知道了';
  540. otherParams.otherType = 'limit';
  541. otherParams.messageAlign = 'center';
  542. return true;
  543. }
  544. // 判断是否为同一个学校
  545. if (
  546. forms.studentItem.schoolId &&
  547. forms.studentItem.schoolId !== forms.registerDetails.schoolId &&
  548. !forms.isChangeSchool &&
  549. forms.isRegister === 'update'
  550. ) {
  551. otherParams.showOtherMessage = `您已绑定<span style="color: #2B85FF">【${
  552. forms.studentItem?.schoolName || ''
  553. }】</span>,提交后将更换到
  554. <span style="color: #2B85FF">【${
  555. forms.registerDetails.schoolName || ''
  556. }】</span>
  557. ,是否确认提交?`;
  558. otherParams.showOtherSchool = true;
  559. otherParams.showCloseButton = false;
  560. otherParams.showCancelButton = true;
  561. otherParams.cancelButtonColor = '';
  562. otherParams.cancelButtonText = '取消';
  563. otherParams.confirmButtonColor = '';
  564. otherParams.confirmButtonText = '确定';
  565. otherParams.otherType = 'change';
  566. otherParams.messageAlign = 'left';
  567. return true;
  568. }
  569. return false;
  570. };
  571. /**
  572. * 登记成功之后购买
  573. */
  574. const onSubmit = async () => {
  575. forms.submitLoading = true;
  576. forms.intervalFnRef.pause();
  577. try {
  578. if (checkForm() || checkSubmit()) {
  579. forms.submitLoading = false;
  580. return;
  581. }
  582. const { extra, loginType, autoRegister, password, multiUser, ...res } =
  583. studentInfo;
  584. /*
  585. 新用户:
  586. autoRegister: true
  587. loginType: 'SMS'
  588. 已存在用户:
  589. autoRegister: false
  590. loginType: 'TOKEN'
  591. password: xxx
  592. */
  593. let tLoginType = loginType,
  594. tAutoRegister = autoRegister,
  595. tPassword = password,
  596. tMultiUser = multiUser;
  597. if (forms.isRegister === 'update') {
  598. tLoginType = 'TOKEN';
  599. tAutoRegister = false;
  600. tPassword = forms.studentItem.token;
  601. tMultiUser = false;
  602. }
  603. const result = await request.post('/edu-app/userlogin', {
  604. requestType: 'form',
  605. data: {
  606. loginType: tLoginType,
  607. autoRegister: tAutoRegister,
  608. password: tPassword,
  609. multiUser: tMultiUser,
  610. ...res,
  611. extra: JSON.stringify({
  612. ...extra,
  613. giftVipDay: forms.giftVipDay || 0,
  614. schoolId: forms.schoolId
  615. })
  616. }
  617. });
  618. if (result.code !== 200) {
  619. if (result.code === 5436) {
  620. forms.showTips = true;
  621. forms.showMessage = '二维码已经失效,详情请咨询学校老师';
  622. forms.showButton = false;
  623. } else if (result.code === 5435) {
  624. forms.showTips = true;
  625. forms.showMessage = result.message;
  626. forms.showButton = true;
  627. } else if (result.code === 5437) {
  628. forms.showTips = true;
  629. forms.showMessage = `<p style="color: #F44541">报名已截止,感谢您的参与</p>`; //result.message;
  630. forms.showButton = false;
  631. }
  632. } else {
  633. studentRegisterStore.setToken(
  634. result.data.token_type + ' ' + result.data.access_token
  635. );
  636. setLoginInit();
  637. let joinType = 'NOT_REGISTER';
  638. if (forms.joinType === 'digitalize') {
  639. joinType = 'SELECT_INSTRUMENT';
  640. }
  641. if (forms.joinType === 'tradition') {
  642. joinType = 'NOT_BUY_INSTRUMENT';
  643. }
  644. // 单独存入时间,为了解决视频播放统计不全的问题
  645. await updateStat(pageTimer.counter.value);
  646. // 更新时间
  647. const id = await updateStat(
  648. pageTimer.counter.value,
  649. joinType,
  650. result.data.userId,
  651. forms.schoolId
  652. );
  653. forms.saveId = id;
  654. forms.saveUserId = id;
  655. pageTimer.counter.value = 0;
  656. // 获取用户信息
  657. const res = await request.get('/edu-app/user/getUserInfo', {
  658. requestType: 'form'
  659. });
  660. setLogin(res.data);
  661. await onRegisterSubmit();
  662. }
  663. } catch {
  664. // 重置信息 - 如果是新建则不提示
  665. changeTipStatus(forms.isRegister === 'create' ? false : true, false);
  666. } finally {
  667. forms.submitLoading = false;
  668. forms.intervalFnRef.resume();
  669. }
  670. };
  671. const updateStudentInfo = async () => {
  672. try {
  673. const { extra, username } = studentInfo;
  674. const registerResult = await request.post('/edu-app/student/register', {
  675. data: {
  676. schoolId: forms.schoolId,
  677. clientType: 'STUDENT',
  678. ...extra,
  679. giftVipFlag: forms.registerDetails.giftVipFlag || false,
  680. giftVipDay: forms.giftVipDay || 0,
  681. schoolVerify: true,
  682. firstVipDay: forms.detailVip.membershipDays || 0,
  683. mobile: username,
  684. newRegUser: forms.isRegister === 'create' ? true : false
  685. }
  686. });
  687. if (registerResult.code !== 200) {
  688. if (registerResult.code === 5436) {
  689. forms.showTips = true;
  690. forms.showMessage = '二维码已经失效,详情请咨询学校老师';
  691. forms.showButton = false;
  692. } else if (registerResult.code === 5435) {
  693. forms.showTips = true;
  694. forms.showMessage = registerResult.message;
  695. forms.showButton = true;
  696. } else if (registerResult.code === 5437) {
  697. forms.showTips = true;
  698. forms.showMessage = `<p style="color: #F44541">报名已截止,感谢您的参与</p>`; //result.message;
  699. forms.showButton = false;
  700. }
  701. return false;
  702. } else {
  703. return true;
  704. }
  705. } catch {}
  706. };
  707. // 登记成功之后购买
  708. const onRegisterSubmit = async () => {
  709. try {
  710. // 请求是否有待支付订单,如果有则自动关闭
  711. const status = await paymentOrderUnpaid();
  712. if (status) return;
  713. const schoolInfo = await request.get(
  714. '/edu-app/userPaymentOrder/registerStatus/' + forms.schoolId
  715. );
  716. const vipList = studentRegisterStore.getVip;
  717. // 传统方式
  718. if (forms.joinType === 'tradition') {
  719. const updateStatus = await updateStudentInfo();
  720. if (!updateStatus) return;
  721. setTimeout(() => {
  722. showToast('报名成功');
  723. // router.push('/download');
  724. }, 100);
  725. setTimeout(() => {
  726. if (browser().weixin) {
  727. // 关闭微信
  728. (window as any).WeixinJSBridge.call('closeWindow');
  729. }
  730. }, 1000);
  731. return;
  732. }
  733. if (schoolInfo.data.hasBuyCourse && vipList.length > 0) {
  734. // forms.dialogConfirmStatus = true;
  735. otherParams.showOtherMessage = `该学员已购买会员,是否再次购买?`;
  736. otherParams.showOtherSchool = true;
  737. otherParams.showCloseButton = false;
  738. otherParams.showCancelButton = true;
  739. otherParams.cancelButtonColor = '';
  740. otherParams.cancelButtonText = '取消';
  741. otherParams.confirmButtonColor = '';
  742. otherParams.confirmButtonText = '确定';
  743. otherParams.otherType = 'member';
  744. otherParams.messageAlign = 'center';
  745. return;
  746. }
  747. await paymentContinue();
  748. } catch {
  749. // 重置信息 - 如果是新建则不提示
  750. changeTipStatus(forms.isRegister === 'create' ? false : true, false);
  751. }
  752. };
  753. const getUserInfos = async () => {
  754. if (
  755. studentInfo.password.length !== 6 ||
  756. !checkPhone(studentInfo.username)
  757. ) {
  758. return;
  759. }
  760. try {
  761. // 15907120131;
  762. const { data } = await request.get(
  763. `/edu-app/open/student/studentInfo?mobile=${studentInfo.username}&code=${studentInfo.password}&type=REGISTER&activationCodeFlag=1`
  764. );
  765. forms.studentList = data || [];
  766. if (forms.studentList.length > 0) {
  767. const firstStudent: any = forms.studentList[0];
  768. forms.studentItem = firstStudent;
  769. studentInfo.extra.nickname = firstStudent.nickname;
  770. const tempGrade: any = forms.gradeList || [];
  771. tempGrade?.forEach((i: any) => {
  772. if (i.value === firstStudent.currentGradeNum) {
  773. forms.instrumentCode = i.instrumentCode;
  774. forms.gradeNumText = i.text;
  775. studentInfo.extra.currentGradeNum = firstStudent.currentGradeNum;
  776. if (forms.schoolInstrumentSetType === 'CLASS') {
  777. forms.classList = i.classList;
  778. }
  779. }
  780. });
  781. forms.classList.forEach((i: any) => {
  782. if (i.value === firstStudent.currentClass) {
  783. forms.currentClassText = i.text;
  784. studentInfo.extra.currentClass = firstStudent.currentClass;
  785. }
  786. });
  787. studentInfo.extra.gender = firstStudent.gender;
  788. forms.isRegister = 'update';
  789. changeTipStatus(true, false);
  790. } else {
  791. forms.isRegister = 'create';
  792. changeTipStatus(false, false);
  793. forms.studentItem = [];
  794. }
  795. } catch {
  796. //
  797. }
  798. };
  799. // 查询未支付订单
  800. const paymentOrderUnpaid = async () => {
  801. let result = false;
  802. try {
  803. const { data } = await request.get(
  804. '/edu-app/userPaymentOrder/schoolRegisterOrder?schoolId=' +
  805. forms.schoolId
  806. );
  807. // 判断是否有待支付订单
  808. if (data && data.length > 0) {
  809. let isPadding = false; // 是否有待支付订单
  810. let paddingConfig = {} as any;
  811. let paddingData = {} as any;
  812. let isFinal = false; // 是否有完成订单
  813. let finalConfig = {} as any;
  814. data.forEach((element: any) => {
  815. // 判断是否待支付
  816. if (element.status === 'PAYING' || element.status === 'WAIT_PAY') {
  817. isPadding = true;
  818. paddingConfig = element.paymentConfig;
  819. paddingData = element;
  820. }
  821. if (
  822. element.status === 'PAID' ||
  823. element.status === 'PART_REFUNDED' ||
  824. element.status === 'REFUNDED'
  825. ) {
  826. isFinal = true;
  827. finalConfig = element.paymentConfig;
  828. }
  829. });
  830. // 判断是否有完成订单 并且选择 自备
  831. if (isFinal && forms.joinType === 'tradition') {
  832. const studentResult = await updateStudentInfo();
  833. if (!studentResult) return;
  834. setTimeout(() => {
  835. showToast('您已通过数字化方式报名成功');
  836. }, 100);
  837. return true;
  838. }
  839. // 提交报名信息时,判断该手机号是否存在待支付订单,若存则判断本次提交的报名方式,若本次提交的是团购则提示【您有待支付的报名订单,是否继续支付 重新下单/继续支付】,点击重新下单时,关闭老订单,创建新订单;若本次提交的是自备,则提示 【您有数字化方式报名的待支付订单,请关闭订单后重新报名 取消/关闭】取消则停留在当前界面,关闭则关闭订单,并停留在当前界面,用户需要再次点击报名按钮提交信息
  840. if (isPadding && forms.joinType === 'tradition') {
  841. forms.dialogStatus = true;
  842. forms.dialogMessage =
  843. '您有数字化方式报名的待支付订单,请关闭订单后重新报名';
  844. forms.cancelButtonText = '取消';
  845. forms.confirmButtonText = '关闭';
  846. forms.dialogConfig = paddingConfig;
  847. forms.messageAlign = 'left';
  848. return true;
  849. }
  850. if (isPadding && forms.joinType === 'digitalize') {
  851. // 最终确认,有待支付订单直接去支付,没有则才会创建订单
  852. // state.config = paddingConfig?.paymentConfig;
  853. // state.orderNo = paddingConfig?.orderNo;
  854. // const updateStatus = await updateStudentInfo();
  855. // if (!updateStatus) return;
  856. // await lastSubmit();
  857. // 为了处理,有待支付订单,然后后台改了金额,会导致金额不一致
  858. forms.dialogConfig = paddingConfig;
  859. const cancelStatus = await cancelPaymentOrder();
  860. if (cancelStatus) {
  861. await paymentContinue();
  862. }
  863. return true;
  864. }
  865. return false;
  866. } else {
  867. return false;
  868. }
  869. } catch {
  870. // 重置信息 - 如果是新建则不提示
  871. changeTipStatus(forms.isRegister === 'create' ? false : true, false);
  872. }
  873. return result;
  874. };
  875. // 重新下单
  876. const resetOrderPayment = async () => {
  877. try {
  878. const orderNo = forms.dialogConfig?.orderNo;
  879. if (!orderNo) return;
  880. await request.post(
  881. '/edu-app/userPaymentOrder/cancelPayment/' + orderNo
  882. );
  883. await onRegisterSubmit();
  884. } catch {
  885. //
  886. }
  887. };
  888. // 取消订单
  889. const cancelPaymentOrder = async () => {
  890. try {
  891. const orderNo = forms.dialogConfig?.orderNo;
  892. if (!orderNo) return;
  893. await request.post(
  894. '/edu-app/userPaymentOrder/cancelPayment/' + orderNo
  895. );
  896. return true;
  897. } catch {
  898. return false;
  899. }
  900. };
  901. const paymentContinue = async () => {
  902. try {
  903. const vipList = studentRegisterStore.getVip;
  904. const goodsList = studentRegisterStore.getGoods;
  905. const params: any[] = [];
  906. vipList.forEach((vip: any) => {
  907. params.push({
  908. giftVipDay: vip.membershipDays,
  909. giftPeriod: vip.giftPeriod,
  910. goodsId: vip.goodsId,
  911. goodsNum: 1,
  912. goodsType: vip.goodsType,
  913. paymentCashAmount: vip.currentPrice, // 现金支付金额
  914. paymentCouponAmount: 0 // 优惠券金额
  915. });
  916. });
  917. goodsList.forEach((goods: any) => {
  918. params.push({
  919. goodsId: goods.productId,
  920. goodsNum: goods.quantity,
  921. goodsType: 'INSTRUMENTS',
  922. paymentCashAmount: goods.price, // 现金支付金额
  923. paymentCouponAmount: 0, // 优惠券金额
  924. goodsSkuId: goods.productSkuId
  925. });
  926. });
  927. // 创建订单
  928. const updateStatus = await updateStudentInfo();
  929. // console.log(updateStatus, 'updateStatus');
  930. if (!updateStatus) return;
  931. const result = await request.post(
  932. '/edu-app/userPaymentOrder/executeOrder',
  933. {
  934. // hideLoading: false,
  935. data: {
  936. buryId: forms.saveUserId,
  937. registerType: forms.registerType,
  938. paymentType: forms.paymentType,
  939. bizId: forms.schoolId, // 乐团编号
  940. orderType: 'SCHOOL_REGISTER',
  941. paymentCashAmount: calcPrice.value.amount || 0,
  942. paymentCouponAmount: 0,
  943. goodsInfos: params,
  944. orderName: '学生登记',
  945. orderDesc: '学生登记'
  946. }
  947. }
  948. );
  949. if (result.code === 5436) {
  950. forms.showTips = true;
  951. forms.showMessage = '二维码已经失效,详情请咨询学校老师';
  952. forms.showButton = false;
  953. } else if (result.code === 5435) {
  954. forms.showTips = true;
  955. forms.showMessage = result.message;
  956. forms.showButton = true;
  957. } else {
  958. state.config = {
  959. ...result.data.paymentConfig,
  960. paymentType: result.data.paymentType
  961. };
  962. state.orderNo = result.data.orderNo;
  963. await lastSubmit();
  964. }
  965. } catch (e: any) {
  966. console.log(e, 'any');
  967. // 重置信息 - 如果是新建则不提示
  968. changeTipStatus(forms.isRegister === 'create' ? false : true, false);
  969. }
  970. };
  971. const lastSubmit = async () => {
  972. try {
  973. const users = baseState.user.data;
  974. // 判断是否需要实名认证, 姓名,卡号 - 参数设置可以控制
  975. if (
  976. forms.contract_sign &&
  977. (!users?.account.realName || !users?.account.idCardNo)
  978. ) {
  979. state.authShow = true;
  980. return;
  981. }
  982. const { data } = await request.post(
  983. '/edu-app/userPaymentOrder/updateReceiveAddress',
  984. {
  985. // hideLoading: false,
  986. data: {
  987. orderNo: state.orderNo,
  988. orderType: 'SCHOOL_REGISTER'
  989. }
  990. }
  991. );
  992. state.pay_channel = data.paymentChannel;
  993. if (data.status !== 'WAIT_PAY' && data.status !== 'PAYING') {
  994. router.replace({
  995. path: '/payment-result',
  996. query: {
  997. orderNo: state.orderNo
  998. }
  999. });
  1000. } else {
  1001. onCallback();
  1002. }
  1003. } catch {
  1004. // 重置信息 - 如果是新建则不提示
  1005. changeTipStatus(forms.isRegister === 'create' ? false : true, false);
  1006. }
  1007. };
  1008. /**
  1009. * @description 回调,判断是否有支付渠道,如果有则直接去支付
  1010. * @returns void
  1011. */
  1012. const onCallback = () => {
  1013. const pt = state.pay_channel;
  1014. // 判断是否有支付方式
  1015. if (pt) {
  1016. const payCode: string = beforeSubmit(state.pay_channel);
  1017. onConfirm({
  1018. payCode,
  1019. pay_channel: pt
  1020. });
  1021. } else {
  1022. if (orderType.value === 'VIP') {
  1023. state.paymentStatus = true;
  1024. } else {
  1025. // 直接去拉取微信支付
  1026. onConfirm({
  1027. payCode: 'payResult',
  1028. pay_channel: forms.paymentChannel
  1029. });
  1030. }
  1031. }
  1032. };
  1033. const onConfirm = (val: any) => {
  1034. const config: any = state.config;
  1035. state.pay_channel = val.pay_channel;
  1036. const params = qs.stringify({
  1037. pay_channel: val.pay_channel,
  1038. wxAppId: config.wxAppId,
  1039. alipayAppId: config.alipayAppId,
  1040. paymentType: forms.paymentType,
  1041. body: config.body,
  1042. price: config.price,
  1043. orderNo: config.merOrderNo,
  1044. userId: config.userId
  1045. });
  1046. // console.log(params, state.config);
  1047. // return;
  1048. if (val.payCode === 'payResult') {
  1049. window.location.href =
  1050. getHttpOrigin() + '/classroom-app/#/payResult?' + params;
  1051. } else {
  1052. state.qrCodeUrl =
  1053. getHttpOrigin() + '/classroom-app/#/payDefine?' + params;
  1054. state.showQrcode = true;
  1055. state.paymentStatus = false;
  1056. setTimeout(() => {
  1057. getPaymentOrderStatus();
  1058. }, 300);
  1059. }
  1060. };
  1061. // 放弃支付时,则取消订单
  1062. const onBackOut = async () => {
  1063. try {
  1064. await request.post(
  1065. '/edu-app/userPaymentOrder/cancelPayment/' + state.orderNo
  1066. );
  1067. // router.back();
  1068. } catch {
  1069. //
  1070. }
  1071. };
  1072. // 轮询查询订单状态
  1073. const getPaymentOrderStatus = async () => {
  1074. // 循环查询订单
  1075. // const orderNo = state.orderNo
  1076. const orderTimer = setInterval(async () => {
  1077. // 判断是否在当前路由,如果不是则清除定时器
  1078. if (route.name != 'student-register-form') {
  1079. clearInterval(orderTimer);
  1080. return;
  1081. }
  1082. state.orderTimer = orderTimer;
  1083. try {
  1084. const { data } = await request.post(
  1085. '/edu-app/open/userOrder/paymentStatus/' + state.orderNo,
  1086. {
  1087. hideLoading: true
  1088. }
  1089. );
  1090. if (data.status !== 'WAIT_PAY' && data.status !== 'PAYING') {
  1091. // 默认关闭支付二维码弹窗
  1092. state.showQrcode = false;
  1093. clearInterval(state.orderTimer);
  1094. setTimeout(() => {
  1095. router.replace({
  1096. path: '/payment-result',
  1097. query: {
  1098. orderNo: state.orderNo
  1099. }
  1100. });
  1101. }, 100);
  1102. }
  1103. } catch {
  1104. //
  1105. clearInterval(state.orderTimer);
  1106. }
  1107. }, 5000);
  1108. };
  1109. // 实名认证成功
  1110. const onAuthSuccess = () => {
  1111. //
  1112. state.authShow = false;
  1113. paymentContinue(); // 实名成功后自动支付
  1114. };
  1115. /**
  1116. * 页面停留时间
  1117. * @param pageBrowseTime 停留时间
  1118. * @param joinType 加入方式
  1119. * @param userId 用户编号
  1120. * @param schoolId 学校编号
  1121. */
  1122. const updateStat = async (
  1123. pageBrowseTime = 5,
  1124. joinType?: string,
  1125. userId?: string,
  1126. schoolId?: string
  1127. ) => {
  1128. try {
  1129. const params = {
  1130. id: forms.saveId,
  1131. useTime: pageBrowseTime, // 固定5秒
  1132. joinType,
  1133. userId,
  1134. schoolId
  1135. };
  1136. let otherParams = {};
  1137. if (!userId && videoForms.player.duration() > 0) {
  1138. const videoBrowseData =
  1139. moreTime.value.length > 0
  1140. ? formatEffectiveTime(moreTime.value)
  1141. : [];
  1142. const time =
  1143. videoBrowseData.length > 0 ? formatTimer(videoBrowseData) : 0;
  1144. // console.log(moreTime.value, videoBrowseData, 'video', time);
  1145. // const videoCountTime = videoIntervalRef?.counter.value
  1146. // 判断 视屏播放时间大于视屏播放有效时间则说明数据有问题,进行重置数据
  1147. const rate = Math.floor(
  1148. (Math.round(time) / Math.floor(videoForms.player.duration())) * 100
  1149. );
  1150. otherParams = {
  1151. videoBrowseData: JSON.stringify(videoBrowseData), // 视屏播放数据
  1152. videoBrowseDataTime: time || 0, // 有效的视频观看时长
  1153. videoBrowsePercentage: rate || 0, // 有效的视频观看时长百分比
  1154. videoBrowseTime: timer.getTime(), // 视频观看时长
  1155. videoBrowsePoint: videoForms.player.currentTime() // 视频最后观看点 - 向下取整
  1156. };
  1157. }
  1158. // console.log(
  1159. // videoIntervalRef.counter.value,
  1160. // timer.getTime(),
  1161. // videoForms.player.currentTime(),
  1162. // videoBrowseData,
  1163. // 'timer count'
  1164. // );
  1165. const { data } = await requestStudent.post(
  1166. '/edu-app/open/studentRegisterPointRecord/update',
  1167. {
  1168. data: {
  1169. ...params,
  1170. ...otherParams
  1171. }
  1172. }
  1173. );
  1174. // 不相同则说明不是一个人,数据重置
  1175. if (data !== forms.saveId) {
  1176. moreTime.value = [];
  1177. }
  1178. forms.saveId = data;
  1179. return data;
  1180. } catch {
  1181. //
  1182. }
  1183. };
  1184. const getAppIdAndCode = async (url?: string) => {
  1185. try {
  1186. const { data } = await request.get(
  1187. '/edu-app/open/paramConfig/wechatAppId'
  1188. );
  1189. // 判断是否有微信appId
  1190. if (data) {
  1191. closeToast();
  1192. goWechatAuth(data, url);
  1193. }
  1194. } catch {
  1195. //
  1196. }
  1197. };
  1198. if (browser().weixin) {
  1199. //授权
  1200. const openId = sessionStorage.getItem('active-open-id');
  1201. forms.openId = openId;
  1202. const code = getUrlCode();
  1203. if (!code) {
  1204. const newUrl =
  1205. getHttpOrigin() +
  1206. window.location.pathname +
  1207. '#' +
  1208. route.path +
  1209. '?' +
  1210. qs.stringify({
  1211. ...route.query
  1212. });
  1213. getAppIdAndCode(newUrl);
  1214. return '';
  1215. } else {
  1216. forms.code = code;
  1217. }
  1218. }
  1219. const formatTimerTo = (num: number): string => {
  1220. if (num > 9) {
  1221. return num + '';
  1222. } else {
  1223. return '0' + num;
  1224. }
  1225. };
  1226. /**
  1227. * 视屏累计时长
  1228. * 1、视屏开始播放时-开始计时
  1229. * 2、视频暂停时暂停-停止计时
  1230. * 3、视频加载时-停止计时
  1231. * 4、视频倍数播放时,时间正常计时
  1232. * 5、点击视频进度或拖动进度时,时间暂停
  1233. */
  1234. const _init = () => {
  1235. const Button = TCPlayer.getComponent('Button');
  1236. const BigPlayButton = TCPlayer.getComponent('BigPlayButton');
  1237. BigPlayButton.prototype.createEl = function () {
  1238. const el = Button.prototype.createEl.call(this);
  1239. const _html =
  1240. '<button><svg width="42px" height="42px" viewBox="0 0 42 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><circle stroke="#FFFFFF" stroke-width="1.0112392" fill-opacity="0.3" fill="#000000" stroke-linecap="square" cx="21" cy="21" r="20.5056196"></circle><g transform="translate(13.000000, 12.000000)" fill="#FFFFFF"><path d="M11.7432433,3.46351367 L18.2071084,14.4520843 C18.7734418,15.4148511 18.4520691,16.6544316 17.4893024,17.2207649 C17.1784947,17.403593 16.8244584,17.5 16.4638651,17.5 L3.53613489,17.5 C2.41915092,17.5 1.51365649,16.5945056 1.51365649,15.4775216 C1.51365649,15.1169283 1.6100635,14.762892 1.79289156,14.4520843 L8.25675667,3.46351367 C8.82309003,2.50074696 10.0626705,2.17937423 11.0254373,2.74570759 C11.3218389,2.92006148 11.5688894,3.16711204 11.7432433,3.46351367 Z" id="三角形" transform="translate(10.000000, 9.000000) rotate(-270.000000) translate(-10.000000, -9.000000) "></path></g></g></svg></button>';
  1241. el.appendChild(
  1242. TCPlayer.dom.createEl('div', {
  1243. className: 'vjs-button-icon',
  1244. innerHTML: _html
  1245. })
  1246. );
  1247. return el;
  1248. };
  1249. videoForms.player = TCPlayer('register-video', {
  1250. appID: '',
  1251. controls: true,
  1252. plugins: {}
  1253. }); // player-container-id 为播放器容器 ID,必须与 html 中一致
  1254. if (videoForms.player) {
  1255. videoForms.player.src(
  1256. videoForms.introductionVideo ||
  1257. 'https://oss.dayaedu.com/ktyq/1719222831427bbef9504.mp4'
  1258. ); // url 播放地址
  1259. videoForms.player.poster(
  1260. 'https://oss.dayaedu.com/ktyq/17158281330381317fd87.png'
  1261. );
  1262. videoForms.player.on('ready', (item: any) => {
  1263. // console.log('ready', item);
  1264. // videoForms.player.pause()
  1265. });
  1266. videoForms.player.on('loadedmetadata', () => {
  1267. console.log('loadedmetadata');
  1268. // videoForms.loading = false;
  1269. videoForms.player.currentTime(videoForms.videoBrowsePoint);
  1270. });
  1271. // 速度变化时
  1272. videoForms.player.on('ratechange', () => {
  1273. videoForms.playerSpeed =
  1274. videoForms.playerSpeed < videoForms.player.playbackRate()
  1275. ? videoForms.player.playbackRate()
  1276. : videoForms.playerSpeed;
  1277. });
  1278. videoForms.player.on('seeking', () => {
  1279. console.log('seeking');
  1280. videoIntervalRef.isActive.value && videoIntervalRef.pause();
  1281. timer.pause();
  1282. });
  1283. // // 拖动结束时
  1284. videoForms.player.on('seeked', () => {
  1285. console.log('seeked');
  1286. videoIntervalRef.isActive.value && videoIntervalRef.pause();
  1287. timer.pause();
  1288. });
  1289. // 正在搜索中
  1290. videoForms.player.on('waiting', () => {
  1291. // console.log('waiting pause')
  1292. videoIntervalRef.isActive.value && videoIntervalRef.pause();
  1293. timer.pause();
  1294. });
  1295. // 如何视频在缓存不会触发
  1296. videoForms.player.on('timeupdate', () => {
  1297. // console.log('timeupdate', videoForms.player.currentTime());
  1298. // 判断视频计时器是否暂停,如果暂停则恢复
  1299. // 添加 「videoForms.player.playing」 是由会跳转到上次播放时间,会触发些方法
  1300. if (
  1301. !videoIntervalRef.isActive.value &&
  1302. videoForms.player.currentTime() > 0 &&
  1303. !videoForms.player.paused()
  1304. ) {
  1305. // console.log('timeupdate play')
  1306. videoIntervalRef.resume();
  1307. timer.resume();
  1308. }
  1309. });
  1310. // 视屏播放时暂停
  1311. videoForms.player.on('ended', () => {
  1312. videoForms.player.pause();
  1313. });
  1314. // 开始播放
  1315. videoForms.player.on('play', () => {
  1316. console.log('play');
  1317. forms.showDuration = false;
  1318. // 判断视频计时器是否暂停,如果暂停则恢复
  1319. videoIntervalRef.resume();
  1320. timer.resume();
  1321. });
  1322. // 暂停播放
  1323. videoForms.player.on('pause', () => {
  1324. console.log('pause', videoIntervalRef.isActive.value);
  1325. videoIntervalRef.pause();
  1326. timer.pause();
  1327. });
  1328. videoForms.player.on('fullscreenchange', () => {
  1329. if (videoForms.player.isFullscreen()) {
  1330. console.log('fullscreen');
  1331. const i = document.createElement('i');
  1332. i.id = 'fullscreen-back';
  1333. i.className = 'van-icon van-icon-arrow-left video-back';
  1334. i.addEventListener('click', () => {
  1335. videoForms.player.exitFullscreen();
  1336. });
  1337. document.getElementsByClassName('video-js')[0].appendChild(i);
  1338. } else {
  1339. console.log('exitfullscreen');
  1340. const i = document.getElementById('fullscreen-back');
  1341. i && i.remove();
  1342. }
  1343. });
  1344. }
  1345. };
  1346. // 保存零时时间
  1347. const moreTime: any = ref([]); // 多个观看时间段
  1348. let tempTime: any = []; // 临时存储时间
  1349. const currentTimer = useInterval(1000, { controls: true });
  1350. // 监听播放状态,
  1351. watch(
  1352. () => videoIntervalRef.isActive.value,
  1353. (newVal: boolean) => {
  1354. console.log(videoIntervalRef.isActive.value, 'videoIntervalRef');
  1355. initVideoCount(newVal);
  1356. }
  1357. );
  1358. /**
  1359. * 初始化视频时长
  1360. * @param newVal 播放状态
  1361. * @param repeat 是否为定时发送的
  1362. */
  1363. const initVideoCount = (newVal: any, repeat = false) => {
  1364. // console.log('watch', videoForms.player.currentTime())
  1365. const initTime = deepClone(tempTime);
  1366. if (repeat) {
  1367. if (tempTime.length > 0) {
  1368. // console.log('join video', tempTime, 'initTime', initTime)
  1369. tempTime[1] =
  1370. Math.floor(videoForms.player.currentTime() * 1000) / 1000;
  1371. // tempTime[1] = videoForms.player.currentTime();
  1372. }
  1373. } else {
  1374. if (newVal) {
  1375. // console.log(
  1376. // videoForms.player.currentTime(),
  1377. // 'videoForms.player.currentTime()'
  1378. // );
  1379. tempTime[0] =
  1380. Math.floor(videoForms.player.currentTime() * 1000) / 1000;
  1381. // tempTime[0] = videoForms.player.currentTime();
  1382. } else {
  1383. tempTime[1] =
  1384. Math.floor(videoForms.player.currentTime() * 1000) / 1000;
  1385. // tempTime[1] = videoForms.player.currentTime();
  1386. }
  1387. }
  1388. // console.log(
  1389. // newVal,
  1390. // repeat,
  1391. // tempTime,
  1392. // tempTime.length,
  1393. // 'videoIntervalRef.isActive.value in'
  1394. // );
  1395. // console.log(videoForms.player.playbackRate(), 'speed');
  1396. if (tempTime.length >= 2) {
  1397. // console.log(tempTime, 'tempTime', moreTime.value)
  1398. // 处理在短时间内的时间差 【视屏拖动,点击可能会导致时间差太大】
  1399. const diffTime =
  1400. tempTime[1] -
  1401. tempTime[0] -
  1402. currentTimer.counter.value * videoForms.playerSpeed >
  1403. 2;
  1404. // console.log(diffTime, 'diffTime', currentTimer.counter.value, videoForms.playerSpeed, 'value')
  1405. // 结束时间,如果 大于开始时间则清除
  1406. if (tempTime[1] >= tempTime[0] && !diffTime)
  1407. moreTime.value.push(tempTime);
  1408. if (repeat) {
  1409. tempTime = deepClone(initTime);
  1410. } else {
  1411. tempTime = [];
  1412. currentTimer.counter.value = 0;
  1413. }
  1414. }
  1415. };
  1416. watch(pageVisibility, (value: any) => {
  1417. if (value == 'hidden') {
  1418. videoForms.player.pause();
  1419. }
  1420. });
  1421. const pagePointInit = async () => {
  1422. try {
  1423. // 判断是否获取微信code码
  1424. if (!forms.code) return;
  1425. const { data } = await request.post(
  1426. '/edu-app/open/studentRegisterPointRecord/save',
  1427. {
  1428. data: {
  1429. code: forms.code,
  1430. schoolId: forms.schoolId,
  1431. openId: forms.openId
  1432. }
  1433. }
  1434. );
  1435. forms.saveId = data.id;
  1436. forms.openId = data.openId;
  1437. moreTime.value = data.videoBrowseData
  1438. ? JSON.parse(data.videoBrowseData)
  1439. : [];
  1440. videoForms.videoBrowsePoint = data.videoBrowsePoint || 0;
  1441. if (videoForms.player) {
  1442. videoForms.player.currentTime(data.videoBrowsePoint || 0);
  1443. }
  1444. sessionStorage.setItem('active-open-id', data.openId);
  1445. // 间隔多少时间同步数据
  1446. forms.intervalFnRef = useIntervalFn(async () => {
  1447. // 页面时间恢复
  1448. forms.intervalFnRef.pause();
  1449. pageTimer.counter.value = 0;
  1450. pageTimer.resume();
  1451. // 同步数据时先进行有效时间进行保存
  1452. initVideoCount(false, true);
  1453. updateStat();
  1454. timer.resetTime();
  1455. videoIntervalRef.counter.value = 0;
  1456. forms.intervalFnRef.resume();
  1457. }, 5000);
  1458. } catch {}
  1459. };
  1460. /** 手机号变更时清空验证码信息,用户信息 */
  1461. const phoneChangeEmptyInfo = () => {
  1462. studentInfo.password = '';
  1463. studentInfo.extra.nickname = '';
  1464. studentInfo.extra.currentGradeNum = '';
  1465. studentInfo.extra.currentClass = '';
  1466. studentInfo.extra.gender = 1;
  1467. forms.currentClassText = '';
  1468. forms.gradeNumText = '';
  1469. forms.studentList = []; // 手机号关联学生列表
  1470. forms.studentItem = {}; // 选择的学生
  1471. forms.isRegister = 'create'; // 是否注册学生
  1472. forms.isTipRegister = false; // 是否显示名字不一致 - 默认显示
  1473. forms.isChangeSchool = false; // 是否切换学校
  1474. };
  1475. onMounted(async () => {
  1476. try {
  1477. // 获取支付类型
  1478. let expireDay = null;
  1479. const { data } = await request.get(
  1480. '/edu-app/open/paramConfig/queryByParamNameList',
  1481. {
  1482. requestType: 'form',
  1483. params: {
  1484. paramNames:
  1485. 'payment_service_provider,contract_sign,multi_user_limit,qr_code_expire_time'
  1486. }
  1487. }
  1488. );
  1489. if (data && Array.isArray(data)) {
  1490. data.forEach((item: any) => {
  1491. if (item.paramName === 'contract_sign') {
  1492. forms.contract_sign = item.paramValue === '1' ? true : false;
  1493. } else if (item.paramName === 'payment_service_provider') {
  1494. // forms.paymentType = item.paramValue || '';
  1495. const provider = JSON.parse(item.paramValue);
  1496. forms.paymentType = provider.vendor;
  1497. forms.paymentChannel = provider.channel;
  1498. } else if (item.paramName === 'multi_user_limit') {
  1499. forms.multi_user_limit = item.paramValue
  1500. ? Number(item.paramValue)
  1501. : 1;
  1502. } else if (item.paramName === 'qr_code_expire_time') {
  1503. expireDay = item.paramValue ? Number(item.paramValue) : null;
  1504. }
  1505. });
  1506. }
  1507. const createT = route.query.t;
  1508. if (createT && expireDay !== null) {
  1509. if (dayjs(Number(createT)).add(expireDay, 'day').isBefore(dayjs())) {
  1510. forms.showTips = true;
  1511. forms.showMessage = '二维码已经失效,详情请咨询学校老师';
  1512. forms.showButton = false;
  1513. }
  1514. }
  1515. // 初始化视频播放器
  1516. _init();
  1517. await getRegisterGoods();
  1518. } catch {}
  1519. });
  1520. onUnmounted(() => {
  1521. forms.intervalFnRef?.pause(); // 暂停回调
  1522. });
  1523. return () => (
  1524. <div class={styles['student-register']}>
  1525. <div class={styles.studentRegisterContainer}>
  1526. {!forms.activeOverStatus && (
  1527. <div class={styles.countdownSection}>
  1528. <div class={styles.timer}>
  1529. <img src={icon3} class={styles.timerTitle} />
  1530. <div class={styles.timerAll}>
  1531. <span>{formatTimerTo(overCountDown.current.value.days)}</span>
  1532. <span>
  1533. {formatTimerTo(overCountDown.current.value.hours)}
  1534. </span>
  1535. <span>
  1536. {formatTimerTo(overCountDown.current.value.minutes)}
  1537. </span>
  1538. <span>
  1539. {formatTimerTo(overCountDown.current.value.seconds)}
  1540. </span>
  1541. </div>
  1542. </div>
  1543. <div class={styles.timerTip}>
  1544. 为了确保您能顺利参与学习,请在规定时间内报名。
  1545. </div>
  1546. </div>
  1547. )}
  1548. <div class={[styles.studentSection, styles.studentSectionForm]}>
  1549. <div class={styles.title4}></div>
  1550. <div class={styles['video-content']}>
  1551. <video
  1552. id="register-video"
  1553. class={styles['video']}
  1554. src={'https://oss.dayaedu.com/ktyq/1719222831427bbef9504.mp4'}
  1555. playsinline={true}
  1556. poster={
  1557. 'https://oss.dayaedu.com/ktyq/17158281330381317fd87.png'
  1558. }
  1559. preload="auto"></video>
  1560. {forms.showDuration && (
  1561. <span class={styles.videoDuration}>1:24</span>
  1562. )}
  1563. </div>
  1564. </div>
  1565. <div
  1566. class={[
  1567. styles.studentSection,
  1568. styles.studentSectionForm,
  1569. forms.giftVipDay <= 0 && styles.noSendDay
  1570. ]}
  1571. // style={{ display: 'none' }}
  1572. >
  1573. <div class={styles.title1}></div>
  1574. <Form labelAlign="left" class={styles.registerForm}>
  1575. <Field
  1576. clearable={false}
  1577. label="联系方式(直接监护人)"
  1578. placeholder="请输入手机号码"
  1579. type="tel"
  1580. required
  1581. autocomplete="off"
  1582. inputAlign="right"
  1583. class={styles.username}
  1584. v-model={studentInfo.username}
  1585. border={false}
  1586. maxlength={11}
  1587. onUpdate:modelValue={() => {
  1588. phoneChangeEmptyInfo();
  1589. }}>
  1590. {{
  1591. label: () => (
  1592. <div>
  1593. 联系方式
  1594. {/* (直接监护人) */}
  1595. <p class={styles.tips}>(直接监护人)</p>
  1596. </div>
  1597. )
  1598. }}
  1599. </Field>
  1600. <div class={['van-hairline--bottom', styles.fieldTipsGroup]}>
  1601. <div class={[styles.fieldTips]}>
  1602. 手机号是音乐数字课堂的唯一登录账户
  1603. </div>
  1604. </div>
  1605. <Field
  1606. center
  1607. clearable={false}
  1608. required
  1609. inputAlign="right"
  1610. label="验证码"
  1611. placeholder="请输入验证码"
  1612. autocomplete="off"
  1613. type="number"
  1614. v-model={studentInfo.password}
  1615. maxlength={6}
  1616. onUpdate:modelValue={(val: any) => {
  1617. getUserInfos();
  1618. }}>
  1619. {{
  1620. button: () =>
  1621. forms.countDownStatus ? (
  1622. <span
  1623. class={[
  1624. styles.codeText,
  1625. !validatePhone.value ? styles.codeTextDisabled : ''
  1626. ]}
  1627. onClick={onSendCode}>
  1628. 获取验证码
  1629. </span>
  1630. ) : (
  1631. <CountDown
  1632. ref={(el: any) => (countDownRef.value = el)}
  1633. auto-start={false}
  1634. class={styles.countDown}
  1635. time={forms.countDownTime}
  1636. onFinish={onFinished}
  1637. format="ss秒后重试"
  1638. />
  1639. )
  1640. }}
  1641. </Field>
  1642. {/* 大于等于2,则可以切换学生 */}
  1643. {/* {forms.studentList.length > 1 && (
  1644. <div
  1645. class={[
  1646. styles.selectStudentGroup,
  1647. forms.showSelectStudent && styles.selectStudentGroupChecked
  1648. ]}
  1649. onClick={() => (forms.showSelectStudent = true)}>
  1650. <i
  1651. class={[
  1652. styles.studentIcon,
  1653. !forms.studentItem.userId && styles.studentIconAdd
  1654. ]}></i>
  1655. <span>
  1656. {forms.studentItem.userId
  1657. ? forms.studentItem.nickname
  1658. : '新增学生'}
  1659. </span>
  1660. </div>
  1661. )} */}
  1662. <Field
  1663. clearable={false}
  1664. required
  1665. inputAlign="right"
  1666. label="学生姓名"
  1667. placeholder="请输入学生姓名"
  1668. autocomplete="off"
  1669. maxlength={14}
  1670. v-model={studentInfo.extra.nickname}>
  1671. {{
  1672. extra: () =>
  1673. forms.studentList.length > 1 && (
  1674. <div
  1675. class={[
  1676. styles.selectStudentGroup,
  1677. forms.showSelectStudent &&
  1678. styles.selectStudentGroupChecked
  1679. ]}
  1680. onClick={() => (forms.showSelectStudent = true)}>
  1681. <span>
  1682. {forms.studentItem.userId ? '切换' : '新增'}
  1683. </span>
  1684. </div>
  1685. )
  1686. }}
  1687. </Field>
  1688. <Field
  1689. clearable={false}
  1690. required
  1691. inputAlign="right"
  1692. label="学生性别"
  1693. placeholder="请选择性别"
  1694. autocomplete="off"
  1695. // v-model={studentInfo.extra.nickname}
  1696. >
  1697. {{
  1698. input: () => (
  1699. <RadioGroup
  1700. checked-color="linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)"
  1701. v-model={studentInfo.extra.gender}
  1702. direction="horizontal">
  1703. <Tag
  1704. size="large"
  1705. type="primary"
  1706. color={
  1707. !(studentInfo.extra.gender === 1)
  1708. ? '#F5F6FA'
  1709. : 'linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)'
  1710. }
  1711. textColor={
  1712. !(studentInfo.extra.gender === 1) ? '#626264' : '#fff'
  1713. }
  1714. class={styles.radioSection}>
  1715. <Radio class={styles.radioItem} name={1}></Radio>男
  1716. </Tag>
  1717. <Tag
  1718. size="large"
  1719. type="primary"
  1720. color={
  1721. !(studentInfo.extra.gender === 0)
  1722. ? '#F5F6FA'
  1723. : 'linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)'
  1724. }
  1725. textColor={
  1726. !(studentInfo.extra.gender === 0) ? '#626264' : '#fff'
  1727. }
  1728. class={styles.radioSection}>
  1729. <Radio class={styles.radioItem} name={0}></Radio>女
  1730. </Tag>
  1731. </RadioGroup>
  1732. )
  1733. }}
  1734. </Field>
  1735. <Field
  1736. clearable={false}
  1737. required
  1738. inputAlign="right"
  1739. label="所在年级"
  1740. placeholder="请选择年级"
  1741. isLink
  1742. readonly
  1743. clickable={false}
  1744. modelValue={forms.gradeNumText}
  1745. onClick={() => {
  1746. forms.gradePopupIndex = [studentInfo.extra.currentGradeNum];
  1747. forms.gradeStatus = true;
  1748. }}
  1749. />
  1750. <Field
  1751. clearable={false}
  1752. required
  1753. inputAlign="right"
  1754. label="所在班级"
  1755. placeholder="请选择班级"
  1756. isLink
  1757. readonly
  1758. clickable={false}
  1759. modelValue={forms.currentClassText}
  1760. onClick={() => {
  1761. if (
  1762. forms.schoolInstrumentSetType === 'CLASS' &&
  1763. forms.classList.length <= 0
  1764. ) {
  1765. showToast('请先选择年级');
  1766. return;
  1767. }
  1768. forms.classPopupIndex = [studentInfo.extra.currentClass];
  1769. forms.classStatus = true;
  1770. }}
  1771. />
  1772. {(forms.giftVipDay > 0 && forms.registerDetails.giftVipFlag) ? (
  1773. <div class={styles.memberNumer}>
  1774. <img src={iconGift} class={styles.iconGift} />
  1775. <p>
  1776. 注册成功即可获得乐器AI学练工具
  1777. <span>{forms.giftVipDay || 0}</span>天有效期
  1778. </p>
  1779. </div>
  1780. ) : (
  1781. ''
  1782. )}
  1783. </Form>
  1784. </div>
  1785. <div class={styles.studentSection}>
  1786. <div class={styles.title2}></div>
  1787. <div class={styles.goodsGroup}>
  1788. <div
  1789. class={[
  1790. styles.goodsItem,
  1791. styles.digitalize,
  1792. forms.joinType === 'digitalize' && styles.checked
  1793. ]}
  1794. onClick={() => {
  1795. //
  1796. if (checkForm()) {
  1797. showToast('请将资料填写完整');
  1798. return;
  1799. }
  1800. forms.joinType = 'digitalize';
  1801. nextTick(() => {
  1802. mstickyRef.value?.onChnageHeight();
  1803. setTimeout(() => {
  1804. window.scrollTo(0, 1000);
  1805. }, 50);
  1806. });
  1807. }}>
  1808. <div class={styles.goodsInner}>
  1809. <i class={styles.proposalTip}></i>
  1810. 数字化方式
  1811. </div>
  1812. </div>
  1813. <div
  1814. class={[
  1815. styles.goodsItem,
  1816. styles.tradition,
  1817. forms.joinType === 'tradition' && styles.checked1
  1818. ]}
  1819. onClick={() => {
  1820. if (checkForm()) {
  1821. showToast('请将资料填写完整');
  1822. return;
  1823. }
  1824. forms.joinType = 'tradition';
  1825. nextTick(() => {
  1826. mstickyRef.value?.onChnageHeight();
  1827. setTimeout(() => {
  1828. window.scrollTo(0, 1000);
  1829. }, 50);
  1830. });
  1831. }}>
  1832. <div class={styles.goodsInner}>传统方式</div>
  1833. </div>
  1834. </div>
  1835. {forms.joinType && (
  1836. <div class={styles.goodsTypeGroup}>
  1837. {forms.joinType === 'digitalize' && (
  1838. <img src={icon10} class={styles.showImg} />
  1839. )}
  1840. {forms.joinType === 'tradition' && (
  1841. <img src={icon11} class={styles.showImg} />
  1842. )}
  1843. </div>
  1844. )}
  1845. </div>
  1846. {forms.detailVip.membershipDays && forms.joinType === 'digitalize' ? (
  1847. <div class={styles.vipGiftContainer}>
  1848. <img src={vipGiftTIps} class={styles.iconGift} />
  1849. <p>
  1850. 现在购买额外赠送有效期
  1851. <div>
  1852. <span class={styles.vipGiftNum}>
  1853. {forms.detailVip.membershipDays || 0}
  1854. </span>
  1855. <span class={styles.vipGiftPreviod}>
  1856. {vipGiftPeriodType[forms.detailVip.giftPeriod]}
  1857. </span>
  1858. </div>
  1859. </p>
  1860. </div>
  1861. ) : (
  1862. ''
  1863. )}
  1864. {/* {forms.joinType === 'digitalize' && (
  1865. <div class={[styles.goodsExtra]}>
  1866. <i class={styles.iconArrow}></i>
  1867. <Cell border={false} class={styles.goodsCell}>
  1868. {{
  1869. icon: () => (
  1870. <Image
  1871. class={styles.img}
  1872. src={forms.detailVip.goodsUrl || tuangou}
  1873. />
  1874. ),
  1875. title: () => (
  1876. <div class={styles.section}>
  1877. <div class={styles.sectionContent}>
  1878. <h2>
  1879. <img src={icon5} class={styles.goodsName} />
  1880. <Tag class={styles.brandName}>
  1881. 12个月
  1882. </Tag>
  1883. </h2>
  1884. <p class={[styles.model]}>
  1885. <p>
  1886. <i></i>解决学生不会练、不知练的对错
  1887. </p>
  1888. <p>
  1889. <i></i>家长无法辅导、无需再额外请老师
  1890. </p>
  1891. </p>
  1892. <img src={icon6} class={styles.sendInstrument} />
  1893. </div>
  1894. </div>
  1895. )
  1896. }}
  1897. </Cell>
  1898. {forms.detailVip.membershipDays ? (
  1899. <div class={styles.memberNumer}>
  1900. <img src={iconGift} class={styles.iconGift} />
  1901. <p>
  1902. 首次购买赠送乐器AI学练工具
  1903. <span>{forms.detailVip.membershipDays || 0}</span>天有效期
  1904. </p>
  1905. </div>
  1906. ) : (
  1907. ''
  1908. )}
  1909. </div>
  1910. )}
  1911. {forms.joinType === 'tradition' && (
  1912. <div class={styles.goodsTradition}>
  1913. <i class={styles.iconArrow}></i>
  1914. <div class={styles.goodsTitle}></div>
  1915. <div class={styles.steps}>
  1916. <div class={styles.step}>
  1917. <span class={styles.nums}>
  1918. <span class={styles.numInner}>1</span>
  1919. </span>
  1920. <div class={styles.stepContent}>
  1921. <span>AI工具标准:</span>
  1922. 可以学练音乐教材中的乐曲,通过手机应用商店准备。
  1923. </div>
  1924. </div>
  1925. {['Panpipes', 'Ocarina', 'Tenor Recorder', 'Woodwind'].includes(
  1926. forms.instrumentCode
  1927. ) && (
  1928. <div class={styles.step}>
  1929. <span class={styles.nums}>
  1930. <span class={styles.numInner}>2</span>
  1931. </span>
  1932. <div class={styles.stepContent}>
  1933. <span>
  1934. {forms.instrumentCode === 'Panpipes' && '排箫'}
  1935. {forms.instrumentCode === 'Ocarina' && '陶笛'}
  1936. {forms.instrumentCode === 'Tenor Recorder' && '竖笛'}
  1937. {forms.instrumentCode === 'Woodwind' && '葫芦丝'}
  1938. 标准:
  1939. </span>
  1940. {forms.instrumentCode === 'Panpipes' &&
  1941. '管数不限,建议20管以上C调加嘴排箫(不需要重复更换),黑色,选择单一原调(调性多很难掌握);'}
  1942. {forms.instrumentCode === 'Ocarina' &&
  1943. 'C调、蓝色、十二孔高音、树脂或陶土均可;'}
  1944. {forms.instrumentCode === 'Tenor Recorder' &&
  1945. 'C调、木质、高音德式八孔;'}
  1946. {forms.instrumentCode === 'Woodwind' &&
  1947. 'C调、红木色、树脂或木质;'}
  1948. </div>
  1949. </div>
  1950. )}
  1951. </div>
  1952. </div>
  1953. )} */}
  1954. {forms.joinType && (
  1955. <MSticky position="bottom" ref={mstickyRef}>
  1956. <div class={styles.paymentContainer}>
  1957. {forms.joinType === 'digitalize' && (
  1958. <>
  1959. <div class={styles.payemntPrice}>
  1960. <img src={giftTip} class={styles.giftTip} />
  1961. <div>
  1962. <span class={styles.needPrice}>
  1963. <i style="font-style: normal">¥ </i>
  1964. <span>{moneyFormat(calcPrice.value.amount)}</span>
  1965. <i class={styles.unit} style="font-style: normal">
  1966. /年
  1967. </i>
  1968. </span>
  1969. {calcPrice.value.originAmount >
  1970. calcPrice.value.amount ? (
  1971. <del class={styles.allPrice}>
  1972. ¥ {moneyFormat(calcPrice.value.originAmount)}
  1973. </del>
  1974. ) : (
  1975. ''
  1976. )}
  1977. </div>
  1978. </div>
  1979. <div
  1980. class={styles.paymentBtn}
  1981. onClick={() => {
  1982. onSubmit();
  1983. }}>
  1984. <Button
  1985. round
  1986. disabled={forms.submitLoading}
  1987. loading={forms.submitLoading}>
  1988. 立即支付
  1989. </Button>
  1990. </div>
  1991. </>
  1992. )}
  1993. {forms.joinType === 'tradition' && (
  1994. <div
  1995. class={styles.traditionBtn}
  1996. onClick={() => {
  1997. onSubmit();
  1998. }}>
  1999. <Button
  2000. round
  2001. disabled={forms.submitLoading}
  2002. loading={forms.submitLoading}>
  2003. 提交报名
  2004. </Button>
  2005. </div>
  2006. )}
  2007. </div>
  2008. </MSticky>
  2009. )}
  2010. </div>
  2011. {forms.imgCodeStatus ? (
  2012. <MImgCode
  2013. v-model:value={forms.imgCodeStatus}
  2014. phone={studentInfo.username}
  2015. type="REGISTER"
  2016. onClose={() => {
  2017. forms.imgCodeStatus = false;
  2018. }}
  2019. onSendCode={onCodeSend}
  2020. />
  2021. ) : null}
  2022. {/* 年级 */}
  2023. <Popup
  2024. v-model:show={forms.gradeStatus}
  2025. position="bottom"
  2026. round
  2027. safeAreaInsetBottom
  2028. lazyRender={false}
  2029. class={'popupBottomSearch'}
  2030. onOpen={() => {
  2031. forms.gradePopupShow = true;
  2032. }}
  2033. onClosed={() => {
  2034. forms.gradePopupShow = false;
  2035. }}>
  2036. {forms.gradePopupShow && (
  2037. <Picker
  2038. showToolbar
  2039. v-model={forms.gradePopupIndex}
  2040. columns={forms.gradeList}
  2041. onCancel={() => (forms.gradeStatus = false)}
  2042. onConfirm={(val: any) => {
  2043. const selectedOption = val.selectedOptions[0];
  2044. studentInfo.extra.currentGradeNum = selectedOption.value;
  2045. forms.gradeNumText = selectedOption.text;
  2046. forms.gradeStatus = false;
  2047. if (
  2048. ['SCHOOL', 'GRADE'].includes(forms.schoolInstrumentSetType)
  2049. ) {
  2050. forms.instrumentCode = selectedOption.instrumentCode;
  2051. }
  2052. if (forms.schoolInstrumentSetType === 'CLASS') {
  2053. forms.classList = selectedOption.classList;
  2054. }
  2055. if (
  2056. ['CLASS', 'GRADE'].includes(forms.schoolInstrumentSetType)
  2057. ) {
  2058. forms.currentClassText = '';
  2059. studentInfo.extra.currentClass = '';
  2060. }
  2061. }}
  2062. />
  2063. )}
  2064. </Popup>
  2065. {/* 班级 */}
  2066. <Popup
  2067. v-model:show={forms.classStatus}
  2068. position="bottom"
  2069. round
  2070. class={'popupBottomSearch'}
  2071. onOpen={() => {
  2072. forms.classPopupShow = true;
  2073. }}
  2074. onClosed={() => {
  2075. forms.classPopupShow = false;
  2076. }}>
  2077. {forms.classPopupShow && (
  2078. <Picker
  2079. showToolbar
  2080. v-model={forms.classPopupIndex}
  2081. columns={forms.classList}
  2082. onCancel={() => (forms.classStatus = false)}
  2083. onConfirm={(val: any) => {
  2084. const selectedOption = val.selectedOptions[0];
  2085. studentInfo.extra.currentClass = selectedOption.value;
  2086. forms.currentClassText = selectedOption.text;
  2087. forms.classStatus = false;
  2088. if (['CLASS'].includes(forms.schoolInstrumentSetType)) {
  2089. forms.instrumentCode = selectedOption.instrumentCode;
  2090. }
  2091. }}
  2092. />
  2093. )}
  2094. </Popup>
  2095. {/* 已经购买过样品 */}
  2096. {/* <MDialog
  2097. title="提示"
  2098. v-model:show={forms.dialogConfirmStatus}
  2099. message={'已购买会员,是否确认购买?'}
  2100. primaryColor="#FF8057"
  2101. allowHtml={true}
  2102. confirmButtonText="确定"
  2103. showCancelButton
  2104. onConfirm={async () => {
  2105. await paymentContinue();
  2106. }}
  2107. onCancel={() => {
  2108. //取消支付,判断是否有结束时间,是否已经结束
  2109. if (forms.registerExpireTime && forms.activeOverStatus) {
  2110. applyOver();
  2111. }
  2112. }}
  2113. /> */}
  2114. <MDialog
  2115. title="提示"
  2116. v-model:show={forms.dialogStatus}
  2117. message={forms.dialogMessage}
  2118. allowHtml={true}
  2119. primaryColor="#FF8057"
  2120. showCancelButton={true}
  2121. messageAlign={forms.messageAlign}
  2122. confirmButtonText={forms.confirmButtonText}
  2123. cancelButtonText={forms.cancelButtonText}
  2124. onConfirm={async () => {
  2125. if (forms.joinType === 'tradition') {
  2126. //
  2127. await cancelPaymentOrder();
  2128. //取消支付,判断是否有结束时间,是否已经结束
  2129. if (forms.registerExpireTime && forms.activeOverStatus) {
  2130. applyOver();
  2131. }
  2132. }
  2133. if (forms.joinType === 'digitalize') {
  2134. // 继续支付
  2135. const paymentConfig = forms.dialogConfig;
  2136. state.config = paymentConfig?.paymentConfig;
  2137. state.orderNo = paymentConfig?.orderNo;
  2138. const updateStatus = await updateStudentInfo();
  2139. if (!updateStatus) return;
  2140. await lastSubmit();
  2141. }
  2142. }}
  2143. onCancel={(val: any) => {
  2144. // countDown.pause();
  2145. if (forms.joinType === 'tradition') {
  2146. forms.dialogStatus = false;
  2147. //取消支付,判断是否有结束时间,是否已经结束
  2148. if (forms.registerExpireTime && forms.activeOverStatus) {
  2149. applyOver();
  2150. }
  2151. }
  2152. if (forms.joinType === 'digitalize') {
  2153. // 重新下单 - 先关闭订单
  2154. resetOrderPayment();
  2155. }
  2156. }}
  2157. />
  2158. <Popup
  2159. show={state.paymentStatus}
  2160. closeOnClickOverlay={false}
  2161. position="bottom"
  2162. round
  2163. closeOnPopstate
  2164. safeAreaInsetBottom
  2165. style={{ minHeight: '30%' }}>
  2166. <Payment
  2167. paymentConfig={state.orderInfo}
  2168. onClose={() => (state.paymentStatus = false)}
  2169. onBackOut={onBackOut}
  2170. onConfirm={(val: any) => onConfirm(val)}
  2171. />
  2172. </Popup>
  2173. <Popup
  2174. v-model:show={state.showQrcode}
  2175. round
  2176. onClose={() => {
  2177. // 二维码关闭时清除定时器
  2178. clearInterval(state.orderTimer);
  2179. }}>
  2180. <QrcodePayment
  2181. url={state.qrCodeUrl}
  2182. pay_channel={state.pay_channel}
  2183. orderType={orderType.value}
  2184. />
  2185. </Popup>
  2186. <MPopup v-model:modelValue={state.authShow}>
  2187. <UserAuth onSuccess={onAuthSuccess} hideHeader={!browser().isApp} />
  2188. </MPopup>
  2189. {/* 是否在微信中打开 */}
  2190. <OWxTip
  2191. show={forms.showTips}
  2192. message={forms.showMessage}
  2193. showButton={forms.showButton}
  2194. buttonText="刷新"
  2195. onConfirm={() => window.location.reload()}
  2196. />
  2197. <MMessageTip
  2198. show={otherParams.showOtherSchool}
  2199. // showCloseButton={otherParams.showCloseButton}
  2200. messageAlign={otherParams.messageAlign}
  2201. message={otherParams.showOtherMessage}
  2202. showCancelButton={otherParams.showCancelButton}
  2203. cancelButtonColor={otherParams.cancelButtonColor}
  2204. cancelButtonText={otherParams.cancelButtonText}
  2205. confirmButtonColor={otherParams.confirmButtonColor}
  2206. confirmButtonText={otherParams.confirmButtonText}
  2207. onClose={() => (otherParams.showOtherSchool = false)}
  2208. onCancel={async () => {
  2209. otherParams.showOtherSchool = false;
  2210. if (otherParams.otherType === 'nickname') {
  2211. forms.isRegister = 'create'; // 新建
  2212. changeTipStatus(false, false);
  2213. onSubmit();
  2214. } else if (otherParams.otherType === 'member') {
  2215. const updateStatus = await updateStudentInfo();
  2216. if (!updateStatus) return;
  2217. //取消支付,判断是否有结束时间,是否已经结束
  2218. if (forms.registerExpireTime && forms.activeOverStatus) {
  2219. applyOver();
  2220. }
  2221. // onConfirm={async () => {
  2222. // await paymentContinue();
  2223. // }}
  2224. // onCancel={() => {
  2225. // //取消支付,判断是否有结束时间,是否已经结束
  2226. // if (forms.registerExpireTime && forms.activeOverStatus) {
  2227. // applyOver();
  2228. // }
  2229. // }}
  2230. }
  2231. }}
  2232. onConfirm={async () => {
  2233. otherParams.showOtherSchool = false;
  2234. // 名字
  2235. if (otherParams.otherType === 'nickname') {
  2236. forms.isRegister = 'update'; // 修改
  2237. changeTipStatus(false, false);
  2238. // 直接注册
  2239. onSubmit();
  2240. } else if (otherParams.otherType === 'change') {
  2241. // 学校更换
  2242. forms.isChangeSchool = true;
  2243. // 直接注册
  2244. onSubmit();
  2245. } else if (otherParams.otherType === 'limit') {
  2246. // 人数超限制
  2247. changeTipStatus(
  2248. forms.isRegister === 'create' && !forms.studentItem.userId
  2249. ? false
  2250. : true,
  2251. false
  2252. );
  2253. } else if (otherParams.otherType === 'member') {
  2254. await paymentContinue();
  2255. }
  2256. }}
  2257. />
  2258. <Popup
  2259. v-model:show={forms.showSelectStudent}
  2260. round
  2261. position="bottom"
  2262. safeAreaInsetBottom
  2263. closeable
  2264. class={styles.selectStudentPopup}>
  2265. <SelectStudent
  2266. studentItem={forms.studentItem}
  2267. list={forms.studentList}
  2268. onClose={() => (forms.showSelectStudent = false)}
  2269. onConfirm={(val: any) => {
  2270. if (val.userId) {
  2271. forms.studentItem = val;
  2272. const firstStudent = val;
  2273. studentInfo.extra.nickname = firstStudent.nickname;
  2274. const tempGrade: any = forms.gradeList || [];
  2275. studentInfo.extra.currentGradeNum = null;
  2276. forms.gradeNumText = '';
  2277. forms.instrumentCode = '';
  2278. tempGrade?.forEach((i: any) => {
  2279. if (i.value === firstStudent.currentGradeNum) {
  2280. forms.instrumentCode = i.instrumentCode;
  2281. forms.gradeNumText = i.text;
  2282. studentInfo.extra.currentGradeNum =
  2283. firstStudent.currentGradeNum;
  2284. if (forms.schoolInstrumentSetType === 'CLASS') {
  2285. forms.classList = i.classList;
  2286. }
  2287. }
  2288. });
  2289. studentInfo.extra.currentClass = null;
  2290. forms.currentClassText = '';
  2291. forms.classList.forEach((i: any) => {
  2292. if (i.value === firstStudent.currentClass) {
  2293. forms.currentClassText = i.text;
  2294. studentInfo.extra.currentClass = firstStudent.currentClass;
  2295. }
  2296. });
  2297. studentInfo.extra.gender = firstStudent.gender;
  2298. forms.isRegister = 'update';
  2299. changeTipStatus(true, false);
  2300. forms.showSelectStudent = false;
  2301. } else {
  2302. // 判断新建学员是否上限了
  2303. if (forms.studentList.length >= forms.multi_user_limit) {
  2304. otherParams.showOtherMessage = `同一手机号最多创建${forms.multi_user_limit}个学生`;
  2305. otherParams.showOtherSchool = true;
  2306. otherParams.showCancelButton = false;
  2307. otherParams.showCloseButton = true;
  2308. otherParams.confirmButtonColor =
  2309. 'linear-gradient( 305deg, #40C8FF 0%, #3192FF 100%)';
  2310. otherParams.confirmButtonText = '我知道了';
  2311. otherParams.otherType = 'limit';
  2312. otherParams.messageAlign = 'center';
  2313. return true;
  2314. } else {
  2315. forms.studentItem = val;
  2316. forms.isRegister = 'create';
  2317. changeTipStatus(false, false);
  2318. studentInfo.extra.nickname = '';
  2319. studentInfo.extra.currentGradeNum = '';
  2320. studentInfo.extra.currentClass = '';
  2321. studentInfo.extra.gender = 1;
  2322. forms.currentClassText = '';
  2323. forms.gradeNumText = '';
  2324. forms.showSelectStudent = false;
  2325. }
  2326. }
  2327. }}
  2328. />
  2329. </Popup>
  2330. </div>
  2331. );
  2332. }
  2333. });