smart-admin/rc-busness/pages/personal/userpay.vue
Vion 31fe06b2c2 Merge branch 'sit-Carl' into sit-Leung
# Conflicts:
#	rc-busness/pages/personal/userpay.vue
2022-01-27 09:52:47 +08:00

391 lines
9.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="page_modules">
<Myheader></Myheader>
<div class="rc-top rc-md-up"></div>
<div class="cont_modules">
<el-row class="order_info">
<el-col :span="6" class="ph_hidden">
<ul class="li_inline">
<li class="sucess_img">
<img src="../../assets/image/usersucess.png" alt="" />
</li>
<li class="ready">
<p>订单提交成功</p>
<p>等待付款</p>
</li>
</ul>
</el-col>
<el-col :span="12" class="ph_hidden">&nbsp;</el-col>
<el-col :span="6" class="ready_right">
<div class="inline_right">
<p>付款金额:</p>
<p class="price" v-if="userPayData.userprice">¥{{ userPayData.userprice }}</p>
</div>
<div class="inline_right">
<p>收货信息:</p>
<p>{{ userPayData.userinformation }}</p>
</div>
</el-col>
</el-row>
</div>
<div class="rc_contline"></div>
<div class="cont_modules">
<div class="pay_title color_red">请选择支付方式</div>
</div>
<div class="rc_contline"></div>
<div class="cont_modules">
<div class="pay_list">
<ul>
<li
class="pay_item"
v-for="(item, index) in userpaystype"
:key="index"
@click="selectGoods(item, index)"
:class="activeIndex == index ? 'active' : ''"
v-if="(!disableAlipay || (disableAlipay && item.type!='alipay'))"
>
<div style="display:flex;">
<img :src="item.payimage" alt="" />
<span>{{ item.paytype }}支付</span>
</div>
</li>
</ul>
</div>
</div>
<div class="payconfirm rc-padding-y--md" v-if="disableQrcode">
<span class="ts-standard-btn ts-standard-btn--two center" @click="goPayH5">
确认支付
</span>
</div>
<div class="paycord" v-if="!disableQrcode">
<div class="qrcode"><vue-qr :text="qrtext" :size="260"></vue-qr></div>
<span>{{ paytype }}扫一扫立即支付</span>
</div>
<el-dialog :visible.sync="dialogSuccess" @close="closeDialogSuccess">
<div class="tc dl_cont">
<div class="dl_img">
<img src="../../assets/image/usersucess.png" alt="" />
</div>
<h3 class="title">支付成功</h3>
<p>您的商品我们正在抓紧打包请耐心等候</p>
<div class="line_dashed"></div>
<div class="userer">
<div class="qrcode">
<img src="/images/qrcode-wxgroup.jpg">
</div>
<p>微信扫一扫识别二维码</p>
<p class="tips">加入社群0元试用商品随单发放</p>
</div>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogFail" @close="closeDialogFail">
<div class="tc dl_cont">
<div class="dl_img">
<img src="../../assets/pay/fail.png" alt="" />
</div>
<h3 class="title">支付失败</h3>
<p>请返回商品结算页面重新支付</p>
</div>
</el-dialog>
</div>
</template>
<script>
import Myheader from "~/components/header.vue";
import tabs from "@/components/tabs.vue";
import vueQr from 'vue-qr'
import { generateOrderAlipay, updateOrderWX, monitorOrderNotify,repayOrde } from "../../ajax/getData";
export default {
data() {
return {
activeIndex: 0,
paymentTimer:undefined,
isSucess: false,
dialogSuccess: false,
paytype: "微信",
userpaystype: [
{
paytype: "微信",
payimage: require("../../assets/pay/wx.png"),
type:'wechat'
},
{
paytype: "支付宝",
payimage: require("../../assets/pay/zfb.png"),
type:'alipay'
},
],
dialogFail: false,
userPayData: {},
qrtext:'',
userData:'',
disableAlipay:true,
disableQrcode:false,
};
},
created(){
},
mounted() {
let stype=this.$route.query.stype;
this.userPayData = JSON.parse(this.$route.query.userPayData);
this.defaultHandlePayment();
},
methods: {
defaultHandlePayment() {
let isMobile = this.isMobile();
if(this.userPayData.wxPay && !isMobile) {
this.qrtext=this.userPayData.wxPay;
this.payOrderWX();
this.disableQrcode=false;
} else if (this.userPayData.wxPay && isMobile) {
this.disableQrcode=true;
} else if(!this.userPayData.wxPay || this.userPayData.wxPay.length<=4) {
throw new Error("订单信息错误,请删除商品后再次购买");
}
},
goPayH5() {
let isMobile = this.isMobile();
if(this.userPayData.wxPay && isMobile) {
window.location.href=this.userPayData.wxPay;
this.disableQrcode=true;
} else {
throw new Error("订单信息错误,请删除商品后再次购买");
}
},
isMobile () {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {
return false;
} else {
return true;
}
},
closeDialogSuccess() {
this.qrtext = '';
this.$router.push({
path: "/myorder/usertion",
query:{
stype:1,
orderNumber:this.userPayData.orderId
}
});
},
closeDialogFail() {
this.qrtext = '';
// this.$router.push({
// path: "/personal/useraddress",
// });
},
async selectGoods(item, index) {
this.activeIndex = index;
this.paytype = item.paytype;
if (index == 1) {
//支付宝
let res = await generateOrderAlipay(this.userPayData.orderId);
async selectGoods(item, index) {
this.activeIndex = index;
this.paytype = item.paytype;
if (index == 1) {
//支付宝
let res = await generateOrderAlipay(this.userPayData.orderId);
this.qrtext = '';
if (res.success) {
this.qrtext=res.data;
}
} else {
this.userPayData = JSON.parse(this.$route.query.userPayData);
this.qrtext=this.userPayData.wxPay
}
},
//支付监听
async payOrderWX() {
let res = await monitorOrderNotify(this.userPayData.orderId);
if (res.success) {
this.qrtext = '成功加入群的二维码';
this.dialogSuccess = true;
} else if (res.fail) {
this.dialogFail = true;
} else {
let _self = this;
this.paymentTimer = setTimeout(function(){
_self.payOrderWX()
},5000);
}
}
},
components: {
Myheader,
tabs,
vueQr,
},
};
</script>
<style lang="less" scoped >
.sucess_img {
width: 96px;
height: 96px;
margin-right: 10px;
}
.order_info {
padding: 10px 0;
}
.info {
display: flex;
justify-content: space-between;
}
.ready {
font-size: 20px;
color: #e2001a;
}
.ready_right {
line-height: 200%;
padding-top: 8px;
}
.price {
font-size: 20px;
color: #e2001a;
}
.pay_title {
font-size: 26px;
padding: 26px 0;
border-bottom: 1px solid #d7d7d7;
}
.pay_list {
padding: 20px 0;
.pay_item {
float: left;
margin-right: 20px;
display: flex;
justify-content: center;
border: 1px solid #333333;
padding: 5px 20px;
cursor: pointer;
&.active {
border: 1px solid #e2001a;
color: #e2001a;
}
img {
margin-right: 5px;
width: 24px;
height: 24px;
}
}
&::after {
content: "";
display: block;
clear: both;
}
}
.paycord {
padding: 10px;
text-align: center;
.qrcode {
margin: 0 auto 10px;
width: 260px;
height: 260px;
}
}
.dl_width {
width: 440px;
}
.dl_cont {
color: #333;
margin-top: -10px;
.title {
font-size: 26px;
font-weight: bold;
padding-bottom: 10px;
}
.line_dashed {
border-bottom: 2px dashed #999999;
margin: 10px 0;
}
.dl_img {
img {
width: 90px;
height: 90px;
margin: 0 auto;
}
padding: 0px 0 20px;
}
.userer {
img {
margin: 0 auto;
}
}
.tips {
color: #e2001a;
margin-top: 30px;
font-size: 18px;
}
}
@media screen and (max-width: 768px) {
.payconfirm{
position:fixed;
bottom:0;
left:0;
width:100%;
}
.ph_hidden {
display: none;
}
.ready_right {
width: 100%;
padding: 10px;
}
.pay_title {
padding: 10px;
}
.pay_list {
padding: 0;
.pay_item {
float: none;
border: none;
border-bottom: 1px solid #d7d7d7;
height: 50px;
margin-right: 0;
align-items: center;
justify-content: left;
justify-content: left;
&.active {
border: none;
border-bottom: 4px solid #e2001a;
}
}
}
.paycord {
//display: none;
}
}
</style>