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

chore: update

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