Merge branch 'master-vue3' of gitee.com:yudaocode/yudao-mall-uniapp into vue3_tmp

Signed-off-by: 落日晚风 <1811466536@qq.com>
pull/29/head
落日晚风 2023-12-19 02:29:43 +00:00 committed by Gitee
commit 434b049b0d
5 changed files with 123 additions and 130 deletions

View File

@ -1,47 +1,36 @@
<!-- 充值记录 -->
<template> <template>
<s-layout class="widthdraw-log-wrap" title="充值记录"> <s-layout class="widthdraw-log-wrap" title="充值记录">
<!-- 记录卡片 --> <!-- 记录卡片 -->
<view class="wallet-log-box ss-p-b-30"> <view class="wallet-log-box ss-p-b-30">
<view class="log-list" v-for="item in state.pagination.data" :key="item"> <view class="log-list" v-for="item in state.pagination.list" :key="item">
<view class="head ss-flex ss-col-center ss-row-between"> <view class="head ss-flex ss-col-center ss-row-between">
<view class="title">充值金额</view> <view class="title">充值金额</view>
<view <view class="num" :class="item.refundStatus === 10 ? 'danger-color' : 'success-color'">
class="num" {{ fen2yuan(item.payPrice) }}
:class=" <text v-if="item.bonusPrice > 0"> {{ fen2yuan(item.bonusPrice)}} </text>
item.status === -1 </view>
? 'danger-color'
: item.status === 2
? 'success-color'
: 'warning-color'
"
>{{ item.pay_fee }}</view
>
</view> </view>
<view class="status-box item ss-flex ss-col-center ss-row-between"> <view class="status-box item ss-flex ss-col-center ss-row-between">
<view class="item-title">支付状态</view> <view class="item-title">支付状态</view>
<view <view
class="status-text" class="status-text"
:class=" :class="item.refundStatus === 10 ? 'danger-color' : 'success-color'"
item.status === -1
? 'danger-color'
: item.status === 2
? 'success-color'
: 'warning-color'
"
>{{ item.status_text }}</view
> >
{{ item.refundStatus === 10 ? '已退款' : '已支付' }}
</view>
</view> </view>
<view class="time-box item ss-flex ss-col-center ss-row-between"> <view class="time-box item ss-flex ss-col-center ss-row-between">
<text class="item-title">充值渠道</text> <text class="item-title">充值渠道</text>
<view class="time ss-ellipsis-1">{{ item.platform_text }}</view> <view class="time ss-ellipsis-1">{{ item.payChannelName }}</view>
</view> </view>
<view class="time-box item ss-flex ss-col-center ss-row-between"> <view class="time-box item ss-flex ss-col-center ss-row-between">
<text class="item-title">充值单号</text> <text class="item-title">充值单号</text>
<view class="time"> {{ item.order_sn }} </view> <view class="time"> {{ item.payOrderChannelOrderNo }} </view>
</view> </view>
<view class="time-box item ss-flex ss-col-center ss-row-between"> <view class="time-box item ss-flex ss-col-center ss-row-between">
<text class="item-title">充值时间</text> <text class="item-title">充值时间</text>
<view class="time"> {{ item.paid_time }}</view> <view class="time"> {{ sheep.$helper.timeFormat(item.payTime, 'yyyy-mm-dd hh:MM:ss') }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -49,59 +38,64 @@
v-if="state.pagination.total === 0" v-if="state.pagination.total === 0"
icon="/static/comment-empty.png" icon="/static/comment-empty.png"
text="暂无充值记录" text="暂无充值记录"
></s-empty> />
<uni-load-more <uni-load-more
v-if="state.pagination.total > 0" v-if="state.pagination.total > 0"
:status="state.loadStatus" :status="state.loadStatus"
:content-text="{ :content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" }"
@tap="loadmore" @tap="loadMore"
/> />
</s-layout> </s-layout>
</template> </template>
<script setup> <script setup>
import { reactive } from 'vue'; import { reactive } from 'vue';
import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app'; import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import _ from 'lodash'; import _ from 'lodash';
import PayWalletApi from '@/sheep/api/pay/wallet';
import sheep from '@/sheep';
import { fen2yuan } from '../../sheep/hooks/useGoods';
const state = reactive({ const state = reactive({
currentTab: 0,
pagination: { pagination: {
data: [], list: [],
current_page: 1, total: 0,
total: 1, pageNo: 1,
last_page: 1, pageSize: 5,
}, },
loadStatus: '', loadStatus: '',
}); });
async function getLogList(page = 1, list_rows = 5) { async function getLogList(page = 1, list_rows = 5) {
const res = await sheep.$api.trade.orderLog({ type: 'recharge', list_rows, page }); const { code, data } = await PayWalletApi.getWalletRechargePage({
if (res.error === 0) { pageNo: page,
let logList = _.concat(state.pagination.data, res.data.data); pageSize: list_rows,
state.pagination = { });
...res.data, if (code !== 0) {
data: logList, return;
};
if (state.pagination.current_page < state.pagination.last_page) {
state.loadStatus = 'more';
} else {
state.loadStatus = 'noMore';
}
} }
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
} }
// //
function loadmore() { function loadMore() {
if (state.loadStatus !== 'noMore') { if (state.loadStatus === 'noMore') {
getLogList(state.pagination.current_page + 1); return;
} }
state.pagination.pageNo++;
getLogList();
} }
onLoad(() => { onLoad(() => {
getLogList(); getLogList();
}); });
onReachBottom(() => { onReachBottom(() => {
loadmore(); loadMore();
}); });
</script> </script>

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; state.packageList = data;
console.log(res);
console.log(res2);
// state.faceValueList = res.data.quick_amounts;
state.faceValueList = res2.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) {
// #ifdef MP return;
sheep.$platform.useProvider('wechat').subscribeMessage('money_change');
// #endif
sheep.$router.go('/pages/pay/index', {
orderSN: data.order_sn,
type: 'recharge'
});
} }
// #ifdef MP
sheep.$platform.useProvider('wechat').subscribeMessage('money_change');
// #endif
sheep.$router.go('/pages/pay/index', {
id: data.payOrderId,
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,37 @@ 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,
});
},
// 获得钱包充值记录分页
getWalletRechargePage: (params) => {
return request({
url: '/app-api/pay/wallet-recharge/page',
method: 'GET',
params,
custom: {
showError: false,
showLoading: false,
},
});
},
}; };
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,
}),
}; };

View File

@ -94,7 +94,7 @@ http.interceptors.request.use(
if (config.url.indexOf('/app-api/') !== -1) { if (config.url.indexOf('/app-api/') !== -1) {
config.header['Accept'] = '*/*' config.header['Accept'] = '*/*'
config.header['tenant-id'] = '1'; config.header['tenant-id'] = '1';
config.header['terminal'] = '20'; config.header['terminal'] = '20';
config.header['Authorization'] = 'Bearer test247'; config.header['Authorization'] = 'Bearer test247';
} }
return config; return config;
@ -113,7 +113,7 @@ http.interceptors.response.use(
if (response.header.authorization || response.header.Authorization) { if (response.header.authorization || response.header.Authorization) {
$store('user').setToken(response.header.authorization || response.header.Authorization); $store('user').setToken(response.header.authorization || response.header.Authorization);
} }
// TODO 芋艿:如果是登录的 API则自动设置 token // TODO 芋艿:如果是登录的 API则自动设置 token
response.config.custom.showLoading && closeLoading(); response.config.custom.showLoading && closeLoading();
if (response.data.error !== 0 && response.data.code !== 0) { if (response.data.error !== 0 && response.data.code !== 0) {
@ -125,10 +125,10 @@ http.interceptors.response.use(
}); });
return Promise.resolve(response.data); return Promise.resolve(response.data);
} }
// 成功时的提示 // 成功时的提示
if ( if (
(response.data.error === 0 || response.data.code === 0) && (response.data.error === 0 || response.data.code === 0) &&
(response.data.msg !== '' || response.config.custom.successMsg !== '') && ( response.data.msg !== '' || response.config.custom.successMsg !== '' ) &&
response.config.custom.showSuccess response.config.custom.showSuccess
) { ) {
uni.showToast({ uni.showToast({
@ -215,8 +215,8 @@ const request = (config) => {
} }
// TODO 芋艿:额外拼接 // TODO 芋艿:额外拼接
if (config.url.indexOf('/app-api/') >= 0) { if (config.url.indexOf('/app-api/') >= 0) {
config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】 // config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】 config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
} }
return http.middleware(config); return http.middleware(config);
}; };