admin接入数据库
This commit is contained in:
@@ -1,27 +1,240 @@
|
||||
<template>
|
||||
<AdminLayout :currentPage="currentPage">
|
||||
<view class="page">
|
||||
<view class="header">
|
||||
<text class="title">{{ title }}</text>
|
||||
<text class="sub-title">页面占位 (自动生成)</text>
|
||||
<view class="marketing-recharge-record">
|
||||
<!-- 1. 搜索过滤栏 -->
|
||||
<view class="filter-card border-shadow">
|
||||
<view class="filter-row">
|
||||
<view class="filter-item">
|
||||
<text class="label">搜索记录:</text>
|
||||
<input class="input-mock" placeholder="订单号/用户名" v-model="searchQuery" @confirm="handleSearch" />
|
||||
</view>
|
||||
<view class="filter-btns">
|
||||
<button class="btn-query" @click="handleSearch">查询</button>
|
||||
<button class="btn-reset" @click="handleReset">重置</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 2. 数据表格 -->
|
||||
<view class="table-card border-shadow">
|
||||
<view class="table-container">
|
||||
<view v-if="isLoading" class="loading-mask">
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
|
||||
<view class="table-head">
|
||||
<view class="th cell-id">ID</view>
|
||||
<view class="th cell-user">用户信息</view>
|
||||
<view class="th cell-no">充值订单号</view>
|
||||
<view class="th cell-price">实际充值</view>
|
||||
<view class="th cell-price">赠送金额</view>
|
||||
<view class="th cell-type">支付渠道</view>
|
||||
<view class="th cell-status">支付状态</view>
|
||||
<view class="th cell-time">充值时间</view>
|
||||
</view>
|
||||
|
||||
<view class="table-body">
|
||||
<view v-if="recordList.length === 0 && !isLoading" class="empty-row">
|
||||
<text>暂无充值记录</text>
|
||||
</view>
|
||||
<view v-for="item in recordList" :key="item.id" class="table-row">
|
||||
<view class="td cell-id">
|
||||
<text class="td-txt-small">{{ item.id }}</text>
|
||||
</view>
|
||||
<view class="td cell-user">
|
||||
<view class="u-info">
|
||||
<image class="u-avatar" :src="item.avatar || '/static/logo.png'" mode="aspectFill" />
|
||||
<text class="u-nick">{{ item.nickname || '未知用户' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="td cell-no">
|
||||
<text class="td-txt">{{ item.order_no }}</text>
|
||||
</view>
|
||||
<view class="td cell-price">
|
||||
<text class="td-txt-bold">¥{{ item.price.toFixed(2) }}</text>
|
||||
</view>
|
||||
<view class="td cell-price">
|
||||
<text class="td-txt color-orange">¥{{ item.give_price.toFixed(2) }}</text>
|
||||
</view>
|
||||
<view class="td cell-type">
|
||||
<text class="td-txt">{{ formatRechargeType(item.recharge_type) }}</text>
|
||||
</view>
|
||||
<view class="td cell-status">
|
||||
<text class="status-tag" :class="item.paid === 1 ? 'paid' : 'unpaid'">
|
||||
{{ item.paid === 1 ? '已支付' : '未支付' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="td cell-time">
|
||||
<text class="td-txt-small">{{ formatDateTime(item.created_at) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 3. 分页控制 -->
|
||||
<view class="pagination-footer">
|
||||
<view class="page-total">
|
||||
<text class="total-txt">共 {{ total }} 条</text>
|
||||
</view>
|
||||
<view class="page-btns">
|
||||
<text class="p-btn" :class="{ disabled: page <= 1 }" @click="onPrevPage">‹</text>
|
||||
<text class="p-btn active">{{ page }}</text>
|
||||
<text class="p-btn" :class="{ disabled: recordList.length < pageSize }" @click="onNextPage">›</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</AdminLayout>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import AdminLayout from '@/layouts/admin/AdminLayout.uvue'
|
||||
const currentPage = ref<string>('recharge-record')
|
||||
const title = ref<string>('record')
|
||||
import { fetchRechargeRecords, RechargeRecord } from '@/services/admin/marketingService.uts'
|
||||
|
||||
const currentPage = ref('recharge-record')
|
||||
const recordList = ref<RechargeRecord[]>([])
|
||||
const isLoading = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const page = ref(1)
|
||||
const pageSize = 15
|
||||
const total = ref(0)
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await fetchRechargeRecords({
|
||||
search: searchQuery.value,
|
||||
page: page.value,
|
||||
pageSize: pageSize
|
||||
})
|
||||
recordList.value = res.items
|
||||
total.value = res.total
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
page.value = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchQuery.value = ''
|
||||
page.value = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function onPrevPage() {
|
||||
if (page.value > 1) {
|
||||
page.value--
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function onNextPage() {
|
||||
if (recordList.value.length >= pageSize) {
|
||||
page.value++
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function formatRechargeType(type : string) : string {
|
||||
switch (type) {
|
||||
case 'wechat': return '微信支付'
|
||||
case 'alipay': return '支付宝'
|
||||
case 'system': return '系统补单'
|
||||
default: return type
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateTime(iso : string) : string {
|
||||
return iso.substring(0, 16).replace('T', ' ')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '@/uni.scss';
|
||||
.page { padding: $space-lg; }
|
||||
.header { padding: $space-lg; border-radius: $radius; background: $background-primary; box-shadow: $shadow-xs; }
|
||||
.title { font-size: $font-size-lg; font-weight: $font-weight-bold; color: $text-primary; }
|
||||
.sub-title { margin-top: $space-xs; font-size: $font-size-md; color: $text-secondary; }
|
||||
.marketing-recharge-record {
|
||||
min-height: 100vh;
|
||||
background: #f0f2f5;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.border-shadow {
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.filter-card { padding: 24px; margin-bottom: 16px; }
|
||||
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
|
||||
.filter-item { display: flex; flex-direction: row; align-items: center; }
|
||||
.label { font-size: 14px; color: #606266; }
|
||||
.input-mock {
|
||||
width: 240px; height: 32px; border: 1px solid #dcdfe6; border-radius: 4px;
|
||||
padding: 0 12px; font-size: 13px;
|
||||
}
|
||||
.filter-btns { display: flex; flex-direction: row; gap: 12px; }
|
||||
.btn-query { background: #1890ff; color: #fff; height: 32px; padding: 0 16px; border-radius: 4px; font-size: 14px; border: none; cursor: pointer; }
|
||||
.btn-reset { background: #fff; color: #666; height: 32px; padding: 0 16px; border-radius: 4px; font-size: 14px; border: 1px solid #dcdfe6; cursor: pointer; }
|
||||
|
||||
.table-card { padding: 24px; position: relative; }
|
||||
.table-container { min-height: 400px; position: relative; }
|
||||
.loading-mask {
|
||||
position: absolute; top: 0; left: 0; right: 0; bottom: 0;
|
||||
background: rgba(255,255,255,0.7); display: flex; align-items: center; justify-content: center; z-index: 10;
|
||||
}
|
||||
.loading-text { color: #1890ff; font-size: 14px; }
|
||||
|
||||
.table-head {
|
||||
display: flex; flex-direction: row; background-color: #f8faff;
|
||||
border-bottom: 1px solid #e8eaec;
|
||||
}
|
||||
.th { padding: 12px 8px; font-size: 13px; color: #515a6e; font-weight: bold; text-align: center; }
|
||||
|
||||
.table-row {
|
||||
display: flex; flex-direction: row; border-bottom: 1px solid #e8eaec; align-items: center;
|
||||
&:hover { background-color: #fafafa; }
|
||||
}
|
||||
.td { padding: 12px 8px; text-align: center; display: flex; align-items: center; justify-content: center; }
|
||||
.td-txt { font-size: 13px; color: #515a6e; }
|
||||
.td-txt-bold { font-size: 14px; color: #333; font-weight: bold; }
|
||||
.td-txt-small { font-size: 12px; color: #999; }
|
||||
.color-orange { color: #ff9900; }
|
||||
|
||||
.cell-id { width: 60px; }
|
||||
.cell-user { flex: 1; justify-content: flex-start; }
|
||||
.cell-no { width: 200px; }
|
||||
.cell-price { width: 100px; }
|
||||
.cell-type { width: 100px; }
|
||||
.cell-status { width: 100px; }
|
||||
.cell-time { width: 160px; }
|
||||
|
||||
.u-info { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
||||
.u-avatar { width: 32px; height: 32px; border-radius: 16px; background: #f5f5f5; }
|
||||
.u-nick { font-size: 13px; color: #333; }
|
||||
|
||||
.status-tag {
|
||||
padding: 2px 8px; border-radius: 4px; font-size: 12px;
|
||||
&.paid { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
|
||||
&.unpaid { background: #fff7e6; color: #faad14; border: 1px solid #ffe7ba; }
|
||||
}.pagination-footer {
|
||||
margin-top: 24px; display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 12px;
|
||||
}
|
||||
.total-txt { font-size: 13px; color: #999; }
|
||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
||||
.p-btn {
|
||||
width: 28px; height: 28px; border: 1px solid #dcdfe6; border-radius: 4px;
|
||||
display: flex; align-items: center; justify-content: center; font-size: 14px;
|
||||
&.active { background: #1890ff; color: #fff; border-color: #1890ff; }
|
||||
&.disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
}
|
||||
.empty-row { padding: 60px 0; text-align: center; color: #999; }
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user