From 9e7b4d7d56830b133099170e484b004dcddea5c7 Mon Sep 17 00:00:00 2001 From: xuan Date: Thu, 1 Dec 2022 18:10:18 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20style(eslint):=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3eslint=E7=9A=84=E9=94=99=E8=AF=AF=E2=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc | 3 +- global.d.ts | 2 +- src/api/index.ts | 2 +- src/api/product/index.ts | 2 +- src/api/product/product.ts | 2 +- src/common/money.ts | 16 +- src/components/AddressList/index.tsx | 3 +- src/components/afterOrderBtns/index copy.tsx | 34 ++- src/components/afterOrderBtns/index.tsx | 26 +- src/components/bluetooth/LinkBlueTooth.tsx | 27 +- src/components/closeBtn/index.tsx | 6 +- src/components/iconfont/iconfont.tsx | 2 +- src/components/orderBtns/index copy.tsx | 34 ++- src/components/timePickerPopup/index.tsx | 2 +- .../colorRelated/sampleComparison/index.tsx | 4 +- src/pages/customerDetails/index.tsx | 4 +- .../customerEditor/components/Form/index.tsx | 5 +- src/pages/index/index.tsx | 3 +- src/pages/order/index.tsx | 258 +++++++++--------- src/pages/takeDelivery/index.tsx | 1 - src/store/index.ts | 4 +- src/use/contextBlueTooth.tsx | 5 +- 22 files changed, 222 insertions(+), 223 deletions(-) diff --git a/.eslintrc b/.eslintrc index 943159f..ef3a582 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,6 +7,7 @@ "eqeqeq": "off", "no-prototype-builtins": "off", "import/first": "off", - "react/no-children-prop": "off" + "react/no-children-prop": "off", + "import/no-commonjs": "off" } } diff --git a/global.d.ts b/global.d.ts index 660d8ca..da1d751 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,4 +1,4 @@ -/// +/// declare module '*.png' declare module '*.gif' diff --git a/src/api/index.ts b/src/api/index.ts index 336eeb4..4991e71 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -4,7 +4,7 @@ import { useRequest } from '@/use/useHttp' export { LoginApi } from './login/index' export { - productabsorbcontrast, + ProductAbsorbContrast, SelectProductListApi, ColorListApi, ColorDetailedApi, diff --git a/src/api/product/index.ts b/src/api/product/index.ts index 0e1fb14..2421ad7 100644 --- a/src/api/product/index.ts +++ b/src/api/product/index.ts @@ -1,3 +1,3 @@ -export { productabsorbcontrast, SelectProductListApi } from './product' +export { ProductAbsorbContrast, SelectProductListApi } from './product' export { ColorListApi, ColorDetailedApi, ColorSamplingSaveApi, TextureSaveApi } from './takeColor' export { FindColorListApi } from './findColor' diff --git a/src/api/product/product.ts b/src/api/product/product.ts index 71d5d0f..72e1f37 100644 --- a/src/api/product/product.ts +++ b/src/api/product/product.ts @@ -1,7 +1,7 @@ import { useRequest } from '@/use/useHttp' // 取色对比 -export const productabsorbcontrast = () => { +export const ProductAbsorbContrast = () => { return useRequest({ url: '/v2/mp/product/color/absorb/contrast', method: 'get', diff --git a/src/common/money.ts b/src/common/money.ts index 734bc45..0a7a965 100644 --- a/src/common/money.ts +++ b/src/common/money.ts @@ -18,9 +18,9 @@ const smallToBig = function(money) { const cnInteger = '整' // 整数金额时后面跟的字符 const cnIntLast = '元' // 整数完以后的单位 // 最大处理的数字 + // eslint-disable-next-line @typescript-eslint/no-loss-of-precision const maxNum = 999999999999999.9999 - let integerNum // 金额整数部分 - let decimalNum // 金额小数部分 + // 输出的中文金额字符串 let chineseStr = '' let parts // 分离金额后用的数组,预定义 @@ -40,15 +40,15 @@ const smallToBig = function(money) { // 四舍五入保留两位小数,转换为字符串 money = Math.round(money * 100).toString() - integerNum = money.substr(0, money.length - 2) - decimalNum = money.substr(money.length - 2) + const integerNum = money.substr(0, money.length - 2) // 金额整数部分 + const decimalNum = money.substr(money.length - 2) // 金额小数部分 // 获取整型部分转换 if (parseInt(integerNum, 10) > 0) { let zeroCount = 0 const IntLen = integerNum.length - for (var i = 0; i < IntLen; i++) { - var n = integerNum.substr(i, 1) + for (let i = 0; i < IntLen; i++) { + const n = integerNum.substr(i, 1) const p = IntLen - i - 1 const q = p / 4 const m = p % 4 @@ -72,8 +72,8 @@ const smallToBig = function(money) { // 小数部分 if (decimalNum != '') { const decLen = decimalNum.length - for (var i = 0; i < decLen; i++) { - var n = decimalNum.substr(i, 1) + for (let i = 0; i < decLen; i++) { + const n = decimalNum.substr(i, 1) if (n != '0') { chineseStr += cnNums[Number(n)] + cnDecUnits[i] } diff --git a/src/components/AddressList/index.tsx b/src/components/AddressList/index.tsx index 45f6ab9..b587cf0 100644 --- a/src/components/AddressList/index.tsx +++ b/src/components/AddressList/index.tsx @@ -1,10 +1,9 @@ - +import Taro, { showModal, useDidShow, useRouter } from '@tarojs/taro' import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components' import { forwardRef, memo, useEffect, useImperativeHandle, useState } from 'react' import './index.scss' import { MpPurchaserAddressList } from '@/api/addressList' import { alert } from '@/common/common' -import Taro, { showModal, useDidShow, useRouter } from '@tarojs/taro' import IconFont from '@/components/iconfont/iconfont' import { MpSaleOrderAddress } from '@/api/order' diff --git a/src/components/afterOrderBtns/index copy.tsx b/src/components/afterOrderBtns/index copy.tsx index 00bb4ee..be1eff9 100644 --- a/src/components/afterOrderBtns/index copy.tsx +++ b/src/components/afterOrderBtns/index copy.tsx @@ -16,8 +16,7 @@ interface Param { }|null onClick?: (val: number) => void // 点击后触发的事件,返回订单状态 } - -export default memo(({ orderInfo, onClick }: Param) => { +const AfterOrderBtns = ({ orderInfo, onClick }: Param) => { // 订单状态枚举 const { SaleOrderStatusBooking, @@ -93,15 +92,15 @@ export default memo(({ orderInfo, onClick }: Param) => { if (item.id == 1) { // 取消订单按钮 return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款 - } + } else if (item.id == 2) { // 去付款按钮 return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示 - } + } else if (item.id == 3) { // 申请退款, 只有大货才有 return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款 - } + } else if (item.id == 8) { // 退款按钮(直接退款不用申请), 只有散剪和剪板有 return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款 @@ -120,13 +119,6 @@ export default memo(({ orderInfo, onClick }: Param) => { }) }, [orderInfo]) - // 点击按钮操作 - const submitBtns = (val, index) => { - (val == 1) && cancelOrder(); // 取消订单按钮 - (val == 2) && onClick?.(2); // 去付款按钮 - (val == 6) && receiveOrder() // 确认收货 - } - // 取消订单 const { fetchData: cancelFetchData } = CancelOrderApi() const cancelOrder = () => { @@ -138,11 +130,11 @@ export default memo(({ orderInfo, onClick }: Param) => { if (res.success) { alert.success('取消成功') onClick?.(1) - } + } else { alert.none(res.msg) } - } + } else if (res.cancel) { console.log('用户点击取消') } @@ -162,18 +154,23 @@ export default memo(({ orderInfo, onClick }: Param) => { if (res.success) { onClick?.(6) alert.success('收货成功') - } + } else { alert.error('收货失败') } - } + } else if (res.cancel) { console.log('用户点击取消') } }, }) } - + // 点击按钮操作 + const submitBtns = (val, index) => { + (val == 1) && cancelOrder(); // 取消订单按钮 + (val == 2) && onClick?.(2); // 去付款按钮 + (val == 6) && receiveOrder() // 确认收货 + } // 显示更多按钮 const [showMore, setShowMore] = useState(false) const styleTop = useMemo(() => { @@ -202,4 +199,5 @@ export default memo(({ orderInfo, onClick }: Param) => { ) -}) +} +export default memo(AfterOrderBtns) diff --git a/src/components/afterOrderBtns/index.tsx b/src/components/afterOrderBtns/index.tsx index 377e3a4..0cd84f7 100644 --- a/src/components/afterOrderBtns/index.tsx +++ b/src/components/afterOrderBtns/index.tsx @@ -87,19 +87,6 @@ const AfterOrderBtns = ({ orderInfo, onClick, fixedBottom = true }: Param) => { }) }, [orderInfo]) - // 点击按钮操作 - const submitBtns = throttle((val, index) => { - if (val == 1) { - cancelOrder({ title: '要取消退货吗?', val }) - } - else if (val == 6) { - cancelOrder({ title: '要取消退款吗?', val }) - } - else { - onClick?.(val) - } - }, 600) - // 取消退货/退款 const { fetchData: returnApplyOrderCancelFetchData } = ReturnApplyOrderCancelApi() const cancelOrder = ({ title = '', val }) => { @@ -122,7 +109,18 @@ const AfterOrderBtns = ({ orderInfo, onClick, fixedBottom = true }: Param) => { }, }) } - + // 点击按钮操作 + const submitBtns = throttle((val, index) => { + if (val == 1) { + cancelOrder({ title: '要取消退货吗?', val }) + } + else if (val == 6) { + cancelOrder({ title: '要取消退款吗?', val }) + } + else { + onClick?.(val) + } + }, 600) // 显示更多按钮 const [showMore, setShowMore] = useState(false) const styleTop = useMemo(() => { diff --git a/src/components/bluetooth/LinkBlueTooth.tsx b/src/components/bluetooth/LinkBlueTooth.tsx index 7abae2e..b7d15ae 100644 --- a/src/components/bluetooth/LinkBlueTooth.tsx +++ b/src/components/bluetooth/LinkBlueTooth.tsx @@ -8,7 +8,7 @@ import SearchInput from '@/components/searchInput' import Popup from '@/components/bluetooth/Popup' import useCheckAuthorize from '@/use/useCheckAuthorize' -export default memo(() => { +const LinkBlueTooth = () => { const { state, init, startScan, connect, disconnect } = useBluetooth() const { check } = useCheckAuthorize({ scope: 'scope.bluetooth', msg: '请开启小程序蓝牙权限' }) @@ -21,10 +21,10 @@ export default memo(() => { useEffect(() => { if (!state.available) { setLinkStatus(1) - } + } else if (state.available && state.connected?.name) { setLinkStatus(3) - } + } else { setLinkStatus(2) } @@ -40,6 +40,9 @@ export default memo(() => { } const [popupShow, setPopupShow] = useState(false) + const onFindEven = () => { + if (!state.discovering && !state.connected && !state.connecting) { startScan() } + } // 显示设备列表 const onFindDevice = () => { check().then((res) => { @@ -48,16 +51,13 @@ export default memo(() => { title: '请打开手机蓝牙', icon: 'none', }) - } + } else { setPopupShow(true) onFindEven() } }) } - const onFindEven = () => { - if (!state.discovering && !state.connected && !state.connecting) { startScan() } - } // 断开链接 const onDisconnect = () => { @@ -72,9 +72,11 @@ export default memo(() => { { - linkStatus == 1 && 请开启蓝牙 - || linkStatus == 2 && 未连接设备 - || linkStatus == 3 && {linkName} + linkStatus == 1 + ? 请开启蓝牙 + : linkStatus == 2 + ? 未连接设备 + : linkStatus == 3 ? {linkName} : null } @@ -89,5 +91,6 @@ export default memo(() => { - ) -}) + ) +} +export default memo(LinkBlueTooth) diff --git a/src/components/closeBtn/index.tsx b/src/components/closeBtn/index.tsx index 1323890..6037950 100644 --- a/src/components/closeBtn/index.tsx +++ b/src/components/closeBtn/index.tsx @@ -7,8 +7,7 @@ interface Params { onClose?: () => void styleObj?: Object } - -export default memo(({ onClose, styleObj = {} }: Params) => { +const CloseBtn = ({ onClose, styleObj = {} }: Params) => { return ( @@ -16,4 +15,5 @@ export default memo(({ onClose, styleObj = {} }: Params) => { ) -}) +} +export default memo(CloseBtn) diff --git a/src/components/iconfont/iconfont.tsx b/src/components/iconfont/iconfont.tsx index 26547db..ad741d2 100644 --- a/src/components/iconfont/iconfont.tsx +++ b/src/components/iconfont/iconfont.tsx @@ -1,8 +1,8 @@ import { Block, View } from '@tarojs/components' +import Taro from '@tarojs/taro' import type { FC } from 'react' import React, { useEffect, useState } from 'react' import './iconfont.scss' -import Taro from '@tarojs/taro' import classnames from 'classnames' const SystemWidth = Taro.getSystemInfoSync().windowWidth diff --git a/src/components/orderBtns/index copy.tsx b/src/components/orderBtns/index copy.tsx index 00bb4ee..883f48b 100644 --- a/src/components/orderBtns/index copy.tsx +++ b/src/components/orderBtns/index copy.tsx @@ -16,8 +16,7 @@ interface Param { }|null onClick?: (val: number) => void // 点击后触发的事件,返回订单状态 } - -export default memo(({ orderInfo, onClick }: Param) => { +const OrderBtns = ({ orderInfo, onClick }: Param) => { // 订单状态枚举 const { SaleOrderStatusBooking, @@ -93,15 +92,15 @@ export default memo(({ orderInfo, onClick }: Param) => { if (item.id == 1) { // 取消订单按钮 return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款 - } + } else if (item.id == 2) { // 去付款按钮 return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示 - } + } else if (item.id == 3) { // 申请退款, 只有大货才有 return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款 - } + } else if (item.id == 8) { // 退款按钮(直接退款不用申请), 只有散剪和剪板有 return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款 @@ -120,13 +119,6 @@ export default memo(({ orderInfo, onClick }: Param) => { }) }, [orderInfo]) - // 点击按钮操作 - const submitBtns = (val, index) => { - (val == 1) && cancelOrder(); // 取消订单按钮 - (val == 2) && onClick?.(2); // 去付款按钮 - (val == 6) && receiveOrder() // 确认收货 - } - // 取消订单 const { fetchData: cancelFetchData } = CancelOrderApi() const cancelOrder = () => { @@ -138,11 +130,11 @@ export default memo(({ orderInfo, onClick }: Param) => { if (res.success) { alert.success('取消成功') onClick?.(1) - } + } else { alert.none(res.msg) } - } + } else if (res.cancel) { console.log('用户点击取消') } @@ -162,18 +154,23 @@ export default memo(({ orderInfo, onClick }: Param) => { if (res.success) { onClick?.(6) alert.success('收货成功') - } + } else { alert.error('收货失败') } - } + } else if (res.cancel) { console.log('用户点击取消') } }, }) } - + // 点击按钮操作 + const submitBtns = (val, index) => { + (val == 1) && cancelOrder(); // 取消订单按钮 + (val == 2) && onClick?.(2); // 去付款按钮 + (val == 6) && receiveOrder() // 确认收货 + } // 显示更多按钮 const [showMore, setShowMore] = useState(false) const styleTop = useMemo(() => { @@ -202,4 +199,5 @@ export default memo(({ orderInfo, onClick }: Param) => { ) -}) +} +export default memo(OrderBtns) diff --git a/src/components/timePickerPopup/index.tsx b/src/components/timePickerPopup/index.tsx index edc9c7d..7b53258 100644 --- a/src/components/timePickerPopup/index.tsx +++ b/src/components/timePickerPopup/index.tsx @@ -1,7 +1,7 @@ -import Popup from '@/components/popup' import { memo } from 'react' import './index.scss' import TimePicker from '../timePicker' +import Popup from '@/components/popup' type DateArg = string | number | Date interface Props { diff --git a/src/pages/colorRelated/sampleComparison/index.tsx b/src/pages/colorRelated/sampleComparison/index.tsx index e1e3f1b..a39d7c9 100644 --- a/src/pages/colorRelated/sampleComparison/index.tsx +++ b/src/pages/colorRelated/sampleComparison/index.tsx @@ -7,7 +7,7 @@ import LinkBlueTooth from '../components/bluetooth/LinkBlueTooth' import styles from './index.module.scss' import { useBluetooth } from '@/use/contextBlueTooth' import { toRgb } from '@/common/bluetooth/color/colorSpace' -import { productabsorbcontrast } from '@/api/index' +import { ProductAbsorbContrast } from '@/api/index' import { alert } from '@/common/common' const SampleComparison = () => { @@ -82,7 +82,7 @@ const SampleComparison = () => { const [data, setData] = useState('') const [result, setResult] = useState('') - const { fetchData } = productabsorbcontrast() + const { fetchData } = ProductAbsorbContrast() const handTake = async() => { if (searchField.l1 === '') { Taro.showToast({ diff --git a/src/pages/customerDetails/index.tsx b/src/pages/customerDetails/index.tsx index ef2513a..27ccf5b 100644 --- a/src/pages/customerDetails/index.tsx +++ b/src/pages/customerDetails/index.tsx @@ -88,9 +88,9 @@ const CustomerDetails = () => { {infoObj?.purchaser_type_name || '暂无'} {infoObj?.sale_user_name || '暂无'} { - infoObj?.label_list?.map((item) => { + infoObj?.label_list?.map((item, key) => { return ( - {item.label_name} + {item.label_name} ) }) } diff --git a/src/pages/customerEditor/components/Form/index.tsx b/src/pages/customerEditor/components/Form/index.tsx index ab92e1c..eb9fc9d 100644 --- a/src/pages/customerEditor/components/Form/index.tsx +++ b/src/pages/customerEditor/components/Form/index.tsx @@ -24,7 +24,7 @@ interface Props { showBorder?: boolean handNav?: () => void } -export default memo((props: Props) => { +const Form = (props: Props) => { const { title = '标题', isQuire = true, @@ -70,4 +70,5 @@ export default memo((props: Props) => { {children} ) -}) +} +export default memo(Form) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 97e2874..b88d332 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -9,9 +9,8 @@ import ShopCart from '@/components/shoppingCart' import { goLink } from '@/common/common' import { KindListApi, ProductListApi } from '@/api/index' // import useLogin from '@/use/useLogin' -import { MpProductColorList, MpShoppingCartProductColorList } from '@/api/order' +import { ClientListApi, MpProductColorList, MpShoppingCartProductColorList } from '@/api/order' import { dataLoadingStatus, getFilterData } from '@/common/util' -import { ClientListApi } from '@/api/order' const Index = () => { // 获取客户 diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index d94c0eb..4249a2e 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -34,8 +34,7 @@ interface filterObj { sale_mode?: Number | undefined shipment_mode?: Number | undefined } - -export default () => { +const Order = () => { // 页码和页数 const [searchField, setSearchField] = useState<{ status: number | unknown; page: number; size: number; order_no: string }>({ status: -1, @@ -47,6 +46,21 @@ export default () => { // 获取订单列表 const { fetchData: listFetchData, state: orderState } = OrderListApi() const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) + // 筛选参数 + const [searchObj, setsearchObj] = useState({ + purchaser_id: '', + clientName: '', + sale_user_id: '', + saleuserName: '', + sale_mode: undefined, + shipment_mode: undefined, + }) + // 筛选内容展示 + const [showPopup, setshowPopup] = useState(false) + // 上拉加载数据 + const pageNum = useRef({ size: searchField.size, page: searchField.page }) + // 列表下拉刷新 + const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) const getOrderList = async() => { const res = await listFetchData({ ...getFilterData(searchField), @@ -57,8 +71,6 @@ export default () => { setRefresherTriggeredStatus(() => false) } - // 列表下拉刷新 - const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) const getRefresherRefresh = async() => { pageNum.current.size = 1 setRefresherTriggeredStatus(true) @@ -67,11 +79,9 @@ export default () => { // 数据加载状态 const statusMore = useMemo(() => { console.log({ list: orderData.list, total: orderData.total, status: orderState.loading }, '{ list: orderData.list, total: orderData.total, status: orderState.loading }') - return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading }) + return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading! }) }, [orderData, orderState]) - // 上拉加载数据 - const pageNum = useRef({ size: searchField.size, page: searchField.page }) const getScrolltolower = useCallback(() => { if (orderData.list.length < orderData.total) { pageNum.current.page++ @@ -106,8 +116,6 @@ export default () => { setOrderData(() => ({ list: [], total: 0 })) setSearchField(val => ({ ...val, order_no: e, size: 10 })) }, []) - // 筛选内容展示 - const [showPopup, setshowPopup] = useState(false) const showSelctPopup = () => { setshowPopup(true) } @@ -131,15 +139,6 @@ export default () => { })) }) - // 筛选参数 - const [searchObj, setsearchObj] = useState({ - purchaser_id: '', - clientName: '', - sale_user_id: '', - saleuserName: '', - sale_mode: undefined, - shipment_mode: undefined, - }) // 跳转选择客户 const navTo = (index) => { if (index === 1) { @@ -201,6 +200,18 @@ export default () => { } }, [searchObj]) + // 数组重置 + const resetArr = (arr) => { + arr.map((it) => { + it.checked = false + return it + }) + return arr + } + // 确认筛选 + const handSure = async() => { + getOrderList() + } // 重置 const handReset = () => { pageNum.current.page = 1 @@ -218,19 +229,6 @@ export default () => { const arrTwo = resetArr(deliveryList) setdeliveryList([...arrTwo]) } - - // 数组重置 - const resetArr = (arr) => { - arr.map((it) => { - it.checked = false - return it - }) - return arr - } - // 确认筛选 - const handSure = async() => { - getOrderList() - } // 扫描 const handScan = () => { Taro.scanCode({ @@ -358,6 +356,103 @@ export default () => { color: '#ffffff', }, ]) + + // 显示支付 + const [showPay, setShowPay] = useState(false) + + // 显示线下汇款 + const [showOffline, setShowOffine] = useState(false) + + // 扫码支付 + const [showSide, setShowSide] = useState(true) + const [title, setTitle] = useState('') + const [picUrl, setPicUrl] = useState('') + const { fetchData: payFetch } = GetPayCode() + const handScanpay = async() => { + const list: any = [] + itemObj.product_list.forEach((item) => { + item.product_colors.forEach((it) => { + list.push({ + product_code: item.code, + product_name: item.name, + product_color_code: it.product_color_code, + product_color_name: it.product_color_name, + num: it.roll.toString(), + weight: formatWeightDiv(it.actual_weight).toString(), + sale_price: (it.sale_price / 100).toString(), + total_price: + it.total_sale_price !== 0 + ? (it.total_sale_price / 100).toString() + : (it.estimate_amount / 100).toString(), + length: (it.length / 100).toString(), + weight_error: formatWeightDiv(it.weight_error).toString(), + }) + }) + }) + const query = { + list, + title: '面料销售电子确认单', + show_qrcode: true, + show_barcode: true, + show_wait_pay_amount: true, + order_type: itemObj.sale_mode_name, + shipment_mode: itemObj.shipment_mode_name, + company: itemObj.title_purchaser_name, + sale_user: itemObj.sale_user_name, + order_created_time: formatDateTime(itemObj.create_time), + order_no: itemObj.order_no, + target_user_name: itemObj.target_user_name, + target_address: itemObj.address_detail, + target_description: itemObj.remark, + pay_account: itemObj.transfer_remittance_account, + bank_account_name: itemObj.account_name, + bank_name: itemObj.bank_of_deposit, + pay_type: itemObj.settle_mode_name, + client: itemObj.purchaser_name, + phone: itemObj.target_user_phone, + order_total_length: (itemObj.total_number / 100).toString(), + order_total_price: ( + itemObj.bill_total_sale_price / 100 + ).toString(), + total_weight_error_discount: ( + itemObj.total_weight_error_discount / 100 + ).toString(), + order_total_num: itemObj.total_number.toString(), + qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${itemObj.order_no}`, + order_total_weight: (itemObj.total_weight / 1000).toString(), + estimate_amount: (itemObj.estimate_amount / 100).toString(), + total_sale_price: (itemObj.total_sale_price / 100).toString(), + show_total_sale_price: true, + show_total_weight_error_discount: true, + actual_amount: (itemObj.actual_amount / 100).toString(), + wait_pay_amount: (itemObj.wait_pay_amount / 100).toString(), + order_total_weight_error: ( + itemObj.total_weight_error / 1000 + ).toString(), + } + const res = await payFetch(query) + if (res.data) { + console.log(res.data.base64) + setShowSide(false) + setTitle('查看销售码单') + setPicUrl(res.data.base64) + } + } + // 选择支付方式 + const clickItem = (item) => { + if (item.name === '扫码支付') { handScanpay() } + if (item.name === '线下汇款') { setShowOffine(true) } + payList.map((it) => { + if (item.id === it.id) { + it.checked = true + } + else { + it.checked = false + } + return it + }) + setPayList([...payList]) + } const toPay = async(e, item) => { e.stopPropagation() @@ -445,99 +540,6 @@ export default () => { setTitle('待支付款项') setShowPay(true) } - - // 选择支付方式 - const clickItem = (item) => { - if (item.name === '扫码支付') { handScanpay() } - if (item.name === '线下汇款') { setShowOffine(true) } - payList.map((it) => { - if (item.id === it.id) { - it.checked = true - } - else { - it.checked = false - } - return it - }) - setPayList([...payList]) - } - - // 扫码支付 - const [showSide, setShowSide] = useState(true) - const [title, setTitle] = useState('') - const [picUrl, setPicUrl] = useState('') - const { fetchData: payFetch } = GetPayCode() - const handScanpay = async() => { - const list: any = [] - itemObj.product_list.forEach((item) => { - item.product_colors.forEach((it) => { - list.push({ - product_code: item.code, - product_name: item.name, - product_color_code: it.product_color_code, - product_color_name: it.product_color_name, - num: it.roll.toString(), - weight: formatWeightDiv(it.actual_weight).toString(), - sale_price: (it.sale_price / 100).toString(), - total_price: - it.total_sale_price !== 0 - ? (it.total_sale_price / 100).toString() - : (it.estimate_amount / 100).toString(), - length: (it.length / 100).toString(), - weight_error: formatWeightDiv(it.weight_error).toString(), - }) - }) - }) - const query = { - list, - title: '面料销售电子确认单', - show_qrcode: true, - show_barcode: true, - show_wait_pay_amount: true, - order_type: itemObj.sale_mode_name, - shipment_mode: itemObj.shipment_mode_name, - company: itemObj.title_purchaser_name, - sale_user: itemObj.sale_user_name, - order_created_time: formatDateTime(itemObj.create_time), - order_no: itemObj.order_no, - target_user_name: itemObj.target_user_name, - target_address: itemObj.address_detail, - target_description: itemObj.remark, - pay_account: itemObj.transfer_remittance_account, - bank_account_name: itemObj.account_name, - bank_name: itemObj.bank_of_deposit, - pay_type: itemObj.settle_mode_name, - client: itemObj.purchaser_name, - phone: itemObj.target_user_phone, - order_total_length: (itemObj.total_number / 100).toString(), - order_total_price: ( - itemObj.bill_total_sale_price / 100 - ).toString(), - total_weight_error_discount: ( - itemObj.total_weight_error_discount / 100 - ).toString(), - order_total_num: itemObj.total_number.toString(), - qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${itemObj.order_no}`, - order_total_weight: (itemObj.total_weight / 1000).toString(), - estimate_amount: (itemObj.estimate_amount / 100).toString(), - total_sale_price: (itemObj.total_sale_price / 100).toString(), - show_total_sale_price: true, - show_total_weight_error_discount: true, - actual_amount: (itemObj.actual_amount / 100).toString(), - wait_pay_amount: (itemObj.wait_pay_amount / 100).toString(), - order_total_weight_error: ( - itemObj.total_weight_error / 1000 - ).toString(), - } - const res = await payFetch(query) - if (res.data) { - console.log(res.data.base64) - setShowSide(false) - setTitle('查看销售码单') - setPicUrl(res.data.base64) - } - } - // 确认交易 const { fetchData: payOneFetch } = OrderPaymentOrderPaymentSubmission() const { fetchData: payTwoFetch } = OrderPaymentPreCollectOrderOrderPaymentSubmission() @@ -587,15 +589,10 @@ export default () => { // } } - // 显示支付 - const [showPay, setShowPay] = useState(false) - - // 显示线下汇款 - const [showOffline, setShowOffine] = useState(false) return ( - handScan()} defaultValue={searchField.order_no} showScan placeholder="搜索商品/名称/颜色/订单号" showBtn={false} changeOnSearch={getSearchData} debounceTime={300}> + handScan()} defaultValue={searchField.order_no} showScan placeholder="搜索商品/名称/颜色/订单号" showBtn={false} changeOnSearch={getSearchData}> showSelctPopup()}> {/* */} @@ -726,3 +723,4 @@ export default () => { ) } +export default Order diff --git a/src/pages/takeDelivery/index.tsx b/src/pages/takeDelivery/index.tsx index cb00aae..2219446 100644 --- a/src/pages/takeDelivery/index.tsx +++ b/src/pages/takeDelivery/index.tsx @@ -61,7 +61,6 @@ const Delivery: FC = () => { pageNum.current.page++ const size = pageNum.current.size * pageNum.current.page setSearch(e => ({ ...e, size })) - console.log(search, 11111) } }, [takeDeliveryOrderList]) diff --git a/src/store/index.ts b/src/store/index.ts index aaa7b73..3a27470 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -7,13 +7,15 @@ const composeEnhancers && (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize... - }) : compose + }) + : compose const middlewares = [ thunkMiddleware, ] if (process.env.NODE_ENV === 'development' && process.env.TARO_ENV !== 'quickapp') { + // eslint-disable-next-line @typescript-eslint/no-var-requires middlewares.push(require('redux-logger').createLogger()) } diff --git a/src/use/contextBlueTooth.tsx b/src/use/contextBlueTooth.tsx index 411dd55..dd4b246 100644 --- a/src/use/contextBlueTooth.tsx +++ b/src/use/contextBlueTooth.tsx @@ -69,7 +69,10 @@ const stateObj: BluetoothStateType = { // 取色仪主动返回的数据 deviceLab: null, } -const ContextBlueTooth = (props) => { +interface PropsType { + children?: React.ReactNode +} +const ContextBlueTooth = (props: PropsType) => { const refStatus = useRef(stateObj) const [state, setState] = useState(refStatus.current)