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>