Merge branch 'dev' of http://git.online.zzfzyc.com/mp/EShop into dev
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
|
||||
.main{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
.reduce, .plus{
|
||||
font-size: $font_size_big;
|
||||
color: $color_main;
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content:center;
|
||||
font-size: 50px;
|
||||
background-color: $color_main;
|
||||
color: #fff;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.input{
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
background-color: #fff;
|
||||
padding: 5px 10px;
|
||||
box-sizing: border-box;
|
||||
width: 106px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
input{
|
||||
font-size: $font_size_medium;
|
||||
}
|
||||
.unit{
|
||||
font-size: $font_size_min;
|
||||
color: $color_font_two;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { Input, View } from "@tarojs/components"
|
||||
import { useEffect, useMemo, useRef, useState } from "react"
|
||||
import Big from 'big.js'
|
||||
import styles from "./index.module.scss"
|
||||
type params = {
|
||||
minNum?: number, //最小值
|
||||
maxNum?: number, //最大值
|
||||
step?: number, //步长
|
||||
defaultNum?: number, //默认值
|
||||
digits?: number //多少位小数
|
||||
onChange?:(val:number) => void,
|
||||
onBlue?:(val:number) => void, //失去焦点触发
|
||||
onClickBtn?:(val:number) => void,
|
||||
unit?: string
|
||||
}
|
||||
export default ({minNum = 0, maxNum = 100, step=1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = ''}: params) => {
|
||||
const [value, setValue] = useState<any>({count:defaultNum})
|
||||
|
||||
const onPlus = () => {
|
||||
let {count} = value
|
||||
let num_res = Big(count).add(step).toNumber()
|
||||
num_res = num_res >= maxNum?maxNum:num_res
|
||||
num_res = formatDigits(num_res)
|
||||
setValue({...value, count:num_res})
|
||||
onChange?.(parseFloat(num_res))
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
const minus = () => {
|
||||
let {count} = value
|
||||
let num_res = Big(count).minus(step).toNumber()
|
||||
num_res = num_res < minNum?0:num_res
|
||||
setValue({...value, count:num_res})
|
||||
onChange?.(parseFloat(num_res))
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
|
||||
//保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = num + ''
|
||||
if(num.includes('.')&&digits > 0) {
|
||||
console.log('num::',num.includes('.'))
|
||||
let res = num.split('.')
|
||||
let last_num = res[1].substr(0, digits)
|
||||
return res[0] + '.' + last_num
|
||||
}
|
||||
return parseFloat(num)
|
||||
}
|
||||
|
||||
//检查数据
|
||||
const checkData = (val) => {
|
||||
let num = parseFloat(val)
|
||||
if(num > maxNum) return maxNum
|
||||
if(num < minNum) return minNum
|
||||
return val
|
||||
}
|
||||
|
||||
|
||||
const onInputEven = (e) => {
|
||||
let res = e.detail.value
|
||||
if(res === '') {
|
||||
setValue({...value, count:minNum})
|
||||
onChange?.(minNum)
|
||||
}
|
||||
else if(!isNaN(Number(res))) {
|
||||
let count = formatDigits(res)
|
||||
count = checkData(count)
|
||||
setValue({...value, count})
|
||||
onChange?.(parseFloat(count as string))
|
||||
} else {
|
||||
let num = parseFloat(res)
|
||||
if(!isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
setValue({...value, count})
|
||||
onChange?.(count as number)
|
||||
} else {
|
||||
setValue({...value, count:defaultNum})
|
||||
onChange?.(defaultNum)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const onBluerEven = () => {
|
||||
let num = parseFloat(value.count)
|
||||
if(!isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
setValue({...value, count})
|
||||
onBlue?.(count as number)
|
||||
} else {
|
||||
setValue({...value, count:defaultNum})
|
||||
onBlue?.(defaultNum)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<View className={styles.reduce} onClick={() => minus()}>-</View>
|
||||
<View className={styles.input}>
|
||||
<Input
|
||||
value={String(value.count)}
|
||||
onInput={onInputEven}
|
||||
onBlur={onBluerEven}
|
||||
type='digit'
|
||||
/>
|
||||
<View className={styles.unit}>{unit}</View>
|
||||
</View>
|
||||
<View className={styles.plus} onClick={() => onPlus()}>+</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ScrollView, View } from "@tarojs/components"
|
||||
import { memo, ReactNode, useState } from "react"
|
||||
import { memo, ReactNode, useMemo, useState } from "react"
|
||||
import style from "./index.module.scss"
|
||||
import DotLoading from "@/components/dotLoading"
|
||||
import LoadingCard from "../loadingCard"
|
||||
@@ -64,6 +64,13 @@ export default memo(({
|
||||
selfOnRefresherAbort?.()
|
||||
}
|
||||
|
||||
//返回顶部
|
||||
const scrollTop = useMemo(() => {
|
||||
if(statusMore == 0) {
|
||||
return 0.1
|
||||
}
|
||||
},[statusMore])
|
||||
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
@@ -81,6 +88,7 @@ export default memo(({
|
||||
onRefresherRestore = {() => refresherRestore()}
|
||||
onRefresherAbort = {() => refresherAbort()}
|
||||
refresherBackground ='#F8F8F8'
|
||||
scrollTop={scrollTop}
|
||||
>
|
||||
{!moreStatus&&<>
|
||||
<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.btns_list{
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 30px;
|
||||
// margin-top: 30px;
|
||||
.btns_item{
|
||||
width: 152px;
|
||||
height: 72px;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { CancelOrderApi } from "@/api/order"
|
||||
import { alert } from "@/common/common"
|
||||
import { ORDER_STATUS } from "@/common/enum"
|
||||
import { View } from "@tarojs/components"
|
||||
import Taro from "@tarojs/taro"
|
||||
import { useCallback, useRef, memo } from "react"
|
||||
@@ -7,63 +8,83 @@ import styles from './index.module.scss'
|
||||
|
||||
type Param = {
|
||||
orderInfo: {
|
||||
status?: number, //订单状态
|
||||
status: number, //订单状态
|
||||
orderId: number, //订单id
|
||||
payModel: number, //支付方式
|
||||
realPayPrice: number, //实付金额
|
||||
pendingPayPrice: number, //待付金额
|
||||
},
|
||||
actual_amount: number, //实付金额
|
||||
wait_pay_amount: number, //待付金额
|
||||
}|null,
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
// export const OrderBtnsemus = [{id:1, label:'取消订单'},{id:2, label:'去付款'},{id:3, label:'申请退款'},{id:4, label:'查看物流'}, {id:5, label:'申请退货'}, {id:6, label:'确认收货'}, {id:7, label:'再次购买'}]
|
||||
export default memo(({orderInfo, onClick}:Param) => {
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusCancel,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt
|
||||
} = ORDER_STATUS
|
||||
//订单按钮按订单状态归类
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [0, 1, 2, 3, 4], //取消订单按钮对应: 待接单,待配布,已配布, 待付款, 待发货
|
||||
value: [SaleOrderStatusBooking.value, SaleOrderStatusArranging.value, SaleOrderStatusArranged.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value], //取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [3, 4], //去付款按钮对应:待付款, 待发货
|
||||
value: [SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], //去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [4], //取消订单按钮对应: 待发货
|
||||
value: [SaleOrderStatusWaitingDelivery.value], //取消订单按钮对应: 待发货
|
||||
label: '申请退款'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [5, 6, 7, 8], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [5, 6, 8], //取消订单按钮对应: 待收货, 已收货, 已退款
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], //取消订单按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [5], //取消订单按钮对应: 待收货
|
||||
value: [SaleOrderStatusWaitingReceipt.value], //取消订单按钮对应: 待收货
|
||||
label: '确认收货'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [5,6,7,8], //取消订单按钮对应: 待收货,已收货,已完成, 已退款
|
||||
value: [SaleOrderStatusWaitingReceipt.value,SaleOrderStatusAlreadyReceipt.value,SaleOrderStatusComplete.value,SaleOrderStatusRefund.value], //取消订单按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买'
|
||||
}
|
||||
])
|
||||
//判断是否显示该按钮
|
||||
const orderBtnsShow = useCallback((item, status) => {
|
||||
if(item.id == 1) {
|
||||
return( orderInfo.realPayPrice == 0 && status <= 4) //在代发货之前没有付过款
|
||||
}
|
||||
if(item.id == 2) {
|
||||
return( orderInfo.pendingPayPrice != 0 && status <= 4) //在代发货之前没有付完款
|
||||
const orderBtnsShow = useCallback((item) => {
|
||||
if(orderInfo) {
|
||||
if(item.id == 1) {
|
||||
//取消订单按钮
|
||||
return( orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) //在代发货之前没有付过款
|
||||
} else if (item.id == 2) {
|
||||
//去付款按钮
|
||||
return( orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) //只要没有付完款就显示
|
||||
} else if(item.id == 3) {
|
||||
//申请退款
|
||||
return (orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //在代发货之前付过款
|
||||
} else {
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
}
|
||||
return item.value.includes(status)
|
||||
},[])
|
||||
},[orderInfo])
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = (val) => {
|
||||
@@ -73,12 +94,12 @@ export default memo(({orderInfo, onClick}:Param) => {
|
||||
|
||||
//取消订单
|
||||
const {fetchData: cancelFetchData} = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({id: orderInfo.orderId})
|
||||
let res = await cancelFetchData({id: orderInfo?.orderId})
|
||||
if(res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
@@ -94,8 +115,8 @@ export default memo(({orderInfo, onClick}:Param) => {
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{orderBtnsList.current.map((item, index) =>
|
||||
orderBtnsShow(item, status)&&<View className={styles.btns_item} onClick={() => submitBtns(item.id)}>{item.label}</View>
|
||||
{orderBtnsList.current.map((item) =>
|
||||
orderBtnsShow(item)&&<View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id)}>{item.label}</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -3,25 +3,25 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 62px;
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px solid #F0F0F0;
|
||||
.searchInput_title {
|
||||
width: 150px;
|
||||
min-width: 145px;
|
||||
min-height: 50px;
|
||||
font-size: 28px;
|
||||
border-right: 1px solid #F0F0F0;
|
||||
color: $color_font_two;
|
||||
margin-right: 20px;
|
||||
padding-left: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
// &::before{
|
||||
// content: "";
|
||||
// height: 50px;
|
||||
// width: 1px;
|
||||
// background-color: #F0F0F0;
|
||||
// }
|
||||
position: relative;
|
||||
&::before{
|
||||
content: "";
|
||||
height: 30px;
|
||||
width: 1px;
|
||||
background-color: #F0F0F0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
.searchInput_con{
|
||||
flex:1;
|
||||
|
||||
@@ -13,7 +13,8 @@ type Params = {
|
||||
clickOnInput?: () => void,
|
||||
children?: ReactNode
|
||||
height?: number,
|
||||
titleStyle?: Object
|
||||
titleStyle?: Object,
|
||||
styleObj?: Object
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ export default memo((props: Params) => {
|
||||
return {}
|
||||
}, [showBorder])
|
||||
return (
|
||||
<View className={styles.searchInput_main} style={{height: height + 'rpx', ...stylen}}>
|
||||
<View className={styles.searchInput_main} style={{height: height + 'rpx', ...stylen,}}>
|
||||
{showTitle&&<View className={styles.searchInput_title} style={titleStyle}>{title}</View>}
|
||||
<View className={styles.searchInput_con}>
|
||||
{!props.children&&<Input disabled={disabled} placeholder={placeholder} onClick={() => clickOnInput?.()} onInput={(e) => changeOnInput?.(e.detail.value)}/>
|
||||
|
||||
@@ -202,6 +202,7 @@ export default ({show = false, onClose}: param) => {
|
||||
} else {
|
||||
let ids = selectIds.current.join('-')
|
||||
setParam({ids, sale_mode:selectIndex})
|
||||
closePopup()
|
||||
goLink('/pages/order/comfirm')
|
||||
}
|
||||
}, 500)
|
||||
@@ -224,7 +225,7 @@ export default ({show = false, onClose}: param) => {
|
||||
</View>
|
||||
<View className={styles.con}>
|
||||
{loading&&<LoadingCard/>}
|
||||
{!loading&&list?.length > 0&&<InfiniteScroll moreStatus={false} >
|
||||
{!loading&&list?.length > 0&&<InfiniteScroll moreStatus={false} >
|
||||
<View className={styles.product_list}>
|
||||
{list?.map((item, index) => {
|
||||
return <View key={index} className={classnames(styles.product_item, (selectIndex!=-1&&selectIndex!= item.sale_mode)&&styles.no_product_item_select)}>
|
||||
|
||||
Reference in New Issue
Block a user