提交 0151e062 authored 作者: haodaking's avatar haodaking

feat: 办事大厅支付迁移

上级 b26754ac
...@@ -117,3 +117,17 @@ export function getGraduationProductList(data) { ...@@ -117,3 +117,17 @@ export function getGraduationProductList(data) {
export function mergeGraduationProduct(data) { export function mergeGraduationProduct(data) {
return httpRequest.post('/api/pay/v1/product/create-by-details', data) return httpRequest.post('/api/pay/v1/product/create-by-details', data)
} }
/**
* 创建订单
* */
export function createOrder(data) {
return httpRequest.post('/api/shop/order/add', data, { headers: { 'Content-Type': 'application/json' } })
}
/**
* 获取订单
* */
export function getOrderList(data) {
return httpRequest.post('/api/shop/order/search', data, { headers: { 'Content-Type': 'application/json' } })
}
<template> <template>
<div class="pay"> <div class="pay">
<!-- 微信 --> <!-- 微信 -->
<div class="qr-pay" v-if="payment === '2'"> <div class="qr-pay" v-if="payment === '1'">
<qrcode-vue :value="qrcodeValue" size="200"></qrcode-vue> <qrcode-vue :value="qrcodeValue" size="200"></qrcode-vue>
<p class="tips">微信扫一扫支付</p> <p class="tips">微信扫一扫支付</p>
</div> </div>
<!-- 支付宝 --> <!-- 支付宝 -->
<div class="qr-pay" v-else-if="payment === '1'"> <div class="qr-pay" v-else-if="payment === '11'">
<qrcode-vue :value="qrcodeValue" size="200"></qrcode-vue> <qrcode-vue :value="qrcodeValue" size="200"></qrcode-vue>
<p class="tips">支付宝扫一扫支付</p> <p class="tips">支付宝扫一扫支付</p>
</div> </div>
...@@ -29,7 +29,7 @@ import QrcodeVue from 'qrcode.vue' ...@@ -29,7 +29,7 @@ import QrcodeVue from 'qrcode.vue'
export default { export default {
props: { props: {
payment: { type: String }, // 支付方式 payment: { type: String }, // 支付方式
productId: { type: String, required: true }, // 商品ID product: { type: Object, required: true }, // 商品信息
num: { type: [Number, String], default: 1 } // 购买数量 num: { type: [Number, String], default: 1 } // 购买数量
}, },
components: { QrcodeVue }, components: { QrcodeVue },
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
}, },
computed: { computed: {
qrcodeValue() { qrcodeValue() {
return this.order.url return this.order.payment_url
}, },
pid() { pid() {
return this.$route.params.id return this.$route.params.id
...@@ -52,23 +52,32 @@ export default { ...@@ -52,23 +52,32 @@ export default {
} }
}, },
methods: { methods: {
// 创建微信订单 // 创建订单
createWxPayOrder(productId, num = 1) { createOrder() {
return api.createWxpayOrder('ezijing', productId, { num, notify_url: this.notifyUrl }).then(response => { const params = {
this.order = response buy_count: this.num + '',
return response payment_method: this.payment,
}) shop_id: this.product.shop_id,
}, spu_id: this.product.spu_id,
// 创建支付宝订单 sku_id: this.product.sku_id
createAliPayOrder(productId, num = 1) { }
return api.createAlipayOrder(productId, { type: 2, num, notify_url: this.notifyUrl }).then(response => { return api.createOrder(params).then(response => {
if (response.code === 0) {
this.order = response this.order = response
} else {
this.$message.error(response.msg)
}
return response return response
}) })
}, },
getOrder() { getOrder() {
return api.getOrder(this.order.order_no).then(response => { const params = {
const { order } = response shop_id: this.product.shop_id,
spu_id: this.product.spu_id,
order_id: this.order.order_id
}
return api.getOrderList(params).then(response => {
const [order = {}] = response.data
this.rawOrder = order this.rawOrder = order
return order return order
}) })
...@@ -77,7 +86,7 @@ export default { ...@@ -77,7 +86,7 @@ export default {
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.getOrder().then(response => { this.getOrder().then(response => {
// 支付成功 // 支付成功
if (response.status === 1) { if (response.order_status === '4') {
this.$emit('success') this.$emit('success')
this.clearTimer() this.clearTimer()
} }
...@@ -89,13 +98,8 @@ export default { ...@@ -89,13 +98,8 @@ export default {
} }
}, },
mounted() { mounted() {
if (this.payment === '2') { if (this.payment === '3') return
// 微信支付 this.createOrder().then(this.setTimer)
this.createWxPayOrder(this.productId, this.num).then(this.setTimer)
} else if (this.payment === '1') {
// 支付宝支付
this.createAliPayOrder(this.productId, this.num).then(this.setTimer)
}
}, },
destroyed() { destroyed() {
this.clearTimer() this.clearTimer()
......
...@@ -18,8 +18,8 @@ export default { ...@@ -18,8 +18,8 @@ export default {
{ value: '冬季学期(1月11日---4月10日)' } { value: '冬季学期(1月11日---4月10日)' }
], ],
payList: [ payList: [
{ label: '微信支付', value: '2' }, { label: '微信支付', value: '1' },
{ label: '支付宝支付', value: '1' }, { label: '支付宝支付', value: '11' },
{ label: '银行转账', value: '3' } { label: '银行转账', value: '3' }
], ],
submitLoading: false submitLoading: false
......
...@@ -34,8 +34,7 @@ ...@@ -34,8 +34,7 @@
</el-form-item> </el-form-item>
<el-form-item label="需打印份数" prop="number"> <el-form-item label="需打印份数" prop="number">
<el-select v-model="ruleForm.number" :disabled="isPaid"> <el-select v-model="ruleForm.number" :disabled="isPaid">
<el-option v-for="item in productList" :key="item.value" :label="item.label" :value="item.value"> <el-option v-for="item in productList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
</el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="支付方式" prop="payment"> <el-form-item label="支付方式" prop="payment">
...@@ -64,9 +63,7 @@ ...@@ -64,9 +63,7 @@
</el-form-item> </el-form-item>
</template> </template>
<el-form-item v-if="!this.isView"> <el-form-item v-if="!this.isView">
<el-button type="primary" :loading="submitLoading" @click="handleSubmit(handleSubmitSuccess)" v-if="!isPaid" <el-button type="primary" :loading="submitLoading" @click="handleSubmit(handleSubmitSuccess)" v-if="!isPaid">去支付</el-button>
>去支付</el-button
>
<el-button type="primary" :loading="submitLoading" @click="handleSubmit" v-else>保存并提交</el-button> <el-button type="primary" :loading="submitLoading" @click="handleSubmit" v-else>保存并提交</el-button>
<el-button type="info" @click="onRemove" v-if="hasAbort">撤回申请</el-button> <el-button type="info" @click="onRemove" v-if="hasAbort">撤回申请</el-button>
</el-form-item> </el-form-item>
...@@ -75,7 +72,7 @@ ...@@ -75,7 +72,7 @@
</div> </div>
<el-dialog title="支付" width="400px" :visible.sync="payVisible"> <el-dialog title="支付" width="400px" :visible.sync="payVisible">
<pay :payment="ruleForm.payment" :productId="productId" @success="handlePaySuccess" v-if="payVisible"></pay> <pay :payment="ruleForm.payment" :product="product" @success="handlePaySuccess" v-if="payVisible"></pay>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
...@@ -99,7 +96,7 @@ export default { ...@@ -99,7 +96,7 @@ export default {
receive_name: '', receive_name: '',
telephone: '', telephone: '',
email: '', email: '',
payment: '2' payment: '1'
}, },
rules: { rules: {
personal_name: [{ required: true, message: '请输入您的姓名', trigger: 'blur' }], personal_name: [{ required: true, message: '请输入您的姓名', trigger: 'blur' }],
...@@ -111,9 +108,9 @@ export default { ...@@ -111,9 +108,9 @@ export default {
email: [{ required: true, message: '请输入邮寄地址', trigger: 'blur' }] email: [{ required: true, message: '请输入邮寄地址', trigger: 'blur' }]
}, },
productList: [ productList: [
{ label: '1份—¥127元', value: '1', product_id: '6747325185390542848' }, { label: '1份—¥127元', value: '1', shop_id: '6816247184455892992', spu_id: '6869466274636759040', sku_id: '6869466274674507776' },
{ label: '2份—¥203元', value: '2', product_id: '6747325279879823360' }, { label: '2份—¥203元', value: '2', shop_id: '6816247184455892992', spu_id: '6869466274636759040', sku_id: '6869466274737422336' },
{ label: '3份—¥278元', value: '3', product_id: '6747325351686307840' } { label: '3份—¥278元', value: '3', shop_id: '6816247184455892992', spu_id: '6869466274636759040', sku_id: '6869466274800336896' }
], ],
payVisible: false payVisible: false
} }
...@@ -129,9 +126,8 @@ export default { ...@@ -129,9 +126,8 @@ export default {
} }
}, },
computed: { computed: {
productId() { product() {
const found = this.productList.find(item => item.value === this.ruleForm.number) return this.productList.find(item => item.value === this.ruleForm.number)
return found ? found.product_id : ''
} }
}, },
methods: { methods: {
......
...@@ -3,15 +3,7 @@ ...@@ -3,15 +3,7 @@
<div class="con-title">重修申请</div> <div class="con-title">重修申请</div>
<div class="con-box"> <div class="con-box">
<el-button type="text" @click="goBack">返回列表</el-button> <el-button type="text" @click="goBack">返回列表</el-button>
<el-form <el-form ref="ruleForm" :model="ruleForm" :rules="rules" :disabled="isView" label-width="100px" class="main-form" v-loading="loading">
ref="ruleForm"
:model="ruleForm"
:rules="rules"
:disabled="isView"
label-width="100px"
class="main-form"
v-loading="loading"
>
<el-form-item label="姓名" prop="personal_name"> <el-form-item label="姓名" prop="personal_name">
<el-input v-model="ruleForm.personal_name" :disabled="disabledInfo" readonly /> <el-input v-model="ruleForm.personal_name" :disabled="disabledInfo" readonly />
</el-form-item> </el-form-item>
...@@ -22,22 +14,14 @@ ...@@ -22,22 +14,14 @@
<el-input v-model="ruleForm.sofia_id" :disabled="disabledInfo" readonly /> <el-input v-model="ruleForm.sofia_id" :disabled="disabledInfo" readonly />
</el-form-item> </el-form-item>
<el-form-item label="重修时间" prop="semester_name"> <el-form-item label="重修时间" prop="semester_name">
<el-radio-group <el-radio-group v-model="ruleForm.semester_name" :disabled="disabledInfo" style="line-height: 30px; margin-top: 10px">
v-model="ruleForm.semester_name"
:disabled="disabledInfo"
style="line-height: 30px; margin-top: 10px"
>
<div v-for="item in semesterList" :key="item.value"> <div v-for="item in semesterList" :key="item.value">
<el-radio :label="item.value"></el-radio> <el-radio :label="item.value"></el-radio>
</div> </div>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="重修课程" prop="course_id"> <el-form-item label="重修课程" prop="course_id">
<el-checkbox-group <el-checkbox-group v-model="ruleForm.course_id" :disabled="disabledInfo" style="line-height: 24px; margin-top: 10px">
v-model="ruleForm.course_id"
:disabled="disabledInfo"
style="line-height: 24px; margin-top: 10px"
>
<div v-for="item in currentCourseList" :key="item.id"> <div v-for="item in currentCourseList" :key="item.id">
<el-checkbox :label="item.id">{{ item.course_name }}</el-checkbox> <el-checkbox :label="item.id">{{ item.course_name }}</el-checkbox>
</div> </div>
...@@ -81,13 +65,7 @@ ...@@ -81,13 +65,7 @@
</div> </div>
<el-dialog title="支付" width="400px" :visible.sync="payVisible"> <el-dialog title="支付" width="400px" :visible.sync="payVisible">
<pay <pay :payment="ruleForm.payment" :product="product" :num="detail.form.credit" @success="handlePaySuccess" v-if="payVisible"></pay>
:payment="ruleForm.payment"
:productId="productId"
:num="detail.form.credit"
@success="handlePaySuccess"
v-if="payVisible"
></pay>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
...@@ -118,7 +96,7 @@ export default { ...@@ -118,7 +96,7 @@ export default {
}, },
courseList: [], // 课程列表 courseList: [], // 课程列表
submitedCourseList: [], // 提交的课程列表 submitedCourseList: [], // 提交的课程列表
productId: '6745273257873637376', // 商品ID product: { shop_id: '6816247184455892992', spu_id: '6869463821962969088', sku_id: '6869463822004912128' }, // 商品
payVisible: false payVisible: false
} }
}, },
...@@ -184,14 +162,7 @@ export default { ...@@ -184,14 +162,7 @@ export default {
}) })
} }
// 设置表单数据 // 设置表单数据
const ruleForm = this.$_.pick(response.form, [ const ruleForm = this.$_.pick(response.form, ['personal_name', 'class_name', 'sofia_id', 'semester_name', 'course_id', 'payment'])
'personal_name',
'class_name',
'sofia_id',
'semester_name',
'course_id',
'payment'
])
Object.assign(this.ruleForm, ruleForm) Object.assign(this.ruleForm, ruleForm)
// 设置接口返回的数据 // 设置接口返回的数据
this.detail = response this.detail = response
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论