diff --git a/src/components/sp-login/index.weapp.js b/src/components/sp-login/index.weapp.js index 0ddefbb63..6a9f2ae9f 100644 --- a/src/components/sp-login/index.weapp.js +++ b/src/components/sp-login/index.weapp.js @@ -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) { diff --git a/src/pages/item/espier-detail.js b/src/pages/item/espier-detail.js index a9007f7cd..0f81a7f1b 100644 --- a/src/pages/item/espier-detail.js +++ b/src/pages/item/espier-detail.js @@ -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) => ( @@ -847,7 +858,7 @@ function EspierDetail(props) { {info?.itemParams?.map((item, index) => { return ( - + {item.attribute_name} {item.attribute_value_name} diff --git a/src/subpages/auth/login.js b/src/subpages/auth/login.js index 5eccd98a0..b233940df 100644 --- a/src/subpages/auth/login.js +++ b/src/subpages/auth/login.js @@ -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) diff --git a/src/subpages/guide/item/espier-detail.js b/src/subpages/guide/item/espier-detail.js index 5bb29e85b..57a6294e0 100644 --- a/src/subpages/guide/item/espier-detail.js +++ b/src/subpages/guide/item/espier-detail.js @@ -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) => ( diff --git a/src/subpages/member/index.js b/src/subpages/member/index.js index 7e8359674..2abdcb67e 100644 --- a/src/subpages/member/index.js +++ b/src/subpages/member/index.js @@ -433,13 +433,17 @@ function MemberIndex(props) { Taro.navigateTo({ url: link }) } } + + const onLoginChange = (url) => { + if (!isLogin) return + Taro.navigateTo({ url }) + } + const VipGradeDom = () => { return ( { - Taro.navigateTo({ url: '/subpages/member/member-level' }) - }} + onClick={() => onLoginChange('/subpages/member/member-level')} > {{ @@ -480,15 +484,11 @@ function MemberIndex(props) { className='header-block' style={userInfo?.gradeInfo?.grade_background ? memberBckStyle : {}} > - + { - if (isLogin) { - Taro.navigateTo({ url: '/subpages/member/user-info' }) - } - }} + onClick={() => onLoginChange('/subpages/member/user-info')} style={{ width: '72px', height: '72px' }} > Taro.navigateTo({ url: '/subpages/member/user-info' })} + onClick={() => onLoginChange('/subpages/member/user-info')} > {userInfo?.username || userInfo?.mobile} @@ -519,9 +519,7 @@ function MemberIndex(props) { ) : ( - - 点击登录 - + 点击登录 )} @@ -543,38 +541,27 @@ function MemberIndex(props) { {isLogin && config.menu.member_code && ( Taro.navigateTo({ url: '/marketing/pages/member/member-code' })} + onClick={() => onLoginChange('/marketing/pages/member/member-code')} > )} - { - Taro.navigateTo({ url: '/subpages/marketing/coupon' }) - }} + onLoginChange('/subpages/marketing/coupon')} > - } - > - {isLogin ? state.couponCount || 0 : '···'} - 优惠券 - - - { - handleClickLink('/subpages/member/point-detail') - }} - > - - {isLogin ? state.point || 0 : '···'} - 积分 - - + {isLogin ? state.couponCount || 0 : '···'} + 优惠券 + + + onLoginChange('/subpages/member/point-detail')}> + {isLogin ? state.point || 0 : '···'} + 积分 + - + {/* */} diff --git a/src/subpages/member/index.scss b/src/subpages/member/index.scss index e72be77ef..b6cf5d71e 100644 --- a/src/subpages/member/index.scss +++ b/src/subpages/member/index.scss @@ -88,6 +88,7 @@ .login-text { color: #1a1a1a; + font-size: 30px; } }