添加接口

This commit is contained in:
李志鹏
2025-10-23 15:11:24 +08:00
parent ac5abc454d
commit 73525c3803
10 changed files with 378 additions and 129 deletions

View File

@@ -4,7 +4,10 @@
import FooterNavigation from '@/components/FooterNavigation.vue'
import MyList from '@/components/myList.vue'
import router from '@/router'
import { FormatDate } from '@/utils/tools'
import { getCustomerPhotos, deleteCustomerPhoto } from '@/api/workshop'
const emit = defineEmits(['view-type'])
import { showConfirmDialog } from 'vant'
onMounted(() => {
emit('view-type', 1)
@@ -15,26 +18,50 @@
const onLoad = () => {
loading.value = true
setTimeout(() => {
for (var i = 0; i < 10; i++) {
list.push({
id: list.length + 1,
userID: 10000000 + list.length,
datetime: '7/22/2025 18:20',
lastopened: '18:20'
const customerId = '123123123'
getCustomerPhotos(customerId)
.then((data) => {
data?.forEach((v) => {
const obj = {
visitRecordId: v.visitRecordId,
defaultImageUrl: v.defaultImageUrl,
datetime: FormatDate(v.visitTime, 'dd-MM-yyyy HH:mm'),
lastopened: FormatDate(v.visitTime, 'HH:mm')
}
list.push(obj)
})
}
loading.value = false
if (list.length >= 50) finish.value = true
}, 500)
loading.value = false
finish.value = true
})
.catch((err) => {
console.error(err)
loading.value = false
finish.value = false
})
}
// 删除项
const deleteItem = async (obj: any, i: number) => {
const res = await showConfirmDialog({
title: 'Delete',
message: 'Are you sure you want to delete this item?',
confirmButtonText: 'Yes',
cancelButtonText: 'Cancel'
}).catch(() => 0)
if (res === 0) return
console.log(obj,i)
deleteCustomerPhoto(obj.visitRecordId)
.then(() => {
list.splice(i, 1)
console.log('删除成功')
})
.catch((err) => {
console.error(err)
})
}
// 详情项
const onDetailsItem = (v) => {
// console.log('检索' + i)
router.push({ name: 'creation', query: { date: v.datetime } })
}
const deleteItem = (i: number) => {
list.splice(i, 1)
router.push({ name: 'creation', query: { visitRecordId: v.visitRecordId } })
}
</script>
@@ -44,9 +71,9 @@
<div class="title">Library</div>
<div class="list">
<my-list v-model:loading="loading" v-model:finish="finish" @load="onLoad">
<div class="item" v-for="(v, i) in list" :key="v.id">
<div class="item" v-for="(v, i) in list" :key="v.visitRecordId">
<div class="image">
<img src="@/assets/images/workshop/posture/posture_1.png" />
<img :src="v.defaultImageUrl" />
</div>
<div class="content">
<!-- <span class="userID">User ID: {{ v.userID }}</span> -->
@@ -54,7 +81,7 @@
<span class="lastopened">Last opened {{ v.lastopened }}</span>
<button @click="onDetailsItem(v)">Details</button>
</div>
<div class="delete" @click="deleteItem(i)"><SvgIcon name="delete2" size="30" /></div>
<div class="delete" @click="deleteItem(v, i)"><SvgIcon name="delete2" size="30" /></div>
</div>
</my-list>
</div>