Merge branch 'master' of https://tp-git.shopex.cn/huiqi/ecshopx-vshop into feature/ECX-7316

This commit is contained in:
maqian
2025-10-17 17:44:11 +08:00
6 changed files with 113 additions and 63 deletions

View File

@@ -86,6 +86,7 @@ function SpLogin(props, ref) {
// const { uid } = entryLaunch.getLaunchParams()
const { uid, dtid } = Taro.getStorageSync(SG_ROUTER_PARAMS)
const { gu_user_id, gu } = Taro.getStorageSync(SG_GUIDE_PARAMS)
const { source_id, monitor_id, latest_source_id, latest_monitor_id } = Taro.getStorageSync('sourceInfo') // 千人千码参数
if (uid) {
// 分销绑定
params['uid'] = uid
@@ -110,6 +111,19 @@ function SpLogin(props, ref) {
params['work_userid'] = work_userid
}
if (source_id) {
params['source_id'] = source_id
}
if (monitor_id) {
params['monitor_id'] = monitor_id
}
if (latest_source_id) {
params['latest_source_id'] = latest_source_id
}
if (latest_monitor_id) {
params['latest_monitor_id'] = latest_monitor_id
}
try {
const { token, is_new } = await api.wx.newlogin(params)
if (token) {

View File

@@ -104,7 +104,8 @@ const initialState = {
recommendList: [],
isParameter: false,
imgHeightList: [], // 用于存储banner高度
navigateMantle: false
navigateMantle: false,
defaultImageHeight: 520 // 默认图片高度,避免空白
}
function EspierDetail(props) {
@@ -142,7 +143,8 @@ function EspierDetail(props) {
recommendList,
isParameter,
imgHeightList,
navigateMantle
navigateMantle,
defaultImageHeight
} = state
useEffect(() => {
@@ -305,15 +307,24 @@ function EspierDetail(props) {
}
})
}
const banner = await getMultipleImageInfo(data.imgs)
setState((draft) => {
draft.info = {
...data,
subscribe
}
draft.play = data.video ? true : false // 辉绮需求
draft.imgHeightList = banner
draft.promotionActivity = data.promotionActivity
// 初始化图片高度数组,使用默认高度
draft.imgHeightList = new Array(data.imgs.length).fill(draft.defaultImageHeight)
})
// 异步计算图片真实高度,不阻塞页面渲染
getMultipleImageInfo(data.imgs).then(heights => {
setState((draft) => {
draft.imgHeightList = heights
})
}).catch(error => {
console.log('计算图片高度失败,使用默认高度:', error)
})
if (isAPP() && userInfo) {
@@ -339,7 +350,7 @@ function EspierDetail(props) {
}
}
const getMultipleImageInfo = async (imageUrls = []) => {
let windowWidth = 375
let windowWidth = defaultImageHeight
try {
const sys = Taro.getSystemInfoSync()
if (sys && sys.windowWidth) windowWidth = sys.windowWidth
@@ -349,9 +360,9 @@ function EspierDetail(props) {
const promises = imageUrls.map(async (url) => {
try {
const info = await Taro.getImageInfo({ src: url })
const imgWidth = Number(info?.width) || 0
const imgHeight = Number(info?.height) || 0
const imageInfo = await Taro.getImageInfo({ src: url })
const imgWidth = Number(imageInfo?.width) || 0
const imgHeight = Number(imageInfo?.height) || 0
if (imgWidth > 0 && imgHeight > 0) {
return Math.round((windowWidth * imgHeight) / imgWidth)
}
@@ -503,7 +514,7 @@ function EspierDetail(props) {
className='goods-swiper'
// current={curImgIdx}
onChange={onChangeSwiper}
style={{ height: imgHeightList[curImgIdx] + 'px' }}
style={{ height: (imgHeightList[curImgIdx] || defaultImageHeight) + 'px' }}
>
{info.imgs.map((img, idx) => (
<SwiperItem key={`swiperitem__${idx}`}>
@@ -847,7 +858,7 @@ function EspierDetail(props) {
<View className='product-parameter-all'>
{info?.itemParams?.map((item, index) => {
return (
<View className='product-parameter-item'>
<View className='product-parameter-item' key={`product-parameter-item__${index}`}>
<Text className='title'>{item.attribute_name}</Text>
<Text className='content'>{item.attribute_value_name}</Text>
</View>

View File

@@ -110,6 +110,7 @@ export default class Login extends Component {
}
async handleSubmit() {
const { source_id, monitor_id, latest_source_id, latest_monitor_id } = Taro.getStorageSync('sourceInfo') // 千人千码参数
const { redirect } = this.$instance.router.params
const { loginType } = this.state
const { mobile, password, vcode } = this.state.info
@@ -145,6 +146,19 @@ export default class Login extends Component {
params['auth_type'] = 'local'
if (source_id) {
params['source_id'] = source_id
}
if (monitor_id) {
params['monitor_id'] = monitor_id
}
if (latest_source_id) {
params['latest_source_id'] = latest_source_id
}
if (latest_monitor_id) {
params['latest_monitor_id'] = latest_monitor_id
}
try {
const { token, error_message } = await api.wx.newloginh5(params)

View File

@@ -88,6 +88,7 @@ const initialState = {
// 多规格商品选中的规格
curItem: null,
imgHeightList: [], // 用于存储banner高度
defaultImageHeight: 520, // 默认图片高度,避免空白
}
function EspierDetail(props) {
@@ -123,6 +124,7 @@ function EspierDetail(props) {
subtaskId,
curItem,
imgHeightList, // 用于存储banner高度
defaultImageHeight,
} = state
useEffect(() => {
@@ -255,30 +257,51 @@ function EspierDetail(props) {
}
})
}
const banner = await getMultipleImageInfo(data.imgs)
setState((draft) => {
draft.info = {
...data,
subscribe
}
draft.imgHeightList = banner
draft.promotionActivity = data.promotionActivity
// 初始化图片高度数组,使用默认高度
draft.imgHeightList = new Array(data.imgs.length).fill(draft.defaultImageHeight)
})
// 异步计算图片真实高度,不阻塞页面渲染
getMultipleImageInfo(data.imgs).then(heights => {
setState((draft) => {
draft.imgHeightList = heights
})
}).catch(error => {
console.log('计算图片高度失败,使用默认高度:', error)
})
}
const getMultipleImageInfo = async (imageUrls) => {
const promises = imageUrls.map(url =>
Taro.getImageInfo({ src: url })
.then(info => info)
.catch(error => {
console.log('获取图片信息失败:', url, error)
// 返回一个默认高度或 null
return { width: 0, height: 650 }
})
)
const results = await Promise.all(promises)
return results.map(info => (info.height) / 2 > 650 ? 650 : info.height / 2)
const getMultipleImageInfo = async (imageUrls = []) => {
let windowWidth = defaultImageHeight
try {
const sys = Taro.getSystemInfoSync()
if (sys && sys.windowWidth) windowWidth = sys.windowWidth
} catch (e) {
console.log('获取系统信息失败,使用默认宽度:', e)
}
const promises = imageUrls.map(async (url) => {
try {
const imageInfo = await Taro.getImageInfo({ src: url })
const imgWidth = Number(imageInfo?.width) || 0
const imgHeight = Number(imageInfo?.height) || 0
if (imgWidth > 0 && imgHeight > 0) {
return Math.round((windowWidth * imgHeight) / imgWidth)
}
return Math.round(windowWidth)
} catch (error) {
console.log('获取图片信息失败:', url, error)
return Math.round(windowWidth)
}
})
return Promise.all(promises)
}
// 获取包裹
@@ -388,7 +411,7 @@ function EspierDetail(props) {
className='goods-swiper'
// current={curImgIdx}
onChange={onChangeSwiper}
style={{ height: (imgHeightList[curImgIdx]) + 'px' }}
style={{ height: (imgHeightList[curImgIdx] || defaultImageHeight) + 'px' }}
>
{info.imgs.map((img, idx) => (
<SwiperItem key={`swiperitem__${idx}`}>

View File

@@ -433,13 +433,17 @@ function MemberIndex(props) {
Taro.navigateTo({ url: link })
}
}
const onLoginChange = (url) => {
if (!isLogin) return
Taro.navigateTo({ url })
}
const VipGradeDom = () => {
return (
<View
className='user-grade-name'
onClick={() => {
Taro.navigateTo({ url: '/subpages/member/member-level' })
}}
onClick={() => onLoginChange('/subpages/member/member-level')}
>
<Text>
{{
@@ -480,15 +484,11 @@ function MemberIndex(props) {
className='header-block'
style={userInfo?.gradeInfo?.grade_background ? memberBckStyle : {}}
>
<View className='user-info-card'>
<SpLogin className='user-info-card'>
<View className='user-info-header'>
<View
className='user-avatar'
onClick={() => {
if (isLogin) {
Taro.navigateTo({ url: '/subpages/member/user-info' })
}
}}
onClick={() => onLoginChange('/subpages/member/user-info')}
style={{ width: '72px', height: '72px' }}
>
<SpImage
@@ -504,7 +504,7 @@ function MemberIndex(props) {
<>
<View
className='user-name'
onClick={() => Taro.navigateTo({ url: '/subpages/member/user-info' })}
onClick={() => onLoginChange('/subpages/member/user-info')}
>
{userInfo?.username || userInfo?.mobile}
</View>
@@ -519,9 +519,7 @@ function MemberIndex(props) {
</View>
</>
) : (
<SpLogin newUser={isNewUser}>
<Text className='login-text font-medium text-34'>点击登录</Text>
</SpLogin>
<Text className='login-text font-medium text-34'>点击登录</Text>
)}
</View>
@@ -543,38 +541,27 @@ function MemberIndex(props) {
{isLogin && config.menu.member_code && (
<Text
className='iconfont icon-erweima-01'
onClick={() => Taro.navigateTo({ url: '/marketing/pages/member/member-code' })}
onClick={() => onLoginChange('/marketing/pages/member/member-code')}
></Text>
)}
</View>
</View>
<View className='user-stats'>
<SpLogin
onChange={() => {
Taro.navigateTo({ url: '/subpages/marketing/coupon' })
}}
<View
className='stat-item'
onClick={() => onLoginChange('/subpages/marketing/coupon')}
>
<View
className='stat-item'
// onClick={() => }
>
<Text className='stat-value'>{isLogin ? state.couponCount || 0 : '···'}</Text>
<Text className='stat-label'>优惠券</Text>
</View>
</SpLogin>
<SpLogin
onChange={() => {
handleClickLink('/subpages/member/point-detail')
}}
>
<View className='stat-item'>
<Text className='stat-value'>{isLogin ? state.point || 0 : '···'}</Text>
<Text className='stat-label'>积分</Text>
</View>
</SpLogin>
<Text className='stat-value'>{isLogin ? state.couponCount || 0 : '···'}</Text>
<Text className='stat-label'>优惠券</Text>
</View>
<View className='stat-item' onClick={() => onLoginChange('/subpages/member/point-detail')}>
<Text className='stat-value'>{isLogin ? state.point || 0 : '···'}</Text>
<Text className='stat-label'>积分</Text>
</View>
</View>
</View>
</SpLogin>
{/* <View className='header-block__ft'></View> */}
</View>

View File

@@ -88,6 +88,7 @@
.login-text {
color: #1a1a1a;
font-size: 30px;
}
}