完善功能

This commit is contained in:
wangxiaowei
2025-12-10 21:30:49 +08:00
parent 5709317af2
commit 6cba10eb94
7 changed files with 621 additions and 384 deletions

View File

@ -8,87 +8,18 @@
<view class="r-desc2">充值金额只能消费不能提现</view>
</view>
<view class="bg-white card" @click="selectCard">
<view class="bg-white card">
<view>
<view class="card-item">
<view class="card-item" :class="currentType == i + 1 ? 'active' : ''" v-for="i in 5" :key="i" @click="selectCard(i + 1)">
<view class="d-f a-i-c">
<view class="icon-box d-c-c card-checkout"><span class="icon iconfont icon-xuanze"></span></view>
<view class="card-balance">充值1000</view>
<view class="card-balance">充值{{ balance['balance' + (i + 1)] }}</view>
</view>
<view class="d-f a-i-c">
<view class="d-f a-i-c">
<view class="sale">
<text>预存享</text>
<text class="discount">9.5</text>
<text></text>
</view>
</view>
</view>
</view>
<view class="card-item">
<view class="d-f a-i-c">
<view class="icon-box d-c-c card-checkout"><span class="icon iconfont icon-xuanze"></span></view>
<view class="card-balance">充值1000</view>
</view>
<view class="d-f a-i-c">
<view class="d-f a-i-c">
<view class="sale">
<text>预存享</text>
<text class="discount">9.5</text>
<text></text>
</view>
</view>
</view>
</view>
<view class="card-item">
<view class="d-f a-i-c">
<view class="icon-box d-c-c card-checkout"><span class="icon iconfont icon-xuanze"></span></view>
<view class="card-balance">充值1000</view>
</view>
<view class="d-f a-i-c">
<view class="d-f a-i-c">
<view class="sale">
<text>预存享</text>
<text class="discount">9.5</text>
<text></text>
</view>
</view>
</view>
</view>
<view class="card-item">
<view class="d-f a-i-c">
<view class="icon-box d-c-c card-checkout"><span class="icon iconfont icon-xuanze"></span></view>
<view class="card-balance">充值1000</view>
</view>
<view class="d-f a-i-c">
<view class="d-f a-i-c">
<view class="sale">
<text>预存享</text>
<text class="discount">9.5</text>
<text></text>
</view>
</view>
</view>
</view>
<view class="card-item active">
<view class="d-f a-i-c">
<view class="icon-box d-c-c card-checkout"><span class="icon iconfont icon-xuanze"></span></view>
<view class="card-balance">充值1000</view>
</view>
<view class="d-f a-i-c">
<view class="d-f a-i-c">
<view class="sale">
<text>预存享</text>
<text class="discount">9.5</text>
<text class="discount">{{ balance['discount' + (i + 1)] }}</text>
<text></text>
</view>
</view>
@ -104,32 +35,158 @@
</view>
<view class="card-btn" @click="confirmCard">确定</view>
</view>
<!-- 会员卡选择弹窗 -->
<!-- <Popup :show="cardPopup" :width='750' :padding="0" type="bottom" backgroundColor="#fff" radius="32rpx 32rpx 0 0">
<view class="notice-popup">
<view class="title">提示</view>
<view class="desc">
<view class="rule">是否充值该</view>
</view>
<view class="btn">
<view class="btn1" @click="cancelReservePopup = false">取消</view>
<view class="btn2" @click="cancelReserveOrder">确定</view>
</view>
</view>
</Popup> -->
</view>
</template>
<script>
import navbar from '@/components/navbar.vue';
import Popup from '@/components/uni-popup.vue';
export default {
components: {
navbar,
Popup
},
data() {
return {}
return {
cardPopup: false,
currentType: -1,
balance: {}
}
},
onLoad() {
let self = this;
// 获取充值卡
self._post(
'ground.ground/groundSetting',
{
app_id: self.getAppId(),
},
function(res) {
self.balance = res.data.lists.balance;
console.log("🚀 ~ res:", self.balance)
}
)
},
methods: {
// 选择会员卡
selectCard() {
console.log("选择会员卡");
selectCard(index) {
this.currentType = index;
},
// 确认选择
confirmCard() {
console.log("确认选择");
}
if (this.currentType == -1) {
uni.showToast({
title: '请选择充值金额',
icon: 'none'
});
return;
}
this.wxPay()
},
// 微信支付
wxPay() {
let self = this;
uni.showLoading({
title: '加载中'
});
try {
self._post(
'user.groundOrder/recharge',
{
app_id: self.getAppId(),
type: this.currentType
},
function(res) {
if (res.code) {
const data = res.data
console.log("🚀 ~ pay data:", data)
uni.requestPayment({
provider: 'wxpay',
timeStamp: data.payment.timeStamp,
nonceStr: data.payment.nonceStr,
package: 'prepay_id=' + data.payment.prepay_id,
signType: 'MD5',
paySign: data.payment.paySign,
success: res => {
self.result = 'success'
console.log("🚀 ~ pay success res:", res)
uni.showToast({
title: '支付成功',
icon: 'none'
});
self.loadding = false;
setTimeout(() => {
uni.redirectTo({
url: '/bundle/recharge/card'
});
}, 500);
},
fail: res => {
console.log("🚀 ~ pay error res:", res)
self.result = 'fail'
self.loadding = false;
uni.showToast({
title: '支付失败',
icon: 'none'
});
setTimeout(() => {
uni.redirectTo({
url: '/bundle/recharge/card'
});
}, 500);
},
});
} else {
self.loadding = false;
uni.showToast({
title: '创建订单失败',
icon: 'none'
});
return
}
}
)
} catch (error) {
console.log("🚀 ~ pay error res:", res)
self.result = 'fail'
self.loadding = false;
uni.showToast({
title: '支付失败',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack({delta: 1})
}, 500);
}
},
}
}
@ -227,4 +284,39 @@
text-align: center;
}
}
.notice-popup {
padding: 20rpx 0;
width: 100%;
.title {
font-size: 36rpx;
color: #303133;
line-height: 50rpx;
text-align: center;
}
.desc {
margin-top: 48rpx;
font-weight: 400;
font-size: 32rpx;
color: #303133;
line-height: 52rpx;
text-align: center;
}
.rule {
margin-bottom: 18rpx;
text-align: left;
}
.rule1 {
font-weight: 400;
font-size: 32rpx;
color: #303133;
line-height: 44rpx;
text-align: left;
margin-bottom: 10rpx;
}
}
</style>