From f05389ced77235101c2e913c7137ccf692ee0c5b Mon Sep 17 00:00:00 2001 From: czm <2192718639@qq.com> Date: Wed, 6 Jul 2022 20:29:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E5=AD=90=E5=95=86=E5=9F=8E=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=89=88v4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.ts | 1 - src/common/constant.js | 5 +- src/common/enum.ts | 21 +- src/common/util.ts | 1 - src/components/afterOrderBtns/index.tsx | 33 +- src/components/orderBtns/index.tsx | 22 +- src/components/shopCart/index copy.tsx | 352 ------------------ src/components/shopCart/index.tsx | 2 +- src/components/textareaEnhance/index.tsx | 7 +- src/components/uploadImage/index.tsx | 11 +- src/pages/addressAdd/index.tsx | 2 + src/pages/addressManager/index.tsx | 3 +- src/pages/applyAfterSales/index.tsx | 3 +- src/pages/classList/index.tsx | 2 + .../collection/collectionClass/index.tsx | 40 +- .../collection/components/product/index.tsx | 22 +- src/pages/collection/index.tsx | 11 +- src/pages/company/index.tsx | 2 + src/pages/creditLine/index.tsx | 3 +- src/pages/creditUsed/index.tsx | 2 + src/pages/depositBeforehand/index.tsx | 2 + src/pages/depositBeforehandDetail/index.tsx | 3 +- src/pages/depositList/index.tsx | 2 + .../components/preview/index.module.scss | 5 +- .../details/components/preview/index.tsx | 7 +- src/pages/details/index.module.scss | 17 + src/pages/details/index.tsx | 21 +- src/pages/editOrder/index.tsx | 3 +- src/pages/index/index.tsx | 15 +- .../components/addressInfoDetail/index.tsx | 39 +- src/pages/order/index.tsx | 19 +- .../components/addressInfoDetail/index.tsx | 2 +- .../salesAfter/components/kindList/index.tsx | 2 +- .../components/returnLogistics/index.tsx | 13 +- src/pages/salesAfter/index.tsx | 39 +- .../salesAfterList/components/order/index.tsx | 13 +- .../components/orderStatusTag/index.tsx | 12 +- src/pages/salesAfterList/index.tsx | 11 +- src/pages/search/index.tsx | 2 + src/pages/searchList/hightSearchList.tsx | 5 +- src/pages/searchList/search.tsx | 5 +- src/pages/searchList/searchList.tsx | 5 +- src/pages/user/index.tsx | 83 +++-- src/pages/weightList/index.tsx | 2 + src/pages/weightListAdd/index.tsx | 2 + src/use/useHttp.ts | 8 +- src/use/useLogin.ts | 9 +- src/use/useLoginRequest.ts | 12 +- 48 files changed, 358 insertions(+), 545 deletions(-) delete mode 100644 src/components/shopCart/index copy.tsx diff --git a/src/api/user.ts b/src/api/user.ts index 0eaf833..abdc9c9 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,5 +1,4 @@ import { useRequest } from "@/use/useHttp" - /** * 解密用户微信信息 */ diff --git a/src/common/constant.js b/src/common/constant.js index 3dc9ec4..7ac4281 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -6,12 +6,13 @@ // export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞 // export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境 // export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发 +// export const BASE_URL = `http://192.168.1.9:50005/lymarket` // 发 // export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发 // 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/common/enum.ts b/src/common/enum.ts index 0016360..3a57fb1 100644 --- a/src/common/enum.ts +++ b/src/common/enum.ts @@ -29,13 +29,13 @@ export const AFTER_ORDER_STATUS = { //支付方式 export const PAYMENT_METHOD = { - PaymentMethodPreDeposit: {value:1, label:'预存款'}, - PaymentMethodAccountPeriod : {value:2, label:'账期'}, - PaymentMethodofflineRemittance: {value:0, label:'线下汇款'}, - PaymentMethodScanCodeToPay: {value:3, label:'扫码支付'}, - PaymentMethodCashOnDelivery: {value:4, label:'货到付款'}, + PaymentMethodPreDeposit: {value:2, label:'预存款'}, + PaymentMethodAccountPeriod : {value:3, label:'账期'}, + PaymentMethodofflineRemittance: {value:1, label:'线下汇款'}, + PaymentMethodScanCodeToPay: {value:4, label:'扫码支付'}, + PaymentMethodCashOnDelivery: {value:5, label:'货到付款'}, } -export type PAYMENT_METHOD_PARAM = 0|1|2|3|4 +export type PAYMENT_METHOD_PARAM = 1|2|3|4|5 //订单类型 @@ -58,10 +58,17 @@ export const SUBSCRIPTION_MESSAGE_SCENE = { ApplyGoods: {value:3, label: '申请退款'} } -//退款状态枚举 +//应收单退款状态枚举 export const REFUND_STATUS = { ShouldCollectOrderRefundTypeUnknown: {value:0, label:'未知退款'}, ShouldCollectOrderRefundTypeAdvanceReceiptRefund: {value:1, label:'预收退款'}, ShouldCollectOrderRefundTypeReturnForRefund: {value:2, label:'退货退款'}, ShouldCollectOrderRefundTypeSalesRefund: {value:3, label:'销售退款'}, +} + +//申请单退款状态枚举 +export const REFUND_STATUS_ORDER = { + ReturnApplyOrderTypeAdvanceReceiptRefund: {value:1, label:'预收退款'}, // 预收退款 + ReturnApplyOrderTypeReturnForRefund: {value:2, label:'退货退款'}, // 退货退款 + ReturnApplyOrderTypeSalesRefund: {value:3, label:'销售退款'}, // 销售退款 } \ No newline at end of file diff --git a/src/common/util.ts b/src/common/util.ts index bd14ea0..4bb0803 100644 --- a/src/common/util.ts +++ b/src/common/util.ts @@ -24,7 +24,6 @@ export const throttle = (fn, delay) => { let pre = 0; return (...params) => { let now = new Date().getTime(); - console.log('相差:',now-pre) if (now - pre > delay) { fn(...params); pre = now; diff --git a/src/components/afterOrderBtns/index.tsx b/src/components/afterOrderBtns/index.tsx index 7519615..2f730a6 100644 --- a/src/components/afterOrderBtns/index.tsx +++ b/src/components/afterOrderBtns/index.tsx @@ -1,12 +1,13 @@ import { CancelOrderApi, ReceiveOrderApi } from "@/api/order" import { alert } from "@/common/common" -import { AFTER_ORDER_STATUS, ORDER_STATUS, SALE_MODE } from "@/common/enum" +import { AFTER_ORDER_STATUS, ORDER_STATUS, REFUND_STATUS_ORDER, SALE_MODE } from "@/common/enum" import {Text, View } from "@tarojs/components" import Taro from "@tarojs/taro" import {useRef, memo, useState, useMemo } from "react" import classnames from "classnames"; import styles from './index.module.scss' import { ReturnApplyOrderCancelApi } from "@/api/salesAfterOrder" +import { throttle } from "@/common/util" type Param = { orderInfo: { @@ -31,6 +32,12 @@ export default memo(({orderInfo, onClick, fixedBottom = true}:Param) => { ReturnStageServiceOrderPendingRefund, } = AFTER_ORDER_STATUS + const { + ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款 + ReturnApplyOrderTypeReturnForRefund, // 退货退款 + ReturnApplyOrderTypeSalesRefund // 销售退款 + } = REFUND_STATUS_ORDER + //订单类型 // const { // SaLeModeBulk, @@ -50,7 +57,7 @@ export default memo(({orderInfo, onClick, fixedBottom = true}:Param) => { { id: 1, big_value: [ReturnStageApplying.value, ReturnStageWaitCheck.value], - cut_value: [], + cut_value: [ReturnStageApplying.value, ReturnStageWaitCheck.value, ], model_value: [], label: '取消退货' }, @@ -77,13 +84,17 @@ export default memo(({orderInfo, onClick, fixedBottom = true}:Param) => { let key = ['big_value', 'model_value', 'cut_value'] if(item.id == 1) { //取消退货 - return (orderInfo.type == 1)&&item[key[orderInfo?.sale_mode]]?.includes(orderInfo.stage) + return (orderInfo.type == ReturnApplyOrderTypeReturnForRefund.value)&&item[key[orderInfo?.sale_mode]]?.includes(orderInfo.stage) } else if (item.id == 6) { //取消退款 - return (orderInfo.type == 2)&&item[key[orderInfo?.sale_mode]]?.includes(orderInfo.stage) + if(orderInfo?.sale_mode == 0) { + return (orderInfo.type != ReturnApplyOrderTypeReturnForRefund.value)&&item[key[orderInfo?.sale_mode]]?.includes(orderInfo.stage) + } else { + return item[key[orderInfo?.sale_mode]]?.includes(orderInfo.stage) + } } else if (item.id == 4) { //质检结果 - return (orderInfo?.type == 1)&&item[key[orderInfo?.sale_mode]]?.includes(orderInfo.stage) //退货才有 + return (orderInfo?.type == ReturnApplyOrderTypeReturnForRefund.value)&&item[key[orderInfo?.sale_mode]]?.includes(orderInfo.stage) //退货才有 } else { return item[key[orderInfo?.sale_mode]]?.includes(orderInfo.stage) } @@ -99,19 +110,19 @@ export default memo(({orderInfo, onClick, fixedBottom = true}:Param) => { //点击按钮操作 - const submitBtns = (val, index) => { + const submitBtns = throttle((val, index) => { if (val == 1) { - cancelOrder({title:'要取消退货吗?'}) + cancelOrder({title:'要取消退货吗?', val}) } else if (val == 6) { - cancelOrder({title:'要取消退款吗?'}) + cancelOrder({title:'要取消退款吗?', val}) } else { onClick?.(val) } - } + }, 600) //取消退货/退款 const {fetchData: returnApplyOrderCancelFetchData} = ReturnApplyOrderCancelApi() - const cancelOrder = ({title = ''}) => { + const cancelOrder = ({title = '', val}) => { Taro.showModal({ title, success: async function (res) { @@ -119,7 +130,7 @@ export default memo(({orderInfo, onClick, fixedBottom = true}:Param) => { let res = await returnApplyOrderCancelFetchData({id: orderInfo?.return_apply_order_id}) if(res.success) { alert.success('取消成功') - onClick?.(1) + onClick?.(val) } else { alert.none(res.msg) } diff --git a/src/components/orderBtns/index.tsx b/src/components/orderBtns/index.tsx index 1ed060d..aaef418 100644 --- a/src/components/orderBtns/index.tsx +++ b/src/components/orderBtns/index.tsx @@ -9,6 +9,7 @@ import styles from './index.module.scss' import { AddShoppingCartApi } from "@/api/shopCart" import { ApplyRefundApi } from "@/api/salesAfterOrder" import { UseSubscriptionMessage } from "@/use/useCommonData" +import { throttle } from "@/common/util" type Param = { orderInfo: { @@ -132,7 +133,7 @@ export default memo(({orderInfo, onClick}:Param) => { const {openSubscriptionMessage} = UseSubscriptionMessage() //点击按钮操作 - const submitBtns = async (val, index) => { + const submitBtns = throttle(async (val, index) => { if (val == 1) { cancelOrder() } else if (val == 6) { @@ -142,14 +143,27 @@ export default memo(({orderInfo, onClick}:Param) => { await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value}) goLink('/pages/applyAfterSales/index',{id:orderInfo?.orderId}) } else if (val == 3) { - await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value}) - onClick?.(val) + bigApplyRefurn() } else if(val == 8) { applyRefund() } else { onClick?.(val) } - + }, 600) + + //大货申请退款 + const bigApplyRefurn = () => { + Taro.showModal({ + title: '要申请退款吗?', + success: async function (res) { + if(res.confirm) { + await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value}) + onClick?.(3) + } else { + console.log('用户点击取消') + } + } + }) } //取消订单 diff --git a/src/components/shopCart/index copy.tsx b/src/components/shopCart/index copy.tsx deleted file mode 100644 index 9297d36..0000000 --- a/src/components/shopCart/index copy.tsx +++ /dev/null @@ -1,352 +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, UpdateShoppingCartApi} from "@/api/shopCart" -import { formatHashTag, formatImgUrl, formatPriceDiv } from "@/common/fotmat"; -import { setParam } from "@/common/system"; -import { debounce } from "@/common/util"; -import Counter from "../counter"; -import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from "@/api/user"; - -type param = { - show?: true|false, - onClose?: () => void -} -export default ({show = false, onClose}: param) => { - const selectList = [ - {value:0, title:'大货', unit:'条', eunit:'kg', step:1, digits:0, minNum:1, maxNum:100000, defaultNum:1}, - {value:1,title:'剪板', unit:'米', eunit:'m', step:1, digits:2, minNum:0.5, maxNum:9.99, defaultNum:1}, - {value:2,title:'散剪', unit:'米', eunit:'kg', step:1, digits:2, minNum:5, maxNum:100000, defaultNum:10}, - ] - - 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 () => { - const {data} = await fetchData() - let color_list = data.color_list||[] - initList(color_list) - setLoading(false) - } - - //初始化勾选数据 - const [selectData, setSelectData] = useState<{id: number, checked: true|false}[]>([]) - const initSelectData = (data:{id:number}[] = []) => { - let res = data?.map(item => { - return {id: item.id, checked: true} - }) - setSelectData(() => res) - } - - //初始化全部数据 - const initList = (color_list) => { - color_list?.map(item => { - if(selectIndex == item.sale_mode) item.select = true - item.count = formatCount(item) - }) - setList(color_list) - } - - //显示是展示数据 - useEffect(() => { - if(!show) { - setList([]) - setSelectIndex(0) - } else { - setLoading(true) - 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 = () => { - getSelectId() - if(selectIds.current.length <= 0) return alert.none('请选择要删除的面料!') - Taro.showModal({ - content: '删除所选商品?', - success: async function (res) { - if (res.confirm) { - - 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) => { - console.log('item:::',item) - return item.sale_mode == 0? item.roll : (item.length/100) - }, []) - - //格式化单位 - const formatUnit = useCallback((item) => { - return item.sale_mode == 0? '条':'米' - }, []) - - //预估金额和总条数 - const estimatePrice = useMemo(() => { - let estimate_amount = 0 - let product_list = new Set() //面料 - let color_count = 0 //颜色数量 - let all_count = 0 //总数量 - list.map(item => { - if(item.select) { - estimate_amount += item.estimate_amount - product_list.add(item.product_id) - color_count++ - all_count += item.sale_mode == 0?item.roll: (item.length) - } - }) - let all_count_text = selectIndex == 0?all_count + '条': (all_count/100) + '米' - return {price: Number(formatPriceDiv(estimate_amount)).toFixed(2), countText: `已选${product_list.size}种面料,${color_count}个颜色,共${all_count_text}`, color_count} - },[list]) - - - //去结算 - const {fetchData: useFetchData} = GetAdminUserInfoApi() - const {fetchData: applyOrderAccessFetchData} = ApplyOrderAccessApi() - const orderDetail = debounce( async () => { - let res = await useFetchData() - if(res.data.order_access_status !== 3) { - if(res.data.order_access_status == 1) applyOrderAccessFetchData() - Taro.showModal({ - title: '提示', - content: '暂未开通下单权限功能,稍后有客服联系您,请注意接受电话。', - cancelText: '联系客服', - confirmText: '我知道', - success: function (res) { - if (res.confirm) { - } else if (res.cancel) { - console.log('用户点击取消') - } - } - }) - return false - } - 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) - - - //计数组件-当后端修改完成才修改前端显示 - const {fetchData: fetchDataUpdateShoppingCart} = UpdateShoppingCartApi() - const [UpdateShoppingCartLoading, setUpdateShoppingCartLoading] = useState(false) - 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) { - getShoppingCart() - } - }, 300) - - return ( - - closePopup()} > - - - {!selectStatus?'全选':'反选'} - - - 删除所选 - - - {estimatePrice.countText} - - {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)}{selectList[selectIndex].unit} */} - - getInputValue(e, item)} - defaultNum={item.count} - step={selectList[selectIndex].step} - digits={selectList[selectIndex].digits} - onClickBtn={(e) => getInputValue(e, item)} - unit={formatUnit(item)} - minNum={selectList[selectIndex].minNum} - maxNum={selectList[selectIndex].maxNum} - disable={UpdateShoppingCartLoading} - /> - - - - })} - - } - {!loading&&list?.length == 0 && - 暂未选择商品 - 去选购 - } - - - - - - - - - {estimatePrice.price} - 预估金额 - - orderDetail()}> - 去结算({estimatePrice.color_count}) - - - - - - - ) -} - diff --git a/src/components/shopCart/index.tsx b/src/components/shopCart/index.tsx index e58684f..a8b51fe 100644 --- a/src/components/shopCart/index.tsx +++ b/src/components/shopCart/index.tsx @@ -302,7 +302,7 @@ export default ({show = false, onClose}: param) => { {item.sale_mode_name} - {formatPirce(item.sale_price)}/{selectList[selectIndex].eunit} + {formatPirce(item.sale_price)}/{selectList[item.sale_mode].eunit} {/* ×{formatCount(item)}{selectList[selectIndex].unit} */} void, placeholder?: string, - defaultValue?: string + defaultValue?: string, + onlyRead?: false|true } -export default memo(({onChange, title = '', placeholder = '请输入', defaultValue}:Param) => { +export default memo(({onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false}:Param) => { const [descData, setDescData] = useState({ number: 0, value: '', @@ -37,7 +38,7 @@ export default memo(({onChange, title = '', placeholder = '请输入', defaultVa {title} - {descData.show&&|| + {(descData.show && !onlyRead)&&|| toggleShowRealTextarea(true)}>{descData.value||placeholder} } {descData.number +'/'+ descData.count} diff --git a/src/components/uploadImage/index.tsx b/src/components/uploadImage/index.tsx index 864d8ef..53502c7 100644 --- a/src/components/uploadImage/index.tsx +++ b/src/components/uploadImage/index.tsx @@ -9,9 +9,10 @@ import styles from './index.module.scss' //图片列表 type ImageParam = { onChange?:(val: string[]) => void, - defaultList?: string[] + defaultList?: string[], + onlyRead?: false|true } -const PictureItem:FC = memo(({onChange, defaultList}) => { +const PictureItem:FC = memo(({onChange, defaultList, onlyRead = false}) => { const {getWxPhoto} = useUploadCDNImg() const [imageList, setImageLise] = useState([]) @@ -54,12 +55,12 @@ const PictureItem:FC = memo(({onChange, defaultList}) => { {imageList.map((item, index) => - delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}> + {!onlyRead && delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}>} )} - + {!onlyRead && 上传照片 - + } ) }) diff --git a/src/pages/addressAdd/index.tsx b/src/pages/addressAdd/index.tsx index cf9ac26..a9a106a 100644 --- a/src/pages/addressAdd/index.tsx +++ b/src/pages/addressAdd/index.tsx @@ -7,8 +7,10 @@ import Taro, { setNavigationBarTitle, useRouter } from "@tarojs/taro" import { useEffect, useState } from "react" import "./index.scss" import {addressAddApi, addressDetailApi,addressEditApi} from "@/api/addressManager" +import useLogin from "@/use/useLogin" export default ()=>{ + useLogin() const [showSiteModal, setShowSiteModal] = useState(false); const {type,id} = useRouter().params; useEffect(()=>{ diff --git a/src/pages/addressManager/index.tsx b/src/pages/addressManager/index.tsx index 081d0bc..427553e 100644 --- a/src/pages/addressManager/index.tsx +++ b/src/pages/addressManager/index.tsx @@ -1,12 +1,13 @@ import AddressList from "@/components/AddressList" +import useLogin from "@/use/useLogin" import { Button, ScrollView, Text, View } from "@tarojs/components" import { stopPullDownRefresh, usePullDownRefresh } from "@tarojs/taro" import { useState } from "react" import "./index.scss" export default ()=>{ - + useLogin() return ( diff --git a/src/pages/applyAfterSales/index.tsx b/src/pages/applyAfterSales/index.tsx index 7d320eb..fd06f1d 100644 --- a/src/pages/applyAfterSales/index.tsx +++ b/src/pages/applyAfterSales/index.tsx @@ -11,6 +11,7 @@ import { ReturnApplyOrderApi, ReturnExplainApi, ReturnGoodsStatusApi, ReturnReas import { alert, goLink } from "@/common/common"; import UploadImage from "@/components/uploadImage" import TextareaEnhance from "@/components/textareaEnhance"; +import useLogin from "@/use/useLogin"; enum returnStatus { return_reason = 1, //原因 @@ -19,7 +20,7 @@ enum returnStatus { } export default () => { - + useLogin() useDidShow(() => { getSaleOrderPreView() }) diff --git a/src/pages/classList/index.tsx b/src/pages/classList/index.tsx index c2a46c9..6538ab8 100644 --- a/src/pages/classList/index.tsx +++ b/src/pages/classList/index.tsx @@ -12,8 +12,10 @@ import {GetProductListApi} from '@/api/material' import { useRouter } from "@tarojs/taro"; import { dataLoadingStatus, getFilterData } from "@/common/util"; import LoadingCard from "@/components/loadingCard"; +import useLogin from "@/use/useLogin"; export default () => { + useLogin() const [showPopup, setShowPopup] = useState(false) const router = useRouter() diff --git a/src/pages/collection/collectionClass/index.tsx b/src/pages/collection/collectionClass/index.tsx index c097b2f..16a0447 100644 --- a/src/pages/collection/collectionClass/index.tsx +++ b/src/pages/collection/collectionClass/index.tsx @@ -4,7 +4,7 @@ import { getFilterData } from "@/common/util"; import Product from "../components/product"; import Search from "@/components/search" import { Text, View } from "@tarojs/components" -import Taro from "@tarojs/taro"; +import Taro, { useRouter } from "@tarojs/taro"; import classnames from "classnames"; import { useCallback, useEffect, useRef, useState } from "react"; import CreatePopup from "../components/createPopup"; @@ -16,6 +16,8 @@ import AddCollection from "@/components/addCollection"; export default () => { + const router = useRouter() + //获取收藏夹面料 const [list, setList] = useState([]) const getFavoriteInfo = () => { @@ -43,24 +45,40 @@ export default () => { }, []) //全选反选 - const [selectStatus, setSelectStatus] = useState(false) + const [allSelectStatus, setAllSelectStatus] = useState(false) const selectCallBack = useCallback(() => { - setSelectStatus(() => true) + setAllSelectStatus(() => true) + setSelectStatus(1) }, []) const colseCallBack = useCallback(() => { - setSelectStatus(() => false) + setAllSelectStatus(() => false) + setSelectStatus(3) }, []) - // useEffect(() => { - // if(list.length) - // setSelectStatus(ids.length == list.length) - // }, [ids, list]) + + const [selectStatus, setSelectStatus] = useState<1|2|3>(3) + useEffect(() => { + if(list.length) { + if(ids.length == list.length) { + setSelectStatus(1) + setAllSelectStatus(true) + } else if ( 0 < ids.length && ids.length < list.length){ + setSelectStatus(2) + setAllSelectStatus(false) + } else { + setSelectStatus(3) + setAllSelectStatus(false) + } + } + }, [ids, list]) + + const [collectionShow, setCollectionShow] = useState(false) const closeCollection = useCallback(() => { setCollectionShow(false) }, []) const onAdd = () => { - + } return ( @@ -70,7 +88,7 @@ export default () => { - selectCallBack()} onClose={() => colseCallBack()}/> + selectCallBack()} onClose={() => colseCallBack()}/> 全选 @@ -79,7 +97,7 @@ export default () => { - + diff --git a/src/pages/collection/components/product/index.tsx b/src/pages/collection/components/product/index.tsx index cfab59b..1e48ba7 100644 --- a/src/pages/collection/components/product/index.tsx +++ b/src/pages/collection/components/product/index.tsx @@ -9,22 +9,24 @@ import { useCallback, useEffect, useRef, useState } from "react" type Params = { productList?: any[], - onSelectIds?: (val: number[]) => void - selectStatus?: false|true + onSelectIds?: (val: number[]) => void, + selectStatus?: 1|2|3, //1全选,2不做处理,3全清空 + openCheckBox?: true|false //是否开启选择 } -export default ({productList = [], onSelectIds, selectStatus = false}:Params) => { +export default ({productList = [], onSelectIds, selectStatus = 2, openCheckBox = false}:Params) => { const [list, setList] = useState([]) useEffect(() => { setList(() => [...productList]) },[productList]) useEffect(() => { - if(list.length) { + if(list.length && selectStatus != 2) { list.map(item => { - item.check = selectStatus + item.check = (selectStatus == 1) }) + setList(() => [...list]) } - setList(() => [...list]) + }, [selectStatus]) const onChangeSelect = (item) => { @@ -57,13 +59,13 @@ export default ({productList = [], onSelectIds, selectStatus = false}:Params) => return ( {list?.map(item => { - return onChangeSelect(item)}> - e.stopPropagation()}> + return openCheckBox?onChangeSelect(item):goLink(`/pages/details/index?id=${item.product_id}`)}> + {openCheckBox&& e.stopPropagation()}> onSelect(item)} onClose={() => onClose(item)}/> - + } - {item.product_color_count}色 + {item.enable_product_color_count}色 {formatHashTag(item.product_code, '')} {item.product_name} diff --git a/src/pages/collection/index.tsx b/src/pages/collection/index.tsx index 08e5e49..c78a1ac 100644 --- a/src/pages/collection/index.tsx +++ b/src/pages/collection/index.tsx @@ -1,5 +1,5 @@ import { CreateFavoriteApi, DelFavoriteApi, FavoriteListApi, UpdateFavoriteApi } from "@/api/favorite"; -import { alert } from "@/common/common"; +import { alert, goLink } from "@/common/common"; import { getFilterData } from "@/common/util"; import Product from "./components/product"; import Search from "@/components/search" @@ -10,8 +10,9 @@ import { useCallback, useEffect, useRef, useState } from "react"; import CreatePopup from "./components/createPopup"; import UpdatePopup from "./components/updatePopup"; import styles from './index.module.scss' +import useLogin from "@/use/useLogin"; export default () => { - + useLogin() const changeOpenCon = (item) => { item.openStatus = !item.openStatus setList((e) => [...e]) @@ -117,6 +118,10 @@ export default () => { } } + const onBatchManagement = useCallback(() => { + // goLink('pages/collection/collectionClass/index', {id: }) + }, []) + //操作文件夹 const onCreatSuccess = (submitData) => { if (!initData.id) { @@ -147,7 +152,7 @@ export default () => { )} - + ) diff --git a/src/pages/company/index.tsx b/src/pages/company/index.tsx index 0472783..e2b9845 100644 --- a/src/pages/company/index.tsx +++ b/src/pages/company/index.tsx @@ -7,8 +7,10 @@ import { useEffect, useState } from "react" import { alert, retrieval } from "@/common/common"; import { companyDetailApi, companyUpdateApi } from "@/api/company" import "./index.scss" +import useLogin from "@/use/useLogin" export default ()=>{ + useLogin() const [showSiteModal, setShowSiteModal] = useState(false); const handleSelectSite = ()=>{ setShowSiteModal(true); diff --git a/src/pages/creditLine/index.tsx b/src/pages/creditLine/index.tsx index 6a9d4e9..c56062e 100644 --- a/src/pages/creditLine/index.tsx +++ b/src/pages/creditLine/index.tsx @@ -8,9 +8,10 @@ import "./index.scss" import { useSelector } from "@/reducers/hooks"; import { formatDateTime, formatPriceDiv } from "@/common/fotmat" import Message from "@/components/Message" +import useLogin from "@/use/useLogin" export default ()=>{ - + useLogin() const userInfo = useSelector(state => state.userInfo); useEffect(()=>{ getData() diff --git a/src/pages/creditUsed/index.tsx b/src/pages/creditUsed/index.tsx index 11cdbd8..f2f5eed 100644 --- a/src/pages/creditUsed/index.tsx +++ b/src/pages/creditUsed/index.tsx @@ -6,8 +6,10 @@ import {creditListApi} from "@/api/creditLine" import "./index.scss" import { formatDateTime, formatPriceDiv, toDecimal2 } from "@/common/fotmat" import { dataLoadingStatus, getFilterData } from "@/common/util"; +import useLogin from "@/use/useLogin" export default ()=>{ + useLogin() const {fetchData, state} = creditListApi(); // 渲染(数据) const [data, setData] = useState({ diff --git a/src/pages/depositBeforehand/index.tsx b/src/pages/depositBeforehand/index.tsx index 9636d30..6232afc 100644 --- a/src/pages/depositBeforehand/index.tsx +++ b/src/pages/depositBeforehand/index.tsx @@ -7,8 +7,10 @@ import { useEffect } from "react"; import { formatPriceDiv, toDecimal2 } from "@/common/fotmat"; import { setClipboardData } from "@tarojs/taro"; import Message from "@/components/Message"; +import useLogin from "@/use/useLogin"; export default ()=>{ + useLogin() const {fetchData, state} = depositInfoApi(); const getData = async ()=>{ fetchData(); diff --git a/src/pages/depositBeforehandDetail/index.tsx b/src/pages/depositBeforehandDetail/index.tsx index 7d5f73e..11abfb0 100644 --- a/src/pages/depositBeforehandDetail/index.tsx +++ b/src/pages/depositBeforehandDetail/index.tsx @@ -6,9 +6,10 @@ import Taro, { useReady } from "@tarojs/taro" import { useEffect, useState } from "react" import {creditListApi} from "@/api/creditLine" import "./index.scss" +import useLogin from "@/use/useLogin" export default ()=>{ - + useLogin() return ( diff --git a/src/pages/depositList/index.tsx b/src/pages/depositList/index.tsx index eb9077c..3ef5918 100644 --- a/src/pages/depositList/index.tsx +++ b/src/pages/depositList/index.tsx @@ -7,8 +7,10 @@ import { useCallback, useEffect, useState } from "react" import { depositListApi } from "@/api/deposit" import "./index.scss" import { formatDateTime, formatPriceDiv } from "@/common/fotmat" +import useLogin from "@/use/useLogin" export default ()=>{ + useLogin() const {fetchData, state} = depositListApi(); // 渲染(数据) const [data, setData] = useState({ diff --git a/src/pages/details/components/preview/index.module.scss b/src/pages/details/components/preview/index.module.scss index cab4ce5..9db49ae 100644 --- a/src/pages/details/components/preview/index.module.scss +++ b/src/pages/details/components/preview/index.module.scss @@ -14,7 +14,10 @@ align-items: center; flex-direction: column; width: 100%; - margin-top: 200px; + height: 60vh; + margin-top: 100px; + padding: 20px; + box-sizing: border-box; image{ width:100%; border-radius: 10px; diff --git a/src/pages/details/components/preview/index.tsx b/src/pages/details/components/preview/index.tsx index 8b3488a..ff86ecf 100644 --- a/src/pages/details/components/preview/index.tsx +++ b/src/pages/details/components/preview/index.tsx @@ -1,9 +1,12 @@ +import LabAndImg from "@/components/LabAndImg" import { Image, View } from "@tarojs/components" import styles from './index.module.scss' export type colorItem = { title: string, - img: string + lab: {l:number, a:number, b:number}, + rgb: {r:number, g:number, b:number}, + texture_url: string } export type colorParams = { value?: colorItem, @@ -15,7 +18,7 @@ export default ({value, show = false, onClose}: colorParams) => { <> {show&& onClose?.()}> - + {value?.title} } diff --git a/src/pages/details/index.module.scss b/src/pages/details/index.module.scss index ed14ea5..ec682c6 100644 --- a/src/pages/details/index.module.scss +++ b/src/pages/details/index.module.scss @@ -125,16 +125,33 @@ background-color: #fff; padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom); + + .buy_cart{ width: 150px; color: $color_font_three; text-align: center; + position: relative; .text{ font-size: $font_size_min; } .miconfont{ font-size: 36px; } + .product_num{ + position: absolute; + font-size: 23px; + background-color: red; + color: #fff; + height: 36px; + line-height: 36px; + padding: 0 6px; + border-radius: 72px; + min-width: 25px; + text-align: center; + top: 0; + right: 20px; + } } .buy_btn{ display: flex; diff --git a/src/pages/details/index.tsx b/src/pages/details/index.tsx index 00c1c17..5e20e56 100644 --- a/src/pages/details/index.tsx +++ b/src/pages/details/index.tsx @@ -18,6 +18,7 @@ import LabAndImg from '@/components/LabAndImg'; import { alert } from '@/common/common'; import AddCollection from '@/components/addCollection'; import { AddFavoriteApi } from '@/api/favorite'; +import { GetShoppingCartApi } from '@/api/shopCart'; type item = {title:string, img:string, url:string, id:number} @@ -27,7 +28,7 @@ type Params = { style?: Object } export default (props:Params) => { - const {checkLogin, getPhoneNumber, userInfo} = useLogin() + const {getPhoneNumber, userInfo} = useLogin() //获取参数(有两种参数:1.商品id, 2.页面分享) const router = useRouter() @@ -50,9 +51,9 @@ export default (props:Params) => { } useDidShow(() => { - checkLogin() judgeParam() setShowCart(false) + getShoppingCart() }) useEffect(() => { @@ -96,7 +97,9 @@ export default (props:Params) => { const getColorItem = (item) => { setColorInfo({ title: item.code, - img: item.texture_url, + texture_url: item.texture_url, + lab: item.lab, + rgb: item.rgb }) setShowPreview(true) } @@ -149,7 +152,14 @@ export default (props:Params) => { setCollectionShow(false) }, []) - + //获取购物车数据数量 + const [shopCount, setShopCount] = useState(0) + const {fetchData: fetchDataShopCount} = GetShoppingCartApi() + const getShoppingCart = async () => { + const {data} = await fetchDataShopCount() + let color_list = data.color_list||[] + setShopCount(color_list.length) + } //页面下拉刷新 @@ -163,7 +173,7 @@ export default (props:Params) => { - {productName} + {productInfo.code&&{productName}} {productInfo.describe} @@ -205,6 +215,7 @@ export default (props:Params) => { setShowCart(true)}> 购物车 + {(shopCount > 0)&&{shopCount > 99?'99+':shopCount}} { (!userInfo.adminUserInfo?.is_authorize_phone)&& diff --git a/src/pages/editOrder/index.tsx b/src/pages/editOrder/index.tsx index 627165c..1ce0acf 100644 --- a/src/pages/editOrder/index.tsx +++ b/src/pages/editOrder/index.tsx @@ -8,9 +8,10 @@ import { alert, goLink } from "@/common/common"; import { getParam } from "@/common/system"; import {EditSaleOrderAddressApi, EditSaleOrderShipmentModeApi} from "@/api/order"; import Taro from "@tarojs/taro"; +import useLogin from "@/use/useLogin"; export default () => { - + useLogin() //获取临时传递的数据 const params = getParam() const [paramsData, setParamsData] = useState(params) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index eafe883..9aea20a 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -15,11 +15,7 @@ import { dataLoadingStatus } from '@/common/util' export default () => { - const { checkLogin } = useLogin() - useDidShow(async () => { - await checkLogin() - }) - + useLogin() useEffect(() => { categoryList() }, []) @@ -87,21 +83,12 @@ export default () => { setRefresherTriggeredStatus(true) } - - //页面下拉刷新 - // const res = useManualPullDownRefresh() - // usePullDownRefresh(() => { - // console.log('123') - // }) - //数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: productData.list, total: productData.total, status: productState.loading }) }, [productData, productState.loading]) - - return ( setShowShopCart(!showShopCart)}> diff --git a/src/pages/order/components/addressInfoDetail/index.tsx b/src/pages/order/components/addressInfoDetail/index.tsx index 89b8216..8ec72ac 100644 --- a/src/pages/order/components/addressInfoDetail/index.tsx +++ b/src/pages/order/components/addressInfoDetail/index.tsx @@ -37,6 +37,20 @@ type Param = { } } +//订单状态 +const { + SaleorderstatusWaitingPrePayment, + SaleOrderStatusBooking, + SaleOrderStatusArranging, + SaleOrderStatusArranged, + SaleOrderStatusWaitingPayment, + SaleOrderStatusWaitingReceipt, + SaleOrderStatusAlreadyReceipt, + SaleOrderStatusComplete, + SaleOrderStatusRefund, + SaleOrderStatusCancel, +} = ORDER_STATUS + export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, status = 2, disabled = false, onLogistics}: Param, ref) => { const [addressInfo, setAddressInfo] = useState() @@ -53,7 +67,7 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat //打开地址列表 const [showAddressList, setShowAddressList] = useState(false) const changeShow = () => { - if(receivingStatus == 2 && !logisticsShow) + if(receivingStatus == 2 && !logisticsShow && limitEdit()) setShowAddressList(() => true) } @@ -67,7 +81,8 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat const {fetchData: shipmentModeFetchData} = EditSaleOrderShipmentModeApi() const onReceivingStatus = (value, e) => { e.stopPropagation() - changeReceivingStatus(value) + if(limitEdit()) changeReceivingStatus(value) + } const changeReceivingStatus = debounce(async (value) => { if(!orderInfo) return false @@ -112,14 +127,18 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat } } - //订单状态 - const { - SaleOrderStatusWaitingReceipt, - SaleOrderStatusAlreadyReceipt, - SaleOrderStatusComplete, - SaleOrderStatusRefund, - SaleOrderStatusCancel, - } = ORDER_STATUS + //根据订单状态判断是否可用修改 + const limitEdit = () => { + let res = [ + SaleorderstatusWaitingPrePayment.value, + SaleOrderStatusBooking.value, + SaleOrderStatusArranging.value, + SaleOrderStatusArranged.value, + SaleOrderStatusWaitingPayment.value, + ].includes(orderInfo?.status as number) + if(!res && status != 1) alert.none('该订单状态不能修改地址!') + return status == 1? true : res + } //根据订单状态判断是否显示物流 diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index c75665b..1af69a7 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -13,6 +13,7 @@ import OrderBtns from "@/components/orderBtns"; import Popup from "@/components/popup"; import SearchInput from "@/components/searchInput"; import ShopCart from "@/components/shopCart"; +import useLogin from "@/use/useLogin"; import { Text, Textarea, View } from "@tarojs/components" import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro"; import classnames from "classnames"; @@ -28,6 +29,7 @@ import Remark from "./components/remark"; import styles from './index.module.scss' export default () => { + useLogin() const [showDesc, setShowDesc] = useState(false) const router = useRouter() const orderId = useRef(Number(router.params.id)) @@ -37,6 +39,8 @@ import styles from './index.module.scss' //订单状态枚举 const { + SaleOrderStatusTaking, + SaleOrderStatusWaitingDelivery, SaleOrderStatusWaitingReceipt, // 待收货 SaleOrderStatusAlreadyReceipt, // 已收货 SaleOrderStatusComplete, // 已完成 @@ -46,6 +50,7 @@ import styles from './index.module.scss' } = ORDER_STATUS //获取订单详情 + const firstOpen = useRef(true) const [orderDetail, setOrderDetail] = useState() //获取到的原始数据 const {fetchData: getOrderFetchData} = GetSaleOrderDetailApi() const getSaleOrderPreView = async () => { @@ -53,7 +58,10 @@ import styles from './index.module.scss' let res = await getOrderFetchData({id: orderId.current}) setOrderDetail(res.data) setOrderRemark(res.data.remark) - if(res.data.status == SaleorderstatusWaitingPrePayment.value) toPay() + if(firstOpen.current) { + firstOpen.current = false + toPay() + } } Taro.stopPullDownRefresh() Taro.hideToast() @@ -115,7 +123,9 @@ import styles from './index.module.scss' shipment_mode: orderDetail?.shipment_mode, id: orderDetail?.id, sale_mode: orderDetail?.sale_mode, - status: orderDetail?.status + status: orderDetail?.status, + take_goods_address: orderDetail?.take_goods_address, + take_goods_phone: orderDetail?.take_goods_phone } }, [orderDetail]) @@ -135,6 +145,8 @@ import styles from './index.module.scss' setShowDesc(() => false) }, []) const noCanOpenDescList = useRef([ + SaleOrderStatusTaking.value, //提货中 + SaleOrderStatusWaitingDelivery.value, //待发货 SaleOrderStatusWaitingReceipt.value, // 待收货 SaleOrderStatusAlreadyReceipt.value, // 已收货 SaleOrderStatusComplete.value, // 已完成 @@ -142,7 +154,7 @@ import styles from './index.module.scss' SaleOrderStatusCancel.value, // 已取消 ]) const descOpen = () => { - if(noCanOpenDescList.current.includes(orderDetail?.status)) return false + if(noCanOpenDescList.current.includes(orderDetail?.status)) return alert.none('该订单状态不能修改备注') setShowDesc(() => true) } @@ -167,7 +179,6 @@ import styles from './index.module.scss' //获取底部按钮点击, 获取按钮状态 const orderStateClick = useCallback((val) => { - console.log('123456789',val) if(val == 1 || val == 6) { //取消订单 getSaleOrderPreView() diff --git a/src/pages/salesAfter/components/addressInfoDetail/index.tsx b/src/pages/salesAfter/components/addressInfoDetail/index.tsx index ef9438c..d219d4d 100644 --- a/src/pages/salesAfter/components/addressInfoDetail/index.tsx +++ b/src/pages/salesAfter/components/addressInfoDetail/index.tsx @@ -7,7 +7,7 @@ import styles from './index.module.scss' type Param = { return_address?:string, return_phone?: string, - onLogistics?: (val: number) => void, + onLogistics?: (val: 1|2) => void, //1 上传物流 2 查看物流 stage?: number, } export default memo(({return_address = '', return_phone = '', onLogistics, stage}:Param) => { diff --git a/src/pages/salesAfter/components/kindList/index.tsx b/src/pages/salesAfter/components/kindList/index.tsx index 7a2dd69..9e9ee6f 100644 --- a/src/pages/salesAfter/components/kindList/index.tsx +++ b/src/pages/salesAfter/components/kindList/index.tsx @@ -118,7 +118,7 @@ export default memo(({order, comfirm = false}:Param) => { cut_value: [ReturnStageReturned.value], model_value: [ReturnStageReturned.value], label:'退款去向', - field: 'actual_amount' + field: 'refund_flow_name' }, ] diff --git a/src/pages/salesAfter/components/returnLogistics/index.tsx b/src/pages/salesAfter/components/returnLogistics/index.tsx index e49f04c..61b034b 100644 --- a/src/pages/salesAfter/components/returnLogistics/index.tsx +++ b/src/pages/salesAfter/components/returnLogistics/index.tsx @@ -14,8 +14,9 @@ type Param = { id?: number, //订单id images: string[], //图片列表 descValue?: string, //描述 + onlyRead?: false|true //true 只读 } -export default memo(({show = false, onClose, onSubmit, id = 0, images = [], descValue = ''}: Param) => { +export default memo(({show = false, onClose, onSubmit, id = 0, images = [], descValue = '', onlyRead = false}: Param) => { //需要提交的数据 const submitData = useRef({ accessory_url: [], @@ -52,20 +53,20 @@ export default memo(({show = false, onClose, onSubmit, id = 0, images = [], desc return ( <> - + 上传附件: - + - + - + {!onlyRead&& onSubmitEven()}>保存 - + } diff --git a/src/pages/salesAfter/index.tsx b/src/pages/salesAfter/index.tsx index 90cb0e7..0122f35 100644 --- a/src/pages/salesAfter/index.tsx +++ b/src/pages/salesAfter/index.tsx @@ -4,6 +4,7 @@ import { AFTER_ORDER_STATUS, ORDER_STATUS } from "@/common/enum"; import { formatDateTime, formatImgUrl, formatPriceDiv } from "@/common/fotmat"; import AfterOrderBtns from "@/components/afterOrderBtns"; import SearchInput from "@/components/searchInput"; +import useLogin from "@/use/useLogin"; import { Image, Text, Textarea, View } from "@tarojs/components" import Taro, {useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro"; import classnames from "classnames"; @@ -17,7 +18,7 @@ import ReturnLogistics from "./components/returnLogistics"; import styles from './index.module.scss' export default () => { - + useLogin() const router = useRouter() const orderId = useRef(Number(router.params.id)) useDidShow(() => { @@ -63,7 +64,8 @@ import styles from './index.module.scss' other_deduction_amount: orderDetail.other_deduction_amount, //其他扣除金额 total_refund_amount: orderDetail.total_refund_amount, //合计金额 refund_amount: orderDetail.refund_amount, //退款金额 - refund_type: orderDetail.refund_type //退款状态 + refund_type: orderDetail.refund_type, //退款状态 + refund_flow_name: orderDetail.refund_flow_name //退款去向 }) } @@ -74,7 +76,9 @@ import styles from './index.module.scss' //获取底部按钮点击, 获取按钮状态 const orderStateClick = useCallback((val) => { - if(val == 8) { + if(val == 1 || val == 6) { + getSaleOrderPreView() + } else if(val == 8) { //申请记录 setApplyRecord(true) } @@ -105,19 +109,22 @@ import styles from './index.module.scss' //物流显示 const [logisticsShow, setLogisticsShow] = useState(false) + const [logistics, setLogistics] = useState(false) const onShowLogistics = useCallback((val) => { - if(val == 1) { - setLogisticsShow(true) - } else { - const list = orderDetail?.accessory_url.map(item => { - return formatImgUrl(item) - }) - Taro.previewImage({ - current: list[0], // 当前显示 - urls: list // 需要预览的图片http链接列表 - }) - } - }, [orderDetail]) + setLogisticsShow(true) + if(val != 1) setLogistics(true) + // if(val == 1) { + // setLogisticsShow(true) + // } else { + // const list = orderDetail?.accessory_url.map(item => { + // return formatImgUrl(item) + // }) + // Taro.previewImage({ + // current: list[0], // 当前显示 + // urls: list // 需要预览的图片http链接列表 + // }) + // } + }, []) const onCloseLogistics = useCallback(() => { setLogisticsShow(false) }, []) @@ -139,7 +146,7 @@ import styles from './index.module.scss' - + setApplyRecord(false)}/> diff --git a/src/pages/salesAfterList/components/order/index.tsx b/src/pages/salesAfterList/components/order/index.tsx index 9be4b5d..29b88e1 100644 --- a/src/pages/salesAfterList/components/order/index.tsx +++ b/src/pages/salesAfterList/components/order/index.tsx @@ -1,4 +1,5 @@ import { goLink } from "@/common/common"; +import { REFUND_STATUS_ORDER } from "@/common/enum"; import { formatHashTag, formatImgUrl, formatPriceDiv } from "@/common/fotmat"; import AfterOrderBtns from "@/components/afterOrderBtns"; import LabAndImg from "@/components/LabAndImg"; @@ -26,7 +27,7 @@ type Param = { lab: {l:number, a:number, b:number}, rgb: {r:number, g:number, b:number}, texturl_url: string, - type: number //1 退货 2退款 + type: number //2 退货 1 预收退款 3 销售 return_apply_order_id: number //退款申请单 }, onClickBtn?: (val:{status:number, orderInfo:Param['value']}) => void @@ -63,6 +64,10 @@ export default memo(({value, onClickBtn}: Param) => { return {lab:{...value?.lab}, rgb:{...value?.rgb}, texturl_url: value?.texturl_url} }, [value]) + const { + ReturnApplyOrderTypeReturnForRefund, // 退货退款 + } = REFUND_STATUS_ORDER + return ( goLink('/pages/salesAfter/index', {id: value?.id})}> @@ -71,8 +76,8 @@ export default memo(({value, onClickBtn}: Param) => { {userInfo?.adminUserInfo?.user_name} - 售后单号:{value?.return_order_no} - + 售后单号:{value?.return_order_no} + @@ -107,7 +112,7 @@ export default memo(({value, onClickBtn}: Param) => { {`${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${value?.total_number}条`} - {value?.type == 1?'已申请退货':'已申请退款'} + {value?.type == ReturnApplyOrderTypeReturnForRefund.value?'已申请退货':'已申请退款'} 订单号:{value?.order_no} diff --git a/src/pages/salesAfterList/components/orderStatusTag/index.tsx b/src/pages/salesAfterList/components/orderStatusTag/index.tsx index c72373e..968fe99 100644 --- a/src/pages/salesAfterList/components/orderStatusTag/index.tsx +++ b/src/pages/salesAfterList/components/orderStatusTag/index.tsx @@ -2,17 +2,23 @@ import { Text, View } from "@tarojs/components" import { memo } from "react" import classnames from "classnames"; import styles from './index.module.scss' +import { REFUND_STATUS_ORDER } from "@/common/enum"; type Param = { - status?: number //0默认不处理, 1退货,2退款 + status?: number } export default memo(({status = 0}:Param) => { + const { + ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款 + ReturnApplyOrderTypeReturnForRefund, // 退货退款 + ReturnApplyOrderTypeSalesRefund // 销售退款 + } = REFUND_STATUS_ORDER return ( <> - {(status !== 0)&& + {(status !== 0)&& - { status == 1?'退货':'退款'} + { status == ReturnApplyOrderTypeReturnForRefund.value?'退货':'退款'} } ) diff --git a/src/pages/salesAfterList/index.tsx b/src/pages/salesAfterList/index.tsx index 2d64951..8256d9e 100644 --- a/src/pages/salesAfterList/index.tsx +++ b/src/pages/salesAfterList/index.tsx @@ -14,9 +14,9 @@ import { GetSaleOrderListApi, RefundOrderSatausApi } from "@/api/salesAfterOrder import ReturnLogistics from "./components/returnLogistics" export default () => { - const {checkLogin} = useLogin() - useDidShow(async () => { - await checkLogin() + useLogin() + useDidShow(() => { + getOrderList() }) //搜索参数 @@ -94,9 +94,8 @@ export default () => { //监听点击的按钮 const clickOrderBtn = useCallback(({status, orderInfo}) => { - if(status == 2) { - //退货物流 - + if(status == 1 || status == 6) { + getOrderList() } }, [orderData]) diff --git a/src/pages/search/index.tsx b/src/pages/search/index.tsx index d342443..dbdc018 100644 --- a/src/pages/search/index.tsx +++ b/src/pages/search/index.tsx @@ -5,8 +5,10 @@ import { goLink } from '@/common/common'; import classnames from "classnames"; import styles from './index.module.scss' import { useEffect } from 'react'; +import useLogin from '@/use/useLogin'; export default () => { + useLogin() return ( diff --git a/src/pages/searchList/hightSearchList.tsx b/src/pages/searchList/hightSearchList.tsx index 9496028..7a696e0 100644 --- a/src/pages/searchList/hightSearchList.tsx +++ b/src/pages/searchList/hightSearchList.tsx @@ -20,10 +20,7 @@ import SelectData, {ListProps} from "./components/selectData"; import LabAndImg from "@/components/LabAndImg"; export default () => { - const {checkLogin} = useLogin() - useDidShow(async () => { - await checkLogin() - }) + useLogin() const [showFilter, setShowFilter] = useState(false) diff --git a/src/pages/searchList/search.tsx b/src/pages/searchList/search.tsx index dd80f20..46616cf 100644 --- a/src/pages/searchList/search.tsx +++ b/src/pages/searchList/search.tsx @@ -12,10 +12,7 @@ import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro'; type searchDataParam = {'search_key':''} export default () => { - const {checkLogin} = useLogin() - useDidShow(async () => { - await checkLogin() - }) + useLogin() const [searchData, setSearchData] = useState<{hotField: searchDataParam[], historyField: searchDataParam[]}>({ hotField: [], diff --git a/src/pages/searchList/searchList.tsx b/src/pages/searchList/searchList.tsx index 53e50f4..13b5309 100644 --- a/src/pages/searchList/searchList.tsx +++ b/src/pages/searchList/searchList.tsx @@ -16,10 +16,7 @@ import useLogin from "@/use/useLogin"; import LabAndImg from "@/components/LabAndImg"; export default () => { - const {checkLogin} = useLogin() - useDidShow(async () => { - await checkLogin() - }) + useLogin() const [showFilter, setShowFilter] = useState(false) const router = useRouter() diff --git a/src/pages/user/index.tsx b/src/pages/user/index.tsx index f578118..b41bdc9 100644 --- a/src/pages/user/index.tsx +++ b/src/pages/user/index.tsx @@ -10,7 +10,17 @@ import Taro from "@tarojs/taro"; import { userassets, userorderStatistics } from "@/api/mine" import { formatPriceDiv } from "@/common/fotmat" import { useDidShow, } from '@tarojs/taro' +import { GetAdminUserInfoApi } from "@/api/user"; export default () => { + //重新获取用户信息 + const {fetchData: useFetchData} = GetAdminUserInfoApi() + const [userDataAgain, setUserDataAgain] = useState({}) + const getUserData = async () => { + let res = await useFetchData() + setUserDataAgain(res.data) + } + + // 用户信息 const { getSelfUserInfo } = useLogin(); const { adminUserInfo } = useSelector(state => state.userInfo); @@ -31,6 +41,7 @@ export default () => { }, []) useDidShow(() => { ApigetTotal() + getUserData() }) const checkGo = () => { if (adminUserInfo?.authentication_status === 0 || adminUserInfo?.authentication_status === 1 || adminUserInfo?.authentication_status === 2 || adminUserInfo?.authentication_status === 3) { @@ -55,13 +66,13 @@ export default () => { } return ( -
- checkGo()} /> +
+ checkGo()} userInfo={userDataAgain}/>
{/* {(adminUserInfo as any)?.authentication_status==1&&} */} {/* 测试暂时添加 */} {BASE_URL} - {!adminUserInfo.is_authorize_name && } + {!userDataAgain?.is_authorize_name && } ) } @@ -143,7 +154,7 @@ const Header = memo((props: any) => { - {(data?.authentication_status == 0 || data?.authentication_status == 1) && + {((data?.authentication_status == 0 || data?.authentication_status == 1) && data?.order_access_status == 3) && navTo()}> @@ -156,7 +167,7 @@ const Header = memo((props: any) => { } - {(data?.authentication_status == 3) && + {(data?.authentication_status == 3 && data?.order_access_status == 3) && navTo()}> @@ -169,7 +180,7 @@ const Header = memo((props: any) => { } - {data?.authentication_status == 2 && + {(data?.authentication_status == 2 && data?.order_access_status == 3) && navTo()}> @@ -182,7 +193,7 @@ const Header = memo((props: any) => { } - {data?.authentication_status == 4 && + {(data?.authentication_status == 4 && data?.order_access_status == 3) && navTo()}> @@ -274,34 +285,36 @@ const Header = memo((props: any) => { // 我的资产 const Assets = (props: any) => { return ( - - 我的资产 - - - - ¥ - {formatPriceDiv(props.data.data.wallet_money || 0)} - {/* {props.wallet_money || 0} */} - - 预存款 - - {/* - - {props.data.data.coupon_count || 0} - - - 优惠券 - */} - props.checkShow()}> - - ¥ - {formatPriceDiv(props.data.data.credit_line || 0)} - {/* .-00 */} - - 授信额度 - - - + <> + {(props.userInfo.order_access_status == 3) && + 我的资产 + + + + ¥ + {formatPriceDiv(props.data.data.wallet_money || 0)} + {/* {props.wallet_money || 0} */} + + 预存款 + + {/* + + {props.data.data.coupon_count || 0} + + + 优惠券 + */} + props.checkShow()}> + + ¥ + {formatPriceDiv(props.data.data.credit_line || 0)} + {/* .-00 */} + + 授信额度 + + + ||} + ) }; diff --git a/src/pages/weightList/index.tsx b/src/pages/weightList/index.tsx index 9c67547..00a8a69 100644 --- a/src/pages/weightList/index.tsx +++ b/src/pages/weightList/index.tsx @@ -5,7 +5,9 @@ import {weightListApi,weightDeleteApi} from "@/api/weightList" import "./index.scss" import Taro, { showModal } from "@tarojs/taro" import { alert } from "@/common/common" +import useLogin from "@/use/useLogin" const weightListManager = ()=>{ + useLogin() return( diff --git a/src/pages/weightListAdd/index.tsx b/src/pages/weightListAdd/index.tsx index 19241c7..ecd060e 100644 --- a/src/pages/weightListAdd/index.tsx +++ b/src/pages/weightListAdd/index.tsx @@ -6,8 +6,10 @@ import {weightAddApi, weightDetailApi,weightEditApi} from "@/api/weightList" import { useEffect, useState } from "react" import { alert, retrieval } from "@/common/common" import "./index.scss" +import useLogin from "@/use/useLogin" export default ()=>{ + useLogin() const {type,id} = useRouter().params; useEffect(()=>{ if(type=="add"){ diff --git a/src/use/useHttp.ts b/src/use/useHttp.ts index 3930f57..0403c1b 100644 --- a/src/use/useHttp.ts +++ b/src/use/useHttp.ts @@ -122,14 +122,12 @@ export const useRequest = (options:option = { const stateRef = useRef({...params}) const [state, setState] = useState({...stateRef.current}) - const {removeToken, removeSessionKey} = useUserInfo() + const {removeToken, removeSessionKey, removeUserInfo} = useUserInfo() const {login} = useLoginRequest() - useEffect(() => { - console.log('变化1::', state.loading) - }, [state.loading]) // 请求函数 const fetchData = async (sub_options?:any) => { + stateRef.current.loading = true setState((e) => ({...e, loading:true})) stateRef.current.query = { @@ -179,9 +177,11 @@ export const useRequest = (options:option = { console.log('错误::',msg) } }else{ + if (statusCode === 401) { removeToken() removeSessionKey() + removeUserInfo() login() //todo 登录数据刷新次数问题 } else { diff --git a/src/use/useLogin.ts b/src/use/useLogin.ts index 7435b02..698aed8 100644 --- a/src/use/useLogin.ts +++ b/src/use/useLogin.ts @@ -1,19 +1,22 @@ import useUserInfo from "./useUserInfo" -import Taro, { useRouter } from "@tarojs/taro" +import Taro, { useDidShow, useRouter } from "@tarojs/taro" import { GetWxUserInfoApi, GetAdminUserInfoApi, GetPhoneNumberApi, BindingCompanyApi } from "@/api/user" import useLoginRequest from "./useLoginRequest" import { SHARE_SCENE } from "@/common/enum" import { GetShortCodeApi } from "@/api/share" import { alert } from "@/common/common" +import { LoginApi } from "@/api/login" export default () => { const {setUserInfo, setAdminUserInfo, setSortCode, userInfo} = useUserInfo() - //登录请求 (调用这个就不能再useHttp中使用,当前这个hook, 否则会死循环内存溢出) - // const {fetchData} = LoginApi() + useDidShow(() => { + checkLogin() + }) //登录请求 const {login} = useLoginRequest() + // const {fetchData:login} = LoginApi() const wxLogin = async () => { try { await login() diff --git a/src/use/useLoginRequest.ts b/src/use/useLoginRequest.ts index dc7d55e..d4db5de 100644 --- a/src/use/useLoginRequest.ts +++ b/src/use/useLoginRequest.ts @@ -3,11 +3,15 @@ import Taro, { useRouter } from "@tarojs/taro" import { useRef, useState } from "react" import qs from 'qs' import useUserInfo from "./useUserInfo" +import useLogin from "./useLogin" //开这个hook 主要是为了让useHttp 能够调用 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 = { success: false, data: null, @@ -19,7 +23,7 @@ export default () => { const {setToken, setSessionKey} = useUserInfo() const router = useRouter() //微信登录请求v2 - const fetchData = async (login_code) => { + const fetchDataLogin = async (login_code) => { const q = { url: BASE_URL + '/v1/mall/login', header: { @@ -57,11 +61,13 @@ export default () => { //微信登录 const login = () => { + if(loginStatus) return false + loginStatus = true return new Promise((reslove, reject) => { Taro.login({ success: async (res) => { if (res.code) { - const {data, success, msg} = await fetchData(res.code) + const {data, success, msg} = await fetchDataLogin(res.code) if(success) { setToken(data.token) setSessionKey(data.session_key) @@ -88,10 +94,12 @@ export default () => { console.log('登录失败!' + res.errMsg) reject(res.errMsg) } + loginStatus = false }, fail: function(e) { console.log('登录失败!::',e) reject(e) + loginStatus = false } }) })