sql数据流,amdin业务逻辑接入
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user