mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-09-21 20:32:01 +08:00
feat(miniprogram): 微信小程序个人资料页面功能优化
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user