商城测试版v7
This commit is contained in:
parent
305c3aa0eb
commit
87bcda1c38
@ -17,7 +17,7 @@
|
||||
position: absolute;
|
||||
background-color: #fff;
|
||||
width: 226px;
|
||||
box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.06);
|
||||
box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.3);
|
||||
border-radius: 10px;
|
||||
padding: 0 20px;
|
||||
box-sizing: border-box;
|
||||
|
@ -49,12 +49,13 @@ export default memo(({orderInfo, showStatus = 'detail', onClick}:Param) => {
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//注册按钮
|
||||
type orderBtnsListParams = {id: number, label: string, validatarFunc: (val: typeof orderInfo) => any}
|
||||
//注册按钮, id:按钮id唯一,label:按钮名称,sort:排序数字越大越靠后,validatarFunc:验证
|
||||
type orderBtnsListParams = {id: number, label: string, sort: number, validatarFunc: (val: typeof orderInfo) => any}
|
||||
const orderBtnsList = useRef<orderBtnsListParams[]>([
|
||||
{
|
||||
id: 1,
|
||||
label: '取消订单',
|
||||
sort: 1,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//在待发货之前没有付过款
|
||||
let orderStatus = [
|
||||
@ -69,74 +70,10 @@ export default memo(({orderInfo, showStatus = 'detail', onClick}:Param) => {
|
||||
return orderInfo.actual_amount == 0 && orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
label: '再次购买',
|
||||
validatarFunc: () => {
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
label: '退款',
|
||||
validatarFunc: (orderInfo) => {
|
||||
//散剪和剪板在待接单时付过款
|
||||
let orderStatus = [
|
||||
SaleOrderStatusBooking.value
|
||||
]
|
||||
return orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
label: '售后记录',
|
||||
validatarFunc: (orderInfo) => {
|
||||
return orderInfo.is_return
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
label: '申请退款',
|
||||
validatarFunc: (orderInfo) => {
|
||||
//大货在待发货付过款
|
||||
let orderStatus = [
|
||||
SaleOrderStatusWaitingDelivery.value,
|
||||
SaleOrderStatusTaking.value
|
||||
]
|
||||
return orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
label: '申请退货',
|
||||
validatarFunc: (orderInfo) => {
|
||||
let orderStatus = [
|
||||
SaleOrderStatusAlreadyReceipt.value,
|
||||
SaleOrderStatusRefund.value
|
||||
]
|
||||
return orderInfo.av_return_roll&& orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
label: '确认收货',
|
||||
validatarFunc: (orderInfo) => {
|
||||
let orderStatus = [
|
||||
SaleOrderStatusWaitingReceipt.value
|
||||
]
|
||||
return orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
label: '销售码单',
|
||||
validatarFunc: (orderInfo) => {
|
||||
return orderInfo.actual_amount > 0 && orderInfo.wait_pay_amount == 0 && showStatus == 'detail'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: '去付款',
|
||||
sort: 100,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//只要没有付完款就显示
|
||||
let orderStatus = [
|
||||
@ -150,15 +87,87 @@ export default memo(({orderInfo, showStatus = 'detail', onClick}:Param) => {
|
||||
]
|
||||
return orderInfo.wait_pay_amount != 0 && orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
label: '申请退款',
|
||||
sort: 5,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//大货在待发货付过款
|
||||
let orderStatus = [
|
||||
SaleOrderStatusWaitingDelivery.value,
|
||||
SaleOrderStatusTaking.value
|
||||
]
|
||||
return orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
label: '申请退货',
|
||||
sort: 5,
|
||||
validatarFunc: (orderInfo) => {
|
||||
let orderStatus = [
|
||||
SaleOrderStatusAlreadyReceipt.value,
|
||||
SaleOrderStatusRefund.value
|
||||
]
|
||||
return orderInfo.av_return_roll&& orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
label: '确认收货',
|
||||
sort: 10,
|
||||
validatarFunc: (orderInfo) => {
|
||||
let orderStatus = [
|
||||
SaleOrderStatusWaitingReceipt.value
|
||||
]
|
||||
return orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
label: '再次购买',
|
||||
sort: 6,
|
||||
validatarFunc: () => {
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
label: '退款',
|
||||
sort: 5,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//散剪和剪板在待接单时付过款
|
||||
let orderStatus = [
|
||||
SaleOrderStatusBooking.value
|
||||
]
|
||||
return orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
label: '售后记录',
|
||||
sort: 6,
|
||||
validatarFunc: (orderInfo) => {
|
||||
return orderInfo.is_return
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
label: '销售码单',
|
||||
sort: 9,
|
||||
validatarFunc: (orderInfo) => {
|
||||
return orderInfo.actual_amount > 0 && orderInfo.wait_pay_amount == 0 && showStatus == 'detail'
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
//显示的按钮数组
|
||||
const orderBtnsShowList: orderBtnsListParams[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter(item => {
|
||||
let list = orderBtnsList.current.filter(item => {
|
||||
return item.validatarFunc(orderInfo)
|
||||
})
|
||||
return list.sort((a, b) => a.sort - b.sort)
|
||||
}, [orderInfo])
|
||||
|
||||
//小程序订阅
|
||||
@ -278,7 +287,7 @@ export default memo(({orderInfo, showStatus = 'detail', onClick}:Param) => {
|
||||
{showMore&&<View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) &&<View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
return ((index < (orderBtnsShowList.length - 3)) &&<View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
@ -287,7 +296,7 @@ export default memo(({orderInfo, showStatus = 'detail', onClick}:Param) => {
|
||||
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3)&&<View key={item.id} className={classnames(styles.btns_item)} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
||||
((orderBtnsShowList.length - 3) <= index)&&<View key={item.id} className={classnames(styles.btns_item)} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
@ -14,6 +14,7 @@ type OrderParam = {
|
||||
total_fabrics?: number,
|
||||
total_number?: number,
|
||||
status?: number, //订单状态
|
||||
av_return_product?: any[] //申请售后列表
|
||||
}
|
||||
|
||||
type Param = {
|
||||
@ -22,40 +23,28 @@ type Param = {
|
||||
}
|
||||
|
||||
const kindeList:FC<Param> = memo(({order, onSelectChange}) => {
|
||||
//对应数量
|
||||
const formatCount = useCallback((item) => {
|
||||
return (order?.sale_mode == 0? item.roll : Number(item.length / 100)) + order?.unit
|
||||
}, [order])
|
||||
|
||||
|
||||
//checkbox选中回调
|
||||
const selectCallBack = (colorItem) => {
|
||||
onSelectChange?.({color_id:colorItem.id, length:colorItem.length, sale_order_detail_id:colorItem.sale_order_detail_id, status: true})
|
||||
onSelectChange?.({color_id:colorItem.product_color_id, length:colorItem.length, sale_order_detail_id:colorItem.sale_order_detail_id, status: true})
|
||||
}
|
||||
|
||||
//checkbox关闭回调
|
||||
const colseCallBack = (colorItem) => {
|
||||
onSelectChange?.({color_id:colorItem.id, length:colorItem.length, status: false, sale_order_detail_id:colorItem.sale_order_detail_id,})
|
||||
}
|
||||
|
||||
//判断该面料下的颜色都退完了
|
||||
const colorNum = (item) => {
|
||||
return item.product_colors.some(val => {
|
||||
return val.return_roll + val.apply_return_roll == 0
|
||||
})
|
||||
onSelectChange?.({color_id:colorItem.product_color_id, length:colorItem.length, status: false, sale_order_detail_id:colorItem.sale_order_detail_id,})
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.apply_after_sales_list}>
|
||||
{order?.list?.map(item => colorNum(item)&&<View className={styles.apply_after_sales_item} >
|
||||
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item} >
|
||||
<View className={styles.apply_after_sales_title}>
|
||||
<View className={styles.tag}>{order.sale_mode_name}</View>
|
||||
<View className={styles.title}>{formatHashTag(item.code, item.name)}</View>
|
||||
<View className={styles.title}>{formatHashTag(item.product_code, item.product_name)}</View>
|
||||
</View>
|
||||
<View className={styles.color_list}>
|
||||
{item.product_colors.map(colorItem => ((colorItem.return_roll + colorItem.apply_return_roll) == 0)&&<View className={styles.color_item}>
|
||||
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
||||
<View className={styles.image}><Image src={formatImgUrl('')}/></View>
|
||||
<View className={styles.name_and_number}><Text>{colorItem.code + ' ' + colorItem.name}</Text><Text>x {formatCount(colorItem)}</Text></View>
|
||||
<View className={styles.name_and_number}><Text>{colorItem.product_color_code + ' ' + colorItem.product_color_name}</Text><Text>x {colorItem.length/100} m</Text></View>
|
||||
<MCheckbox status={item.select} onSelect={() => selectCallBack(colorItem)} onClose={() => colseCallBack(colorItem)}/>
|
||||
</View>)}
|
||||
</View>
|
||||
|
@ -14,6 +14,7 @@ type OrderParam = {
|
||||
total_fabrics?: number,
|
||||
total_number?: number,
|
||||
status?: number, //订单状态
|
||||
av_return_product?: any[] //申请售后列表
|
||||
}
|
||||
|
||||
type Param = {
|
||||
@ -22,39 +23,27 @@ type Param = {
|
||||
}
|
||||
|
||||
const kindeList:FC<Param> = memo(({order, onNumChange}) => {
|
||||
//对应数量
|
||||
const formatCount = useCallback((item) => {
|
||||
return (item.roll - item.return_roll - item.apply_return_roll) + order?.unit!
|
||||
}, [order])
|
||||
|
||||
//计步器失返回值
|
||||
//计步器返回值
|
||||
const getCounterChange = useCallback((colorItem) => {
|
||||
return (number) => {
|
||||
onNumChange?.({number, color_id: colorItem.id, sale_order_detail_id:colorItem.sale_order_detail_id})
|
||||
}
|
||||
}, [])
|
||||
|
||||
//判断该面料下的颜色都退完了
|
||||
const colorNum = (item) => {
|
||||
let res = item.product_colors.some(val => {
|
||||
return (val.return_roll + val.apply_return_roll) < val.roll
|
||||
})
|
||||
return res
|
||||
onNumChange?.({number, color_id: colorItem.product_color_id, sale_order_detail_id:colorItem.sale_order_detail_id})
|
||||
}
|
||||
}, [order])
|
||||
|
||||
return (
|
||||
<View className={styles.apply_after_sales_list}>
|
||||
{order?.list?.map(item => (colorNum(item))&&<View className={styles.apply_after_sales_item}>
|
||||
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item}>
|
||||
<View className={styles.apply_after_sales_title}>
|
||||
<View className={styles.tag}>{order.sale_mode_name}</View>
|
||||
<View className={styles.title}>{formatHashTag(item.code, item.name)}</View>
|
||||
<View className={styles.title}>{formatHashTag(item.product_code, item.product_name)}</View>
|
||||
</View>
|
||||
<View className={styles.color_list}>
|
||||
{item.product_colors.map(colorItem => ((colorItem.return_roll + colorItem.apply_return_roll) < colorItem.roll)&&<View className={styles.color_item}>
|
||||
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
||||
<View className={styles.image}><Image src={formatImgUrl('')}/></View>
|
||||
<View className={styles.name_and_number}><Text>{colorItem.code + ' ' + colorItem.name}</Text><Text>x {formatCount(colorItem)}</Text></View>
|
||||
<View className={styles.name_and_number}><Text>{colorItem.product_color_code + ' ' + colorItem.product_color_name}</Text><Text>x {colorItem.roll}</Text></View>
|
||||
<View className={styles.btn_count}>
|
||||
<Counter maxNum={colorItem.roll - (colorItem.return_roll + colorItem.apply_return_roll)} onChange={getCounterChange(colorItem)}/>
|
||||
<Counter maxNum={colorItem.roll} onChange={getCounterChange(colorItem)}/>
|
||||
</View>
|
||||
</View>)}
|
||||
</View>
|
||||
|
@ -65,6 +65,7 @@ export default () => {
|
||||
...orderDetail,
|
||||
unit: orderDetail.sale_mode == 0?'条':'m', //单位
|
||||
list: orderDetail.product_list,
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@ -84,30 +85,21 @@ export default () => {
|
||||
//大货时获取计步器数据
|
||||
const getNumChange = useCallback((val) => {
|
||||
if(parseInt(val.number) > 0) {
|
||||
roll_list.current[val.color_id] = {product_color_id: val.color_id, product_roll: val.number, sale_order_detail_id: val.sale_order_detail_id}
|
||||
roll_list.current[val.color_id] = {product_roll: val.number, sale_order_detail_id: val.sale_order_detail_id}
|
||||
} else {
|
||||
delete roll_list.current[val.color_id]
|
||||
}
|
||||
|
||||
let count = 0
|
||||
Object.values(roll_list.current).map((item: any) => {
|
||||
count += item.product_roll
|
||||
})
|
||||
setSubmitData((e) => ({...e, roll_list:Object.values(roll_list.current), roll: count}))
|
||||
setSubmitData((e) => ({...e, roll_list:Object.values(roll_list.current)}))
|
||||
}, [])
|
||||
|
||||
//散剪和剪板
|
||||
const getSelectChange = useCallback((val) => {
|
||||
if(val.status) {
|
||||
roll_list.current[val.color_id] = {product_color_id: val.color_id, product_roll: val.length, sale_order_detail_id: val.sale_order_detail_id}
|
||||
roll_list.current[val.color_id] = {product_roll: val.length, sale_order_detail_id: val.sale_order_detail_id}
|
||||
} else {
|
||||
delete roll_list.current[val.color_id]
|
||||
}
|
||||
let count = 0
|
||||
Object.values(roll_list.current).map((item: any) => {
|
||||
count += item.product_roll
|
||||
})
|
||||
setSubmitData((e) => ({...e, roll_list:Object.values(roll_list.current), roll: count}))
|
||||
setSubmitData((e) => ({...e, roll_list:Object.values(roll_list.current)}))
|
||||
}, [])
|
||||
|
||||
//获取图片列表
|
||||
|
@ -5,7 +5,7 @@ import styles from './index.module.scss'
|
||||
import Popup from "@/components/popup";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { alert } from "@/common/common";
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from "@/common/fotmat";
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from "@/common/fotmat";
|
||||
import useCheckAuthorize from "@/use/useCheckAuthorize";
|
||||
import { GetPayCode } from "@/api/onlinePay";
|
||||
import LoadingCard from "@/components/loadingCard";
|
||||
@ -34,28 +34,6 @@ type ListParam = {
|
||||
export default memo(({show = true, onClose, company, orderInfo}:Param) => {
|
||||
const [detail, setDetail] = useState<any>()
|
||||
|
||||
//获取支付方式数据
|
||||
const [payInfo, setPayInfo] = useState<any>()
|
||||
const {fetchData: orderFetchData} = GetOrderPayApi()
|
||||
const {fetchData: prepayOrderFetchData} = GetPrepayOrderPayApi()
|
||||
const getOrderPay = async () => {
|
||||
if(orderInfo&&orderInfo.should_collect_order_id) {
|
||||
//有应收单id时用应收单获取数据
|
||||
let {data} = await orderFetchData({id: orderInfo?.should_collect_order_id})
|
||||
setPayInfo(() => data)
|
||||
}
|
||||
else if(orderInfo&&orderInfo.pre_collect_order_id) {
|
||||
//用预付单id获取支付信息
|
||||
let {data} = await prepayOrderFetchData({id: orderInfo?.pre_collect_order_id})
|
||||
setPayInfo(() => data)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if(orderInfo)
|
||||
getOrderPay()
|
||||
}, [orderInfo])
|
||||
|
||||
useEffect(() => {
|
||||
if(show) {
|
||||
getCore()
|
||||
@ -63,14 +41,14 @@ export default memo(({show = true, onClose, company, orderInfo}:Param) => {
|
||||
}, [show])
|
||||
|
||||
useEffect(() => {
|
||||
if(orderInfo && payInfo) {
|
||||
if(orderInfo) {
|
||||
let lists:ListParam[] = []
|
||||
orderInfo.product_list?.map(pitem => {
|
||||
pitem?.product_colors?.map(citem => {
|
||||
lists.push({
|
||||
product_code: formatHashTag(pitem.code, '', 'name')!,
|
||||
product_code: formatRemoveHashTag(pitem.code),
|
||||
product_name: pitem.name,
|
||||
product_color_code: formatHashTag(citem.code)!,
|
||||
product_color_code: formatRemoveHashTag(citem.code),
|
||||
product_color_name: citem.name,
|
||||
num: citem.roll.toString(),
|
||||
length: (citem.length/100).toString(),
|
||||
@ -91,21 +69,21 @@ export default memo(({show = true, onClose, company, orderInfo}:Param) => {
|
||||
target_user_name: userName(orderInfo), //收件人
|
||||
target_address: address(orderInfo), //收货地址
|
||||
target_description: orderInfo.remark, //发货备注
|
||||
pay_account: payInfo.offline_remittance_information?.transfer_remittance_account, //专属收款账号
|
||||
bank_account_name: payInfo.offline_remittance_information?.account_name, //账户名称
|
||||
bank_name: payInfo.offline_remittance_information?.bank_of_deposit, //开户银行
|
||||
pay_account: orderInfo.account, //专属收款账号
|
||||
bank_account_name: orderInfo.account_name, //账户名称
|
||||
bank_name: orderInfo.bank_of_deposit, //开户银行
|
||||
pay_type:"", //支付方式, 可不传
|
||||
client: orderInfo.purchaser_name, //客户名称
|
||||
phone: userPhone(orderInfo), //收货手机号码
|
||||
order_total_length: (orderInfo.total_number/100).toString(), //订单布匹长度
|
||||
order_total_price: formatPriceDiv(orderInfo.total_sale_price).toString(), //订单价格
|
||||
order_total_num: (orderInfo.total_number) + '',
|
||||
order_total_num: (orderInfo.total_number).toString(),
|
||||
qrcode:"", //跳转链接
|
||||
order_total_weight: formatWeightDiv(orderInfo.total_estimate_weight).toString(), //订单布匹重量
|
||||
list: lists
|
||||
}))
|
||||
}
|
||||
}, [orderInfo, payInfo])
|
||||
}, [orderInfo])
|
||||
|
||||
//收货地址
|
||||
const address = (addressInfo) => {
|
||||
@ -199,6 +177,5 @@ export default memo(({show = true, onClose, company, orderInfo}:Param) => {
|
||||
</View>
|
||||
</Popup>
|
||||
</View>
|
||||
|
||||
)
|
||||
})
|
@ -195,6 +195,7 @@ import styles from './index.module.scss'
|
||||
|
||||
//支付成功
|
||||
const onPaySuccess = useCallback(() => {
|
||||
alert.success('支付成功')
|
||||
getSaleOrderPreView()
|
||||
closePayShow()
|
||||
}, [orderDetail])
|
||||
|
@ -1,194 +0,0 @@
|
||||
import Search from "@/components/search"
|
||||
import useLogin from "@/use/useLogin"
|
||||
import { Image, ScrollView, Text, View } from "@tarojs/components"
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro"
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import Order from "./components/order"
|
||||
import InfiniteScroll from "@/components/infiniteScroll"
|
||||
import {GetOrderStatusListApi, GetOrderListApi, OrderStatusListApi} from '@/api/order'
|
||||
import { dataLoadingStatus, getFilterData } from "@/common/util"
|
||||
import OrderStatusList from "./components/orderStatusList"
|
||||
import Payment from "../order/components/payment"
|
||||
import { ORDER_STATUS } from "@/common/enum"
|
||||
import { AddShoppingCartApi } from "@/api/shopCart"
|
||||
import ShopCart from "@/components/shopCart"
|
||||
import ApplyRefund from "./components/applyRefund"
|
||||
import { alert } from "@/common/common"
|
||||
|
||||
export default () => {
|
||||
const {checkLogin} = useLogin()
|
||||
useDidShow(async () => {
|
||||
await checkLogin()
|
||||
})
|
||||
|
||||
//搜索参数
|
||||
const [searchField, setSearchField] = useState({
|
||||
status: -1,
|
||||
page : 1,
|
||||
size : 10,
|
||||
Name:''
|
||||
})
|
||||
|
||||
//获取订单状态
|
||||
const {fetchData: orderStatusListFetchData} = OrderStatusListApi()
|
||||
const [statusList, setStatusList] = useState<any[]>([{id: -1, name: '全部'}])
|
||||
const getOrderStatusList = () => {
|
||||
const status = Object.values(ORDER_STATUS).map(item => {
|
||||
return {id: item.value, name: item.label}
|
||||
})
|
||||
setStatusList((e) => [...e, ...status])
|
||||
}
|
||||
useEffect(() => {
|
||||
getOrderStatusList()
|
||||
}, [])
|
||||
|
||||
//获取订单列表
|
||||
const {fetchData: listFetchData, state:orderState} = GetOrderListApi()
|
||||
const [orderData, setOrderData] = useState<{list:any[], total:number}>({list:[], total:0})
|
||||
const getOrderList = async () => {
|
||||
let res = await listFetchData(getFilterData(searchField))
|
||||
setOrderData({list: res.data.list, total: res.data.total})
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
|
||||
|
||||
//监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getOrderList()
|
||||
}, [searchField])
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({size: searchField.size, page: searchField.page})
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if(orderData.list.length < orderData.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearchField({...searchField, size })
|
||||
}
|
||||
}, [orderData])
|
||||
|
||||
//状态改变
|
||||
const changeStatus = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setSearchField((value) => ({...value, status:e, size:10}))
|
||||
setOrderData(() => ({list:[], total:0}))
|
||||
}, [])
|
||||
|
||||
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({list:orderData.list, total: orderData.total, status: orderState.loading})
|
||||
}, [orderData, orderState])
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({list:[], total:0}))
|
||||
setSearchField((val) => ({...val, name:e, size:10}))
|
||||
}, [])
|
||||
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearchField((val) => ({...val, size:10}))
|
||||
}
|
||||
|
||||
//监听点击的按钮
|
||||
const clickOrderBtn = useCallback(({status, orderInfo}) => {
|
||||
setCallBackPayOrderInfo(() => orderInfo)
|
||||
if(status == 1 || status == 6) {
|
||||
getOrderList()
|
||||
} else if(status == 2) {
|
||||
//去支付
|
||||
toPay()
|
||||
} else if (status == 3) {
|
||||
//申请退款
|
||||
if(!orderInfo?.av_return_roll) return alert.none('该订单已申请过退款')
|
||||
setRefundShow(true)
|
||||
} else if (status == 7) {
|
||||
//购买
|
||||
addShopCart(orderInfo)
|
||||
}
|
||||
}, [orderData])
|
||||
|
||||
|
||||
const [callBackOrderInfo, setCallBackPayOrderInfo] = useState<any>()
|
||||
|
||||
//去付款
|
||||
const [payMentShow, setPayMentShow] = useState(false)
|
||||
const toPay = () => {
|
||||
setPayMentShow(true)
|
||||
}
|
||||
//关闭支付弹窗
|
||||
const closePayShow = useCallback(() => {
|
||||
setPayMentShow(() => false)
|
||||
}, [])
|
||||
//支付成功
|
||||
const onPaySuccess = useCallback(() => {
|
||||
getOrderList()
|
||||
closePayShow()
|
||||
}, [])
|
||||
|
||||
//添加购物车
|
||||
const [showCart, setShowCart] = useState(false)
|
||||
const {fetchData:addFetchData} = AddShoppingCartApi()
|
||||
const addShopCart = async (item) => {
|
||||
let color_list:{product_color_id: number, roll?: number, length?: number}[] = []
|
||||
item?.product_list.map(pitem => {
|
||||
pitem?.product_colors.map(citem => {
|
||||
if(item?.sale_mode == 0) {
|
||||
return color_list.push({product_color_id: citem.id, roll: citem.roll})
|
||||
} else {
|
||||
return color_list.push({product_color_id: citem.id, length: citem.length})
|
||||
}
|
||||
})
|
||||
})
|
||||
const state = await addFetchData({
|
||||
sale_mode: item?.sale_mode,
|
||||
color_list
|
||||
})
|
||||
if(state.success) {
|
||||
Taro.showToast({
|
||||
title:'已加入购物车'
|
||||
})
|
||||
setShowCart(true)
|
||||
} else {
|
||||
Taro.showToast({
|
||||
icon:'none',
|
||||
title: state.msg
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//申请退款
|
||||
const [refundShow, setRefundShow] = useState(false)
|
||||
const applyRefundClose = useCallback(() => {
|
||||
setRefundShow(false)
|
||||
}, [])
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.order_list_main}>
|
||||
<View className={styles.title}>
|
||||
<Search placeIcon="out" placeholder="搜索商品/名称/颜色/订单号" showBtn={true} changeOnSearch={getSearchData} debounceTime={300}/>
|
||||
<OrderStatusList list={statusList} onSelect={changeStatus} defaultId={1}/>
|
||||
</View>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll statusMore={statusMore} selfonScrollToLower={getScrolltolower} refresherEnabled={false} refresherTriggered={refresherTriggeredStatus} selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
{orderData?.list.map(item => {
|
||||
return <View key={item.id} className={styles.order_item_con}> <Order value={item} onClickBtn={clickOrderBtn}/></View>
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<ApplyRefund show={refundShow} onClose={applyRefundClose} orderId={callBackOrderInfo?.id}/>
|
||||
<ShopCart show={showCart} onClose={() => setShowCart(false)}/>
|
||||
<Payment onSubmitSuccess={onPaySuccess} show={payMentShow} onClose={closePayShow} orderInfo={callBackOrderInfo}/>
|
||||
</View>
|
||||
)
|
||||
}
|
@ -119,11 +119,11 @@ export default memo(({value, onClickBtn}: Param) => {
|
||||
)
|
||||
})
|
||||
}
|
||||
<View className={styles.color_item}>
|
||||
{value?.product_list?.[0].product_colors.length > 2 && <View className={styles.color_item}>
|
||||
<View className={styles.color_more}>……</View>
|
||||
<View className={styles.color_more}>……</View>
|
||||
<View className={styles.color_more}>……</View>
|
||||
</View>
|
||||
</View>}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.color_count_num}>{numText}</View>
|
||||
|
@ -1,124 +0,0 @@
|
||||
import Search from "@/components/search"
|
||||
import useLogin from "@/use/useLogin"
|
||||
import { Image, ScrollView, Text, View } from "@tarojs/components"
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro"
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import Order from "./components/order"
|
||||
import InfiniteScroll from "@/components/infiniteScroll"
|
||||
import { dataLoadingStatus, getFilterData } from "@/common/util"
|
||||
import OrderStatusList from "./components/orderStatusList"
|
||||
import { AFTER_ORDER_STATUS } from "@/common/enum"
|
||||
import { GetSaleOrderListApi } from "@/api/salesAfterOrder"
|
||||
import ReturnLogistics from "./components/returnLogistics"
|
||||
|
||||
export default () => {
|
||||
const {checkLogin} = useLogin()
|
||||
useDidShow(async () => {
|
||||
await checkLogin()
|
||||
})
|
||||
|
||||
//搜索参数
|
||||
const [searchField, setSearchField] = useState({
|
||||
status: -1,
|
||||
page : 1,
|
||||
size : 10,
|
||||
Name:''
|
||||
})
|
||||
|
||||
//获取订单状态
|
||||
const [statusList, setStatusList] = useState<any[]>([{id: -1, name: '全部'}])
|
||||
const getOrderStatusList = () => {
|
||||
const status = Object.values(AFTER_ORDER_STATUS).map(item => {
|
||||
return {id: item.value, name: item.label}
|
||||
})
|
||||
setStatusList((e) => [...e, ...status])
|
||||
}
|
||||
useEffect(() => {
|
||||
getOrderStatusList()
|
||||
}, [])
|
||||
|
||||
//获取订单列表
|
||||
const {fetchData: listFetchData, state:orderState} = GetSaleOrderListApi()
|
||||
const [orderData, setOrderData] = useState<{list:any[], total:number}>({list:[], total:0})
|
||||
const getOrderList = async () => {
|
||||
let res = await listFetchData(getFilterData(searchField))
|
||||
setOrderData({list: res.data.list, total: res.data.total})
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
|
||||
|
||||
//监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getOrderList()
|
||||
}, [searchField])
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({size: searchField.size, page: searchField.page})
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if(orderData.list.length < orderData.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearchField({...searchField, size })
|
||||
}
|
||||
}, [orderData])
|
||||
|
||||
//状态改变
|
||||
const changeStatus = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setSearchField((value) => ({...value, status:e, size:10}))
|
||||
setOrderData(() => ({list:[], total:0}))
|
||||
}, [])
|
||||
|
||||
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({list:orderData.list, total: orderData.total, status: orderState.loading})
|
||||
}, [orderData, orderState])
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({list:[], total:0}))
|
||||
setSearchField((val) => ({...val, name:e, size:10}))
|
||||
}, [])
|
||||
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearchField((val) => ({...val, size:10}))
|
||||
}
|
||||
|
||||
//监听点击的按钮
|
||||
const clickOrderBtn = useCallback(({status, orderInfo}) => {
|
||||
if(status == 2) {
|
||||
//退货物流
|
||||
|
||||
}
|
||||
}, [orderData])
|
||||
|
||||
//物流显示
|
||||
const [logisticsShow, setLogisticsShow] = useState(false)
|
||||
const onCloseLogistics = useCallback(() => setLogisticsShow(false), [])
|
||||
|
||||
return (
|
||||
<View className={styles.order_list_main}>
|
||||
<View className={styles.title}>
|
||||
<Search placeIcon="out" placeholder="搜索商品/名称/颜色/订单号" showBtn={true} changeOnSearch={getSearchData} debounceTime={300}/>
|
||||
<OrderStatusList list={statusList} onSelect={changeStatus} defaultId={1}/>
|
||||
</View>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll statusMore={statusMore} selfonScrollToLower={getScrolltolower} refresherEnabled={true} refresherTriggered={refresherTriggeredStatus} selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
{orderData?.list.map(item => {
|
||||
return <View key={item.id} className={styles.order_item_con}> <Order value={item} onClickBtn={clickOrderBtn}/></View>
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
<ReturnLogistics show={logisticsShow} onClose={onCloseLogistics}/>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
|
||||
import { View } from '@tarojs/components'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Search from '@/components/search'
|
||||
import { alert, goLink } from '@/common/common';
|
||||
import classnames from "classnames";
|
||||
@ -80,7 +80,7 @@ export default () => {
|
||||
{searchData?.historyField.length > 0 && <View className={styles.history}>
|
||||
<View className={styles.history_header}>
|
||||
<View className={styles.history_header_title}>历史搜索</View>
|
||||
<View className={classnames('iconfont icon-lajixiang', styles.miconfont)}></View>
|
||||
<View className={classnames('iconfont icon-shanchu', styles.miconfont)}></View>
|
||||
</View>
|
||||
<View className={styles.list}>
|
||||
{searchData?.historyField?.map((item, index) => <View key={index} className={styles.item} onClick={() => searchEvent(item.search_key, false)}>{item.search_key}</View>)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user