线上测试
This commit is contained in:
parent
78ed044c49
commit
76dca1ef45
4
global.d.ts
vendored
4
global.d.ts
vendored
@ -16,3 +16,7 @@ declare namespace NodeJS {
|
||||
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
|
||||
}
|
||||
}
|
||||
|
||||
declare const CURRENT_VERSION: string
|
||||
declare const CURRENT_GITHASH: string
|
||||
declare const CURRENT_ENV: string
|
@ -28,7 +28,7 @@ export default (props: params) => {
|
||||
}
|
||||
|
||||
const skipTo = (item) => {
|
||||
if (item.jump_type == 2) {
|
||||
if (item.jump_type == 2 || item.jump_type == 0) {
|
||||
goLink(item.link + '&title=' + item.title)
|
||||
} else {
|
||||
goLink(item.link)
|
||||
|
@ -1,312 +1,312 @@
|
||||
import { CancelOrderApi, ReceiveOrderApi } from "@/api/order"
|
||||
import { alert, goLink } from "@/common/common"
|
||||
import { ORDER_STATUS, SALE_MODE, SUBSCRIPTION_MESSAGE_SCENE } from "@/common/enum"
|
||||
import {Text, View } from "@tarojs/components"
|
||||
import Taro from "@tarojs/taro"
|
||||
import {useRef, memo, useState, useMemo } from "react"
|
||||
import classnames from "classnames";
|
||||
import styles from './index.module.scss'
|
||||
import { AddShoppingCartApi } from "@/api/shopCart"
|
||||
import { ApplyRefundApi } from "@/api/salesAfterOrder"
|
||||
import { UseSubscriptionMessage } from "@/use/useCommon"
|
||||
import { throttle } from "@/common/util"
|
||||
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { ORDER_STATUS, SALE_MODE, SUBSCRIPTION_MESSAGE_SCENE } from '@/common/enum'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useRef, memo, useState, useMemo } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import { AddShoppingCartApi } from '@/api/shopCart'
|
||||
import { ApplyRefundApi } from '@/api/salesAfterOrder'
|
||||
import { UseSubscriptionMessage } from '@/use/useCommon'
|
||||
import { throttle } from '@/common/util'
|
||||
|
||||
type Param = {
|
||||
orderInfo: {
|
||||
status: number, //订单状态
|
||||
orderId: number, //订单id
|
||||
actual_amount: number, //实付金额
|
||||
wait_pay_amount: number, //待付金额
|
||||
sale_mode: number, //订单类型
|
||||
av_return_roll?: number, //可退数量
|
||||
is_return?: true|false, //是否申请了售后
|
||||
is_should_collect_audit?: true|false, //应收单是否审核
|
||||
|
||||
},
|
||||
showStatus?: 'detail'|'list', //订单详情,订单列表
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
orderInfo: {
|
||||
status: number //订单状态
|
||||
orderId: number //订单id
|
||||
actual_amount: number //实付金额
|
||||
wait_pay_amount: number //待付金额
|
||||
sale_mode: number //订单类型
|
||||
av_return_roll?: number //可退数量
|
||||
is_return?: true | false //是否申请了售后
|
||||
is_should_collect_audit?: true | false //应收单是否审核
|
||||
}
|
||||
showStatus?: 'detail' | 'list' //订单详情,订单列表
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
export default memo(({orderInfo, showStatus = 'detail', onClick}:Param) => {
|
||||
//订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment,
|
||||
SaleOrderStatusTaking
|
||||
} = ORDER_STATUS
|
||||
export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
//订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment,
|
||||
SaleOrderStatusTaking,
|
||||
} = ORDER_STATUS
|
||||
|
||||
//订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//注册按钮, 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 = [
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusTaking.value,
|
||||
SaleOrderStatusWaitingDelivery.value
|
||||
]
|
||||
return orderInfo.actual_amount == 0 && orderStatus.includes(orderInfo.status)
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: '去付款',
|
||||
sort: 100,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//只要没有付完款就显示
|
||||
let orderStatus = [
|
||||
SaleOrderStatusTaking.value,
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value,
|
||||
SaleOrderStatusWaitingReceipt.value,
|
||||
SaleOrderStatusAlreadyReceipt.value,
|
||||
SaleOrderStatusComplete.value
|
||||
]
|
||||
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.is_should_collect_audit && showStatus == 'detail'
|
||||
}
|
||||
},
|
||||
])
|
||||
//订单类型
|
||||
const { SaLeModeBulk, SaleModeLengthCut, SaLeModeWeightCut } = SALE_MODE
|
||||
|
||||
//显示的按钮数组
|
||||
const orderBtnsShowList: orderBtnsListParams[] = useMemo(() => {
|
||||
let list = orderBtnsList.current.filter(item => {
|
||||
return item.validatarFunc(orderInfo)
|
||||
})
|
||||
return list.sort((a, b) => a.sort - b.sort)
|
||||
}, [orderInfo])
|
||||
//注册按钮, 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 = [
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusTaking.value,
|
||||
SaleOrderStatusWaitingDelivery.value,
|
||||
]
|
||||
return orderInfo.actual_amount == 0 && orderStatus.includes(orderInfo.status)
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: '去付款',
|
||||
sort: 100,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//只要没有付完款就显示
|
||||
let orderStatus = [
|
||||
SaleOrderStatusTaking.value,
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value,
|
||||
SaleOrderStatusWaitingReceipt.value,
|
||||
SaleOrderStatusAlreadyReceipt.value,
|
||||
SaleOrderStatusComplete.value,
|
||||
]
|
||||
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) => {
|
||||
if (orderInfo.sale_mode === 1 && showStatus == 'detail') return true
|
||||
if (orderInfo.sale_mode !== 1 && showStatus == 'detail') return orderInfo.is_should_collect_audit
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
//小程序订阅
|
||||
const {ApplyGoods} = SUBSCRIPTION_MESSAGE_SCENE
|
||||
const {openSubscriptionMessage} = UseSubscriptionMessage()
|
||||
//显示的按钮数组
|
||||
const orderBtnsShowList: orderBtnsListParams[] = useMemo(() => {
|
||||
let list = orderBtnsList.current.filter((item) => {
|
||||
return item.validatarFunc(orderInfo)
|
||||
})
|
||||
return list.sort((a, b) => a.sort - b.sort)
|
||||
}, [orderInfo])
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = throttle(async (val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder()
|
||||
} else if (val == 6) {
|
||||
receiveOrder()
|
||||
} else if(val == 5) {
|
||||
applyProduct()
|
||||
} else if (val == 3) {
|
||||
bigApplyRefurn()
|
||||
} else if(val == 8) {
|
||||
applyRefund()
|
||||
//小程序订阅
|
||||
const { ApplyGoods } = SUBSCRIPTION_MESSAGE_SCENE
|
||||
const { openSubscriptionMessage } = UseSubscriptionMessage()
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = throttle(async (val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder()
|
||||
} else if (val == 6) {
|
||||
receiveOrder()
|
||||
} else if (val == 5) {
|
||||
applyProduct()
|
||||
} else if (val == 3) {
|
||||
bigApplyRefurn()
|
||||
} else if (val == 8) {
|
||||
applyRefund()
|
||||
} else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 800)
|
||||
|
||||
//大货申请退款
|
||||
const bigApplyRefurn = () => {
|
||||
Taro.showModal({
|
||||
title: '要申请退款吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
onClick?.(3)
|
||||
} else {
|
||||
onClick?.(val)
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}, 800)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//大货申请退款
|
||||
const bigApplyRefurn = () => {
|
||||
Taro.showModal({
|
||||
title: '要申请退款吗?',
|
||||
success: async function (res) {
|
||||
if(res.confirm) {
|
||||
await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value})
|
||||
onClick?.(3)
|
||||
} else {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//取消订单
|
||||
const { fetchData: cancelFetchData } = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//取消订单
|
||||
const {fetchData: cancelFetchData} = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({id: orderInfo?.orderId})
|
||||
if(res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//确认订单
|
||||
const { fetchData: receiveOrderFetchData } = ReceiveOrderApi()
|
||||
const receiveOrder = async () => {
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
alert.showLoading('收货中', true)
|
||||
let res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
} else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//确认订单
|
||||
const {fetchData: receiveOrderFetchData} = ReceiveOrderApi()
|
||||
const receiveOrder = async () => {
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
alert.showLoading('收货中', true)
|
||||
let res = await receiveOrderFetchData({sale_order_id: orderInfo?.orderId})
|
||||
if(res.success){
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
} else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//退款
|
||||
const { fetchData: fetchDataApplyRefund } = ApplyRefundApi()
|
||||
const applyRefund = async () => {
|
||||
Taro.showModal({
|
||||
title: '确定退款?',
|
||||
success: async function async(res) {
|
||||
if (res.confirm) {
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
alert.showLoading('申请中', true)
|
||||
let res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('申请成功')
|
||||
} else {
|
||||
alert.error('申请失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
onClick?.(8)
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//退款
|
||||
const {fetchData: fetchDataApplyRefund} = ApplyRefundApi()
|
||||
const applyRefund = async () => {
|
||||
Taro.showModal({
|
||||
title: '确定退款?',
|
||||
success: async function async (res) {
|
||||
if(res.confirm) {
|
||||
await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value})
|
||||
alert.showLoading('申请中', true)
|
||||
let res = await fetchDataApplyRefund({sale_order_id: orderInfo?.orderId})
|
||||
if(res.success) {
|
||||
alert.success('申请成功')
|
||||
} else {
|
||||
alert.error('申请失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
onClick?.(8)
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
//申请退货
|
||||
const applyProduct = async () => {
|
||||
if (!orderInfo?.av_return_roll) return alert.none('该订单没有可退条数')
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
goLink('/pages/applyAfterSales/index', { id: orderInfo?.orderId })
|
||||
}
|
||||
|
||||
//申请退货
|
||||
const applyProduct = async () => {
|
||||
if(!orderInfo?.av_return_roll) return alert.none('该订单没有可退条数')
|
||||
await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value})
|
||||
goLink('/pages/applyAfterSales/index',{id:orderInfo?.orderId})
|
||||
}
|
||||
//显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
//显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return {top:`-${(orderBtnsShowList.length - 3)*70 + 10}rpx`, left: `-${10}rpx`}
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3)&&<View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(!showMore)}>{!showMore?'更多':'关闭'}</Text>
|
||||
{showMore&&<View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
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> */}
|
||||
</View>}
|
||||
</View>}
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
((orderBtnsShowList.length - 3) <= index)&&<View key={item.id} className={classnames(styles.btns_item)} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
||||
)}
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{orderBtnsShowList.length > 3 && (
|
||||
<View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(!showMore)}>{!showMore ? '更多' : '关闭'}</Text>
|
||||
{showMore && (
|
||||
<View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
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> */}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
)}
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map(
|
||||
(item, index) =>
|
||||
orderBtnsShowList.length - 3 <= index && (
|
||||
<View key={item.id} className={classnames(styles.btns_item)} onClick={() => submitBtns(item.id, index)}>
|
||||
{item.label}
|
||||
</View>
|
||||
),
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
@ -1,142 +1,150 @@
|
||||
import { Input, ScrollView, Text, Textarea, View } from "@tarojs/components"
|
||||
import classnames from "classnames";
|
||||
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import Search from '@/components/search'
|
||||
import Product from '@/components/product'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import styles from './index.module.scss'
|
||||
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 { dataLoadingStatus, getFilterData } from "@/common/util";
|
||||
import LoadingCard from "@/components/loadingCard";
|
||||
import useLogin from "@/use/useLogin";
|
||||
import styles from './index.module.scss'
|
||||
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 { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
import Taro from '@tarojs/taro'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
useLogin()
|
||||
const [showPopup, setShowPopup] = useState(false)
|
||||
useLogin()
|
||||
const [showPopup, setShowPopup] = useState(false)
|
||||
|
||||
const router = useRouter()
|
||||
//搜索参数
|
||||
const [searchField, setSearchField] = useState({
|
||||
code_or_name: '',
|
||||
product_category_id: router.params.id,
|
||||
page : 1,
|
||||
size : 10,
|
||||
width: '',
|
||||
weight_density: '',
|
||||
product_kind_id: '',
|
||||
component: ''
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
Taro.setNavigationBarTitle({
|
||||
title: router.params.title || '分类页面',
|
||||
})
|
||||
}, [router])
|
||||
|
||||
//获取列表
|
||||
const [categoryList, setCategoryList] = useState<{list:any[], total:number}>({
|
||||
list:[],
|
||||
total:0
|
||||
//搜索参数
|
||||
const [searchField, setSearchField] = useState({
|
||||
code_or_name: '',
|
||||
product_category_id: router.params.id,
|
||||
page: 1,
|
||||
size: 10,
|
||||
width: '',
|
||||
weight_density: '',
|
||||
product_kind_id: '',
|
||||
component: '',
|
||||
})
|
||||
|
||||
//获取列表
|
||||
const [categoryList, setCategoryList] = useState<{ list: any[]; total: number }>({
|
||||
list: [],
|
||||
total: 0,
|
||||
})
|
||||
const { fetchData, state } = GetProductListApi()
|
||||
const getSubjectList = async () => {
|
||||
let res = await fetchData(getFilterData(searchField))
|
||||
setCategoryList({ ...categoryList, list: res.data.list, total: res.data.total })
|
||||
}
|
||||
|
||||
//监听筛选数据变化
|
||||
useEffect(() => {
|
||||
getSubjectList()
|
||||
}, [searchField])
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
const getScrolltolower = () => {
|
||||
if (categoryList.list.length < categoryList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearchField({ ...searchField, size })
|
||||
}
|
||||
}
|
||||
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: categoryList.list, total: categoryList.total, status: state.loading })
|
||||
}, [categoryList, state])
|
||||
|
||||
//获取筛选条件
|
||||
const getFiltr = (e) => {
|
||||
pageNum.current.page = 1
|
||||
setCategoryList(() => ({ list: [], total: 0 }))
|
||||
const { data } = e
|
||||
setSearchField({
|
||||
...searchField,
|
||||
width: data?.width,
|
||||
weight_density: data?.weight,
|
||||
size: 10,
|
||||
component: data?.element,
|
||||
product_kind_id: data?.seriesId,
|
||||
})
|
||||
const {fetchData, state} = GetProductListApi()
|
||||
const getSubjectList = async () => {
|
||||
let res = await fetchData(getFilterData(searchField))
|
||||
setCategoryList({...categoryList, list:res.data.list, total: res.data.total})
|
||||
formatSelectList(e)
|
||||
}
|
||||
|
||||
//筛选条件格式化
|
||||
const [selectList, setSelectList] = useState<ListProps[]>()
|
||||
const formatSelectList = (val = { data: {}, field: {} }) => {
|
||||
let data: ListProps[] = []
|
||||
for (let key in val.data) {
|
||||
if (key !== 'seriesId' && val.data[key] != '') {
|
||||
data.push({ title: val.field[key], value: val.data[key] })
|
||||
}
|
||||
}
|
||||
setSelectList([...data])
|
||||
}
|
||||
|
||||
//监听筛选数据变化
|
||||
useEffect(() => {
|
||||
getSubjectList()
|
||||
}, [searchField])
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setCategoryList(() => ({ list: [], total: 0 }))
|
||||
setSearchField((val) => ({ ...val, code_or_name: e, size: 10 }))
|
||||
}, [])
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({size: searchField.size, page: searchField.page})
|
||||
const getScrolltolower = () => {
|
||||
if(categoryList.list.length < categoryList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearchField({...searchField, size })
|
||||
}
|
||||
}
|
||||
//排序
|
||||
type sortParam = 'none' | 'top' | 'bottom'
|
||||
const sortComprehensiveRef = useRef<any>(null)
|
||||
const [sortStatus, setSortStatus] = useState<{ comprehensive: sortParam }>({
|
||||
comprehensive: 'none',
|
||||
})
|
||||
const changeSort = () => {
|
||||
setCategoryList(() => ({ list: [], total: 0 }))
|
||||
const { status, value } = sortComprehensiveRef.current.changeSort()
|
||||
setSortStatus((e) => ({ ...e, comprehensive: status, collection: 'none' }))
|
||||
setSearchField((e) => ({ ...e, abstract_sort_key: value, size: 10, page: 1 }))
|
||||
pageNum.current = { size: 10, page: 1 }
|
||||
}
|
||||
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({list:categoryList.list, total: categoryList.total, status: state.loading})
|
||||
}, [categoryList, state])
|
||||
|
||||
//获取筛选条件
|
||||
const getFiltr = (e) => {
|
||||
pageNum.current.page = 1
|
||||
setCategoryList(() => ({list:[], total:0}))
|
||||
const {data} = e
|
||||
setSearchField({
|
||||
...searchField,
|
||||
width: data?.width,
|
||||
weight_density: data?.weight,
|
||||
size: 10,
|
||||
component: data?.element,
|
||||
product_kind_id: data?.seriesId
|
||||
})
|
||||
formatSelectList(e)
|
||||
}
|
||||
|
||||
//筛选条件格式化
|
||||
const [selectList , setSelectList] = useState<ListProps[]>()
|
||||
const formatSelectList = (val = {data:{}, field:{}}) => {
|
||||
let data:ListProps[] = []
|
||||
for(let key in val.data) {
|
||||
if(key !== 'seriesId'&& val.data[key] != '') {
|
||||
data.push({title:val.field[key], value:val.data[key]})
|
||||
}
|
||||
}
|
||||
setSelectList([...data])
|
||||
}
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setCategoryList(() => ({list:[], total:0}))
|
||||
setSearchField((val) => ({...val, code_or_name:e, size:10}))
|
||||
}, [])
|
||||
|
||||
//排序
|
||||
type sortParam = 'none'|'top'|'bottom'
|
||||
const sortComprehensiveRef = useRef<any>(null)
|
||||
const [sortStatus, setSortStatus] = useState<{comprehensive:sortParam}>({
|
||||
comprehensive: 'none'
|
||||
})
|
||||
const changeSort = () => {
|
||||
setCategoryList(() => ({list:[], total:0}))
|
||||
const {status, value} = sortComprehensiveRef.current.changeSort()
|
||||
setSortStatus((e) => ({...e, comprehensive: status, collection: 'none'}))
|
||||
setSearchField((e) => ({...e, abstract_sort_key: value, size:10, page:1}))
|
||||
pageNum.current = {size: 10, page: 1}
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<View className={styles.search}>
|
||||
<Search placeIcon="out" showBtn={true} btnStyle={{color: '#007AFF'}} changeOnSearch={getSearchData} debounceTime={300}/>
|
||||
</View>
|
||||
<View className={styles.filter}>
|
||||
<View className={styles.filter_all}>
|
||||
<View className={styles.text_one} onClick={() => changeSort()}>
|
||||
<Text>综合</Text>
|
||||
<SortBtn status={sortStatus.comprehensive} ref={sortComprehensiveRef} sortValue={{desc: '1', asc: '-1'}}/>
|
||||
</View>
|
||||
<View className={styles.text_two} onClick={() => setShowPopup(true)}>
|
||||
<Text>筛选</Text>
|
||||
<Text className={classnames('iconfont icon-bianji_bianji', styles.miconfont)}></Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.filter_btns}>
|
||||
<SelectData list={selectList}/>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.list}>
|
||||
<InfiniteScroll selfonScrollToLower={() => getScrolltolower()} statusMore={statusMore}>
|
||||
<Product desStatus={false} productList={categoryList.list}/>
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<Filter show={showPopup} onClose={() => setShowPopup(false)} onFiltr={getFiltr}/>
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<View className={styles.search}>
|
||||
<Search placeIcon='out' showBtn={true} btnStyle={{ color: '#007AFF' }} changeOnSearch={getSearchData} debounceTime={300} />
|
||||
</View>
|
||||
<View className={styles.filter}>
|
||||
<View className={styles.filter_all}>
|
||||
<View className={styles.text_one} onClick={() => changeSort()}>
|
||||
<Text>综合</Text>
|
||||
<SortBtn status={sortStatus.comprehensive} ref={sortComprehensiveRef} sortValue={{ desc: '1', asc: '-1' }} />
|
||||
</View>
|
||||
<View className={styles.text_two} onClick={() => setShowPopup(true)}>
|
||||
<Text>筛选</Text>
|
||||
<Text className={classnames('iconfont icon-bianji_bianji', styles.miconfont)}></Text>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
<View className={styles.filter_btns}>
|
||||
<SelectData list={selectList} />
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.list}>
|
||||
<InfiniteScroll selfonScrollToLower={() => getScrolltolower()} statusMore={statusMore}>
|
||||
<Product desStatus={false} productList={categoryList.list} />
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<Filter show={showPopup} onClose={() => setShowPopup(false)} onFiltr={getFiltr} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
length: (citem.length / 100).toString(),
|
||||
weight: formatWeightDiv(citem.actual_weight || citem.estimate_weight).toString(),
|
||||
sale_price: formatPriceDiv(citem.sale_price).toString(),
|
||||
total_price: formatPriceDiv(citem.estimate_amount).toString(),
|
||||
total_price: formatPriceDiv(citem.total_sale_price || citem.estimate_amount).toString(), //小计
|
||||
weight_error: formatWeightDiv(citem.weight_error).toString(),
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user