feat(miniprogram): 微信小程序个人资料页面功能优化

This commit is contained in:
pikachu1995@126.com
2026-08-26 11:01:59 +08:00
parent 4a194ee0a1
commit e026b4e0d4
2 changed files with 247 additions and 23 deletions

View File

@@ -234,7 +234,7 @@ import {
getStoreIsCollect,
} from '@/api/members.js'
import config from '@/config/config'
import { getGoodsList } from '@/api/goods.js'
import { getGoodsList, getMpScene } from '@/api/goods.js'
import { getAllCoupons } from '@/api/promotions.js'
import { getFloorStoreData } from '@/api/home'
import {
@@ -504,12 +504,41 @@ function getCoupon(item: any) {
})
}
onLoad((options: any) => {
storeId.value = options.id
console.log(storeId.value, 'this.storeId')
function parseShopIdFromScene(raw: string) {
const scene = decodeURIComponent(String(raw || ''))
if (!scene) return ''
if (scene.includes('id=')) {
return scene.split('id=')[1].split('&')[0]
}
return scene
}
goodsParams.storeId = options.id
couponParams.storeId = options.id
async function resolveShopId(options: any) {
if (options?.id) return String(options.id)
if (!options?.scene) return ''
const scene = decodeURIComponent(String(options.scene))
if (scene.includes('id=')) {
return parseShopIdFromScene(scene)
}
try {
const res = await getMpScene(scene)
const payload = res?.data != null ? res.data : res
if (payload?.success && payload.result) {
return parseShopIdFromScene(String(payload.result))
}
} catch (e) {
// 短链解析失败时,把 scene 当店铺ID用
}
return scene
}
onLoad(async (options: any) => {
storeId.value = await resolveShopId(options)
goodsParams.storeId = storeId.value
couponParams.storeId = storeId.value
if (storeId.value) {
init()
}
})
onPageScroll((e) => {
@@ -531,7 +560,6 @@ onMounted(() => {
withShareTicket: true,
})
// #endif
init()
})
</script>