refactor: 重构页面结构,将页面按模块拆分至pages-user、pages-activity等目录并更新相关配置和组件。

This commit is contained in:
邹方成 2025-12-28 00:23:55 +08:00
parent 2af47b7979
commit 3175c6e8ae
39 changed files with 396 additions and 369 deletions

View File

@ -5,8 +5,8 @@ export function wechatLogin(code, invite_code) {
return request({ url: '/api/app/users/weixin/login', method: 'POST', data }) return request({ url: '/api/app/users/weixin/login', method: 'POST', data })
} }
export function getInventory(user_id, page = 1, page_size = 20) { export function getInventory(user_id, page = 1, page_size = 20, params = {}) {
return authRequest({ url: `/api/app/users/${user_id}/inventory`, method: 'GET', data: { page, page_size } }) return authRequest({ url: `/api/app/users/${user_id}/inventory`, method: 'GET', data: { page, page_size, ...params } })
} }
export function bindPhone(user_id, code, extraHeader = {}) { export function bindPhone(user_id, code, extraHeader = {}) {

View File

@ -163,7 +163,7 @@ function onCardChange(e) {
function openAgreement() { function openAgreement() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/agreement/purchase' // url: '/pages-user/agreement/purchase' //
}) })
} }

View File

@ -76,29 +76,22 @@ async function loadItems() {
try { try {
const userId = uni.getStorageSync('user_id') const userId = uni.getStorageSync('user_id')
if (!userId) { items.value = []; total.value = 0; return } if (!userId) { items.value = []; total.value = 0; return }
const res = await getInventory(userId, 1, 50) const res = await getInventory(userId, 1, 50, { status: 1 })
let list = [] let list = []
let rawTotal = 0 let rawTotal = 0
if (res && Array.isArray(res.list)) { list = res.list; rawTotal = res.total || 0 } if (res && Array.isArray(res.list)) { list = res.list; rawTotal = res.total || 0 }
else if (res && Array.isArray(res.data)) { list = res.data; rawTotal = res.total || 0 } else if (res && Array.isArray(res.data)) { list = res.data; rawTotal = res.total || 0 }
else if (Array.isArray(res)) { list = res; rawTotal = res.length } else if (Array.isArray(res)) { list = res; rawTotal = res.length }
const filtered = list.filter(item => Number(item.status) === 1 && !item.has_shipment) // status=1
const aggregated = new Map() // status=1
filtered.forEach(item => { const displayRes = list.map(item => ({
const key = String(item.product_id || item.id) id: item.product_id,
if (aggregated.has(key)) { name: (item.product_name || '未知商品').trim(),
aggregated.get(key).count += 1
} else {
aggregated.set(key, {
id: key,
name: (item.product_name || item.name || '').trim() || '未知物品',
image: cleanUrl(item.product_images || item.image), image: cleanUrl(item.product_images || item.image),
count: 1 count: item.count
}) }))
} items.value = displayRes
})
items.value = Array.from(aggregated.values())
total.value = rawTotal total.value = rawTotal
} catch (e) { } catch (e) {
console.error('[CabinetPreviewPopup] 加载失败', e) console.error('[CabinetPreviewPopup] 加载失败', e)

View File

@ -57,7 +57,11 @@
"es6": true, "es6": true,
"postcss": true "postcss": true
}, },
"usingComponents" : true "usingComponents": true,
"lazyCodeLoading": "requiredComponents",
"optimization": {
"subPackages": true
}
}, },
"mp-alipay": { "mp-alipay": {
"usingComponents": true "usingComponents": true

View File

@ -170,6 +170,13 @@
v-model:visible="cabinetVisible" v-model:visible="cabinetVisible"
:activity-id="activityId" :activity-id="activityId"
/> />
<!-- 开奖结果弹窗 -->
<LotteryResultPopup
v-model:visible="resultVisible"
:results="resultItems"
@close="onResultClose"
/>
</template> </template>
</ActivityPageLayout> </ActivityPageLayout>
</template> </template>
@ -186,6 +193,7 @@ import RewardsPopup from '@/components/activity/RewardsPopup.vue'
import RecordsList from '@/components/activity/RecordsList.vue' import RecordsList from '@/components/activity/RecordsList.vue'
import RulesPopup from '@/components/activity/RulesPopup.vue' import RulesPopup from '@/components/activity/RulesPopup.vue'
import CabinetPreviewPopup from '@/components/activity/CabinetPreviewPopup.vue' import CabinetPreviewPopup from '@/components/activity/CabinetPreviewPopup.vue'
import LotteryResultPopup from '@/components/activity/LotteryResultPopup.vue'
import { getActivityDetail, getActivityIssues, getActivityIssueRewards, getUserCoupons, getItemCards, createWechatOrder, getMatchingCardTypes, createMatchingPreorder, checkMatchingGame, getIssueDrawLogs, getMatchingGameCards } from '../../../api/appUser' import { getActivityDetail, getActivityIssues, getActivityIssueRewards, getUserCoupons, getItemCards, createWechatOrder, getMatchingCardTypes, createMatchingPreorder, checkMatchingGame, getIssueDrawLogs, getMatchingGameCards } from '../../../api/appUser'
import { levelToAlpha } from '@/utils/activity' import { levelToAlpha } from '@/utils/activity'
@ -211,6 +219,8 @@ const selectedCardTypeCode = ref('')
const rewardsVisible = ref(false) const rewardsVisible = ref(false)
const rulesVisible = ref(false) const rulesVisible = ref(false)
const cabinetVisible = ref(false) const cabinetVisible = ref(false)
const resultVisible = ref(false)
const resultItems = ref([])
const resumeGame = ref(null) const resumeGame = ref(null)
const resumeIssueId = ref('') const resumeIssueId = ref('')
const hasResumeGame = computed(() => { const hasResumeGame = computed(() => {
@ -928,16 +938,97 @@ async function finishAndReport() {
const entry = gameEntry.value || null const entry = gameEntry.value || null
const gameId = entry && entry.game_id ? String(entry.game_id) : '' const gameId = entry && entry.game_id ? String(entry.game_id) : ''
if (!gameId) return if (!gameId) return
await checkMatchingGame(gameId, Number(totalPairs.value || 0))
try {
const checkRes = await checkMatchingGame(gameId, Number(totalPairs.value || 0))
clearMatchingGameCacheEntry(aid, issueId) clearMatchingGameCacheEntry(aid, issueId)
gameFinished.value = true gameFinished.value = true
closeGame() closeGame()
console.log('[对对碰] checkRes:', JSON.stringify(checkRes))
console.log('[对对碰] currentIssueRewards:', currentIssueRewards.value?.length, 'items')
console.log('[对对碰] rewardsMap keys:', Object.keys(rewardsMap.value || {}))
// - { reward: { reward_id, name, level } }
let wonItems = []
// reward
if (checkRes?.reward && checkRes.reward.reward_id) {
const reward = checkRes.reward
console.log('[对对碰] 检测到reward对象:', reward)
// rewardsMap
const allRewards = rewardsMap.value[issueId] || currentIssueRewards.value || []
console.log('[对对碰] 本地奖励数据:', allRewards.length, 'items')
const foundReward = allRewards.find(r =>
String(r.id) === String(reward.reward_id) ||
String(r.reward_id) === String(reward.reward_id)
)
console.log('[对对碰] 匹配到的奖励:', foundReward)
wonItems = [{
title: reward.name || foundReward?.name || foundReward?.title || '神秘奖励',
image: foundReward?.image || foundReward?.pic || foundReward?.img || foundReward?.product_image || '',
reward_id: reward.reward_id
}]
}
//
else if (Array.isArray(checkRes) && checkRes.length > 0) {
wonItems = checkRes
} else if (checkRes?.list && checkRes.list.length > 0) {
wonItems = checkRes.list
} else if (checkRes?.data && Array.isArray(checkRes.data) && checkRes.data.length > 0) {
wonItems = checkRes.data
} else if (checkRes?.rewards && checkRes.rewards.length > 0) {
wonItems = checkRes.rewards
} else if (checkRes?.items && checkRes.items.length > 0) {
wonItems = checkRes.items
}
console.log('[对对碰] wonItems:', wonItems)
// LotteryResultPopup
if (wonItems.length > 0) {
const allRewards = rewardsMap.value[issueId] || currentIssueRewards.value || []
resultItems.value = wonItems.map(item => {
// title使
if (item.title) return item
//
const found = allRewards.find(r =>
String(r.id) === String(item.reward_id) ||
String(r.reward_id) === String(item.reward_id)
)
return {
title: item.title || item.name || found?.name || found?.title || '神秘奖励',
image: item.image || item.img || found?.image || found?.pic || found?.product_image || '',
reward_id: item.reward_id || item.id
}
})
} else {
resultItems.value = []
}
console.log('[对对碰] resultItems:', resultItems.value)
//
if (resultItems.value.length > 0) {
resultVisible.value = true
} else {
//
uni.showModal({ uni.showModal({
title: '游戏结束', title: '游戏结束',
content: `总对数:${Number(totalPairs.value || 0)}`, content: `总对数:${Number(totalPairs.value || 0)}`,
showCancel: false showCancel: false
}) })
} }
} catch (e) {
console.error('finishAndReport error', e)
uni.showToast({ title: e?.message || '结算失败', icon: 'none' })
}
}
function onResultClose() {
resultVisible.value = false
resultItems.value = []
}
async function advanceOne() { async function advanceOne() {
if (gameLoading.value) return if (gameLoading.value) return

View File

@ -94,10 +94,10 @@ function onActivityTap(a) {
let path = '' let path = ''
// Navigate to DETAIL, not list // Navigate to DETAIL, not list
if (name.includes('一番赏')) path = '/pages/activity/yifanshang/index' if (name.includes('一番赏')) path = '/pages-activity/activity/yifanshang/index'
else if (name.includes('无限赏')) path = '/pages/activity/wuxianshang/index' else if (name.includes('无限赏')) path = '/pages-activity/activity/wuxianshang/index'
else if (name.includes('对对碰')) path = '/pages/activity/duiduipeng/index' else if (name.includes('对对碰')) path = '/pages-activity/activity/duiduipeng/index'
else if (name.includes('爬塔')) path = '/pages/activity/pata/index' else if (name.includes('爬塔')) path = '/pages-activity/activity/pata/index'
if (path && id) { if (path && id) {
uni.navigateTo({ url: `${path}?id=${id}` }) uni.navigateTo({ url: `${path}?id=${id}` })

View File

@ -93,7 +93,7 @@ function onStartChallenge() {
const gameUrl = 'http://localhost:5174/' const gameUrl = 'http://localhost:5174/'
uni.navigateTo({ uni.navigateTo({
url: `/pages/game/webview?url=${encodeURIComponent(gameUrl)}&ticket=${ticketId.value}` url: `/pages-game/game/webview?url=${encodeURIComponent(gameUrl)}&ticket=${ticketId.value}`
}) })
} }

View File

@ -130,7 +130,7 @@ import LotteryResultPopup from '@/components/activity/LotteryResultPopup.vue'
import DrawLoadingPopup from '@/components/activity/DrawLoadingPopup.vue' import DrawLoadingPopup from '@/components/activity/DrawLoadingPopup.vue'
import PaymentPopup from '@/components/PaymentPopup.vue' import PaymentPopup from '@/components/PaymentPopup.vue'
// Composables // Composables
import { useActivity, useIssues, useRewards, useRecords } from '@/composables' import { useActivity, useIssues, useRewards, useRecords } from '../../composables'
// API // API
import { joinLottery, createWechatOrder, getLotteryResult, getItemCards, getUserCoupons } from '@/api/appUser' import { joinLottery, createWechatOrder, getLotteryResult, getItemCards, getUserCoupons } from '@/api/appUser'

View File

@ -131,7 +131,7 @@ import CabinetPreviewPopup from '@/components/activity/CabinetPreviewPopup.vue'
import FlipGrid from '@/components/FlipGrid.vue' import FlipGrid from '@/components/FlipGrid.vue'
import YifanSelector from '@/components/YifanSelector.vue' import YifanSelector from '@/components/YifanSelector.vue'
// Composables // Composables
import { useActivity, useIssues, useRewards, useRecords } from '@/composables' import { useActivity, useIssues, useRewards, useRecords } from '../../composables'
// Utils // Utils
import { formatDateTime, parseTimeMs } from '@/utils/format' import { formatDateTime, parseTimeMs } from '@/utils/format'

View File

@ -124,7 +124,7 @@ export default {
// webview // webview
uni.navigateTo({ uni.navigateTo({
url: `/pages/game/webview?url=${encodeURIComponent(gameUrl)}` url: `/pages-game/game/webview?url=${encodeURIComponent(gameUrl)}`
}) })
} catch (e) { } catch (e) {
uni.showToast({ uni.showToast({

View File

@ -112,12 +112,12 @@ async function fetchList() {
function toAdd() { function toAdd() {
uni.removeStorageSync('edit_address') uni.removeStorageSync('edit_address')
uni.navigateTo({ url: '/pages/address/edit' }) uni.navigateTo({ url: '/pages-user/address/edit' })
} }
function toEdit(item) { function toEdit(item) {
uni.setStorageSync('edit_address', item) uni.setStorageSync('edit_address', item)
uni.navigateTo({ url: `/pages/address/edit?id=${item.id}` }) uni.navigateTo({ url: `/pages-user/address/edit?id=${item.id}` })
} }
function onDelete(item) { function onDelete(item) {

View File

@ -14,8 +14,8 @@
<script> <script>
export default { export default {
methods: { methods: {
toUser() { uni.navigateTo({ url: '/pages/agreement/user' }) }, toUser() { uni.navigateTo({ url: '/pages-user/agreement/user' }) },
toPurchase() { uni.navigateTo({ url: '/pages/agreement/purchase' }) } toPurchase() { uni.navigateTo({ url: '/pages-user/agreement/purchase' }) }
} }
} }
</script> </script>

View File

@ -122,8 +122,8 @@ function toggleAgreement() {
agreementChecked.value = !agreementChecked.value agreementChecked.value = !agreementChecked.value
} }
function toUserAgreement() { uni.navigateTo({ url: '/pages/agreement/user' }) } function toUserAgreement() { uni.navigateTo({ url: '/pages-user/agreement/user' }) }
function toPurchaseAgreement() { uni.navigateTo({ url: '/pages/agreement/purchase' }) } function toPurchaseAgreement() { uni.navigateTo({ url: '/pages-user/agreement/purchase' }) }
function goLogin() { function goLogin() {
uni.navigateTo({ url: '/pages/login/index' }) uni.navigateTo({ url: '/pages/login/index' })

View File

@ -338,11 +338,11 @@ function navigateToGame(ord) {
let url = '' let url = ''
if (playType === 'match') { if (playType === 'match') {
url = `/pages/activity/duiduipeng/index?activity_id=${activityId}` url = `/pages-activity/activity/duiduipeng/index?activity_id=${activityId}`
} else if (playType === 'ichiban') { } else if (playType === 'ichiban') {
url = `/pages/activity/yifanshang/index?activity_id=${activityId}` url = `/pages-activity/activity/yifanshang/index?activity_id=${activityId}`
} else if (playType === 'infinity') { } else if (playType === 'infinity') {
url = `/pages/activity/wuxianshang/index?activity_id=${activityId}` url = `/pages-activity/activity/wuxianshang/index?activity_id=${activityId}`
} }
if (url) { if (url) {

View File

@ -399,7 +399,7 @@ async function fetchAllOrders() {
function goOrderDetail(item) { function goOrderDetail(item) {
// //
uni.navigateTo({ uni.navigateTo({
url: `/pages/orders/detail?id=${item.id}&order_no=${item.order_no}` url: `/pages-user/orders/detail?id=${item.id}&order_no=${item.order_no}`
}) })
} }
@ -476,11 +476,11 @@ function navigateToGame(item) {
let url = '' let url = ''
if (playType === 'match') { if (playType === 'match') {
url = `/pages/activity/duiduipeng/index?activity_id=${activityId}` url = `/pages-activity/activity/duiduipeng/index?activity_id=${activityId}`
} else if (playType === 'ichiban') { } else if (playType === 'ichiban') {
url = `/pages/activity/yifanshang/index?activity_id=${activityId}` url = `/pages-activity/activity/yifanshang/index?activity_id=${activityId}`
} else if (playType === 'infinity') { } else if (playType === 'infinity') {
url = `/pages/activity/wuxianshang/index?activity_id=${activityId}` url = `/pages-activity/activity/wuxianshang/index?activity_id=${activityId}`
} }
if (url) { if (url) {

View File

@ -18,12 +18,6 @@
"navigationBarTitleText": "商城" "navigationBarTitleText": "商城"
} }
}, },
{
"path": "pages/shop/detail",
"style": {
"navigationBarTitleText": "商品详情"
}
},
{ {
"path": "pages/cabinet/index", "path": "pages/cabinet/index",
"style": { "style": {
@ -35,136 +29,164 @@
"style": { "style": {
"navigationBarTitleText": "我的" "navigationBarTitleText": "我的"
} }
},
{
"path": "pages/points/index",
"style": {
"navigationBarTitleText": "积分记录"
} }
}, ],
"subPackages": [
{ {
"path": "pages/coupons/index", "root": "pages-activity",
"style": { "pages": [
"navigationBarTitleText": "我的优惠券"
}
},
{ {
"path": "pages/item-cards/index", "path": "activity/yifanshang/index",
"style": {
"navigationBarTitleText": "我的道具卡"
}
},
{
"path": "pages/invite/landing",
"style": {
"navigationBarTitleText": "好友邀请"
}
},
{
"path": "pages/invites/index",
"style": {
"navigationBarTitleText": "邀请记录"
}
},
{
"path": "pages/tasks/index",
"style": {
"navigationBarTitleText": "任务中心"
}
},
{
"path": "pages/orders/index",
"style": {
"navigationBarTitleText": "我的订单"
}
},
{
"path": "pages/orders/detail",
"style": {
"navigationBarTitleText": "订单详情"
}
},
{
"path": "pages/address/index",
"style": {
"navigationBarTitleText": "地址管理"
}
},
{
"path": "pages/address/edit",
"style": {
"navigationBarTitleText": "编辑地址"
}
},
{
"path": "pages/address/submit",
"style": {
"navigationBarTitleText": "填写收货信息"
}
},
{
"path": "pages/help/index",
"style": {
"navigationBarTitleText": "使用帮助"
}
},
{
"path": "pages/agreement/user",
"style": {
"navigationBarTitleText": "用户协议"
}
},
{
"path": "pages/agreement/purchase",
"style": {
"navigationBarTitleText": "购买协议"
}
},
{
"path": "pages/activity/yifanshang/index",
"style": { "style": {
"navigationBarTitleText": "一番赏" "navigationBarTitleText": "一番赏"
} }
}, },
{ {
"path": "pages/activity/wuxianshang/index", "path": "activity/wuxianshang/index",
"style": { "style": {
"navigationBarTitleText": "无限赏" "navigationBarTitleText": "无限赏"
} }
}, },
{ {
"path": "pages/activity/duiduipeng/index", "path": "activity/duiduipeng/index",
"style": { "style": {
"navigationBarTitleText": "对对碰" "navigationBarTitleText": "对对碰"
} }
}, },
{ {
"path": "pages/activity/list/index", "path": "activity/list/index",
"style": { "style": {
"navigationBarTitleText": "活动列表" "navigationBarTitleText": "活动列表"
} }
}, },
{ {
"path": "pages/activity/pata/index", "path": "activity/pata/index",
"style": { "style": {
"navigationBarTitleText": "爬塔" "navigationBarTitleText": "爬塔"
} }
}
]
}, },
{ {
"path": "pages/game/minesweeper/index", "root": "pages-user",
"pages": [
{
"path": "points/index",
"style": { "style": {
"navigationStyle": "custom", "navigationBarTitleText": "积分记录"
"navigationBarTitleText": "扫雷游戏"
} }
}, },
{ {
"path": "pages/game/webview", "path": "coupons/index",
"style": {
"navigationBarTitleText": "我的优惠券"
}
},
{
"path": "item-cards/index",
"style": {
"navigationBarTitleText": "我的道具卡"
}
},
{
"path": "invite/landing",
"style": {
"navigationBarTitleText": "好友邀请"
}
},
{
"path": "invites/index",
"style": {
"navigationBarTitleText": "邀请记录"
}
},
{
"path": "tasks/index",
"style": {
"navigationBarTitleText": "任务中心"
}
},
{
"path": "orders/index",
"style": {
"navigationBarTitleText": "我的订单"
}
},
{
"path": "orders/detail",
"style": {
"navigationBarTitleText": "订单详情"
}
},
{
"path": "address/index",
"style": {
"navigationBarTitleText": "地址管理"
}
},
{
"path": "address/edit",
"style": {
"navigationBarTitleText": "编辑地址"
}
},
{
"path": "address/submit",
"style": {
"navigationBarTitleText": "填写收货信息"
}
},
{
"path": "help/index",
"style": {
"navigationBarTitleText": "使用帮助"
}
},
{
"path": "agreement/user",
"style": {
"navigationBarTitleText": "用户协议"
}
},
{
"path": "agreement/purchase",
"style": {
"navigationBarTitleText": "购买协议"
}
}
]
},
{
"root": "pages-shop",
"pages": [
{
"path": "shop/detail",
"style": {
"navigationBarTitleText": "商品详情"
}
}
]
},
{
"root": "pages-game",
"pages": [
{
"path": "game/minesweeper/index",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "扫雷 game"
}
},
{
"path": "game/webview",
"style": { "style": {
"navigationBarTitleText": "游戏挑战", "navigationBarTitleText": "游戏挑战",
"navigationBarBackgroundColor": "#000000", "navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white" "navigationBarTextStyle": "white"
} }
} }
]
}
], ],
"tabBar": { "tabBar": {
"color": "#7A7E83", "color": "#7A7E83",

View File

@ -162,7 +162,7 @@
<script setup> <script setup>
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
import { onShow, onReachBottom, onShareAppMessage } from '@dcloudio/uni-app' import { onShow, onReachBottom, onShareAppMessage, onPullDownRefresh } from '@dcloudio/uni-app'
import { getInventory, getProductDetail, redeemInventory, requestShipping, cancelShipping, listAddresses, getShipments, createAddressShare } from '@/api/appUser' import { getInventory, getProductDetail, redeemInventory, requestShipping, cancelShipping, listAddresses, getShipments, createAddressShare } from '@/api/appUser'
const currentTab = ref(0) const currentTab = ref(0)
@ -253,6 +253,20 @@ onShow(() => {
} }
}) })
onPullDownRefresh(() => {
const uid = uni.getStorageSync("user_id")
page.value = 1
hasMore.value = true
// Reset lists
if (currentTab.value === 1) {
shippedList.value = []
loadShipments(uid).finally(() => uni.stopPullDownRefresh())
} else {
aggregatedList.value = []
loadInventory(uid).finally(() => uni.stopPullDownRefresh())
}
})
onReachBottom(() => { onReachBottom(() => {
if (hasMore.value && !loading.value) { if (hasMore.value && !loading.value) {
const uid = uni.getStorageSync("user_id") const uid = uni.getStorageSync("user_id")
@ -415,7 +429,7 @@ async function loadShipments(uid) {
const next = page.value === 1 ? mapped : [...shippedList.value, ...mapped] const next = page.value === 1 ? mapped : [...shippedList.value, ...mapped]
shippedList.value = next shippedList.value = next
if (list.length < pageSize.value || (page.value * pageSize.value >= total && total > 0)) { hasMore.value = false } else { page.value += 1 } if (page.value * pageSize.value >= total && total > 0) { hasMore.value = false } else { page.value += 1 }
if (list.length === 0) { hasMore.value = false } if (list.length === 0) { hasMore.value = false }
} catch (e) { } catch (e) {
console.error('Load shipments error:', e) console.error('Load shipments error:', e)
@ -429,7 +443,11 @@ async function loadInventory(uid) {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true
try { try {
const res = await getInventory(uid, page.value, pageSize.value) const params = {}
if (currentTab.value === 0) {
params.status = 1
}
const res = await getInventory(uid, page.value, pageSize.value, params)
console.log('Inventory loaded:', res) console.log('Inventory loaded:', res)
let list = [] let list = []
@ -446,138 +464,37 @@ async function loadInventory(uid) {
total = res.length total = res.length
} }
// status=1 () status=3 (使//) // status items
// status=1: const nextList = page.value === 1 ? [] : (currentTab.value === 1 ? [...shippedList.value] : [...aggregatedList.value])
// status=3:
const filteredList = list.filter(item => {
const s = Number(item.status)
return s === 1 || s === 3
})
// list.forEach(item => {
if (filteredList.length > 0) { let imageUrl = cleanUrl(item.product_images || item.image)
console.log('Debug Inventory Item:', filteredList[0]) const mappedItem = {
} id: item.product_id,
original_ids: item.inventory_ids || [],
// Tab name: (item.product_name || '未知商品').trim(),
const targetItems = filteredList.filter(item => {
// Tab 0: (has_shipment false status=1)
// Tab 1: (has_shipment true)
// API has_shipment true/false 1/0 "true"/"false"
//
const isShipped = item.has_shipment === true || item.has_shipment === 1 || String(item.has_shipment) === 'true' || String(item.has_shipment) === '1'
if (currentTab.value === 1) {
//
// status=3 has_shipment=true
return isShipped
} else {
// status=1 (status=3 )
return !isShipped && Number(item.status) === 1
}
})
console.log('Filtered list (status=1, tab=' + currentTab.value + '):', targetItems)
//
const newItems = targetItems.map(item => {
let imageUrl = ''
try {
let rawImg = item.product_images || item.image
if (rawImg && typeof rawImg === 'string') {
imageUrl = cleanUrl(rawImg)
}
} catch (e) {
console.error('Image parse error:', e)
}
const isShipped = item.has_shipment === true || item.has_shipment === 1 || String(item.has_shipment) === 'true' || String(item.has_shipment) === '1'
return {
id: item.product_id || item.id, // 使 product_id
original_ids: [item.id], // id
name: (item.product_name || item.name || '').trim(),
image: imageUrl, image: imageUrl,
price: item.product_price ? item.product_price / 100 : null, // 使 price: item.product_price ? item.product_price / 100 : null,
count: 1, count: item.count || 0,
selected: false, selected: false,
selectedCount: 1, selectedCount: item.count || 0,
has_shipment: isShipped, has_shipment: item.has_shipment,
updated_at: item.updated_at // updated_at: item.updated_at
} }
nextList.push(mappedItem)
}) })
console.log('Mapped new items:', newItems.length) console.log('Final list (tab=' + currentTab.value + '):', JSON.parse(JSON.stringify(nextList)))
//
// 1. newItems
// 2. newItems
//
let currentList = currentTab.value === 1 ? shippedList : aggregatedList
let next = page.value === 1 ? [] : [...currentList.value]
if (currentTab.value === 1) { if (currentTab.value === 1) {
// updated_at shippedList.value = nextList
// ID
// UI computed
// flat list updated_at + product_id
// updated_at
// updated_at product_id
newItems.forEach(newItem => {
// updated_at product_id
// updated_at ISO
const existingItem = next.find(i =>
i.id == newItem.id &&
new Date(i.updated_at).getTime() === new Date(newItem.updated_at).getTime()
)
if (existingItem) {
existingItem.count += 1
if (Array.isArray(existingItem.original_ids)) {
existingItem.original_ids.push(...newItem.original_ids)
}
} else { } else {
next.push(newItem) aggregatedList.value = nextList
}
})
} else {
// product_id (id)
newItems.forEach(newItem => {
if (!newItem.id) {
next.push(newItem)
return
}
const existingItem = next.find(i => i.id == newItem.id)
if (existingItem) {
existingItem.count += 1
if (Array.isArray(existingItem.original_ids)) {
existingItem.original_ids.push(...newItem.original_ids)
} else {
existingItem.original_ids = [...newItem.original_ids]
}
} else {
next.push(newItem)
}
})
}
console.log('Final aggregated list:', JSON.parse(JSON.stringify(next)))
if (currentTab.value === 1) {
shippedList.value = next
} else {
aggregatedList.value = next
} }
// //
// total status=1 // total
// if ((page.value * pageSize.value >= total && total > 0) || list.length === 0) {
if (list.length < pageSize.value || (page.value * pageSize.value >= total && total > 0)) {
hasMore.value = false hasMore.value = false
} else { } else {
page.value += 1 page.value += 1
@ -673,7 +590,7 @@ async function onRedeem() {
aggregatedList.value = [] aggregatedList.value = []
page.value = 1 page.value = 1
hasMore.value = true hasMore.value = true
loadAllInventory(user_id) loadInventory(user_id)
} catch (e) { } catch (e) {
uni.showToast({ title: e.message || '兑换失败', icon: 'none' }) uni.showToast({ title: e.message || '兑换失败', icon: 'none' })
} finally { } finally {
@ -721,7 +638,7 @@ async function onShip() {
aggregatedList.value = [] aggregatedList.value = []
page.value = 1 page.value = 1
hasMore.value = true hasMore.value = true
loadAllInventory(user_id) loadInventory(user_id)
} catch (e) { } catch (e) {
uni.showToast({ title: e.message || '申请失败', icon: 'none' }) uni.showToast({ title: e.message || '申请失败', icon: 'none' })
} finally { } finally {
@ -762,7 +679,7 @@ onShareAppMessage((res) => {
showSharePopup.value = false showSharePopup.value = false
return { return {
title: `送你一个好礼,快来填写地址领走吧!`, title: `送你一个好礼,快来填写地址领走吧!`,
path: `/pages/address/submit?token=${currentShareToken.value}`, path: `/pages-user/address/submit?token=${currentShareToken.value}`,
imageUrl: sharingItem.value.image || '/static/logo.png' imageUrl: sharingItem.value.image || '/static/logo.png'
} }
}) })
@ -809,7 +726,7 @@ async function onInvite(item) {
function onCopyShareLink() { function onCopyShareLink() {
let url = currentShortLink.value let url = currentShortLink.value
if (!url) { if (!url) {
url = `${window?.location?.origin || ''}/pages/address/submit?token=${currentShareToken.value}` url = `${window?.location?.origin || ''}/pages-user/address/submit?token=${currentShareToken.value}`
} }
uni.setClipboardData({ uni.setClipboardData({

View File

@ -52,7 +52,7 @@
<view class="gameplay-grid-v2"> <view class="gameplay-grid-v2">
<!-- 上排两大核心 --> <!-- 上排两大核心 -->
<view class="grid-row-top"> <view class="grid-row-top">
<view class="game-card-large card-yifan" @tap="navigateTo('/pages/activity/list/index?category=一番赏')"> <view class="game-card-large card-yifan" @tap="navigateTo('/pages-activity/activity/list/index?category=一番赏')">
<view class="card-bg-decoration"></view> <view class="card-bg-decoration"></view>
<view class="card-content-large"> <view class="card-content-large">
<text class="card-title-large">一番赏</text> <text class="card-title-large">一番赏</text>
@ -60,7 +60,7 @@
<image class="card-mascot-large" src="https://via.placeholder.com/150/90EE90/000000?text=YI" mode="aspectFit" /> <image class="card-mascot-large" src="https://via.placeholder.com/150/90EE90/000000?text=YI" mode="aspectFit" />
</view> </view>
</view> </view>
<view class="game-card-large card-wuxian" @tap="navigateTo('/pages/activity/list/index?category=无限赏')"> <view class="game-card-large card-wuxian" @tap="navigateTo('/pages-activity/activity/list/index?category=无限赏')">
<view class="card-content-large"> <view class="card-content-large">
<text class="card-title-large">无限赏</text> <text class="card-title-large">无限赏</text>
<view class="card-tag-large yellow">一发入魂</view> <view class="card-tag-large yellow">一发入魂</view>
@ -71,13 +71,13 @@
<!-- 下排三小功能 --> <!-- 下排三小功能 -->
<view class="grid-row-bottom"> <view class="grid-row-bottom">
<view class="game-card-small card-match" @tap="navigateTo('/pages/activity/list/index?category=对对碰')"> <view class="game-card-small card-match" @tap="navigateTo('/pages-activity/activity/list/index?category=对对碰')">
<text class="card-title-small">对对碰</text> <text class="card-title-small">对对碰</text>
<text class="card-subtitle-small">碰一碰消除</text> <text class="card-subtitle-small">碰一碰消除</text>
<image class="card-icon-small" src="https://via.placeholder.com/80/FFB6C1/000000?text=Match" mode="aspectFit" /> <image class="card-icon-small" src="https://via.placeholder.com/80/FFB6C1/000000?text=Match" mode="aspectFit" />
</view> </view>
<view class="game-card-small card-tower" @tap="navigateTo('/pages/game/minesweeper/index')"> <view class="game-card-small card-tower" @tap="navigateTo('/pages-game/game/minesweeper/index')">
<text class="card-title-small">扫雷</text> <text class="card-title-small">扫雷</text>
<text class="card-subtitle-small">福利挑战</text> <text class="card-subtitle-small">福利挑战</text>
<image class="card-icon-small" src="https://via.placeholder.com/80/9370DB/000000?text=Mine" mode="aspectFit" /> <image class="card-icon-small" src="https://via.placeholder.com/80/9370DB/000000?text=Mine" mode="aspectFit" />
@ -282,10 +282,10 @@ export default {
const name = (a.category_name || a.categoryName || '').trim() const name = (a.category_name || a.categoryName || '').trim()
const id = a.id const id = a.id
let path = '' let path = ''
if (name.includes('一番赏')) path = '/pages/activity/yifanshang/index' if (name.includes('一番赏')) path = '/pages-activity/activity/yifanshang/index'
else if (name.includes('无限赏')) path = '/pages/activity/wuxianshang/index' else if (name.includes('无限赏')) path = '/pages-activity/activity/wuxianshang/index'
else if (name.includes('对对碰')) path = '/pages/activity/duiduipeng/index' else if (name.includes('对对碰')) path = '/pages-activity/activity/duiduipeng/index'
else if (name.includes('爬塔')) path = '/pages/activity/pata/index' else if (name.includes('爬塔')) path = '/pages-activity/activity/pata/index'
if (path && id) { if (path && id) {
uni.navigateTo({ url: `${path}?id=${id}` }) uni.navigateTo({ url: `${path}?id=${id}` })

View File

@ -123,8 +123,8 @@ function handleTestLogin() {
}, 1000) }, 1000)
} }
function toUserAgreement() { uni.navigateTo({ url: '/pages/agreement/user' }) } function toUserAgreement() { uni.navigateTo({ url: '/pages-user/agreement/user' }) }
function toPurchaseAgreement() { uni.navigateTo({ url: '/pages/agreement/purchase' }) } function toPurchaseAgreement() { uni.navigateTo({ url: '/pages-user/agreement/purchase' }) }
function onGetPhoneNumber(e) { function onGetPhoneNumber(e) {
if (!agreementChecked.value) { if (!agreementChecked.value) {

View File

@ -527,7 +527,7 @@ export default {
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || '' const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
return { return {
title: '🎁 好友邀请你一起玩,快来领福利!', title: '🎁 好友邀请你一起玩,快来领福利!',
path: inviteCode ? `/pages/invite/landing?invite_code=${inviteCode}` : '/pages/invite/landing', path: inviteCode ? `/pages-user/invite/landing?invite_code=${inviteCode}` : '/pages-user/invite/landing',
imageUrl: '/static/share_invite.png' imageUrl: '/static/share_invite.png'
} }
}, },
@ -565,7 +565,7 @@ export default {
}, },
getInviteSharePath() { getInviteSharePath() {
const code = this.getInviteCode() const code = this.getInviteCode()
return code ? `/pages/invite/landing?invite_code=${encodeURIComponent(code)}` : '/pages/invite/landing' return code ? `/pages-user/invite/landing?invite_code=${encodeURIComponent(code)}` : '/pages-user/invite/landing'
}, },
normalizePointsBalance(v) { normalizePointsBalance(v) {
if (v && typeof v === 'object') { if (v && typeof v === 'object') {
@ -647,29 +647,29 @@ export default {
uni.navigateTo({ url: '/pages/login/index' }) uni.navigateTo({ url: '/pages/login/index' })
}, },
toOrders(status) { toOrders(status) {
uni.navigateTo({ url: `/pages/orders/index?status=${status}` }) uni.navigateTo({ url: `/pages-user/orders/index?status=${status}` })
}, },
toCabinetTab(tabIndex) { toCabinetTab(tabIndex) {
uni.setStorageSync('cabinet_target_tab', tabIndex) uni.setStorageSync('cabinet_target_tab', tabIndex)
uni.switchTab({ url: '/pages/cabinet/index' }) uni.switchTab({ url: '/pages/cabinet/index' })
}, },
toAddresses() { toAddresses() {
uni.navigateTo({ url: '/pages/address/index' }) uni.navigateTo({ url: '/pages-user/address/index' })
}, },
toPointsPage() { toPointsPage() {
uni.navigateTo({ url: '/pages/points/index' }) uni.navigateTo({ url: '/pages-user/points/index' })
}, },
toCouponsPage() { toCouponsPage() {
uni.navigateTo({ url: '/pages/coupons/index' }) uni.navigateTo({ url: '/pages-user/coupons/index' })
}, },
toItemCardsPage() { toItemCardsPage() {
uni.navigateTo({ url: '/pages/item-cards/index' }) uni.navigateTo({ url: '/pages-user/item-cards/index' })
}, },
toInvitesPage() { toInvitesPage() {
uni.navigateTo({ url: '/pages/invites/index' }) uni.navigateTo({ url: '/pages-user/invites/index' })
}, },
toTasksPage() { toTasksPage() {
uni.navigateTo({ url: '/pages/tasks/index' }) uni.navigateTo({ url: '/pages-user/tasks/index' })
}, },
toHelp() { toHelp() {
uni.showActionSheet({ uni.showActionSheet({
@ -677,11 +677,11 @@ export default {
success: (res) => { success: (res) => {
const idx = Number(res && res.tapIndex) const idx = Number(res && res.tapIndex)
if (idx === 0) { if (idx === 0) {
uni.navigateTo({ url: '/pages/agreement/purchase' }) uni.navigateTo({ url: '/pages-user/agreement/purchase' })
return return
} }
if (idx === 1) { if (idx === 1) {
uni.navigateTo({ url: '/pages/agreement/user' }) uni.navigateTo({ url: '/pages-user/agreement/user' })
return return
} }
} }

View File

@ -203,7 +203,7 @@ function onSearchConfirm() { applyFilters() }
function onProductTap(p) { function onProductTap(p) {
if (p.kind === 'product') { if (p.kind === 'product') {
uni.navigateTo({ url: `/pages/shop/detail?id=${p.id}` }) uni.navigateTo({ url: `/pages-shop/shop/detail?id=${p.id}` })
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 KiB

After

Width:  |  Height:  |  Size: 44 KiB