|
@@ -1,522 +0,0 @@
|
|
-<!-- 支付方式页 -->
|
|
|
|
-<template>
|
|
|
|
- <div>
|
|
|
|
- <slot name="desc" v-if="step == 1 || step == 2"></slot>
|
|
|
|
- <!-- 支付第一步 选择支付方式 start -->
|
|
|
|
- <template v-if="step == 1">
|
|
|
|
- <div class="font-weight margin-t20 margin-b20">支付方式</div>
|
|
|
|
- <div class="pay_list">
|
|
|
|
- <div :class="{'select_Type': active.index==index}"
|
|
|
|
- class="pay-type-item"
|
|
|
|
- v-for="(item,index) in paymentVOList"
|
|
|
|
- :key="index"
|
|
|
|
- @click="changeActive(index,item.code)">
|
|
|
|
- <img :src="item.payImgPc">
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- <!-- 企业网银 支持的银行列表 start-->
|
|
|
|
- <div
|
|
|
|
- class="pay-bank-list"
|
|
|
|
- v-if="isShowBankList" >
|
|
|
|
- <div
|
|
|
|
- v-for="(item,index) in bankList"
|
|
|
|
- :key="index"
|
|
|
|
- class="bank-item"
|
|
|
|
- @click="handleBankPay(item)" >
|
|
|
|
- <img
|
|
|
|
- :src="item.logo"
|
|
|
|
- class="bank-img" >
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- <!-- 企业网银 支持的银行列表 end-->
|
|
|
|
- <div class="margin-t20 margin-b20 text-right" v-if="[9,17].indexOf(active.payId) != -1">
|
|
|
|
- <el-button type="primary" size="small" :disabled="disabledPayBtn" @click="changeStep(2)">立即支付</el-button>
|
|
|
|
- </div>
|
|
|
|
- </template>
|
|
|
|
- <!-- 支付第一步 选择支付方式 end -->
|
|
|
|
-
|
|
|
|
- <!-- 支付第二步 微信或支付宝的支付码 start -->
|
|
|
|
- <template v-if="step == 2 ">
|
|
|
|
- <template v-if="[9,17].indexOf(active.payId) != -1">
|
|
|
|
- <div class="QR-code-box">
|
|
|
|
- <div class="margin-b20" :class="countDown === 0 ? 'text-lose-efficacy' : 'text-count-down'">
|
|
|
|
- {{countDown === 0 ? '二维码已失效,点击刷新' : countDown + 'S后二维码失效,请尽快支付'}}
|
|
|
|
- </div>
|
|
|
|
- <div class="qrcode"
|
|
|
|
- v-show="paymentData.qrCodeUrl">
|
|
|
|
- <img :src="paymentData.qrImageUrl"
|
|
|
|
- alt="qrcode">
|
|
|
|
- <div v-if="countDown === 0"
|
|
|
|
- class="qr-lose-efficacy"
|
|
|
|
- @click="againPay">
|
|
|
|
- <img class="qr-lose-efficacy-img"
|
|
|
|
- src="~@/assets/images/icon/refresh.png"
|
|
|
|
- alt="shuaxin">
|
|
|
|
- <p>点击刷新</p>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- <div class="pay-text">
|
|
|
|
- <span>请使用手机打开{{active.payName}}扫描二维码完成支付</span>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </template>
|
|
|
|
- <el-button type="text" @click="changeStep(1)">
|
|
|
|
- <el-icon><ArrowLeftBold /></el-icon>
|
|
|
|
- <span>选择其他支付方式</span>
|
|
|
|
- </el-button>
|
|
|
|
- </template>
|
|
|
|
- <!-- 支付第二步 微信或支付宝的支付码 start -->
|
|
|
|
-
|
|
|
|
- <!-- 支付第三步 查看支付结果 start -->
|
|
|
|
- <template v-if="step == 3">
|
|
|
|
- <div class="flex-center pay-status">
|
|
|
|
- <!-- 支付结果支持 传入props(payResConfig),来对默认支付结果页做简单的修改;
|
|
|
|
- 也支持 插槽 <template v-slot:response> <div>自定义支付结果页</div> </template> -->
|
|
|
|
- <slot name="response">
|
|
|
|
- <img src="~@/assets/ok.png" />
|
|
|
|
- <div class="margin-l20">
|
|
|
|
- <div class="font-weight font-s20 margin-b20" >付款成功</div>
|
|
|
|
- <div class="font-weight font-s18 margin-b20" v-if="payResConfig.subTitle">{{payResConfig.subTitle}}</div>
|
|
|
|
- <div class="margin-b10">付款订单编号:{{paidRes.orderSns}}</div>
|
|
|
|
- <div class="margin-b10">{{paidRes.payName}}:{{paidRes.orderAmount}}元</div>
|
|
|
|
- <div class="margin-b20">
|
|
|
|
- <el-button type="text" v-if="isShowPaidDetailBtn" @click="toDetail">查看付款订单详情</el-button>
|
|
|
|
- <el-button type="text" @click="backList">返回列表</el-button>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </slot>
|
|
|
|
- </div>
|
|
|
|
- </template>
|
|
|
|
- <!-- 支付第三步 查看支付结果 start -->
|
|
|
|
- </div>
|
|
|
|
-</template>
|
|
|
|
-
|
|
|
|
-<script>
|
|
|
|
-import { ElMessageBox, ElMessage } from 'element-plus'
|
|
|
|
-import alert from "./payAlert"
|
|
|
|
-import { h, resolveComponent } from "vue"
|
|
|
|
-export default {
|
|
|
|
- name: 'payType',
|
|
|
|
- data () {
|
|
|
|
- return {
|
|
|
|
- bankAndOrderData:{
|
|
|
|
- paymentVOList:[
|
|
|
|
- // { payImgPc:'https://baiyingxianniu.oss-cn-beijing.aliyuncs.com/images/common/payment_list/wxpay_pc.png'},
|
|
|
|
- // { payImgPc:'https://baiyingxianniu.oss-cn-beijing.aliyuncs.com/images/common/payment_list/alipay_pc.png'},
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- active:{
|
|
|
|
- index:'-1',
|
|
|
|
- payId:'',
|
|
|
|
- payName:''
|
|
|
|
- },
|
|
|
|
- bankList:[],
|
|
|
|
- step:1,
|
|
|
|
- countDown: 60,
|
|
|
|
- paymentData:{
|
|
|
|
- // qrCodeUrl:'https://payment.china-clearing.com/Cashier/Im?q=MDEyOWhGWHk0T0NzSERYMSZjb2RlPTE2Ljg0Mg==',
|
|
|
|
- // qrImageUrl:'https://payment.china-clearing.com/Cashier/Im?q=MDEyOWhGWHk0T0NzSERYMSZjb2RlPTE2Ljg0Mg=='
|
|
|
|
- },
|
|
|
|
- timer:null,
|
|
|
|
- checkStatusTimer:null,
|
|
|
|
- paidRes:{}
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- props:{
|
|
|
|
- payOrderIdList:{
|
|
|
|
- type: Array,
|
|
|
|
- default:() => []
|
|
|
|
- },
|
|
|
|
- payResConfig:{
|
|
|
|
- type: Object,
|
|
|
|
- default:() => {
|
|
|
|
- return {
|
|
|
|
- title:'付款成功!',
|
|
|
|
- subTitle:'', // 温馨提示:占用信用额度将返回可用额度,您可以继续申请采购!
|
|
|
|
- showPaidDetailBtn:false // 如果是非批量支付,支付完成显示 【查看付款订单详情】 按钮,点击后的逻辑emit处理
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // shipAmount: {
|
|
|
|
- // type: String,
|
|
|
|
- // default: '0'
|
|
|
|
- // },
|
|
|
|
- },
|
|
|
|
- components: {},
|
|
|
|
- computed: {
|
|
|
|
- isShowPaidDetailBtn(){
|
|
|
|
- // 多单支付 不显示 查看付款订单详情 按钮
|
|
|
|
- return this.payOrderIdList.length == 1 && this.payResConfig.showPaidDetailBtn
|
|
|
|
- },
|
|
|
|
- disabledPayBtn(){
|
|
|
|
- const {payId} = this.active
|
|
|
|
- // 支付类型:;9-微信;17-支付宝 19 企业网银
|
|
|
|
- return !(payId == '9' || payId == '17' || payId == '')
|
|
|
|
- },
|
|
|
|
- paymentVOList(){
|
|
|
|
- return this.bankAndOrderData.paymentVOList
|
|
|
|
- },
|
|
|
|
- isShowBankList(){
|
|
|
|
- return this.active.payId == 19
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- methods: {
|
|
|
|
- // 获取支付方式
|
|
|
|
- async payOrderCashier () {
|
|
|
|
- let params = {
|
|
|
|
- payOrderIdList: this.payOrderIdList
|
|
|
|
- }
|
|
|
|
- const res = await this.$api.distributionMode.payOrderCashier(params)
|
|
|
|
- if (res.code != 200) return this.$message.error(res.message || '系统开小差了~')
|
|
|
|
- this.bankAndOrderData = res.data
|
|
|
|
- this.$emit('payOrderCashier',res.data)
|
|
|
|
- },
|
|
|
|
- // 支付方式点击
|
|
|
|
- async changeActive(index){
|
|
|
|
- this.active = {
|
|
|
|
- index,
|
|
|
|
- ...this.paymentVOList[index]
|
|
|
|
- }
|
|
|
|
- if(this.paymentVOList[index].payId == 19){
|
|
|
|
- this.bankList = this.paymentVOList[index].bankVoList
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- changeStep(step){
|
|
|
|
- if(step == 2 && this.active.index == -1) return this.$message.error("请选择支付方式")
|
|
|
|
- if(step == 1){
|
|
|
|
- // 初始化状态
|
|
|
|
- this.initSetInterval()
|
|
|
|
- }else if(step == 2){
|
|
|
|
- this.getPaymentData()
|
|
|
|
- }else if( step == 3){
|
|
|
|
- // 啥也不干 通过改变this.step = 3 展示支付结果
|
|
|
|
- }
|
|
|
|
- this.step = step
|
|
|
|
- },
|
|
|
|
- // 刷新支付码
|
|
|
|
- againPay(){
|
|
|
|
- this.getPaymentData()
|
|
|
|
- },
|
|
|
|
- // 预单 (预先去中金那里生成一个待支付的订单) 返回支付码或者网银的支付链接
|
|
|
|
- async getPaymentData(bankId){
|
|
|
|
- let params = {
|
|
|
|
- payOrderIdList: this.payOrderIdList,
|
|
|
|
- payId: this.active.payId // 支付类型:;9-微信;17-支付宝 19 企业网银
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (bankId && this.active.payId == 19){
|
|
|
|
- params.bankId = bankId
|
|
|
|
- }
|
|
|
|
- const res = await this.$api.distributionMode.getPayQrCode(params)
|
|
|
|
- if(res.code != 200) return this.$message.error(res.message || '系统开小差了~')
|
|
|
|
- if([9,17].indexOf(this.active.payId) != -1){
|
|
|
|
- // 微信 支付宝支付
|
|
|
|
- this.countDown = res.data.expireTime // 二维码有效期 单位是s 没返回则是默认的60s
|
|
|
|
- this.paymentData = res.data.paymentInfoVO
|
|
|
|
- this.setIntervalFun() // 页面上的支付倒计时
|
|
|
|
- this.checkPaidStatus()// 支付状态轮询
|
|
|
|
- }else if(this.active.payId == 19){
|
|
|
|
- // 企业网银支付
|
|
|
|
- window.open(res.data.paymentInfoVO.ebankPayUrl)
|
|
|
|
- this.toBankPay()
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 清除倒计时 包括支付Interval(timer) 和 轮询支付状态Interval(checkStatusTimer)
|
|
|
|
- initSetInterval(){
|
|
|
|
- clearInterval(this.timer)
|
|
|
|
- clearInterval(this.checkStatusTimer)
|
|
|
|
- this.countDown = 60
|
|
|
|
- this.timer = null
|
|
|
|
- this.checkStatusTimer = null
|
|
|
|
- this.active = {
|
|
|
|
- index:'-1',
|
|
|
|
- payId:''
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 支付码有效期倒计时
|
|
|
|
- async setIntervalFun () {
|
|
|
|
- clearInterval(this.timer)
|
|
|
|
- if (this.paymentData.qrCodeUrl) {
|
|
|
|
- this.timer = setInterval(async () => {
|
|
|
|
- if (this.countDown === 0) {
|
|
|
|
- clearInterval(this.timer)
|
|
|
|
- this.timer = null
|
|
|
|
- } else {
|
|
|
|
- this.countDown--
|
|
|
|
- }
|
|
|
|
- }, 1000)
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 每5s来检查一下支付状态
|
|
|
|
- checkPaidStatus(){
|
|
|
|
- clearInterval(this.checkStatusTimer)
|
|
|
|
- this.checkStatusTimer = setInterval( () => {
|
|
|
|
- this.getCheckStatus().then((res) => {
|
|
|
|
- console.log(res,'0-0-0-0-0')
|
|
|
|
- if (res) {
|
|
|
|
- clearInterval(this.checkStatusTimer)
|
|
|
|
- this.checkStatusTimer = null
|
|
|
|
- }
|
|
|
|
- }).catch(err=>{
|
|
|
|
- console.log(err,'0-0-0-')
|
|
|
|
- })
|
|
|
|
- }, 5000)
|
|
|
|
- },
|
|
|
|
- // 获取支付状态
|
|
|
|
- getCheckStatus(){
|
|
|
|
- return new Promise( async (resolve, reject) =>{
|
|
|
|
- let params = {
|
|
|
|
- payOrderIdList: this.payOrderIdList
|
|
|
|
- }
|
|
|
|
- const res = await this.$api.distributionMode.getCheckPaid(params)
|
|
|
|
- if(res.code !== 200){
|
|
|
|
- reject(false)
|
|
|
|
- return this.$message.error(res.message || '检查支付状态失败')
|
|
|
|
- }else{
|
|
|
|
- if (res.data.paid) {
|
|
|
|
- this.paidRes = res.data
|
|
|
|
- this.initSetInterval()
|
|
|
|
- this.changeStep(3)
|
|
|
|
- this.$emit('refresh')
|
|
|
|
- resolve(true)
|
|
|
|
- }else{
|
|
|
|
- reject(false)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- // 支付方式选择 企业网银
|
|
|
|
- handleBankPay(item){
|
|
|
|
- this.getPaymentData(item.code)
|
|
|
|
- },
|
|
|
|
- // 选择了某个银行 去支付 处理页面的等待支付结果逻辑
|
|
|
|
- toBankPay(){
|
|
|
|
- ElMessageBox.alert(
|
|
|
|
- h(alert,
|
|
|
|
- {
|
|
|
|
- error () {
|
|
|
|
- ElMessageBox.close()
|
|
|
|
- this.getCheckStatus().then((res) => {
|
|
|
|
- console.log(res,'支付成功')
|
|
|
|
- }).catch(err=>{
|
|
|
|
- console.log(err,'0-0-0-')
|
|
|
|
- //失败 提示
|
|
|
|
- ElMessageBox.confirm(
|
|
|
|
- '检测到您尚未付款,请前去支付',
|
|
|
|
- {
|
|
|
|
- confirmButtonText: '去支付',
|
|
|
|
- center: true,
|
|
|
|
- showCancelButton: false,
|
|
|
|
- showClose: false,
|
|
|
|
- customClass: 'check_box',
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
- ok: () => {
|
|
|
|
- ElMessageBox.close()
|
|
|
|
- this.getCheckStatus().then((res) => {
|
|
|
|
- console.log(res,'支付成功')
|
|
|
|
- }).catch(err=>{
|
|
|
|
- console.log(err,'0-0-0-')
|
|
|
|
- //失败 提示
|
|
|
|
- ElMessageBox.confirm(
|
|
|
|
- '检测到您尚未付款,请前去支付',
|
|
|
|
- {
|
|
|
|
- confirmButtonText: '去支付',
|
|
|
|
- center: true,
|
|
|
|
- showCancelButton: false,
|
|
|
|
- showClose: false,
|
|
|
|
- customClass: 'check_box',
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ),
|
|
|
|
- '',
|
|
|
|
- {
|
|
|
|
- dangerouslyUseHTMLString: true,
|
|
|
|
- showClose: false,
|
|
|
|
- showConfirmButton: false,
|
|
|
|
- customClass: 'alert_class',
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
- },
|
|
|
|
- toDetail(){
|
|
|
|
- this.$emit('toDetail')
|
|
|
|
- this.$emit('backList')
|
|
|
|
- },
|
|
|
|
- backList(){
|
|
|
|
- this.$emit('backList')
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- created () {
|
|
|
|
- this.payOrderCashier()
|
|
|
|
- },
|
|
|
|
- beforeDestroy(){
|
|
|
|
- this.initSetInterval()
|
|
|
|
- this.step=1
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-</script>
|
|
|
|
-<style lang='less' scoped>
|
|
|
|
-.font-weight{
|
|
|
|
- font-weight: bold;
|
|
|
|
-}
|
|
|
|
-.margin-t20{
|
|
|
|
- margin-top:20px;
|
|
|
|
-}
|
|
|
|
-.margin-b20{
|
|
|
|
- margin-bottom: 20px;
|
|
|
|
-}
|
|
|
|
-.margin-b10{
|
|
|
|
- margin-bottom: 10px;
|
|
|
|
-}
|
|
|
|
-.margin-l20{
|
|
|
|
- margin-left: 20px;
|
|
|
|
-}
|
|
|
|
-.red{
|
|
|
|
- color: #ff3d3d;
|
|
|
|
-}
|
|
|
|
-.font-s20{
|
|
|
|
- font-size: 20px;
|
|
|
|
-}
|
|
|
|
-.font-s18{
|
|
|
|
- font-size:18px;
|
|
|
|
-}
|
|
|
|
-.flex-between{
|
|
|
|
- display: flex;
|
|
|
|
- justify-content:space-between;
|
|
|
|
-}
|
|
|
|
-.flex-center{
|
|
|
|
- display: flex;
|
|
|
|
- justify-content:center;
|
|
|
|
- align-items:center;
|
|
|
|
-}
|
|
|
|
-.text-right{
|
|
|
|
- text-align: right;
|
|
|
|
-}
|
|
|
|
-.pay_list {
|
|
|
|
- display: flex;
|
|
|
|
- flex-wrap: wrap;
|
|
|
|
- padding-right: 20px;
|
|
|
|
- padding-bottom: 15px;
|
|
|
|
- .pay-type-item{
|
|
|
|
- border: #e6e6e6 1px solid;
|
|
|
|
- border-radius:5px;
|
|
|
|
- img{
|
|
|
|
- width: 170px;
|
|
|
|
- height: 40px;
|
|
|
|
- cursor: pointer;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- .pay-type-item+.pay-type-item{
|
|
|
|
- margin-left: 20px;
|
|
|
|
- }
|
|
|
|
- .select_Type {
|
|
|
|
- border: #a4b8fb 1px solid !important;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-.pay-bank-list {
|
|
|
|
- border: 1px solid #ebe6e6;
|
|
|
|
- // width: 835px;
|
|
|
|
- display: flex;
|
|
|
|
- flex-wrap: wrap;
|
|
|
|
- padding-right: 20px;
|
|
|
|
- padding-bottom: 15px;
|
|
|
|
- .bank-item {
|
|
|
|
- margin-top: 15px;
|
|
|
|
- margin-left: 20px;
|
|
|
|
- border: #e6e6e6 1px solid;
|
|
|
|
- cursor: pointer;
|
|
|
|
- &:hover{
|
|
|
|
- border: #a4b8fb 1px solid;
|
|
|
|
- }
|
|
|
|
- img {
|
|
|
|
- width: 145px;
|
|
|
|
- height: 42px;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-.QR-code-box{
|
|
|
|
- .text-count-down {
|
|
|
|
- height: 14px;
|
|
|
|
- font-size: 14px;
|
|
|
|
- font-family: PingFangSC-Medium, PingFang SC;
|
|
|
|
- font-weight: 500;
|
|
|
|
- color: #25b6ed;
|
|
|
|
- line-height: 14px;
|
|
|
|
- margin-top: 16px;
|
|
|
|
- text-align: center;
|
|
|
|
- }
|
|
|
|
- .text-lose-efficacy {
|
|
|
|
- height: 14px;
|
|
|
|
- font-size: 14px;
|
|
|
|
- font-family: PingFangSC-Medium, PingFang SC;
|
|
|
|
- font-weight: 500;
|
|
|
|
- color: #888888;
|
|
|
|
- line-height: 14px;
|
|
|
|
- margin-top: 16px;
|
|
|
|
- text-align: center;
|
|
|
|
- }
|
|
|
|
- .pay-text {
|
|
|
|
- text-align: center;
|
|
|
|
- margin-top: 11px;
|
|
|
|
- line-height: 100%;
|
|
|
|
- }
|
|
|
|
- .qrcode{
|
|
|
|
- width: 100%;
|
|
|
|
- height: 143px;
|
|
|
|
- text-align: center;
|
|
|
|
- overflow: hidden;
|
|
|
|
- position: relative;
|
|
|
|
- // margin: 0 auto;
|
|
|
|
- img {
|
|
|
|
- width: 143px;
|
|
|
|
- height: 143px;
|
|
|
|
- transform: scale(1.4);
|
|
|
|
- }
|
|
|
|
- .qr-lose-efficacy {
|
|
|
|
- width: 150px;
|
|
|
|
- height: 143px;
|
|
|
|
- position: absolute;
|
|
|
|
- top: 0;
|
|
|
|
- left: 0;
|
|
|
|
- right: 0;
|
|
|
|
- bottom: 0;
|
|
|
|
- margin: auto;
|
|
|
|
- background: #ffffff;
|
|
|
|
- opacity: 0.94;
|
|
|
|
- cursor: pointer;
|
|
|
|
- text-align: center;
|
|
|
|
- .qr-lose-efficacy-img {
|
|
|
|
- width: 32px;
|
|
|
|
- height: 32px;
|
|
|
|
- margin-top: 46px;
|
|
|
|
- transform: rotate(0deg);
|
|
|
|
- transition: all 1.2s;
|
|
|
|
- }
|
|
|
|
- p {
|
|
|
|
- height: 20px;
|
|
|
|
- font-size: 13px;
|
|
|
|
- font-family: PingFangSC-Medium, PingFang SC;
|
|
|
|
- font-weight: 500;
|
|
|
|
- color: #25b6ed;
|
|
|
|
- line-height: 20px;
|
|
|
|
- margin-top: 10px;
|
|
|
|
- text-align: center;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-.pay-status{
|
|
|
|
- min-height: 300px;
|
|
|
|
-}
|
|
|
|
-.el-button--primary{
|
|
|
|
- color: #fff;
|
|
|
|
-}
|
|
|
|
-</style>
|
|
|