feat(user): 使用微信原生 Picker 替换所在地选择弹层
- 删除 NutUI Address 相关导入、状态及地区数据转换逻辑 - 新增派生 regionValue 用于绑定微信原生 Picker 的 value - 将 handleRegionChange 调整为处理微信 Picker 的事件 - 将所在地选择 UI 修改为微信原生 Picker 包裹的视图结构 - 地图定位失败使用弹窗提示,引导用户手动选择或重试 - 移除手动打开地区选择器的函数及 NutUI 组件 - 保留 RegionData 用于文本智能识别解析 - 编译通过,提升在无地图或无权限环境下的地区选择稳定性
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import React, { useEffect, useState, useRef } from 'react'
|
||||
import { View, Text, Image, ScrollView } from '@tarojs/components'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { getShopGroupBuy, listShopGroupBuyRecords, joinGroupBuy, createGroupBuy } from '@/api/shop/shopGroupBuy'
|
||||
@@ -8,9 +8,13 @@ import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
||||
import type { ShopGoodsSku } from '@/api/shop/shopGoodsSku/model'
|
||||
import SkuSelector from '@/components/business/SkuSelector'
|
||||
import { getCompressedImageUrl } from '@/utils/image'
|
||||
import { useShare } from '@/hooks/useShare'
|
||||
import SharePoster, { SharePosterHandle } from '@/components/SharePoster'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '拼团详情',
|
||||
enableShareAppMessage: true,
|
||||
enableShareTimeline: true,
|
||||
})
|
||||
|
||||
const GroupBuyDetailPage: React.FC = () => {
|
||||
@@ -25,6 +29,31 @@ const GroupBuyDetailPage: React.FC = () => {
|
||||
const [skuVisible, setSkuVisible] = useState(false)
|
||||
const [pendingRecordId, setPendingRecordId] = useState<number | null>(null)
|
||||
|
||||
// 分享 / 朋友圈
|
||||
const posterRef = useRef<SharePosterHandle>(null)
|
||||
const [posterPath, setPosterPath] = useState('')
|
||||
useShare({
|
||||
title: groupBuy?.goodsName || groupBuy?.product?.name || '拼团商品推荐',
|
||||
path: `/pages/shop/group-buy-detail?groupBuyId=${groupBuyId}`,
|
||||
query: `groupBuyId=${groupBuyId}`,
|
||||
imageUrl: posterPath || groupBuy?.goodsImage || groupBuy?.product?.image || undefined,
|
||||
})
|
||||
|
||||
// 数据加载完成后异步生成分享海报(带小程序码)
|
||||
useEffect(() => {
|
||||
if (groupBuy) {
|
||||
posterRef.current
|
||||
?.generate({
|
||||
cover: groupBuy.goodsImage || groupBuy.product?.image,
|
||||
title: groupBuy.goodsName || groupBuy.product?.name || '拼团商品',
|
||||
price: groupBuy.groupPrice,
|
||||
page: 'pages/shop/group-buy-detail',
|
||||
})
|
||||
.then(setPosterPath)
|
||||
.catch(() => {})
|
||||
}
|
||||
}, [groupBuy])
|
||||
|
||||
useEffect(() => {
|
||||
if (groupBuyId) {
|
||||
fetchData()
|
||||
@@ -317,6 +346,8 @@ const GroupBuyDetailPage: React.FC = () => {
|
||||
onClose={() => setSkuVisible(false)}
|
||||
onConfirm={handleSkuConfirm}
|
||||
/>
|
||||
{/* 分享海报画布(离屏,用于生成带小程序码的海报图) */}
|
||||
<SharePoster ref={posterRef} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user