充值界面:接入完成

pull/29/head^2
YunaiV 2023-12-18 21:56:17 +08:00
parent 56666b4836
commit 6584a70fa0
3 changed files with 64 additions and 77 deletions

View File

@ -1,3 +1,4 @@
<!-- 充值界面 -->
<template> <template>
<s-layout title="充值" class="withdraw-wrap" navbar="inner"> <s-layout title="充值" class="withdraw-wrap" navbar="inner">
<view class="wallet-num-box ss-flex ss-col-center ss-row-between" :style="[ <view class="wallet-num-box ss-flex ss-col-center ss-row-between" :style="[
@ -8,96 +9,86 @@
]"> ]">
<view class=""> <view class="">
<view class="num-title">当前余额</view> <view class="num-title">当前余额</view>
<view class="wallet-num">{{ userInfo.money }}</view> <view class="wallet-num">{{ fen2yuan(userInfo.money) }}</view>
</view> </view>
<button class="ss-reset-button log-btn" @tap="sheep.$router.go('/pages/pay/recharge-log')"></button> <button class="ss-reset-button log-btn" @tap="sheep.$router.go('/pages/pay/recharge-log')">
充值记录
</button>
</view> </view>
<view class="recharge-box"> <view class="recharge-box">
<view class="recharge-card-box" v-if="state.data.status"> <view class="recharge-card-box">
<view class="input-label ss-m-b-50">充值金额</view> <view class="input-label ss-m-b-50">充值金额</view>
<view class="input-box ss-flex border-bottom ss-p-b-20" v-if="state.data.custom_status"> <view class="input-box ss-flex border-bottom ss-p-b-20">
<view class="unit"></view> <view class="unit"></view>
<uni-easyinput v-model="state.recharge_money" type="digit" placeholder="请输入充值金额" <uni-easyinput v-model="state.recharge_money" type="digit" placeholder="请输入充值金额"
:inputBorder="false"> :inputBorder="false" />
</uni-easyinput>
</view> </view>
<view class="face-value-box ss-flex ss-flex-wrap ss-m-y-40"> <view class="face-value-box ss-flex ss-flex-wrap ss-m-y-40">
<button class="ss-reset-button face-value-btn" v-for="item in state.faceValueList" :key="item.money" <button class="ss-reset-button face-value-btn" v-for="item in state.packageList" :key="item.money"
:class="[{ 'btn-active': state.recharge_money == parseFloat(item.money) }]" :class="[{ 'btn-active': state.recharge_money === fen2yuan(item.payPrice) }]"
@tap="onCard(item.payPrice/100)"> @tap="onCard(item.payPrice)">
<text class="face-value-title">{{ item.payPrice/100 }}</text> <text class="face-value-title">{{ fen2yuan(item.payPrice) }}</text>
<view v-if="item.bonusPrice" class="face-value-tag"> <view v-if="item.bonusPrice" class="face-value-tag">
{{ item.bonusPrice/100 }}{{ state.data.gift_type == 'money' ? '元' : '积分' }}</view> {{ fen2yuan(item.bonusPrice) }}
</view>
</button> </button>
</view> </view>
<button class="ss-reset-button save-btn ui-BG-Main-Gradient ss-m-t-60 ui-Shadow-Main" @tap="onConfirm"> <button class="ss-reset-button save-btn ui-BG-Main-Gradient ss-m-t-60 ui-Shadow-Main" @tap="onConfirm">
确认充值 确认充值
</button> </button>
</view> </view>
<view class="" v-if="state.data.status === 0"> </view>
</view> </view>
</s-layout> </s-layout>
</template> </template>
<script setup> <script setup>
import { import { computed, reactive } from 'vue';
computed,
reactive
} from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { import { onLoad } from '@dcloudio/uni-app';
onLoad import { fen2yuan } from '@/sheep/hooks/useGoods';
} from '@dcloudio/uni-app'; import PayWalletApi from '@/sheep/api/pay/wallet';
const userInfo = computed(() => sheep.$store('user').userInfo); const userInfo = computed(() => sheep.$store('user').userInfo);
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2; const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png'); const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
const state = reactive({ const state = reactive({
recharge_money: '', recharge_money: '', //
data: {}, packageList: [],
faceValueList: [],
}); });
//
//
function onCard(e) { function onCard(e) {
state.recharge_money = e; state.recharge_money = fen2yuan(e);
} }
//
async function getRechargeTabs() { async function getRechargeTabs() {
const res = await sheep.$api.trade.rechargeRules(); const { code, data } = await PayWalletApi.getWalletRechargePackageList();
const res2 = await sheep.$api.trade.rechargeRules2(); if (code !== 0) {
if (res.error === 0) { return;
state.data = res.data;
state.data.status = res.data.status;
console.log(res);
console.log(res2);
// state.faceValueList = res.data.quick_amounts;
state.faceValueList = res2.data;
} }
state.packageList = data;
} }
function onChange(e) { //
state.data.gift_type = e.detail.value;
}
async function onConfirm() { async function onConfirm() {
const { const { code, data } = await PayWalletApi.createWalletRecharge({
code, packageId: state.packageList.find((item) => fen2yuan(item.payPrice) === state.recharge_money)?.id,
data
} = await sheep.$api.trade.recharge({
packageId: 0,
payPrice: state.recharge_money * 100 payPrice: state.recharge_money * 100
}); });
if (code === 0) { if (code !== 0) {
return;
}
// #ifdef MP // #ifdef MP
sheep.$platform.useProvider('wechat').subscribeMessage('money_change'); sheep.$platform.useProvider('wechat').subscribeMessage('money_change');
// #endif // #endif
sheep.$router.go('/pages/pay/index', { sheep.$router.go('/pages/pay/index', {
orderSN: data.order_sn, id: data.payOrderId,
type: 'recharge' type: 'recharge'
}); });
} }
}
onLoad(() => { onLoad(() => {
getRechargeTabs(); getRechargeTabs();
}); });

View File

@ -8,12 +8,12 @@ const PayWalletApi = {
.join('&'); .join('&');
return request({ return request({
url: `/app-api/pay/wallet-transaction/page?${queryString}`, url: `/app-api/pay/wallet-transaction/page?${queryString}`,
method: 'GET' method: 'GET',
}); });
}, },
// 获得钱包流水统计 // 获得钱包流水统计
getWalletTransactionSummary: (params) => { getWalletTransactionSummary: (params) => {
const queryString = `createTime=${params.createTime[0]}&createTime=${params.createTime[1]}` const queryString = `createTime=${params.createTime[0]}&createTime=${params.createTime[1]}`;
return request({ return request({
url: `/app-api/pay/wallet-transaction/get-summary?${queryString}`, url: `/app-api/pay/wallet-transaction/get-summary?${queryString}`,
// url: `/app-api/pay/wallet-transaction/get-summary`, // url: `/app-api/pay/wallet-transaction/get-summary`,
@ -21,6 +21,25 @@ const PayWalletApi = {
// params: params // params: params
}); });
}, },
// 获得钱包充值套餐列表
getWalletRechargePackageList: () => {
return request({
url: '/app-api/pay/wallet-recharge-package/list',
method: 'GET',
custom: {
showError: false,
showLoading: false,
},
});
},
// 创建钱包充值记录(发起充值)
createWalletRecharge: (data) => {
return request({
url: '/app-api/pay/wallet-recharge/create',
method: 'POST',
data,
});
}
}; };
export default PayWalletApi; export default PayWalletApi;

View File

@ -19,28 +19,5 @@ export default {
}, },
}), }),
rechargeRules: () =>
request({
url: 'trade/order/rechargeRules',
method: 'GET',
custom: {
showError: false,
showLoading: false,
},
}),
rechargeRules2: () =>
request({
url: '/app-api/pay/wallet-recharge-package/list',
method: 'GET',
custom: {
showError: false,
showLoading: false,
},
}),
recharge: (data) =>
request({
url: '/app-api/pay/wallet-recharge/create',
method: 'POST',
data,
}),
}; };