import { defineComponent, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue' import styles from './index.module.less' import headTitle from './images/header-title.png' import headPhone from './images/header-phone.png' import headBg from './images/header-bg.png' import iconHead from './images/icon-head.png' import iconBao from './images/icon-bao.png' import iconFree from './images/icon-free.png' import icon12 from './images/icon-12.png' import iconCheckbox from './images/icon-checkbox-ring.png' import iconCheckboxActive from './images/icon-checkbox-active.png' import { Button, Cell, CellGroup, Field, Form, Radio, RadioGroup, Tag, showToast, Image, Checkbox } from 'vant' import { useRoute, useRouter } from 'vue-router' import { moneyFormat } from '@/helpers/utils' import request from '@/helpers/request' // 乐团交付,乐团停止或关闭,有新的交付团;则不允许报名 const classList: any = [] for (let i = 1; i <= 40; i++) { classList.push({ text: i + '班', value: i }) } export default defineComponent({ name: 'pre-goods-apply', setup() { const route = useRoute() // 获取是否已经看过训练工具图片 const state = reactive({ code: '' as any, // 微信授权code码 detail: {} as any, // 学员详情 toolImgStatus: false, currentGrade: [ { text: '一年级', value: 1 }, { text: '二年级', value: 2 }, { text: '三年级', value: 3 }, { text: '四年级', value: 4 }, { text: '五年级', value: 5 }, { text: '六年级', value: 6 }, { text: '七年级', value: 7 }, { text: '八年级', value: 8 }, { text: '九年级', value: 9 } ], // 年级数组列表 classList: classList, subjectList: [] as any, // 选报声部列表 instrumentsInspectionDescribe: '', // 配置信息 inspectPopupStatus: false, // 查看说明 gradeStatus: false, classStatus: false, subjectStatus: false, registerInfo: {} as any, // 乐团信息 goodsInfo: {} as any, // 商品 textBookInfo: {} as any, // 教材 inspectInfo: {} as any, // 乐器检查 vipYearInfo: {} as any, // 学练工具 inspectStatus: true, // 是否开启微信登录(测试使用)默认为false testIsWeixin: false, details: [] as any, // pattern: /^1(3|4|5|6|7|8|9)\d{9}$/, nameReg: /^[\u4E00-\u9FA5]+$/, paymentType: '', musicPaymentType: '', // 乐团中对应支付方式 studentReadStatus: false, // 学生在读 dialogStatus: false, dialogMessage: '', dialogOrchestraStatus: false, // 是否为不同的乐团 dialogConfig: {} as any, orderInfo: { needPrice: 0, originalPrice: 0 }, submitStatus: false }) const forms = reactive({ username: null, sex: null as any, currentGrade: null, currentGradeTxt: null, // 年级编号 currentClass: '', // 班级 currentClassTxt: null, // 年级编号 registerSubjectId: '', registerSubjectTxt: null, // 所在选报声部 parentName: null, groupBuyType: '' as any, phone: null as any, learningTools: null, instrumentsBrand: null }) const otherParams = reactive({ toolPlan: { title: '', // 训练工具准备 groupTitle: '', // 团购标题 groupDesc: '', // 团购文案 selfTitle: '', // 自备标题 selfDesc: '' // 自备文案 }, leBao: { // 乐器保障 show: 1, // 是否显示 selected: 1 // 是否选择 } }) const validator = (val: any) => { // 校验函数返回 true 表示校验通过,false 表示不通过 return state.nameReg.test(val) && val.length >= 2 && val.length <= 15 } const message = (value: any) => { if (!value) { return '请填写学员真实姓名' } else if (!state.nameReg.test(value)) { return '学员姓名必须为中文' } else if (value.length < 2 || value.length > 15) { return '学员姓名必须为2~15个字' } else { return '' } } // 乐团报名 const onSubmit = async () => { // } const messageContent = ref('') const orchestraName = ref(route.query.orchestraName || '') // 乐团名称 const getMessage = (ev: any) => { if (ev.data.api === 'payment-notes') { const result = ev.data.data ? JSON.parse(ev.data.data) : {} console.log(result, 'result') messageContent.value = result.notice otherParams.toolPlan = result.toolPlan otherParams.leBao = result.leBao // document.body } } // 获取入选声部信息 const getSubjects = async () => { try { const subjects = await request.post( '/api-student/open/orchestraSubjectConfig/pageByOrchestraId', { data: { orchestraId: route.query.id, page: 1, rows: 100 } } ) const rows = subjects.data.rows || [] rows.forEach((item: any) => { state.subjectList.push({ text: item.name, value: item.subjectId }) }) if (rows.length > 0) { forms.registerSubjectId = rows[0].subjectId // detail.registerSubjectId forms.registerSubjectTxt = rows[0].name registerGoods() } } catch { // } } // 获取商品信息 const registerGoods = async () => { try { const { data } = await request.get( '/api-student/orchestraRegister/registerGoods/' + route.query.id, { params: { subjectId: forms.registerSubjectId } } ) state.musicPaymentType = data.paymentServiceProvider || '' // 初始化数据商品数据 const details = data.details || [] details.forEach((item: any) => { if (item.goodsType === 'INSTRUMENTS') { const img = item.goodsUrl ? item.goodsUrl.split(',')[0] : '' state.goodsInfo = { ...item, goodsUrl: img } state.instrumentsInspectionDescribe = item.instrumentsInspectionDescribe } else if (item.goodsType === 'TEXTBOOK') { const img = item.goodsUrl ? item.goodsUrl.split(',')[0] : '' state.textBookInfo = { ...item, goodsUrl: img } } else if (item.goodsType === 'INSTRUMENT_INSPECT') { state.inspectInfo = { ...item } } else if (item.goodsType === 'VIP_YEAR') { state.vipYearInfo = { ...item } } state.details = details }) } catch { // } } onMounted(async () => { await getSubjects() nextTick(() => { // 是否加载完成 window.parent && window.parent.postMessage( { api: 'onLoad', status: true }, '*' ) }) window.addEventListener('message', getMessage) }) onUnmounted(() => { window.removeEventListener('message', getMessage) }) return () => (
{orchestraName.value}