From d49314aa5b07801fe702d5f1dceb36ae28f40577 Mon Sep 17 00:00:00 2001 From: xuan Date: Fri, 2 Dec 2022 18:59:29 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20style(eslint):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9Eeslint=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 12 - .eslintignore | 7 + .eslintrc | 15 +- .prettierrc.js | 10 - babel.config.js | 6 +- config/dev.js | 1 + config/index.js | 15 +- config/pre.js | 1 + config/prod.js | 1 + global.d.ts | 4 +- package.json | 15 +- src/api/addressList.ts | 14 +- src/api/addressManager.ts | 10 +- src/api/banner.ts | 2 +- src/api/cdn.ts | 2 +- src/api/certification.ts | 42 +- src/api/company.ts | 4 +- src/api/creditLine.ts | 4 +- src/api/deposit.ts | 6 +- src/api/favorite.ts | 16 +- src/api/login.ts | 2 +- src/api/material.ts | 12 +- src/api/materialColor.ts | 12 +- src/api/mine.ts | 34 +- src/api/onlinePay.ts | 6 +- src/api/order.ts | 22 +- src/api/orderPay.ts | 8 +- src/api/salesAfterOrder.ts | 121 +- src/api/search.ts | 36 +- src/api/share.ts | 32 +- src/api/shopCart.ts | 8 +- src/api/subjectMaterial.ts | 13 +- src/api/user.ts | 110 +- src/api/weightList.ts | 46 +- src/app.config.ts | 168 +- src/app.tsx | 16 +- src/common/bluetooth/color/colorDiff.js | 156 +- src/common/bluetooth/color/colorSpace.js | 8 +- src/common/bluetooth/color/lab.js | 82 +- src/common/bluetooth/color/rgb.js | 13 +- src/common/bluetooth/color/xyz.js | 184 +- src/common/bluetooth/command.js | 199 +- src/common/bluetooth/utils.js | 59 +- src/common/common.ts | 39 +- src/common/constant.js | 14 +- src/common/enum.ts | 18 +- src/common/fotmat.js | 53 +- src/common/shortCode/index.js | 54 +- src/common/system.ts | 13 +- src/common/util.ts | 55 +- src/components/AddressList/index.tsx | 167 +- src/components/FromList/index.tsx | 68 +- .../FromListCertification/index.tsx | 62 +- src/components/InfiniteScrollPaging/index.tsx | 28 +- src/components/LabAndImg/index.tsx | 34 +- src/components/LabAndImgShow/index.tsx | 35 +- src/components/Message/index.tsx | 12 +- src/components/addCollection/index.tsx | 18 +- src/components/address/index.tsx | 388 +- src/components/afterOrderBtns/index copy.tsx | 385 +- src/components/afterOrderBtns/index.tsx | 69 +- src/components/amountShow/index.tsx | 50 +- src/components/banner/index.tsx | 21 +- src/components/bindSalesmanPopup/index.tsx | 93 +- src/components/bluetooth/LinkBlueTooth.tsx | 162 +- src/components/bluetooth/Popup.tsx | 132 +- src/components/checkbox/index.tsx | 17 +- src/components/closeBtn/index.tsx | 34 +- src/components/counter/index copy.tsx | 68 +- src/components/counter/index.tsx | 80 +- src/components/dotLoading/index.tsx | 28 +- src/components/estimatedAmount/index.tsx | 119 +- src/components/filter/index.tsx | 54 +- src/components/filterV2/index.tsx | 63 +- src/components/infiniteScroll/index.tsx | 217 +- src/components/loading/index.tsx | 47 +- src/components/loadingCard/index.tsx | 44 +- src/components/moveBtn/index.tsx | 20 +- src/components/orderBtns/index copy.tsx | 385 +- src/components/orderBtns/index.tsx | 140 +- src/components/popup/index.tsx | 135 +- src/components/product/index.tsx | 12 +- src/components/search/index.tsx | 36 +- src/components/searchInput/index.tsx | 15 +- .../shopCart/components/productItem/index.tsx | 23 +- src/components/shopCart/index copy.tsx | 150 +- src/components/shopCart/index.tsx | 150 +- src/components/sideBar/index.tsx | 49 +- src/components/sortBtn/index.tsx | 82 +- src/components/tabs/index.tsx | 103 +- src/components/textareaEnhance/index.tsx | 88 +- src/components/uploadImage/index.tsx | 30 +- src/constants/common.ts | 2 +- src/constants/userInfo.ts | 2 +- src/pages/addressAdd/index.tsx | 99 +- src/pages/addressManager/index.tsx | 18 +- .../components/cutKindList/index.tsx | 92 +- .../components/kindList/index.tsx | 92 +- .../components/otherReason/index.tsx | 72 +- .../components/reasonPopup/index copy 2.tsx | 84 +- .../components/reasonPopup/index copy.tsx | 55 +- .../components/reasonPopup/index.tsx | 115 +- src/pages/applyAfterSales/index.tsx | 138 +- .../component/successBind/index.tsx | 76 +- src/pages/bindSalesman/index.tsx | 55 +- .../components/SelectEnterpriseType.tsx | 70 +- src/pages/certification/index.tsx | 154 +- .../classList/components/filter/index.tsx | 56 +- src/pages/classList/index.config.ts | 2 +- src/pages/classList/index.tsx | 44 +- .../collection/collectionClass/index.tsx | 58 +- .../components/createPopup/index.tsx | 22 +- .../collection/components/product/index.tsx | 147 +- .../components/updatePopup/index.tsx | 88 +- src/pages/collection/index.tsx | 307 +- src/pages/company/index.tsx | 153 +- src/pages/creditLine/index.tsx | 309 +- src/pages/creditUsed/index.tsx | 43 +- src/pages/depositBeforehand/index.tsx | 36 +- src/pages/depositBeforehandDetail/index.tsx | 72 +- src/pages/depositList/index.tsx | 26 +- .../details/components/counter/index.tsx | 59 +- .../details/components/orderCount/index.tsx | 98 +- .../details/components/preview/index.tsx | 38 +- .../details/components/productItem/index.tsx | 7 +- src/pages/details/components/swiper/index.tsx | 16 +- src/pages/details/index.config.ts | 2 +- src/pages/details/index.tsx | 96 +- .../components/shipmentMode/index.tsx | 60 +- src/pages/editOrder/index.tsx | 71 +- src/pages/index/components/product/index.tsx | 2 +- .../index/components/productClass/index.tsx | 22 +- src/pages/index/context.ts | 4 +- src/pages/index/index.tsx | 54 +- src/pages/order/comfirm.tsx | 97 +- .../order/components/addressInfo/index.tsx | 126 +- .../components/addressInfoDetail/index.tsx | 109 +- .../components/advanceOrderState/index.tsx | 22 +- .../order/components/amountShow/index.tsx | 48 +- .../order/components/applyRefund/index.tsx | 42 +- .../components/estimatedAmount/index.tsx | 117 +- .../order/components/kindList/index copy.tsx | 392 +- src/pages/order/components/kindList/index.tsx | 92 +- .../order/components/movableAreaBtn/index.tsx | 16 +- .../order/components/offlinePay/index.tsx | 105 +- .../order/components/orderState/index.tsx | 136 +- .../order/components/orderStatusTag/index.tsx | 45 +- src/pages/order/components/payment/index.tsx | 118 +- .../order/components/reasonPopup/index.tsx | 55 +- src/pages/order/components/remark/index.tsx | 74 +- .../order/components/returnRecord/index.tsx | 299 +- src/pages/order/components/scanPay/index.tsx | 87 +- .../order/components/scanPayCheck/index.tsx | 79 +- .../order/components/shipmentMode/index.tsx | 52 +- .../order/components/submitOrderBtn/index.tsx | 69 +- .../order/components/weightMemo/index.tsx | 66 +- src/pages/order/index.tsx | 144 +- .../orderList/components/order/index.tsx | 47 +- .../components/orderStatusList/index.tsx | 19 +- src/pages/order/orderList/index.tsx | 131 +- .../components/addressInfo/index.tsx | 126 +- .../components/addressInfoDetail/index.tsx | 18 +- .../components/amountShow/index.tsx | 48 +- .../components/applyRecord/index.tsx | 70 +- .../components/contentBox/index.tsx | 37 +- .../components/estimatedAmount/index.tsx | 57 +- .../salesAfter/components/kindList/index.tsx | 73 +- .../components/offlinePay/index.tsx | 95 +- .../components/orderState/index.tsx | 102 +- .../salesAfter/components/payment/index.tsx | 342 +- .../salesAfter/components/remark/index.tsx | 70 +- .../components/returnLogistics/index.tsx | 37 +- .../components/returnPayCheck/index.tsx | 45 +- .../salesAfter/components/scanPay/index.tsx | 34 +- .../components/shipmentMode/index.tsx | 52 +- .../components/submitOrderBtn/index.tsx | 75 +- .../components/weightMemo/index.tsx | 66 +- src/pages/salesAfter/index.tsx | 89 +- .../salesAfterList/components/order/index.tsx | 49 +- .../components/orderStatusList/index.tsx | 79 +- .../components/orderStatusTag/index.tsx | 45 +- .../components/returnLogistics/index.tsx | 127 +- src/pages/salesAfter/salesAfterList/index.tsx | 86 +- .../compoents/bluetooth/LinkBlueTooth.tsx | 151 +- .../compoents/bluetooth/Popup.tsx | 132 +- src/pages/sampleComparison/index.tsx | 378 +- src/pages/search/index.tsx | 12 +- .../components/selectData/index.tsx | 95 +- .../searchList/hightSearchList.config.ts | 2 +- src/pages/searchList/hightSearchList.tsx | 55 +- src/pages/searchList/search.tsx | 38 +- src/pages/searchList/searchList.config.ts | 2 +- src/pages/searchList/searchList.tsx | 54 +- .../subjectList/components/filter/index.tsx | 56 +- src/pages/subjectList/index.config.ts | 2 +- src/pages/subjectList/index.tsx | 240 +- src/pages/user/index.tsx | 72 +- src/pages/userEdit/components/ModifyModal.tsx | 56 +- src/pages/userEdit/index.tsx | 106 +- src/pages/weightList/index.tsx | 130 +- src/pages/weightListAdd/index.tsx | 80 +- src/reducers/commonData.ts | 46 +- src/reducers/hooks.ts | 18 +- src/reducers/index.ts | 6 +- src/reducers/userInfo.ts | 211 +- src/store/index.ts | 16 +- src/use/BlueToothCopy.tsx | 79 +- src/use/contextBlueTooth.tsx | 79 +- src/use/useCheckAuthorize.tsx | 19 +- src/use/useCommon.ts | 49 +- src/use/useCommonData.ts | 15 +- src/use/useHttp.ts | 41 +- src/use/useLogin.ts | 48 +- src/use/useLoginRequest.ts | 214 +- src/use/useUploadImage.ts | 52 +- src/use/useUserInfo.ts | 7 +- yarn.lock | 22999 ++++++++-------- 217 files changed, 19491 insertions(+), 19187 deletions(-) delete mode 100644 .editorconfig create mode 100644 .eslintignore delete mode 100644 .prettierrc.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 5760be5..0000000 --- a/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -# http://editorconfig.org -root = true - -[*] -indent_style = space -indent_size = 2 -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..ce8d250 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +/node_modules +/build +/key +/dist +project.*.json +*.lock +*.log diff --git a/.eslintrc b/.eslintrc index ec9427d..ef3a582 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,13 @@ { - "extends": ["taro/react"], + "extends": ["taro/react","@aaronghx/eslint-config-react"], "rules": { - "react/jsx-uses-react": "off", - "react/react-in-jsx-scope": "off" - }, - "plugins": [""] + "no-console": "off", + "@typescript-eslint/no-shadow": "off", + "@typescript-eslint/no-unused-vars": "off", + "eqeqeq": "off", + "no-prototype-builtins": "off", + "import/first": "off", + "react/no-children-prop": "off", + "import/no-commonjs": "off" + } } diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 4276115..0000000 --- a/.prettierrc.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - printWidth: 160, // 每行代码最大长度 - tabWidth: 2, //一个tab代表几个空格数,默认为80 - useTabs: false, //是否使用tab进行缩进,默认为false,表示用空格进行缩减 - semi: false, // 声明后带分号 - singleQuote: true, // 使用单引号 - jsxSingleQuote: true, // 使用单引号 - jsxBracketSameLine: true, // 启用jsx语法,> 放在末尾 - trailingComma: 'all', -} diff --git a/babel.config.js b/babel.config.js index f3acb81..f0f4486 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,7 +4,7 @@ module.exports = { presets: [ ['taro', { framework: 'react', - ts: true - }] - ] + ts: true, + }], + ], } diff --git a/config/dev.js b/config/dev.js index df7c8c0..d3e1af0 100644 --- a/config/dev.js +++ b/config/dev.js @@ -1,4 +1,5 @@ const path = require('path') + module.exports = { env: { NODE_ENV: '"development"', diff --git a/config/index.js b/config/index.js index cbc3245..163dbc4 100644 --- a/config/index.js +++ b/config/index.js @@ -1,15 +1,16 @@ const path = require('path') const childProcess = require('child_process') -const versions = - childProcess.execSync('git rev-parse --abbrev-ref HEAD', { + +const versions + = childProcess.execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8', }) != 'HEAD\n' ? childProcess.execSync('git rev-parse --abbrev-ref HEAD', { - encoding: 'utf8', - }) + encoding: 'utf8', + }) : childProcess.execSync('git describe --tags --abbrev=0', { - encoding: 'utf8', - }) + encoding: 'utf8', + }) const CURRENT_GITHASH = childProcess.execSync('git rev-parse --short HEAD', { encoding: 'utf8', }) @@ -109,7 +110,7 @@ const config = { // }, } -module.exports = function (merge) { +module.exports = function(merge) { if (process.env.NODE_ENV === 'development') { return merge({}, config, require('./dev')) } diff --git a/config/pre.js b/config/pre.js index ac743ed..0ec1843 100644 --- a/config/pre.js +++ b/config/pre.js @@ -1,4 +1,5 @@ const path = require('path') + module.exports = { env: { NODE_ENV: '"pre"', diff --git a/config/prod.js b/config/prod.js index 3c77e38..2e1b3b2 100644 --- a/config/prod.js +++ b/config/prod.js @@ -1,4 +1,5 @@ const path = require('path') + module.exports = { env: { NODE_ENV: '"production"', diff --git a/global.d.ts b/global.d.ts index 947366a..78b17be 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,4 +1,4 @@ -/// +/// declare module '*.png' declare module '*.gif' @@ -19,4 +19,4 @@ declare namespace NodeJS { declare const CURRENT_VERSION: string declare const CURRENT_GITHASH: string -declare const CURRENT_ENV: string \ No newline at end of file +declare const CURRENT_ENV: string diff --git a/package.json b/package.json index 5bf3d7f..f5f6aa6 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "typescript": true, "css": "sass" }, + "author": "", "scripts": { "build:weapp": "taro build --type weapp", "build:swan": "taro build --type swan", @@ -31,14 +32,15 @@ "dev:weapp:pre": "cross-env NODE_ENV=pre npm run build:weapp -- --watch", "build:weapp:open": "taro build --type weapp --open", "build:weapp:upload": "taro build --type weapp --upload", - "build:weapp:preview": "taro build --type weapp --preview" + "build:weapp:preview": "taro build --type weapp --preview", + "lint": "eslint .", + "lint:fix": "eslint . --fix" }, "browserslist": [ "last 3 versions", "Android >= 4.1", "ios >= 8" ], - "author": "", "dependencies": { "@babel/runtime": "^7.7.7", "@tarojs/components": "3.5.6", @@ -59,6 +61,7 @@ "tarojs": "^2.1.1" }, "devDependencies": { + "@aaronghx/eslint-config-react": "^0.1.11", "@babel/core": "^7.8.0", "@pmmmwh/react-refresh-webpack-plugin": "0.5.5", "@tarojs/plugin-mini-ci": "3.5.6", @@ -67,15 +70,11 @@ "@types/qs": "^6.9.7", "@types/react": "^18.0.0", "@types/webpack-env": "^1.13.6", - "@typescript-eslint/eslint-plugin": "^4.15.1", - "@typescript-eslint/parser": "^4.15.1", "babel-preset-taro": "3.5.6", + "classnames": "^2.3.2", "cross-env": "^7.0.3", - "eslint": "^6.8.0", + "eslint": "^8.28.0", "eslint-config-taro": "3.5.6", - "eslint-plugin-import": "^2.12.0", - "eslint-plugin-react": "^7.8.2", - "eslint-plugin-react-hooks": "^4.2.0", "react-refresh": "0.11.0", "stylelint": "9.3.0", "typescript": "^4.1.0", diff --git a/src/api/addressList.ts b/src/api/addressList.ts index 4ff2e32..0c9a363 100644 --- a/src/api/addressList.ts +++ b/src/api/addressList.ts @@ -1,12 +1,12 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 获取行政地区列表 */ - export const GetAddressListApi = () => { - return useRequest({ - url: `/v1/mall/district/list`, - method: "get", - }) -} \ No newline at end of file +export const GetAddressListApi = () => { + return useRequest({ + url: '/v1/mall/district/list', + method: 'get', + }) +} diff --git a/src/api/addressManager.ts b/src/api/addressManager.ts index 6d9310c..6d1e225 100644 --- a/src/api/addressManager.ts +++ b/src/api/addressManager.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const addressListApi = () => { return useRequest({ - url: `/v1/mall/address/list`, + url: '/v1/mall/address/list', method: 'get', }) } @@ -17,7 +17,7 @@ export const addressListApi = () => { */ export const addressAddApi = () => { return useRequest({ - url: `/v1/mall/address`, + url: '/v1/mall/address', method: 'post', }) } @@ -28,7 +28,7 @@ export const addressAddApi = () => { */ export const addressDetailApi = () => { return useRequest({ - url: `/v1/mall/address`, + url: '/v1/mall/address', method: 'get', }) } @@ -39,7 +39,7 @@ export const addressDetailApi = () => { */ export const addressEditApi = () => { return useRequest({ - url: `/v1/mall/address`, + url: '/v1/mall/address', method: 'put', }) } @@ -50,7 +50,7 @@ export const addressEditApi = () => { */ export const addressDeleteApi = () => { return useRequest({ - url: `/v1/mall/address`, + url: '/v1/mall/address', method: 'delete', }) } diff --git a/src/api/banner.ts b/src/api/banner.ts index d39c350..4926403 100644 --- a/src/api/banner.ts +++ b/src/api/banner.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const GetBannerList = () => { return useRequest({ - url: `/v1/mall/carouselBanner/list`, + url: '/v1/mall/carouselBanner/list', method: 'get', }) } diff --git a/src/api/cdn.ts b/src/api/cdn.ts index 1c34ec8..c94eed5 100644 --- a/src/api/cdn.ts +++ b/src/api/cdn.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const GetSignApi = () => { return useRequest({ - url: `/v1/mall/cdn/token`, + url: '/v1/mall/cdn/token', method: 'get', }) } diff --git a/src/api/certification.ts b/src/api/certification.ts index 02e6d60..37fe370 100644 --- a/src/api/certification.ts +++ b/src/api/certification.ts @@ -1,34 +1,34 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 企业认证信息获取 - * @returns + * @returns */ - export const certificationDetailApi = () => { - return useRequest({ - url: `/v1/mall/company/authentication`, - method: "get", - }) +export const certificationDetailApi = () => { + return useRequest({ + url: '/v1/mall/company/authentication', + method: 'get', + }) } /** - * 企业认证信息提交 - * @returns + * 企业认证信息提交 + * @returns */ - export const certificationSaveApi = () => { - return useRequest({ - url: `/v1/mall/company/authentication`, - method: "put", - }) +export const certificationSaveApi = () => { + return useRequest({ + url: '/v1/mall/company/authentication', + method: 'put', + }) } /** * 企业认证类型枚举列表 - * @returns + * @returns */ - export const certificationTypeListApi = () => { - return useRequest({ - url: `/v1/mall/enum/companyAuthenticationType`, - method: "get", - }) -} \ No newline at end of file +export const certificationTypeListApi = () => { + return useRequest({ + url: '/v1/mall/enum/companyAuthenticationType', + method: 'get', + }) +} diff --git a/src/api/company.ts b/src/api/company.ts index 500d626..f2c68e7 100644 --- a/src/api/company.ts +++ b/src/api/company.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const companyDetailApi = () => { return useRequest({ - url: `/v1/mall/company/info`, + url: '/v1/mall/company/info', method: 'get', }) } @@ -17,7 +17,7 @@ export const companyDetailApi = () => { */ export const companyUpdateApi = () => { return useRequest({ - url: `/v1/mall/company/info`, + url: '/v1/mall/company/info', method: 'put', }) } diff --git a/src/api/creditLine.ts b/src/api/creditLine.ts index 2fd133b..42210fb 100644 --- a/src/api/creditLine.ts +++ b/src/api/creditLine.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const creditInfoApi = () => { return useRequest({ - url: `/v1/mall/credit`, + url: '/v1/mall/credit', method: 'get', }) } @@ -17,7 +17,7 @@ export const creditInfoApi = () => { */ export const creditListApi = () => { return useRequest({ - url: `/v1/mall/credit/list`, + url: '/v1/mall/credit/list', method: 'get', }) } diff --git a/src/api/deposit.ts b/src/api/deposit.ts index 4a24d8e..9bff8c7 100644 --- a/src/api/deposit.ts +++ b/src/api/deposit.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const depositInfoApi = () => { return useRequest({ - url: `/v1/mall/rechargeApplication`, + url: '/v1/mall/rechargeApplication', method: 'get', }) } @@ -17,7 +17,7 @@ export const depositInfoApi = () => { */ export const depositListApi = () => { return useRequest({ - url: `/v1/mall/rechargeApplication/list`, + url: '/v1/mall/rechargeApplication/list', method: 'get', }) } @@ -28,7 +28,7 @@ export const depositListApi = () => { */ export const depositDetailApi = () => { return useRequest({ - url: `/v1/mall/rechargeApplication/order`, + url: '/v1/mall/rechargeApplication/order', method: 'get', }) } diff --git a/src/api/favorite.ts b/src/api/favorite.ts index 09eaa77..937138a 100644 --- a/src/api/favorite.ts +++ b/src/api/favorite.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const FavoriteListApi = () => { return useRequest({ - url: `/v1/mall/favorite/list`, + url: '/v1/mall/favorite/list', method: 'get', }) } @@ -17,7 +17,7 @@ export const FavoriteListApi = () => { */ export const CreateFavoriteApi = () => { return useRequest({ - url: `/v1/mall/favorite`, + url: '/v1/mall/favorite', method: 'post', }) } @@ -28,7 +28,7 @@ export const CreateFavoriteApi = () => { */ export const DelFavoriteApi = () => { return useRequest({ - url: `/v1/mall/favorite`, + url: '/v1/mall/favorite', method: 'delete', }) } @@ -39,7 +39,7 @@ export const DelFavoriteApi = () => { */ export const UpdateFavoriteApi = () => { return useRequest({ - url: `/v1/mall/favorite`, + url: '/v1/mall/favorite', method: 'put', }) } @@ -50,7 +50,7 @@ export const UpdateFavoriteApi = () => { */ export const AddFavoriteApi = () => { return useRequest({ - url: `/v1/mall/favorite/product`, + url: '/v1/mall/favorite/product', method: 'post', }) } @@ -61,7 +61,7 @@ export const AddFavoriteApi = () => { */ export const DelFavoriteProductApi = () => { return useRequest({ - url: `/v1/mall/favorite/product`, + url: '/v1/mall/favorite/product', method: 'delete', }) } @@ -72,7 +72,7 @@ export const DelFavoriteProductApi = () => { */ export const DetailFavoriteProductApi = () => { return useRequest({ - url: `/v1/mall/favorite`, + url: '/v1/mall/favorite', method: 'get', }) } @@ -83,7 +83,7 @@ export const DetailFavoriteProductApi = () => { */ export const MoveFavoriteProductApi = () => { return useRequest({ - url: `/v1/mall/favorite/product`, + url: '/v1/mall/favorite/product', method: 'put', }) } diff --git a/src/api/login.ts b/src/api/login.ts index d1e830c..d0b56f6 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const LoginApi = () => { return useRequest({ - url: `/v1/mall/login`, + url: '/v1/mall/login', method: 'post', }) } diff --git a/src/api/material.ts b/src/api/material.ts index ab3131b..e89363f 100644 --- a/src/api/material.ts +++ b/src/api/material.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const GetCategoryList = () => { return useRequest({ - url: `/v1/mall/category/list`, + url: '/v1/mall/category/list', method: 'get', }) } @@ -17,7 +17,7 @@ export const GetCategoryList = () => { */ export const GetProductKindListApi = () => { return useRequest({ - url: `/v2/mall/product/kind/list`, + url: '/v2/mall/product/kind/list', method: 'get', }) } @@ -28,7 +28,7 @@ export const GetProductKindListApi = () => { */ export const GetProductListApi = () => { return useRequest({ - url: `/v2/mall/product/list`, + url: '/v2/mall/product/list', method: 'get', }) } @@ -38,7 +38,7 @@ export const GetProductListApi = () => { */ export const GetClassList = () => { return useRequest({ - url: `/v2/mall/product/kind/sub/list`, + url: '/v2/mall/product/kind/sub/list', method: 'get', }) } @@ -49,7 +49,7 @@ export const GetClassList = () => { */ export const GetProductDetailApi = () => { return useRequest({ - url: `/v1/mall/product`, + url: '/v1/mall/product', method: 'get', }) } @@ -60,7 +60,7 @@ export const GetProductDetailApi = () => { */ export const GetLabProductApi = () => { return useRequest({ - url: `/v1/mall/product/color/absorb/match`, + url: '/v1/mall/product/color/absorb/match', method: 'get', }) } diff --git a/src/api/materialColor.ts b/src/api/materialColor.ts index 589241e..bdb807e 100644 --- a/src/api/materialColor.ts +++ b/src/api/materialColor.ts @@ -1,12 +1,12 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 获取面料颜色列表 - * @returns + * @returns */ export const GetColorList = () => { - return useRequest({ - url: `/v1/mall/product/color/list`, - method: "get", - }) + return useRequest({ + url: '/v1/mall/product/color/list', + method: 'get', + }) } diff --git a/src/api/mine.ts b/src/api/mine.ts index bb53baf..e856e54 100644 --- a/src/api/mine.ts +++ b/src/api/mine.ts @@ -1,26 +1,26 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 获取用户资产 - * @returns + * @returns */ export const userassets = () => { - return useRequest({ - url: `/v1/mall/user/assets`, - method: "get", - }) + return useRequest({ + url: '/v1/mall/user/assets', + method: 'get', + }) } -//取色对比 +// 取色对比 export const productabsorbcontrast = () => { - return useRequest({ - url: `/v1/mall/product/color/absorb/contrast`, - method: "get", - }) + return useRequest({ + url: '/v1/mall/product/color/absorb/contrast', + method: 'get', + }) } -//订单统计 +// 订单统计 export const userorderStatistics = () => { - return useRequest({ - url: `/v1/mall/user/orderStatistics`, - method: "get", - }) -} \ No newline at end of file + return useRequest({ + url: '/v1/mall/user/orderStatistics', + method: 'get', + }) +} diff --git a/src/api/onlinePay.ts b/src/api/onlinePay.ts index 6886495..09bbe43 100644 --- a/src/api/onlinePay.ts +++ b/src/api/onlinePay.ts @@ -6,13 +6,13 @@ import { useRequest } from '@/use/useHttp' */ export const GetPayCode = () => { return useRequest({ - url: `/xima-caphtml/caphtml`, + url: '/xima-caphtml/caphtml', base_url: CAP_HTML_TO_IMAGE_BASE_URL, method: 'post', }) } -//本地获取二维码 +// 本地获取二维码 // export const GetPayCode = () => { // return useRequest({ // url: `/caphtml`, @@ -26,7 +26,7 @@ export const GetPayCode = () => { */ export const GetReturnPayCode = () => { return useRequest({ - url: `/xima-caphtml/caphtml-return`, + url: '/xima-caphtml/caphtml-return', base_url: CAP_HTML_TO_IMAGE_BASE_URL, method: 'post', }) diff --git a/src/api/order.ts b/src/api/order.ts index bc1f632..875b2a3 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -5,7 +5,7 @@ import { useRequest } from '@/use/useHttp' */ export const SaleOrderApi = () => { return useRequest({ - url: `/v1/mall/saleOrder`, + url: '/v1/mall/saleOrder', method: 'post', }) } @@ -15,7 +15,7 @@ export const SaleOrderApi = () => { */ export const SaleOrderPreViewApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/preView`, + url: '/v1/mall/saleOrder/preView', method: 'put', }) } @@ -25,7 +25,7 @@ export const SaleOrderPreViewApi = () => { */ export const GetSaleOrderDetailApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/detail`, + url: '/v1/mall/saleOrder/detail', method: 'get', }) } @@ -35,7 +35,7 @@ export const GetSaleOrderDetailApi = () => { */ export const EditSaleOrderRemarkApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/remark`, + url: '/v1/mall/saleOrder/remark', method: 'put', }) } @@ -45,7 +45,7 @@ export const EditSaleOrderRemarkApi = () => { */ export const EditSaleOrderAddressApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/address`, + url: '/v1/mall/saleOrder/address', method: 'put', }) } @@ -55,7 +55,7 @@ export const EditSaleOrderAddressApi = () => { */ export const EditSaleOrderShipmentModeApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/shipmentMode`, + url: '/v1/mall/saleOrder/shipmentMode', method: 'put', }) } @@ -65,7 +65,7 @@ export const EditSaleOrderShipmentModeApi = () => { */ export const GetOrderStatusListApi = () => { return useRequest({ - url: `/v1/mall/enum/sale/order/status`, + url: '/v1/mall/enum/sale/order/status', method: 'get', }) } @@ -75,7 +75,7 @@ export const GetOrderStatusListApi = () => { */ export const GetOrderListApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/list`, + url: '/v1/mall/saleOrder/list', method: 'get', }) } @@ -85,7 +85,7 @@ export const GetOrderListApi = () => { */ export const CancelOrderApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/cancel`, + url: '/v1/mall/saleOrder/cancel', method: 'put', }) } @@ -95,7 +95,7 @@ export const CancelOrderApi = () => { */ export const ReceiveOrderApi = () => { return useRequest({ - url: `/v1/mall/saleOrder/receive`, + url: '/v1/mall/saleOrder/receive', method: 'put', }) } @@ -105,7 +105,7 @@ export const ReceiveOrderApi = () => { */ export const OrderStatusListApi = () => { return useRequest({ - url: `/v1/mall/enum/filterSaleOrderStatus`, + url: '/v1/mall/enum/filterSaleOrderStatus', method: 'get', }) } diff --git a/src/api/orderPay.ts b/src/api/orderPay.ts index eb34c41..d7bef93 100644 --- a/src/api/orderPay.ts +++ b/src/api/orderPay.ts @@ -5,7 +5,7 @@ import { useRequest } from '@/use/useHttp' */ export const GetOrderPayApi = () => { return useRequest({ - url: `/v1/mall/orderPayment/orderPaymentMethodInfo`, + url: '/v1/mall/orderPayment/orderPaymentMethodInfo', method: 'get', }) } @@ -15,7 +15,7 @@ export const GetOrderPayApi = () => { */ export const SubmitOrderPayApi = () => { return useRequest({ - url: `/v1/mall/orderPayment/orderPaymentSubmission`, + url: '/v1/mall/orderPayment/orderPaymentSubmission', method: 'put', }) } @@ -25,7 +25,7 @@ export const SubmitOrderPayApi = () => { */ export const GetPrepayOrderPayApi = () => { return useRequest({ - url: `/v1/mall/orderPayment/preCollectOrder/orderPaymentMethodInfo`, + url: '/v1/mall/orderPayment/preCollectOrder/orderPaymentMethodInfo', method: 'get', }) } @@ -35,7 +35,7 @@ export const GetPrepayOrderPayApi = () => { */ export const SubmitPrepayOrderPayApi = () => { return useRequest({ - url: `/v1/mall/orderPayment/preCollectOrder/orderPaymentSubmission`, + url: '/v1/mall/orderPayment/preCollectOrder/orderPaymentSubmission', method: 'put', }) } diff --git a/src/api/salesAfterOrder.ts b/src/api/salesAfterOrder.ts index b62b9ee..2aef83d 100644 --- a/src/api/salesAfterOrder.ts +++ b/src/api/salesAfterOrder.ts @@ -1,122 +1,121 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 售后订单列表 */ export const GetSaleOrderListApi = () => { - return useRequest({ - url: `/v1/mall/returnApplyOrder/list`, - method: "get", - }) + return useRequest({ + url: '/v1/mall/returnApplyOrder/list', + method: 'get', + }) } /** * 申请售后订单 */ - export const ReturnApplyOrderApi = () => { - return useRequest({ - url: `/v1/mall/returnApplyOrder`, - method: "post", - }) +export const ReturnApplyOrderApi = () => { + return useRequest({ + url: '/v1/mall/returnApplyOrder', + method: 'post', + }) } /** * 取消退货/退款 */ - export const ReturnApplyOrderCancelApi = () => { - return useRequest({ - url: `/v1/mall/returnApplyOrder/cancel`, - method: "post", - }) +export const ReturnApplyOrderCancelApi = () => { + return useRequest({ + url: '/v1/mall/returnApplyOrder/cancel', + method: 'post', + }) } /** * 售后订单详情 */ - export const SaleOrderOrderDetailApi = () => { - return useRequest({ - url: `/v1/mall/returnApplyOrder`, - method: "get", - }) +export const SaleOrderOrderDetailApi = () => { + return useRequest({ + url: '/v1/mall/returnApplyOrder', + method: 'get', + }) } /** * 物流上传 */ - export const ReturnApplyLogisticsApi = () => { - return useRequest({ - url: `/v1/mall/returnApplyOrder/upload`, - method: "put", - }) +export const ReturnApplyLogisticsApi = () => { + return useRequest({ + url: '/v1/mall/returnApplyOrder/upload', + method: 'put', + }) } - /** * 售后货物状况 */ - export const ReturnGoodsStatusApi = () => { - return useRequest({ - url: `/v1/mall/enum/return/goodsStatus`, - method: "get", - }) +export const ReturnGoodsStatusApi = () => { + return useRequest({ + url: '/v1/mall/enum/return/goodsStatus', + method: 'get', + }) } /** * 售后退货原因 */ - export const ReturnReasonApi = () => { - return useRequest({ - url: `/v1/mall/enum/returnOrder/returnReason`, - method: "get", - }) +export const ReturnReasonApi = () => { + return useRequest({ + url: '/v1/mall/enum/returnOrder/returnReason', + method: 'get', + }) } /** * 售后退货原因 */ - export const ReturnExplainApi = () => { - return useRequest({ - url: `/v1/mall/enum/returnExplain`, - method: "get", - }) +export const ReturnExplainApi = () => { + return useRequest({ + url: '/v1/mall/enum/returnExplain', + method: 'get', + }) } /** * 申请退款 */ - export const ApplyRefundApi = () => { - return useRequest({ - url: `/v1/mall/returnApplyOrder`, - method: "post", - }) +export const ApplyRefundApi = () => { + return useRequest({ + url: '/v1/mall/returnApplyOrder', + method: 'post', + }) } /** * 售后订单状态列表 */ - export const RefundOrderSatausApi = () => { - return useRequest({ - url: `/v1/mall/enum/filterReturnStage`, - method: "get", - }) +export const RefundOrderSatausApi = () => { + return useRequest({ + url: '/v1/mall/enum/filterReturnStage', + method: 'get', + }) } /** * 退款说明 */ - export const RefundExplainApi = () => { - return useRequest({ - url: `/v1/mall/enum/refundExplain`, - method: "get", - }) +export const RefundExplainApi = () => { + return useRequest({ + url: '/v1/mall/enum/refundExplain', + method: 'get', + }) } /** * 售后记录 */ - export const ReturnRecordApi = () => { - return useRequest({ - url: `/v1/mall/saleOrder/return`, - method: "get", - }) +export const ReturnRecordApi = () => { + return useRequest({ + url: '/v1/mall/saleOrder/return', + method: 'get', + }) } diff --git a/src/api/search.ts b/src/api/search.ts index 5b0f296..174cace 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -1,33 +1,31 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 获取热门搜索 */ - export const GetHotSearchApi = () => { - return useRequest({ - url: `/v1/mall/hotSearch/list`, - method: "get", - }) +export const GetHotSearchApi = () => { + return useRequest({ + url: '/v1/mall/hotSearch/list', + method: 'get', + }) } - /** * 获取历史搜索 */ - export const GetSearchHistoryApi = () => { - return useRequest({ - url: `/v1/mall/searchHistory/list`, - method: "get", - }) +export const GetSearchHistoryApi = () => { + return useRequest({ + url: '/v1/mall/searchHistory/list', + method: 'get', + }) } - /** * 添加搜索关键字 */ - export const AddSearchHistoryApi = () => { - return useRequest({ - url: `/v1/mall/searchHistory`, - method: "post", - }) -} \ No newline at end of file +export const AddSearchHistoryApi = () => { + return useRequest({ + url: '/v1/mall/searchHistory', + method: 'post', + }) +} diff --git a/src/api/share.ts b/src/api/share.ts index aaecc87..12108c6 100644 --- a/src/api/share.ts +++ b/src/api/share.ts @@ -1,31 +1,31 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 分享短码 */ - export const GetShortCodeApi = () => { - return useRequest({ - url: `/v1/mall/shortCode/add`, - method: "post", - }) +export const GetShortCodeApi = () => { + return useRequest({ + url: '/v1/mall/shortCode/add', + method: 'post', + }) } /** * 解析短码 */ - export const AnalysisShortCodeApi = () => { - return useRequest({ - url: `/v1/mall/shortCode`, - method: "get", - }) +export const AnalysisShortCodeApi = () => { + return useRequest({ + url: '/v1/mall/shortCode', + method: 'get', + }) } /** * 绑定上下级 */ export const BindShortCodeApi = () => { - return useRequest({ - url: `/v1/mall/shortCode/bind`, - method: "post", - }) -} \ No newline at end of file + return useRequest({ + url: '/v1/mall/shortCode/bind', + method: 'post', + }) +} diff --git a/src/api/shopCart.ts b/src/api/shopCart.ts index 6a101ca..6ad2307 100644 --- a/src/api/shopCart.ts +++ b/src/api/shopCart.ts @@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp' */ export const GetShoppingCartApi = () => { return useRequest({ - url: `/v1/mall/shoppingCart/productColor`, + url: '/v1/mall/shoppingCart/productColor', method: 'get', }) } @@ -17,7 +17,7 @@ export const GetShoppingCartApi = () => { */ export const AddShoppingCartApi = () => { return useRequest({ - url: `/v1/mall/shoppingCart/productColor/list`, + url: '/v1/mall/shoppingCart/productColor/list', method: 'post', }) } @@ -28,7 +28,7 @@ export const AddShoppingCartApi = () => { */ export const DelShoppingCartApi = () => { return useRequest({ - url: `/v1/mall/shoppingCart/productColor`, + url: '/v1/mall/shoppingCart/productColor', method: 'delete', }) } @@ -39,7 +39,7 @@ export const DelShoppingCartApi = () => { */ export const UpdateShoppingCartApi = () => { return useRequest({ - url: `/v1/mall/shoppingCart/productColor`, + url: '/v1/mall/shoppingCart/productColor', method: 'put', }) } diff --git a/src/api/subjectMaterial.ts b/src/api/subjectMaterial.ts index 78a9cd1..e0bb3de 100644 --- a/src/api/subjectMaterial.ts +++ b/src/api/subjectMaterial.ts @@ -1,13 +1,12 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 获取专题列表 - * @returns + * @returns */ export const GetSubjectList = () => { - return useRequest({ - url: `/v1/mall/subject/list`, - method: "get", - }) + return useRequest({ + url: '/v1/mall/subject/list', + method: 'get', + }) } - diff --git a/src/api/user.ts b/src/api/user.ts index 9dc2573..b8ac650 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,110 +1,110 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 解密用户微信信息 */ - export const GetWxUserInfoApi = () => { - return useRequest({ - url: `/v1/mall/user/decrypt`, - method: "post", - }) +export const GetWxUserInfoApi = () => { + return useRequest({ + url: '/v1/mall/user/decrypt', + method: 'post', + }) } /** * 获取后台返回的用户信息 */ - export const GetAdminUserInfoApi = () => { - return useRequest({ - url: `/v1/mall/user/info`, - method: "get", - }) +export const GetAdminUserInfoApi = () => { + return useRequest({ + url: '/v1/mall/user/info', + method: 'get', + }) } /** * 获取后台返回的用户手机号码信息 */ - export const GetPhoneNumberApi = () => { - return useRequest({ - url: `/v1/mall/user/phoneNumber`, - method: "post", - }) +export const GetPhoneNumberApi = () => { + return useRequest({ + url: '/v1/mall/user/phoneNumber', + method: 'post', + }) } /** * 修改用户昵称 */ - export const realNameUpdateApi = () => { - return useRequest({ - url: `/v1/mall/user`, - method: "put", - }) +export const realNameUpdateApi = () => { + return useRequest({ + url: '/v1/mall/user', + method: 'put', + }) } /** * 公司类型|企业类型 下拉列表 */ export const companyTypeApi = () => { - return useRequest({ - url: `/v1/mall/enum/purchaserType`, - method: "get", - }) + return useRequest({ + url: '/v1/mall/enum/purchaserType', + method: 'get', + }) } /** * 头像更改 */ - export const portraitUpdateApi = () => { - return useRequest({ - url: `/v1/mall/user/avatar`, - method: "put", - }) +export const portraitUpdateApi = () => { + return useRequest({ + url: '/v1/mall/user/avatar', + method: 'put', + }) } /** * 绑定公司 */ - export const BindingCompanyApi = () => { - return useRequest({ - url: `/v1/mall/user/binding/company`, - method: "put", - }) +export const BindingCompanyApi = () => { + return useRequest({ + url: '/v1/mall/user/binding/company', + method: 'put', + }) } /** * 申请下单权限 */ - export const ApplyOrderAccessApi = () => { - return useRequest({ - url: `/v1/mall/orderAccess/apply`, - method: "post", - }) +export const ApplyOrderAccessApi = () => { + return useRequest({ + url: '/v1/mall/orderAccess/apply', + method: 'post', + }) } /** * 订阅模板id */ - export const SubscriptionMessageApi = () => { - return useRequest({ - url: `/v1/mall/subscriptionMessage`, - method: "get", - }) +export const SubscriptionMessageApi = () => { + return useRequest({ + url: '/v1/mall/subscriptionMessage', + method: 'get', + }) } /** * 邀请码获取业务员信息 */ - export const GetInvitationInfoApi = () => { - return useRequest({ - url: `/v1/mall/user/invitationInfo`, - method: "get", - }) +export const GetInvitationInfoApi = () => { + return useRequest({ + url: '/v1/mall/user/invitationInfo', + method: 'get', + }) } /** * 绑定业务员 */ - export const BindInvitationInfoApi = () => { - return useRequest({ - url: `/v1/mall/user/bindInvitationCode`, - method: "post", - }) +export const BindInvitationInfoApi = () => { + return useRequest({ + url: '/v1/mall/user/bindInvitationCode', + method: 'post', + }) } diff --git a/src/api/weightList.ts b/src/api/weightList.ts index bc31b89..290d5ff 100644 --- a/src/api/weightList.ts +++ b/src/api/weightList.ts @@ -1,56 +1,56 @@ -import { useRequest } from "@/use/useHttp" +import { useRequest } from '@/use/useHttp' /** * 码单列表获取 - * @returns + * @returns */ - export const weightListApi = () => { - return useRequest({ - url: `/v1/mall/title/list`, - method: "get", - }) +export const weightListApi = () => { + return useRequest({ + url: '/v1/mall/title/list', + method: 'get', + }) } /** * 码单添加 - * @returns + * @returns */ - export const weightAddApi = () => { +export const weightAddApi = () => { return useRequest({ - url: `/v1/mall/title`, - method: "post", + url: '/v1/mall/title', + method: 'post', }) } /** * 码单详情 - * @returns + * @returns */ - export const weightDetailApi = () => { +export const weightDetailApi = () => { return useRequest({ - url: `/v1/mall/title`, - method: "get", + url: '/v1/mall/title', + method: 'get', }) } /** * 码单编辑 - * @returns + * @returns */ - export const weightEditApi = () => { +export const weightEditApi = () => { return useRequest({ - url: `/v1/mall/title`, - method: "put", + url: '/v1/mall/title', + method: 'put', }) } /** * 码单删除 - * @returns + * @returns */ - export const weightDeleteApi = () => { +export const weightDeleteApi = () => { return useRequest({ - url: `/v1/mall/title`, - method: "delete", + url: '/v1/mall/title', + method: 'delete', }) } diff --git a/src/app.config.ts b/src/app.config.ts index eee2dca..e5dccda 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -23,164 +23,164 @@ export default { text: '我的', iconPath: './styles/tabbar/my.png', selectedIconPath: './styles/tabbar/my_selected.png', - } + }, ], - 'color': '#707070', - 'selectedColor': '#2680EB', - 'backgroundColor': '#fff', - 'borderStyle': 'white' + color: '#707070', + selectedColor: '#2680EB', + backgroundColor: '#fff', + borderStyle: 'white', }, subPackages: [ { - root: "pages/search", + root: 'pages/search', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/classList", + root: 'pages/classList', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/details", + root: 'pages/details', pages: [ - "index", - ] + 'index', + ], }, { - root: "pages/searchList", + root: 'pages/searchList', pages: [ - "searchList", - "hightSearchList", - "search" - ] + 'searchList', + 'hightSearchList', + 'search', + ], }, { - root: "pages/userEdit", + root: 'pages/userEdit', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/addressManager", + root: 'pages/addressManager', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/addressAdd", + root: 'pages/addressAdd', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/company", + root: 'pages/company', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/weightList", + root: 'pages/weightList', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/weightListAdd", + root: 'pages/weightListAdd', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/order", + root: 'pages/order', pages: [ - "index", - "comfirm", - "orderList/index" - ] + 'index', + 'comfirm', + 'orderList/index', + ], }, { - root: "pages/editOrder", + root: 'pages/editOrder', pages: [ - "index", - ] + 'index', + ], }, { - root: "pages/subjectList", + root: 'pages/subjectList', pages: [ - "index", - ] + 'index', + ], }, { - root: "pages/creditLine", + root: 'pages/creditLine', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/creditUsed", + root: 'pages/creditUsed', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/depositBeforehandDetail", + root: 'pages/depositBeforehandDetail', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/depositBeforehand", + root: 'pages/depositBeforehand', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/depositList", + root: 'pages/depositList', pages: [ - "index" - ] + 'index', + ], }, { - root: "pages/salesAfter", + root: 'pages/salesAfter', pages: [ - "index", - "salesAfterList/index" - ] + 'index', + 'salesAfterList/index', + ], }, { - root: "pages/certification", + root: 'pages/certification', pages: [ - "index", - ] + 'index', + ], }, { - root: "pages/applyAfterSales", + root: 'pages/applyAfterSales', pages: [ - "index", - ] + 'index', + ], }, { - root: "pages/collection", + root: 'pages/collection', pages: [ - "index", - "collectionClass/index" - ] + 'index', + 'collectionClass/index', + ], }, { - root: "pages/sampleComparison", + root: 'pages/sampleComparison', pages: [ - "index", - ] + 'index', + ], }, { - root: "pages/bindSalesman", + root: 'pages/bindSalesman', pages: [ - "index", - ] + 'index', + ], }, - ] + ], } diff --git a/src/app.tsx b/src/app.tsx index 9636423..13e9a38 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,7 +1,7 @@ -import { FC } from 'react' -import ContextBlueTooth from '@/use/contextBlueTooth' +import type { FC } from 'react' import { Provider } from 'react-redux' import configStore from './store' +import ContextBlueTooth from '@/use/contextBlueTooth' import './app.scss' import Taro, { onAppShow, useDidShow } from '@tarojs/taro' import { shareShop } from './common/util' @@ -12,21 +12,21 @@ const App: FC = (params) => { withShareTicket: true, }) - //分享 + // 分享 shareShop() - //检查版本更新 + // 检查版本更新 onAppShow(() => { const updateManager = Taro.getUpdateManager() - updateManager.onCheckForUpdate(function (res) { + updateManager.onCheckForUpdate((res) => { // 请求完新版本信息的回调 console.log('版本信息:', res.hasUpdate) }) - updateManager.onUpdateReady(function () { + updateManager.onUpdateReady(() => { Taro.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', - success: function (res) { + success(res) { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() @@ -34,7 +34,7 @@ const App: FC = (params) => { }, }) }) - updateManager.onUpdateFailed(function () { + updateManager.onUpdateFailed(() => { console.log('新版本更新失败') }) }) diff --git a/src/common/bluetooth/color/colorDiff.js b/src/common/bluetooth/color/colorDiff.js index 73e380d..ae8066d 100644 --- a/src/common/bluetooth/color/colorDiff.js +++ b/src/common/bluetooth/color/colorDiff.js @@ -1,86 +1,76 @@ -module.exports = function(lab1, lab2){ - - var rgb2labArray1 = lab1; - var rgb2labArray2 = lab2; - - var l1 = rgb2labArray1[0]; - var a1 = rgb2labArray1[1]; - var b1 = rgb2labArray1[2]; - - var l2 = rgb2labArray2[0]; - var a2 = rgb2labArray2[1]; - var b2 = rgb2labArray2[2]; - - - var avg_lp = (l1 + l2) / 2; - var c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2)); - var c2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2)); - var avg_c = (c1 + c2) / 2; - var g = (1- Math.sqrt(Math.pow(avg_c, 7) / (Math.pow(avg_c, 7) + Math.pow(25, 7)))) / 2; - - var a1p = a1 * (1 + g); - var a2p = a2 * (1 + g); - - var c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2)); - var c2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b2, 2)); - - var avg_cp = (c1p + c2p) / 2; - - var h1p = rad2deg(Math.atan2(b1, a1p)); - if(h1p < 0){ - - h1p = h1p + 360; - } - - var h2p = rad2deg(Math.atan2(b2, a2p)); - if(h2p < 0){ - - h2p = h2p + 360; - } - - var avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2; - - var 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)) - - var delta_hp = h2p - h1p; - if(Math.abs(delta_hp) > 180){ - if (h2p <= h1p) { - delta_hp += 360; - } - else { - delta_hp -= 360; - } - } - - var delta_lp = l2 - l1; - var delta_cp = c2p - c1p; - - delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2); - - var s_l = 1 + ((0.015 * Math.pow(avg_lp - 50, 2)) / Math.sqrt(20 + Math.pow(avg_lp - 50, 2))); - var s_c = 1 + 0.045 * avg_cp - var s_h = 1 + 0.015 * avg_cp * t; - - var delta_ro = 30 * Math.exp( - (Math.pow((avg_hp - 275) / 25, 2))); - var r_c = 2 * Math.sqrt(Math.pow(avg_cp, 7) / (Math.pow(avg_cp, 7) + Math.pow(25, 7))); - var r_t = -r_c * Math.sin(2 * deg2rad(delta_ro)); - - var kl = 1, kc =1, kh = 1; +module.exports = function(lab1, lab2) { + const rgb2labArray1 = lab1 + const rgb2labArray2 = lab2 - var delta_e = Math.sqrt(Math.pow(delta_lp / (kl * s_l), 2) + Math.pow(delta_cp / (kc * s_c), 2) + Math.pow(delta_hp / (kh * s_h), 2) + r_t * (delta_cp / (kc * s_c)) * (delta_hp / (kh * s_h))) + const l1 = rgb2labArray1[0] + const a1 = rgb2labArray1[1] + const b1 = rgb2labArray1[2] - return delta_e - - - function rad2deg(rad){ - - return 360 * rad / (2 * Math.PI); - } - function deg2rad(deg){ - - return (2 * Math.PI * deg) / 360; - } + const l2 = rgb2labArray2[0] + 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 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 avg_cp = (c1p + c2p) / 2 + + let h1p = rad2deg(Math.atan2(b1, a1p)) + if (h1p < 0) { + h1p = h1p + 360 + } + + 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 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 + if (Math.abs(delta_hp) > 180) { + if (h2p <= h1p) { + delta_hp += 360 + } + else { + delta_hp -= 360 + } + } + + const delta_lp = l2 - l1 + const delta_cp = c2p - c1p + + 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 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 + + const delta_e = Math.sqrt(Math.pow(delta_lp / (kl * s_l), 2) + Math.pow(delta_cp / (kc * s_c), 2) + Math.pow(delta_hp / (kh * s_h), 2) + r_t * (delta_cp / (kc * s_c)) * (delta_hp / (kh * s_h))) + + return delta_e + + function rad2deg(rad) { + return 360 * rad / (2 * Math.PI) + } + function deg2rad(deg) { + return (2 * Math.PI * deg) / 360 + } } - - - diff --git a/src/common/bluetooth/color/colorSpace.js b/src/common/bluetooth/color/colorSpace.js index 8d05344..3417197 100644 --- a/src/common/bluetooth/color/colorSpace.js +++ b/src/common/bluetooth/color/colorSpace.js @@ -4,10 +4,10 @@ import XyzCom from './xyz' import ColorDiff from './colorDiff' export const toRgb = (lab) => { - let xyz = LabCom.xyz(lab) - return XyzCom.rgb(xyz) + const xyz = LabCom.xyz(lab) + return XyzCom.rgb(xyz) } export const Ediff = (lab1, lab2) => { - return ColorDiff(lab1, lab2) -} \ No newline at end of file + return ColorDiff(lab1, lab2) +} diff --git a/src/common/bluetooth/color/lab.js b/src/common/bluetooth/color/lab.js index b4c0eab..6741df7 100644 --- a/src/common/bluetooth/color/lab.js +++ b/src/common/bluetooth/color/lab.js @@ -1,54 +1,54 @@ -var xyz = require('./xyz'); +const xyz = require('./xyz') module.exports = { - name: 'lab', - min: [0,-100,-100], - max: [100,100,100], - channel: ['lightness', 'a', 'b'], - alias: ['LAB', 'cielab'], + name: 'lab', + min: [0, -100, -100], + max: [100, 100, 100], + channel: ['lightness', 'a', 'b'], + alias: ['LAB', 'cielab'], - xyz: function(lab) { - var l = lab[0], - a = lab[1], - b = lab[2], - x, y, z, y2; + xyz(lab) { + const l = lab[0] + const a = lab[1] + const b = lab[2] + let x; let y; let z; let y2 - 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); - } + 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) + } - x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3); + x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3) - z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3); + z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3) - return [x, y, z]; - } -}; + return [x, y, z] + }, +} +// extend xyz +xyz.lab = function(xyz) { + let x = xyz[0] + let y = xyz[1] + let z = xyz[2] + let l; let a; let b -//extend xyz -xyz.lab = function(xyz){ - var x = xyz[0], - y = xyz[1], - z = xyz[2], - l, a, b; + x /= 95.047 + y /= 100 + z /= 108.883 - x /= 95.047; - y /= 100; - z /= 108.883; + x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116) + 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) - x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116); - 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) - l = (116 * y) - 16; - a = 500 * (x - y); - b = 200 * (y - z); - - return [l, a, b]; -}; + return [l, a, b] +} diff --git a/src/common/bluetooth/color/rgb.js b/src/common/bluetooth/color/rgb.js index 60ff577..0aba252 100644 --- a/src/common/bluetooth/color/rgb.js +++ b/src/common/bluetooth/color/rgb.js @@ -1,9 +1,8 @@ - module.exports = { - name: 'rgb', - min: [0,0,0], - max: [255,255,255], - channel: ['red', 'green', 'blue'], - alias: ['RGB'] -}; + name: 'rgb', + min: [0, 0, 0], + max: [255, 255, 255], + channel: ['red', 'green', 'blue'], + alias: ['RGB'], +} diff --git a/src/common/bluetooth/color/xyz.js b/src/common/bluetooth/color/xyz.js index c6e2bee..f25cb3b 100644 --- a/src/common/bluetooth/color/xyz.js +++ b/src/common/bluetooth/color/xyz.js @@ -1,13 +1,12 @@ -var rgb = require('./rgb'); - -var xyz = { - name: 'xyz', - min: [0,0,0], - channel: ['X','Y','Z'], - alias: ['XYZ', 'ciexyz', 'cie1931'] -}; +const rgb = require('./rgb') +const xyz = { + name: 'xyz', + min: [0, 0, 0], + channel: ['X', 'Y', 'Z'], + alias: ['XYZ', 'ciexyz', 'cie1931'], +} /** * Whitepoint reference values with observer/illuminant @@ -15,57 +14,55 @@ var xyz = { * http://en.wikipedia.org/wiki/Standard_illuminant */ xyz.whitepoint = { - //1931 2° - 2: { - //incadescent - A:[109.85, 100, 35.585], - // B:[], - C: [98.074, 100, 118.232], - D50: [96.422, 100, 82.521], - D55: [95.682, 100, 92.149], - //daylight - D65: [95.045592705167, 100, 108.9057750759878], - D75: [94.972, 100, 122.638], - //flourescent - // F1: [], - F2: [99.187, 100, 67.395], - // F3: [], - // F4: [], - // F5: [], - // F6:[], - F7: [95.044, 100, 108.755], - // F8: [], - // F9: [], - // F10: [], - F11: [100.966, 100, 64.370], - // F12: [], - E: [100,100,100] - }, - - //1964 10° - 10: { - //incadescent - A:[111.144, 100, 35.200], - C: [97.285, 100, 116.145], - D50: [96.720, 100, 81.427], - D55: [95.799, 100, 90.926], - //daylight - D65: [94.811, 100, 107.304], - D75: [94.416, 100, 120.641], - //flourescent - F2: [103.280, 100, 69.026], - F7: [95.792, 100, 107.687], - F11: [103.866, 100, 65.627], - E: [100,100,100] - } -}; + // 1931 2° + 2: { + // incadescent + A: [109.85, 100, 35.585], + // B:[], + C: [98.074, 100, 118.232], + D50: [96.422, 100, 82.521], + D55: [95.682, 100, 92.149], + // daylight + D65: [95.045592705167, 100, 108.9057750759878], + D75: [94.972, 100, 122.638], + // flourescent + // F1: [], + F2: [99.187, 100, 67.395], + // F3: [], + // F4: [], + // F5: [], + // F6:[], + F7: [95.044, 100, 108.755], + // F8: [], + // F9: [], + // F10: [], + F11: [100.966, 100, 64.370], + // F12: [], + E: [100, 100, 100], + }, + // 1964 10° + 10: { + // incadescent + A: [111.144, 100, 35.200], + C: [97.285, 100, 116.145], + D50: [96.720, 100, 81.427], + D55: [95.799, 100, 90.926], + // daylight + D65: [94.811, 100, 107.304], + D75: [94.416, 100, 120.641], + // flourescent + F2: [103.280, 100, 69.026], + F7: [95.792, 100, 107.687], + F11: [103.866, 100, 65.627], + E: [100, 100, 100], + }, +} /** * Top values are the whitepoint’s top values, default are D65 */ -xyz.max = xyz.whitepoint[2].D65; - +xyz.max = xyz.whitepoint[2].D65 /** * Transform xyz to rgb @@ -74,39 +71,40 @@ xyz.max = xyz.whitepoint[2].D65; * * @return {Array} RGB values */ -xyz.rgb = function (_xyz, white) { - //FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then - white = white || xyz.whitepoint[2].E; +xyz.rgb = function(_xyz, white) { + // FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then + white = white || xyz.whitepoint[2].E - var x = _xyz[0] / white[0], - y = _xyz[1] / white[1], - z = _xyz[2] / white[2], - r, g, b; + const x = _xyz[0] / white[0] + const y = _xyz[1] / white[1] + const z = _xyz[2] / white[2] + let r; let g; let b - // assume sRGB - // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html - r = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293); - g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175); - b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878); + // assume sRGB + // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + r = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293) + g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175) + b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878) - r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) - : r = (r * 12.92); + r = r > 0.0031308 + ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) + : r = (r * 12.92) - g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) - : g = (g * 12.92); + g = g > 0.0031308 + ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) + : g = (g * 12.92) - b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) - : b = (b * 12.92); + b = b > 0.0031308 + ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) + : b = (b * 12.92) - r = Math.min(Math.max(0, r), 1); - g = Math.min(Math.max(0, g), 1); - b = Math.min(Math.max(0, b), 1); + r = Math.min(Math.max(0, r), 1) + g = Math.min(Math.max(0, g), 1) + b = Math.min(Math.max(0, b), 1) - return [r * 255, g * 255, b * 255]; + return [r * 255, g * 255, b * 255] } - - /** * RGB to XYZ * @@ -115,24 +113,22 @@ xyz.rgb = function (_xyz, white) { * @return {Array} XYZ channels */ rgb.xyz = function(rgb, white) { - var r = rgb[0] / 255, - g = rgb[1] / 255, - b = rgb[2] / 255; + let r = rgb[0] / 255 + let g = rgb[1] / 255 + let b = rgb[2] / 255 - // assume sRGB - r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); - g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); - b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); + // assume sRGB + r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92) + g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92) + b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92) - var x = (r * 0.41239079926595) + (g * 0.35758433938387) + (b * 0.18048078840183); - var y = (r * 0.21263900587151) + (g * 0.71516867876775) + (b * 0.072192315360733); - var z = (r * 0.019330818715591) + (g * 0.11919477979462) + (b * 0.95053215224966); + const x = (r * 0.41239079926595) + (g * 0.35758433938387) + (b * 0.18048078840183) + const y = (r * 0.21263900587151) + (g * 0.71516867876775) + (b * 0.072192315360733) + const z = (r * 0.019330818715591) + (g * 0.11919477979462) + (b * 0.95053215224966) - white = white || xyz.whitepoint[2].E; + white = white || xyz.whitepoint[2].E - return [x * white[0], y * white[1], z * white[2]]; -}; + return [x * white[0], y * white[1], z * white[2]] +} - - -module.exports = xyz; +module.exports = xyz diff --git a/src/common/bluetooth/command.js b/src/common/bluetooth/command.js index 97292d0..4cd55b7 100644 --- a/src/common/bluetooth/command.js +++ b/src/common/bluetooth/command.js @@ -1,146 +1,141 @@ -import { uint32ToUint8Array, uint8ArrayToHex } from "./utils"; +import { uint32ToUint8Array, uint8ArrayToHex } from './utils' export class Command { - // 测量序号 - static measureId = 1; + // 测量序号 + static measureId = 1 - // 命令完整响应的长度 - responseSize = 0; - // 命令发送的数据 - content = new Uint8Array(0); - // 命令响应的数据 - response = new Uint8Array(0); - // 等待响应的超时时间 - timeout = 3000; - // 发送的数据是否需要生成和校验值 - needSign = true; - + // 命令完整响应的长度 + responseSize = 0 + // 命令发送的数据 + content = new Uint8Array(0) + // 命令响应的数据 + response = new Uint8Array(0) + // 等待响应的超时时间 + timeout = 3000 + // 发送的数据是否需要生成和校验值 + needSign = true - /** + /** * @param {Uint8Array|ArrayBuffer|number[]} content - * @param {number} responseSize - * @param {number} timeout + * @param {number} responseSize + * @param {number} timeout * @param {boolean} needSign */ - constructor(content, responseSize, timeout = 3000, needSign = true) { - if (content instanceof Uint8Array) { - this.content = content; - } else { - this.content = new Uint8Array(content); - } - this.responseSize = responseSize; - if (typeof timeout === 'number' && timeout >= 0) { - this.timeout = timeout; - } - this.needSign = needSign; + constructor(content, responseSize, timeout = 3000, needSign = true) { + if (content instanceof Uint8Array) { + this.content = content + } + else { + this.content = new Uint8Array(content) } - - /** + this.responseSize = responseSize + if (typeof timeout === 'number' && timeout >= 0) { + this.timeout = timeout + } + this.needSign = needSign + } + + /** * 返回一个 ArrayBuffer 数组, 用于发送 * @returns {ArrayBuffer[]} */ - get data() { - if (this.content.length === 0) throw new Error('正文内容不能为空'); - const data = []; - const b = new Uint8Array(this.content.buffer); - if (this.needSign) { - b[b.length - 1] = Command.getSign(b); - } - for (let i = 0; i < b.length; i += 20) { - data.push(b.slice(i, i + 20).buffer); - } - return data; + get data() { + if (this.content.length === 0) { throw new Error('正文内容不能为空') } + const data = [] + const b = new Uint8Array(this.content.buffer) + if (this.needSign) { + b[b.length - 1] = Command.getSign(b) } - - /** 是否接收完成 */ - get isComplete() { - return this.response.length >= this.responseSize; + for (let i = 0; i < b.length; i += 20) { + data.push(b.slice(i, i + 20).buffer) } + return data + } - /** 是否有效 */ - get isValid() { - return Command.getSign(this.response) === this.response[this.response.length - 1]; - } + /** 是否接收完成 */ + get isComplete() { + return this.response.length >= this.responseSize + } - /** + /** 是否有效 */ + get isValid() { + return Command.getSign(this.response) === this.response[this.response.length - 1] + } + + /** * 填充响应数组 - * @param {ArrayBuffer} buffer + * @param {ArrayBuffer} buffer */ - fillResponse(buffer) { - this.response = new Uint8Array([...this.response, ...(new Uint8Array(buffer))]); - } + fillResponse(buffer) { + this.response = new Uint8Array([...this.response, ...(new Uint8Array(buffer))]) + } - - /** + /** * 获取和校验值 - * @param {ArrayBuffer|Uint8Array} buffer + * @param {ArrayBuffer|Uint8Array} buffer */ - static getSign(buffer) { - const _b = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer); - let sum = 0; - _b.slice(0, _b.length - 1).forEach(i => sum += i); - return new Uint8Array([sum])[0]; - } + static getSign(buffer) { + const _b = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer) + let sum = 0 + _b.slice(0, _b.length - 1).forEach(i => sum += i) + return new Uint8Array([sum])[0] + } - // 唤醒命令 - static WakeUp = new Command([0xf0], 0, 0, false); + // 唤醒命令 + static WakeUp = new Command([0xF0], 0, 0, false) - /** + /** * 获取测量命令 - * @param {number} mode + * @param {number} mode */ - static measure(mode = 0) { - Command.measureId += 1; - const measureId = uint32ToUint8Array(Command.measureId); - return new Command([0xbb, 1, mode, ...measureId, 0, 0xff, 0], 10, 1500); - } + static measure(mode = 0) { + Command.measureId += 1 + const measureId = uint32ToUint8Array(Command.measureId) + return new Command([0xBB, 1, mode, ...measureId, 0, 0xFF, 0], 10, 1500) + } - /** + /** * 获取测量数据 (Lab) - * @param {number} mode + * @param {number} mode */ - static getLab(mode = 0) { - return new Command([0xbb, 3, mode, 0, 0, 0, 0, 0, 0xff, 0], 20, 1500); - } + static getLab(mode = 0) { + return new Command([0xBB, 3, mode, 0, 0, 0, 0, 0, 0xFF, 0], 20, 1500) + } - /** + /** * 获取测量数据 (RGB) - * @param {number} mode + * @param {number} mode */ - static getRGB(mode = 0) { - return new Command([0xbb, 4, mode, 0, 0, 0, 0, 0, 0xff, 0], 20, 1500); - } + static getRGB(mode = 0) { + return new Command([0xBB, 4, mode, 0, 0, 0, 0, 0, 0xFF, 0], 20, 1500) + } - /** + /** * 获取测量的光谱数据 * @param {number} mode */ - static getSpectral(mode = 0) { - return new Command([0xbb, 2, 0x10 + mode, 0, 0, 0 ,0 ,0, 0xff, 0], 200, 5000); - } + static getSpectral(mode = 0) { + return new Command([0xBB, 2, 0x10 + mode, 0, 0, 0, 0, 0, 0xFF, 0], 200, 5000) + } - /** + /** * 白校准 * @param {number} check 是否判断校准成功 1 判断 0 不判断 */ - static whiteCalibrate(check = 1) { - return new Command([0xbb, 0x11, check, 0, 0, 0, 0, 0, 0xff, 0], 10, 1500); - } + static whiteCalibrate(check = 1) { + return new Command([0xBB, 0x11, check, 0, 0, 0, 0, 0, 0xFF, 0], 10, 1500) + } - - /** + /** * 黑校准 * @param {number} check 是否判断校准成功 */ - static blackCalibrate(check = 1) { - return new Command([0xbb, 0x10, check, 0, 0, 0, 0, 0, 0xff, 0], 10, 1500); - } + static blackCalibrate(check = 1) { + return new Command([0xBB, 0x10, check, 0, 0, 0, 0, 0, 0xFF, 0], 10, 1500) + } + /** 获取校准状态 */ + static GetCalibrationInf = new Command([0xBB, 0x1E, 0, 0, 0, 0, 0, 0, 0xFF, 0], 20, 1500) - /** 获取校准状态 */ - static GetCalibrationInf = new Command([0xbb, 0x1e, 0, 0, 0, 0, 0, 0, 0xff, 0], 20, 1500); - - - - static GetDeviceInf = new Command([0xbb, 0x12, 0x01, 0, 0, 0, 0, 0, 0xff, 0], 200, 5000); -} \ No newline at end of file + static GetDeviceInf = new Command([0xBB, 0x12, 0x01, 0, 0, 0, 0, 0, 0xFF, 0], 200, 5000) +} diff --git a/src/common/bluetooth/utils.js b/src/common/bluetooth/utils.js index 9c4b018..d6b0ab2 100644 --- a/src/common/bluetooth/utils.js +++ b/src/common/bluetooth/utils.js @@ -1,70 +1,65 @@ /** * Uint32 转 Uint8 数组 - * @param {number} n + * @param {number} n */ export function uint32ToUint8Array(n) { - return new Uint8Array(new Uint32Array([n]).buffer); + return new Uint8Array(new Uint32Array([n]).buffer) } /** * Uint8 数组 转 Float32 - * @param {Uint8Array} raw + * @param {Uint8Array} raw */ export function uint8ArrayToFloat32(raw) { - return new Float32Array(raw.buffer)[0]; + return new Float32Array(raw.buffer)[0] } - /** * Uint8 数组 转 Uint16 - * @param {Uint8Array} raw + * @param {Uint8Array} raw */ export function uint8ArrayToUint16(raw) { - return new Uint16Array(raw.buffer)[0]; + return new Uint16Array(raw.buffer)[0] } - /** * Uint8 数组转 Uint32 - * @param {Uint8Array} raw - * @returns + * @param {Uint8Array} raw + * @returns */ export function uint8ArrayToUnit32(raw) { - return new Uint32Array(raw.buffer)[0]; + return new Uint32Array(raw.buffer)[0] } - /** * 等待指定时长 - * @param {number} duration + * @param {number} duration */ export function waitFor(duration) { - return new Promise(resolve => { - setTimeout(resolve, duration); - }); + return new Promise((resolve) => { + setTimeout(resolve, duration) + }) } - /** * uint8 数组转 hex 字符串 - * @param {Uint8Array} raw + * @param {Uint8Array} raw */ export function uint8ArrayToHex(raw) { - const s = []; - raw.forEach(i => { - const b = i.toString(16); - s.push(b.length > 1 ? b : `0${b}`); - }); - return s.join(' '); + const s = [] + raw.forEach((i) => { + const b = i.toString(16) + s.push(b.length > 1 ? b : `0${b}`) + }) + return s.join(' ') } - // 二进制转字符串(ascii) export function bufferToString(buffer) { - let str = ""; - for (let code of buffer) { - if (code === 0) break; - str += utf82string(code); - } - return str; -} \ No newline at end of file + let str = '' + for (const code of buffer) { + if (code === 0) { break } + str += utf82string(code) + } + return str +} diff --git a/src/common/common.ts b/src/common/common.ts index 4c57039..c9e63d2 100644 --- a/src/common/common.ts +++ b/src/common/common.ts @@ -8,7 +8,7 @@ import Qs from 'qs' * @param type false 跳转普通页面,true 跳转tabbar页面 */ type ParamLink = 'navigateTo' | 'switchTab' | 'reLaunch' | 'redirectTo' -export const goLink = (path: string = '', params: object | null = null, way: ParamLink = 'navigateTo') => { +export const goLink = (path = '', params: object | null = null, way: ParamLink = 'navigateTo') => { if (path) { // let params_str = Qs_.stringify(params || {}, { encode: false }) // path = params_str ? path + '?' + params_str : path @@ -18,17 +18,18 @@ export const goLink = (path: string = '', params: object | null = null, way: Par } const setUrlQuery = (options: { url: string; query: object | null }) => { let { url, query } = options - if (!url) return '' + if (!url) { return '' } if (query) { - let queryArr: any[] = [] + const queryArr: any[] = [] for (const key in query) { if (query.hasOwnProperty(key)) { queryArr.push(`${key}=${query[key]}`) } } - if (url.indexOf('?') !== -1) { + if (url.includes('?')) { url = `${url}&${queryArr.join('&')}` - } else { + } + else { url = `${url}?${queryArr.join('&')}` } } @@ -42,12 +43,15 @@ const setUrlQuery = (options: { url: string; query: object | null }) => { export const isEmptyObject = (object: any) => { if (object == undefined || object == null || Number.isNaN(object)) { return true - } else { + } + else { if (object.constructor == Object) { return Reflect.ownKeys(object).length == 0 - } else if (object.constructor == Array) { + } + else if (object.constructor == Array) { return object.length == 0 - } else if (object.constructor == String) { + } + else if (object.constructor == String) { return object == '' } } @@ -56,7 +60,7 @@ export const isEmptyObject = (object: any) => { /** * 表单检索 - * @param data + * @param data * @param rules = { account: [{ message: "请输入正确的用户名", @@ -70,25 +74,27 @@ export const isEmptyObject = (object: any) => { // regex: /\d/ }] }; - * @param message - * @returns + * @param message + * @returns */ -export const retrieval = (data: any, rules?: Object, message: string = '请填写完信息') => { +export const retrieval = (data: any, rules?: Object, message = '请填写完信息') => { return new Promise((resolve, reject) => { if (rules) { const keys = Reflect.ownKeys(rules) const result = keys.some((key: any) => { - for (let item of (rules as any)[key]) { + for (const item of (rules as any)[key]) { let _res = false if (item.validator) { if (item.validator(data[key], item)) { _res = true } - } else if (item.regex) { + } + else if (item.regex) { if (!item.regex.test(data[key])) { _res = true } - } else { + } + else { if (isEmptyObject(data[key])) { _res = true } @@ -100,7 +106,8 @@ export const retrieval = (data: any, rules?: Object, message: string = '请填 if (result) { reject(message) } - } else { + } + else { const keys = Reflect.ownKeys(data) if (keys.some((key: any) => isEmptyObject(data[key]))) { reject(message) diff --git a/src/common/constant.js b/src/common/constant.js index 092ab96..2e26ffb 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -18,27 +18,27 @@ export const BASE_URL = CURRENT_BASE_URL // CDN // 生成密钥 -export const GET_UPLOAD_SIGN = `/upyun/getsign` // 请求签名 url -export const UPLOAD_CDN_URL = `https://v0.api.upyun.com/` +export const GET_UPLOAD_SIGN = '/upyun/getsign' // 请求签名 url +export const UPLOAD_CDN_URL = 'https://v0.api.upyun.com/' // cdn export const IMG_CND_Prefix = CURRENT_ENV.includes('production') ? 'https://cdn.zzfzyc.com' : 'https://test.cdn.zzfzyc.com' // export const IMG_CND_Prefix = CURRENT_ENV.includes('production') ? 'https://cdn.zzfzyc.com' : 'https://cdn.zzfzyc.com' -//在线支付图片baseUrl +// 在线支付图片baseUrl export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_CAP_HTML_TO_IMAGE_BASE_URL // export const CAP_HTML_TO_IMAGE_BASE_URL = 'http://192.168.1.127:8081' // 上传图片视频 export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}` -//appid +// appid export const WX_APPID = 'wx68d92d7cbf0b6963' -//支付码单跳转链接 +// 支付码单跳转链接 export const PAY_H5_CODE_URL = CURRENT_PAY_H5_CODE_URL -//场景值 +// 场景值 export const SCENE = { - SearchScene: 0, //商城面料搜索 + SearchScene: 0, // 商城面料搜索 } diff --git a/src/common/enum.ts b/src/common/enum.ts index f9fc3a5..fbdca02 100644 --- a/src/common/enum.ts +++ b/src/common/enum.ts @@ -1,11 +1,11 @@ -//订单状态枚举 +// 订单状态枚举 export const ORDER_STATUS = { SaleorderstatusWaitingPrePayment: { value: 10, label: '预付款' }, // 预付款 SaleOrderStatusBooking: { value: 0, label: '待接单' }, // 待接单 SaleOrderStatusArranging: { value: 1, label: '配布中' }, // 配布中 SaleOrderStatusArranged: { value: 2, label: '已配布' }, // 已配布 SaleOrderStatusWaitingPayment: { value: 7, label: '待付款' }, // 待付款 - SaleOrderStatusTaking: { value: 11, label: '提货中' }, //提货中 + SaleOrderStatusTaking: { value: 11, label: '提货中' }, // 提货中 SaleOrderStatusWaitingDelivery: { value: 3, label: '待发货' }, // 待发货 SaleOrderStatusWaitingReceipt: { value: 8, label: '待收货' }, // 待收货 SaleOrderStatusAlreadyReceipt: { value: 9, label: '已收货' }, // 已收货 @@ -14,7 +14,7 @@ export const ORDER_STATUS = { SaleOrderStatusCancel: { value: 5, label: '已取消' }, // 已取消 } -//售后单状态枚举 +// 售后单状态枚举 export const AFTER_ORDER_STATUS = { ReturnStageApplying: { value: 0, label: '申请中' }, // 申请中 ReturnStageWaitCheck: { value: 1, label: '退货中' }, // 退货中 @@ -26,7 +26,7 @@ export const AFTER_ORDER_STATUS = { ReturnStageRejected: { value: 7, label: '已拒绝' }, // 已拒绝 } -//支付方式 +// 支付方式 export const PAYMENT_METHOD = { PaymentMethodPreDeposit: { value: 2, label: '预存款' }, PaymentMethodAccountPeriod: { value: 3, label: '账期' }, @@ -35,7 +35,7 @@ export const PAYMENT_METHOD = { PaymentMethodCashOnDelivery: { value: 5, label: '货到付款' }, } -//订单类型 +// 订单类型 export const SALE_MODE = { SaLeModeBulk: { value: 0, label: '大货' }, SaleModeLengthCut: { value: 1, label: '剪版' }, @@ -43,20 +43,20 @@ export const SALE_MODE = { } export type saleModeType = 0 | 1 | 2 -//分享场景枚举 +// 分享场景枚举 export const SHARE_SCENE = { ShareDetail: { value: 1, label: '详情分享' }, SharePage: { value: 2, label: '页面分享' }, } -//订阅消息 +// 订阅消息 export const SUBSCRIPTION_MESSAGE_SCENE = { SubmitOrder: { value: 1, label: '确认下单' }, ToPay: { value: 2, label: '去付款' }, ApplyGoods: { value: 3, label: '申请退款' }, } -//应收单退款状态枚举 +// 应收单退款状态枚举 export const REFUND_STATUS = { ShouldCollectOrderRefundTypeUnknown: { value: 0, label: '未知退款' }, ShouldCollectOrderRefundTypeAdvanceReceiptRefund: { value: 1, label: '预收退款' }, @@ -64,7 +64,7 @@ export const REFUND_STATUS = { ShouldCollectOrderRefundTypeSalesRefund: { value: 3, label: '销售退款' }, } -//申请单退款状态枚举 +// 申请单退款状态枚举 export const REFUND_STATUS_ORDER = { ReturnApplyOrderTypeAdvanceReceiptRefund: { value: 2, label: '预收退款' }, // 预收退款 ReturnApplyOrderTypeReturnForRefund: { value: 1, label: '退货退款' }, // 退货退款 diff --git a/src/common/fotmat.js b/src/common/fotmat.js index 7a1acf0..05ece51 100644 --- a/src/common/fotmat.js +++ b/src/common/fotmat.js @@ -20,7 +20,8 @@ export const formatRemoveHashTag = (val = '') => { export const formatHashTag = (code = '', name = '', mode = 'both') => { if (mode == 'both') { return `${formatRemoveHashTag(code)}# ${name}` - } else if (mode == 'name') { + } + else if (mode == 'name') { return `${name}` } } @@ -40,7 +41,7 @@ export const weightDigit = 1000 * @returns */ export const formatPriceDiv = (val, digit = Digit, priceStatus = false) => { - let res = strip(Number(val / digit)) || 0 + const res = strip(Number(val / digit)) || 0 return priceStatus ? numberWithCommas({ number: res }) : res } /** @@ -72,13 +73,13 @@ export const formatWeightDiv = (val, digit = weightDigit) => { export const formatDateTime = (val, fmt = 'YYYY-MM-DD HH:mm:ss') => { if (val) { - let time = new Date(val) - let Y = time.getFullYear() - let M = time.getMonth() + 1 - let d = time.getDate() - let h = time.getHours() - let m = time.getMinutes() - let s = time.getSeconds() + const time = new Date(val) + const Y = time.getFullYear() + const M = time.getMonth() + 1 + const d = time.getDate() + const h = time.getHours() + const m = time.getMinutes() + const s = time.getSeconds() fmt = fmt .replace('YYYY', Y) @@ -89,7 +90,8 @@ export const formatDateTime = (val, fmt = 'YYYY-MM-DD HH:mm:ss') => { .replace('ss', s.toString().padStart(2, '0')) return fmt - } else { + } + else { return val } } @@ -120,17 +122,18 @@ export const formatMillionYuan = (num, digit = 10000) => { * @returns */ export const toDecimal2 = (x) => { - var f = parseFloat(x) + let f = parseFloat(x) if (isNaN(f)) { return 0 } - f = f + '' - let index = f.lastIndexOf('.') + f = `${f}` + const index = f.lastIndexOf('.') if (index >= 0) { - let decimal = f.substring(index + 1) + const decimal = f.substring(index + 1) if (decimal.length == 1) { - f = f.substring(0, index + 1) + decimal + '0' - } else { + f = `${f.substring(0, index + 1) + decimal}0` + } + else { f = f.substring(0, index + 1) + decimal.substring(0, 2) } } @@ -146,8 +149,9 @@ export const toDecimal2 = (x) => { export const formatImgUrl = (url, suffix = '!w200') => { if (url) { return url.includes('http') ? url + suffix : IMG_CND_Prefix + url + suffix - } else { - return IMG_CND_Prefix + '/mall/no_img.png' + } + else { + return `${IMG_CND_Prefix}/mall/no_img.png` } } @@ -160,11 +164,13 @@ export const formatImgUrl = (url, suffix = '!w200') => { */ export const isLabImage = (imgurl, rgb, suffix = '!w200') => { if (imgurl) { - return { status: 1, value: IMG_CND_Prefix + '/' + imgurl + suffix } - } else if (rgb.r != 0 || rgb.g != 0 || rgb.b != 0) { + return { status: 1, value: `${IMG_CND_Prefix}/${imgurl}${suffix}` } + } + else if (rgb.r != 0 || rgb.g != 0 || rgb.b != 0) { return { status: 2, value: rgb } - } else { - return { status: 3, value: IMG_CND_Prefix + '/mall/no_img.png' } + } + else { + return { status: 3, value: `${IMG_CND_Prefix}/mall/no_img.png` } } } @@ -177,7 +183,8 @@ export const numberWithCommas = ({ number = 0, digit = 2 }) => { if (!isNaN(Number(number))) { // return parseFloat(number).toFixed(digit).replace(/^\B(? { - //解析短码 - Taro.request({ - url:BASE_URL+'/v1/mall/shortCode', - method:"GET", - data:{md5_key: val}, - success:(res) => { - if(res.data.code == 0) { - //绑定上下级 - bindParent(res.data.data.share_user_id) - } - } - }) + // 解析短码 + Taro.request({ + url: `${BASE_URL}/v1/mall/shortCode`, + method: 'GET', + data: { md5_key: val }, + success: (res) => { + if (res.data.code == 0) { + // 绑定上下级 + bindParent(res.data.data.share_user_id) + } + }, + }) } -//绑定上下级 +// 绑定上下级 const bindParent = (share_user_id) => { - //绑定上下级 - Taro.request({ - url:BASE_URL+'/v1/mall/shortCode/bind', - method:"POST", - data:{share_user_id: share_user_id}, - success:(res) => { - if(res.data.code == 0) { - //绑定上下级 - } + // 绑定上下级 + Taro.request({ + url: `${BASE_URL}/v1/mall/shortCode/bind`, + method: 'POST', + data: { share_user_id }, + success: (res) => { + if (res.data.code == 0) { + // 绑定上下级 } - }) - } \ No newline at end of file + }, + }) +} diff --git a/src/common/system.ts b/src/common/system.ts index 1d99ae5..b87ef79 100644 --- a/src/common/system.ts +++ b/src/common/system.ts @@ -1,9 +1,8 @@ -import Taro from "@tarojs/taro"; - +import Taro from '@tarojs/taro' /** * 设置 系统 本地存储 - * @param {Object} systemInfo + * @param {Object} systemInfo */ export const setSystem = (systemInfo) => { Taro.setStorageSync('system', JSON.stringify(systemInfo)) @@ -19,7 +18,7 @@ export const getSystem = () => { /** * 设置 小程序 本地存储 - * @param {Object} systemInfo + * @param {Object} systemInfo */ export const setAccountInfo = (systemInfo) => { Taro.setStorageSync('accountInfo', JSON.stringify(systemInfo)) @@ -35,9 +34,9 @@ export const getAccountInfo = () => { /** * 设置 参数本地存储 - * @param {Object} info + * @param {Object} info */ -export const setParam = (info:Object) => { +export const setParam = (info: Object) => { Taro.setStorageSync('params', JSON.stringify(info)) } @@ -46,5 +45,5 @@ export const setParam = (info:Object) => { */ export const getParam = () => { const res = Taro.getStorageSync('params') || null - return res?JSON.parse(res):null + return res ? JSON.parse(res) : null } diff --git a/src/common/util.ts b/src/common/util.ts index 34e1f88..6e3ba73 100644 --- a/src/common/util.ts +++ b/src/common/util.ts @@ -1,6 +1,6 @@ +import Taro from '@tarojs/taro' import { formatImgUrl } from './fotmat' import { analysisShortCodeApi } from './shortCode' -import Taro from '@tarojs/taro' /** * 防抖 @@ -11,7 +11,7 @@ import Taro from '@tarojs/taro' export const debounce = (fn, delay) => { let timer: any = null return (...param) => { - if (timer) clearTimeout(timer) + if (timer) { clearTimeout(timer) } timer = setTimeout(() => { fn(...param) }, delay) @@ -27,7 +27,7 @@ export const debounce = (fn, delay) => { export const throttle = (fn, delay) => { let pre = 0 return (...params) => { - let now = new Date().getTime() + const now = new Date().getTime() if (now - pre > delay) { fn(...params) pre = now @@ -42,14 +42,15 @@ export const throttle = (fn, delay) => { * @returns */ export const getFilterData = (val = {}, arr: string[] = []) => { - let res = {} - for (let key in val) { + const res = {} + for (const key in val) { if (val[key] !== undefined && val[key] !== null && val[key] !== '' && !arr.includes(key)) { if (typeof val[key] == 'number') { if (!isNaN(val[key])) { res[key] = val[key] } - } else { + } + else { res[key] = val[key] } } @@ -63,24 +64,26 @@ export const getFilterData = (val = {}, arr: string[] = []) => { */ export const copyObject = (object) => { if (object.constructor == Object) { - let keys = Object.keys(object) - let newObject = {} + const keys = Object.keys(object) + const newObject = {} keys.map((key) => { newObject[key] = copyObject(object[key]) }) return newObject - } else if (object.constructor == Array) { + } + else if (object.constructor == Array) { return object.map((item) => { return copyObject(item) }) - } else { + } + else { return object } } /** - * - * @param {*} suffix + * + * @param {*} suffix * !w80 !w100 !w160 @@ -94,23 +97,26 @@ export const screenshot = (url, suffix = '!w200') => { return url + suffix } -//获取数据加载状态 //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据 +// 获取数据加载状态 //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据 export const dataLoadingStatus = ({ list = [], total = 0, status = false }: { list: any[]; total: number; status: true | false }) => { if (list.length == 0 && status) { return 0 - } else if (list.length == 0 && !status) { + } + else if (list.length == 0 && !status) { return 1 - } else if (list.length < total) { + } + else if (list.length < total) { return 2 - } else { + } + else { return 3 } } -//全局分享监听 +// 全局分享监听 export const shareShop = () => { const page = Taro.getCurrentInstance().page - //当有分享参数时,绑定上下级 + // 当有分享参数时,绑定上下级 if (page && page.options?.share) { analysisShortCodeApi(page.options.share) } @@ -119,16 +125,17 @@ export const shareShop = () => { let path = '' let title = '' let imageUrl = '' - let sortCode = Taro.getStorageSync('sort_code') ? JSON.parse(Taro.getStorageSync('sort_code')) : '' - let pageInfo: any = page - //商品详情分享 + const sortCode = Taro.getStorageSync('sort_code') ? JSON.parse(Taro.getStorageSync('sort_code')) : '' + const pageInfo: any = page + // 商品详情分享 if (pageInfo.route === 'pages/details/index') { path = `/pages/details/index?share=${sortCode.shareShortDetail.code}` title = sortCode.shareShortDetail.title imageUrl = sortCode.shareShortDetail.img - } else { - path = - pageInfo.route === 'pages/user/index' + } + else { + path + = pageInfo.route === 'pages/user/index' ? `/pages/user/index?share=${sortCode.shareShortPage.code}` : `/pages/index/index?share=${sortCode.shareShortPage.code}` title = sortCode.shareShortPage.title diff --git a/src/components/AddressList/index.tsx b/src/components/AddressList/index.tsx index 7f71e93..e060cb6 100644 --- a/src/components/AddressList/index.tsx +++ b/src/components/AddressList/index.tsx @@ -1,80 +1,82 @@ -import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components" -import { memo, useEffect, useState } from "react" -import "./index.scss" -import {addressListApi,addressDeleteApi} from "@/api/addressManager" -import { alert } from "@/common/common" -import Taro, { showModal } from "@tarojs/taro" +import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components' +import { memo, useEffect, useState } from 'react' +import './index.scss' +import { addressDeleteApi, addressListApi } from '@/api/addressManager' +import { alert } from '@/common/common' +import Taro, { showModal } from '@tarojs/taro' interface Params{ - refresherEnabled?: boolean,//是否开启刷新 - onSelect?: (item:any,index:number)=>void,//列表选择 - addButtonEnabled?: boolean, //是否显示添加按钮 - focusBorderEnabled?: boolean, //焦点显示蓝色边框 - id?: number, //默认选择值 + refresherEnabled?: boolean// 是否开启刷新 + onSelect?: (item: any, index: number) => void// 列表选择 + addButtonEnabled?: boolean // 是否显示添加按钮 + focusBorderEnabled?: boolean // 焦点显示蓝色边框 + id?: number // 默认选择值 } // 地址列表 -const AddressList = memo((props:Params)=>{ - const {addButtonEnabled=true,focusBorderEnabled=false} = props; - const {fetchData, state} = addressListApi() +const AddressList = memo((props: Params) => { + const { addButtonEnabled = true, focusBorderEnabled = false } = props + const { fetchData, state } = addressListApi() // 获取数据 - const getData = async ()=>{ - const result = await fetchData(); - if(props.id){ - setFocusId(props.id as any); - }else{ - result.data.list?.every(item=>{ - if(item.is_default){ - setFocusId(item.id); - return false; + const getData = async() => { + const result = await fetchData() + if (props.id) { + setFocusId(props.id as any) + } + else { + result.data.list?.every((item) => { + if (item.is_default) { + setFocusId(item.id) + return false } - return true; + return true }) } } - useEffect(()=>{ - getData(); + useEffect(() => { + getData() // 监听刷新 - Taro.eventCenter.on("addressList:refresh", getData); - return ()=>{ - Taro.eventCenter.off("addressList:refresh", getData); + Taro.eventCenter.on('addressList:refresh', getData) + return () => { + Taro.eventCenter.off('addressList:refresh', getData) } - },[]) + }, []) // 处理刷新 - const [refreshState, setRefreshState] = useState(false); - const handleRefresh = async ()=>{ - setRefreshState(true); - await getData(); - setRefreshState(false); + const [refreshState, setRefreshState] = useState(false) + const handleRefresh = async() => { + setRefreshState(true) + await getData() + setRefreshState(false) } - const data = Array.from({length:15}); + const data = Array.from({ length: 15 }) // 焦点 - const [focusId, setFocusId] = useState(); + const [focusId, setFocusId] = useState() // 列表选择 - const handleSelect = (item: any, index: number)=>{ - props.onSelect&&props.onSelect(item,index); - if(focusBorderEnabled){ - setFocusId(item?.id); + const handleSelect = (item: any, index: number) => { + props.onSelect && props.onSelect(item, index) + if (focusBorderEnabled) { + setFocusId(item?.id) } } // 删除地址 - const {fetchData: deleteFetch} = addressDeleteApi() - const handleDelete = (item:any)=>{ + const { fetchData: deleteFetch } = addressDeleteApi() + const handleDelete = (item: any) => { showModal(({ - title: "提示", - content: "是否删除地址?", - async success(ev){ - if(ev.confirm){ - const result = await deleteFetch({id:item.id}); - if(result.success){ - alert.success("删除成功"); - getData(); - }else{ - alert.success(result.msg); + title: '提示', + content: '是否删除地址?', + async success(ev) { + if (ev.confirm) { + const result = await deleteFetch({ id: item.id }) + if (result.success) { + alert.success('删除成功') + getData() + } + else { + alert.success(result.msg) } } - } + }, })) } @@ -83,42 +85,43 @@ const AddressList = memo((props:Params)=>{ { - state?.data?.list?.length>0? - state?.data?.list?.map((item,index)=>{ - // data.length>0? - // data.map((item,index)=>{ - return( - handleDelete(item)} onClick={()=>handleSelect(item,index)} className={`address-list ${focusId==item.id&&'address-active'}`}> - - {item.name} - { - item.is_default?默认: - {item.phone.replace(item.phone.substring(3,7), "****")} - } - - - - {item.province_name+item.city_name+item.district_name} - {/* {item.address_detail} */} - + state?.data?.list?.length > 0 + ? state?.data?.list?.map((item, index) => { + // data.length>0? + // data.map((item,index)=>{ + return ( + handleDelete(item)} onClick={() => handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}> + + {item.name} { - item.is_default&&{item.phone.replace(item.phone.substring(3,7), "****")} + item.is_default + ? 默认 + : {item.phone.replace(item.phone.substring(3, 7), '****')} } - e.stopPropagation()} url={`/pages/addressAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="address-edit"> - - + + + {item.province_name + item.city_name + item.district_name} + {/* {item.address_detail} */} + + { + item.is_default && {item.phone.replace(item.phone.substring(3, 7), '****')} + } + + e.stopPropagation()} url={`/pages/addressAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="address-edit"> + + + - - ); - }): - 暂未添加地址 + ) + }) + : 暂未添加地址 } - {addButtonEnabled&&添加收货地址} + {addButtonEnabled && 添加收货地址} ) }) -export default AddressList; \ No newline at end of file +export default AddressList diff --git a/src/components/FromList/index.tsx b/src/components/FromList/index.tsx index 156391f..ee4839d 100644 --- a/src/components/FromList/index.tsx +++ b/src/components/FromList/index.tsx @@ -3,15 +3,15 @@ import { memo } from 'react' import './index.scss' interface ListParams { - label: string //左边label + label: string // 左边label onInput?: (ev: Object) => void // 输入框输入 - onClick?: () => any //点击列表 + onClick?: () => any // 点击列表 placeholder?: string // 提示文本 children?: any // 插槽 type?: string // 类型:1.input,2.textarea,3.select, primordialType?: 'text' | 'number' | 'idcard' | 'digit' value?: any - style?: object //整行样式 + style?: object // 整行样式 labelStyle?: object // label样式 contentStyle?: object required?: boolean @@ -22,40 +22,44 @@ const FromList = memo((props: ListParams) => { const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props return ( - + {props.label} - + {props.children ?? ( - - {type == 'input' ? ( - - - {value && ( - - props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' /> - - )} - - ) : type == 'textarea' ? ( - + || toggleShowRealTextarea(true)}>{descData.value || placeholder} } - setDescData({...descData, number:res.length, value: res}) - onChange?.(res) - } - - useEffect(() => { - getDesc(defaultValue) - }, [defaultValue]) - - const toggleShowRealTextarea = (show) => { - setDescData({...descData, show:show}) - } - return ( - - {title} - - {(descData.show && !onlyRead)&&|| - toggleShowRealTextarea(true)}>{descData.value||placeholder} - } - {descData.number +'/'+ descData.count} - - - ) + {`${descData.number}/${descData.count}`} + + + ) }) diff --git a/src/components/uploadImage/index.tsx b/src/components/uploadImage/index.tsx index f427e02..ebd820a 100644 --- a/src/components/uploadImage/index.tsx +++ b/src/components/uploadImage/index.tsx @@ -1,13 +1,13 @@ -import Taro, { FC } from '@tarojs/taro' -import { memo, useEffect, useState } from 'react' -import useUploadCDNImg from '@/use/useUploadImage' +import Taro from '@tarojs/taro' import { Image, Text, View } from '@tarojs/components' -import { formatImgUrl } from '@/common/fotmat' +import { FC, memo, useEffect, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' +import useUploadCDNImg from '@/use/useUploadImage' +import { formatImgUrl } from '@/common/fotmat' -//图片列表 -type ImageParam = { +// 图片列表 +interface ImageParam { onChange?: (val: string[]) => void defaultList?: string[] onlyRead?: false | true @@ -20,28 +20,28 @@ const PictureItem: FC = memo(({ onChange, defaultList, onlyRead = fa setImageLise(defaultList || []) }, [defaultList]) - //上传图片 - const uploadImage = async () => { - let list: any = await getWxPhoto('after-sale', 5) - let images: any[] = [] + // 上传图片 + const uploadImage = async() => { + const list: any = await getWxPhoto('after-sale', 5) + const images: any[] = [] list?.map((item) => { images.push(item.url) }) setImageLise([...imageList, ...images]) } - //删除图片 + // 删除图片 const delImage = (index) => { imageList.splice(index, 1) setImageLise(() => [...imageList]) } - //监听上传的图片变化 + // 监听上传的图片变化 useEffect(() => { onChange?.(imageList) }, [imageList]) - //预览图片 + // 预览图片 const showImage = () => { - let list = imageList?.map((item) => { + const list = imageList?.map((item) => { return formatImgUrl(item, '!w800') }) Taro.previewImage({ @@ -54,7 +54,7 @@ const PictureItem: FC = memo(({ onChange, defaultList, onlyRead = fa {imageList?.map((item, index) => ( - + {!onlyRead && delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}>} ))} diff --git a/src/constants/common.ts b/src/constants/common.ts index d14b9fd..798d6c6 100644 --- a/src/constants/common.ts +++ b/src/constants/common.ts @@ -1,3 +1,3 @@ export const SET_SHOPCOUNT = 'set_shopCount' export const CLEAR_SHOPCOUNT = 'clear_shopCount' -export const STORAGE_SHOPCOUNT = 'storage_shopcount' \ No newline at end of file +export const STORAGE_SHOPCOUNT = 'storage_shopcount' diff --git a/src/constants/userInfo.ts b/src/constants/userInfo.ts index 14f529a..4ec186b 100644 --- a/src/constants/userInfo.ts +++ b/src/constants/userInfo.ts @@ -8,4 +8,4 @@ export const CLEAR_SESSIONKEY = 'clearSessionkey' export const CLEAR_USERINFO = 'clearUserInfo' export const CLEAR_ADMINUSERINFO = 'clearAdminUserInfo' export const CLEAR_SORTCODE = 'clearSortCode' -export const LOGIN_STATUS = 'loginStatus' \ No newline at end of file +export const LOGIN_STATUS = 'loginStatus' diff --git a/src/pages/addressAdd/index.tsx b/src/pages/addressAdd/index.tsx index 360b277..19be3ca 100644 --- a/src/pages/addressAdd/index.tsx +++ b/src/pages/addressAdd/index.tsx @@ -1,9 +1,9 @@ -import { alert, retrieval } from '@/common/common' -import Address from '@/components/address' -import FromList from '@/components/FromList' import { Button, Input, Text, Textarea, View } from '@tarojs/components' import Taro, { setNavigationBarTitle, useRouter } from '@tarojs/taro' import { useEffect, useState } from 'react' +import { alert, retrieval } from '@/common/common' +import Address from '@/components/address' +import FromList from '@/components/FromList' import './index.scss' import { addressAddApi, addressDetailApi, addressEditApi } from '@/api/addressManager' import useLogin from '@/use/useLogin' @@ -15,14 +15,15 @@ export default () => { useEffect(() => { if (type == 'add') { setNavigationBarTitle({ title: '新增收货地址' }) - } else { + } + else { initalFormData() setNavigationBarTitle({ title: '编辑收货地址' }) } }, []) // 获取编辑地址信息 const { fetchData: getFromData } = addressDetailApi() - const initalFormData = async () => { + const initalFormData = async() => { const detail = await getFromData({ id }) const { province_id, province_name, city_id, city_name, district_id, district_name } = detail.data const siteArray = [{ id: province_id, name: province_name }] @@ -31,7 +32,7 @@ export default () => { setFormData({ name: detail.data.name, phone: detail.data.phone, - site: siteArray.map((item) => item.name).join(' '), + site: siteArray.map(item => item.name).join(' '), siteArray: siteArray as any, district_id: detail.data.district_id, address_detail: detail.data.address_detail, @@ -81,29 +82,30 @@ export default () => { } const handleSave = () => { retrieval(formData, rules) - .then(async () => { - const result = - type == 'add' + .then(async() => { + const result + = type == 'add' ? await fetchData({ - name: formData.name, - phone: formData.phone, - district_id: formData.district_id, - address_detail: formData.address_detail, - is_default: formData.is_default, - }) + name: formData.name, + phone: formData.phone, + district_id: formData.district_id, + address_detail: formData.address_detail, + is_default: formData.is_default, + }) : await editFetch({ - name: formData.name, - phone: formData.phone, - district_id: formData.district_id, - address_detail: formData.address_detail, - is_default: formData.is_default, - id: formData.id, - }) + name: formData.name, + phone: formData.phone, + district_id: formData.district_id, + address_detail: formData.address_detail, + is_default: formData.is_default, + id: formData.id, + }) if (result.success) { Taro.eventCenter.trigger('addressList:refresh') Taro.navigateBack() alert.success('保存成功') - } else { + } + else { alert.error(result.msg) } }) @@ -126,51 +128,54 @@ export default () => { setFormData({ ...formData, siteArray: ev, - site: ev.map((item) => item.name + ' '), + site: ev.map(item => `${item.name} `), district_id: ev[ev.length - 1]?.id, }) - } else { + } + else { alert.error('请选择地址') } } return ( - + setFormData({ ...formData, name: ev.detail.value })} - value={formData['name']} - label='联系人' - placeholder='请输入收货人姓名' + value={formData.name} + label="联系人" + placeholder="请输入收货人姓名" /> setFormData({ ...formData, phone: ev.detail.value })} - value={formData['phone']} - label='联系方式' - placeholder='请输入联系方式' + value={formData.phone} + label="联系方式" + placeholder="请输入联系方式" /> - setShowSiteModal(true)} label='收货地址' type='select' placeholder='请选择/省/市/区' /> + setShowSiteModal(true)} label="收货地址" type="select" placeholder="请选择/省/市/区" /> setFormData({ ...formData, address_detail: ev.detail.value })} - value={formData['address_detail']} - label='详细地址' - type='textarea' - placeholder='请输入详细地址(街道、门牌号等)' + value={formData.address_detail} + label="详细地址" + type="textarea" + placeholder="请输入详细地址(街道、门牌号等)" /> - + 设为默认地址 setFormData({ ...formData, is_default: !formData.is_default })}> - {formData.is_default ? ( - - - - ) : ( - - )} + {formData.is_default + ? ( + + + + ) + : ( + + )} -
setShowSiteModal(false)} show={showSiteModal} /> diff --git a/src/pages/addressManager/index.tsx b/src/pages/addressManager/index.tsx index 427553e..0d32548 100644 --- a/src/pages/addressManager/index.tsx +++ b/src/pages/addressManager/index.tsx @@ -1,16 +1,16 @@ -import AddressList from "@/components/AddressList" -import useLogin from "@/use/useLogin" -import { Button, ScrollView, Text, View } from "@tarojs/components" -import { stopPullDownRefresh, usePullDownRefresh } from "@tarojs/taro" -import { useState } from "react" -import "./index.scss" +import { Button, ScrollView, Text, View } from '@tarojs/components' +import { stopPullDownRefresh, usePullDownRefresh } from '@tarojs/taro' +import { useState } from 'react' +import useLogin from '@/use/useLogin' +import AddressList from '@/components/AddressList' +import './index.scss' -export default ()=>{ +export default () => { useLogin() return ( - + ) -} \ No newline at end of file +} diff --git a/src/pages/applyAfterSales/components/cutKindList/index.tsx b/src/pages/applyAfterSales/components/cutKindList/index.tsx index aea397b..b97cf66 100644 --- a/src/pages/applyAfterSales/components/cutKindList/index.tsx +++ b/src/pages/applyAfterSales/components/cutKindList/index.tsx @@ -1,56 +1,56 @@ -import { formatHashTag, formatImgUrl } from "@/common/fotmat"; -import Counter from "@/components/counter"; -import MCheckbox from "@/components/checkbox"; -import { Image, Text, View } from "@tarojs/components"; -import { FC, memo, useCallback } from "react"; -import styles from './index.module.scss' +import { Image, Text, View } from '@tarojs/components' +import type { FC } from 'react' +import { memo, useCallback } from 'react' +import styles from './index.module.scss' +import { formatHashTag, formatImgUrl } from '@/common/fotmat' +import Counter from '@/components/counter' +import MCheckbox from '@/components/checkbox' -type OrderParam = { - list?: any[], - sale_mode?: number, - sale_mode_name?: string, - unit?: string, - total_colors?: number, - total_fabrics?: number, - total_number?: number, - status?: number, //订单状态 - av_return_product?: any[] //申请售后列表 +interface OrderParam { + list?: any[] + sale_mode?: number + sale_mode_name?: string + unit?: string + total_colors?: number + total_fabrics?: number + total_number?: number + status?: number // 订单状态 + av_return_product?: any[] // 申请售后列表 } -type Param = { - order: OrderParam, - onSelectChange?: (val: {color_id:number, length: number, status: true|false, sale_order_detail_id:number}) => void +interface Param { + order: OrderParam + onSelectChange?: (val: { color_id: number; length: number; status: true|false; sale_order_detail_id: number }) => void } -const kindeList:FC = memo(({order, onSelectChange}) => { +const kindeList: FC = memo(({ order, onSelectChange }) => { + // checkbox选中回调 + const selectCallBack = (colorItem) => { + onSelectChange?.({ color_id: colorItem.product_color_id, length: colorItem.length, sale_order_detail_id: colorItem.sale_order_detail_id, status: true }) + } - //checkbox选中回调 - const selectCallBack = (colorItem) => { - onSelectChange?.({color_id:colorItem.product_color_id, length:colorItem.length, sale_order_detail_id:colorItem.sale_order_detail_id, status: true}) - } + // checkbox关闭回调 + const colseCallBack = (colorItem) => { + onSelectChange?.({ color_id: colorItem.product_color_id, length: colorItem.length, status: false, sale_order_detail_id: colorItem.sale_order_detail_id }) + } - //checkbox关闭回调 - const colseCallBack = (colorItem) => { - onSelectChange?.({color_id:colorItem.product_color_id, length:colorItem.length, status: false, sale_order_detail_id:colorItem.sale_order_detail_id,}) - } - - return ( - - {order?.av_return_product?.map(item => - - {order.sale_mode_name} - {formatHashTag(item.product_code, item.product_name)} - - - {item?.av_product_color?.map(colorItem => - - {colorItem.product_color_code + ' ' + colorItem.product_color_name}x {colorItem.length/100} m - selectCallBack(colorItem)} onClose={() => colseCallBack(colorItem)}/> - )} - - )} + return ( + + {order?.av_return_product?.map(item => + + {order.sale_mode_name} + {formatHashTag(item.product_code, item.product_name)} - ) + + {item?.av_product_color?.map(colorItem => + + {`${colorItem.product_color_code} ${colorItem.product_color_name}`}x {colorItem.length / 100} m + selectCallBack(colorItem)} onClose={() => colseCallBack(colorItem)} /> + )} + + )} + + ) }) -export default kindeList \ No newline at end of file +export default kindeList diff --git a/src/pages/applyAfterSales/components/kindList/index.tsx b/src/pages/applyAfterSales/components/kindList/index.tsx index c5cecd2..85b7d98 100644 --- a/src/pages/applyAfterSales/components/kindList/index.tsx +++ b/src/pages/applyAfterSales/components/kindList/index.tsx @@ -1,55 +1,55 @@ -import { formatHashTag, formatImgUrl } from "@/common/fotmat"; -import Counter from "@/components/counter"; -import MCheckbox from "@/components/checkbox"; -import { Image, Text, View } from "@tarojs/components"; -import { FC, memo, useCallback } from "react"; -import styles from './index.module.scss' +import { Image, Text, View } from '@tarojs/components' +import type { FC } from 'react' +import { memo, useCallback } from 'react' +import styles from './index.module.scss' +import { formatHashTag, formatImgUrl } from '@/common/fotmat' +import Counter from '@/components/counter' +import MCheckbox from '@/components/checkbox' -type OrderParam = { - list?: any[], - sale_mode?: number, - sale_mode_name?: string, - unit?: string, - total_colors?: number, - total_fabrics?: number, - total_number?: number, - status?: number, //订单状态 - av_return_product?: any[] //申请售后列表 +interface OrderParam { + list?: any[] + sale_mode?: number + sale_mode_name?: string + unit?: string + total_colors?: number + total_fabrics?: number + total_number?: number + status?: number // 订单状态 + av_return_product?: any[] // 申请售后列表 } -type Param = { - order: OrderParam, - onNumChange?: (val:any) => void +interface Param { + order: OrderParam + onNumChange?: (val: any) => void } -const kindeList:FC = memo(({order, onNumChange}) => { +const kindeList: FC = memo(({ order, onNumChange }) => { + // 计步器返回值 + const getCounterChange = useCallback((colorItem) => { + return (number) => { + onNumChange?.({ number, color_id: colorItem.product_color_id, sale_order_detail_id: colorItem.sale_order_detail_id }) + } + }, [order]) - //计步器返回值 - const getCounterChange = useCallback((colorItem) => { - return (number) => { - onNumChange?.({number, color_id: colorItem.product_color_id, sale_order_detail_id:colorItem.sale_order_detail_id}) - } - }, [order]) - - return ( - - {order?.av_return_product?.map(item => - - {order.sale_mode_name} - {formatHashTag(item.product_code, item.product_name)} - - - {item?.av_product_color?.map(colorItem => - - {colorItem.product_color_code + ' ' + colorItem.product_color_name}x {colorItem.roll} - - - - )} - - )} + return ( + + {order?.av_return_product?.map(item => + + {order.sale_mode_name} + {formatHashTag(item.product_code, item.product_name)} - ) + + {item?.av_product_color?.map(colorItem => + + {`${colorItem.product_color_code} ${colorItem.product_color_name}`}x {colorItem.roll} + + + + )} + + )} + + ) }) -export default kindeList \ No newline at end of file +export default kindeList diff --git a/src/pages/applyAfterSales/components/otherReason/index.tsx b/src/pages/applyAfterSales/components/otherReason/index.tsx index 5059f75..0f48e08 100644 --- a/src/pages/applyAfterSales/components/otherReason/index.tsx +++ b/src/pages/applyAfterSales/components/otherReason/index.tsx @@ -1,41 +1,41 @@ -import {Textarea, View } from "@tarojs/components"; -import { memo, useMemo, useState } from "react"; -import styles from './index.module.scss' -import classnames from "classnames"; +import { Textarea, View } from '@tarojs/components' +import { memo, useMemo, useState } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' -//其他说明 -type Param = { - onChange: (val: string) => void +// 其他说明 +interface Param { + onChange: (val: string) => void } -export default memo(({onChange}:Param) => { - const [descData, setDescData] = useState({ - number: 0, - value: '', - count: 200, - show: false - }) - const getDesc = (e) => { - let value = e.detail.value - let res = value - if(value.length > descData.count) { - res = value.slice(0, descData.count) - } - setDescData({...descData, number:res.length, value: res}) - onChange?.(res) +export default memo(({ onChange }: Param) => { + const [descData, setDescData] = useState({ + number: 0, + value: '', + count: 200, + show: false, + }) + const getDesc = (e) => { + const value = e.detail.value + let res = value + if (value.length > descData.count) { + res = value.slice(0, descData.count) } + setDescData({ ...descData, number: res.length, value: res }) + onChange?.(res) + } - const toggleShowRealTextarea = (show) => { - setDescData({...descData, show:show}) - } - return ( - - 其他说明 - - {descData.show&&|| - toggleShowRealTextarea(true)}>{descData.value||'一般情况下选填,当退货说明=“其它问题”时,必填'} - } - {descData.number +'/'+ descData.count} - - - ) + const toggleShowRealTextarea = (show) => { + setDescData({ ...descData, show }) + } + return ( + + 其他说明 + + {descData.show && + || toggleShowRealTextarea(true)}>{descData.value || '一般情况下选填,当退货说明=“其它问题”时,必填'} + } + {`${descData.number}/${descData.count}`} + + + ) }) diff --git a/src/pages/applyAfterSales/components/reasonPopup/index copy 2.tsx b/src/pages/applyAfterSales/components/reasonPopup/index copy 2.tsx index 1cecb2a..71dda5b 100644 --- a/src/pages/applyAfterSales/components/reasonPopup/index copy 2.tsx +++ b/src/pages/applyAfterSales/components/reasonPopup/index copy 2.tsx @@ -1,44 +1,44 @@ -import Popup from "@/components/popup"; -import { ScrollView, Text, View } from "@tarojs/components"; -import { memo, useEffect, useMemo, useState } from "react"; -import classnames from "classnames"; -import styles from './index.module.scss' +import { ScrollView, Text, View } from '@tarojs/components' +import { memo, useEffect, useMemo, useState } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import Popup from '@/components/popup' -//原因选择 -type Param = {id:number, name:string, typle?:number} -type ReasonInfoParam = { - show?: boolean, //显示 - onClose?: () => void, //关闭 - title?: string, //标题 - list?: {id:number, name:string, typle?:number, children?:Param[]}[], //数据列表 - onSelect?: (val: object) => void, //选择 - defaultValue?: number, //默认选中 +// 原因选择 +interface Param { id: number; name: string; typle?: number } +interface ReasonInfoParam { + show?: boolean // 显示 + onClose?: () => void // 关闭 + title?: string // 标题 + list?: { id: number; name: string; typle?: number; children?: Param[] }[] // 数据列表 + onSelect?: (val: object) => void // 选择 + defaultValue?: number // 默认选中 } -export default memo(({show = false, onClose, title = '', list = [], onSelect, defaultValue}: ReasonInfoParam) => { - const [hasNextData, setHasNextData] = useState(true) //是否有下一级数据 - const [selectData, setSelectData] = useState() - const [headerList, setHeaderList] = useState<{id: number, name: string}[]>([]) - const onSelectData = (item) => { - setHeaderList((e) => [...e, {id:item.id, name:item.name}]) - } - useEffect(() => { - console.log('headerList::', headerList) - }, [headerList]) - return ( - - - - {headerList.map(item => { - return {item.name} - })} - {hasNextData&&请选择} - - - - {list.map(item => onSelectData(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name} )} - - - - - ) -}) \ No newline at end of file +export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => { + const [hasNextData, setHasNextData] = useState(true) // 是否有下一级数据 + const [selectData, setSelectData] = useState() + const [headerList, setHeaderList] = useState<{ id: number; name: string }[]>([]) + const onSelectData = (item) => { + setHeaderList(e => [...e, { id: item.id, name: item.name }]) + } + useEffect(() => { + console.log('headerList::', headerList) + }, [headerList]) + return ( + + + + {headerList.map((item) => { + return {item.name} + })} + {hasNextData && 请选择} + + + + {list.map(item => onSelectData(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue && styles.select_item)}>{item.name})} + + + + + ) +}) diff --git a/src/pages/applyAfterSales/components/reasonPopup/index copy.tsx b/src/pages/applyAfterSales/components/reasonPopup/index copy.tsx index 0ed990c..26d2b8f 100644 --- a/src/pages/applyAfterSales/components/reasonPopup/index copy.tsx +++ b/src/pages/applyAfterSales/components/reasonPopup/index copy.tsx @@ -1,30 +1,29 @@ -import Popup from "@/components/popup"; -import { ScrollView, Text, View } from "@tarojs/components"; -import { memo, useMemo } from "react"; -import classnames from "classnames"; -import styles from './index.module.scss' +import { ScrollView, Text, View } from '@tarojs/components' +import { memo, useMemo } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import Popup from '@/components/popup' -//原因选择 -type ReasonInfoParam = { - show?: boolean, //显示 - onClose?: () => void, //关闭 - title?: string, //标题 - list?: {id:number, name:string, typle?:number}[], //数据列表 - onSelect?: (val: object) => void, //选择 - defaultValue?: number, //默认选中 +// 原因选择 +interface ReasonInfoParam { + show?: boolean // 显示 + onClose?: () => void // 关闭 + title?: string // 标题 + list?: { id: number; name: string; typle?: number }[] // 数据列表 + onSelect?: (val: object) => void // 选择 + defaultValue?: number // 默认选中 } -export default memo(({show = false, onClose, title = '', list= [], onSelect, defaultValue}: ReasonInfoParam) => { - - return ( - - - {title} - - - {list.map(item => onSelect?.(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name} )} - - - - - ) -}) \ No newline at end of file +export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => { + return ( + + + {title} + + + {list.map(item => onSelect?.(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue && styles.select_item)}>{item.name})} + + + + + ) +}) diff --git a/src/pages/applyAfterSales/components/reasonPopup/index.tsx b/src/pages/applyAfterSales/components/reasonPopup/index.tsx index ec631c4..610f300 100644 --- a/src/pages/applyAfterSales/components/reasonPopup/index.tsx +++ b/src/pages/applyAfterSales/components/reasonPopup/index.tsx @@ -1,63 +1,62 @@ -import Popup from "@/components/popup"; -import { ScrollView, Text, View } from "@tarojs/components"; -import { Children, memo, useEffect, useMemo, useRef, useState } from "react"; -import classnames from "classnames"; -import styles from './index.module.scss' -import { ReturnExplainApi, ReturnReasonApi } from "@/api/salesAfterOrder"; +import { ScrollView, Text, View } from '@tarojs/components' +import { Children, memo, useEffect, useMemo, useRef, useState } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import Popup from '@/components/popup' +import { ReturnExplainApi, ReturnReasonApi } from '@/api/salesAfterOrder' -//原因选择 -type Param = {id:number, name:string, typle?:number} -type ReasonInfoParam = { - show?: boolean, //显示 - onClose?: () => void, //关闭 - title?: string, //标题 - list?: {id:number, name:string, typle?:number}[], //数据列表 - onSelect?: (val: object) => void, //选择 - onHeaderSelect?: (val: object) => void, //点击头部标题 - defaultValue?: number, //默认选中 - dataLength?: number, //可显示的数据列数 +// 原因选择 +interface Param { id: number; name: string; typle?: number } +interface ReasonInfoParam { + show?: boolean // 显示 + onClose?: () => void // 关闭 + title?: string // 标题 + list?: { id: number; name: string; typle?: number }[] // 数据列表 + onSelect?: (val: object) => void // 选择 + onHeaderSelect?: (val: object) => void // 点击头部标题 + defaultValue?: number // 默认选中 + dataLength?: number // 可显示的数据列数 } -export default memo(({show = false, onClose, title = '', list = [], onSelect, onHeaderSelect, defaultValue, dataLength = 1}: ReasonInfoParam) => { +export default memo(({ show = false, onClose, title = '', list = [], onSelect, onHeaderSelect, defaultValue, dataLength = 1 }: ReasonInfoParam) => { + const [initList, setInitList] = useState([]) - const [initList, setInitList] = useState([]) - - useEffect(() => { - setInitList(list) - }, [list]) - const [selectIndex, setSelectIndex] = useState(1) - const [headerList, setHeaderList] = useState<{id: number, name: string}[]>([]) - const onSelectData = (item) => { - if(selectIndex <= dataLength) { - headerList[selectIndex - 1] = {id:item.id, name:item.name} - onSelect?.({data:headerList, index:selectIndex}) - setSelectIndex(selectIndex == dataLength?dataLength:selectIndex + 1) - setHeaderList((e) => [...e]) - if(selectIndex == dataLength) onClose?.() - } + useEffect(() => { + setInitList(list) + }, [list]) + const [selectIndex, setSelectIndex] = useState(1) + const [headerList, setHeaderList] = useState<{ id: number; name: string }[]>([]) + const onSelectData = (item) => { + if (selectIndex <= dataLength) { + headerList[selectIndex - 1] = { id: item.id, name: item.name } + onSelect?.({ data: headerList, index: selectIndex }) + setSelectIndex(selectIndex == dataLength ? dataLength : selectIndex + 1) + setHeaderList(e => [...e]) + if (selectIndex == dataLength) { onClose?.() } } + } - const onHeaderClick = ({val, index}) => { - let list = headerList.slice(0, index + 1) - setSelectIndex(index + 1) - setHeaderList(list) - onHeaderSelect?.({data:val, index: index + 1}) - } - - return ( - - - - {headerList.map((item, index) => { - return onHeaderClick({val:item, index})} className={classnames(styles.selectName, (headerList.length == index + 1)&&styles.select_bottom)}>{item.name} - })} - {dataLength > headerList.length&&请选择} - - - - {initList.map(item => onSelectData(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name} )} - - - - - ) -}) \ No newline at end of file + const onHeaderClick = ({ val, index }) => { + const list = headerList.slice(0, index + 1) + setSelectIndex(index + 1) + setHeaderList(list) + onHeaderSelect?.({ data: val, index: index + 1 }) + } + + return ( + + + + {headerList.map((item, index) => { + return onHeaderClick({ val: item, index })} className={classnames(styles.selectName, (headerList.length == index + 1) && styles.select_bottom)}>{item.name} + })} + {dataLength > headerList.length && 请选择} + + + + {initList.map(item => onSelectData(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue && styles.select_item)}>{item.name})} + + + + + ) +}) diff --git a/src/pages/applyAfterSales/index.tsx b/src/pages/applyAfterSales/index.tsx index bf4647d..174e036 100644 --- a/src/pages/applyAfterSales/index.tsx +++ b/src/pages/applyAfterSales/index.tsx @@ -1,12 +1,12 @@ import { Image, ScrollView, Text, View } from '@tarojs/components' +import Taro, { useDidShow, useRouter } from '@tarojs/taro' import { FC, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import ReasonPopup from './components/reasonPopup' -import Taro, { useDidShow, useRouter } from '@tarojs/taro' -import { GetSaleOrderDetailApi } from '@/api/order' import KindList from './components/kindList' import CutKindList from './components/cutkindList' +import { GetSaleOrderDetailApi } from '@/api/order' import { ReturnApplyOrderApi, ReturnExplainApi, ReturnGoodsStatusApi, ReturnReasonApi } from '@/api/salesAfterOrder' import { alert, goLink } from '@/common/common' import UploadImage from '@/components/uploadImage' @@ -15,9 +15,9 @@ import useLogin from '@/use/useLogin' import { throttle } from '@/common/util' enum returnStatus { - return_reason = 1, //原因 - goods_status = 2, //状况 - return_explain = 3, //说明 + return_reason = 1, // 原因 + goods_status = 2, // 状况 + return_explain = 3, // 说明 } export default () => { useLogin() @@ -28,113 +28,117 @@ export default () => { const router = useRouter() const orderId = useRef(Number(router.params.id)) - //需要提交的数据 + // 需要提交的数据 const [submitData, setSubmitData] = useState({ fabric_piece_accessory_url: [], - goods_status: '', //货物状况 - reason_describe: '', //其他说明 - return_explain: '', //退货说明 - return_reason: '', //退货原因 + goods_status: '', // 货物状况 + reason_describe: '', // 其他说明 + return_explain: '', // 退货说明 + return_reason: '', // 退货原因 roll: 0, roll_list: [], sale_order_id: orderId.current, }) - //获取订单数据 - const [orderDetail, setOrderDetail] = useState() //获取到的原始数据 + // 获取订单数据 + const [orderDetail, setOrderDetail] = useState() // 获取到的原始数据 const { fetchData: getOrderFetchData } = GetSaleOrderDetailApi() - const getSaleOrderPreView = async () => { + const getSaleOrderPreView = async() => { if (orderId.current) { - let res = await getOrderFetchData({ id: orderId.current }) + const res = await getOrderFetchData({ id: orderId.current }) setOrderDetail(res.data) } } - //监听获取到的数据 + // 监听获取到的数据 useEffect(() => { if (orderDetail) { formatData() } }, [orderDetail]) - //格式化数据格式 - const [formatDetailOrder, setFormatDetailOrder] = useState() //格式化后的数据 + // 格式化数据格式 + const [formatDetailOrder, setFormatDetailOrder] = useState() // 格式化后的数据 const formatData = () => { setFormatDetailOrder({ ...orderDetail, - unit: orderDetail.sale_mode == 0 ? '条' : 'm', //单位 + unit: orderDetail.sale_mode == 0 ? '条' : 'm', // 单位 list: orderDetail.product_list, }) } - //数据总量 + // 数据总量 const dataCount = useMemo(() => { if (formatDetailOrder) { - let total_number = formatDetailOrder.sale_mode == 0 ? formatDetailOrder.av_total_number + '条' : formatDetailOrder.av_total_number / 100 + '米' + const total_number = formatDetailOrder.sale_mode == 0 ? `${formatDetailOrder.av_total_number}条` : `${formatDetailOrder.av_total_number / 100}米` return `${formatDetailOrder.av_total_fabrics}种面料,${formatDetailOrder.av_total_colors}种颜色,共${total_number}` } }, [formatDetailOrder]) - //面料数据 - let roll_list = useRef({}) + // 面料数据 + const roll_list = useRef({}) - //大货时获取计步器数据 + // 大货时获取计步器数据 const getNumChange = useCallback((val) => { if (parseInt(val.number) > 0) { roll_list.current[val.color_id] = { product_roll: val.number, sale_order_detail_id: val.sale_order_detail_id } - } else { + } + else { delete roll_list.current[val.color_id] } - setSubmitData((e) => ({ ...e, roll_list: Object.values(roll_list.current) })) + setSubmitData(e => ({ ...e, roll_list: Object.values(roll_list.current) })) }, []) - //散剪和剪板 + // 散剪和剪板 const getSelectChange = useCallback((val) => { if (val.status) { roll_list.current[val.sale_order_detail_id] = { product_roll: val.length, sale_order_detail_id: val.sale_order_detail_id } - } else { + } + else { delete roll_list.current[val.sale_order_detail_id] } - setSubmitData((e) => ({ ...e, roll_list: Object.values(roll_list.current) })) + setSubmitData(e => ({ ...e, roll_list: Object.values(roll_list.current) })) }, []) - //获取图片列表 + // 获取图片列表 const getImageList = useCallback((list) => { - setSubmitData((e) => ({ ...e, fabric_piece_accessory_url: list })) + setSubmitData(e => ({ ...e, fabric_piece_accessory_url: list })) }, []) - //其他说明 + // 其他说明 const getOtherReason = useCallback((val) => { - setSubmitData((e) => ({ ...e, reason_describe: val })) + setSubmitData(e => ({ ...e, reason_describe: val })) }, []) - //提交数据 + // 提交数据 const { fetchData: fetchDataReturnApply } = ReturnApplyOrderApi() - const onSubmitData = async () => { - if (submitData.roll_list.length <= 0) return alert.none('请选择或输入退货颜色') + const onSubmitData = async() => { + if (submitData.roll_list.length <= 0) { return alert.none('请选择或输入退货颜色') } console.log('submitData::', submitData) - let res = await fetchDataReturnApply(submitData) + const res = await fetchDataReturnApply(submitData) if (res.success) { alert.success('申请成功') goLink('/pages/salesAfter/salesAfterList/index', {}, 'reLaunch') - } else { + } + else { alert.error(res.msg) } } - //底部按钮 + // 底部按钮 const onSubmit = throttle((val) => { if (val == 2) { - if (submitData.goods_status === '') return alert.error('请选择货物状况') - if (submitData.return_explain === '') return alert.error('请选择退货原因') - if (!submitData.return_explain && !submitData.reason_describe) return alert.error('请填写其他说明') + if (submitData.goods_status === '') { return alert.error('请选择货物状况') } + if (submitData.return_explain === '') { return alert.error('请选择退货原因') } + if (!submitData.return_explain && !submitData.reason_describe) { return alert.error('请填写其他说明') } onSubmitData() - } else { + } + else { Taro.navigateBack() } }, 600) - //退货原因选择弹窗 + // 退货原因选择弹窗 const [showReason, setShowReason] = useState(false) const closeReason = useCallback(() => setShowReason(false), []) const onShowReason = () => { @@ -144,44 +148,44 @@ export default () => { getReturnReason() }, []) - //请求获取到的数据 + // 请求获取到的数据 const [returnGoodsInfo, setReturnGoodsInfo] = useState([]) - //退货原因 + // 退货原因 const { fetchData: fetchDataReturnReason } = ReturnReasonApi() - const getReturnReason = async () => { - let res = await fetchDataReturnReason() - setReturnGoodsInfo((e) => res.data?.list) + const getReturnReason = async() => { + const res = await fetchDataReturnReason() + setReturnGoodsInfo(e => res.data?.list) } - //售后退货说明 + // 售后退货说明 const { fetchData: fetchDataReturnExplain } = ReturnExplainApi() - const getReturnExplain = async (id) => { - let res = await fetchDataReturnExplain({ return_reason: id }) - setReturnGoodsInfo((e) => res.data?.list) + const getReturnExplain = async(id) => { + const res = await fetchDataReturnExplain({ return_reason: id }) + setReturnGoodsInfo(e => res.data?.list) } - //退货原因选择列表返回的数据 + // 退货原因选择列表返回的数据 const [returnObj, setReturnObj] = useState([]) const onReturnSelect = useCallback((val) => { - let res = val.data[val.data.length - 1] + const res = val.data[val.data.length - 1] if (val.index == 1) { getReturnExplain(res.id) setReturnGoodsInfo(() => []) } - if (val.index == 2) setReturnObj(val.data) + if (val.index == 2) { setReturnObj(val.data) } }, []) const onHeaderSelect = useCallback((val) => { - setReturnGoodsInfo((e) => []) - if (val.index == 1) getReturnReason() + setReturnGoodsInfo(e => []) + if (val.index == 1) { getReturnReason() } }, []) - //选择货物状况 + // 选择货物状况 const [showStatus, setShowStatus] = useState(false) const [statusInfo, setStatusInfo] = useState() const [statusGoodsInfo, setStatusGoodsInfo] = useState([]) const { fetchData: fetchDataGoodsStatus } = ReturnGoodsStatusApi() - const getReturnGoodsStatus = async () => { - let res = await fetchDataGoodsStatus() - setStatusGoodsInfo((e) => res.data?.list) + const getReturnGoodsStatus = async() => { + const res = await fetchDataGoodsStatus() + setStatusGoodsInfo(e => res.data?.list) } const onShowStatus = () => { setShowStatus(() => true) @@ -191,7 +195,7 @@ export default () => { setShowStatus(() => false) }, []) const onStatusSelect = useCallback((val) => { - let res = val.data[val.data.length - 1] + const res = val.data[val.data.length - 1] setStatusInfo(res) }, []) @@ -222,7 +226,7 @@ export default () => { 退货原因 0 && styles.selected}> - {returnObj?.length > 0 ? returnObj[0]?.name + '/' + returnObj[1]?.name : '请选择'} + {returnObj?.length > 0 ? `${returnObj[0]?.name}/${returnObj[1]?.name}` : '请选择'} @@ -240,11 +244,11 @@ export default () => { - + - + @@ -259,13 +263,13 @@ export default () => { - + ) } diff --git a/src/pages/bindSalesman/component/successBind/index.tsx b/src/pages/bindSalesman/component/successBind/index.tsx index 35beb6b..60ec1c7 100644 --- a/src/pages/bindSalesman/component/successBind/index.tsx +++ b/src/pages/bindSalesman/component/successBind/index.tsx @@ -1,41 +1,39 @@ -import { Image, Swiper, SwiperItem, Text, View } from "@tarojs/components" -import styles from './index.module.scss' -import { formatImgUrl } from "@/common/fotmat" -import Taro from "@tarojs/taro"; -import { goLink } from "@/common/common"; -import CloseBtn from "@/components/closeBtn"; -import { useEffect, useState } from "react"; +import { Image, Swiper, SwiperItem, Text, View } from '@tarojs/components' +import Taro from '@tarojs/taro' +import { useEffect, useState } from 'react' +import styles from './index.module.scss' +import { formatImgUrl } from '@/common/fotmat' +import { goLink } from '@/common/common' +import CloseBtn from '@/components/closeBtn' -type params = { - show?: true|false, - onClose?: () => void, - saleMan?: string +interface params { + show?: true|false + onClose?: () => void + saleMan?: string } -export default ({show = false, saleMan = '', onClose}:params) => { - const onClick = async () => { - onClose?.() - goLink('/pages/index/index', {}, 'switchTab') - - } - const onCloseEven = () => { - onClose?.() - } - return ( - <> - {show&& - - onClick()}> - - 邀请人: {saleMan} - - - onClick()}/> - - - - - } - - ) - -} \ No newline at end of file +export default ({ show = false, saleMan = '', onClose }: params) => { + const onClick = async() => { + onClose?.() + goLink('/pages/index/index', {}, 'switchTab') + } + const onCloseEven = () => { + onClose?.() + } + return ( + <> + {show && + + onClick()}> + + 邀请人: {saleMan} + + + onClick()} /> + + + + + } + + ) +} diff --git a/src/pages/bindSalesman/index.tsx b/src/pages/bindSalesman/index.tsx index 842b5a5..411516d 100644 --- a/src/pages/bindSalesman/index.tsx +++ b/src/pages/bindSalesman/index.tsx @@ -1,15 +1,16 @@ import { Image, Input, Text, View } from '@tarojs/components' -import styles from './index.module.scss' -import useLogin from '@/use/useLogin' +import Taro, { useDidShow } from '@tarojs/taro' import classnames from 'classnames' -import { formatImgUrl } from '@/common/fotmat' import { useEffect, useMemo, useRef, useState } from 'react' +import styles from './index.module.scss' +import SuccessBind from './component/successBind' +import useLogin from '@/use/useLogin' +import { formatImgUrl } from '@/common/fotmat' import { alert } from '@/common/common' import CloseBtn from '@/components/closeBtn' -import SuccessBind from './component/successBind' -import Taro, { useDidShow } from '@tarojs/taro' import { BindInvitationInfoApi, GetInvitationInfoApi } from '@/api/user' import { debounce, getFilterData, throttle } from '@/common/util' + export default () => { useLogin() @@ -21,52 +22,52 @@ export default () => { invitation_code: '', }) - //获取业务员信息 - type Param = { invitation_code: string; name: string; phone: string } + // 获取业务员信息 + interface Param { invitation_code: string; name: string; phone: string } const [salesMan, setSalesMan] = useState(null) const { fetchData: GetInvitationInfoFetchData } = GetInvitationInfoApi() - const getInvitationInfo = async () => { - let res = await GetInvitationInfoFetchData(getFilterData({ ...submitData })) + const getInvitationInfo = async() => { + const res = await GetInvitationInfoFetchData(getFilterData({ ...submitData })) res.success ? setSalesMan(res.data) : setSalesMan(null) } useEffect(() => { - if (submitData.invitation_code.length === 4) getInvitationInfo() + if (submitData.invitation_code.length === 4) { getInvitationInfo() } }, [submitData]) const onInputCode = (e) => { const value = e.detail.value.replace(/[\W]/g, '') - setSubmitData((val) => ({ ...val, invitation_code: value })) + setSubmitData(val => ({ ...val, invitation_code: value })) } const oncloseEven = () => { - setSubmitData((val) => ({ ...val, invitation_code: '' })) + setSubmitData(val => ({ ...val, invitation_code: '' })) setSalesMan(null) } - //绑定业务员 + // 绑定业务员 const [bindShow, setBindShow] = useState(false) const { fetchData: bindInvitationInfoFetchData } = BindInvitationInfoApi() - const onSubmit = async () => { - if (!submitData.invitation_code) return alert.error('请输入邀请码') - let res = await bindInvitationInfoFetchData({ ...submitData }) - if (res.success) setBindShow(() => true) + const onSubmit = async() => { + if (!submitData.invitation_code) { return alert.error('请输入邀请码') } + const res = await bindInvitationInfoFetchData({ ...submitData }) + if (res.success) { setBindShow(() => true) } } const onScanCode = () => { Taro.scanCode({ success: (res) => { - let val = res.result.match(/InviteCode:([a-zA-Z0-9]{4})/) + const val = res.result.match(/InviteCode:([a-zA-Z0-9]{4})/) setSubmitData(() => ({ invitation_code: val ? val![1] : '' })) }, }) } - //获取粘贴版内容 + // 获取粘贴版内容 const onClipboardData = () => { Taro.getClipboardData({ - success: function (res) { - let val = res.data.match(/InviteCode:([a-zA-Z0-9]{4})/) - if (val) setSubmitData((e) => ({ ...e, invitation_code: val ? val[1] : '' })) + success(res) { + const val = res.data.match(/InviteCode:([a-zA-Z0-9]{4})/) + if (val) { setSubmitData(e => ({ ...e, invitation_code: val ? val[1] : '' })) } }, }) } @@ -74,17 +75,17 @@ export default () => { return ( - + {submitData.invitation_code && } @@ -107,7 +108,7 @@ export default () => { 1. 新用户授权手机号码后,7天内可以输入邀请码,超过时间不能输入。 2. 一个手机只能输入一次邀请码。输入邀请码。 - + setBindShow(false)} saleMan={salesMan?.name} /> ) diff --git a/src/pages/certification/components/SelectEnterpriseType.tsx b/src/pages/certification/components/SelectEnterpriseType.tsx index acf9598..0e8cef3 100644 --- a/src/pages/certification/components/SelectEnterpriseType.tsx +++ b/src/pages/certification/components/SelectEnterpriseType.tsx @@ -1,55 +1,55 @@ -import { Text, View } from "@tarojs/components" -import Popup from "@/components/popup"; -import "./SelectEnterpriseType.scss" -import { forwardRef, useEffect, useImperativeHandle, useState } from "react"; -import {certificationTypeListApi} from "@/api/certification" +import { Text, View } from '@tarojs/components' +import Popup from '@/components/popup' +import './SelectEnterpriseType.scss' +import { forwardRef, useEffect, useImperativeHandle, useState } from 'react' +import { certificationTypeListApi } from '@/api/certification' interface Params{ - confirm?: (selected:any)=>void, // 确定 + confirm?: (selected: any) => void // 确定 } -export default forwardRef((props: Params, ref)=>{ +export default forwardRef((props: Params, ref) => { const [modalShow, setModalShow] = useState(false) // 获取认证信息 - const {fetchData, state} = certificationTypeListApi(); - useEffect(()=>{ - fetchData(); + const { fetchData, state } = certificationTypeListApi() + useEffect(() => { + fetchData() }, []) - const [selected, setSelected] = useState({}); + const [selected, setSelected] = useState({}) // 确定 - const handleSelect = (item)=>{ - setSelected(item); + const handleSelect = (item) => { + setSelected(item) } // 设置弹窗是否显示 - const setShow = (ev)=>{ - setModalShow(ev); + const setShow = (ev) => { + setModalShow(ev) } - useImperativeHandle(ref,()=>({ - setShow + useImperativeHandle(ref, () => ({ + setShow, })) // 确定 - const handleConfirm = ()=>{ - props.confirm&&props.confirm(selected); - setModalShow(false); + const handleConfirm = () => { + props.confirm && props.confirm(selected) + setModalShow(false) } - + return ( setModalShow(false)}> - - setModalShow(false)}>取消 - 确定 - - - { - state.data?.list?.map((item,index)=>{ - return handleSelect(item)} key={index}> - {item.name} - {item.id==(selected as any).id?:} - - }) - } - + + setModalShow(false)}>取消 + 确定 + + + { + state.data?.list?.map((item, index) => { + return handleSelect(item)} key={index}> + {item.name} + {item.id == (selected as any).id ? : } + + }) + } + ) diff --git a/src/pages/certification/index.tsx b/src/pages/certification/index.tsx index bc53251..e9fb037 100644 --- a/src/pages/certification/index.tsx +++ b/src/pages/certification/index.tsx @@ -1,28 +1,28 @@ -import FromListCertification from "@/components/FromListCertification" -import { Button, Image, Input, NavigationBar, Navigator, Text, Textarea, View } from "@tarojs/components" -import Taro, { setNavigationBarTitle, useRouter } from "@tarojs/taro" -import { certificationSaveApi, certificationDetailApi } from "@/api/certification" -import { useEffect, useRef, useState } from "react" -import { alert, retrieval } from "@/common/common" -import "./index.scss" -import useUploadCDNImg from "@/use/useUploadImage"; -import Message from "@/components/Message" -import { IMG_CND_Prefix } from "@/common/constant"; -import SelectEnterpriseType from "./components/SelectEnterpriseType" -import { useSelector } from "@/reducers/hooks"; -import useLogin from "@/use/useLogin"; +import { Button, Image, Input, NavigationBar, Navigator, Text, Textarea, View } from '@tarojs/components' +import Taro, { setNavigationBarTitle, useRouter } from '@tarojs/taro' +import { useEffect, useRef, useState } from 'react' +import SelectEnterpriseType from './components/SelectEnterpriseType' +import FromListCertification from '@/components/FromListCertification' +import { certificationDetailApi, certificationSaveApi } from '@/api/certification' +import { alert, retrieval } from '@/common/common' +import './index.scss' +import useUploadCDNImg from '@/use/useUploadImage' +import Message from '@/components/Message' +import { IMG_CND_Prefix } from '@/common/constant' +import { useSelector } from '@/reducers/hooks' +import useLogin from '@/use/useLogin' export default () => { - const { getAdminUserInfo } = useLogin(); - const { adminUserInfo } = useSelector(state => state.userInfo); + const { getAdminUserInfo } = useLogin() + const { adminUserInfo } = useSelector(state => state.userInfo) useEffect(() => { - initalFormData(); - }, []); + initalFormData() + }, []) // 获取认证信息 const { fetchData: getFromData } = certificationDetailApi() - const initalFormData = async () => { - const detail = await getFromData(); + const initalFormData = async() => { + const detail = await getFromData() setFormData({ ...detail.data ?? {}, legal_person_identity_url: detail?.data?.legal_person_identity_url ?? [], @@ -32,68 +32,69 @@ export default () => { // 保存 const [formData, setFormData] = useState({ authentication_type: 0, - authentication_type_name: "", - business_license_url: "", - legal_person: "", - legal_person_identity: "", + authentication_type_name: '', + business_license_url: '', + legal_person: '', + legal_person_identity: '', business_license: '', legal_person_identity_url: [], - name: "" - }); + name: '', + }) const rules = { // authentication_type: [{ // message: "请选择认证类型" // }], name: [{ - message: "请输入企业名称" + message: '请输入企业名称', }], business_license: [{ - message: "请输入企业营业执照" + message: '请输入企业营业执照', }], business_license_url: [{ - message: "请上传营业执照" + message: '请上传营业执照', }], legal_person: [{ - message: "请输入法人名称" + message: '请输入法人名称', }], legal_person_identity: [{ - message: "请输入正确法人身份证", - regex: /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/ + message: '请输入正确法人身份证', + regex: /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, }], legal_person_identity_url: [{ - message: "请上传法人身份证", + message: '请上传法人身份证', validator: (value: any, rule: any) => { if (!value[0] || !value[1]) { - return true; + return true } - return false; - } + return false + }, }], } const { fetchData } = certificationSaveApi() const handleSave = () => { - retrieval(formData, rules).then(async () => { + retrieval(formData, rules).then(async() => { const result = await fetchData({ ...formData, authentication_type: 2 }) if (result.success) { // Taro.eventCenter.trigger("weightList:refresh"); - getAdminUserInfo(); - Taro.navigateBack(); - alert.success("保存成功"); - } else { - alert.error(result.msg); + getAdminUserInfo() + Taro.navigateBack() + alert.success('保存成功') + } + else { + alert.error(result.msg) } }).catch((message) => { alert.none(message) }) } // 监听表单完善 - const [hozon, setHozon] = useState(false); + const [hozon, setHozon] = useState(false) useEffect(() => { if (retrieval) { retrieval(formData).then(() => setHozon(true)).catch(() => setHozon(false)) } }, [formData]) - // 选择类型弹窗显示 + // 选择类型弹窗显示 const selectTypeRef = useRef(null) const handleSelectTypeModalShow = () => { (selectTypeRef.current as any).setShow(true) @@ -103,26 +104,27 @@ export default () => { setFormData({ ...formData, authentication_type: item.id, - authentication_type_name: item.name - }); + authentication_type_name: item.name, + }) } // 上传图片 - const { getWxPhoto } = useUploadCDNImg(); - const handleUploadImage = async (text: any) => { - let result = await getWxPhoto('mall'); - if (text == "business_license_url") { - formData.business_license_url = IMG_CND_Prefix + (result as any).url; - } else { - formData.legal_person_identity_url[text] = IMG_CND_Prefix + (result as any).url as never; + const { getWxPhoto } = useUploadCDNImg() + const handleUploadImage = async(text: any) => { + const result = await getWxPhoto('mall') + if (text == 'business_license_url') { + formData.business_license_url = IMG_CND_Prefix + (result as any).url + } + else { + formData.legal_person_identity_url[text] = IMG_CND_Prefix + (result as any).url as never } - setFormData({ ...formData }); + setFormData({ ...formData }) } // 查看图片 const handleViewImage = (event, url) => { - event.stopPropagation(); + event.stopPropagation() Taro.previewImage({ current: url, - urls: [url] + urls: [url], }) } @@ -133,20 +135,20 @@ export default () => { 企业认证 {/* */} - setFormData({ ...formData, name: ev.detail.value })} value={formData["name"]} label="企业名称" placeholder="请输入营业执照上的企业名称" required /> + setFormData({ ...formData, name: ev.detail.value })} value={formData.name} label="企业名称" placeholder="请输入营业执照上的企业名称" required /> {/* */} - setFormData({ ...formData, business_license: ev.detail.value })} value={formData["business_license"]} style={{ border: "0" }} label="企业营业执照" placeholder="注册号、统一社会信用代码、组织机构代码" required /> - handleUploadImage("business_license_url")} className="certification-upload"> - {(formData as any)?.business_license_url ? - <> + setFormData({ ...formData, business_license: ev.detail.value })} value={formData.business_license} style={{ border: '0' }} label="企业营业执照" placeholder="注册号、统一社会信用代码、组织机构代码" required /> + handleUploadImage('business_license_url')} className="certification-upload"> + {(formData as any)?.business_license_url + ? <> 营业执照正面 - handleViewImage(e, (formData as any)?.business_license_url)}>查看证件 + handleViewImage(e, (formData as any)?.business_license_url)}>查看证件 重新上传 - : - + + : + 上传营业执照正面 @@ -155,35 +157,35 @@ export default () => { 法人认证 - setFormData({ ...formData, legal_person: ev.detail.value })} value={formData["legal_person"]} label="法人代表" placeholder="填写法人名称" required /> - setFormData({ ...formData, legal_person_identity: ev.detail.value })} value={formData["legal_person_identity"]} label="法人身份" placeholder="填写法人代表身份证号" required /> + setFormData({ ...formData, legal_person: ev.detail.value })} value={formData.legal_person} label="法人代表" placeholder="填写法人名称" required /> + setFormData({ ...formData, legal_person_identity: ev.detail.value })} value={formData.legal_person_identity} label="法人身份" placeholder="填写法人代表身份证号" required /> handleUploadImage(0)} className="certification-upload"> - {(formData as any)?.legal_person_identity_url[0] ? - <> + {(formData as any)?.legal_person_identity_url[0] + ? <> 营业执照正面 - handleViewImage(e, (formData as any)?.legal_person_identity_url[0])}>查看证件 + handleViewImage(e, (formData as any)?.legal_person_identity_url[0])}>查看证件 重新上传 - : - + + : + 上传身份证正面 } handleUploadImage(1)} className="certification-upload"> - {(formData as any)?.legal_person_identity_url[1] ? - <> + {(formData as any)?.legal_person_identity_url[1] + ? <> 营业执照正面 - handleViewImage(e, (formData as any)?.legal_person_identity_url[1])}>查看证件 + handleViewImage(e, (formData as any)?.legal_person_identity_url[1])}>查看证件 重新上传 - : - + + : + 上传身份证正面 @@ -193,7 +195,7 @@ export default () => { 取消 - {[3, 4].includes((adminUserInfo as any)?.authentication_status) ? "重新认证" : "提交"} + {[3, 4].includes((adminUserInfo as any)?.authentication_status) ? '重新认证' : '提交'} diff --git a/src/pages/classList/components/filter/index.tsx b/src/pages/classList/components/filter/index.tsx index 7495aa7..e92e4fa 100644 --- a/src/pages/classList/components/filter/index.tsx +++ b/src/pages/classList/components/filter/index.tsx @@ -1,8 +1,9 @@ -import Popup, { Params as PopuParams } from '@/components/popup' import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components' import classnames from 'classnames' import { useEffect, useState } from 'react' import styles from './index.module.scss' +import Popup from '@/components/popup' +import type { Params as PopuParams } from '@/components/popup' type params = { onFiltr?: (val: object) => void @@ -41,21 +42,22 @@ export default ({ onClose, onFiltr, show = false }: params) => { const setNumber = (e, field) => { console.log(e) - let num = parseFloat(e.detail.value) + const num = parseFloat(e.detail.value) if (isNaN(num)) { filterObj[field] = null - } else { + } + else { filterObj[field] = parseFloat(num.toFixed(2)) } setFilterObj({ ...filterObj }) } const setElement = (e) => { - let res = e.detail.value + const res = e.detail.value setFilterObj({ ...filterObj, element: res }) } return ( - onCloseEven()} showIconButton={true}> + onCloseEven()} showIconButton> 全部筛选 @@ -77,25 +79,25 @@ export default ({ onClose, onFiltr, show = false }: params) => { setNumber(e, 'minWidth')} - placeholder='自定义最低值' - placeholderStyle='font-size: 26rpx' + type="digit" + onBlur={e => setNumber(e, 'minWidth')} + placeholder="自定义最低值" + placeholderStyle="font-size: 26rpx" /> setNumber(e, 'maxWidth')} - placeholder='自定义最高值' - placeholderStyle='font-size: 26rpx' + type="digit" + onBlur={e => setNumber(e, 'maxWidth')} + placeholder="自定义最高值" + placeholderStyle="font-size: 26rpx" /> cm @@ -106,25 +108,25 @@ export default ({ onClose, onFiltr, show = false }: params) => { setNumber(e, 'minWeight')} - placeholder='自定义最低值' - placeholderStyle='font-size: 26rpx' + onBlur={e => setNumber(e, 'minWeight')} + placeholder="自定义最低值" + placeholderStyle="font-size: 26rpx" /> setNumber(e, 'maxWeight')} - placeholder='自定义最高值' - placeholderStyle='font-size: 26rpx' + onBlur={e => setNumber(e, 'maxWeight')} + placeholder="自定义最高值" + placeholderStyle="font-size: 26rpx" /> g @@ -133,11 +135,11 @@ export default ({ onClose, onFiltr, show = false }: params) => { 成分 - - {descData.number}/{descData.count} - - setSave()}>保存 - - ) -} \ No newline at end of file + const setSave = () => { + onSave?.(descData.value) + } + return ( + + 编辑备注 + + + {descData.number}/{descData.count} + + setSave()}>保存 + + ) +} diff --git a/src/pages/order/components/returnRecord/index.tsx b/src/pages/order/components/returnRecord/index.tsx index 30a5ac9..1549887 100644 --- a/src/pages/order/components/returnRecord/index.tsx +++ b/src/pages/order/components/returnRecord/index.tsx @@ -1,164 +1,165 @@ -import { GetSaleOrderListApi, ReturnRecordApi } from "@/api/salesAfterOrder"; -import { goLink } from "@/common/common"; -import { formatHashTag, formatPriceDiv } from "@/common/fotmat"; -import { dataLoadingStatus, getFilterData } from "@/common/util"; -import InfiniteScroll from "@/components/infiniteScroll"; -import LabAndImg from "@/components/LabAndImg"; -import Popup from "@/components/popup"; -import { useSelector } from "@/reducers/hooks"; -import { Image, Text, View } from "@tarojs/components"; -import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react"; -import classnames from "classnames"; -import styles from './index.module.scss' -import { REFUND_STATUS_ORDER } from "@/common/enum"; -import OrderStatusTag from "../orderStatusTag"; +import { Image, Text, View } from '@tarojs/components' +import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import classnames from 'classnames' +import OrderStatusTag from '../orderStatusTag' +import styles from './index.module.scss' +import { GetSaleOrderListApi, ReturnRecordApi } from '@/api/salesAfterOrder' +import { goLink } from '@/common/common' +import { formatHashTag, formatPriceDiv } from '@/common/fotmat' +import { dataLoadingStatus, getFilterData } from '@/common/util' +import InfiniteScroll from '@/components/infiniteScroll' +import LabAndImg from '@/components/LabAndImg' +import Popup from '@/components/popup' +import { useSelector } from '@/reducers/hooks' +import { REFUND_STATUS_ORDER } from '@/common/enum' -type Param = { - show?: true|false, - onClose?: () => void, - onSubmit?: () => void, - id?: number +interface Param { + show?: true|false + onClose?: () => void + onSubmit?: () => void + id?: number } -export default memo(({show, onClose, onSubmit, id}:Param) => { - //搜索参数 - const searchField = useRef({ - page : 1, - size : 10, - sale_order_id: 0 - }) +export default memo(({ show, onClose, onSubmit, id }: Param) => { + // 搜索参数 + const searchField = useRef({ + page: 1, + size: 10, + sale_order_id: 0, + }) - useEffect(() => { - if(show && id) { - searchField.current.sale_order_id = id - getOrderList() - } - }, [show, id]) - - const userInfo = useSelector(state => state.userInfo) - - //获取售后订单列表 - const {fetchData: listFetchData, state:orderState} = ReturnRecordApi() - const [orderData, setOrderData] = useState<{list:any[], total:number}>({list:[], total:0}) - const getOrderList = async () => { - let res = await listFetchData(getFilterData(searchField.current)) - setOrderData({list: res.data.list, total: res.data.total}) + useEffect(() => { + if (show && id) { + searchField.current.sale_order_id = id + getOrderList() } + }, [show, id]) - //整理颜色 - const labAndRgbAndUrl = useCallback((item) => { - return {lab:{...item?.lab}, rgb:{...item?.rgb}, texturl_url: item?.texturl_url} - }, [orderData]) + const userInfo = useSelector(state => state.userInfo) - const { - ReturnApplyOrderTypeReturnForRefund, // 退货退款 - } = REFUND_STATUS_ORDER + // 获取售后订单列表 + const { fetchData: listFetchData, state: orderState } = ReturnRecordApi() + const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) + const getOrderList = async() => { + const res = await listFetchData(getFilterData(searchField.current)) + setOrderData({ list: res.data.list, total: res.data.total }) + } - //对应单价 - const standardPrice = useCallback((price, sale_mode) => { - return formatPriceDiv(price).toLocaleString() + '/' + (sale_mode == 1?'m':'kg') - }, [orderData]) + // 整理颜色 + const labAndRgbAndUrl = useCallback((item) => { + return { lab: { ...item?.lab }, rgb: { ...item?.rgb }, texturl_url: item?.texturl_url } + }, [orderData]) - //对应数量 - const formatCount = useCallback((item, sale_mode) => { - return sale_mode == 0? item.roll + '条' : Number(item.length / 100) + '米' - }, [orderData]) + const { + ReturnApplyOrderTypeReturnForRefund, // 退货退款 + } = REFUND_STATUS_ORDER - //上拉加载数据 - const pageNum = useRef({size: searchField.current.size, page: searchField.current.page}) - const getScrolltolower = () => { - if(orderData.list.length < orderData.total) { - pageNum.current.page++ - const size = pageNum.current.size * pageNum.current.page - searchField.current.size = size - } + // 对应单价 + const standardPrice = useCallback((price, sale_mode) => { + return `${formatPriceDiv(price).toLocaleString()}/${sale_mode == 1 ? 'm' : 'kg'}` + }, [orderData]) + + // 对应数量 + const formatCount = useCallback((item, sale_mode) => { + return sale_mode == 0 ? `${item.roll}条` : `${Number(item.length / 100)}米` + }, [orderData]) + + // 上拉加载数据 + const pageNum = useRef({ size: searchField.current.size, page: searchField.current.page }) + const getScrolltolower = () => { + if (orderData.list.length < orderData.total) { + pageNum.current.page++ + const size = pageNum.current.size * pageNum.current.page + searchField.current.size = size } + } - const numText = useCallback((value) => { - let total_number_new = value?.sale_mode == 0? value?.total_number:(value?.total_number/100) - return `${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${total_number_new}${value?.sale_mode == 0? '条':'米'}` - }, [orderData]) + const numText = useCallback((value) => { + const total_number_new = value?.sale_mode == 0 ? value?.total_number : (value?.total_number / 100) + return `${value?.total_fabrics}种面料,${value?.total_colors}种颜色,共${total_number_new}${value?.sale_mode == 0 ? '条' : '米'}` + }, [orderData]) - //监听滚动 - const [scrollStatus, setScrollStatus] = useState(false) - const onscroll = useCallback((e) => { - if(e.detail.scrollTop > 20) { - setScrollStatus(true) - } else { - setScrollStatus(false) - } - },[]) + // 监听滚动 + const [scrollStatus, setScrollStatus] = useState(false) + const onscroll = useCallback((e) => { + if (e.detail.scrollTop > 20) { + setScrollStatus(true) + } + else { + setScrollStatus(false) + } + }, []) - //数据加载状态 - const statusMore = useMemo(() => { - return dataLoadingStatus({list:orderData.list, total: orderData.total, status: orderState.loading}) - }, [orderData, orderState]) + // 数据加载状态 + const statusMore = useMemo(() => { + return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading }) + }, [orderData, orderState]) - return ( - <> - - - - - {orderData?.list?.map(item => - goLink('/pages/salesAfter/index', {id: item?.id})}> - - - - - {userInfo?.adminUserInfo?.user_name} - - - 售后单号:{item?.return_order_no} - - - - - - - goLink('/pages/salesAfter/index', {id: item?.id})}> - - {item?.sale_mode_name} - {formatHashTag(item?.product_list?.[0].code, item?.product_list?.[0].name)} - {item?.stage_name} - - - - - {item?.product_list?.[0].product_colors?.[0].code} - - - {item?.product_list?.[0].product_colors?.map((itemColor, index) => { - return ( - (index <= 1)&& - {formatHashTag(itemColor.code, itemColor.name)} - {standardPrice(itemColor.sale_price, item.sale_mode)} - ×{formatCount(itemColor, item.sale_mode)} - - ) - }) - } - {(item?.product_list?.[0].product_colors.length > 2) && - …… - …… - …… - } - - - {numText(item)} - - {item?.type == ReturnApplyOrderTypeReturnForRefund?.value?'已申请退货':'已申请退款'} - 订单号:{item?.order_no} - - - )} - - + return ( + <> + + + + + {orderData?.list?.map(item => + goLink('/pages/salesAfter/index', { id: item?.id })}> + + + + + {userInfo?.adminUserInfo?.user_name} + + + 售后单号:{item?.return_order_no} + + + + + - - - ) -}) \ No newline at end of file + goLink('/pages/salesAfter/index', { id: item?.id })}> + + {item?.sale_mode_name} + {formatHashTag(item?.product_list?.[0].code, item?.product_list?.[0].name)} + {item?.stage_name} + + + + + {item?.product_list?.[0].product_colors?.[0].code} + + + {item?.product_list?.[0].product_colors?.map((itemColor, index) => { + return ( + (index <= 1) && + {formatHashTag(itemColor.code, itemColor.name)} + {standardPrice(itemColor.sale_price, item.sale_mode)} + ×{formatCount(itemColor, item.sale_mode)} + + ) + }) + } + {(item?.product_list?.[0].product_colors.length > 2) && + …… + …… + …… + } + + + {numText(item)} + + {item?.type == ReturnApplyOrderTypeReturnForRefund?.value ? '已申请退货' : '已申请退款'} + 订单号:{item?.order_no} + + + )} + + + + + + ) +}) diff --git a/src/pages/order/components/scanPay/index.tsx b/src/pages/order/components/scanPay/index.tsx index ccad5a1..7e6f2c6 100644 --- a/src/pages/order/components/scanPay/index.tsx +++ b/src/pages/order/components/scanPay/index.tsx @@ -1,9 +1,9 @@ import { Image, ScrollView, Text, View } from '@tarojs/components' +import Taro from '@tarojs/taro' import { memo, useEffect, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import Popup from '@/components/popup' -import Taro from '@tarojs/taro' import { alert } from '@/common/common' import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/fotmat' import useCheckAuthorize from '@/use/useCheckAuthorize' @@ -11,14 +11,14 @@ import { GetPayCode } from '@/api/onlinePay' import LoadingCard from '@/components/loadingCard' import { PAY_H5_CODE_URL } from '@/common/constant' -type Param = { +interface Param { show?: true | false onClose?: () => void company?: string qrcode?: string orderInfo?: any } -type ListParam = { +interface ListParam { product_code: string product_name: string product_color_code: string @@ -35,7 +35,7 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { useEffect(() => { if (orderInfo) { - let lists: ListParam[] = [] + const lists: ListParam[] = [] orderInfo.product_list?.map((pitem) => { pitem?.product_colors?.map((citem) => { lists.push({ @@ -47,7 +47,7 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { length: (citem.length / 100).toString(), weight: formatWeightDiv(citem.actual_weight || citem.estimate_weight).toString(), sale_price: formatPriceDiv(citem.sale_price).toString(), - total_price: formatPriceDiv(citem.total_sale_price || citem.estimate_amount).toString(), //小计 + total_price: formatPriceDiv(citem.total_sale_price || citem.estimate_amount).toString(), // 小计 weight_error: formatWeightDiv(citem.weight_error).toString(), }) }) @@ -55,29 +55,29 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { console.log('md5_key:::', orderInfo.md5_key) setDetail(() => ({ title: '面料销售电子确认单', - company: orderInfo.company_name, //后端公司 - order_type: orderInfo.sale_mode_name, //类型:大货 - sale_user: orderInfo.sale_user_name, //业务员 + company: orderInfo.company_name, // 后端公司 + order_type: orderInfo.sale_mode_name, // 类型:大货 + sale_user: orderInfo.sale_user_name, // 业务员 order_created_time: formatDateTime(orderInfo.create_time), order_no: orderInfo.order_no, - shipment_mode: orderInfo.shipment_mode_name, //发货方式 - target_user_name: userName(orderInfo), //收件人 - target_address: address(orderInfo), //收货地址 - target_description: orderInfo.remark, //发货备注 - pay_account: orderInfo.offline_remittance_information?.transfer_remittance_account, //专属收款账号 - bank_account_name: orderInfo.offline_remittance_information?.account_name, //账户名称 - bank_name: orderInfo.offline_remittance_information?.bank_of_deposit, //开户银行 - pay_type: '', //支付方式, 可不传 - client: orderInfo.purchaser_name, //客户名称 - phone: userPhone(orderInfo), //收货手机号码 - order_total_length: (orderInfo.total_number / 100).toString(), //订单布匹长度 - order_total_price: formatPriceDiv(orderInfo.bill_total_sale_price).toString(), //订单价格 + shipment_mode: orderInfo.shipment_mode_name, // 发货方式 + target_user_name: userName(orderInfo), // 收件人 + target_address: address(orderInfo), // 收货地址 + target_description: orderInfo.remark, // 发货备注 + pay_account: orderInfo.offline_remittance_information?.transfer_remittance_account, // 专属收款账号 + bank_account_name: orderInfo.offline_remittance_information?.account_name, // 账户名称 + bank_name: orderInfo.offline_remittance_information?.bank_of_deposit, // 开户银行 + pay_type: '', // 支付方式, 可不传 + client: orderInfo.purchaser_name, // 客户名称 + phone: userPhone(orderInfo), // 收货手机号码 + order_total_length: (orderInfo.total_number / 100).toString(), // 订单布匹长度 + order_total_price: formatPriceDiv(orderInfo.bill_total_sale_price).toString(), // 订单价格 show_order_total_price: orderInfo.is_display_price, - order_total_num: orderInfo.total_number + '', - qrcode: `${PAY_H5_CODE_URL}?key=${orderInfo.md5_key}`, //跳转链接 - order_total_weight: formatWeightDiv(orderInfo.total_weight || orderInfo.total_estimate_weight).toString(), //订单布匹重量 + order_total_num: `${orderInfo.total_number}`, + qrcode: `${PAY_H5_CODE_URL}?key=${orderInfo.md5_key}`, // 跳转链接 + order_total_weight: formatWeightDiv(orderInfo.total_weight || orderInfo.total_estimate_weight).toString(), // 订单布匹重量 list: lists, - show_qrcode: true, //是否显示码单 + show_qrcode: true, // 是否显示码单 estimate_amount: formatPriceDiv(orderInfo.estimate_amount).toString(), show_estimate_amount: orderInfo.estimate_amount > 0 && orderInfo.total_sale_price <= 0 && orderInfo.is_display_price, total_sale_price: formatPriceDiv(orderInfo.total_sale_price).toString(), @@ -88,47 +88,48 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { show_actual_amount: orderInfo.actual_amount > 0 && orderInfo.is_display_price, wait_pay_amount: formatPriceDiv(orderInfo.wait_pay_amount).toString(), show_wait_pay_amount: orderInfo.wait_pay_amount > 0 && orderInfo.is_display_price, - show_barcode: false, //条形码 - order_total_weight_error: formatWeightDiv(orderInfo.total_weight_error).toString(), //总空差重量 + show_barcode: false, // 条形码 + order_total_weight_error: formatWeightDiv(orderInfo.total_weight_error).toString(), // 总空差重量 show_total_price: orderInfo.is_display_price, show_sale_price: orderInfo.is_display_price, })) } }, [orderInfo, show]) - //收货地址 + // 收货地址 const address = (addressInfo) => { if (addressInfo?.shipment_mode == 2) { return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : '' - } else { + } + else { return addressInfo?.take_goods_address } } - //收件人 + // 收件人 const userName = (addressInfo) => { return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : '' } - //手机号 + // 手机号 const userPhone = (addressInfo) => { return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone } - //获取支付二维码 + // 获取支付二维码 const [payCodeImage, setPayCodeImage] = useState('') const fileData = useRef({ filePath: '', base64: '', }) const { fetchData, state } = GetPayCode() - const getCore = async () => { - let res = await fetchData(detail) + const getCore = async() => { + const res = await fetchData(detail) const base64 = res.data.base64 setPayCodeImage(() => base64) const time = new Date().valueOf() const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || [] - let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format + const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}` fileData.current.filePath = filePath fileData.current.base64 = bodyData const save = Taro.getFileSystemManager() @@ -139,34 +140,34 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { }) } useEffect(() => { - if (show) getCore() + if (show) { getCore() } }, [show]) - //检查是否开启保存图片权限 + // 检查是否开启保存图片权限 const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片', }) - const saveImageCheck = async () => { + const saveImageCheck = async() => { const res = await check() res && saveImage() } - //保存图片 + // 保存图片 const saveImage = () => { alert.loading('正在保存图片') Taro.saveImageToPhotosAlbum({ filePath: fileData.current.filePath, - success: function (res) { + success(res) { alert.success('图片保存成功') }, - fail: function (err) { + fail(err) { console.log('err::', err) }, }) } - //预览图片 + // 预览图片 const showImage = () => { console.log('fileData.current.filePath::', fileData.current.filePath) Taro.previewImage({ @@ -175,7 +176,7 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { }) } - //复制功能 + // 复制功能 return ( @@ -189,7 +190,7 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { {(state.loading && ) || ( - + )} diff --git a/src/pages/order/components/scanPayCheck/index.tsx b/src/pages/order/components/scanPayCheck/index.tsx index 76ccd2d..022ed91 100644 --- a/src/pages/order/components/scanPayCheck/index.tsx +++ b/src/pages/order/components/scanPayCheck/index.tsx @@ -1,23 +1,23 @@ import { Image, ScrollView, Text, View } from '@tarojs/components' +import Taro from '@tarojs/taro' import { memo, useEffect, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import Popup from '@/components/popup' -import Taro from '@tarojs/taro' import { alert } from '@/common/common' import { formatDateTime, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/fotmat' import useCheckAuthorize from '@/use/useCheckAuthorize' import { GetPayCode } from '@/api/onlinePay' import LoadingCard from '@/components/loadingCard' -type Param = { +interface Param { show?: true | false onClose?: () => void company?: string qrcode?: string orderInfo?: any } -type ListParam = { +interface ListParam { product_code: string product_name: string product_color_code: string @@ -40,7 +40,7 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { useEffect(() => { if (orderInfo) { - let lists: ListParam[] = [] + const lists: ListParam[] = [] orderInfo.product_list?.map((pitem) => { pitem?.product_colors?.map((citem) => { lists.push({ @@ -52,33 +52,33 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { length: (citem.length / 100).toString(), weight: formatWeightDiv(citem.actual_weight || citem.estimate_weight).toString(), sale_price: formatPriceDiv(citem.sale_price).toString(), - total_price: formatPriceDiv(citem.total_sale_price || citem.estimate_amount).toString(), //小计 + total_price: formatPriceDiv(citem.total_sale_price || citem.estimate_amount).toString(), // 小计 weight_error: formatWeightDiv(citem.weight_error).toString(), }) }) }) setDetail(() => ({ title: '面料销售电子确认单', - company: orderInfo.company_name, //后端公司 - order_type: orderInfo.sale_mode_name, //类型:大货 - sale_user: orderInfo.sale_user_name, //业务员 + company: orderInfo.company_name, // 后端公司 + order_type: orderInfo.sale_mode_name, // 类型:大货 + sale_user: orderInfo.sale_user_name, // 业务员 order_created_time: formatDateTime(orderInfo.create_time), order_no: orderInfo.order_no, - shipment_mode: orderInfo.shipment_mode_name, //发货方式 - target_user_name: userName(orderInfo), //收件人 - target_address: address(orderInfo), //收货地址 - target_description: orderInfo.remark, //发货备注 - pay_account: orderInfo.transfer_remittance_account, //专属收款账号 - bank_account_name: orderInfo.account_name, //账户名称 - bank_name: orderInfo.bank_of_deposit, //开户银行 - pay_type: '', //支付方式, 可不传 - client: orderInfo.purchaser_name, //客户名称 - phone: userPhone(orderInfo), //收货手机号码 - order_total_length: (orderInfo.total_number / 100).toString(), //订单布匹长度 - order_total_price: formatPriceDiv(orderInfo.bill_total_sale_price).toString(), //订单价格 + shipment_mode: orderInfo.shipment_mode_name, // 发货方式 + target_user_name: userName(orderInfo), // 收件人 + target_address: address(orderInfo), // 收货地址 + target_description: orderInfo.remark, // 发货备注 + pay_account: orderInfo.transfer_remittance_account, // 专属收款账号 + bank_account_name: orderInfo.account_name, // 账户名称 + bank_name: orderInfo.bank_of_deposit, // 开户银行 + pay_type: '', // 支付方式, 可不传 + client: orderInfo.purchaser_name, // 客户名称 + phone: userPhone(orderInfo), // 收货手机号码 + order_total_length: (orderInfo.total_number / 100).toString(), // 订单布匹长度 + order_total_price: formatPriceDiv(orderInfo.bill_total_sale_price).toString(), // 订单价格 order_total_num: orderInfo.total_number.toString(), - qrcode: '', //跳转链接 - order_total_weight: formatWeightDiv(orderInfo.total_weight || orderInfo.total_estimate_weight).toString(), //订单布匹重量 + qrcode: '', // 跳转链接 + order_total_weight: formatWeightDiv(orderInfo.total_weight || orderInfo.total_estimate_weight).toString(), // 订单布匹重量 list: lists, estimate_amount: formatPriceDiv(orderInfo.estimate_amount).toString(), @@ -92,46 +92,47 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { wait_pay_amount: formatPriceDiv(orderInfo.wait_pay_amount).toString(), show_wait_pay_amount: orderInfo.wait_pay_amount > 0 && orderInfo.is_display_price, show_barcode: true, - order_total_weight_error: formatWeightDiv(orderInfo.total_weight_error).toString(), //总空差重量 + order_total_weight_error: formatWeightDiv(orderInfo.total_weight_error).toString(), // 总空差重量 show_total_price: orderInfo.is_display_price, show_sale_price: orderInfo.is_display_price, })) } }, [orderInfo]) - //收货地址 + // 收货地址 const address = (addressInfo) => { if (addressInfo?.shipment_mode == 2) { return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : '' - } else { + } + else { return addressInfo?.take_goods_address } } - //收件人 + // 收件人 const userName = (addressInfo) => { return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : '' } - //手机号 + // 手机号 const userPhone = (addressInfo) => { return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone } - //获取支付二维码 + // 获取支付二维码 const [payCodeImage, setPayCodeImage] = useState('') const fileData = useRef({ filePath: '', base64: '', }) const { fetchData, state } = GetPayCode() - const getCore = async () => { - let res = await fetchData(detail) + const getCore = async() => { + const res = await fetchData(detail) const base64 = res.data.base64 setPayCodeImage(() => base64) const time = new Date().valueOf() const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || [] - let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format + const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}` fileData.current.filePath = filePath fileData.current.base64 = bodyData const save = Taro.getFileSystemManager() @@ -142,28 +143,28 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { }) } - //检查是否开启保存图片权限 + // 检查是否开启保存图片权限 const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' }) - const saveImageCheck = async () => { + const saveImageCheck = async() => { const res = await check() res && saveImage() } - //保存图片 + // 保存图片 const saveImage = () => { alert.loading('正在保存图片') Taro.saveImageToPhotosAlbum({ filePath: fileData.current.filePath, - success: function () { + success() { alert.success('图片保存成功') }, - fail: function (err) { + fail(err) { console.log('err::', err) }, }) } - //预览图片 + // 预览图片 const showImage = () => { console.log('fileData.current.filePath::', fileData.current.filePath) Taro.previewImage({ @@ -172,7 +173,7 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { }) } - //复制功能 + // 复制功能 return ( @@ -182,7 +183,7 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => { {(state.loading && ) || ( - + )} diff --git a/src/pages/order/components/shipmentMode/index.tsx b/src/pages/order/components/shipmentMode/index.tsx index 235591c..fcae893 100644 --- a/src/pages/order/components/shipmentMode/index.tsx +++ b/src/pages/order/components/shipmentMode/index.tsx @@ -1,28 +1,28 @@ -import { Text, View } from "@tarojs/components" -import styles from './index.module.scss' -import classnames from "classnames"; -import { memo, useRef, useState } from "react"; +import { Text, View } from '@tarojs/components' +import classnames from 'classnames' +import { memo, useRef, useState } from 'react' +import styles from './index.module.scss' -type Param = { - onSelect?:(val:number) => void +interface Param { + onSelect?: (val: number) => void } -export default memo(({onSelect}: Param) => { - //收货方法 1:自提,2:物流 - const shipmentMode = useRef([ - {value:1, label:'上门自提', selected:false}, - {value:2, label:'物流', selected:false} - ]) - const [selectValue, setSelectValue] = useState() - const selectShipmentMode = (value) => { - setSelectValue(() => value) - onSelect?.(value) - } - return ( - - 收货方式 - {shipmentMode.current.map(item => { - return selectShipmentMode(item.value)}>{item.label} - })} - - ) -}) \ No newline at end of file +export default memo(({ onSelect }: Param) => { + // 收货方法 1:自提,2:物流 + const shipmentMode = useRef([ + { value: 1, label: '上门自提', selected: false }, + { value: 2, label: '物流', selected: false }, + ]) + const [selectValue, setSelectValue] = useState() + const selectShipmentMode = (value) => { + setSelectValue(() => value) + onSelect?.(value) + } + return ( + + 收货方式 + {shipmentMode.current.map((item) => { + return selectShipmentMode(item.value)}>{item.label} + })} + + ) +}) diff --git a/src/pages/order/components/submitOrderBtn/index.tsx b/src/pages/order/components/submitOrderBtn/index.tsx index 5e083c3..b708478 100644 --- a/src/pages/order/components/submitOrderBtn/index.tsx +++ b/src/pages/order/components/submitOrderBtn/index.tsx @@ -1,38 +1,39 @@ -import { Text, View } from "@tarojs/components" -import { memo, useCallback, useEffect, useMemo } from "react" -import {formatKbPrice} from '@/common/common' -import classnames from "classnames"; -import styles from './index.module.scss' -type Param = { - style?: Object, - number?: number, //数量 - priceTitle: string //描述 +import { Text, View } from '@tarojs/components' +import { memo, useCallback, useEffect, useMemo } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import { formatKbPrice } from '@/common/common' + +interface Param { + style?: Object + number?: number // 数量 + priceTitle: string // 描述 } -export default memo(({style, number = 0, priceTitle = ''}:Param) => { - const priceDom = useCallback(() => { - let res = number.toFixed(2).split('.') - let int_num = parseInt(res[0]) + '' - let decimals_num = res[1] - return ( - <> - ¥ - {Number(int_num).toLocaleString()} - .{decimals_num} - - ) - }, [number]) +export default memo(({ style, number = 0, priceTitle = '' }: Param) => { + const priceDom = useCallback(() => { + const res = number.toFixed(2).split('.') + const int_num = `${parseInt(res[0])}` + const decimals_num = res[1] return ( - <> - - - {priceTitle}: - - - {priceDom()} - - - - + <> + ¥ + {Number(int_num).toLocaleString()} + .{decimals_num} + ) -}) \ No newline at end of file + }, [number]) + return ( + <> + + + {priceTitle}: + + + {priceDom()} + + + + + ) +}) diff --git a/src/pages/order/components/weightMemo/index.tsx b/src/pages/order/components/weightMemo/index.tsx index 7cbfd13..7ce2889 100644 --- a/src/pages/order/components/weightMemo/index.tsx +++ b/src/pages/order/components/weightMemo/index.tsx @@ -1,36 +1,36 @@ -import Popup from "@/components/popup" -import { Text, Textarea, View } from "@tarojs/components" -import { memo, useCallback, useState } from "react" -import styles from './index.module.scss' -import classnames from "classnames"; +import { Text, Textarea, View } from '@tarojs/components' +import { memo, useCallback, useState } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import Popup from '@/components/popup' -type Param = { - onCheck?: () => void - onCustom?: () => void +interface Param { + onCheck?: () => void + onCustom?: () => void } -export default memo(({onCheck, onCustom}:Param) => { - return ( - - onCheck?.()}> - - - 陆盈纺织 - - - 查看原码单 - - - - onCustom?.()}> - - - 我的码单 - - - 自定义 - - - +export default memo(({ onCheck, onCustom }: Param) => { + return ( + + onCheck?.()}> + + + 陆盈纺织 - ) -}) \ No newline at end of file + + 查看原码单 + + + + onCustom?.()}> + + + 我的码单 + + + 自定义 + + + + + ) +}) diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index 03c1abf..c9457b8 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -1,13 +1,3 @@ -import { GetSaleOrderDetailApi, EditSaleOrderRemarkApi } from '@/api/order' -import { AddShoppingCartApi } from '@/api/shopCart' -import { SubscriptionMessageApi } from '@/api/user' -import { alert, goLink } from '@/common/common' -import { ORDER_STATUS } from '@/common/enum' -import { formatDateTime, formatImgUrl } from '@/common/fotmat' -import OrderBtns from '@/components/orderBtns' -import Popup from '@/components/popup' -import SearchInput from '@/components/searchInput' -import ShopCart from '@/components/shopCart' import useLogin from '@/use/useLogin' import { MovableArea, Text, View } from '@tarojs/components' import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro' @@ -24,6 +14,16 @@ import Remark from './components/remark' import ReturnRecord from './components/returnRecord' import ScanPayCheck from './components/scanPayCheck' import styles from './index.module.scss' +import ShopCart from '@/components/shopCart' +import SearchInput from '@/components/searchInput' +import Popup from '@/components/popup' +import OrderBtns from '@/components/orderBtns' +import { formatDateTime, formatImgUrl } from '@/common/fotmat' +import { ORDER_STATUS } from '@/common/enum' +import { alert, goLink } from '@/common/common' +import { SubscriptionMessageApi } from '@/api/user' +import { AddShoppingCartApi } from '@/api/shopCart' +import { EditSaleOrderRemarkApi, GetSaleOrderDetailApi } from '@/api/order' export default () => { useLogin() @@ -34,7 +34,7 @@ export default () => { getSaleOrderPreView() }) - //订单状态枚举 + // 订单状态枚举 const { SaleOrderStatusTaking, SaleOrderStatusWaitingDelivery, @@ -46,16 +46,16 @@ export default () => { SaleorderstatusWaitingPrePayment, // 预付款 } = ORDER_STATUS - //获取订单详情 + // 获取订单详情 const firstOpen = useRef(true) - const [orderDetail, setOrderDetail] = useState() //获取到的原始数据 + const [orderDetail, setOrderDetail] = useState() // 获取到的原始数据 const { fetchData: getOrderFetchData } = GetSaleOrderDetailApi() - const getSaleOrderPreView = async () => { + const getSaleOrderPreView = async() => { if (orderId.current) { - let res = await getOrderFetchData({ id: orderId.current }) + const res = await getOrderFetchData({ id: orderId.current }) setOrderDetail(res.data) setOrderRemark(res.data.remark) - //预付款自动打开支付 + // 预付款自动打开支付 if (firstOpen.current && SaleorderstatusWaitingPrePayment.value == res.data.status) { firstOpen.current = false toPay() @@ -65,17 +65,17 @@ export default () => { // Taro.hideToast() } - //监听获取到的数据 + // 监听获取到的数据 useEffect(() => { - if (orderDetail) formatData() + if (orderDetail) { formatData() } }, [orderDetail]) - //格式化数据格式 - const [formatDetailOrder, setFormatDetailOrder] = useState() //格式化后的数据 + // 格式化数据格式 + const [formatDetailOrder, setFormatDetailOrder] = useState() // 格式化后的数据 const formatData = () => { setFormatDetailOrder({ ...orderDetail, - unit: orderDetail.sale_mode == 0 ? '条' : 'm', //单位 + unit: orderDetail.sale_mode == 0 ? '条' : 'm', // 单位 list: orderDetail.product_list, }) } @@ -83,11 +83,11 @@ export default () => { return formatDetailOrder }, [formatDetailOrder]) - //复制功能 + // 复制功能 const clipboardData = () => { Taro.setClipboardData({ data: orderDetail?.order_no || '', - success: function (res) { + success(res) { Taro.showToast({ icon: 'none', title: '复制成功', @@ -96,7 +96,7 @@ export default () => { }) } - //初始地址数据 + // 初始地址数据 const defaultAddress = useMemo(() => { return { province_name: orderDetail?.province_name, @@ -114,23 +114,24 @@ export default () => { } }, [orderDetail]) - //订单备注 + // 订单备注 const { fetchData: remarkFetchData } = EditSaleOrderRemarkApi() const [orderRemark, setOrderRemark] = useState('') - const getRemark = useCallback(async (e) => { + const getRemark = useCallback(async(e) => { setOrderRemark(() => e) - let res = await remarkFetchData({ remark: e, id: orderId.current }) + const res = await remarkFetchData({ remark: e, id: orderId.current }) if (res.success) { getSaleOrderPreView() alert.success('提交成功') - } else { + } + else { alert.error(res.msg) } setShowDesc(() => false) }, []) const noCanOpenDescList = useRef([ - SaleOrderStatusTaking.value, //提货中 - SaleOrderStatusWaitingDelivery.value, //待发货 + SaleOrderStatusTaking.value, // 提货中 + SaleOrderStatusWaitingDelivery.value, // 待发货 SaleOrderStatusWaitingReceipt.value, // 待收货 SaleOrderStatusAlreadyReceipt.value, // 已收货 SaleOrderStatusComplete.value, // 已完成 @@ -138,72 +139,77 @@ export default () => { SaleOrderStatusCancel.value, // 已取消 ]) const descOpen = () => { - if (noCanOpenDescList.current.includes(orderDetail?.status)) return alert.none('该订单状态不能修改备注') + if (noCanOpenDescList.current.includes(orderDetail?.status)) { return alert.none('该订单状态不能修改备注') } setShowDesc(() => true) } - //去付款 + // 去付款 const [payMentShow, setPayMentShow] = useState(false) const toPay = () => { setPayMentShow(true) } - //打开地址修改 + // 打开地址修改 const addressRef = useRef(null) - //修改收货方式 + // 修改收货方式 const getShipmentMode = useCallback(() => { getSaleOrderPreView() }, [orderDetail]) - //修改地址 + // 修改地址 const getAddress = useCallback(() => { getSaleOrderPreView() }, [orderDetail]) - //获取底部按钮点击, 获取按钮状态 + // 获取底部按钮点击, 获取按钮状态 const orderStateClick = useCallback( (val) => { if (val == 1 || val == 6 || val == 8) { getSaleOrderPreView() - } else if (val == 2) { - //待付款 + } + else if (val == 2) { + // 待付款 toPay() - } else if (val == 3) { - //申请退款 - if (!orderDetail?.av_return_roll) return alert.none('该订单已申请过退款') + } + else if (val == 3) { + // 申请退款 + if (!orderDetail?.av_return_roll) { return alert.none('该订单已申请过退款') } setRefundShow(true) - } else if (val == 7) { - //再购 + } + else if (val == 7) { + // 再购 addShopCart() - } else if (val == 9) { - //售后记录 + } + else if (val == 9) { + // 售后记录 onReturnRecordShow() - } else if (val == 10) { + } + else if (val == 10) { setShowScanPayCheck(true) } }, [orderDetail], ) - //页面下拉刷新 + // 页面下拉刷新 usePullDownRefresh(() => { getSaleOrderPreView() }) - //支付成功 + // 支付成功 const onPaySuccess = useCallback(() => { alert.success('支付成功') getSaleOrderPreView() closePayShow() }, [orderDetail]) - //关闭支付弹窗 + // 关闭支付弹窗 const closePayShow = useCallback(() => { setPayMentShow(() => false) }, [orderDetail]) - //按钮所需数据 + // 按钮所需数据 const orderInfo = useMemo(() => { return { orderId: orderDetail?.id, @@ -211,13 +217,13 @@ export default () => { } }, [orderDetail]) - //刷新页面 + // 刷新页面 const refresh = useCallback(() => { alert.loading('刷新中') getSaleOrderPreView() }, [orderDetail]) - //退款申请 + // 退款申请 const [refundShow, setRefundShow] = useState(false) const applyRefundClose = useCallback(() => { setRefundShow(false) @@ -226,13 +232,13 @@ export default () => { getSaleOrderPreView() }, []) - //查看物流 + // 查看物流 const getLogistics = useCallback(() => { if (orderDetail?.delivery_appendix_url) { const list = orderDetail?.delivery_appendix_url?.map((item) => { return formatImgUrl(item, '!w800') }) - if (list?.length <= 0) return alert.error('暂无图片') + if (list?.length <= 0) { return alert.error('暂无图片') } Taro.previewImage({ current: list[0], // 当前显示 urls: list, // 需要预览的图片http链接列表 @@ -240,16 +246,17 @@ export default () => { } }, [orderDetail]) - //添加购物车 + // 添加购物车 const [showCart, setShowCart] = useState(false) const { fetchData: addFetchData } = AddShoppingCartApi() - const addShopCart = async () => { - let color_list: { product_color_id: number; roll?: number; length?: number }[] = [] + const addShopCart = async() => { + const color_list: { product_color_id: number; roll?: number; length?: number }[] = [] orderDetail?.product_list.map((pitem) => { pitem?.product_colors.map((citem) => { if (orderDetail?.sale_mode == 0) { return color_list.push({ product_color_id: citem.id, roll: citem.roll }) - } else { + } + else { return color_list.push({ product_color_id: citem.id, length: citem.length }) } }) @@ -263,7 +270,8 @@ export default () => { title: '已加入购物车', }) setShowCart(true) - } else { + } + else { Taro.showToast({ icon: 'none', title: state.msg, @@ -271,7 +279,7 @@ export default () => { } } - //显示售后记录 + // 显示售后记录 const [returnRecordShow, setReturnRecordShow] = useState(false) const onReturnRecordShow = useCallback(() => { setReturnRecordShow(true) @@ -280,7 +288,7 @@ export default () => { setReturnRecordShow(false) }, []) - //显示 + // 显示 const [showScanPayCheck, setShowScanPayCheck] = useState(false) return ( @@ -301,7 +309,7 @@ export default () => { 订单信息 - + {orderDetail?.order_no} clipboardData()}> @@ -309,11 +317,11 @@ export default () => { - + {formatDateTime(orderDetail?.create_time)} {orderDetail?.payment_time && ( - + {formatDateTime(orderDetail?.payment_time)} )} @@ -328,18 +336,18 @@ export default () => { {orderDetail?.status != SaleOrderStatusCancel.value && ( - + )} setShowDesc(false)}> - getRemark(e)} defaultValue={orderDetail?.remark} /> + getRemark(e)} defaultValue={orderDetail?.remark} /> setShowScanPayCheck(false)} orderInfo={orderDetail} /> - setShowCart(false)} /> + setShowCart(false)} /> - + ) diff --git a/src/pages/order/orderList/components/order/index.tsx b/src/pages/order/orderList/components/order/index.tsx index b52f925..3d2b93e 100644 --- a/src/pages/order/orderList/components/order/index.tsx +++ b/src/pages/order/orderList/components/order/index.tsx @@ -1,3 +1,8 @@ +import { Image, Text, View } from '@tarojs/components' +import { useRouter } from '@tarojs/taro' +import classnames from 'classnames' +import { memo, useCallback, useMemo, useRef, useState } from 'react' +import styles from './index.module.scss' import { goLink } from '@/common/common' import { ORDER_STATUS } from '@/common/enum' import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat' @@ -5,13 +10,8 @@ import LabAndImg from '@/components/LabAndImg' import OrderBtns from '@/components/orderBtns' import Payment from '@/pages/order/components/payment' import { useSelector } from '@/reducers/hooks' -import { Image, Text, View } from '@tarojs/components' -import { useRouter } from '@tarojs/taro' -import classnames from 'classnames' -import { memo, useCallback, useMemo, useRef, useState } from 'react' -import styles from './index.module.scss' -type Param = { +interface Param { value: { order_no: string sale_mode: number @@ -28,10 +28,10 @@ type Param = { lab: any rgb: any texture_url: string - payment_method: number //支付方式 - actual_amount: number //实付金额 - wait_pay_amount: number //待付金额 - should_collect_order_id: number //应付单id + payment_method: number // 支付方式 + actual_amount: number // 实付金额 + wait_pay_amount: number // 待付金额 + should_collect_order_id: number // 应付单id av_return_roll: number total_sale_price: number estimate_amount: number @@ -40,23 +40,23 @@ type Param = { onClickBtn?: (val: { status: number; orderInfo: Param['value'] }) => void } export default memo(({ value, onClickBtn }: Param) => { - const userInfo = useSelector((state) => state.userInfo) - //对应数量 + const userInfo = useSelector(state => state.userInfo) + // 对应数量 const formatCount = useCallback( (item, sale_mode) => { return sale_mode == 0 ? item.roll : Number(item.length / 100) }, [value], ) - //对应单价 + // 对应单价 const standardPrice = useCallback( (price, sale_mode) => { - return '¥' + formatPriceDiv(price).toLocaleString() + '/' + (sale_mode == 1 ? 'm' : 'kg') + return `¥${formatPriceDiv(price).toLocaleString()}/${sale_mode == 1 ? 'm' : 'kg'}` }, [value], ) - //点击订单按钮 + // 点击订单按钮 const orderBtnsClick = useCallback( (status) => { onClickBtn?.({ status, orderInfo: value }) @@ -64,14 +64,14 @@ export default memo(({ value, onClickBtn }: Param) => { [value], ) - let { SaleOrderStatusTaking, SaleOrderStatusWaitingReceipt } = ORDER_STATUS + const { SaleOrderStatusTaking, SaleOrderStatusWaitingReceipt } = ORDER_STATUS - //订单状态 + // 订单状态 // const orderStatus = useCallback((item) => { // return item.status == SaleOrderStatusTaking.value?'装车中':item.status_name // }, [value]) - //按钮所需数据 + // 按钮所需数据 const orderInfo = useMemo(() => { return { orderId: value?.id, @@ -79,17 +79,18 @@ export default memo(({ value, onClickBtn }: Param) => { } }, [value]) - //总条数 + // 总条数 const numText = useMemo(() => { - let total_number_new = value?.sale_mode == 0 ? value?.total_number : value?.total_number / 100 + const total_number_new = value?.sale_mode == 0 ? value?.total_number : value?.total_number / 100 return `${value?.total_fabrics} 种面料,${value?.total_colors} 种颜色,共 ${total_number_new}${value?.sale_mode == 0 ? ' 条' : ' 米'}` }, [value]) - //订单状态 + // 订单状态 const orderStatus = useMemo(() => { if (value.status == SaleOrderStatusWaitingReceipt.value && value.shipment_mode == 1) { return '待提货' - } else { + } + else { return value?.status_name } }, [value]) @@ -157,7 +158,7 @@ export default memo(({ value, onClickBtn }: Param) => { - + ) }) diff --git a/src/pages/order/orderList/components/orderStatusList/index.tsx b/src/pages/order/orderList/components/orderStatusList/index.tsx index bd21c1c..5bb5d40 100644 --- a/src/pages/order/orderList/components/orderStatusList/index.tsx +++ b/src/pages/order/orderList/components/orderStatusList/index.tsx @@ -1,17 +1,17 @@ import { ScrollView, View } from '@tarojs/components' import { memo, useEffect, useState } from 'react' -import styles from './index.module.scss' import classnames from 'classnames' +import styles from './index.module.scss' -type Param = { +interface Param { list: { id: number; name: string }[] defaultId?: number onSelect?: (val: number) => void } export default memo(({ list = [], defaultId = -1, onSelect }: Param) => { const [selectInfo, setSelectInfo] = useState({ - selected: -1, //当前选中的id - tabId: '', //需要滚动到的id + selected: -1, // 当前选中的id + tabId: '', // 需要滚动到的id }) useEffect(() => { const index = list?.findIndex((item) => { @@ -19,19 +19,19 @@ export default memo(({ list = [], defaultId = -1, onSelect }: Param) => { }) if (index !== -1) { const num = index > 0 ? index - 1 : 0 - setSelectInfo((e) => ({ ...e, tabId: list[num].id.toString() })) + setSelectInfo(e => ({ ...e, tabId: list[num].id.toString() })) } - setSelectInfo((e) => ({ ...e, selected: defaultId })) + setSelectInfo(e => ({ ...e, selected: defaultId })) }, [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 })) + setSelectInfo(e => ({ ...e, tabId: list[num].id.toString(), selected: item.id })) onSelect?.(item.id) } return ( - + {list.map((item, index) => { return ( @@ -39,7 +39,8 @@ export default memo(({ list = [], defaultId = -1, onSelect }: Param) => { key={item.id} id={`tabs_${item.id}`} onClick={() => clickEvent({ item, index })} - className={classnames(styles.order_status_item, selectInfo.selected == item.id && styles.selected)}> + className={classnames(styles.order_status_item, selectInfo.selected == item.id && styles.selected)} + > {item.name} ) diff --git a/src/pages/order/orderList/index.tsx b/src/pages/order/orderList/index.tsx index 064c9e9..c1b2f26 100644 --- a/src/pages/order/orderList/index.tsx +++ b/src/pages/order/orderList/index.tsx @@ -1,43 +1,44 @@ -import Search from '@/components/search' -import useLogin from '@/use/useLogin' import { View } from '@tarojs/components' import Taro, { useDidHide, useDidShow, useRouter, useUnload } from '@tarojs/taro' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' -import styles from './index.module.scss' -import Order from './components/order' -import InfiniteScroll from '@/components/infiniteScroll' -import { GetOrderListApi, OrderStatusListApi } from '@/api/order' -import { dataLoadingStatus, getFilterData } from '@/common/util' -import OrderStatusList from './components/orderStatusList' -import { AddShoppingCartApi } from '@/api/shopCart' -import ShopCart from '@/components/shopCart' -import { alert } from '@/common/common' import Payment from '../components/payment' import ApplyRefund from '../components/applyRefund' import ReturnRecord from '../components/returnRecord' +import styles from './index.module.scss' +import Order from './components/order' +import OrderStatusList from './components/orderStatusList' +import Search from '@/components/search' +import useLogin from '@/use/useLogin' +import InfiniteScroll from '@/components/infiniteScroll' +import { GetOrderListApi, OrderStatusListApi } from '@/api/order' +import { dataLoadingStatus, getFilterData } from '@/common/util' +import { AddShoppingCartApi } from '@/api/shopCart' +import ShopCart from '@/components/shopCart' +import { alert } from '@/common/common' export default () => { const { checkLogin } = useLogin() - useDidShow(async () => { + useDidShow(async() => { await checkLogin() }) - //传递过来的参数 + // 传递过来的参数 const router = useRouter() useEffect(() => { if (router?.params.status != undefined && router?.params.status !== '') { - setSearchField((e) => ({ ...e, status: router?.params.status as unknown as number })) - } else { - setSearchField((e) => ({ ...e, status: -1 })) + setSearchField(e => ({ ...e, status: router?.params.status as unknown as number })) + } + else { + setSearchField(e => ({ ...e, status: -1 })) } getOrderStatusList() }, []) useDidHide(() => { - setSearchField((e) => ({ ...e, status: -1 })) + setSearchField(e => ({ ...e, status: -1 })) }) - //搜索参数 + // 搜索参数 const [searchField, setSearchField] = useState<{ status: number | null; page: number; size: number; name: string }>({ status: null, page: 1, @@ -45,29 +46,29 @@ export default () => { name: '', }) - //获取订单状态 + // 获取订单状态 const { fetchData: orderStatusListFetchData } = OrderStatusListApi() const [statusList, setStatusList] = useState([]) - const getOrderStatusList = async () => { - let res = await orderStatusListFetchData() + const getOrderStatusList = async() => { + const res = await orderStatusListFetchData() setStatusList(() => [{ id: -1, name: '全部' }, ...res.data.list]) } - //获取订单列表 + // 获取订单列表 const { fetchData: listFetchData, state: orderState } = GetOrderListApi() const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) - const getOrderList = async () => { - let res = await listFetchData(getFilterData(searchField)) - setOrderData((e) => ({ ...e, list: res.data?.list, total: res.data?.total })) + const getOrderList = async() => { + const res = await listFetchData(getFilterData(searchField)) + setOrderData(e => ({ ...e, list: res.data?.list, total: res.data?.total })) setRefresherTriggeredStatus(() => false) } - //监听筛选条件变化 + // 监听筛选条件变化 useEffect(() => { - if (searchField.status != null) getOrderList() + if (searchField.status != null) { getOrderList() } }, [searchField]) - //上拉加载数据 + // 上拉加载数据 const pageNum = useRef({ size: searchField.size, page: searchField.page }) const getScrolltolower = useCallback(() => { if (orderData.list.length < orderData.total) { @@ -77,52 +78,57 @@ export default () => { } }, [orderData]) - //状态改变 + // 状态改变 const changeStatus = useCallback((e) => { pageNum.current.page = 1 - setSearchField((value) => ({ ...value, status: e, size: 10 })) + setSearchField(value => ({ ...value, status: e, size: 10 })) setOrderData(() => ({ list: [], total: 0 })) }, []) - //数据加载状态 + // 数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading }) }, [orderData, orderState]) - //输入了搜索关键字 + // 输入了搜索关键字 const getSearchData = useCallback((e) => { pageNum.current.page = 1 setOrderData(() => ({ list: [], total: 0 })) - setSearchField((val) => ({ ...val, name: e, size: 10 })) + setSearchField(val => ({ ...val, name: e, size: 10 })) }, []) - //列表下拉刷新 + // 列表下拉刷新 const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) - const getRefresherRefresh = async () => { + const getRefresherRefresh = async() => { pageNum.current.size = 1 setRefresherTriggeredStatus(true) - setSearchField((val) => ({ ...val, size: 10 })) + setSearchField(val => ({ ...val, size: 10 })) } - //监听点击的按钮 + // 监听点击的按钮 const clickOrderBtn = useCallback( ({ status, orderInfo }) => { setCallBackPayOrderInfo(() => orderInfo) if (status == 1 || status == 6 || status == 8) { getOrderList() - } else if (status == 2) { - //去支付 + } + else if (status == 2) { + // 去支付 toPay() - } else if (status == 3) { - //申请退款 - if (!orderInfo?.av_return_roll) return alert.none('该订单已申请过退款') + } + else if (status == 3) { + // 申请退款 + if (!orderInfo?.av_return_roll) { return alert.none('该订单已申请过退款') } setRefundShow(true) - } else if (status == 7) { - //购买 + } + else if (status == 7) { + // 购买 addShopCart(orderInfo) - } else if (status == 9) { + } + else if (status == 9) { onReturnRecordShow() - } else if (status == 10) { + } + else if (status == 10) { setShowScanPayCheck(true) } }, @@ -131,31 +137,32 @@ export default () => { const [callBackOrderInfo, setCallBackPayOrderInfo] = useState() - //去付款 + // 去付款 const [payMentShow, setPayMentShow] = useState(false) const toPay = () => { setPayMentShow(true) } - //关闭支付弹窗 + // 关闭支付弹窗 const closePayShow = useCallback(() => { setPayMentShow(() => false) }, []) - //支付成功 + // 支付成功 const onPaySuccess = () => { getOrderList() closePayShow() } - //添加购物车 + // 添加购物车 const [showCart, setShowCart] = useState(false) const { fetchData: addFetchData } = AddShoppingCartApi() - const addShopCart = async (item) => { - let color_list: { product_color_id: number; roll?: number; length?: number }[] = [] + const addShopCart = async(item) => { + const color_list: { product_color_id: number; roll?: number; length?: number }[] = [] item?.product_list.map((pitem) => { pitem?.product_colors.map((citem) => { if (item?.sale_mode == 0) { return color_list.push({ product_color_id: citem.id, roll: citem.roll }) - } else { + } + else { return color_list.push({ product_color_id: citem.id, length: citem.length }) } }) @@ -169,7 +176,8 @@ export default () => { title: '已加入购物车', }) setShowCart(true) - } else { + } + else { Taro.showToast({ icon: 'none', title: state.msg, @@ -177,7 +185,7 @@ export default () => { } } - //申请退款 + // 申请退款 const [refundShow, setRefundShow] = useState(false) const applyRefundClose = useCallback(() => { setRefundShow(false) @@ -186,7 +194,7 @@ export default () => { getOrderList() }, []) - //显示售后记录 + // 显示售后记录 const [returnRecordShow, setReturnRecordShow] = useState(false) const onReturnRecordShow = useCallback(() => { setReturnRecordShow(true) @@ -195,22 +203,23 @@ export default () => { setReturnRecordShow(false) }, []) - //显示 + // 显示 const [showScanPayCheck, setShowScanPayCheck] = useState(false) return ( - + + selfOnRefresherRefresh={getRefresherRefresh} + > {orderData?.list?.map((item) => { return ( @@ -221,7 +230,7 @@ export default () => { - setShowCart(false)} default_sale_mode={callBackOrderInfo?.sale_mode} /> + setShowCart(false)} default_sale_mode={callBackOrderInfo?.sale_mode} /> diff --git a/src/pages/salesAfter/components/addressInfo/index.tsx b/src/pages/salesAfter/components/addressInfo/index.tsx index 4225fea..734fdb8 100644 --- a/src/pages/salesAfter/components/addressInfo/index.tsx +++ b/src/pages/salesAfter/components/addressInfo/index.tsx @@ -1,76 +1,74 @@ -import AddressList from "@/components/AddressList"; -import Popup from "@/components/popup"; -import { Text, View } from "@tarojs/components" -import classnames from "classnames"; -import { memo, useCallback, useEffect, useMemo, useState } from "react"; -import styles from './index.module.scss' +import { Text, View } from '@tarojs/components' +import classnames from 'classnames' +import { memo, useCallback, useEffect, useMemo, useState } from 'react' +import styles from './index.module.scss' +import Popup from '@/components/popup' +import AddressList from '@/components/AddressList' -export type AddressInfoParam = { - province_name: string, - city_name: string, - district_name: string, - address_detail: string, - id?: number, - name: string, - phone: string +export interface AddressInfoParam { + province_name: string + city_name: string + district_name: string + address_detail: string + id?: number + name: string + phone: string } -type Param = { - onSelect?: (val:any) => void, //选择 - defaultValue?: AddressInfoParam|null //默认值 - disabled?: false|true //true禁用后只用于展示 +interface Param { + onSelect?: (val: any) => void // 选择 + defaultValue?: AddressInfoParam|null // 默认值 + disabled?: false|true // true禁用后只用于展示 } -export default memo(({onSelect, defaultValue = null, disabled = false}: Param) => { - const [showAddressList, setShowAddressList] = useState(false) +export default memo(({ onSelect, defaultValue = null, disabled = false }: Param) => { + const [showAddressList, setShowAddressList] = useState(false) - useEffect(() => { - setUserInfo(() => defaultValue) - }, [defaultValue]) + useEffect(() => { + setUserInfo(() => defaultValue) + }, [defaultValue]) - //选择地址 - const [userInfo, setUserInfo] = useState() - const getAddress = useCallback((val) => { - setShowAddressList(() => false) - setUserInfo(() => val) - onSelect?.(val) - }, []) + // 选择地址 + const [userInfo, setUserInfo] = useState() + const getAddress = useCallback((val) => { + setShowAddressList(() => false) + setUserInfo(() => val) + onSelect?.(val) + }, []) - //地址格式 - const formatAddress = useMemo(() => { - if(userInfo) - return userInfo.province_name + userInfo.city_name + userInfo.district_name + userInfo.address_detail - }, [userInfo]) + // 地址格式 + const formatAddress = useMemo(() => { + if (userInfo) { return userInfo.province_name + userInfo.city_name + userInfo.district_name + userInfo.address_detail } + }, [userInfo]) - const changeShow = () => { - if(!disabled) - setShowAddressList(() => true) - } - return ( - - changeShow()}> - - {!userInfo&& - <> - 请选择收货地址及信息 - + const changeShow = () => { + if (!disabled) { setShowAddressList(() => true) } + } + return ( + + changeShow()}> + + {!userInfo + && <> + 请选择收货地址及信息 + - ||<> - - - {userInfo?.name} - {userInfo?.phone} - - {formatAddress} + || <> + + + {userInfo?.name} + {userInfo?.phone} - 修改 + {formatAddress} + + 修改 } - - {!disabled&& setShowAddressList(false)}> - - 请选择收货地址 - getAddress(item)}/> - - } + + {!disabled && setShowAddressList(false)}> + + 请选择收货地址 + getAddress(item)} /> - ) -}) \ No newline at end of file + } + + ) +}) diff --git a/src/pages/salesAfter/components/addressInfoDetail/index.tsx b/src/pages/salesAfter/components/addressInfoDetail/index.tsx index fb99242..3640730 100644 --- a/src/pages/salesAfter/components/addressInfoDetail/index.tsx +++ b/src/pages/salesAfter/components/addressInfoDetail/index.tsx @@ -1,17 +1,17 @@ -import { AFTER_ORDER_STATUS, REFUND_STATUS_ORDER } from '@/common/enum' import { Text, View } from '@tarojs/components' import classnames from 'classnames' import { memo, useMemo } from 'react' import styles from './index.module.scss' +import { AFTER_ORDER_STATUS, REFUND_STATUS_ORDER } from '@/common/enum' -type Param = { - onLogistics?: (val: 1 | 2) => void //1 上传物流 2 查看物流 +interface Param { + onLogistics?: (val: 1 | 2) => void // 1 上传物流 2 查看物流 orderInfo: { return_user_name?: string return_user_phone?: string stage?: number - sale_mode?: 0 | 1 | 2 //0 大货 1剪板 2散剪 - type?: number //申请单退款状态 + sale_mode?: 0 | 1 | 2 // 0 大货 1剪板 2散剪 + type?: number // 申请单退款状态 return_address?: string } } @@ -33,14 +33,14 @@ export default memo(({ orderInfo, onLogistics }: Param) => { ReturnApplyOrderTypeSalesRefund, // 销售退款 } = REFUND_STATUS_ORDER - //是否显示地址 + // 是否显示地址 const showAddress = useMemo(() => { - let after_list = [ReturnStageApplying.value, ReturnStageCancel.value, ReturnStageRejected.value] - let refurn_list = [ReturnApplyOrderTypeSalesRefund.value, ReturnApplyOrderTypeAdvanceReceiptRefund.value] + const after_list = [ReturnStageApplying.value, ReturnStageCancel.value, ReturnStageRejected.value] + const refurn_list = [ReturnApplyOrderTypeSalesRefund.value, ReturnApplyOrderTypeAdvanceReceiptRefund.value] return !after_list.includes(orderInfo?.stage!) && orderInfo?.sale_mode != 1 && !refurn_list.includes(orderInfo?.type!) }, [orderInfo]) - //上传物流 + // 上传物流 const upLogistics = useMemo(() => { return orderInfo?.stage == ReturnStageWaitCheck.value }, [orderInfo]) diff --git a/src/pages/salesAfter/components/amountShow/index.tsx b/src/pages/salesAfter/components/amountShow/index.tsx index 877f7df..10f4fea 100644 --- a/src/pages/salesAfter/components/amountShow/index.tsx +++ b/src/pages/salesAfter/components/amountShow/index.tsx @@ -1,28 +1,28 @@ -import { Text, View } from "@tarojs/components"; -import { memo, useCallback } from "react"; -import styles from './index.module.scss' -import classnames from "classnames"; +import { Text, View } from '@tarojs/components' +import { memo, useCallback } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' -type Param = { - number: number, //数字 - status: 0|1|2 //0 小型,1中型,2大 +interface Param { + number: number // 数字 + status: 0|1|2 // 0 小型,1中型,2大 } -export default memo(({number = 0, status = 1}:Param) => { - const priceDom = useCallback(() => { - let res = number.toFixed(2).split('.') - let int_num = parseInt(res[0]) + '' - let decimals_num = res[1] - return ( - <> - ¥ - {Number(int_num).toLocaleString()} - .{decimals_num} - - ) - }, [number]) +export default memo(({ number = 0, status = 1 }: Param) => { + const priceDom = useCallback(() => { + const res = number.toFixed(2).split('.') + const int_num = `${parseInt(res[0])}` + const decimals_num = res[1] return ( - - {priceDom()} - + <> + ¥ + {Number(int_num).toLocaleString()} + .{decimals_num} + ) -}) \ No newline at end of file + }, [number]) + return ( + + {priceDom()} + + ) +}) diff --git a/src/pages/salesAfter/components/applyRecord/index.tsx b/src/pages/salesAfter/components/applyRecord/index.tsx index d704020..f881455 100644 --- a/src/pages/salesAfter/components/applyRecord/index.tsx +++ b/src/pages/salesAfter/components/applyRecord/index.tsx @@ -1,13 +1,13 @@ +import { ScrollView, Text, View } from '@tarojs/components' +import Taro from '@tarojs/taro' +import { memo, useCallback, useEffect, useMemo, useState } from 'react' +import styles from './index.module.scss' import { SaleOrderOrderDetailApi } from '@/api/salesAfterOrder' import { formatHashTag, formatPriceDiv, formatWeightDiv } from '@/common/fotmat' import LabAndImg from '@/components/LabAndImg' import Popup from '@/components/popup' -import { ScrollView, Text, View } from '@tarojs/components' -import { memo, useCallback, useEffect, useMemo, useState } from 'react' -import Taro from '@tarojs/taro' -import styles from './index.module.scss' -type Param = { +interface Param { show?: true | false onClose?: () => void onSubmit?: () => void @@ -15,48 +15,48 @@ type Param = { } export default memo(({ show, onClose, onSubmit, id }: Param) => { useEffect(() => { - if (show && id) getSaleOrderPreView() - if (!show) setFormatDetailOrder(() => null) + if (show && id) { getSaleOrderPreView() } + if (!show) { setFormatDetailOrder(() => null) } }, [show, id]) - //获取订单详情 - const [orderDetail, setOrderDetail] = useState(null) //获取到的原始数据 + // 获取订单详情 + const [orderDetail, setOrderDetail] = useState(null) // 获取到的原始数据 const { fetchData: saleOrderOrderDetailData } = SaleOrderOrderDetailApi() - const getSaleOrderPreView = async () => { + const getSaleOrderPreView = async() => { if (id) { - let res = await saleOrderOrderDetailData({ id: id }) + const res = await saleOrderOrderDetailData({ id }) setOrderDetail(res.data) } Taro.stopPullDownRefresh() } - //格式化数据格式 - const [formatDetailOrder, setFormatDetailOrder] = useState() //格式化后的数据 + // 格式化数据格式 + const [formatDetailOrder, setFormatDetailOrder] = useState() // 格式化后的数据 const formatData = () => { setFormatDetailOrder({ - estimate_amount: orderDetail.estimate_amount, //预估金额 + estimate_amount: orderDetail.estimate_amount, // 预估金额 sale_mode: orderDetail.sale_mode, sale_mode_name: orderDetail.sale_mode_name, - total_colors: orderDetail.total_colors, //总颜色数量 - total_number: orderDetail.total_number, //总数量 - total_fabrics: orderDetail.total_fabrics, //面料数量 - unit: orderDetail.sale_mode == 0 ? '条' : 'm', //单位 + total_colors: orderDetail.total_colors, // 总颜色数量 + total_number: orderDetail.total_number, // 总数量 + total_fabrics: orderDetail.total_fabrics, // 面料数量 + unit: orderDetail.sale_mode == 0 ? '条' : 'm', // 单位 list: orderDetail.product_list, - stage: orderDetail.stage, //订单状态 - type: orderDetail.type, //退货or退款 - total_sale_price: orderDetail.total_sale_price, //销售金额 - total_should_collect_money: orderDetail.total_should_collect_money, //应收金额 - total_weight_error_discount: orderDetail.total_weight_error_discount, //空差优惠 - actual_amount: orderDetail.actual_amount, //实付金额 - the_previous_status: orderDetail.the_previous_status, //取消订单时的订单状态 + stage: orderDetail.stage, // 订单状态 + type: orderDetail.type, // 退货or退款 + total_sale_price: orderDetail.total_sale_price, // 销售金额 + total_should_collect_money: orderDetail.total_should_collect_money, // 应收金额 + total_weight_error_discount: orderDetail.total_weight_error_discount, // 空差优惠 + actual_amount: orderDetail.actual_amount, // 实付金额 + the_previous_status: orderDetail.the_previous_status, // 取消订单时的订单状态 }) } - //监听获取到的数据 + // 监听获取到的数据 useEffect(() => { - if (orderDetail) formatData() + if (orderDetail) { formatData() } }, [orderDetail]) - //对应数量 + // 对应数量 const formatCount = useCallback( (item) => { return formatDetailOrder?.sale_mode == 0 ? item.roll : Number(item.length / 100) @@ -64,30 +64,30 @@ export default memo(({ show, onClose, onSubmit, id }: Param) => { [formatDetailOrder], ) - //对应单价 + // 对应单价 const standardPrice = useCallback( (price) => { - return formatPriceDiv(price).toLocaleString() + '/' + (formatDetailOrder?.sale_mode == 1 ? 'm' : 'kg') + return `${formatPriceDiv(price).toLocaleString()}/${formatDetailOrder?.sale_mode == 1 ? 'm' : 'kg'}` }, [formatDetailOrder], ) - //数量格式 + // 数量格式 const numText = useMemo(() => { if (formatDetailOrder) { - let tatal_number = formatDetailOrder?.sale_mode == 0 ? formatDetailOrder?.total_number : formatDetailOrder?.total_number / 100 + const tatal_number = formatDetailOrder?.sale_mode == 0 ? formatDetailOrder?.total_number : formatDetailOrder?.total_number / 100 return `${formatDetailOrder?.total_fabrics} 种面料,${formatDetailOrder?.total_colors} 种颜色,共 ${tatal_number} ${formatDetailOrder?.unit}` } }, [formatDetailOrder]) - //整理颜色 + // 整理颜色 const labAndRgbAndUrl = useCallback((item) => { return { lab: { ...item?.lab }, rgb: { ...item?.rgb }, texturl_url: item?.texturl_url } }, []) return ( <> - + {formatDetailOrder && ( <> @@ -113,7 +113,7 @@ export default memo(({ show, onClose, onSubmit, id }: Param) => { - {colorItem.code + ' ' + colorItem.name} + {`${colorItem.code} ${colorItem.name}`} ¥{standardPrice(colorItem.sale_price)} 总重{formatWeightDiv(colorItem.estimate_weight)}kg diff --git a/src/pages/salesAfter/components/contentBox/index.tsx b/src/pages/salesAfter/components/contentBox/index.tsx index 8a81420..f0069aa 100644 --- a/src/pages/salesAfter/components/contentBox/index.tsx +++ b/src/pages/salesAfter/components/contentBox/index.tsx @@ -1,20 +1,21 @@ -import {View } from "@tarojs/components"; -import { memo, ReactDOM, ReactNode } from "react"; -import styles from './index.module.scss' +import { View } from '@tarojs/components' +import type { ReactNode } from 'react' +import { ReactDOM, memo } from 'react' +import styles from './index.module.scss' -type Param = { - children?: ReactNode, - title?: string +interface Param { + children?: ReactNode + title?: string } -export default memo(({children, title=''}: Param) => { - return ( - <> - - {title} - - {children} - - - - ) -}) \ No newline at end of file +export default memo(({ children, title = '' }: Param) => { + return ( + <> + + {title} + + {children} + + + + ) +}) diff --git a/src/pages/salesAfter/components/estimatedAmount/index.tsx b/src/pages/salesAfter/components/estimatedAmount/index.tsx index 04bc49a..2798f92 100644 --- a/src/pages/salesAfter/components/estimatedAmount/index.tsx +++ b/src/pages/salesAfter/components/estimatedAmount/index.tsx @@ -1,29 +1,30 @@ -import { Text, View } from "@tarojs/components" -import { memo, useCallback, useEffect, useMemo } from "react" -import {formatKbPrice} from '@/common/common' -import classnames from "classnames"; -import styles from './index.module.scss' -import AmountShow from "../amountShow"; -type Param = { - style?: Object, - number?: number, - title?: string, - titleStatus?: true|false, //true 标题加大加深 - numberStatus?: 0|1|2, //数字尺寸 +import { Text, View } from '@tarojs/components' +import { memo, useCallback, useEffect, useMemo } from 'react' +import classnames from 'classnames' +import AmountShow from '../amountShow' +import styles from './index.module.scss' +import { formatKbPrice } from '@/common/common' + +interface Param { + style?: Object + number?: number + title?: string + titleStatus?: true|false // true 标题加大加深 + numberStatus?: 0|1|2 // 数字尺寸 } -export default memo(({style, number = 0, titleStatus = true, title = '', numberStatus = 1}:Param) => { - return ( - <> - - - {title} - - - {/* 123123123121212312312312312 */} - - - - - - ) -}) \ No newline at end of file +export default memo(({ style, number = 0, titleStatus = true, title = '', numberStatus = 1 }: Param) => { + return ( + <> + + + {title} + + + {/* 123123123121212312312312312 */} + + + + + + ) +}) diff --git a/src/pages/salesAfter/components/kindList/index.tsx b/src/pages/salesAfter/components/kindList/index.tsx index c813a0b..e179fc6 100644 --- a/src/pages/salesAfter/components/kindList/index.tsx +++ b/src/pages/salesAfter/components/kindList/index.tsx @@ -1,14 +1,14 @@ -import { AFTER_ORDER_STATUS, ORDER_STATUS, REFUND_STATUS } from '@/common/enum' -import { formatHashTag, formatPriceDiv, formatWeightDiv } from '@/common/fotmat' -import EstimatedAmount from '@/components/estimatedAmount' -import LabAndImg from '@/components/LabAndImg' import { Text, View } from '@tarojs/components' import { memo, useCallback, useMemo } from 'react' import classnames from 'classnames' import styles from './index.module.scss' +import { AFTER_ORDER_STATUS, ORDER_STATUS, REFUND_STATUS } from '@/common/enum' +import { formatHashTag, formatPriceDiv, formatWeightDiv } from '@/common/fotmat' +import EstimatedAmount from '@/components/estimatedAmount' +import LabAndImg from '@/components/LabAndImg' -type OrderParam = { - estimate_amount: number //预估金额 +interface OrderParam { + estimate_amount: number // 预估金额 list: any[] product_list: any[] quality_check_pass_product: any[] @@ -18,27 +18,27 @@ type OrderParam = { total_colors: number total_fabrics: number total_number: number - stage: number //订单状态 - type: 1 | 2 //1退货, 2退款 - refund_type: number //退款状态 - total_sale_price: number //销售金额 - total_should_collect_money: number //应收金额 - total_weight_error_discount: number //空差优惠 - the_previous_status: number //取消订单时的订单状态 - actual_amount: number //实付金额 - quality_check_pass_colors: number //验布后的颜色总数 - quality_check_pass_fabrics: number //验布后的面料数量 - quality_check_pass_number: number //验布后的总数量 - is_quality_check: true | false //是否质检过 + stage: number // 订单状态 + type: 1 | 2 // 1退货, 2退款 + refund_type: number // 退款状态 + total_sale_price: number // 销售金额 + total_should_collect_money: number // 应收金额 + total_weight_error_discount: number // 空差优惠 + the_previous_status: number // 取消订单时的订单状态 + actual_amount: number // 实付金额 + quality_check_pass_colors: number // 验布后的颜色总数 + quality_check_pass_fabrics: number // 验布后的面料数量 + quality_check_pass_number: number // 验布后的总数量 + is_quality_check: true | false // 是否质检过 } -type Param = { +interface Param { order: OrderParam - comfirm?: boolean //是否是确认订单页面使用 + comfirm?: boolean // 是否是确认订单页面使用 } export default memo(({ order, comfirm = false }: Param) => { - //售后单状态枚举 + // 售后单状态枚举 const { ReturnStageApplying, // 申请中 ReturnStageWaitCheck, // 退货中 @@ -50,7 +50,7 @@ export default memo(({ order, comfirm = false }: Param) => { ReturnStageRejected, // 已拒绝 } = AFTER_ORDER_STATUS - //金额列表枚举 + // 金额列表枚举 const priceList = [ { id: 5, @@ -82,7 +82,7 @@ export default memo(({ order, comfirm = false }: Param) => { }, ] - //是否显示价格 + // 是否显示价格 const showPrice = useCallback( (priceInfo) => { return priceInfo.value.includes(order?.stage) @@ -91,7 +91,7 @@ export default memo(({ order, comfirm = false }: Param) => { ) const priceConDom = useMemo(() => { - if (!order) return + if (!order) { return } return ( <> {priceList.map((item) => { @@ -113,7 +113,7 @@ export default memo(({ order, comfirm = false }: Param) => { ) }, [order]) - //对应数量 + // 对应数量 const formatCount = useCallback( (item) => { return order?.sale_mode == 0 ? item.roll : Number(item.length / 100) @@ -121,43 +121,44 @@ export default memo(({ order, comfirm = false }: Param) => { [order], ) - //对应单价 + // 对应单价 const standardPrice = useCallback( (price) => { - return formatPriceDiv(price).toLocaleString() + '/' + (order?.sale_mode == 1 ? 'm' : 'kg') + return `${formatPriceDiv(price).toLocaleString()}/${order?.sale_mode == 1 ? 'm' : 'kg'}` }, [order], ) - //数量格式 + // 数量格式 const numText = useMemo(() => { if (order) { if (!order?.is_quality_check) { - let total_number = order?.sale_mode == 0 ? order?.total_number : order?.total_number / 100 + const total_number = order?.sale_mode == 0 ? order?.total_number : order?.total_number / 100 return `${order?.total_fabrics} 种面料,${order?.total_colors} 种颜色,共 ${total_number} ${order?.unit}` - } else { - let total_number = order?.sale_mode == 0 ? order?.quality_check_pass_number : order?.quality_check_pass_number / 100 + } + else { + const total_number = order?.sale_mode == 0 ? order?.quality_check_pass_number : order?.quality_check_pass_number / 100 return `${order?.quality_check_pass_fabrics} 种面料,${order?.quality_check_pass_colors} 种颜色,共 ${total_number} ${order?.unit}` } } }, [order]) - //获取面料数组 + // 获取面料数组 const list = useMemo(() => { return order?.is_quality_check ? order?.quality_check_pass_product : order?.product_list }, [order]) - //整理颜色 + // 整理颜色 const labAndRgbAndUrl = useCallback((item) => { return { lab: { ...item?.lab }, rgb: { ...item?.rgb }, texturl_url: item?.texturl_url } }, []) - //单价显示判断 + // 单价显示判断 const sale_price_show = useMemo(() => { return order?.stage != ReturnStageServiceOrderPendingRefund.value && order?.stage != ReturnStageQualityCheckPendingRefund.value }, [order]) - //销售价格 + // 销售价格 const formatPrice = useCallback( (colorItem) => { return ( @@ -194,7 +195,7 @@ export default memo(({ order, comfirm = false }: Param) => { - {colorItem.code + ' ' + colorItem.name} + {`${colorItem.code} ${colorItem.name}`} {sale_price_show && ¥{standardPrice(colorItem.sale_price)}} {order?.stage == ReturnStageReturned.value && 总重{formatWeightDiv(colorItem.estimate_weight)}kg} diff --git a/src/pages/salesAfter/components/offlinePay/index.tsx b/src/pages/salesAfter/components/offlinePay/index.tsx index 4022374..d87a51e 100644 --- a/src/pages/salesAfter/components/offlinePay/index.tsx +++ b/src/pages/salesAfter/components/offlinePay/index.tsx @@ -1,52 +1,51 @@ -import { Text, View } from "@tarojs/components"; -import { memo } from "react"; -import AmountShow from "../amountShow"; -import classnames from "classnames"; -import styles from './index.module.scss' +import { Text, View } from '@tarojs/components' +import Taro from '@tarojs/taro' +import { memo } from 'react' +import classnames from 'classnames' +import AmountShow from '../amountShow' +import styles from './index.module.scss' +import MCheckbox from '@/components/checkbox' +import Popup from '@/components/popup' +import SearchInput from '@/components/searchInput' -import MCheckbox from "@/components/checkbox"; -import Popup from "@/components/popup"; -import SearchInput from "@/components/searchInput"; -import Taro from "@tarojs/taro"; - -type Param = { - show?: true|false, - onClose?: () => void +interface Param { + show?: true|false + onClose?: () => void } -export default memo(({show = true, onClose}:Param) => { - //复制功能 - const clipboardData = () => { - Taro.setClipboardData({ - data: '开户名称:佛山市浩川盛世科技有限公司; 开户银行:招商银行汾江支行; 转账汇款账号:62062342120001221231212', - success: function (res) { - Taro.showToast({ - icon: 'none', - title: '复制成功' - }) - } +export default memo(({ show = true, onClose }: Param) => { + // 复制功能 + const clipboardData = () => { + Taro.setClipboardData({ + data: '开户名称:佛山市浩川盛世科技有限公司; 开户银行:招商银行汾江支行; 转账汇款账号:62062342120001221231212', + success(res) { + Taro.showToast({ + icon: 'none', + title: '复制成功', }) - } - return ( - - - - - 线下汇款 - - - 佛山市浩川盛世科技有限公司 - - - 招商银行汾江支行 - - - 62062342120001221231212 - - - 复制信息 - - + }, + }) + } + return ( + + + + + 线下汇款 + + + 佛山市浩川盛世科技有限公司 + + + 招商银行汾江支行 + + + 62062342120001221231212 + + + 复制信息 - - ) -}) \ No newline at end of file + + + + ) +}) diff --git a/src/pages/salesAfter/components/orderState/index.tsx b/src/pages/salesAfter/components/orderState/index.tsx index f5b5d84..a7613bc 100644 --- a/src/pages/salesAfter/components/orderState/index.tsx +++ b/src/pages/salesAfter/components/orderState/index.tsx @@ -1,60 +1,58 @@ -import { Text, View } from "@tarojs/components" -import { memo, useMemo, useState } from "react" -import styles from './index.module.scss' -import classnames from "classnames"; -import { formatDateTime } from "@/common/fotmat"; -import { ORDER_STATUS } from "@/common/enum"; +import { Text, View } from '@tarojs/components' +import { memo, useMemo, useState } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import { formatDateTime } from '@/common/fotmat' +import { ORDER_STATUS } from '@/common/enum' -type List = { - status: string, - time: string, - tag: string, - desc: string, - expire_time: string +interface List { + status: string + time: string + tag: string + desc: string + expire_time: string } -type Param = { - onRefresh?: () => void, - orderInfo?: { - logistics_details:List[], //订单状态列表 - payment_method: number, //支付方式 - status: number, //订单状态 - } +interface Param { + onRefresh?: () => void + orderInfo?: { + logistics_details: List[] // 订单状态列表 + payment_method: number // 支付方式 + status: number // 订单状态 + } } -export default memo(({orderInfo = {logistics_details: [],payment_method: 0, status: 0}, onRefresh}:Param) => { - - const [showMore, setShowMore] = useState(false) - const changeMore = () => { - setShowMore(() => !showMore) - } - const dataList = useMemo(() => { - return orderInfo.logistics_details?orderInfo?.logistics_details.reverse():[] - }, [orderInfo.logistics_details]) +export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => { + const [showMore, setShowMore] = useState(false) + const changeMore = () => { + setShowMore(() => !showMore) + } + const dataList = useMemo(() => { + return orderInfo.logistics_details ? orderInfo?.logistics_details.reverse() : [] + }, [orderInfo.logistics_details]) - //订单状态枚举 - const {SaleorderstatusWaitingPrePayment} = ORDER_STATUS + // 订单状态枚举 + const { SaleorderstatusWaitingPrePayment } = ORDER_STATUS - - return ( - <> - {(dataList?.length > 0)&& - - {dataList.map((item, index) => - {(dataList.length > 1)&&} - {(dataList.length != (index + 1))&&} - - {item.status} - {formatDateTime(item.time)} - - {item.desc} - )} - - {(dataList.length > 2) && changeMore()}> - {showMore&&'收起详情'||'点击查看详情'} - - } - } - - ) + return ( + <> + {(dataList?.length > 0) && + + {dataList.map((item, index) => + {(dataList.length > 1) && } + {(dataList.length != (index + 1)) && } + + {item.status} + {formatDateTime(item.time)} + + {item.desc} + )} + + {(dataList.length > 2) && changeMore()}> + {showMore && '收起详情' || '点击查看详情'} + + } + } + + ) }) diff --git a/src/pages/salesAfter/components/payment/index.tsx b/src/pages/salesAfter/components/payment/index.tsx index 8af70dc..4efb938 100644 --- a/src/pages/salesAfter/components/payment/index.tsx +++ b/src/pages/salesAfter/components/payment/index.tsx @@ -1,185 +1,185 @@ -import { Text, View } from "@tarojs/components"; -import { memo, useCallback, useEffect, useMemo, useState } from "react"; -import AmountShow from "../amountShow"; -import classnames from "classnames"; -import styles from './index.module.scss' +import { Text, View } from '@tarojs/components' +import { memo, useCallback, useEffect, useMemo, useState } from 'react' +import classnames from 'classnames' +import AmountShow from '../amountShow' +import OfflinePay from '../offlinePay' +import ScanPay from '../scanPay' +import styles from './index.module.scss' +import MCheckbox from '@/components/checkbox' +import Popup from '@/components/popup' +import { GetOrderPayApi, SubmitOrderPayApi } from '@/api/orderPay' +import { formatPriceDiv } from '@/common/fotmat' +import { alert } from '@/common/common' +import type { PAYMENT_METHOD_PARAM } from '@/common/enum' +import { PAYMENT_METHOD } from '@/common/enum' -import MCheckbox from "@/components/checkbox"; -import Popup from "@/components/popup"; -import OfflinePay from "../offlinePay"; -import ScanPay from "../scanPay"; -import { GetOrderPayApi, SubmitOrderPayApi } from "@/api/orderPay"; -import { formatPriceDiv } from "@/common/fotmat"; -import {alert} from "@/common/common" -import { PAYMENT_METHOD, PAYMENT_METHOD_PARAM } from "@/common/enum"; - -type Param = { - show?: true|false, - onClose?: () => void, - onSubmitSuccess?: () => void, //支付成功 - orderInfo?: OrderInfo +interface Param { + show?: true|false + onClose?: () => void + onSubmitSuccess?: () => void // 支付成功 + orderInfo?: OrderInfo } -type OrderInfo = { - orderId: number, //应付单id - payment_method: 0|PAYMENT_METHOD_PARAM //支付方式 +interface OrderInfo { + orderId: number // 应付单id + payment_method: 0|PAYMENT_METHOD_PARAM // 支付方式 } -type PayStatus = 1|2|3|4|5|null //1:预存款, 2:账期,3:线下汇款, 4:扫码支付, 5:货到付款 -export default memo(({show = false, onClose, orderInfo, onSubmitSuccess}:Param) => { +type PayStatus = 1|2|3|4|5|null // 1:预存款, 2:账期,3:线下汇款, 4:扫码支付, 5:货到付款 +export default memo(({ show = false, onClose, orderInfo, onSubmitSuccess }: Param) => { + // 提交参数 + const [submitData, setSubmitData] = useState<{ id: number; payment_method: PayStatus }>({ + id: 0, + payment_method: null, + }) - //提交参数 - const [submitData, setSubmitData] = useState<{id:number, payment_method: PayStatus}>({ - id:0, - payment_method: null - }) + // 线下付款 + const [offlinePayShow, setofflinePayShow] = useState(false) + const onShowOfflinePay = () => { + setofflinePayShow(true) + onClose?.() + } - //线下付款 - const [offlinePayShow, setofflinePayShow] = useState(false) - const onShowOfflinePay = () => { - setofflinePayShow(true) - onClose?.() + // 扫码支付 + const [scanPayShow, setScanPayShow] = useState(false) + const onShowScanPay = () => { + setScanPayShow(true) + onClose?.() + } + + // 获取支付方式数据 + const [payInfo, setPayInfo] = useState() + const { fetchData: orderFetchData } = GetOrderPayApi() + const getOrderPay = async() => { + const { data } = await orderFetchData({ id: orderInfo?.orderId }) + setPayInfo(() => data) + } + useEffect(() => { + if (show && orderInfo?.orderId) { + setSubmitData(val => ({ ...val, id: orderInfo.orderId })) + getOrderPay() } + }, [show, orderInfo]) - //扫码支付 - const [scanPayShow, setScanPayShow] = useState(false) - const onShowScanPay = () => { - setScanPayShow(true) - onClose?.() + // 预存款选择 + const advanceSelectData = useCallback((val) => { + setSubmitData(e => ({ ...e, payment_method: val })) + }, []) + + // 账期选择 + const periodSelectData = (val) => { + setSubmitData(e => ({ ...e, payment_method: val })) + } + + // 提交支付 + const { fetchData: submitFetchData } = SubmitOrderPayApi() + const submitPay = async() => { + if (submitData.payment_method === null) { + alert.error('请选择支付方式') + return false } - - //获取支付方式数据 - const [payInfo, setPayInfo] = useState() - const {fetchData: orderFetchData} = GetOrderPayApi() - const getOrderPay = async () => { - let {data} = await orderFetchData({id: orderInfo?.orderId}) - setPayInfo(() => data) + alert.loading('正在支付') + const res = await submitFetchData(submitData) + if (res.success) { + alert.success('支付成功') + onSubmitSuccess?.() + } + else { + alert.none(res.msg) } - useEffect(() => { - if(show&&orderInfo?.orderId) { - setSubmitData((val) => ({...val, id:orderInfo.orderId})) - getOrderPay() - } - }, [show, orderInfo]) - - //预存款选择 - const advanceSelectData = useCallback((val) => { - setSubmitData((e) => ({...e, payment_method:val})) - }, []) - - //账期选择 - const periodSelectData = (val) => { - setSubmitData((e) => ({...e, payment_method:val})) - } - - //提交支付 - const {fetchData: submitFetchData} = SubmitOrderPayApi() - const submitPay = async () => { - if(submitData.payment_method === null) { - alert.error('请选择支付方式') - return false - } - alert.loading('正在支付') - let res = await submitFetchData(submitData) - if(res.success) { - alert.success('支付成功') - onSubmitSuccess?.() - } else { - alert.none(res.msg) - } - } - - //预付款 - const advance_payment = useMemo(() => { - const price = payInfo?.should_collect_money - payInfo?.amount_paid - return ( - {(payInfo?.advance_deposit_balance < price)&&'余额不足,' }剩余 ¥{formatPriceDiv(payInfo?.advance_deposit_balance)} - ) - }, [payInfo]) - - //账期 - const account_peyment = useMemo(() => { - const price = payInfo?.should_collect_money - payInfo?.amount_paid - return ( - {(payInfo?.account_period < price)&&'额度不足, '}剩余 ¥{formatPriceDiv(payInfo?.account_period_credit_available_line)} - ) - }, [payInfo]) - - //支付方式枚举 - const {PaymentMethodPreDeposit, PaymentMethodAccountPeriod} = PAYMENT_METHOD + } + // 预付款 + const advance_payment = useMemo(() => { + const price = payInfo?.should_collect_money - payInfo?.amount_paid return ( - - - - - 订单支付 - - - - - - - {/* 向商家发起支付 */} - - - 订单金额 - ¥{formatPriceDiv(payInfo?.should_collect_money)} - - - 已付金额 - ¥{formatPriceDiv(payInfo?.amount_paid)} - - - - - - - - - 预存款 - - {advance_payment} - - advanceSelectData(PaymentMethodPreDeposit.value)} onClose={() => advanceSelectData(null)}/> - - {(orderInfo?.payment_method != PaymentMethodAccountPeriod.value)&& - - - - {payInfo?.account_period}天账期 - - {/* 可用额度 ¥{formatPriceDiv(payInfo?.account_period_credit_available_line)} */} - {account_peyment} - - periodSelectData(PaymentMethodAccountPeriod.value)} onClose={() => periodSelectData(null)}/> - } - - - - - 线下汇款 - - - - - - - - - 扫码支付 - - - - - - - 确认交易 - - - setofflinePayShow(false)}/> - setScanPayShow(false)}/> - - + {(payInfo?.advance_deposit_balance < price) && '余额不足,' }剩余 ¥{formatPriceDiv(payInfo?.advance_deposit_balance)} ) -}) \ No newline at end of file + }, [payInfo]) + + // 账期 + const account_peyment = useMemo(() => { + const price = payInfo?.should_collect_money - payInfo?.amount_paid + return ( + {(payInfo?.account_period < price) && '额度不足, '}剩余 ¥{formatPriceDiv(payInfo?.account_period_credit_available_line)} + ) + }, [payInfo]) + + // 支付方式枚举 + const { PaymentMethodPreDeposit, PaymentMethodAccountPeriod } = PAYMENT_METHOD + + return ( + + + + + 订单支付 + + + + + + + {/* 向商家发起支付 */} + + + 订单金额 + ¥{formatPriceDiv(payInfo?.should_collect_money)} + + + 已付金额 + ¥{formatPriceDiv(payInfo?.amount_paid)} + + + + + + + + + 预存款 + + {advance_payment} + + advanceSelectData(PaymentMethodPreDeposit.value)} onClose={() => advanceSelectData(null)} /> + + {(orderInfo?.payment_method != PaymentMethodAccountPeriod.value) && + + + + {payInfo?.account_period}天账期 + + {/* 可用额度 ¥{formatPriceDiv(payInfo?.account_period_credit_available_line)} */} + {account_peyment} + + periodSelectData(PaymentMethodAccountPeriod.value)} onClose={() => periodSelectData(null)} /> + } + + + + + 线下汇款 + + + + + + + + + 扫码支付 + + + + + + + 确认交易 + + + setofflinePayShow(false)} /> + setScanPayShow(false)} /> + + + ) +}) diff --git a/src/pages/salesAfter/components/remark/index.tsx b/src/pages/salesAfter/components/remark/index.tsx index 14d981b..27e41eb 100644 --- a/src/pages/salesAfter/components/remark/index.tsx +++ b/src/pages/salesAfter/components/remark/index.tsx @@ -1,38 +1,38 @@ -import Popup from "@/components/popup" -import { Textarea, View } from "@tarojs/components" -import { useCallback, useState } from "react" -import styles from './index.module.scss' +import { Textarea, View } from '@tarojs/components' +import { useCallback, useState } from 'react' +import styles from './index.module.scss' +import Popup from '@/components/popup' -type Param = { - onBlur?: (val:any) => void - onSave?: (val: string) => void +interface Param { + onBlur?: (val: any) => void + onSave?: (val: string) => void } -export default ({onBlur, onSave}:Param) => { - const [descData, setDescData] = useState({ - number: 0, - value: '', - count: 200 - }) - const getDesc = useCallback((e) => { - let value = e.detail.value - let res = value - if(value.length > descData.count) { - res = value.slice(0, descData.count) - } - setDescData({...descData, number:res.length, value: res}) - },[]) - - const setSave = () => { - onSave?.(descData.value) +export default ({ onBlur, onSave }: Param) => { + const [descData, setDescData] = useState({ + number: 0, + value: '', + count: 200, + }) + const getDesc = useCallback((e) => { + const value = e.detail.value + let res = value + if (value.length > descData.count) { + res = value.slice(0, descData.count) } - return ( - - 编辑备注 - - - {descData.number}/{descData.count} - - setSave()}>保存 - - ) -} \ No newline at end of file + setDescData({ ...descData, number: res.length, value: res }) + }, []) + + const setSave = () => { + onSave?.(descData.value) + } + return ( + + 编辑备注 + + + {descData.number}/{descData.count} + + setSave()}>保存 + + ) +} diff --git a/src/pages/salesAfter/components/returnLogistics/index.tsx b/src/pages/salesAfter/components/returnLogistics/index.tsx index c51c38e..20c1712 100644 --- a/src/pages/salesAfter/components/returnLogistics/index.tsx +++ b/src/pages/salesAfter/components/returnLogistics/index.tsx @@ -1,51 +1,52 @@ -import Popup from '@/components/popup' import { Text, View } from '@tarojs/components' import { memo, useCallback, useEffect, useRef, useState } from 'react' -import UploadImage from '@/components/uploadImage' import styles from './index.module.scss' +import UploadImage from '@/components/uploadImage' +import Popup from '@/components/popup' import TextareaEnhance from '@/components/textareaEnhance' import { ReturnApplyLogisticsApi } from '@/api/salesAfterOrder' import { alert } from '@/common/common' -type Param = { +interface Param { show?: true | false onClose?: () => void onSubmit?: () => void - id?: number //订单id - images: string[] //图片列表 - descValue?: string //描述 - onlyRead?: false | true //true 只读 + id?: number // 订单id + images: string[] // 图片列表 + descValue?: string // 描述 + onlyRead?: false | true // true 只读 } export default memo(({ show = false, onClose, onSubmit, id = 0, images = [], descValue = '', onlyRead = false }: Param) => { - //需要提交的数据 + // 需要提交的数据 const submitData = useRef({ accessory_url: [], remark: '', id: 0, }) useEffect(() => { - if (id) submitData.current.id = id + if (id) { submitData.current.id = id } }, [id]) - //获取图片列表 + // 获取图片列表 const getImageList = useCallback((list) => { submitData.current.accessory_url = list }, []) - //备注 + // 备注 const getOtherReason = useCallback((val) => { submitData.current.remark = val }, []) - //确定 + // 确定 const { fetchData } = ReturnApplyLogisticsApi() - const onSubmitEven = async () => { - if (!id) return alert.error('参数有误') - if (submitData.current.accessory_url.length <= 0) return alert.error('请上传附件') - let res = await fetchData(submitData.current) + const onSubmitEven = async() => { + if (!id) { return alert.error('参数有误') } + if (submitData.current.accessory_url.length <= 0) { return alert.error('请上传附件') } + const res = await fetchData(submitData.current) if (res.success) { alert.success('上传成功') - } else { + } + else { alert.error('上传失败') } onSubmit?.() @@ -62,7 +63,7 @@ export default memo(({ show = false, onClose, onSubmit, id = 0, images = [], des - + {!onlyRead && ( diff --git a/src/pages/salesAfter/components/returnPayCheck/index.tsx b/src/pages/salesAfter/components/returnPayCheck/index.tsx index b7a1e93..59c7e9d 100644 --- a/src/pages/salesAfter/components/returnPayCheck/index.tsx +++ b/src/pages/salesAfter/components/returnPayCheck/index.tsx @@ -1,23 +1,23 @@ import { Image, ScrollView, Text, View } from '@tarojs/components' +import Taro from '@tarojs/taro' import { memo, useEffect, useMemo, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import Popup from '@/components/popup' -import Taro from '@tarojs/taro' import { alert } from '@/common/common' import { formatDateTime, formatPriceDiv, formatRemoveHashTag, formatWeightDiv } from '@/common/fotmat' import useCheckAuthorize from '@/use/useCheckAuthorize' import { GetReturnPayCode } from '@/api/onlinePay' import LoadingCard from '@/components/loadingCard' -type Param = { +interface Param { show?: true | false onClose?: () => void company?: string qrcode?: string orderInfo?: any } -type ListParam = { +interface ListParam { product_code: string product_name: string product_color_code: string @@ -45,7 +45,7 @@ export default memo(({ show = true, onClose, orderInfo }: Param) => { useEffect(() => { if (orderInfo) { - let lists: ListParam[] = [] + const lists: ListParam[] = [] product_list?.map((pitem) => { pitem?.product_colors?.map((citem) => { lists.push({ @@ -57,7 +57,7 @@ export default memo(({ show = true, onClose, orderInfo }: Param) => { length: (citem.length / 100).toString(), weight: formatWeightDiv(citem.label_weight).toString(), sale_price: formatPriceDiv(citem.sale_price).toString(), - total_price: formatPriceDiv(citem.refund_amount).toString(), //小计 + total_price: formatPriceDiv(citem.refund_amount).toString(), // 小计 weight_error: formatWeightDiv(citem.settle_weight_error).toString(), deduction_weight: formatWeightDiv(citem.deductions_weight).toString(), settle_weight: formatWeightDiv(citem.settle_weight).toString(), @@ -67,7 +67,7 @@ export default memo(({ show = true, onClose, orderInfo }: Param) => { }) setDetail(() => ({ title: '售后确认单', - order_type: orderInfo.sale_mode_name, //类型:大货 + order_type: orderInfo.sale_mode_name, // 类型:大货 client: orderInfo.purchaser_name, order_created_time: formatDateTime(orderInfo.create_time), order_no: orderInfo.return_order_no, @@ -91,39 +91,40 @@ export default memo(({ show = true, onClose, orderInfo }: Param) => { } }, [orderInfo]) - //收货地址 + // 收货地址 const address = (addressInfo) => { if (addressInfo?.shipment_mode == 2) { return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : '' - } else { + } + else { return addressInfo?.take_goods_address } } - //收件人 + // 收件人 const userName = (addressInfo) => { return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : '' } - //手机号 + // 手机号 const userPhone = (addressInfo) => { return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone } - //获取支付二维码 + // 获取支付二维码 const [payCodeImage, setPayCodeImage] = useState('') const fileData = useRef({ filePath: '', base64: '', }) const { fetchData, state } = GetReturnPayCode() - const getCore = async () => { - let res = await fetchData(detail) + const getCore = async() => { + const res = await fetchData(detail) const base64 = res.data.base64 setPayCodeImage(() => base64) const time = new Date().valueOf() const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || [] - let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format + const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}` fileData.current.filePath = filePath fileData.current.base64 = bodyData const save = Taro.getFileSystemManager() @@ -134,28 +135,28 @@ export default memo(({ show = true, onClose, orderInfo }: Param) => { }) } - //检查是否开启保存图片权限 + // 检查是否开启保存图片权限 const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' }) - const saveImageCheck = async () => { + const saveImageCheck = async() => { const res = await check() res && saveImage() } - //保存图片 + // 保存图片 const saveImage = () => { alert.loading('正在保存图片') Taro.saveImageToPhotosAlbum({ filePath: fileData.current.filePath, - success: function () { + success() { alert.success('图片保存成功') }, - fail: function (err) { + fail(err) { console.log('err::', err) }, }) } - //预览图片 + // 预览图片 const showImage = () => { console.log('fileData.current.filePath::', fileData.current.filePath) Taro.previewImage({ @@ -164,7 +165,7 @@ export default memo(({ show = true, onClose, orderInfo }: Param) => { }) } - //复制功能 + // 复制功能 return ( @@ -174,7 +175,7 @@ export default memo(({ show = true, onClose, orderInfo }: Param) => { {(state.loading && ) || ( - + )} diff --git a/src/pages/salesAfter/components/scanPay/index.tsx b/src/pages/salesAfter/components/scanPay/index.tsx index 6480100..4625be5 100644 --- a/src/pages/salesAfter/components/scanPay/index.tsx +++ b/src/pages/salesAfter/components/scanPay/index.tsx @@ -1,21 +1,21 @@ import { Image, ScrollView, Text, View } from '@tarojs/components' +import Taro from '@tarojs/taro' import { memo, useEffect, useRef, useState } from 'react' import classnames from 'classnames' import styles from './index.module.scss' import Popup from '@/components/popup' -import Taro from '@tarojs/taro' import { alert } from '@/common/common' import { formatImgUrl } from '@/common/fotmat' import useCheckAuthorize from '@/use/useCheckAuthorize' import { GetPayCode } from '@/api/onlinePay' import LoadingCard from '@/components/loadingCard' -type Param = { +interface Param { show?: true | false onClose?: () => void } -type Item = { +interface Item { product_code: string product_name: string product_color_code: string @@ -25,7 +25,7 @@ type Item = { sale_price: string total_price: string } -type CodeParam = { +interface CodeParam { title: string company: string order_type: string @@ -50,15 +50,15 @@ type CodeParam = { list: Item[] } export default memo(({ show = true, onClose }: Param) => { - //获取支付二维码 + // 获取支付二维码 const [payCodeImage, setPayCodeImage] = useState('') const fileData = useRef({ filePath: '', base64: '', }) const { fetchData, state } = GetPayCode() - const getCore = async () => { - let res = await fetchData({ + const getCore = async() => { + const res = await fetchData({ title: '面料销售电子确认单', company: '什么什么公司123', order_type: '散剪', @@ -97,7 +97,7 @@ export default memo(({ show = true, onClose }: Param) => { setPayCodeImage(() => base64) const time = new Date().valueOf() const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || [] - let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format + const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}` fileData.current.filePath = filePath fileData.current.base64 = bodyData const save = Taro.getFileSystemManager() @@ -108,31 +108,31 @@ export default memo(({ show = true, onClose }: Param) => { }) } useEffect(() => { - if (show) getCore() + if (show) { getCore() } }, [show]) - //检查是否开启保存图片权限 + // 检查是否开启保存图片权限 const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' }) - const saveImageCheck = async () => { + const saveImageCheck = async() => { const res = await check() res && saveImage() } - //保存图片 + // 保存图片 const saveImage = () => { alert.loading('正在保存图片') Taro.saveImageToPhotosAlbum({ filePath: fileData.current.filePath, - success: function (res) { + success(res) { alert.success('图片保存成功') }, - fail: function (err) { + fail(err) { console.log('err::', err) }, }) } - //预览图片 + // 预览图片 const showImage = () => { console.log('fileData.current.filePath::', fileData.current.filePath) Taro.previewImage({ @@ -141,7 +141,7 @@ export default memo(({ show = true, onClose }: Param) => { }) } - //复制功能 + // 复制功能 return ( @@ -155,7 +155,7 @@ export default memo(({ show = true, onClose }: Param) => { {(state.loading && ) || ( - + )} diff --git a/src/pages/salesAfter/components/shipmentMode/index.tsx b/src/pages/salesAfter/components/shipmentMode/index.tsx index 235591c..fcae893 100644 --- a/src/pages/salesAfter/components/shipmentMode/index.tsx +++ b/src/pages/salesAfter/components/shipmentMode/index.tsx @@ -1,28 +1,28 @@ -import { Text, View } from "@tarojs/components" -import styles from './index.module.scss' -import classnames from "classnames"; -import { memo, useRef, useState } from "react"; +import { Text, View } from '@tarojs/components' +import classnames from 'classnames' +import { memo, useRef, useState } from 'react' +import styles from './index.module.scss' -type Param = { - onSelect?:(val:number) => void +interface Param { + onSelect?: (val: number) => void } -export default memo(({onSelect}: Param) => { - //收货方法 1:自提,2:物流 - const shipmentMode = useRef([ - {value:1, label:'上门自提', selected:false}, - {value:2, label:'物流', selected:false} - ]) - const [selectValue, setSelectValue] = useState() - const selectShipmentMode = (value) => { - setSelectValue(() => value) - onSelect?.(value) - } - return ( - - 收货方式 - {shipmentMode.current.map(item => { - return selectShipmentMode(item.value)}>{item.label} - })} - - ) -}) \ No newline at end of file +export default memo(({ onSelect }: Param) => { + // 收货方法 1:自提,2:物流 + const shipmentMode = useRef([ + { value: 1, label: '上门自提', selected: false }, + { value: 2, label: '物流', selected: false }, + ]) + const [selectValue, setSelectValue] = useState() + const selectShipmentMode = (value) => { + setSelectValue(() => value) + onSelect?.(value) + } + return ( + + 收货方式 + {shipmentMode.current.map((item) => { + return selectShipmentMode(item.value)}>{item.label} + })} + + ) +}) diff --git a/src/pages/salesAfter/components/submitOrderBtn/index.tsx b/src/pages/salesAfter/components/submitOrderBtn/index.tsx index db9b432..b559292 100644 --- a/src/pages/salesAfter/components/submitOrderBtn/index.tsx +++ b/src/pages/salesAfter/components/submitOrderBtn/index.tsx @@ -1,40 +1,41 @@ -import { Text, View } from "@tarojs/components" -import { memo, useCallback, useEffect, useMemo } from "react" -import {formatKbPrice} from '@/common/common' -import classnames from "classnames"; -import styles from './index.module.scss' -type Param = { - style?: Object, - number?: number +import { Text, View } from '@tarojs/components' +import { memo, useCallback, useEffect, useMemo } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import { formatKbPrice } from '@/common/common' + +interface Param { + style?: Object + number?: number } -export default memo(({style, number = 0}:Param) => { - const priceDom = useCallback(() => { - let res = number.toFixed(2).split('.') - let int_num = parseInt(res[0]) + '' - let decimals_num = res[1] - return ( - <> - ¥ - {Number(int_num).toLocaleString()} - .{decimals_num} - - ) - }, [number]) +export default memo(({ style, number = 0 }: Param) => { + const priceDom = useCallback(() => { + const res = number.toFixed(2).split('.') + const int_num = `${parseInt(res[0])}` + const decimals_num = res[1] return ( - <> - - - 应付金额 - - - {/* 123123123121212312312312312 */} - - - - {priceDom()} - - - - + <> + ¥ + {Number(int_num).toLocaleString()} + .{decimals_num} + ) -}) \ No newline at end of file + }, [number]) + return ( + <> + + + 应付金额 + + + {/* 123123123121212312312312312 */} + + + + {priceDom()} + + + + + ) +}) diff --git a/src/pages/salesAfter/components/weightMemo/index.tsx b/src/pages/salesAfter/components/weightMemo/index.tsx index 7cbfd13..7ce2889 100644 --- a/src/pages/salesAfter/components/weightMemo/index.tsx +++ b/src/pages/salesAfter/components/weightMemo/index.tsx @@ -1,36 +1,36 @@ -import Popup from "@/components/popup" -import { Text, Textarea, View } from "@tarojs/components" -import { memo, useCallback, useState } from "react" -import styles from './index.module.scss' -import classnames from "classnames"; +import { Text, Textarea, View } from '@tarojs/components' +import { memo, useCallback, useState } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import Popup from '@/components/popup' -type Param = { - onCheck?: () => void - onCustom?: () => void +interface Param { + onCheck?: () => void + onCustom?: () => void } -export default memo(({onCheck, onCustom}:Param) => { - return ( - - onCheck?.()}> - - - 陆盈纺织 - - - 查看原码单 - - - - onCustom?.()}> - - - 我的码单 - - - 自定义 - - - +export default memo(({ onCheck, onCustom }: Param) => { + return ( + + onCheck?.()}> + + + 陆盈纺织 - ) -}) \ No newline at end of file + + 查看原码单 + + + + onCustom?.()}> + + + 我的码单 + + + 自定义 + + + + + ) +}) diff --git a/src/pages/salesAfter/index.tsx b/src/pages/salesAfter/index.tsx index f7185f8..28ff014 100644 --- a/src/pages/salesAfter/index.tsx +++ b/src/pages/salesAfter/index.tsx @@ -1,13 +1,7 @@ -import { SaleOrderOrderDetailApi } from '@/api/salesAfterOrder' -import { AFTER_ORDER_STATUS, ORDER_STATUS } from '@/common/enum' -import { formatDateTime, formatImgUrl, formatPriceDiv } from '@/common/fotmat' -import AfterOrderBtns from '@/components/afterOrderBtns' -import SearchInput from '@/components/searchInput' -import useLogin from '@/use/useLogin' import { Image, Text, Textarea, View } from '@tarojs/components' import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro' import classnames from 'classnames' -import { useCallback, useEffect, useMemo, useRef, useState, memo } from 'react' +import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import AddressInfoDetail from './components/addressInfoDetail' import ApplyRecord from './components/applyRecord' import ContentBox from './components/contentBox' @@ -16,6 +10,12 @@ import OrderState from './components/orderState' import ReturnLogistics from './components/returnLogistics' import ReturnPayCheck from './components/returnPayCheck' import styles from './index.module.scss' +import useLogin from '@/use/useLogin' +import SearchInput from '@/components/searchInput' +import AfterOrderBtns from '@/components/afterOrderBtns' +import { formatDateTime, formatImgUrl, formatPriceDiv } from '@/common/fotmat' +import { AFTER_ORDER_STATUS, ORDER_STATUS } from '@/common/enum' +import { SaleOrderOrderDetailApi } from '@/api/salesAfterOrder' export default () => { useLogin() @@ -25,86 +25,89 @@ export default () => { getSaleOrderPreView() }) - //获取订单详情 - const [orderDetail, setOrderDetail] = useState() //获取到的原始数据 + // 获取订单详情 + const [orderDetail, setOrderDetail] = useState() // 获取到的原始数据 const { fetchData: saleOrderOrderDetailData } = SaleOrderOrderDetailApi() - const getSaleOrderPreView = async () => { + const getSaleOrderPreView = async() => { if (orderId.current) { - let res = await saleOrderOrderDetailData({ id: orderId.current }) + const res = await saleOrderOrderDetailData({ id: orderId.current }) setOrderDetail(res.data) } Taro.stopPullDownRefresh() } - //监听获取到的数据 + // 监听获取到的数据 useEffect(() => { - if (orderDetail) formatData() + if (orderDetail) { formatData() } }, [orderDetail]) - //格式化数据格式 - const [formatDetailOrder, setFormatDetailOrder] = useState() //格式化后的数据 + // 格式化数据格式 + const [formatDetailOrder, setFormatDetailOrder] = useState() // 格式化后的数据 const formatData = () => { setFormatDetailOrder({ ...orderDetail, - unit: orderDetail.sale_mode == 0 ? '条' : 'm', //单位 + unit: orderDetail.sale_mode == 0 ? '条' : 'm', // 单位 }) } const formatPreViewOrderMemo = useMemo(() => { return formatDetailOrder }, [formatDetailOrder]) - //获取底部按钮点击, 获取按钮状态 + // 获取底部按钮点击, 获取按钮状态 const orderStateClick = useCallback( (val) => { if (val == 1 || val == 6) { getSaleOrderPreView() - } else if (val == 8) { - //申请记录 + } + else if (val == 8) { + // 申请记录 setApplyRecord(true) - } else if (val == 5) { + } + else if (val == 5) { onShowLogistics(1) - } else if (val == 7) { + } + else if (val == 7) { setReturnCodeShow(true) } }, [orderDetail], ) - //页面下拉刷新 + // 页面下拉刷新 usePullDownRefresh(() => { getSaleOrderPreView() }) - //按钮所需数据 + // 按钮所需数据 const orderInfo = useMemo(() => { return { ...orderDetail, } }, [orderDetail]) - //售后订单状态枚举 + // 售后订单状态枚举 const {} = AFTER_ORDER_STATUS - //物流显示 + // 物流显示 const [logisticsShow, setLogisticsShow] = useState(false) const [logistics, setLogistics] = useState(false) const onShowLogistics = useCallback((val) => { setLogisticsShow(true) - if (val != 1) setLogistics(true) + if (val != 1) { setLogistics(true) } }, []) const onCloseLogistics = useCallback(() => { setLogisticsShow(false) }, []) - //物流成功上传 + // 物流成功上传 const logisticsSuccess = useCallback(() => { setLogisticsShow(false) getSaleOrderPreView() }, []) - //显示记录 + // 显示记录 const [applyRecord, setApplyRecord] = useState(false) - //显示码单 + // 显示码单 const [returnCodeShow, setReturnCodeShow] = useState(false) return ( @@ -126,17 +129,17 @@ export default () => { /> setApplyRecord(false)} /> setReturnCodeShow(false)} /> - + ) } const OrderDes = memo(({ orderInfo }: { orderInfo?: any }) => { - //复制功能 + // 复制功能 const clipboardData = (val) => { Taro.setClipboardData({ data: val, - success: function (res) { + success(res) { Taro.showToast({ icon: 'none', title: '复制成功', @@ -147,7 +150,7 @@ const OrderDes = memo(({ orderInfo }: { orderInfo?: any }) => { return ( 订单信息 - + {orderInfo?.return_order_no} clipboardData(orderInfo?.return_order_no)}> @@ -155,7 +158,7 @@ const OrderDes = memo(({ orderInfo }: { orderInfo?: any }) => { - + {orderInfo?.order_no} clipboardData(orderInfo?.order_no)}> @@ -163,19 +166,19 @@ const OrderDes = memo(({ orderInfo }: { orderInfo?: any }) => { - + {orderInfo?.return_reason_name} - + {orderInfo?.return_explain_name} - + {orderInfo?.goods_status_name} - + {formatDateTime(orderInfo?.apply_time)} - + {orderInfo?.reason_describe} @@ -184,13 +187,13 @@ const OrderDes = memo(({ orderInfo }: { orderInfo?: any }) => { const AfterSalePricture = memo(({ urls = [] }: { urls: string[] }) => { const showList = useMemo(() => { - let res = urls.map((item) => { + const res = urls.map((item) => { return formatImgUrl(item, '!w800') }) return res }, [urls]) - //预览图片 + // 预览图片 const showImage = () => { Taro.previewImage({ current: showList[0], // 当前显示 @@ -198,9 +201,9 @@ const AfterSalePricture = memo(({ urls = [] }: { urls: string[] }) => { }) } return ( - + - {urls?.map((item) => ( + {urls?.map(item => ( diff --git a/src/pages/salesAfter/salesAfterList/components/order/index.tsx b/src/pages/salesAfter/salesAfterList/components/order/index.tsx index e32fe8e..d59384d 100644 --- a/src/pages/salesAfter/salesAfterList/components/order/index.tsx +++ b/src/pages/salesAfter/salesAfterList/components/order/index.tsx @@ -1,16 +1,16 @@ +import { Image, Text, View } from '@tarojs/components' +import classnames from 'classnames' +import { memo, useCallback, useMemo, useRef, useState } from 'react' +import OrderStatusTag from '../orderStatusTag' +import styles from './index.module.scss' import { goLink } from '@/common/common' import { AFTER_ORDER_STATUS, REFUND_STATUS_ORDER } from '@/common/enum' import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat' import AfterOrderBtns from '@/components/afterOrderBtns' import LabAndImg from '@/components/LabAndImg' import { useSelector } from '@/reducers/hooks' -import { Image, Text, View } from '@tarojs/components' -import classnames from 'classnames' -import { memo, useCallback, useMemo, useRef, useState } from 'react' -import OrderStatusTag from '../orderStatusTag' -import styles from './index.module.scss' -type Param = { +interface Param { value: { order_no: string return_order_no: string @@ -27,12 +27,12 @@ type Param = { lab: { l: number; a: number; b: number } rgb: { r: number; g: number; b: number } texturl_url: string - type: number //2 退货 1 预收退款 3 销售 - return_apply_order_id: number //退款申请单 + type: number // 2 退货 1 预收退款 3 销售 + return_apply_order_id: number // 退款申请单 refund_amount: number // 退款金额 is_quality_check: true | false - accessory_url: string[] //物流图片 - take_goods_remark: string //物流备注 + accessory_url: string[] // 物流图片 + take_goods_remark: string // 物流备注 quality_check_pass_product: any[] quality_check_pass_number: number quality_check_pass_fabrics: number @@ -41,23 +41,23 @@ type Param = { onClickBtn?: (val: { status: number; orderInfo: Param['value'] }) => void } export default memo(({ value, onClickBtn }: Param) => { - const userInfo = useSelector((state) => state.userInfo) - //对应数量 + const userInfo = useSelector(state => state.userInfo) + // 对应数量 const formatCount = useCallback( (item, sale_mode) => { - return sale_mode == 0 ? item.roll + '条' : Number(item.length / 100) + '米' + return sale_mode == 0 ? `${item.roll}条` : `${Number(item.length / 100)}米` }, [value], ) - //对应单价 + // 对应单价 const standardPrice = useCallback( (price, sale_mode) => { - return formatPriceDiv(price).toLocaleString() + '/' + (sale_mode == 1 ? 'm' : 'kg') + return `${formatPriceDiv(price).toLocaleString()}/${sale_mode == 1 ? 'm' : 'kg'}` }, [value], ) - //点击订单按钮 + // 点击订单按钮 const orderBtnsClick = useCallback( (status) => { onClickBtn?.({ status, orderInfo: value }) @@ -65,12 +65,12 @@ export default memo(({ value, onClickBtn }: Param) => { [value], ) - //按钮所需数据 + // 按钮所需数据 const orderInfo = useMemo(() => { return value }, [value]) - //整理颜色 + // 整理颜色 const labAndRgbAndUrl = useMemo(() => { return { lab: { ...value?.lab }, rgb: { ...value?.rgb }, texturl_url: value?.texturl_url } }, [value]) @@ -81,25 +81,26 @@ export default memo(({ value, onClickBtn }: Param) => { const numText = useMemo(() => { if (!value?.is_quality_check) { - let total_number_new = value?.sale_mode == 0 ? value?.total_number : value?.total_number / 100 + const total_number_new = value?.sale_mode == 0 ? value?.total_number : value?.total_number / 100 return `${value?.total_fabrics} 种面料,${value?.total_colors} 种颜色,共 ${total_number_new}${value?.sale_mode == 0 ? ' 条' : ' 米'}` - } else { - let total_number_new = value?.sale_mode == 0 ? value?.quality_check_pass_number : value?.quality_check_pass_number / 100 + } + else { + const total_number_new = value?.sale_mode == 0 ? value?.quality_check_pass_number : value?.quality_check_pass_number / 100 return `${value?.quality_check_pass_fabrics} 种面料,${value?.quality_check_pass_colors} 种颜色,共 ${total_number_new}${ value?.sale_mode == 0 ? ' 条' : ' 米' }` } }, [value]) - //售后单状态 + // 售后单状态 const { ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund, ReturnStageReturned } = AFTER_ORDER_STATUS const stage_name = useMemo(() => { return [ReturnStageQualityCheckPendingRefund.value, ReturnStageServiceOrderPendingRefund.value].includes(value?.stage) ? '待退款' : value?.stage_name }, [value]) - //获取面料数组 + // 获取面料数组 const list = useMemo(() => { - let res = value?.is_quality_check ? value?.quality_check_pass_product : value?.product_list + const res = value?.is_quality_check ? value?.quality_check_pass_product : value?.product_list return res || [] }, [value]) diff --git a/src/pages/salesAfter/salesAfterList/components/orderStatusList/index.tsx b/src/pages/salesAfter/salesAfterList/components/orderStatusList/index.tsx index 3e12f6f..62439f1 100644 --- a/src/pages/salesAfter/salesAfterList/components/orderStatusList/index.tsx +++ b/src/pages/salesAfter/salesAfterList/components/orderStatusList/index.tsx @@ -1,46 +1,45 @@ -import { ScrollView, View } from "@tarojs/components" -import { memo, useEffect, useState } from "react" -import styles from './index.module.scss' -import classnames from "classnames"; +import { ScrollView, View } from '@tarojs/components' +import { memo, useEffect, useState } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' -type Param = { - list: {id: number, name: string}[], - defaultId?: number|null, - onSelect?: (val: number) => void +interface Param { + list: { id: number; name: string }[] + defaultId?: number|null + onSelect?: (val: number) => void } -export default memo(({list = [], defaultId = null, onSelect}: Param) => { - const [selectInfo, setSelectInfo] = useState({ - selected: -1, //当前选中的id - tabId: '', //需要滚动到的id - }) - useEffect(() => { - if(defaultId) { - const index = list?.findIndex(item => { - console.log(item.id, defaultId) - return item.id == defaultId - }) - if(index !== -1) { - const num = index > 0?( index - 1) : 0 - setSelectInfo((e) => ({...e, tabId:list[num].id.toString()})) - } - } - }, [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) +export default memo(({ list = [], defaultId = null, onSelect }: Param) => { + const [selectInfo, setSelectInfo] = useState({ + selected: -1, // 当前选中的id + tabId: '', // 需要滚动到的id + }) + useEffect(() => { + if (defaultId) { + const index = list?.findIndex((item) => { + console.log(item.id, defaultId) + return item.id == defaultId + }) + if (index !== -1) { + const num = index > 0 ? (index - 1) : 0 + setSelectInfo(e => ({ ...e, tabId: list[num].id.toString() })) + } } + }, [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 ( - - - - {list.map((item, index) => { - return clickEvent({item, index})} className={classnames(styles.order_status_item, (selectInfo.selected==item.id)&&styles.selected)}>{item.name} - })} - - + return ( + + + + {list.map((item, index) => { + return clickEvent({ item, index })} className={classnames(styles.order_status_item, (selectInfo.selected == item.id) && styles.selected)}>{item.name} + })} - ) + + + ) }) - diff --git a/src/pages/salesAfter/salesAfterList/components/orderStatusTag/index.tsx b/src/pages/salesAfter/salesAfterList/components/orderStatusTag/index.tsx index 968fe99..66ce2c7 100644 --- a/src/pages/salesAfter/salesAfterList/components/orderStatusTag/index.tsx +++ b/src/pages/salesAfter/salesAfterList/components/orderStatusTag/index.tsx @@ -1,25 +1,24 @@ -import { Text, View } from "@tarojs/components" -import { memo } from "react" -import classnames from "classnames"; -import styles from './index.module.scss' -import { REFUND_STATUS_ORDER } from "@/common/enum"; +import { Text, View } from '@tarojs/components' +import { memo } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import { REFUND_STATUS_ORDER } from '@/common/enum' - -type Param = { - status?: number +interface Param { + status?: number } -export default memo(({status = 0}:Param) => { - const { - ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款 - ReturnApplyOrderTypeReturnForRefund, // 退货退款 - ReturnApplyOrderTypeSalesRefund // 销售退款 - } = REFUND_STATUS_ORDER - return ( - <> - {(status !== 0)&& - - { status == ReturnApplyOrderTypeReturnForRefund.value?'退货':'退款'} - } - - ) -}) \ No newline at end of file +export default memo(({ status = 0 }: Param) => { + const { + ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款 + ReturnApplyOrderTypeReturnForRefund, // 退货退款 + ReturnApplyOrderTypeSalesRefund, // 销售退款 + } = REFUND_STATUS_ORDER + return ( + <> + {(status !== 0) && + + { status == ReturnApplyOrderTypeReturnForRefund.value ? '退货' : '退款'} + } + + ) +}) diff --git a/src/pages/salesAfter/salesAfterList/components/returnLogistics/index.tsx b/src/pages/salesAfter/salesAfterList/components/returnLogistics/index.tsx index 3d6b19f..75d49f8 100644 --- a/src/pages/salesAfter/salesAfterList/components/returnLogistics/index.tsx +++ b/src/pages/salesAfter/salesAfterList/components/returnLogistics/index.tsx @@ -1,70 +1,71 @@ -import Popup from "@/components/popup"; -import { Text, View } from "@tarojs/components"; -import { memo, useCallback, useEffect, useRef, useState } from "react"; -import UploadImage from "@/components/uploadImage" -import styles from './index.module.scss' -import TextareaEnhance from "@/components/textareaEnhance"; -import { ReturnApplyLogisticsApi } from "@/api/salesAfterOrder"; -import { alert } from "@/common/common"; +import { Text, View } from '@tarojs/components' +import { memo, useCallback, useEffect, useRef, useState } from 'react' +import styles from './index.module.scss' +import UploadImage from '@/components/uploadImage' +import Popup from '@/components/popup' +import TextareaEnhance from '@/components/textareaEnhance' +import { ReturnApplyLogisticsApi } from '@/api/salesAfterOrder' +import { alert } from '@/common/common' -type Param = { - show?: true|false, - onClose?: () => void, - onSubmit?: () => void, - id?: number //订单id +interface Param { + show?: true|false + onClose?: () => void + onSubmit?: () => void + id?: number // 订单id } -export default memo(({show = false, onClose, onSubmit, id = 0}: Param) => { - //需要提交的数据 - const submitData = useRef({ - accessory_url: [], - remark: '', - id: 0 - }) - useEffect(() => { - if(id) submitData.current.id = id - }, [id]) +export default memo(({ show = false, onClose, onSubmit, id = 0 }: Param) => { + // 需要提交的数据 + const submitData = useRef({ + accessory_url: [], + remark: '', + id: 0, + }) + useEffect(() => { + if (id) { submitData.current.id = id } + }, [id]) - //获取图片列表 - const getImageList = useCallback((list) => { - submitData.current.accessory_url = list - }, []) + // 获取图片列表 + const getImageList = useCallback((list) => { + submitData.current.accessory_url = list + }, []) - //备注 - const getOtherReason = useCallback((val) => { - submitData.current.remark = val - }, []) + // 备注 + const getOtherReason = useCallback((val) => { + submitData.current.remark = val + }, []) - //确定 - const {fetchData} = ReturnApplyLogisticsApi() - const onSubmitEven = async () => { - if(!id) return alert.error('参数有误') - if(submitData.current.accessory_url.length <= 0) return alert.error('请上传附件') - let res = await fetchData(submitData.current) - if(res.success) { - alert.success('上传成功') - } else { - alert.error('上传失败') - } + // 确定 + const { fetchData } = ReturnApplyLogisticsApi() + const onSubmitEven = async() => { + if (!id) { return alert.error('参数有误') } + if (submitData.current.accessory_url.length <= 0) { return alert.error('请上传附件') } + const res = await fetchData(submitData.current) + if (res.success) { + alert.success('上传成功') + } + else { + alert.error('上传失败') } + } - return ( - <> - - - - 上传附件: - - - - - - - - - onSubmitEven()}>保存 - - - - - ) -}) \ No newline at end of file + return ( + <> + + + + 上传附件: + + + + + + + + + onSubmitEven()}>保存 + + + + + ) +}) diff --git a/src/pages/salesAfter/salesAfterList/index.tsx b/src/pages/salesAfter/salesAfterList/index.tsx index e316594..03855de 100644 --- a/src/pages/salesAfter/salesAfterList/index.tsx +++ b/src/pages/salesAfter/salesAfterList/index.tsx @@ -1,23 +1,23 @@ -import Search from '@/components/search' -import useLogin from '@/use/useLogin' import { View } from '@tarojs/components' import Taro, { useDidShow } from '@tarojs/taro' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' -import styles from './index.module.scss' import classnames from 'classnames' -import Order from './components/order' -import InfiniteScroll from '@/components/infiniteScroll' -import { dataLoadingStatus, getFilterData } from '@/common/util' -import OrderStatusList from './components/orderStatusList' -import { GetSaleOrderListApi, RefundOrderSatausApi } from '@/api/salesAfterOrder' import ApplyRecord from '../components/applyRecord' import ReturnLogistics from '../components/returnLogistics' import ReturnPayCheck from '../components/returnPayCheck' +import styles from './index.module.scss' +import Order from './components/order' +import OrderStatusList from './components/orderStatusList' +import InfiniteScroll from '@/components/infiniteScroll' +import { dataLoadingStatus, getFilterData } from '@/common/util' +import { GetSaleOrderListApi, RefundOrderSatausApi } from '@/api/salesAfterOrder' +import useLogin from '@/use/useLogin' +import Search from '@/components/search' export default () => { useLogin() - //搜索参数 + // 搜索参数 const [searchField, setSearchField] = useState<{ status: number | null; page: number; size: number; name: string }>({ status: null, page: 1, @@ -25,84 +25,87 @@ export default () => { name: '', }) - //获取订单状态 + // 获取订单状态 const [statusList, setStatusList] = useState([{ id: -1, name: '全部' }]) const { fetchData: fetchDataStatus } = RefundOrderSatausApi() - const getOrderStatusList = async () => { - let res = await fetchDataStatus() - setStatusList((e) => [...e, ...res.data.list]) + const getOrderStatusList = async() => { + const res = await fetchDataStatus() + setStatusList(e => [...e, ...res.data.list]) } useEffect(() => { getOrderStatusList() - setSearchField((e) => ({ ...e, status: -1 })) + setSearchField(e => ({ ...e, status: -1 })) }, []) - //获取订单列表 + // 获取订单列表 const { fetchData: listFetchData, state: orderState } = GetSaleOrderListApi() const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) - const getOrderList = async () => { - let res = await listFetchData(getFilterData(searchField)) + const getOrderList = async() => { + const res = await listFetchData(getFilterData(searchField)) setOrderData({ list: res.data.list, total: res.data.total }) setRefresherTriggeredStatus(() => false) } useDidShow(() => { - if (searchField.status != null) getOrderList() + if (searchField.status != null) { getOrderList() } }) - //监听筛选条件变化 + // 监听筛选条件变化 useEffect(() => { - if (searchField.status != null) getOrderList() + if (searchField.status != null) { getOrderList() } }, [searchField]) - //上拉加载数据 + // 上拉加载数据 const pageNum = useRef({ size: searchField.size, page: searchField.page }) const getScrolltolower = useCallback(() => { if (orderData.list.length < orderData.total) { pageNum.current.page++ const size = pageNum.current.size * pageNum.current.page - setSearchField((e) => ({ ...e, size })) + setSearchField(e => ({ ...e, size })) } }, [orderData]) - //状态改变 + // 状态改变 const changeStatus = useCallback((e) => { pageNum.current.page = 1 - setSearchField((value) => ({ ...value, status: e, size: 10 })) + setSearchField(value => ({ ...value, status: e, size: 10 })) setOrderData(() => ({ list: [], total: 0 })) }, []) - //数据加载状态 + // 数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading }) }, [orderData, orderState]) - //输入了搜索关键字 + // 输入了搜索关键字 const getSearchData = useCallback((e) => { pageNum.current.page = 1 setOrderData(() => ({ list: [], total: 0 })) - setSearchField((val) => ({ ...val, name: e, size: 10 })) + setSearchField(val => ({ ...val, name: e, size: 10 })) }, []) - //列表下拉刷新 + // 列表下拉刷新 const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false) - const getRefresherRefresh = async () => { + const getRefresherRefresh = async() => { pageNum.current.size = 1 setRefresherTriggeredStatus(true) - setSearchField((val) => ({ ...val, size: 10 })) + setSearchField(val => ({ ...val, size: 10 })) } - //监听点击的按钮 + // 监听点击的按钮 const [callBackOrderInfo, setCallBackPayOrderInfo] = useState() const clickOrderBtn = useCallback( ({ status, orderInfo }) => { if (status == 1 || status == 6) { getOrderList() - } else if (status == 8) { + } + else if (status == 8) { setApplyRecord(true) - } else if (status == 5) { + } + else if (status == 5) { onShowLogistics(() => true) - } else if (status == 7) { + } + else if (status == 7) { setReturnCodeShow(true) } console.log('orderInfo::', orderInfo) @@ -111,13 +114,13 @@ export default () => { [orderData], ) - //显示记录 + // 显示记录 const [applyRecord, setApplyRecord] = useState(false) - //显示码单 + // 显示码单 const [returnCodeShow, setReturnCodeShow] = useState(false) - //物流显示 + // 物流显示 const [logisticsShow, setLogisticsShow] = useState(false) const onShowLogistics = useCallback((val) => { setLogisticsShow(true) @@ -125,7 +128,7 @@ export default () => { const onCloseLogistics = useCallback(() => { setLogisticsShow(false) }, []) - //物流成功上传 + // 物流成功上传 const logisticsSuccess = useCallback(() => { setLogisticsShow(false) getOrderList() @@ -134,16 +137,17 @@ export default () => { return ( - + + selfOnRefresherRefresh={getRefresherRefresh} + > {orderData?.list.map((item) => { return ( diff --git a/src/pages/sampleComparison/compoents/bluetooth/LinkBlueTooth.tsx b/src/pages/sampleComparison/compoents/bluetooth/LinkBlueTooth.tsx index 4be6b33..ac9c0f0 100644 --- a/src/pages/sampleComparison/compoents/bluetooth/LinkBlueTooth.tsx +++ b/src/pages/sampleComparison/compoents/bluetooth/LinkBlueTooth.tsx @@ -1,89 +1,88 @@ -import { View } from "@tarojs/components"; -import { memo, useEffect, useMemo, useState } from "react"; -import Taro from "@tarojs/taro"; -import { useBluetooth } from "@/use/contextBlueTooth" -import SearchInput from "@/components/searchInput"; -import Popup from "./Popup" -import classnames from "classnames"; -import styles from "../../css/linkBlueTooth.module.scss" +import { View } from '@tarojs/components' +import Taro from '@tarojs/taro' +import { memo, useEffect, useMemo, useState } from 'react' +import classnames from 'classnames' +import styles from '../../css/linkBlueTooth.module.scss' +import Popup from './Popup' +import { useBluetooth } from '@/use/contextBlueTooth' +import SearchInput from '@/components/searchInput' export default memo(() => { - const { state, init, startScan, connect, disconnect } = useBluetooth() + const { state, init, startScan, connect, disconnect } = useBluetooth() - useEffect(() => { - init() - }, []) + useEffect(() => { + init() + }, []) - const [linkStatus, setLinkStatus] = useState(1) - useEffect(() => { - if (!state.available) { - setLinkStatus(1) - } else if (state.available && state.connected?.name) { - setLinkStatus(3) - } else { - setLinkStatus(2) - } - }, [state.available, state.connected]) - - const linkName = useMemo(() => { - return state.connected?.localName || '' - }, [state.connected]) - - //链接设备 - const onLinkListen = (item) => { - if (!state.connected && !state.connecting) - connect(item) + const [linkStatus, setLinkStatus] = useState(1) + useEffect(() => { + if (!state.available) { + setLinkStatus(1) } - - const [popupShow, setPopupShow] = useState(false) - //显示设备列表 - const onFindDevice = () => { - if (linkStatus == 1) { - Taro.showToast({ - title: '请打开蓝牙', - icon: 'none' - }) - } else { - setPopupShow(true) - onFindEven() - } - + else if (state.available && state.connected?.name) { + setLinkStatus(3) } - const onFindEven = () => { - if (!state.discovering && !state.connected && !state.connecting) - startScan() + else { + setLinkStatus(2) } + }, [state.available, state.connected]) - //断开链接 - const onDisconnect = () => { - disconnect() - setPopupShow(false) + const linkName = useMemo(() => { + return state.connected?.localName || '' + }, [state.connected]) + + // 链接设备 + const onLinkListen = (item) => { + if (!state.connected && !state.connecting) { connect(item) } + } + + const [popupShow, setPopupShow] = useState(false) + // 显示设备列表 + const onFindDevice = () => { + if (linkStatus == 1) { + Taro.showToast({ + title: '请打开蓝牙', + icon: 'none', + }) } + else { + setPopupShow(true) + onFindEven() + } + } + const onFindEven = () => { + if (!state.discovering && !state.connected && !state.connecting) { startScan() } + } - return ( - <> - - - - - { - linkStatus == 1 && 请开启蓝牙 || - linkStatus == 2 && 未连接设备 || - linkStatus == 3 && {linkName} - } - - - setPopupShow(false)} - onLink={item => onLinkListen(item)} - onOff={onDisconnect} - onFind={onFindEven} - /> - - + // 断开链接 + const onDisconnect = () => { + disconnect() + setPopupShow(false) + } - ); + return ( + <> + + + + + { + linkStatus == 1 && 请开启蓝牙 + || linkStatus == 2 && 未连接设备 + || linkStatus == 3 && {linkName} + } + + + setPopupShow(false)} + onLink={item => onLinkListen(item)} + onOff={onDisconnect} + onFind={onFindEven} + /> + + + ) }) diff --git a/src/pages/sampleComparison/compoents/bluetooth/Popup.tsx b/src/pages/sampleComparison/compoents/bluetooth/Popup.tsx index d8a9464..0a25022 100644 --- a/src/pages/sampleComparison/compoents/bluetooth/Popup.tsx +++ b/src/pages/sampleComparison/compoents/bluetooth/Popup.tsx @@ -1,73 +1,73 @@ -import { ScrollView, View } from "@tarojs/components" -import { memo, useEffect, useState } from "react" -import Loading from "@/components/loading" -import style from "../../css/popup.module.scss" +import { ScrollView, View } from '@tarojs/components' +import { memo, useEffect, useState } from 'react' +import style from '../../css/popup.module.scss' +import Loading from '@/components/loading' interface params { - state: any, - show: Boolean, - onClose: (Boolean) => void, - onLink: (any) => void, - children?: React.ReactNode - onOff: () => void, - onFind: () => void, + state: any + show: Boolean + onClose: (Boolean) => void + onLink: (any) => void + children?: React.ReactNode + onOff: () => void + onFind: () => void } -export default memo(({state, show=false, onClose, onLink, onOff, onFind}:params) => { - const [popupShow, setPopupShow] = useState(show) - useEffect(() => { - setPopupShow(show) - }, [show]) - const onCloseListener = () => { - onClose(false) - } - - return ( - <> - { - popupShow&& - - 搜索设备 - - - { - (state.devices&&state.devices.length > 0)&&state?.devices.map(item => { - return ( - onLink(item)}> - {item.name} - { - (!state.connecting&&!state.connected)&&链接|| - (state.connecting&&item.deviceId == state.connecting.deviceId)&&正在链接...|| - (state.connected&&item.deviceId == state.connected.deviceId)&&链接成功 - } - - ) - })|| - - { - (!state.discovering)&& <> - 暂无设备,请按以下条件检查 - 1.请确保取色仪处于激活状态 - 2.请确保取色仪没有链接其他设备 - 3.请打开手机定位 - || - 设备搜索中 - } - - - - } - - +export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => { + const [popupShow, setPopupShow] = useState(show) + useEffect(() => { + setPopupShow(show) + }, [show]) + const onCloseListener = () => { + onClose(false) + } + + return ( + <> + { + popupShow && + + 搜索设备 + + + { + (state.devices && state.devices.length > 0) && state?.devices.map((item) => { + return ( + onLink(item)}> + {item.name} { - state.connected&&断开链接|| - (!state.connected&&state.discovering)&&搜索中|| - 重新搜索 + (!state.connecting && !state.connected) && 链接 + || (state.connecting && item.deviceId == state.connecting.deviceId) && 正在链接... + || (state.connected && item.deviceId == state.connected.deviceId) && 链接成功 } - - - + + ) + }) + || + { + (!state.discovering) && <> + 暂无设备,请按以下条件检查 + 1.请确保取色仪处于激活状态 + 2.请确保取色仪没有链接其他设备 + 3.请打开手机定位 + + || 设备搜索中 + } + + + + } + + + { + state.connected && 断开链接 + || (!state.connected && state.discovering) && 搜索中 + || 重新搜索 } - - ) -}) \ No newline at end of file + + + + } + + ) +}) diff --git a/src/pages/sampleComparison/index.tsx b/src/pages/sampleComparison/index.tsx index f91c0bd..598aa03 100644 --- a/src/pages/sampleComparison/index.tsx +++ b/src/pages/sampleComparison/index.tsx @@ -1,129 +1,129 @@ -import { Image, Text, Textarea, View } from "@tarojs/components" -import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro"; -import { useCallback, useEffect, useMemo, useRef, useState } from "react"; -import { useBluetooth } from "../../use/contextBlueTooth" -import classnames from "classnames"; -import LinkBlueTooth from "./compoents/bluetooth/LinkBlueTooth"; +import { Image, Text, Textarea, View } from '@tarojs/components' +import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro' +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import classnames from 'classnames' +import { useBluetooth } from '../../use/contextBlueTooth' import { toRgb } from '../../common/bluetooth/color/colorSpace' +import LinkBlueTooth from './compoents/bluetooth/LinkBlueTooth' import styles from './index.module.scss' -import { productabsorbcontrast } from "@/api/mine" +import { productabsorbcontrast } from '@/api/mine' + export default () => { - //搜索参数 - const [searchField, setSearchField] = useState({ - l1: '', - a1: '', - b1: '', - l2: '', - a2: '', - b2: '', - }) - type ColorList = { - one?: any, - two?: any - } - const [colorList, setColorList] = useState({ - one: null, - two: null - }) - const { state: colorState, measureAndGetLab } = useBluetooth() + // 搜索参数 + const [searchField, setSearchField] = useState({ + l1: '', + a1: '', + b1: '', + l2: '', + a2: '', + b2: '', + }) + interface ColorList { + one?: any + two?: any + } + const [colorList, setColorList] = useState({ + one: null, + two: null, + }) + const { state: colorState, measureAndGetLab } = useBluetooth() - const getLab = async (val) => { - if (colorState.connected) { - let res = await measureAndGetLab() - if (val === 1) { - setColorList({ ...colorList, one: res }) - } else { - setColorList({ ...colorList, two: res }) - } - } else { - Taro.showToast({ - title: '请链接设备', - icon: 'none' - }) - } + const getLab = async(val) => { + if (colorState.connected) { + const res = await measureAndGetLab() + if (val === 1) { + setColorList({ ...colorList, one: res }) + } + else { + setColorList({ ...colorList, two: res }) + } } - const getNowTime = () => { - const yy = new Date().getFullYear() - const MM = (new Date().getMonth() + 1) < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1) - const dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate() - const HH = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours() - const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes() - const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds() - return yy + '-' + MM + '-' + dd + ' ' + HH + ':' + mm + ':' + ss + else { + Taro.showToast({ + title: '请链接设备', + icon: 'none', + }) } - //监听lab数据变化 - const [blueToothColor, setBlueToothColor] = useState('') - const [blueToothColorTwo, setBlueToothColorTwo] = useState('') - const [time, setTime] = useState('') - const [timeTwo, setTimeTwo] = useState('') - useEffect(() => { - if (colorState.deviceLab) { - - if ((colorList as any).one?.constructor === Object) { - const rgb = toRgb([(colorList as any).one?.L, (colorList as any).one?.a, (colorList as any).one?.b]) - setBlueToothColor(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`) - setTime(getNowTime()) - setSearchField({ ...searchField, l1: rgb[0], a1: rgb[1], b1: rgb[2] }) - } - if ((colorList as any).two?.constructor === Object) { - - const rgb = toRgb([(colorList as any).two?.L, (colorList as any).two?.a, (colorList as any).two?.b]) - setBlueToothColorTwo(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`) - setTimeTwo(getNowTime()) - setSearchField({ ...searchField, l2: rgb[0], a2: rgb[1], b2: rgb[2] }) - - } - } - }, [colorList]) - const reset = () => { - setColorList({}) - setBlueToothColor('') - setBlueToothColorTwo('') - setTime('') - setTimeTwo('') - setData('') - setResult('') + } + const getNowTime = () => { + const yy = new Date().getFullYear() + const MM = (new Date().getMonth() + 1) < 10 ? `0${new Date().getMonth() + 1}` : (new Date().getMonth() + 1) + const dd = new Date().getDate() < 10 ? `0${new Date().getDate()}` : new Date().getDate() + const HH = new Date().getHours() < 10 ? `0${new Date().getHours()}` : new Date().getHours() + const mm = new Date().getMinutes() < 10 ? `0${new Date().getMinutes()}` : new Date().getMinutes() + const ss = new Date().getSeconds() < 10 ? `0${new Date().getSeconds()}` : new Date().getSeconds() + return `${yy}-${MM}-${dd} ${HH}:${mm}:${ss}` + } + // 监听lab数据变化 + const [blueToothColor, setBlueToothColor] = useState('') + const [blueToothColorTwo, setBlueToothColorTwo] = useState('') + const [time, setTime] = useState('') + const [timeTwo, setTimeTwo] = useState('') + useEffect(() => { + if (colorState.deviceLab) { + if ((colorList as any).one?.constructor === Object) { + const rgb = toRgb([(colorList as any).one?.L, (colorList as any).one?.a, (colorList as any).one?.b]) + setBlueToothColor(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`) + setTime(getNowTime()) + setSearchField({ ...searchField, l1: rgb[0], a1: rgb[1], b1: rgb[2] }) + } + if ((colorList as any).two?.constructor === Object) { + const rgb = toRgb([(colorList as any).two?.L, (colorList as any).two?.a, (colorList as any).two?.b]) + setBlueToothColorTwo(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`) + setTimeTwo(getNowTime()) + setSearchField({ ...searchField, l2: rgb[0], a2: rgb[1], b2: rgb[2] }) + } } - const [data, setData] = useState('') - const [result, setResult] = useState('') - const { fetchData } = productabsorbcontrast() - const handTake = async () => { - if (searchField.l1 === '') { - Taro.showToast({ - title: '请填充基础样品', - icon: 'none' - }) - return - } - if (searchField.l2 === '') { - Taro.showToast({ - title: '请填充对比样品', - icon: 'none' - }) - return - } - const query = { - ...searchField - } - const res = await fetchData(query) - if (res.data) { - setData(res.data) - let diffarray = [ - res.data.reddish && "偏红", - res.data.yellowish && "偏黄", - res.data.greenish && "偏绿", - res.data.bluish && "偏蓝", - res.data.whitish && "偏亮", - res.data.darker && "偏暗", - ]; - let resCont = diffarray.filter(item => item).join(","); - setResult(resCont) - } + }, [colorList]) + const reset = () => { + setColorList({}) + setBlueToothColor('') + setBlueToothColorTwo('') + setTime('') + setTimeTwo('') + setData('') + setResult('') + } + const [data, setData] = useState('') + const [result, setResult] = useState('') + const { fetchData } = productabsorbcontrast() + const handTake = async() => { + if (searchField.l1 === '') { + Taro.showToast({ + title: '请填充基础样品', + icon: 'none', + }) + return } - return ( - - {/* + if (searchField.l2 === '') { + Taro.showToast({ + title: '请填充对比样品', + icon: 'none', + }) + return + } + const query = { + ...searchField, + } + const res = await fetchData(query) + if (res.data) { + setData(res.data) + const diffarray = [ + res.data.reddish && '偏红', + res.data.yellowish && '偏黄', + res.data.greenish && '偏绿', + res.data.bluish && '偏蓝', + res.data.whitish && '偏亮', + res.data.darker && '偏暗', + ] + const resCont = diffarray.filter(item => item).join(',') + setResult(resCont) + } + } + return ( + + {/* 蓝牙设备 @@ -132,81 +132,81 @@ export default () => { */} - - - - 基础样品 - { - blueToothColor === '' && - getLab(1)}> - 点击取色 + + + + 基础样品 + { + blueToothColor === '' + && getLab(1)}> + 点击取色 - } - {blueToothColor && getLab(1)} style={{ background: blueToothColor }}> + } + {blueToothColor && getLab(1)} style={{ background: blueToothColor }}> - } - { - time === '' && -- - } - { - time && {time} - } - - - 对比样品 - { - blueToothColorTwo === '' && - getLab(2)}> - 点击取色 + } + { + time === '' && -- + } + { + time && {time} + } + + + 对比样品 + { + blueToothColorTwo === '' + && getLab(2)}> + 点击取色 - } - {blueToothColorTwo && getLab(2)} style={{ background: blueToothColorTwo }}> + } + {blueToothColorTwo && getLab(2)} style={{ background: blueToothColorTwo }}> - } - { - timeTwo === '' && -- - } - { - timeTwo && {timeTwo} - } - - - - - 测量结果 - { - (data as any).ciede_2000 >= 1 && - 不合格 - } - { - (data as any).ciede_2000 <= 1 && - 合格 - } + } + { + timeTwo === '' && -- + } + { + timeTwo && {timeTwo} + } + + + + + 测量结果 + { + (data as any).ciede_2000 >= 1 + && 不合格 + } + { + (data as any).ciede_2000 <= 1 + && 合格 + } - - { - data === '' && - 暂无数据 - } - { - data && - - 色差值: {(data as any).ciede_2000} - { - !(data as any).reddish && !(data as any).yellowish && !(data as any).greenish && !(data as any).bluish && !(data as any).whitish && !(data as any).darker && - 无明显色差 - } - { - result && - {result} - } + + { + data === '' + && 暂无数据 + } + { + data + && + 色差值: {(data as any).ciede_2000} + { + !(data as any).reddish && !(data as any).yellowish && !(data as any).greenish && !(data as any).bluish && !(data as any).whitish && !(data as any).darker + && 无明显色差 + } + { + result + && {result} + } - } - - - reset()}>重置 - handTake()}>提交 - - - ) -} \ No newline at end of file + } + + + reset()}>重置 + handTake()}>提交 + + + ) +} diff --git a/src/pages/search/index.tsx b/src/pages/search/index.tsx index dbdc018..b229a4f 100644 --- a/src/pages/search/index.tsx +++ b/src/pages/search/index.tsx @@ -1,18 +1,18 @@ import { View } from '@tarojs/components' +import classnames from 'classnames' +import { useEffect } from 'react' +import styles from './index.module.scss' import Search from '@/components/search' -import { goLink } from '@/common/common'; -import classnames from "classnames"; -import styles from './index.module.scss' -import { useEffect } from 'react'; -import useLogin from '@/use/useLogin'; +import { goLink } from '@/common/common' +import useLogin from '@/use/useLogin' export default () => { useLogin() return ( - console.log(e)} placeholder="请输入面料关键词" placeIcon="out" showBtn={true} /> + console.log(e)} placeholder="请输入面料关键词" placeIcon="out" showBtn /> diff --git a/src/pages/searchList/components/selectData/index.tsx b/src/pages/searchList/components/selectData/index.tsx index e82b2d2..d3b094d 100644 --- a/src/pages/searchList/components/selectData/index.tsx +++ b/src/pages/searchList/components/selectData/index.tsx @@ -1,57 +1,56 @@ -import { ScrollView, View } from "@tarojs/components"; -import { memo, useState, ReactNode, useEffect } from "react"; -import classnames from "classnames"; +import { ScrollView, View } from '@tarojs/components' +import type { ReactNode } from 'react' +import { memo, useEffect, useState } from 'react' +import classnames from 'classnames' import styles from './index.module.scss' - -export type ListProps = { - title: string, - value: number +export interface ListProps { + title: string + value: number } -type Params = { - list?: ListProps[], - defaultValue?: number|string, - children?: ReactNode, - tabsOnClick?: (ListProps) => void, +interface Params { + list?: ListProps[] + defaultValue?: number|string + children?: ReactNode + tabsOnClick?: (ListProps) => void } -export default memo(({list = [], defaultValue = 0, tabsOnClick}: Params) => { - - const [tabId, setTabId] = useState('') +export default memo(({ list = [], defaultValue = 0, tabsOnClick }: Params) => { + const [tabId, setTabId] = useState('') - useEffect(() => { - const index = list?.findIndex(item => { - return item.value == defaultValue - }) - if(index !== -1) { - const num = index > 0?( index - 1) : 0 - setTabId(list[num].value.toString()) - } - }, []) - - const clickEvent = ({item, index}: {item:ListProps, index:number}) => { - tabsOnClick?.(item) - setTabId(index.toString()) + useEffect(() => { + const index = list?.findIndex((item) => { + return item.value == defaultValue + }) + if (index !== -1) { + const num = index > 0 ? (index - 1) : 0 + setTabId(list[num].value.toString()) } - return ( - <> - - - - { - list.map((item, index) => { - return ( - clickEvent({item,index})}> - {`${item.title}: ${item.value}`} - - ) - }) - } - - - - - ) -}) \ No newline at end of file + }, []) + + const clickEvent = ({ item, index }: { item: ListProps; index: number }) => { + tabsOnClick?.(item) + setTabId(index.toString()) + } + return ( + <> + + + + { + list.map((item, index) => { + return ( + clickEvent({ item, index })}> + {`${item.title}: ${item.value}`} + + ) + }) + } + + + + + ) +}) diff --git a/src/pages/searchList/hightSearchList.config.ts b/src/pages/searchList/hightSearchList.config.ts index 34c8c61..22d7a05 100644 --- a/src/pages/searchList/hightSearchList.config.ts +++ b/src/pages/searchList/hightSearchList.config.ts @@ -1,5 +1,5 @@ export default { navigationBarTitleText: '搜索', enablePullDownRefresh: true, - backgroundTextStyle: 'dark' + backgroundTextStyle: 'dark', } diff --git a/src/pages/searchList/hightSearchList.tsx b/src/pages/searchList/hightSearchList.tsx index 0ba64ce..9ba6869 100644 --- a/src/pages/searchList/hightSearchList.tsx +++ b/src/pages/searchList/hightSearchList.tsx @@ -1,5 +1,10 @@ import { Image, ScrollView, Text, View } from '@tarojs/components' +import Taro, { useDidShow, usePullDownRefresh, useReady } from '@tarojs/taro' import classnames from 'classnames' +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import styles from './hightSearchList.module.scss' +import type { ListProps } from './components/selectData' +import SelectData from './components/selectData' import Filter from '@/components/filter' import InfiniteScroll from '@/components/infiniteScroll' import SortBtn from '@/components/sortBtn' @@ -7,15 +12,11 @@ import SearchInput from '@/components/searchInput' import LinkBlueTooth from '@/components/bluetooth/LinkBlueTooth' import { useBluetooth } from '@/use/contextBlueTooth' import { toRgb } from '@/common/bluetooth/color/colorSpace' -import styles from './hightSearchList.module.scss' -import { useCallback, useEffect, useMemo, useRef, useState } from 'react' -import Taro, { useDidShow, usePullDownRefresh, useReady } from '@tarojs/taro' import { GetLabProductApi } from '@/api/material' import { dataLoadingStatus, getFilterData } from '@/common/util' import { formatHashTag, formatImgUrl } from '@/common/fotmat' import useLogin from '@/use/useLogin' import { goLink } from '@/common/common' -import SelectData, { ListProps } from './components/selectData' import LabAndImg from '@/components/LabAndImg' export default () => { @@ -23,7 +24,7 @@ export default () => { const firstOpen = useRef(true) const [showFilter, setShowFilter] = useState(false) - //搜索参数 + // 搜索参数 const [searchField, setSearchField] = useState({ l: '', a: '', @@ -37,22 +38,22 @@ export default () => { abstract_sort_key: '', }) - //获取面料列表 + // 获取面料列表 const [materialList, setMaterialList] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) const { fetchData: materialFetchData, state: materialState } = GetLabProductApi() - const getProductList = async () => { - let { data } = await materialFetchData(getFilterData(searchField)) + const getProductList = async() => { + const { data } = await materialFetchData(getFilterData(searchField)) setMaterialList({ list: data.list, total: data.total }) Taro.stopPullDownRefresh() firstOpen.current = false } - //监听筛选条件变化 + // 监听筛选条件变化 useEffect(() => { getProductList() }, [searchField]) - //上拉加载数据 + // 上拉加载数据 const pageNum = useRef({ size: searchField.size, page: searchField.page }) const getScrolltolower = () => { if (materialList.list.length < materialList.total) { @@ -62,7 +63,7 @@ export default () => { } } - //数据加载状态 + // 数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: materialList.list, total: materialList.total, status: materialState.loading }) }, [materialList, materialState]) @@ -71,7 +72,8 @@ export default () => { const getLab = () => { if (colorState.connected) { measureAndGetLab() - } else { + } + else { Taro.showToast({ title: '请链接设备', icon: 'none', @@ -79,7 +81,7 @@ export default () => { } } - //监听lab数据变化 + // 监听lab数据变化 const [blueToothColor, setBlueToothColor] = useState('') useEffect(() => { if (colorState.deviceLab && !firstOpen.current) { @@ -95,7 +97,7 @@ export default () => { goLink('/pages/details/index', { id: item.product_id }) } - //获取筛选条件 + // 获取筛选条件 const getFiltr = (e) => { pageNum.current.page = 1 setMaterialList(() => ({ list: [], total: 0 })) @@ -111,11 +113,11 @@ export default () => { formatSelectList(e) } - //筛选条件格式化 + // 筛选条件格式化 const [selectList, setSelectList] = useState() const formatSelectList = (val = { data: {}, field: {} }) => { - let data: ListProps[] = [] - for (let key in val.data) { + const data: ListProps[] = [] + for (const key in val.data) { if (key !== 'seriesId' && val.data[key] != '') { data.push({ title: val.field[key], value: val.data[key] }) } @@ -123,12 +125,12 @@ export default () => { setSelectList([...data]) } - //页面下拉刷新 + // 页面下拉刷新 usePullDownRefresh(() => { setSearchField({ ...searchField, size: 10 }) }) - //排序 + // 排序 type sortParam = 'none' | 'top' | 'bottom' const sortComprehensiveRef = useRef(null) const sortCollectionRef = useRef(null) @@ -140,12 +142,13 @@ export default () => { setMaterialList(() => ({ list: [], total: 0 })) if (val == 1) { const { status, value } = sortComprehensiveRef.current.changeSort() - setSortStatus((e) => ({ ...e, comprehensive: status, collection: 'none' })) - setSearchField((e) => ({ ...e, abstract_sort_key: value, size: 10, page: 1 })) - } else { + setSortStatus(e => ({ ...e, comprehensive: status, collection: 'none' })) + setSearchField(e => ({ ...e, abstract_sort_key: value, size: 10, page: 1 })) + } + else { const { status, value } = sortCollectionRef.current.changeSort() - setSortStatus((e) => ({ ...e, collection: status, comprehensive: 'none' })) - setSearchField((e) => ({ ...e, abstract_sort_key: value, size: 10, page: 1 })) + setSortStatus(e => ({ ...e, collection: status, comprehensive: 'none' })) + setSearchField(e => ({ ...e, abstract_sort_key: value, size: 10, page: 1 })) } pageNum.current = { size: 10, page: 1 } } @@ -162,7 +165,7 @@ export default () => { - + getLab()}> {(blueToothColor && ) || ( 请取色 @@ -215,7 +218,7 @@ export default () => { - getFiltr(e)} onClose={() => setShowFilter(false)} /> + getFiltr(e)} onClose={() => setShowFilter(false)} /> ) } diff --git a/src/pages/searchList/search.tsx b/src/pages/searchList/search.tsx index a37cbbc..057cd28 100644 --- a/src/pages/searchList/search.tsx +++ b/src/pages/searchList/search.tsx @@ -1,15 +1,15 @@ import { Text, View } from '@tarojs/components' +import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro' +import classnames from 'classnames' +import { useEffect, useRef, useState } from 'react' +import styles from './search.module.scss' import Search from '@/components/search' import { alert, goLink } from '@/common/common' -import classnames from 'classnames' -import styles from './search.module.scss' -import { useEffect, useRef, useState } from 'react' -import { GetHotSearchApi, GetSearchHistoryApi, AddSearchHistoryApi } from '@/api/search' +import { AddSearchHistoryApi, GetHotSearchApi, GetSearchHistoryApi } from '@/api/search' import { SCENE } from '@/common/constant' import useLogin from '@/use/useLogin' -import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro' -type searchDataParam = { search_key: '' } +interface searchDataParam { search_key: '' } export default () => { useLogin() @@ -18,18 +18,18 @@ export default () => { historyField: [], }) - //获取热门搜索数据 + // 获取热门搜索数据 const { fetchData: hotFetchData } = GetHotSearchApi() - const getHotSearch = async () => { - let { data } = await hotFetchData({ page: 1, size: 10 }) - setSearchData((val) => ({ ...val, hotField: data.list })) + const getHotSearch = async() => { + const { data } = await hotFetchData({ page: 1, size: 10 }) + setSearchData(val => ({ ...val, hotField: data.list })) } - //获取历史搜索数据 + // 获取历史搜索数据 const { fetchData: HistoryFetchData } = GetSearchHistoryApi() - const getSearchHistory = async () => { - let { data } = await HistoryFetchData({ page: 1, size: 10 }) - setSearchData((val) => ({ ...val, historyField: data.list })) + const getSearchHistory = async() => { + const { data } = await HistoryFetchData({ page: 1, size: 10 }) + setSearchData(val => ({ ...val, historyField: data.list })) } useDidShow(() => { @@ -37,15 +37,15 @@ export default () => { getSearchHistory() }) - //添加搜索关键字 + // 添加搜索关键字 const addSearchField = useRef({ key: '', screen: SCENE.SearchScene }) const { fetchData: addFetchData } = AddSearchHistoryApi() - const addSearchHistory = async () => { + const addSearchHistory = async() => { await addFetchData(addSearchField.current) // goLink('/pages/searchList/searchList', {key: addSearchField.current.key}) } - //搜索事件, status = true 添加搜索, status = false 直接跳转 + // 搜索事件, status = true 添加搜索, status = false 直接跳转 const searchEvent = (e, status = true) => { if (e == '') { alert.error('请输入关键词') @@ -61,7 +61,7 @@ export default () => { return ( - searchEvent(e)} /> + searchEvent(e)} /> goLink('/pages/searchList/hightSearchList')}> 高级搜索 @@ -89,7 +89,7 @@ export default () => { {/* */} - {searchData?.historyField?.map((item) => ( + {searchData?.historyField?.map(item => ( searchEvent(item.search_key, false)}> {item.search_key} diff --git a/src/pages/searchList/searchList.config.ts b/src/pages/searchList/searchList.config.ts index 34c8c61..22d7a05 100644 --- a/src/pages/searchList/searchList.config.ts +++ b/src/pages/searchList/searchList.config.ts @@ -1,5 +1,5 @@ export default { navigationBarTitleText: '搜索', enablePullDownRefresh: true, - backgroundTextStyle: 'dark' + backgroundTextStyle: 'dark', } diff --git a/src/pages/searchList/searchList.tsx b/src/pages/searchList/searchList.tsx index d9c39f6..0caba59 100644 --- a/src/pages/searchList/searchList.tsx +++ b/src/pages/searchList/searchList.tsx @@ -1,15 +1,16 @@ import { Image, ScrollView, Text, View } from '@tarojs/components' +import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro' import classnames from 'classnames' +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import type { ListProps } from './components/selectData' +import SelectData from './components/selectData' +import styles from './searchList.module.scss' import Search from '@/components/search' import Filter from '@/components/filter' import InfiniteScroll from '@/components/infiniteScroll' import SortBtn from '@/components/sortBtn' -import SelectData, { ListProps } from './components/selectData' import { goLink } from '@/common/common' -import styles from './searchList.module.scss' -import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { GetProductListApi } from '@/api/material' -import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro' import { formatHashTag, formatImgUrl } from '@/common/fotmat' import { dataLoadingStatus, getFilterData } from '@/common/util' import useLogin from '@/use/useLogin' @@ -21,7 +22,7 @@ export default () => { const [showFilter, setShowFilter] = useState(false) const router = useRouter() - //搜索参数 + // 搜索参数 const [searchField, setSearchField] = useState({ code_or_name: router.params.key, page: 1, @@ -33,21 +34,21 @@ export default () => { abstract_sort_key: '', }) - //获取面料列表 + // 获取面料列表 const [materialList, setMaterialList] = useState<{ list: any[]; total: number }>({ list: [], total: 0 }) const { fetchData: materialFetchData, state: materialState } = GetProductListApi() - const getProductList = async () => { - let { data } = await materialFetchData(getFilterData(searchField)) + const getProductList = async() => { + const { data } = await materialFetchData(getFilterData(searchField)) setMaterialList({ list: data.list, total: data.total }) Taro.stopPullDownRefresh() } - //监听筛选条件变化 + // 监听筛选条件变化 useEffect(() => { getProductList() }, [searchField]) - //上拉加载数据 + // 上拉加载数据 const pageNum = useRef({ size: searchField.size, page: searchField.page }) const getScrolltolower = () => { if (materialList.list.length < materialList.total) { @@ -57,16 +58,16 @@ export default () => { } } - //数据加载状态 + // 数据加载状态 const statusMore = useMemo(() => { return dataLoadingStatus({ list: materialList.list, total: materialList.total, status: materialState.loading }) }, [materialList, materialState]) - //输入了搜索关键字 + // 输入了搜索关键字 const getSearchData = useCallback((e) => { pageNum.current.page = 1 setMaterialList(() => ({ list: [], total: 0 })) - setSearchField((val) => ({ ...val, code_or_name: e, size: 10 })) + setSearchField(val => ({ ...val, code_or_name: e, size: 10 })) pageNum.current = { size: 10, page: 1 } }, []) @@ -74,12 +75,12 @@ export default () => { goLink('/pages/details/index', { id: item.id }) } - //页面下拉刷新 + // 页面下拉刷新 usePullDownRefresh(() => { setSearchField({ ...searchField, size: 10 }) }) - //获取筛选条件 + // 获取筛选条件 const getFiltr = (e) => { pageNum.current.page = 1 setMaterialList(() => ({ list: [], total: 0 })) @@ -95,11 +96,11 @@ export default () => { formatSelectList(e) } - //筛选条件格式化 + // 筛选条件格式化 const [selectList, setSelectList] = useState() const formatSelectList = (val = { data: {}, field: {} }) => { - let data: ListProps[] = [] - for (let key in val.data) { + const data: ListProps[] = [] + for (const key in val.data) { if (key !== 'seriesId' && val.data[key] != '') { data.push({ title: val.field[key], value: val.data[key] }) } @@ -107,7 +108,7 @@ export default () => { setSelectList([...data]) } - //排序 + // 排序 type sortParam = 'none' | 'top' | 'bottom' const sortComprehensiveRef = useRef(null) const sortCollectionRef = useRef(null) @@ -118,12 +119,13 @@ export default () => { const changeSort = (val) => { if (val == 1) { const { status, value } = sortComprehensiveRef.current.changeSort() - setSortStatus((e) => ({ ...e, comprehensive: status, collection: 'none' })) - setSearchField((e) => ({ ...e, abstract_sort_key: value, size: 10, page: 1 })) - } else { + setSortStatus(e => ({ ...e, comprehensive: status, collection: 'none' })) + setSearchField(e => ({ ...e, abstract_sort_key: value, size: 10, page: 1 })) + } + else { const { status, value } = sortCollectionRef.current.changeSort() - setSortStatus((e) => ({ ...e, collection: status, comprehensive: 'none' })) - setSearchField((e) => ({ ...e, abstract_sort_key: value, size: 10, page: 1 })) + setSortStatus(e => ({ ...e, collection: status, comprehensive: 'none' })) + setSearchField(e => ({ ...e, abstract_sort_key: value, size: 10, page: 1 })) } pageNum.current = { size: 10, page: 1 } } @@ -138,7 +140,7 @@ export default () => { return ( - + @@ -193,7 +195,7 @@ export default () => { - setShowFilter(false)} onFiltr={(e) => getFiltr(e)} /> + setShowFilter(false)} onFiltr={e => getFiltr(e)} /> ) } diff --git a/src/pages/subjectList/components/filter/index.tsx b/src/pages/subjectList/components/filter/index.tsx index 7495aa7..e92e4fa 100644 --- a/src/pages/subjectList/components/filter/index.tsx +++ b/src/pages/subjectList/components/filter/index.tsx @@ -1,8 +1,9 @@ -import Popup, { Params as PopuParams } from '@/components/popup' import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components' import classnames from 'classnames' import { useEffect, useState } from 'react' import styles from './index.module.scss' +import Popup from '@/components/popup' +import type { Params as PopuParams } from '@/components/popup' type params = { onFiltr?: (val: object) => void @@ -41,21 +42,22 @@ export default ({ onClose, onFiltr, show = false }: params) => { const setNumber = (e, field) => { console.log(e) - let num = parseFloat(e.detail.value) + const num = parseFloat(e.detail.value) if (isNaN(num)) { filterObj[field] = null - } else { + } + else { filterObj[field] = parseFloat(num.toFixed(2)) } setFilterObj({ ...filterObj }) } const setElement = (e) => { - let res = e.detail.value + const res = e.detail.value setFilterObj({ ...filterObj, element: res }) } return ( - onCloseEven()} showIconButton={true}> + onCloseEven()} showIconButton> 全部筛选 @@ -77,25 +79,25 @@ export default ({ onClose, onFiltr, show = false }: params) => { setNumber(e, 'minWidth')} - placeholder='自定义最低值' - placeholderStyle='font-size: 26rpx' + type="digit" + onBlur={e => setNumber(e, 'minWidth')} + placeholder="自定义最低值" + placeholderStyle="font-size: 26rpx" /> setNumber(e, 'maxWidth')} - placeholder='自定义最高值' - placeholderStyle='font-size: 26rpx' + type="digit" + onBlur={e => setNumber(e, 'maxWidth')} + placeholder="自定义最高值" + placeholderStyle="font-size: 26rpx" /> cm @@ -106,25 +108,25 @@ export default ({ onClose, onFiltr, show = false }: params) => { setNumber(e, 'minWeight')} - placeholder='自定义最低值' - placeholderStyle='font-size: 26rpx' + onBlur={e => setNumber(e, 'minWeight')} + placeholder="自定义最低值" + placeholderStyle="font-size: 26rpx" /> setNumber(e, 'maxWeight')} - placeholder='自定义最高值' - placeholderStyle='font-size: 26rpx' + onBlur={e => setNumber(e, 'maxWeight')} + placeholder="自定义最高值" + placeholderStyle="font-size: 26rpx" /> g @@ -133,11 +135,11 @@ export default ({ onClose, onFiltr, show = false }: params) => { 成分 -