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