From b93b59332b18f98abd7b7726641cb230ef6e6a07 Mon Sep 17 00:00:00 2001 From: czm <2192718639@qq.com> Date: Fri, 27 May 2022 20:34:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/order.ts | 4 +- src/api/orderPay.ts | 21 ++++++ src/common/common.ts | 15 ++-- src/common/constant.js | 4 +- .../infiniteScroll/index.module.scss | 3 + src/components/infiniteScroll/index.tsx | 2 +- src/components/orderBtns/index.tsx | 35 ++++++--- src/pages/order/comfirm.tsx | 15 +++- .../components/addressInfoDetail/index.tsx | 8 +- .../components/amountShow/index.module.scss | 2 +- .../components/estimatedAmount/index.tsx | 9 ++- src/pages/order/components/kindList/index.tsx | 25 ++++++- .../components/orderState/index.module.scss | 3 + .../order/components/orderState/index.tsx | 17 +++-- src/pages/order/components/payment/index.tsx | 75 ++++++++++++++++--- src/pages/order/index.config.ts | 4 +- src/pages/order/index.tsx | 36 +++++++-- .../orderList/components/order/index.tsx | 51 +++---------- src/pages/orderList/index.tsx | 18 ++++- 19 files changed, 236 insertions(+), 111 deletions(-) create mode 100644 src/api/orderPay.ts diff --git a/src/api/order.ts b/src/api/order.ts index 45eb243..f723f47 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -21,11 +21,11 @@ export const SaleOrderApi = () => { } /** - * 获取商城待配布订单详情 + * 获取商城订单详情 */ export const GetSaleOrderDetailApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/arranging`, + url: `/v1/mall/saleOrder/detail`, method: "get", }) } diff --git a/src/api/orderPay.ts b/src/api/orderPay.ts new file mode 100644 index 0000000..99ba9d9 --- /dev/null +++ b/src/api/orderPay.ts @@ -0,0 +1,21 @@ +import { useRequest } from "@/use/useHttp" + +/** + * 获取订单支付方式信息 + */ + export const GetOrderPayApi = () => { + return useRequest({ + url: `/v1/mall/orderPayment/orderPaymentMethodInfo`, + method: "get", + }) +} + +/** + * 订单支付提交 + */ + export const SubmitOrderPayApi = () => { + return useRequest({ + url: `/v1/mall/orderPayment/orderPaymentSubmission`, + method: "put", + }) +} \ No newline at end of file diff --git a/src/common/common.ts b/src/common/common.ts index 080373b..0c814aa 100644 --- a/src/common/common.ts +++ b/src/common/common.ts @@ -7,20 +7,15 @@ import Qs from 'qs' * @param params * @param type false 跳转普通页面,true 跳转tabbar页面 */ -export const goLink = (path = '', params = {}, type:false|true = false) => { +type ParamLink = 'navigateTo'|'switchTab'|'reLaunch'|'redirectTo' +export const goLink = (path = '', params = {}, way: ParamLink = 'navigateTo') => { if(path) { let params_str = Qs.stringify(params) console.log('params_str::',params_str) path = params_str?path+'?'+params_str:path - if(!type) { - Taro.navigateTo({ - url: path - }) - } else { - Taro.switchTab({ - url: path - }) - } + console.log('path::', way) + Taro[way]({url: path}) + } } diff --git a/src/common/constant.js b/src/common/constant.js index f62112f..861155e 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -8,9 +8,9 @@ // 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.4:40001/lymarket` // 王霞 // export const BASE_URL = `http://192.168.1.224:50002/lymarket` // 添 -export const BASE_URL = `http://192.168.1.15:50001/lymarket` // 杰 +// export const BASE_URL = `http://192.168.1.15:50001/lymarket` // 杰 // CDN // 生成密钥 diff --git a/src/components/infiniteScroll/index.module.scss b/src/components/infiniteScroll/index.module.scss index c92bd1f..aab1d77 100644 --- a/src/components/infiniteScroll/index.module.scss +++ b/src/components/infiniteScroll/index.module.scss @@ -11,6 +11,9 @@ display: flex; align-items: center; } + .noMore{ + padding-top: 20px; + } } .scrollViewCon { // height: 100%; diff --git a/src/components/infiniteScroll/index.tsx b/src/components/infiniteScroll/index.tsx index 26ab828..cb22671 100644 --- a/src/components/infiniteScroll/index.tsx +++ b/src/components/infiniteScroll/index.tsx @@ -93,7 +93,7 @@ export default memo(({ { (statusMore == 2)&&加载中|| - 没有更多数据了 + 没有更多数据了 } diff --git a/src/components/orderBtns/index.tsx b/src/components/orderBtns/index.tsx index 53e33a1..3cc4690 100644 --- a/src/components/orderBtns/index.tsx +++ b/src/components/orderBtns/index.tsx @@ -6,38 +6,46 @@ import { useCallback, useRef, memo } from "react" import styles from './index.module.scss' type Param = { - status?: number //订单状态 - orderId?: number //订单id + status?: number, //订单状态 + orderId: number, //订单id + onClick?: (val: number) => void //点击后触发的事件,返回订单状态 } -export default memo(({status = 0, orderId = 0}:Param) => { +export default memo(({status = 0, orderId = 0, onClick}:Param) => { //订单按钮按订单状态归类 const orderBtnsList = useRef([ { - value: [0, 1, 2, 9, 3], //取消订单按钮对应: 待接单,待配布,已配布, 待付款, 待发货 + id: 1, + value: [0, 1, 2, 3, 4], //取消订单按钮对应: 待接单,待配布,已配布, 待付款, 待发货 label: '取消订单' }, { - value: [3, 9], //去付款按钮对应:待付款, 待发货 + id: 2, + value: [3, 4], //去付款按钮对应:待付款, 待发货 label: '去付款' }, { - value: [3], //取消订单按钮对应: 待发货 + id: 3, + value: [4], //取消订单按钮对应: 待发货 label: '申请退款' }, { - value: [4, 7, 8, 6], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款 + id: 4, + value: [5, 6, 7, 8], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款 label: '查看物流' }, { - value: [4, 7, 6], //取消订单按钮对应: 待收货, 已收货, 已退款 + id: 5, + value: [5, 6, 8], //取消订单按钮对应: 待收货, 已收货, 已退款 label: '申请退货' }, { - value: [4], //取消订单按钮对应: 待收货 + id: 6, + value: [5], //取消订单按钮对应: 待收货 label: '确认收货' }, { - value: [4,7,8,6], //取消订单按钮对应: 待收货,已收货,已完成, 已退款 + id: 7, + value: [5,6,7,8], //取消订单按钮对应: 待收货,已收货,已完成, 已退款 label: '再次购买' } ]) @@ -47,7 +55,9 @@ export default memo(({status = 0, orderId = 0}:Param) => { //点击按钮操作 const submitBtns = (val) => { - if( val == 0 ) cancelOrder() + (val == 1)&&cancelOrder(); //取消订单按钮 + (val == 2)&&onClick?.(val); //去付款按钮 + } //取消订单 @@ -60,6 +70,7 @@ export default memo(({status = 0, orderId = 0}:Param) => { let res = await cancelFetchData({id: orderId}) if(res.success) { alert.success('取消成功') + onClick?.(1) } else { alert.none(res.msg) } @@ -73,7 +84,7 @@ export default memo(({status = 0, orderId = 0}:Param) => { return ( {orderBtnsList.current.map((item, index) => - orderBtnsShow(item, status)&& submitBtns(index)}>{item.label} + orderBtnsShow(item, status)&& submitBtns(item.id)}>{item.label} )} ) diff --git a/src/pages/order/comfirm.tsx b/src/pages/order/comfirm.tsx index 87a0048..3dd3e12 100644 --- a/src/pages/order/comfirm.tsx +++ b/src/pages/order/comfirm.tsx @@ -56,6 +56,7 @@ import SubmitOrderBtn from "./components/submitOrderBtn"; useEffect(() => { if(preViewOrder) { formatData() + getDataList() //当有默认地址时设置默认地址id preViewOrder.default_address&&setSubmitOrderData((val) => ({...val, address_id:preViewOrder.default_address.id})) } @@ -76,7 +77,6 @@ import SubmitOrderBtn from "./components/submitOrderBtn"; }) } const formatPreViewOrderMemo = useMemo(() => { - console.log('formatPreViewOrder::',formatPreViewOrder) return formatPreViewOrder }, [formatPreViewOrder]) @@ -97,6 +97,17 @@ import SubmitOrderBtn from "./components/submitOrderBtn"; return null }, [preViewOrder]) + //获取提交格式数据列表 + const getDataList = () => { + let list:{shopping_cart_product_color_id:number}[] = [] + preViewOrder.product_list?.map(item => { + item.product_colors?.map(colorItem => { + list.push({shopping_cart_product_color_id:colorItem.id}) + }) + }) + setSubmitOrderData((val) => ({...val, list})) + } + //获取地址 const getAddress = (e) => { setSubmitOrderData((val) => ({...val, address_id:e.id})) @@ -138,7 +149,7 @@ import SubmitOrderBtn from "./components/submitOrderBtn"; if (res.confirm) { const res = await saleOrderFetchData(submitOrderData) if(res.success) { - goLink('/pages/order/index',{id: res.data.id}) + goLink('/pages/order/index',{id: res.data.id}, 'redirectTo') } else { alert.none(res.msg) } diff --git a/src/pages/order/components/addressInfoDetail/index.tsx b/src/pages/order/components/addressInfoDetail/index.tsx index fe9b337..7290ae6 100644 --- a/src/pages/order/components/addressInfoDetail/index.tsx +++ b/src/pages/order/components/addressInfoDetail/index.tsx @@ -66,7 +66,7 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, defaultValue = alert.loading('正在修改') const res = await shipmentModeFetchData({id: orderId, shipment_mode:value}) if(res.success) { - alert.success('修改成功') + alert.success('收货方式修改成功') onChangeShipmentMode?.(value) setReceivingStatus(value) } else { @@ -78,12 +78,12 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, defaultValue = const {fetchData: addressFetchData} = EditSaleOrderAddressApi() const getAddress = async (value) => { alert.loading('正在修改') - setShowAddressList(() => false) - setUserInfo(() => value) const res = await addressFetchData({id: orderId, address_id: value.id}) if(res.success) { - alert.success('修改成功') + alert.success('地址修改成功') onSelect?.(value) + setShowAddressList(() => false) + setUserInfo(() => value) } else { alert.none(res.msg) } diff --git a/src/pages/order/components/amountShow/index.module.scss b/src/pages/order/components/amountShow/index.module.scss index 58368a8..647e203 100644 --- a/src/pages/order/components/amountShow/index.module.scss +++ b/src/pages/order/components/amountShow/index.module.scss @@ -6,7 +6,7 @@ font-size: $font_size_min; } &:nth-child(2) { - font-size: 26px; + font-size: $font_size; } &:nth-child(3) { font-size: $font_size_medium; diff --git a/src/pages/order/components/estimatedAmount/index.tsx b/src/pages/order/components/estimatedAmount/index.tsx index 0292f6b..04bc49a 100644 --- a/src/pages/order/components/estimatedAmount/index.tsx +++ b/src/pages/order/components/estimatedAmount/index.tsx @@ -8,20 +8,21 @@ type Param = { style?: Object, number?: number, title?: string, - status?: true|false, //true 加大加深 + titleStatus?: true|false, //true 标题加大加深 + numberStatus?: 0|1|2, //数字尺寸 } -export default memo(({style, number = 0, status = true, title = ''}:Param) => { +export default memo(({style, number = 0, titleStatus = true, title = '', numberStatus = 1}:Param) => { return ( <> - + {title} {/* 123123123121212312312312312 */} - + ) diff --git a/src/pages/order/components/kindList/index.tsx b/src/pages/order/components/kindList/index.tsx index db30c54..e6ea05a 100644 --- a/src/pages/order/components/kindList/index.tsx +++ b/src/pages/order/components/kindList/index.tsx @@ -5,17 +5,22 @@ import EstimatedAmount from "../estimatedAmount" import styles from './index.module.scss' type OrderParam = { - estimate_amount: number, + estimate_amount: number, //预估金额 list: any[], sale_mode: number, sale_mode_name: string, unit: string, total_colors: number, total_fabrics: number, - total_number: number + total_number: number, + status: number, //订单状态 + total_sale_price: number, //销售金额 + total_should_collect_money: number, //应收金额 + total_weight_error_discount: number, //空差优惠 + } -export default memo(({value}:{value:OrderParam|null}) => { +export default memo(({value}:{value?:OrderParam}) => { //对应数量 const formatCount = useCallback((item) => { return value?.sale_mode == 0? item.roll : Number(item.length / 100) @@ -30,6 +35,18 @@ export default memo(({value}:{value:OrderParam|null}) => { if(value) return `${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${value?.total_number}${value?.unit}` }, [value]) + + const priceConDom = useMemo(() => { + return ( + <> + {(value&&value.status < 3)&&} + {(value&&value.status >= 3)&&} + {(value&&value.status >= 3)&&} + {(value&&value.status >= 3)&&} + + ) + }, [value]) + return ( <> {numText} @@ -63,7 +80,7 @@ export default memo(({value}:{value:OrderParam|null}) => { }) } - + {priceConDom} diff --git a/src/pages/order/components/orderState/index.module.scss b/src/pages/order/components/orderState/index.module.scss index c1aef8a..90dbcbb 100644 --- a/src/pages/order/components/orderState/index.module.scss +++ b/src/pages/order/components/orderState/index.module.scss @@ -16,6 +16,9 @@ .order_status_item{ position: relative; padding-left: 50px; + &:nth-last-child(n+2) { + padding-bottom: 30px; + } .order_status_tail_end, .order_status_tail{ width: 15px; height: 15px; diff --git a/src/pages/order/components/orderState/index.tsx b/src/pages/order/components/orderState/index.tsx index d710730..0ba593d 100644 --- a/src/pages/order/components/orderState/index.tsx +++ b/src/pages/order/components/orderState/index.tsx @@ -1,5 +1,5 @@ import { Image, Text, View } from "@tarojs/components" -import { memo, useState } from "react" +import { memo, useMemo, useState } from "react" import styles from './index.module.scss' import classnames from "classnames"; import { formatDateTime, formatImgUrl } from "@/common/fotmat"; @@ -14,23 +14,26 @@ export default memo(({list = []}:{list?:Param[]}) => { const changeMore = () => { setShowMore(() => !showMore) } + const dataList = useMemo(() => { + return list.reverse() + }, [list]) return ( <> - {(list.length > 0)&& + {(dataList.length > 0)&& - {list.map((item, index) => - {(list.length > 1)&&} - {(list.length != (index + 1))&&} + {dataList.map((item, index) => + {(dataList.length > 1)&&} + {(dataList.length != (index + 1))&&} {item.status} {formatDateTime(item.time)} - {item.tag} + {/* {item.tag} */} {item.desc} )} - {(list.length > 2) && changeMore()}> + {(dataList.length > 2) && changeMore()}> {showMore&&'收起详情'||'点击查看详情'} } diff --git a/src/pages/order/components/payment/index.tsx b/src/pages/order/components/payment/index.tsx index 65e5c71..a354b1f 100644 --- a/src/pages/order/components/payment/index.tsx +++ b/src/pages/order/components/payment/index.tsx @@ -1,5 +1,5 @@ import { Text, View } from "@tarojs/components"; -import { memo, useState } from "react"; +import { memo, useEffect, useState } from "react"; import AmountShow from "../amountShow"; import classnames from "classnames"; import styles from './index.module.scss' @@ -8,12 +8,28 @@ import MCheckbox from "@/components/checkbox"; import Popup from "@/components/popup"; import OfflinePay from "../offlinePay"; import ScanPay from "../scanPay"; +import { GetOrderPayApi, SubmitOrderPayApi } from "@/api/orderPay"; +import { formatPriceDiv } from "@/common/fotmat"; +import {alert} from "@/common/common" type Param = { show?: true|false, - onClose?: () => void + onClose?: () => void, + orderId?: number //应付单id } -export default memo(({show = false, onClose}:Param) => { + +type PayInfo = { + amount: string +} + +type PayStatus = 0|1|2|3|4|null //0:预存款, 1:账期,2:线下汇款, 3:扫码支付, 4:货到付款 +export default memo(({show = false, onClose, orderId = 0}:Param) => { + + //提交参数 + const [submitData, setSubmitData] = useState<{id:number, payment_method: PayStatus}>({ + id:0, + payment_method: null + }) //线下付款 const [offlinePayShow, setofflinePayShow] = useState(false) @@ -28,6 +44,45 @@ export default memo(({show = false, onClose}:Param) => { setScanPayShow(true) onClose?.() } + + //获取支付方式数据 + const [payInfo, setPayInfo] = useState() + const {fetchData: orderFetchData} = GetOrderPayApi() + const getOrderPay = async () => { + let {data} = await orderFetchData({id: orderId}) + setPayInfo(() => data) + } + useEffect(() => { + if(show&&orderId) + setSubmitData((val) => ({...val, id:orderId})) + getOrderPay() + }, [show, orderId]) + + //预存款选择 + const advanceSelectData = (val) => { + setSubmitData((e) => ({...e, payment_method:val})) + } + //账期选择 + const periodSelectData = (val) => { + setSubmitData((e) => ({...e, payment_method:val})) + } + + //提交支付 + const {fetchData: submitFetchData} = SubmitOrderPayApi() + const submitPay = async () => { + if(submitData.payment_method === null) { + alert.error('请选择支付方式') + return false + } + alert.loading('正在支付') + let res = await submitFetchData(submitData) + if(res.success) { + alert.success('支付成功') + } else { + alert.none(res.msg) + } + } + return ( @@ -35,7 +90,7 @@ export default memo(({show = false, onClose}:Param) => { 订单支付 - + @@ -59,19 +114,19 @@ export default memo(({show = false, onClose}:Param) => { 预存款 - 金额不足,剩余 ¥0.00 + 金额不足,剩余 ¥{payInfo?.advance_deposit_balance} - console.log()} onClose={() =>console.log()}/> + advanceSelectData(0)} onClose={() => advanceSelectData(null)}/> - x天账期 + {payInfo?.account_period}天账期 - 可用额度 ¥3,000.00 + 可用额度 ¥{payInfo?.account_period_credit_available_line} - console.log()} onClose={() =>console.log()}/> + periodSelectData(1)} onClose={() => periodSelectData(null)}/> @@ -93,7 +148,7 @@ export default memo(({show = false, onClose}:Param) => { - 确认交易 + 确认交易 setofflinePayShow(false)}/> diff --git a/src/pages/order/index.config.ts b/src/pages/order/index.config.ts index d88c826..b518f53 100644 --- a/src/pages/order/index.config.ts +++ b/src/pages/order/index.config.ts @@ -1,3 +1,5 @@ export default { - navigationBarTitleText: '订单详情' + navigationBarTitleText: '订单详情', + enablePullDownRefresh: true, + backgroundTextStyle: 'dark' } diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index cc718f3..5c9d498 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -3,17 +3,20 @@ import { EditSaleOrderRemarkApi, CancelOrderApi } from "@/api/order"; +import { GetOrderPayApi } from "@/api/orderPay"; import { alert, goLink } from "@/common/common"; import { formatDateTime, formatPriceDiv } from "@/common/fotmat"; import OrderBtns from "@/components/orderBtns"; import Popup from "@/components/popup"; import SearchInput from "@/components/searchInput"; import { Text, Textarea, View } from "@tarojs/components" -import Taro, { useDidShow, useRouter } from "@tarojs/taro"; +import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro"; import classnames from "classnames"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import order from "../orderList/components/order"; import AddressInfoDetail from "./components/addressInfoDetail"; import KindList from "./components/kindList"; +import orderState from "./components/orderState"; import OrderState from "./components/orderState"; import Payment from "./components/payment"; import Remark from "./components/remark"; @@ -37,7 +40,8 @@ import styles from './index.module.scss' let res = await getOrderFetchData({id: orderId.current}) setOrderDetail(res.data) setOrderRemark(res.data.remark) - } + } + Taro.stopPullDownRefresh() } //监听获取到的数据 @@ -57,7 +61,11 @@ import styles from './index.module.scss' total_number: orderDetail.total_number, //总数量 total_fabrics: orderDetail.total_fabrics, //面料数量 unit: orderDetail.sale_mode == 0?'条':'m', //单位 - list: orderDetail.product_list + list: orderDetail.product_list, + status: orderDetail.status, //订单状态 + total_sale_price: orderDetail.total_sale_price, //销售金额 + total_should_collect_money: orderDetail.total_should_collect_money, //应收金额 + total_weight_error_discount: orderDetail.total_weight_error_discount, //空差优惠 }) } const formatPreViewOrderMemo = useMemo(() => { @@ -125,7 +133,23 @@ import styles from './index.module.scss' getSaleOrderPreView() }, [orderDetail]) + //获取底部按钮点击, 获取按钮状态 + const orderStateClick = useCallback((val) => { + console.log('val::', val) + if(val == 1) { + //取消订单 + getSaleOrderPreView() + } + if(val == 2) { + //待付款 + toPay() + } + }, [orderDetail]) + //页面下拉刷新 + usePullDownRefresh(() => { + getSaleOrderPreView() + }) return ( @@ -161,13 +185,13 @@ import styles from './index.module.scss' - - toPay()}>去支付 + + {/* toPay()}>去支付 */} setShowDesc(false)} > getRemark(e)}/> - setPayMentShow(false)}/> + setPayMentShow(false)} orderId={orderDetail?.should_collect_order_id}/> ) diff --git a/src/pages/orderList/components/order/index.tsx b/src/pages/orderList/components/order/index.tsx index 659d18c..7ad9512 100644 --- a/src/pages/orderList/components/order/index.tsx +++ b/src/pages/orderList/components/order/index.tsx @@ -20,9 +20,10 @@ type Param = { total_number: number, status: 0, id: number - } + }, + onClickBtn?: (val:number) => void } -export default memo(({value}: Param) => { +export default memo(({value, onClickBtn}: Param) => { const userInfo = useSelector(state => state.userInfo) //对应数量 const formatCount = useCallback((item, sale_mode) => { @@ -33,49 +34,17 @@ export default memo(({value}: Param) => { return formatPriceDiv(price).toLocaleString() + '/' + (sale_mode == 1?'m':'kg') }, [value]) - - - //订单按钮按订单状态归类 - const orderBtnsList = useRef([ - { - value: [0, 1, 2, 9, 3], //取消订单按钮对应: 待接单,待配布,已配布, 待付款, 待发货 - label: '取消订单' - }, - { - value: [3, 9], //去付款按钮对应:待付款, 待发货 - label: '去付款' - }, - { - value: [3], //取消订单按钮对应: 待发货 - label: '申请退款' - }, - { - value: [4, 7, 8, 6], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款 - label: '查看物流' - }, - { - value: [4, 7, 6], //取消订单按钮对应: 待收货, 已收货, 已退款 - label: '申请退货' - }, - { - value: [4], //取消订单按钮对应: 待收货 - label: '确认收货' - }, - { - value: [4,7,8,6], //取消订单按钮对应: 待收货,已收货,已完成, 已退款 - label: '再次购买' - } - ]) - const orderBtnsShow = useCallback((item, status) => { - return item.value.includes(status) - },[]) + //点击订单按钮 + const orderBtnsClick = useCallback((status) => { + onClickBtn?.(status) + }, [value]) return ( goLink('/pages/order/index', {id: value?.id})}> - - {userInfo.adminUserInfo.user_name} + + {userInfo?.adminUserInfo?.user_name} 订单号:{value?.order_no} @@ -114,7 +83,7 @@ export default memo(({value}: Param) => { {`${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${value?.total_number}条`} - + ) }) diff --git a/src/pages/orderList/index.tsx b/src/pages/orderList/index.tsx index 8bceb49..04aedfe 100644 --- a/src/pages/orderList/index.tsx +++ b/src/pages/orderList/index.tsx @@ -1,7 +1,7 @@ import Search from "@/components/search" import useLogin from "@/use/useLogin" import { Image, ScrollView, Text, View } from "@tarojs/components" -import Taro, { useDidShow, useRouter } from "@tarojs/taro" +import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro" import { useCallback, useEffect, useMemo, useRef, useState } from "react" import {ORDER_STATUS} from '@/common/enum' import styles from './index.module.scss' @@ -44,7 +44,6 @@ export default () => { const getOrderList = async () => { let res = await listFetchData(getFilterData(searchField)) setOrderData({list: res.data.list, total: res.data.total}) - Taro.stopPullDownRefresh() } @@ -82,6 +81,17 @@ export default () => { setOrderData(() => ({list:[], total:0})) setSearchField((val) => ({...val, name:e, size:10})) }, []) + + const clickOrderBtn = useCallback((state) => { + getOrderList() + }, [orderData]) + + //列表下拉刷新 + const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) + const getRefresherRefresh = async () => { + pageNum.current.size = 1 + setRefresherTriggeredStatus(true) + } return ( @@ -98,9 +108,9 @@ export default () => { - + {orderData?.list.map(item => { - return + return })}