补充数据库数据,修改分类栏内容
This commit is contained in:
@@ -201,6 +201,15 @@ const currentCategoryDesc = ref('')
|
||||
// 页面参数
|
||||
const pageParams = ref<any>({})
|
||||
|
||||
function normalizeSelectedMedicalCategoryId(categoryId: string): string {
|
||||
if (categoryId == 'device') return 'med_device'
|
||||
if (categoryId == 'external') return 'home_care_daily'
|
||||
if (categoryId == 'cold') return 'otc_medicine'
|
||||
if (categoryId == 'medicine') return 'otc_medicine'
|
||||
if (categoryId == 'care') return 'home_care_daily'
|
||||
return categoryId
|
||||
}
|
||||
|
||||
function getProductCover(product: Product): string {
|
||||
if (product.main_image_url != null && product.main_image_url !== '') return product.main_image_url
|
||||
if (product.images != null && product.images.length > 0 && product.images[0] !== '') return product.images[0]
|
||||
@@ -272,7 +281,7 @@ async function loadProducts(): Promise<void> {
|
||||
loading.value = true
|
||||
try {
|
||||
console.log('开始加载商品,分类ID:', activePrimary.value, '页码:', currentPage.value)
|
||||
const response = await supabaseService.getProductsByCategory(activePrimary.value, currentPage.value)
|
||||
const response = await supabaseService.getMedicalMallProductsByCategory(activePrimary.value, currentPage.value, 20)
|
||||
console.log('商品加载结果:', {
|
||||
dataCount: response.data.length,
|
||||
total: response.total,
|
||||
@@ -324,7 +333,7 @@ async function loadProducts(): Promise<void> {
|
||||
async function loadSubCategories(parentId: string): Promise<void> {
|
||||
console.log('加载二级分类,父级ID:', parentId)
|
||||
try {
|
||||
const subCats = await supabaseService.getSubCategories(parentId)
|
||||
const subCats = await supabaseService.getMedicalMallSubCategories(parentId)
|
||||
console.log('获取到二级分类数量:', subCats.length)
|
||||
|
||||
const categories: LocalCategory[] = []
|
||||
@@ -379,9 +388,10 @@ async function selectSubCategory(subCategoryId: string): Promise<void> {
|
||||
// originalCategoryId: 可能是一级分类ID,也可能是二级分类ID
|
||||
async function selectPrimaryCategory(originalCategoryId: string): Promise<void> {
|
||||
console.log('=== selectPrimaryCategory函数开始执行 ===')
|
||||
console.log('传入的categoryId:', originalCategoryId)
|
||||
const normalizedCategoryId = normalizeSelectedMedicalCategoryId(originalCategoryId)
|
||||
console.log('传入的categoryId:', originalCategoryId, '归一化后:', normalizedCategoryId)
|
||||
|
||||
if (originalCategoryId == '') {
|
||||
if (normalizedCategoryId == '') {
|
||||
console.error('categoryId为空,尝试使用第一个分类')
|
||||
if (primaryCategories.value.length > 0) {
|
||||
originalCategoryId = primaryCategories.value[0].id
|
||||
@@ -397,8 +407,9 @@ async function selectPrimaryCategory(originalCategoryId: string): Promise<void>
|
||||
console.log('当前一级分类列表长度:', primaryCategories.value.length)
|
||||
let foundInPrimary: LocalCategory | null = null
|
||||
for (let i = 0; i < primaryCategories.value.length; i++) {
|
||||
if (primaryCategories.value[i].id == originalCategoryId) {
|
||||
if (primaryCategories.value[i].id == normalizedCategoryId) {
|
||||
foundInPrimary = primaryCategories.value[i]
|
||||
targetParentId = normalizedCategoryId
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -410,7 +421,7 @@ async function selectPrimaryCategory(originalCategoryId: string): Promise<void>
|
||||
|
||||
// 从服务器获取分类信息以确定父级
|
||||
try {
|
||||
const categoryInfo = await supabaseService.getCategoryById(originalCategoryId)
|
||||
const categoryInfo = await supabaseService.getMedicalMallCategoryById(normalizedCategoryId)
|
||||
if (categoryInfo != null && categoryInfo.parent_id != null && categoryInfo.parent_id != '') {
|
||||
console.log('找到父级分类ID:', categoryInfo.parent_id)
|
||||
|
||||
@@ -427,7 +438,7 @@ async function selectPrimaryCategory(originalCategoryId: string): Promise<void>
|
||||
if (parentInPrimary != null) {
|
||||
console.log('父级分类在列表中找到:', parentInPrimary.name)
|
||||
targetParentId = categoryInfo.parent_id!
|
||||
targetSubId = originalCategoryId // 记住要选中的二级分类
|
||||
targetSubId = normalizedCategoryId // 记住要选中的二级分类
|
||||
} else {
|
||||
console.log('父级分类不在列表中,使用第一个分类')
|
||||
// 打印当前列表中的所有分类ID
|
||||
@@ -530,21 +541,13 @@ async function selectPrimaryCategory(originalCategoryId: string): Promise<void>
|
||||
|
||||
async function loadCategories(): Promise<void> {
|
||||
try {
|
||||
// 只获取一级分类(parent_id 为 null 的分类)
|
||||
const categoriesData = await supabaseService.getParentCategories()
|
||||
const categoriesData = await supabaseService.getMedicalMallParentCategories()
|
||||
console.log('加载一级分类数据成功,数量:', categoriesData.length)
|
||||
|
||||
// 映射数据并添加默认颜色,防止选中时背景透明导致文字看不清
|
||||
// 过滤掉医药健康相关分类
|
||||
const categories: LocalCategory[] = []
|
||||
for (let i = 0; i < categoriesData.length; i++) {
|
||||
const cat = categoriesData[i]
|
||||
const name = cat.name
|
||||
console.log('一级分类:', cat.id, name)
|
||||
if (name.includes('医药') || name.includes('健康')) {
|
||||
console.log('过滤掉分类:', name)
|
||||
continue
|
||||
}
|
||||
console.log('一级分类:', cat.id, cat.name)
|
||||
categories.push({
|
||||
id: cat.id,
|
||||
name: cat.name,
|
||||
@@ -572,16 +575,16 @@ async function loadCategories(): Promise<void> {
|
||||
// 检查是否有预设的分类ID
|
||||
if (activePrimary.value != '') {
|
||||
console.log('有预设的分类ID:', activePrimary.value)
|
||||
const target = categories.find((c: LocalCategory): boolean => c.id == activePrimary.value)
|
||||
const normalizedCategoryId = normalizeSelectedMedicalCategoryId(activePrimary.value)
|
||||
const target = categories.find((c: LocalCategory): boolean => c.id == normalizedCategoryId)
|
||||
if (target != null) {
|
||||
console.log('找到目标分类,执行选中:', target.name)
|
||||
selectPrimaryCategory(activePrimary.value)
|
||||
selectPrimaryCategory(normalizedCategoryId)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 默认选中第一个分类或"厨具"分类
|
||||
const defaultCategory = categories.find((c: LocalCategory): boolean => c.name.includes('厨具')) ?? categories[0]
|
||||
const defaultCategory = categories.find((c: LocalCategory): boolean => c.id == 'all_medical') ?? categories[0]
|
||||
if (defaultCategory != null) {
|
||||
console.log('设置默认分类:', defaultCategory.name)
|
||||
selectPrimaryCategory(defaultCategory.id)
|
||||
@@ -622,7 +625,7 @@ onShow(() => {
|
||||
console.log('onShow检查Storage:', savedCategoryId)
|
||||
|
||||
if (savedCategoryId != null && savedCategoryId != '') {
|
||||
const targetId = savedCategoryId as string
|
||||
const targetId = normalizeSelectedMedicalCategoryId(savedCategoryId as string)
|
||||
console.log('onShow发现存储的分类ID:', targetId)
|
||||
|
||||
// 清除存储,避免下次进入默认选中
|
||||
@@ -679,7 +682,7 @@ onLoad((options: any) => {
|
||||
const optObj = (options instanceof UTSJSONObject) ? (options as UTSJSONObject) : (JSON.parse(JSON.stringify(options ?? {})) as UTSJSONObject)
|
||||
const optCategoryId = optObj.getString('categoryId') ?? ''
|
||||
if (optCategoryId !== '') {
|
||||
categoryId = optCategoryId
|
||||
categoryId = normalizeSelectedMedicalCategoryId(optCategoryId)
|
||||
categoryName = optObj.getString('name') ?? ''
|
||||
console.log('✅ onLoad中找到分类参数:', categoryId, categoryName)
|
||||
}
|
||||
@@ -694,7 +697,7 @@ onLoad((options: any) => {
|
||||
const pageOptObj = (rawPageOptions instanceof UTSJSONObject) ? (rawPageOptions as UTSJSONObject) : (JSON.parse(JSON.stringify(rawPageOptions)) as UTSJSONObject)
|
||||
const pageCategoryId = pageOptObj.getString('categoryId') ?? ''
|
||||
if (pageCategoryId !== '') {
|
||||
categoryId = pageCategoryId
|
||||
categoryId = normalizeSelectedMedicalCategoryId(pageCategoryId)
|
||||
categoryName = pageOptObj.getString('name') ?? ''
|
||||
console.log('✅ 从getCurrentPages()找到分类参数:', categoryId, categoryName)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<scroll-view
|
||||
class="category-scroll"
|
||||
direction="horizontal"
|
||||
:scroll-x="true"
|
||||
:show-scrollbar="false"
|
||||
:scroll-with-animation="true"
|
||||
:scroll-into-view="categoryScrollIntoView"
|
||||
@@ -66,6 +67,8 @@
|
||||
:loading="loading"
|
||||
:has-more="hasMore"
|
||||
:show-load-more="showLoadMore"
|
||||
:empty-state-title="homeEmptyStateTitle"
|
||||
:empty-state-description="homeEmptyStateDescription"
|
||||
@secondary-category-click="handleSecondaryCategoryClick"
|
||||
@select-channel="navigateToChannel"
|
||||
@select-simple-channel="navigateToSimpleChannel"
|
||||
@@ -285,7 +288,7 @@ const headerSearchPlaceholder = computed((): string => {
|
||||
if (activeTopModule.value == 'service') {
|
||||
return '居家护理 / 康复照护 / 血压计 / 助餐服务'
|
||||
}
|
||||
return currentPlaceholderKeyword.value != '' ? currentPlaceholderKeyword.value : '感冒药 / 康复护理 / 居家护理 / 血压计'
|
||||
return currentPlaceholderKeyword.value != '' ? currentPlaceholderKeyword.value : '血压计 / 血糖仪 / 制氧机 / 维生素'
|
||||
})
|
||||
|
||||
type HomeCareCategoryType = {
|
||||
@@ -641,11 +644,16 @@ const showSubCategories = ref(false)
|
||||
|
||||
// 首页占位词轮播相关
|
||||
const placeholderKeywords = ref([
|
||||
'neo2无人机',
|
||||
'华为mate50',
|
||||
'血压计',
|
||||
'血糖仪',
|
||||
'体温计',
|
||||
'制氧机',
|
||||
'口罩',
|
||||
'创可贴',
|
||||
'维生素',
|
||||
'钙片',
|
||||
'感冒药',
|
||||
'维生素C',
|
||||
'康复护具',
|
||||
'护理床',
|
||||
|
||||
])
|
||||
const currentPlaceholderIndex = ref(0)
|
||||
@@ -655,6 +663,20 @@ const placeholderAnimating = ref(false)
|
||||
let placeholderTimer: number = 0
|
||||
let placeholderAnimationTimer: number = 0
|
||||
|
||||
const homeEmptyStateTitle = computed((): string => {
|
||||
if (currentFeedCategoryId.value == 'recommend') {
|
||||
return '康养医疗商品正在完善中'
|
||||
}
|
||||
return '当前分类暂无商品'
|
||||
})
|
||||
|
||||
const homeEmptyStateDescription = computed((): string => {
|
||||
if (currentFeedCategoryId.value == 'recommend') {
|
||||
return '可先查看居家服务或稍后再试'
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
const syncNextPlaceholderKeyword = () => {
|
||||
const total = placeholderKeywords.value.length
|
||||
if (total <= 1) {
|
||||
@@ -1114,7 +1136,7 @@ const handleSecondaryCategoryClick = async (category: Category): Promise<void> =
|
||||
hasMore.value = true
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await supabaseService.getProductsByCategory(category.id, 1, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallProductsByCategory(category.id, 1, defaultLoadLimit)
|
||||
failedProductImageIds.value = []
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
@@ -1165,9 +1187,9 @@ const healthNews = [
|
||||
]
|
||||
|
||||
// 获取一级分类数据
|
||||
const loadCategories = async (): Promise<void> => {
|
||||
const loadMedicalMallCategories = async (): Promise<void> => {
|
||||
try {
|
||||
const categoriesData = await supabaseService.getParentCategories()
|
||||
const categoriesData = await supabaseService.getMedicalMallParentCategories()
|
||||
parentCategories.value = categoriesData
|
||||
// 兼容其他使用 categories 的地方
|
||||
categories.value = categoriesData
|
||||
@@ -1190,7 +1212,7 @@ const loadCategories = async (): Promise<void> => {
|
||||
async function loadSubCategories(parentId: string): Promise<void> {
|
||||
try {
|
||||
console.log('[loadSubCategories] 开始加载二级分类, parentId:', parentId)
|
||||
const subData = await supabaseService.getSubCategories(parentId)
|
||||
const subData = await supabaseService.getMedicalMallSubCategories(parentId)
|
||||
console.log('[loadSubCategories] 获取到二级分类数量:', subData.length)
|
||||
console.log('[loadSubCategories] 二级分类数据:', JSON.stringify(subData))
|
||||
subCategories.value = subData
|
||||
@@ -1315,6 +1337,15 @@ function getCategoryLabelById(categoryId: string): string {
|
||||
return '精选'
|
||||
}
|
||||
|
||||
function normalizeSelectedMedicalCategoryId(categoryId: string): string {
|
||||
if (categoryId == 'device') return 'med_device'
|
||||
if (categoryId == 'external') return 'home_care_daily'
|
||||
if (categoryId == 'cold') return 'otc_medicine'
|
||||
if (categoryId == 'medicine') return 'otc_medicine'
|
||||
if (categoryId == 'care') return 'home_care_daily'
|
||||
return categoryId
|
||||
}
|
||||
|
||||
async function consumeSelectedCategoryFromStorage(): Promise<boolean> {
|
||||
if (activeTopModule.value != 'home' || categoryList.value.length == 0) {
|
||||
return false
|
||||
@@ -1328,14 +1359,15 @@ async function consumeSelectedCategoryFromStorage(): Promise<boolean> {
|
||||
return false
|
||||
}
|
||||
uni.removeStorageSync('selectedCategory')
|
||||
const matchedItem = categoryList.value.find((item: CategoryItem): boolean => item.id == nextCategoryId)
|
||||
const normalizedCategoryId = normalizeSelectedMedicalCategoryId(nextCategoryId)
|
||||
const matchedItem = categoryList.value.find((item: CategoryItem): boolean => item.id == normalizedCategoryId)
|
||||
if (matchedItem != null) {
|
||||
await refreshHomeCategory(matchedItem)
|
||||
return true
|
||||
}
|
||||
await refreshHomeCategory({
|
||||
id: nextCategoryId,
|
||||
name: getCategoryLabelById(nextCategoryId)
|
||||
id: normalizedCategoryId,
|
||||
name: getCategoryLabelById(normalizedCategoryId)
|
||||
})
|
||||
return true
|
||||
}
|
||||
@@ -1364,17 +1396,17 @@ const fetchSortedProductsPage = async (page: number, limit: number): Promise<Pag
|
||||
console.log('加载热销商品,当前排序方式:', activeSort.value, 'page:', page, 'limit:', limit)
|
||||
switch (activeSort.value) {
|
||||
case 'sales':
|
||||
console.log('调用 getProductsBySales')
|
||||
return await supabaseService.getProductsBySales(page, limit)
|
||||
console.log('调用 getMedicalMallSmartRecommendations(sales-fallback)')
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
case 'price':
|
||||
console.log('调用 getProductsByPrice, 升序:', priceAscending.value)
|
||||
return await supabaseService.getProductsByPrice(page, limit, priceAscending.value)
|
||||
console.log('调用 getMedicalMallSmartRecommendations(price-fallback), 升序:', priceAscending.value)
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
case 'new':
|
||||
console.log('调用 getProductsByNewest')
|
||||
return await supabaseService.getProductsByNewest(page, limit)
|
||||
console.log('调用 getMedicalMallSmartRecommendations(new-fallback)')
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
case 'recommend':
|
||||
console.log('调用 getSmartRecommendations')
|
||||
return await supabaseService.getSmartRecommendations(page, limit)
|
||||
console.log('调用 getMedicalMallSmartRecommendations')
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
case 'discount': {
|
||||
console.log('调用 getDiscountProducts')
|
||||
const products = await supabaseService.getDiscountProducts(limit)
|
||||
@@ -1387,8 +1419,8 @@ const fetchSortedProductsPage = async (page: number, limit: number): Promise<Pag
|
||||
}
|
||||
}
|
||||
default:
|
||||
console.log('调用默认 getProductsBySales')
|
||||
return await supabaseService.getProductsBySales(page, limit)
|
||||
console.log('调用默认 getMedicalMallSmartRecommendations')
|
||||
return await supabaseService.getMedicalMallSmartRecommendations(page, limit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1427,7 +1459,7 @@ async function syncCategoryLayout(categoryId: string): Promise<void> {
|
||||
}
|
||||
|
||||
try {
|
||||
const subData = await supabaseService.getSubCategories(categoryId)
|
||||
const subData = await supabaseService.getMedicalMallSubCategories(categoryId)
|
||||
subCategories.value = subData
|
||||
} catch (error) {
|
||||
console.error('加载子分类数据失败:', error)
|
||||
@@ -1444,33 +1476,7 @@ async function loadCategoryGoods(categoryId: string): Promise<void> {
|
||||
await syncCategoryLayout(categoryId)
|
||||
if (categoryId === 'recommend') {
|
||||
try {
|
||||
let result: PaginatedResponse<Product>
|
||||
switch (activeSort.value) {
|
||||
case 'sales':
|
||||
result = await supabaseService.getProductsBySales(1, defaultLoadLimit)
|
||||
break
|
||||
case 'price':
|
||||
result = await supabaseService.getProductsByPrice(1, defaultLoadLimit, priceAscending.value)
|
||||
break
|
||||
case 'new':
|
||||
result = await supabaseService.getProductsByNewest(1, defaultLoadLimit)
|
||||
break
|
||||
case 'discount': {
|
||||
const products = await supabaseService.getDiscountProducts(defaultLoadLimit)
|
||||
result = {
|
||||
data: products,
|
||||
total: products.length,
|
||||
page: 1,
|
||||
limit: defaultLoadLimit,
|
||||
hasmore: false
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'recommend':
|
||||
default:
|
||||
result = await supabaseService.getSmartRecommendations(1, defaultLoadLimit)
|
||||
break
|
||||
}
|
||||
const result = await supabaseService.getMedicalMallSmartRecommendations(1, defaultLoadLimit)
|
||||
failedProductImageIds.value = []
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
@@ -1483,7 +1489,7 @@ async function loadCategoryGoods(categoryId: string): Promise<void> {
|
||||
} else {
|
||||
try {
|
||||
loading.value = true
|
||||
const result = await supabaseService.getProductsByCategory(categoryId, 1, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallProductsByCategory(categoryId, 1, defaultLoadLimit)
|
||||
failedProductImageIds.value = []
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
@@ -1514,7 +1520,7 @@ async function refreshHomeCategory(item: CategoryItem): Promise<void> {
|
||||
secondaryCategoryDisplay.value = buildSecondaryCategoryDisplay(item.id)
|
||||
applyChannelDisplay(item.id)
|
||||
try {
|
||||
const result = await supabaseService.getSmartRecommendations(1, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallSmartRecommendations(1, defaultLoadLimit)
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
} catch (error) {
|
||||
@@ -1528,7 +1534,7 @@ async function refreshHomeCategory(item: CategoryItem): Promise<void> {
|
||||
}
|
||||
|
||||
try {
|
||||
const subData = await supabaseService.getSubCategories(item.id)
|
||||
const subData = await supabaseService.getMedicalMallSubCategories(item.id)
|
||||
subCategories.value = subData
|
||||
} catch (error) {
|
||||
console.error('加载子分类数据失败:', error)
|
||||
@@ -1537,7 +1543,7 @@ async function refreshHomeCategory(item: CategoryItem): Promise<void> {
|
||||
secondaryCategoryDisplay.value = buildSecondaryCategoryDisplay(item.id)
|
||||
applyChannelDisplay(item.id)
|
||||
try {
|
||||
const result = await supabaseService.getProductsByCategory(item.id, 1, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallProductsByCategory(item.id, 1, defaultLoadLimit)
|
||||
setHotProducts(result.data)
|
||||
hasMore.value = result.hasmore
|
||||
} catch (error) {
|
||||
@@ -1559,7 +1565,8 @@ function selectCategoryFromPanel(item: CategoryItem): void {
|
||||
}
|
||||
|
||||
const loadRecommendedProducts = async (limit: number): Promise<void> => {
|
||||
recommendedProducts.value = await supabaseService.getRecommendedProducts(limit)
|
||||
const result = await supabaseService.getMedicalMallSmartRecommendations(1, limit)
|
||||
recommendedProducts.value = result.data
|
||||
}
|
||||
|
||||
// 加载热搜词
|
||||
@@ -1592,7 +1599,7 @@ const initData = async () => {
|
||||
} catch (error) {
|
||||
console.error('加载用户资料失败:', error)
|
||||
}
|
||||
await loadCategories()
|
||||
await loadMedicalMallCategories()
|
||||
await loadBrands()
|
||||
await loadHotKeywords()
|
||||
await loadServiceHomeData()
|
||||
@@ -1613,7 +1620,7 @@ const familyItems = [
|
||||
desc: '伤口护理',
|
||||
icon: '🩹',
|
||||
color: '#FF5722',
|
||||
categoryId: 'external'
|
||||
categoryId: 'wound_care'
|
||||
},
|
||||
{
|
||||
id: 'family2',
|
||||
@@ -1621,7 +1628,7 @@ const familyItems = [
|
||||
desc: '健康监测',
|
||||
icon: '🌡️',
|
||||
color: '#2196F3',
|
||||
categoryId: 'device'
|
||||
categoryId: 'thermometer'
|
||||
},
|
||||
{
|
||||
id: 'family3',
|
||||
@@ -1629,7 +1636,7 @@ const familyItems = [
|
||||
desc: '环境消毒',
|
||||
icon: '🧪',
|
||||
color: '#ff5000',
|
||||
categoryId: 'external'
|
||||
categoryId: 'disinfectant'
|
||||
},
|
||||
{
|
||||
id: 'family4',
|
||||
@@ -1637,7 +1644,7 @@ const familyItems = [
|
||||
desc: '日常防护',
|
||||
icon: '😷',
|
||||
color: '#607D8B',
|
||||
categoryId: 'device'
|
||||
categoryId: 'mask'
|
||||
},
|
||||
{
|
||||
id: 'family5',
|
||||
@@ -1645,7 +1652,7 @@ const familyItems = [
|
||||
desc: '物理降温',
|
||||
icon: '🧊',
|
||||
color: '#00BCD4',
|
||||
categoryId: 'cold'
|
||||
categoryId: 'cold_fever'
|
||||
},
|
||||
{
|
||||
id: 'family6',
|
||||
@@ -1653,7 +1660,7 @@ const familyItems = [
|
||||
desc: '伤口处理',
|
||||
icon: '🩹',
|
||||
color: '#FF9800',
|
||||
categoryId: 'external'
|
||||
categoryId: 'dressing_tools'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1931,7 +1938,7 @@ const loadMore = async () => {
|
||||
currentPage.value = nextPage
|
||||
}
|
||||
} else {
|
||||
const result = await supabaseService.getProductsByCategory(currentFeedCategoryId.value, nextPage, defaultLoadLimit)
|
||||
const result = await supabaseService.getMedicalMallProductsByCategory(currentFeedCategoryId.value, nextPage, defaultLoadLimit)
|
||||
if (result.data.length == 0) {
|
||||
hasMore.value = false
|
||||
} else {
|
||||
|
||||
@@ -1,363 +1,433 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="工作台" fallback-url="/pages/user/login?mode=delivery" :hide-header="true">
|
||||
<view class="delivery-home-page">
|
||||
<view class="delivery-home-hero">
|
||||
<view class="delivery-home-hero-top">
|
||||
<view class="delivery-home-hero-main">
|
||||
<text class="delivery-home-hero-title">服务工作台</text>
|
||||
<text class="delivery-home-hero-subtitle">聚焦今日任务、异常处理和服务进度,帮助你快速进入当前工作状态。</text>
|
||||
<view class="delivery-home-user-tags">
|
||||
<text class="delivery-home-user-tag delivery-home-user-tag-light">{{ onlineStatusText }}</text>
|
||||
<text class="delivery-home-user-tag delivery-home-user-tag-soft">今日完成 {{ dashboard.completedCount }} 单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delivery-home-hero-actions">
|
||||
<view class="delivery-home-hero-action" @click="loadData()">
|
||||
<text class="delivery-home-hero-action-text">刷新</text>
|
||||
</view>
|
||||
<view class="delivery-home-hero-action" @click="goMessages()">
|
||||
<text class="delivery-home-hero-action-text">消息</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-hero-info-row">
|
||||
<view class="delivery-home-hero-info-item">
|
||||
<text class="delivery-home-hero-info-value">{{ dashboard.pendingAcceptCount }}</text>
|
||||
<text class="delivery-home-hero-info-label">待接单</text>
|
||||
</view>
|
||||
<view class="delivery-home-hero-info-item">
|
||||
<text class="delivery-home-hero-info-value">{{ dashboard.servingCount }}</text>
|
||||
<text class="delivery-home-hero-info-label">服务中</text>
|
||||
</view>
|
||||
<view class="delivery-home-hero-info-item">
|
||||
<text class="delivery-home-hero-info-value">{{ dashboard.exceptionCount }}</text>
|
||||
<text class="delivery-home-hero-info-label">异常待跟进</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-card delivery-home-overview-card">
|
||||
<view class="delivery-home-card-header">
|
||||
<view class="page">
|
||||
<view class="hero">
|
||||
<view class="hero-top">
|
||||
<view>
|
||||
<text class="delivery-home-card-title">今日概览</text>
|
||||
<text class="delivery-home-card-subtitle">聚焦待接单、服务执行和异常处理</text>
|
||||
<text class="hero-title">服务人员工作台</text>
|
||||
<text class="hero-subtitle">聚焦今日接单、上门履约和异常处理</text>
|
||||
</view>
|
||||
<text class="delivery-status-pill" :class="getStatusPillClass()">{{ onlineStatusText }}</text>
|
||||
<view class="hero-refresh" @click="loadData"><text class="hero-refresh-text">刷新</text></view>
|
||||
</view>
|
||||
<view class="delivery-overview-row">
|
||||
<view class="delivery-overview-item">
|
||||
<text class="delivery-overview-num delivery-overview-num-warning">{{ dashboard.pendingAcceptCount }}</text>
|
||||
<text class="delivery-overview-label">待接单</text>
|
||||
</view>
|
||||
<view class="delivery-overview-item">
|
||||
<text class="delivery-overview-num delivery-overview-num-active">{{ dashboard.pendingDepartCount }}</text>
|
||||
<text class="delivery-overview-label">待出发</text>
|
||||
</view>
|
||||
<view class="delivery-overview-item">
|
||||
<text class="delivery-overview-num delivery-overview-num-teal">{{ dashboard.servingCount }}</text>
|
||||
<text class="delivery-overview-label">服务中</text>
|
||||
</view>
|
||||
<view class="delivery-overview-item">
|
||||
<text class="delivery-overview-num delivery-overview-num-success">{{ dashboard.completedCount }}</text>
|
||||
<text class="delivery-overview-label">已完成</text>
|
||||
<view class="profile-card">
|
||||
<view class="avatar"><text class="avatar-text">护</text></view>
|
||||
<view class="profile-main">
|
||||
<text class="profile-name">{{ profileName }}</text>
|
||||
<text class="profile-role">{{ profileRole }}</text>
|
||||
<text class="profile-org">{{ organizationName }}</text>
|
||||
</view>
|
||||
<view class="status-pill"><text class="status-pill-text">{{ onlineText }}</text></view>
|
||||
</view>
|
||||
<view class="delivery-home-inline-alert" @click="goOrders('exception')">
|
||||
<view class="delivery-status-left">
|
||||
<text class="delivery-status-title">异常任务</text>
|
||||
<text class="delivery-status-desc">待优先跟进 {{ dashboard.exceptionCount }} 个异常事项</text>
|
||||
</view>
|
||||
|
||||
<view class="card stats-card">
|
||||
<view class="section-head">
|
||||
<text class="section-title">今日数据</text>
|
||||
<text class="section-desc">面向上门服务场景的实时工作概览</text>
|
||||
</view>
|
||||
<view class="stats-grid">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ dashboard.pendingAssignmentCount }}</text>
|
||||
<text class="stat-label">待接单</text>
|
||||
</view>
|
||||
<view class="delivery-status-right">
|
||||
<text class="delivery-exception-num">{{ dashboard.exceptionCount }}</text>
|
||||
<text class="delivery-inline-link">立即查看</text>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ dashboard.todayOrderCount }}</text>
|
||||
<text class="stat-label">今日待服务</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ dashboard.servingCount }}</text>
|
||||
<text class="stat-label">服务中</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value money">{{ incomeText }}</text>
|
||||
<text class="stat-label">预计收入</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="dashboard.exceptionCount > 0" class="delivery-home-card delivery-home-alert-card" @click="goOrders('exception')">
|
||||
<view class="delivery-alert-main">
|
||||
<text class="delivery-alert-title">当前有 {{ dashboard.exceptionCount }} 个异常任务待处理</text>
|
||||
<text class="delivery-alert-desc">建议先进入异常工单列表,确认原因、联系对象并更新处理进度。</text>
|
||||
<view class="card quick-card">
|
||||
<view class="section-head">
|
||||
<text class="section-title">快捷入口</text>
|
||||
<text class="section-desc">适配上门场景的大按钮操作</text>
|
||||
</view>
|
||||
<view class="delivery-alert-action">
|
||||
<text class="delivery-alert-action-text">查看异常</text>
|
||||
<view class="quick-grid">
|
||||
<view class="quick-item" @click="openOrders('pending')"><text class="quick-title">待接单</text><text class="quick-desc">优先确认新派单</text></view>
|
||||
<view class="quick-item" @click="openOrders('today')"><text class="quick-title">今日订单</text><text class="quick-desc">查看全部待服务订单</text></view>
|
||||
<view class="quick-item" @click="openServingOrder"><text class="quick-title">服务中</text><text class="quick-desc">继续填写记录</text></view>
|
||||
<view class="quick-item" @click="openOrders('history')"><text class="quick-title">历史订单</text><text class="quick-desc">查看已完成和异常</text></view>
|
||||
<view class="quick-item" @click="openAbnormal"><text class="quick-title">异常上报</text><text class="quick-desc">快速上报现场风险</text></view>
|
||||
<view class="quick-item" @click="openProfile"><text class="quick-title">我的资料</text><text class="quick-desc">查看个人信息与设置</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-card delivery-home-current-card">
|
||||
<view class="delivery-home-card-header">
|
||||
<view>
|
||||
<text class="delivery-home-card-title">当前任务</text>
|
||||
<text class="delivery-home-card-subtitle">首页先看这一单,明确今天的下一步动作</text>
|
||||
</view>
|
||||
<view class="card next-card">
|
||||
<view class="section-head">
|
||||
<text class="section-title">下一单服务提醒</text>
|
||||
<text class="section-desc">优先处理当前最需要行动的一单</text>
|
||||
</view>
|
||||
<view v-if="dashboard.recentOrders.length == 0" class="empty-box"><text class="empty-text">暂无待执行服务</text></view>
|
||||
<view v-else class="current-task-card" :class="getStatusSurfaceClass(dashboard.recentOrders[0].status)" @click="goDetail(dashboard.recentOrders[0].id)">
|
||||
<view class="current-task-top">
|
||||
<view class="current-task-main">
|
||||
<text class="current-task-title">{{ dashboard.recentOrders[0].serviceName }}</text>
|
||||
<text class="current-task-subtitle">{{ dashboard.recentOrders[0].elderNameMasked }} · {{ dashboard.recentOrders[0].appointmentStartTime }}</text>
|
||||
</view>
|
||||
<ServiceStatusTag :text="dashboard.recentOrders[0].statusText" :tone="dashboard.recentOrders[0].statusTone"></ServiceStatusTag>
|
||||
<view v-if="dashboard.nextOrder == null" class="empty-box"><text class="empty-text">暂无待处理订单</text></view>
|
||||
<view v-else class="next-body">
|
||||
<view class="next-row">
|
||||
<text class="next-title">{{ dashboard.nextOrder!.serviceName }}</text>
|
||||
<text class="next-status">{{ nextStatusText }}</text>
|
||||
</view>
|
||||
<view class="current-task-info-card">
|
||||
<view class="current-task-field">
|
||||
<text class="current-task-field-label">服务地址</text>
|
||||
<text class="current-task-field-value">{{ dashboard.recentOrders[0].addressSummary }}</text>
|
||||
</view>
|
||||
<view class="current-task-field current-task-field-last">
|
||||
<text class="current-task-field-label">风险标签</text>
|
||||
<text class="current-task-field-value">{{ formatRiskTags(dashboard.recentOrders[0].riskTags) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="current-task-footer">
|
||||
<view class="current-task-step">
|
||||
<text class="current-task-step-label">下一步</text>
|
||||
<text class="current-task-step-text">{{ getPrimaryActionText(dashboard.recentOrders[0].status) }}</text>
|
||||
</view>
|
||||
<view class="current-task-btn" :class="getPrimaryActionClass(dashboard.recentOrders[0].status)" @click.stop="handlePrimaryAction(dashboard.recentOrders[0])">
|
||||
<text class="current-task-btn-text">{{ getPrimaryActionText(dashboard.recentOrders[0].status) }}</text>
|
||||
</view>
|
||||
<text class="next-meta">预约时间:{{ dashboard.nextOrder!.appointmentTime }}</text>
|
||||
<text class="next-meta">服务地址:{{ dashboard.nextOrder!.address }}</text>
|
||||
<text class="next-meta">下一步:{{ nextStepText }}</text>
|
||||
<view class="next-actions">
|
||||
<view class="outline-btn" @click="goDetail(dashboard.nextOrder!.id)"><text class="outline-btn-text">查看详情</text></view>
|
||||
<view class="primary-btn" @click="handleOrderAction(dashboard.nextOrder!.id)"><text class="primary-btn-text">{{ nextActionText }}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-card delivery-home-tools-card">
|
||||
<view class="delivery-home-card-header">
|
||||
<view>
|
||||
<text class="delivery-home-card-title">常用功能</text>
|
||||
<text class="delivery-home-card-subtitle">保留当前可用入口,缩短日常处理路径</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shortcut-grid">
|
||||
<view class="shortcut-item" @click="goOrders('pending_accept')">
|
||||
<view class="shortcut-icon shortcut-icon-warning"><text class="shortcut-icon-text">接</text></view>
|
||||
<text class="shortcut-title">待接单</text>
|
||||
<text class="shortcut-desc">优先查看新派单</text>
|
||||
</view>
|
||||
<view class="shortcut-item" @click="goOrders('all')">
|
||||
<view class="shortcut-icon shortcut-icon-primary"><text class="shortcut-icon-text">单</text></view>
|
||||
<text class="shortcut-title">今日任务</text>
|
||||
<text class="shortcut-desc">进入全部工单列表</text>
|
||||
</view>
|
||||
<view class="shortcut-item" @click="goMessages()">
|
||||
<view class="shortcut-icon shortcut-icon-teal"><text class="shortcut-icon-text">讯</text></view>
|
||||
<text class="shortcut-title">消息提醒</text>
|
||||
<text class="shortcut-desc">查看沟通与通知</text>
|
||||
</view>
|
||||
<view class="shortcut-item" @click="goRecords()">
|
||||
<view class="shortcut-icon shortcut-icon-success"><text class="shortcut-icon-text">档</text></view>
|
||||
<text class="shortcut-title">服务记录</text>
|
||||
<text class="shortcut-desc">回顾已完成服务</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-card delivery-home-list-card">
|
||||
<view class="delivery-home-card-header">
|
||||
<view>
|
||||
<text class="delivery-home-card-title">服务工单</text>
|
||||
<text class="delivery-home-card-subtitle">保留最近工单,突出状态、地址和下一步动作</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="dashboard.recentOrders.length == 0" class="empty-box"><text class="empty-text">暂无任务</text></view>
|
||||
<view v-for="item in dashboard.recentOrders" :key="item.id" class="order-card" :class="getStatusSurfaceClass(item.status)" @click="goDetail(item.id)">
|
||||
<view class="card-top">
|
||||
<view class="order-main">
|
||||
<text class="order-title">{{ item.serviceName }} · {{ item.elderNameMasked }}</text>
|
||||
<text class="order-meta">预约时间:{{ item.appointmentStartTime }}</text>
|
||||
</view>
|
||||
<ServiceStatusTag :text="item.statusText" :tone="item.statusTone"></ServiceStatusTag>
|
||||
</view>
|
||||
<view class="order-info-box">
|
||||
<text class="order-meta">服务地址:{{ item.addressSummary }}</text>
|
||||
<text class="order-meta">风险标签:{{ formatRiskTags(item.riskTags) }}</text>
|
||||
</view>
|
||||
<view class="order-footer">
|
||||
<text class="order-next-text">下一步:{{ getPrimaryActionText(item.status) }}</text>
|
||||
<view class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click.stop="handlePrimaryAction(item)">
|
||||
<text class="order-action-btn-text">立即处理</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-home-safe"></view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServiceStatusTag from '@/components/homeService/ServiceStatusTag.uvue'
|
||||
import type { DeliveryDashboardType, DeliveryInfoType, DeliveryOrderType } from '@/types/delivery.uts'
|
||||
import { getDeliveryDashboard, getDeliveryProfile } from '@/services/deliveryService.uts'
|
||||
import { getDeliveryInfo, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import type { DeliveryDashboardType, DeliveryInfoType } from '@/types/delivery.uts'
|
||||
import { acceptServiceOrder, getDeliveryDashboardStats, getDeliveryProfile, markDeparted } from '@/services/deliveryService.uts'
|
||||
import { getNextStepText, getPrimaryActionText } from '@/utils/deliveryCareUi.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
|
||||
const dashboard = ref<DeliveryDashboardType>({
|
||||
const dashboard = ref({
|
||||
pendingAssignmentCount: 0,
|
||||
pendingAcceptCount: 0,
|
||||
todayOrderCount: 0,
|
||||
pendingDepartCount: 0,
|
||||
servingCount: 0,
|
||||
completedCount: 0,
|
||||
exceptionCount: 0,
|
||||
onlineStatus: 'resting',
|
||||
expectedIncome: 0,
|
||||
onlineStatus: 'online',
|
||||
nextOrder: null,
|
||||
recentOrders: [] as Array<any>
|
||||
} as DeliveryDashboardType)
|
||||
const onlineStatusText = ref('休息中')
|
||||
const deliveryInfo = ref<DeliveryInfoType | null>(null)
|
||||
const profile = ref<DeliveryInfoType | null>(null)
|
||||
|
||||
function syncStatusText(status: string) {
|
||||
if (status == 'online') {
|
||||
onlineStatusText.value = '在线接单'
|
||||
return
|
||||
}
|
||||
if (status == 'busy') {
|
||||
onlineStatusText.value = '忙碌中'
|
||||
return
|
||||
}
|
||||
onlineStatusText.value = '休息中'
|
||||
}
|
||||
|
||||
function getStatusPillClass(): string {
|
||||
if (onlineStatusText.value == '在线接单') {
|
||||
return 'delivery-status-online'
|
||||
}
|
||||
if (onlineStatusText.value == '忙碌中') {
|
||||
return 'delivery-status-busy'
|
||||
}
|
||||
return 'delivery-status-resting'
|
||||
}
|
||||
|
||||
function getPrimaryActionText(status: string): string {
|
||||
if (status == 'pending_accept') {
|
||||
return '立即接单'
|
||||
}
|
||||
if (status == 'accepted') {
|
||||
return '准备出发'
|
||||
}
|
||||
if (status == 'on_the_way' || status == 'arrived') {
|
||||
return '去签到'
|
||||
}
|
||||
if (status == 'checked_in' || status == 'serving' || status == 'pending_submit' || status == 'pending_acceptance') {
|
||||
return '继续服务'
|
||||
}
|
||||
if (status == 'exception_pending') {
|
||||
return '处理异常'
|
||||
}
|
||||
if (status == 'completed' || status == 'settled' || status == 'archived') {
|
||||
return '查看结果'
|
||||
}
|
||||
return '查看详情'
|
||||
}
|
||||
|
||||
function getPrimaryActionClass(status: string): string {
|
||||
if (status == 'pending_accept') {
|
||||
return 'action-warning'
|
||||
}
|
||||
if (status == 'accepted' || status == 'on_the_way' || status == 'arrived') {
|
||||
return 'action-primary'
|
||||
}
|
||||
if (status == 'checked_in' || status == 'serving' || status == 'pending_submit' || status == 'pending_acceptance') {
|
||||
return 'action-teal'
|
||||
}
|
||||
if (status == 'exception_pending') {
|
||||
return 'action-danger'
|
||||
}
|
||||
if (status == 'completed' || status == 'settled' || status == 'archived') {
|
||||
return 'action-success'
|
||||
}
|
||||
return 'action-default'
|
||||
}
|
||||
|
||||
function getStatusSurfaceClass(status: string): string {
|
||||
if (status == 'pending_accept') {
|
||||
return 'status-surface-warning'
|
||||
}
|
||||
if (status == 'accepted' || status == 'on_the_way' || status == 'arrived') {
|
||||
return 'status-surface-primary'
|
||||
}
|
||||
if (status == 'checked_in' || status == 'serving' || status == 'pending_submit' || status == 'pending_acceptance') {
|
||||
return 'status-surface-teal'
|
||||
}
|
||||
if (status == 'exception_pending') {
|
||||
return 'status-surface-danger'
|
||||
}
|
||||
if (status == 'completed' || status == 'settled' || status == 'archived') {
|
||||
return 'status-surface-success'
|
||||
}
|
||||
return 'status-surface-default'
|
||||
}
|
||||
|
||||
function formatRiskTags(tags: Array<string>): string {
|
||||
if (tags.length == 0) {
|
||||
return '常规服务'
|
||||
}
|
||||
return tags.join(' / ')
|
||||
}
|
||||
|
||||
function goRoute(id: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + id })
|
||||
}
|
||||
|
||||
function goCheckin(id: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/checkin?id=' + id })
|
||||
}
|
||||
|
||||
function goExecute(id: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/execute?id=' + id })
|
||||
}
|
||||
|
||||
function goException(id: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/exception?id=' + id })
|
||||
}
|
||||
|
||||
function handlePrimaryAction(order: DeliveryOrderType) {
|
||||
if (order.status == 'pending_accept') {
|
||||
goDetail(order.id)
|
||||
return
|
||||
}
|
||||
if (order.status == 'accepted') {
|
||||
goRoute(order.id)
|
||||
return
|
||||
}
|
||||
if (order.status == 'on_the_way' || order.status == 'arrived') {
|
||||
goCheckin(order.id)
|
||||
return
|
||||
}
|
||||
if (order.status == 'checked_in' || order.status == 'serving' || order.status == 'pending_submit' || order.status == 'pending_acceptance') {
|
||||
goExecute(order.id)
|
||||
return
|
||||
}
|
||||
if (order.status == 'exception_pending') {
|
||||
goException(order.id)
|
||||
return
|
||||
}
|
||||
goDetail(order.id)
|
||||
}
|
||||
const profileName = computed((): string => profile.value != null ? profile.value.name : '服务人员')
|
||||
const profileRole = computed((): string => profile.value != null ? '护工 / 上门服务人员' : '服务人员')
|
||||
const organizationName = computed((): string => profile.value != null ? profile.value.organizationName : '机构待绑定')
|
||||
const onlineText = computed((): string => {
|
||||
if (profile.value == null) return '离线'
|
||||
if (profile.value.onlineStatus == 'online') return '在线'
|
||||
if (profile.value.onlineStatus == 'busy') return '忙碌'
|
||||
return '离线'
|
||||
})
|
||||
const incomeText = computed((): string => '¥' + String(dashboard.value.expectedIncome))
|
||||
const nextActionText = computed((): string => dashboard.value.nextOrder == null ? '查看详情' : getPrimaryActionText(dashboard.value.nextOrder!.status))
|
||||
const nextStepText = computed((): string => dashboard.value.nextOrder == null ? '暂无' : getNextStepText(dashboard.value.nextOrder!.status))
|
||||
const nextStatusText = computed((): string => dashboard.value.nextOrder == null ? '' : dashboard.value.nextOrder!.statusText)
|
||||
|
||||
async function loadData() {
|
||||
const startedAt = Date.now()
|
||||
console.log('[deliveryHome] loadData start')
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
console.log('[deliveryHome] auth done', {
|
||||
ok: authResult.ok,
|
||||
message: authResult.message,
|
||||
elapsed: Date.now() - startedAt
|
||||
})
|
||||
if (!authResult.ok) {
|
||||
return
|
||||
}
|
||||
dashboard.value = await getDeliveryDashboard()
|
||||
console.log('[deliveryHome] dashboard loaded, elapsed=' + (Date.now() - startedAt))
|
||||
deliveryInfo.value = await getDeliveryProfile()
|
||||
console.log('[deliveryHome] profile loaded, elapsed=' + (Date.now() - startedAt))
|
||||
const info = deliveryInfo.value != null ? deliveryInfo.value : getDeliveryInfo()
|
||||
if (info != null) {
|
||||
syncStatusText(info.onlineStatus)
|
||||
profile.value = await getDeliveryProfile()
|
||||
dashboard.value = await getDeliveryDashboardStats()
|
||||
}
|
||||
|
||||
function openOrders(tab: string) {
|
||||
uni.setStorageSync('delivery_order_tab', tab)
|
||||
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
|
||||
}
|
||||
|
||||
function openProfile() {
|
||||
uni.switchTab({ url: '/pages/mall/delivery/profile/index' })
|
||||
}
|
||||
|
||||
function openServingOrder() {
|
||||
if (dashboard.value.nextOrder == null) {
|
||||
openOrders('today')
|
||||
return
|
||||
}
|
||||
goDetail(dashboard.value.nextOrder!.id)
|
||||
}
|
||||
|
||||
function openAbnormal() {
|
||||
if (dashboard.value.nextOrder != null) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/exception?id=' + dashboard.value.nextOrder!.id })
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: '请先进入订单详情页再上报异常', icon: 'none' })
|
||||
}
|
||||
|
||||
function goDetail(orderId: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId })
|
||||
}
|
||||
|
||||
async function handleOrderAction(orderId: string) {
|
||||
const order = dashboard.value.nextOrder
|
||||
if (order == null) {
|
||||
return
|
||||
}
|
||||
if (order.status == 'pending_assignment' || order.status == 'pending_accept') {
|
||||
await acceptServiceOrder(orderId)
|
||||
uni.showToast({ title: '已接单', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (order.status == 'accepted' || order.status == 'waiting_departure') {
|
||||
await markDeparted(orderId)
|
||||
uni.showToast({ title: '已标记出发', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
goDetail(orderId)
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
min-height: 100%;
|
||||
margin-left: -24rpx;
|
||||
margin-right: -24rpx;
|
||||
margin-top: -24rpx;
|
||||
padding: 0 24rpx 36rpx;
|
||||
background-color: #f3f8fb;
|
||||
}
|
||||
|
||||
.hero {
|
||||
padding: 64rpx 28rpx 32rpx;
|
||||
border-bottom-left-radius: 36rpx;
|
||||
border-bottom-right-radius: 36rpx;
|
||||
background: linear-gradient(180deg, #1f7db4 0%, #22a380 100%);
|
||||
}
|
||||
|
||||
.hero-top,
|
||||
.profile-card,
|
||||
.section-head,
|
||||
.stats-grid,
|
||||
.quick-grid,
|
||||
.next-row,
|
||||
.next-actions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.hero-top,
|
||||
.section-head,
|
||||
.next-row,
|
||||
.next-actions {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-subtitle,
|
||||
.profile-role,
|
||||
.profile-org,
|
||||
.section-desc,
|
||||
.stat-label,
|
||||
.quick-desc,
|
||||
.next-meta,
|
||||
.empty-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.hero-subtitle,
|
||||
.profile-role,
|
||||
.profile-org {
|
||||
margin-top: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.hero-refresh {
|
||||
padding: 14rpx 22rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.hero-refresh-text,
|
||||
.status-pill-text,
|
||||
.primary-btn-text,
|
||||
.quick-title,
|
||||
.section-title,
|
||||
.profile-name,
|
||||
.next-title,
|
||||
.stat-value {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.hero-refresh-text,
|
||||
.status-pill-text {
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.profile-card,
|
||||
.card,
|
||||
.quick-item,
|
||||
.next-body {
|
||||
background-color: #ffffff;
|
||||
border-radius: 28rpx;
|
||||
}
|
||||
|
||||
.profile-card {
|
||||
align-items: center;
|
||||
margin-top: 28rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
background-color: #d8eff8;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.avatar-text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: #166e96;
|
||||
}
|
||||
|
||||
.profile-main {
|
||||
flex: 1;
|
||||
padding-left: 20rpx;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.profile-name {
|
||||
font-size: 32rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
padding: 12rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #22a380;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-top: 22rpx;
|
||||
padding: 26rpx;
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.section-head {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.section-desc,
|
||||
.stat-label,
|
||||
.quick-desc,
|
||||
.next-meta,
|
||||
.empty-text,
|
||||
.outline-btn-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.stats-grid,
|
||||
.quick-grid {
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.stat-item,
|
||||
.quick-item {
|
||||
width: 48%;
|
||||
margin-top: 14rpx;
|
||||
padding: 22rpx;
|
||||
background-color: #f7fbfd;
|
||||
border-radius: 22rpx;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 38rpx;
|
||||
color: #166e96;
|
||||
}
|
||||
|
||||
.money {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.quick-title {
|
||||
font-size: 28rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.quick-desc,
|
||||
.next-meta {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.next-body {
|
||||
margin-top: 18rpx;
|
||||
padding: 24rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.next-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
flex: 1;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.next-status {
|
||||
font-size: 24rpx;
|
||||
color: #1f7db4;
|
||||
}
|
||||
|
||||
.next-actions {
|
||||
margin-top: 20rpx;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
width: 48%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.outline-btn {
|
||||
background-color: #eef6fa;
|
||||
}
|
||||
|
||||
.outline-btn-text {
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background-color: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
</style>
|
||||
console.log('[deliveryHome] loadData complete, elapsed=' + (Date.now() - startedAt))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,82 +1,214 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="工单详情" fallback-url="/pages/mall/delivery/orders/index">
|
||||
<ServicePanel title="基础信息" subtitle="接单前脱敏,接单后展示完整信息。">
|
||||
<view v-if="order != null">
|
||||
<text class="row-text">工单号:{{ order.orderNo }}</text>
|
||||
<text class="row-text">服务项目:{{ order.serviceName }}</text>
|
||||
<text class="row-text">服务对象:{{ order.status == 'pending_accept' ? order.elderNameMasked : order.fullElderName }}</text>
|
||||
<text class="row-text">联系电话:{{ order.status == 'pending_accept' ? order.elderPhoneMasked : order.fullPhone }}</text>
|
||||
<text class="row-text">服务地址:{{ order.status == 'pending_accept' ? order.addressSummary : order.fullAddress }}</text>
|
||||
<text class="row-text">预约时间:{{ order.appointmentStartTime }} - {{ order.appointmentEndTime }}</text>
|
||||
<text class="row-text">联系人:{{ order.contactName }} / {{ order.contactPhone }}</text>
|
||||
<text class="row-text">注意事项:{{ order.notices.join(';') }}</text>
|
||||
<ServicePageScaffold title="订单详情" fallback-url="/pages/mall/delivery/orders/index">
|
||||
<view v-if="order != null" class="page">
|
||||
<view class="status-card">
|
||||
<view class="status-head">
|
||||
<view>
|
||||
<text class="status-title">当前状态</text>
|
||||
<text class="status-subtitle">{{ order.statusText }}</text>
|
||||
</view>
|
||||
<text class="status-tag">{{ nextStepText }}</text>
|
||||
</view>
|
||||
<view class="timeline-box">
|
||||
<view v-for="item in order.timeline" :key="item.id" class="timeline-item">
|
||||
<text class="timeline-title">{{ item.title }}</text>
|
||||
<text class="timeline-meta">{{ item.time }}</text>
|
||||
<text class="timeline-desc">{{ item.description }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePanel>
|
||||
|
||||
<ServicePanel title="服务项目" subtitle="未完成项需在执行页填写原因。">
|
||||
<view v-if="order != null" v-for="item in order.serviceItems" :key="item.id" class="item-row">
|
||||
<text class="row-text">{{ item.name }}</text>
|
||||
<view class="card">
|
||||
<text class="section-title">服务信息</text>
|
||||
<text class="row-text">服务名称:{{ order.serviceName }}</text>
|
||||
<text class="row-text">服务类型:{{ order.serviceType }}</text>
|
||||
<text class="row-text">预约时间:{{ order.appointmentTime }}</text>
|
||||
<text class="row-text">预计时长:{{ order.duration }} 分钟</text>
|
||||
<text class="row-text">服务价格:¥{{ order.price }}</text>
|
||||
<text class="row-text">预计收入:¥{{ order.staffIncome }}</text>
|
||||
</view>
|
||||
</ServicePanel>
|
||||
|
||||
<ServicePanel title="状态时间轴" subtitle="所有关键动作都需要留痕。">
|
||||
<ServiceTimeline :items="timelineItems"></ServiceTimeline>
|
||||
</ServicePanel>
|
||||
<view class="card">
|
||||
<text class="section-title">服务对象</text>
|
||||
<text class="row-text">姓名:{{ order.elderName }}</text>
|
||||
<text class="row-text">性别:{{ order.elderGender }}</text>
|
||||
<text class="row-text">年龄:{{ order.elderAge }}</text>
|
||||
<text class="row-text">电话:{{ order.elderPhone }}</text>
|
||||
<text class="row-text">健康标签:{{ joinTags(order.healthTags) }}</text>
|
||||
</view>
|
||||
|
||||
<view class="bottom-space"></view>
|
||||
<view v-if="order != null" class="fixed-bar">
|
||||
<view class="bar-btn secondary-btn" @click="goException"><text class="bar-text secondary-text">异常上报</text></view>
|
||||
<view v-if="order.status == 'pending_accept'" class="bar-btn primary-btn" @click="acceptOrder"><text class="bar-text">接单</text></view>
|
||||
<view v-else-if="order.status == 'accepted' || order.status == 'on_the_way' || order.status == 'arrived'" class="bar-btn primary-btn" @click="goRoute"><text class="bar-text">出发/签到</text></view>
|
||||
<view v-else class="bar-btn primary-btn" @click="goExecute"><text class="bar-text">进入执行</text></view>
|
||||
<view class="card">
|
||||
<text class="section-title">联系人信息</text>
|
||||
<text class="row-text">联系人:{{ order.contactName }}</text>
|
||||
<text class="row-text">联系电话:{{ order.contactPhone }}</text>
|
||||
<text class="row-text">关系:{{ order.contactRelation }}</text>
|
||||
<view class="inline-actions">
|
||||
<view class="outline-btn" @click="makePhoneCall(order.contactPhone)"><text class="outline-btn-text">拨打联系人</text></view>
|
||||
<view class="outline-btn" @click="makePhoneCall(order.elderPhone)"><text class="outline-btn-text">拨打服务对象</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">地址信息</text>
|
||||
<text class="row-text">完整地址:{{ order.address }}</text>
|
||||
<text class="row-text">门牌号:{{ order.addressDetail }}</text>
|
||||
<text class="row-text">距离:{{ order.distance }}</text>
|
||||
<view class="inline-actions">
|
||||
<view class="outline-btn" @click="mockNavigate"><text class="outline-btn-text">导航按钮</text></view>
|
||||
<view class="outline-btn" @click="makePhoneCall(order.contactPhone)"><text class="outline-btn-text">拨打电话</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">用户备注</text>
|
||||
<text class="row-text">特殊需求:{{ order.remark }}</text>
|
||||
<text class="row-text">需家属在场:{{ order.needFamilyPresent ? '是' : '否' }}</text>
|
||||
<text class="row-text">需携带耗材:{{ order.needMaterials ? '是' : '否' }}</text>
|
||||
<text class="row-text">风险标签:{{ joinTags(order.riskTags) }}</text>
|
||||
</view>
|
||||
|
||||
<view v-if="order.abnormalReport != null" class="card">
|
||||
<text class="section-title">异常记录</text>
|
||||
<text class="row-text">异常类型:{{ order.abnormalReport!.type }}</text>
|
||||
<text class="row-text">异常说明:{{ order.abnormalReport!.description }}</text>
|
||||
<text class="row-text">发生时间:{{ order.abnormalReport!.occurredAt }}</text>
|
||||
</view>
|
||||
|
||||
<view class="action-card">
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goException"><text class="outline-btn-text">异常上报</text></view>
|
||||
<view v-if="showRejectButton" class="warn-btn" @click="rejectOrder"><text class="warn-btn-text">拒单</text></view>
|
||||
<view class="primary-btn" @click="handlePrimary"><text class="primary-btn-text">{{ primaryText }}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
|
||||
import ServiceTimeline from '@/components/homeService/ServiceTimeline.uvue'
|
||||
import { acceptDeliveryOrder, getDeliveryOrderDetail } from '@/services/deliveryService.uts'
|
||||
import type { DeliveryOrderType } from '@/types/delivery.uts'
|
||||
import {
|
||||
acceptServiceOrder,
|
||||
checkInServiceOrder,
|
||||
completeServiceOrder,
|
||||
getServiceOrderDetail,
|
||||
markArrived,
|
||||
markDeparted,
|
||||
rejectServiceOrder,
|
||||
startServiceOrder
|
||||
} from '@/services/deliveryService.uts'
|
||||
import { getNextStepText, getPrimaryActionText, needsServiceRecord } from '@/utils/deliveryCareUi.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
|
||||
|
||||
const orderId = ref('')
|
||||
const order = ref<DeliveryOrderType | null>(null)
|
||||
const timelineItems = ref([] as Array<any>)
|
||||
|
||||
const primaryText = computed((): string => order.value == null ? '查看详情' : getPrimaryActionText(order.value!.status))
|
||||
const nextStepText = computed((): string => order.value == null ? '' : getNextStepText(order.value!.status))
|
||||
const showRejectButton = computed((): boolean => order.value != null && (order.value!.status == 'pending_assignment' || order.value!.status == 'pending_accept'))
|
||||
|
||||
async function loadData() {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok || orderId.value == '') {
|
||||
return
|
||||
}
|
||||
order.value = await getDeliveryOrderDetail(orderId.value)
|
||||
if (order.value != null) {
|
||||
timelineItems.value = order.value.timeline
|
||||
}
|
||||
order.value = await getServiceOrderDetail(orderId.value)
|
||||
}
|
||||
|
||||
async function acceptOrder() {
|
||||
await acceptDeliveryOrder(orderId.value)
|
||||
uni.showToast({ title: '接单成功', icon: 'success' })
|
||||
loadData()
|
||||
function joinTags(tags: Array<string>): string {
|
||||
if (tags.length == 0) return '无'
|
||||
return tags.join(' / ')
|
||||
}
|
||||
|
||||
function goRoute() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/route?id=' + orderId.value })
|
||||
function makePhoneCall(phone: string) {
|
||||
uni.makePhoneCall({ phoneNumber: phone })
|
||||
}
|
||||
|
||||
function goExecute() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/execute?id=' + orderId.value })
|
||||
function mockNavigate() {
|
||||
uni.showToast({ title: '导航为 mock 占位', icon: 'none' })
|
||||
}
|
||||
|
||||
function goException() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/exception?id=' + orderId.value })
|
||||
}
|
||||
|
||||
function goRecord() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/service-record/index?id=' + orderId.value })
|
||||
}
|
||||
|
||||
async function rejectOrder() {
|
||||
uni.showActionSheet({
|
||||
itemList: ['时间冲突', '距离过远', '技能不匹配', '其他原因'],
|
||||
success: async (result) => {
|
||||
const reasons = ['时间冲突', '距离过远', '技能不匹配', '其他原因']
|
||||
await rejectServiceOrder(orderId.value, reasons[result.tapIndex])
|
||||
uni.showToast({ title: '已拒单', icon: 'success' })
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function handlePrimary() {
|
||||
if (order.value == null) {
|
||||
return
|
||||
}
|
||||
const status = order.value.status
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') {
|
||||
await acceptServiceOrder(orderId.value)
|
||||
uni.showToast({ title: '已接单', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'accepted' || status == 'waiting_departure') {
|
||||
await markDeparted(orderId.value)
|
||||
uni.showToast({ title: '已出发', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'departed' || status == 'on_the_way') {
|
||||
await markArrived(orderId.value)
|
||||
uni.showToast({ title: '已到达', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'arrived') {
|
||||
await checkInServiceOrder(orderId.value, '详情页签到', null)
|
||||
uni.showToast({ title: '签到成功', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'checked_in') {
|
||||
await startServiceOrder(orderId.value)
|
||||
uni.showToast({ title: '开始服务', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'in_service' || status == 'serving' || status == 'completed') {
|
||||
goRecord()
|
||||
return
|
||||
}
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') {
|
||||
if (needsServiceRecord(order.value)) {
|
||||
uni.showToast({ title: '请先填写服务记录', icon: 'none' })
|
||||
goRecord()
|
||||
return
|
||||
}
|
||||
await completeServiceOrder(orderId.value)
|
||||
uni.showToast({ title: '服务已完成', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (status == 'abnormal' || status == 'exception_pending') {
|
||||
goException()
|
||||
return
|
||||
}
|
||||
goRecord()
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
if (options != null) {
|
||||
orderId.value = getDeliveryRouteParam(options as UTSJSONObject, 'id')
|
||||
@@ -86,59 +218,123 @@ onLoad((options) => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.row-text {
|
||||
display: block;
|
||||
margin-bottom: 14rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 38rpx;
|
||||
.page {
|
||||
padding-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.status-card,
|
||||
.card,
|
||||
.action-card {
|
||||
margin-bottom: 18rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 24rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.status-head,
|
||||
.inline-actions,
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-title,
|
||||
.section-title,
|
||||
.timeline-title,
|
||||
.primary-btn-text {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.status-title,
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.item-row {
|
||||
padding: 16rpx 0;
|
||||
border-bottom: 1rpx solid #e6edf1;
|
||||
.status-subtitle,
|
||||
.status-tag,
|
||||
.row-text,
|
||||
.timeline-meta,
|
||||
.timeline-desc,
|
||||
.outline-btn-text,
|
||||
.warn-btn-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 140rpx;
|
||||
.status-subtitle,
|
||||
.timeline-meta,
|
||||
.timeline-desc,
|
||||
.outline-btn-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.fixed-bar {
|
||||
position: fixed;
|
||||
left: 24rpx;
|
||||
right: 24rpx;
|
||||
bottom: 24rpx;
|
||||
padding: 16rpx;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
box-shadow: 0 12rpx 24rpx rgba(15, 118, 110, 0.08);
|
||||
.status-tag {
|
||||
padding: 10rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #e6f3fa;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.bar-btn {
|
||||
width: 48%;
|
||||
padding: 20rpx 0;
|
||||
.timeline-box {
|
||||
margin-top: 18rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.timeline-item {
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.timeline-title {
|
||||
font-size: 26rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.row-text {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.inline-actions,
|
||||
.action-row {
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.warn-btn,
|
||||
.primary-btn {
|
||||
width: 31%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background: #0f766e;
|
||||
.outline-btn {
|
||||
background-color: #eef6fa;
|
||||
}
|
||||
|
||||
.secondary-btn {
|
||||
background: #eaf2f0;
|
||||
.warn-btn {
|
||||
background-color: #fff3e6;
|
||||
}
|
||||
|
||||
.bar-text {
|
||||
font-size: 28rpx;
|
||||
.warn-btn-text {
|
||||
color: #c77413;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background-color: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.secondary-text {
|
||||
color: #0f766e;
|
||||
}
|
||||
</style>
|
||||
@@ -1,84 +1,104 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="异常上报" fallback-url="/pages/mall/delivery/orders/detail">
|
||||
<ServicePanel title="异常类型" subtitle="高风险异常需立即提醒联系家属、调度或 120。">
|
||||
<view class="type-grid">
|
||||
<view v-for="item in exceptionTypes" :key="item.value" class="type-item" :class="currentType == item.value ? 'type-active' : ''" @click="currentType = item.value">
|
||||
<text class="type-text">{{ item.label }}</text>
|
||||
<view class="page">
|
||||
<view class="card">
|
||||
<text class="section-title">异常类型</text>
|
||||
<view class="type-grid">
|
||||
<view v-for="item in exceptionTypes" :key="item.value" class="type-item" :class="currentType == item.value ? 'type-active' : ''" @click="currentType = item.value">
|
||||
<text class="type-text">{{ item.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePanel>
|
||||
<ServicePanel title="异常说明" subtitle="说明必填,支持上传图片凭证。">
|
||||
<textarea class="textarea" v-model="description" placeholder="请填写异常发生情况、现场处置动作和需要协同的事项"></textarea>
|
||||
<button class="secondary-btn" @click="chooseImage">上传异常图片</button>
|
||||
<text class="info-text">已选择图片:{{ images.length }} 张</text>
|
||||
<text v-if="isHighRisk" class="risk-text">高风险异常:请同步联系家属/调度/120,并保留处置留痕。</text>
|
||||
</ServicePanel>
|
||||
<button class="primary-btn" :disabled="submitting" @click="submitForm">{{ submitting ? '提交中...' : '提交异常' }}</button>
|
||||
<view class="card">
|
||||
<text class="section-title">异常说明</text>
|
||||
<textarea class="textarea" v-model="description" placeholder="请填写异常说明"></textarea>
|
||||
<input class="field" v-model="occurredAt" placeholder="发生时间,例如 2026-05-20 15:36" />
|
||||
<input class="field" v-model="locationText" placeholder="当前位置 mock" />
|
||||
<view class="switch-row"><text class="switch-label">需要平台介入</text><switch :checked="needPlatformIntervention" color="#1f7db4" @change="changePlatformIntervention" /></view>
|
||||
<view class="switch-row"><text class="switch-label">申请取消订单</text><switch :checked="requestCancelOrder" color="#1f7db4" @change="changeCancelOrder" /></view>
|
||||
<view class="switch-row"><text class="switch-label">申请改期</text><switch :checked="requestReschedule" color="#1f7db4" @change="changeReschedule" /></view>
|
||||
<view class="mock-upload" @click="addMockImage"><text class="mock-upload-text">图片上传占位</text></view>
|
||||
<text class="info-text">已添加图片占位:{{ imageCount }} 张</text>
|
||||
</view>
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goBack"><text class="outline-btn-text">返回详情</text></view>
|
||||
<view class="primary-btn" @click="submitForm"><text class="primary-btn-text">提交异常</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
|
||||
import { submitException } from '@/services/deliveryService.uts'
|
||||
import { submitAbnormalReport } from '@/services/deliveryService.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
|
||||
|
||||
const orderId = ref('')
|
||||
const currentType = ref('cannot_contact_elder')
|
||||
const currentType = ref('cannot_contact_user')
|
||||
const description = ref('')
|
||||
const images = ref([] as Array<string>)
|
||||
const submitting = ref(false)
|
||||
const occurredAt = ref(new Date().toISOString().replace('T', ' ').substring(0, 19))
|
||||
const locationText = ref('当前位置 mock')
|
||||
const needPlatformIntervention = ref(false)
|
||||
const requestCancelOrder = ref(false)
|
||||
const requestReschedule = ref(false)
|
||||
const imageCount = ref(0)
|
||||
const exceptionTypes = [
|
||||
{ label: '无法联系老人', value: 'cannot_contact_elder' },
|
||||
{ label: '无法入户', value: 'cannot_enter_home' },
|
||||
{ label: '联系不上用户', value: 'cannot_contact_user' },
|
||||
{ label: '用户不在家', value: 'user_not_home' },
|
||||
{ label: '地址错误', value: 'wrong_address' },
|
||||
{ label: '老人拒绝服务', value: 'elder_refuse_service' },
|
||||
{ label: '家属要求改期', value: 'family_requests_reschedule' },
|
||||
{ label: '现场存在安全风险', value: 'safety_risk' },
|
||||
{ label: '老人身体异常', value: 'elder_health_abnormal' },
|
||||
{ label: '家属不配合', value: 'family_uncooperative' },
|
||||
{ label: '服务对象身体异常', value: 'elder_health_abnormal' },
|
||||
{ label: '环境不适合服务', value: 'safety_risk' },
|
||||
{ label: '超出服务范围', value: 'outside_service_scope' },
|
||||
{ label: '服务人员无法继续服务', value: 'staff_cannot_continue' },
|
||||
{ label: '突发疾病', value: 'emergency_illness' },
|
||||
{ label: '服务项目无法完成', value: 'item_unavailable' },
|
||||
{ label: '投诉纠纷', value: 'complaint_dispute' },
|
||||
{ label: '其他', value: 'other' }
|
||||
]
|
||||
const isHighRisk = computed(() => currentType.value == 'safety_risk' || currentType.value == 'elder_health_abnormal' || currentType.value == 'emergency_illness')
|
||||
|
||||
function wrapChooseImage(): Promise<Array<string>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.chooseImage({
|
||||
count: 3,
|
||||
sourceType: ['camera', 'album'],
|
||||
success: (res) => { resolve(res.tempFilePaths) },
|
||||
fail: () => { reject(new Error('选择图片失败')) }
|
||||
})
|
||||
})
|
||||
function changePlatformIntervention(event: any) {
|
||||
needPlatformIntervention.value = event.detail.value === true
|
||||
}
|
||||
|
||||
async function chooseImage() {
|
||||
try {
|
||||
images.value = await wrapChooseImage()
|
||||
} catch (error) {
|
||||
uni.showToast({ title: '图片选择失败', icon: 'none' })
|
||||
}
|
||||
function changeCancelOrder(event: any) {
|
||||
requestCancelOrder.value = event.detail.value === true
|
||||
}
|
||||
|
||||
function changeReschedule(event: any) {
|
||||
requestReschedule.value = event.detail.value === true
|
||||
}
|
||||
|
||||
function addMockImage() {
|
||||
imageCount.value = imageCount.value + 1
|
||||
uni.showToast({ title: '已添加图片占位', icon: 'success' })
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
if (submitting.value) return
|
||||
if (description.value.trim() == '') {
|
||||
uni.showToast({ title: '异常说明不能为空', icon: 'none' })
|
||||
uni.showToast({ title: '请填写异常说明', icon: 'none' })
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
try {
|
||||
await submitException(orderId.value, { exceptionType: currentType.value as any, description: description.value.trim(), images: images.value })
|
||||
uni.showToast({ title: '异常已上报', icon: 'success' })
|
||||
uni.setStorageSync('delivery_orders_tab', 'exception')
|
||||
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
await submitAbnormalReport(orderId.value, {
|
||||
exceptionType: currentType.value as any,
|
||||
description: description.value,
|
||||
images: imageCount.value > 0 ? ['mock-abnormal-image-' + String(imageCount.value)] : [] as Array<string>,
|
||||
occurredAt: occurredAt.value,
|
||||
locationText: locationText.value,
|
||||
needPlatformIntervention: needPlatformIntervention.value,
|
||||
requestCancelOrder: requestCancelOrder.value,
|
||||
requestReschedule: requestReschedule.value
|
||||
})
|
||||
uni.showToast({ title: '异常已提交', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
|
||||
}, 300)
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
|
||||
}
|
||||
|
||||
onLoad(async (options) => {
|
||||
@@ -93,6 +113,51 @@ onLoad(async (options) => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
padding-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-bottom: 18rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 24rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.section-title,
|
||||
.primary-btn-text,
|
||||
.type-text {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.field,
|
||||
.textarea {
|
||||
margin-top: 16rpx;
|
||||
padding: 0 20rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f4f8fb;
|
||||
font-size: 26rpx;
|
||||
color: #16324f;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.field {
|
||||
height: 84rpx;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
min-height: 180rpx;
|
||||
padding-top: 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.type-grid {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
@@ -102,13 +167,13 @@ onLoad(async (options) => {
|
||||
.type-item {
|
||||
width: 48%;
|
||||
padding: 18rpx 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
margin-top: 16rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #eef2f6;
|
||||
}
|
||||
|
||||
.type-active {
|
||||
background: #0f766e;
|
||||
background: #1f7db4;
|
||||
}
|
||||
|
||||
.type-text {
|
||||
@@ -121,47 +186,54 @@ onLoad(async (options) => {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
min-height: 220rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #f2f7f6;
|
||||
font-size: 28rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.secondary-btn,
|
||||
.primary-btn {
|
||||
margin-top: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.secondary-btn {
|
||||
background: #eaf2f0;
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background: #0f766e;
|
||||
color: #ffffff;
|
||||
.switch-row,
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.switch-label,
|
||||
.info-text,
|
||||
.risk-text {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
.outline-btn-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.risk-text {
|
||||
color: #b45309;
|
||||
font-weight: 700;
|
||||
.mock-upload,
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
margin-top: 18rpx;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.mock-upload,
|
||||
.outline-btn {
|
||||
background: #eaf2f0;
|
||||
}
|
||||
|
||||
.mock-upload-text,
|
||||
.outline-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
@@ -1,164 +1,371 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="工单列表" fallback-url="/pages/mall/delivery/home/index" :hide-header="true">
|
||||
<view class="delivery-orders-page">
|
||||
<view class="delivery-orders-hero">
|
||||
<view class="delivery-orders-hero-top">
|
||||
<view class="delivery-orders-hero-main">
|
||||
<text class="delivery-orders-hero-title">服务工单</text>
|
||||
<text class="delivery-orders-hero-subtitle">{{ getCurrentTabLabel() }} · {{ getCurrentTabSubtitle() }}</text>
|
||||
</view>
|
||||
<view class="delivery-orders-hero-badge">
|
||||
<text class="delivery-orders-hero-badge-text">{{ orders.length }} 单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delivery-orders-hero-tip-box">
|
||||
<text class="delivery-orders-hero-tip">接单前仅显示脱敏信息,接单后查看详情可见完整信息。</text>
|
||||
<ServicePageScaffold title="订单" fallback-url="/pages/mall/delivery/home/index" :hide-header="true">
|
||||
<view class="page">
|
||||
<view class="hero">
|
||||
<text class="hero-title">服务订单</text>
|
||||
<text class="hero-subtitle">待接单、今日订单、历史订单统一查看</text>
|
||||
</view>
|
||||
<view class="tab-row">
|
||||
<view v-for="item in tabs" :key="item.value" class="tab-item" :class="currentTab == item.value ? 'tab-item-active' : ''" @click="switchTab(item.value)">
|
||||
<text class="tab-text" :class="currentTab == item.value ? 'tab-text-active' : ''">{{ item.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-orders-card delivery-orders-filter-card">
|
||||
<view class="delivery-orders-card-header">
|
||||
<view>
|
||||
<text class="delivery-orders-card-title">状态筛选</text>
|
||||
<text class="delivery-orders-card-subtitle">横向切换工单状态,列表会同步刷新对应内容</text>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view
|
||||
class="status-scroll"
|
||||
direction="horizontal"
|
||||
:show-scrollbar="false"
|
||||
:scroll-into-view="activeTabViewId"
|
||||
scroll-with-animation="true"
|
||||
>
|
||||
<view class="status-tabs-row">
|
||||
<view
|
||||
v-for="item in tabs"
|
||||
:key="item.value"
|
||||
:id="'status-tab-' + item.value"
|
||||
class="status-tab-item"
|
||||
:class="currentTab == item.value ? 'status-tab-active' : ''"
|
||||
@click="switchTab(item.value)"
|
||||
>
|
||||
<text class="status-tab-text" :class="currentTab == item.value ? 'status-tab-text-active' : ''">{{ item.label }}</text>
|
||||
<view class="list-card">
|
||||
<view v-if="orders.length == 0" class="empty-box"><text class="empty-text">{{ emptyText }}</text></view>
|
||||
<view v-for="item in orders" :key="item.id" class="order-card">
|
||||
<view class="order-top" @click="goDetail(item.id)">
|
||||
<view class="order-main">
|
||||
<text class="order-title">{{ item.serviceName }}</text>
|
||||
<text class="order-subtitle">{{ item.elderName }} · {{ item.appointmentTime }}</text>
|
||||
</view>
|
||||
<text class="order-status">{{ item.statusText }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-orders-card delivery-orders-list-card">
|
||||
<view class="delivery-orders-card-header">
|
||||
<view>
|
||||
<text class="delivery-orders-card-title">工单列表</text>
|
||||
<text class="delivery-orders-card-subtitle">突出状态、地址、风险与下一步处理动作</text>
|
||||
<view class="meta-box" @click="goDetail(item.id)">
|
||||
<text class="meta-text">地址:{{ item.address }} {{ item.addressDetail }}</text>
|
||||
<text class="meta-text">时长:{{ item.duration }} 分钟 · 预计收入:¥{{ item.staffIncome }}</text>
|
||||
<text class="meta-text">风险:{{ formatTags(item.riskTags) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="orders.length == 0" class="empty-box"><text class="empty-text">{{ getEmptyText() }}</text></view>
|
||||
<view v-for="item in orders" :key="item.id" class="order-card" :class="getStatusSurfaceClass(item.status)">
|
||||
<view class="card-top">
|
||||
<view class="order-main" @click="goDetail(item.id)">
|
||||
<text class="order-title">{{ item.serviceType }} · {{ item.serviceName }}</text>
|
||||
<text class="order-meta">服务对象:{{ item.elderNameMasked }}</text>
|
||||
</view>
|
||||
<ServiceStatusTag :text="item.statusText" :tone="item.statusTone"></ServiceStatusTag>
|
||||
</view>
|
||||
<view class="order-info-box" @click="goDetail(item.id)">
|
||||
<text class="order-meta">预约时间:{{ item.appointmentStartTime }}</text>
|
||||
<text class="order-meta">服务地址:{{ item.addressSummary }}</text>
|
||||
<text class="order-meta">距离:{{ item.distanceKm }} · 风险:{{ formatRiskTags(item.riskTags) }}</text>
|
||||
</view>
|
||||
<view class="order-footer">
|
||||
<text class="order-next-text">下一步:{{ getPrimaryActionText(item.status) }}</text>
|
||||
<view class="order-action-btn order-action-btn-secondary" @click="goDetail(item.id)">
|
||||
<text class="order-action-btn-text order-action-btn-text-secondary">查看详情</text>
|
||||
</view>
|
||||
<view v-if="item.status == 'pending_accept'" class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click="acceptOrder(item.id)"><text class="order-action-btn-text">接单</text></view>
|
||||
<view v-else-if="item.status == 'accepted'" class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click="goRoute(item.id)"><text class="order-action-btn-text">去出发</text></view>
|
||||
<view v-else-if="item.status == 'on_the_way' || item.status == 'arrived'" class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click="goCheckin(item.id)"><text class="order-action-btn-text">去签到</text></view>
|
||||
<view v-else-if="item.status == 'checked_in' || item.status == 'serving' || item.status == 'pending_submit' || item.status == 'pending_acceptance'" class="order-action-btn" :class="getPrimaryActionClass(item.status)" @click="goExecute(item.id)"><text class="order-action-btn-text">继续服务</text></view>
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goDetail(item.id)"><text class="outline-btn-text">查看详情</text></view>
|
||||
<view v-if="showReject(item.status)" class="warn-btn" @click="rejectOrder(item.id)"><text class="warn-btn-text">拒单</text></view>
|
||||
<view class="primary-btn" @click="handleAction(item.id, item.status)"><text class="primary-btn-text">{{ getActionText(item.status) }}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-orders-safe"></view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import ServiceStatusTag from '@/components/homeService/ServiceStatusTag.uvue'
|
||||
import { acceptDeliveryOrder, getDeliveryOrders } from '@/services/deliveryService.uts'
|
||||
import type { DeliveryOrderType } from '@/types/delivery.uts'
|
||||
import type { DeliveryOrderStatus, DeliveryOrderType } from '@/types/delivery.uts'
|
||||
import {
|
||||
acceptServiceOrder,
|
||||
checkInServiceOrder,
|
||||
completeServiceOrder,
|
||||
getHistoryServiceOrders,
|
||||
getPendingServiceOrders,
|
||||
getTodayServiceOrders,
|
||||
markArrived,
|
||||
markDeparted,
|
||||
rejectServiceOrder,
|
||||
startServiceOrder
|
||||
} from '@/services/deliveryService.uts'
|
||||
import { getDeliveryOrderTabs, getPrimaryActionText } from '@/utils/deliveryCareUi.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
|
||||
|
||||
const tabs = [
|
||||
{ label: '全部', value: 'all' },
|
||||
{ label: '待接单', value: 'pending_accept' },
|
||||
{ label: '待出发', value: 'accepted' },
|
||||
{ label: '服务中', value: 'serving' },
|
||||
{ label: '待提交', value: 'pending_submit' },
|
||||
{ label: '已完成', value: 'completed' },
|
||||
{ label: '异常', value: 'exception' }
|
||||
]
|
||||
const tabs = getDeliveryOrderTabs()
|
||||
const currentTab = ref('pending')
|
||||
const orders = ref([] as Array<DeliveryOrderType>)
|
||||
|
||||
const currentTab = ref('all')
|
||||
const activeTabViewId = ref('status-tab-all')
|
||||
const orders = ref<Array<DeliveryOrderType>>([])
|
||||
const emptyText = computed((): string => {
|
||||
if (currentTab.value == 'pending') return '暂无待接单订单'
|
||||
if (currentTab.value == 'today') return '暂无今日订单'
|
||||
return '暂无历史订单'
|
||||
})
|
||||
|
||||
function getCurrentTabLabel(): string {
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
if (tabs[i].value == currentTab.value) {
|
||||
return tabs[i].label
|
||||
async function loadData() {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok) {
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'pending') {
|
||||
orders.value = await getPendingServiceOrders()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'history') {
|
||||
orders.value = await getHistoryServiceOrders()
|
||||
return
|
||||
}
|
||||
orders.value = await getTodayServiceOrders()
|
||||
}
|
||||
|
||||
function consumeStoredTab(): void {
|
||||
const storedTab = uni.getStorageSync('delivery_order_tab') as string | null
|
||||
if (storedTab != null && storedTab != '') {
|
||||
currentTab.value = storedTab
|
||||
uni.removeStorageSync('delivery_order_tab')
|
||||
}
|
||||
}
|
||||
|
||||
function switchTab(tab: string) {
|
||||
currentTab.value = tab
|
||||
loadData()
|
||||
}
|
||||
|
||||
function formatTags(tags: Array<string>): string {
|
||||
if (tags.length == 0) return '常规'
|
||||
return tags.join(' / ')
|
||||
}
|
||||
|
||||
function showReject(status: DeliveryOrderStatus): boolean {
|
||||
return status == 'pending_assignment' || status == 'pending_accept'
|
||||
}
|
||||
|
||||
function getActionText(status: DeliveryOrderStatus): string {
|
||||
return getPrimaryActionText(status)
|
||||
}
|
||||
|
||||
function goDetail(orderId: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId })
|
||||
}
|
||||
|
||||
function goRecord(orderId: string) {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/service-record/index?id=' + orderId })
|
||||
}
|
||||
|
||||
function rejectOrder(orderId: string) {
|
||||
uni.showActionSheet({
|
||||
itemList: ['时间冲突', '距离过远', '技能不匹配', '其他原因'],
|
||||
success: async (result) => {
|
||||
const reasons = ['时间冲突', '距离过远', '技能不匹配', '其他原因']
|
||||
const reason = reasons[result.tapIndex]
|
||||
await rejectServiceOrder(orderId, reason)
|
||||
uni.showToast({ title: '已拒单', icon: 'success' })
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
}
|
||||
return '全部'
|
||||
}
|
||||
|
||||
function getCurrentTabSubtitle(): string {
|
||||
if (currentTab.value == 'pending_accept') {
|
||||
return '优先响应新派单,避免错过服务时效'
|
||||
async function handleAction(orderId: string, status: DeliveryOrderStatus) {
|
||||
if (status == 'pending_assignment' || status == 'pending_accept') {
|
||||
await acceptServiceOrder(orderId)
|
||||
uni.showToast({ title: '接单成功', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'accepted') {
|
||||
return '确认出发路线,尽快进入上门流程'
|
||||
if (status == 'accepted' || status == 'waiting_departure') {
|
||||
await markDeparted(orderId)
|
||||
uni.showToast({ title: '已标记出发', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'serving') {
|
||||
return '关注执行进度、签到与服务记录'
|
||||
if (status == 'departed' || status == 'on_the_way') {
|
||||
await markArrived(orderId)
|
||||
uni.showToast({ title: '已标记到达', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'pending_submit') {
|
||||
return '尽快补齐记录,完成本次服务提交'
|
||||
if (status == 'arrived') {
|
||||
await checkInServiceOrder(orderId, '已到达并签到', null)
|
||||
uni.showToast({ title: '签到成功', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'completed') {
|
||||
return '回顾已完成服务,跟进结算与评价反馈'
|
||||
if (status == 'checked_in') {
|
||||
await startServiceOrder(orderId)
|
||||
uni.showToast({ title: '已开始服务', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
if (currentTab.value == 'exception') {
|
||||
return '优先处理异常事项,保障服务连续性'
|
||||
if (status == 'in_service' || status == 'serving' || status == 'completed') {
|
||||
goRecord(orderId)
|
||||
return
|
||||
}
|
||||
return '集中查看全部服务工单与处理进展'
|
||||
}
|
||||
|
||||
function isValidTab(tab: string): boolean {
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
if (tabs[i].value == tab) {
|
||||
return true
|
||||
if (status == 'pending_confirm' || status == 'pending_acceptance' || status == 'pending_submit') {
|
||||
const result = await completeServiceOrder(orderId)
|
||||
if (result == null) {
|
||||
uni.showToast({ title: '请先填写服务记录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: '服务已完成', icon: 'success' })
|
||||
loadData()
|
||||
return
|
||||
}
|
||||
return false
|
||||
goDetail(orderId)
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
consumeStoredTab()
|
||||
loadData()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
consumeStoredTab()
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
min-height: 100%;
|
||||
margin-left: -24rpx;
|
||||
margin-right: -24rpx;
|
||||
margin-top: -24rpx;
|
||||
padding: 0 24rpx 36rpx;
|
||||
background-color: #f3f8fb;
|
||||
}
|
||||
|
||||
function syncActiveTabViewId(): void {
|
||||
activeTabViewId.value = 'status-tab-' + currentTab.value
|
||||
.hero {
|
||||
padding: 68rpx 28rpx 26rpx;
|
||||
border-bottom-left-radius: 32rpx;
|
||||
border-bottom-right-radius: 32rpx;
|
||||
background: linear-gradient(180deg, #1f7db4 0%, #1aa67f 100%);
|
||||
}
|
||||
|
||||
function applyTab(tab: string): void {
|
||||
if (tab == '' || !isValidTab(tab)) {
|
||||
currentTab.value = 'all'
|
||||
} else {
|
||||
currentTab.value = tab
|
||||
}
|
||||
syncActiveTabViewId()
|
||||
.hero-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-subtitle,
|
||||
.meta-text,
|
||||
.empty-text,
|
||||
.outline-btn-text,
|
||||
.tab-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
margin-top: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.tab-row,
|
||||
.order-top,
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.tab-row {
|
||||
justify-content: space-between;
|
||||
margin-top: 20rpx;
|
||||
padding: 10rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
width: 32%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.tab-item-active {
|
||||
background-color: #e6f3fa;
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.tab-text-active {
|
||||
font-weight: 700;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.list-card {
|
||||
margin-top: 22rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 28rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.order-card {
|
||||
padding: 24rpx;
|
||||
margin-bottom: 18rpx;
|
||||
border-radius: 22rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.order-top,
|
||||
.action-row {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.order-main {
|
||||
flex: 1;
|
||||
padding-right: 18rpx;
|
||||
}
|
||||
|
||||
.order-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.order-subtitle,
|
||||
.order-status,
|
||||
.meta-text,
|
||||
.empty-text,
|
||||
.outline-btn-text,
|
||||
.warn-btn-text,
|
||||
.primary-btn-text {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.order-subtitle,
|
||||
.meta-text,
|
||||
.empty-text,
|
||||
.outline-btn-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.order-status {
|
||||
font-size: 24rpx;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.meta-box {
|
||||
margin-top: 14rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #eef7fb;
|
||||
}
|
||||
|
||||
.action-row {
|
||||
margin-top: 18rpx;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.warn-btn,
|
||||
.primary-btn {
|
||||
width: 31%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.outline-btn {
|
||||
background-color: #eef6fa;
|
||||
}
|
||||
|
||||
.warn-btn {
|
||||
background-color: #fff3e6;
|
||||
}
|
||||
|
||||
.warn-btn-text {
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
color: #c77413;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background-color: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.empty-box {
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
function consumeStoredTab(): void {
|
||||
|
||||
@@ -1,313 +1,72 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="我的" fallback-url="/pages/mall/delivery/home/index" :hide-header="true">
|
||||
<view class="delivery-profile-page">
|
||||
<view class="delivery-profile-hero">
|
||||
<view class="delivery-hero-top">
|
||||
<view class="delivery-avatar">
|
||||
<text class="delivery-avatar-text">{{ getAvatarText() }}</text>
|
||||
</view>
|
||||
<view class="delivery-user-main">
|
||||
<text class="delivery-user-name">{{ deliveryInfo != null ? deliveryInfo.name : '服务人员' }}</text>
|
||||
<view class="delivery-user-tags">
|
||||
<text class="delivery-user-tag">{{ deliveryInfo != null ? deliveryInfo.role : '居家服务人员' }}</text>
|
||||
<text class="delivery-user-tag delivery-user-tag-light">{{ getOnlineStatusText() }}</text>
|
||||
</view>
|
||||
<text class="delivery-user-org">{{ displayOrganizationName() }}</text>
|
||||
</view>
|
||||
<view class="delivery-setting-btn" @click="goSettings">
|
||||
<text class="delivery-setting-text">设置</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-hero-info-row">
|
||||
<view class="delivery-hero-info-item">
|
||||
<text class="delivery-hero-info-value">{{ displayStaffNo() }}</text>
|
||||
<text class="delivery-hero-info-label">人员编号</text>
|
||||
</view>
|
||||
<view class="delivery-hero-info-item">
|
||||
<text class="delivery-hero-info-value">{{ getCertificateStatusText() }}</text>
|
||||
<text class="delivery-hero-info-label">资质状态</text>
|
||||
</view>
|
||||
<view class="delivery-hero-info-item">
|
||||
<text class="delivery-hero-info-value">{{ displayServiceArea() }}</text>
|
||||
<text class="delivery-hero-info-label">服务区域</text>
|
||||
<view class="page">
|
||||
<view class="hero">
|
||||
<view class="hero-row">
|
||||
<view class="avatar"><text class="avatar-text">护</text></view>
|
||||
<view class="hero-main">
|
||||
<text class="hero-name">{{ nameText }}</text>
|
||||
<text class="hero-role">服务人员 / 护工 / 上门服务人员</text>
|
||||
<text class="hero-org">{{ organizationText }}</text>
|
||||
</view>
|
||||
<view class="hero-setting" @click="goSettings"><text class="hero-setting-text">设置</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-level-card">
|
||||
<view class="delivery-card-header">
|
||||
<view>
|
||||
<text class="delivery-card-title">服务等级</text>
|
||||
<text class="delivery-card-subtitle">接单、完成服务和用户好评会提升等级</text>
|
||||
</view>
|
||||
<text class="delivery-level-badge">{{ growthStats.levelName }}</text>
|
||||
</view>
|
||||
<view class="card stats-card">
|
||||
<view class="stat-item"><text class="stat-value">{{ acceptedText }}</text><text class="stat-label">今日接单</text></view>
|
||||
<view class="stat-item"><text class="stat-value">{{ servingText }}</text><text class="stat-label">服务中</text></view>
|
||||
<view class="stat-item"><text class="stat-value">{{ completedText }}</text><text class="stat-label">今日完成</text></view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-level-main">
|
||||
<text class="delivery-growth-value">{{ growthStats.growthValue }}</text>
|
||||
<text class="delivery-growth-total"> / {{ growthStats.nextLevelValue }} 成长值</text>
|
||||
</view>
|
||||
<view class="card">
|
||||
<text class="section-title">账号信息</text>
|
||||
<text class="row-text">人员编号:{{ staffNoText }}</text>
|
||||
<text class="row-text">联系电话:{{ phoneText }}</text>
|
||||
<text class="row-text">服务区域:{{ serviceAreaText }}</text>
|
||||
<text class="row-text">资质状态:{{ certificateText }}</text>
|
||||
<text class="row-text">资质到期:{{ certificateExpireText }}</text>
|
||||
</view>
|
||||
|
||||
<view class="delivery-progress-track">
|
||||
<view class="delivery-progress-fill" :style="{ width: getLevelProgressWidth() }"></view>
|
||||
</view>
|
||||
|
||||
<text class="delivery-level-tip">{{ growthStats.nextTips }}</text>
|
||||
|
||||
<view class="delivery-level-tags">
|
||||
<text class="delivery-level-tag">接单稳定</text>
|
||||
<text class="delivery-level-tag">好评优秀</text>
|
||||
<text class="delivery-level-tag">准时服务</text>
|
||||
<view class="card">
|
||||
<text class="section-title">工作状态</text>
|
||||
<view class="status-row">
|
||||
<view class="status-btn" :class="onlineStatusText == 'online' ? 'status-btn-active' : ''" @click="changeStatus('online')"><text class="status-btn-text">在线</text></view>
|
||||
<view class="status-btn" :class="onlineStatusText == 'resting' ? 'status-btn-active' : ''" @click="changeStatus('resting')"><text class="status-btn-text">离线</text></view>
|
||||
<view class="status-btn" :class="onlineStatusText == 'busy' ? 'status-btn-active' : ''" @click="changeStatus('busy')"><text class="status-btn-text">忙碌</text></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-stats-card">
|
||||
<view class="delivery-stat-item">
|
||||
<text class="delivery-stat-value">{{ deliveryInfo != null ? deliveryInfo.todayAccepted : 0 }}</text>
|
||||
<text class="delivery-stat-label">今日接单</text>
|
||||
</view>
|
||||
<view class="delivery-stat-item">
|
||||
<text class="delivery-stat-value">{{ deliveryInfo != null ? deliveryInfo.todayServing : 0 }}</text>
|
||||
<text class="delivery-stat-label">服务中</text>
|
||||
</view>
|
||||
<view class="delivery-stat-item">
|
||||
<text class="delivery-stat-value">{{ deliveryInfo != null ? deliveryInfo.todayCompleted : 0 }}</text>
|
||||
<text class="delivery-stat-label">今日完成</text>
|
||||
</view>
|
||||
<view class="delivery-stat-item">
|
||||
<text class="delivery-stat-value">{{ growthStats.goodRate }}%</text>
|
||||
<text class="delivery-stat-label">好评率</text>
|
||||
</view>
|
||||
<view class="card action-card">
|
||||
<view class="tool-item" @click="goOrders('today')"><text class="tool-title">今日订单</text><text class="tool-desc">查看待服务订单</text></view>
|
||||
<view class="tool-item" @click="goOrders('history')"><text class="tool-title">历史订单</text><text class="tool-desc">查看已完成和异常</text></view>
|
||||
<view class="tool-item" @click="goSettings"><text class="tool-title">设置</text><text class="tool-desc">退出登录和提醒设置</text></view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-status-card">
|
||||
<view class="delivery-card-header">
|
||||
<view>
|
||||
<text class="delivery-card-title">当前状态</text>
|
||||
<text class="delivery-card-subtitle">切换后会影响平台派单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delivery-status-row">
|
||||
<view class="delivery-status-btn" :class="deliveryInfo != null && deliveryInfo.onlineStatus == 'online' ? 'delivery-status-active' : ''" @click="changeStatus('online')">
|
||||
<text class="delivery-status-text">在线</text>
|
||||
</view>
|
||||
<view class="delivery-status-btn" :class="deliveryInfo != null && deliveryInfo.onlineStatus == 'resting' ? 'delivery-status-active' : ''" @click="changeStatus('resting')">
|
||||
<text class="delivery-status-text">休息</text>
|
||||
</view>
|
||||
<view class="delivery-status-btn" :class="deliveryInfo != null && deliveryInfo.onlineStatus == 'busy' ? 'delivery-status-active' : ''" @click="changeStatus('busy')">
|
||||
<text class="delivery-status-text">忙碌</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-tools-card">
|
||||
<view class="delivery-card-header">
|
||||
<text class="delivery-card-title">常用功能</text>
|
||||
</view>
|
||||
<view class="delivery-tools-grid">
|
||||
<view class="delivery-tool-item" @click="goOrders">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">单</text></view>
|
||||
<text class="delivery-tool-name">工单列表</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="goMessages">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">息</text></view>
|
||||
<text class="delivery-tool-name">消息中心</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="goCertificates">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">证</text></view>
|
||||
<text class="delivery-tool-name">资质证书</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="goRecords">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">记</text></view>
|
||||
<text class="delivery-tool-name">服务记录</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="showTodo('异常上报')">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">异</text></view>
|
||||
<text class="delivery-tool-name">异常上报</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="showTodo('服务规范')">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">规</text></view>
|
||||
<text class="delivery-tool-name">服务规范</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="goSettings">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">设</text></view>
|
||||
<text class="delivery-tool-name">设置</text>
|
||||
</view>
|
||||
<view class="delivery-tool-item" @click="showTodo('联系平台')">
|
||||
<view class="delivery-tool-icon"><text class="delivery-tool-icon-text">客</text></view>
|
||||
<text class="delivery-tool-name">联系平台</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-account-card">
|
||||
<view class="delivery-card-header">
|
||||
<view>
|
||||
<text class="delivery-card-title">账号与资质</text>
|
||||
<text class="delivery-card-subtitle">展示机构、区域、证书与账号安全信息</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="delivery-account-row">
|
||||
<text class="delivery-account-label">所属机构</text>
|
||||
<text class="delivery-account-value">{{ displayOrganizationName() }}</text>
|
||||
</view>
|
||||
<view class="delivery-account-row">
|
||||
<text class="delivery-account-label">服务区域</text>
|
||||
<text class="delivery-account-value">{{ displayServiceArea() }}</text>
|
||||
</view>
|
||||
<view class="delivery-account-row">
|
||||
<text class="delivery-account-label">资质状态</text>
|
||||
<text class="delivery-account-value">{{ getCertificateStatusText() }}</text>
|
||||
</view>
|
||||
<view class="delivery-account-row delivery-account-row-last">
|
||||
<text class="delivery-account-label">资质到期</text>
|
||||
<text class="delivery-account-value">{{ displayCertificateExpireAt() != '' ? displayCertificateExpireAt() : '暂无' }}</text>
|
||||
</view>
|
||||
<view class="delivery-logout-btn" @click="logout">
|
||||
<text class="delivery-logout-text">退出登录</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delivery-profile-safe"></view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import type { DeliveryInfoType } from '@/types/delivery.uts'
|
||||
import { getDeliveryProfile, updateDeliveryOnlineStatus } from '@/services/deliveryService.uts'
|
||||
import { logoutDelivery, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
|
||||
type DeliveryGrowthStatsType = {
|
||||
levelName: string
|
||||
growthValue: number
|
||||
nextLevelValue: number
|
||||
completedTotal: number
|
||||
goodRate: number
|
||||
goodReviewCount: number
|
||||
onTimeRate: number
|
||||
nextTips: string
|
||||
}
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
|
||||
const deliveryInfo = ref<DeliveryInfoType | null>(null)
|
||||
|
||||
// TODO: 后续接入真实 delivery 服务等级统计接口
|
||||
const growthStats = ref({
|
||||
levelName: '银牌服务师',
|
||||
growthValue: 486,
|
||||
nextLevelValue: 800,
|
||||
completedTotal: 126,
|
||||
goodRate: 98,
|
||||
goodReviewCount: 112,
|
||||
onTimeRate: 96,
|
||||
nextTips: '再完成 12 单并获得 5 个好评可升级'
|
||||
} as DeliveryGrowthStatsType)
|
||||
|
||||
function displayOrganizationName(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '暂未绑定服务机构'
|
||||
}
|
||||
const organizationName = deliveryInfo.value.organizationName.trim()
|
||||
if (organizationName != '') {
|
||||
return organizationName
|
||||
}
|
||||
return '暂未绑定服务机构'
|
||||
}
|
||||
|
||||
function displayStaffNo(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '待分配'
|
||||
}
|
||||
const staffNo = deliveryInfo.value.staffNo.trim()
|
||||
if (staffNo != '') {
|
||||
return staffNo
|
||||
}
|
||||
return '待分配'
|
||||
}
|
||||
|
||||
function displayServiceArea(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '待完善'
|
||||
}
|
||||
const serviceArea = deliveryInfo.value.serviceArea.trim()
|
||||
if (serviceArea != '') {
|
||||
return serviceArea
|
||||
}
|
||||
return '待完善'
|
||||
}
|
||||
|
||||
function displayCertificateExpireAt(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return ''
|
||||
}
|
||||
return deliveryInfo.value.certificateExpireAt.trim()
|
||||
}
|
||||
|
||||
function getOnlineStatusText(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '未登录'
|
||||
}
|
||||
const status = deliveryInfo.value.onlineStatus
|
||||
if (status == 'online') {
|
||||
return '在线接单'
|
||||
}
|
||||
if (status == 'resting') {
|
||||
return '休息中'
|
||||
}
|
||||
if (status == 'busy') {
|
||||
return '忙碌中'
|
||||
}
|
||||
return '未知状态'
|
||||
}
|
||||
|
||||
function getCertificateStatusText(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '待认证'
|
||||
}
|
||||
const status = deliveryInfo.value.certificateStatus.trim()
|
||||
if (status == 'valid') {
|
||||
return '已认证'
|
||||
}
|
||||
if (status == 'expired') {
|
||||
return '已过期'
|
||||
}
|
||||
if (status == 'pending') {
|
||||
return '审核中'
|
||||
}
|
||||
if (status != '') {
|
||||
return status
|
||||
}
|
||||
return '待认证'
|
||||
}
|
||||
|
||||
function getAvatarText(): string {
|
||||
if (deliveryInfo.value == null) {
|
||||
return '护'
|
||||
}
|
||||
const name = deliveryInfo.value.name.trim()
|
||||
if (name == '') {
|
||||
return '护'
|
||||
}
|
||||
return name.substring(0, 1)
|
||||
}
|
||||
|
||||
function getLevelProgressWidth(): string {
|
||||
if (growthStats.value.nextLevelValue <= 0) {
|
||||
return '0%'
|
||||
}
|
||||
const percent = growthStats.value.growthValue * 100 / growthStats.value.nextLevelValue
|
||||
if (percent >= 100) {
|
||||
return '100%'
|
||||
}
|
||||
if (percent <= 0) {
|
||||
return '0%'
|
||||
}
|
||||
return percent.toString() + '%'
|
||||
}
|
||||
const nameText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.name : '服务人员')
|
||||
const organizationText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.organizationName : '机构待绑定')
|
||||
const acceptedText = computed((): string => deliveryInfo.value != null ? String(deliveryInfo.value.todayAccepted) : '0')
|
||||
const servingText = computed((): string => deliveryInfo.value != null ? String(deliveryInfo.value.todayServing) : '0')
|
||||
const completedText = computed((): string => deliveryInfo.value != null ? String(deliveryInfo.value.todayCompleted) : '0')
|
||||
const staffNoText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.staffNo : '待分配')
|
||||
const phoneText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.phone : '待完善')
|
||||
const serviceAreaText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.serviceArea : '待完善')
|
||||
const certificateText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.certificateStatus : '待认证')
|
||||
const certificateExpireText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.certificateExpireAt : '暂无')
|
||||
const onlineStatusText = computed((): string => deliveryInfo.value != null ? deliveryInfo.value.onlineStatus : 'resting')
|
||||
|
||||
async function loadData() {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
@@ -318,419 +77,193 @@ async function loadData() {
|
||||
}
|
||||
|
||||
async function changeStatus(status: string) {
|
||||
const nextInfo = await updateDeliveryOnlineStatus(status)
|
||||
if (nextInfo != null) {
|
||||
deliveryInfo.value = nextInfo
|
||||
uni.showToast({ title: '状态已更新', icon: 'success' })
|
||||
if (deliveryInfo.value == null) {
|
||||
return
|
||||
}
|
||||
deliveryInfo.value = await updateDeliveryOnlineStatus(status)
|
||||
uni.showToast({ title: '状态已更新', icon: 'success' })
|
||||
}
|
||||
|
||||
function goCertificates() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/profile/certificates' })
|
||||
function goOrders(tab: string) {
|
||||
uni.setStorageSync('delivery_order_tab', tab)
|
||||
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
|
||||
}
|
||||
|
||||
function goSettings() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/profile/settings' })
|
||||
}
|
||||
|
||||
function goOrders() {
|
||||
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
|
||||
}
|
||||
|
||||
function goMessages() {
|
||||
uni.switchTab({ url: '/pages/mall/delivery/messages/index' })
|
||||
}
|
||||
|
||||
function goRecords() {
|
||||
uni.navigateTo({ url: '/pages/mall/delivery/records/index' })
|
||||
}
|
||||
|
||||
function showTodo(title: string) {
|
||||
uni.showToast({
|
||||
title: title + '建设中',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await logoutDelivery()
|
||||
uni.reLaunch({ url: '/pages/user/login?mode=delivery' })
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.delivery-profile-page {
|
||||
.page {
|
||||
min-height: 100%;
|
||||
margin-left: -24rpx;
|
||||
margin-right: -24rpx;
|
||||
margin-top: -24rpx;
|
||||
padding-bottom: 32rpx;
|
||||
background-color: #f4f8fb;
|
||||
padding: 0 24rpx 36rpx;
|
||||
background-color: #f3f8fb;
|
||||
}
|
||||
|
||||
.delivery-profile-hero {
|
||||
padding: 72rpx 28rpx 34rpx;
|
||||
border-bottom-left-radius: 36rpx;
|
||||
border-bottom-right-radius: 36rpx;
|
||||
background-color: #0f766e;
|
||||
}
|
||||
|
||||
.delivery-hero-top {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delivery-avatar {
|
||||
width: 112rpx;
|
||||
height: 112rpx;
|
||||
margin-right: 22rpx;
|
||||
border-radius: 56rpx;
|
||||
background-color: rgba(255, 255, 255, 0.92);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.delivery-avatar-text {
|
||||
font-size: 42rpx;
|
||||
font-weight: 700;
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.delivery-user-main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.delivery-user-name {
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.delivery-user-tags {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-top: 12rpx;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.delivery-user-tag {
|
||||
margin-right: 10rpx;
|
||||
margin-bottom: 8rpx;
|
||||
padding: 6rpx 14rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
color: #0f766e;
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.delivery-user-tag-light {
|
||||
color: #ffffff;
|
||||
background-color: rgba(255, 255, 255, 0.22);
|
||||
}
|
||||
|
||||
.delivery-user-org {
|
||||
margin-top: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.delivery-setting-btn {
|
||||
padding: 10rpx 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: rgba(255, 255, 255, 0.18);
|
||||
}
|
||||
|
||||
.delivery-setting-text {
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.delivery-hero-info-row {
|
||||
margin-top: 32rpx;
|
||||
padding: 22rpx 18rpx;
|
||||
border-radius: 26rpx;
|
||||
background-color: rgba(255, 255, 255, 0.18);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.delivery-hero-info-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delivery-hero-info-value {
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
max-width: 180rpx;
|
||||
text-align: center;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.delivery-hero-info-label {
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
}
|
||||
|
||||
.delivery-level-card,
|
||||
.delivery-stats-card,
|
||||
.delivery-status-card,
|
||||
.delivery-tools-card,
|
||||
.delivery-account-card {
|
||||
margin-left: 24rpx;
|
||||
margin-right: 24rpx;
|
||||
margin-top: 22rpx;
|
||||
padding: 26rpx;
|
||||
.hero,
|
||||
.card {
|
||||
border-radius: 28rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 28rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.delivery-level-card {
|
||||
margin-top: -18rpx;
|
||||
position: relative;
|
||||
.hero {
|
||||
padding: 64rpx 28rpx 28rpx;
|
||||
border-bottom-left-radius: 36rpx;
|
||||
border-bottom-right-radius: 36rpx;
|
||||
background: linear-gradient(180deg, #1f7db4 0%, #22a380 100%);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.delivery-card-header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.delivery-card-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.delivery-card-subtitle {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-level-badge {
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
color: #92400e;
|
||||
background-color: #fef3c7;
|
||||
}
|
||||
|
||||
.delivery-level-main {
|
||||
margin-top: 24rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.delivery-growth-value {
|
||||
font-size: 46rpx;
|
||||
font-weight: 700;
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.delivery-growth-total {
|
||||
margin-left: 6rpx;
|
||||
margin-bottom: 6rpx;
|
||||
font-size: 24rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-progress-track {
|
||||
margin-top: 18rpx;
|
||||
height: 16rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #e2e8f0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.delivery-progress-fill {
|
||||
height: 16rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #0f766e;
|
||||
}
|
||||
|
||||
.delivery-level-tip {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
font-size: 23rpx;
|
||||
line-height: 34rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-level-tags {
|
||||
margin-top: 18rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.delivery-level-tag {
|
||||
margin-right: 12rpx;
|
||||
margin-bottom: 10rpx;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 22rpx;
|
||||
color: #0f766e;
|
||||
background-color: #ecfdf5;
|
||||
}
|
||||
|
||||
.delivery-stats-card {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding-top: 28rpx;
|
||||
padding-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.delivery-stat-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delivery-stat-value {
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.delivery-stat-label {
|
||||
margin-top: 8rpx;
|
||||
font-size: 22rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-status-row {
|
||||
margin-top: 22rpx;
|
||||
.hero-row,
|
||||
.stats-card,
|
||||
.status-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.delivery-status-btn {
|
||||
width: 31%;
|
||||
height: 68rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: #f1f5f9;
|
||||
display: flex;
|
||||
.hero-row {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border-radius: 48rpx;
|
||||
background-color: rgba(255, 255, 255, 0.22);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.delivery-status-active {
|
||||
background-color: #0f766e;
|
||||
box-shadow: 0 8rpx 18rpx rgba(15, 118, 110, 0.18);
|
||||
}
|
||||
|
||||
.delivery-status-text {
|
||||
font-size: 26rpx;
|
||||
.avatar-text {
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-status-active .delivery-status-text {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.delivery-tools-grid {
|
||||
margin-top: 22rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
.hero-main {
|
||||
flex: 1;
|
||||
padding-left: 20rpx;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.delivery-tool-item {
|
||||
width: 25%;
|
||||
margin-bottom: 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delivery-tool-icon {
|
||||
width: 72rpx;
|
||||
height: 72rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ecfdf5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.delivery-tool-icon-text {
|
||||
font-size: 28rpx;
|
||||
.hero-name {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: #0f766e;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.delivery-tool-name {
|
||||
margin-top: 10rpx;
|
||||
font-size: 23rpx;
|
||||
color: #334155;
|
||||
}
|
||||
|
||||
.delivery-account-row {
|
||||
min-height: 72rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
border-bottom-width: 1rpx;
|
||||
border-bottom-color: #eef2f7;
|
||||
}
|
||||
|
||||
.delivery-account-row-last {
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
|
||||
.delivery-account-label {
|
||||
font-size: 26rpx;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.delivery-account-value {
|
||||
max-width: 420rpx;
|
||||
text-align: right;
|
||||
font-size: 26rpx;
|
||||
.hero-role,
|
||||
.hero-org,
|
||||
.stat-label,
|
||||
.row-text,
|
||||
.tool-desc,
|
||||
.hero-setting-text,
|
||||
.status-btn-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.hero-role,
|
||||
.hero-org {
|
||||
margin-top: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.88);
|
||||
}
|
||||
|
||||
.hero-setting {
|
||||
padding: 14rpx 22rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.hero-setting-text {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-top: 22rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.stats-card {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
width: 31%;
|
||||
padding: 22rpx 14rpx;
|
||||
border-radius: 20rpx;
|
||||
background-color: #f7fbfd;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.stat-value,
|
||||
.section-title,
|
||||
.tool-title {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 34rpx;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.stat-label,
|
||||
.tool-desc,
|
||||
.row-text {
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.section-title,
|
||||
.tool-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.delivery-logout-btn {
|
||||
margin-top: 24rpx;
|
||||
height: 76rpx;
|
||||
border-radius: 20rpx;
|
||||
background-color: #fff1f2;
|
||||
display: flex;
|
||||
.row-text {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.status-btn {
|
||||
width: 31%;
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
background-color: #eef6fa;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.delivery-logout-text {
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
color: #e11d48;
|
||||
.status-btn-active {
|
||||
background-color: #d8eef9;
|
||||
}
|
||||
|
||||
.delivery-profile-safe {
|
||||
height: 40rpx;
|
||||
.status-btn-text {
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.tool-item {
|
||||
margin-top: 14rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.tool-title {
|
||||
font-size: 28rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.tool-desc {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -8,20 +8,22 @@
|
||||
<text v-if="deliveryInfo != null" class="info-text">资质状态:{{ deliveryInfo.certificateStatus }}</text>
|
||||
</ServicePanel>
|
||||
|
||||
<ServicePanel title="提醒与权限" subtitle="预留定位权限、语音播报和消息提醒控制。">
|
||||
<ServicePanel title="提醒与权限" subtitle="保留消息提醒和定位权限提示占位。">
|
||||
<view class="setting-row">
|
||||
<text class="setting-text">消息提醒</text>
|
||||
<switch :checked="messageEnabled" color="#0f766e" @change="toggleMessage" />
|
||||
</view>
|
||||
<view class="setting-row">
|
||||
<text class="setting-text">语音播报</text>
|
||||
<switch :checked="voiceEnabled" color="#0f766e" @change="toggleVoice" />
|
||||
<switch :checked="messageEnabled" color="#1f7db4" @change="toggleMessage" />
|
||||
</view>
|
||||
<view class="setting-row">
|
||||
<text class="setting-text">定位权限提示</text>
|
||||
<text class="setting-hint">请确保 Android 和小程序侧授权开启</text>
|
||||
<text class="setting-hint">定位轨迹仅做字段预留,当前为 mock</text>
|
||||
</view>
|
||||
<view class="setting-row setting-row-last">
|
||||
<text class="setting-text">图片上传</text>
|
||||
<text class="setting-hint">当前仅占位,不做真实上传</text>
|
||||
</view>
|
||||
</ServicePanel>
|
||||
|
||||
<view class="logout-btn" @click="confirmLogout"><text class="logout-text">退出登录</text></view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
@@ -32,10 +34,9 @@ import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uv
|
||||
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
|
||||
import type { DeliveryInfoType } from '@/types/delivery.uts'
|
||||
import { getDeliveryProfile } from '@/services/deliveryService.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { logoutDelivery, requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
|
||||
const messageEnabled = ref(true)
|
||||
const voiceEnabled = ref(false)
|
||||
const deliveryInfo = ref<DeliveryInfoType | null>(null)
|
||||
|
||||
function displayOrganizationName(): string {
|
||||
@@ -62,9 +63,7 @@ function displayStaffNo(): string {
|
||||
|
||||
function restoreSettings() {
|
||||
const msg = uni.getStorageSync('delivery_setting_message') as boolean | null
|
||||
const voice = uni.getStorageSync('delivery_setting_voice') as boolean | null
|
||||
messageEnabled.value = msg == null ? true : msg
|
||||
voiceEnabled.value = voice == null ? false : voice
|
||||
}
|
||||
|
||||
function toggleMessage(event: any) {
|
||||
@@ -72,9 +71,17 @@ function toggleMessage(event: any) {
|
||||
uni.setStorageSync('delivery_setting_message', messageEnabled.value)
|
||||
}
|
||||
|
||||
function toggleVoice(event: any) {
|
||||
voiceEnabled.value = event.detail.value === true
|
||||
uni.setStorageSync('delivery_setting_voice', voiceEnabled.value)
|
||||
function confirmLogout() {
|
||||
uni.showModal({
|
||||
title: '退出登录',
|
||||
content: '退出后将清除服务人员信息并返回登录页。',
|
||||
success: async (result) => {
|
||||
if (result.confirm) {
|
||||
await logoutDelivery()
|
||||
uni.reLaunch({ url: '/pages/user/login?mode=delivery' })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
@@ -100,6 +107,10 @@ onShow(() => {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.setting-row-last {
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
@@ -120,4 +131,19 @@ onShow(() => {
|
||||
text-align: right;
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
margin-top: 24rpx;
|
||||
padding: 20rpx 0;
|
||||
border-radius: 18rpx;
|
||||
background-color: #fff1f2;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.logout-text {
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
color: #dc2626;
|
||||
}
|
||||
</style>
|
||||
328
pages/mall/delivery/service-record/index.uvue
Normal file
328
pages/mall/delivery/service-record/index.uvue
Normal file
@@ -0,0 +1,328 @@
|
||||
<template>
|
||||
<ServicePageScaffold title="服务记录" fallback-url="/pages/mall/delivery/orders/detail">
|
||||
<view class="page">
|
||||
<view class="card">
|
||||
<text class="section-title">服务时间</text>
|
||||
<input class="field" v-model="startTime" placeholder="服务开始时间,例如 2026-05-20 15:00" />
|
||||
<input class="field" v-model="endTime" placeholder="服务结束时间,例如 2026-05-20 16:30" />
|
||||
<input class="field" v-model="actualDurationText" placeholder="实际服务时长(分钟)" type="number" />
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">服务内容</text>
|
||||
<view v-for="item in serviceItems" :key="item.id" class="item-row">
|
||||
<view class="item-top">
|
||||
<text class="item-name">{{ item.name }}</text>
|
||||
<switch :checked="item.completed" color="#1f7db4" @change="toggleItem(item.id, $event)" />
|
||||
</view>
|
||||
<input class="field" v-model="item.remark" placeholder="服务过程说明" />
|
||||
<input v-if="item.completed == false" class="field" v-model="item.incompleteReason" placeholder="未完成原因" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">健康与过程记录</text>
|
||||
<textarea class="textarea" v-model="processNote" placeholder="服务过程说明"></textarea>
|
||||
<input class="field" v-model="elderStatus" placeholder="服务对象状态" />
|
||||
<input class="field" v-model="bloodPressure" placeholder="血压" />
|
||||
<input class="field" v-model="heartRate" placeholder="心率" />
|
||||
<input class="field" v-model="bloodSugar" placeholder="血糖" />
|
||||
<input class="field" v-model="bloodOxygen" placeholder="血氧" />
|
||||
<input class="field" v-model="materialsUsed" placeholder="耗材使用记录" />
|
||||
<input class="field" v-model="abnormalNote" placeholder="异常情况说明" />
|
||||
<input class="field" v-model="staffRemark" placeholder="服务人员备注" />
|
||||
<view class="placeholder-row">
|
||||
<view class="placeholder-btn" @click="mockPhoto"><text class="placeholder-btn-text">服务照片占位</text></view>
|
||||
<text class="placeholder-text">{{ photosText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<text class="section-title">家属确认方式</text>
|
||||
<view class="confirm-row">
|
||||
<view class="confirm-item" :class="confirmMethod == 'sms_code' ? 'confirm-item-active' : ''" @click="confirmMethod = 'sms_code'"><text class="confirm-text">验证码确认</text></view>
|
||||
<view class="confirm-item" :class="confirmMethod == 'signature' ? 'confirm-item-active' : ''" @click="confirmMethod = 'signature'"><text class="confirm-text">签字确认</text></view>
|
||||
</view>
|
||||
<input v-if="confirmMethod == 'sms_code'" class="field" v-model="confirmCode" placeholder="验证码 mock" />
|
||||
<input v-else class="field" v-model="signatureName" placeholder="签字人姓名 mock" />
|
||||
</view>
|
||||
|
||||
<view class="action-row">
|
||||
<view class="outline-btn" @click="goBack"><text class="outline-btn-text">返回详情</text></view>
|
||||
<view class="primary-btn" @click="submitRecord"><text class="primary-btn-text">提交服务记录</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</ServicePageScaffold>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
|
||||
import type { DeliveryOrderType, DeliveryServiceItemType, DeliveryServiceRecordType } from '@/types/delivery.uts'
|
||||
import { getServiceOrderDetail, submitServiceRecord } from '@/services/deliveryService.uts'
|
||||
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
|
||||
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
|
||||
|
||||
const orderId = ref('')
|
||||
const order = ref<DeliveryOrderType | null>(null)
|
||||
const serviceItems = ref([] as Array<DeliveryServiceItemType>)
|
||||
const startTime = ref('')
|
||||
const endTime = ref('')
|
||||
const actualDurationText = ref('90')
|
||||
const processNote = ref('')
|
||||
const elderStatus = ref('')
|
||||
const bloodPressure = ref('')
|
||||
const heartRate = ref('')
|
||||
const bloodSugar = ref('')
|
||||
const bloodOxygen = ref('')
|
||||
const materialsUsed = ref('')
|
||||
const abnormalNote = ref('')
|
||||
const staffRemark = ref('')
|
||||
const confirmMethod = ref('sms_code')
|
||||
const confirmCode = ref('')
|
||||
const signatureName = ref('')
|
||||
const photoCount = ref(0)
|
||||
|
||||
const photosText = computed((): string => '已添加占位照片 ' + String(photoCount.value) + ' 张')
|
||||
|
||||
function toggleItem(itemId: string, event: any) {
|
||||
for (let i = 0; i < serviceItems.value.length; i++) {
|
||||
if (serviceItems.value[i].id == itemId) {
|
||||
serviceItems.value[i].completed = event.detail.value === true
|
||||
serviceItems.value[i].updatedAt = new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
if (serviceItems.value[i].completed) {
|
||||
serviceItems.value[i].incompleteReason = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mockPhoto() {
|
||||
photoCount.value = photoCount.value + 1
|
||||
uni.showToast({ title: '已添加照片占位', icon: 'success' })
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
const authResult = await requireDeliveryAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!authResult.ok || orderId.value == '') {
|
||||
return
|
||||
}
|
||||
order.value = await getServiceOrderDetail(orderId.value)
|
||||
if (order.value != null) {
|
||||
serviceItems.value = order.value.serviceItems
|
||||
startTime.value = order.value.startServiceTime != null && order.value.startServiceTime != '' ? order.value.startServiceTime : order.value.appointmentTime
|
||||
endTime.value = order.value.finishTime
|
||||
processNote.value = order.value.serviceSummary
|
||||
staffRemark.value = order.value.progressNote
|
||||
if (order.value.serviceRecord != null) {
|
||||
elderStatus.value = order.value.serviceRecord!.elderStatus
|
||||
bloodPressure.value = order.value.serviceRecord!.healthMetrics.bloodPressure
|
||||
heartRate.value = order.value.serviceRecord!.healthMetrics.heartRate
|
||||
bloodSugar.value = order.value.serviceRecord!.healthMetrics.bloodSugar
|
||||
bloodOxygen.value = order.value.serviceRecord!.healthMetrics.bloodOxygen
|
||||
materialsUsed.value = order.value.serviceRecord!.materialsUsed
|
||||
abnormalNote.value = order.value.serviceRecord!.abnormalNote
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateRecord(): boolean {
|
||||
if (startTime.value == '' || endTime.value == '') {
|
||||
uni.showToast({ title: '请填写开始和结束时间', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
for (let i = 0; i < serviceItems.value.length; i++) {
|
||||
if (serviceItems.value[i].completed == false && serviceItems.value[i].incompleteReason == '') {
|
||||
uni.showToast({ title: '未完成项目需要说明原因', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function submitRecordAction() {
|
||||
if (!validateRecord()) {
|
||||
return
|
||||
}
|
||||
const record = {
|
||||
id: 'record-' + orderId.value,
|
||||
orderId: orderId.value,
|
||||
startTime: startTime.value,
|
||||
endTime: endTime.value,
|
||||
actualDurationMinutes: parseInt(actualDurationText.value),
|
||||
serviceItems: serviceItems.value,
|
||||
serviceContent: serviceItems.value.filter((item) => item.completed).map((item) => item.name),
|
||||
processNote: processNote.value,
|
||||
elderStatus: elderStatus.value,
|
||||
healthMetrics: {
|
||||
bloodPressure: bloodPressure.value,
|
||||
heartRate: heartRate.value,
|
||||
bloodSugar: bloodSugar.value,
|
||||
bloodOxygen: bloodOxygen.value
|
||||
},
|
||||
materialsUsed: materialsUsed.value,
|
||||
abnormalNote: abnormalNote.value,
|
||||
photos: photoCount.value > 0 ? ['mock-photo-' + String(photoCount.value)] : [] as Array<string>,
|
||||
staffRemark: staffRemark.value,
|
||||
familyConfirmation: {
|
||||
method: confirmMethod.value == 'sms_code' ? 'sms_code' : 'signature',
|
||||
code: confirmCode.value,
|
||||
signatureName: signatureName.value,
|
||||
signatureUrl: '',
|
||||
confirmedAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
},
|
||||
createdAt: new Date().toISOString().replace('T', ' ').substring(0, 19),
|
||||
updatedAt: new Date().toISOString().replace('T', ' ').substring(0, 19)
|
||||
} as DeliveryServiceRecordType
|
||||
await submitServiceRecord(orderId.value, record)
|
||||
uni.showToast({ title: '服务记录已提交', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
|
||||
}, 300)
|
||||
}
|
||||
|
||||
function submitRecord() {
|
||||
submitRecordAction()
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
if (options != null) {
|
||||
orderId.value = getDeliveryRouteParam(options as UTSJSONObject, 'id')
|
||||
}
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
padding-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-bottom: 18rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 10rpx 24rpx rgba(15, 35, 55, 0.06);
|
||||
}
|
||||
|
||||
.section-title,
|
||||
.item-name,
|
||||
.primary-btn-text,
|
||||
.confirm-text {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.field,
|
||||
.textarea {
|
||||
margin-top: 16rpx;
|
||||
padding: 0 20rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f4f8fb;
|
||||
font-size: 26rpx;
|
||||
color: #16324f;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.field {
|
||||
height: 84rpx;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
min-height: 180rpx;
|
||||
padding-top: 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.item-row {
|
||||
margin-top: 16rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background-color: #f7fbfd;
|
||||
}
|
||||
|
||||
.item-top,
|
||||
.placeholder-row,
|
||||
.confirm-row,
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: 28rpx;
|
||||
color: #16324f;
|
||||
}
|
||||
|
||||
.placeholder-row,
|
||||
.action-row {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.placeholder-btn,
|
||||
.confirm-item,
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
padding: 18rpx 0;
|
||||
border-radius: 18rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.placeholder-btn,
|
||||
.confirm-item,
|
||||
.outline-btn {
|
||||
background-color: #eef6fa;
|
||||
}
|
||||
|
||||
.placeholder-btn {
|
||||
width: 42%;
|
||||
}
|
||||
|
||||
.placeholder-btn-text,
|
||||
.placeholder-text,
|
||||
.outline-btn-text {
|
||||
font-size: 24rpx;
|
||||
color: #5e758c;
|
||||
}
|
||||
|
||||
.confirm-item {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.confirm-item-active {
|
||||
background-color: #d8eef9;
|
||||
}
|
||||
|
||||
.confirm-text {
|
||||
font-size: 26rpx;
|
||||
color: #176e97;
|
||||
}
|
||||
|
||||
.outline-btn,
|
||||
.primary-btn {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
background-color: #1f7db4;
|
||||
}
|
||||
|
||||
.primary-btn-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user