diff --git a/.eslintrc b/.eslintrc index c311d0c..943159f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,6 +4,9 @@ "no-console": "off", "@typescript-eslint/no-shadow": "off", "@typescript-eslint/no-unused-vars": "off", - "eqeqeq": "off" + "eqeqeq": "off", + "no-prototype-builtins": "off", + "import/first": "off", + "react/no-children-prop": "off" } } diff --git a/project.private.config.json b/project.private.config.json index ce8d630..04498e7 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -236,5 +236,5 @@ ] } }, - "libVersion": "2.27.3" + "libVersion": "2.28.0" } \ No newline at end of file diff --git a/src/api/addressList.ts b/src/api/addressList.ts index c95ca2b..5592606 100644 --- a/src/api/addressList.ts +++ b/src/api/addressList.ts @@ -12,35 +12,35 @@ export const GetAddressListApi = () => { } // 获取客户地址 -export const mppurchaseraddresslist = () => { +export const MpPurchaserAddressList = () => { return useRequest({ url: '/v2/mp/purchaser/address/list', method: 'get', }) } // 新增客户地址 -export const mppurchaseraddress = () => { +export const MpPurchaserAddress = () => { return useRequest({ url: '/v2/mp/purchaser/address', method: 'post', }) } // 获取编辑地址信息 -export const mppurchaseraddressget = () => { +export const MpPurchaserAddressGet = () => { return useRequest({ url: '/v2/mp/purchaser/address', method: 'get', }) } // 编辑收货地址信息 -export const mppurchaseraddressput = () => { +export const MpPurchaserAddressPut = () => { return useRequest({ url: '/v2/mp/purchaser/address', method: 'put', }) } // 删除收货地址信息 -export const mppurchaseraddressdelect = () => { +export const MpPurchaserAddressDelete = () => { return useRequest({ url: '/v2/mp/purchaser/address', method: 'delete', diff --git a/src/api/customer.ts b/src/api/customer.ts index 9afde1f..ee34004 100644 --- a/src/api/customer.ts +++ b/src/api/customer.ts @@ -1,35 +1,35 @@ import { useRequest } from '@/use/useHttp' // 获取客户信息 -export const mppurchaser = () => { +export const MpPurchaser = () => { return useRequest({ url: '/v2/mp/purchaser', method: 'get', }) } // 新建客户 -export const mppurchaserpost = () => { +export const MpPurchaserPost = () => { return useRequest({ url: '/v2/mp/purchaser', method: 'post', }) } // 编辑客户 -export const mppurchaserput = () => { +export const MpPurchaserPut = () => { return useRequest({ url: '/v2/mp/purchaser', method: 'put', }) } // 获取标签列表 -export const mppurchaserlist = () => { +export const MpPurchaserList = () => { return useRequest({ url: '/v2/mp/purchaser/label/list', method: 'get', }) } // 保存标签 -export const mppurchaserlabeladd = () => { +export const MpPurchaserLabelAdd = () => { return useRequest({ url: '/v2/mp/purchaser/label/add', method: 'post', diff --git a/src/api/index.ts b/src/api/index.ts index 41f4077..fc037d6 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -54,7 +54,7 @@ export { * 系列列表 * @returns */ -export const kindListApi = () => { +export const KindListApi = () => { return useRequest({ url: '/v2/mp/product/kind/list', method: 'get', diff --git a/src/api/newCollection.ts b/src/api/newCollection.ts index a36f25d..3f7f30f 100644 --- a/src/api/newCollection.ts +++ b/src/api/newCollection.ts @@ -1,35 +1,35 @@ import { useRequest } from '@/use/useHttp' // 收款单列表 -export const mpcashManagementOrderlist = () => { +export const MpCashManagementOrderList = () => { return useRequest({ url: '/v2/mp/cashManagementOrder/list', method: 'get', }) } // 收款单详情 -export const mpcashManagementOrder = () => { +export const MpCashManagementOrder = () => { return useRequest({ url: '/v2/mp/cashManagementOrder', method: 'get', }) } // 收款账号 -export const mpcashManagementOrderaccount = () => { +export const MpCashManagementOrderAccount = () => { return useRequest({ url: '/v2/mp/cashManagementOrder/account', method: 'get', }) } // 新建收款单 -export const mpcashManagementOrderpost = () => { +export const MpCashManagementOrderPost = () => { return useRequest({ url: '/v2/mp/cashManagementOrder', method: 'post', }) } // 扫描获取应收单的客户信息 -export const mpshouldCollectOrderpurchaser = () => { +export const MpShouldCollectOrderPurchaser = () => { return useRequest({ url: '/v2/mp/shouldCollectOrder/purchaser', method: 'get', diff --git a/src/api/order.ts b/src/api/order.ts index f3c0a50..d005496 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -1,7 +1,7 @@ import { useRequest } from '@/use/useHttp' import { CAP_HTML_TO_IMAGE_BASE_URL } from '@/common/constant' -export const mpenumsaleorderstatus = () => { +export const MpEnumSaleOrderStatus = () => { return useRequest({ url: '/v2/mp/enum/filterMPSaleOrderStatus', method: 'get', @@ -30,70 +30,70 @@ export const ClientListApi = () => { }) } // 面料种类列表 -export const mpproductcolorlist = () => { +export const MpProductColorList = () => { return useRequest({ url: '/v2/mp/product/color/list', method: 'get', }) } // 购物车提交 -export const mpsaleOrderpreView = () => { +export const MpSaleOrderPreview = () => { return useRequest({ url: '/v2/mp/saleOrder/preView', method: 'put', }) } // 业务员枚举 -export const mpenumsaleUserlist = () => { +export const MpEnumSaleUserList = () => { return useRequest({ url: '/v2/mp/enum/saleUser/list', method: 'get', }) } // 订单详情 -export const mpsaleOrder = () => { +export const MpSaleOrder = () => { return useRequest({ url: '/v2/mp/saleOrder', method: 'get', }) } // 取消订单 -export const mpsaleOrdercancel = () => { +export const MpSaleOrderCancel = () => { return useRequest({ url: '/v2/mp/saleOrder/cancel', method: 'put', }) } // 再次购买 -export const mpshoppingCartproductColorlist = () => { +export const MpShoppingCartProductColorList = () => { return useRequest({ url: '/v2/mp/shoppingCart/productColor/list', method: 'post', }) } // 获取账期付款 -export const orderPaymentorderPaymentMethodInfo = () => { +export const OrderPaymentOrderPaymentMethodInfo = () => { return useRequest({ url: '/v2/mp/orderPayment/orderPaymentMethodInfo', method: 'get', }) } // 预收单获取接口信息 -export const orderPaymentpreCollectOrderorderPaymentMethodInfo = () => { +export const OrderPaymentPreCollectOrderOrderPaymentMethodInfo = () => { return useRequest({ url: '/v2/mp/orderPayment/preCollectOrder/orderPaymentMethodInfo', method: 'get', }) } // 确认交易 -export const orderPaymentorderPaymentSubmission = () => { +export const OrderPaymentOrderPaymentSubmission = () => { return useRequest({ url: '/v2/mp/orderPayment/orderPaymentSubmission', method: 'put', }) } // 订单预支付提交 -export const orderPaymentpreCollectOrderorderPaymentSubmission = () => { +export const OrderPaymentPreCollectOrderOrderPaymentSubmission = () => { return useRequest({ url: '/v2/mp/orderPayment/preCollectOrder/orderPaymentSubmission', method: 'put', @@ -120,70 +120,70 @@ export const GetReturnPayCode = () => { }) } // 编辑备注信息 -export const mpsaleOrderput = () => { +export const MpSaleOrderPut = () => { return useRequest({ url: '/v2/mp/saleOrder', method: 'put', }) } // 修改销售单的收货地址 -export const mpsaleOrderaddress = () => { +export const MpSaleOrderAddress = () => { return useRequest({ url: '/v2/mp/saleOrder/address', method: 'put', }) } // 关键字搜索历史 -export const mpsearchHistorylist = () => { +export const MpSearchHistoryList = () => { return useRequest({ url: '/v2/mp/searchHistory/list', method: 'get', }) } // 添加关键字搜索 -export const mpsearchHistory = () => { +export const MpSearchHistory = () => { return useRequest({ url: '/v2/mp/searchHistory', method: 'post', }) } // 确认收货 -export const mpsaleOrderreceive = () => { +export const MpSaleOrderReceive = () => { return useRequest({ url: '/v2/mp/saleOrder/receive', method: 'put', }) } // 退货原因 -export const mpenumreturnOrderreturnReason = () => { +export const MpEnumReturnOrderReturnReason = () => { return useRequest({ url: '/v2/mp/enum/returnOrder/returnReason', method: 'get', }) } // 二次选择退货原因 -export const mpenumreturnExplain = () => { +export const MpEnumReturnExplain = () => { return useRequest({ url: '/v2/mp/enum/returnExplain', method: 'get', }) } // 货物状况 -export const mpenumreturngoodsStatus = () => { +export const MpEnumReturnGoodsStatus = () => { return useRequest({ url: '/v2/mp/enum/return/goodsStatus', method: 'get', }) } // 申请退货 -export const mpreturnApplyOrder = () => { +export const MpReturnApplyOrder = () => { return useRequest({ url: '/v2/mp/returnApplyOrder', method: 'put', }) } // 退款说明 -export const mpenumrefundExplainone = () => { +export const MpEnumRefundExplainOne = () => { return useRequest({ url: '/v2/mp/enum/refundExplain', method: 'get', @@ -191,14 +191,14 @@ export const mpenumrefundExplainone = () => { } // 提交订单 -export const mpsaleOrderpost = () => { +export const MpSaleOrderPost = () => { return useRequest({ url: '/v2/mp/saleOrder', method: 'post', }) } // 修改销售单物流方式 -export const mpsaleOrdershipmentMode = () => { +export const MpSaleOrderShipmentMode = () => { return useRequest({ url: '/v2/mp/saleOrder/shipmentMode', method: 'put', diff --git a/src/api/refound.ts b/src/api/refound.ts index 93b01b8..2aa0245 100644 --- a/src/api/refound.ts +++ b/src/api/refound.ts @@ -1,42 +1,42 @@ import { useRequest } from '@/use/useHttp' // 售后订单列表 -export const mpreturnApplyOrderlist = () => { +export const MpReturnApplyOrderList = () => { return useRequest({ url: '/v2/mp/returnApplyOrder/list', method: 'get', }) } // 售后状态枚举 -export const mpenumreturnStage = () => { +export const MpEnumReturnStage = () => { return useRequest({ url: '/v2/mp/enum/returnStage', method: 'get', }) } // 退款类型枚举 -export const mpenumreturnType = () => { +export const MpEnumReturnType = () => { return useRequest({ url: '/v2/mp/enum/returnType', method: 'get', }) } // 售后详情 -export const mpreturnApplyOrder = () => { +export const MpReturnApplyOrder = () => { return useRequest({ url: '/v2/mp/returnApplyOrder', method: 'get', }) } // 取消退货 -export const returnApplyOrdercancel = () => { +export const ReturnApplyOrderCancel = () => { return useRequest({ url: '/v2/mp/returnApplyOrder/cancel', method: 'post', }) } // 售后确认上传附件 -export const returnApplyOrderuploadAccessory = () => { +export const ReturnApplyOrderUploadAccessory = () => { return useRequest({ url: '/v2/mp/returnApplyOrder/uploadAccessory', method: 'put', diff --git a/src/api/search.ts b/src/api/search.ts index 2710845..a4848a2 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -1,6 +1,6 @@ import { useRequest } from '@/use/useHttp' // 搜索商品 -export const mpproductlist = () => { +export const MpProductList = () => { return useRequest({ url: '/v2/mp/product/list', method: 'get', diff --git a/src/app.tsx b/src/app.tsx index 6dbceb6..57276e3 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,10 +1,10 @@ +import Taro, { onAppShow } from '@tarojs/taro' import type { FC } from 'react' import { Provider } from 'react-redux' import configStore from './store' +import { shareShop } from './common/util' import ContextBlueTooth from '@/use/contextBlueTooth' import './app.scss' -import Taro, { onAppShow, useDidShow } from '@tarojs/taro' -import { shareShop } from './common/util' interface ParamsType { children?: React.ReactNode diff --git a/src/common/bluetooth/color/colorDiff.js b/src/common/bluetooth/color/colorDiff.js index ae8066d..57d5da4 100644 --- a/src/common/bluetooth/color/colorDiff.js +++ b/src/common/bluetooth/color/colorDiff.js @@ -1,4 +1,4 @@ -module.exports = function(lab1, lab2) { +module.exports = function(lab1, lab2) { const rgb2labArray1 = lab1 const rgb2labArray2 = lab2 @@ -10,35 +10,35 @@ module.exports = function(lab1, lab2) { const a2 = rgb2labArray2[1] const b2 = rgb2labArray2[2] - const avg_lp = (l1 + l2) / 2 - const c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2)) - const c2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2)) - const avg_c = (c1 + c2) / 2 - const g = (1 - Math.sqrt(Math.pow(avg_c, 7) / (Math.pow(avg_c, 7) + Math.pow(25, 7)))) / 2 + const avg_lp = (l1 + l2) / 2 + const c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2)) + const c2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2)) + const avg_c = (c1 + c2) / 2 + const g = (1 - Math.sqrt(Math.pow(avg_c, 7) / (Math.pow(avg_c, 7) + Math.pow(25, 7)))) / 2 - const a1p = a1 * (1 + g) - const a2p = a2 * (1 + g) + const a1p = a1 * (1 + g) + const a2p = a2 * (1 + g) - const c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2)) - const c2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b2, 2)) + const c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2)) + const c2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b2, 2)) - const avg_cp = (c1p + c2p) / 2 + const avg_cp = (c1p + c2p) / 2 - let h1p = rad2deg(Math.atan2(b1, a1p)) - if (h1p < 0) { + let h1p = rad2deg(Math.atan2(b1, a1p)) + if (h1p < 0) { h1p = h1p + 360 } - let h2p = rad2deg(Math.atan2(b2, a2p)) - if (h2p < 0) { + let h2p = rad2deg(Math.atan2(b2, a2p)) + if (h2p < 0) { h2p = h2p + 360 } - const avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2 + const avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2 - const t = 1 - 0.17 * Math.cos(deg2rad(avg_hp - 30)) + 0.24 * Math.cos(deg2rad(2 * avg_hp)) + 0.32 * Math.cos(deg2rad(3 * avg_hp + 6)) - 0.2 * Math.cos(deg2rad(4 * avg_hp - 63)) + const t = 1 - 0.17 * Math.cos(deg2rad(avg_hp - 30)) + 0.24 * Math.cos(deg2rad(2 * avg_hp)) + 0.32 * Math.cos(deg2rad(3 * avg_hp + 6)) - 0.2 * Math.cos(deg2rad(4 * avg_hp - 63)) - let delta_hp = h2p - h1p + let delta_hp = h2p - h1p if (Math.abs(delta_hp) > 180) { if (h2p <= h1p) { delta_hp += 360 @@ -48,18 +48,18 @@ module.exports = function(lab1, lab2) { } } - const delta_lp = l2 - l1 - const delta_cp = c2p - c1p + const delta_lp = l2 - l1 + const delta_cp = c2p - c1p - delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2) + delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2) - const s_l = 1 + ((0.015 * Math.pow(avg_lp - 50, 2)) / Math.sqrt(20 + Math.pow(avg_lp - 50, 2))) - const s_c = 1 + 0.045 * avg_cp - const s_h = 1 + 0.015 * avg_cp * t + const s_l = 1 + ((0.015 * Math.pow(avg_lp - 50, 2)) / Math.sqrt(20 + Math.pow(avg_lp - 50, 2))) + const s_c = 1 + 0.045 * avg_cp + const s_h = 1 + 0.015 * avg_cp * t - const delta_ro = 30 * Math.exp(-(Math.pow((avg_hp - 275) / 25, 2))) - const r_c = 2 * Math.sqrt(Math.pow(avg_cp, 7) / (Math.pow(avg_cp, 7) + Math.pow(25, 7))) - const r_t = -r_c * Math.sin(2 * deg2rad(delta_ro)) + const delta_ro = 30 * Math.exp(-(Math.pow((avg_hp - 275) / 25, 2))) + const r_c = 2 * Math.sqrt(Math.pow(avg_cp, 7) / (Math.pow(avg_cp, 7) + Math.pow(25, 7))) + const r_t = -r_c * Math.sin(2 * deg2rad(delta_ro)) const kl = 1; const kc = 1; const kh = 1 @@ -67,10 +67,10 @@ module.exports = function(lab1, lab2) { return delta_e - function rad2deg(rad) { + function rad2deg(rad) { return 360 * rad / (2 * Math.PI) } - function deg2rad(deg) { + function deg2rad(deg) { return (2 * Math.PI * deg) / 360 } } diff --git a/src/common/bluetooth/color/lab.js b/src/common/bluetooth/color/lab.js index 6741df7..d2bb0a3 100644 --- a/src/common/bluetooth/color/lab.js +++ b/src/common/bluetooth/color/lab.js @@ -1,4 +1,6 @@ +/* eslint-disable import/no-commonjs */ + const xyz = require('./xyz') module.exports = { @@ -17,7 +19,7 @@ module.exports = { if (l <= 8) { y = (l * 100) / 903.3 y2 = (7.787 * (y / 100)) + (16 / 116) - } + } else { y = 100 * Math.pow((l + 16) / 116, 3) y2 = Math.pow(y / 100, 1 / 3) @@ -32,11 +34,10 @@ module.exports = { } // extend xyz -xyz.lab = function(xyz) { - let x = xyz[0] - let y = xyz[1] - let z = xyz[2] - let l; let a; let b +xyz.lab = function(xyz1) { + let x = xyz1[0] + let y = xyz1[1] + let z = xyz1[2] x /= 95.047 y /= 100 @@ -46,9 +47,9 @@ xyz.lab = function(xyz) { y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116) z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116) - l = (116 * y) - 16 - a = 500 * (x - y) - b = 200 * (y - z) + const l = (116 * y) - 16 + const a = 500 * (x - y) + const b = 200 * (y - z) return [l, a, b] } diff --git a/src/common/bluetooth/color/rgb.js b/src/common/bluetooth/color/rgb.js index 0aba252..c0c9ea8 100644 --- a/src/common/bluetooth/color/rgb.js +++ b/src/common/bluetooth/color/rgb.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-commonjs */ module.exports = { name: 'rgb', diff --git a/src/common/bluetooth/color/xyz.js b/src/common/bluetooth/color/xyz.js index f25cb3b..6c1dee0 100644 --- a/src/common/bluetooth/color/xyz.js +++ b/src/common/bluetooth/color/xyz.js @@ -1,4 +1,6 @@ +/* eslint-disable import/no-commonjs */ + const rgb = require('./rgb') const xyz = { @@ -86,15 +88,15 @@ xyz.rgb = function(_xyz, white) { g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175) b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878) - r = r > 0.0031308 + r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) : r = (r * 12.92) - g = g > 0.0031308 + g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) : g = (g * 12.92) - b = b > 0.0031308 + b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) : b = (b * 12.92) @@ -112,10 +114,10 @@ xyz.rgb = function(_xyz, white) { * * @return {Array} XYZ channels */ -rgb.xyz = function(rgb, white) { - let r = rgb[0] / 255 - let g = rgb[1] / 255 - let b = rgb[2] / 255 +rgb.xyz = function(rgb1, white) { + let r = rgb1[0] / 255 + let g = rgb1[1] / 255 + let b = rgb1[2] / 255 // assume sRGB r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92) diff --git a/src/common/bluetooth/utils.js b/src/common/bluetooth/utils.js index d6b0ab2..15c9da6 100644 --- a/src/common/bluetooth/utils.js +++ b/src/common/bluetooth/utils.js @@ -55,11 +55,11 @@ export function uint8ArrayToHex(raw) { } // 二进制转字符串(ascii) -export function bufferToString(buffer) { - let str = '' - for (const code of buffer) { - if (code === 0) { break } - str += utf82string(code) - } - return str -} +// export function bufferToString(buffer) { +// let str = '' +// for (const code of buffer) { +// if (code === 0) { break } +// str += utf82string(code) +// } +// return str +// } diff --git a/src/common/format.js b/src/common/format.js index 2dcf9eb..bd68e9a 100644 --- a/src/common/format.js +++ b/src/common/format.js @@ -1,5 +1,27 @@ import { IMG_CND_Prefix } from './constant' - +/** + * 精度 + * @param {*} num + * @param {*} precision + * @returns + */ +export const strip = (num, precision = 12) => { + return +parseFloat(num.toPrecision(precision)) +} +/** + * + * @param {千位分割付} number + * @returns + */ +export const numberWithCommas = ({ number = 0, digit = 2 }) => { + if (!Number.isNaN(Number(number))) { + // return parseFloat(number).toFixed(digit).replace(/^\B(? { } } -/** - * 精度 - * @param {*} num - * @param {*} precision - * @returns - */ -export const strip = (num, precision = 12) => { - return +parseFloat(num.toPrecision(precision)) -} - -/** - * 转换金额单位 - * @param {*} num 金额 / 数值 - * @param {*} digit 转换单位 - * @returns - */ -export const formatMillionYuan = (num, digit = 10000) => { - return num / digit > 1 ? { num: toDecimal2(num / digit), million: true } : { num, million: false } -} - /** * 数值保留两位小数 * @param {*} x @@ -145,7 +147,7 @@ export const formatMillionYuan = (num, digit = 10000) => { */ export const toDecimal2 = (x) => { let f = parseFloat(x) - if (isNaN(f)) { + if (Number.isNaN(f)) { return 0 } f = `${f}` @@ -162,6 +164,16 @@ export const toDecimal2 = (x) => { return f } +/** + * 转换金额单位 + * @param {*} num 金额 / 数值 + * @param {*} digit 转换单位 + * @returns + */ +export const formatMillionYuan = (num, digit = 10000) => { + return num / digit > 1 ? { num: toDecimal2(num / digit), million: true } : { num, million: false } +} + // 匹配前缀 例如://xxx.com 或者 http://xxx.com 或者 https://xxx.com // eslint-disable-next-line no-useless-escape const URL_REGEXP = /(https?:)?\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&=]*)/gi @@ -231,21 +243,6 @@ export const isLabImage = (imgurl, rgb, suffix = '!w200') => { } } -/** - * - * @param {千位分割付} number - * @returns - */ -export const numberWithCommas = ({ number = 0, digit = 2 }) => { - if (!isNaN(Number(number))) { - // return parseFloat(number).toFixed(digit).replace(/^\B(? { if (cls) { diff --git a/src/common/shortCode/index.js b/src/common/shortCode/index.js index 22d6dc5..af2ac37 100644 --- a/src/common/shortCode/index.js +++ b/src/common/shortCode/index.js @@ -1,6 +1,20 @@ import Taro from '@tarojs/taro' import { BASE_URL } from '../constant' +// 绑定上下级 +const bindParent = (share_user_id) => { + // 绑定上下级 + Taro.request({ + url: `${BASE_URL}/v1/mall/shortCode/bind`, + method: 'POST', + data: { share_user_id }, + success: (res) => { + if (res.data.code == 0) { + // 绑定上下级 + } + }, + }) +} // 解析短码(主要用于右上角按钮分享) export const analysisShortCodeApi = (val) => { // 解析短码 @@ -16,18 +30,3 @@ export const analysisShortCodeApi = (val) => { }, }) } - -// 绑定上下级 -const bindParent = (share_user_id) => { - // 绑定上下级 - Taro.request({ - url: `${BASE_URL}/v1/mall/shortCode/bind`, - method: 'POST', - data: { share_user_id }, - success: (res) => { - if (res.data.code == 0) { - // 绑定上下级 - } - }, - }) -} diff --git a/src/components/AddressList/index.tsx b/src/components/AddressList/index.tsx index 2bc0af2..45f6ab9 100644 --- a/src/components/AddressList/index.tsx +++ b/src/components/AddressList/index.tsx @@ -2,11 +2,11 @@ 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 { 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' +import { MpSaleOrderAddress } from '@/api/order' interface Params { refresherEnabled?: boolean// 是否开启刷新 @@ -19,12 +19,14 @@ interface Params { } // 地址列表 -const AddressList = memo(forwardRef((props: Params, AddressListRef) => { +const AddressList = (props: Params, AddressListRef) => { const pages = Taro.getCurrentPages() // 获取当前的页面栈 const prevPage = pages[pages.length - 2] + // 焦点 + const [focusId, setFocusId] = useState() const { addButtonEnabled = true, focusBorderEnabled = false } = props - const { fetchData, state } = mppurchaseraddresslist() + const { fetchData, state } = MpPurchaserAddressList() // 获取数据 const getData = async() => { const result = await fetchData({ purchaser_id: props.purchaser_id }) @@ -64,12 +66,10 @@ const AddressList = memo(forwardRef((props: Params, AddressListRef) => { setRefreshState(false) } const data = Array.from({ length: 15 }) - // 焦点 - const [focusId, setFocusId] = useState() const router = useRouter() const [addressObj, setAddressObj] = useState({}) // 列表选择 - const { fetchData: selectFetch } = mpsaleOrderaddress() + const { fetchData: selectFetch } = MpSaleOrderAddress() const handleSelect = async(item: any, index: number) => { if (router.params.orderId && router.params.orderId != '-100') { console.log(typeof (router.params.orderId) != 'undefined', 'router.params.orderId') @@ -126,7 +126,7 @@ const AddressList = memo(forwardRef((props: Params, AddressListRef) => { // data.length>0? // data.map((item,index)=>{ return ( - handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}> + handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}> {item.name} {item.phone} @@ -164,6 +164,6 @@ const AddressList = memo(forwardRef((props: Params, AddressListRef) => { {addButtonEnabled && 添加收货地址} ) -})) +} -export default AddressList +export default memo(forwardRef(AddressList)) diff --git a/src/components/BottomBtns/index.tsx b/src/components/BottomBtns/index.tsx index e638e8c..2bc8316 100644 --- a/src/components/BottomBtns/index.tsx +++ b/src/components/BottomBtns/index.tsx @@ -20,8 +20,7 @@ interface prosObj { showDetail?: boolean goodsObj?: any } - -export default memo(forwardRef((props: prosObj, ref) => { +const BottomBtns = (props: prosObj, ref) => { const { obj = { sale_mode: 0, @@ -192,4 +191,5 @@ export default memo(forwardRef((props: prosObj, ref) => { ) -})) +} +export default memo(forwardRef(BottomBtns)) diff --git a/src/components/BottomCustomer/index.tsx b/src/components/BottomCustomer/index.tsx index d75e8af..d245ebd 100644 --- a/src/components/BottomCustomer/index.tsx +++ b/src/components/BottomCustomer/index.tsx @@ -10,8 +10,7 @@ interface prosObj { clientId?: Number clientName?: string } - -export default memo((props: prosObj) => { +const BottomCustomer = (props: prosObj) => { const { isDisabled = true, handSure, @@ -32,4 +31,5 @@ export default memo((props: prosObj) => { ) -}) +} +export default memo(BottomCustomer) diff --git a/src/components/FromList/index.tsx b/src/components/FromList/index.tsx index 794c0c1..83102b6 100644 --- a/src/components/FromList/index.tsx +++ b/src/components/FromList/index.tsx @@ -19,7 +19,7 @@ interface ListParams{ } // 表单列表 -const FromList = memo((props: ListParams) => { +const FromList = (props: ListParams) => { const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props return ( @@ -37,11 +37,11 @@ const FromList = memo((props: ListParams) => { && props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" /> } - : type == 'textarea' + : type == 'textarea' ? - || toggleShowRealTextarea(true)}>{descData.value || placeholder} + {(descData.show && !onlyRead) + ? + : toggleShowRealTextarea(true)}>{descData.value || placeholder} } {`${descData.number}/${descData.count}`} ) -}) +} +export default memo(TextareaEnhance) diff --git a/src/components/timePicker/index.tsx b/src/components/timePicker/index.tsx index 8bb0a56..7d36b9f 100644 --- a/src/components/timePicker/index.tsx +++ b/src/components/timePicker/index.tsx @@ -12,8 +12,7 @@ interface Props { start?: DateArg onSelectDate?: (any) => void } - -export default memo((props: Props) => { +const TimePicker = (props: Props) => { const { start = '', end = '', onSelectDate } = props const [time, setTime] = useState({}) @@ -49,4 +48,5 @@ export default memo((props: Props) => { */} ) -}) +} +export default memo(TimePicker) diff --git a/src/components/timePickerPopup/index.tsx b/src/components/timePickerPopup/index.tsx index 32c3f43..edc9c7d 100644 --- a/src/components/timePickerPopup/index.tsx +++ b/src/components/timePickerPopup/index.tsx @@ -11,8 +11,7 @@ interface Props { start?: DateArg onSelectDate?: (any) => void } - -export default memo((props: Props) => { +const TimePickerPopup = (props: Props) => { const { showTime = false, closePopup, start = '', end = '', onSelectDate } = props return ( @@ -20,4 +19,5 @@ export default memo((props: Props) => { ) -}) +} +export default memo(TimePickerPopup) diff --git a/src/components/toolTips/index.tsx b/src/components/toolTips/index.tsx index b8d393b..48bfb33 100644 --- a/src/components/toolTips/index.tsx +++ b/src/components/toolTips/index.tsx @@ -54,7 +54,7 @@ const popoverStyle = { color: '#333333', } -const ToolTip = forwardRef((props, ref) => { +const ToolTip = (props: ToolTipPropsType, ref) => { const id = useId() const [, setForceUpdate] = useState({}) const { placement = 'top-start', defaultVisible = false, onVisibleChange, children, content = '请填入提示信息', customClassName, customStyle, customContentStyle } = props @@ -326,6 +326,6 @@ const ToolTip = forwardRef((props, ref) => { ) -}) +} -export default ToolTip +export default forwardRef(ToolTip) diff --git a/src/components/uploadImage/index.tsx b/src/components/uploadImage/index.tsx index 0d78b51..65f34f2 100644 --- a/src/components/uploadImage/index.tsx +++ b/src/components/uploadImage/index.tsx @@ -13,11 +13,13 @@ interface ImageParam { defaultList?: string[] onlyRead?: boolean } -const PictureItem = memo(({ onChange, defaultList, onlyRead = false }) => { +const PictureItem = ({ onChange, defaultList, onlyRead = false }: ImageParam) => { const { getWxPhoto, getChatPhoto } = useUploadCDNImg() const [imageList, setImageLise] = useState([]) - + // 筛选内容展示 + const [showPopup, setshowPopup] = useState(false) + const [List, setList] = useState([{ id: 1, name: '手机相册', check: false }, { id: 2, name: '从微信对话选择', check: false }]) useEffect(() => { setImageLise(defaultList || []) }, [defaultList]) @@ -29,17 +31,18 @@ const PictureItem = memo(({ onChange, defaultList, onlyRead = false // 上传图片逻辑 const handPic = async(id) => { + let list: any // let resArr = List.filter(item => { // return item.check // }) if (id == 1) { - var list: any = await getWxPhoto('after-sale', 5) - } + list = await getWxPhoto('after-sale', 5) + } else { - var list: any = await getChatPhoto('after-sale', 5) + list = await getChatPhoto('after-sale', 5) } const images: any[] = [] - list?.map((item) => { + list?.forEach((item) => { images.push(item.url) }) setImageLise([...imageList, ...images]) @@ -67,15 +70,12 @@ const PictureItem = memo(({ onChange, defaultList, onlyRead = false }) } - // 筛选内容展示 - const [showPopup, setshowPopup] = useState(false) - const [List, setList] = useState([{ id: 1, name: '手机相册', check: false }, { id: 2, name: '从微信对话选择', check: false }]) // 点击选择的方式 const handItem = (item) => { List.map((it) => { if (item.id == it.id) { it.check = true - } + } else { it.check = false } @@ -89,7 +89,7 @@ const PictureItem = memo(({ onChange, defaultList, onlyRead = false <> {imageList?.map((item, index) => ( - + {!onlyRead && delImage(index)}> @@ -119,6 +119,6 @@ const PictureItem = memo(({ onChange, defaultList, onlyRead = false ) -}) +} -export default PictureItem +export default memo(PictureItem) diff --git a/src/custom-tab-bar/index.tsx b/src/custom-tab-bar/index.tsx index 47d1562..f24aef5 100644 --- a/src/custom-tab-bar/index.tsx +++ b/src/custom-tab-bar/index.tsx @@ -35,16 +35,15 @@ const CustomTabBar: FC = () => { console.log('selectedId', selectedId) const dispatch = useDispatch>() - + const setSelected = (id: TabBarIndexMap[number]['id']) => { + dispatch({ type: TabBarType.SET_SELECTED, data: { tabItem, selectedId: id } }) + } const handleSelectTabItem = (id: TabBarIndexMap[number]['id']) => { return () => { setSelected(id) - Taro.switchTab({ url: tabItem?.find(item => item.id === id)?.pagePath! }) + Taro.switchTab({ url: tabItem?.find(item => item.id === id)?.pagePath as string }) } } - const setSelected = (id: TabBarIndexMap[number]['id']) => { - dispatch({ type: TabBarType.SET_SELECTED, data: { tabItem, selectedId: id } }) - } return ( diff --git a/src/index.html b/src/index.html index ec38302..5716178 100644 --- a/src/index.html +++ b/src/index.html @@ -10,7 +10,8 @@ diff --git a/src/pages/accountPage/index.tsx b/src/pages/accountPage/index.tsx index 0ca4d59..e4a4d6b 100644 --- a/src/pages/accountPage/index.tsx +++ b/src/pages/accountPage/index.tsx @@ -4,11 +4,11 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import Search from '@/components/search' -import { mpcashManagementOrderaccount } from '@/api/newCollection' +import { MpCashManagementOrderAccount } from '@/api/newCollection' import InfiniteScroll from '@/components/infiniteScroll' import { dataLoadingStatus, getFilterData } from '@/common/util' -export default () => { +const AccountPage = () => { const [search, setSearch] = useState({ search_name: null, page: 1, @@ -16,7 +16,7 @@ export default () => { }) const [clentList, setClientlist] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) - const { fetchData: clitentFetch, state: orderState } = mpcashManagementOrderaccount() + const { fetchData: clitentFetch, state: orderState } = MpCashManagementOrderAccount() // 数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: clentList.list, total: clentList.total, status: orderState.loading! }) @@ -27,22 +27,8 @@ export default () => { bankName: '', }) - // 输入了搜索关键字 - const getSearchData = useCallback((eq) => { - pageNum.current.page = 1 - setClientlist(() => ({ list: [], total: 0 })) - setSearch(e => ({ ...e, search_name: eq, size: 10 })) - }, []) - const router = useRouter() - useEffect(() => { - if (search.search_name === '') { - setSearch(e => ({ ...e, search_name: null })) - } - if (search.search_name !== '') { getCuss() } - }, [search]) - // 上拉加载数据 const pageNum = useRef({ size: search.size, page: search.page }) const getScrolltolower = useCallback(() => { @@ -54,6 +40,13 @@ export default () => { } }, [clentList]) + // 输入了搜索关键字 + const getSearchData = useCallback((eq) => { + pageNum.current.page = 1 + setClientlist(() => ({ list: [], total: 0 })) + setSearch(e => ({ ...e, search_name: eq, size: 10 })) + }, []) + // 列表下拉刷新 const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) const getRefresherRefresh = async() => { @@ -77,6 +70,12 @@ export default () => { setClientlist(e => ({ ...e, list: res.data?.list, total: res.data?.total })) setRefresherTriggeredStatus(() => false) } + useEffect(() => { + if (search.search_name === '') { + setSearch(e => ({ ...e, search_name: null })) + } + if (search.search_name !== '') { getCuss() } + }, [search]) // 选择业务员 const selectClient = (item) => { clentList.list.map((it) => { @@ -146,3 +145,5 @@ export default () => { ) } + +export default AccountPage diff --git a/src/pages/addAddress/index.tsx b/src/pages/addAddress/index.tsx index 2f880bd..f63d540 100644 --- a/src/pages/addAddress/index.tsx +++ b/src/pages/addAddress/index.tsx @@ -6,11 +6,10 @@ import styles from './index.module.scss' import FromList from '@/components/FromList' import Address from '@/components/address' import { alert } from '@/common/common' -import { mppurchaseraddress, mppurchaseraddressdelect, mppurchaseraddressget, mppurchaseraddressput } from '@/api/addressList' -import { getFilterData } from '@/common/util' +import { MpPurchaserAddress, MpPurchaserAddressDelete, MpPurchaserAddressGet, MpPurchaserAddressPut } from '@/api/addressList' import IconFont from '@/components/iconfont/iconfont' -export default () => { +const AddAddress = () => { const [itemList, setItemList] = useState( [ { @@ -54,22 +53,6 @@ export default () => { ) const [ischecked, setIsChecked] = useState(false) - const onChange = (eq) => { - setIsChecked(eq.detail.value) - setFormData(e => ({ ...e, is_default: eq.detail.value, address_detail: itemList[4].value })) - } - - const router = useRouter() - useDidShow(() => { - if (router.params.type === 'add') { - setNavigationBarTitle({ title: '新增收货地址' }) - } - else { - setFormData(e => ({ ...e, id: router.params.id as any })) - getInfo() - setNavigationBarTitle({ title: '编辑收货地址' }) - } - }) const [formData, setFormData] = useState({ name: '', phone: '', @@ -81,8 +64,15 @@ export default () => { id: '', factory: '', }) + const onChange = (eq) => { + setIsChecked(eq.detail.value) + setFormData(e => ({ ...e, is_default: eq.detail.value, address_detail: itemList[4].value })) + } + + const router = useRouter() + // 获取相应id的信息 - const { fetchData: infoFetch } = mppurchaseraddressget() + const { fetchData: infoFetch } = MpPurchaserAddressGet() const [infoObj, setinfoObj] = useState() const getInfo = async() => { const res = await infoFetch({ @@ -116,7 +106,7 @@ export default () => { item.value = res.data.phone } if (item.title === '收货地址') { - item.value = res.data.province_name, res.data.city_name, res.data.district_name + item.value = `${res.data.province_name}${res.data.city_name}${res.data.district_name}` } if (item.title === '详细地址') { item.value = res.data.address_detail @@ -131,13 +121,20 @@ export default () => { } } // `${res.data.province_name} + ${res.data.city_name} + ${res.data.district_name}` - + useDidShow(() => { + if (router.params.type === 'add') { + setNavigationBarTitle({ title: '新增收货地址' }) + } + else { + setFormData(e => ({ ...e, id: router.params.id as any })) + getInfo() + setNavigationBarTitle({ title: '编辑收货地址' }) + } + }) const btnDisabled = useMemo(() => { let canShow = false const obj = itemList.filter((item) => { - if (item.require) { - return item.value !== '' - } + return item.require && (item.value !== '') }) if (obj.length < 4) { canShow = true @@ -214,7 +211,7 @@ export default () => { }) } // 新增地址 - const { fetchData: addAddressFetch } = mppurchaseraddress() + const { fetchData: addAddressFetch } = MpPurchaserAddress() const handAdd = async() => { // if (!btnDisabled) return false const res = await addAddressFetch({ ...formData, purchaser_id: Number(router.params.purchaser_id) }) @@ -233,7 +230,7 @@ export default () => { } // 编辑地址 - const { fetchData: putFetch } = mppurchaseraddressput() + const { fetchData: putFetch } = MpPurchaserAddressPut() const handEdit = async() => { // if (!btnDisabled) return false const res = await putFetch({ ...formData, purchaser_id: Number(router.params.purchaser_id), id: Number(infoObj?.id) }) @@ -251,7 +248,7 @@ export default () => { } } // 删除地址 - const { fetchData: deleteFetch } = mppurchaseraddressdelect() + const { fetchData: deleteFetch } = MpPurchaserAddressDelete() const handleDelete = async() => { Taro.showModal(({ title: '提示', @@ -334,3 +331,5 @@ export default () => { ) } + +export default AddAddress diff --git a/src/pages/addCollection/components/form/index.tsx b/src/pages/addCollection/components/form/index.tsx index 8655696..e0119f9 100644 --- a/src/pages/addCollection/components/form/index.tsx +++ b/src/pages/addCollection/components/form/index.tsx @@ -30,8 +30,7 @@ interface Params { bigMoney?: any // 展示的大写金额, isOpen?: boolean // 是否展开状态 } - -export default memo((pros: Params) => { +const Form = (pros: Params) => { return ( <> { @@ -98,4 +97,5 @@ export default memo((pros: Params) => { } ) -}) +} +export default memo(Form) diff --git a/src/pages/addCollection/index.tsx b/src/pages/addCollection/index.tsx index ec30d6b..4154ae4 100644 --- a/src/pages/addCollection/index.tsx +++ b/src/pages/addCollection/index.tsx @@ -5,26 +5,17 @@ import classnames from 'classnames' import styles from './index.module.scss' import Form from './components/form' import { - mpcashManagementOrderaccount, mpcashManagementOrderpost, - mpshouldCollectOrderpurchaser, + MpCashManagementOrderAccount, MpCashManagementOrderPost, + MpShouldCollectOrderPurchaser, } from '@/api/newCollection' import { alert } from '@/common/common' import smallToBig from '@/common/money' import IconFont from '@/components/iconfont/iconfont' -export default () => { +const AddCollection = () => { // 获取选择的客户 const pages = Taro.getCurrentPages() const currPage = pages[pages.length - 1] // 获取当前页面 - useDidShow(() => { - setQuery(e => ({ - ...e, - purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : Query.purchaser_id, - clientName: currPage.data?.clientName ? currPage.data?.clientName : Query.clientName, - bankId: currPage.data?.bankId ? currPage.data?.bankId : Query.bankId, - bankName: currPage.data?.bankName ? currPage.data?.bankName : Query.bankName, - })) - }) const [Query, setQuery] = useState({}) @@ -35,12 +26,8 @@ export default () => { setQuery(val => ({ ...val, picList: list })) }, []) - useEffect(() => { - getCuss() - }, []) - // 获取首个银行账号 - const { fetchData: clitentFetch } = mpcashManagementOrderaccount() + const { fetchData: clitentFetch } = MpCashManagementOrderAccount() const getCuss = async() => { const res = await clitentFetch({ page: 1, size: 10 }) if (res.data) { @@ -48,7 +35,7 @@ export default () => { } } - const { fetchData: scanFetch } = mpshouldCollectOrderpurchaser() + const { fetchData: scanFetch } = MpShouldCollectOrderPurchaser() // 扫描 const handScan = (e) => { e.stopPropagation() @@ -81,7 +68,18 @@ export default () => { } } } - + useDidShow(() => { + setQuery(e => ({ + ...e, + purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : Query.purchaser_id, + clientName: currPage.data?.clientName ? currPage.data?.clientName : Query.clientName, + bankId: currPage.data?.bankId ? currPage.data?.bankId : Query.bankId, + bankName: currPage.data?.bankName ? currPage.data?.bankName : Query.bankName, + })) + }) + useEffect(() => { + getCuss() + }, []) // 判断是否可以提交 const isDisabled = useMemo(() => { if (Query.clientName == '' @@ -125,7 +123,7 @@ export default () => { } // 确认新建 - const { fetchData: sureFetch } = mpcashManagementOrderpost() + const { fetchData: sureFetch } = MpCashManagementOrderPost() const handSure = () => { const query = { payment_credential_url: picUrl.current, @@ -279,3 +277,5 @@ export default () => { ) } + +export default AddCollection diff --git a/src/pages/addressManager/index.tsx b/src/pages/addressManager/index.tsx index 9a7ebeb..5cd8cc8 100644 --- a/src/pages/addressManager/index.tsx +++ b/src/pages/addressManager/index.tsx @@ -5,7 +5,7 @@ import { useState } from 'react' import AddressList from '@/components/AddressList' import './index.scss' -export default () => { +const AddressManager = () => { const router = useRouter() return ( @@ -13,3 +13,4 @@ export default () => { ) } +export default AddressManager diff --git a/src/pages/applyGoods/index.tsx b/src/pages/applyGoods/index.tsx index 7cbc8a1..33ddef5 100644 --- a/src/pages/applyGoods/index.tsx +++ b/src/pages/applyGoods/index.tsx @@ -5,21 +5,99 @@ import classnames from 'classnames' import styles from './index.module.scss' import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format' import { - mpenumreturnExplain, - mpenumreturnOrderreturnReason, - mpenumreturngoodsStatus, - mpreturnApplyOrder, - mpsaleOrder, + MpEnumReturnExplain, + MpEnumReturnGoodsStatus, + MpEnumReturnOrderReturnReason, + MpReturnApplyOrder, + MpSaleOrder, } from '@/api/order' import Popup from '@/components/popup' import UploadImage from '@/components/uploadImage' -export default () => { +// 产品商品元素 +interface PropGoods { + list: any[] + obj: { + sale_mode?: number | string + } + handTui?: (any) => void + handCancel?: (any) => void + onBlur?: (e: any, obj: any) => void + onInputEven?: (e: any, obj: any) => void + handReduce?: (any) => void + handAdd?: (any) => void +} +const GoodsItem = (porps: PropGoods) => { + const { list = [], obj = {}, handTui, handCancel, onBlur, handReduce, handAdd, onInputEven } = porps + // const [value, setValue] = useState({ count: 1 }) + // const onInputEven = (e) => { + // let res = Number(e.detail.value) + // if (res < 1) { + // setValue({ count: 1 }) + // } else { + // setValue({ count: res }) + // } + // } + + return ( + <> + { + list.map((item, index) => { + return ( + + {item.product_code}# {item.product_name} + + { + item.av_product_color.map((it, inx) => { + return ( + + + {/* */} + + + {it.product_color_code} {it.product_color_name} + + + x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} + { + !it.isTui && handTui?.(it)}>退货 + } + { + (it.sale_mode != 0 && it.isTui) && handCancel?.(it)}>已选择退货 + } + { + (it.sale_mode == 0 && it.isTui) && + handReduce?.(it)}> + + + + onInputEven?.(e, it)} maxlength={it.roll} onBlur={e => onBlur?.(e, it)}> + + handAdd?.(it)}> + + + + + } + + + + ) + }) + } + + ) + }) + } + + + ) +} +const GoodsItemWithMemo = memo(GoodsItem) + +const ApplyGoods = () => { const router = useRouter() - useEffect(() => { - getDetail() - }, []) - const { fetchData: infoFetch } = mpsaleOrder() + + const { fetchData: infoFetch } = MpSaleOrder() const [infoObj, setInfoObj] = useState({}) const [ListArr, setListArr] = useState([]) // 获取订单详情 @@ -31,7 +109,7 @@ export default () => { const res = await infoFetch({ id: router.params.orderId }) if (res.data) { res.data.av_return_product.forEach((item) => { - item.av_product_color.map((it) => { + item.av_product_color.forEach((it) => { it.isTui = false it.nums = 1 }) @@ -132,16 +210,12 @@ export default () => { // 点击加 const handAdd = (val) => { ListArr.forEach((item) => { - item.av_product_color.map((it) => { + item.av_product_color.forEach((it) => { if (it.sale_order_detail_id === val.sale_order_detail_id) { if (it.nums < it.roll) { it.nums++ } - else { - return - } } - return it }) }) setListArr([...ListArr]) @@ -159,6 +233,10 @@ export default () => { return arr.length }, [ListArr]) + useEffect(() => { + getDetail() + }, []) + // 获取图片列表 const picUrl = useRef([]) const getImageList = useCallback((list) => { @@ -168,11 +246,6 @@ export default () => { // 筛选内容展示 const [showPopup, setshowPopup] = useState(false) - useEffect(() => { - getReason() - getReasonTwo() - }, []) - const queryRef = useRef( { return_reason: 1, // 退货原因 @@ -210,7 +283,7 @@ export default () => { }, [Query, totalNums]) /// 获取退货原因 - const { fetchData: resonFetch } = mpenumreturnOrderreturnReason() + const { fetchData: resonFetch } = MpEnumReturnOrderReturnReason() const [ReasonList, setReasonList] = useState([]) const getReason = async() => { const res = await resonFetch() @@ -220,7 +293,7 @@ export default () => { } // 获取退货原因2 - const { fetchData: resonTwoFetch } = mpenumreturnExplain() + const { fetchData: resonTwoFetch } = MpEnumReturnExplain() const [ReasonListTwo, setReasonListTwo] = useState([]) const getReasonTwo = async() => { const res = await resonTwoFetch({ return_reason: queryRef.current.return_reason }) @@ -264,7 +337,18 @@ export default () => { // queryRef.current.return_explain = item.id } - + useEffect(() => { + getReason() + getReasonTwo() + }, []) + // 数组重置 + const resetArr = (arr) => { + arr.map((it) => { + it.default = false + return it + }) + return arr + } // 重置 const handReset = () => { queryRef.current.return_reason = 1 @@ -279,15 +363,6 @@ export default () => { setReasonListTwo([...arrTwo]) } - // 数组重置 - const resetArr = (arr) => { - arr.map((it) => { - it.default = false - return it - }) - return arr - } - // 判断选择原因 const selectIsDisabled = useMemo(() => { if (Query.return_explain !== '') { @@ -327,18 +402,18 @@ export default () => { // 货物情况 const [DescPopup, setDescPopup] = useState(false) - const { fetchData: statusFetch } = mpenumreturngoodsStatus() + const { fetchData: statusFetch } = MpEnumReturnGoodsStatus() const [GoodStatusList, setGoodStatusList] = useState([]) - useEffect(() => { - getGoodStatus() - }, []) + const getGoodStatus = async() => { const res = await statusFetch() if (res.data) { setGoodStatusList(res.data.list) } } - + useEffect(() => { + getGoodStatus() + }, []) const handStatus = (item) => { GoodStatusList.map((it) => { if (it.id === item.id) { @@ -389,9 +464,10 @@ export default () => { delta: 1, }) } - + // 备注信息 + const [TextareaValue, setTextareaValue] = useState('') // 确认退货 - const { fetchData: sureFetch } = mpreturnApplyOrder() + const { fetchData: sureFetch } = MpReturnApplyOrder() const handSure = () => { if (Query.reasonNameTwo == '其他问题' && TextareaValue == '') { Taro.showToast({ @@ -458,15 +534,13 @@ export default () => { setQuery(Query) }, [Query]) - // 备注信息 - const [TextareaValue, setTextareaValue] = useState('') const getDesc = (e) => { setTextareaValue(e) } return ( - handTui(item)} @@ -475,7 +549,7 @@ export default () => { handReduce={item => handReduce(item)} handAdd={item => handAdd(item)} onInputEven={(e, item) => onInputEven(e, item)} - > + > 汇总:已选{totalNums}种商品 @@ -589,82 +663,4 @@ export default () => { ) } - -// 产品商品元素 -interface PropGoods { - list: any[] - obj: { - sale_mode?: number | string - } - handTui?: (any) => void - handCancel?: (any) => void - onBlur?: (e: any, obj: any) => void - onInputEven?: (e: any, obj: any) => void - handReduce?: (any) => void - handAdd?: (any) => void -} -const GoodsItem = memo((porps: PropGoods) => { - const { list = [], obj = {}, handTui, handCancel, onBlur, handReduce, handAdd, onInputEven } = porps - // const [value, setValue] = useState({ count: 1 }) - // const onInputEven = (e) => { - // let res = Number(e.detail.value) - // if (res < 1) { - // setValue({ count: 1 }) - // } else { - // setValue({ count: res }) - // } - // } - - return ( - <> - { - list.map((item, index) => { - return ( - - {item.product_code}# {item.product_name} - - { - item.av_product_color.map((it, inx) => { - return ( - - - {/* */} - - - {it.product_color_code} {it.product_color_name} - - - x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} - { - !it.isTui && handTui?.(it)}>退货 - } - { - (it.sale_mode != 0 && it.isTui) && handCancel?.(it)}>已选择退货 - } - { - (it.sale_mode == 0 && it.isTui) && - handReduce?.(it)}> - - - - onInputEven?.(e, it)} maxlength={it.roll} onBlur={e => onBlur?.(e, it)}> - - handAdd?.(it)}> - + - - - } - - - - ) - }) - } - - ) - }) - } - - - ) -}) +export default ApplyGoods diff --git a/src/pages/applyMoney/index.tsx b/src/pages/applyMoney/index.tsx index 79d8c40..c2179d3 100644 --- a/src/pages/applyMoney/index.tsx +++ b/src/pages/applyMoney/index.tsx @@ -5,19 +5,96 @@ import classnames from 'classnames' import styles from './index.module.scss' import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format' import { - mpenumrefundExplainone, - mpreturnApplyOrder, - mpsaleOrder, + MpEnumRefundExplainOne, + MpReturnApplyOrder, + MpSaleOrder, } from '@/api/order' import Popup from '@/components/popup' -export default () => { - useEffect(() => { - getDetail() - getEnum() - }, []) +// 产品商品元素 +interface PropGoods { + list: any[] + obj: { + sale_mode?: number | string + } + handTui?: (any) => void + handCancel?: (any) => void + onBlur?: (e: any, obj: any) => void + onInputEven?: (e: any, obj: any) => void + handReduce?: (any) => void + handAdd?: (any) => void +} + +const GoodsItem = (porps: PropGoods) => { + const { list = [], obj = {}, handTui, handCancel, onBlur, handReduce, handAdd, onInputEven } = porps + // const [value, setValue] = useState({ count: 1 }) + // const onInputEven = (e) => { + // let res = Number(e.detail.value) + // if (res < 1) { + // setValue({ count: 1 }) + // } else { + // setValue({ count: res }) + // } + // } + + return ( + <> + { + list.map((item, index) => { + return ( + + {item.product_code}# {item.product_name} + + { + item.av_product_color.map((it, inx) => { + return ( + + + {/* */} + + + {it.product_color_code} {it.product_color_name} + + + x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} + { + !it.isTui && handTui?.(it)}>退货 + } + { + (it.sale_mode != 0 && it.isTui) && handCancel?.(it)}>已选择退货 + } + { + (it.sale_mode == 0 && it.isTui) && + handReduce?.(it)}> + + + + onInputEven?.(e, it)} maxlength={it.roll} onBlur={e => onBlur?.(e, it)}> + + handAdd?.(it)}> + + + + + } + + + + ) + }) + } + + ) + }) + } + + + ) +} +const GoodsItemWithMemo = memo(GoodsItem) + +const ApplyMoney = () => { const Router = useRouter() - const { fetchData: infoFetch } = mpsaleOrder() + const { fetchData: infoFetch } = MpSaleOrder() const [ListArr, setListArr] = useState([]) const [infoObj, setInfoObj] = useState({}) @@ -30,7 +107,7 @@ export default () => { const res = await infoFetch({ id: Router.params.orderId }) if (res.data) { res.data.av_return_product.forEach((item) => { - item.av_product_color.map((it) => { + item.av_product_color.forEach((it) => { it.isTui = false it.nums = 1 }) @@ -132,16 +209,12 @@ export default () => { // 点击加 const handAdd = (val) => { ListArr.forEach((item) => { - item.av_product_color.map((it) => { + item.av_product_color.forEach((it) => { if (it.sale_order_detail_id === val.sale_order_detail_id) { if (it.nums < it.roll) { it.nums++ } - else { - return - } } - return it }) }) setListArr([...ListArr]) @@ -149,14 +222,20 @@ export default () => { // 获取枚举 const [List, setList] = useState([]) - const { fetchData: explanFetch } = mpenumrefundExplainone() + const { fetchData: explanFetch } = MpEnumRefundExplainOne() const getEnum = async() => { const res = await explanFetch() if (res.data) { setList(res.data.list) } } - + const queryRef = useRef({ + reasonName: '请选择', + }) + const [Query, setQuery] = useState({ + reasonId: '', + reasonName: '请选择', + }) // 选择退货原因 const handReasonOne = (item) => { List.map((it) => { @@ -176,14 +255,6 @@ export default () => { // 筛选内容展示 const [showPopup, setshowPopup] = useState(false) - const queryRef = useRef({ - reasonName: '请选择', - }) - const [Query, setQuery] = useState({ - reasonId: '', - reasonName: '请选择', - }) - // 备注信息 const [TextareaValue, setTextareaValue] = useState('') const getDesc = (e) => { @@ -214,7 +285,14 @@ export default () => { }) return arr.length }, [ListArr]) - + // 数组重置 + const resetArr = (arr) => { + arr.map((it) => { + it.default = false + return it + }) + return arr + } // 重置 const handReset = () => { setQuery(({ reasonId: '', reasonName: '请选择' })) @@ -251,17 +329,13 @@ export default () => { return true } }, [Query]) + useEffect(() => { + getDetail() + getEnum() + }, []) - // 数组重置 - const resetArr = (arr) => { - arr.map((it) => { - it.default = false - return it - }) - return arr - } // 确认退款 - const { fetchData: sureFetch } = mpreturnApplyOrder() + const { fetchData: sureFetch } = MpReturnApplyOrder() const handSure = () => { if (queryRef.current.reasonName == '其他问题' && TextareaValue == '') { Taro.showToast({ @@ -354,7 +428,7 @@ export default () => { { showItem && - handTui(item)} @@ -363,7 +437,7 @@ export default () => { handReduce={item => handReduce(item)} handAdd={item => handAdd(item)} onInputEven={(e, item) => onInputEven(e, item)} - > + > 汇总:已选{totalNums}种商品 } @@ -435,82 +509,4 @@ export default () => { ) } - -// 产品商品元素 -interface PropGoods { - list: any[] - obj: { - sale_mode?: number | string - } - handTui?: (any) => void - handCancel?: (any) => void - onBlur?: (e: any, obj: any) => void - onInputEven?: (e: any, obj: any) => void - handReduce?: (any) => void - handAdd?: (any) => void -} -const GoodsItem = memo((porps: PropGoods) => { - const { list = [], obj = {}, handTui, handCancel, onBlur, handReduce, handAdd, onInputEven } = porps - // const [value, setValue] = useState({ count: 1 }) - // const onInputEven = (e) => { - // let res = Number(e.detail.value) - // if (res < 1) { - // setValue({ count: 1 }) - // } else { - // setValue({ count: res }) - // } - // } - - return ( - <> - { - list.map((item, index) => { - return ( - - {item.product_code}# {item.product_name} - - { - item.av_product_color.map((it, inx) => { - return ( - - - {/* */} - - - {it.product_color_code} {it.product_color_name} - - - x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} - { - !it.isTui && handTui?.(it)}>退货 - } - { - (it.sale_mode != 0 && it.isTui) && handCancel?.(it)}>已选择退货 - } - { - (it.sale_mode == 0 && it.isTui) && - handReduce?.(it)}> - - - - onInputEven?.(e, it)} maxlength={it.roll} onBlur={e => onBlur?.(e, it)}> - - handAdd?.(it)}> - + - - - } - - - - ) - }) - } - - ) - }) - } - - - ) -}) +export default ApplyMoney diff --git a/src/pages/collectionDetail/components/form/index.tsx b/src/pages/collectionDetail/components/form/index.tsx index 96b4a81..8744cb0 100644 --- a/src/pages/collectionDetail/components/form/index.tsx +++ b/src/pages/collectionDetail/components/form/index.tsx @@ -29,8 +29,7 @@ interface Params { showSizeFont?: boolean // 展示金额的大写 bigMoney?: any // 展示的大写金额 } - -export default memo((pros: Params) => { +const Form = (pros: Params) => { return ( { ) -}) +} +export default memo(Form) diff --git a/src/pages/collectionDetail/index.tsx b/src/pages/collectionDetail/index.tsx index 8c9a323..7b90526 100644 --- a/src/pages/collectionDetail/index.tsx +++ b/src/pages/collectionDetail/index.tsx @@ -11,20 +11,15 @@ import Popup from '@/components/popup' import InfiniteScroll from '@/components/infiniteScroll' import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format' import { - mpcashManagementOrder, + MpCashManagementOrder, } from '@/api/newCollection' -import TimePicker from '@/components/timePicker' -import { alert } from '@/common/common' import smallToBig from '@/common/money' -import { IMG_CND_Prefix } from '@/common/constant' -export default () => { +const CollectionDetail = () => { const router = useRouter() const [Query, setQuery] = useState({}) - const { fetchData: getFetch } = mpcashManagementOrder() - useEffect(() => { - getDetail() - }, []) + const { fetchData: getFetch } = MpCashManagementOrder() + const getDetail = async() => { Taro.showLoading({ title: '请稍等', @@ -50,7 +45,9 @@ export default () => { res = Query.receipt_amount / 100 return res }, [Query]) - + useEffect(() => { + getDetail() + }, []) return ( <> @@ -152,3 +149,5 @@ export default () => { ) } + +export default CollectionDetail diff --git a/src/pages/colorRelated/components/bluetooth/LinkBlueTooth.tsx b/src/pages/colorRelated/components/bluetooth/LinkBlueTooth.tsx index 96918bd..78d935d 100644 --- a/src/pages/colorRelated/components/bluetooth/LinkBlueTooth.tsx +++ b/src/pages/colorRelated/components/bluetooth/LinkBlueTooth.tsx @@ -7,7 +7,7 @@ import Popup from './Popup' import { useBluetooth } from '@/use/contextBlueTooth' import SearchInput from '@/components/searchInput' -export default memo(() => { +const LinkBlueTooth = () => { const { state, init, startScan, connect, disconnect } = useBluetooth() useEffect(() => { @@ -36,7 +36,9 @@ export default memo(() => { const onLinkListen = (item) => { if (!state.connected && !state.connecting) { connect(item) } } - + const onFindEven = () => { + if (!state.discovering && !state.connected && !state.connecting) { startScan() } + } const [popupShow, setPopupShow] = useState(false) // 显示设备列表 const onFindDevice = () => { @@ -52,9 +54,6 @@ export default memo(() => { onFindEven() } } - const onFindEven = () => { - if (!state.discovering && !state.connected && !state.connecting) { startScan() } - } // 断开链接 const onDisconnect = () => { @@ -84,4 +83,5 @@ export default memo(() => { ) -}) +} +export default memo(LinkBlueTooth) diff --git a/src/pages/colorRelated/components/bluetooth/Popup.tsx b/src/pages/colorRelated/components/bluetooth/Popup.tsx index d6190bc..8eb06a7 100644 --- a/src/pages/colorRelated/components/bluetooth/Popup.tsx +++ b/src/pages/colorRelated/components/bluetooth/Popup.tsx @@ -12,8 +12,7 @@ interface params { onOff: () => void onFind: () => void } - -export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => { +const Popup = ({ state, show = false, onClose, onLink, onOff, onFind }: params) => { const [popupShow, setPopupShow] = useState(show) useEffect(() => { setPopupShow(show) @@ -32,9 +31,9 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa {(state.devices && state.devices.length > 0 - && state?.devices.map((item) => { + && state?.devices.map((item, key) => { return ( - onLink(item)}> + onLink(item)}> {item.name} {(!state.connecting && !state.connected && 链接) || (state.connecting && item.deviceId == state.connecting.deviceId && 正在链接...) @@ -76,4 +75,5 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa )} ) -}) +} +export default memo(Popup) diff --git a/src/pages/colorRelated/findColor/components/DrawerCenter/index.tsx b/src/pages/colorRelated/findColor/components/DrawerCenter/index.tsx index 2daf39c..6592ada 100644 --- a/src/pages/colorRelated/findColor/components/DrawerCenter/index.tsx +++ b/src/pages/colorRelated/findColor/components/DrawerCenter/index.tsx @@ -8,7 +8,7 @@ interface PropsType { children?: React.ReactNode } -const DrawerCenter: FC = memo((props) => { +const DrawerCenter: FC = (props) => { const { children, showModal } = props const [show, setShow] = useState(false) @@ -29,5 +29,5 @@ const DrawerCenter: FC = memo((props) => { ) : null -}) -export default DrawerCenter +} +export default memo(DrawerCenter) diff --git a/src/pages/colorRelated/findColor/components/HistoryColor/index.tsx b/src/pages/colorRelated/findColor/components/HistoryColor/index.tsx index 027b61d..9b20e9d 100644 --- a/src/pages/colorRelated/findColor/components/HistoryColor/index.tsx +++ b/src/pages/colorRelated/findColor/components/HistoryColor/index.tsx @@ -19,7 +19,7 @@ interface HistoryListItem { code: string name: string } -const HistoryColor: FC = forwardRef((props, ref) => { +const HistoryColor = (props: PropsType, ref) => { const { onColor, showModal, onVisibleChange } = props const [visible, setVisible] = usePropsValue({ @@ -28,12 +28,6 @@ const HistoryColor: FC = forwardRef((props, ref) => { onChange: onVisibleChange, }) - useEffect(() => { - if (visible) { - getList() - } - }, [visible]) - useImperativeHandle( ref, () => { @@ -50,6 +44,7 @@ const HistoryColor: FC = forwardRef((props, ref) => { console.log('closeEven') setVisible(false) } + const [list, setList] = useState([]) // 获取本地列表(无差别存储版本) const getList = () => { @@ -57,8 +52,11 @@ const HistoryColor: FC = forwardRef((props, ref) => { console.log('historyColorList==>', historyColorList) setList(historyColorList || []) } - - const [list, setList] = useState([]) + useEffect(() => { + if (visible) { + getList() + } + }, [visible]) // 保留1位小数 const noScale = (val, num = 1) => { @@ -116,5 +114,5 @@ const HistoryColor: FC = forwardRef((props, ref) => { ) -}) -export default HistoryColor +} +export default forwardRef(HistoryColor) diff --git a/src/pages/colorRelated/findColor/index.tsx b/src/pages/colorRelated/findColor/index.tsx index c2d5263..bed71cf 100644 --- a/src/pages/colorRelated/findColor/index.tsx +++ b/src/pages/colorRelated/findColor/index.tsx @@ -68,13 +68,12 @@ const FindColor: FC = () => { }) getData(val.lab) } + const [showHistory, setShowHistory] = useState(false) const handleVisibleChange = (visible) => { setShowHistory(visible) } - const [showHistory, setShowHistory] = useState(false) - const ResultContainer = useMemo(() => { if (!colorState.loading && list?.length > 0) { return @@ -94,7 +93,18 @@ const FindColor: FC = () => { const historyShowEven = () => { setShowHistory(true) } - + // 本地存储取色记录(无差别存储版本) + const localSave = (lab) => { + const historyColorList = Taro.getStorageSync('historyColor') || [] + const obj = { + ...product, + p_time: +new Date(), + lab, + } + historyColorList.unshift(obj) + if (historyColorList.length > 30) { historyColorList.pop() } + Taro.setStorageSync('historyColor', historyColorList) + } useEffect(() => { if (!product) { Taro.showToast({ title: '请选择面料', icon: 'none' }) @@ -109,19 +119,6 @@ const FindColor: FC = () => { } }, [bluetoothState.deviceLab]) - // 本地存储取色记录(无差别存储版本) - const localSave = (lab) => { - const historyColorList = Taro.getStorageSync('historyColor') || [] - const obj = { - ...product, - p_time: +new Date(), - lab, - } - historyColorList.unshift(obj) - if (historyColorList.length > 30) { historyColorList.pop() } - Taro.setStorageSync('historyColor', historyColorList) - } - return ( diff --git a/src/pages/colorRelated/sampleComparison/index.tsx b/src/pages/colorRelated/sampleComparison/index.tsx index e9ddb41..e1e3f1b 100644 --- a/src/pages/colorRelated/sampleComparison/index.tsx +++ b/src/pages/colorRelated/sampleComparison/index.tsx @@ -10,7 +10,7 @@ import { toRgb } from '@/common/bluetooth/color/colorSpace' import { productabsorbcontrast } from '@/api/index' import { alert } from '@/common/common' -export default () => { +const SampleComparison = () => { // 搜索参数 const [searchField, setSearchField] = useState({ l1: '', @@ -79,15 +79,7 @@ export default () => { } } }, [colorList]) - const reset = () => { - setColorList({}) - setBlueToothColor('') - setBlueToothColorTwo('') - setTime('') - setTimeTwo('') - setData('') - setResult('') - } + const [data, setData] = useState('') const [result, setResult] = useState('') const { fetchData } = productabsorbcontrast() @@ -126,6 +118,15 @@ export default () => { } alert.hideLoading() } + const reset = () => { + setColorList({}) + setBlueToothColor('') + setBlueToothColorTwo('') + setTime('') + setTimeTwo('') + setData('') + setResult('') + } return ( @@ -186,3 +187,4 @@ export default () => { ) } +export default SampleComparison diff --git a/src/pages/colorRelated/takeColor/components/Upload/index.tsx b/src/pages/colorRelated/takeColor/components/Upload/index.tsx index 2868c24..8831ce3 100644 --- a/src/pages/colorRelated/takeColor/components/Upload/index.tsx +++ b/src/pages/colorRelated/takeColor/components/Upload/index.tsx @@ -13,7 +13,7 @@ interface PropsType extends UploadColorEvent { uploadConfirmState: boolean } -const UploadColor = forwardRef((params: PropsType, ref) => { +const UploadColor = (params: PropsType, ref) => { const { onUploadConfirm, uploadConfirmState } = params const [showModal, setShowModal] = useState(false) const [filePath, setFilePath] = useState('') @@ -31,13 +31,6 @@ const UploadColor = forwardRef((params: PropsType, ref) => { }) } - useEffect(() => { - if (uploadConfirmState) { - setFilePath('') - handleTriggerUploadModal(false) - } - }, [uploadConfirmState]) - const handleTriggerUploadModal = (bool: boolean) => { setShowModal(bool) } @@ -55,7 +48,12 @@ const UploadColor = forwardRef((params: PropsType, ref) => { const handleUploadConfirm = () => { onUploadConfirm && onUploadConfirm(file) } - + useEffect(() => { + if (uploadConfirmState) { + setFilePath('') + handleTriggerUploadModal(false) + } + }, [uploadConfirmState]) return ( handleTriggerUploadModal(false)}> @@ -75,5 +73,5 @@ const UploadColor = forwardRef((params: PropsType, ref) => { ) -}) -export default UploadColor +} +export default forwardRef(UploadColor) diff --git a/src/pages/colorRelated/takeColor/index.tsx b/src/pages/colorRelated/takeColor/index.tsx index 01bb99a..19b7d07 100644 --- a/src/pages/colorRelated/takeColor/index.tsx +++ b/src/pages/colorRelated/takeColor/index.tsx @@ -23,6 +23,7 @@ const TakeColor: FC = () => { const { measureAndGetLab, state: bluetoothState } = useBluetooth() const [searchValue, setSearchValue] = useState('') const [selectedProduct, setSelectedProduct] = useState>({}) + const [listData, setListData] = useState[]>([]) const selectInput = async(event) => { if (event) { @@ -30,7 +31,7 @@ const TakeColor: FC = () => { setSelectedProduct(event) const res = await fetchData({ id: event.id }) if (res.success) { - res.data?.list.map((item, index) => { + res.data?.list.forEach((item, index) => { item.currnetRgb = item.rgb item.currentLab = item.lab item.sampling = !(item.currentLab?.l == 0 && item.currentLab?.a == 0 && item.currentLab?.b == 0) @@ -53,18 +54,12 @@ const TakeColor: FC = () => { setSearchValue('') } - const handlePrViewRgb = useCallback((event) => { - setLabPreview(event) - setShowLabPreview(true) - }, []) - const [currentTakeColorIndex, setCurrentTakeColorIndex] = useState(null) const handleTakeColor = (index: number) => { setCurrentTakeColorIndex(index) } - const [listData, setListData] = useState[]>([]) // const listData = useMemo(() => { // return state.data?.list?.filter(item => { // if (searchValue) { @@ -73,6 +68,7 @@ const TakeColor: FC = () => { // return true // }) // }, [state.data?.list, state]) + const productSelectEl = useRef(null) const onSearchInput = (event) => { const current = event.detail.value @@ -149,8 +145,6 @@ const TakeColor: FC = () => { const [showLabPreview, setShowLabPreview] = useState(false) - const productSelectEl = useRef(null) - const [uploadConfirmState, setUploadConfirmState] = useState(false) const handleUploadConfirm = async(file) => { @@ -185,7 +179,10 @@ const TakeColor: FC = () => { alert.none('请选择图片') } } - + const handlePrViewRgb = useCallback((event) => { + setLabPreview(event) + setShowLabPreview(true) + }, []) return ( <> diff --git a/src/pages/customerDetails/components/form/index.tsx b/src/pages/customerDetails/components/form/index.tsx index 2b332b7..92223d0 100644 --- a/src/pages/customerDetails/components/form/index.tsx +++ b/src/pages/customerDetails/components/form/index.tsx @@ -13,8 +13,7 @@ interface Props { isPhone?: boolean isBorder?: boolean } - -export default memo((props: Props) => { +const Form = (props: Props) => { const { isPhone = false, isBorder = true, @@ -35,4 +34,5 @@ export default memo((props: Props) => { } ) -}) +} +export default memo(Form) diff --git a/src/pages/customerDetails/components/tabs/index.tsx b/src/pages/customerDetails/components/tabs/index.tsx index 7ce8be6..4bf6cf6 100644 --- a/src/pages/customerDetails/components/tabs/index.tsx +++ b/src/pages/customerDetails/components/tabs/index.tsx @@ -7,7 +7,7 @@ interface Props { list: any[] handChose?: (any) => void } -export default memo((props: Props) => { +const Tabs = (props: Props) => { const { list = [], handChose } = props return ( @@ -29,4 +29,5 @@ export default memo((props: Props) => { } ) -}) +} +export default memo(Tabs) diff --git a/src/pages/customerDetails/components/tagPopup/index.tsx b/src/pages/customerDetails/components/tagPopup/index.tsx index ad78e66..c9f70f7 100644 --- a/src/pages/customerDetails/components/tagPopup/index.tsx +++ b/src/pages/customerDetails/components/tagPopup/index.tsx @@ -7,7 +7,7 @@ import { alert, goLink } from '@/common/common' import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format' import IconFont from '@/components/iconfont/iconfont' import Popup from '@/components/popup' -import { mppurchaserlabeladd, mppurchaserlist } from '@/api/customer' +import { MpPurchaserLabelAdd, MpPurchaserList } from '@/api/customer' interface Props { showPopup: boolean @@ -15,12 +15,12 @@ interface Props { purchaser_id?: string | number diseShow?: () => void } -export default memo(forwardRef((props: Props, ref) => { +const TagPopup = (props: Props, ref) => { const router = useRouter() - useEffect(() => { - getList() - }, []) - const { fetchData } = mppurchaserlist() + + const { fetchData } = MpPurchaserList() + // 标签 + const [modeList, setModeList] = useState([]) const getList = async() => { const res = await fetchData() if (res.data) { @@ -28,8 +28,6 @@ export default memo(forwardRef((props: Props, ref) => { } } - // 标签 - const [modeList, setModeList] = useState([]) // 选择标签 const handCheckMode = (item) => { modeList.map((it) => { @@ -48,7 +46,7 @@ export default memo(forwardRef((props: Props, ref) => { }) setModeList([...modeList]) } - const { fetchData: addFetch } = mppurchaserlabeladd() + const { fetchData: addFetch } = MpPurchaserLabelAdd() const handSure = async() => { const arr: any[] = [] const fltArr = modeList.filter((item) => { return item.checked }) @@ -98,6 +96,9 @@ export default memo(forwardRef((props: Props, ref) => { modeList, setModeList, })) + useEffect(() => { + getList() + }, []) return ( { props.handClose() }}> @@ -142,4 +143,5 @@ export default memo(forwardRef((props: Props, ref) => { ) -})) +} +export default memo(forwardRef(TagPopup)) diff --git a/src/pages/customerDetails/index.tsx b/src/pages/customerDetails/index.tsx index 5c78338..ef2513a 100644 --- a/src/pages/customerDetails/index.tsx +++ b/src/pages/customerDetails/index.tsx @@ -11,34 +11,21 @@ import { debounce } from '@/common/util' import { alert, goLink } from '@/common/common' import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format' import AddressList from '@/components/AddressList' -import { mppurchaser } from '@/api/customer' +import { MpPurchaser } from '@/api/customer' -export default () => { +const CustomerDetails = () => { const router = useRouter() const [status, setstatus] = useState(1) - useDidShow(() => { - getInfo() - }) const [infoObj, setinfoObj] = useState() - const { fetchData: getDesc } = mppurchaser() - const getInfo = async() => { - Taro.showLoading({ - title: '请稍等...', - mask: true, - }) - const res = await getDesc({ id: router.params.purchaser_id }) - setinfoObj(res.data) - Taro.hideLoading() - setshowPopup(false) - } + const { fetchData: getDesc } = MpPurchaser() // 顶部栏 const AddressListRef = useRef() const [TarBarList, setTarBarList] = useState([{ id: 1, name: '基础信息', showBorder: true }, { id: 2, name: '收货地址', showBorder: false }]) const handChose = (item) => { - TarBarList.map((it) => { + TarBarList.forEach((it) => { if (it.id === item.id) { it.showBorder = true } @@ -72,6 +59,19 @@ export default () => { TagPopupRef.current.setModeList([...TagPopupRef.current.modeList]) setshowPopup(true) } + const getInfo = async() => { + Taro.showLoading({ + title: '请稍等...', + mask: true, + }) + const res = await getDesc({ id: router.params.purchaser_id }) + setinfoObj(res.data) + Taro.hideLoading() + setshowPopup(false) + } + useDidShow(() => { + getInfo() + }) return ( @@ -133,3 +133,4 @@ export default () => { ) } +export default CustomerDetails diff --git a/src/pages/customerEditor/index.tsx b/src/pages/customerEditor/index.tsx index 1eaee74..d642dfd 100644 --- a/src/pages/customerEditor/index.tsx +++ b/src/pages/customerEditor/index.tsx @@ -11,14 +11,45 @@ import { debounce } from '@/common/util' import { alert, goLink } from '@/common/common' import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format' import Address from '@/components/address' -import { mppurchaser, mppurchaserpost, mppurchaserput } from '@/api/customer' +import { MpPurchaser, MpPurchaserPost, MpPurchaserPut } from '@/api/customer' +// 卡片盒子元素 +interface Obs { + title?: string + modeName?: string + showMode?: boolean + children?: ReactNode + clickNode?: () => void +} + +const DefaultBox = (props: Obs) => { + const { + title = '标题', + modeName = '大货', + showMode = false, + children, + clickNode, + } = props + + return ( + + + {title} + { + showMode && clickNode?.()}>{modeName} + } + + + {children} + + ) +} +const DefaultBoxWithMemo = memo(DefaultBox) interface AddressParms { id: number name: string } - -export default () => { +const CustomerEditor = () => { const router = useRouter() const [infoObj, setinfoObj] = useState() @@ -26,11 +57,6 @@ export default () => { const [formData, setformData] = useState() const [addressArr, setaddressArr] = useState([]) - useEffect(() => { - if (router.params.type === 'edit') { - getInfo() - } - }, []) // 默认业务员 useDidShow(() => { @@ -62,46 +88,7 @@ export default () => { } }) - const { fetchData: getDesc } = mppurchaser() - const getInfo = async() => { - Taro.showLoading({ - title: '请稍等...', - mask: true, - }) - const res = await getDesc({ id: router.params.id }) - setinfoObj(res.data) - list.map((item) => { - if (item.id == res.data.purchaser_type) { - item.check = true - } - else { - item.check = false - } - return item - }) - setlist([...list]) - setformData({ - sale_user_id: res.data?.sale_user_id, - sale_user_name: res.data?.sale_user_name, - name: res.data?.name, - short_name: res.data?.short_name, - director: res.data?.director, - phone: res.data?.phone, - addressName: res.data?.province_name + res.data?.city_name + res.data?.district_name, - address_detail: res.data?.address_detail, - purchaser_type: res.data?.purchaser_type, - district_id: res.data?.district_id, - }) - setremarkDesc(res.data?.remark) - let arr: any[] = [] - arr = [ - { id: res.data.province_id, name: res.data.province_name }, - { id: res.data.city_id, name: res.data.city_name }, - { id: res.data.district_id, name: res.data.district_name }, - ] - setaddressArr([...arr]) - Taro.hideLoading() - } + const { fetchData: getDesc } = MpPurchaser() const handTitle = useCallback((e) => { setformData(val => ({ ...val, name: e })) @@ -156,9 +143,48 @@ export default () => { setlist([...list]) setformData(val => ({ ...val, purchaser_type: item.id })) } - // 备注操作 const [remarkDesc, setremarkDesc] = useState('') + const getInfo = async() => { + Taro.showLoading({ + title: '请稍等...', + mask: true, + }) + const res = await getDesc({ id: router.params.id }) + setinfoObj(res.data) + list.map((item) => { + if (item.id == res.data.purchaser_type) { + item.check = true + } + else { + item.check = false + } + return item + }) + setlist([...list]) + setformData({ + sale_user_id: res.data?.sale_user_id, + sale_user_name: res.data?.sale_user_name, + name: res.data?.name, + short_name: res.data?.short_name, + director: res.data?.director, + phone: res.data?.phone, + addressName: res.data?.province_name + res.data?.city_name + res.data?.district_name, + address_detail: res.data?.address_detail, + purchaser_type: res.data?.purchaser_type, + district_id: res.data?.district_id, + }) + setremarkDesc(res.data?.remark) + let arr: any[] = [] + arr = [ + { id: res.data.province_id, name: res.data.province_name }, + { id: res.data.city_id, name: res.data.city_name }, + { id: res.data.district_id, name: res.data.district_name }, + ] + setaddressArr([...arr]) + Taro.hideLoading() + } + const [showDesc, setShowDesc] = useState(false) const getRemark = useCallback(async(e) => { setShowDesc(false) @@ -183,12 +209,16 @@ export default () => { const onClose = () => { setShowSiteModal(false) } - + useEffect(() => { + if (router.params.type === 'edit') { + getInfo() + } + }, []) const isDisabled = useMemo(() => { let empty: any = null if (typeof (formData) == 'undefined') { return } for (const key in formData) { - if (formData.hasOwnProperty(key)) { + if (key in formData) { if (formData[key] !== '' && typeof (formData[key]) !== 'undefined') { empty = false } @@ -218,8 +248,8 @@ export default () => { }) } - const { fetchData: postFetch } = mppurchaserpost() - const { fetchData: putFetch } = mppurchaserput() + const { fetchData: postFetch } = MpPurchaserPost() + const { fetchData: putFetch } = MpPurchaserPut() // 提交 const handSure = async() => { // if (!isDisabled) return false @@ -284,9 +314,9 @@ export default () => { > { - list.map((item) => { + list.map((item, key) => { return ( - handItem(item)}>{item.name} + handItem(item)}>{item.name} ) }) } @@ -330,9 +360,9 @@ export default () => { inputValue={formData?.sale_user_name} > - `} clickNode={() => setShowDesc(true)}> + `} clickNode={() => setShowDesc(true)}> {remarkDesc === '' ? '尚未备注信息' : remarkDesc} - + setShowDesc(false)}> getRemark(e)} defaultValue={infoObj?.remark} showInput={!!showDesc} /> @@ -345,35 +375,4 @@ export default () => { ) } - -// 卡片盒子元素 -interface Obs { - title?: string - modeName?: string - showMode?: boolean - children?: ReactNode - clickNode?: () => void -} - -const DefaultBox = memo((props: Obs) => { - const { - title = '标题', - modeName = '大货', - showMode = false, - children, - clickNode, - } = props - - return ( - - - {title} - { - showMode && clickNode?.()}>{modeName} - } - - - {children} - - ) -}) +export default CustomerEditor diff --git a/src/pages/customerManagement/components/ChoseCity/index.tsx b/src/pages/customerManagement/components/ChoseCity/index.tsx index d26b472..1dd6f31 100644 --- a/src/pages/customerManagement/components/ChoseCity/index.tsx +++ b/src/pages/customerManagement/components/ChoseCity/index.tsx @@ -15,8 +15,7 @@ interface Props { value?: any onCloseOverlay?: () => void } - -export default memo(forwardRef((props: Props, ref) => { +const ChoseCity = (props: Props, ref) => { const DropDownItemRef = useRef() const close = () => { DropDownItemRef.current.closePopup() @@ -35,17 +34,6 @@ export default memo(forwardRef((props: Props, ref) => { // 获取地址 const { fetchData } = GetAddressListApi() - useEffect(() => { - getProvince() - }, []) - - // 获取省 - const getProvince = async() => { - const res = await fetchData({ parent_id: 1 }) - if (res.data) { - setlist([...res.data.list]) - } - } // 已选的集合市 // const [choseCityArr, setchoseCityArr] = useState([]) @@ -55,14 +43,23 @@ export default memo(forwardRef((props: Props, ref) => { const [list, setlist] = useState([]) // 区数组 const [cityList, setcityList] = useState([]) - + // 获取省 + const getProvince = async() => { + const res = await fetchData({ parent_id: 1 }) + if (res.data) { + setlist([...res.data.list]) + } + } + useEffect(() => { + getProvince() + }, []) // 区分在哪一栏 const [currentValue, setCurrentValue] = useState(1) // 顶部栏 const [TarBarList, setTarBarList] = useState([{ id: 1, name: '选择省', showBorder: true }, { id: 2, name: '选择市', showBorder: false }]) const handChose = (item) => { - TarBarList.map((it) => { + TarBarList.forEach((it) => { if (it.id === item.id) { it.showBorder = true } @@ -74,6 +71,23 @@ export default memo(forwardRef((props: Props, ref) => { }) } + // 获取市 + const getCity = async(id) => { + const res = await fetchData({ parent_id: id }) + if (res.data) { + res.data.list.map((item) => { + choseCityArr.current.list.forEach((it) => { + if (item.id == it.id) { + item.check = true + } + }) + return item + }) + setcityList([...res.data.list]) + } + const provinceArr = list.filter((next) => { return next.check }) + props.handCity?.(provinceArr, choseCityArr.current.list) + } // 选择省 const handProvince = (item) => { list.map((it) => { @@ -98,25 +112,6 @@ export default memo(forwardRef((props: Props, ref) => { }) setTarBarList([...TarBarList]) } - - // 获取市 - const getCity = async(id) => { - const res = await fetchData({ parent_id: id }) - if (res.data) { - res.data.list.map((item) => { - choseCityArr.current.list.forEach((it) => { - if (item.id == it.id) { - item.check = true - } - }) - return item - }) - setcityList([...res.data.list]) - } - const provinceArr = list.filter((next) => { return next.check }) - props.handCity?.(provinceArr, choseCityArr.current.list) - } - // 选择市 const handCity = (item) => { cityList.map((it) => { @@ -197,9 +192,9 @@ export default memo(forwardRef((props: Props, ref) => { { currentValue == 1 && { - list.map((item) => { + list.map((item, key) => { return ( - handProvince(item)}> + handProvince(item)}> {item.name} @@ -211,9 +206,9 @@ export default memo(forwardRef((props: Props, ref) => { { currentValue == 2 && { - cityList.map((item) => { + cityList.map((item, key) => { return ( - handCity(item)}> + handCity(item)}> {item.name} {/* */} @@ -225,4 +220,5 @@ export default memo(forwardRef((props: Props, ref) => { ) -})) +} +export default memo(forwardRef(ChoseCity)) diff --git a/src/pages/customerManagement/components/ItemList/index.tsx b/src/pages/customerManagement/components/ItemList/index.tsx index 59a96ed..d1d1408 100644 --- a/src/pages/customerManagement/components/ItemList/index.tsx +++ b/src/pages/customerManagement/components/ItemList/index.tsx @@ -11,8 +11,7 @@ interface Props { obj: any sortId: number | string } - -export default memo((props: Props) => { +const ItemList = (props: Props) => { const handPhone = (e) => { e.stopPropagation() Taro.makePhoneCall({ @@ -72,9 +71,9 @@ export default memo((props: Props) => { {props.obj.purchaser_type_name || '暂无'} {props.obj.sale_user_name || '暂无'} { - props.obj?.label_list?.map((item) => { + props.obj?.label_list?.map((item, key) => { return ( - {item.label_name} + {item.label_name} ) }) } @@ -94,4 +93,5 @@ export default memo((props: Props) => { ) -}) +} +export default memo(ItemList) diff --git a/src/pages/customerManagement/components/Sort/index.tsx b/src/pages/customerManagement/components/Sort/index.tsx index 6c119ca..05dad1d 100644 --- a/src/pages/customerManagement/components/Sort/index.tsx +++ b/src/pages/customerManagement/components/Sort/index.tsx @@ -18,8 +18,7 @@ interface ListType { id: string checked: boolean } - -export default memo(forwardRef((props: Props, ref) => { +const Sort = (props: Props, ref) => { const DropDownItemRef = useRef() useImperativeHandle( ref, @@ -98,11 +97,12 @@ export default memo(forwardRef((props: Props, ref) => { { list.map((item, index) => { return ( - handItem?.(item)}>{item.name} + handItem?.(item)}>{item.name} ) }) } ) -})) +} +export default memo(forwardRef(Sort)) diff --git a/src/pages/customerManagement/components/Tag/index.tsx b/src/pages/customerManagement/components/Tag/index.tsx index a9358f9..04f6f27 100644 --- a/src/pages/customerManagement/components/Tag/index.tsx +++ b/src/pages/customerManagement/components/Tag/index.tsx @@ -7,7 +7,7 @@ import { alert } from '@/common/common' import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format' import { EnumPurchaserType } from '@/api/order' import DropDownItem from '@/components/dropDown-item' -import { mppurchaserlist } from '@/api/customer' +import { MpPurchaserList } from '@/api/customer' interface Props { handType: (any) => void @@ -15,8 +15,7 @@ interface Props { value?: any onCloseOverlay?: () => void } - -export default memo(forwardRef((props: Props, ref) => { +const Tag = (props: Props, ref) => { const DropDownItemRef = useRef() useImperativeHandle( ref, @@ -49,11 +48,9 @@ export default memo(forwardRef((props: Props, ref) => { }, ]) - useEffect(() => { - getList() - }, []) const { fetchData: fetchPurchaserType } = EnumPurchaserType() - const { fetchData } = mppurchaserlist() + const { fetchData } = MpPurchaserList() + const [taglist, settaglist] = useState([]) const getList = async() => { const res = await fetchData() const purchaserType = await fetchPurchaserType() @@ -62,8 +59,9 @@ export default memo(forwardRef((props: Props, ref) => { setlist([...purchaserType.data.list]) } } - - const [taglist, settaglist] = useState([]) + useEffect(() => { + getList() + }, []) const handItem = (it) => { list.map((item) => { @@ -98,7 +96,7 @@ export default memo(forwardRef((props: Props, ref) => { { list.map((item, index) => { return ( - handItem?.(item)}>{item.name} + handItem?.(item)}>{item.name} ) }) } @@ -108,7 +106,7 @@ export default memo(forwardRef((props: Props, ref) => { { taglist.map((item, index) => { return ( - handTag?.(item)}>{item.name} + handTag?.(item)}>{item.name} ) }) } @@ -116,4 +114,5 @@ export default memo(forwardRef((props: Props, ref) => { ) -})) +} +export default memo(forwardRef(Tag)) diff --git a/src/pages/customerManagement/components/tabs/index.tsx b/src/pages/customerManagement/components/tabs/index.tsx index 4a7d148..a745b5b 100644 --- a/src/pages/customerManagement/components/tabs/index.tsx +++ b/src/pages/customerManagement/components/tabs/index.tsx @@ -8,7 +8,7 @@ interface Props { handChose?: (any) => void handReset?: () => void } -export default memo((props: Props) => { +const Tabs = (props: Props) => { const { list = [], handChose } = props return ( @@ -34,4 +34,5 @@ export default memo((props: Props) => { props?.handReset?.()}>重置 ) -}) +} +export default memo(Tabs) diff --git a/src/pages/customerManagement/index.tsx b/src/pages/customerManagement/index.tsx index 359c56f..ce1cd85 100644 --- a/src/pages/customerManagement/index.tsx +++ b/src/pages/customerManagement/index.tsx @@ -16,7 +16,7 @@ import InfiniteScroll from '@/components/infiniteScroll' import { ClientListApi } from '@/api/order' import SelectGroup from '@/components/SelectGroup' -export default () => { +const CustomerManagement = () => { const [searchField, setSearchField] = useState< { page: number @@ -41,6 +41,9 @@ export default () => { const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) const { fetchData: listFetchData, state: orderState } = ClientListApi() + + // 列表下拉刷新 + const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) const getOrderList = async() => { const res = await listFetchData({ ...getFilterData(searchField), @@ -54,13 +57,6 @@ export default () => { getOrderList() }, [searchField]) - // 输入了搜索关键字 - const getSearchData = useCallback((e) => { - pageNum.current.page = 1 - setOrderData(() => ({ list: [], total: 0 })) - setSearchField(val => ({ ...val, name_phone_or_sale_user: e, size: 10 })) - }, []) - // 数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading! }) @@ -68,6 +64,12 @@ export default () => { // 上拉加载数据 const pageNum = useRef({ size: searchField.size, page: searchField.page }) + // 输入了搜索关键字 + const getSearchData = useCallback((e) => { + pageNum.current.page = 1 + setOrderData(() => ({ list: [], total: 0 })) + setSearchField(val => ({ ...val, name_phone_or_sale_user: e, size: 10 })) + }, []) const getScrolltolower = useCallback(() => { if (orderData.list.length < orderData.total) { pageNum.current.page++ @@ -76,8 +78,6 @@ export default () => { } }, [orderData]) - // 列表下拉刷新 - const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) const getRefresherRefresh = async() => { pageNum.current.size = 1 setRefresherTriggeredStatus(true) @@ -137,7 +137,7 @@ export default () => { - + @@ -158,7 +158,7 @@ export default () => { > {orderData?.list?.map((item, index) => { return ( - + ) })} @@ -169,3 +169,5 @@ export default () => { ) } + +export default CustomerManagement diff --git a/src/pages/customerPage/index.tsx b/src/pages/customerPage/index.tsx index bad64eb..f7e527c 100644 --- a/src/pages/customerPage/index.tsx +++ b/src/pages/customerPage/index.tsx @@ -8,7 +8,7 @@ import { ClientListApi } from '@/api/order' import InfiniteScroll from '@/components/infiniteScroll' import { dataLoadingStatus, getFilterData } from '@/common/util' -export default () => { +const CustomerPage = () => { const [search, setSearch] = useState({ name_phone_or_sale_user: null, page: 1, @@ -26,7 +26,8 @@ export default () => { clientId: null, clientName: '', }) - + // 上拉加载数据 + const pageNum = useRef({ size: search.size, page: search.page }) // 输入了搜索关键字 const getSearchData = useCallback((eq) => { pageNum.current.page = 1 @@ -36,15 +37,6 @@ export default () => { const router = useRouter() - useEffect(() => { - if (search.name_phone_or_sale_user === '') { - setSearch(e => ({ ...e, name_phone_or_sale_user: null })) - } - if (search.name_phone_or_sale_user !== '') { getCuss() } - }, [search]) - - // 上拉加载数据 - const pageNum = useRef({ size: search.size, page: search.page }) const getScrolltolower = useCallback(() => { if (clentList.list.length < clentList.total) { pageNum.current.page++ @@ -77,7 +69,12 @@ export default () => { setClientlist(e => ({ ...e, list: res.data?.list, total: res.data?.total })) setRefresherTriggeredStatus(() => false) } - + useEffect(() => { + if (search.name_phone_or_sale_user === '') { + setSearch(e => ({ ...e, name_phone_or_sale_user: null })) + } + if (search.name_phone_or_sale_user !== '') { getCuss() } + }, [search]) // 选择客户 const selectClient = (item) => { clentList.list.map((it) => { @@ -118,7 +115,7 @@ export default () => { - + @@ -147,3 +144,5 @@ export default () => { ) } + +export default CustomerPage diff --git a/src/pages/delivery/components/DeliveryStatusList/index.tsx b/src/pages/delivery/components/DeliveryStatusList/index.tsx index 4d4cc96..4dbfb5a 100644 --- a/src/pages/delivery/components/DeliveryStatusList/index.tsx +++ b/src/pages/delivery/components/DeliveryStatusList/index.tsx @@ -6,7 +6,7 @@ interface PropsType { onChangeStatus?: (data: { id: number; name: string }) => void } -const DeliveryStatusList = memo((props) => { +const DeliveryStatusList = (props: PropsType) => { const { onChangeStatus } = props const { fetchData } = EnumSaleorderStatus() const [statusList, setStatusList] = useState([ @@ -38,5 +38,5 @@ const DeliveryStatusList = memo((props) => { [onChangeStatus], ) return -}) -export default DeliveryStatusList +} +export default memo(DeliveryStatusList) diff --git a/src/pages/delivery/components/Filter/index.tsx b/src/pages/delivery/components/Filter/index.tsx index def817c..f3bfb8a 100644 --- a/src/pages/delivery/components/Filter/index.tsx +++ b/src/pages/delivery/components/Filter/index.tsx @@ -12,6 +12,23 @@ import IconFont from '@/components/iconfont/iconfont' import { EnumDeliveryNoticeTypeList } from '@/api/index' import { getFilterData } from '@/common/util' +interface ButtonPropsType { + isActive: boolean + onClick?: Function + children?: React.ReactNode + customClassName?: string +} +const FilterButton: FC = (props) => { + const { onClick, children, isActive = false, customClassName } = props + const handleClick = () => { + onClick?.() + } + return ( + + {children} + + ) +} interface SearchFilter { type?: number timeKey?: string @@ -29,13 +46,6 @@ interface DeliveryPropsType { onReset?: () => void } -interface ButtonPropsType { - isActive: boolean - onClick?: Function - children?: React.ReactNode - customClassName?: string -} - export const filterTimeOptions = { 0: { name: '不限', @@ -69,7 +79,7 @@ export const filterTimeOptions = { }, } as const -const DeliveryFilter = memo((props) => { +const DeliveryFilter = (props: DeliveryPropsType) => { const { onSearchTime, onConfirm, onCancal, onReset } = props const { fetchData, state } = EnumDeliveryNoticeTypeList() @@ -92,17 +102,15 @@ const DeliveryFilter = memo((props) => { return state.data.list }, [state]) + const getEnumData = async() => { + await fetchData() + } useEffect(() => { if (!typeList?.length) { getEnumData() console.log('getEnumData') } }, [typeList]) - - const getEnumData = async() => { - await fetchData() - } - const [customTime, setCustomTime] = useState({ date_min: undefined, date_max: undefined, @@ -144,9 +152,9 @@ const DeliveryFilter = memo((props) => { 不限 {!!typeList?.length - && typeList?.map((item) => { + && typeList?.map((item, key) => { return ( - handleSelectedType(item?.id)}> + handleSelectedType(item?.id)}> {item.name} ) @@ -157,9 +165,9 @@ const DeliveryFilter = memo((props) => { 查询日期 - {Object.entries(filterTimeOptions).map(([key, value]) => { + {Object.entries(filterTimeOptions).map(([key, value], index) => { return ( - handleSelectedTime(key)}> + handleSelectedTime(key)}> {value.name} ) @@ -179,18 +187,6 @@ const DeliveryFilter = memo((props) => { ) -}) - -const FilterButton: FC = (props) => { - const { onClick, children, isActive = false, customClassName } = props - const handleClick = () => { - onClick?.() - } - return ( - - {children} - - ) } -export default DeliveryFilter +export default memo(DeliveryFilter) diff --git a/src/pages/delivery/index.tsx b/src/pages/delivery/index.tsx index c74714e..f605c54 100644 --- a/src/pages/delivery/index.tsx +++ b/src/pages/delivery/index.tsx @@ -51,16 +51,6 @@ const Delivery: FC = () => { console.log('searchValue==>', searchValue) }, []) - useEffect(() => { - if (!isFirst.current) { - getData() - } - }, [search]) - - useDidShow(() => { - getData() - }) - // 上拉加载数据 const pageNum = useRef({ size: search.size, page: search.page }) @@ -173,11 +163,19 @@ const Delivery: FC = () => { ) } + useEffect(() => { + if (!isFirst.current) { + getData() + } + }, [search]) + useDidShow(() => { + getData() + }) return ( - + diff --git a/src/pages/deliveryDetail/index.tsx b/src/pages/deliveryDetail/index.tsx index 5f228bb..7fd9cf2 100644 --- a/src/pages/deliveryDetail/index.tsx +++ b/src/pages/deliveryDetail/index.tsx @@ -41,9 +41,9 @@ const DeliveryDetail: FC = () => { const DetailItem = useMemo(() => { const element = !!detailInfo?.weight_list?.length - && detailInfo?.weight_list.map((weightItem) => { + && detailInfo?.weight_list.map((weightItem, index) => { return ( - + diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 17686c8..97e2874 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -7,21 +7,23 @@ import SideBar from '@/components/sideBar' import Product from '@/components/product' import ShopCart from '@/components/shoppingCart' import { goLink } from '@/common/common' -import { ProductListApi, kindListApi } from '@/api/index' +import { KindListApi, ProductListApi } from '@/api/index' // import useLogin from '@/use/useLogin' -import { mpproductcolorlist, mpshoppingCartproductColorlist } from '@/api/order' +import { MpProductColorList, MpShoppingCartProductColorList } from '@/api/order' import { dataLoadingStatus, getFilterData } from '@/common/util' import { ClientListApi } from '@/api/order' -export default () => { - useEffect(() => { - categoryList() - getClient() - }, []) - +const Index = () => { // 获取客户 const [clienList, setclienList] = useState([]) const { fetchData: listFetchData } = ClientListApi() + // 列表下拉刷新 + const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) + + const [clientObj, setclientObj] = useState({ + clientId: -1, + clientName: '', + }) const getClient = async() => { const res = await listFetchData({ page: 1, size: 10, @@ -33,9 +35,10 @@ export default () => { setclienList([...res.data.list]) } + const [filtrate, setFiltrate] = useState({ product_kind_id: 0, size: 5, page: 1 }) // 获取面料种类 const [kindData, setKindData] = useState({ list: [], defaultId: 0 }) - const { fetchData } = kindListApi() + const { fetchData } = KindListApi() const categoryList = async() => { const res = await fetchData() if (res.data?.list) { @@ -47,7 +50,6 @@ export default () => { // 获取面料列表 const [productData, setProductData] = useState({ list: [], total: 0 }) const [hasMore, setHasMore] = useState(true) - const [filtrate, setFiltrate] = useState({ product_kind_id: 0, size: 5, page: 1 }) const pageNum = useRef({ size: filtrate.size, page: filtrate.page }) const { fetchData: productFetchData, state: productState } = ProductListApi() // 获取数据方法 @@ -82,15 +84,16 @@ export default () => { const [showShopCart, setShowShopCart] = useState(false) - // 列表下拉刷新 - const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) const getRefresherRefresh = async() => { pageNum.current.page = 1 setFiltrate({ ...filtrate, size: 5 }) setHasMore(true) setRefresherTriggeredStatus(true) } - + useEffect(() => { + categoryList() + getClient() + }, []) const onj = JSON.parse(Taro.getStorageSync('userInfo') || '{}') const [search, setSearchObj] = useState({ modeId: 0, @@ -102,6 +105,8 @@ export default () => { // 选择的类型 const [typeList, setTypeList] = useState([{ id: 0, name: '大货', checked: true }, { id: 1, name: '剪版', checked: false }, { id: 2, name: '散剪', checked: false }]) + + const [goodList, setGoodlist] = useState([]) // 选择类型 const handCheckMode = (item) => { typeList.map((it) => { @@ -117,8 +122,7 @@ export default () => { setTypeList([...typeList]) setGoodlist([]) } - const [goodList, setGoodlist] = useState([]) - const { fetchData: colorlistFetch } = mpproductcolorlist() + const { fetchData: colorlistFetch } = MpProductColorList() const ShopCartRef = useRef(null) const [goodObj, setGoodsobj] = useState({}) @@ -162,7 +166,7 @@ export default () => { } // 数据加载状态 const statusMore = useMemo(() => { - return dataLoadingStatus({ list: productData.list, total: productData.total, status: productState.loading }) + return dataLoadingStatus({ list: productData.list, total: productData.total, status: productState.loading! }) }, [productData, productState.loading]) // 点击加展示输入框 @@ -181,13 +185,22 @@ export default () => { if (item.id === it.id) { item.nums-- if (search.modeId == 0) { - if (item.nums < 1) { it.showInput = false, it.nums = 1 } + if (item.nums < 1) { + it.showInput = false + it.nums = 1 + } } if (search.modeId == 1) { - if (item.nums < 0.5) { it.showInput = false, it.nums = 0.5 } + if (item.nums < 0.5) { + it.showInput = false + it.nums = 0.5 + } } if (search.modeId == 2) { - if (item.nums < 3) { it.showInput = false, it.nums = 3 } + if (item.nums < 3) { + it.showInput = false + it.nums = 3 + } } } return item @@ -211,13 +224,8 @@ export default () => { setSearchObj(e => ({ ...e, code_or_name: eq })) }, []) - const [clientObj, setclientObj] = useState({ - clientId: -1, - clientName: '', - }) - // 加入购物车 - const { fetchData: preViewFetch } = mpshoppingCartproductColorlist() + const { fetchData: preViewFetch } = MpShoppingCartProductColorList() const handSure = async() => { const arr = goodList.filter((item) => { return item.showInput @@ -368,4 +376,5 @@ export default () => { // ) } +export default Index // oninputEvent={(e, item) => { oninputEvent(e, item) }} diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index b2747b9..66b78cd 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -12,6 +12,19 @@ import { LoginApi } from '@/api' import { alert } from '@/common/common' import useUserInfo from '@/use/useUserInfo' +const QuickLogin: FC = () => { + return ( + + + 或通过以下方式登录 + + + + + + ) +} +const QuickLoginWithMemo = memo(QuickLogin) const Login: FC = () => { const [isRemember, setRemember] = useState(false) @@ -115,23 +128,10 @@ const Login: FC = () => { 登录 - + ) } -const QuickLogin: FC = memo(() => { - return ( - - - 或通过以下方式登录 - - - - - - ) -}) - export default Login diff --git a/src/pages/newCollection/components/itemList/index.tsx b/src/pages/newCollection/components/itemList/index.tsx index 4568125..072e554 100644 --- a/src/pages/newCollection/components/itemList/index.tsx +++ b/src/pages/newCollection/components/itemList/index.tsx @@ -10,8 +10,7 @@ import { formatDateTime, formatPriceDiv } from '@/common/format' interface Params { obj: any } - -export default memo((pros: Params) => { +const ItemList = (pros: Params) => { const navTo = () => { Taro.navigateTo({ url: `/pages/collectionDetail/index?id=${pros.obj.id}`, @@ -51,4 +50,5 @@ export default memo((pros: Params) => { navTo()}>查看详情 ) -}) +} +export default memo(ItemList) diff --git a/src/pages/newCollection/index.tsx b/src/pages/newCollection/index.tsx index c6be1d6..b3b89e8 100644 --- a/src/pages/newCollection/index.tsx +++ b/src/pages/newCollection/index.tsx @@ -11,12 +11,12 @@ import Popup from '@/components/popup' import InfiniteScroll from '@/components/infiniteScroll' import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format' import { - mpcashManagementOrderlist, + MpCashManagementOrderList, } from '@/api/newCollection' import TimePickerPopup from '@/components/timePickerPopup' import IconFont from '@/components/iconfont/iconfont' -export default () => { +const NewCollection = () => { const myDate = new Date() const [searchField, setSearchField] = useState< { @@ -34,24 +34,18 @@ export default () => { }) const pageNum = useRef({ size: searchField.size, page: searchField.page }) - useDidShow(() => { - getOrderList() - }) + // 获取订单列表 + const { fetchData: listFetchData, state: orderState } = MpCashManagementOrderList() + const [orderData, setOrderData] = useState<{ list: any[]; total: number; summary?: any }>({ list: [], total: 0, summary: {} }) - // 监听筛选条件变化 - useEffect(() => { - getOrderList() - }, [searchField.size, searchField.search_name]) // 输入了搜索关键字 const getSearchData = useCallback((e) => { pageNum.current.page = 1 setOrderData(() => ({ list: [], total: 0 })) setSearchField(val => ({ ...val, search_name: e, size: 10 })) }, []) - - // 获取订单列表 - const { fetchData: listFetchData, state: orderState } = mpcashManagementOrderlist() - const [orderData, setOrderData] = useState<{ list: any[]; total: number; summary?: any }>({ list: [], total: 0, summary: {} }) + // 列表下拉刷新 + const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) const getOrderList = async() => { const res = await listFetchData({ ...searchField, @@ -60,9 +54,6 @@ export default () => { // setshowPopup(false) setRefresherTriggeredStatus(false) } - - // 列表下拉刷新 - const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) const getRefresherRefresh = async() => { pageNum.current.page = 1 // pageNum.current.size = 10 @@ -132,6 +123,65 @@ export default () => { ], ) + // 弹窗确认选择 + const handSureSelect = () => { + pageNum.current.size = 10 + setSearchField({ ...searchField, size: 10 }) + getOrderList() + setSelectPopup(false) + } + + // 展示时间筛选 + const [showTime, setShowTime] = useState(false) + // 关闭时间筛选 + const handClose = () => { + setShowTime(false) + } + + const [start, setStart] = useState(myDate.toLocaleDateString()) + const [end, setEnd] = useState('') + // 选择时间 + const handTime = (eq) => { + // 直接进来点确定的时候做处理 + if (Object.keys(eq).length === 0) { + const obj = { + start: '', + end: '', + } + obj.start = `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).format('YYYY-MM-DD')} 00:00:00` + obj.end = `${dayjs(new Date(obj?.start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00` + eq.value = obj + } + setSearchField(val => ({ ...val, start_time: eq?.value?.start, end_time: eq?.value?.end })) + setStart(eq?.value?.start) + setEnd(eq?.value?.end) + setShowTime(false) + pageNum.current.size = 10 + } + useDidShow(() => { + getOrderList() + }) + + // 监听筛选条件变化 + useEffect(() => { + getOrderList() + }, [searchField.size, searchField.search_name]) + const timeArea = useMemo(() => { + // const res = TimeList.filter(item => { + // return item.checked + // }) + // && res.length > 0 + if (end !== '') { + return `${start} ` + '-' + ` ${end}` + } + else { + return '自定义起始时间' + } + }, [end]) + + useEffect(() => { + setSearchField(searchField) + }, [searchField]) // 选择时间item const handSelect = (it) => { TimeList.map((item) => { @@ -171,64 +221,10 @@ export default () => { setStart(myDate.toLocaleDateString()) setEnd('') } - - // 弹窗确认选择 - const handSureSelect = () => { - pageNum.current.size = 10 - setSearchField({ ...searchField, size: 10 }) - getOrderList() - setSelectPopup(false) - } - - // 展示时间筛选 - const [showTime, setShowTime] = useState(false) - // 关闭时间筛选 - const handClose = () => { - setShowTime(false) - } - - const [start, setStart] = useState(myDate.toLocaleDateString()) - const [end, setEnd] = useState('') - // 选择时间 - const handTime = (eq) => { - // 直接进来点确定的时候做处理 - if (Object.keys(eq).length === 0) { - const obj = { - start: '', - end: '', - } - obj.start = `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).format('YYYY-MM-DD')} 00:00:00`, - obj.end = `${dayjs(new Date(obj?.start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00` - eq.value = obj - } - setSearchField(val => ({ ...val, start_time: eq?.value?.start, end_time: eq?.value?.end })) - setStart(eq?.value?.start) - setEnd(eq?.value?.end) - setShowTime(false) - pageNum.current.size = 10 - } - - const timeArea = useMemo(() => { - // const res = TimeList.filter(item => { - // return item.checked - // }) - // && res.length > 0 - if (end !== '') { - return `${start} ` + '-' + ` ${end}` - } - else { - return '自定义起始时间' - } - }, [end]) - - useEffect(() => { - setSearchField(searchField) - }, [searchField]) - return ( <> - + { setSelectPopup(true) }}> {/* */} @@ -303,3 +299,4 @@ export default () => { ) } +export default NewCollection diff --git a/src/pages/order/components/PayPopup/index.tsx b/src/pages/order/components/PayPopup/index.tsx index 6ea9010..aa46f6c 100644 --- a/src/pages/order/components/PayPopup/index.tsx +++ b/src/pages/order/components/PayPopup/index.tsx @@ -29,8 +29,7 @@ interface Props { title: string picUrl?: string } - -export default memo((props: Props) => { +const PayPopup = (props: Props) => { const { showSide = true, showPopup = false, @@ -73,10 +72,6 @@ export default memo((props: Props) => { // 检查是否开启保存图片权限 const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' }) - const saveImageCheck = async() => { - const res = await check() - res && saveImage() - } // 保存图片 const saveImage = () => { @@ -102,7 +97,10 @@ export default memo((props: Props) => { }, }) } - + const saveImageCheck = async() => { + const res = await check() + res && saveImage() + } return ( popupClose?.()}> @@ -190,4 +188,5 @@ export default memo((props: Props) => { ) -}) +} +export default memo(PayPopup) diff --git a/src/pages/order/components/itemList/index.tsx b/src/pages/order/components/itemList/index.tsx index 51a9ccc..bb5adea 100644 --- a/src/pages/order/components/itemList/index.tsx +++ b/src/pages/order/components/itemList/index.tsx @@ -13,8 +13,7 @@ interface propsObj { nextBuy?: (arg: any, obj: any) => void toPay?: (arg: any, obj: any) => void } - -export default memo((props: propsObj) => { +const ItemList = (props: propsObj) => { const navTo = (e) => { Taro.navigateTo({ url: `/pages/orderDetails/index?id=${props?.obj?.id}`, @@ -105,4 +104,5 @@ export default memo((props: propsObj) => { ) -}) +} +export default memo(ItemList) diff --git a/src/pages/order/components/offlinePay/index.tsx b/src/pages/order/components/offlinePay/index.tsx index bfeb881..d6f1b09 100644 --- a/src/pages/order/components/offlinePay/index.tsx +++ b/src/pages/order/components/offlinePay/index.tsx @@ -18,7 +18,7 @@ interface Param { } showKong?: true | false } -export default memo(({ show = true, onClose, offlineInfo, showKong = true }: Param) => { +const OfflinePay = ({ show = true, onClose, offlineInfo, showKong = true }: Param) => { // 复制功能 const clipboardData = () => { Taro.setClipboardData({ @@ -98,4 +98,5 @@ export default memo(({ show = true, onClose, offlineInfo, showKong = true }: Par ) -}) +} +export default memo(OfflinePay) diff --git a/src/pages/order/components/orderStatusList/index.tsx b/src/pages/order/components/orderStatusList/index.tsx index ed46c5e..e5da965 100644 --- a/src/pages/order/components/orderStatusList/index.tsx +++ b/src/pages/order/components/orderStatusList/index.tsx @@ -8,11 +8,17 @@ interface Param { defaultId?: number | null onSelect?: (val: number) => void } -export default memo(({ list = [], defaultId = null, onSelect }: Param) => { +const OrderStatusList = ({ list = [], defaultId = null, onSelect }: Param) => { const [selectInfo, setSelectInfo] = useState({ selected: -1, // 当前选中的id tabId: '', // 需要滚动到的id }) + + const clickEvent = ({ item, index }: { item: any; index: number }) => { + const num = index > 0 ? index - 1 : 0 + setSelectInfo(e => ({ ...e, tabId: list[num].id.toString(), selected: item.id })) + onSelect?.(item.id) + } useEffect(() => { if (typeof defaultId === 'number' && defaultId >= 0) { console.log('defaultId:::', defaultId) @@ -26,12 +32,6 @@ export default memo(({ list = [], defaultId = null, onSelect }: Param) => { } setSelectInfo(e => ({ ...e, selected: defaultId || -1 })) }, [defaultId]) - const clickEvent = ({ item, index }: { item: any; index: number }) => { - const num = index > 0 ? index - 1 : 0 - setSelectInfo(e => ({ ...e, tabId: list[num].id.toString(), selected: item.id })) - onSelect?.(item.id) - } - return ( @@ -52,4 +52,5 @@ export default memo(({ list = [], defaultId = null, onSelect }: Param) => { ) -}) +} +export default memo(OrderStatusList) diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index ef7f26b..d94c0eb 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -8,14 +8,14 @@ import ItemList from './components/itemList' import OfflinePay from './components/offlinePay' import PayPopup from './components/PayPopup' import { - GetPayCode, OrderListApi, - mpenumsaleorderstatus, - mpsaleOrdercancel, - mpshoppingCartproductColorlist, - orderPaymentorderPaymentMethodInfo, - orderPaymentorderPaymentSubmission, - orderPaymentpreCollectOrderorderPaymentMethodInfo, - orderPaymentpreCollectOrderorderPaymentSubmission, + GetPayCode, MpEnumSaleOrderStatus, + MpSaleOrderCancel, + MpShoppingCartProductColorList, + OrderListApi, + OrderPaymentOrderPaymentMethodInfo, + OrderPaymentOrderPaymentSubmission, + OrderPaymentPreCollectOrderOrderPaymentMethodInfo, + OrderPaymentPreCollectOrderOrderPaymentSubmission, } from '@/api/order' import Search from '@/components/search' import { dataLoadingStatus, getFilterData } from '@/common/util' @@ -81,7 +81,7 @@ export default () => { }, [orderData]) // //获取订单状态 - const { fetchData: orderStatusListFetchData } = mpenumsaleorderstatus() + const { fetchData: orderStatusListFetchData } = MpEnumSaleOrderStatus() const [statusList, setStatusList] = useState([{ id: -1, name: '全部' }]) const getOrderStatusList = async() => { const res = await orderStatusListFetchData() @@ -247,7 +247,7 @@ export default () => { getOrderStatusList() }, []) - const { fetchData: cancelFetch } = mpsaleOrdercancel() + const { fetchData: cancelFetch } = MpSaleOrderCancel() // 取消订单 const cancle = async(e, item) => { e.stopPropagation() @@ -280,7 +280,7 @@ export default () => { }) } // 再次购买 - const { fetchData: buyFetch } = mpshoppingCartproductColorlist() + const { fetchData: buyFetch } = MpShoppingCartProductColorList() const nextBuy = async(e, item) => { e.stopPropagation() Taro.showLoading({ @@ -318,8 +318,8 @@ export default () => { } } // 去支付逻辑 - const { fetchData: infoOneFetch } = orderPaymentorderPaymentMethodInfo() - const { fetchData: infoTwoFetch } = orderPaymentpreCollectOrderorderPaymentMethodInfo() + const { fetchData: infoOneFetch } = OrderPaymentOrderPaymentMethodInfo() + const { fetchData: infoTwoFetch } = OrderPaymentPreCollectOrderOrderPaymentMethodInfo() const [itemObj, setItemObj] = useState({}) const [payList, setPayList] = useState([ { @@ -539,8 +539,8 @@ export default () => { } // 确认交易 - const { fetchData: payOneFetch } = orderPaymentorderPaymentSubmission() - const { fetchData: payTwoFetch } = orderPaymentpreCollectOrderorderPaymentSubmission() + const { fetchData: payOneFetch } = OrderPaymentOrderPaymentSubmission() + const { fetchData: payTwoFetch } = OrderPaymentPreCollectOrderOrderPaymentSubmission() const handsurePay = (obj) => { let arr: any = [] // if (obj.status !== 10) { diff --git a/src/pages/orderDetails/components/BottomApply/index.tsx b/src/pages/orderDetails/components/BottomApply/index.tsx index 3008a20..9699130 100644 --- a/src/pages/orderDetails/components/BottomApply/index.tsx +++ b/src/pages/orderDetails/components/BottomApply/index.tsx @@ -16,8 +16,7 @@ interface prosObj { goodsObj?: any // handSureGoods?: () => void, } - -export default memo((props: prosObj) => { +const BottomApply = (props: prosObj) => { const { obj = { sale_mode: 0, @@ -86,4 +85,5 @@ export default memo((props: prosObj) => { } ) -}) +} +export default memo(BottomApply) diff --git a/src/pages/orderDetails/components/addressDetailBox/index.tsx b/src/pages/orderDetails/components/addressDetailBox/index.tsx index 3bbd1ce..32647b9 100644 --- a/src/pages/orderDetails/components/addressDetailBox/index.tsx +++ b/src/pages/orderDetails/components/addressDetailBox/index.tsx @@ -11,7 +11,7 @@ interface propsObj { obj?: any navSelect?: (any) => void } -export default memo((props: propsObj) => { +const AddressDetailBox = (props: propsObj) => { const { receivingStatus = null, onReceivingStatus, @@ -61,4 +61,5 @@ export default memo((props: propsObj) => { ) -}) +} +export default memo(AddressDetailBox) diff --git a/src/pages/orderDetails/components/advanceOrderState/index.tsx b/src/pages/orderDetails/components/advanceOrderState/index.tsx index 7ef9d78..5f6efee 100644 --- a/src/pages/orderDetails/components/advanceOrderState/index.tsx +++ b/src/pages/orderDetails/components/advanceOrderState/index.tsx @@ -23,8 +23,7 @@ interface Param { status: number // 订单状态 } } - -export default memo(({ orderInfo, onRefresh }: Param) => { +const AdvanceOrderState = ({ orderInfo, onRefresh }: Param) => { const { showTime, onStart, timeStatus } = useTimeCountDown() // 订单状态枚举 @@ -68,4 +67,5 @@ export default memo(({ orderInfo, onRefresh }: Param) => { ) -}) +} +export default memo(AdvanceOrderState) diff --git a/src/pages/orderDetails/components/orderState/index.tsx b/src/pages/orderDetails/components/orderState/index.tsx index a4d187d..7c86530 100644 --- a/src/pages/orderDetails/components/orderState/index.tsx +++ b/src/pages/orderDetails/components/orderState/index.tsx @@ -24,8 +24,7 @@ interface Param { account_period_time?: string // 还款日期 } } - -export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => { +const OrderState = ({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => { useEffect(() => { console.log('orderInfo33::', orderInfo) }, [orderInfo]) @@ -51,7 +50,7 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s <> {(dataList?.length > 0) && - {dataList.map((item, index) => + {dataList.map((item, index) => {(dataList.length > 1) && } {(dataList.length != (index + 1)) && } @@ -62,7 +61,7 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s )} {(dataList.length > 2) && changeMore()}> - {showMore && '收起详情' || '点击查看详情'} + {showMore ? '收起详情' : '点击查看详情'} } @@ -76,4 +75,5 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s } ) -}) +} +export default memo(OrderState) diff --git a/src/pages/orderDetails/components/remark/index.tsx b/src/pages/orderDetails/components/remark/index.tsx index 16c0c92..5ee6d7d 100644 --- a/src/pages/orderDetails/components/remark/index.tsx +++ b/src/pages/orderDetails/components/remark/index.tsx @@ -9,17 +9,13 @@ interface Param { defaultValue?: string showInput: boolean } -export default ({ onBlur, onSave, defaultValue = '', showInput = false }: Param) => { +const Remark = ({ onBlur, onSave, defaultValue = '', showInput = false }: Param) => { const [descData, setDescData] = useState({ number: 0, value: '', count: 200, }) - useEffect(() => { - getDesc(defaultValue) - }, [defaultValue]) - const getDesc = (value) => { let res = value if (value.length > descData.count) { @@ -31,6 +27,9 @@ export default ({ onBlur, onSave, defaultValue = '', showInput = false }: Param) const setSave = () => { onSave?.(descData.value) } + useEffect(() => { + getDesc(defaultValue) + }, [defaultValue]) return ( 编辑备注 @@ -45,3 +44,5 @@ export default ({ onBlur, onSave, defaultValue = '', showInput = false }: Param) ) } + +export default Remark diff --git a/src/pages/orderDetails/index.tsx b/src/pages/orderDetails/index.tsx index f23668c..182c32a 100644 --- a/src/pages/orderDetails/index.tsx +++ b/src/pages/orderDetails/index.tsx @@ -16,40 +16,165 @@ import BottomBtns from '@/components/BottomBtns' import { debounce } from '@/common/util' import { GetPayCode, - mpsaleOrder, - mpsaleOrderaddress, - mpsaleOrdercancel, - mpsaleOrderput, - mpsaleOrderreceive, - mpsaleOrdershipmentMode, - mpshoppingCartproductColorlist, - orderPaymentorderPaymentMethodInfo, - orderPaymentorderPaymentSubmission, - orderPaymentpreCollectOrderorderPaymentMethodInfo, - orderPaymentpreCollectOrderorderPaymentSubmission, + MpSaleOrder, + MpSaleOrderAddress, + MpSaleOrderCancel, + MpSaleOrderPut, + MpSaleOrderReceive, + MpSaleOrderShipmentMode, + MpShoppingCartProductColorList, + OrderPaymentOrderPaymentMethodInfo, + OrderPaymentOrderPaymentSubmission, + OrderPaymentPreCollectOrderOrderPaymentMethodInfo, + OrderPaymentPreCollectOrderOrderPaymentSubmission, } from '@/api/order' import { alert, goLink } from '@/common/common' import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format' import IconFont from '@/components/iconfont/iconfont' import { PAY_H5_CODE_URL } from '@/common/constant' -export default () => { +// 卡片盒子元素 +interface Obs { + title?: string + modeName?: string + showMode?: boolean + children?: ReactNode + clickNode?: () => void +} + +const DefaultBox = (props: Obs) => { + const { + title = '标题', + modeName = '大货', + showMode = false, + children, + clickNode, + } = props + + return ( + + + {title} + { + showMode && clickNode?.()}>{modeName} + } + + + {children} + + ) +} +const DefaultBoxWithMemo = memo(DefaultBox) + +// 产品商品元素 +interface PropGoods { + // item?: { + // code?: string | number + // } + list: any[] + obj: { + sale_mode?: number | string + } +} +const GoodsItem = (porps: PropGoods) => { + const { list = [], obj = {} } = porps + return ( + <> + { + list.map((item, index) => { + return ( + + {item.code}# {item.name} + + { + item.product_colors.map((it, inx) => { + return ( + + + + + {it.code}# {it.name} + x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} + + + ¥{it.sale_price / 100}/{obj?.sale_mode === 1 ? 'm' : 'kg'} + ¥{formatPriceDiv(it.total_sale_price)} + + + + ) + }) + } + + ) + }) + } + + + ) +} +const GoodsItemWithMemo = memo(GoodsItem) + +const OrderDetails = () => { const router = useRouter() // useEffect(() => { // getDetail() // }, []) - useDidShow(() => { - getDetail() - }) - // 页面下拉刷新 - usePullDownRefresh(() => { - getDetail() - }) // 收货方法,1:自提,2物流 const [receivingStatus, setReceivingStatus] = useState(null) // 切换自提或者物流 - const { fetchData: selectFetch } = mpsaleOrdershipmentMode() + const { fetchData: selectFetch } = MpSaleOrderShipmentMode() + // 订单信息文字数组 + const [orderMsg, setOrderMsg] = useState([ + { + leftTitle: '订单编号:', + rightTitle: '------', + showBtn: true, + }, + { + leftTitle: '创建时间:', + rightTitle: '------', + }, + { + leftTitle: '发货时间:', + rightTitle: '------', + }, + { + leftTitle: '业务员:', + rightTitle: '------', + }, + ]) + const { fetchData: infoFetch } = MpSaleOrder() + const [infoObj, setInfoObj] = useState({}) + // 获取订单详情 + const getDetail = async() => { + Taro.showLoading({ + title: '加载中...', + mask: true, + }) + const res = await infoFetch({ id: router.params.id }) + setInfoObj(res.data) + orderMsg.forEach((it) => { + if (it.leftTitle === '订单编号:') { + it.rightTitle = res.data.order_no + } + if (it.leftTitle === '创建时间:') { + it.rightTitle = formatDateTime(res.data.create_time) + } + if (it.leftTitle === '发货时间:') { + it.rightTitle = formatDateTime(res.data.delivery_time) + } + if (it.leftTitle === '业务员:') { + it.rightTitle = res.data.sale_user_name + } + }) + setOrderMsg([...orderMsg]) + setReceivingStatus(res.data.shipment_mode) + // 小程序提供的api,通知页面停止下拉刷新效果 + Taro.stopPullDownRefresh() + Taro.hideLoading() + } const onReceivingStatus = debounce(async(e, value) => { if (infoObj.status === 8 || infoObj.status === 9 || infoObj.status === 4 || infoObj.status === 5 || infoObj.status === 3 || infoObj.status === 11) { alert.error('不允许更改') @@ -92,36 +217,6 @@ export default () => { } }, 300) - const { fetchData: infoFetch } = mpsaleOrder() - const [infoObj, setInfoObj] = useState({}) - // 获取订单详情 - const getDetail = async() => { - Taro.showLoading({ - title: '加载中...', - mask: true, - }) - const res = await infoFetch({ id: router.params.id }) - setInfoObj(res.data) - orderMsg.map((it) => { - if (it.leftTitle === '订单编号:') { - it.rightTitle = res.data.order_no - } - if (it.leftTitle === '创建时间:') { - it.rightTitle = formatDateTime(res.data.create_time) - } - if (it.leftTitle === '发货时间:') { - it.rightTitle = formatDateTime(res.data.delivery_time) - } - if (it.leftTitle === '业务员:') { - it.rightTitle = res.data.sale_user_name - } - }) - setOrderMsg([...orderMsg]) - setReceivingStatus(res.data.shipment_mode) - // 小程序提供的api,通知页面停止下拉刷新效果 - Taro.stopPullDownRefresh() - Taro.hideLoading() - } // 复制功能 const clipboardData = () => { Taro.setClipboardData({ @@ -138,30 +233,10 @@ export default () => { // useEffect(() => { // setReceivingStatus(receivingStatus) // }, [receivingStatus]) - // 订单信息文字数组 - const [orderMsg, setOrderMsg] = useState([ - { - leftTitle: '订单编号:', - rightTitle: '------', - showBtn: true, - }, - { - leftTitle: '创建时间:', - rightTitle: '------', - }, - { - leftTitle: '发货时间:', - rightTitle: '------', - }, - { - leftTitle: '业务员:', - rightTitle: '------', - }, - ]) // 备注操作 const [showDesc, setShowDesc] = useState(false) - const { fetchData: remarkFetch } = mpsaleOrderput() + const { fetchData: remarkFetch } = MpSaleOrderPut() const getRemark = async() => { const res = await remarkFetch({ remark: infoObj.remark, id: Number(router.params.id) }) if (res.msg === 'success') { @@ -183,7 +258,7 @@ export default () => { getDetail() }, []) - const { fetchData: cancelFetch } = mpsaleOrdercancel() + const { fetchData: cancelFetch } = MpSaleOrderCancel() // 取消订单 const cancle = async(e, item) => { e.stopPropagation() @@ -216,7 +291,7 @@ export default () => { }) } // 再次购买 - const { fetchData: buyFetch } = mpshoppingCartproductColorlist() + const { fetchData: buyFetch } = MpShoppingCartProductColorList() const nextBuy = async(e, item) => { e.stopPropagation() Taro.showLoading({ @@ -254,8 +329,8 @@ export default () => { } } // 去支付逻辑 - const { fetchData: infoOneFetch } = orderPaymentorderPaymentMethodInfo() - const { fetchData: infoTwoFetch } = orderPaymentpreCollectOrderorderPaymentMethodInfo() + const { fetchData: infoOneFetch } = OrderPaymentOrderPaymentMethodInfo() + const { fetchData: infoTwoFetch } = OrderPaymentPreCollectOrderOrderPaymentMethodInfo() const [payList, setPayList] = useState([ { id: 2, @@ -290,6 +365,138 @@ export default () => { name: '扫码支付', }, ]) + + useDidShow(() => { + getDetail() + }) + // 页面下拉刷新 + usePullDownRefresh(() => { + getDetail() + }) + + // 扫码支付 + const [showSide, setShowSide] = useState(true) + const [title, setTitle] = useState('') + const [picUrl, setPicUrl] = useState('') + const { fetchData: payFetch } = GetPayCode() + const handScanpay = async() => { + const list: any = [] + infoObj.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: infoObj.sale_mode_name, + shipment_mode: infoObj.shipment_mode_name, + company: infoObj.title_purchaser_name, + sale_user: infoObj.sale_user_name, + order_created_time: formatDateTime(infoObj.create_time), + order_no: infoObj.order_no, + target_user_name: infoObj.target_user_name, + target_address: infoObj.address_detail, + target_description: infoObj.remark, + pay_account: infoObj.transfer_remittance_account, + bank_account_name: infoObj.account_name, + bank_name: infoObj.bank_of_deposit, + pay_type: infoObj.settle_mode_name, + client: infoObj.purchaser_name, + phone: infoObj.target_user_phone, + order_total_length: (infoObj.total_number / 100).toString(), + order_total_price: ( + infoObj.bill_total_sale_price / 100 + ).toString(), + total_weight_error_discount: ( + infoObj.total_weight_error_discount / 100 + ).toString(), + order_total_num: infoObj.total_number.toString(), + qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${infoObj.order_no}`, + order_total_weight: (infoObj.total_weight / 1000).toString(), + estimate_amount: (infoObj.estimate_amount / 100).toString(), + total_sale_price: (infoObj.total_sale_price / 100).toString(), + show_total_sale_price: true, + show_total_weight_error_discount: true, + actual_amount: (infoObj.actual_amount / 100).toString(), + wait_pay_amount: (infoObj.wait_pay_amount / 100).toString(), + order_total_weight_error: ( + infoObj.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() + + // 显示支付 + const [showPay, setShowPay] = useState(false) + // 显示线下汇款 + const [showOffline, setShowOffine] = useState(false) + // 选择地址 + const handSelect = (obj) => { + if (receivingStatus === 1 || (infoObj.status === 8 || infoObj.status === 9 || infoObj.status === 4 || infoObj.status === 5 || infoObj.status === 11 || infoObj.status === 3)) { + alert.error('不允许更改') + return false + } + Taro.navigateTo({ + url: `/pages/addressManager/index?orderId=${obj.id}&purchaser_id=${obj.purchaser_id}`, + }) + } + + // 申请退货 + const handApplyGood = () => { + if (infoObj.av_return_product.length == 0) { + return alert.error('暂无货物退') + } + else { + Taro.navigateTo({ + url: `/pages/applyGoods/index?orderId=${infoObj.id}`, + }) + setShowMore(false) + } + } + + // 申请退款 + const handApplyMoney = () => { + // 三种类型的 待收货,已收货后申请退货退款,需要选择质量/非质量问题 + if (infoObj?.status == 8 || infoObj?.status == 9) { + Taro.navigateTo({ + url: `/pages/applyGoods/index?orderId=${infoObj.id}`, + }) + } + else { + Taro.navigateTo({ + url: `/pages/applyMoney/index?orderId=${infoObj.id}`, + }) + } + setShowMore(false) + } const toPay = async(e, item) => { e.stopPropagation() @@ -372,102 +579,43 @@ 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 + // 确认收货 + const { fetchData: receveFetch } = MpSaleOrderReceive() + const handSureGoods = async() => { + Taro.showModal({ + content: '确认收货吗?', + confirmText: '确认', + cancelText: '取消', + async success(res) { + if (res.confirm) { + Taro.showLoading({ + title: '请稍等...', + mask: true, + }) + const res = await receveFetch({ sale_order_id: Number(infoObj.id) }) + if (res?.msg === 'success') { + Taro.showToast({ + title: '成功', + }) + Taro.hideLoading() + setShowMore(false) + getDetail() + } + else { + Taro.hideLoading() + Taro.showToast({ + title: res?.msg, + icon: 'error', + }) + } + } + }, }) - 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 = [] - infoObj.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: infoObj.sale_mode_name, - shipment_mode: infoObj.shipment_mode_name, - company: infoObj.title_purchaser_name, - sale_user: infoObj.sale_user_name, - order_created_time: formatDateTime(infoObj.create_time), - order_no: infoObj.order_no, - target_user_name: infoObj.target_user_name, - target_address: infoObj.address_detail, - target_description: infoObj.remark, - pay_account: infoObj.transfer_remittance_account, - bank_account_name: infoObj.account_name, - bank_name: infoObj.bank_of_deposit, - pay_type: infoObj.settle_mode_name, - client: infoObj.purchaser_name, - phone: infoObj.target_user_phone, - order_total_length: (infoObj.total_number / 100).toString(), - order_total_price: ( - infoObj.bill_total_sale_price / 100 - ).toString(), - total_weight_error_discount: ( - infoObj.total_weight_error_discount / 100 - ).toString(), - order_total_num: infoObj.total_number.toString(), - qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${infoObj.order_no}`, - order_total_weight: (infoObj.total_weight / 1000).toString(), - estimate_amount: (infoObj.estimate_amount / 100).toString(), - total_sale_price: (infoObj.total_sale_price / 100).toString(), - show_total_sale_price: true, - show_total_weight_error_discount: true, - actual_amount: (infoObj.actual_amount / 100).toString(), - wait_pay_amount: (infoObj.wait_pay_amount / 100).toString(), - order_total_weight_error: ( - infoObj.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 onChange = (e) => { + setInfoObj(val => ({ ...val, remark: e })) } - - // 确认交易 - const { fetchData: payOneFetch } = orderPaymentorderPaymentSubmission() - const { fetchData: payTwoFetch } = orderPaymentpreCollectOrderorderPaymentSubmission() const handsurePay = (obj) => { let arr: any = [] // if (obj.status !== 10) { @@ -514,89 +662,6 @@ export default () => { // } } - - // 显示支付 - const [showPay, setShowPay] = useState(false) - // 显示线下汇款 - const [showOffline, setShowOffine] = useState(false) - // 选择地址 - const handSelect = (obj) => { - if (receivingStatus === 1 || (infoObj.status === 8 || infoObj.status === 9 || infoObj.status === 4 || infoObj.status === 5 || infoObj.status === 11 || infoObj.status === 3)) { - alert.error('不允许更改') - return false - } - Taro.navigateTo({ - url: `/pages/addressManager/index?orderId=${obj.id}&purchaser_id=${obj.purchaser_id}`, - }) - } - - // 申请退货 - const handApplyGood = () => { - if (infoObj.av_return_product.length == 0) { - return alert.error('暂无货物退') - } - else { - Taro.navigateTo({ - url: `/pages/applyGoods/index?orderId=${infoObj.id}`, - }) - setShowMore(false) - } - } - - // 申请退款 - const handApplyMoney = () => { - // 三种类型的 待收货,已收货后申请退货退款,需要选择质量/非质量问题 - if (infoObj?.status == 8 || infoObj?.status == 9) { - Taro.navigateTo({ - url: `/pages/applyGoods/index?orderId=${infoObj.id}`, - }) - } - else { - Taro.navigateTo({ - url: `/pages/applyMoney/index?orderId=${infoObj.id}`, - }) - } - setShowMore(false) - } - - // 确认收货 - const { fetchData: receveFetch } = mpsaleOrderreceive() - const handSureGoods = async() => { - Taro.showModal({ - content: '确认收货吗?', - confirmText: '确认', - cancelText: '取消', - async success(res) { - if (res.confirm) { - Taro.showLoading({ - title: '请稍等...', - mask: true, - }) - const res = await receveFetch({ sale_order_id: Number(infoObj.id) }) - if (res?.msg === 'success') { - Taro.showToast({ - title: '成功', - }) - Taro.hideLoading() - setShowMore(false) - getDetail() - } - else { - Taro.hideLoading() - Taro.showToast({ - title: res?.msg, - icon: 'error', - }) - } - } - }, - }) - } - - const onChange = (e) => { - setInfoObj(val => ({ ...val, remark: e })) - } - useEffect(() => { setInfoObj(infoObj) }, [infoObj]) @@ -632,7 +697,21 @@ export default () => { return '合计金额' } }, [infoObj]) - + // 选择支付方式 + 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]) + } return ( {(infoObj?.status != 10 && )} @@ -645,7 +724,7 @@ export default () => { receivingStatus={receivingStatus} onReceivingStatus={(e, value) => onReceivingStatus(e, value)} > - { {infoObj.purchaser_name} {infoObj.purchaser_phone} - + {infoObj.total_fabrics} 种面料,{infoObj.total_colors} 个颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'} - + {payFont} @@ -692,7 +771,7 @@ export default () => { } - + { orderMsg.map((item, index) => { return ( @@ -710,7 +789,7 @@ export default () => { }) } - + setShowDesc(showRemarkFont != '')}> {infoObj.remark === '' ? '暂无' : infoObj.remark} @@ -779,83 +858,4 @@ export default () => { ) } - -// 卡片盒子元素 -interface Obs { - title?: string - modeName?: string - showMode?: boolean - children?: ReactNode - clickNode?: () => void -} - -const DefaultBox = memo((props: Obs) => { - const { - title = '标题', - modeName = '大货', - showMode = false, - children, - clickNode, - } = props - - return ( - - - {title} - { - showMode && clickNode?.()}>{modeName} - } - - - {children} - - ) -}) - -// 产品商品元素 -interface PropGoods { - // item?: { - // code?: string | number - // } - list: any[] - obj: { - sale_mode?: number | string - } -} -const GoodsItem = memo((porps: PropGoods) => { - const { list = [], obj = {} } = porps - return ( - <> - { - list.map((item, index) => { - return ( - - {item.code}# {item.name} - - { - item.product_colors.map((it, inx) => { - return ( - - - - - {it.code}# {it.name} - x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} - - - ¥{it.sale_price / 100}/{obj?.sale_mode === 1 ? 'm' : 'kg'} - ¥{formatPriceDiv(it.total_sale_price)} - - - - ) - }) - } - - ) - }) - } - - - ) -}) +export default OrderDetails diff --git a/src/pages/refundDetail/components/addressDetailBox/index.tsx b/src/pages/refundDetail/components/addressDetailBox/index.tsx index ade546a..878800a 100644 --- a/src/pages/refundDetail/components/addressDetailBox/index.tsx +++ b/src/pages/refundDetail/components/addressDetailBox/index.tsx @@ -10,7 +10,7 @@ interface propsObj { obj: any handUp?: (any) => void } -export default memo((props: propsObj) => { +const AddressDetailBox = (props: propsObj) => { const { obj = {}, handUp, @@ -46,4 +46,5 @@ export default memo((props: propsObj) => { ) -}) +} +export default memo(AddressDetailBox) diff --git a/src/pages/refundDetail/components/orderState/index.tsx b/src/pages/refundDetail/components/orderState/index.tsx index d7a721b..97ce19f 100644 --- a/src/pages/refundDetail/components/orderState/index.tsx +++ b/src/pages/refundDetail/components/orderState/index.tsx @@ -24,8 +24,7 @@ interface Param { account_period_time?: string // 还款日期 } } - -export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => { +const OrderState = ({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => { useEffect(() => { console.log('orderInfo33::', orderInfo) }, [orderInfo]) @@ -48,7 +47,7 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s <> {(dataList?.length > 0) && - {dataList.map((item, index) => + {dataList.map((item, index) => {(dataList.length > 1) && } {(dataList.length != (index + 1)) && } @@ -59,10 +58,11 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s )} {(dataList.length > 2) && changeMore()}> - {showMore && '收起详情' || '点击查看详情'} + {showMore ? '收起详情' : '点击查看详情'} } } ) -}) +} +export default memo(OrderState) diff --git a/src/pages/refundDetail/index.tsx b/src/pages/refundDetail/index.tsx index b2315f0..290f437 100644 --- a/src/pages/refundDetail/index.tsx +++ b/src/pages/refundDetail/index.tsx @@ -9,9 +9,9 @@ import OrderState from './components/orderState' import AddressDetailBox from './components/addressDetailBox' import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format' import { - mpreturnApplyOrder, - returnApplyOrdercancel, - returnApplyOrderuploadAccessory, + MpReturnApplyOrder, + ReturnApplyOrderCancel, + ReturnApplyOrderUploadAccessory, } from '@/api/refound' import { IMG_CND_Prefix } from '@/common/constant' import Popup from '@/components/popup' @@ -20,17 +20,150 @@ import { alert } from '@/common/common' import RefundCodelist from '@/components/RefundCodelist' import LabAndImg from '@/components/LabAndImg' -export default () => { - // 页面下拉刷新 - usePullDownRefresh(() => { - getDetail() - }) - const router = useRouter() - useEffect(() => { - getDetail() +interface Obs { + title?: string + modeName?: string + showMode?: boolean + children?: ReactNode + clickNode?: () => void +} + +const DefaultBox = (props: Obs) => { + const { + title = '标题', + modeName = '大货', + showMode = false, + children, + clickNode, + } = props + + return ( + + + {title} + { + showMode && clickNode?.()}>{modeName} + } + + + {children} + + ) +} +const DefaultBoxWithMemo = memo(DefaultBox) + +interface PropGoods { + // item?: { + // code?: string | number + // } + list: any[] + obj: any +} + +const GoodsItem = (porps: PropGoods) => { + const { list = [], obj = {} } = porps + + const labAndImgObj = useCallback((item) => { + return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url } }, []) + return ( + <> + { + list.map((item, index) => { + return ( + + {item.code}# {item.name} + { + item.product_colors.map((it, inx) => { + return ( + + { + it.texture_url === '' + && + } + { + it.texture_url !== '' + && + + + } + + + + {it.code}# {it.name} + {/* x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} */} + { + obj.sale_mode == 0 && x{obj.stage == 0 || obj.stage == 1 || obj.stage == 2 + ? it.roll + : obj.stage == 5 || obj.stage == 6 || obj.stage == 3 + ? it.return_roll + : it.roll}{obj?.sale_mode == 0 ? '条' : 'm'} + } + { + obj.sale_mode != 0 && x{it.length / 100}m + } + + + ¥{it.sale_price / 100}/{obj?.sale_mode == 0 ? 'kg' : 'm'} + {/* ¥{formatPriceDiv(it.total_sale_price)} */} + + + + ) + }) + } + + ) + }) + } + + + ) +} +const GoodsItemWithMemo = memo(GoodsItem) + +const RefundDetail = () => { + // 页面下拉刷新 + const router = useRouter() + // 查看图片 + const [ShowPic, setShowPic] = useState(false) + + const [PicList, setPicList] = useState([]) + // 订单信息文字数组 + const [orderMsg, setOrderMsg] = useState([ + { + leftTitle: '售后编号:', + rightTitle: '------', + showBtn: true, + }, + { + leftTitle: '订单号:', + rightTitle: '------', + showBtn: true, + }, + { + leftTitle: '退货原因:', + rightTitle: '------', + }, + { + leftTitle: '退货说明:', + rightTitle: '------', + }, + { + leftTitle: '其他说明:', + rightTitle: '------', + }, + { + leftTitle: '货物状况:', + rightTitle: '------', + }, + { + leftTitle: '申请时间:', + rightTitle: '------', + }, + ]) // 获取详情 - const { fetchData: detailFetch } = mpreturnApplyOrder() + const { fetchData: detailFetch } = MpReturnApplyOrder() const [DeatailObj, setDeatailObj] = useState({}) const getDetail = async() => { Taro.showLoading({ @@ -40,7 +173,7 @@ export default () => { const res = await detailFetch({ id: Number(router.params.id) }) if (res.data) { setDeatailObj(res.data) - orderMsg.map((it) => { + orderMsg.forEach((it) => { if (it.leftTitle === '售后编号:') { it.rightTitle = res.data.return_order_no } @@ -82,40 +215,6 @@ export default () => { } }, [DeatailObj]) - // 订单信息文字数组 - const [orderMsg, setOrderMsg] = useState([ - { - leftTitle: '售后编号:', - rightTitle: '------', - showBtn: true, - }, - { - leftTitle: '订单号:', - rightTitle: '------', - showBtn: true, - }, - { - leftTitle: '退货原因:', - rightTitle: '------', - }, - { - leftTitle: '退货说明:', - rightTitle: '------', - }, - { - leftTitle: '其他说明:', - rightTitle: '------', - }, - { - leftTitle: '货物状况:', - rightTitle: '------', - }, - { - leftTitle: '申请时间:', - rightTitle: '------', - }, - ]) - // 复制功能 const clipboardData = (val) => { Taro.setClipboardData({ @@ -130,7 +229,7 @@ export default () => { } // 取消退货 - const { fetchData: cancelFetch } = returnApplyOrdercancel() + const { fetchData: cancelFetch } = ReturnApplyOrderCancel() const handCancle = async() => { Taro.showModal({ content: '确定要取消吗?', @@ -160,10 +259,6 @@ export default () => { }, }) } - // 查看图片 - const [ShowPic, setShowPic] = useState(false) - - const [PicList, setPicList] = useState([]) const handUp = (value) => { setShowPic(true) @@ -185,7 +280,7 @@ export default () => { }, []) // 提交附件 - const { fetchData: sureFetch } = returnApplyOrderuploadAccessory() + const { fetchData: sureFetch } = ReturnApplyOrderUploadAccessory() const handSure = () => { let arr: any = [] arr = [...picUrl.current] @@ -234,7 +329,12 @@ export default () => { const handSee = () => { setShowCode(true) } - + usePullDownRefresh(() => { + getDetail() + }) + useEffect(() => { + getDetail() + }, []) return ( @@ -242,7 +342,7 @@ export default () => { obj={DeatailObj} handUp={() => handUp(DeatailObj)} > - { {DeatailObj.purchaser_name} {DeatailObj.purchaser_phone} - - - + + + 总计 {DeatailObj.total_fabrics} 种面料,{DeatailObj?.total_colors} 种颜色,共 { @@ -270,8 +370,8 @@ export default () => { } - - + + { orderMsg.map((item, index) => { return ( @@ -289,8 +389,8 @@ export default () => { }) } - - + + { DeatailObj?.fabric_piece_accessory_url?.length > 0 && DeatailObj?.fabric_piece_accessory_url.map((item, index) => { @@ -305,7 +405,7 @@ export default () => { DeatailObj?.fabric_piece_accessory_url?.length === 0 && 暂无图片 } - + @@ -336,102 +436,4 @@ export default () => { ) } - -interface Obs { - title?: string - modeName?: string - showMode?: boolean - children?: ReactNode - clickNode?: () => void -} - -const DefaultBox = memo((props: Obs) => { - const { - title = '标题', - modeName = '大货', - showMode = false, - children, - clickNode, - } = props - - return ( - - - {title} - { - showMode && clickNode?.()}>{modeName} - } - - - {children} - - ) -}) - -interface PropGoods { - // item?: { - // code?: string | number - // } - list: any[] - obj: any -} -const GoodsItem = memo((porps: PropGoods) => { - const { list = [], obj = {} } = porps - - const labAndImgObj = useCallback((item) => { - return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url } - }, []) - return ( - <> - { - list.map((item, index) => { - return ( - - {item.code}# {item.name} - { - item.product_colors.map((it, inx) => { - return ( - - { - it.texture_url === '' - && - } - { - it.texture_url !== '' - && - - - } - - - - {it.code}# {it.name} - {/* x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} */} - { - obj.sale_mode == 0 && x{obj.stage == 0 || obj.stage == 1 || obj.stage == 2 - ? it.roll - : obj.stage == 5 || obj.stage == 6 || obj.stage == 3 - ? it.return_roll - : it.roll}{obj?.sale_mode == 0 ? '条' : 'm'} - } - { - obj.sale_mode != 0 && x{it.length / 100}m - } - - - ¥{it.sale_price / 100}/{obj?.sale_mode == 0 ? 'kg' : 'm'} - {/* ¥{formatPriceDiv(it.total_sale_price)} */} - - - - ) - }) - } - - ) - }) - } - - - ) -}) +export default RefundDetail diff --git a/src/pages/refundMoneyDetail/components/addressDetailBox/index.tsx b/src/pages/refundMoneyDetail/components/addressDetailBox/index.tsx index 98a0518..343a1c5 100644 --- a/src/pages/refundMoneyDetail/components/addressDetailBox/index.tsx +++ b/src/pages/refundMoneyDetail/components/addressDetailBox/index.tsx @@ -9,7 +9,7 @@ interface propsObj { obj: any handUp?: (any) => void } -export default memo((props: propsObj) => { +const AddressDetailBox = (props: propsObj) => { const { obj = {}, handUp, @@ -46,4 +46,5 @@ export default memo((props: propsObj) => { ) -}) +} +export default memo(AddressDetailBox) diff --git a/src/pages/refundMoneyDetail/components/orderState/index.tsx b/src/pages/refundMoneyDetail/components/orderState/index.tsx index d7a721b..97ce19f 100644 --- a/src/pages/refundMoneyDetail/components/orderState/index.tsx +++ b/src/pages/refundMoneyDetail/components/orderState/index.tsx @@ -24,8 +24,7 @@ interface Param { account_period_time?: string // 还款日期 } } - -export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => { +const OrderState = ({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => { useEffect(() => { console.log('orderInfo33::', orderInfo) }, [orderInfo]) @@ -48,7 +47,7 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s <> {(dataList?.length > 0) && - {dataList.map((item, index) => + {dataList.map((item, index) => {(dataList.length > 1) && } {(dataList.length != (index + 1)) && } @@ -59,10 +58,11 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s )} {(dataList.length > 2) && changeMore()}> - {showMore && '收起详情' || '点击查看详情'} + {showMore ? '收起详情' : '点击查看详情'} } } ) -}) +} +export default memo(OrderState) diff --git a/src/pages/refundMoneyDetail/index.tsx b/src/pages/refundMoneyDetail/index.tsx index 9bf836a..c2aa4ff 100644 --- a/src/pages/refundMoneyDetail/index.tsx +++ b/src/pages/refundMoneyDetail/index.tsx @@ -8,65 +8,122 @@ import ItemList from './components/itemList' import OrderState from './components/orderState' import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format' import { - mpreturnApplyOrder, - returnApplyOrdercancel, - returnApplyOrderuploadAccessory, + MpReturnApplyOrder, + ReturnApplyOrderCancel, + ReturnApplyOrderUploadAccessory, } from '@/api/refound' // import AddressDetailBox from './components/addressDetailBox' import { IMG_CND_Prefix } from '@/common/constant' import RefundCodelist from '@/components/RefundCodelist' import LabAndImg from '@/components/LabAndImg' -export default () => { - const router = useRouter() - useEffect(() => { - getDetail() +interface Obs { + title?: string + modeName?: string + showMode?: boolean + children?: ReactNode + clickNode?: () => void +} + +const DefaultBox = (props: Obs) => { + const { + title = '标题', + modeName = '大货', + showMode = false, + children, + clickNode, + } = props + + return ( + + + {title} + { + showMode && clickNode?.()}>{modeName} + } + + + {children} + + ) +} +const DefaultBoxWithMemo = memo(DefaultBox) + +interface PropGoods { + // item?: { + // code?: string | number + // } + list: any[] + obj: any +} +const GoodsItem = (porps: PropGoods) => { + const { list = [], obj = {} } = porps + const labAndImgObj = useCallback((item) => { + return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url } }, []) - // 页面下拉刷新 - usePullDownRefresh(() => { - getDetail() - }) + return ( + <> + { + list.map((item, index) => { + return ( + + {item.code}# {item.name} + { + item?.product_colors.map((it, inx) => { + return ( + + { + it.texture_url === '' + && + } + { + it.texture_url !== '' + && + + + } + {/* */} + + + + {it.code}# {it.name} + {/* x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} */} + { + obj.sale_mode == 0 && x{obj.stage == 0 || obj.stage == 1 || obj.stage == 2 + ? it.roll + : obj.stage == 5 || obj.stage == 6 || obj.stage == 3 + ? it.return_roll + : it.roll}{obj?.sale_mode == 0 ? '条' : 'm'} + } + { + obj.sale_mode != 0 && x{it.length / 100}m + } + + + ¥{it.sale_price / 100}/{obj?.sale_mode == 0 ? 'kg' : 'm'} + {/* ¥{formatPriceDiv(it.total_sale_price)} */} + + + + ) + }) + } + + ) + }) + } + + + ) +} +const GoodsItemWithMemo = memo(GoodsItem) + +const RefundMoneyDetail = () => { + const router = useRouter() // 获取详情 - const { fetchData: detailFetch } = mpreturnApplyOrder() + const { fetchData: detailFetch } = MpReturnApplyOrder() const [DeatailObj, setDeatailObj] = useState({}) - const getDetail = async() => { - Taro.showLoading({ - title: '加载中...', - mask: true, - }) - const res = await detailFetch({ id: Number(router.params.id) }) - if (res.data) { - setDeatailObj(res.data) - orderMsg.map((it) => { - if (it.leftTitle === '售后编号:') { - it.rightTitle = res.data.return_order_no - } - if (it.leftTitle === '订单号:') { - it.rightTitle = res.data.order_no - } - if (it.leftTitle === '退货原因:') { - it.rightTitle = res.data.return_reason_name - } - if (it.leftTitle === '退货说明:') { - it.rightTitle = res.data.return_explain_name - } - if (it.leftTitle === '其他说明:') { - it.rightTitle = res.data.reason_describe - } - // if (it.leftTitle === '货物状况:') { - // it.rightTitle = res.data.goods_status_name - // } - if (it.leftTitle === '申请时间:') { - it.rightTitle = formatDateTime(res.data.apply_time) - } - }) - setOrderMsg([...orderMsg]) - Taro.stopPullDownRefresh() - // setPicList([...res.data?.accessory_url !== null ? res.data?.accessory_url : []]) - Taro.hideLoading() - } - } // 分辨用质检中还是质检前的数组 const productList = useMemo(() => { @@ -124,9 +181,45 @@ export default () => { }, }) } - + const getDetail = async() => { + Taro.showLoading({ + title: '加载中...', + mask: true, + }) + const res = await detailFetch({ id: Number(router.params.id) }) + if (res.data) { + setDeatailObj(res.data) + orderMsg.forEach((it) => { + if (it.leftTitle === '售后编号:') { + it.rightTitle = res.data.return_order_no + } + if (it.leftTitle === '订单号:') { + it.rightTitle = res.data.order_no + } + if (it.leftTitle === '退货原因:') { + it.rightTitle = res.data.return_reason_name + } + if (it.leftTitle === '退货说明:') { + it.rightTitle = res.data.return_explain_name + } + if (it.leftTitle === '其他说明:') { + it.rightTitle = res.data.reason_describe + } + // if (it.leftTitle === '货物状况:') { + // it.rightTitle = res.data.goods_status_name + // } + if (it.leftTitle === '申请时间:') { + it.rightTitle = formatDateTime(res.data.apply_time) + } + }) + setOrderMsg([...orderMsg]) + Taro.stopPullDownRefresh() + // setPicList([...res.data?.accessory_url !== null ? res.data?.accessory_url : []]) + Taro.hideLoading() + } + } // 取消退货 - const { fetchData: cancelFetch } = returnApplyOrdercancel() + const { fetchData: cancelFetch } = ReturnApplyOrderCancel() const handCancle = async() => { Taro.showModal({ content: '确定要取消吗?', @@ -193,6 +286,13 @@ export default () => { setShowCode(true) } + useEffect(() => { + getDetail() + }, []) + // 页面下拉刷新 + usePullDownRefresh(() => { + getDetail() + }) return ( @@ -200,7 +300,7 @@ export default () => { obj={DeatailObj} handUp={() => handUp(DeatailObj)} > */} - { {DeatailObj.purchaser_name} {DeatailObj.purchaser_phone} - - - + + + 总计 {DeatailObj.total_fabrics} 种面料,{DeatailObj?.total_colors} 种颜色,共 { @@ -251,8 +351,8 @@ export default () => { } } - - + + { orderMsg.map((item, index) => { return ( @@ -270,8 +370,8 @@ export default () => { }) } - - + + { DeatailObj?.fabric_piece_accessory_url?.length > 0 && DeatailObj?.fabric_piece_accessory_url.map((item, index) => { @@ -286,7 +386,7 @@ export default () => { DeatailObj?.fabric_piece_accessory_url?.length === 0 && 暂无图片 } - + { @@ -307,102 +407,4 @@ export default () => { ) } - -interface Obs { - title?: string - modeName?: string - showMode?: boolean - children?: ReactNode - clickNode?: () => void -} - -const DefaultBox = memo((props: Obs) => { - const { - title = '标题', - modeName = '大货', - showMode = false, - children, - clickNode, - } = props - - return ( - - - {title} - { - showMode && clickNode?.()}>{modeName} - } - - - {children} - - ) -}) - -interface PropGoods { - // item?: { - // code?: string | number - // } - list: any[] - obj: any -} -const GoodsItem = memo((porps: PropGoods) => { - const { list = [], obj = {} } = porps - const labAndImgObj = useCallback((item) => { - return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url } - }, []) - return ( - <> - { - list.map((item, index) => { - return ( - - {item.code}# {item.name} - { - item?.product_colors.map((it, inx) => { - return ( - - { - it.texture_url === '' - && - } - { - it.texture_url !== '' - && - - - } - {/* */} - - - - {it.code}# {it.name} - {/* x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} */} - { - obj.sale_mode == 0 && x{obj.stage == 0 || obj.stage == 1 || obj.stage == 2 - ? it.roll - : obj.stage == 5 || obj.stage == 6 || obj.stage == 3 - ? it.return_roll - : it.roll}{obj?.sale_mode == 0 ? '条' : 'm'} - } - { - obj.sale_mode != 0 && x{it.length / 100}m - } - - - ¥{it.sale_price / 100}/{obj?.sale_mode == 0 ? 'kg' : 'm'} - {/* ¥{formatPriceDiv(it.total_sale_price)} */} - - - - ) - }) - } - - ) - }) - } - - - ) -}) +export default RefundMoneyDetail diff --git a/src/pages/refundPage/components/itemList/index.tsx b/src/pages/refundPage/components/itemList/index.tsx index 1cca9ab..b7190de 100644 --- a/src/pages/refundPage/components/itemList/index.tsx +++ b/src/pages/refundPage/components/itemList/index.tsx @@ -14,8 +14,7 @@ interface propsObj { toPay?: (arg: any, obj: any) => void handSee?: (any) => void } - -export default memo((props: propsObj) => { +const ItemList = (props: propsObj) => { const navTo = (e) => { if (e.type == 1) { Taro.navigateTo({ @@ -124,4 +123,5 @@ export default memo((props: propsObj) => { } ) -}) +} +export default memo(ItemList) diff --git a/src/pages/refundPage/components/tabs/index.tsx b/src/pages/refundPage/components/tabs/index.tsx index 7ce8be6..4bf6cf6 100644 --- a/src/pages/refundPage/components/tabs/index.tsx +++ b/src/pages/refundPage/components/tabs/index.tsx @@ -7,7 +7,7 @@ interface Props { list: any[] handChose?: (any) => void } -export default memo((props: Props) => { +const Tabs = (props: Props) => { const { list = [], handChose } = props return ( @@ -29,4 +29,5 @@ export default memo((props: Props) => { } ) -}) +} +export default memo(Tabs) diff --git a/src/pages/refundPage/index.tsx b/src/pages/refundPage/index.tsx index 2b5a6de..b195022 100644 --- a/src/pages/refundPage/index.tsx +++ b/src/pages/refundPage/index.tsx @@ -12,15 +12,15 @@ import Popup from '@/components/popup' import InfiniteScroll from '@/components/infiniteScroll' import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format' import { - mpenumreturnStage, - mpenumreturnType, - mpreturnApplyOrderlist, + MpEnumReturnStage, + MpEnumReturnType, + MpReturnApplyOrderList, } from '@/api/refound' import TimePickerPopup from '@/components/timePickerPopup' import IconFont from '@/components/iconfont/iconfont' import RefundCodelist from '@/components/RefundCodelist' -export default () => { +const RefundPage = () => { // 页码和页数 const [searchField, setSearchField] = useState< @@ -47,24 +47,9 @@ export default () => { }) const pageNum = useRef({ size: searchField.size, page: searchField.page }) - // 监听筛选条件变化 - useEffect(() => { - getOrderList() - }, [searchField.size, searchField.name, searchField.status]) - // 获取订单列表 - const { fetchData: listFetchData, state: orderState } = mpreturnApplyOrderlist() + const { fetchData: listFetchData, state: orderState } = MpReturnApplyOrderList() const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) - const getOrderList = async() => { - const res = await listFetchData({ - ...searchField, - // ...getFilterData(searchField), - // ...getFilterData(searchObj) - }) - setOrderData(e => ({ ...e, list: res.data?.list, total: res.data?.total })) - // setshowPopup(false) - setRefresherTriggeredStatus(false) - } // 输入了搜索关键字 const getSearchData = useCallback((e) => { @@ -75,12 +60,7 @@ export default () => { // 列表下拉刷新 const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) - const getRefresherRefresh = async() => { - pageNum.current.size = 1 - setRefresherTriggeredStatus(true) - setSearchField(val => ({ ...val, size: 10 })) - getOrderList() - } + // 数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading! }) @@ -99,7 +79,7 @@ export default () => { const [TarBarList, setTarBarList] = useState([{ id: 1, name: '售后申请', showBorder: true }, { id: 2, name: '申请记录', showBorder: false }]) const handChose = (item) => { if (item.id === searchField.status) { return } - TarBarList.map((it) => { + TarBarList.forEach((it) => { if (it.id === item.id) { it.showBorder = true } @@ -141,14 +121,10 @@ export default () => { setModeList([...modeList]) setSearchField(e => ({ ...e, sale_mode: item.id })) } - useEffect(() => { - getStagelist() - getTypeList() - }, []) // 售后状态 const [stageList, setStageList] = useState([]) - const { fetchData: stageFetch } = mpenumreturnStage() + const { fetchData: stageFetch } = MpEnumReturnStage() const getStagelist = async() => { const res = await stageFetch() if (res.data) { @@ -178,7 +154,7 @@ export default () => { // 退款类型 const [typeList, setTypeList] = useState([]) - const { fetchData: typeFetch } = mpenumreturnType() + const { fetchData: typeFetch } = MpEnumReturnType() const getTypeList = async() => { const res = await typeFetch() if (res.data) { @@ -221,6 +197,59 @@ export default () => { } }, [searchField]) + // 数组重置 + const resetArr = (arr) => { + arr.map((it) => { + it.checked = false + return it + }) + return arr + } + + // 展示时间筛选 + const [showTime, setShowTime] = useState(false) + // 关闭时间筛选 + const handClose = () => { + setShowTime(false) + } + const myDate = new Date() + const [start, setStart] = useState(myDate.toLocaleDateString()) + const [end, setEnd] = useState('') + // 选择时间 + const handTime = (eq) => { + // 直接进来点确定的时候做处理 + if (Object.keys(eq).length === 0) { + const obj = { + start: '', + end: '', + } + obj.start = `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).format('YYYY-MM-DD')} 00:00:00` + obj.end = `${dayjs(new Date(obj?.start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00` + eq.value = obj + } + setSearchField(val => ({ ...val, sale_start_time: eq?.value?.start, sale_end_time: eq?.value?.end, size: 10 })) + setStart(eq?.value?.start) + setEnd(eq?.value?.end) + setShowTime(false) + } + const getOrderList = async() => { + const res = await listFetchData({ + ...searchField, + // ...getFilterData(searchField), + // ...getFilterData(searchObj) + }) + setOrderData(e => ({ ...e, list: res.data?.list, total: res.data?.total })) + // setshowPopup(false) + setRefresherTriggeredStatus(false) + } + const timeArea = useMemo(() => { + if (end !== '') { + return `${start} ` + '-' + ` ${end}` + } + else { + return '自定义起始时间' + } + }, [end]) // 重置 const handReset = () => { const arrOne = resetArr(modeList) @@ -241,59 +270,18 @@ export default () => { getOrderList() setEnd('') } - - // 数组重置 - const resetArr = (arr) => { - arr.map((it) => { - it.checked = false - return it - }) - return arr - } - - // 展示时间筛选 - const [showTime, setShowTime] = useState(false) - // 关闭时间筛选 - const handClose = () => { - setShowTime(false) - } - let myDate = new Date() - const [start, setStart] = useState(myDate.toLocaleDateString()) - const [end, setEnd] = useState('') - // 选择时间 - const handTime = (eq) => { - // 直接进来点确定的时候做处理 - if (Object.keys(eq).length === 0) { - const obj = { - start: '', - end: '', - } - obj.start = `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).format('YYYY-MM-DD')} 00:00:00`, - obj.end = `${dayjs(new Date(obj?.start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00` - eq.value = obj - } - setSearchField(val => ({ ...val, sale_start_time: eq?.value?.start, sale_end_time: eq?.value?.end, size: 10 })) - setStart(eq?.value?.start) - setEnd(eq?.value?.end) - setShowTime(false) - } - - const timeArea = useMemo(() => { - if (end !== '') { - return `${start} ` + '-' + ` ${end}` - } - else { - return '自定义起始时间' - } - }, [end]) - const handSure = () => { pageNum.current.page = 1 setSearchField(val => ({ ...val, size: 10 })) setshowPopup?.(false) getOrderList() } - + const getRefresherRefresh = async() => { + pageNum.current.size = 1 + setRefresherTriggeredStatus(true) + setSearchField(val => ({ ...val, size: 10 })) + getOrderList() + } useEffect(() => { setSearchField(searchField) }, [searchField]) @@ -305,7 +293,14 @@ export default () => { setItemInfo(item) setShowCode(true) } - + useEffect(() => { + getStagelist() + getTypeList() + }, []) + // 监听筛选条件变化 + useEffect(() => { + getOrderList() + }, [searchField.size, searchField.name, searchField.status]) return ( <> @@ -416,3 +411,5 @@ export default () => { ) } + +export default RefundPage diff --git a/src/pages/saleStatistic/index.tsx b/src/pages/saleStatistic/index.tsx index 3eab592..b792d6e 100644 --- a/src/pages/saleStatistic/index.tsx +++ b/src/pages/saleStatistic/index.tsx @@ -77,8 +77,278 @@ const FilterTimeOptions = { }, } +// 需要传进来的数据示例 + +// 需要传进来的表头数据示例 +const productRankingColumns = [ + { + key: 'index', + title: '编号', + dataIndex: 'index', + width: '20%', + }, + { + key: 'product_name', + title: '面料名称', + dataIndex: 'product_name', + width: '20%', + ellipsis: { + isEllipsis: true, + rows: 2, + }, + }, + { + key: 'roll', + title: '匹数', + dataIndex: 'roll', + width: '30%', + }, + { + key: 'sales_amount', + title: '交易金额', + dataIndex: 'sales_amount', + width: '30%', + render: (text: string) => {text}, + }, +] + +// 需要传进来的表头数据示例 +const purchaserRankingColumns = [ + { + key: 'index', + title: '编号', + dataIndex: 'index', + width: '20%', + }, + { + key: 'purchaser_name', + title: '客户名称', + dataIndex: 'purchaser_name', + width: '20%', + ellipsis: { + isEllipsis: true, + rows: 2, + }, + }, + { + key: 'roll', + title: '交易匹数', + dataIndex: 'roll', + width: '30%', + }, + { + key: 'sales_amount', + title: '交易金额', + dataIndex: 'sales_amount', + width: '30%', + render: (text: string) => {text}, + }, +] + +// 需要传进来的表头数据示例 +const salesmanRankingColumns = [ + { + key: 'index', + title: '编号', + dataIndex: 'index', + width: '20%', + }, + { + key: 'sale_user_name', + title: '业务员名称', + dataIndex: 'sale_user_name', + width: '25%', + ellipsis: { + isEllipsis: true, + rows: 2, + }, + }, + { + key: 'roll', + title: '销售匹数', + dataIndex: 'roll', + width: '25%', + }, + { + key: 'sales_amount', + title: '销售金额', + dataIndex: 'sales_amount', + width: '30%', + render: (text: string) => {text}, + }, +] + +const tabsConfig = [ + { + name: '面料', + key: 0, + }, + { + name: '客户', + key: 1, + }, + { + name: '业务员', + key: 2, + }, +] + +interface RankingBlockPropsType { + saleType?: number | null + saleDepartmentId?: number | null + date_min?: string + date_max?: string +} +// 销售排行 +const RankingBlock = (props: RankingBlockPropsType) => { + const { saleType, saleDepartmentId, date_min, date_max } = props + + const { fetchData: fetchProductRank } = ProductRankApi() + const { fetchData: fetchPurchaserRank } = PurchaserRankApi() + const { fetchData: fetchSalesmanRank } = SalesmanRankApi() + + const [limit, setLimit] = useState(defaultLimit) + + const [indicator, setIndicator] = useState(null) + + // 切换排行指标 + const onChangeIndicators = useCallback((indicators: number) => { + console.log('indicators', indicators) + if (indicators === -1) { + setIndicator(null) + } + else { + setIndicator(indicators) + } + }, []) + + const [currentKey, setCurrentKey] = useState(tabsConfig[0].key) + + const handleClickTab = (event) => { + const key = event.target.dataset.key + if (key === currentKey) { return } + setCurrentKey(key) + setLimit(defaultLimit) + } + const [currentTable, setCurrentTable] = useState({ + columns: productRankingColumns, + }) + const getData = useCallback( + async(tabKey: number) => { + let res: any + const payload = { + limit, + saleType, + saleDepartmentId, + date_min, + date_max, + data_form_status: indicator, + } + if (tabKey === 0) { + res = await fetchProductRank(getFilterData(payload)) + } + else if (tabKey === 1) { + res = await fetchPurchaserRank(getFilterData(payload)) + } + else { + res = await fetchSalesmanRank(getFilterData(payload)) + } + if (res.data) { + console.log('排名', res.data) + if (tabKey === 0) { + setCurrentTable(() => ({ + columns: productRankingColumns, + dataSource: { + list: res.data.list.map((item, index: number) => ({ + key: index, + index: index + 1, + product_name: item.product_name || '--', + sales_amount: `¥${priceformat(item.sales_amount)}`, + roll: dataUnit(item.roll), + })), + total: res.data.total, + }, + })) + } + else if (tabKey === 1) { + setCurrentTable(() => ({ + columns: purchaserRankingColumns, + dataSource: { + list: res.data.list.map((item, index: number) => ({ + key: index, + index: index + 1, + purchaser_name: item.purchaser_name || '--', + sales_amount: `¥${priceformat(item.sales_amount)}`, + roll: dataUnit(item.roll), + })), + total: res.data.total, + }, + })) + } + else { + setCurrentTable(() => ({ + columns: salesmanRankingColumns, + dataSource: { + list: res.data.list.map((item, index: number) => ({ + key: index, + index: index + 1, + sale_user_name: item.sale_user_name || '--', + sales_amount: `¥${priceformat(item.sales_amount)}`, + roll: dataUnit(item.roll), + })), + total: res.data.total, + }, + })) + } + } + }, + [limit, saleType, saleDepartmentId, date_min, date_max, indicator], + ) + + useEffect(() => { + getData(currentKey) + }, [currentKey, getData]) + + const handleLoadMore = () => { + console.log('loadmore') + // TODO(优化):结合接口的offset 和 limit 分段请求接口然后通过 push 将旧数据和新数据拼接起来 + setLimit(v => v + defaultLimit) + } + + return ( + <> + {/* 销售排行 */} + + + + + 销售排行 + + + + + + + + + {tabsConfig.map((item) => { + return ( + + {item.name} + + ) + })} + +
+
+
+ + ) +} +const RankingBlockWithMemo = memo(RankingBlock) + // 销售统计 -const saleStatistic = () => { +const SaleStatistic = () => { const { fetchData } = SaleOrderDataFormApi() const [saleType, setSaleType] = useState(null) @@ -88,10 +358,6 @@ const saleStatistic = () => { date_max: FilterTimeOptions[0].date_max, }) - useEffect(() => { - getData() - }, [saleType, saleDepartmentId, dateRange]) - const getData = async() => { const res = await fetchData( getFilterData({ @@ -164,14 +430,16 @@ const saleStatistic = () => { const selectSaleTypeRef = useRef(null) const selectMarketingDepartmentRef = useRef(null) const selectTimePickerRef = useRef(null) - + useEffect(() => { + getData() + }, [saleType, saleDepartmentId, dateRange]) return ( true} ref={selectSaleTypeRef}> true} ref={selectMarketingDepartmentRef}> - true} defaultValue="0" timeOptions={FilterTimeOptions} ref={selectTimePickerRef}> + true} defaultValue={0} timeOptions={FilterTimeOptions} ref={selectTimePickerRef}> @@ -319,281 +587,10 @@ const saleStatistic = () => { ) })} - + ) } -// 需要传进来的数据示例 - -// 需要传进来的表头数据示例 -const productRankingColumns = [ - { - key: 'index', - title: '编号', - dataIndex: 'index', - width: '20%', - }, - { - key: 'product_name', - title: '面料名称', - dataIndex: 'product_name', - width: '20%', - ellipsis: { - isEllipsis: true, - rows: 2, - }, - }, - { - key: 'roll', - title: '匹数', - dataIndex: 'roll', - width: '30%', - }, - { - key: 'sales_amount', - title: '交易金额', - dataIndex: 'sales_amount', - width: '30%', - render: (text: string) => {text}, - }, -] - -// 需要传进来的表头数据示例 -const purchaserRankingColumns = [ - { - key: 'index', - title: '编号', - dataIndex: 'index', - width: '20%', - }, - { - key: 'purchaser_name', - title: '客户名称', - dataIndex: 'purchaser_name', - width: '20%', - ellipsis: { - isEllipsis: true, - rows: 2, - }, - }, - { - key: 'roll', - title: '交易匹数', - dataIndex: 'roll', - width: '30%', - }, - { - key: 'sales_amount', - title: '交易金额', - dataIndex: 'sales_amount', - width: '30%', - render: (text: string) => {text}, - }, -] - -// 需要传进来的表头数据示例 -const salesmanRankingColumns = [ - { - key: 'index', - title: '编号', - dataIndex: 'index', - width: '20%', - }, - { - key: 'sale_user_name', - title: '业务员名称', - dataIndex: 'sale_user_name', - width: '25%', - ellipsis: { - isEllipsis: true, - rows: 2, - }, - }, - { - key: 'roll', - title: '销售匹数', - dataIndex: 'roll', - width: '25%', - }, - { - key: 'sales_amount', - title: '销售金额', - dataIndex: 'sales_amount', - width: '30%', - render: (text: string) => {text}, - }, -] - -const tabsConfig = [ - { - name: '面料', - key: 0, - }, - { - name: '客户', - key: 1, - }, - { - name: '业务员', - key: 2, - }, -] - -interface RankingBlockPropsType { - saleType?: number | null - saleDepartmentId?: number | null - date_min?: string - date_max?: string -} -// 销售排行 -const RankingBlock = memo((props) => { - const { saleType, saleDepartmentId, date_min, date_max } = props - - const { fetchData: fetchProductRank } = ProductRankApi() - const { fetchData: fetchPurchaserRank } = PurchaserRankApi() - const { fetchData: fetchSalesmanRank } = SalesmanRankApi() - - const [limit, setLimit] = useState(defaultLimit) - - const [indicator, setIndicator] = useState(null) - - // 切换排行指标 - const onChangeIndicators = useCallback((indicators: number) => { - console.log('indicators', indicators) - if (indicators === -1) { - setIndicator(null) - } - else { - setIndicator(indicators) - } - }, []) - - const [currentKey, setCurrentKey] = useState(tabsConfig[0].key) - - const handleClickTab = (event) => { - const key = event.target.dataset.key - if (key === currentKey) { return } - setCurrentKey(key) - setLimit(defaultLimit) - } - - const getData = useCallback( - async(tabKey: number) => { - let res: any - const payload = { - limit, - saleType, - saleDepartmentId, - date_min, - date_max, - data_form_status: indicator, - } - if (tabKey === 0) { - res = await fetchProductRank(getFilterData(payload)) - } - else if (tabKey === 1) { - res = await fetchPurchaserRank(getFilterData(payload)) - } - else { - res = await fetchSalesmanRank(getFilterData(payload)) - } - if (res.data) { - console.log('排名', res.data) - if (tabKey === 0) { - setCurrentTable(() => ({ - columns: productRankingColumns, - dataSource: { - list: res.data.list.map((item, index: number) => ({ - key: index, - index: index + 1, - product_name: item.product_name || '--', - sales_amount: `¥${priceformat(item.sales_amount)}`, - roll: dataUnit(item.roll), - })), - total: res.data.total, - }, - })) - } - else if (tabKey === 1) { - setCurrentTable(() => ({ - columns: purchaserRankingColumns, - dataSource: { - list: res.data.list.map((item, index: number) => ({ - key: index, - index: index + 1, - purchaser_name: item.purchaser_name || '--', - sales_amount: `¥${priceformat(item.sales_amount)}`, - roll: dataUnit(item.roll), - })), - total: res.data.total, - }, - })) - } - else { - setCurrentTable(() => ({ - columns: salesmanRankingColumns, - dataSource: { - list: res.data.list.map((item, index: number) => ({ - key: index, - index: index + 1, - sale_user_name: item.sale_user_name || '--', - sales_amount: `¥${priceformat(item.sales_amount)}`, - roll: dataUnit(item.roll), - })), - total: res.data.total, - }, - })) - } - } - }, - [limit, saleType, saleDepartmentId, date_min, date_max, indicator], - ) - - useEffect(() => { - getData(currentKey) - }, [currentKey, getData]) - - const handleLoadMore = () => { - console.log('loadmore') - // TODO(优化):结合接口的offset 和 limit 分段请求接口然后通过 push 将旧数据和新数据拼接起来 - setLimit(v => v + defaultLimit) - } - - const [currentTable, setCurrentTable] = useState({ - columns: productRankingColumns, - }) - - return ( - <> - {/* 销售排行 */} - - - - - 销售排行 - - - - - - - - - {tabsConfig.map((item) => { - return ( - - {item.name} - - ) - })} - -
-
-
- - ) -}) - -export default saleStatistic +export default SaleStatistic diff --git a/src/pages/saleuserPage/index.tsx b/src/pages/saleuserPage/index.tsx index d66da09..296d921 100644 --- a/src/pages/saleuserPage/index.tsx +++ b/src/pages/saleuserPage/index.tsx @@ -4,11 +4,11 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import Search from '@/components/search' -import { mpenumsaleUserlist } from '@/api/order' +import { MpEnumSaleUserList } from '@/api/order' import InfiniteScroll from '@/components/infiniteScroll' import { dataLoadingStatus, getFilterData } from '@/common/util' -export default () => { +const SaleUserPage = () => { const [search, setSearch] = useState({ name: null, page: 1, @@ -16,7 +16,7 @@ export default () => { }) const [clentList, setClientlist] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) - const { fetchData: clitentFetch, state: orderState } = mpenumsaleUserlist() + const { fetchData: clitentFetch, state: orderState } = MpEnumSaleUserList() // 数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: clentList.list, total: clentList.total, status: orderState.loading! }) @@ -27,6 +27,7 @@ export default () => { saleuserName: '', }) + const pageNum = useRef({ size: search.size, page: search.page }) // 输入了搜索关键字 const getSearchData = useCallback((eq) => { pageNum.current.page = 1 @@ -36,15 +37,7 @@ export default () => { const router = useRouter() - useEffect(() => { - if (search.name === '') { - setSearch(e => ({ ...e, name: null })) - } - if (search.name !== '') { getCuss() } - }, [search]) - // 上拉加载数据 - const pageNum = useRef({ size: search.size, page: search.page }) const getScrolltolower = useCallback(() => { if (clentList.list.length < clentList.total) { pageNum.current.page++ @@ -113,6 +106,13 @@ export default () => { }) } }, [clientObj]) + + useEffect(() => { + if (search.name === '') { + setSearch(e => ({ ...e, name: null })) + } + if (search.name !== '') { getCuss() } + }, [search]) return ( @@ -146,3 +146,5 @@ export default () => { ) } + +export default SaleUserPage diff --git a/src/pages/searchPage/index.tsx b/src/pages/searchPage/index.tsx index ece313a..c9ba099 100644 --- a/src/pages/searchPage/index.tsx +++ b/src/pages/searchPage/index.tsx @@ -6,15 +6,15 @@ import styles from './index.module.scss' import Goods from './components/goods' import Search from '@/components/search' import Empty from '@/components/empty' -import { mpproductlist } from '@/api/search' +import { MpProductList } from '@/api/search' import { debounce, getFilterData } from '@/common/util' import ShopCart from '@/components/shoppingCart' import { ClientListApi, - mpproductcolorlist, - mpsearchHistory, - mpsearchHistorylist - , mpshoppingCartproductColorlist, + MpProductColorList, + MpSearchHistory, + MpSearchHistoryList + , MpShoppingCartProductColorList, } from '@/api/order' const SearchPage = () => { @@ -78,7 +78,7 @@ const SearchPage = () => { const [showShopCart, setShowShopCart] = useState(false) // 获取商品 - const { fetchData: colorlistFetch } = mpproductcolorlist() + const { fetchData: colorlistFetch } = MpProductColorList() const getGoodList = async() => { const res = await colorlistFetch({ product_id: search.goodsId, sale_mode: search.modeId, code_or_name: search.code_or_name, physical_warehouse: search?.physical_warehouse, purchaser_id: clientObj?.clientId }) res.data.list.map((item) => { @@ -107,7 +107,7 @@ const SearchPage = () => { }, [search]) // 加入购物车 - const { fetchData: preViewFetch } = mpshoppingCartproductColorlist() + const { fetchData: preViewFetch } = MpShoppingCartProductColorList() const handSure = async() => { const arr = goodList.filter((item) => { return item.showInput @@ -199,13 +199,22 @@ const SearchPage = () => { if (item.id === it.id) { item.nums-- if (search.modeId == 0) { - if (item.nums < 1) { it.showInput = false, it.nums = 1 } + if (item.nums < 1) { + it.showInput = false + it.nums = 1 + } } if (search.modeId == 1) { - if (item.nums < 0.5) { it.showInput = false, it.nums = 0.5 } + if (item.nums < 0.5) { + it.showInput = false + it.nums = 0.5 + } } if (search.modeId == 2) { - if (item.nums < 3) { it.showInput = false, it.nums = 3 } + if (item.nums < 3) { + it.showInput = false + it.nums = 3 + } } } return item @@ -236,7 +245,7 @@ const SearchPage = () => { // 获取关键字数据 const [histroyList, setHistroyList] = useState([]) - const { fetchData: historyFetch } = mpsearchHistorylist() + const { fetchData: historyFetch } = MpSearchHistoryList() const getHistory = async() => { Taro.showLoading({ title: '加载中...', @@ -258,8 +267,8 @@ const SearchPage = () => { }, []) // 搜索获取商品数据 - const { fetchData: productFetch } = mpproductlist() - const { fetchData: historyputFetch } = mpsearchHistory() + const { fetchData: productFetch } = MpProductList() + const { fetchData: historyputFetch } = MpSearchHistory() const getProduct = debounce(async(e) => { Taro.showLoading({ title: '加载中...', diff --git a/src/pages/shopping/components/bottomEditBar/index.tsx b/src/pages/shopping/components/bottomEditBar/index.tsx index 56c7e82..12fd75d 100644 --- a/src/pages/shopping/components/bottomEditBar/index.tsx +++ b/src/pages/shopping/components/bottomEditBar/index.tsx @@ -11,8 +11,7 @@ interface PropsType { disabled?: boolean isSelectAll?: boolean } - -export default (props: PropsType) => { +const BottomEditBar = (props: PropsType) => { const { onDelete, onSelectCheckbox, disabled = false, isSelectAll: selectAll = false } = props const dispatch = useShoppingDispatch() console.log('isSelectAll==>', selectAll) @@ -57,3 +56,5 @@ export default (props: PropsType) => { ) } + +export default BottomEditBar diff --git a/src/pages/shopping/components/bottomSettleBar/index.tsx b/src/pages/shopping/components/bottomSettleBar/index.tsx index 3ff555c..0912520 100644 --- a/src/pages/shopping/components/bottomSettleBar/index.tsx +++ b/src/pages/shopping/components/bottomSettleBar/index.tsx @@ -8,8 +8,7 @@ interface PropsType { amount?: number onSettleAccount?: Function } - -export default (props: PropsType) => { +const BottomSettleBar = (props: PropsType) => { const { onSettleAccount, amount = 0 } = props const handleSettle = () => { @@ -36,3 +35,5 @@ export default (props: PropsType) => {
) } + +export default BottomSettleBar diff --git a/src/pages/shopping/components/colorKindItem/index.tsx b/src/pages/shopping/components/colorKindItem/index.tsx index 2d51f8f..2121c87 100644 --- a/src/pages/shopping/components/colorKindItem/index.tsx +++ b/src/pages/shopping/components/colorKindItem/index.tsx @@ -43,11 +43,6 @@ const ColorKindItem: FC = (props) => { return itemData.sale_mode == EnumSaleMode.Bulk ? itemData.roll : formatMeterDiv(itemData.length) } - useEffect(() => { - console.log('itemData==>', itemData) - setCount(formatCount(itemData)) - }, [itemData.roll, itemData.length]) - const [count, setCount] = useState(formatCount(itemData)) // 格式化金额 @@ -111,7 +106,10 @@ const ColorKindItem: FC = (props) => { const labAndImgObj = useCallback((item) => { return { lab: item.lab, rgb: item.rgb, texture_url: item.product_color_texture_url } }, []) - + useEffect(() => { + console.log('itemData==>', itemData) + setCount(formatCount(itemData)) + }, [itemData.roll, itemData.length]) return ( = (props) => { ) } -const DrawerButton = memo<{ isOpen: boolean }>(({ isOpen }) => { +const DrawerButton = ({ isOpen }: { isOpen: boolean }) => { return ( {isOpen ? : } ) -}) - -enum BackEndSaleModeListFieldMap { - bulk_color_list = 0, - length_cut_color_list = 1, - weight_cut_color_list = 2, } +const DrawerButtonWithMemo = memo(DrawerButton) + +interface GoodsListPropType { + itemData?: ShoppingCartData + multipleSelection?: GoodsMeta['multipleSelection'] + selected: EnumSaleMode + isPending: boolean + startTransition: React.TransitionStartFunction +} +const GoodsList = (props: GoodsListPropType) => { + const { itemData, selected, isPending, startTransition, multipleSelection } = props + const prevMultipleSelection = useRef(multipleSelection) + const currentSelected = useRef(null) + + const dispatch = useShoppingDispatch() + + const [component, setComponent] = useState(null) + // 使用 produce 更新特定的 ColorKindItem + const updateSpecifiedComponent = () => { + let newId + if (multipleSelection && prevMultipleSelection.current !== multipleSelection) { + for (const key in multipleSelection) { + if (!prevMultipleSelection.current?.hasOwnProperty(key)) { + newId = key + break + } + } + } + console.log('multipleSelection==+>', multipleSelection) + console.log('currentSelected', currentSelected.current, selected) + console.log('component', component) + if (component) { + if (itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0) { + setComponent(produce(component, (draft) => { + console.log('prev', component) + const index = (draft as unknown as any[]).findIndex(item => item.key === newId) + console.log('index', index) + if (index !== -1) { + const item = itemData?.[BackEndSaleModeListFieldMap[selected]].find((item) => { + return item.id === Number(newId) + }) + console.log('item', item, newId) + draft![index] = + } + })) + } + else { + setComponent(暂无数据) + } + } + prevMultipleSelection.current = multipleSelection + } + // 更新 GoodsList 组件 + const updateComponent = () => { + setComponent( + () => itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0 + ? ( + itemData?.[BackEndSaleModeListFieldMap[selected]].map((item) => { + console.log('item===>', item, multipleSelection?.hasOwnProperty(item.id)) + return + }) + ) + : ( + 暂无数据 + ), + ) + prevMultipleSelection.current = multipleSelection + } + + useEffect(() => { + const newGoodsKind = Object.fromEntries( + itemData?.[BackEndSaleModeListFieldMap[selected]].map(item => [ + item?.id, + { + id: item?.id, + estimate_amount: item.estimate_amount, + product_code: item.product_code, + product_color_code: item.product_color_code, + sale_mode: item.sale_mode, + count: selected === EnumSaleMode.Bulk ? item.roll : Number(formatMeterDiv(item.length)), + }, + ]), + ) + // 这里做一层比较是为了 重新渲染的时候如果没有切换订单类型的话就不让面料的选中状态初始化 + if (currentSelected.current === selected) { + dispatch({ + type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX, + data: { + purchaserId: itemData?.purchaser_id as number, + goodsKind: newGoodsKind, + multipleSelection, + }, + }) + updateComponent() + } + else { + currentSelected.current = selected + // 重新把当前的选中状态赋值给ref 作为下一次比较的旧状态 + dispatch({ + type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX, + data: { + purchaserId: itemData?.purchaser_id as number, + goodsKind: newGoodsKind, + multipleSelection: {}, + }, + }) + startTransition(updateComponent) + } + }, [itemData, selected, multipleSelection]) + + return ( + <> + {isPending + ? ( + + + + ) + : ( + component + )} + + ) +} +const GoodsListWithMemo = memo(GoodsList) interface PropsType { itemData?: ShoppingCartData @@ -79,13 +203,9 @@ const ShoppingCartItem: FC = (props) => { const [openDetail, setOpenDetail] = useState(false) - const handleOpenDetail = () => { - setOpenDetail(isOpen => !isOpen) - handleClickLayout() - } - const [selected, setSelect] = useState(0) + const [isPending, startTransition] = useTransition() const onSelectOrderType = (type: EnumSaleMode) => { if (isPending) { return } setSelect(type) @@ -107,7 +227,10 @@ const ShoppingCartItem: FC = (props) => { }) dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: false }) } - + const handleOpenDetail = () => { + setOpenDetail(isOpen => !isOpen) + handleClickLayout() + } // 统计已选面料 const materialChecked = useMemo(() => { if (!multipleSelection || isEmptyObject(multipleSelection)) { return 0 } @@ -146,7 +269,6 @@ const ShoppingCartItem: FC = (props) => { ) }, [multipleSelection, currentCheckedPurchaserId, selected, itemData]) - const [isPending, startTransition] = useTransition() const { fetchData } = ShoppingCartListApi() // 更新当前客户的多选项 const updatePurchaserMultipleSelection = (purchaserId, payload, operationType: OperationType, goodsId: number) => { @@ -268,7 +390,7 @@ const ShoppingCartItem: FC = (props) => {
- +
{/* 减少节点渲染 */} {openDetail && ( @@ -313,7 +435,7 @@ const ShoppingCartItem: FC = (props) => {
- = (props) => { ) } -interface GoodsListPropType { - itemData?: ShoppingCartData - multipleSelection?: GoodsMeta['multipleSelection'] - selected: EnumSaleMode - isPending: boolean - startTransition: React.TransitionStartFunction -} -const GoodsList = memo((props) => { - const { itemData, selected, isPending, startTransition, multipleSelection } = props - const prevMultipleSelection = useRef(multipleSelection) - const currentSelected = useRef(null) - - const dispatch = useShoppingDispatch() - - const [component, setComponent] = useState(null) - // 使用 produce 更新特定的 ColorKindItem - const updateSpecifiedComponent = () => { - let newId - if (multipleSelection && prevMultipleSelection.current !== multipleSelection) { - for (const key in multipleSelection) { - if (!prevMultipleSelection.current?.hasOwnProperty(key)) { - newId = key - break - } - } - } - console.log('multipleSelection==+>', multipleSelection) - console.log('currentSelected', currentSelected.current, selected) - console.log('component', component) - if (component) { - if (itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0) { - setComponent(produce(component, (draft) => { - console.log('prev', component) - const index = (draft as unknown as any[]).findIndex(item => item.key === newId) - console.log('index', index) - if (index !== -1) { - const item = itemData?.[BackEndSaleModeListFieldMap[selected]].find((item) => { - return item.id === Number(newId) - }) - console.log('item', item, newId) - draft![index] = - } - })) - } - else { - setComponent(暂无数据) - } - } - prevMultipleSelection.current = multipleSelection - } - // 更新 GoodsList 组件 - const updateComponent = () => { - setComponent( - () => itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0 - ? ( - itemData?.[BackEndSaleModeListFieldMap[selected]].map((item) => { - console.log('item===>', item, multipleSelection?.hasOwnProperty(item.id)) - return - }) - ) - : ( - 暂无数据 - ), - ) - prevMultipleSelection.current = multipleSelection - } - - useEffect(() => { - const newGoodsKind = Object.fromEntries( - itemData?.[BackEndSaleModeListFieldMap[selected]].map(item => [ - item?.id, - { - id: item?.id, - estimate_amount: item.estimate_amount, - product_code: item.product_code, - product_color_code: item.product_color_code, - sale_mode: item.sale_mode, - count: selected === EnumSaleMode.Bulk ? item.roll : Number(formatMeterDiv(item.length)), - }, - ]), - ) - // 这里做一层比较是为了 重新渲染的时候如果没有切换订单类型的话就不让面料的选中状态初始化 - if (currentSelected.current === selected) { - dispatch({ - type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX, - data: { - purchaserId: itemData?.purchaser_id!, - goodsKind: newGoodsKind, - multipleSelection, - }, - }) - updateComponent() - } - else { - currentSelected.current = selected - // 重新把当前的选中状态赋值给ref 作为下一次比较的旧状态 - dispatch({ - type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX, - data: { - purchaserId: itemData?.purchaser_id!, - goodsKind: newGoodsKind, - multipleSelection: {}, - }, - }) - startTransition(updateComponent) - } - }, [itemData, selected, multipleSelection]) - - return ( - <> - {isPending - ? ( - - - - ) - : ( - component - )} - - ) -}) // State 分割组件 思路就是把 context 直接通过 props 的形式传给组件,这样的话就解决了 context 强制刷新 memo 的问题了 // 那么当 context 内的 value 被更新的时候,react 只会强制渲染 Wrapper const withStateSlice = (comp, slice) => { diff --git a/src/pages/shopping/index.tsx b/src/pages/shopping/index.tsx index 5be4970..3524374 100644 --- a/src/pages/shopping/index.tsx +++ b/src/pages/shopping/index.tsx @@ -18,29 +18,6 @@ import IconText from '@/components/iconText' import Search from '@/components/search' import { alert, goLink, isEmptyObject } from '@/common/common' -export const Shopping: FC = memo(() => { - // 计算总的预估金额 - const handleTriggerCheckbox = ({ multipleSelection, setSelectedAmount }) => { - console.log('handleTriggerCheckbox==>', multipleSelection) - - if (multipleSelection) { - const result = Object.values(multipleSelection).reduce((prev: number, value: Goods) => { - return prev + Number(formatPriceDiv(value.estimate_amount)) - }, 0) as number - // 同步修改上下文的 预估金额 - setSelectedAmount(result) - } - else { - setSelectedAmount(0) - } - } - return ( - - - - ) -}) - interface SearchOptions { short_name_or_phone?: string } @@ -272,5 +249,27 @@ const ShoppingCartContainer: FC = () => { ) } +export const Shopping: FC = () => { + // 计算总的预估金额 + const handleTriggerCheckbox = ({ multipleSelection, setSelectedAmount }) => { + console.log('handleTriggerCheckbox==>', multipleSelection) -export default Shopping + if (multipleSelection) { + const result = Object.values(multipleSelection).reduce((prev: number, value: Goods) => { + return prev + Number(formatPriceDiv(value.estimate_amount)) + }, 0) as number + // 同步修改上下文的 预估金额 + setSelectedAmount(result) + } + else { + setSelectedAmount(0) + } + } + return ( + + + + ) +} + +export default memo(Shopping) diff --git a/src/pages/submitOrder/index.tsx b/src/pages/submitOrder/index.tsx index 7d20bec..6d8fbed 100644 --- a/src/pages/submitOrder/index.tsx +++ b/src/pages/submitOrder/index.tsx @@ -9,57 +9,99 @@ import styles from './index.module.scss' import Popup from '@/components/popup' import { debounce } from '@/common/util' import { - mpsaleOrderpost, - mpsaleOrderpreView, + MpSaleOrderPost, + MpSaleOrderPreview, } from '@/api/order' import { alert } from '@/common/common' import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format' import IconFont from '@/components/iconfont/iconfont' -export default () => { +// 卡片盒子元素 +interface Obs { + title?: string + modeName?: string + showMode?: boolean + children?: ReactNode + clickNode?: () => void +} + +const DefaultBox = (props: Obs) => { + const { + title = '标题', + modeName = '大货', + showMode = false, + children, + clickNode, + } = props + + return ( + + + {title} + { + showMode && clickNode?.()}>{modeName} + } + + + {children} + + ) +} +const DefaultBoxWithMemo = memo(DefaultBox) + +// 产品商品元素 +interface PropGoods { + // item?: { + // code?: string | number + // } + list: any[] + obj: { + sale_mode?: number | string + } +} +const GoodsItem = (porps: PropGoods) => { + const { list = [], obj = {} } = porps + return ( + <> + { + list.map((item, index) => { + return ( + + {item.code}# {item.name} + + { + item.product_colors.map((it, inx) => { + return ( + + + + + {it.code} {it.name} + x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} + + + ¥{it.sale_price / 100}/{obj?.sale_mode === 1 ? 'm' : 'kg'} + ¥{formatPriceDiv(it.estimate_amount)} + + + + ) + }) + } + + ) + }) + } + + + ) +} +const GoodsItemWithMemo = memo(GoodsItem) + +const SubmitOrder = () => { const router: any = useRouter() const [infoObj, setInfoObj] = useState({}) let selectId = -1 - useDidShow(() => { - // 获取选择的地址 - const pages = Taro.getCurrentPages() - const currPage = pages[pages.length - 1] // 获取当前页面 - setInfoObj(val => ({ - ...val, - sale_mode: Number(router.params.sale_mode), - province_name: currPage.data?.addressObj?.province_name ? currPage.data?.addressObj?.province_name : '', - address_id: currPage.data?.addressObj?.id ? currPage.data?.addressObj?.id : '', - city_name: currPage.data?.addressObj?.city_name ? currPage.data?.addressObj?.city_name : '', - address_detail: currPage.data?.addressObj?.address_detail ? currPage.data?.addressObj?.address_detail : '', - district_name: currPage.data?.addressObj?.district_name ? currPage.data?.addressObj?.district_name : '', - target_user_name: currPage.data?.addressObj?.name ? currPage.data?.addressObj?.name : '', - purchaser_phone: currPage.data?.addressObj?.phone ? currPage.data?.addressObj?.phone : '', - })) - selectId = currPage.data?.addressObj?.id - const obj = currPage?.data?.ids?.filter((item) => { return item == selectId }) - if (currPage?.data?.ids && obj.length === 0) { - setInfoObj(val => ({ - ...val, - sale_mode: Number(router.params.sale_mode), - province_name: '', - address_id: '', - city_name: '', - address_detail: '', - district_name: '', - target_user_name: '', - purchaser_phone: '', - })) - } - if (!currPage.data?.addressObj) { - setReceivingStatus(1) - } - else { - setReceivingStatus(2) - } - }) - useEffect(() => { - getDetail() - }, []) // 收货方法,1:自提,2物流 const [receivingStatus, setReceivingStatus] = useState(null) @@ -78,7 +120,7 @@ export default () => { Taro.hideLoading() }, 300) - const { fetchData: infoFetch } = mpsaleOrderpreView() + const { fetchData: infoFetch } = MpSaleOrderPreview() const [pussName, setPusername] = useState('') // 获取订单详情 const getDetail = async() => { @@ -116,7 +158,7 @@ export default () => { } // 提交订单 - const { fetchData: postFetch } = mpsaleOrderpost() + const { fetchData: postFetch } = MpSaleOrderPost() const handSure = () => { if (receivingStatus == 2 && !infoObj.address_id) { return alert.error('请选择地址') @@ -174,6 +216,46 @@ export default () => { useEffect(() => { setInfoObj(infoObj) }, [infoObj]) + useDidShow(() => { + // 获取选择的地址 + const pages = Taro.getCurrentPages() + const currPage = pages[pages.length - 1] // 获取当前页面 + setInfoObj(val => ({ + ...val, + sale_mode: Number(router.params.sale_mode), + province_name: currPage.data?.addressObj?.province_name ? currPage.data?.addressObj?.province_name : '', + address_id: currPage.data?.addressObj?.id ? currPage.data?.addressObj?.id : '', + city_name: currPage.data?.addressObj?.city_name ? currPage.data?.addressObj?.city_name : '', + address_detail: currPage.data?.addressObj?.address_detail ? currPage.data?.addressObj?.address_detail : '', + district_name: currPage.data?.addressObj?.district_name ? currPage.data?.addressObj?.district_name : '', + target_user_name: currPage.data?.addressObj?.name ? currPage.data?.addressObj?.name : '', + purchaser_phone: currPage.data?.addressObj?.phone ? currPage.data?.addressObj?.phone : '', + })) + selectId = currPage.data?.addressObj?.id + const obj = currPage?.data?.ids?.filter((item) => { return item == selectId }) + if (currPage?.data?.ids && obj.length === 0) { + setInfoObj(val => ({ + ...val, + sale_mode: Number(router.params.sale_mode), + province_name: '', + address_id: '', + city_name: '', + address_detail: '', + district_name: '', + target_user_name: '', + purchaser_phone: '', + })) + } + if (!currPage.data?.addressObj) { + setReceivingStatus(1) + } + else { + setReceivingStatus(2) + } + }) + useEffect(() => { + getDetail() + }, []) return ( { receivingStatus={receivingStatus} onReceivingStatus={(e, value) => onReceivingStatus(e, value)} > - { {pussName} {/* {infoObj.purchaser_phone} */} - + {/* {infoObj.product_list?.length} 种面料,{infoObj.total_colors} 个颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'} */} - + 合计金额 @@ -204,9 +286,9 @@ export default () => { ¥{formatPriceDiv(infoObj.estimate_amount)} - `} clickNode={() => setShowDesc(true)}> + `} clickNode={() => setShowDesc(true)}> {infoObj.remark === '' ? '暂无' : infoObj.remark} - + setShowDesc(false)}> getRemark(e)} defaultValue={infoObj.remark} showInput={!!showDesc} /> @@ -224,83 +306,4 @@ export default () => { ) } - -// 卡片盒子元素 -interface Obs { - title?: string - modeName?: string - showMode?: boolean - children?: ReactNode - clickNode?: () => void -} - -const DefaultBox = memo((props: Obs) => { - const { - title = '标题', - modeName = '大货', - showMode = false, - children, - clickNode, - } = props - - return ( - - - {title} - { - showMode && clickNode?.()}>{modeName} - } - - - {children} - - ) -}) - -// 产品商品元素 -interface PropGoods { - // item?: { - // code?: string | number - // } - list: any[] - obj: { - sale_mode?: number | string - } -} -const GoodsItem = memo((porps: PropGoods) => { - const { list = [], obj = {} } = porps - return ( - <> - { - list.map((item, index) => { - return ( - - {item.code}# {item.name} - - { - item.product_colors.map((it, inx) => { - return ( - - - - - {it.code} {it.name} - x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'} - - - ¥{it.sale_price / 100}/{obj?.sale_mode === 1 ? 'm' : 'kg'} - ¥{formatPriceDiv(it.estimate_amount)} - - - - ) - }) - } - - ) - }) - } - - - ) -}) +export default SubmitOrder diff --git a/src/pages/takeDelivery/components/DeliveryStatusList/index.tsx b/src/pages/takeDelivery/components/DeliveryStatusList/index.tsx index 2929646..1aff9af 100644 --- a/src/pages/takeDelivery/components/DeliveryStatusList/index.tsx +++ b/src/pages/takeDelivery/components/DeliveryStatusList/index.tsx @@ -6,7 +6,7 @@ interface PropsType { onChangeStatus?: (data: { id: number; name: string }) => void } -const DeliveryStatusList = memo((props) => { +const DeliveryStatusList = (props: PropsType) => { const { onChangeStatus } = props const { fetchData } = EnumTakeGoodsOrderStatus() const [statusList, setStatusList] = useState([ @@ -38,5 +38,5 @@ const DeliveryStatusList = memo((props) => { [onChangeStatus], ) return -}) -export default DeliveryStatusList +} +export default memo(DeliveryStatusList) diff --git a/src/pages/takeDelivery/components/Filter/index.tsx b/src/pages/takeDelivery/components/Filter/index.tsx index 035785f..4c4b21f 100644 --- a/src/pages/takeDelivery/components/Filter/index.tsx +++ b/src/pages/takeDelivery/components/Filter/index.tsx @@ -60,7 +60,7 @@ export const filterTimeOptions = { }, } as const -const DeliveryFilter = memo((props) => { +const DeliveryFilter = (props: DeliveryPropsType) => { const { onSearchTime, onConfirm, onCancal, onReset } = props const { fetchData, state } = EnumTakeGoodsOrderTypeList() @@ -83,17 +83,15 @@ const DeliveryFilter = memo((props) => { return state.data.list }, [state]) + const getEnumData = async() => { + await fetchData() + } useEffect(() => { if (!typeList?.length) { getEnumData() console.log('getEnumData') } }, [typeList]) - - const getEnumData = async() => { - await fetchData() - } - const [customTime, setCustomTime] = useState({ date_min: undefined, date_max: undefined, @@ -135,9 +133,9 @@ const DeliveryFilter = memo((props) => { 不限 {!!typeList?.length - && typeList?.map((item) => { + && typeList?.map((item, key) => { return ( - handleSelectedType(item?.id)}> + handleSelectedType(item?.id)}> {item.name} // handleSelectedType(item?.id)}> @@ -151,9 +149,9 @@ const DeliveryFilter = memo((props) => { 查询日期 - {Object.entries(filterTimeOptions).map(([key, value]) => { + {Object.entries(filterTimeOptions).map(([key, value], index) => { return ( - handleSelectedTime(key)}> + handleSelectedTime(key)}> {value.name} ) @@ -173,6 +171,6 @@ const DeliveryFilter = memo((props) => { ) -}) +} -export default DeliveryFilter +export default memo(DeliveryFilter) diff --git a/src/pages/takeDelivery/components/remark/index.tsx b/src/pages/takeDelivery/components/remark/index.tsx index 4b64487..c4a1d9d 100644 --- a/src/pages/takeDelivery/components/remark/index.tsx +++ b/src/pages/takeDelivery/components/remark/index.tsx @@ -8,17 +8,13 @@ interface Param { onSave?: (val: string) => void defaultValue?: string } -export default ({ onBlur, onSave, defaultValue = '' }: Param) => { +const Remark = ({ onBlur, onSave, defaultValue = '' }: Param) => { const [descData, setDescData] = useState({ number: 0, value: '', count: 200, }) - useEffect(() => { - getDesc(defaultValue) - }, [defaultValue]) - const getDesc = (value) => { let res = value if (value.length > descData.count) { @@ -30,6 +26,9 @@ export default ({ onBlur, onSave, defaultValue = '' }: Param) => { const setSave = () => { onSave?.(descData.value) } + useEffect(() => { + getDesc(defaultValue) + }, [defaultValue]) return ( 编辑备注 @@ -41,3 +40,5 @@ export default ({ onBlur, onSave, defaultValue = '' }: Param) => { ) } + +export default Remark diff --git a/src/pages/takeDelivery/index.tsx b/src/pages/takeDelivery/index.tsx index 475d083..cb00aae 100644 --- a/src/pages/takeDelivery/index.tsx +++ b/src/pages/takeDelivery/index.tsx @@ -53,19 +53,6 @@ const Delivery: FC = () => { console.log('searchValue==>', searchValue) }, []) - useEffect(() => { - console.log('useEffect ===> search', search) - // 已经不是第一次加载该页面了 - if (!isFirst.current) { - getData() - } - }, [search]) - - useDidShow(() => { - getData() - isFirst.current = false - }) - // 上拉加载数据 const pageNum = useRef({ size: search.size, page: search.page }) @@ -172,11 +159,22 @@ const Delivery: FC = () => { ) } + useEffect(() => { + console.log('useEffect ===> search', search) + // 已经不是第一次加载该页面了 + if (!isFirst.current) { + getData() + } + }, [search]) + useDidShow(() => { + getData() + isFirst.current = false + }) return ( - + diff --git a/src/pages/takeDeliveryDetail/index.tsx b/src/pages/takeDeliveryDetail/index.tsx index afede8e..4764a4a 100644 --- a/src/pages/takeDeliveryDetail/index.tsx +++ b/src/pages/takeDeliveryDetail/index.tsx @@ -44,9 +44,9 @@ const TakeDeliveryDetail: FC = () => { const DetailItem = useMemo(() => { const element = !!detailInfo?.dyelot_number_list?.length - && detailInfo?.dyelot_number_list.map((weightItem) => { + && detailInfo?.dyelot_number_list.map((weightItem, key) => { return ( - + diff --git a/src/pages/user/index.tsx b/src/pages/user/index.tsx index 589f5ae..eef6295 100644 --- a/src/pages/user/index.tsx +++ b/src/pages/user/index.tsx @@ -6,6 +6,10 @@ import { useDispatch } from 'react-redux' import type { Dispatch } from 'redux' import defaultAvatar from '../../styles/image/defaultAvatar.png' import styles from './index.module.scss' +import { checkKey, goLink } from '@/common/common' +import type { TabBarAction } from '@/reducers/tabBar' +import { TabBarIndex } from '@/reducers/tabBar' +import { TabBarType } from '@/constants/tabbar' import NormalButton from '@/components/normalButton' import Tag from '@/components/tag' import Divider from '@/components/Divider' @@ -13,11 +17,16 @@ import LayoutBlock from '@/components/layoutBlock' import IconCard from '@/components/iconCard' import type { IconNames } from '@/components/iconfont/iconfont' import useUserInfo from '@/use/useUserInfo' -import { checkKey, goLink } from '@/common/common' -import type { TabBarAction } from '@/reducers/tabBar' -import { TabBarIndex } from '@/reducers/tabBar' -import { TabBarType } from '@/constants/tabbar' +// 用户头像 +const UserAvatar = ({ src }: { src?: string }) => { + return ( + + + {src ? null : 编辑} + + ) +} interface IconCardType { jurisdiction?: string // 权限key值 iconName: IconNames @@ -196,8 +205,8 @@ const UserInfo: FC = () => { !!Features.length && 功能特色 - {Features.map((item) => { - return handleClickIconCard(item)}> + {Features.map((item, key) => { + return handleClickIconCard(item)}> })} @@ -206,8 +215,8 @@ const UserInfo: FC = () => { !!Coloring.length && 布料取色 - {Coloring.map((item) => { - return handleClickIconCard(item)}> + {Coloring.map((item, key) => { + return handleClickIconCard(item)}> })} @@ -216,8 +225,8 @@ const UserInfo: FC = () => { !!Statistics.length && 统计分析 - {Statistics.map((item) => { - return handleClickIconCard(item)}> + {Statistics.map((item, key) => { + return handleClickIconCard(item)}> })} @@ -226,15 +235,6 @@ const UserInfo: FC = () => { ) } -// 用户头像 -const UserAvatar = ({ src }) => { - return ( - - - {src ? null : 编辑} - - ) -} // 我的 const User = () => { diff --git a/src/reducers/userInfo.ts b/src/reducers/userInfo.ts index 5d61739..0b2a830 100644 --- a/src/reducers/userInfo.ts +++ b/src/reducers/userInfo.ts @@ -14,6 +14,7 @@ export interface UserParam { user_id?: string user_name?: number avatar_url?: string + phone?: string } export interface UserAdminParam { diff --git a/src/store/index.ts b/src/store/index.ts index c8c7122..aaa7b73 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -24,4 +24,4 @@ const enhancer = composeEnhancers( export default function configStore() { const store = createStore(rootReducer, enhancer) return store -} +} diff --git a/src/use/BlueToothCopy.tsx b/src/use/BlueToothCopy.tsx index a34611d..60b76b9 100644 --- a/src/use/BlueToothCopy.tsx +++ b/src/use/BlueToothCopy.tsx @@ -69,8 +69,10 @@ const stateObj: stateStype = { // 取色仪主动返回的数据 deviceLab: null, } - -export default (props) => { +interface PropsType { + children?: React.ReactNode +} +const BlueToothCopy = (props: PropsType) => { const refStatus = useRef(stateObj) const [state, setState] = useState(refStatus.current) @@ -78,6 +80,31 @@ export default (props) => { refStatus.current = { ...refStatus.current, ...obj } setState({ ...refStatus.current }) } + /** 打开蓝牙适配器 */ + const openAdapter = () => { + return new Promise((resolve, reject) => { + Taro.openBluetoothAdapter({ + success: resolve, + fail: reject, + }) + }) + } + const subscribe = (cb) => { + if (cb) { + changeStatus({ + listeners: refStatus.current.listeners.add(cb), + }) + } + } + /** + * 推送事件 + * @param {{type: string; data: any}} event + */ + const emit = (event) => { + refStatus.current.listeners.forEach((cb) => { + cb && cb(event) + }) + } const init = async() => { try { @@ -123,34 +150,6 @@ export default (props) => { }) } - /** 打开蓝牙适配器 */ - const openAdapter = () => { - return new Promise((resolve, reject) => { - Taro.openBluetoothAdapter({ - success: resolve, - fail: reject, - }) - }) - } - - /** - * 推送事件 - * @param {{type: string; data: any}} event - */ - const emit = (event) => { - refStatus.current.listeners.forEach((cb) => { - cb && cb(event) - }) - } - - const subscribe = (cb) => { - if (cb) { - changeStatus({ - listeners: refStatus.current.listeners.add(cb), - }) - } - } - /** * 获取蓝牙适配器状态 * @returns {Promise<{discovering: boolean; available: boolean}>} @@ -164,6 +163,15 @@ export default (props) => { }) } + // 获取搜索到的设备 + const getDevices = (res) => { + res.devices.forEach((device) => { + // 排除掉已搜索到的设备和名称不合法的设备, 将新发现的设备添加到列表中 + if (/^CM/.test(device.name) && !refStatus.current.devices.find(i => i.deviceId === device.deviceId)) { + changeStatus({ devices: [...refStatus.current.devices, device] }) + } + }) + } /** * 启动设备扫描 * @param {(res: { devices: { name: string, deviceId: string, RSSI: number }[] }) => void} cb @@ -189,17 +197,6 @@ export default (props) => { } }) } - - // 获取搜索到的设备 - const getDevices = (res) => { - res.devices.forEach((device) => { - // 排除掉已搜索到的设备和名称不合法的设备, 将新发现的设备添加到列表中 - if (/^CM/.test(device.name) && !refStatus.current.devices.find(i => i.deviceId === device.deviceId)) { - changeStatus({ devices: [...refStatus.current.devices, device] }) - } - }) - } - /** * 连接设备 * @param {{ name: string, deviceId: string, RSSI: number }} device @@ -354,6 +351,7 @@ export default (props) => { * @returns {Promise} */ function exec(command) { + // eslint-disable-next-line no-async-promise-executor return new Promise(async(resolve, reject) => { if (refStatus.current.command) { reject(new Error('正在执行其他命令')) @@ -478,6 +476,7 @@ export default (props) => { /> ) } +export default BlueToothCopy export const useBluetoothTwo = () => { const res = React.useContext(Context) diff --git a/src/use/contextBlueTooth.tsx b/src/use/contextBlueTooth.tsx index 66f9a9e..411dd55 100644 --- a/src/use/contextBlueTooth.tsx +++ b/src/use/contextBlueTooth.tsx @@ -69,8 +69,7 @@ const stateObj: BluetoothStateType = { // 取色仪主动返回的数据 deviceLab: null, } - -export default (props) => { +const ContextBlueTooth = (props) => { const refStatus = useRef(stateObj) const [state, setState] = useState(refStatus.current) @@ -79,50 +78,6 @@ export default (props) => { setState({ ...refStatus.current }) } - const init = async() => { - try { - await openAdapter() - } - catch (e) { - changeStatus({ available: false }) - } - - // 绑定事件通知 - Taro.onBluetoothAdapterStateChange((res) => { - emit({ type: 'stateUpdate', detail: res }) - }) - Taro.onBLEConnectionStateChange((res) => { - emit({ type: res.connected ? 'connected' : 'disconnect', detail: res }) - }) - Taro.onBLECharacteristicValueChange(({ value }) => notifySubscriber(value)) - subscribe(async(ev) => { - if (ev.type === 'stateUpdate') { - // 蓝牙状态发生的变化 - changeStatus({ discovering: ev.detail.discovering, available: ev.detail.available }) - } - else if (ev.type === 'disconnect' && refStatus.current.connected && refStatus.current.connected.deviceId === ev.detail.deviceId) { - // 断开连接 - changeStatus({ - connected: null, - serviceId: null, - characteristicId: null, - deviceLab: null, - devices: [], - }) - Taro.showToast({ icon: 'none', title: '蓝牙连接已断开' }) - } - else if (ev.type === 'connected' && refStatus.current.connecting) { - // 连接成功 - changeStatus({ connected: refStatus.current.connecting, connecting: null }) - Taro.showToast({ title: '蓝牙已连接' }) - } - else if (ev.type === 'measure') { - // 监听取色仪主动推送lab - await measureAndGetLab() - } - }) - } - /** 打开蓝牙适配器 */ const openAdapter = () => { return new Promise((resolve, reject) => { @@ -151,6 +106,50 @@ export default (props) => { } } + const init = async() => { + try { + await openAdapter() + } + catch (e) { + changeStatus({ available: false }) + } + + // 绑定事件通知 + Taro.onBluetoothAdapterStateChange((res) => { + emit({ type: 'stateUpdate', detail: res }) + }) + Taro.onBLEConnectionStateChange((res) => { + emit({ type: res.connected ? 'connected' : 'disconnect', detail: res }) + }) + Taro.onBLECharacteristicValueChange(({ value }) => notifySubscriber(value)) + subscribe(async(ev) => { + if (ev.type === 'stateUpdate') { + // 蓝牙状态发生的变化 + changeStatus({ discovering: ev.detail.discovering, available: ev.detail.available }) + } + else if (ev.type === 'disconnect' && refStatus.current.connected && refStatus.current.connected.deviceId === ev.detail.deviceId) { + // 断开连接 + changeStatus({ + connected: null, + serviceId: null, + characteristicId: null, + deviceLab: null, + devices: [], + }) + Taro.showToast({ icon: 'none', title: '蓝牙连接已断开' }) + } + else if (ev.type === 'connected' && refStatus.current.connecting) { + // 连接成功 + changeStatus({ connected: refStatus.current.connecting, connecting: null }) + Taro.showToast({ title: '蓝牙已连接' }) + } + else if (ev.type === 'measure') { + // 监听取色仪主动推送lab + await measureAndGetLab() + } + }) + } + /** * 获取蓝牙适配器状态 * @returns {Promise<{discovering: boolean; available: boolean}>} @@ -164,6 +163,15 @@ export default (props) => { }) } + // 获取搜索到的设备 + const getDevices = (res) => { + res.devices.forEach((device) => { + // 排除掉已搜索到的设备和名称不合法的设备, 将新发现的设备添加到列表中 + if (/^CM/.test(device.name) && !refStatus.current.devices.find(i => i.deviceId === device.deviceId)) { + changeStatus({ devices: [...refStatus.current.devices, device] }) + } + }) + } /** * 启动设备扫描 * @param {(res: { devices: { name: string, deviceId: string, RSSI: number }[] }) => void} cb @@ -189,17 +197,6 @@ export default (props) => { } }) } - - // 获取搜索到的设备 - const getDevices = (res) => { - res.devices.forEach((device) => { - // 排除掉已搜索到的设备和名称不合法的设备, 将新发现的设备添加到列表中 - if (/^CM/.test(device.name) && !refStatus.current.devices.find(i => i.deviceId === device.deviceId)) { - changeStatus({ devices: [...refStatus.current.devices, device] }) - } - }) - } - /** * 连接设备 * @param {{ name: string, deviceId: string, RSSI: number }} device @@ -212,7 +209,7 @@ export default (props) => { await discoverService(device.deviceId) await discoverCharacteristic(device.deviceId) await notifyCharacteristicValueChange(device.deviceId) - } + } catch (e) { changeStatus({ connecting: null }) Taro.showToast({ icon: 'none', title: '蓝牙连接失败' }) @@ -273,7 +270,7 @@ export default (props) => { const service = services.find(i => refStatus.current.serviceRule.test(i.uuid)) if (!service) { reject(new Error('服务不可用')) - } + } else { changeStatus({ serviceId: service.uuid }) resolve(service) @@ -294,7 +291,7 @@ export default (props) => { const characteristic = characteristics.find(i => refStatus.current.characteristicRule.test(i.uuid)) if (!characteristic) { reject(new Error('特征不可用')) - } + } else { changeStatus({ characteristicId: characteristic.uuid }) resolve(characteristic) @@ -332,13 +329,13 @@ export default (props) => { if (refStatus.current.command.isComplete) { if (refStatus.current.command.isValid && refStatus.current.responseResolve) { refStatus.current.responseResolve(refStatus.current.command.response) - } + } else if (!refStatus.current.command.isValid) { refStatus.current.responseReject(new Error('无效数据')) } resetCommand() } - } + } else { const uint8Array = new Uint8Array(buffer) if (uint8Array[0] === 0xBB && uint8Array[1] === 1 && uint8Array[3] === 0) { @@ -354,10 +351,11 @@ export default (props) => { * @returns {Promise} */ function exec(command) { + // eslint-disable-next-line no-async-promise-executor return new Promise(async(resolve, reject) => { if (refStatus.current.command) { reject(new Error('正在执行其他命令')) - } + } else { try { refStatus.current.command = command @@ -369,7 +367,7 @@ export default (props) => { if (command.responseSize <= 0) { resolve(true) resetCommand() - } + } else { refStatus.current.responseReject = reject refStatus.current.responseResolve = resolve @@ -378,7 +376,7 @@ export default (props) => { resetCommand() }, command.timeout) } - } + } catch (e) { reject(e) } @@ -478,12 +476,13 @@ export default (props) => { /> ) } +export default ContextBlueTooth export const useBluetooth = () => { const res = React.useContext(Context) if (res) { return { ...res } - } + } else { return {} } diff --git a/src/use/useCheckAuthorize.tsx b/src/use/useCheckAuthorize.tsx index a5ad7c7..075cadc 100644 --- a/src/use/useCheckAuthorize.tsx +++ b/src/use/useCheckAuthorize.tsx @@ -23,32 +23,34 @@ interface Param { export default ({ scope, msg }: Param) => { // 这个hook微信授权检查授权 const check = useCallback(() => { - return new Promise((reslove, reject) => { + return new Promise((resolve, reject) => { Taro.getSetting({ success: (res) => { if (res.authSetting[scope]) { - reslove(true) - } + resolve(true) + } else if (res.authSetting[scope] === undefined) { Taro.authorize({ scope, success() { - reslove(true) + resolve(true) }, fail() { alert.none(msg) + // eslint-disable-next-line prefer-promise-reject-errors reject(false) }, }) - } + } else { Taro.openSetting({ success(res) { if (res.authSetting[scope]) { - reslove(true) - } + resolve(true) + } else { alert.none(msg) + // eslint-disable-next-line prefer-promise-reject-errors reject(false) } }, diff --git a/src/use/useCommon.ts b/src/use/useCommon.ts index 6b8168e..8c7e88b 100644 --- a/src/use/useCommon.ts +++ b/src/use/useCommon.ts @@ -1,6 +1,6 @@ import { useRouter } from '@tarojs/taro' import dayjs from 'dayjs' -import type { SetStateAction } from 'react' +import type { SetStateAction } from 'react' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useSelector } from '@/reducers/hooks' @@ -15,21 +15,6 @@ export const useTimeCountDown = () => { const [timeStatus, setTimeStatus] = useState<0 | 1 | 2>(0) // 倒计时状体 0:倒计时未开始 1:倒计时中, 2:倒计时已结束 const timeObj: any = useRef() const endTime = useRef('') - const onStart = (val = '') => { - // console.log('time:::', val) - endTime.current = val - if (endTime.current) { - clearInterval(timeObj.current) - timeObj.current = setInterval(() => { - count_down() - }, 1000) - } - } - useEffect(() => { - return () => { - clearInterval(timeObj.current) - } - }, []) const count_down = () => { const startData = dayjs() const endDate = dayjs(endTime.current) @@ -56,6 +41,22 @@ export const useTimeCountDown = () => { // console.log('endTime::', `${DD}-${HH}-${MM}-${SS}`) setShowTime(e => ({ ...e, DD, HH, MM, SS })) } + const onStart = (val = '') => { + // console.log('time:::', val) + endTime.current = val + if (endTime.current) { + clearInterval(timeObj.current) + timeObj.current = setInterval(() => { + count_down() + }, 1000) + } + } + useEffect(() => { + return () => { + clearInterval(timeObj.current) + } + }, []) + return { showTime, onStart, diff --git a/src/use/useLogin.ts b/src/use/useLogin.ts index 5169f7f..afd4a0d 100644 --- a/src/use/useLogin.ts +++ b/src/use/useLogin.ts @@ -10,11 +10,21 @@ import { IMG_CND_Prefix } from '@/common/constant' export default () => { const { setUserInfo, setAdminUserInfo, setSortCode, userInfo } = useUserInfo() + // 获取分享码(右上角分享码) + const { SharePage } = SHARE_SCENE + const { fetchData: fetchDataShortCode } = GetShortCodeApi() + const getShortCode = async(user_id) => { + const { data: resPage } = await fetchDataShortCode({ share_user_id: user_id, type: SharePage.value }) + setSortCode({ ...userInfo.sort_code, shareShortPage: { title: '打造面料爆品 专注客户服务', code: resPage.md5_key, img: `${IMG_CND_Prefix}/mall/share_img_01.png` } }) + } - useDidShow(() => { - checkLogin() - }) - + // 获取用户信息 + const { fetchData: FetchData } = GetAdminUserInfoApi() + const getAdminUserInfo = async() => { + const res = await FetchData() + setAdminUserInfo({ ...res.data }) + getShortCode(res.data.user_id) + } // 登录请求 const { login } = useLoginRequest() // const {fetchData:login} = LoginApi() @@ -28,31 +38,24 @@ export default () => { } } - // 获取用户信息 - const { fetchData: useFetchData } = GetAdminUserInfoApi() - const getAdminUserInfo = async() => { - const res = await useFetchData() - setAdminUserInfo({ ...res.data }) - getShortCode(res.data.user_id) - } - // 登录加checkLogin检查 const checkLogin = () => { - return new Promise(async(reslove) => { + // eslint-disable-next-line no-async-promise-executor + return new Promise(async(resolve) => { if (!userInfo.token) { await wxLogin() - reslove(true) + resolve(true) } else { // 这个东西不要打开,checkSession有调用频率问题 // Taro.checkSession({ // success: async () => { - // reslove(true) + // resolve(true) // if(!userInfo.adminUserInfo) getAdminUserInfo() // }, // fail: async () => { // await wxLogin() - // reslove(true) + // resolve(true) // } // }) } @@ -62,9 +65,9 @@ export default () => { // 获取用户头像等信息数据 const { fetchData: fetchDataUserInfo } = GetWxUserInfoApi() const getSelfUserInfo = async() => { - return new Promise((reslove, reject) => { + return new Promise((resolve, reject) => { if (userInfo.adminUserInfo?.is_authorize_name) { - reslove(true) + resolve(true) return true } Taro.getUserProfile({ @@ -83,7 +86,7 @@ export default () => { if (user_res.success) { setUserInfo({ ...user_res.data }) getAdminUserInfo() - reslove(true) + resolve(true) } else { reject(user_res.msg) @@ -101,9 +104,10 @@ export default () => { const { fetchData: fetchDataUserPhone } = GetPhoneNumberApi() const { fetchData: fetchBindingCompany } = BindingCompanyApi() const getPhoneNumber = (code) => { - return new Promise(async(reslove, reject) => { + // eslint-disable-next-line no-async-promise-executor + return new Promise(async(resolve, reject) => { if (userInfo.adminUserInfo?.is_authorize_phone) { - reslove(true) + resolve(true) return true } const res = await fetchDataUserPhone({ code }) @@ -111,22 +115,16 @@ export default () => { setUserInfo({ ...userInfo.userInfo, phone: res.data.phone_number }) await fetchBindingCompany() getAdminUserInfo() - reslove(res.data) + resolve(res.data) } else { reject(res.msg) } }) } - - // 获取分享码(右上角分享码) - const { SharePage } = SHARE_SCENE - const { fetchData: fetchDataShortCode } = GetShortCodeApi() - const getShortCode = async(user_id) => { - const { data: resPage } = await fetchDataShortCode({ share_user_id: user_id, type: SharePage.value }) - setSortCode({ ...userInfo.sort_code, shareShortPage: { title: '打造面料爆品 专注客户服务', code: resPage.md5_key, img: `${IMG_CND_Prefix}/mall/share_img_01.png` } }) - } - + useDidShow(() => { + checkLogin() + }) return { checkLogin, wxLogin,