diff --git a/src/api/salesAfterOrder.ts b/src/api/salesAfterOrder.ts index 1b08495..1755ce0 100644 --- a/src/api/salesAfterOrder.ts +++ b/src/api/salesAfterOrder.ts @@ -48,4 +48,15 @@ export const GetSaleOrderListApi = () => { url: `/v1/mall/returnApplyOrder/upload`, method: "put", }) -} \ No newline at end of file +} + + +/** + * 售后货物状况 + */ + export const ReturnGoodsStatusApi = () => { + return useRequest({ + url: `/v1/mall/enum/return/goodsStatus`, + method: "get", + }) +} diff --git a/src/common/constant.js b/src/common/constant.js index 42b4b0b..ba43cfa 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -10,8 +10,8 @@ // export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境 // export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境 // export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞 -export const BASE_URL = `http://192.168.1.224:50002/lymarket` // 添 -// export const BASE_URL = `http://192.168.1.15:50001/lymarket` // 杰 +// export const BASE_URL = `http://192.168.1.224:50002/lymarket` // 添 +export const BASE_URL = `http://192.168.1.15:50001/lymarket` // 杰 // CDN // 生成密钥 diff --git a/src/components/shopCart/index copy.tsx b/src/components/shopCart/index copy.tsx deleted file mode 100644 index 504abbd..0000000 --- a/src/components/shopCart/index copy.tsx +++ /dev/null @@ -1,275 +0,0 @@ -import {Image, ScrollView, View } from "@tarojs/components" -import Popup from "@/components/popup" -import classnames from "classnames"; -import MCheckbox from "@/components/checkbox"; -import LoadingCard from "@/components/loadingCard"; -import InfiniteScroll from "@/components/infiniteScroll"; -import styles from "./index.module.scss" -import { useCallback, useEffect, useMemo, useRef, useState } from "react"; -import Taro from "@tarojs/taro"; -import { alert, goLink } from "@/common/common"; -import {GetShoppingCartApi, DelShoppingCartApi} from "@/api/shopCart" -import { formatHashTag, formatImgUrl, formatPriceDiv } from "@/common/fotmat"; -import { setParam } from "@/common/system"; -import { debounce } from "@/common/util"; - -type param = { - show?: true|false, - onClose?: () => void -} -export default ({show = false, onClose}: param) => { - const selectList = [ - // {value:-1, title:'不限', unit:'', eunit:''}, - {value:0, title:'大货', unit:'件', eunit:'kg'}, - {value:1,title:'剪板', unit:'米', eunit:'m'}, - {value:2,title:'散剪', unit:'米', eunit:'kg'}, - - ] - - const [selectIndex, setSelectIndex] = useState(0) - const selectProduct = (index:number) => { - setSelectIndex(index) - } - - useEffect(() => { - resetList() - setSelectStatus(true) - }, [selectIndex]) - - //重置勾选数据 - const resetList = () => { - list?.map(item => { - if(selectIndex == item.sale_mode || selectIndex == -1) { - item.select = true - } else { - item.select = false - } - }) - setList([...list]) - } - - //获取数据 - const [list, setList] = useState([]) - const [loading, setLoading] = useState(false) - const {fetchData} = GetShoppingCartApi() - const getShoppingCart = async () => { - setLoading(true) - const {data} = await fetchData() - let color_list = data.color_list||[] - color_list.reverse() - initList(color_list) - setList(color_list) - setLoading(false) - } - - //初始化全部数据 - const initList = (color_list) => { - color_list?.map(item => { - if(selectIndex == item.sale_mode) item.select = true - }) - } - - //显示是展示数据 - useEffect(() => { - if(!show) { - setList([]) - setSelectIndex(0) - } else { - getShoppingCart() - } - }, [show]) - - useEffect(() => { - return () => { - setList([]) - } - }, []) - - const [showPopup, setShowPopup] = useState(false) - useEffect(() => { - setShowPopup(show) - }, [show]) - - //全选反选 - const [selectStatus, setSelectStatus] = useState(false) - const selectAll = () => { - list.map(item => { - if(selectIndex == item.sale_mode || selectIndex == -1) - item.select = !selectStatus - }) - setSelectStatus(!selectStatus) - setList([...list]) - } - - //checkbox选中回调 - const selectCallBack = (item) => { - item.select = true - checkSelect() - setList([...list]) - } - - //checkbox选中判断是否全部选中,全部选中后是全选,否则反选 - const checkSelect = () => { - let list_count = 0 - let select_count = 0 - list?.map(item => { - if(selectIndex == -1 || selectIndex == item.sale_mode) { - list_count ++ - if(item.select) select_count++ - } - }) - setSelectStatus(select_count == list_count) - } - - //checkbox关闭回调 - const colseCallBack = (item) => { - item.select = false - checkSelect() - setList([...list]) - } - - //popup关闭 - const closePopup = () => { - onClose?.() - setShowPopup(false) - } - - //删除购物车内容 - const {fetchData:delShopFetchData} = DelShoppingCartApi() - const delSelect = () => { - Taro.showModal({ - content: '删除所选商品?', - success: async function (res) { - if (res.confirm) { - getSelectId() - const res = await delShopFetchData({id:selectIds.current}) - if(res.success) { - getShoppingCart() - Taro.showToast({ - title: '成功', - icon: 'success', - }) - } else { - Taro.showToast({ - title: res.msg, - icon: 'none', - }) - } - - } else if (res.cancel) { - console.log('用户点击取消') - } - } - }) - } - - //获取面料选中的id - const selectIds = useRef([]) - const getSelectId = () => { - selectIds.current = [] - list?.map(item => { - if(selectIndex == -1 || selectIndex == item.sale_mode) { - item.select&&selectIds.current.push(item.id) - } - }) - } - - //格式化金额 - const formatPirce = useCallback((price) => { - return Number(formatPriceDiv(price)) - }, []) - - //格式化数量 - const formatCount = useCallback((item) => { - return item.sale_mode == 0? item.roll + '件': (item.length/100) + 'm' - }, []) - - //预估金额 - const estimatePrice = useMemo(() => { - let count = 0 - list.map(item => { - if(item.select) count += item.estimate_amount - }) - return Number(formatPriceDiv(count)) - },[list]) - - //去结算 - const orderDetail = debounce(() => { - getSelectId() - if(selectIds.current.length == 0) { - alert.error('请选择面料') - } else { - let ids = selectIds.current.join('-') - setParam({ids, sale_mode:selectIndex}) - closePopup() - goLink('/pages/order/comfirm') - } - }, 500) - - return ( - - closePopup()} > - - - {!selectStatus?'全选':'反选'} - - - 删除所选 - - - - {selectList.map((item) => { - return selectProduct(item.value)} className={classnames(styles.search_item, (selectIndex==item.value)&&styles.search_item_select)}>{item.title} - })} - - - {loading&&} - {!loading&&list?.length > 0&& - - {list?.map((item, index) => { - return - - selectCallBack(item)} onClose={() => colseCallBack(item)}/> - - - - - - {formatHashTag(item.product_code, item.product_name)} - {item.product_color_code +' ' + item.product_color_name} - {item.sale_mode_name} - - - {formatPirce(item.sale_price)}/{selectList[selectIndex].eunit} - ×{formatCount(item)} - - - })} - - } - {!loading&&list?.length == 0 && - 暂未选择商品 - 去选购 - } - - - - - - - - - {estimatePrice} - 预估金额 - - orderDetail()}> - 去结算 - - - - - - - ) -} - diff --git a/src/components/shopCart/index.module.scss b/src/components/shopCart/index.module.scss index 008bf06..dcccd27 100644 --- a/src/components/shopCart/index.module.scss +++ b/src/components/shopCart/index.module.scss @@ -164,6 +164,7 @@ justify-content: center; padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom); + z-index: 999; .buy_con{ width: 702px; height: 95px; diff --git a/src/components/shopCart/index.tsx b/src/components/shopCart/index.tsx index 2af1202..905ef9d 100644 --- a/src/components/shopCart/index.tsx +++ b/src/components/shopCart/index.tsx @@ -52,7 +52,6 @@ export default ({show = false, onClose}: param) => { const [loading, setLoading] = useState(false) const {fetchData} = GetShoppingCartApi() const getShoppingCart = async () => { - setLoading(true) const {data} = await fetchData() let color_list = data.color_list||[] initList(color_list) @@ -74,6 +73,7 @@ export default ({show = false, onClose}: param) => { setList([]) setSelectIndex(0) } else { + setLoading(true) getShoppingCart() } }, [show]) @@ -206,7 +206,7 @@ export default ({show = false, onClose}: param) => { } }) let all_count_text = selectIndex == 0?all_count + '条': (all_count/100) + '米' - return {price: Number(formatPriceDiv(estimate_amount)), countText: `已选${product_list.size}种面料,${color_count}个颜色,共${all_count_text}`, color_count} + return {price: Number(formatPriceDiv(estimate_amount)).toFixed(2), countText: `已选${product_list.size}种面料,${color_count}个颜色,共${all_count_text}`, color_count} },[list]) @@ -226,18 +226,16 @@ export default ({show = false, onClose}: param) => { //计数组件-当后端修改完成才修改前端显示 const {fetchData: fetchDataUpdateShoppingCart} = UpdateShoppingCartApi() const [UpdateShoppingCartLoading, setUpdateShoppingCartLoading] = useState(false) - const getInputValue = async (num, item) => { + const getInputValue = debounce(async (num, item) => { let roll = item.sale_mode == 0?parseFloat(num):0 let length = item.sale_mode != 0?(parseFloat(num)*100):0 setUpdateShoppingCartLoading(() => true) let res = await fetchDataUpdateShoppingCart({id: item.id, roll, length}) setUpdateShoppingCartLoading(() => false) if(res.success) { - item.count = parseFloat(num) - setList([...list]) + getShoppingCart() } - - } + }, 300) return ( @@ -275,7 +273,7 @@ export default ({show = false, onClose}: param) => { {formatPirce(item.sale_price)}/{selectList[selectIndex].eunit} - {/* ×{formatCount(item)} */} + {/* ×{formatCount(item)}{selectList[selectIndex].unit} */} getInputValue(e, item)} diff --git a/src/pages/applyAfterSales/components/reasonPopup/index.tsx b/src/pages/applyAfterSales/components/reasonPopup/index.tsx index fc7ba76..6b1f1ef 100644 --- a/src/pages/applyAfterSales/components/reasonPopup/index.tsx +++ b/src/pages/applyAfterSales/components/reasonPopup/index.tsx @@ -3,39 +3,22 @@ import { ScrollView, Text, View } from "@tarojs/components"; import { memo, useMemo } from "react"; import styles from './index.module.scss' -type ReasonParam = 1|2|3 //1 退货原因 2 货物状况 3 退货说明 //原因选择 type ReasonInfoParam = { show?: boolean, onClose?: () => void, - status: ReasonParam + title?: string, + list?: {id:number, name:string}[] } -export default memo(({show = false, onClose, status}: ReasonInfoParam) => { - const title = useMemo(() => { - if(status == 1) return '退货原因' - if(status == 2) return '货物状况' - if(status == 3) return '退货说明' - },[status]) +export default memo(({show = false, onClose, title = '', list= []}: ReasonInfoParam) => { + return ( - + {title} - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 + {list.map(item => {item.name} )} diff --git a/src/pages/applyAfterSales/index.tsx b/src/pages/applyAfterSales/index.tsx index 44f3b95..9698934 100644 --- a/src/pages/applyAfterSales/index.tsx +++ b/src/pages/applyAfterSales/index.tsx @@ -7,7 +7,7 @@ import OtherReason from "./components/otherReason"; import { useDidShow, useRouter } from "@tarojs/taro"; import { GetSaleOrderDetailApi } from "@/api/order"; import KindList from "./components/kindList" -import { ReturnApplyOrderApi } from "@/api/salesAfterOrder"; +import { ReturnApplyOrderApi, ReturnGoodsStatusApi } from "@/api/salesAfterOrder"; import { alert, goLink } from "@/common/common"; import UploadImage from "@/components/uploadImage" import TextareaEnhance from "@/components/textareaEnhance"; @@ -76,9 +76,11 @@ export default () => { //退货选择弹窗 - const [showReason, setShowReason] = useState<{show:true|false, status:ReasonParam}>({show:false, status:1}) + const [showReason, setShowReason] = useState<{show:true|false, title: string}>({show:false, title: ''}) const closeReason = useCallback(() => setShowReason({...showReason, show:false}), []) - const onShowReason = (status) => setShowReason({...showReason, status, show:true}) + const onShowReason = (status) => { + setShowReason({...showReason, show:true}) + } //面料数据 let roll_list = useRef({}) @@ -143,7 +145,18 @@ export default () => { onSubmitData() } } - + + const [returnGoodsInfo, setReturnGoodsInfo] = useState<{title:string, list: any[]}>({title:'', list:[]}) + //售后货物状况 + const {fetchData: fetchDataGoodsStatus} = ReturnGoodsStatusApi() + const getReturnGoodsStatus = async () => { + let res = await fetchDataGoodsStatus() + setReturnGoodsInfo((e) => ({...e, title: '售后货物状况', list:res.data?.list||[]})) + } + useEffect(() => { + getReturnGoodsStatus() + }, []) + return ( @@ -192,7 +205,7 @@ export default () => { onSubmit(2)}>确认 - + ) } \ No newline at end of file diff --git a/src/pages/details/components/orderCount/index.module.scss b/src/pages/details/components/orderCount/index.module.scss index c22118d..705cf29 100644 --- a/src/pages/details/components/orderCount/index.module.scss +++ b/src/pages/details/components/orderCount/index.module.scss @@ -72,6 +72,9 @@ padding-bottom:151px; } .color_con{ + .virtual_list{ + padding-bottom: 300px; + } .item { display: flex; justify-content: space-between; diff --git a/src/pages/details/components/orderCount/index.tsx b/src/pages/details/components/orderCount/index.tsx index 78166e7..d06a1c4 100644 --- a/src/pages/details/components/orderCount/index.tsx +++ b/src/pages/details/components/orderCount/index.tsx @@ -50,20 +50,14 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param) //获取面料颜色列表 const {fetchData:colorFetchData, state: colorState} = GetColorList() const [list, setList] = useState([]) - const [loading, setLoading] = useState(false) const condition = useRef({physical_warehouse:adminUserInfo?.physical_warehouse, sale_mode:selectIndex, product_id:0, code_or_name:null}) const getColorList = async () => { - setLoading(() => true) let {data} = await colorFetchData(getFilterData(condition.current)) let lists = initList(data.list) setList(() => [...lists]) - setLoading(() => false) } const [showPopup, setShowPopup] = useState(false) - useEffect(() => { - console.log('colorState::',colorState) - }, [colorState]) //显示获取 useEffect(() => { @@ -206,32 +200,35 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param) const Rows = memo(({id, index, style, data}:any) => { let item = data[index] return ( - - - - - - {formatHashTag(item.code, item.name)} - - {formatPrice(item)} + <> + {item&& + + - - - {!item.show&& onAdd(item)}>添加 - || - getInputValue(e, item)} - defaultNum={item.count} - step={selectList[selectIndex].step} - digits={selectList[selectIndex].digits} - onClickBtn={(e) => getInputValue(e, item)} - unit={selectList[selectIndex].unit} - minNum={selectList[selectIndex].minNum} - maxNum={selectList[selectIndex].maxNum} - /> - } - - + + {formatHashTag(item.code, item.name)} + + {formatPrice(item)} + + + + {!item.show&& onAdd(item)}>添加 + || + getInputValue(e, item)} + defaultNum={item.count} + step={selectList[selectIndex].step} + digits={selectList[selectIndex].digits} + onClickBtn={(e) => getInputValue(e, item)} + unit={selectList[selectIndex].unit} + minNum={selectList[selectIndex].minNum} + maxNum={selectList[selectIndex].maxNum} + /> + } + + || + } + ) }) @@ -296,10 +293,11 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param) // } diff --git a/src/pages/order/comfirm.tsx b/src/pages/order/comfirm.tsx index f1fcb70..52371dc 100644 --- a/src/pages/order/comfirm.tsx +++ b/src/pages/order/comfirm.tsx @@ -2,7 +2,7 @@ import { SaleOrderPreViewApi, SaleOrderApi } from "@/api/order"; import { formatPriceDiv } from "@/common/fotmat"; import Popup from "@/components/popup"; import { View } from "@tarojs/components" -import Taro, { useDidShow} from "@tarojs/taro"; +import Taro, { useDidShow, usePullDownRefresh} from "@tarojs/taro"; import classnames from "classnames"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import AddressInfo from "./components/addressInfo"; @@ -160,6 +160,11 @@ import AddressInfoDetail from "./components/addressInfoDetail"; } }) } + + //页面下拉刷新 + usePullDownRefresh(() => { + getSaleOrderPreView() + }) return ( diff --git a/src/pages/order/components/payment/index.module.scss b/src/pages/order/components/payment/index.module.scss index 340b0ed..0f16e80 100644 --- a/src/pages/order/components/payment/index.module.scss +++ b/src/pages/order/components/payment/index.module.scss @@ -35,9 +35,9 @@ $top:190px; border-radius: 10px; padding-bottom: 100px; position: relative; - background: radial-gradient(circle 20px at left $top, transparent 20px, #fff 20px + 3px) left 0px/60% no-repeat , - radial-gradient(circle 20px at right $top, transparent 20px, #fff 20px + 3px) right 0px/60% no-repeat; - filter: drop-shadow(2px 2px 6px rgba(0, 0, 0, .16)); + // background: radial-gradient(circle 20px at left $top, transparent 20px, #fff 20px + 3px) left 0px/60% no-repeat , + // radial-gradient(circle 20px at right $top, transparent 20px, #fff 20px + 3px) right 0px/60% no-repeat; + // filter: drop-shadow(2px 2px 6px rgba(0, 0, 0, .16)); position: relative; &::before{ content: ''; diff --git a/src/pages/order/components/payment/index.tsx b/src/pages/order/components/payment/index.tsx index 32237e7..303b62f 100644 --- a/src/pages/order/components/payment/index.tsx +++ b/src/pages/order/components/payment/index.tsx @@ -142,6 +142,10 @@ export default memo(({show = false, onClose, orderInfo, onSubmitSuccess}:Param) ) }, [payInfo]) + //选择改变 + const changeSelect = () => { + } + return ( @@ -167,7 +171,7 @@ export default memo(({show = false, onClose, orderInfo, onSubmitSuccess}:Param) - + diff --git a/src/pages/orderList/index.tsx b/src/pages/orderList/index.tsx index 49c1b4b..982f9d2 100644 --- a/src/pages/orderList/index.tsx +++ b/src/pages/orderList/index.tsx @@ -12,6 +12,8 @@ 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" export default () => { const {checkLogin} = useLogin() @@ -108,6 +110,9 @@ export default () => { payment_method: orderInfo.payment_method //支付方式 }) toPay() + } else if (status == 7) { + //购买 + addShopCart(orderInfo) } }, [orderData]) @@ -128,6 +133,38 @@ export default () => { 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 + }) + } + + } + return ( @@ -142,6 +179,7 @@ export default () => { })} + setShowCart(false)}/> )