Browse Source

更新商品页面和结算页面

pull/19/head
徐飞洋 1 month ago
parent
commit
f4877acf21
  1. 37
      pages/goods/index.js
  2. 13
      pages/goods/index.wxml
  3. 4
      pages/settlement/index.js

37
pages/goods/index.js

@ -51,7 +51,7 @@ Page({
total: 0, // 总数据条数
searchTimer: null, // 搜索防抖定时器
// 分页相关字段
pageSize: 7, // 每页数量
pageSize: 20, // 每页数量
publishedCurrentPage: 1, // 已上架商品当前页码
publishedHasMore: true, // 已上架商品是否有更多
soldOutCurrentPage: 1, // 售空商品当前页码
@ -332,9 +332,13 @@ Page({
const sellerNickName = item.seller?.nickName || item.seller?.sellerNickName || item.seller?.name || '未知';
const creatorName = sellerNickName;
// 处理媒体URL - 简化处理,只保留图片URL
// 处理媒体URL
const imageUrls = item.imageUrls || item.images || []
const formattedImageUrls = Array.isArray(imageUrls) ? imageUrls : [imageUrls]
const mediaItems = formattedImageUrls.map(url => ({
url: url,
type: isVideoUrl(url) ? 'video' : 'image'
}))
// 处理商品状态
let status = item.status
@ -369,7 +373,8 @@ Page({
price: processedPrice,
formattedCreatedAt: this.formatDateTime(displayTime),
creatorName: creatorName,
imageUrls: formattedImageUrls
imageUrls: formattedImageUrls,
mediaItems: mediaItems
}
})
@ -383,7 +388,7 @@ Page({
/**
* 加载已上架(published)状态的货源 - 支持分页
*/
async loadPublishedGoods(page = 1, pageSize = this.data.pageSize, allGoodsData = null) {
async loadPublishedGoods(page = 1, pageSize = this.data.pageSize) {
if (this.data.isLoadingPublished) return { goods: [], hasMore: true }
this.setData({
@ -398,8 +403,8 @@ Page({
})
try {
// 使用传入的商品数据或获取所有商品数据
const allGoods = allGoodsData || await this.loadAllGoodsData()
// 获取所有商品数据
const allGoods = await this.loadAllGoodsData()
// 过滤出已上架状态的商品
let publishedGoods = allGoods.filter(item => item.status === 'published')
@ -451,7 +456,7 @@ Page({
/**
* 加载售空(sold_out)状态的货源 - 支持分页
*/
async loadSoldOutGoods(page = 1, pageSize = this.data.pageSize, allGoodsData = null) {
async loadSoldOutGoods(page = 1, pageSize = this.data.pageSize) {
if (this.data.isLoadingSoldOut) return { goods: [], hasMore: true }
this.setData({
@ -466,8 +471,8 @@ Page({
})
try {
// 使用传入的商品数据或获取所有商品数据
const allGoods = allGoodsData || await this.loadAllGoodsData()
// 获取所有商品数据
const allGoods = await this.loadAllGoodsData()
// 过滤出售空状态的商品
let soldOutGoods = allGoods.filter(item => item.status === 'sold_out')
@ -585,19 +590,12 @@ Page({
let updatedPublishedHasMore = this.data.publishedHasMore
let updatedSoldOutHasMore = this.data.soldOutHasMore
// 只在初始加载时获取所有商品数据
let allGoodsData = null
if (!isLoadMore) {
allGoodsData = await this.loadAllGoodsData()
}
// 1. 如果已上架商品还有更多,继续加载已上架商品
if (this.data.publishedHasMore) {
console.log('加载已上架商品第', this.data.publishedCurrentPage, '页')
const publishedResult = await this.loadPublishedGoods(
this.data.publishedCurrentPage,
this.data.pageSize,
allGoodsData
this.data.pageSize
)
newGoods = publishedResult.goods
@ -623,7 +621,7 @@ Page({
}
// 添加缓冲,避免请求太快
await new Promise(resolve => setTimeout(resolve, 300))
await new Promise(resolve => setTimeout(resolve, 500))
}
// 2. 如果已上架商品加载完,开始加载售空商品
@ -631,8 +629,7 @@ Page({
console.log('加载售空商品第', this.data.soldOutCurrentPage, '页')
const soldOutResult = await this.loadSoldOutGoods(
this.data.soldOutCurrentPage,
this.data.pageSize,
allGoodsData
this.data.pageSize
)
newGoods = soldOutResult.goods

13
pages/goods/index.wxml

@ -85,7 +85,20 @@
>
<view class="product-card {{item.status === 'sold_out' ? 'sold-out-grayscale' : ''}}">
<view class="product-image-wrapper">
<video
wx:if="{{item.mediaItems && item.mediaItems.length > 0 && item.mediaItems[0].type === 'video'}}"
class="product-image"
src="{{item.mediaItems[0].url}}"
mode="aspectFill"
show-center-play-btn="{{true}}"
show-play-btn="{{false}}"
controls="{{true}}"
autoplay="{{false}}"
loop="{{false}}"
muted="{{true}}"
></video>
<image
wx:else
class="product-image"
src="{{item.imageUrls && item.imageUrls.length > 0 ? item.imageUrls[0] : '/images/default-avatar.png'}}"
mode="aspectFill"

4
pages/settlement/index.js

@ -481,7 +481,7 @@ Page({
},
'采销联盟合作': {
title: '采销联盟合作规则',
content: '\n1. 合作主体:外部采购公司可通过成立独立的盒子公司,与平台开展货源包场或货源收购合作。\n\n2. 风险承担:盒子公司承担合作过程中产生的各类风险(包括但不限于货源质量风险、销售风险、市场风险等)。\n\n3. 利润分配:合作产生的净利润按以下比例分配:平台占20%、甲方占30%、乙方(盒子公司对应的外部采购公司)占50%。\n'
content: '\n1. 合作主体:外部采购公司可通过成立独立的合资公司,与平台开展货源包场或货源收购合作。\n\n2. 风险承担:合资公司承担合作过程中产生的各类风险(包括但不限于货源质量风险、销售风险、市场风险等)。\n\n3. 利润分配:合作产生的净利润按以下比例分配:平台占20%、甲方占30%、乙方(合资公司对应的外部采购公司)占50%。\n'
},
'其他': {
title: '其他',
@ -1540,7 +1540,7 @@ Page({
},
'采销联盟合作': {
title: '采销联盟合作规则',
content: '\n1. 合作主体:外部采购公司可通过成立独立的盒子公司,与平台开展货源包场或货源收购合作。\n\n2. 风险承担:盒子公司承担合作过程中产生的各类风险(包括但不限于货源质量风险、销售风险、市场风险等)。\n\n3. 利润分配:合作产生的净利润按以下比例分配:平台占20%、甲方占30%、乙方(盒子公司对应的外部采购公司)占50%。\n'
content: '\n1. 合作主体:外部采购公司可通过成立独立的合资公司,与平台开展货源包场或货源收购合作。\n\n2. 风险承担:合资公司承担合作过程中产生的各类风险(包括但不限于货源质量风险、销售风险、市场风险等)。\n\n3. 利润分配:合作产生的净利润按以下比例分配:平台占20%、甲方占30%、乙方(合资公司对应的外部采购公司)占50%。\n'
},
'其他': {
title: '其他',

Loading…
Cancel
Save