前端小程序

这个提交包含在:
可乐加冰
2026-09-14 17:24:53 +08:00
父节点 bb69a43a0f
当前提交 019630f12c
共有 2629 个文件被更改,包括 403657 次插入 和 0 次删除

查看文件

@@ -0,0 +1,436 @@
<!-- 收银台 -->
<template>
<view class="pay-method-wrap">
<view class="u-flex-col u-col-center money-box" v-if="orderDetail.total_fee">
<text class="time" v-show="isCountDown">{{ timeText }}</text>
<view class="money">{{ orderDetail.total_fee }}</view>
</view>
<!-- 支付方式单选项 -->
<u-radio-group v-if="paymentList && paymentList.length" class="pay-box" v-model="payType"
active-color="#1677FF">
<!-- 微信支付 -->
<view class="u-flex u-row-between pay-item" v-show="paymentList.includes('wechat')"
@tap="payType = 'wechat'">
<view class="u-flex">
<image class="pay-img" :src="$IMG_URL + '/imgs/order/order_wx_pay.png'" mode=""></image>
<text>微信支付</text>
</view>
<u-radio shape="circle" name="wechat"></u-radio>
</view>
<!-- 支付宝支付 -->
<view class="u-flex u-row-between pay-item" v-show="paymentList.includes('alipay')"
@tap="payType = 'alipay'">
<view class="u-flex">
<image class="pay-img" :src="$IMG_URL + '/imgs/order/order_ali_pay.png'" mode=""></image>
<text>支付宝支付</text>
</view>
<u-radio shape="circle" name="alipay"></u-radio>
</view>
<!-- 苹果支付 -->
<view class="u-flex u-row-between pay-item" v-show="paymentList.includes('iospay') && appPlatfrom === 'ios'"
@tap="payType = 'iospay'">
<view class="u-flex">
<image class="pay-img" :src="$IMG_URL + '/imgs/order/order_apple_pay.png'" mode=""></image>
<text>ApplePay</text>
</view>
<u-radio shape="circle" name="iospay"></u-radio>
</view>
<!-- 余额支付 -->
<view class="u-flex u-row-between pay-item" v-show="paymentList.includes('wallet')"
@tap="payType = 'wallet'">
<view class="u-flex">
<image class="pay-img" :src="$IMG_URL + '/imgs/order/order_wallet_pay.png'" mode=""></image>
<text>余额支付</text>
</view>
<u-radio shape="circle" name="wallet"></u-radio>
</view>
</u-radio-group>
<button class="u-reset-button pay-btn" @tap="confirmPay">确认支付 ¥{{ orderDetail.total_fee || '0.00' }}</button>
<!-- 组合支付弹窗 -->
<u-popup v-model="showGrpupDialog" @close="handleCloseGroupDialog" mode="bottom" :mask-close-able="false" :border-radius="20" closeable
close-icon-pos="top-left">
<view class="group-box">
<view class="price"><text>¥</text>{{orderDetail.total_fee}}</view>
<view class="content">
<view class="account">
<view class="name">支付账号</view>
<view class="mobile">{{orderDetail.user_mobile}}</view>
</view>
<view class="desc">
<view class="name">组合支付</view>
<view class="icon">
<!-- <image :src="$IMG_URL + '/imgs/order/money.png'" mode=""></image> -->
</view>
</view>
<view class="price-box">
<view class="div">
<view class="left">
<image class="pay-img" :src="$IMG_URL + '/imgs/order/order_wallet_pay.png'" mode="">
</image>
<text>余额支付</text>
</view>
<view class="right">
¥{{orderDetail.user_money}}
</view>
</view>
<view class="div">
<view class="left">
<image class="pay-img" :src="$IMG_URL + '/imgs/order/order_wx_pay.png'" mode=""></image>
<text>微信支付</text>
</view>
<view class="right">
¥{{orderDetail.group_fee}}
</view>
</view>
</view>
<view @tap="confirmPay" class="pay-btn">
<!-- <image class="pay-img" :src="$IMG_URL + '/imgs/order/group-pay.png'" mode=""></image> -->
<text>确认支付 ¥{{ orderDetail.group_fee}}</text>
</view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
/**
* 接收商品订单orderType:goods,充值订单orderType:recharge
*/
import Pay from '@/shopro/pay';
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
let timer;
export default {
components: {},
data() {
return {
showGrpupDialog: false, // 组合支付弹窗
payType: '', // 支付方式
isGroupPay: false,
isCountDown: true, // 是否显示订单倒计时。
orderDetail: {},
timeText: '', // 倒计时文本
platform: this.$platform.get(),
appPlatfrom: '',
orderType: ''
};
},
computed: {
...mapGetters(['initPayment', 'initRecharge']),
paymentList() {
let list = []
switch (this.orderType) {
case 'goods':
list = this.initPayment
break;
case 'recharge':
list = this.initPayment?.length && this.initPayment.filter(item => {
if (this.initRecharge.methods.includes(item)) return item
})
break;
default:
list = this.initPayment
break;
}
console.log(list);
this.payType = list?.[0];
return list
},
},
onShow() {
this.orderDetail.id && this.countDown();
},
onLoad() {
this.orderType = this.$Route.query.orderType
if (this.$platform.get() === 'wxOfficialAccount' && this.$platform.device() === 'ios' && this.$platform
.entry() !== location.href) location.reload();
// 获取订单详情
this.getOrderDetail()
},
onHide() {
clearInterval(timer);
timer = null;
},
methods: {
// 关闭组合支付弹窗
handleCloseGroupDialog() {
this.showGrpupDialog = false;
this.isGroupPay = false;
},
// 获取订单详情
getOrderDetail() {
switch (this.$Route.query.orderType) {
case 'goods':
this.getGoodsOrderDetail()
break;
case 'recharge':
this.getRechargeOrderDetail()
break;
default:
this.getGoodsOrderDetail()
break;
}
},
// 倒计时
countDown() {
let that = this;
let t = parseInt(that.orderDetail.ext_arr.expired_time * 1000) - parseInt(new Date().getTime());
t = t / 1000;
timer = setInterval(() => {
if (t > 0) {
let time = that.$tools.format(t);
that.timeText = `支付剩余时间 ${time.m}:${time.s}`;
t--;
} else {
clearInterval(timer);
that.timeText = '订单已过期!';
}
}, 1000);
},
// 发起支付
confirmPay() {
let that = this;
let pay = null;
let userMoney = parseFloat(that.orderDetail.user_money);
let totalFee = parseFloat(that.orderDetail.total_fee);
if (!that.payType) {
this.$u.toast('请选择支付方式');
return;
}
if (userMoney <= 0 && that.payType === 'wallet') {
uni.showModal({
title: '温馨提示',
confirmColor: '#1677FF',
content: `您的余额不足无法支付`,
showCancel: false,
success: res => {
}
});
return false;
} else if (that.payType === 'wallet' && userMoney >= totalFee) {
uni.showModal({
title: '温馨提示',
confirmColor: '#1677FF',
content: `是否确认使用余额支付:${that.orderDetail.total_fee || '0.00'}元?`,
success: res => {
if (res.confirm) {
pay = new Pay(that.payType, that.orderDetail, that.$Route.query.orderType);
}
}
});
} else if (that.payType === 'wallet' && userMoney < totalFee && that.isGroupPay == false && userMoney > 0) {
// 组合支付
that.showGrpupDialog = true;
that.isGroupPay = true;
} else {
pay = new Pay(that.isGroupPay ? 'group' : that.payType, that.orderDetail, that.$Route.query.orderType);
}
},
// 支付商品订单信息
getGoodsOrderDetail() {
let that = this;
that.$http('order.detail', {
id: that.$Route.query.orderId
}).then(res => {
if (res.code === 1) {
that.orderDetail = res.data;
if (res.data.ext_arr !== null) {
that.countDown();
} else {
that.isCountDown = false;
}
}
});
},
// 充值订单信息
getRechargeOrderDetail() {
let that = this;
that.$http('money.rechargeDetail', {
id: that.$Route.query.orderId
}).then(res => {
if (res.code === 1) {
that.orderDetail = res.data;
if (res.data.ext_arr !== null) {
that.countDown();
} else {
that.isCountDown = false;
}
}
});
}
}
};
</script>
<style lang="scss">
.group-box {
min-height: 620rpx;
margin: 120rpx 40rpx 40rpx 40rpx;
.content {
margin-top: 50rpx;
.pay-btn {
margin-top: 50rpx;
display: flex;
align-items: center;
justify-content: center;
image {
width: 42rpx;
height: 42rpx;
margin-right: 10rpx;
}
}
.price-box {
margin-top: 30rpx;
border-bottom: 2rpx solid $brand-border;
padding-bottom: 10rpx;
.div {
margin-bottom: 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
.left {
display: flex;
align-items: center;
text {
color: #333;
font-size: 28rpx;
}
.pay-img {
margin-right: 10rpx;
width: 40rpx;
height: 40rpx;
}
}
.right {
font-size: 30rpx;
color: #585454;
font-weight: bold;
}
}
}
.desc {
margin-top: 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
.name {
font-size: 30rpx;
color: #333;
font-weight: bold;
}
.icon {
image {
width: 48rpx;
height: 48rpx;
}
}
}
.account {
display: flex;
justify-content: space-between;
border-bottom: 2rpx solid $brand-border;
padding-bottom: 30rpx;
.name {
font-size: 30rpx;
color: #999;
}
.mobile {
font-size: 28rpx;
color: #333;
}
}
}
.price {
text-align: center;
color: #e1212b;
font-size: 60rpx;
font-weight: bold;
text {
font-size: 32rpx;
margin-right: 5rpx;
}
}
}
.money-box {
background: #fff;
height: 250rpx;
margin-bottom: 20rpx;
padding-top: 30rpx;
.time {
font-size: 28rpx;
color: #c4c4c4;
}
.money {
color: #e1212b;
font-size: 60rpx;
margin-top: 60rpx;
&::before {
content: '¥';
font-size: 46rpx;
}
}
}
.pay-box {
.pay-item {
height: 90rpx;
padding: 0 30rpx;
font-size: 26rpx;
background: #fff;
width: 750rpx;
border-bottom: 1rpx solid #eeeeee;
&:last-child {
border-bottom: none;
}
.pay-img {
width: 40rpx;
height: 40rpx;
margin-right: 25rpx;
}
}
}
.pay-btn {
width: 690rpx;
line-height: 80rpx;
background: linear-gradient(90deg, rgba(240, 199, 133, 1), rgba(246, 214, 157, 1));
border-radius: 40rpx;
color: rgba(#fff, 0.9);
margin: 100rpx auto 0;
}
</style>

查看文件

@@ -0,0 +1,292 @@
<!-- 支付结果页 -->
<template>
<view class="success-page">
<!-- 商品结果页 -->
<template v-if="orderType==='goods'">
<view class="success-box u-flex-col u-row-center u-col-center">
<image class="pay-img" :src="payImg[payState]" mode=""></image>
<text class="notice">{{ payText[payState] }}</text>
<text class="pay-money"
v-if="payState === 'success' && orderDetail.total_fee">¥{{ orderDetail.total_fee }}</text>
<view class="btn-box u-flex u-row-between">
<block
v-if="payState === 'success' && orderDetail.activity_type === 'groupon' && orderDetail.ext_arr.buy_type === 'groupon'">
<button class="u-reset-button base-btn" v-if="orderDetail.ext_arr.groupon_id > 0"
@tap="$Router.replace({ path: '/pages/activity/groupon/detail', query: { id: orderDetail.ext_arr.groupon_id } })">
拼团详情
</button>
<button class="u-reset-button base-btn" v-else
@tap="$Router.push('/pages/activity/groupon/my-groupon')">我的拼团</button>
</block>
<button class="u-reset-button base-btn" v-else
@tap="$Router.pushTab('/pages/index/index')">返回首页</button>
<button class="u-reset-button base-btn u-m-l-10 u-m-r-10"
@tap="$Router.replace({ path: '/pages/order/detail', query: { id: orderDetail.id } })">查看订单</button>
<button class="u-reset-button again-pay " v-show="payState === 'fail'" @tap="onPay">重新支付</button>
</view>
</view>
<!-- modal -->
<!-- #ifdef MP-WEIXIN -->
<u-modal v-if="payState === 'success'" ref="uModal" v-model="showModal" :show-cancel-button="true"
confirm-color="#F0E6C8" cancel-color="#666666" @confirm="onConfirm" confirm-text="订阅消息" cancel-text="取消"
content="是否订阅消息,追踪订单信息?" title="提示"></u-modal>
<!-- #endif -->
</template>
<template v-if="orderType==='recharge'">
<view class="success-box u-flex-col u-row-center u-col-center">
<image class="pay-img" :src="payImg[payState]" mode=""></image>
<text class="notice">{{ payText[payState] }}</text>
<text class="pay-money"
v-if="payState === 'success' && orderDetail.total_fee">¥{{ orderDetail.total_fee }}</text>
<view class="btn-box u-flex u-row-between">
<button class="u-reset-button base-btn" @tap="$Router.pushTab('/pages/index/index')">返回首页</button>
<button v-if="payState === 'fail'" class="u-reset-button again-pay" @tap="onPay">重新支付</button>
<button v-else class="u-reset-button base-btn"
@tap="$Router.pushTab('/pages/index/user')">个人中心</button>
</view>
</view>
</template>
</view>
</template>
<script>
import Pay from '@/shopro/pay';
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
let payTimer = null;
const payCount = 5;
export default {
components: {},
data() {
return {
showModal: false,
messageType: '',
templateIds: [],
wxOpenTags: '',
orderDetail: {}, //订单详情
orderType: '', //订单类型
payText: {
fail: '支付失败',
success: '支付成功',
paying: '查询中...'
},
payImg: {
fail: this.$IMG_URL + '/imgs/order/order_pay_fail.gif',
success: this.$IMG_URL + '/imgs/order/order_pay_success.gif',
paying: this.$IMG_URL + '/imgs/order/order_paying.gif'
},
payState: '' //支付状态
};
},
computed: {
...mapGetters(['subscribeMessageIdsMap'])
},
onLoad() {
this.payState = this.$Route.query.payState ? this.$Route.query.payState : 'paying';
this.orderType = this.$Route.query.orderType
this.$Route.query.orderId && this.getOrderDetail();
switch (this.payState) {
case 'success':
this.getCartList();
break;
case 'fail':
break;
case 'paying':
this.checkTimer();
break;
default:
break;
}
},
onHide() {
clearInterval(payTimer);
payTimer = null;
},
methods: {
...mapActions(['getCartList']),
// 订阅消息
onConfirm() {
// #ifdef MP-WEIXIN
this.templateIds.length && this.$store.commit('subscribeMessage', this.messageType);
// #endif
},
// 获取订单详情
getOrderDetail() {
switch (this.$Route.query.orderType) {
case 'goods':
this.getGoodsOrderDetail()
break;
case 'recharge':
this.getRechargeOrderDetail()
break;
default:
break;
}
},
// 支付订单信息
getGoodsOrderDetail() {
let that = this;
that.$http('order.detail', {
id: that.$Route.query.orderId
}).then(async res => {
if (res.code === 1) {
that.orderDetail = res.data;
if (res.data.status > 0) {
this.messageType = this.orderDetail.activity_type == 'groupon' ? 'grouponResult' :
'result';
// #ifdef MP-WEIXIN
this.templateIds = this.subscribeMessageIdsMap[this.messageType];
this.showModal = this.templateIds.length;
// #endif
}
}
});
},
// 充值订单信息
getRechargeOrderDetail() {
let that = this;
that.$http('money.rechargeDetail', {
id: that.$Route.query.orderId
}).then(res => {
if (res.code === 1) {
that.orderDetail = res.data;
if (res.data.status > 0) {
this.messageType = 'result';
}
}
});
},
// 支付倒计时
checkTimer() {
let that = this;
let count = 0;
that.payState = 'paying';
payTimer = setInterval(() => {
count++;
if (count < payCount) {
that.checkPay();
} else {
clearInterval(payTimer);
that.payState = 'fail';
}
}, 800);
},
// 检测支付
async checkPay() {
let that = this;
let paiMap = {
'goods': 'order.detail',
'recharge': 'money.rechargeDetail'
}
if (that.orderType === 'goods') {
await that.$http('money.syncHuifu', {
order_id: that.$Route.query.orderId
}, '', false).catch(() => {});
}
let res = await that.$http(
paiMap[that.orderType], {
id: that.$Route.query.orderId
},
false
);
if (res.code === 1 && res.data.status > 0) {
that.payState = 'success';
clearInterval(payTimer);
}
},
// 重新支付
onPay() {
let that = this;
let pay = new Pay(that.$Route.query.type, that.orderDetail, that.orderType);
}
}
};
</script>
<style lang="scss" scopeds>
.success-box {
background: #fff;
width: 750rpx;
padding: 40rpx 0;
.pay-img {
width: 130rpx;
height: 130rpx;
}
.notice {
font-size: 30rpx;
font-weight: bold;
color: rgba(51, 51, 51, 1);
line-height: 30rpx;
margin-top: 30rpx;
}
.pay-money {
font-size: 36rpx;
color: #ff3000;
font-weight: 600;
margin-top: 20rpx;
}
.btn-box {
margin-top: 30rpx;
width: 660rpx;
.base-btn {
width: 320rpx;
line-height: 70rpx;
background: rgba(255, 255, 255, 1);
border: 1rpx solid rgba(223, 223, 223, 0.5);
border-radius: 35rpx;
font-size: 28rpx;
font-weight: 400;
color: rgba(153, 153, 153, 1);
padding: 0;
}
.again-pay {
width: 320rpx;
line-height: 70rpx;
background: linear-gradient(90deg, #1677FF, #4096FF);
box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
border-radius: 35rpx;
font-size: 28rpx;
font-weight: 400;
color: rgba(255, 255, 255, 0.8);
padding: 0;
}
}
}
.hot-box {
background: #fff;
padding: 20rpx;
margin-top: 20rpx;
.hot-title {
font-size: 30rpx;
font-weight: 500;
color: rgba(51, 51, 51, 1);
height: 80rpx;
}
}
</style>