对接api
This commit is contained in:
parent
e7a130533d
commit
4c46c6e22d
12
src/api/banner.ts
Normal file
12
src/api/banner.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
|
||||
/**
|
||||
* 获取轮播图列表
|
||||
* @returns
|
||||
*/
|
||||
export const GetBannerList = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/carouselBanner/list`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
35
src/api/material.ts
Normal file
35
src/api/material.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
|
||||
/**
|
||||
* 获取面料分类列表
|
||||
* @returns
|
||||
*/
|
||||
export const GetCategoryList = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/category/list`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取面料种类列表
|
||||
* @returns
|
||||
*/
|
||||
export const GetProductKindListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/product/kind/list`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取面料列表
|
||||
* @returns
|
||||
*/
|
||||
export const GetProductListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/product/list`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
console.log('环境变量2',CURRENT_ENV);
|
||||
// export const BASE_URL = CURRENT_ENV.includes('development') ? `https://test.zzfzyc.com/lymarket` : `https://www.zzfzyc.com/lymarket`
|
||||
// export const BASE_URL = `http://192.168.0.75:50001/lymarket`
|
||||
// export const BASE_URL = `http://192.168.0.89:50001/lymarket`
|
||||
@ -9,9 +8,6 @@ console.log('环境变量2',CURRENT_ENV);
|
||||
export const BASE_URL = `http://192.168.1.30:40001/lymarket` // 发
|
||||
// export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境
|
||||
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
|
||||
|
||||
|
||||
|
||||
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
||||
|
||||
// CDN
|
||||
@ -27,4 +23,4 @@ export const IMG_CND_Prefix = "http://test.cdn.zzfzyc.com/"
|
||||
export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}`;
|
||||
|
||||
//appid
|
||||
export const WX_APPID = 'wx6c8b9156543480b0'
|
||||
export const WX_APPID = 'wx68d92d7cbf0b6963'
|
51
src/components/banner/index.tsx
Normal file
51
src/components/banner/index.tsx
Normal file
@ -0,0 +1,51 @@
|
||||
import { Image, Swiper, SwiperItem, View } from "@tarojs/components"
|
||||
import { goLink } from "@/common/common"
|
||||
import {GetBannerList} from "@/api/banner"
|
||||
import styles from './index.module.scss'
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
type item = {title:string, img:string, url:string, id:number}
|
||||
|
||||
type params = {
|
||||
list?: item[]
|
||||
swiperOnClick?: (val: item) => void,
|
||||
style?: Object
|
||||
}
|
||||
export default (props:params) => {
|
||||
let {swiperOnClick, style = {}} = props
|
||||
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const {fetchData, state} = GetBannerList()
|
||||
|
||||
useEffect(() => {
|
||||
getData()
|
||||
}, [])
|
||||
|
||||
const getData = async () => {
|
||||
const res = await fetchData()
|
||||
setList(res.data.list)
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.swiper_con} style={style}>
|
||||
<Swiper
|
||||
className={styles.xswiper}
|
||||
indicatorColor='#ccc'
|
||||
indicatorActiveColor='#fff'
|
||||
circular
|
||||
indicatorDots
|
||||
autoplay>
|
||||
{
|
||||
list.map(item => {
|
||||
return <SwiperItem key={item.id}>
|
||||
<View className={styles.image_item} onClick={() => goLink(item.link)}>
|
||||
<Image mode="aspectFill" src={item.prev_view_url}></Image>
|
||||
</View>
|
||||
</SwiperItem>
|
||||
})
|
||||
}
|
||||
</Swiper>
|
||||
</View>
|
||||
)
|
||||
|
||||
}
|
@ -82,7 +82,7 @@ export default memo(({
|
||||
{moreStatus&&<View className={style.infinite_scroll}>
|
||||
{
|
||||
hasMore&&<View className={style.loading_more}>加载中<DotLoading/></View>||
|
||||
<View>没有更多了</View>
|
||||
<View>没有更多数据了</View>
|
||||
}
|
||||
</View>}
|
||||
</View>
|
||||
|
@ -3,27 +3,27 @@ import Taro from "@tarojs/taro"
|
||||
import { goLink } from "@/common/common"
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type params = {
|
||||
desStatus?: true|false
|
||||
type Params = {
|
||||
desStatus?: true|false,
|
||||
productList?: any[]
|
||||
}
|
||||
export default ({desStatus = true}: params) => {
|
||||
|
||||
export default ({desStatus = true, productList = []}:Params) => {
|
||||
return (
|
||||
<View className={styles.products_list}>
|
||||
{new Array(10).fill('').map(item => {
|
||||
{productList.map(item => {
|
||||
return <View className={styles.products_item} onClick={() => goLink('/pages/details/index?id=1')}>
|
||||
<View className={styles.item_img}>
|
||||
<Image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp01%2F1ZZQ214233446-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651827249&t=b2fc2a3672dc8ced9e0f37ce7e2ff901"/>
|
||||
<View className={styles.num}>230色</View>
|
||||
<Image src={item.texture_url}/>
|
||||
<View className={styles.num}>{item.product_color_count}色</View>
|
||||
</View>
|
||||
<View className={styles.item_con}>
|
||||
<View className={styles.title}><text>0770#</text>21S单面平纹(食毛)</View>
|
||||
<View className={styles.title}><text>{item.code}#</text>{item.name}</View>
|
||||
<View className={styles.tag_list}>
|
||||
<View className={styles.tag}>160cm</View>
|
||||
<View className={styles.tag}>110g</View>
|
||||
<View className={styles.tag}>{item.width}</View>
|
||||
<View className={styles.tag}>{item.weight_density}</View>
|
||||
</View>
|
||||
<View className={styles.introduce}>67.6%棉24%涤纶6.4%氨纶</View>
|
||||
{desStatus&&<View className={styles.des}>产品描述产品描述产品描述产品描述产品描述</View>}
|
||||
<View className={styles.introduce}>{item.component}</View>
|
||||
{desStatus&&<View className={styles.des}>{item.describe}</View>}
|
||||
</View>
|
||||
</View>
|
||||
})}
|
||||
|
@ -1,24 +1,23 @@
|
||||
import { ScrollView, View } from "@tarojs/components"
|
||||
import { memo, ReactNode, useRef, useState } from "react"
|
||||
import { memo, ReactNode, useEffect, useRef, useState } from "react"
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Taro, { useReady } from "@tarojs/taro";
|
||||
import InfiniteScroll from "../infiniteScroll";
|
||||
|
||||
type ListProps = {
|
||||
title: string,
|
||||
value: number
|
||||
}
|
||||
|
||||
|
||||
type Params = {
|
||||
list?: ListProps[],
|
||||
list?: any[],
|
||||
defaultValue?: number|string,
|
||||
children?: ReactNode,
|
||||
height?: string,
|
||||
heightItem?: number,
|
||||
sideBarOnClick?: (ListProps) => void,
|
||||
sideBarOnClick?: (val:any) => void,
|
||||
refresherTriggered?: true|false,
|
||||
selfOnRefresherRefresh?: () => void
|
||||
selfOnScrolltolower?: () => void,
|
||||
hasMore?: true|false
|
||||
}
|
||||
|
||||
export default memo(({list = [],
|
||||
@ -28,7 +27,9 @@ export default memo(({list = [],
|
||||
children,
|
||||
heightItem = 100,
|
||||
refresherTriggered = false,
|
||||
selfOnRefresherRefresh
|
||||
selfOnRefresherRefresh,
|
||||
selfOnScrolltolower,
|
||||
hasMore = true
|
||||
}: Params) => {
|
||||
|
||||
let num_half = useRef(0)
|
||||
@ -36,17 +37,21 @@ export default memo(({list = [],
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
setSelected(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const init = () => {
|
||||
const index = list?.findIndex(item => {
|
||||
return item.value == defaultValue
|
||||
return item.id == defaultValue
|
||||
})
|
||||
if(index !== -1) {
|
||||
computeSelectTab(index)
|
||||
}
|
||||
}
|
||||
|
||||
const clickEvent = ({item, index}: {item:ListProps, index:number}) => {
|
||||
setSelected(item.value)
|
||||
const clickEvent = ({item, index}: {item, index:number}) => {
|
||||
setSelected(item.id)
|
||||
sideBarOnClick?.(item)
|
||||
computeSelectTab(index)
|
||||
}
|
||||
@ -54,9 +59,10 @@ export default memo(({list = [],
|
||||
const computeSelectTab = (index) => {
|
||||
if((index + 1) > num_half.current) {
|
||||
let num = index + 1 - num_half.current
|
||||
setTabId(list[num].value.toString())
|
||||
setTabId(list[num].id.toString())
|
||||
} else {
|
||||
setTabId(list[0].value.toString())
|
||||
setTabId(list[0].id.toString())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,10 +81,7 @@ export default memo(({list = [],
|
||||
})
|
||||
})
|
||||
|
||||
//触底事件
|
||||
const onScrolltolower = () => {
|
||||
console.log('触底了')
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -88,14 +91,14 @@ export default memo(({list = [],
|
||||
list?.map((item, index) => {
|
||||
return(
|
||||
<View
|
||||
className={classnames(styles.sideBar_select_title, {[styles.sideBar_select_title_select]:(selected == item.value)})}
|
||||
className={classnames(styles.sideBar_select_title, {[styles.sideBar_select_title_select]:(selected == item.id)})}
|
||||
onClick={() => clickEvent({item, index})}
|
||||
id={`tab_${item.value}`}
|
||||
key={item.value}
|
||||
id={`tab_${item.id}`}
|
||||
key={item.id}
|
||||
style={{height:heightItem+'rpx'}}
|
||||
>
|
||||
<View className={styles.title_con}>
|
||||
{item.title}
|
||||
{item.name}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
@ -104,7 +107,7 @@ export default memo(({list = [],
|
||||
<View className="common_safe_area_y"></View>
|
||||
</ScrollView>
|
||||
<View className={styles.sideBar_con}>
|
||||
<InfiniteScroll selfonScrollToLower={() => onScrolltolower()} refresherTriggered={refresherTriggered} refresherEnabled={true} selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
|
||||
<InfiniteScroll hasMore={hasMore} selfonScrollToLower={() => selfOnScrolltolower?.()} refresherTriggered={refresherTriggered} refresherEnabled={true} selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
|
||||
{children}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
@ -1,52 +0,0 @@
|
||||
import { Image, Swiper, SwiperItem, View } from "@tarojs/components"
|
||||
import { goLink } from "@/common/common"
|
||||
import Taro from "@tarojs/taro"
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type item = {title:string, img:string, url:string, id:number}
|
||||
|
||||
type params = {
|
||||
list?: item[]
|
||||
swiperOnClick?: (val: item) => void,
|
||||
style?: Object
|
||||
}
|
||||
export default (props:params) => {
|
||||
let {list = [], swiperOnClick, style = {}} = props
|
||||
list = [
|
||||
{
|
||||
title:'数据',
|
||||
img:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F811%2F021315104H2%2F150213104H2-3-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651817947&t=5467a207f845ddfc7737d55934e6b26d',
|
||||
url:'',
|
||||
id:1
|
||||
},
|
||||
{
|
||||
title:'数据',
|
||||
img:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F811%2F021315104H2%2F150213104H2-3-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651817947&t=5467a207f845ddfc7737d55934e6b26d',
|
||||
url:'',
|
||||
id:2
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<View className={styles.swiper_con} style={style}>
|
||||
<Swiper
|
||||
className={styles.xswiper}
|
||||
indicatorColor='#ccc'
|
||||
indicatorActiveColor='#fff'
|
||||
circular
|
||||
indicatorDots
|
||||
autoplay>
|
||||
{
|
||||
list.map(item => {
|
||||
return <SwiperItem key={item.id}>
|
||||
<View className={styles.image_item} onClick={() => goLink(`/pages/classList/index?id=${item.id}`)}>
|
||||
<Image mode="aspectFill" src={item.img}></Image>
|
||||
</View>
|
||||
</SwiperItem>
|
||||
})
|
||||
}
|
||||
</Swiper>
|
||||
</View>
|
||||
)
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { Image, Swiper, SwiperItem, View } from "@tarojs/components"
|
||||
import { useMemo, useState } from "react"
|
||||
import { useMemo, useRef, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type item = {title:string, img:string, url:string, id:number}
|
||||
@ -10,6 +10,7 @@ type params = {
|
||||
export default ({list = []}: params) => {
|
||||
|
||||
const [pageIndex, setPageIndex] = useState(1)
|
||||
const pageRef = useRef<any>(null)
|
||||
|
||||
const pageCount = useMemo(() => {
|
||||
return list.length
|
||||
@ -17,8 +18,10 @@ export default ({list = []}: params) => {
|
||||
|
||||
const swiperChange = (e) => {
|
||||
setPageIndex(e.detail.current + 1)
|
||||
pageRef.current.innerHTML = 2
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.swiper}>
|
||||
<Swiper className={styles.swiper_item} circular={true} onAnimationFinish={(e) => swiperChange(e)}>
|
||||
@ -30,7 +33,7 @@ export default ({list = []}: params) => {
|
||||
</SwiperItem>
|
||||
})}
|
||||
</Swiper>
|
||||
<View className={styles.page}>{pageIndex+'/'+pageCount}</View>
|
||||
<View className={styles.page} ref={pageRef}>{pageIndex+'/'+pageCount}</View>
|
||||
</View>
|
||||
)
|
||||
}
|
@ -11,6 +11,7 @@ import { useEffect, useMemo, useState } from 'react';
|
||||
import useManualPullDownRefresh from '@/use/useManualPullDownRefresh';
|
||||
import { goLink } from '@/common/common';
|
||||
import useUserInfo from '@/use/useUserInfo';
|
||||
|
||||
type item = {title:string, img:string, url:string, id:number}
|
||||
|
||||
type params = {
|
||||
@ -48,9 +49,6 @@ export default (props:params) => {
|
||||
|
||||
|
||||
const [showOrderCount, setShowOrderCount] = useState(false)
|
||||
// const showCartmemo = useMemo(() => {
|
||||
// return showCart
|
||||
// },[showCart])
|
||||
|
||||
const html = `<h1>这里是详情</h1>
|
||||
<div style="font-size:13px">你好啊啊</div>
|
||||
@ -106,6 +104,7 @@ export default (props:params) => {
|
||||
|
||||
const {user} = useUserInfo()
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<DesSwiper list={list}/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {View} from '@tarojs/components'
|
||||
import Swiper from '@/components/swiper'
|
||||
import Banner from '@/components/banner'
|
||||
import Search from '@/components/search'
|
||||
import SideBar from '@/components/sideBar'
|
||||
import Product from '@/components/product'
|
||||
@ -7,50 +7,77 @@ import MoveBtn from '@/components/moveBtn'
|
||||
import ShopCart from '@/components/shopCart'
|
||||
import styles from './index.module.scss'
|
||||
import { goLink } from '@/common/common'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import useManualPullDownRefresh from '@/use/useManualPullDownRefresh'
|
||||
import useUserInfo from '@/use/useUserInfo'
|
||||
import {GetProductKindListApi, GetProductListApi} from '@/api/material'
|
||||
|
||||
export default () => {
|
||||
const tabs_list = [
|
||||
{title:'平纹系列', value: 1},
|
||||
{title:'平纹系列', value: 2},
|
||||
{title:'平纹系列', value: 3},
|
||||
{title:'平纹系列', value: 4},
|
||||
{title:'平纹系列', value: 5},
|
||||
{title:'平纹系列', value: 6},
|
||||
{title:'平纹系列', value: 7},
|
||||
{title:'平纹系列', value: 8},
|
||||
{title:'平纹系列', value: 9},
|
||||
{title:'平纹系列', value: 10},
|
||||
{title:'平纹系列', value: 11},
|
||||
{title:'平纹系列', value: 12},
|
||||
{title:'平纹系列', value: 13},
|
||||
{title:'平纹系列', value: 14},
|
||||
{title:'平纹系列', value: 15},
|
||||
{title:'平纹系列', value: 16},
|
||||
{title:'平纹系列', value: 17},
|
||||
]
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
categoryList()
|
||||
}, [])
|
||||
|
||||
//获取面料种类
|
||||
const [kindData, setKindData] = useState<any>({list:[], defaultId:0})
|
||||
const {fetchData} = GetProductKindListApi()
|
||||
const categoryList = async () => {
|
||||
const res = await fetchData()
|
||||
setKindData({...kindData, list:res.data.list, defaultId: res.data.list[0].id})
|
||||
filtrate.current.product_kind_id = res.data.list[0].id
|
||||
getProductList()
|
||||
}
|
||||
|
||||
//获取面料列表
|
||||
const [productData, setProductData] = useState({list:[], total:0, hasMore:true})
|
||||
const filtrate = useRef({product_kind_id:0, size: 5,page: 1})
|
||||
const pageNum = useRef(1)
|
||||
const {fetchData: productFetchData, state: productState} = GetProductListApi()
|
||||
const getProductKindId = async (e) => {
|
||||
filtrate.current.size = 5
|
||||
pageNum.current = 1
|
||||
filtrate.current.product_kind_id = e.id
|
||||
getProductList()
|
||||
}
|
||||
const getProductList = async () => {
|
||||
filtrate.current.size = filtrate.current.size * pageNum.current
|
||||
const {data,total} = await productFetchData(filtrate.current)
|
||||
setProductData({...productData,list:data.list,total})
|
||||
}
|
||||
|
||||
//上拉加载数据
|
||||
const getScrolltolower = () => {
|
||||
if(productData.list.length >= productData.total) {
|
||||
setProductData({...productData, hasMore: false})
|
||||
} else {
|
||||
pageNum.current++
|
||||
getProductList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const [showShopCart, setShowShopCart] = useState(false)
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
filtrate.current.size = 5
|
||||
pageNum.current = 1
|
||||
getProductList()
|
||||
}
|
||||
useEffect(() => {
|
||||
setRefresherTriggeredStatus(productState.loading)
|
||||
}, [productState.loading])
|
||||
|
||||
//页面下拉刷新
|
||||
const res = useManualPullDownRefresh()
|
||||
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getData = () => {
|
||||
setRefresherTriggeredStatus(true)
|
||||
setTimeout(() => {
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
console.log('12123')
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
return (
|
||||
<MoveBtn onClick={() => setShowShopCart(!showShopCart)}>
|
||||
<View className={styles.main}>
|
||||
<Swiper/>
|
||||
<Banner/>
|
||||
<View className={styles.search}>
|
||||
<View className={styles.search_collect}>我的收藏</View>
|
||||
<View className={styles.search_input}>
|
||||
@ -58,8 +85,8 @@ export default () => {
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.products}>
|
||||
<SideBar list={tabs_list} height="100%" heightItem={150} refresherTriggered={refresherTriggeredStatus} selfOnRefresherRefresh={() => getData()}>
|
||||
<Product/>
|
||||
<SideBar list={kindData.list} height="100%" defaultValue={kindData.defaultId} hasMore={productData.hasMore} selfOnScrolltolower={() => getScrolltolower()} sideBarOnClick={(e) => getProductKindId(e)} heightItem={150} refresherTriggered={refresherTriggeredStatus} selfOnRefresherRefresh={() => getRefresherRefresh()}>
|
||||
<Product productList={productData.list}/>
|
||||
</SideBar>
|
||||
</View>
|
||||
<View className='common_safe_area_y'></View>
|
||||
|
@ -11,11 +11,14 @@ export default ({onBlur, onSave}:Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 10
|
||||
count: 200
|
||||
})
|
||||
const getDesc = useCallback((e) => {
|
||||
let value = e.detail.value
|
||||
let res = value.slice(0, descData.count)
|
||||
let res = value
|
||||
if(value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({...descData, number:res.length, value: res})
|
||||
},[])
|
||||
|
||||
@ -26,7 +29,7 @@ export default ({onBlur, onSave}:Param) => {
|
||||
<View className={styles.order_popup}>
|
||||
<View className={styles.order_popup_title}>添加备注</View>
|
||||
<View className={styles.order_popup_input}>
|
||||
<Textarea placeholder="请添加备注" maxlength={10} cursorSpacing={100} onInput={(e) => getDesc(e)} onBlur={(e) => onBlur?.(e)}></Textarea>
|
||||
<Textarea placeholder="请添加备注" maxlength={descData.count} cursorSpacing={100} onInput={(e) => getDesc(e)} onBlur={(e) => onBlur?.(e)}></Textarea>
|
||||
<View className={styles.descDataNum}>{descData.number}/{descData.count}</View>
|
||||
</View>
|
||||
<View className={styles.order_save_address} onClick={() => setSave()}>保存</View>
|
||||
|
@ -1,6 +1,13 @@
|
||||
|
||||
import Taro from '@tarojs/taro'
|
||||
import { SET_USERINFO, SET_TOKEN, SET_SESSIONKEY, CLEAR_TOKEN, CLEAR_USERINFO, CLEAR_SESSIONKEY} from '../constants/userInfo'
|
||||
import {
|
||||
SET_USERINFO,
|
||||
SET_TOKEN,
|
||||
SET_SESSIONKEY,
|
||||
CLEAR_TOKEN,
|
||||
CLEAR_USERINFO,
|
||||
CLEAR_SESSIONKEY
|
||||
} from '../constants/userInfo'
|
||||
|
||||
export type UserParam = {
|
||||
name?:string,
|
||||
@ -8,17 +15,19 @@ export type UserParam = {
|
||||
avatarUrl?:string,
|
||||
}
|
||||
|
||||
type Action = {
|
||||
type?: string,
|
||||
data?: DataParam
|
||||
}
|
||||
|
||||
export type DataParam = {
|
||||
token?: string
|
||||
sessionkey?: string,
|
||||
userInfo: UserParam
|
||||
}
|
||||
|
||||
type Action = {
|
||||
type?: string,
|
||||
data?: DataParam
|
||||
}
|
||||
|
||||
|
||||
|
||||
const INIT_USER = {
|
||||
userInfo: Taro.getStorageSync('userInfo')?JSON.parse(Taro.getStorageSync('userInfo')):null,
|
||||
token: Taro.getStorageSync('token')||'',
|
||||
|
@ -2,10 +2,9 @@
|
||||
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useRef, useState } from 'react'
|
||||
import {BASE_URL} from '@/common/constant'
|
||||
import qs from 'qs';
|
||||
|
||||
|
||||
|
||||
type Params = {
|
||||
code: string|null
|
||||
success: true|false
|
||||
@ -24,6 +23,16 @@ type Params = {
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
type option = {
|
||||
url?: string,
|
||||
method?: 'get'|'post'|'put'|'delete',
|
||||
type?: string,
|
||||
data?: any,
|
||||
page?: number,
|
||||
pageSize?: number,
|
||||
pagination?: true|false
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回状态信息,根据 http 状态错
|
||||
* @param {Number} status
|
||||
@ -80,7 +89,7 @@ const showStatus = (status) => {
|
||||
* @param {Object} options.data 请求的参数
|
||||
* @returns {Object} 返回fetch(), loading, error, code, msg
|
||||
*/
|
||||
export const useRequest = (options = {
|
||||
export const useRequest = (options:option = {
|
||||
url: '/',
|
||||
method: 'get',
|
||||
type: 'json',
|
||||
@ -90,7 +99,7 @@ export const useRequest = (options = {
|
||||
pagination: false, // 是否分页
|
||||
}) => {
|
||||
|
||||
|
||||
options.url = `${BASE_URL}${options.url}`
|
||||
let params:Params = {
|
||||
code: null, // 业务码
|
||||
success: false, // 请求是否成功
|
||||
@ -110,43 +119,8 @@ export const useRequest = (options = {
|
||||
const stateRef = useRef({...params})
|
||||
const [state, setState] = useState({...stateRef.current})
|
||||
|
||||
// // 每页多少条记录
|
||||
// const handleSizeChange = (val) => {
|
||||
// state.size = val
|
||||
// }
|
||||
|
||||
// // 当前
|
||||
// const handleCurrentChange = (val) => {
|
||||
// state.page = val
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 筛选搜索
|
||||
// * @param {Object} val `{name:'ppx'}` name 为字段名,ppx 为字段内容
|
||||
// */
|
||||
// const handleFilterChange = (val) => {
|
||||
// state.filter = val
|
||||
// }
|
||||
|
||||
// 排序
|
||||
|
||||
/**
|
||||
* 排序字段,排序方式
|
||||
* @param {String} val 排序字段
|
||||
* @param {String} sortOrder `desc` / `asc`
|
||||
*/
|
||||
// eslint-disable-next-line
|
||||
const handleSort = (val, orderby = "desc") => {
|
||||
if (val != null) {
|
||||
stateRef.current.sort = orderby ? {
|
||||
sort_key: `${orderby == 'desc' ? '-' + val : val}`
|
||||
} : null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 请求函数
|
||||
const fetchData = async (sub_options) => {
|
||||
const fetchData = async (sub_options?:any) => {
|
||||
stateRef.current.loading = true
|
||||
setState((e) => ({...e, loading:true}))
|
||||
stateRef.current.query = {
|
||||
@ -164,7 +138,7 @@ export const useRequest = (options = {
|
||||
...options,
|
||||
...{
|
||||
header: {
|
||||
"Platform": 3,
|
||||
"Platform": 6,
|
||||
"Authorization": token || stateRef.current.token,
|
||||
}
|
||||
},
|
||||
@ -214,7 +188,6 @@ export const useRequest = (options = {
|
||||
}
|
||||
|
||||
return {
|
||||
handleSort,
|
||||
fetchData,
|
||||
state,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user