订单列表对接

This commit is contained in:
2022-06-02 20:14:05 +08:00
parent b921bcaa07
commit 5ae2eb3541
9 changed files with 152 additions and 30 deletions
+49 -9
View File
@@ -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 {
+1
View File
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: '首页',
enableShareAppMessage: true,
}
+1 -1
View File
@@ -8,7 +8,7 @@ import ShopCart from '@/components/shopCart'
import { goLink } from '@/common/common'
import styles from './index.module.scss'
import React, { useEffect, useMemo, useRef, useState } from 'react'
import Taro, { Events, useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
import Taro, { Events, useDidShow, usePullDownRefresh, useRouter, useShareAppMessage } from '@tarojs/taro'
import {GetProductKindListApi, GetProductListApi} from '@/api/material'
import useLogin from '@/use/useLogin'
import LoadingCard from '@/components/loadingCard'
+3 -3
View File
@@ -1,5 +1,5 @@
.order_list_main{
min-height: 100vh;
height: 100vh;
background-color: $color_bg_one;
display: flex;
flex-direction: column;
@@ -8,6 +8,7 @@
background-color: #fff;
box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.16);
border-bottom: 2px solid #e2e2e2;
height: 160px;
.order_status_list{
font-size: $font_size;
color: #9E9E9E;
@@ -28,8 +29,7 @@
}
}
.order_list{
flex:1;
height: 0;
height: calc(100vh - 160px);
.order_item_con{
margin-top: 20px;
padding: 0 20px;