购物车添加数量组件
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
navigationBarTitleText: '我的收藏',
|
||||
enableShareAppMessage: true,
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import Search from "@/components/search"
|
||||
import { View } from "@tarojs/components"
|
||||
import styles from './index.module.scss'
|
||||
export default () => {
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<View className={styles.search}>
|
||||
<Search style={{width: '100%'}} debounceTime={300} changeOnSearch={(e) => console.log(e)} placeholder="请输入面料关键词" placeIcon="out" showBtn={true} />
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -296,7 +296,7 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
// </InfiniteScroll>}
|
||||
<View className={styles.color_con}>
|
||||
<VirtualList
|
||||
height={500} /* 列表的高度 */
|
||||
height={400} /* 列表的高度 */
|
||||
width='100%' /* 列表的宽度 */
|
||||
itemData={list} /* 渲染列表的数据 */
|
||||
itemCount={list.length} /* 渲染列表的长度 */
|
||||
|
||||
@@ -20,7 +20,6 @@ export type AddressInfoParam = {
|
||||
}
|
||||
type Param = {
|
||||
onSelect?: (val:any) => void, //选择地址
|
||||
defaultValue?: AddressInfoParam|null, //默认值
|
||||
disabled?: false|true, //true禁用后只用于展示
|
||||
onChangeShipmentMode?: (val: number) => void, //返回收货方式
|
||||
status?: 1|2, //1确认订单时使用, 2订单流程
|
||||
@@ -35,7 +34,7 @@ type Param = {
|
||||
}
|
||||
}
|
||||
|
||||
export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, status = 2}: Param, ref) => {
|
||||
export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, status = 2, disabled = false}: Param, ref) => {
|
||||
|
||||
|
||||
const [addressInfo, setAddressInfo] = useState<any>()
|
||||
@@ -46,6 +45,7 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat
|
||||
}
|
||||
}, [orderInfo])
|
||||
|
||||
|
||||
//地址格式
|
||||
const formatAddress = useMemo(() => {
|
||||
if(addressInfo?.province_name) {
|
||||
@@ -58,7 +58,7 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat
|
||||
//打开地址列表
|
||||
const [showAddressList, setShowAddressList] = useState(false)
|
||||
const changeShow = () => {
|
||||
if(receivingStatus == 2 && !logisticsShow)
|
||||
if(receivingStatus == 2 && !logisticsShow && !disabledSelect)
|
||||
setShowAddressList(() => true)
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat
|
||||
const {fetchData: shipmentModeFetchData} = EditSaleOrderShipmentModeApi()
|
||||
const onReceivingStatus = (value, e) => {
|
||||
e.stopPropagation()
|
||||
if(!disabledSelect) return false
|
||||
changeReceivingStatus(value)
|
||||
}
|
||||
const changeReceivingStatus = debounce(async (value) => {
|
||||
@@ -123,9 +124,21 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusCancel
|
||||
SaleOrderStatusCancel,
|
||||
} = ORDER_STATUS
|
||||
|
||||
//禁用
|
||||
const disabledSelect = useMemo(() => {
|
||||
let statusList = [
|
||||
SaleOrderStatusWaitingReceipt.value,
|
||||
SaleOrderStatusAlreadyReceipt.value,
|
||||
SaleOrderStatusComplete.value,
|
||||
SaleOrderStatusRefund.value,
|
||||
SaleOrderStatusCancel.value,
|
||||
]
|
||||
return (statusList.includes(orderInfo?.status!)||disabled)
|
||||
}, [orderInfo, disabled])
|
||||
|
||||
//根据订单状态判断是否显示物流
|
||||
const logisticsShowList = [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value, SaleOrderStatusCancel.value]
|
||||
const logisticsShow = useMemo(() => {
|
||||
|
||||
@@ -4,12 +4,14 @@ import {
|
||||
CancelOrderApi
|
||||
} from "@/api/order";
|
||||
import { GetOrderPayApi } from "@/api/orderPay";
|
||||
import { AddShoppingCartApi } from "@/api/shopCart";
|
||||
import { alert, goLink } from "@/common/common";
|
||||
import { ORDER_STATUS } from "@/common/enum";
|
||||
import { formatDateTime, formatPriceDiv } from "@/common/fotmat";
|
||||
import OrderBtns from "@/components/orderBtns";
|
||||
import Popup from "@/components/popup";
|
||||
import SearchInput from "@/components/searchInput";
|
||||
import ShopCart from "@/components/shopCart";
|
||||
import { Text, Textarea, View } from "@tarojs/components"
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro";
|
||||
import classnames from "classnames";
|
||||
@@ -97,7 +99,8 @@ import styles from './index.module.scss'
|
||||
name: orderDetail?.target_user_name,
|
||||
phone: orderDetail?.target_user_phone,
|
||||
shipment_mode: orderDetail?.shipment_mode,
|
||||
id: orderDetail?.id
|
||||
id: orderDetail?.id,
|
||||
sale_mode: orderDetail?.sale_mode,
|
||||
}
|
||||
|
||||
}, [orderDetail])
|
||||
@@ -152,6 +155,9 @@ import styles from './index.module.scss'
|
||||
toPay()
|
||||
} else if(val == 3) {
|
||||
setRefundShow(true)
|
||||
} else if(val == 7) {
|
||||
//再购
|
||||
addShopCart()
|
||||
}
|
||||
|
||||
}, [orderDetail])
|
||||
@@ -199,6 +205,40 @@ import styles from './index.module.scss'
|
||||
setRefundShow(false)
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
//添加购物车
|
||||
const [showCart, setShowCart] = useState(false)
|
||||
const {fetchData:addFetchData} = AddShoppingCartApi()
|
||||
const addShopCart = async () => {
|
||||
let color_list:{product_color_id: number, roll?: number, length?: number}[] = []
|
||||
orderDetail?.product_list.map(pitem => {
|
||||
pitem?.product_colors.map(citem => {
|
||||
if(orderDetail?.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: orderDetail?.sale_mode,
|
||||
color_list
|
||||
})
|
||||
if(state.success) {
|
||||
Taro.showToast({
|
||||
title:'已加入购物车'
|
||||
})
|
||||
setShowCart(true)
|
||||
} else {
|
||||
Taro.showToast({
|
||||
icon:'none',
|
||||
title: state.msg
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.order_main}>
|
||||
<OrderState orderInfo={orderDetail} onRefresh={refresh}/>
|
||||
@@ -238,6 +278,7 @@ import styles from './index.module.scss'
|
||||
</Popup>
|
||||
<Payment onSubmitSuccess={onPaySuccess} show={payMentShow} onClose={closePayShow} orderInfo={orderDetail} />
|
||||
<ApplyRefund show={refundShow} onClose={applyRefundClose}/>
|
||||
<ShopCart show={showCart} onClose={() => setShowCart(false)}/>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ export default memo(({return_address = '', return_phone = '', onLogistics, stage
|
||||
//是否显示地址
|
||||
const showAddress = useMemo(() => {
|
||||
return stage != ReturnStageApplying.value
|
||||
}, [])
|
||||
}, [stage])
|
||||
|
||||
//上传物流
|
||||
const upLogistics = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user