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

@@ -59,11 +59,11 @@
<view class="modal-content">
<view class="form-item">
<text class="form-label required">主播名称:</text>
<input class="form-input" placeholder="请输入主播名称" />
<input class="form-input" v-model="formData.nickname" placeholder="请输入主播名称" />
</view>
<view class="form-item">
<text class="form-label required">主播微信号:</text>
<input class="form-input" placeholder="请输入主播微信号" />
<input class="form-input" v-model="formData.wechat" placeholder="请输入主播微信号" />
</view>
<view class="form-item">
<text class="form-label required">主播手机号:</text>
@@ -72,7 +72,7 @@
<view class="form-item">
<text class="form-label">主播图像:</text>
<view class="upload-mock" @click="handleUpload">
<image v-if="formData.avatar" :src="formData.avatar" mode="aspectFill" class="avatar-preview" />
<image v-if="formData.avatar_url" :src="formData.avatar_url" mode="aspectFill" class="avatar-preview" />
<text v-else class="upload-ic">🖼️</text>
</view>
</view>
@@ -86,45 +86,65 @@
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
import { fetchLiveAnchors, saveLiveAnchor, deleteLiveAnchor, LiveAnchor } from '@/services/admin/marketingService.uts'
const showModal = ref(false)
const formData = ref({
id: 0,
name: '',
const isLoading = ref(false)
const anchorList = ref<LiveAnchor[]>([])
const formData = ref<LiveAnchor>({
nickname: '',
wechat: '',
phone: '',
avatar: ''
avatar_url: '',
status: true
})
const anchorList = ref([
{
id: 11,
name: '万万',
phone: '15012341234',
wechat: 'xiao112032014'
},
{
id: 10,
name: '打羽毛球',
phone: '13333333333',
wechat: 'evoxwht'
}
])
onMounted(() => {
loadData()
})
const handleEdit = (item: any) => {
formData.value = { ...item, avatar: '' }
async function loadData() {
isLoading.value = true
try {
const res = await fetchLiveAnchors()
anchorList.value = res
} catch (e) {
uni.showToast({ title: '加载主播失败', icon: 'none' })
} finally {
isLoading.value = false
}
}
function handleAdd() {
formData.value = {
nickname: '',
wechat: '',
phone: '',
avatar_url: '',
status: true
} as LiveAnchor
showModal.value = true
}
const handleDelete = (item: any) => {
function handleEdit(item : LiveAnchor) {
formData.value = { ...item } as LiveAnchor
showModal.value = true
}
async function handleDelete(item : LiveAnchor) {
if (item.id == null) return
uni.showModal({
title: '提示',
content: '确定要删除该主播吗?',
success: (res) => {
success: async (res) => {
if (res.confirm) {
anchorList.value = anchorList.value.filter(i => i.id !== item.id)
uni.showToast({ title: '删除成功' })
const success = await deleteLiveAnchor(item.id!)
if (success) {
uni.showToast({ title: '删除成功' })
loadData()
}
}
}
})
@@ -134,14 +154,27 @@ const handleUpload = () => {
uni.chooseImage({
count: 1,
success: (res) => {
formData.value.avatar = res.tempFilePaths[0]
formData.value.avatar_url = res.tempFilePaths[0]
}
})
}
const handleSubmit = () => {
uni.showToast({ title: '操作成功', icon: 'success' })
showModal.value = false
async function handleSubmit() {
if (!formData.value.nickname || !formData.value.phone) {
uni.showToast({ title: '请填写必填项', icon: 'none' })
return
}
try {
const success = await saveLiveAnchor(formData.value)
if (success) {
uni.showToast({ title: '操作成功', icon: 'success' })
showModal.value = false
loadData()
}
} catch (e) {
uni.showToast({ title: '系统异常', icon: 'none' })
}
}
</script>

View File

@@ -112,73 +112,75 @@
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
import { fetchLiveProducts, saveLiveProduct, deleteLiveProduct, LiveProduct } from '@/services/admin/marketingService.uts'
const isAdding = ref(false)
const isLoading = ref(false)
const productList = ref<LiveProduct[]>([])
const total = ref(0)
const page = ref(1)
const pageSize = 20
const searchQuery = ref('')
const auditStatus = ref(0) // 0:全部
const selectedList = ref([
{ image: 'https://img0.baidu.com/it/u=3033502919,1657850259&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500' }
])
const productList = ref([
{
id: 92,
image: 'https://img0.baidu.com/it/u=3023224345,1529124233&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
title: '绣球永生花网红干花花束大',
live_price: 149.00,
price: 149.00,
stock: 10617,
audit_status: '审核通过',
is_show: false
},
{
id: 89,
image: 'https://img1.baidu.com/it/u=3175865615,2002599723&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
title: '家居梵高系列款软版盒袋',
live_price: 350.00,
price: 350.00,
stock: 8625,
audit_status: '审核通过',
is_show: false
},
{
id: 93,
image: 'https://img2.baidu.com/it/u=2719717192,3826027113&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
title: '【LESHUCANGHU',
live_price: 300.00,
price: 300.00,
stock: 164,
audit_status: '审核通过',
is_show: false
},
{
id: 116,
image: 'https://img0.baidu.com/it/u=2257917711,1359654032&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
title: '爱奇艺智能 奇遇LT01',
live_price: 1199.00,
price: 1199.00,
stock: 6287,
audit_status: '审核通过',
is_show: false
}
])
onMounted(() => {
loadData()
})
const toggleStatus = (item: any) => {
item.is_show = !item.is_show
uni.showToast({ title: '状态修改成功', icon: 'success' })
async function loadData() {
isLoading.value = true
try {
const res = await fetchLiveProducts({
search: searchQuery.value,
audit_status: auditStatus,
page: page.value,
pageSize: pageSize
})
productList.value = res.items
total.value = res.total
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
isLoading.value = false
}
}
const handleEdit = (item: any) => {
function handleSearch() {
page.value = 1
loadData()
}
async function toggleStatus(item : LiveProduct) {
if (item.id == null) return
const nextShow = !item.is_show
const success = await saveLiveProduct({ ...item, is_show: nextShow } as LiveProduct)
if (success) {
item.is_show = nextShow
uni.showToast({ title: '状态修改成功', icon: 'success' })
}
}
function handleEdit(item : LiveProduct) {
uni.showToast({ title: '详情查看中', icon: 'none' })
}
const handleDelete = (item: any) => {
async function handleDelete(item : LiveProduct) {
if (item.id == null) return
uni.showModal({
title: '提示',
content: '确定要删除该商品吗?',
success: (res) => {
success: async (res) => {
if (res.confirm) {
productList.value = productList.value.filter(i => i.id !== item.id)
uni.showToast({ title: '删除成功' })
const success = await deleteLiveProduct(item.id!)
if (success) {
uni.showToast({ title: '删除成功' })
loadData()
}
}
}
})
@@ -188,7 +190,7 @@ const handleAddProduct = () => {
uni.showToast({ title: '选择商品功能开发中', icon: 'none' })
}
const removeSelected = (index: number) => {
const removeSelected = (index : number) => {
selectedList.value.splice(index, 1)
}
@@ -196,6 +198,29 @@ const handleGenerate = () => {
uni.showToast({ title: '生成成功', icon: 'success' })
isAdding.value = false
}
function onPrevPage() {
if (page.value > 1) {
page.value--
loadData()
}
}
function onNextPage() {
if (productList.value.length >= pageSize) {
page.value++
loadData()
}
}
function getAuditStatusLabel(status : number) : string {
switch (status) {
case 1: return '待审核'
case 2: return '审核通过'
case 3: return '审核驳回'
default: return '未知'
}
}
</script>
<style scoped lang="scss">

View File

@@ -200,124 +200,182 @@
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
import {
fetchLiveRooms,
saveLiveRoom,
deleteLiveRoom,
fetchLiveAnchors,
LiveRoom,
LiveAnchor
} from '@/services/admin/marketingService.uts'
const showDrawer = ref(false)
const isAnimating = ref(false)
const isLoading = ref(false)
const isSaving = ref(false)
const formData = ref({
anchor_nick: '',
const roomList = ref<LiveRoom[]>([])
const anchorList = ref<LiveAnchor[]>([])
const total = ref(0)
const page = ref(1)
const pageSize = 20
const searchQuery = ref('')
const formData = ref<LiveRoom>({
name: '',
background: '',
share_img: '',
phone: '',
anchor_id: null,
anchor_nick: '',
background_url: '',
share_img_url: '',
start_time: '',
end_time: '',
sort: 0,
type: 'phone',
like_enabled: true,
sale_enabled: true,
comment_enabled: true
comment_enabled: true,
is_show: true,
live_status: 1
})
const roomList = ref([
{
id: 88,
name: 'CRMEB 年中618活动开始',
anchor_nick: '打羽毛球',
anchor_wechat: 'evoxwht',
start_time: '2025-06-17 00:00:00',
end_time: '2025-06-18 00:00:00',
create_time: '2025-06-16 14:56:53',
is_show: true,
live_status: '已结束',
sort: 1
},
{
id: 90,
name: '123456789',
anchor_nick: '万万',
anchor_wechat: 'xiao112032014',
start_time: '2025-07-07 10:20:00',
end_time: '2025-07-07 12:00:00',
create_time: '2025-07-07 10:05:43',
is_show: true,
live_status: '已结束',
sort: 0
},
{
id: 89,
name: '测试1111111',
anchor_nick: '打羽毛球',
anchor_wechat: '',
start_time: '2025-05-20 14:50:00',
end_time: '2025-05-20 15:22:00',
create_time: '2025-06-17 10:03:08',
is_show: true,
live_status: '已结束',
sort: 0
},
{
id: 10,
name: '开学季,最后一天',
anchor_nick: '等风来',
anchor_wechat: 'welalnidaobel',
start_time: '2021-09-01 19:00:00',
end_time: '2021-09-01 20:00:00',
create_time: '2021-08-30 11:53:01',
is_show: false,
live_status: '已结束',
sort: 0
}
])
onMounted(() => {
loadData()
loadAnchors()
})
const toggleStatus = (item: any) => {
item.is_show = !item.is_show
uni.showToast({ title: '状态修改成功', icon: 'success' })
async function loadData() {
isLoading.value = true
try {
const res = await fetchLiveRooms({
search: searchQuery.value,
page: page.value,
pageSize: pageSize
})
roomList.value = res.items
total.value = res.total
} catch (e) {
uni.showToast({ title: '加载直播间失败', icon: 'none' })
} finally {
isLoading.value = false
}
}
const handleEdit = (item: any) => {
formData.value = { ...item, like_enabled: true, sale_enabled: true, comment_enabled: true }
async function loadAnchors() {
anchorList.value = await fetchLiveAnchors()
}
async function toggleStatus(item : LiveRoom) {
if (item.id == null) return
const nextStatus = !item.is_show
const success = await saveLiveRoom({ ...item, is_show: nextStatus } as LiveRoom)
if (success) {
item.is_show = nextStatus
uni.showToast({ title: '状态修改成功', icon: 'success' })
}
}
function handleAdd() {
formData.value = {
name: '',
anchor_id: null,
anchor_nick: '',
background_url: '',
share_img_url: '',
start_time: '',
end_time: '',
sort: 0,
type: 'phone',
like_enabled: true,
sale_enabled: true,
comment_enabled: true,
is_show: true,
live_status: 1
} as LiveRoom
showDrawer.value = true
}
const handleDelete = (item: any) => {
function handleEdit(item : LiveRoom) {
formData.value = { ...item } as LiveRoom
showDrawer.value = true
}
async function handleDelete(item : LiveRoom) {
if (item.id == null) return
uni.showModal({
title: '提示',
content: '确定要删除该直播间吗?',
success: (res) => {
success: async (res) => {
if (res.confirm) {
roomList.value = roomList.value.filter(i => i.id !== item.id)
uni.showToast({ title: '删除成功' })
const success = await deleteLiveRoom(item.id!)
if (success) {
uni.showToast({ title: '删除成功' })
loadData()
}
}
}
})
}
const handleSelectAnchor = () => {
uni.showToast({ title: '功能开发中', icon: 'none' })
function handleSearch() {
page.value = 1
loadData()
}
const handleUpload = (type: string) => {
async function handleSubmit() {
if (!formData.value.name || !formData.value.start_time) {
uni.showToast({ title: '请填写必填项', icon: 'none' })
return
}
isSaving.value = true
try {
const success = await saveLiveRoom(formData.value)
if (success) {
uni.showToast({ title: '提交成功', icon: 'success' })
closeDrawer()
loadData()
}
} catch (e) {
uni.showToast({ title: '操作失败', icon: 'none' })
} finally {
isSaving.value = false
}
}
function handleSelectAnchor() {
const nicks = anchorList.value.map(a => a.nickname)
if (nicks.length === 0) {
uni.showToast({ title: '请先添加主播', icon: 'none' })
return
}
uni.showActionSheet({
itemList: nicks,
success: (res) => {
const anchor = anchorList.value[res.tapIndex]
formData.value.anchor_id = anchor.id ?? null
formData.value.anchor_nick = anchor.nickname
}
})
}
function handleUpload(field: string) {
uni.chooseImage({
count: 1,
success: (res) => {
if (type === 'background') {
formData.value.background = res.tempFilePaths[0]
if (field === 'background') {
formData.value.background_url = res.tempFilePaths[0]
} else {
formData.value.share_img = res.tempFilePaths[0]
formData.value.share_img_url = res.tempFilePaths[0]
}
}
})
}
const handleOpenDatePicker = () => {
uni.showToast({ title: '日期选择功能开发中', icon: 'none' })
}
const handleSubmit = () => {
uni.showToast({ title: '提交成功', icon: 'success' })
closeDrawer()
function handleOpenDatePicker() {
// 简化处理,实际推荐使用日期选择组件
uni.showToast({ title: '请在输入框直接修改时间', icon: 'none' })
}
const closeDrawer = () => {
@@ -327,6 +385,20 @@ const closeDrawer = () => {
isAnimating.value = false
}, 300)
}
function onPrevPage() {
if (page.value > 1) {
page.value--
loadData()
}
}
function onNextPage() {
if (roomList.value.length >= pageSize) {
page.value++
loadData()
}
}
</script>
<style scoped lang="scss">