cyywl_server/yudao-ui-app/components/paymentMember/index.vue

208 lines
4.7 KiB
Vue

<template>
<view>
<view class="payment" :class="pay_close ? 'on' : ''">
<view class="title acea-row row-center-wrapper">
选择付款方式<text class="iconfont icon-guanbi" @click='close'></text>
</view>
<view class="item acea-row row-between-wrapper" @click='goPay(item.value)' v-for="(item,index) in payMode"
:key="index">
<view class="left acea-row row-between-wrapper">
<view class="iconfont" :class="item.icon"></view>
<view class="text">
<view class="name">{{item.name}}</view>
<view class="info" v-if="item.number">
{{item.title}} <span class="money">¥{{ item.number }}</span>
</view>
<view class="info" v-else>{{item.title}}</view>
</view>
</view>
<view class="iconfont icon-xiangyou"></view>
</view>
</view>
<view class="mask" @click='close' v-if="pay_close"></view>
<button style="cursor: pointer;display:none;" class="clipboard" :data-clipboard-text="alipayLink">
</button>
<!-- 支付宝支付界面 -->
<u-modal :show="alipayShow" title="支付宝支付" @confirm="handleConfirm">
<view class="slot-content">
<rich-text :nodes="alipayForm"></rich-text>
</view>
</u-modal>
</view>
</template>
<script>
import {
orderPay,
wechatOrderPay,
wechatQueryPayResult
} from '@/api/order.js';
import uniPay from '@/libs/pay.js'
import {
memberTopUp
} from '@/api/member.js';
import {
mapGetters
} from "vuex";
import Clipboard from 'clipboard'
export default {
props: {
payMode: {
type: Array,
default: function() {
return [];
}
},
pay_close: {
type: Boolean,
default: false,
},
payInfo: {
type: Object,
deafult: () => {
return {
orderInfos: []
}
}
}
},
data() {
return {
alipayShow: false,
alipayForm: `链接已复制,请到外部浏览器完成支付`,
alipayLink: ''
};
},
computed: mapGetters(['systemPlatform', 'openId']),
mounted() {
new Clipboard('.clipboard')
},
methods: {
handleConfirm() {
this.alipayShow = false
window.location.reload()
},
close: function() {
this.$emit('onChangeFun', {
action: 'payClose'
});
},
// 微信支付JSAPI调起
goPay: function(paytype) {
let that = this;
if (that.payInfo.orderInfos.length === 0) return that.$util.Tips({
title: '请选择要支付的订单'
});
uniPay({
payInfo: that.payInfo,
payType: paytype,
createOrderFun: memberTopUp,
wxPaySuccess: () => {
window.location.reload()
},
aliPaySuccess: (link) => {
that.alipayLink = link
setTimeout(() => {
document.querySelector(".clipboard").click();
that.alipayShow = true
}, 500)
}
})
}
}
}
</script>
<style scoped lang="scss">
.payment {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
border-radius: 16rpx 16rpx 0 0;
background-color: #fff;
padding-bottom: 20%;
z-index: 99;
transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
transform: translate3d(0, 100%, 0);
}
.payment.on {
transform: translate3d(0, 0, 0);
}
.payment .title {
text-align: center;
height: 123rpx;
font-size: 32rpx;
color: #282828;
font-weight: bold;
padding-right: 30rpx;
margin-left: 30rpx;
position: relative;
border-bottom: 1rpx solid #eee;
}
.payment .title .iconfont {
position: absolute;
right: 30rpx;
top: 50%;
transform: translateY(-50%);
font-size: 43rpx;
color: #8a8a8a;
font-weight: normal;
}
.payment .item {
border-bottom: 1rpx solid #eee;
height: 130rpx;
margin-left: 30rpx;
padding-right: 30rpx;
}
.payment .item .left {
width: 600rpx;
}
.payment .item .left .text {
width: 540rpx;
}
.payment .item .left .text .name {
font-size: 32rpx;
color: #282828;
}
.payment .item .left .text .info {
font-size: 24rpx;
color: #999;
}
.payment .item .left .text .info .money {
color: #ff9900;
}
.payment .item .left .iconfont {
font-size: 45rpx;
color: #09bb07;
}
.payment .item .left .iconfont.icon-zhifubao {
color: #00aaea;
}
.payment .item .left .iconfont.icon-yuezhifu {
color: #ff9900;
}
.payment .item .left .iconfont.icon-yuezhifu1 {
color: #eb6623;
}
.payment .item .iconfont {
font-size: 0.3rpx;
color: #999;
}
</style>