提交 7415c3dc authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 2f4d4a85
...@@ -45,7 +45,7 @@ export default { ...@@ -45,7 +45,7 @@ export default {
form: { form: {
name: '', name: '',
phone: '', phone: '',
project_id: 1000, project_id: 5009,
}, },
} }
}, },
......
...@@ -39,11 +39,9 @@ export default { ...@@ -39,11 +39,9 @@ export default {
font-weight: bold; font-weight: bold;
color: #c01540; color: #c01540;
line-height: 25px; line-height: 25px;
width: 400px;
} }
.des-box { .des-box {
width: 400px; margin-top: 10px;
margin-top: 24px;
p { p {
font-size: 14px; font-size: 14px;
color: #717171; color: #717171;
......
<template> <template>
<div class="pay-pop-box"> <div class="pay-pop-box">
<div class="content-box" v-if="!isCodeShow"> <div class="content-box" v-if="!isCodeShow">
<i class="el-icon-close" @click="$emit('closePayPop')"></i> <i class="el-icon-close" @click="$emit('close')"></i>
<div class="tips-cen"> <div class="tips-cen">
<div class="name">活动名称:</div> <div class="name">活动名称:</div>
<div class="js">{{ train.title }}</div> <div class="js">{{ train.title }}</div>
...@@ -72,7 +72,7 @@ export default { ...@@ -72,7 +72,7 @@ export default {
.createOrder({ .createOrder({
pay_type: this.payMethod, pay_type: this.payMethod,
shop_id: this.train.shop_id, shop_id: this.train.shop_id,
spu_id: this.train.shop_id, spu_id: this.train.spu_id,
sku_id: this.train.sku_id, sku_id: this.train.sku_id,
form_id: this.form.id, form_id: this.form.id,
}) })
...@@ -111,14 +111,14 @@ export default { ...@@ -111,14 +111,14 @@ export default {
}, },
closeClear() { closeClear() {
this.isCodeShow = false this.isCodeShow = false
this.$emit('closePayPop') this.$emit('close')
}, },
payEnd(orderOn) { payEnd(orderOn) {
const param = { const param = {
order_no: orderOn, order_no: orderOn,
form_id: this.form.id.toString(), form_id: this.form.id,
} }
api.payEnd(param).then((res) => {}) api.payEnd(param)
}, },
}, },
beforeDestroy() { beforeDestroy() {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div> <div>
<div class="title-form">技能培训报名信息填写</div> <div class="title-form">技能培训报名信息填写</div>
<div class="form-box"> <div class="form-box">
<el-form ref="form" :model="form" :rules="rules" label-width="110px" class="forms" :disabled="isPayStatus"> <el-form ref="form" :model="form" :rules="rules" label-width="110px" :disabled="isPay">
<el-form-item label="真实姓名" id="name" prop="username"> <el-form-item label="真实姓名" id="name" prop="username">
<el-input v-model="form.username"></el-input> <el-input v-model="form.username"></el-input>
</el-form-item> </el-form-item>
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<el-form-item label="手机号码" prop="mobile"> <el-form-item label="手机号码" prop="mobile">
<el-input v-model="form.mobile"></el-input> <el-input v-model="form.mobile"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="验证码"> <el-form-item label="验证码" prop="code" v-if="!isLogin" required>
<el-input v-model="form.checked_code"> <el-input v-model="form.code">
<template #append> <template #append>
<countdown @start="getCheckedCode"></countdown> <countdown @start="getCheckedCode"></countdown>
</template> </template>
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
<el-form-item label="学生来源" prop="school_name"> <el-form-item label="学生来源" prop="school_name">
<el-input v-model="form.school_name"></el-input> <el-input v-model="form.school_name"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="等级" prop="grade"> <el-form-item label="等级" prop="grade" required>
<el-select v-model="form.grade" class="width100"> <el-select v-model="form.grade" class="width100">
<el-option v-for="item in gradList" :key="item.value" :label="item.label" :value="item.value"></el-option> <el-option v-for="item in gradList" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="证书邮寄地址" prop="address"> <el-form-item label="证书邮寄地址" prop="address" required>
<el-input v-model="form.address"></el-input> <el-input type="textarea" :rows="4" v-model="form.address"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="是否需要发票" prop="has_invoice"> <el-form-item label="是否需要发票" prop="has_invoice">
<el-radio-group v-model="form.has_invoice"> <el-radio-group v-model="form.has_invoice">
...@@ -76,12 +76,17 @@ ...@@ -76,12 +76,17 @@
</template> </template>
<el-form-item> <el-form-item>
<template v-if="isPayStatus"> <template v-if="isPay">
<el-button style="width: 200px" type="primary">已支付</el-button> <el-button style="width: 290px" type="primary">已支付</el-button>
</template> </template>
<template v-else> <template v-else>
<el-button style="width: 100px" type="primary" @click="formVerification(onSubmit)">提 交</el-button> <el-button style="width: 140px" type="primary" @click="handleSubmit">提 交</el-button>
<el-button style="width: 100px; margin-left: 10px" type="primary" @click="formVerification(goPay)" <el-button
plain
type="primary"
style="width: 140px; margin-left: 10px"
@click="payVisible = true"
v-if="isSubmit"
>去付款</el-button >去付款</el-button
> >
</template> </template>
...@@ -89,11 +94,11 @@ ...@@ -89,11 +94,11 @@
</el-form> </el-form>
</div> </div>
<pay-pop <pay-pop
v-show="isPayPopShow"
:train="train" :train="train"
:form="form" :form="form"
@payStatus="payStatus" @success="getDetail"
@closePayPop="closePayPop" @close="payVisible = false"
v-if="payVisible"
class="payPop" /> class="payPop" />
</div> </div>
</template> </template>
...@@ -104,9 +109,7 @@ import nations from '@/utils/nations' ...@@ -104,9 +109,7 @@ import nations from '@/utils/nations'
import countdown from '@/components/countdown.vue' import countdown from '@/components/countdown.vue'
import datalist from './data.js' import datalist from './data.js'
const IDCARD_REG = import { IDCARD_REG, MOBILE_REG } from '@/utils/validate'
/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$)/
const MOBILE_REG = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/
export default { export default {
components: { payPop, countdown }, components: { payPop, countdown },
...@@ -130,8 +133,10 @@ export default { ...@@ -130,8 +133,10 @@ export default {
} }
} }
return { return {
isLogin: false,
isSubmit: false, isSubmit: false,
isPayStatus: false, isPay: false,
payVisible: false,
nations: nations, nations: nations,
gradList: [ gradList: [
{ label: '初级', value: '初级' }, { label: '初级', value: '初级' },
...@@ -155,7 +160,7 @@ export default { ...@@ -155,7 +160,7 @@ export default {
opening_bank_account: '', opening_bank_account: '',
invoice_detail: '非学历教育*培训费', invoice_detail: '非学历教育*培训费',
mobile: '', mobile: '',
checked_code: '', code: '',
grade: '', grade: '',
address: '', address: '',
avatar: '', avatar: '',
...@@ -177,9 +182,6 @@ export default { ...@@ -177,9 +182,6 @@ export default {
{ validator: mobileChecked, trigger: 'blur' }, { validator: mobileChecked, trigger: 'blur' },
], ],
}, },
isBtnDisabled: false,
isPayPopShow: false,
isLogin: false,
} }
}, },
computed: { computed: {
...@@ -196,118 +198,38 @@ export default { ...@@ -196,118 +198,38 @@ export default {
} }
api.getUser().then((res) => { api.getUser().then((res) => {
if (res && res.code === 0) { if (res && res.code === 0) {
window.sessionStorage.userInfo = JSON.stringify(res.data)
this.isLogin = true this.isLogin = true
this.getDetail() this.getDetail()
} }
}) })
}, },
methods: { methods: {
goPay() {
this.isPayPopShow = true
},
// 获取报名信息 // 获取报名信息
async getDetail(call) { async getDetail() {
const res = await api.getFormDetail({ periods: this.id }) const res = await api.getFormDetail({ periods: this.id })
this.isSubmit = Object.keys(res.data.detail).length > 0 const detail = res.data.detail
this.form = Object.assign(this.form, res.data.detail) this.isSubmit = Object.keys(detail).length > 0
if (res.data.detail.order_info) { if (this.isSubmit) {
this.checkPay(res.data.detail.order_info.pay_order_id, call) this.form = Object.assign(this.form, detail)
this.isPay = detail.order_status
this.payVisible = false
} }
}, },
// 支付 // 提交报名信息
checkPay(id, call) { async handleSubmit() {
api.checkPay(id).then((res) => { await this.$refs.form.validate()
if (res.code === 0) { if (!this.isLogin) {
const [order = {}] = res.data await api.registerAndLogin({
if (order.status === 1) { mobile: this.form.mobile,
this.isPayStatus = true code: this.form.code,
} else { nickname: this.form.username,
call && call() project_id: 5009,
}
}
}) })
},
payStatus() {
this.isPayStatus = true
this.isPayPopShow = false
},
// 关闭支付弹窗
closePayPop() {
this.isPayPopShow = false
},
formVerification(call) {
if (this.isLogin) {
this.form.checked_code = '1234'
if (this.form.order_no === '') {
this.form.order_no = '1'
}
} }
this.$refs.form.validate((valid) => { const { code } = await api.submitForm({ ...this.form, periods: this.id })
if (valid) { if (code === 200) {
call() this.$message.success('报名信息提交成功')
} else {
return false
}
})
},
onSubmit() {
// 登录了直接走报名表单 没有登录走注册登录后再走报名表单
if (this.isLogin) {
this.submitForm()
.then((res) => {
this.message('提交成功!', 'success', 6000)
this.getDetail() this.getDetail()
this.updateUser()
// setTimeout(() => {
// this.message('手机号注册成功!','success', 6000)
// }, 300)
})
.catch((error) => {
if (error && error.type === 'register') {
// this.message('报名信息提交成功!','success', 6000)
// setTimeout(() => {
// this.message('注册失败,' + error.msg + ',请重新注册','error', 6000)
// }, 300)
} else {
let errorMsg = error.msg || ''
this.message('报名信息提交失败!' + errorMsg, 'error', 6000)
}
})
} else {
this.defaultRegister().then((res) => {
this.getDetail(
this.submitForm()
.then((res) => {
this.message('报名信息提交成功!', 'success', 6000)
// this.message('报名信息修改成功!','success', 6000)
// setTimeout(() => {
// this.message('手机号注册成功!','success', 6000)
// }, 300)
setTimeout(() => {
this.$router.go(0)
}, 1000)
})
.catch((error) => {
if (error && error.type === 'register') {
// this.message('报名信息提交成功!','success', 6000)
// setTimeout(() => {
// this.message('注册失败,' + error.msg + ',请重新注册','error', 6000)
// }, 300)
} else {
let errorMsg = error.msg || ''
this.message('报名信息提交失败!' + errorMsg, 'error', 6000)
}
})
)
})
}
},
async submitForm() {
const res = await api.submitForm({ ...this.form, periods: this.id })
if (res && res.code === 200) {
this.$message('报名信息提交成功')
} else { } else {
this.$message.error('报名信息提交失败') this.$message.error('报名信息提交失败')
} }
...@@ -318,73 +240,19 @@ export default { ...@@ -318,73 +240,19 @@ export default {
} else if (!MOBILE_REG.test(this.form.mobile)) { } else if (!MOBILE_REG.test(this.form.mobile)) {
this.$message('手机号格式错误') this.$message('手机号格式错误')
} else { } else {
let param = { api
.sendCode({
account: this.form.mobile, account: this.form.mobile,
service: 'sofia.ezijing.com', service: 'sofia.ezijing.com',
}
api.sendCode(param).then((res) => {
if (res && res.code === 0) {
this.$message({
message: '验证码发送成功',
type: 'success',
})
} else {
this.$message({
message: res.msg || '发送验证码失败',
type: 'error',
})
}
}) })
this.isBtnDisabled = true .then((res) => {
this.btnDisabledTimer()
}
},
defaultRegister() {
let param = {
mobile: this.form.mobile,
code: this.form.checked_code,
nickname: this.form.username,
project_id: 5002,
// password: '123456',
// secret: true,
// service: 'sofia.ezijing.com'
}
let promise = new Promise((resolve, reject) => {
api.registerAndLogin(param).then((res) => {
if (res && res.code === 0) { if (res && res.code === 0) {
//code: 0注册成功 5已注册 this.$message({ message: '验证码发送成功', type: 'success' })
resolve({
type: 'register',
state: 'success',
msg: 'success',
})
} else if (res && res.code === 5) {
reject({
type: 'register',
state: 'fail',
msg: res.msg || '此手机号已经被注册',
})
} else { } else {
this.$message.error(res.msg) this.$message({ message: res.msg || '发送验证码失败', type: 'error' })
reject({
type: 'register',
state: 'fail',
msg: res.msg || '注册失败',
})
} }
}) })
})
return promise
},
message(errMsg, type, dur) {
this.$message({ message: errMsg, type: type || 'info', duration: dur || 3000 })
},
async updateUser() {
if (!this.form.username) {
return
} }
await api.updateUser({ real_name: this.form.username })
}, },
}, },
} }
...@@ -427,16 +295,6 @@ export default { ...@@ -427,16 +295,6 @@ export default {
margin: 0 auto; margin: 0 auto;
padding: 24px 0; padding: 24px 0;
} }
::v-deep {
.forms {
i {
font-size: 20px;
}
input {
border-radius: 4px;
}
}
}
.payPop { .payPop {
position: fixed; position: fixed;
top: 0; top: 0;
......
...@@ -59,15 +59,8 @@ httpRequest.interceptors.request.use( ...@@ -59,15 +59,8 @@ httpRequest.interceptors.request.use(
// 响应拦截 // 响应拦截
httpRequest.interceptors.response.use( httpRequest.interceptors.response.use(
function (response) { function (response) {
const { data } = response const { config, data } = response
if (config.url.includes('/api/microservices') && data.code !== 200) {
if (parseInt(data.error) && data.message === '需要登录才能调用接口') {
location.href = `${process.env.loginURL}/login/index?redirect_uri=${encodeURIComponent(location.href)}`
return Promise.reject(data)
}
// enrollment
if (parseInt(data.error)) {
Message.error(data.message) Message.error(data.message)
return Promise.reject(data) return Promise.reject(data)
} }
......
export const IDCARD_REG =
/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$)/
export const MOBILE_REG = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论