sql数据流,amdin业务逻辑接入

This commit is contained in:
comlibmb
2026-02-15 16:37:37 +08:00
parent ec636dc703
commit e648ff0c22
43 changed files with 5412 additions and 1024 deletions

View File

@@ -4,19 +4,12 @@
<view class="filter-row">
<view class="filter-item">
<text class="label">活动搜索:</text>
<input class="input-mock" placeholder="请输入活动名称, ID" />
<input class="input-mock" placeholder="请输入活动名称, ID" v-model="searchQuery" @confirm="handleSearch" />
</view>
<view class="filter-item">
<text class="label">活动状态:</text>
<view class="select-mock">
<text class="select-val">请选择</text>
<text class="arrow">▼</text>
</view>
</view>
<view class="filter-item">
<text class="label">活动时段:</text>
<view class="select-mock">
<text class="select-val">请选择</text>
<text class="select-val">全部</text>
<text class="arrow">▼</text>
</view>
</view>
@@ -26,10 +19,10 @@
<text class="label">活动时间:</text>
<view class="date-picker-mock">
<text class="calendar-ic">📅</text>
<text class="date-placeholder">开始日期 - 结束日期</text>
<text class="date-placeholder">暂时使用默认范围</text>
</view>
</view>
<button class="btn-query">查询</button>
<button class="btn-query" @click="handleSearch">查询</button>
</view>
</view>
@@ -39,19 +32,26 @@
<view class="table-card border-shadow">
<view class="table-container">
<!-- Loading 遮罩 -->
<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-title">活动标题</view>
<view class="th cell-limit">单次限购</view>
<view class="th cell-total">总购买数量限制</view>
<view class="th cell-count">商品数</view>
<view class="th cell-period">活动时段</view>
<view class="th cell-time">活动时间</view>
<view class="th cell-total">总购</view>
<view class="th cell-count">商品数</view>
<view class="th cell-period">时段</view>
<view class="th cell-time">活动日期</view>
<view class="th cell-status">状态</view>
<view class="th cell-op">操作</view>
</view>
<view class="table-body">
<view v-if="seckillList.length === 0 && !isLoading" class="empty-row">
<text>暂无数据</text>
</view>
<view v-for="item in seckillList" :key="item.id" class="table-row">
<view class="td cell-id">
<text class="td-txt">{{ item.id }}</text>
@@ -74,8 +74,8 @@
</view>
</view>
<view class="td cell-time">
<text class="td-txt-small">开始: {{ item.start_date }}</text>
<text class="td-txt-small">结束: {{ item.end_date }}</text>
<text class="td-txt-small">{{ item.start_date.substring(0,10) }}</text>
<text class="td-txt-small">{{ item.end_date.substring(0,10) }}</text>
</view>
<view class="td cell-status">
<view class="switch-mock" :class="{ active: item.status }" @click="toggleStatus(item)">
@@ -96,23 +96,12 @@
<view class="pagination-footer">
<view class="page-total">
<text class="total-txt">共 {{ seckillList.length }} 条</text>
</view>
<view class="page-select">
<view class="select-mock mini">
<text class="select-val">15条/页</text>
<text class="arrow">▼</text>
</view>
<text class="total-txt">共 {{ total }} 条</text>
</view>
<view class="page-btns">
<text class="p-btn disabled"></text>
<text class="p-btn active">1</text>
<text class="p-btn disabled"></text>
</view>
<view class="page-jump">
<text class="jump-txt">前往</text>
<input class="jump-input" placeholder="1" />
<text class="jump-txt">页</text>
<text class="p-btn" :class="{ disabled: page <= 1 }" @click="onPrevPage"></text>
<text class="p-btn active">{{ page }}</text>
<text class="p-btn" :class="{ disabled: seckillList.length < pageSize }" @click="onNextPage"></text>
</view>
</view>
</view>
@@ -120,47 +109,90 @@
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
import { fetchSeckillActivities, deleteSeckillActivity, saveSeckillActivity, SeckillActivity } from '@/services/admin/marketingService.uts'
const seckillList = ref([
{
id: 91,
title: '秒杀活动',
single_limit: 1,
total_limit: 10,
product_count: 5,
time_range: '06:00-24:00',
start_date: '2025-07-01 00:00:00',
end_date: '2028-08-22 23:59:59',
status: true
const seckillList = ref<SeckillActivity[]>([])
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 fetchSeckillActivities({
search: searchQuery.value,
page: page.value,
pageSize: pageSize
})
seckillList.value = res.items
total.value = res.total
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
isLoading.value = false
}
])
const toggleStatus = (item: any) => {
item.status = !item.status
uni.showToast({ title: '修改成功', icon: 'success' })
}
const handleAdd = () => {
uni.showToast({ title: '添加活动功能开发中', icon: 'none' })
async function toggleStatus(item : SeckillActivity) {
if (item.id == null) return
const nextStatus = !item.status
const success = await saveSeckillActivity({ ...item, status: nextStatus } as SeckillActivity)
if (success) {
item.status = nextStatus
uni.showToast({ title: '修改成功', icon: 'success' })
}
}
const handleEdit = (item: any) => {
uni.showToast({ title: '编辑活动功能开发中', icon: 'none' })
function handleSearch() {
page.value = 1
loadData()
}
const handleDelete = (item: any) => {
function handleAdd() {
uni.showToast({ title: '添加功能开发中', icon: 'none' })
}
function handleEdit(item : SeckillActivity) {
uni.showToast({ title: '编辑功能开发中', icon: 'none' })
}
async function handleDelete(item : SeckillActivity) {
if (item.id == null) return
uni.showModal({
title: '提示',
content: '确定要删除该活动吗?',
success: (res) => {
success: async (res) => {
if (res.confirm) {
seckillList.value = seckillList.value.filter(i => i.id !== item.id)
uni.showToast({ title: '删除成功' })
const success = await deleteSeckillActivity(item.id!)
if (success) {
uni.showToast({ title: '删除成功' })
loadData()
}
}
}
})
}
function onPrevPage() {
if (page.value > 1) {
page.value--
loadData()
}
}
function onNextPage() {
if (seckillList.value.length >= pageSize) {
page.value++
loadData()
}
}
</script>
<style scoped lang="scss">