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

feat: 办事大厅支付迁移

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