订单列表对接
This commit is contained in:
parent
b921bcaa07
commit
5ae2eb3541
@ -9,3 +9,23 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
method: "post",
|
method: "post",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析短码
|
||||||
|
*/
|
||||||
|
export const AnalysisShortCodeApi = () => {
|
||||||
|
return useRequest({
|
||||||
|
url: `/v1/mall/shortCode`,
|
||||||
|
method: "get",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定上下级
|
||||||
|
*/
|
||||||
|
export const BindShortCodeApi = () => {
|
||||||
|
return useRequest({
|
||||||
|
url: `/v1/mall/shortCode/bind`,
|
||||||
|
method: "post",
|
||||||
|
})
|
||||||
|
}
|
55
src/app.tsx
55
src/app.tsx
@ -2,27 +2,58 @@ import { FC } from 'react'
|
|||||||
import ContextBlueTooth from "@/use/contextBlueTooth"
|
import ContextBlueTooth from "@/use/contextBlueTooth"
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import configStore from './store'
|
import configStore from './store'
|
||||||
|
import {BASE_URL, WX_APPID} from '@/common/constant'
|
||||||
import './app.scss'
|
import './app.scss'
|
||||||
import { useShareAppMessage } from '@tarojs/taro'
|
import Taro, { useDidShow, useRouter, useShareAppMessage } from '@tarojs/taro'
|
||||||
import { useSelector } from './reducers/hooks'
|
import { useSelector } from './reducers/hooks'
|
||||||
|
import { AnalysisShortCodeApi } from './api/share'
|
||||||
|
|
||||||
const store = configStore()
|
const store = configStore()
|
||||||
const App:FC = ({children}) => {
|
const App:FC = (params) => {
|
||||||
//转发分享
|
|
||||||
// const userObj = useSelector(state => state.userInfo)
|
Taro.showShareMenu({
|
||||||
useShareAppMessage(res => {
|
withShareTicket: true
|
||||||
return {
|
|
||||||
title: '电子商城',
|
|
||||||
path: `/pages/details/index`,
|
|
||||||
imageUrl:'',
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
useDidShow(() => {
|
||||||
|
console.log('paramsparamsparamsparams:',params)
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = useRouter()
|
||||||
|
const page = Taro.getCurrentInstance().page
|
||||||
|
|
||||||
|
// console.log('page::::',page)
|
||||||
|
//解析短码参数(该请求不能校验token)
|
||||||
|
// const {fetchData: fetchDataAnalysisShortCode} = AnalysisShortCodeApi()
|
||||||
|
// const analysisShortCode = async () => {
|
||||||
|
// let res = await fetchDataAnalysisShortCode({md5_key: page?.options?.share})
|
||||||
|
// // setParams({id: res.data.id, share: res.data})
|
||||||
|
// console.log('res::::&&', res.data)
|
||||||
|
// }
|
||||||
|
|
||||||
|
const sortCode = JSON.parse(Taro.getStorageSync('sort_code'))
|
||||||
|
console.log('res:::', page)
|
||||||
|
if(page && page.onShareAppMessage) {
|
||||||
|
if(page.options?.share) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
page.onShareAppMessage = () => {
|
||||||
|
return {
|
||||||
|
title: '电子商城',
|
||||||
|
path: `/pages/index/index?share=${sortCode.shareShortPage}`,
|
||||||
|
imageUrl:'',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextBlueTooth>
|
<ContextBlueTooth>
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
{children}
|
{params.children}
|
||||||
</Provider>
|
</Provider>
|
||||||
</ContextBlueTooth>
|
</ContextBlueTooth>
|
||||||
)
|
)
|
||||||
|
31
src/common/shortCode/index.js
Normal file
31
src/common/shortCode/index.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
//解析短码
|
||||||
|
export const analysisShortCodeApi = () => {
|
||||||
|
//解析短码
|
||||||
|
Taro.request({
|
||||||
|
url:BASE_URL+'/v1/mall/shortCode',
|
||||||
|
method:"GET",
|
||||||
|
data:{md5_key: page.options?.share},
|
||||||
|
success:(res) => {
|
||||||
|
if(res.data.code == 0) {
|
||||||
|
//绑定上下级
|
||||||
|
bindParent(res.data.data.share_user_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//绑定上下级
|
||||||
|
const bindParent = (share_user_id) => {
|
||||||
|
//绑定上下级
|
||||||
|
Taro.request({
|
||||||
|
url:BASE_URL+'/v1/mall/shortCode/bind',
|
||||||
|
method:"POST",
|
||||||
|
data:{share_user_id: share_user_id},
|
||||||
|
success:(res) => {
|
||||||
|
if(res.data.code == 0) {
|
||||||
|
//绑定上下级
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -12,6 +12,8 @@ import {formatHashTag, formatImgUrl} from '@/common/fotmat'
|
|||||||
import {GetProductDetailApi} from '@/api/material'
|
import {GetProductDetailApi} from '@/api/material'
|
||||||
import useLogin from '@/use/useLogin';
|
import useLogin from '@/use/useLogin';
|
||||||
import { useSelector } from '@/reducers/hooks';
|
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}
|
type item = {title:string, img:string, url:string, id:number}
|
||||||
|
|
||||||
@ -23,20 +25,47 @@ type params = {
|
|||||||
export default (props:params) => {
|
export default (props:params) => {
|
||||||
const {checkLogin, getPhoneNumber, userInfo} = useLogin()
|
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(() => {
|
useDidShow(() => {
|
||||||
checkLogin()
|
judgeParam()
|
||||||
})
|
})
|
||||||
|
|
||||||
const router = useRouter()
|
useEffect(() => {
|
||||||
|
//先确保能拿到订单id才做其他请求
|
||||||
|
if(params.id) {
|
||||||
|
checkLogin()
|
||||||
|
getShortCode()
|
||||||
|
getProductDetail()
|
||||||
|
}
|
||||||
|
}, [params])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//获取数据
|
//获取数据
|
||||||
const [productInfo, setProductInfo] = useState<any>({})
|
const [productInfo, setProductInfo] = useState<any>({})
|
||||||
const {fetchData} = GetProductDetailApi()
|
const {fetchData} = GetProductDetailApi()
|
||||||
useEffect(() => {
|
|
||||||
getProductDetail()
|
|
||||||
}, [])
|
|
||||||
const getProductDetail = async () => {
|
const getProductDetail = async () => {
|
||||||
let {data} = await fetchData({id: router.params.id})
|
let {data} = await fetchData({id: params.id})
|
||||||
setProductInfo(data)
|
setProductInfo(data)
|
||||||
Taro.stopPullDownRefresh()
|
Taro.stopPullDownRefresh()
|
||||||
}
|
}
|
||||||
@ -74,18 +103,29 @@ export default (props:params) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//转发分享
|
|
||||||
const userObj = useSelector(state => state.userInfo)
|
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 => {
|
useShareAppMessage(res => {
|
||||||
let path = ''
|
let path = ''
|
||||||
let title = ''
|
let title = ''
|
||||||
let imageUrl = ''
|
let imageUrl = ''
|
||||||
if (res.from === 'button') {
|
if (res.from === 'button') {
|
||||||
path = `/pages/details/index?id=${userObj.sort_code.shareShortDetail}`
|
path = `/pages/details/index?share=${sortCode.current}`
|
||||||
title = productName as string
|
title = productName as string
|
||||||
// imageUrl =
|
// imageUrl =
|
||||||
} else {
|
} else {
|
||||||
path = `/pages/details/index?id=${userObj.sort_code.shareShortPage}`
|
path = `/pages/index/index?share=${sortCode.current}`
|
||||||
title = '陆盈电子商城'
|
title = '陆盈电子商城'
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
export default {
|
export default {
|
||||||
navigationBarTitleText: '首页',
|
navigationBarTitleText: '首页',
|
||||||
|
enableShareAppMessage: true,
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import ShopCart from '@/components/shopCart'
|
|||||||
import { goLink } from '@/common/common'
|
import { goLink } from '@/common/common'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
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 {GetProductKindListApi, GetProductListApi} from '@/api/material'
|
||||||
import useLogin from '@/use/useLogin'
|
import useLogin from '@/use/useLogin'
|
||||||
import LoadingCard from '@/components/loadingCard'
|
import LoadingCard from '@/components/loadingCard'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.order_list_main{
|
.order_list_main{
|
||||||
min-height: 100vh;
|
height: 100vh;
|
||||||
background-color: $color_bg_one;
|
background-color: $color_bg_one;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -8,6 +8,7 @@
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.16);
|
box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.16);
|
||||||
border-bottom: 2px solid #e2e2e2;
|
border-bottom: 2px solid #e2e2e2;
|
||||||
|
height: 160px;
|
||||||
.order_status_list{
|
.order_status_list{
|
||||||
font-size: $font_size;
|
font-size: $font_size;
|
||||||
color: #9E9E9E;
|
color: #9E9E9E;
|
||||||
@ -28,8 +29,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.order_list{
|
.order_list{
|
||||||
flex:1;
|
height: calc(100vh - 160px);
|
||||||
height: 0;
|
|
||||||
.order_item_con{
|
.order_item_con{
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
|
@ -68,8 +68,6 @@ const INIT_USER = {
|
|||||||
sort_code: Taro.getStorageSync('sort_code')?JSON.parse(Taro.getStorageSync('sort_code')):null,
|
sort_code: Taro.getStorageSync('sort_code')?JSON.parse(Taro.getStorageSync('sort_code')):null,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default function counter (state = INIT_USER, action: Action) {
|
export default function counter (state = INIT_USER, action: Action) {
|
||||||
const {type, data} = action
|
const {type, data} = action
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -110,14 +110,15 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取分享转码
|
//获取分享转码
|
||||||
const {ShareDetail, SharePage} = SHARE_SCENE
|
const {SharePage} = SHARE_SCENE
|
||||||
const {fetchData: fetchDataShortCode} = GetShortCodeApi()
|
const {fetchData: fetchDataShortCode} = GetShortCodeApi()
|
||||||
const getShortCode = async (user_id) => {
|
const getShortCode = async (user_id) => {
|
||||||
const {data: resDetail} = await fetchDataShortCode({"share_user_id": user_id, type:ShareDetail.value})
|
|
||||||
const {data: resPage} = await fetchDataShortCode({"share_user_id": user_id, type:SharePage.value})
|
const {data: resPage} = await fetchDataShortCode({"share_user_id": user_id, type:SharePage.value})
|
||||||
setSortCode({shareShortDetail: resDetail.md5_key, shareShortPage: resPage.md5_key})
|
setSortCode({shareShortDetail: '', shareShortPage: resPage.md5_key})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
return {
|
return {
|
||||||
checkLogin,
|
checkLogin,
|
||||||
wxLogin,
|
wxLogin,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user