feat(user): 使用微信原生 Picker 替换所在地选择弹层
- 删除 NutUI Address 相关导入、状态及地区数据转换逻辑 - 新增派生 regionValue 用于绑定微信原生 Picker 的 value - 将 handleRegionChange 调整为处理微信 Picker 的事件 - 将所在地选择 UI 修改为微信原生 Picker 包裹的视图结构 - 地图定位失败使用弹窗提示,引导用户手动选择或重试 - 移除手动打开地区选择器的函数及 NutUI 组件 - 保留 RegionData 用于文本智能识别解析 - 编译通过,提升在无地图或无权限环境下的地区选择稳定性
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import React, { useState, useEffect, useRef } from 'react'
|
||||
import { View, Text, Image, ScrollView, Swiper, SwiperItem, RichText } from '@tarojs/components'
|
||||
import { Tag } from '@nutui/nutui-react-taro'
|
||||
import Taro, { useRouter, useShareAppMessage } from '@tarojs/taro'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { getShopGoods } from '@/api/shop/shopGoods'
|
||||
import {
|
||||
addShopGoodsFavorite,
|
||||
@@ -14,12 +14,16 @@ import SkuSelector from '@/components/business/SkuSelector'
|
||||
import { useCartContext } from '@/contexts/CartContext'
|
||||
import { useUserContext } from '@/contexts/UserContext'
|
||||
import { useScrollHeight } from '@/hooks/useScrollHeight'
|
||||
import { useShare } from '@/hooks/useShare'
|
||||
import SharePoster, { SharePosterHandle } from '@/components/SharePoster'
|
||||
import { isGuest } from '@/utils/auth'
|
||||
import { requireLogin } from '@/utils/login-guard'
|
||||
import { isVipMember } from '@/utils/vip'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '商品详情',
|
||||
enableShareAppMessage: true,
|
||||
enableShareTimeline: true,
|
||||
})
|
||||
|
||||
const ProductDetailPage: React.FC = () => {
|
||||
@@ -35,13 +39,14 @@ const ProductDetailPage: React.FC = () => {
|
||||
// 底部操作栏高度约 90px(含按钮 + 安全区),动态计算 ScrollView 可用高度
|
||||
const scrollHeight = useScrollHeight(44)
|
||||
|
||||
// 微信分享配置
|
||||
useShareAppMessage(() => {
|
||||
return {
|
||||
title: product?.name || product?.goodsName || '优质商品推荐',
|
||||
path: `/pages/shop/product-detail?id=${id}`,
|
||||
imageUrl: product?.image || ''
|
||||
}
|
||||
// 分享 / 朋友圈
|
||||
const posterRef = useRef<SharePosterHandle>(null)
|
||||
const [posterPath, setPosterPath] = useState('')
|
||||
useShare({
|
||||
title: product?.name || product?.goodsName || '优质商品推荐',
|
||||
path: `/pages/shop/product-detail?id=${id}`,
|
||||
query: `id=${id}`,
|
||||
imageUrl: posterPath || product?.image || undefined,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
@@ -53,10 +58,20 @@ const ProductDetailPage: React.FC = () => {
|
||||
}
|
||||
}, [id, isLoggedIn])
|
||||
|
||||
// 监听 product 变化后再添加到历史记录
|
||||
// 监听 product 变化后再添加到历史记录,并异步生成分享海报
|
||||
useEffect(() => {
|
||||
if (product) {
|
||||
addToHistory()
|
||||
posterRef.current
|
||||
?.generate({
|
||||
cover: product.image,
|
||||
title: product.name || product.goodsName || '优质商品推荐',
|
||||
price:
|
||||
product.dealerPrice && isVipMember() ? product.dealerPrice : product.price,
|
||||
page: 'pages/shop/product-detail',
|
||||
})
|
||||
.then(setPosterPath)
|
||||
.catch(() => {})
|
||||
}
|
||||
}, [product])
|
||||
|
||||
@@ -444,6 +459,9 @@ const ProductDetailPage: React.FC = () => {
|
||||
onClose={() => setSkuVisible(false)}
|
||||
onConfirm={handleSkuConfirm}
|
||||
/>
|
||||
|
||||
{/* 分享海报画布(离屏,用于生成带小程序码的海报图) */}
|
||||
<SharePoster ref={posterRef} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user