优化滚动
This commit is contained in:
parent
f30e174e3e
commit
8112d38499
@ -29,3 +29,34 @@ export const SaleOrderApi = () => {
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改销售单备注
|
||||
*/
|
||||
export const EditSaleOrderRemarkApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/remark`,
|
||||
method: "put",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改销售单地址
|
||||
*/
|
||||
export const EditSaleOrderAddressApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/address`,
|
||||
method: "put",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改销售单收货方法
|
||||
*/
|
||||
export const EditSaleOrderShipmentModeApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/shipmentMode`,
|
||||
method: "put",
|
||||
})
|
||||
}
|
@ -5,8 +5,8 @@
|
||||
// export const BASE_URL = `http://192.168.0.89:40001/lymarket`
|
||||
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
||||
// export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境
|
||||
export const BASE_URL = `http://192.168.1.30:40001/lymarket` // 发
|
||||
// export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境
|
||||
// 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.4:40001/lymarket` // 王霞
|
||||
// export const BASE_URL = `http://192.168.1.224:50002/lymarket` // 添
|
||||
|
@ -5,7 +5,7 @@
|
||||
* @returns
|
||||
*/
|
||||
export const debounce = (fn, delay) => {
|
||||
let timer = null;
|
||||
let timer:any = null;
|
||||
return (...param) => {
|
||||
if (timer) clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
@ -90,4 +90,17 @@ export const throttle = (fn, delay) => {
|
||||
*/
|
||||
export const screenshot = (url, suffix="!w200")=>{
|
||||
return url+suffix;
|
||||
}
|
||||
|
||||
//获取数据加载状态 //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
export const dataLoadingStatus = ({list = [], total = 0, status = false}:{list:any[], total:number, status:true|false}) => {
|
||||
if(list.length == 0 && status) {
|
||||
return 0
|
||||
} else if (list.length == 0 && !status) {
|
||||
return 1
|
||||
} else if (list.length < total) {
|
||||
return 2
|
||||
} else {
|
||||
return 3
|
||||
}
|
||||
}
|
@ -4,12 +4,14 @@ import style from "./index.module.scss"
|
||||
import DotLoading from "@/components/dotLoading"
|
||||
import LoadingCard from "../loadingCard"
|
||||
|
||||
export type StatusParam = 0|1|2|3
|
||||
|
||||
type Params = {
|
||||
styleObj?: Object,
|
||||
selfonScrollToLower?: () => void,
|
||||
hasMore?: false|true,
|
||||
hasMore?: false|true,
|
||||
moreStatus?: false|true,
|
||||
statusMore?: 0|1|2, //0:没数据加载,1:下拉加载,2:没有数据
|
||||
statusMore?: StatusParam //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
children?: ReactNode,
|
||||
lowerThresholdNum?: number,
|
||||
selfOnScrollToUpper?:() => void
|
||||
@ -80,20 +82,28 @@ export default memo(({
|
||||
onRefresherAbort = {() => refresherAbort()}
|
||||
refresherBackground ='#F8F8F8'
|
||||
>
|
||||
{(statusMore != 0)&&<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
||||
{children}
|
||||
{moreStatus&&<View className={style.infinite_scroll}>
|
||||
{
|
||||
hasMore&&<View className={style.loading_more}>加载中<DotLoading/></View>||
|
||||
<View>没有更多数据了</View>
|
||||
}
|
||||
</View>}
|
||||
</View>||
|
||||
<LoadingCard/>
|
||||
}
|
||||
{!moreStatus&&<>
|
||||
<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
</>||
|
||||
<>
|
||||
{(statusMore == 2 || statusMore == 3)&&<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
||||
{children}
|
||||
<View className={style.infinite_scroll}>
|
||||
{
|
||||
(statusMore == 2)&&<View className={style.loading_more}>加载中<DotLoading/></View>||
|
||||
<View>没有更多数据了</View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
{(statusMore == 0)&&<LoadingCard/>}
|
||||
{(statusMore == 1)&&<LoadingCard loadingIcon={false} title="暂无数据"/>}
|
||||
</>}
|
||||
|
||||
<View className="common_safe_area_y"></View>
|
||||
</ScrollView>
|
||||
|
||||
</>
|
||||
)
|
||||
})
|
@ -1,13 +1,12 @@
|
||||
import { ScrollView, View } from "@tarojs/components"
|
||||
import { memo, ReactNode, useEffect, useRef, useState } from "react"
|
||||
import React, { 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";
|
||||
import InfiniteScroll, {StatusParam} from "../infiniteScroll";
|
||||
import LoadingCard from "../loadingCard";
|
||||
|
||||
|
||||
|
||||
type Params = {
|
||||
list?: any[],
|
||||
defaultValue?: number|string,
|
||||
@ -18,7 +17,8 @@ type Params = {
|
||||
refresherTriggered?: true|false,
|
||||
selfOnRefresherRefresh?: () => void
|
||||
selfOnScrolltolower?: () => void,
|
||||
hasMore?: true|false
|
||||
hasMore?: true|false,
|
||||
statusMore?: StatusParam
|
||||
}
|
||||
|
||||
export default memo(({list = [],
|
||||
@ -30,7 +30,8 @@ export default memo(({list = [],
|
||||
refresherTriggered = false,
|
||||
selfOnRefresherRefresh,
|
||||
selfOnScrolltolower,
|
||||
hasMore = true
|
||||
hasMore = true,
|
||||
statusMore = 0
|
||||
}: Params) => {
|
||||
|
||||
let num_half = useRef(0)
|
||||
@ -82,8 +83,6 @@ export default memo(({list = [],
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={classnames(styles.sideBar_main,'side_bar_select')}>
|
||||
@ -108,8 +107,7 @@ export default memo(({list = [],
|
||||
<View className="common_safe_area_y"></View>
|
||||
</ScrollView>
|
||||
<View className={styles.sideBar_con}>
|
||||
|
||||
<InfiniteScroll hasMore={hasMore} selfonScrollToLower={() => selfOnScrolltolower?.()} refresherTriggered={refresherTriggered} refresherEnabled={true} selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
|
||||
<InfiniteScroll statusMore={statusMore} hasMore={hasMore} selfonScrollToLower={() => selfOnScrolltolower?.()} refresherTriggered={refresherTriggered} refresherEnabled={true} selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
|
||||
{children}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
@ -4,13 +4,13 @@ import Search from '@/components/search'
|
||||
import Product from '@/components/product'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import styles from './index.module.scss'
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Filter from "@/components/filter";
|
||||
import SortBtn from "@/components/sortBtn";
|
||||
import SelectData, {ListProps} from "../searchList/components/selectData";
|
||||
import {GetProductListApi} from '@/api/material'
|
||||
import { useRouter } from "@tarojs/taro";
|
||||
import { getFilterData } from "@/common/util";
|
||||
import { dataLoadingStatus, getFilterData } from "@/common/util";
|
||||
import LoadingCard from "@/components/loadingCard";
|
||||
|
||||
export default () => {
|
||||
@ -56,9 +56,9 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
//监听获得的数据变化
|
||||
useEffect(() => {
|
||||
(categoryList.list.length < categoryList.total)?setHasMore(true):setHasMore(false)
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({list:categoryList.list, total: categoryList.total, status: state.loading})
|
||||
}, [categoryList])
|
||||
|
||||
//获取筛选条件
|
||||
@ -118,11 +118,9 @@ export default () => {
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.list}>
|
||||
{(categoryList.list.length == 0&&state.loading)&&<LoadingCard/>}
|
||||
{(categoryList.list.length == 0 && !state.loading)&&<LoadingCard title="暂无数据" loadingIcon={false}/>}
|
||||
{(categoryList.list.length > 0)&&<InfiniteScroll selfonScrollToLower={() => getScrolltolower()} hasMore={hasMore}>
|
||||
<InfiniteScroll selfonScrollToLower={() => getScrolltolower()} statusMore={statusMore}>
|
||||
<Product desStatus={false} productList={categoryList.list}/>
|
||||
</InfiniteScroll>}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<Filter show={showPopup} onClose={() => setShowPopup(false)} onFiltr={getFiltr}/>
|
||||
</View>
|
||||
|
@ -1,18 +1,22 @@
|
||||
import { Text, View } from "@tarojs/components"
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { memo, useRef, useState } from "react";
|
||||
import { memo, useEffect, useRef, useState } from "react";
|
||||
|
||||
type Param = {
|
||||
onSelect?:(val:number) => void
|
||||
defaultValue?: 0|1|2
|
||||
}
|
||||
export default memo(({onSelect}: Param) => {
|
||||
//收货方法 1:自提,2:物流
|
||||
export default memo(({onSelect, defaultValue = 0}: Param) => {
|
||||
//收货方法 0:没选择, 1:自提,2:物流
|
||||
const shipmentMode = useRef([
|
||||
{value:1, label:'上门自提', selected:false},
|
||||
{value:2, label:'物流', selected:false}
|
||||
])
|
||||
const [selectValue, setSelectValue] = useState()
|
||||
const [selectValue, setSelectValue] = useState<number>()
|
||||
useEffect(() => {
|
||||
setSelectValue(defaultValue)
|
||||
}, [defaultValue])
|
||||
const selectShipmentMode = (value) => {
|
||||
setSelectValue(() => value)
|
||||
onSelect?.(value)
|
||||
|
@ -1,21 +1,62 @@
|
||||
import { Text, View } from "@tarojs/components"
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { useCallback, useMemo, useRef, useState } from "react";
|
||||
import ShipmentMode from "./components/shipmentMode";
|
||||
import AddressList from "@/components/AddressList";
|
||||
import { goLink } from "@/common/common";
|
||||
import { alert, goLink } from "@/common/common";
|
||||
import { getParam } from "@/common/system";
|
||||
import {EditSaleOrderAddressApi, EditSaleOrderShipmentModeApi} from "@/api/order";
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
export default () => {
|
||||
|
||||
//获取临时传递的数据
|
||||
const params = getParam()
|
||||
const [paramsData, setParamsData] = useState<any>(params)
|
||||
|
||||
//提交的数据
|
||||
const [submitData, setSubmitData] = useState({
|
||||
address_id:0,
|
||||
id:0,
|
||||
shipment_mode: 0
|
||||
id:params.id,
|
||||
shipment_mode: params.shipment_mode
|
||||
})
|
||||
|
||||
|
||||
//格式化地址
|
||||
const address = useMemo(() => {
|
||||
return paramsData.province_name+' '+paramsData.city_name+' '+paramsData.district_name+' '+paramsData.address_detail
|
||||
}, [paramsData])
|
||||
|
||||
//获取收货方法
|
||||
const getShipmentMode = useCallback((num) => {
|
||||
setSubmitData((val) => ({...val, shipment_mode:num}))
|
||||
}, [])
|
||||
|
||||
//获取地址
|
||||
const getSelectAddress = useCallback((e) => {
|
||||
setSubmitData((val) => ({...val, address_id:e.id}))
|
||||
}, [])
|
||||
|
||||
//修改请求
|
||||
const {fetchData: addressFetchData} = EditSaleOrderAddressApi()
|
||||
const {fetchData: shipmentFetchData} = EditSaleOrderShipmentModeApi()
|
||||
const editData = async () => {
|
||||
if(submitData.address_id) {
|
||||
let res = await addressFetchData(submitData)
|
||||
if(!res.success) {
|
||||
alert.error(res.msg)
|
||||
return false
|
||||
}
|
||||
}
|
||||
let res = await shipmentFetchData(submitData)
|
||||
if(!res.success) {
|
||||
alert.error(res.msg)
|
||||
return false
|
||||
}
|
||||
Taro.navigateBack()
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.order_edit_main}>
|
||||
<View className={classnames(styles.title_msg)}>
|
||||
@ -26,24 +67,24 @@ export default () => {
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.shipmentMode_con}>
|
||||
<ShipmentMode onSelect={getShipmentMode}/>
|
||||
<ShipmentMode onSelect={getShipmentMode} defaultValue={paramsData.shipment_mode}/>
|
||||
</View>
|
||||
<View className={styles.old_address}>
|
||||
<Text className={styles.old_address_text}>原地址:</Text>
|
||||
<Text className={styles.old_address_text}>广东省 佛山市 禅城区 张槎街道 清风路1988号麦兜的大 大仓库</Text>
|
||||
<Text className={styles.old_address_text}>{address}</Text>
|
||||
<View className={styles.userInfo}>
|
||||
<Text className={styles.userInfo_text}>陈先生</Text>
|
||||
<Text className={styles.userInfo_text}>1818877790</Text>
|
||||
<Text className={styles.userInfo_text}>{paramsData.name}</Text>
|
||||
<Text className={styles.userInfo_text}>{paramsData.phone}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.select_address_con}>
|
||||
<View className={styles.title}>重新选择收货地址</View>
|
||||
<View className={styles.address_list}>
|
||||
<AddressList focusBorderEnabled={true} addButtonEnabled={false}/>
|
||||
<AddressList focusBorderEnabled={true} addButtonEnabled={false} onSelect={getSelectAddress}/>
|
||||
</View>
|
||||
<View className={styles.submitBtn}>
|
||||
<View onClick={() => goLink('/pages/addressAdd/index', {type:'add'})} className={classnames(styles.addAddress, styles.addressBtn)}>添加新地址</View>
|
||||
<View className={classnames(styles.submitUpdate, styles.addressBtn)}>提交修改</View>
|
||||
<View className={classnames(styles.submitUpdate, styles.addressBtn)} onClick={() => editData()}>提交修改</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
|
3
src/pages/index/context.ts
Normal file
3
src/pages/index/context.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import React from "react";
|
||||
|
||||
export const ParamsContext = React.createContext<any>(null)
|
@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '修改地址',
|
||||
navigationBarTitleText: '首页',
|
||||
}
|
||||
|
@ -7,11 +7,12 @@ import MoveBtn from '@/components/moveBtn'
|
||||
import ShopCart from '@/components/shopCart'
|
||||
import { goLink } from '@/common/common'
|
||||
import styles from './index.module.scss'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Taro, { Events, useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import {GetProductKindListApi, GetProductListApi} from '@/api/material'
|
||||
import useLogin from '@/use/useLogin'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
import { dataLoadingStatus } from '@/common/util'
|
||||
|
||||
export default () => {
|
||||
|
||||
@ -54,6 +55,7 @@ export default () => {
|
||||
getProductList()
|
||||
}, [filtrate])
|
||||
|
||||
|
||||
//点击面料类型
|
||||
const getProductKindId = async (e) => {
|
||||
pageNum.current.page = 1
|
||||
@ -90,6 +92,11 @@ export default () => {
|
||||
usePullDownRefresh(() => {
|
||||
console.log('123')
|
||||
})
|
||||
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({list:productData.list, total: productData.total, status: productState.loading})
|
||||
}, [productData])
|
||||
|
||||
return (
|
||||
<MoveBtn onClick={() => setShowShopCart(!showShopCart)}>
|
||||
@ -102,9 +109,9 @@ export default () => {
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.products}>
|
||||
<SideBar list={kindData.list} height="100%" defaultValue={kindData.defaultId} hasMore={hasMore} selfOnScrolltolower={() => getScrolltolower()} sideBarOnClick={(e) => getProductKindId(e)} heightItem={150} refresherTriggered={refresherTriggeredStatus} selfOnRefresherRefresh={() => getRefresherRefresh()}>
|
||||
<Product productList={productData.list}/>
|
||||
</SideBar>
|
||||
<SideBar list={kindData.list} height="100%" defaultValue={kindData.defaultId} hasMore={hasMore} statusMore={statusMore} 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>
|
||||
<ShopCart show={showShopCart} onClose={() => setShowShopCart(false)}/>
|
||||
@ -112,3 +119,4 @@ export default () => {
|
||||
</MoveBtn>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ export type AddressInfoParam = {
|
||||
city_name: string,
|
||||
district_name: string,
|
||||
address_detail: string,
|
||||
id: number,
|
||||
id?: number,
|
||||
name: string,
|
||||
phone: string
|
||||
}
|
||||
|
@ -5,9 +5,11 @@ import classnames from "classnames";
|
||||
import styles from './index.module.scss'
|
||||
type Param = {
|
||||
style?: Object,
|
||||
number?: number
|
||||
number?: number,
|
||||
title?: string,
|
||||
status?: true|false, //true 加大加深
|
||||
}
|
||||
export default memo(({style, number = 0}:Param) => {
|
||||
export default memo(({style, number = 0, status = true, title = ''}:Param) => {
|
||||
const priceDom = useCallback(() => {
|
||||
let res = number.toFixed(2).split('.')
|
||||
let int_num = parseInt(res[0]) + ''
|
||||
@ -21,40 +23,16 @@ export default memo(({style, number = 0}:Param) => {
|
||||
)
|
||||
}, [number])
|
||||
return (
|
||||
<>
|
||||
<>
|
||||
<View className={styles.order_price}>
|
||||
<View className={styles.order_price_text}>
|
||||
<Text>合计金额</Text>
|
||||
<View className={classnames(styles.order_price_text, status&&styles.emphasis)}>
|
||||
<Text>{title}</Text>
|
||||
<View className={styles.iconfont_msg}>
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
||||
{/* <View className={classnames(styles.message)}>123123123121212312312312312</View> */}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.order_price_num} style={style}>
|
||||
{priceDom()}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.order_price}>
|
||||
<View className={styles.order_price_text}>
|
||||
<Text>空差优惠</Text>
|
||||
<View className={styles.iconfont_msg}>
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
||||
{/* <View className={classnames(styles.message)}>123123123121212312312312312</View> */}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.order_price_num} style={style}>
|
||||
{priceDom()}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.order_price}>
|
||||
<View className={classnames(styles.order_price_text, styles.emphasis)}>
|
||||
<Text>应付金额</Text>
|
||||
<View className={styles.iconfont_msg}>
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
||||
{/* <View className={classnames(styles.message)}>123123123121212312312312312</View> */}
|
||||
</View>
|
||||
</View>
|
||||
<View className={classnames(styles.order_price_num, styles.emphasis_num)} style={style}>
|
||||
<View className={classnames(styles.order_price_num, status&&styles.emphasis_num)} style={style}>
|
||||
{priceDom()}
|
||||
</View>
|
||||
</View>
|
||||
|
@ -64,7 +64,7 @@ export default memo(({value}:{value:OrderParam|null}) => {
|
||||
})
|
||||
}
|
||||
<View className={styles.order_estimated_amount}>
|
||||
<EstimatedAmount number={formatPriceDiv(value?.estimate_amount)}/>
|
||||
<EstimatedAmount number={formatPriceDiv(value?.estimate_amount)} title="预估金额" />
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
|
@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '确认订单'
|
||||
navigationBarTitleText: '订单详情'
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { GetSaleOrderDetailApi } from "@/api/order";
|
||||
import { goLink } from "@/common/common";
|
||||
import { GetSaleOrderDetailApi, EditSaleOrderRemarkApi } from "@/api/order";
|
||||
import { alert, goLink } from "@/common/common";
|
||||
import { formatDateTime, formatPriceDiv } from "@/common/fotmat";
|
||||
import { setParam } from "@/common/system";
|
||||
import Popup from "@/components/popup";
|
||||
import SearchInput from "@/components/searchInput";
|
||||
import { Text, Textarea, View } from "@tarojs/components"
|
||||
import Taro, { useRouter } from "@tarojs/taro";
|
||||
import Taro, { useDidShow, useRouter } from "@tarojs/taro";
|
||||
import classnames from "classnames";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import AddressInfo from "./components/addressInfo";
|
||||
@ -18,17 +19,20 @@ import styles from './index.module.scss'
|
||||
const [showDesc, setShowDesc] = useState(false)
|
||||
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
const orderId = useRef<number>(Number(router.params.id))
|
||||
|
||||
useDidShow(() => {
|
||||
getSaleOrderPreView()
|
||||
}, [])
|
||||
})
|
||||
|
||||
//获取订单详情
|
||||
const [orderDetail, setOrderDetail] = useState<any>() //获取到的原始数据
|
||||
const {fetchData: getOrderFetchData} = GetSaleOrderDetailApi()
|
||||
const getSaleOrderPreView = async () => {
|
||||
if(router.params.id) {
|
||||
let res = await getOrderFetchData({id: router.params.id})
|
||||
if(orderId.current) {
|
||||
let res = await getOrderFetchData({id: orderId.current})
|
||||
setOrderDetail(res.data)
|
||||
setOrderRemark(res.data.remark)
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,32 +93,48 @@ import styles from './index.module.scss'
|
||||
|
||||
//格式化初始地址
|
||||
const defaultAddress = useMemo(() => {
|
||||
const address = orderDetail?.default_address
|
||||
if(address) {
|
||||
return {
|
||||
province_name: address.province_name,
|
||||
city_name: address.city_name,
|
||||
district_name: address.district_name,
|
||||
address_detail: address.address_detail,
|
||||
id: address.id,
|
||||
name: address.name,
|
||||
phone: address.phone
|
||||
}
|
||||
return {
|
||||
province_name: orderDetail?.province_name,
|
||||
city_name: orderDetail?.city_name,
|
||||
district_name: orderDetail?.district_name,
|
||||
address_detail: orderDetail?.address_detail,
|
||||
// id: address.id,
|
||||
name: orderDetail?.target_user_name,
|
||||
phone: orderDetail?.target_user_phone
|
||||
}
|
||||
return null
|
||||
|
||||
}, [orderDetail])
|
||||
|
||||
//订单备注
|
||||
const {fetchData: remarkFetchData} = EditSaleOrderRemarkApi()
|
||||
const [orderRemark, setOrderRemark] = useState('')
|
||||
const getRemark = useCallback((e) => {
|
||||
const getRemark = useCallback(async (e) => {
|
||||
setOrderRemark(() => e)
|
||||
let res = await remarkFetchData({remark:e, id: orderId.current})
|
||||
if(res.success) {
|
||||
alert.success('修改成功')
|
||||
} else {
|
||||
alert.error(res.msg)
|
||||
}
|
||||
setShowDesc(() => false)
|
||||
}, [])
|
||||
|
||||
//修改地址
|
||||
const changeAddress = useCallback(() => {
|
||||
goLink('/pages/editOrder/index', {id: router.params.id})
|
||||
}, [router.params])
|
||||
const changeAddress = () => {
|
||||
//临时传递数据
|
||||
setParam({
|
||||
province_name: orderDetail?.province_name,
|
||||
city_name: orderDetail?.city_name,
|
||||
district_name: orderDetail?.district_name,
|
||||
address_detail: orderDetail?.address_detail,
|
||||
id: orderId.current,
|
||||
name: orderDetail?.target_user_name,
|
||||
phone: orderDetail?.target_user_phone,
|
||||
shipment_mode: orderDetail?.shipment_mode,
|
||||
}
|
||||
)
|
||||
goLink('/pages/editOrder/index')
|
||||
}
|
||||
return (
|
||||
<View className={styles.order_main}>
|
||||
<View className={styles.weight_memo_con}>
|
||||
|
@ -58,7 +58,6 @@ export default () => {
|
||||
return <View className={styles.order_item}> <Order/></View>
|
||||
|
||||
})}
|
||||
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
</View>
|
||||
|
@ -8,10 +8,10 @@ import LinkBlueTooth from "@/components/bluetooth/LinkBlueTooth";
|
||||
import {useBluetooth} from "@/use/contextBlueTooth"
|
||||
import {toRgb} from '@/common/bluetooth/color/colorSpace'
|
||||
import styles from './hightSearchList.module.scss'
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Taro, { useDidShow, usePullDownRefresh, useReady } from "@tarojs/taro";
|
||||
import {GetLabProductApi} from "@/api/material"
|
||||
import { getFilterData } from "@/common/util";
|
||||
import { dataLoadingStatus, getFilterData } from "@/common/util";
|
||||
import { formatHashTag, formatImgUrl } from "@/common/fotmat";
|
||||
import LoadingCard from "@/components/loadingCard";
|
||||
import useLogin from "@/use/useLogin";
|
||||
@ -64,11 +64,11 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
//监听获得的数据变化
|
||||
useEffect(() => {
|
||||
(materialList.list.length < materialList.total)?setHasMore(true):setHasMore(false)
|
||||
}, [materialList])
|
||||
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({list:materialList.list, total: materialList.total, status: materialState.loading})
|
||||
}, [materialList])
|
||||
|
||||
const [scrollStatus, setScrollStatus] = useState(false)
|
||||
const onscroll = useCallback((e) => {
|
||||
@ -176,12 +176,11 @@ export default () => {
|
||||
<View className={styles.list}>
|
||||
<View className={classnames(styles.list_num, scrollStatus&&styles.list_num_shadow)}>搜索结果 ({materialList.total}条记录)</View>
|
||||
<View className={styles.scroll}>
|
||||
{(materialList.list.length == 0&&materialState.loading)&&<LoadingCard/>}
|
||||
{(materialList.list.length == 0 && !materialState.loading)&&<LoadingCard title="暂无数据" loadingIcon={false}/>}
|
||||
{(materialList.list.length > 0)&&<InfiniteScroll
|
||||
|
||||
<InfiniteScroll
|
||||
selfonScrollToLower={() => getScrolltolower()}
|
||||
selfOnScroll={(e) => onscroll(e)}
|
||||
hasMore={hasMore}
|
||||
statusMore={statusMore}
|
||||
>
|
||||
<View className={styles.product_list}>
|
||||
{materialList.list.map(item => {
|
||||
@ -197,7 +196,7 @@ export default () => {
|
||||
</View>
|
||||
})}
|
||||
</View>
|
||||
</InfiniteScroll>}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
</View>
|
||||
<Filter show={showFilter} onFiltr={(e) => getFiltr(e)} onClose={() => setShowFilter(false)}/>
|
||||
|
@ -7,12 +7,12 @@ import SortBtn from "@/components/sortBtn";
|
||||
import SelectData, {ListProps} from "./components/selectData";
|
||||
import { goLink } from "@/common/common";
|
||||
import styles from './searchList.module.scss'
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import useManualPullDownRefresh from "@/use/useManualPullDownRefresh";
|
||||
import {GetProductListApi} from "@/api/material"
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro";
|
||||
import { formatHashTag, formatImgUrl } from "@/common/fotmat";
|
||||
import { getFilterData } from "@/common/util";
|
||||
import { dataLoadingStatus, getFilterData } from "@/common/util";
|
||||
import LoadingCard from "@/components/loadingCard";
|
||||
import useLogin from "@/use/useLogin";
|
||||
|
||||
@ -53,7 +53,6 @@ export default () => {
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({size: searchField.size, page: searchField.page})
|
||||
const [hasMore, setHasMore] = useState(true)
|
||||
const getScrolltolower = () => {
|
||||
if(materialList.list.length < materialList.total) {
|
||||
pageNum.current.page++
|
||||
@ -62,9 +61,9 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
//监听获得的数据变化
|
||||
useEffect(() => {
|
||||
(materialList.list.length < materialList.total)?setHasMore(true):setHasMore(false)
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({list:materialList.list, total: materialList.total, status: materialState.loading})
|
||||
}, [materialList])
|
||||
|
||||
//输入了搜索关键字
|
||||
@ -156,12 +155,10 @@ export default () => {
|
||||
<View className={styles.list}>
|
||||
<View className={classnames(styles.list_num, scrollStatus&&styles.list_num_shadow)}>搜索结果 ({materialList.total}条记录)</View>
|
||||
<View className={styles.scroll}>
|
||||
{(materialList.list.length == 0&&materialState.loading)&&<LoadingCard/>}
|
||||
{(materialList.list.length == 0 && !materialState.loading)&&<LoadingCard title="暂无数据" loadingIcon={false}/>}
|
||||
{(materialList.list.length > 0)&&<InfiniteScroll
|
||||
<InfiniteScroll
|
||||
selfonScrollToLower={() => getScrolltolower()}
|
||||
hasMore={hasMore}
|
||||
selfOnScroll={(e) => onscroll(e)}
|
||||
statusMore={statusMore}
|
||||
>
|
||||
<View className={styles.product_list}>
|
||||
{materialList.list.map(item => {
|
||||
@ -181,7 +178,7 @@ export default () => {
|
||||
</View>
|
||||
})}
|
||||
</View>
|
||||
</InfiniteScroll>}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
</View>
|
||||
<Filter show={showFilter} onClose={() => setShowFilter(false)} onFiltr={(e) => getFiltr(e)} />
|
||||
|
@ -4,13 +4,13 @@ import Search from '@/components/search'
|
||||
import Product from '@/components/product'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import styles from './index.module.scss'
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Filter from "@/components/filter";
|
||||
import SortBtn from "@/components/sortBtn";
|
||||
import SelectData, {ListProps} from "../searchList/components/selectData";
|
||||
import {GetProductListApi} from '@/api/material'
|
||||
import { useRouter } from "@tarojs/taro";
|
||||
import { getFilterData } from "@/common/util";
|
||||
import { dataLoadingStatus, getFilterData } from "@/common/util";
|
||||
import LoadingCard from "@/components/loadingCard";
|
||||
|
||||
export default () => {
|
||||
@ -56,9 +56,9 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
//监听获得的数据变化
|
||||
useEffect(() => {
|
||||
(subjectList.list.length < subjectList.total)?setHasMore(true):setHasMore(false)
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({list:subjectList.list, total: subjectList.total, status: state.loading})
|
||||
}, [subjectList])
|
||||
|
||||
//获取筛选条件
|
||||
@ -118,11 +118,9 @@ export default () => {
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.list}>
|
||||
{(subjectList.list.length == 0&&state.loading)&&<LoadingCard/>}
|
||||
{(subjectList.list.length == 0 && !state.loading)&&<LoadingCard title="暂无数据" loadingIcon={false}/>}
|
||||
{(subjectList.list.length > 0)&&<InfiniteScroll selfonScrollToLower={() => getScrolltolower()} hasMore={hasMore}>
|
||||
<InfiniteScroll selfonScrollToLower={() => getScrolltolower()} statusMore={statusMore}>
|
||||
<Product desStatus={false} productList={subjectList.list}/>
|
||||
</InfiniteScroll>}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<Filter show={showPopup} onClose={() => setShowPopup(false)} onFiltr={getFiltr}/>
|
||||
</View>
|
||||
|
@ -107,7 +107,7 @@ export const useRequest = (options:option = {
|
||||
success: false, // 请求是否成功
|
||||
data: {},
|
||||
msg: '',
|
||||
loading: false,
|
||||
loading: true,
|
||||
error: null,
|
||||
query: {},
|
||||
filter: null,
|
||||
@ -170,7 +170,6 @@ export const useRequest = (options:option = {
|
||||
if (statusCode === 401) {
|
||||
removeToken()
|
||||
removeSessionKey()
|
||||
// remove
|
||||
// Taro.reLaunch({
|
||||
// url: router.path +'?' + qs.stringify(router.params)
|
||||
// })
|
||||
|
Loading…
x
Reference in New Issue
Block a user