index-9448b744.js 15 KB

1
  1. import{d as K,r as B,P as Z,q as ee,x,ag as te,e as F,y as ae,D as i,a as o,A as c,W as D,C as oe,R as w,S as N,z as re,M as T,N as f,bj as se,J as ne,K as ue,X as le}from"./index-0f430fcc.js";import{i as ie}from"./icon-gift-20293d47.js";import{M as ce}from"./index-0ead74db.js";import{u as de}from"./student-register-store-f0c1b2ce.js";import{d as pe}from"./deep-clone-c0d00fc2.js";import{C as me,M as fe}from"./index-0d69ce30.js";import{O as P}from"./index-24d7fd9a.js";import{P as ge,Q as ye,U as he,b as we}from"./user-auth-71363221.js";import{O as Te}from"./index-e851542e.js";import{M as Ce}from"./index-006d92d8.js";import{F as Se}from"./index-a1e7c45c.js";import{F as g}from"./index-42a305c0.js";import{R as _e,a as M}from"./index-e02130b9.js";import{T as R}from"./index-9a0fefcc.js";import{P as O}from"./index-1a705d0f.js";import"./index-cc542b8c.js";import"./index-15acf057.js";import"./index-3a587880.js";import"./index-787e92a9.js";import"./index-9129a731.js";import"./browser-e949d08f.js";import"./index-9b258718.js";import"./Checker-53dd11d8.js";const xe="_registerModal_81pmp_1",Fe="_registerModalSection_81pmp_6",Ae="_infoTitle_81pmp_11",Ee="_registerForm_81pmp_17",be="_fieldTipsGroup_81pmp_24",Ie="_fieldTips_81pmp_24",ve="_tips_81pmp_36",Be="_username_81pmp_43",De="_countDown_81pmp_51",Ne="_codeText_81pmp_68",Pe="_memberNumer_81pmp_72",Me="_iconGift_81pmp_85",Re="_paymentContainer_81pmp_95",Oe="_giftTip_81pmp_105",Ve="_needPrice_81pmp_109",Ge="_allPrice_81pmp_124",ke="_radioSection_81pmp_143",Ue="_radioItem_81pmp_152",u={registerModal:xe,registerModalSection:Fe,infoTitle:Ae,registerForm:Ee,fieldTipsGroup:be,fieldTips:Ie,tips:ve,username:Be,countDown:De,codeText:Ne,memberNumer:Pe,iconGift:Me,paymentContainer:Re,giftTip:Oe,needPrice:Ve,allPrice:Ge,radioSection:ke,radioItem:Ue},qe=""+new URL("r-title-3544dc16.png",import.meta.url).href,Le=""+new URL("gift-tip-43b54b61.png",import.meta.url).href,m=de(),A=[];for(let p=1;p<=40;p++)A.push({text:p+"班",value:p});const pt=K({name:"register-modal",setup(){const p=B(),E=Z(),b=ee(),C=B([]),t=x({schoolId:E.query.schoolId,countDownStatus:!0,countDownTime:1e3*120,modelValue:!1,imgCodeStatus:!1,gradeNumText:"",currentClassText:"",gradeStatus:!1,classStatus:!1,loading:!1,schoolType:"",gradeYear:"",bugGoods:!1,registerType:"",giftVipDay:0,dialogStatus:!1,dialogMessage:"",dialogConfirmStatus:!1,paymentType:"",contract_sign:!1,countDownTimePay:60*1e3,dialogConfig:{},showMore:!0,showTips:!1,showButton:!1,showMessage:"请使用微信打开"}),s=x({showQrcode:!1,qrCodeUrl:"",pay_channel:"",orderInfo:{},authShow:!1,orderNo:null,config:{},paymentStatus:!1,orderTimer:null}),r=x({autoRegister:!0,client_id:"cooleshow-student",client_secret:"cooleshow-student",extra:{nickname:"",currentGradeNum:"",currentClass:"",gender:1,registerType:null,giftVipDay:0},grant_type:"password",loginType:"SMS",password:"",username:""}),y=te({time:t.countDownTimePay,onChange(e){t.dialogMessage=`有待支付订单,请在${Math.ceil(e.total/1e3)}s后重试`},onFinish(){t.dialogStatus=!1}}),V=()=>{t.countDownStatus=!1,re(()=>{p.value.start()})},G=()=>{if(!T(r.username))return f("请输入正确的手机号码");t.imgCodeStatus=!0},k=F(()=>!!T(r.username)),I=F(()=>s.orderInfo.orderType),U=()=>{t.countDownStatus=!0,p.value.reset()},q=async()=>{try{if(L())return;t.loading=!0;const{extra:e,...a}=r,n=await i.post("/edu-app/userlogin",{requestType:"form",data:{...a,extra:JSON.stringify({...e,schoolId:t.schoolId})}});if(n.code!==200)n.code===5436?(t.showTips=!0,t.showMessage="二维码已经失效,详情请咨询学校老师",t.showButton=!1):n.code===5435&&(t.showTips=!0,t.showMessage=n.message,t.showButton=!0);else{m.setToken(n.data.token_type+" "+n.data.access_token),se();const l=await i.get("/edu-app/user/getUserInfo",{requestType:"form"});ne(l.data),await z()}}catch(e){}finally{t.loading=!1}},L=()=>{if(T(r.username))if(r.password)if(r.extra.nickname)if(r.extra.currentGradeNum){if(!r.extra.currentClass)return f("请选择所在班级"),!0}else return f("请选择所在年级"),!0;else return f("请输入学生姓名"),!0;else return f("请输入验证码"),!0;else return f("请输入正确的手机号码"),!0;return!1},Y=()=>{let e=[];const a=[{text:"一年级",value:1},{text:"二年级",value:2},{text:"三年级",value:3},{text:"四年级",value:4},{text:"五年级",value:5}],n=[{text:"六年级",value:6}],l=[{text:"七年级",value:7},{text:"八年级",value:8},{text:"九年级",value:9}];return t.gradeYear==="FIVE_YEAR_SYSTEM"?e.push([...a]):t.gradeYear==="SIX_YEAR_SYSTEM"?e.push([...a,...n]):t.gradeYear==="THREE_YEAR_SYSTEM"?e.push([...l]):t.gradeYear==="FORE_YEAR_SYSTEM"?e.push([...n,...l]):e.push([...a,...n,...l]),e},$=async()=>{try{const{data:e}=await i.get("/edu-app/open/userOrder/registerGoods/"+t.schoolId,{noAuthorization:!0});m.setVip(e.details||[]);const a=pe(e.details||[]);if(a.length>0&&(t.giftVipDay=a[0].membershipDays),t.bugGoods=e.bugGoods,t.schoolType=e.schoolType,t.gradeYear=e.gradeYear,t.registerType=e.registerType,r.extra.giftVipDay=t.giftVipDay,r.extra.registerType=t.registerType,N().weixin){if(e.schoolStatus===0&&t.schoolId=="1770035687490105346"){t.showTips=!0,t.showMessage="团购时间已截止,感谢您的参与",t.showButton=!1;return}if(e.registerType!=="BUG_GOODS"||e.schoolStatus===0){t.showTips=!0,t.showMessage="二维码已经失效,详情请咨询学校老师",t.showButton=!1;return}}else t.showTips=!0}catch(e){}},h=F(()=>{let e=0,a=0;return m.getVip.forEach(l=>{e+=Number(l.currentPrice),a+=Number(l.originalPrice)}),console.log(m.getVip),{amount:e,originAmount:a}}),z=async()=>{try{if(await H())return;const a=await i.get("/edu-app/userPaymentOrder/registerStatus/"+t.schoolId),n=m.getVip;if(a.data.hasBuyCourse&&n.length>0){t.dialogConfirmStatus=!0;return}await S()}catch(e){}},H=async()=>{let e=!1;try{const{data:a}=await i.get("/edu-app/userPaymentOrder/unpaid");if(!a.id)return!1;if(a.cancelPayment)return await i.post("/edu-app/userPaymentOrder/cancelPayment/"+a.orderNo),!1;t.countDownTime=a.cancelTimes,y.reset(Number(a.cancelTimes)),y.start(),t.dialogMessage=`有待支付订单,请在${Math.ceil(y.current.value.total/1e3)}s后重试`,t.dialogStatus=!0,t.dialogConfig=a,e=!0}catch(a){}return e},S=async()=>{try{const e=m.getVip,a=m.getGoods,n=[];e.forEach(d=>{n.push({giftVipDay:d.membershipDays,goodsId:d.goodsId,goodsNum:1,goodsType:d.goodsType,paymentCashAmount:d.currentPrice,paymentCouponAmount:0})}),a.forEach(d=>{n.push({goodsId:d.productId,goodsNum:d.quantity,goodsType:"INSTRUMENTS",paymentCashAmount:d.price,paymentCouponAmount:0,goodsSkuId:d.productSkuId})});const l=await i.post("/edu-app/userPaymentOrder/executeOrder",{data:{registerType:t.registerType,paymentType:t.paymentType,bizId:t.schoolId,orderType:"SCHOOL_REGISTER",paymentCashAmount:h.value.amount||0,paymentCouponAmount:0,goodsInfos:n,orderName:"学生登记",orderDesc:"学生登记"}});l.code===5436?(t.showTips=!0,t.showMessage="二维码已经失效,详情请咨询学校老师",t.showButton=!1):l.code===5435?(t.showTips=!0,t.showMessage=l.message,t.showButton=!0):(s.config={...l.data.paymentConfig,paymentType:l.data.paymentType},s.orderNo=l.data.orderNo,await v())}catch(e){console.log(e,"any")}},v=async()=>{try{const e=ue.user.data;if(t.contract_sign&&(!(e!=null&&e.account.realName)||!(e!=null&&e.account.idCardNo))){s.authShow=!0;return}const{data:a}=await i.post("/edu-app/userPaymentOrder/updateReceiveAddress",{data:{orderNo:s.orderNo,orderType:"SCHOOL_REGISTER"}});s.pay_channel=a.paymentChannel,a.status!=="WAIT_PAY"&&a.status!=="PAYING"?b.replace({path:"/payment-result",query:{orderNo:s.orderNo}}):Q()}catch(e){}},Q=()=>{const e=s.pay_channel;if(e){const a=we(s.pay_channel);_({payCode:a,pay_channel:e})}else I.value==="VIP"?s.paymentStatus=!0:_({payCode:"payResult",pay_channel:"wx_pub"})},_=e=>{const a=s.config;s.pay_channel=e.pay_channel;const n=le.stringify({pay_channel:e.pay_channel,wxAppId:a.wxAppId,alipayAppId:a.alipayAppId,paymentType:t.paymentType,body:a.body,price:a.price,orderNo:a.merOrderNo,userId:a.userId});e.payCode==="payResult"?window.location.href=window.location.origin+"/classroom-app/#/payResult?"+n:(s.qrCodeUrl=window.location.origin+"/classroom-app/#/payDefine?"+n,s.showQrcode=!0,s.paymentStatus=!1,setTimeout(()=>{J()},300))},W=async()=>{try{await i.post("/edu-app/userPaymentOrder/cancelPayment/"+s.orderNo)}catch(e){}},J=async()=>{const e=setInterval(async()=>{if(E.name!="student-register-form"){clearInterval(e);return}s.orderTimer=e;try{const{data:a}=await i.post("/edu-app/open/userOrder/paymentStatus/"+s.orderNo,{hideLoading:!0});a.status!=="WAIT_PAY"&&a.status!=="PAYING"&&(s.showQrcode=!1,clearInterval(s.orderTimer),setTimeout(()=>{b.replace({path:"/payment-result",query:{orderNo:s.orderNo}})},100))}catch(a){clearInterval(s.orderTimer)}},5e3)},X=()=>{s.authShow=!1,S()},j=async()=>{if(!(r.password.length!==6||!T(r.username)))try{const{data:e}=await i.get(`/edu-app/open/student/studentInfo?mobile=${r.username}&code=${r.password}&type=REGISTER`);if(e){r.extra.nickname||(r.extra.nickname=e.nickname),r.extra.currentGradeNum||(r.extra.currentGradeNum=e.currentGradeNum),r.extra.currentClass||(r.extra.currentClass=e.currentClass),r.extra.gender=r.extra.gender!==e.gender?e.gender:r.extra.gender,A.forEach(n=>{n.value===e.currentClass&&(t.currentClassText=n.text)});const a=C.value[0]||[];a==null||a.forEach(n=>{n.value===e.currentGradeNum&&(t.gradeNumText=n.text)})}}catch(e){}};return ae(async()=>{try{const{data:e}=await i.get("/edu-app/open/paramConfig/queryByParamNameList",{requestType:"form",params:{paramNames:"payment_service_provider,contract_sign"}});e&&Array.isArray(e)&&e.forEach(a=>{a.paramName==="contract_sign"?t.contract_sign=a.paramValue==="1":a.paramName==="payment_service_provider"&&(t.paymentType=a.paramValue||"")}),await $()}catch(e){}C.value=Y()}),()=>o("div",{class:u.registerModal},[o("div",{class:u.registerModalSection},[o("img",{src:qe,class:u.infoTitle},null),o(Se,{labelAlign:"left",class:u.registerForm},{default:()=>[o(g,{clearable:!1,label:"联系方式(直接监护人)",placeholder:"请输入手机号码",type:"tel",required:!0,autocomplete:"off",inputAlign:"right",class:u.username,modelValue:r.username,"onUpdate:modelValue":e=>r.username=e,border:!1,maxlength:11},{label:()=>o("div",null,[c("联系方式"),o("p",{class:u.tips},[c("(直接监护人)")])])}),o("div",{class:["van-hairline--bottom",u.fieldTipsGroup]},[o("div",{class:[u.fieldTips]},[c("手机号是音乐数字课堂的唯一登录账户")])]),o(g,{center:!0,clearable:!1,required:!0,inputAlign:"right",label:"验证码",placeholder:"请输入验证码",autocomplete:"off",type:"number",modelValue:r.password,"onUpdate:modelValue":[e=>r.password=e,e=>{console.log(e,"val"),j()}],maxlength:6},{button:()=>t.countDownStatus?o("span",{class:[u.codeText,k.value?"":u.codeTextDisabled],onClick:G},[c("获取验证码")]):o(me,{ref:e=>p.value=e,"auto-start":!1,class:u.countDown,time:t.countDownTime,onFinish:U,format:"ss秒后重试"},null)}),o(g,{clearable:!1,required:!0,inputAlign:"right",label:"学生姓名",placeholder:"请输入学生姓名",autocomplete:"off",maxlength:14,modelValue:r.extra.nickname,"onUpdate:modelValue":e=>r.extra.nickname=e},null),o(g,{clearable:!1,required:!0,inputAlign:"right",label:"学生性别",placeholder:"请选择性别",autocomplete:"off"},{input:()=>o(_e,{"checked-color":"linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)",modelValue:r.extra.gender,"onUpdate:modelValue":e=>r.extra.gender=e,direction:"horizontal"},{default:()=>[o(R,{size:"large",type:"primary",color:r.extra.gender!==1?"#F5F6FA":"linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)",textColor:r.extra.gender!==1?"#626264":"#fff",class:u.radioSection},{default:()=>[o(M,{class:u.radioItem,name:1},null),c("男")]}),o(R,{size:"large",type:"primary",color:r.extra.gender!==0?"#F5F6FA":"linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)",textColor:r.extra.gender!==0?"#626264":"#fff",class:u.radioSection},{default:()=>[o(M,{class:u.radioItem,name:0},null),c("女")]})]})}),o(g,{clearable:!1,required:!0,inputAlign:"right",label:"所在年级",placeholder:"请选择年级",isLink:!0,readonly:!0,clickable:!1,modelValue:t.gradeNumText,onClick:()=>t.gradeStatus=!0},null),o(g,{clearable:!1,required:!0,inputAlign:"right",label:"所在班级",placeholder:"请选择班级",isLink:!0,readonly:!0,clickable:!1,modelValue:t.currentClassText,onClick:()=>t.classStatus=!0},null),t.giftVipDay>0&&o("div",{class:u.memberNumer},[o("img",{src:ie,class:u.iconGift},null),o("p",null,[c("注册成功即可获得乐器AI学练工具"),o("span",null,[t.giftVipDay||0]),c("天有效期")])])]}),o(Ce,{position:"bottom"},{default:()=>[o("div",{class:u.paymentContainer},[o("div",{class:u.payemntPrice},[o("img",{src:Le,class:u.giftTip},null),o("div",null,[o("span",{class:u.needPrice},[o("i",{style:"font-style: normal"},[c("¥ ")]),o("span",null,[D(h.value.amount)]),o("i",{style:"font-style: normal"},[c("/年")])]),h.value.originAmount>h.value.amount?o("del",{class:u.allPrice},[c("¥ "),D(h.value.originAmount)]):""])]),o("div",{class:u.paymentBtn,onClick:q},[o(oe,{round:!0,disabled:t.loading,loading:t.loading},{default:()=>[c("立即支付")]})])])]})]),t.imgCodeStatus?o(ce,{value:t.imgCodeStatus,"onUpdate:value":e=>t.imgCodeStatus=e,phone:r.username,type:"REGISTER",onClose:()=>{t.imgCodeStatus=!1},onSendCode:V},null):null,o(w,{show:t.gradeStatus,"onUpdate:show":e=>t.gradeStatus=e,position:"bottom",round:!0,safeAreaInsetBottom:!0,lazyRender:!1,class:"popupBottomSearch"},{default:()=>[o(O,{showToolbar:!0,columns:C.value,onCancel:()=>t.gradeStatus=!1,onConfirm:e=>{const a=e.selectedOptions[0];r.extra.currentGradeNum=a.value,t.gradeNumText=a.text,t.gradeStatus=!1}},null)]}),o(w,{show:t.classStatus,"onUpdate:show":e=>t.classStatus=e,position:"bottom",round:!0,class:"popupBottomSearch"},{default:()=>[o(O,{showToolbar:!0,columns:A,onCancel:()=>t.classStatus=!1,onConfirm:e=>{const a=e.selectedOptions[0];r.extra.currentClass=a.value,t.currentClassText=a.text,t.classStatus=!1}},null)]}),o(P,{title:"提示",show:t.dialogConfirmStatus,"onUpdate:show":e=>t.dialogConfirmStatus=e,message:"已购买会员,是否确认购买?",primaryColor:"#FF8057",allowHtml:!0,confirmButtonText:"确定",showCancelButton:!0,onConfirm:async()=>{await S()}},null),o(P,{title:"提示",show:t.dialogStatus,"onUpdate:show":e=>t.dialogStatus=e,message:t.dialogMessage,allowHtml:!0,primaryColor:"#FF8057",confirmButtonText:"继续支付",onConfirm:async()=>{console.log(t.dialogConfig,"dialogConfig"),y.pause();const e=t.dialogConfig.paymentConfig;s.config=e==null?void 0:e.paymentConfig,s.orderNo=e==null?void 0:e.orderNo,await v()},onCancel:e=>{y.pause()}},null),o(w,{show:s.paymentStatus,closeOnClickOverlay:!1,position:"bottom",round:!0,closeOnPopstate:!0,safeAreaInsetBottom:!0,style:{minHeight:"30%"}},{default:()=>[o(ge,{paymentConfig:s.orderInfo,onClose:()=>s.paymentStatus=!1,onBackOut:W,onConfirm:e=>_(e)},null)]}),o(w,{show:s.showQrcode,"onUpdate:show":e=>s.showQrcode=e,round:!0,onClose:()=>{clearInterval(s.orderTimer)}},{default:()=>[o(ye,{url:s.qrCodeUrl,pay_channel:s.pay_channel,orderType:I.value},null)]}),o(Te,{modelValue:s.authShow,"onUpdate:modelValue":e=>s.authShow=e},{default:()=>[o(he,{onSuccess:X,hideHeader:!N().isApp},null)]}),o(fe,{show:t.showTips,message:t.showMessage,showButton:t.showButton,buttonText:"刷新",onConfirm:()=>window.location.reload()},null)])}});export{pt as default};