统一甲屿云命名体系

This commit is contained in:
2026-06-29 23:26:43 +08:00
parent 48c47fe3ff
commit bc8a7d8d4c
1268 changed files with 3477 additions and 3511 deletions
+51
View File
@@ -0,0 +1,51 @@
const { formatPrice, getProductTitle } = require('./format')
const { resolveImageList } = require('./file')
const { DEFAULT_PRODUCT_IMAGE } = require('./config')
/**
* Purpose: getProductTags supports product.js by holding or executing the get product tags page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function getProductTags(product) {
if (Array.isArray(product && product.tagInfos)) {
return product.tagInfos
.map(tag => tag && tag.tagName)
.filter(Boolean)
.slice(0, 3)
}
return []
}
/**
* Purpose: buildProductCard supports product.js by holding or executing the build product card page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
async function buildProductCard(product) {
const images = await resolveImageList(product && product.imageFileIds, DEFAULT_PRODUCT_IMAGE)
return {
...product,
displayTitle: getProductTitle(product),
priceText: `¥${formatPrice(product && product.price)}`,
metaText: (product && product.approximateDuration) || '支持预约',
shopNameText: product && product.shopName ? `所属店铺:${product.shopName}` : '',
coverUrl: images[0],
imageUrls: images,
tagsPreview: getProductTags(product),
statsText: `${Number((product && product.likeCount) || 0)}赞 · ${Number((product && product.collectCount) || 0)}藏`
}
}
/**
* Purpose: buildProductCards supports product.js by holding or executing the build product cards page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
async function buildProductCards(products) {
const list = Array.isArray(products) ? products : []
return Promise.all(list.map(item => buildProductCard(item)))
}
module.exports = {
buildProductCard,
buildProductCards
}