订单列表对接
This commit is contained in:
@@ -12,6 +12,8 @@ import {formatHashTag, formatImgUrl} from '@/common/fotmat'
|
||||
import {GetProductDetailApi} from '@/api/material'
|
||||
import useLogin from '@/use/useLogin';
|
||||
import { useSelector } from '@/reducers/hooks';
|
||||
import { AnalysisShortCodeApi, GetShortCodeApi } from '@/api/share';
|
||||
import { SHARE_SCENE } from '@/common/enum';
|
||||
|
||||
type item = {title:string, img:string, url:string, id:number}
|
||||
|
||||
@@ -23,20 +25,47 @@ type params = {
|
||||
export default (props:params) => {
|
||||
const {checkLogin, getPhoneNumber, userInfo} = useLogin()
|
||||
|
||||
//获取参数
|
||||
const router = useRouter()
|
||||
const [params, setParams] = useState({id: '', share: null})
|
||||
|
||||
//判断是否是分享过来的参数
|
||||
const judgeParam = async () => {
|
||||
if(router.params.id) {
|
||||
setParams({...params, id:router.params.id})
|
||||
}else if(router.params.share) {
|
||||
analysisShortCode()
|
||||
}
|
||||
}
|
||||
|
||||
//解析短码参数(该请求不能校验token)
|
||||
const {fetchData: fetchDataAnalysisShortCode} = AnalysisShortCodeApi()
|
||||
const analysisShortCode = async () => {
|
||||
let res = await fetchDataAnalysisShortCode({md5_key: router.params.share})
|
||||
setParams({id: res.data.id, share: res.data})
|
||||
console.log('res::::&&', res.data)
|
||||
}
|
||||
|
||||
useDidShow(() => {
|
||||
checkLogin()
|
||||
judgeParam()
|
||||
})
|
||||
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
//先确保能拿到订单id才做其他请求
|
||||
if(params.id) {
|
||||
checkLogin()
|
||||
getShortCode()
|
||||
getProductDetail()
|
||||
}
|
||||
}, [params])
|
||||
|
||||
|
||||
|
||||
//获取数据
|
||||
const [productInfo, setProductInfo] = useState<any>({})
|
||||
const {fetchData} = GetProductDetailApi()
|
||||
useEffect(() => {
|
||||
getProductDetail()
|
||||
}, [])
|
||||
const getProductDetail = async () => {
|
||||
let {data} = await fetchData({id: router.params.id})
|
||||
let {data} = await fetchData({id: params.id})
|
||||
setProductInfo(data)
|
||||
Taro.stopPullDownRefresh()
|
||||
}
|
||||
@@ -74,18 +103,29 @@ export default (props:params) => {
|
||||
})
|
||||
}
|
||||
|
||||
//转发分享
|
||||
|
||||
const userObj = useSelector(state => state.userInfo)
|
||||
//获取分享转码
|
||||
const {ShareDetail} = SHARE_SCENE
|
||||
const {fetchData: fetchDataShortCode} = GetShortCodeApi()
|
||||
const sortCode = useRef('')
|
||||
const getShortCode = async () => {
|
||||
const {data: resDetail} = await fetchDataShortCode({"share_user_id": userObj.adminUserInfo.user_id, type:ShareDetail.value, id: params.id})
|
||||
sortCode.current = resDetail.md5_key
|
||||
}
|
||||
|
||||
|
||||
//转发分享
|
||||
useShareAppMessage(res => {
|
||||
let path = ''
|
||||
let title = ''
|
||||
let imageUrl = ''
|
||||
if (res.from === 'button') {
|
||||
path = `/pages/details/index?id=${userObj.sort_code.shareShortDetail}`
|
||||
path = `/pages/details/index?share=${sortCode.current}`
|
||||
title = productName as string
|
||||
// imageUrl =
|
||||
} else {
|
||||
path = `/pages/details/index?id=${userObj.sort_code.shareShortPage}`
|
||||
path = `/pages/index/index?share=${sortCode.current}`
|
||||
title = '陆盈电子商城'
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user