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

@@ -2,6 +2,11 @@
<view class="marketing-member-right">
<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-icon">权益图标</view>
@@ -13,20 +18,23 @@
</view>
<view class="table-body">
<view v-if="memberRights.length === 0 && !isLoading" class="empty-row">
<text>暂无权益配置</text>
</view>
<view v-for="item in memberRights" :key="item.id" class="table-row">
<view class="td cell-id"><text class="td-txt">{{ item.id }}</text></view>
<view class="td cell-icon">
<image class="right-icon" :src="item.icon" mode="aspectFit"></image>
<image class="right-icon" :src="item.icon_url || '/static/logo.png'" mode="aspectFit"></image>
</view>
<view class="td cell-name"><text class="td-txt">{{ item.name }}</text></view>
<view class="td cell-desc"><text class="td-txt">{{ item.desc }}</text></view>
<view class="td cell-desc"><text class="td-txt">{{ item.description || '-' }}</text></view>
<view class="td cell-status">
<view class="switch-mock" :class="{ active: item.is_show }" @click="toggleStatus(item)">
<view class="switch-dot"></view>
<text class="switch-txt">{{ item.is_show ? '显示' : '隐藏' }}</text>
</view>
</view>
<view class="td cell-sort"><text class="td-txt">{{ item.sort }}</text></view>
<view class="td cell-sort"><text class="td-txt">{{ item.sort_order }}</text></view>
<view class="td cell-op">
<text class="op-link" @click="handleEdit(item)">编辑</text>
</view>
@@ -38,20 +46,39 @@
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
import { fetchMemberRights, saveMemberRight, MemberRight } from '@/services/admin/marketingService.uts'
const memberRights = ref([
{ id: 9, icon: 'https://demo26.crmeb.net/uploads/attach/2021/11/20211115/a6f3b06e9d6d5a1b3c9d6d5a1b3c9d6d.png', name: '运费券', desc: '每月领取运费券', is_show: true, sort: 10 },
{ id: 8, icon: 'https://demo26.crmeb.net/uploads/attach/2021/11/20211115/a6f3b06e9d6d5a1b3c9d6d5a1b3c9d6d.png', name: '充值优惠', desc: '充值立减优惠', is_show: true, sort: 8 },
{ id: 7, icon: 'https://demo26.crmeb.net/uploads/attach/2021/11/20211115/a6f3b06e9d6d5a1b3c9d6d5a1b3c9d6d.png', name: '积分翻倍', desc: '购物获取双倍积分', is_show: true, sort: 7 }
])
const memberRights = ref<MemberRight[]>([])
const isLoading = ref(false)
const toggleStatus = (item: any) => {
item.is_show = !item.is_show
uni.showToast({ title: '修改成功', icon: 'success' })
onMounted(() => {
loadData()
})
async function loadData() {
isLoading.value = true
try {
const res = await fetchMemberRights()
memberRights.value = res
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
isLoading.value = false
}
}
const handleEdit = (item: any) => {
async function toggleStatus(item : MemberRight) {
if (item.id == null) return
const nextStatus = !item.is_show
const success = await saveMemberRight({ ...item, is_show: nextStatus } as MemberRight)
if (success) {
item.is_show = nextStatus
uni.showToast({ title: '修改成功', icon: 'success' })
}
}
const handleEdit = (item: MemberRight) => {
uni.showToast({ title: '编辑功能开发中', icon: 'none' })
}
</script>
@@ -136,6 +163,31 @@ const handleEdit = (item: any) => {
.switch-mock.active .switch-txt { margin-left: 4px; }
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
/* Loading & Empty Styles */
.table-container {
position: relative;
min-height: 300px;
}
.loading-mask {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background-color: rgba(255, 255, 255, 0.7);
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
.loading-text { color: #1890ff; font-size: 14px; }
.empty-row {
padding: 60px 0;
text-align: center;
color: #999;
font-size: 14px;
}
</style>