You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

923 lines
26 KiB

<template>
<scroll-view class="payment" :scroll-y="true" :scroll-x="false" :style="{ height: phoneHight }">
<view class="paymentPackage">
<view class="surplusTime" v-if="payInfo.sytime !== 0">
<span>支付剩余时间 {{ time }}</span>
</view>
<view class="price">
<span>
<span>{{ payInfo.price }}</span>
</span>
</view>
<view class="goodsInfo">
<span>{{ payInfo.goodname }}</span>
</view>
<!-- 选择支付方式 -->
<view class="paymentTypePackage">
<view class="paymentTypeList" @click="checkPay(1)" v-if="payInfo.credit == 1 && !payInfo.diy_userInfo">
<view class="imgPackage"><image :src="imgfixUrls + 'merchant/balancePay.svg'" /></view>
<view class="inputPackage">
<view class="inputPackageMain">
<view class="inputPackageLeft">
<view class="inputPackageLeftTitle">{{ textSubData.moneytext }}支付</view>
<view class="inputPackageLeftBody">账户余额:¥{{ payInfo.balance }}</view>
</view>
<view class="inputPackageRightCheck" v-if="type == 1"><image :src="imgfixUrls + 'merchant/payCheck.svg'" /></view>
<view class="inputPackageRight" v-if="type !== 1"></view>
</view>
</view>
</view>
<view class="paymentTypeList" @click="checkPay(4)" v-if="payInfo.diy_userInfo">
<view class="imgPackage"><image :src="imgfixUrls + 'merchant/balancePay.svg'" /></view>
<view class="inputPackage">
<view class="inputPackageMain">
<view class="inputPackageLeft" style="flex: 1;">
<view class="inputPackageLeftTitle">
兑换券抵扣
<text style="padding: 0 10upx;">:</text>
可用兑换券金额
<text style="padding: 0 10upx;color: #EF4740;font-weight: 700;">{{ payInfo.balance }}</text>
<text style="padding: 0 10upx;">
(可抵用
<text style="padding: 0 10upx;color: #EF4740;font-weight: 700;">{{ payInfo.diy_userInfo.dkprice }}</text>
元)
</text>
</view>
<view class="inputPackageLeftBody dis-flex" style="color: #333333;">
<view >{{ payInfo.diy_userInfo.dhtip2 }}</view>
<view class="conversion" @click.stop="goduurUrl(payInfo.diy_userInfo.dhurl)">
去兑换
<text class="iconfont icon-right" style="font-size: 24upx;"></text>
</view>
</view>
</view>
<view class="inputPackageRightCheck" v-if="type == 4"><image :src="imgfixUrls + 'merchant/payCheck.svg'" /></view>
<view class="inputPackageRight" v-if="type !== 4"></view>
</view>
</view>
</view>
<view class="paymentTypeList" @click="checkPay(2)" v-if="payInfo.wechat == 1">
<view class="imgPackage"><image :src="imgfixUrls + 'merchant/wechatPay.svg'" /></view>
<view class="inputPackage">
<view class="inputPackageMain">
<view class="inputPackageLeft">
<view class="inputPackageLeftTitle">微信支付</view>
<view class="inputPackageLeftBody">微信支付,安全快捷</view>
</view>
<view class="inputPackageRightCheck" v-if="type == 2"><image :src="imgfixUrls + 'merchant/payCheck.svg'" /></view>
<view class="inputPackageRight" v-if="type !== 2"></view>
</view>
</view>
</view>
<view class="paymentTypeList" @click="checkPay(5)" v-if="payInfo.yunpay == 1">
<view class="imgPackage"><image :src="payInfo.yunset.logo?payInfo.yunset.logo:imgfixUrls + 'merchant/wechatPay.svg'" /></view>
<view class="inputPackage">
<view class="inputPackageMain">
<view class="inputPackageLeft">
<view class="inputPackageLeftTitle">{{payInfo.yunset.title}}</view>
<view class="inputPackageLeftBody">{{payInfo.yunset.desc}}</view>
</view>
<view class="inputPackageRightCheck" v-if="type == 5"><image :src="imgfixUrls + 'merchant/payCheck.svg'" /></view>
<view class="inputPackageRight" v-if="type !== 5"></view>
</view>
</view>
</view>
<view class="paymentTypeList" @click="checkPay(3)" v-if="payInfo.alipay == 1">
<view class="imgPackage"><image :src="imgfixUrls + 'merchant/payPal.svg'" /></view>
<view class="inputPackage1">
<view class="inputPackageMain">
<view class="inputPackageLeft">
<view class="inputPackageLeftTitle">{{examineing==0?'支付宝账号':'渠道1'}}支付</view>
<view class="inputPackageLeftBody">简单、安全、快速</view>
</view>
<view class="inputPackageRightCheck" v-if="type == 3"><image :src="imgfixUrls + 'merchant/payCheck.svg'" /></view>
<view class="inputPackageRight" v-if="type !== 3"></view>
</view>
</view>
</view>
</view>
<!-- 选择支付方式 -->
<!-- 混合支付提示 -->
<!-- 提交支付 -->
<view class="paySubmitPackage" :style="{ marginTop: payInfo.diy_userInfo ? '0' : '100upx' }">
<view class="t-c" style="padding-top: 70upx;padding-bottom: 200upx;" v-if="payInfo.diy_userInfo">
<view class="t-c f-24" style="color: #E44131;">实付款</view>
<view class="f-w" style="color: #E44131;padding-top: 10upx;">
<text class="f-38" style="padding-right: 10upx;">¥</text>
<text style="font-size: 60upx;" v-if="type == 2 || type == 3">{{ payInfo.price }}</text>
<text style="font-size: 60upx;" v-if="type !== 2 && type !== 3">
{{ Math.round((Math.abs(parseFloat(payInfo.diy_userInfo.dkprice) - parseFloat(payInfo.price)) + Number.EPSILON) * 100) / 100 }}
</text>
</view>
<view class="f-24" style="color: #999999;padding-top: 10upx;" v-if="type == 2 || type == 3">总价:¥{{ payInfo.price }},兑换券抵扣:0.00</view>
<view class="f-24" style="color: #999999;padding-top: 10upx;" v-if="type !== 2 && type !== 3">
总价:¥{{ payInfo.price }},兑换券抵扣:¥{{ payInfo.diy_userInfo.dkprice }}
</view>
</view>
<view class="paySubmit" @click="goPay"><span>确认支付</span></view>
</view>
<!-- 提交支付 -->
</view>
</scroll-view>
</template>
<script>
import App from '@/common/js/app.js';
// #ifdef H5
import wxApi from '@/common/js/wxApi.js';
// #endif
export default {
data() {
return {
time: '',
type: 1,
orderid: '',
payInfo: {},
plugin: '',
types: null,
phoneHight: null,
deliverystring: null,
img: '',
pageName:'',
examineing:1
};
},
onLoad: function(option) {
console.log(option)
let _this = this;
_this.img = this.imgfixUrl;
let TextSubstitution = uni.getStorageSync('TextSubstitution');
this.examineing = TextSubstitution.examineing || 0;
//option为object类型,会序列化上个页面传递的参数
this.orderid = option.orderid;
this.plugin = option.plugin;
this.deliverystring = option.deliverystring;
this.init();
if (!!option.types) {
this.types = option.types;
}
if(!!option.page){
this.pageName = option.page
}
// #ifdef APP-PLUS
uni.getProvider({
service: "payment",
success: (e) => {
console.log("payment success:" + JSON.stringify(e));
let providerList = [];
e.provider.map((value) => {
switch (value) {
case 'alipay':
providerList.push({
name: this.examineing==0?'支付宝':'渠道1',
id: value,
loading: false
});
break;
case 'wxpay':
providerList.push({
name: '微信',
id: value,
loading: false
});
break;
default:
break;
}
})
// this.providerList = providerList;
console.log('providerList',JSON.stringify(providerList));
},
fail: (e) => {
console.log("获取支付通道失败:", e);
}
});
// #endif
uni.getSystemInfo({
success(res) {
_this.phoneHight = res.windowHeight + 'px';
}
});
},
onShow() {
// #ifdef H5
// let url = location.href;
// if(url.indexOf('/#/')){
// }
//#endif
},
methods: {
goduurUrl(url) {
// #ifdef H5
let locations = window.location.href;
let urls = url + '&backurl=' + encodeURIComponent(locations);
console.log(urls);
// location.href();
location.href = urls;
//#endif
//#ifndef H5
let pages = getCurrentPages();
let pageObj = pages[pages.length - 1];
let wxurl = pageObj.route + '?orderid=' + pageObj.options.orderid + '&plugin=' + pageObj.options.plugin;
let urls = url + '&backurl=' + wxurl;
console.log(urls);
uni.navigateTo({
url: `/pages/subPages/webview/webview?urlsrc=${encodeURIComponent(urls)}`
});
//#endif
url = encodeURIComponent(url);
// App.navigationTo({
// url: `pages/subPages/webview/webview?urlsrc=${url}`
// })
},
init() {
let _this = this;
_this.getOrderInfo();
},
checkPay(type) {
let _this = this;
// if (_this.type == 4 && type == 2) {
// _this.type = 5;
// } else if (_this.type == 2 && type == 4) {
// _this.type = 5;
// } else if (_this.type == 5 && type == 4) {
// _this.type = 2;
// } else if (_this.type == 5 && type == 2) {
// _this.type = 4;
// } else if (_this.type == type) {
// uni.showToast({
// title: '请选择至少一个支付方式',
// icon: 'none'
// });
// } else {
// _this.type = type;
// }
if (_this.type == type) {
uni.showToast({
title: '请选择至少一个支付方式',
icon: 'none'
});
} else {
_this.type = type;
}
},
// 获取订单信息
getOrderInfo() {
let _this = this;
let data = {
orderid: _this.orderid == '0' ? '' : !_this.orderid ? 1645 : _this.orderid,
plugin: _this.plugin || 'wlfightgroup',
deliverystring: _this.deliverystring
};
App._post_form('&p=pay&do=getOrderInfo', data, res => {
_this.payInfo = res.data;
if (!!res.data.diy_userInfo) {
_this.type = 5;
} else {
if (res.data.wechat == 0) {
if (res.data.credit == 0) {
_this.type = 3;
} else {
_this.type = 1;
}
} else {
_this.type = 2;
}
}
if(res.data.wechat == 0 && res.data.yunpay != 0 && res.data.credit == 0 && res.data.alipay == 0){
_this.type = 5;
}
if (res.data.sytime !== undefined && res.data.sytime != 0) {
let timeClock = setInterval(function() {
_this.payInfo.sytime--;
_this.time = _this.payInfo.sytime;
var min = Math.floor(_this.time % 3600);
_this.time = Math.floor(_this.time / 3600) + ':' + Math.floor(min / 60) + ':' + (_this.time % 60);
if (_this.payInfo.sytime == 0) {
clearInterval(timeClock);
}
}, 1000);
}
if (res.data.sytime == 0) {
_this.time = '00:00:00';
}
});
},
// 跳转支付
goPay() {
let _this = this,
payInfo = _this.payInfo,
pay_type = _this.type,
pay_title = pay_type === 1 ? _this.textSubData.moneytext : pay_type === 2 ? '微信' : pay_type === 4 ? '余额支付' :pay_type === 5?'银联云收单':_this.examineing==0?'支付宝':'渠道1',
source = App.getClientType(),
payData = {
order_no: payInfo.tid,
name: payInfo.goodname,
pay_type: pay_type === 4 ? 1 : pay_type
};
if (pay_type === 1) {
uni.showModal({
title: '温馨提示',
content: `确认使用${pay_title}方式付款`,
success(res) {
if (res.confirm) {
uni.showLoading({
title: '正在处理...'
});
App._post_form(
'&p=pay&do=requestPay',
payData,
res => {
if (_this.types == 1) {
if(_this.pageName == 'postDetails'){
App.showSuccess('支付成功', () => {
uni.navigateBack({
delta: 1
});
});
}else if(_this.plugin == 'mobilerecharge' && !_this.pageName){
App.showSuccess('支付成功', () => {
App.navigationTo({
url: 'pages/subPages2/voucherCenter/phoneOrders',
navType: 'rediRect'
});
});
}else if(_this.plugin == 'rights'){
App.showSuccess('支付成功', () => {
uni.navigateBack({
delta:1
})
});
}else{
App.navigationTo({
url: 'pages/mainPages/successRelease/successRelease?id=' + res.data.tieziid
});
}
} else {
if (pay_type === 1 || pay_type === 4) {
if (res.data.status === 1) {
App.showSuccess('支付成功', () => {
App.navigationTo({
url: 'pages/subPages/paySuccess/paySuccess?tid=' + payInfo.tid + '&plugin=' + _this.plugin,
navType: 'rediRect'
});
});
} else if (res.data.status === 2) {
payData.pay_type = 2;
payData.blendflag = 1;
App._post_form(
'&p=pay&do=requestPay',
payData,
res => {
_this.wechatPayment(res.data, source);
uni.hideLoading();
},
fail => {
// debugger
console.log(fail.data.data.neworder)
if (fail.data.data.neworder && fail.data.data.neworder != '') {
console.log(_this.payInfo.tid,fail.data.data.neworder)
_this.payInfo.tid = fail.data.data.neworder;
}
uni.hideLoading();
}
);
} else {
if(_this.plugin == 'mobilerecharge'){
App.showError('支付失败', () => {
App.navigationTo({
url: 'pages/subPages2/voucherCenter/voucherCenter',
navType: 'rediRect'
});
});
}else{
App.showError('支付失败', () => {
App.navigationTo({
url: 'pages/subPages/orderList/orderList?type=0',
navType: 'reLaunch'
});
});
}
}
}
}
uni.hideLoading();
},
fail => {
// debugger
console.log(fail)
if (fail.data.data.neworder && fail.data.data.neworder != '') {
console.log(_this.payInfo.tid,fail.data.data.neworder)
_this.payInfo.tid = fail.data.data.neworder;
}
if(fail.data.message == '余额不足'){
App.navigationTo({
url: 'pages/subPages/balance/balance'
});
}
uni.hideLoading();
}
);
}
}
});
} else if (pay_type === 4) {
uni.showLoading({
title: '正在处理...'
});
App._post_form(
'&p=pay&do=requestPay',
payData,
res => {
if (_this.types == 1) {
console.info(111111);
if(_this.pageName == 'postDetails'){
App.showSuccess('支付成功', () => {
uni.navigateBack({
delta: 1
});
});
}else if(_this.plugin == 'mobilerecharge' && !_this.pageName){
App.showSuccess('支付成功', () => {
App.navigationTo({
url: 'pages/subPages2/voucherCenter/phoneOrders',
navType: 'rediRect'
});
});
}else if(_this.plugin == 'rights'){
App.showSuccess('支付成功', () => {
uni.navigateBack({
delta:1
})
});
}else{
App.navigationTo({
url: 'pages/mainPages/successRelease/successRelease?id=' + res.data.tieziid
});
}
} else {
console.info(22222);
if (pay_type === 4) {
if (res.data.status === 1) {
App.showSuccess('支付成功', () => {
App.navigationTo({
url: 'pages/subPages/paySuccess/paySuccess?tid=' + payInfo.tid + '&plugin=' + _this.plugin,
navType: 'rediRect'
});
});
} else if (res.data.status === 2) {
_this.type = 5;
payData.pay_type = 2;
payData.blendflag = 1;
App._post_form(
'&p=pay&do=requestPay',
payData,
res => {
_this.wechatPayment(res.data, source);
uni.hideLoading();
},
fail => {
// debugger
console.log(fail.data.data.neworder)
if (fail.data.data.neworder && fail.data.data.neworder != '') {
console.log(_this.payInfo.tid,fail.data.data.neworder)
_this.payInfo.tid = fail.data.data.neworder;
}
uni.hideLoading();
}
);
} else {
if(_this.plugin == 'mobilerecharge'){
App.showError('支付失败', () => {
App.navigationTo({
url: 'pages/subPages2/voucherCenter/voucherCenter',
navType: 'rediRect'
});
});
}else{
App.showError('支付失败', () => {
App.navigationTo({
url: 'pages/subPages/orderList/orderList?type=0',
navType: 'reLaunch'
});
});
}
}
}
}
},
fail => {
console.log(fail.data.data.neworder)
if (fail.data.data.neworder && fail.data.data.neworder != '') {
console.log(_this.payInfo.tid,fail.data.data.neworder)
_this.payInfo.tid = fail.data.data.neworder;
}
uni.hideLoading();
}
);
} else {
uni.showLoading({
title: '正在处理...'
});
console.log('进来了',JSON.stringify(payData))
App._post_form(
'&p=pay&do=requestPay',
payData,
res => {
if (pay_type === 2 || pay_type === 5) {
console.log('进来了')
_this.wechatPayment(res.data, source);
}
if (pay_type === 3) {
_this.aliPayment(res.data);
}
uni.hideLoading();
},
fail => {
// debugger
console.log(fail)
if (fail.data.data.neworder && fail.data.data.neworder != '') {
_this.payInfo.tid = fail.data.data.neworder;
}
uni.hideLoading();
}
);
}
},
/**
* 渠道1H5支付
*/
aliPayment(result) {
console.log(result);
let base64 = new this.$util.Base64(),
param = base64.encode(result);
App.navigationTo({
url: 'pages/mainPages/payment/pay?goto=' + param
});
},
/**
* 微信H5支付
* @param {Object} result 支付信息
* @param {String} clientType 支付平台
*/
wechatPayment(result, clientType) {
console.log(result, clientType);
let _this = this,
payment = result;
if (clientType === '2') {
location.href = payment;
} else if (clientType === '1') {
// #ifdef H5
WeixinJSBridge.invoke(
'getBrandWCPayRequest',
{
appId: payment.appId, //公众号名称,由商户传入
timeStamp: payment.timeStamp, //时间戳,自1970年以来的秒数
nonceStr: payment.nonceStr, //随机串
package: payment.package,
signType: payment.signType, //微信签名方式:
paySign: payment.paySign //微信签名
},
res => {
if (res.err_msg == 'get_brand_wcpay_request:ok') {
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
//支付成功
if (_this.types == 1) {
if(_this.pageName == 'postDetails'){
App.showSuccess('支付成功', () => {
uni.navigateBack({
delta: 1
});
});
}else if(_this.plugin == 'mobilerecharge' && !_this.pageName){
App.showSuccess('支付成功', () => {
App.navigationTo({
url: 'pages/subPages2/voucherCenter/phoneOrders',
navType: 'rediRect'
});
});
}else{
App.navigationTo({
url: 'pages/subPages/paySuccess/paySuccess?tid=' + _this.payInfo.tid,
navType: 'rediRect'
});
}
}else{
App.navigationTo({
url: 'pages/subPages/paySuccess/paySuccess?tid=' + _this.payInfo.tid,
navType: 'rediRect'
});
}
} else {
//支付失败
if(_this.plugin == 'mobilerecharge'){
App.showError('支付失败', () => {
App.navigationTo({
url: 'pages/subPages2/voucherCenter/voucherCenter',
navType: 'rediRect'
});
});
}else{
App.showError('支付失败', () => {
App.navigationTo({
url: 'pages/subPages/orderList/orderList?type=0',
navType: 'reLaunch'
});
});
}
}
}
);
// #endif
} else if (clientType === '3') {
// #ifndef H5
console.log('payment',JSON.stringify(payment));
let payRequestData = {
timeStamp: payment.timeStamp,
nonceStr: payment.nonceStr,
package: payment.package,
signType: 'MD5',
paySign: payment.paySign
};
uni.requestPayment({
provider: 'wxpay',
...payRequestData,
success(res) {
uni.hideLoading();
console.log('支付成功', res);
//支付成功
if (_this.types == 1) {
if(_this.pageName == 'postDetails'){
App.showSuccess('支付成功', () => {
uni.navigateBack({
delta: 1
});
});
}else if(_this.plugin == 'mobilerecharge' && !_this.pageName){
App.showSuccess('支付成功', () => {
App.navigationTo({
url: 'pages/subPages2/voucherCenter/phoneOrders',
navType: 'rediRect'
});
});
}else{
App.navigationTo({
url: 'pages/subPages/paySuccess/paySuccess?tid=' + _this.payInfo.tid,
navType: 'rediRect'
});
}
}else{
if(_this.plugin == 'rights'){
// 权益订单
App.showSuccess('支付成功', () => {
uni.navigateBack({
delta: 1
})
});
}
App.navigationTo({
url: 'pages/subPages/paySuccess/paySuccess?tid=' + _this.payInfo.tid,
navType: 'rediRect'
});
}
},
fail(res) {
uni.hideLoading();
//支付失败
if(_this.plugin == 'mobilerecharge'){
App.showError('支付失败', () => {
App.navigationTo({
url: 'pages/subPages2/voucherCenter/voucherCenter',
navType: 'rediRect'
});
});
}else if(_this.plugin == 'rights'){
// 权益订单
App.showError('支付失败', () => {
uni.navigateBack({
delta:1
})
});
}else{
App.showError('支付失败', () => {
App.navigationTo({
url: 'pages/subPages/orderList/orderList?type=0',
navType: 'reLaunch'
});
});
}
}
});
// #endif
//#ifdef APP-PLUS
//#endif
}
}
},
computed: {
textSubData() {
return uni.getStorageSync('TextSubstitution');
}
}
};
</script>
<style lang="less">
page {
background: rgba(255, 255, 255, 1) !important;
overflow-x: hidden;
}
.payment {
font-size: 0;
background: rgba(255, 255, 255, 1) !important;
padding-bottom: 50upx;
}
.paymentPackage {
border: 1px solid rgba(0, 0, 0, 0);
}
.surplusTime {
margin-top: 99upx;
text-align: center;
> span {
font-size: 24upx;
color: rgba(153, 153, 153, 1);
}
}
.conversion {
padding: 6upx 10upx;
margin-left: 20upx;
min-width: 100upx;
height: 40upx;
line-height: 38upx;
display: inline-block;
color: #ffffff;
background: linear-gradient(to right, #ee3023, #fa6033);
border-radius: 7upx;
}
.price {
margin-top: 29upx;
text-align: center;
> span {
font-size: 48upx;
font-weight: bold;
color: rgba(51, 51, 51, 1);
> span {
font-size: 72upx;
}
}
}
.goodsInfo {
text-align: center;
width: 367upx;
margin: 28upx auto 0 auto;
> span {
font-size: 24upx;
color: rgba(153, 153, 153, 1);
}
}
.paymentTypePackage {
margin-top: 60upx;
padding: 0 30upx;
}
.paymentTypeList {
margin-top: 39upx;
> view {
display: inline-block;
}
}
.imgPackage {
vertical-align: top;
width: 45upx;
height: 50upx;
> image {
width: 45upx;
height: 50upx;
}
}
.inputPackage {
vertical-align: top;
margin-left: 38upx;
width: 600upx;
border-bottom: 1px solid rgba(238, 238, 238, 1);
}
.inputPackage1 {
vertical-align: top;
margin-left: 38upx;
width: 600upx;
}
.inputPackageLeft {
}
.inputPackageLeftTitle {
font-size: 28upx;
color: rgba(51, 51, 51, 1);
}
.inputPackageMain {
width: 600upx;
padding-bottom: 40upx;
display: flex;
justify-content: space-between;
> view {
vertical-align: middle;
display: inline-block;
}
}
.inputPackageLeftBody {
margin-top: 9upx;
font-size: 24upx;
color: rgba(153, 153, 153, 1);
}
.paySubmitPackage {
// position: absolute;
}
.paySubmit {
position: fixed;
bottom: 10vh;
margin-left: 60upx;
width: 630upx;
height: 80upx;
background: #509DFD;
border-radius: 10upx;
text-align: center;
> span {
font-size: 28upx;
color: rgba(255, 255, 255, 1);
line-height: 80upx;
}
}
.inputPackageRight {
margin-top: 20upx;
width: 40upx;
height: 40upx;
border: 1upx solid rgba(204, 204, 204, 1);
border-radius: 50%;
}
.inputPackageRightCheck {
margin-top: 20upx;
width: 40upx;
height: 40upx;
background: rgba(255, 68, 68, 1);
border-radius: 50%;
text-align: center;
overflow: hidden;
> image {
margin-top: 11upx;
width: 28upx;
height: 23upx;
}
}
</style>