index.tsx 84 KB

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