From 575799b71386ffef1479647a3ca9c537ed839102 Mon Sep 17 00:00:00 2001 From: czm <2192718639@qq.com> Date: Tue, 12 Jul 2022 20:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=9F=8E=E6=B5=8B=E8=AF=95=E7=89=88v5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/constant.js | 4 +- src/components/sortBtn/index.tsx | 40 +++++++++++--- .../components/reasonPopup/index copy 2.tsx | 44 +++++++++++++++ .../components/reasonPopup/index copy.tsx | 30 +++++++++++ .../components/reasonPopup/index.tsx | 53 +++++++++++++++++-- src/pages/applyAfterSales/index.tsx | 3 +- .../components/returnRecord/index.module.scss | 7 +++ .../order/components/returnRecord/index.tsx | 15 ++++-- .../orderList/components/order/index.tsx | 3 +- .../salesAfterList/components/order/index.tsx | 17 +++--- src/pages/searchList/hightSearchList.tsx | 31 +++++++++-- src/pages/searchList/searchList.tsx | 18 ++++--- src/use/useLogin.ts | 21 ++++---- src/use/useLoginRequest.ts | 1 - 14 files changed, 235 insertions(+), 52 deletions(-) create mode 100644 src/pages/applyAfterSales/components/reasonPopup/index copy 2.tsx create mode 100644 src/pages/applyAfterSales/components/reasonPopup/index copy.tsx diff --git a/src/common/constant.js b/src/common/constant.js index deed9aa..4b55726 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -11,8 +11,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.7:50002/lymarket` // 添 -// export const BASE_URL = `http://192.168.1.42:50001/lymarket` // 杰 +// export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添 +export const BASE_URL = `http://192.168.1.42:50001/lymarket` // 杰 // CDN // 生成密钥 diff --git a/src/components/sortBtn/index.tsx b/src/components/sortBtn/index.tsx index 68d6642..6d7c477 100644 --- a/src/components/sortBtn/index.tsx +++ b/src/components/sortBtn/index.tsx @@ -1,17 +1,45 @@ import { View } from "@tarojs/components" import classnames from "classnames"; +import { forwardRef, useEffect, useImperativeHandle, useState } from "react"; import styles from './index.module.scss' type params = { - status?: 'top'|'bottom'|'none' + status?: 'top'|'bottom'|'none', + onChange?: (val:{status:string, value:string}) => void, + sortValue?: {desc: string, asc: string} //排序规则,后端制定 } -export default ({status = 'none'}: params) => { +type sortParam = 'none'|'top'|'bottom' +export default forwardRef(({status = 'none', onChange, sortValue}: params,ref) => { + const [sortStatus, setSortStatus] = useState() + useEffect(() => { + setSortStatus(() => status) + }, [status]) + const changeSort = ():{status:sortParam, value:string} => { + let status:sortParam = 'none' + let value = '' + if(sortStatus == 'none') { + status = 'top' + value = sortValue?.asc! + } + if(sortStatus == 'top') { + status = 'bottom' + value = sortValue?.desc! + } + if(sortStatus == 'bottom') status = 'none' + setSortStatus(() => status) + onChange?.({status, value}) + return {status, value} + } + useImperativeHandle(ref, () => ({ + changeSort + })) + return ( <> - - - + + + ) -} \ No newline at end of file +}) \ No newline at end of file diff --git a/src/pages/applyAfterSales/components/reasonPopup/index copy 2.tsx b/src/pages/applyAfterSales/components/reasonPopup/index copy 2.tsx new file mode 100644 index 0000000..1cecb2a --- /dev/null +++ b/src/pages/applyAfterSales/components/reasonPopup/index copy 2.tsx @@ -0,0 +1,44 @@ +import Popup from "@/components/popup"; +import { ScrollView, Text, View } from "@tarojs/components"; +import { memo, useEffect, useMemo, useState } from "react"; +import classnames from "classnames"; +import styles from './index.module.scss' + +//原因选择 +type Param = {id:number, name:string, typle?:number} +type ReasonInfoParam = { + show?: boolean, //显示 + onClose?: () => void, //关闭 + title?: string, //标题 + list?: {id:number, name:string, typle?:number, children?:Param[]}[], //数据列表 + onSelect?: (val: object) => void, //选择 + defaultValue?: number, //默认选中 +} +export default memo(({show = false, onClose, title = '', list = [], onSelect, defaultValue}: ReasonInfoParam) => { + const [hasNextData, setHasNextData] = useState(true) //是否有下一级数据 + const [selectData, setSelectData] = useState() + const [headerList, setHeaderList] = useState<{id: number, name: string}[]>([]) + const onSelectData = (item) => { + setHeaderList((e) => [...e, {id:item.id, name:item.name}]) + } + useEffect(() => { + console.log('headerList::', headerList) + }, [headerList]) + return ( + + + + {headerList.map(item => { + return {item.name} + })} + {hasNextData&&请选择} + + + + {list.map(item => onSelectData(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name} )} + + + + + ) +}) \ No newline at end of file diff --git a/src/pages/applyAfterSales/components/reasonPopup/index copy.tsx b/src/pages/applyAfterSales/components/reasonPopup/index copy.tsx new file mode 100644 index 0000000..0ed990c --- /dev/null +++ b/src/pages/applyAfterSales/components/reasonPopup/index copy.tsx @@ -0,0 +1,30 @@ +import Popup from "@/components/popup"; +import { ScrollView, Text, View } from "@tarojs/components"; +import { memo, useMemo } from "react"; +import classnames from "classnames"; +import styles from './index.module.scss' + +//原因选择 +type ReasonInfoParam = { + show?: boolean, //显示 + onClose?: () => void, //关闭 + title?: string, //标题 + list?: {id:number, name:string, typle?:number}[], //数据列表 + onSelect?: (val: object) => void, //选择 + defaultValue?: number, //默认选中 +} +export default memo(({show = false, onClose, title = '', list= [], onSelect, defaultValue}: ReasonInfoParam) => { + + return ( + + + {title} + + + {list.map(item => onSelect?.(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name} )} + + + + + ) +}) \ No newline at end of file diff --git a/src/pages/applyAfterSales/components/reasonPopup/index.tsx b/src/pages/applyAfterSales/components/reasonPopup/index.tsx index 0ed990c..1008d91 100644 --- a/src/pages/applyAfterSales/components/reasonPopup/index.tsx +++ b/src/pages/applyAfterSales/components/reasonPopup/index.tsx @@ -1,10 +1,12 @@ import Popup from "@/components/popup"; import { ScrollView, Text, View } from "@tarojs/components"; -import { memo, useMemo } from "react"; +import { Children, memo, useEffect, useMemo, useRef, useState } from "react"; import classnames from "classnames"; import styles from './index.module.scss' +import { ReturnExplainApi, ReturnReasonApi } from "@/api/salesAfterOrder"; //原因选择 +type Param = {id:number, name:string, typle?:number} type ReasonInfoParam = { show?: boolean, //显示 onClose?: () => void, //关闭 @@ -12,16 +14,59 @@ type ReasonInfoParam = { list?: {id:number, name:string, typle?:number}[], //数据列表 onSelect?: (val: object) => void, //选择 defaultValue?: number, //默认选中 + dataLength?: number, //可显示的数据列数 } -export default memo(({show = false, onClose, title = '', list= [], onSelect, defaultValue}: ReasonInfoParam) => { +export default memo(({show = false, onClose, title = '', list = [], onSelect, defaultValue, dataLength = 2}: ReasonInfoParam) => { + + const [initList, setInitList] = useState([]) + //退货原因 + const idRef = useRef(0) + const {fetchData: fetchDataReturnReason} = ReturnReasonApi() + const getReturnReason = async () => { + let res = await fetchDataReturnReason() + setInitList(res.data?.list||[]) + } + useEffect(() => { + getReturnReason() + }, []) + + //售后退货说明 + const {fetchData: fetchDataReturnExplain} = ReturnExplainApi() + const getReturnExplain = async () => { + let res = await fetchDataReturnExplain({return_reason: idRef.current}) + setInitList(res.data?.list||[]) + } + + const [headerList, setHeaderList] = useState<{id: number, name: string}[]>([]) + const onSelectData = (item) => { + if(headerList.length <= dataLength) { + idRef.current = item.id + if(headerList.length < dataLength - 1) getReturnExplain() + headerList[headerList.length == dataLength?(dataLength - 1):headerList.length] = {id:item.id, name:item.name} + setHeaderList((e) => [...e]) + console.log('headerList.length',headerList.length) + + } + + } + + const onHeaderClick = (index) => { + let list = headerList.slice(0, index + 1) + } + return ( - {title} + + {headerList.map((item, index) => { + return onHeaderClick(index)}>{item.name} + })} + {dataLength > headerList.length&&请选择} + - {list.map(item => onSelect?.(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name} )} + {initList.map(item => onSelectData(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name} )} diff --git a/src/pages/applyAfterSales/index.tsx b/src/pages/applyAfterSales/index.tsx index 6bd1c67..d012b74 100644 --- a/src/pages/applyAfterSales/index.tsx +++ b/src/pages/applyAfterSales/index.tsx @@ -133,9 +133,8 @@ export default () => { alert.success('申请成功') goLink('/pages/salesAfterList/index',{}, 'reLaunch') } else { - alert.error('申请失败') + alert.error(res.msg) } - console.log('提交::',submitData) } //底部按钮 diff --git a/src/pages/order/components/returnRecord/index.module.scss b/src/pages/order/components/returnRecord/index.module.scss index fc9425c..8fe0d57 100644 --- a/src/pages/order/components/returnRecord/index.module.scss +++ b/src/pages/order/components/returnRecord/index.module.scss @@ -1,10 +1,17 @@ .returnRecord_main{ height: 70vh; + .returnRecord_con{ + padding: 0 20px; + } + .returnRecord_con{ + padding-top: 20px; + } .order_item{ background-color: #fff; border-radius: 20px; padding: 20px; box-sizing: border-box; + box-shadow: 0px 0px 12px 0px rgba(0,0,0,0.16); .header{ display: flex; align-items: center; diff --git a/src/pages/order/components/returnRecord/index.tsx b/src/pages/order/components/returnRecord/index.tsx index 5a2896d..2a615d4 100644 --- a/src/pages/order/components/returnRecord/index.tsx +++ b/src/pages/order/components/returnRecord/index.tsx @@ -24,12 +24,12 @@ export default memo(({show, onClose, onSubmit, id}:Param) => { const searchField = useRef({ page : 1, size : 10, - saleOrderID: 0 + sale_order_id: 0 }) useEffect(() => { if(show && id) { - searchField.current.saleOrderID = id + searchField.current.sale_order_id = id getOrderList() } }, [show, id]) @@ -61,7 +61,7 @@ export default memo(({show, onClose, onSubmit, id}:Param) => { //对应数量 const formatCount = useCallback((item, sale_mode) => { - return sale_mode == 0? item.roll : Number(item.length / 100) + return sale_mode == 0? item.roll + '条' : Number(item.length / 100) + '米' }, [orderData]) //上拉加载数据 @@ -74,6 +74,11 @@ export default memo(({show, onClose, onSubmit, id}:Param) => { } } + const numText = useCallback((value) => { + let total_number_new = value?.sale_mode == 0? value?.total_number:(value?.total_number/100) + return `${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${total_number_new}${value?.sale_mode == 0? '条':'米'}` + }, [orderData]) + //监听滚动 const [scrollStatus, setScrollStatus] = useState(false) const onscroll = useCallback((e) => { @@ -132,7 +137,7 @@ export default memo(({show, onClose, onSubmit, id}:Param) => { (index <= 1)&& {formatHashTag(itemColor.code, itemColor.name)} {standardPrice(itemColor.sale_price, item.sale_mode)} - ×{formatCount(itemColor, itemColor.sale_mode)}条 + ×{formatCount(itemColor, itemColor.sale_mode)} ) }) @@ -144,7 +149,7 @@ export default memo(({show, onClose, onSubmit, id}:Param) => { - {`${item?.total_fabrics}种面料,${item?.total_colors}种颜色,共${item?.total_number}条`} + {numText(item)} {item?.type == ReturnApplyOrderTypeReturnForRefund.value?'已申请退货':'已申请退款'} 订单号:{item?.order_no} diff --git a/src/pages/orderList/components/order/index.tsx b/src/pages/orderList/components/order/index.tsx index 41a7223..9800929 100644 --- a/src/pages/orderList/components/order/index.tsx +++ b/src/pages/orderList/components/order/index.tsx @@ -73,7 +73,8 @@ export default memo(({value, onClickBtn}: Param) => { //总条数 const numText = useMemo(() => { - return `${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${value?.total_number}${value?.sale_mode == 0? '条':'米'}` + let total_number_new = value?.sale_mode == 0? value?.total_number:(value?.total_number/100) + return `${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${total_number_new}${value?.sale_mode == 0? '条':'米'}` }, [value]) diff --git a/src/pages/salesAfterList/components/order/index.tsx b/src/pages/salesAfterList/components/order/index.tsx index fb4426a..4d77e18 100644 --- a/src/pages/salesAfterList/components/order/index.tsx +++ b/src/pages/salesAfterList/components/order/index.tsx @@ -37,7 +37,7 @@ export default memo(({value, onClickBtn}: Param) => { const userInfo = useSelector(state => state.userInfo) //对应数量 const formatCount = useCallback((item, sale_mode) => { - return sale_mode == 0? item.roll : Number(item.length / 100) + return sale_mode == 0? item.roll + '条' : Number(item.length / 100) + '米' }, [value]) //对应单价 const standardPrice = useCallback((price, sale_mode) => { @@ -69,20 +69,17 @@ export default memo(({value, onClickBtn}: Param) => { ReturnApplyOrderTypeReturnForRefund, // 退货退款 } = REFUND_STATUS_ORDER - + const numText = useMemo(() => { + let total_number_new = value?.sale_mode == 0? value?.total_number:(value?.total_number/100) + return `${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${total_number_new}${value?.sale_mode == 0? '条':'米'}` + }, [value]) return ( goLink('/pages/salesAfter/index', {id: value?.id})}> - {/* {userInfo?.adminUserInfo?.user_name} */} - {/* - 售后单号:{value?.return_order_no} - - - */} {userInfo?.adminUserInfo?.user_name} @@ -111,7 +108,7 @@ export default memo(({value, onClickBtn}: Param) => { (index <= 1)&& {formatHashTag(itemColor.code, itemColor.name)} {standardPrice(itemColor.sale_price, value.sale_mode)} - ×{formatCount(itemColor, value.sale_mode)}条 + ×{formatCount(itemColor, value.sale_mode)} ) }) @@ -123,7 +120,7 @@ export default memo(({value, onClickBtn}: Param) => { - {`${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${value?.total_number}条`} + {numText} {value?.type == ReturnApplyOrderTypeReturnForRefund.value?'已申请退货':'已申请退款'} 订单号:{value?.order_no} diff --git a/src/pages/searchList/hightSearchList.tsx b/src/pages/searchList/hightSearchList.tsx index 5388baf..8f80bb9 100644 --- a/src/pages/searchList/hightSearchList.tsx +++ b/src/pages/searchList/hightSearchList.tsx @@ -33,7 +33,8 @@ export default () => { width: '', weight_density: '', product_kind_id: '', - component: '' + component: '', + abstract_sort_key: '' }) //获取面料列表 @@ -132,6 +133,26 @@ export default () => { usePullDownRefresh(() => { setSearchField({...searchField ,size : 10}) }) + + //排序 + type sortParam = 'none'|'top'|'bottom' + const sortComprehensiveRef = useRef(null) + const sortCollectionRef = useRef(null) + const [sortStatus, setSortStatus] = useState<{comprehensive:sortParam, collection:sortParam}>({ + comprehensive: 'none', + collection: 'none' + }) + const changeSort = (val) => { + if(val == 1) { + const {status, value} = sortComprehensiveRef.current.changeSort() + setSortStatus((e) => ({...e, comprehensive: status, collection: 'none'})) + setSearchField((e) => ({...e, abstract_sort_key: value})) + } else { + const {status, value} = sortCollectionRef.current.changeSort() + setSortStatus((e) => ({...e, collection: status, comprehensive: 'none'})) + setSearchField((e) => ({...e, abstract_sort_key: value})) + } + } return ( @@ -148,13 +169,13 @@ export default () => { - + changeSort(1)}> 综合 - + - + changeSort(2)}> 收藏 - + diff --git a/src/pages/searchList/searchList.tsx b/src/pages/searchList/searchList.tsx index d7677ae..12f10da 100644 --- a/src/pages/searchList/searchList.tsx +++ b/src/pages/searchList/searchList.tsx @@ -118,18 +118,24 @@ export default () => { } //排序 - const [sortStatus, setSortStatus] = useState<{comprehensive:'none'|'top'|'bottom', collection:'none'|'top'|'bottom'}>({ + type sortParam = 'none'|'top'|'bottom' + const sortComprehensiveRef = useRef(null) + const sortCollectionRef = useRef(null) + const [sortStatus, setSortStatus] = useState<{comprehensive:sortParam, collection:sortParam}>({ comprehensive: 'none', collection: 'none' }) const changeSort = (val) => { if(val == 1) { - + const {status, value} = sortComprehensiveRef.current.changeSort() + setSortStatus((e) => ({...e, comprehensive: status, collection: 'none'})) + setSearchField((e) => ({...e, abstract_sort_key: value})) } else { - + const {status, value} = sortCollectionRef.current.changeSort() + setSortStatus((e) => ({...e, collection: status, comprehensive: 'none'})) + setSearchField((e) => ({...e, abstract_sort_key: value})) } } - return ( @@ -139,11 +145,11 @@ export default () => { changeSort(1)}> 综合 - + changeSort(2)}> 收藏 - + goLink('/pages/searchList/hightSearchList')}> 高级搜索 diff --git a/src/use/useLogin.ts b/src/use/useLogin.ts index 698aed8..66deb2a 100644 --- a/src/use/useLogin.ts +++ b/src/use/useLogin.ts @@ -41,16 +41,17 @@ export default () => { await wxLogin() reslove(true) } else { - Taro.checkSession({ - success: async () => { - reslove(true) - if(!userInfo.adminUserInfo) getAdminUserInfo() - }, - fail: async () => { - await wxLogin() - reslove(true) - } - }) + //这个东西不要打开,checkSession有调用频率问题 + // Taro.checkSession({ + // success: async () => { + // reslove(true) + // if(!userInfo.adminUserInfo) getAdminUserInfo() + // }, + // fail: async () => { + // await wxLogin() + // reslove(true) + // } + // }) } }) } diff --git a/src/use/useLoginRequest.ts b/src/use/useLoginRequest.ts index d4db5de..893d874 100644 --- a/src/use/useLoginRequest.ts +++ b/src/use/useLoginRequest.ts @@ -9,7 +9,6 @@ import useLogin from "./useLogin" type Param = {success: true|false, data: any, msg: string, code: null|number, loading: false|true} let loginStatus = false //登录状态,true登录中 -console.log('你不要过来啊') export default () => { let initData = {