🌈 style(eslint): 新增eslint规则
This commit is contained in:
parent
c3cb46a5a7
commit
d49314aa5b
@ -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
|
|
||||||
7
.eslintignore
Normal file
7
.eslintignore
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/node_modules
|
||||||
|
/build
|
||||||
|
/key
|
||||||
|
/dist
|
||||||
|
project.*.json
|
||||||
|
*.lock
|
||||||
|
*.log
|
||||||
15
.eslintrc
15
.eslintrc
@ -1,8 +1,13 @@
|
|||||||
{
|
{
|
||||||
"extends": ["taro/react"],
|
"extends": ["taro/react","@aaronghx/eslint-config-react"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"react/jsx-uses-react": "off",
|
"no-console": "off",
|
||||||
"react/react-in-jsx-scope": "off"
|
"@typescript-eslint/no-shadow": "off",
|
||||||
},
|
"@typescript-eslint/no-unused-vars": "off",
|
||||||
"plugins": [""]
|
"eqeqeq": "off",
|
||||||
|
"no-prototype-builtins": "off",
|
||||||
|
"import/first": "off",
|
||||||
|
"react/no-children-prop": "off",
|
||||||
|
"import/no-commonjs": "off"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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',
|
|
||||||
}
|
|
||||||
@ -4,7 +4,7 @@ module.exports = {
|
|||||||
presets: [
|
presets: [
|
||||||
['taro', {
|
['taro', {
|
||||||
framework: 'react',
|
framework: 'react',
|
||||||
ts: true
|
ts: true,
|
||||||
}]
|
}],
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: '"development"',
|
NODE_ENV: '"development"',
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const childProcess = require('child_process')
|
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',
|
encoding: 'utf8',
|
||||||
}) != 'HEAD\n'
|
}) != 'HEAD\n'
|
||||||
? childProcess.execSync('git rev-parse --abbrev-ref HEAD', {
|
? childProcess.execSync('git rev-parse --abbrev-ref HEAD', {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: '"pre"',
|
NODE_ENV: '"pre"',
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: '"production"',
|
NODE_ENV: '"production"',
|
||||||
|
|||||||
2
global.d.ts
vendored
2
global.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/// <reference path="node_modules/@tarojs/plugin-platform-weapp/types/shims-weapp.d.ts" />
|
/// <reference types="@tarojs/taro" />
|
||||||
|
|
||||||
declare module '*.png'
|
declare module '*.png'
|
||||||
declare module '*.gif'
|
declare module '*.gif'
|
||||||
|
|||||||
15
package.json
15
package.json
@ -8,6 +8,7 @@
|
|||||||
"typescript": true,
|
"typescript": true,
|
||||||
"css": "sass"
|
"css": "sass"
|
||||||
},
|
},
|
||||||
|
"author": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:weapp": "taro build --type weapp",
|
"build:weapp": "taro build --type weapp",
|
||||||
"build:swan": "taro build --type swan",
|
"build:swan": "taro build --type swan",
|
||||||
@ -31,14 +32,15 @@
|
|||||||
"dev:weapp:pre": "cross-env NODE_ENV=pre npm run build:weapp -- --watch",
|
"dev:weapp:pre": "cross-env NODE_ENV=pre npm run build:weapp -- --watch",
|
||||||
"build:weapp:open": "taro build --type weapp --open",
|
"build:weapp:open": "taro build --type weapp --open",
|
||||||
"build:weapp:upload": "taro build --type weapp --upload",
|
"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": [
|
"browserslist": [
|
||||||
"last 3 versions",
|
"last 3 versions",
|
||||||
"Android >= 4.1",
|
"Android >= 4.1",
|
||||||
"ios >= 8"
|
"ios >= 8"
|
||||||
],
|
],
|
||||||
"author": "",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@tarojs/components": "3.5.6",
|
"@tarojs/components": "3.5.6",
|
||||||
@ -59,6 +61,7 @@
|
|||||||
"tarojs": "^2.1.1"
|
"tarojs": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@aaronghx/eslint-config-react": "^0.1.11",
|
||||||
"@babel/core": "^7.8.0",
|
"@babel/core": "^7.8.0",
|
||||||
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
|
||||||
"@tarojs/plugin-mini-ci": "3.5.6",
|
"@tarojs/plugin-mini-ci": "3.5.6",
|
||||||
@ -67,15 +70,11 @@
|
|||||||
"@types/qs": "^6.9.7",
|
"@types/qs": "^6.9.7",
|
||||||
"@types/react": "^18.0.0",
|
"@types/react": "^18.0.0",
|
||||||
"@types/webpack-env": "^1.13.6",
|
"@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",
|
"babel-preset-taro": "3.5.6",
|
||||||
|
"classnames": "^2.3.2",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^8.28.0",
|
||||||
"eslint-config-taro": "3.5.6",
|
"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",
|
"react-refresh": "0.11.0",
|
||||||
"stylelint": "9.3.0",
|
"stylelint": "9.3.0",
|
||||||
"typescript": "^4.1.0",
|
"typescript": "^4.1.0",
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取行政地区列表
|
* 获取行政地区列表
|
||||||
*/
|
*/
|
||||||
export const GetAddressListApi = () => {
|
export const GetAddressListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/district/list`,
|
url: '/v1/mall/district/list',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const addressListApi = () => {
|
export const addressListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/address/list`,
|
url: '/v1/mall/address/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ export const addressListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const addressAddApi = () => {
|
export const addressAddApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/address`,
|
url: '/v1/mall/address',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ export const addressAddApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const addressDetailApi = () => {
|
export const addressDetailApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/address`,
|
url: '/v1/mall/address',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ export const addressDetailApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const addressEditApi = () => {
|
export const addressEditApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/address`,
|
url: '/v1/mall/address',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ export const addressEditApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const addressDeleteApi = () => {
|
export const addressDeleteApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/address`,
|
url: '/v1/mall/address',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const GetBannerList = () => {
|
export const GetBannerList = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/carouselBanner/list`,
|
url: '/v1/mall/carouselBanner/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const GetSignApi = () => {
|
export const GetSignApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/cdn/token`,
|
url: '/v1/mall/cdn/token',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业认证信息获取
|
* 企业认证信息获取
|
||||||
@ -6,8 +6,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const certificationDetailApi = () => {
|
export const certificationDetailApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/company/authentication`,
|
url: '/v1/mall/company/authentication',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,8 +17,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const certificationSaveApi = () => {
|
export const certificationSaveApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/company/authentication`,
|
url: '/v1/mall/company/authentication',
|
||||||
method: "put",
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const certificationTypeListApi = () => {
|
export const certificationTypeListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/companyAuthenticationType`,
|
url: '/v1/mall/enum/companyAuthenticationType',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const companyDetailApi = () => {
|
export const companyDetailApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/company/info`,
|
url: '/v1/mall/company/info',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ export const companyDetailApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const companyUpdateApi = () => {
|
export const companyUpdateApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/company/info`,
|
url: '/v1/mall/company/info',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const creditInfoApi = () => {
|
export const creditInfoApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/credit`,
|
url: '/v1/mall/credit',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ export const creditInfoApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const creditListApi = () => {
|
export const creditListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/credit/list`,
|
url: '/v1/mall/credit/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const depositInfoApi = () => {
|
export const depositInfoApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/rechargeApplication`,
|
url: '/v1/mall/rechargeApplication',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ export const depositInfoApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const depositListApi = () => {
|
export const depositListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/rechargeApplication/list`,
|
url: '/v1/mall/rechargeApplication/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ export const depositListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const depositDetailApi = () => {
|
export const depositDetailApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/rechargeApplication/order`,
|
url: '/v1/mall/rechargeApplication/order',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const FavoriteListApi = () => {
|
export const FavoriteListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/favorite/list`,
|
url: '/v1/mall/favorite/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ export const FavoriteListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const CreateFavoriteApi = () => {
|
export const CreateFavoriteApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/favorite`,
|
url: '/v1/mall/favorite',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ export const CreateFavoriteApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const DelFavoriteApi = () => {
|
export const DelFavoriteApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/favorite`,
|
url: '/v1/mall/favorite',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ export const DelFavoriteApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const UpdateFavoriteApi = () => {
|
export const UpdateFavoriteApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/favorite`,
|
url: '/v1/mall/favorite',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ export const UpdateFavoriteApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const AddFavoriteApi = () => {
|
export const AddFavoriteApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/favorite/product`,
|
url: '/v1/mall/favorite/product',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ export const AddFavoriteApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const DelFavoriteProductApi = () => {
|
export const DelFavoriteProductApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/favorite/product`,
|
url: '/v1/mall/favorite/product',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ export const DelFavoriteProductApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const DetailFavoriteProductApi = () => {
|
export const DetailFavoriteProductApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/favorite`,
|
url: '/v1/mall/favorite',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ export const DetailFavoriteProductApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const MoveFavoriteProductApi = () => {
|
export const MoveFavoriteProductApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/favorite/product`,
|
url: '/v1/mall/favorite/product',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const LoginApi = () => {
|
export const LoginApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/login`,
|
url: '/v1/mall/login',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const GetCategoryList = () => {
|
export const GetCategoryList = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/category/list`,
|
url: '/v1/mall/category/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ export const GetCategoryList = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetProductKindListApi = () => {
|
export const GetProductKindListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v2/mall/product/kind/list`,
|
url: '/v2/mall/product/kind/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ export const GetProductKindListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetProductListApi = () => {
|
export const GetProductListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v2/mall/product/list`,
|
url: '/v2/mall/product/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ export const GetProductListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetClassList = () => {
|
export const GetClassList = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v2/mall/product/kind/sub/list`,
|
url: '/v2/mall/product/kind/sub/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ export const GetClassList = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetProductDetailApi = () => {
|
export const GetProductDetailApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/product`,
|
url: '/v1/mall/product',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ export const GetProductDetailApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetLabProductApi = () => {
|
export const GetLabProductApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/product/color/absorb/match`,
|
url: '/v1/mall/product/color/absorb/match',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取面料颜色列表
|
* 获取面料颜色列表
|
||||||
@ -6,7 +6,7 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const GetColorList = () => {
|
export const GetColorList = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/product/color/list`,
|
url: '/v1/mall/product/color/list',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户资产
|
* 获取用户资产
|
||||||
@ -6,21 +6,21 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const userassets = () => {
|
export const userassets = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/assets`,
|
url: '/v1/mall/user/assets',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 取色对比
|
// 取色对比
|
||||||
export const productabsorbcontrast = () => {
|
export const productabsorbcontrast = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/product/color/absorb/contrast`,
|
url: '/v1/mall/product/color/absorb/contrast',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 订单统计
|
// 订单统计
|
||||||
export const userorderStatistics = () => {
|
export const userorderStatistics = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/orderStatistics`,
|
url: '/v1/mall/user/orderStatistics',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const GetPayCode = () => {
|
export const GetPayCode = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/xima-caphtml/caphtml`,
|
url: '/xima-caphtml/caphtml',
|
||||||
base_url: CAP_HTML_TO_IMAGE_BASE_URL,
|
base_url: CAP_HTML_TO_IMAGE_BASE_URL,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
@ -26,7 +26,7 @@ export const GetPayCode = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetReturnPayCode = () => {
|
export const GetReturnPayCode = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/xima-caphtml/caphtml-return`,
|
url: '/xima-caphtml/caphtml-return',
|
||||||
base_url: CAP_HTML_TO_IMAGE_BASE_URL,
|
base_url: CAP_HTML_TO_IMAGE_BASE_URL,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const SaleOrderApi = () => {
|
export const SaleOrderApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder`,
|
url: '/v1/mall/saleOrder',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ export const SaleOrderApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const SaleOrderPreViewApi = () => {
|
export const SaleOrderPreViewApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/preView`,
|
url: '/v1/mall/saleOrder/preView',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ export const SaleOrderPreViewApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetSaleOrderDetailApi = () => {
|
export const GetSaleOrderDetailApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/detail`,
|
url: '/v1/mall/saleOrder/detail',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ export const GetSaleOrderDetailApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const EditSaleOrderRemarkApi = () => {
|
export const EditSaleOrderRemarkApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/remark`,
|
url: '/v1/mall/saleOrder/remark',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ export const EditSaleOrderRemarkApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const EditSaleOrderAddressApi = () => {
|
export const EditSaleOrderAddressApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/address`,
|
url: '/v1/mall/saleOrder/address',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ export const EditSaleOrderAddressApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const EditSaleOrderShipmentModeApi = () => {
|
export const EditSaleOrderShipmentModeApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/shipmentMode`,
|
url: '/v1/mall/saleOrder/shipmentMode',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ export const EditSaleOrderShipmentModeApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetOrderStatusListApi = () => {
|
export const GetOrderStatusListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/sale/order/status`,
|
url: '/v1/mall/enum/sale/order/status',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ export const GetOrderStatusListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetOrderListApi = () => {
|
export const GetOrderListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/list`,
|
url: '/v1/mall/saleOrder/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ export const GetOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const CancelOrderApi = () => {
|
export const CancelOrderApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/cancel`,
|
url: '/v1/mall/saleOrder/cancel',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ export const CancelOrderApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ReceiveOrderApi = () => {
|
export const ReceiveOrderApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/receive`,
|
url: '/v1/mall/saleOrder/receive',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ export const ReceiveOrderApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const OrderStatusListApi = () => {
|
export const OrderStatusListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/filterSaleOrderStatus`,
|
url: '/v1/mall/enum/filterSaleOrderStatus',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const GetOrderPayApi = () => {
|
export const GetOrderPayApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/orderPayment/orderPaymentMethodInfo`,
|
url: '/v1/mall/orderPayment/orderPaymentMethodInfo',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ export const GetOrderPayApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const SubmitOrderPayApi = () => {
|
export const SubmitOrderPayApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/orderPayment/orderPaymentSubmission`,
|
url: '/v1/mall/orderPayment/orderPaymentSubmission',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ export const SubmitOrderPayApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetPrepayOrderPayApi = () => {
|
export const GetPrepayOrderPayApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/orderPayment/preCollectOrder/orderPaymentMethodInfo`,
|
url: '/v1/mall/orderPayment/preCollectOrder/orderPaymentMethodInfo',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ export const GetPrepayOrderPayApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const SubmitPrepayOrderPayApi = () => {
|
export const SubmitPrepayOrderPayApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/orderPayment/preCollectOrder/orderPaymentSubmission`,
|
url: '/v1/mall/orderPayment/preCollectOrder/orderPaymentSubmission',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 售后订单列表
|
* 售后订单列表
|
||||||
*/
|
*/
|
||||||
export const GetSaleOrderListApi = () => {
|
export const GetSaleOrderListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/returnApplyOrder/list`,
|
url: '/v1/mall/returnApplyOrder/list',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,8 +15,8 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ReturnApplyOrderApi = () => {
|
export const ReturnApplyOrderApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/returnApplyOrder`,
|
url: '/v1/mall/returnApplyOrder',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,8 +25,8 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ReturnApplyOrderCancelApi = () => {
|
export const ReturnApplyOrderCancelApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/returnApplyOrder/cancel`,
|
url: '/v1/mall/returnApplyOrder/cancel',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,8 +35,8 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const SaleOrderOrderDetailApi = () => {
|
export const SaleOrderOrderDetailApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/returnApplyOrder`,
|
url: '/v1/mall/returnApplyOrder',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,19 +45,18 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ReturnApplyLogisticsApi = () => {
|
export const ReturnApplyLogisticsApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/returnApplyOrder/upload`,
|
url: '/v1/mall/returnApplyOrder/upload',
|
||||||
method: "put",
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 售后货物状况
|
* 售后货物状况
|
||||||
*/
|
*/
|
||||||
export const ReturnGoodsStatusApi = () => {
|
export const ReturnGoodsStatusApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/return/goodsStatus`,
|
url: '/v1/mall/enum/return/goodsStatus',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,8 +65,8 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ReturnReasonApi = () => {
|
export const ReturnReasonApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/returnOrder/returnReason`,
|
url: '/v1/mall/enum/returnOrder/returnReason',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +75,8 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ReturnExplainApi = () => {
|
export const ReturnExplainApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/returnExplain`,
|
url: '/v1/mall/enum/returnExplain',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +85,8 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ApplyRefundApi = () => {
|
export const ApplyRefundApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/returnApplyOrder`,
|
url: '/v1/mall/returnApplyOrder',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +95,8 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const RefundOrderSatausApi = () => {
|
export const RefundOrderSatausApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/filterReturnStage`,
|
url: '/v1/mall/enum/filterReturnStage',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +105,8 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const RefundExplainApi = () => {
|
export const RefundExplainApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/refundExplain`,
|
url: '/v1/mall/enum/refundExplain',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +115,7 @@ export const GetSaleOrderListApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ReturnRecordApi = () => {
|
export const ReturnRecordApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/saleOrder/return`,
|
url: '/v1/mall/saleOrder/return',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,33 +1,31 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取热门搜索
|
* 获取热门搜索
|
||||||
*/
|
*/
|
||||||
export const GetHotSearchApi = () => {
|
export const GetHotSearchApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/hotSearch/list`,
|
url: '/v1/mall/hotSearch/list',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取历史搜索
|
* 获取历史搜索
|
||||||
*/
|
*/
|
||||||
export const GetSearchHistoryApi = () => {
|
export const GetSearchHistoryApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/searchHistory/list`,
|
url: '/v1/mall/searchHistory/list',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加搜索关键字
|
* 添加搜索关键字
|
||||||
*/
|
*/
|
||||||
export const AddSearchHistoryApi = () => {
|
export const AddSearchHistoryApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/searchHistory`,
|
url: '/v1/mall/searchHistory',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1,12 +1,12 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分享短码
|
* 分享短码
|
||||||
*/
|
*/
|
||||||
export const GetShortCodeApi = () => {
|
export const GetShortCodeApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/shortCode/add`,
|
url: '/v1/mall/shortCode/add',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,8 +15,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const AnalysisShortCodeApi = () => {
|
export const AnalysisShortCodeApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/shortCode`,
|
url: '/v1/mall/shortCode',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const BindShortCodeApi = () => {
|
export const BindShortCodeApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/shortCode/bind`,
|
url: '/v1/mall/shortCode/bind',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
|||||||
*/
|
*/
|
||||||
export const GetShoppingCartApi = () => {
|
export const GetShoppingCartApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/shoppingCart/productColor`,
|
url: '/v1/mall/shoppingCart/productColor',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ export const GetShoppingCartApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const AddShoppingCartApi = () => {
|
export const AddShoppingCartApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/shoppingCart/productColor/list`,
|
url: '/v1/mall/shoppingCart/productColor/list',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ export const AddShoppingCartApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const DelShoppingCartApi = () => {
|
export const DelShoppingCartApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/shoppingCart/productColor`,
|
url: '/v1/mall/shoppingCart/productColor',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ export const DelShoppingCartApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const UpdateShoppingCartApi = () => {
|
export const UpdateShoppingCartApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/shoppingCart/productColor`,
|
url: '/v1/mall/shoppingCart/productColor',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取专题列表
|
* 获取专题列表
|
||||||
@ -6,8 +6,7 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const GetSubjectList = () => {
|
export const GetSubjectList = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/subject/list`,
|
url: '/v1/mall/subject/list',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
/**
|
/**
|
||||||
* 解密用户微信信息
|
* 解密用户微信信息
|
||||||
*/
|
*/
|
||||||
export const GetWxUserInfoApi = () => {
|
export const GetWxUserInfoApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/decrypt`,
|
url: '/v1/mall/user/decrypt',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,8 +14,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const GetAdminUserInfoApi = () => {
|
export const GetAdminUserInfoApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/info`,
|
url: '/v1/mall/user/info',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,8 +24,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const GetPhoneNumberApi = () => {
|
export const GetPhoneNumberApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/phoneNumber`,
|
url: '/v1/mall/user/phoneNumber',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const realNameUpdateApi = () => {
|
export const realNameUpdateApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user`,
|
url: '/v1/mall/user',
|
||||||
method: "put",
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const companyTypeApi = () => {
|
export const companyTypeApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/enum/purchaserType`,
|
url: '/v1/mall/enum/purchaserType',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ export const companyTypeApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const portraitUpdateApi = () => {
|
export const portraitUpdateApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/avatar`,
|
url: '/v1/mall/user/avatar',
|
||||||
method: "put",
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +64,8 @@ export const companyTypeApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const BindingCompanyApi = () => {
|
export const BindingCompanyApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/binding/company`,
|
url: '/v1/mall/user/binding/company',
|
||||||
method: "put",
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +74,8 @@ export const companyTypeApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const ApplyOrderAccessApi = () => {
|
export const ApplyOrderAccessApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/orderAccess/apply`,
|
url: '/v1/mall/orderAccess/apply',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +84,8 @@ export const companyTypeApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const SubscriptionMessageApi = () => {
|
export const SubscriptionMessageApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/subscriptionMessage`,
|
url: '/v1/mall/subscriptionMessage',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,8 +94,8 @@ export const companyTypeApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const GetInvitationInfoApi = () => {
|
export const GetInvitationInfoApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/invitationInfo`,
|
url: '/v1/mall/user/invitationInfo',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ export const companyTypeApi = () => {
|
|||||||
*/
|
*/
|
||||||
export const BindInvitationInfoApi = () => {
|
export const BindInvitationInfoApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/user/bindInvitationCode`,
|
url: '/v1/mall/user/bindInvitationCode',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useRequest } from "@/use/useHttp"
|
import { useRequest } from '@/use/useHttp'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 码单列表获取
|
* 码单列表获取
|
||||||
@ -6,8 +6,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const weightListApi = () => {
|
export const weightListApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/title/list`,
|
url: '/v1/mall/title/list',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,8 +17,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const weightAddApi = () => {
|
export const weightAddApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/title`,
|
url: '/v1/mall/title',
|
||||||
method: "post",
|
method: 'post',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,8 +28,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const weightDetailApi = () => {
|
export const weightDetailApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/title`,
|
url: '/v1/mall/title',
|
||||||
method: "get",
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,8 +39,8 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const weightEditApi = () => {
|
export const weightEditApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/title`,
|
url: '/v1/mall/title',
|
||||||
method: "put",
|
method: 'put',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ import { useRequest } from "@/use/useHttp"
|
|||||||
*/
|
*/
|
||||||
export const weightDeleteApi = () => {
|
export const weightDeleteApi = () => {
|
||||||
return useRequest({
|
return useRequest({
|
||||||
url: `/v1/mall/title`,
|
url: '/v1/mall/title',
|
||||||
method: "delete",
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,164 +23,164 @@ export default {
|
|||||||
text: '我的',
|
text: '我的',
|
||||||
iconPath: './styles/tabbar/my.png',
|
iconPath: './styles/tabbar/my.png',
|
||||||
selectedIconPath: './styles/tabbar/my_selected.png',
|
selectedIconPath: './styles/tabbar/my_selected.png',
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
'color': '#707070',
|
color: '#707070',
|
||||||
'selectedColor': '#2680EB',
|
selectedColor: '#2680EB',
|
||||||
'backgroundColor': '#fff',
|
backgroundColor: '#fff',
|
||||||
'borderStyle': 'white'
|
borderStyle: 'white',
|
||||||
},
|
},
|
||||||
subPackages: [
|
subPackages: [
|
||||||
{
|
{
|
||||||
root: "pages/search",
|
root: 'pages/search',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/classList",
|
root: 'pages/classList',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/details",
|
root: 'pages/details',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/searchList",
|
root: 'pages/searchList',
|
||||||
pages: [
|
pages: [
|
||||||
"searchList",
|
'searchList',
|
||||||
"hightSearchList",
|
'hightSearchList',
|
||||||
"search"
|
'search',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/userEdit",
|
root: 'pages/userEdit',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/addressManager",
|
root: 'pages/addressManager',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/addressAdd",
|
root: 'pages/addressAdd',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/company",
|
root: 'pages/company',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/weightList",
|
root: 'pages/weightList',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/weightListAdd",
|
root: 'pages/weightListAdd',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/order",
|
root: 'pages/order',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
"comfirm",
|
'comfirm',
|
||||||
"orderList/index"
|
'orderList/index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/editOrder",
|
root: 'pages/editOrder',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/subjectList",
|
root: 'pages/subjectList',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/creditLine",
|
root: 'pages/creditLine',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/creditUsed",
|
root: 'pages/creditUsed',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/depositBeforehandDetail",
|
root: 'pages/depositBeforehandDetail',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/depositBeforehand",
|
root: 'pages/depositBeforehand',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/depositList",
|
root: 'pages/depositList',
|
||||||
pages: [
|
pages: [
|
||||||
"index"
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/salesAfter",
|
root: 'pages/salesAfter',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
"salesAfterList/index"
|
'salesAfterList/index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/certification",
|
root: 'pages/certification',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/applyAfterSales",
|
root: 'pages/applyAfterSales',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/collection",
|
root: 'pages/collection',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
"collectionClass/index"
|
'collectionClass/index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/sampleComparison",
|
root: 'pages/sampleComparison',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: "pages/bindSalesman",
|
root: 'pages/bindSalesman',
|
||||||
pages: [
|
pages: [
|
||||||
"index",
|
'index',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/app.tsx
12
src/app.tsx
@ -1,7 +1,7 @@
|
|||||||
import { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import ContextBlueTooth from '@/use/contextBlueTooth'
|
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import configStore from './store'
|
import configStore from './store'
|
||||||
|
import ContextBlueTooth from '@/use/contextBlueTooth'
|
||||||
import './app.scss'
|
import './app.scss'
|
||||||
import Taro, { onAppShow, useDidShow } from '@tarojs/taro'
|
import Taro, { onAppShow, useDidShow } from '@tarojs/taro'
|
||||||
import { shareShop } from './common/util'
|
import { shareShop } from './common/util'
|
||||||
@ -18,15 +18,15 @@ const App: FC = (params) => {
|
|||||||
// 检查版本更新
|
// 检查版本更新
|
||||||
onAppShow(() => {
|
onAppShow(() => {
|
||||||
const updateManager = Taro.getUpdateManager()
|
const updateManager = Taro.getUpdateManager()
|
||||||
updateManager.onCheckForUpdate(function (res) {
|
updateManager.onCheckForUpdate((res) => {
|
||||||
// 请求完新版本信息的回调
|
// 请求完新版本信息的回调
|
||||||
console.log('版本信息:', res.hasUpdate)
|
console.log('版本信息:', res.hasUpdate)
|
||||||
})
|
})
|
||||||
updateManager.onUpdateReady(function () {
|
updateManager.onUpdateReady(() => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '更新提示',
|
title: '更新提示',
|
||||||
content: '新版本已经准备好,是否重启应用?',
|
content: '新版本已经准备好,是否重启应用?',
|
||||||
success: function (res) {
|
success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||||
updateManager.applyUpdate()
|
updateManager.applyUpdate()
|
||||||
@ -34,7 +34,7 @@ const App: FC = (params) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
updateManager.onUpdateFailed(function () {
|
updateManager.onUpdateFailed(() => {
|
||||||
console.log('新版本更新失败')
|
console.log('新版本更新失败')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,86 +1,76 @@
|
|||||||
module.exports = function(lab1, lab2) {
|
module.exports = function(lab1, lab2) {
|
||||||
|
const rgb2labArray1 = lab1
|
||||||
|
const rgb2labArray2 = lab2
|
||||||
|
|
||||||
var rgb2labArray1 = lab1;
|
const l1 = rgb2labArray1[0]
|
||||||
var rgb2labArray2 = lab2;
|
const a1 = rgb2labArray1[1]
|
||||||
|
const b1 = rgb2labArray1[2]
|
||||||
|
|
||||||
var l1 = rgb2labArray1[0];
|
const l2 = rgb2labArray2[0]
|
||||||
var a1 = rgb2labArray1[1];
|
const a2 = rgb2labArray2[1]
|
||||||
var b1 = rgb2labArray1[2];
|
const b2 = rgb2labArray2[2]
|
||||||
|
|
||||||
var l2 = rgb2labArray2[0];
|
const avg_lp = (l1 + l2) / 2
|
||||||
var a2 = rgb2labArray2[1];
|
const c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2))
|
||||||
var b2 = rgb2labArray2[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)
|
||||||
|
|
||||||
var avg_lp = (l1 + l2) / 2;
|
const c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2))
|
||||||
var c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2));
|
const c2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b2, 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);
|
const avg_cp = (c1p + c2p) / 2
|
||||||
var a2p = a2 * (1 + g);
|
|
||||||
|
|
||||||
var c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2));
|
let h1p = rad2deg(Math.atan2(b1, a1p))
|
||||||
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) {
|
if (h1p < 0) {
|
||||||
|
h1p = h1p + 360
|
||||||
h1p = h1p + 360;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var h2p = rad2deg(Math.atan2(b2, a2p));
|
let h2p = rad2deg(Math.atan2(b2, a2p))
|
||||||
if (h2p < 0) {
|
if (h2p < 0) {
|
||||||
|
h2p = h2p + 360
|
||||||
h2p = h2p + 360;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2;
|
const avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2
|
||||||
|
|
||||||
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))
|
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))
|
||||||
|
|
||||||
var delta_hp = h2p - h1p;
|
let delta_hp = h2p - h1p
|
||||||
if (Math.abs(delta_hp) > 180) {
|
if (Math.abs(delta_hp) > 180) {
|
||||||
if (h2p <= h1p) {
|
if (h2p <= h1p) {
|
||||||
delta_hp += 360;
|
delta_hp += 360
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delta_hp -= 360;
|
delta_hp -= 360
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var delta_lp = l2 - l1;
|
const delta_lp = l2 - l1
|
||||||
var delta_cp = c2p - c1p;
|
const delta_cp = c2p - c1p
|
||||||
|
|
||||||
delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2);
|
delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2)
|
||||||
|
|
||||||
var s_l = 1 + ((0.015 * Math.pow(avg_lp - 50, 2)) / Math.sqrt(20 + Math.pow(avg_lp - 50, 2)));
|
const 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
|
const s_c = 1 + 0.045 * avg_cp
|
||||||
var s_h = 1 + 0.015 * avg_cp * t;
|
const s_h = 1 + 0.015 * avg_cp * t
|
||||||
|
|
||||||
var delta_ro = 30 * Math.exp( - (Math.pow((avg_hp - 275) / 25, 2)));
|
const 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)));
|
const 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));
|
const r_t = -r_c * Math.sin(2 * deg2rad(delta_ro))
|
||||||
|
|
||||||
var kl = 1, kc =1, kh = 1;
|
const kl = 1; const kc = 1; const kh = 1
|
||||||
|
|
||||||
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 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
|
return delta_e
|
||||||
|
|
||||||
|
|
||||||
function rad2deg(rad) {
|
function rad2deg(rad) {
|
||||||
|
return 360 * rad / (2 * Math.PI)
|
||||||
return 360 * rad / (2 * Math.PI);
|
|
||||||
}
|
}
|
||||||
function deg2rad(deg) {
|
function deg2rad(deg) {
|
||||||
|
return (2 * Math.PI * deg) / 360
|
||||||
return (2 * Math.PI * deg) / 360;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import XyzCom from './xyz'
|
|||||||
import ColorDiff from './colorDiff'
|
import ColorDiff from './colorDiff'
|
||||||
|
|
||||||
export const toRgb = (lab) => {
|
export const toRgb = (lab) => {
|
||||||
let xyz = LabCom.xyz(lab)
|
const xyz = LabCom.xyz(lab)
|
||||||
return XyzCom.rgb(xyz)
|
return XyzCom.rgb(xyz)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
var xyz = require('./xyz');
|
const xyz = require('./xyz')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'lab',
|
name: 'lab',
|
||||||
@ -8,47 +8,47 @@ module.exports = {
|
|||||||
channel: ['lightness', 'a', 'b'],
|
channel: ['lightness', 'a', 'b'],
|
||||||
alias: ['LAB', 'cielab'],
|
alias: ['LAB', 'cielab'],
|
||||||
|
|
||||||
xyz: function(lab) {
|
xyz(lab) {
|
||||||
var l = lab[0],
|
const l = lab[0]
|
||||||
a = lab[1],
|
const a = lab[1]
|
||||||
b = lab[2],
|
const b = lab[2]
|
||||||
x, y, z, y2;
|
let x; let y; let z; let y2
|
||||||
|
|
||||||
if (l <= 8) {
|
if (l <= 8) {
|
||||||
y = (l * 100) / 903.3;
|
y = (l * 100) / 903.3
|
||||||
y2 = (7.787 * (y / 100)) + (16 / 116);
|
y2 = (7.787 * (y / 100)) + (16 / 116)
|
||||||
} else {
|
}
|
||||||
y = 100 * Math.pow((l + 16) / 116, 3);
|
else {
|
||||||
y2 = Math.pow(y / 100, 1/3);
|
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
|
// extend xyz
|
||||||
xyz.lab = function(xyz) {
|
xyz.lab = function(xyz) {
|
||||||
var x = xyz[0],
|
let x = xyz[0]
|
||||||
y = xyz[1],
|
let y = xyz[1]
|
||||||
z = xyz[2],
|
let z = xyz[2]
|
||||||
l, a, b;
|
let l; let a; let b
|
||||||
|
|
||||||
x /= 95.047;
|
x /= 95.047
|
||||||
y /= 100;
|
y /= 100
|
||||||
z /= 108.883;
|
z /= 108.883
|
||||||
|
|
||||||
x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (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);
|
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);
|
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116)
|
||||||
|
|
||||||
l = (116 * y) - 16;
|
l = (116 * y) - 16
|
||||||
a = 500 * (x - y);
|
a = 500 * (x - y)
|
||||||
b = 200 * (y - z);
|
b = 200 * (y - z)
|
||||||
|
|
||||||
return [l, a, b];
|
return [l, a, b]
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'rgb',
|
name: 'rgb',
|
||||||
min: [0, 0, 0],
|
min: [0, 0, 0],
|
||||||
max: [255, 255, 255],
|
max: [255, 255, 255],
|
||||||
channel: ['red', 'green', 'blue'],
|
channel: ['red', 'green', 'blue'],
|
||||||
alias: ['RGB']
|
alias: ['RGB'],
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
|
|
||||||
var rgb = require('./rgb');
|
const rgb = require('./rgb')
|
||||||
|
|
||||||
var xyz = {
|
const xyz = {
|
||||||
name: 'xyz',
|
name: 'xyz',
|
||||||
min: [0, 0, 0],
|
min: [0, 0, 0],
|
||||||
channel: ['X', 'Y', 'Z'],
|
channel: ['X', 'Y', 'Z'],
|
||||||
alias: ['XYZ', 'ciexyz', 'cie1931']
|
alias: ['XYZ', 'ciexyz', 'cie1931'],
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whitepoint reference values with observer/illuminant
|
* Whitepoint reference values with observer/illuminant
|
||||||
@ -39,7 +38,7 @@ xyz.whitepoint = {
|
|||||||
// F10: [],
|
// F10: [],
|
||||||
F11: [100.966, 100, 64.370],
|
F11: [100.966, 100, 64.370],
|
||||||
// F12: [],
|
// F12: [],
|
||||||
E: [100,100,100]
|
E: [100, 100, 100],
|
||||||
},
|
},
|
||||||
|
|
||||||
// 1964 10°
|
// 1964 10°
|
||||||
@ -56,16 +55,14 @@ xyz.whitepoint = {
|
|||||||
F2: [103.280, 100, 69.026],
|
F2: [103.280, 100, 69.026],
|
||||||
F7: [95.792, 100, 107.687],
|
F7: [95.792, 100, 107.687],
|
||||||
F11: [103.866, 100, 65.627],
|
F11: [103.866, 100, 65.627],
|
||||||
E: [100,100,100]
|
E: [100, 100, 100],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top values are the whitepoint’s top values, default are D65
|
* 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
|
* Transform xyz to rgb
|
||||||
@ -76,37 +73,38 @@ xyz.max = xyz.whitepoint[2].D65;
|
|||||||
*/
|
*/
|
||||||
xyz.rgb = function(_xyz, white) {
|
xyz.rgb = function(_xyz, white) {
|
||||||
// FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then
|
// FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then
|
||||||
white = white || xyz.whitepoint[2].E;
|
white = white || xyz.whitepoint[2].E
|
||||||
|
|
||||||
var x = _xyz[0] / white[0],
|
const x = _xyz[0] / white[0]
|
||||||
y = _xyz[1] / white[1],
|
const y = _xyz[1] / white[1]
|
||||||
z = _xyz[2] / white[2],
|
const z = _xyz[2] / white[2]
|
||||||
r, g, b;
|
let r; let g; let b
|
||||||
|
|
||||||
// assume sRGB
|
// assume sRGB
|
||||||
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
||||||
r = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293);
|
r = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293)
|
||||||
g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175);
|
g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175)
|
||||||
b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878);
|
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 > 0.0031308
|
||||||
: r = (r * 12.92);
|
? ((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 > 0.0031308
|
||||||
: g = (g * 12.92);
|
? ((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 > 0.0031308
|
||||||
: b = (b * 12.92);
|
? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
|
||||||
|
: b = (b * 12.92)
|
||||||
|
|
||||||
r = Math.min(Math.max(0, r), 1);
|
r = Math.min(Math.max(0, r), 1)
|
||||||
g = Math.min(Math.max(0, g), 1);
|
g = Math.min(Math.max(0, g), 1)
|
||||||
b = Math.min(Math.max(0, b), 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
|
* RGB to XYZ
|
||||||
*
|
*
|
||||||
@ -115,24 +113,22 @@ xyz.rgb = function (_xyz, white) {
|
|||||||
* @return {Array} XYZ channels
|
* @return {Array} XYZ channels
|
||||||
*/
|
*/
|
||||||
rgb.xyz = function(rgb, white) {
|
rgb.xyz = function(rgb, white) {
|
||||||
var r = rgb[0] / 255,
|
let r = rgb[0] / 255
|
||||||
g = rgb[1] / 255,
|
let g = rgb[1] / 255
|
||||||
b = rgb[2] / 255;
|
let b = rgb[2] / 255
|
||||||
|
|
||||||
// assume sRGB
|
// assume sRGB
|
||||||
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
|
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);
|
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);
|
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);
|
const x = (r * 0.41239079926595) + (g * 0.35758433938387) + (b * 0.18048078840183)
|
||||||
var y = (r * 0.21263900587151) + (g * 0.71516867876775) + (b * 0.072192315360733);
|
const y = (r * 0.21263900587151) + (g * 0.71516867876775) + (b * 0.072192315360733)
|
||||||
var z = (r * 0.019330818715591) + (g * 0.11919477979462) + (b * 0.95053215224966);
|
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;
|
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
import { uint32ToUint8Array, uint8ArrayToHex } from "./utils";
|
import { uint32ToUint8Array, uint8ArrayToHex } from './utils'
|
||||||
|
|
||||||
export class Command {
|
export class Command {
|
||||||
// 测量序号
|
// 测量序号
|
||||||
static measureId = 1;
|
static measureId = 1
|
||||||
|
|
||||||
// 命令完整响应的长度
|
// 命令完整响应的长度
|
||||||
responseSize = 0;
|
responseSize = 0
|
||||||
// 命令发送的数据
|
// 命令发送的数据
|
||||||
content = new Uint8Array(0);
|
content = new Uint8Array(0)
|
||||||
// 命令响应的数据
|
// 命令响应的数据
|
||||||
response = new Uint8Array(0);
|
response = new Uint8Array(0)
|
||||||
// 等待响应的超时时间
|
// 等待响应的超时时间
|
||||||
timeout = 3000;
|
timeout = 3000
|
||||||
// 发送的数据是否需要生成和校验值
|
// 发送的数据是否需要生成和校验值
|
||||||
needSign = true;
|
needSign = true
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Uint8Array|ArrayBuffer|number[]} content
|
* @param {Uint8Array|ArrayBuffer|number[]} content
|
||||||
@ -24,15 +23,16 @@ export class Command {
|
|||||||
*/
|
*/
|
||||||
constructor(content, responseSize, timeout = 3000, needSign = true) {
|
constructor(content, responseSize, timeout = 3000, needSign = true) {
|
||||||
if (content instanceof Uint8Array) {
|
if (content instanceof Uint8Array) {
|
||||||
this.content = content;
|
this.content = content
|
||||||
} else {
|
|
||||||
this.content = new Uint8Array(content);
|
|
||||||
}
|
}
|
||||||
this.responseSize = responseSize;
|
else {
|
||||||
|
this.content = new Uint8Array(content)
|
||||||
|
}
|
||||||
|
this.responseSize = responseSize
|
||||||
if (typeof timeout === 'number' && timeout >= 0) {
|
if (typeof timeout === 'number' && timeout >= 0) {
|
||||||
this.timeout = timeout;
|
this.timeout = timeout
|
||||||
}
|
}
|
||||||
this.needSign = needSign;
|
this.needSign = needSign
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,26 +40,26 @@ export class Command {
|
|||||||
* @returns {ArrayBuffer[]}
|
* @returns {ArrayBuffer[]}
|
||||||
*/
|
*/
|
||||||
get data() {
|
get data() {
|
||||||
if (this.content.length === 0) throw new Error('正文内容不能为空');
|
if (this.content.length === 0) { throw new Error('正文内容不能为空') }
|
||||||
const data = [];
|
const data = []
|
||||||
const b = new Uint8Array(this.content.buffer);
|
const b = new Uint8Array(this.content.buffer)
|
||||||
if (this.needSign) {
|
if (this.needSign) {
|
||||||
b[b.length - 1] = Command.getSign(b);
|
b[b.length - 1] = Command.getSign(b)
|
||||||
}
|
}
|
||||||
for (let i = 0; i < b.length; i += 20) {
|
for (let i = 0; i < b.length; i += 20) {
|
||||||
data.push(b.slice(i, i + 20).buffer);
|
data.push(b.slice(i, i + 20).buffer)
|
||||||
}
|
}
|
||||||
return data;
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 是否接收完成 */
|
/** 是否接收完成 */
|
||||||
get isComplete() {
|
get isComplete() {
|
||||||
return this.response.length >= this.responseSize;
|
return this.response.length >= this.responseSize
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 是否有效 */
|
/** 是否有效 */
|
||||||
get isValid() {
|
get isValid() {
|
||||||
return Command.getSign(this.response) === this.response[this.response.length - 1];
|
return Command.getSign(this.response) === this.response[this.response.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,32 +67,31 @@ export class Command {
|
|||||||
* @param {ArrayBuffer} buffer
|
* @param {ArrayBuffer} buffer
|
||||||
*/
|
*/
|
||||||
fillResponse(buffer) {
|
fillResponse(buffer) {
|
||||||
this.response = new Uint8Array([...this.response, ...(new Uint8Array(buffer))]);
|
this.response = new Uint8Array([...this.response, ...(new Uint8Array(buffer))])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取和校验值
|
* 获取和校验值
|
||||||
* @param {ArrayBuffer|Uint8Array} buffer
|
* @param {ArrayBuffer|Uint8Array} buffer
|
||||||
*/
|
*/
|
||||||
static getSign(buffer) {
|
static getSign(buffer) {
|
||||||
const _b = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
const _b = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer)
|
||||||
let sum = 0;
|
let sum = 0
|
||||||
_b.slice(0, _b.length - 1).forEach(i => sum += i);
|
_b.slice(0, _b.length - 1).forEach(i => sum += i)
|
||||||
return new Uint8Array([sum])[0];
|
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) {
|
static measure(mode = 0) {
|
||||||
Command.measureId += 1;
|
Command.measureId += 1
|
||||||
const measureId = uint32ToUint8Array(Command.measureId);
|
const measureId = uint32ToUint8Array(Command.measureId)
|
||||||
return new Command([0xbb, 1, mode, ...measureId, 0, 0xff, 0], 10, 1500);
|
return new Command([0xBB, 1, mode, ...measureId, 0, 0xFF, 0], 10, 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +99,7 @@ export class Command {
|
|||||||
* @param {number} mode
|
* @param {number} mode
|
||||||
*/
|
*/
|
||||||
static getLab(mode = 0) {
|
static getLab(mode = 0) {
|
||||||
return new Command([0xbb, 3, mode, 0, 0, 0, 0, 0, 0xff, 0], 20, 1500);
|
return new Command([0xBB, 3, mode, 0, 0, 0, 0, 0, 0xFF, 0], 20, 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +107,7 @@ export class Command {
|
|||||||
* @param {number} mode
|
* @param {number} mode
|
||||||
*/
|
*/
|
||||||
static getRGB(mode = 0) {
|
static getRGB(mode = 0) {
|
||||||
return new Command([0xbb, 4, mode, 0, 0, 0, 0, 0, 0xff, 0], 20, 1500);
|
return new Command([0xBB, 4, mode, 0, 0, 0, 0, 0, 0xFF, 0], 20, 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +115,7 @@ export class Command {
|
|||||||
* @param {number} mode
|
* @param {number} mode
|
||||||
*/
|
*/
|
||||||
static getSpectral(mode = 0) {
|
static getSpectral(mode = 0) {
|
||||||
return new Command([0xbb, 2, 0x10 + mode, 0, 0, 0 ,0 ,0, 0xff, 0], 200, 5000);
|
return new Command([0xBB, 2, 0x10 + mode, 0, 0, 0, 0, 0, 0xFF, 0], 200, 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,23 +123,19 @@ export class Command {
|
|||||||
* @param {number} check 是否判断校准成功 1 判断 0 不判断
|
* @param {number} check 是否判断校准成功 1 判断 0 不判断
|
||||||
*/
|
*/
|
||||||
static whiteCalibrate(check = 1) {
|
static whiteCalibrate(check = 1) {
|
||||||
return new Command([0xbb, 0x11, check, 0, 0, 0, 0, 0, 0xff, 0], 10, 1500);
|
return new Command([0xBB, 0x11, check, 0, 0, 0, 0, 0, 0xFF, 0], 10, 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 黑校准
|
* 黑校准
|
||||||
* @param {number} check 是否判断校准成功
|
* @param {number} check 是否判断校准成功
|
||||||
*/
|
*/
|
||||||
static blackCalibrate(check = 1) {
|
static blackCalibrate(check = 1) {
|
||||||
return new Command([0xbb, 0x10, check, 0, 0, 0, 0, 0, 0xff, 0], 10, 1500);
|
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)
|
||||||
|
|
||||||
static GetDeviceInf = new Command([0xbb, 0x12, 0x01, 0, 0, 0, 0, 0, 0xff, 0], 200, 5000);
|
|
||||||
}
|
}
|
||||||
@ -3,7 +3,7 @@
|
|||||||
* @param {number} n
|
* @param {number} n
|
||||||
*/
|
*/
|
||||||
export function uint32ToUint8Array(n) {
|
export function uint32ToUint8Array(n) {
|
||||||
return new Uint8Array(new Uint32Array([n]).buffer);
|
return new Uint8Array(new Uint32Array([n]).buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,60 +11,55 @@ export function uint32ToUint8Array(n) {
|
|||||||
* @param {Uint8Array} raw
|
* @param {Uint8Array} raw
|
||||||
*/
|
*/
|
||||||
export function uint8ArrayToFloat32(raw) {
|
export function uint8ArrayToFloat32(raw) {
|
||||||
return new Float32Array(raw.buffer)[0];
|
return new Float32Array(raw.buffer)[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uint8 数组 转 Uint16
|
* Uint8 数组 转 Uint16
|
||||||
* @param {Uint8Array} raw
|
* @param {Uint8Array} raw
|
||||||
*/
|
*/
|
||||||
export function uint8ArrayToUint16(raw) {
|
export function uint8ArrayToUint16(raw) {
|
||||||
return new Uint16Array(raw.buffer)[0];
|
return new Uint16Array(raw.buffer)[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uint8 数组转 Uint32
|
* Uint8 数组转 Uint32
|
||||||
* @param {Uint8Array} raw
|
* @param {Uint8Array} raw
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function uint8ArrayToUnit32(raw) {
|
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) {
|
export function waitFor(duration) {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
setTimeout(resolve, duration);
|
setTimeout(resolve, duration)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uint8 数组转 hex 字符串
|
* uint8 数组转 hex 字符串
|
||||||
* @param {Uint8Array} raw
|
* @param {Uint8Array} raw
|
||||||
*/
|
*/
|
||||||
export function uint8ArrayToHex(raw) {
|
export function uint8ArrayToHex(raw) {
|
||||||
const s = [];
|
const s = []
|
||||||
raw.forEach(i => {
|
raw.forEach((i) => {
|
||||||
const b = i.toString(16);
|
const b = i.toString(16)
|
||||||
s.push(b.length > 1 ? b : `0${b}`);
|
s.push(b.length > 1 ? b : `0${b}`)
|
||||||
});
|
})
|
||||||
return s.join(' ');
|
return s.join(' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 二进制转字符串(ascii)
|
// 二进制转字符串(ascii)
|
||||||
export function bufferToString(buffer) {
|
export function bufferToString(buffer) {
|
||||||
let str = "";
|
let str = ''
|
||||||
for (let code of buffer) {
|
for (const code of buffer) {
|
||||||
if (code === 0) break;
|
if (code === 0) { break }
|
||||||
str += utf82string(code);
|
str += utf82string(code)
|
||||||
}
|
}
|
||||||
return str;
|
return str
|
||||||
}
|
}
|
||||||
@ -8,7 +8,7 @@ import Qs from 'qs'
|
|||||||
* @param type false 跳转普通页面,true 跳转tabbar页面
|
* @param type false 跳转普通页面,true 跳转tabbar页面
|
||||||
*/
|
*/
|
||||||
type ParamLink = 'navigateTo' | 'switchTab' | 'reLaunch' | 'redirectTo'
|
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) {
|
if (path) {
|
||||||
// let params_str = Qs_.stringify(params || {}, { encode: false })
|
// let params_str = Qs_.stringify(params || {}, { encode: false })
|
||||||
// path = params_str ? path + '?' + params_str : path
|
// 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 }) => {
|
const setUrlQuery = (options: { url: string; query: object | null }) => {
|
||||||
let { url, query } = options
|
let { url, query } = options
|
||||||
if (!url) return ''
|
if (!url) { return '' }
|
||||||
if (query) {
|
if (query) {
|
||||||
let queryArr: any[] = []
|
const queryArr: any[] = []
|
||||||
for (const key in query) {
|
for (const key in query) {
|
||||||
if (query.hasOwnProperty(key)) {
|
if (query.hasOwnProperty(key)) {
|
||||||
queryArr.push(`${key}=${query[key]}`)
|
queryArr.push(`${key}=${query[key]}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (url.indexOf('?') !== -1) {
|
if (url.includes('?')) {
|
||||||
url = `${url}&${queryArr.join('&')}`
|
url = `${url}&${queryArr.join('&')}`
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
url = `${url}?${queryArr.join('&')}`
|
url = `${url}?${queryArr.join('&')}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,12 +43,15 @@ const setUrlQuery = (options: { url: string; query: object | null }) => {
|
|||||||
export const isEmptyObject = (object: any) => {
|
export const isEmptyObject = (object: any) => {
|
||||||
if (object == undefined || object == null || Number.isNaN(object)) {
|
if (object == undefined || object == null || Number.isNaN(object)) {
|
||||||
return true
|
return true
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (object.constructor == Object) {
|
if (object.constructor == Object) {
|
||||||
return Reflect.ownKeys(object).length == 0
|
return Reflect.ownKeys(object).length == 0
|
||||||
} else if (object.constructor == Array) {
|
}
|
||||||
|
else if (object.constructor == Array) {
|
||||||
return object.length == 0
|
return object.length == 0
|
||||||
} else if (object.constructor == String) {
|
}
|
||||||
|
else if (object.constructor == String) {
|
||||||
return object == ''
|
return object == ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,22 +77,24 @@ export const isEmptyObject = (object: any) => {
|
|||||||
* @param message
|
* @param message
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const retrieval = (data: any, rules?: Object, message: string = '请填写完信息') => {
|
export const retrieval = (data: any, rules?: Object, message = '请填写完信息') => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (rules) {
|
if (rules) {
|
||||||
const keys = Reflect.ownKeys(rules)
|
const keys = Reflect.ownKeys(rules)
|
||||||
const result = keys.some((key: any) => {
|
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
|
let _res = false
|
||||||
if (item.validator) {
|
if (item.validator) {
|
||||||
if (item.validator(data[key], item)) {
|
if (item.validator(data[key], item)) {
|
||||||
_res = true
|
_res = true
|
||||||
}
|
}
|
||||||
} else if (item.regex) {
|
}
|
||||||
|
else if (item.regex) {
|
||||||
if (!item.regex.test(data[key])) {
|
if (!item.regex.test(data[key])) {
|
||||||
_res = true
|
_res = true
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (isEmptyObject(data[key])) {
|
if (isEmptyObject(data[key])) {
|
||||||
_res = true
|
_res = true
|
||||||
}
|
}
|
||||||
@ -100,7 +106,8 @@ export const retrieval = (data: any, rules?: Object, message: string = '请填
|
|||||||
if (result) {
|
if (result) {
|
||||||
reject(message)
|
reject(message)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const keys = Reflect.ownKeys(data)
|
const keys = Reflect.ownKeys(data)
|
||||||
if (keys.some((key: any) => isEmptyObject(data[key]))) {
|
if (keys.some((key: any) => isEmptyObject(data[key]))) {
|
||||||
reject(message)
|
reject(message)
|
||||||
|
|||||||
@ -18,8 +18,8 @@ export const BASE_URL = CURRENT_BASE_URL
|
|||||||
|
|
||||||
// CDN
|
// CDN
|
||||||
// 生成密钥
|
// 生成密钥
|
||||||
export const GET_UPLOAD_SIGN = `/upyun/getsign` // 请求签名 url
|
export const GET_UPLOAD_SIGN = '/upyun/getsign' // 请求签名 url
|
||||||
export const UPLOAD_CDN_URL = `https://v0.api.upyun.com/`
|
export const UPLOAD_CDN_URL = 'https://v0.api.upyun.com/'
|
||||||
|
|
||||||
// cdn
|
// 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://test.cdn.zzfzyc.com'
|
||||||
|
|||||||
@ -20,7 +20,8 @@ export const formatRemoveHashTag = (val = '') => {
|
|||||||
export const formatHashTag = (code = '', name = '', mode = 'both') => {
|
export const formatHashTag = (code = '', name = '', mode = 'both') => {
|
||||||
if (mode == 'both') {
|
if (mode == 'both') {
|
||||||
return `${formatRemoveHashTag(code)}# ${name}`
|
return `${formatRemoveHashTag(code)}# ${name}`
|
||||||
} else if (mode == 'name') {
|
}
|
||||||
|
else if (mode == 'name') {
|
||||||
return `${name}`
|
return `${name}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,7 +41,7 @@ export const weightDigit = 1000
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const formatPriceDiv = (val, digit = Digit, priceStatus = false) => {
|
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
|
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') => {
|
export const formatDateTime = (val, fmt = 'YYYY-MM-DD HH:mm:ss') => {
|
||||||
if (val) {
|
if (val) {
|
||||||
let time = new Date(val)
|
const time = new Date(val)
|
||||||
let Y = time.getFullYear()
|
const Y = time.getFullYear()
|
||||||
let M = time.getMonth() + 1
|
const M = time.getMonth() + 1
|
||||||
let d = time.getDate()
|
const d = time.getDate()
|
||||||
let h = time.getHours()
|
const h = time.getHours()
|
||||||
let m = time.getMinutes()
|
const m = time.getMinutes()
|
||||||
let s = time.getSeconds()
|
const s = time.getSeconds()
|
||||||
|
|
||||||
fmt = fmt
|
fmt = fmt
|
||||||
.replace('YYYY', Y)
|
.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'))
|
.replace('ss', s.toString().padStart(2, '0'))
|
||||||
|
|
||||||
return fmt
|
return fmt
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,17 +122,18 @@ export const formatMillionYuan = (num, digit = 10000) => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const toDecimal2 = (x) => {
|
export const toDecimal2 = (x) => {
|
||||||
var f = parseFloat(x)
|
let f = parseFloat(x)
|
||||||
if (isNaN(f)) {
|
if (isNaN(f)) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
f = f + ''
|
f = `${f}`
|
||||||
let index = f.lastIndexOf('.')
|
const index = f.lastIndexOf('.')
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
let decimal = f.substring(index + 1)
|
const decimal = f.substring(index + 1)
|
||||||
if (decimal.length == 1) {
|
if (decimal.length == 1) {
|
||||||
f = f.substring(0, index + 1) + decimal + '0'
|
f = `${f.substring(0, index + 1) + decimal}0`
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
f = f.substring(0, index + 1) + decimal.substring(0, 2)
|
f = f.substring(0, index + 1) + decimal.substring(0, 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,8 +149,9 @@ export const toDecimal2 = (x) => {
|
|||||||
export const formatImgUrl = (url, suffix = '!w200') => {
|
export const formatImgUrl = (url, suffix = '!w200') => {
|
||||||
if (url) {
|
if (url) {
|
||||||
return url.includes('http') ? url + suffix : IMG_CND_Prefix + url + suffix
|
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') => {
|
export const isLabImage = (imgurl, rgb, suffix = '!w200') => {
|
||||||
if (imgurl) {
|
if (imgurl) {
|
||||||
return { status: 1, value: IMG_CND_Prefix + '/' + imgurl + suffix }
|
return { status: 1, value: `${IMG_CND_Prefix}/${imgurl}${suffix}` }
|
||||||
} else if (rgb.r != 0 || rgb.g != 0 || rgb.b != 0) {
|
}
|
||||||
|
else if (rgb.r != 0 || rgb.g != 0 || rgb.b != 0) {
|
||||||
return { status: 2, value: rgb }
|
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))) {
|
if (!isNaN(Number(number))) {
|
||||||
// return parseFloat(number).toFixed(digit).replace(/^\B(?<!\.\d*)(?=(\d{3})+(?!\d))$/g, ",");
|
// return parseFloat(number).toFixed(digit).replace(/^\B(?<!\.\d*)(?=(\d{3})+(?!\d))$/g, ",");
|
||||||
return parseFloat(number).toLocaleString('zh', { minimumFractionDigits: digit })
|
return parseFloat(number).toLocaleString('zh', { minimumFractionDigits: digit })
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return 0.0
|
return 0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
import Taro from "@tarojs/taro"
|
import Taro from '@tarojs/taro'
|
||||||
import { BASE_URL } from "../constant"
|
import { BASE_URL } from '../constant'
|
||||||
|
|
||||||
// 解析短码(主要用于右上角按钮分享)
|
// 解析短码(主要用于右上角按钮分享)
|
||||||
export const analysisShortCodeApi = (val) => {
|
export const analysisShortCodeApi = (val) => {
|
||||||
// 解析短码
|
// 解析短码
|
||||||
Taro.request({
|
Taro.request({
|
||||||
url:BASE_URL+'/v1/mall/shortCode',
|
url: `${BASE_URL}/v1/mall/shortCode`,
|
||||||
method:"GET",
|
method: 'GET',
|
||||||
data: { md5_key: val },
|
data: { md5_key: val },
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
// 绑定上下级
|
// 绑定上下级
|
||||||
bindParent(res.data.data.share_user_id)
|
bindParent(res.data.data.share_user_id)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,13 +21,13 @@ export const analysisShortCodeApi = (val) => {
|
|||||||
const bindParent = (share_user_id) => {
|
const bindParent = (share_user_id) => {
|
||||||
// 绑定上下级
|
// 绑定上下级
|
||||||
Taro.request({
|
Taro.request({
|
||||||
url:BASE_URL+'/v1/mall/shortCode/bind',
|
url: `${BASE_URL}/v1/mall/shortCode/bind`,
|
||||||
method:"POST",
|
method: 'POST',
|
||||||
data:{share_user_id: share_user_id},
|
data: { share_user_id },
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
// 绑定上下级
|
// 绑定上下级
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
import Taro from "@tarojs/taro";
|
import Taro from '@tarojs/taro'
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 系统 本地存储
|
* 设置 系统 本地存储
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
import Taro from '@tarojs/taro'
|
||||||
import { formatImgUrl } from './fotmat'
|
import { formatImgUrl } from './fotmat'
|
||||||
import { analysisShortCodeApi } from './shortCode'
|
import { analysisShortCodeApi } from './shortCode'
|
||||||
import Taro from '@tarojs/taro'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 防抖
|
* 防抖
|
||||||
@ -11,7 +11,7 @@ import Taro from '@tarojs/taro'
|
|||||||
export const debounce = (fn, delay) => {
|
export const debounce = (fn, delay) => {
|
||||||
let timer: any = null
|
let timer: any = null
|
||||||
return (...param) => {
|
return (...param) => {
|
||||||
if (timer) clearTimeout(timer)
|
if (timer) { clearTimeout(timer) }
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
fn(...param)
|
fn(...param)
|
||||||
}, delay)
|
}, delay)
|
||||||
@ -27,7 +27,7 @@ export const debounce = (fn, delay) => {
|
|||||||
export const throttle = (fn, delay) => {
|
export const throttle = (fn, delay) => {
|
||||||
let pre = 0
|
let pre = 0
|
||||||
return (...params) => {
|
return (...params) => {
|
||||||
let now = new Date().getTime()
|
const now = new Date().getTime()
|
||||||
if (now - pre > delay) {
|
if (now - pre > delay) {
|
||||||
fn(...params)
|
fn(...params)
|
||||||
pre = now
|
pre = now
|
||||||
@ -42,14 +42,15 @@ export const throttle = (fn, delay) => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const getFilterData = (val = {}, arr: string[] = []) => {
|
export const getFilterData = (val = {}, arr: string[] = []) => {
|
||||||
let res = {}
|
const res = {}
|
||||||
for (let key in val) {
|
for (const key in val) {
|
||||||
if (val[key] !== undefined && val[key] !== null && val[key] !== '' && !arr.includes(key)) {
|
if (val[key] !== undefined && val[key] !== null && val[key] !== '' && !arr.includes(key)) {
|
||||||
if (typeof val[key] == 'number') {
|
if (typeof val[key] == 'number') {
|
||||||
if (!isNaN(val[key])) {
|
if (!isNaN(val[key])) {
|
||||||
res[key] = val[key]
|
res[key] = val[key]
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
res[key] = val[key]
|
res[key] = val[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,17 +64,19 @@ export const getFilterData = (val = {}, arr: string[] = []) => {
|
|||||||
*/
|
*/
|
||||||
export const copyObject = (object) => {
|
export const copyObject = (object) => {
|
||||||
if (object.constructor == Object) {
|
if (object.constructor == Object) {
|
||||||
let keys = Object.keys(object)
|
const keys = Object.keys(object)
|
||||||
let newObject = {}
|
const newObject = {}
|
||||||
keys.map((key) => {
|
keys.map((key) => {
|
||||||
newObject[key] = copyObject(object[key])
|
newObject[key] = copyObject(object[key])
|
||||||
})
|
})
|
||||||
return newObject
|
return newObject
|
||||||
} else if (object.constructor == Array) {
|
}
|
||||||
|
else if (object.constructor == Array) {
|
||||||
return object.map((item) => {
|
return object.map((item) => {
|
||||||
return copyObject(item)
|
return copyObject(item)
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return object
|
return object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,11 +101,14 @@ export const screenshot = (url, suffix = '!w200') => {
|
|||||||
export const dataLoadingStatus = ({ list = [], total = 0, status = false }: { list: any[]; total: number; status: true | false }) => {
|
export const dataLoadingStatus = ({ list = [], total = 0, status = false }: { list: any[]; total: number; status: true | false }) => {
|
||||||
if (list.length == 0 && status) {
|
if (list.length == 0 && status) {
|
||||||
return 0
|
return 0
|
||||||
} else if (list.length == 0 && !status) {
|
}
|
||||||
|
else if (list.length == 0 && !status) {
|
||||||
return 1
|
return 1
|
||||||
} else if (list.length < total) {
|
}
|
||||||
|
else if (list.length < total) {
|
||||||
return 2
|
return 2
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return 3
|
return 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,16 +125,17 @@ export const shareShop = () => {
|
|||||||
let path = ''
|
let path = ''
|
||||||
let title = ''
|
let title = ''
|
||||||
let imageUrl = ''
|
let imageUrl = ''
|
||||||
let sortCode = Taro.getStorageSync('sort_code') ? JSON.parse(Taro.getStorageSync('sort_code')) : ''
|
const sortCode = Taro.getStorageSync('sort_code') ? JSON.parse(Taro.getStorageSync('sort_code')) : ''
|
||||||
let pageInfo: any = page
|
const pageInfo: any = page
|
||||||
// 商品详情分享
|
// 商品详情分享
|
||||||
if (pageInfo.route === 'pages/details/index') {
|
if (pageInfo.route === 'pages/details/index') {
|
||||||
path = `/pages/details/index?share=${sortCode.shareShortDetail.code}`
|
path = `/pages/details/index?share=${sortCode.shareShortDetail.code}`
|
||||||
title = sortCode.shareShortDetail.title
|
title = sortCode.shareShortDetail.title
|
||||||
imageUrl = sortCode.shareShortDetail.img
|
imageUrl = sortCode.shareShortDetail.img
|
||||||
} else {
|
}
|
||||||
path =
|
else {
|
||||||
pageInfo.route === 'pages/user/index'
|
path
|
||||||
|
= pageInfo.route === 'pages/user/index'
|
||||||
? `/pages/user/index?share=${sortCode.shareShortPage.code}`
|
? `/pages/user/index?share=${sortCode.shareShortPage.code}`
|
||||||
: `/pages/index/index?share=${sortCode.shareShortPage.code}`
|
: `/pages/index/index?share=${sortCode.shareShortPage.code}`
|
||||||
title = sortCode.shareShortPage.title
|
title = sortCode.shareShortPage.title
|
||||||
|
|||||||
@ -1,80 +1,82 @@
|
|||||||
|
|
||||||
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
|
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { memo, useEffect, useState } from "react"
|
import { memo, useEffect, useState } from 'react'
|
||||||
import "./index.scss"
|
import './index.scss'
|
||||||
import {addressListApi,addressDeleteApi} from "@/api/addressManager"
|
import { addressDeleteApi, addressListApi } from '@/api/addressManager'
|
||||||
import { alert } from "@/common/common"
|
import { alert } from '@/common/common'
|
||||||
import Taro, { showModal } from "@tarojs/taro"
|
import Taro, { showModal } from '@tarojs/taro'
|
||||||
|
|
||||||
interface Params{
|
interface Params{
|
||||||
refresherEnabled?: boolean,//是否开启刷新
|
refresherEnabled?: boolean// 是否开启刷新
|
||||||
onSelect?: (item:any,index:number)=>void,//列表选择
|
onSelect?: (item: any, index: number) => void// 列表选择
|
||||||
addButtonEnabled?: boolean, //是否显示添加按钮
|
addButtonEnabled?: boolean // 是否显示添加按钮
|
||||||
focusBorderEnabled?: boolean, //焦点显示蓝色边框
|
focusBorderEnabled?: boolean // 焦点显示蓝色边框
|
||||||
id?: number, //默认选择值
|
id?: number // 默认选择值
|
||||||
}
|
}
|
||||||
|
|
||||||
// 地址列表
|
// 地址列表
|
||||||
const AddressList = memo((props: Params) => {
|
const AddressList = memo((props: Params) => {
|
||||||
const {addButtonEnabled=true,focusBorderEnabled=false} = props;
|
const { addButtonEnabled = true, focusBorderEnabled = false } = props
|
||||||
const { fetchData, state } = addressListApi()
|
const { fetchData, state } = addressListApi()
|
||||||
// 获取数据
|
// 获取数据
|
||||||
const getData = async() => {
|
const getData = async() => {
|
||||||
const result = await fetchData();
|
const result = await fetchData()
|
||||||
if (props.id) {
|
if (props.id) {
|
||||||
setFocusId(props.id as any);
|
setFocusId(props.id as any)
|
||||||
}else{
|
|
||||||
result.data.list?.every(item=>{
|
|
||||||
if(item.is_default){
|
|
||||||
setFocusId(item.id);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
else {
|
||||||
|
result.data.list?.every((item) => {
|
||||||
|
if (item.is_default) {
|
||||||
|
setFocusId(item.id)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getData();
|
getData()
|
||||||
// 监听刷新
|
// 监听刷新
|
||||||
Taro.eventCenter.on("addressList:refresh", getData);
|
Taro.eventCenter.on('addressList:refresh', getData)
|
||||||
return () => {
|
return () => {
|
||||||
Taro.eventCenter.off("addressList:refresh", getData);
|
Taro.eventCenter.off('addressList:refresh', getData)
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
// 处理刷新
|
// 处理刷新
|
||||||
const [refreshState, setRefreshState] = useState(false);
|
const [refreshState, setRefreshState] = useState(false)
|
||||||
const handleRefresh = async() => {
|
const handleRefresh = async() => {
|
||||||
setRefreshState(true);
|
setRefreshState(true)
|
||||||
await getData();
|
await getData()
|
||||||
setRefreshState(false);
|
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) => {
|
const handleSelect = (item: any, index: number) => {
|
||||||
props.onSelect&&props.onSelect(item,index);
|
props.onSelect && props.onSelect(item, index)
|
||||||
if (focusBorderEnabled) {
|
if (focusBorderEnabled) {
|
||||||
setFocusId(item?.id);
|
setFocusId(item?.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 删除地址
|
// 删除地址
|
||||||
const { fetchData: deleteFetch } = addressDeleteApi()
|
const { fetchData: deleteFetch } = addressDeleteApi()
|
||||||
const handleDelete = (item: any) => {
|
const handleDelete = (item: any) => {
|
||||||
showModal(({
|
showModal(({
|
||||||
title: "提示",
|
title: '提示',
|
||||||
content: "是否删除地址?",
|
content: '是否删除地址?',
|
||||||
async success(ev) {
|
async success(ev) {
|
||||||
if (ev.confirm) {
|
if (ev.confirm) {
|
||||||
const result = await deleteFetch({id:item.id});
|
const result = await deleteFetch({ id: item.id })
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert.success("删除成功");
|
alert.success('删除成功')
|
||||||
getData();
|
getData()
|
||||||
}else{
|
}
|
||||||
alert.success(result.msg);
|
else {
|
||||||
}
|
alert.success(result.msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,8 +85,8 @@ const AddressList = memo((props:Params)=>{
|
|||||||
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
|
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
|
||||||
<View className="address-scroll-view-content">
|
<View className="address-scroll-view-content">
|
||||||
{
|
{
|
||||||
state?.data?.list?.length>0?
|
state?.data?.list?.length > 0
|
||||||
state?.data?.list?.map((item,index)=>{
|
? state?.data?.list?.map((item, index) => {
|
||||||
// data.length>0?
|
// data.length>0?
|
||||||
// data.map((item,index)=>{
|
// data.map((item,index)=>{
|
||||||
return (
|
return (
|
||||||
@ -92,8 +94,9 @@ const AddressList = memo((props:Params)=>{
|
|||||||
<View className="address-user">
|
<View className="address-user">
|
||||||
{item.name}
|
{item.name}
|
||||||
{
|
{
|
||||||
item.is_default?<Text className="address-list-default">默认</Text>:
|
item.is_default
|
||||||
<Text className="address-list-phone">{item.phone.replace(item.phone.substring(3,7), "****")}</Text>
|
? <Text className="address-list-default">默认</Text>
|
||||||
|
: <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), '****')}</Text>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
<View className="address-list-bottom">
|
<View className="address-list-bottom">
|
||||||
@ -102,7 +105,7 @@ const AddressList = memo((props:Params)=>{
|
|||||||
{/* {item.address_detail} */}
|
{/* {item.address_detail} */}
|
||||||
</View>
|
</View>
|
||||||
{
|
{
|
||||||
item.is_default&&<Text className="address-list-phone">{item.phone.replace(item.phone.substring(3,7), "****")}</Text>
|
item.is_default && <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), '****')}</Text>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
<Navigator onClick={e => e.stopPropagation()} url={`/pages/addressAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="address-edit">
|
<Navigator onClick={e => e.stopPropagation()} url={`/pages/addressAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="address-edit">
|
||||||
@ -110,9 +113,9 @@ const AddressList = memo((props:Params)=>{
|
|||||||
</Navigator>
|
</Navigator>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
)
|
||||||
}):
|
})
|
||||||
<View className="address-no-data">暂未添加地址</View>
|
: <View className="address-no-data">暂未添加地址</View>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
@ -121,4 +124,4 @@ const AddressList = memo((props:Params)=>{
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default AddressList;
|
export default AddressList
|
||||||
|
|||||||
@ -22,37 +22,41 @@ const FromList = memo((props: ListParams) => {
|
|||||||
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props
|
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={style} className='form-list'>
|
<View style={style} className="form-list">
|
||||||
<View style={labelStyle} className={`form-list-label ${required && 'form-list-label-required'}`}>
|
<View style={labelStyle} className={`form-list-label ${required && 'form-list-label-required'}`}>
|
||||||
{props.label}
|
{props.label}
|
||||||
</View>
|
</View>
|
||||||
<View onClick={props?.onClick} className='form-list-right'>
|
<View onClick={props?.onClick} className="form-list-right">
|
||||||
{props.children ?? (
|
{props.children ?? (
|
||||||
<View style={contentStyle} onClick={props?.onClick} className='form-list-right-meet'>
|
<View style={contentStyle} onClick={props?.onClick} className="form-list-right-meet">
|
||||||
{type == 'input' ? (
|
{type == 'input'
|
||||||
<View className='form-list-input'>
|
? (
|
||||||
|
<View className="form-list-input">
|
||||||
<Input
|
<Input
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
value={value}
|
value={value}
|
||||||
placeholder-class='phcolor'
|
placeholder-class="phcolor"
|
||||||
type={props.primordialType || 'text'}
|
type={props.primordialType || 'text'}
|
||||||
onInput={props?.onInput}
|
onInput={props?.onInput}
|
||||||
placeholder={props.placeholder}
|
placeholder={props.placeholder}
|
||||||
/>
|
/>
|
||||||
{value && (
|
{value && (
|
||||||
<View>
|
<View>
|
||||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' />
|
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
) : type == 'textarea' ? (
|
)
|
||||||
<Textarea value={value} placeholder-class='phcolor' onInput={props?.onInput} placeholder={props.placeholder} />
|
: type == 'textarea'
|
||||||
) : (
|
? (
|
||||||
|
<Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />
|
||||||
|
)
|
||||||
|
: (
|
||||||
<>
|
<>
|
||||||
{props.value ? <View>{value}</View> : <View className='form-list-right-placeholder'>{props.placeholder}</View>}
|
{props.value ? <View>{value}</View> : <View className="form-list-right-placeholder">{props.placeholder}</View>}
|
||||||
<View className='form-list-right-enter'>
|
<View className="form-list-right-enter">
|
||||||
<Text className='iconfont icon-a-moreback'></Text>
|
<Text className="iconfont icon-a-moreback"></Text>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -22,35 +22,39 @@ const FromList = memo((props: ListParams) => {
|
|||||||
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false, showIcon = true } = props
|
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false, showIcon = true } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={style} className='From-list-certification'>
|
<View style={style} className="From-list-certification">
|
||||||
<View style={labelStyle} className={`From-list-certification-label ${required && 'From-list-certification-label-required'}`}>
|
<View style={labelStyle} className={`From-list-certification-label ${required && 'From-list-certification-label-required'}`}>
|
||||||
{props.label}
|
{props.label}
|
||||||
</View>
|
</View>
|
||||||
<View onClick={props?.onClick} className='From-list-certification-right'>
|
<View onClick={props?.onClick} className="From-list-certification-right">
|
||||||
{props.children ?? (
|
{props.children ?? (
|
||||||
<View style={contentStyle} onClick={props?.onClick} className='From-list-certification-right-meet'>
|
<View style={contentStyle} onClick={props?.onClick} className="From-list-certification-right-meet">
|
||||||
{type == 'input' ? (
|
{type == 'input'
|
||||||
<View className='From-list-certification-input'>
|
? (
|
||||||
|
<View className="From-list-certification-input">
|
||||||
<Input
|
<Input
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
value={value}
|
value={value}
|
||||||
placeholder-class='phcolor'
|
placeholder-class="phcolor"
|
||||||
onInput={props?.onInput}
|
onInput={props?.onInput}
|
||||||
placeholder={props.placeholder}
|
placeholder={props.placeholder}
|
||||||
/>
|
/>
|
||||||
{value && (
|
{value && (
|
||||||
<View>
|
<View>
|
||||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' />
|
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
) : type == 'textarea' ? (
|
)
|
||||||
<Textarea value={value} placeholder-class='phcolor' onInput={props?.onInput} placeholder={props.placeholder} />
|
: type == 'textarea'
|
||||||
) : (
|
? (
|
||||||
|
<Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />
|
||||||
|
)
|
||||||
|
: (
|
||||||
<>
|
<>
|
||||||
{props.value ? <View>{value}</View> : <View className='From-list-certification-right-placeholder'>{props.placeholder}</View>}
|
{props.value ? <View>{value}</View> : <View className="From-list-certification-right-placeholder">{props.placeholder}</View>}
|
||||||
<View className='From-list-certification-right-enter'>{showIcon && <Text className='iconfont icon-a-moreback'></Text>}</View>
|
<View className="From-list-certification-right-enter">{showIcon && <Text className="iconfont icon-a-moreback"></Text>}</View>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
|
import type { ReactNode } from 'react'
|
||||||
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import InfiniteScroll from '@/components/infiniteScroll'
|
import InfiniteScroll from '@/components/infiniteScroll'
|
||||||
import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
|
|
||||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||||
import { alert, isEmptyObject } from '@/common/common'
|
import { alert, isEmptyObject } from '@/common/common'
|
||||||
|
|
||||||
@ -44,7 +45,8 @@ export default (props: Params) => {
|
|||||||
...endStatus,
|
...endStatus,
|
||||||
loading: false,
|
loading: false,
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setData({
|
setData({
|
||||||
list: result.data.list,
|
list: result.data.list,
|
||||||
// list: tRefreshDataRef.page>1?(dataRef.current as any).list.concat(result.data.list):result.data.list,
|
// list: tRefreshDataRef.page>1?(dataRef.current as any).list.concat(result.data.list):result.data.list,
|
||||||
@ -57,7 +59,8 @@ export default (props: Params) => {
|
|||||||
loading: false,
|
loading: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.none(result.msg)
|
alert.none(result.msg)
|
||||||
setRefreshData({
|
setRefreshData({
|
||||||
...tRefreshDataRef,
|
...tRefreshDataRef,
|
||||||
@ -84,7 +87,7 @@ export default (props: Params) => {
|
|||||||
const dataRef = useRef({})
|
const dataRef = useRef({})
|
||||||
// 下拉刷新
|
// 下拉刷新
|
||||||
const handleRefresh = async() => {
|
const handleRefresh = async() => {
|
||||||
let tRefreshData = refreshDataRef.current as any
|
const tRefreshData = refreshDataRef.current as any
|
||||||
setRefreshData({
|
setRefreshData({
|
||||||
...tRefreshData,
|
...tRefreshData,
|
||||||
page: 1,
|
page: 1,
|
||||||
@ -94,8 +97,8 @@ export default (props: Params) => {
|
|||||||
}
|
}
|
||||||
// 加载更多
|
// 加载更多
|
||||||
const handleMoreLoad = async() => {
|
const handleMoreLoad = async() => {
|
||||||
let t = dataRef.current as any
|
const t = dataRef.current as any
|
||||||
let tRefreshData = refreshDataRef.current as any
|
const tRefreshData = refreshDataRef.current as any
|
||||||
if (t.list.length < t.total) {
|
if (t.list.length < t.total) {
|
||||||
setRefreshData({
|
setRefreshData({
|
||||||
...tRefreshData,
|
...tRefreshData,
|
||||||
@ -119,12 +122,13 @@ export default (props: Params) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InfiniteScroll
|
<InfiniteScroll
|
||||||
refresherEnabled={true}
|
refresherEnabled
|
||||||
refresherTriggered={refreshData.refreshStatus}
|
refresherTriggered={refreshData.refreshStatus}
|
||||||
moreStatus={refreshData.moreStatus}
|
moreStatus={refreshData.moreStatus}
|
||||||
selfOnRefresherRefresh={handleRefresh}
|
selfOnRefresherRefresh={handleRefresh}
|
||||||
selfonScrollToLower={handleMoreLoad}
|
selfonScrollToLower={handleMoreLoad}
|
||||||
statusMore={statusMore}>
|
statusMore={statusMore}
|
||||||
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { formatImgUrl, formatRemoveHashTag } from '@/common/fotmat'
|
|
||||||
import Preview from '@/pages/details/components/preview'
|
|
||||||
import { Image, View } from '@tarojs/components'
|
import { Image, View } from '@tarojs/components'
|
||||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
|
||||||
import LabAndImgShow from '../LabAndImgShow'
|
import LabAndImgShow from '../LabAndImgShow'
|
||||||
|
import styles from './index.module.scss'
|
||||||
|
import Preview from '@/pages/details/components/preview'
|
||||||
|
import { formatImgUrl, formatRemoveHashTag } from '@/common/fotmat'
|
||||||
|
|
||||||
// 该组件宽高为100%需调整外层元素宽高
|
// 该组件宽高为100%需调整外层元素宽高
|
||||||
type Param = {
|
interface Param {
|
||||||
value: {
|
value: {
|
||||||
texture_url?: string // 纹理图路径
|
texture_url?: string // 纹理图路径
|
||||||
lab?: { l: number; a: number; b: number } // lab
|
lab?: { l: number; a: number; b: number } // lab
|
||||||
@ -25,14 +25,15 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
|||||||
const rgbStyle = useMemo(() => {
|
const rgbStyle = useMemo(() => {
|
||||||
if (value?.lab && (value?.lab.l || value?.lab.a || value?.lab.b)) {
|
if (value?.lab && (value?.lab.l || value?.lab.a || value?.lab.b)) {
|
||||||
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
|
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}, [value])
|
}, [value])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value?.texture_url) {
|
if (value?.texture_url) {
|
||||||
let imgs = value.texture_url.split(',').map((item) => {
|
const imgs = value.texture_url.split(',').map((item) => {
|
||||||
return formatImgUrl(item)
|
return formatImgUrl(item)
|
||||||
})
|
})
|
||||||
setImgs(() => imgs[0])
|
setImgs(() => imgs[0])
|
||||||
@ -46,7 +47,7 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
|||||||
|
|
||||||
const onShowLabAndImg = (e) => {
|
const onShowLabAndImg = (e) => {
|
||||||
onClick?.(value)
|
onClick?.(value)
|
||||||
if (!showStatus) return false
|
if (!showStatus) { return false }
|
||||||
setLabAndImgShow(true)
|
setLabAndImgShow(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,15 +60,16 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
|||||||
<View className={styles.labAndImg_main} style={{ borderRadius: round ? '50%' : '' }} onClick={onShowLabAndImg}>
|
<View className={styles.labAndImg_main} style={{ borderRadius: round ? '50%' : '' }} onClick={onShowLabAndImg}>
|
||||||
{value.texture_url && (
|
{value.texture_url && (
|
||||||
<Image
|
<Image
|
||||||
mode='aspectFill'
|
mode="aspectFill"
|
||||||
src={imgs}
|
src={imgs}
|
||||||
onError={(e) => checkLoad(e)}
|
onError={e => checkLoad(e)}
|
||||||
className={styles.labAndImg_image}
|
className={styles.labAndImg_image}
|
||||||
style={{ borderRadius: round ? '50%' : '' }}></Image>
|
style={{ borderRadius: round ? '50%' : '' }}
|
||||||
|
></Image>
|
||||||
)}
|
)}
|
||||||
{!value.texture_url && rgbStyle && <View className={styles.boxColor} style={{ ...rgbStyle, borderRadius: round ? '50%' : '' }}></View>}
|
{!value.texture_url && rgbStyle && <View className={styles.boxColor} style={{ ...rgbStyle, borderRadius: round ? '50%' : '' }}></View>}
|
||||||
{!value.texture_url && !rgbStyle && (
|
{!value.texture_url && !rgbStyle && (
|
||||||
<Image mode='aspectFill' src={formatImgUrl('')} className={styles.labAndImg_image} style={{ borderRadius: round ? '50%' : '' }}></Image>
|
<Image mode="aspectFill" src={formatImgUrl('')} className={styles.labAndImg_image} style={{ borderRadius: round ? '50%' : '' }}></Image>
|
||||||
)}
|
)}
|
||||||
{name && <View className={styles.labAndImg_name}>{name}</View>}
|
{name && <View className={styles.labAndImg_name}>{name}</View>}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { formatImgUrl } from '@/common/fotmat'
|
|
||||||
import { View } from '@tarojs/components'
|
import { View } from '@tarojs/components'
|
||||||
|
import Taro from '@tarojs/taro'
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import Taro from '@tarojs/taro'
|
import { formatImgUrl } from '@/common/fotmat'
|
||||||
|
|
||||||
export type colorParams = {
|
export interface colorParams {
|
||||||
value?: {
|
value?: {
|
||||||
texture_url?: string // 纹理图路径
|
texture_url?: string // 纹理图路径
|
||||||
lab?: { l: number; a: number; b: number } // lab
|
lab?: { l: number; a: number; b: number } // lab
|
||||||
@ -17,9 +17,9 @@ export type colorParams = {
|
|||||||
}
|
}
|
||||||
export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) => {
|
export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (show && rgbStyle) setLabShow(() => true)
|
if (show && rgbStyle) { setLabShow(() => true) }
|
||||||
if (show && value?.texture_url) onShowImage()
|
if (show && value?.texture_url) { onShowImage() }
|
||||||
if (!show) setLabShow(() => false)
|
if (!show) { setLabShow(() => false) }
|
||||||
}, [show])
|
}, [show])
|
||||||
|
|
||||||
// 显示颜色
|
// 显示颜色
|
||||||
@ -28,7 +28,8 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
|||||||
const rgbStyle = useMemo(() => {
|
const rgbStyle = useMemo(() => {
|
||||||
if (value?.lab && (value.lab.l || value.lab.a || value.lab.b)) {
|
if (value?.lab && (value.lab.l || value.lab.a || value.lab.b)) {
|
||||||
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
|
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}, [value])
|
}, [value])
|
||||||
@ -42,7 +43,7 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
|||||||
return formatImgUrl(item)
|
return formatImgUrl(item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let n_res = showNumber == 0 ? res : res?.splice(0, showNumber)
|
const n_res = showNumber == 0 ? res : res?.splice(0, showNumber)
|
||||||
Taro.previewImage({
|
Taro.previewImage({
|
||||||
current: n_res[0],
|
current: n_res[0],
|
||||||
urls: n_res,
|
urls: n_res,
|
||||||
@ -52,7 +53,7 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{labShow && (
|
{labShow && (
|
||||||
<View className={styles.main} catch-move='true' onClick={() => onClose?.()}>
|
<View className={styles.main} catch-move="true" onClick={() => onClose?.()}>
|
||||||
<View className={styles.con}>
|
<View className={styles.con}>
|
||||||
<View className={styles.rgb} style={rgbStyle!}></View>
|
<View className={styles.rgb} style={rgbStyle!}></View>
|
||||||
<View className={styles.name}>{value?.title}</View>
|
<View className={styles.name}>{value?.title}</View>
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
|
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { memo } from "react"
|
import { memo } from 'react'
|
||||||
import "./index.scss"
|
import './index.scss'
|
||||||
|
|
||||||
interface Params{
|
interface Params{
|
||||||
text: String,//提示信息
|
text: String// 提示信息
|
||||||
}
|
}
|
||||||
|
|
||||||
// 消息提示
|
// 消息提示
|
||||||
@ -16,4 +16,4 @@ const Message = memo((props:Params)=>{
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default Message;
|
export default Message
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import Popup from '@/components/popup'
|
|
||||||
import { Input, ScrollView, Text, View } from '@tarojs/components'
|
import { Input, ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import Popup from '@/components/popup'
|
||||||
import TextareaEnhance from '@/components/textareaEnhance'
|
import TextareaEnhance from '@/components/textareaEnhance'
|
||||||
import { CreateFavoriteApi, FavoriteListApi } from '@/api/favorite'
|
import { CreateFavoriteApi, FavoriteListApi } from '@/api/favorite'
|
||||||
import { alert, goLink } from '@/common/common'
|
import { alert, goLink } from '@/common/common'
|
||||||
import { getFilterData } from '@/common/util'
|
import { getFilterData } from '@/common/util'
|
||||||
|
|
||||||
// 原因选择
|
// 原因选择
|
||||||
type ReasonInfoParam = {
|
interface ReasonInfoParam {
|
||||||
show?: boolean // 显示
|
show?: boolean // 显示
|
||||||
onClose?: () => void // 关闭
|
onClose?: () => void // 关闭
|
||||||
onAdd?: (val: any) => void
|
onAdd?: (val: any) => void
|
||||||
@ -19,11 +19,11 @@ export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
|
|||||||
const [list, setList] = useState([])
|
const [list, setList] = useState([])
|
||||||
const { fetchData: fetchDataList } = FavoriteListApi()
|
const { fetchData: fetchDataList } = FavoriteListApi()
|
||||||
const getFavoriteList = async() => {
|
const getFavoriteList = async() => {
|
||||||
let res = await fetchDataList(getFilterData())
|
const res = await fetchDataList(getFilterData())
|
||||||
setList(() => res.data.list)
|
setList(() => res.data.list)
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (show) getFavoriteList()
|
if (show) { getFavoriteList() }
|
||||||
}, [show])
|
}, [show])
|
||||||
|
|
||||||
const onCreate = () => {
|
const onCreate = () => {
|
||||||
|
|||||||
@ -1,42 +1,40 @@
|
|||||||
import { ScrollView, Text, View } from "@tarojs/components";
|
import { ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { memo, ReactHTMLElement, useEffect, useRef, useState } from "react";
|
import Taro from '@tarojs/taro'
|
||||||
import Drawer from "@/components/popup";
|
import React, { ReactHTMLElement, memo, useEffect, useRef, useState } from 'react'
|
||||||
import styles from "./index.module.scss"
|
import classnames from 'classnames'
|
||||||
import classnames from "classnames";
|
import styles from './index.module.scss'
|
||||||
import Taro from "@tarojs/taro";
|
import Drawer from '@/components/popup'
|
||||||
import { GetAddressListApi } from "@/api/addressList";
|
import { GetAddressListApi } from '@/api/addressList'
|
||||||
import { alert } from "@/common/common";
|
import { alert } from '@/common/common'
|
||||||
|
|
||||||
|
interface DefaultValueParm { name: string; id: string|number; level?: number|string }
|
||||||
|
|
||||||
type DefaultValueParm = {name: string, id:string|number, level?: number|string}
|
interface Params {
|
||||||
|
addressOnSelect?: (val: DefaultValueParm[]) => void
|
||||||
type Params = {
|
addressOnChange?: (val: DefaultValueParm[]) => void
|
||||||
addressOnSelect?: (val:DefaultValueParm[]) => void,
|
addressOnClose?: () => void
|
||||||
addressOnChange?: (val:DefaultValueParm[]) => void,
|
show?: true|false
|
||||||
addressOnClose?: () => void,
|
|
||||||
show?: true|false,
|
|
||||||
defaultValue?: DefaultValueParm[]
|
defaultValue?: DefaultValueParm[]
|
||||||
selectStatus?: false|true, //false不需要选择完整地址,true需要选择完整地址
|
selectStatus?: false|true // false不需要选择完整地址,true需要选择完整地址
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddresParam = {
|
interface AddresParam {
|
||||||
ad_code?: string,
|
ad_code?: string
|
||||||
id?: number,
|
id?: number
|
||||||
level?: number,
|
level?: number
|
||||||
level_name?: string,
|
level_name?: string
|
||||||
name?: string,
|
name?: string
|
||||||
parent_id?: number,
|
parent_id?: number
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default memo(({
|
export default memo(({
|
||||||
addressOnSelect,
|
addressOnSelect,
|
||||||
addressOnChange,
|
addressOnChange,
|
||||||
addressOnClose,
|
addressOnClose,
|
||||||
show = false,
|
show = false,
|
||||||
defaultValue = [],
|
defaultValue = [],
|
||||||
selectStatus = true
|
selectStatus = true,
|
||||||
}: Params) => {
|
}: Params) => {
|
||||||
// 省
|
// 省
|
||||||
const provinceList = useRef<AddresParam[]>([])
|
const provinceList = useRef<AddresParam[]>([])
|
||||||
@ -53,18 +51,17 @@ export default memo(({
|
|||||||
const [areaStatus, setAreaStatus] = useState(false) // 区镇是否存在
|
const [areaStatus, setAreaStatus] = useState(false) // 区镇是否存在
|
||||||
const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) // 确认按钮是否可用
|
const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) // 确认按钮是否可用
|
||||||
|
|
||||||
const [bottomStyle, setBottomStyle] = useState({width:'100rpx',left:'0rpx'}) //底部滚动条样式
|
const [bottomStyle, setBottomStyle] = useState<React.CSSProperties>({ width: '100rpx', left: '0rpx' }) // 底部滚动条样式
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectArr.length == 0) {
|
if (selectArr.length == 0) {
|
||||||
setSelectArr(defaultValue)
|
setSelectArr(defaultValue)
|
||||||
if(defaultValue.length > 1) setCityStatus(true)
|
if (defaultValue.length > 1) { setCityStatus(true) }
|
||||||
if(defaultValue.length > 2) setAreaStatus(true)
|
if (defaultValue.length > 2) { setAreaStatus(true) }
|
||||||
if(defaultValue.length > 0) setConfirmBtnStatus(true)
|
if (defaultValue.length > 0) { setConfirmBtnStatus(true) }
|
||||||
}
|
}
|
||||||
}, [defaultValue])
|
}, [defaultValue])
|
||||||
|
|
||||||
|
|
||||||
// 获取地址
|
// 获取地址
|
||||||
const { fetchData } = GetAddressListApi()
|
const { fetchData } = GetAddressListApi()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -79,20 +76,20 @@ export default memo(({
|
|||||||
getCity(item.id)
|
getCity(item.id)
|
||||||
setAreaStatus(false)
|
setAreaStatus(false)
|
||||||
setCityStatus(false)
|
setCityStatus(false)
|
||||||
} else if(selectIndex == 1){
|
}
|
||||||
|
else if (selectIndex == 1) {
|
||||||
setSelectArr([selectArr[0], { name: item.name, id: item.id, level: item.level }])
|
setSelectArr([selectArr[0], { name: item.name, id: item.id, level: item.level }])
|
||||||
area(item.id)
|
area(item.id)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setSelectArr([selectArr[0], selectArr[1], { name: item.name, id: item.id, level: item.level }])
|
setSelectArr([selectArr[0], selectArr[1], { name: item.name, id: item.id, level: item.level }])
|
||||||
getDomDes('#address_tab_2')
|
getDomDes('#address_tab_2')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 地址数据
|
// 地址数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectArr && selectArr.length > 0)
|
if (selectArr && selectArr.length > 0) { addressOnChange?.(selectArr) }
|
||||||
addressOnChange?.(selectArr)
|
|
||||||
}, [selectArr])
|
}, [selectArr])
|
||||||
|
|
||||||
// 选中标题
|
// 选中标题
|
||||||
@ -102,19 +99,20 @@ export default memo(({
|
|||||||
setSelectId(selectid as number)
|
setSelectId(selectid as number)
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
getProvince()
|
getProvince()
|
||||||
} else if (index == 1) {
|
}
|
||||||
|
else if (index == 1) {
|
||||||
const id = selectArr[0]?.id
|
const id = selectArr[0]?.id
|
||||||
getCity(id)
|
getCity(id)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const id = selectArr[1]?.id
|
const id = selectArr[1]?.id
|
||||||
area(id)
|
area(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 获取省
|
// 获取省
|
||||||
const getProvince = async() => {
|
const getProvince = async() => {
|
||||||
let res = await fetchData({parent_id: 1})
|
const res = await fetchData({ parent_id: 1 })
|
||||||
provinceList.current = res.data.list || []
|
provinceList.current = res.data.list || []
|
||||||
if (provinceList.current.length > 0) {
|
if (provinceList.current.length > 0) {
|
||||||
setSelectIndex(0)
|
setSelectIndex(0)
|
||||||
@ -125,7 +123,7 @@ export default memo(({
|
|||||||
|
|
||||||
// 获取市
|
// 获取市
|
||||||
const getCity = async(id) => {
|
const getCity = async(id) => {
|
||||||
let res = await fetchData({parent_id: id})
|
const res = await fetchData({ parent_id: id })
|
||||||
cityList.current = res.data.list || []
|
cityList.current = res.data.list || []
|
||||||
if (cityList.current.length > 0) {
|
if (cityList.current.length > 0) {
|
||||||
setSelectIndex(1)
|
setSelectIndex(1)
|
||||||
@ -133,7 +131,8 @@ export default memo(({
|
|||||||
setCityStatus(true)
|
setCityStatus(true)
|
||||||
getDomDes('#address_tab_1')
|
getDomDes('#address_tab_1')
|
||||||
setConfirmBtnStatus(false)
|
setConfirmBtnStatus(false)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setConfirmBtnStatus(true)
|
setConfirmBtnStatus(true)
|
||||||
setCityStatus(false)
|
setCityStatus(false)
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ export default memo(({
|
|||||||
|
|
||||||
// 获取区
|
// 获取区
|
||||||
const area = async(id) => {
|
const area = async(id) => {
|
||||||
let res = await fetchData({parent_id: id})
|
const res = await fetchData({ parent_id: id })
|
||||||
areaList.current = res.data.list || []
|
areaList.current = res.data.list || []
|
||||||
if (areaList.current.length > 0) {
|
if (areaList.current.length > 0) {
|
||||||
setSelectIndex(2)
|
setSelectIndex(2)
|
||||||
@ -149,7 +148,8 @@ export default memo(({
|
|||||||
setAreaStatus(true)
|
setAreaStatus(true)
|
||||||
getDomDes('#address_tab_2')
|
getDomDes('#address_tab_2')
|
||||||
setConfirmBtnStatus(false)
|
setConfirmBtnStatus(false)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setConfirmBtnStatus(true)
|
setConfirmBtnStatus(true)
|
||||||
setAreaStatus(false)
|
setAreaStatus(false)
|
||||||
}
|
}
|
||||||
@ -164,23 +164,23 @@ export default memo(({
|
|||||||
// 获取省市区宽度
|
// 获取省市区宽度
|
||||||
const getDomDes = (id) => {
|
const getDomDes = (id) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let query = Taro.createSelectorQuery();
|
const query = Taro.createSelectorQuery()
|
||||||
query.select(id).boundingClientRect(rect=>{
|
query.select(id).boundingClientRect((rect) => {
|
||||||
let left = rect.left;
|
const left = rect.left
|
||||||
let clientWidth = rect.width;
|
const clientWidth = rect.width
|
||||||
console.log(clientWidth)
|
console.log(clientWidth)
|
||||||
setBottomStyle({
|
setBottomStyle({
|
||||||
width: clientWidth + 'px',
|
width: `${clientWidth}px`,
|
||||||
left: left + 'px'
|
left: `${left}px`,
|
||||||
})
|
})
|
||||||
}).exec();
|
}).exec()
|
||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击标题栏
|
// 点击标题栏
|
||||||
const selectTab = (index) => {
|
const selectTab = (index) => {
|
||||||
onSelectIndex(index)
|
onSelectIndex(index)
|
||||||
getDomDes('#address_tab_'+index)
|
getDomDes(`#address_tab_${index}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -200,7 +200,7 @@ export default memo(({
|
|||||||
<View className={styles.address_list}>
|
<View className={styles.address_list}>
|
||||||
<ScrollView scrollY className={styles.address_scroll}>
|
<ScrollView scrollY className={styles.address_scroll}>
|
||||||
<View className={styles.address_scroll_list}>
|
<View className={styles.address_scroll_list}>
|
||||||
{list.map(item => {
|
{list.map((item) => {
|
||||||
return (
|
return (
|
||||||
<View onClick={() => selectItem(item)} className={classnames(styles.address_list_item, { [styles.addresst_select]: (selectId == item.id) })}>
|
<View onClick={() => selectItem(item)} className={classnames(styles.address_list_item, { [styles.addresst_select]: (selectId == item.id) })}>
|
||||||
<View className={styles.address_list_item_name}>{item.name}</View>
|
<View className={styles.address_list_item_name}>{item.name}</View>
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
import { CancelOrderApi, ReceiveOrderApi } from "@/api/order"
|
import { ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { alert } from "@/common/common"
|
import Taro from '@tarojs/taro'
|
||||||
import { ORDER_STATUS, SALE_MODE } from "@/common/enum"
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { ScrollView, Text, View } from "@tarojs/components"
|
|
||||||
import Taro from "@tarojs/taro"
|
|
||||||
import { useCallback, useRef, memo, useState, useEffect, useMemo } from "react"
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import { ORDER_STATUS, SALE_MODE } from '@/common/enum'
|
||||||
|
import { alert } from '@/common/common'
|
||||||
|
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
||||||
|
|
||||||
type Param = {
|
interface Param {
|
||||||
orderInfo: {
|
orderInfo: {
|
||||||
status: number, //订单状态
|
status: number // 订单状态
|
||||||
orderId: number, //订单id
|
orderId: number // 订单id
|
||||||
actual_amount: number, //实付金额
|
actual_amount: number // 实付金额
|
||||||
wait_pay_amount: number, //待付金额
|
wait_pay_amount: number // 待付金额
|
||||||
sale_mode: number // 订单类型
|
sale_mode: number // 订单类型
|
||||||
}|null,
|
}|null
|
||||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
SaleOrderStatusWaitingPayment,
|
SaleOrderStatusWaitingPayment,
|
||||||
SaleOrderStatusWaitingReceipt,
|
SaleOrderStatusWaitingReceipt,
|
||||||
SaleOrderStatusAlreadyReceipt,
|
SaleOrderStatusAlreadyReceipt,
|
||||||
SaleorderstatusWaitingPrePayment
|
SaleorderstatusWaitingPrePayment,
|
||||||
} = ORDER_STATUS
|
} = ORDER_STATUS
|
||||||
|
|
||||||
// 订单类型
|
// 订单类型
|
||||||
@ -48,59 +48,61 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
SaleOrderStatusArranged.value,
|
SaleOrderStatusArranged.value,
|
||||||
SaleOrderStatusWaitingPayment.value,
|
SaleOrderStatusWaitingPayment.value,
|
||||||
SaleOrderStatusWaitingDelivery.value], // 取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
SaleOrderStatusWaitingDelivery.value], // 取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||||
label: '取消订单'
|
label: '取消订单',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], // 去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], // 去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||||
label: '去付款'
|
label: '去付款',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
value: [SaleOrderStatusWaitingDelivery.value], // 申请退款按钮对应: 待发货
|
value: [SaleOrderStatusWaitingDelivery.value], // 申请退款按钮对应: 待发货
|
||||||
label: '申请退款'
|
label: '申请退款',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||||
label: '查看物流'
|
label: '查看物流',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5,
|
id: 5,
|
||||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], // 申请退货按钮对应: 待收货, 已收货, 已退款
|
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], // 申请退货按钮对应: 待收货, 已收货, 已退款
|
||||||
label: '申请退货'
|
label: '申请退货',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6,
|
id: 6,
|
||||||
value: [SaleOrderStatusWaitingReceipt.value], // 确认收货按钮对应: 待收货
|
value: [SaleOrderStatusWaitingReceipt.value], // 确认收货按钮对应: 待收货
|
||||||
label: '确认收货'
|
label: '确认收货',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 7,
|
id: 7,
|
||||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||||
label: '再次购买'
|
label: '再次购买',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 8,
|
id: 8,
|
||||||
value: [SaleOrderStatusBooking.value], // 按钮对应: 待接单
|
value: [SaleOrderStatusBooking.value], // 按钮对应: 待接单
|
||||||
label: '退款'
|
label: '退款',
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
// 判断是否显示该按钮
|
// 判断是否显示该按钮
|
||||||
const orderBtnsShow = (item) => {
|
const orderBtnsShow = (item) => {
|
||||||
if (orderInfo) {
|
if (orderInfo) {
|
||||||
if (item.id == 1) {
|
if (item.id == 1) {
|
||||||
// 取消订单按钮
|
// 取消订单按钮
|
||||||
return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款
|
return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款
|
||||||
} else if (item.id == 2) {
|
}
|
||||||
|
else if (item.id == 2) {
|
||||||
// 去付款按钮
|
// 去付款按钮
|
||||||
return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示
|
return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示
|
||||||
} else if(item.id == 3 ) {
|
}
|
||||||
|
else if (item.id == 3) {
|
||||||
// 申请退款, 只有大货才有
|
// 申请退款, 只有大货才有
|
||||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款
|
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款
|
||||||
} else if( item.id == 8) {
|
}
|
||||||
|
else if (item.id == 8) {
|
||||||
// 退款按钮(直接退款不用申请), 只有散剪和剪板有
|
// 退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款
|
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款
|
||||||
}
|
}
|
||||||
@ -112,20 +114,17 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 显示的按钮数组
|
// 显示的按钮数组
|
||||||
const orderBtnsShowList: {id: number, value: any, label: string}[] = useMemo(() => {
|
const orderBtnsShowList: { id: number; value: any; label: string }[] = useMemo(() => {
|
||||||
return orderBtnsList.current.filter(item => {
|
return orderBtnsList.current.filter((item) => {
|
||||||
return orderBtnsShow(item)
|
return orderBtnsShow(item)
|
||||||
})
|
})
|
||||||
}, [orderInfo])
|
}, [orderInfo])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 点击按钮操作
|
// 点击按钮操作
|
||||||
const submitBtns = (val, index) => {
|
const submitBtns = (val, index) => {
|
||||||
(val == 1) && cancelOrder(); // 取消订单按钮
|
(val == 1) && cancelOrder(); // 取消订单按钮
|
||||||
(val == 2) && onClick?.(2); // 去付款按钮
|
(val == 2) && onClick?.(2); // 去付款按钮
|
||||||
(val == 6)&&receiveOrder(); //确认收货
|
(val == 6) && receiveOrder() // 确认收货
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消订单
|
// 取消订单
|
||||||
@ -133,19 +132,21 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
const cancelOrder = () => {
|
const cancelOrder = () => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '要取消该订单吗?',
|
title: '要取消该订单吗?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
let res = await cancelFetchData({id: orderInfo?.orderId})
|
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
alert.success('取消成功')
|
alert.success('取消成功')
|
||||||
onClick?.(1)
|
onClick?.(1)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.none(res.msg)
|
alert.none(res.msg)
|
||||||
}
|
}
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,19 +156,21 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
console.log('123456')
|
console.log('123456')
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '确定收货?',
|
title: '确定收货?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
let res = await receiveOrderFetchData({sale_order_id: orderInfo?.orderId})
|
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
onClick?.(6)
|
onClick?.(6)
|
||||||
alert.success('收货成功')
|
alert.success('收货成功')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.error('收货失败')
|
alert.error('收货失败')
|
||||||
}
|
}
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +196,7 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
|
|
||||||
<View className={styles.list_scroll}>
|
<View className={styles.list_scroll}>
|
||||||
{orderBtnsShowList.map((item, index) =>
|
{orderBtnsShowList.map((item, index) =>
|
||||||
(index < 3)&&<View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
(index < 3) && <View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>,
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import { alert } from '@/common/common'
|
|
||||||
import { AFTER_ORDER_STATUS, ORDER_STATUS, REFUND_STATUS_ORDER, SALE_MODE } from '@/common/enum'
|
|
||||||
import { Text, View } from '@tarojs/components'
|
import { Text, View } from '@tarojs/components'
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { useRef, memo, useState, useMemo } from 'react'
|
import { memo, useMemo, useRef, useState } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import { AFTER_ORDER_STATUS, ORDER_STATUS, REFUND_STATUS_ORDER, SALE_MODE } from '@/common/enum'
|
||||||
|
import { alert } from '@/common/common'
|
||||||
import { ReturnApplyOrderCancelApi } from '@/api/salesAfterOrder'
|
import { ReturnApplyOrderCancelApi } from '@/api/salesAfterOrder'
|
||||||
import { throttle } from '@/common/util'
|
import { throttle } from '@/common/util'
|
||||||
|
|
||||||
type Param = {
|
interface Param {
|
||||||
orderInfo: {
|
orderInfo: {
|
||||||
stage: number // 售后状态
|
stage: number // 售后状态
|
||||||
sale_mode: number // 订单类型
|
sale_mode: number // 订单类型
|
||||||
@ -22,8 +22,8 @@ type Param = {
|
|||||||
|
|
||||||
export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||||
// 售后订单状态
|
// 售后订单状态
|
||||||
const { ReturnStageApplying, ReturnStageWaitCheck, ReturnStageReturned, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund } =
|
const { ReturnStageApplying, ReturnStageWaitCheck, ReturnStageReturned, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund }
|
||||||
AFTER_ORDER_STATUS
|
= AFTER_ORDER_STATUS
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款
|
ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款
|
||||||
@ -32,14 +32,13 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
|||||||
} = REFUND_STATUS_ORDER
|
} = REFUND_STATUS_ORDER
|
||||||
|
|
||||||
// 注册按钮
|
// 注册按钮
|
||||||
type orderBtnsListParams = { id: number; label: string; validatarFunc: (val: typeof orderInfo) => any }
|
interface orderBtnsListParams { id: number; label: string; validatarFunc: (val: typeof orderInfo) => any }
|
||||||
const orderBtnsList = useRef<orderBtnsListParams[]>([
|
const orderBtnsList = useRef<orderBtnsListParams[]>([
|
||||||
{
|
{
|
||||||
id: 8,
|
id: 8,
|
||||||
label: '申请记录',
|
label: '申请记录',
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
if (orderInfo.sale_mode !== 1)
|
if (orderInfo.sale_mode !== 1) { return [ReturnStageQualityCheckPendingRefund.value, ReturnStageServiceOrderPendingRefund.value, ReturnStageReturned.value].includes(orderInfo.stage) }
|
||||||
return [ReturnStageQualityCheckPendingRefund.value, ReturnStageServiceOrderPendingRefund.value, ReturnStageReturned.value].includes(orderInfo.stage)
|
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -47,8 +46,7 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
|||||||
id: 1,
|
id: 1,
|
||||||
label: '取消退货',
|
label: '取消退货',
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
if (orderInfo?.sale_mode != 1 && orderInfo.type == ReturnApplyOrderTypeReturnForRefund.value)
|
if (orderInfo?.sale_mode != 1 && orderInfo.type == ReturnApplyOrderTypeReturnForRefund.value) { return [ReturnStageApplying.value, ReturnStageWaitCheck.value].includes(orderInfo.stage) }
|
||||||
return [ReturnStageApplying.value, ReturnStageWaitCheck.value].includes(orderInfo.stage)
|
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -70,9 +68,8 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
|||||||
id: 6,
|
id: 6,
|
||||||
label: '取消退款',
|
label: '取消退款',
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
if (orderInfo?.sale_mode != 1 && orderInfo.type != ReturnApplyOrderTypeReturnForRefund.value)
|
if (orderInfo?.sale_mode != 1 && orderInfo.type != ReturnApplyOrderTypeReturnForRefund.value) { return [ReturnStageApplying.value, ReturnStageServiceOrderPendingRefund.value]?.includes(orderInfo.stage) }
|
||||||
return [ReturnStageApplying.value, ReturnStageServiceOrderPendingRefund.value]?.includes(orderInfo.stage)
|
if (orderInfo?.sale_mode == 1) { return [ReturnStageApplying.value].includes(orderInfo.stage) }
|
||||||
if (orderInfo?.sale_mode == 1) return [ReturnStageApplying.value].includes(orderInfo.stage)
|
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -80,7 +77,7 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
|||||||
id: 7,
|
id: 7,
|
||||||
label: '退款码单',
|
label: '退款码单',
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
if (ReturnStageReturned.value == orderInfo.stage && orderInfo?.sale_mode === 0) return true
|
if (ReturnStageReturned.value == orderInfo.stage && orderInfo?.sale_mode === 0) { return true }
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -97,9 +94,11 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
|||||||
const submitBtns = throttle((val, index) => {
|
const submitBtns = throttle((val, index) => {
|
||||||
if (val == 1) {
|
if (val == 1) {
|
||||||
cancelOrder({ title: '要取消退货吗?', val })
|
cancelOrder({ title: '要取消退货吗?', val })
|
||||||
} else if (val == 6) {
|
}
|
||||||
|
else if (val == 6) {
|
||||||
cancelOrder({ title: '要取消退款吗?', val })
|
cancelOrder({ title: '要取消退款吗?', val })
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
onClick?.(val)
|
onClick?.(val)
|
||||||
}
|
}
|
||||||
}, 600)
|
}, 600)
|
||||||
@ -109,16 +108,18 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
|||||||
const cancelOrder = ({ title = '', val }) => {
|
const cancelOrder = ({ title = '', val }) => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title,
|
title,
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
let res = await returnApplyOrderCancelFetchData({ id: orderInfo?.return_apply_order_id })
|
const res = await returnApplyOrderCancelFetchData({ id: orderInfo?.return_apply_order_id })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
alert.success('取消成功')
|
alert.success('取消成功')
|
||||||
onClick?.(val)
|
onClick?.(val)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.none(res.msg)
|
alert.none(res.msg)
|
||||||
}
|
}
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
import { Text, View } from "@tarojs/components";
|
import { Text, View } from '@tarojs/components'
|
||||||
import { memo, useCallback } from "react";
|
import { memo, useCallback } from 'react'
|
||||||
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import classnames from "classnames";
|
import { numberWithCommas } from '@/common/fotmat'
|
||||||
import { numberWithCommas } from "@/common/fotmat";
|
|
||||||
|
|
||||||
type Param = {
|
interface Param {
|
||||||
number: number, //数字
|
number: number // 数字
|
||||||
status: 0|1|2 // 0 小型,1中型,2大
|
status: 0|1|2 // 0 小型,1中型,2大
|
||||||
}
|
}
|
||||||
export default memo(({ number = 0, status = 1 }: Param) => {
|
export default memo(({ number = 0, status = 1 }: Param) => {
|
||||||
const priceDom = useCallback(() => {
|
const priceDom = useCallback(() => {
|
||||||
let res = number.toFixed(2).split('.')
|
const res = number.toFixed(2).split('.')
|
||||||
let int_num = parseInt(res[0]) + ''
|
const int_num = `${parseInt(res[0])}`
|
||||||
let decimals_num = res[1]
|
const decimals_num = res[1]
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Text className={styles.price_text}>¥</Text>
|
<Text className={styles.price_text}>¥</Text>
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
import { Image, Swiper, SwiperItem, View } from '@tarojs/components'
|
import { Image, Swiper, SwiperItem, View } from '@tarojs/components'
|
||||||
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
|
import styles from './index.module.scss'
|
||||||
import { goLink } from '@/common/common'
|
import { goLink } from '@/common/common'
|
||||||
import { GetBannerList } from '@/api/banner'
|
import { GetBannerList } from '@/api/banner'
|
||||||
import styles from './index.module.scss'
|
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
|
||||||
import { formatImgUrl } from '@/common/fotmat'
|
import { formatImgUrl } from '@/common/fotmat'
|
||||||
|
|
||||||
type item = { title: string; img: string; url: string; id: number }
|
interface item { title: string; img: string; url: string; id: number }
|
||||||
|
|
||||||
type params = {
|
interface params {
|
||||||
list?: item[]
|
list?: item[]
|
||||||
swiperOnClick?: (val: item) => void
|
swiperOnClick?: (val: item) => void
|
||||||
style?: Object
|
style?: Object
|
||||||
}
|
}
|
||||||
export default (props: params) => {
|
export default (props: params) => {
|
||||||
let { swiperOnClick, style = {} } = props
|
const { swiperOnClick, style = {} } = props
|
||||||
|
|
||||||
const [list, setList] = useState<any[]>([])
|
const [list, setList] = useState<any[]>([])
|
||||||
const { fetchData, state } = GetBannerList()
|
const { fetchData, state } = GetBannerList()
|
||||||
@ -29,8 +29,9 @@ export default (props: params) => {
|
|||||||
|
|
||||||
const skipTo = (item) => {
|
const skipTo = (item) => {
|
||||||
if (item.jump_type == 2 || item.jump_type == 0) {
|
if (item.jump_type == 2 || item.jump_type == 0) {
|
||||||
goLink(item.link + '&title=' + item.title)
|
goLink(`${item.link}&title=${item.title}`)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
goLink(item.link)
|
goLink(item.link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,12 +42,12 @@ export default (props: params) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.swiper_con} style={style}>
|
<View className={styles.swiper_con} style={style}>
|
||||||
<Swiper className={styles.xswiper} indicatorColor='#ccc' indicatorActiveColor='#fff' circular indicatorDots={showDot} autoplay>
|
<Swiper className={styles.xswiper} indicatorColor="#ccc" indicatorActiveColor="#fff" circular indicatorDots={showDot} autoplay>
|
||||||
{list?.map((item) => {
|
{list?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<SwiperItem key={item.id}>
|
<SwiperItem key={item.id}>
|
||||||
<View className={styles.image_item} onClick={() => skipTo(item)}>
|
<View className={styles.image_item} onClick={() => skipTo(item)}>
|
||||||
<Image mode='aspectFill' src={formatImgUrl(item.prev_view_url, '!w800')}></Image>
|
<Image mode="aspectFill" src={formatImgUrl(item.prev_view_url, '!w800')}></Image>
|
||||||
</View>
|
</View>
|
||||||
</SwiperItem>
|
</SwiperItem>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
import { Image, Swiper, SwiperItem, Text, View } from "@tarojs/components"
|
import { Image, Swiper, SwiperItem, Text, View } from '@tarojs/components'
|
||||||
|
import Taro from '@tarojs/taro'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import { formatImgUrl } from "@/common/fotmat"
|
import { formatImgUrl } from '@/common/fotmat'
|
||||||
import Taro from "@tarojs/taro";
|
import { goLink } from '@/common/common'
|
||||||
import { goLink } from "@/common/common";
|
|
||||||
|
|
||||||
type params = {
|
interface params {
|
||||||
show?: true|false,
|
show?: true|false
|
||||||
onClose?: () => void
|
onClose?: () => void
|
||||||
}
|
}
|
||||||
export default ({ show, onClose }: params) => {
|
export default ({ show, onClose }: params) => {
|
||||||
const onCustomer = async() => {
|
const onCustomer = async() => {
|
||||||
let res = await Taro.showModal({
|
const res = await Taro.showModal({
|
||||||
title: '是否拨打服务热线',
|
title: '是否拨打服务热线',
|
||||||
confirmText: '拨打',
|
confirmText: '拨打',
|
||||||
content: '(0757) 8270 6695',
|
content: '(0757) 8270 6695',
|
||||||
@ -18,7 +18,7 @@ export default ({show, onClose}:params) => {
|
|||||||
})
|
})
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
Taro.makePhoneCall({
|
Taro.makePhoneCall({
|
||||||
phoneNumber: '(0757)82706695'
|
phoneNumber: '(0757)82706695',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,5 +47,4 @@ export default ({show, onClose}:params) => {
|
|||||||
</View>}
|
</View>}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,12 +1,12 @@
|
|||||||
import { View } from "@tarojs/components";
|
import { View } from '@tarojs/components'
|
||||||
import { memo, useEffect, useMemo, useState } from "react";
|
import Taro, { useDidShow } from '@tarojs/taro'
|
||||||
import Taro, { useDidShow } from "@tarojs/taro";
|
import { memo, useEffect, useMemo, useState } from 'react'
|
||||||
import {useBluetooth} from "@/use/contextBlueTooth"
|
import classnames from 'classnames'
|
||||||
import SearchInput from "@/components/searchInput";
|
import styles from './css/linkBlueTooth.module.scss'
|
||||||
import Popup from "@/components/bluetooth/Popup"
|
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||||
import classnames from "classnames";
|
import SearchInput from '@/components/searchInput'
|
||||||
import styles from "./css/linkBlueTooth.module.scss"
|
import Popup from '@/components/bluetooth/Popup'
|
||||||
import useCheckAuthorize from "@/use/useCheckAuthorize";
|
import useCheckAuthorize from '@/use/useCheckAuthorize'
|
||||||
|
|
||||||
export default memo(() => {
|
export default memo(() => {
|
||||||
const { state, init, startScan, connect, disconnect } = useBluetooth()
|
const { state, init, startScan, connect, disconnect } = useBluetooth()
|
||||||
@ -21,9 +21,11 @@ export default memo(() => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!state.available) {
|
if (!state.available) {
|
||||||
setLinkStatus(1)
|
setLinkStatus(1)
|
||||||
} else if(state.available&&state.connected?.name) {
|
}
|
||||||
|
else if (state.available && state.connected?.name) {
|
||||||
setLinkStatus(3)
|
setLinkStatus(3)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setLinkStatus(2)
|
setLinkStatus(2)
|
||||||
}
|
}
|
||||||
}, [state.available, state.connected])
|
}, [state.available, state.connected])
|
||||||
@ -34,28 +36,27 @@ export default memo(() => {
|
|||||||
|
|
||||||
// 链接设备
|
// 链接设备
|
||||||
const onLinkListen = (item) => {
|
const onLinkListen = (item) => {
|
||||||
if(!state.connected&&!state.connecting)
|
if (!state.connected && !state.connecting) { connect(item) }
|
||||||
connect(item)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const [popupShow, setPopupShow] = useState(false)
|
const [popupShow, setPopupShow] = useState(false)
|
||||||
// 显示设备列表
|
// 显示设备列表
|
||||||
const onFindDevice = () => {
|
const onFindDevice = () => {
|
||||||
check().then(res => {
|
check().then((res) => {
|
||||||
if (linkStatus == 1) {
|
if (linkStatus == 1) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '请打开手机蓝牙',
|
title: '请打开手机蓝牙',
|
||||||
icon:'none'
|
icon: 'none',
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setPopupShow(true)
|
setPopupShow(true)
|
||||||
onFindEven()
|
onFindEven()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const onFindEven = () => {
|
const onFindEven = () => {
|
||||||
if(!state.discovering&&!state.connected&&!state.connecting)
|
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
|
||||||
startScan()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 断开链接
|
// 断开链接
|
||||||
@ -67,13 +68,13 @@ export default memo(() => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View className={styles.main}>
|
<View className={styles.main}>
|
||||||
<SearchInput title="蓝牙设备" showIcon={true}>
|
<SearchInput title="蓝牙设备" showIcon>
|
||||||
<View className={styles.bluetooth_link} onClick={onFindDevice}>
|
<View className={styles.bluetooth_link} onClick={onFindDevice}>
|
||||||
<View className={classnames(styles.link_status, linkStatus == 3 && styles.link_statused, linkStatus == 2 && styles.link_statused_no)}></View>
|
<View className={classnames(styles.link_status, linkStatus == 3 && styles.link_statused, linkStatus == 2 && styles.link_statused_no)}></View>
|
||||||
{
|
{
|
||||||
linkStatus == 1&&<View className={classnames(styles.link_name, styles.link_name_no)}>请开启蓝牙</View>||
|
linkStatus == 1 && <View className={classnames(styles.link_name, styles.link_name_no)}>请开启蓝牙</View>
|
||||||
linkStatus == 2&&<View className={classnames(styles.link_name,styles.link_name_no_link) }>未连接设备</View>||
|
|| linkStatus == 2 && <View className={classnames(styles.link_name, styles.link_name_no_link)}>未连接设备</View>
|
||||||
linkStatus == 3&&<View className={classnames(styles.link_name)}>{linkName}</View>
|
|| linkStatus == 3 && <View className={classnames(styles.link_name)}>{linkName}</View>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</SearchInput>
|
</SearchInput>
|
||||||
@ -88,6 +89,5 @@ export default memo(() => {
|
|||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
);
|
)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
import { ScrollView, View } from "@tarojs/components"
|
import { ScrollView, View } from '@tarojs/components'
|
||||||
import { memo, useEffect, useState } from "react"
|
import { memo, useEffect, useState } from 'react'
|
||||||
import Loading from "@/components/loading"
|
import style from './css/popup.module.scss'
|
||||||
import style from "./css/popup.module.scss"
|
import Loading from '@/components/loading'
|
||||||
|
|
||||||
interface params {
|
interface params {
|
||||||
state: any,
|
state: any
|
||||||
show: Boolean,
|
show: Boolean
|
||||||
onClose: (Boolean) => void,
|
onClose: (Boolean) => void
|
||||||
onLink: (any) => void,
|
onLink: (any) => void
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
onOff: () => void,
|
onOff: () => void
|
||||||
onFind: () => void,
|
onFind: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
|
export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
|
||||||
@ -31,27 +31,27 @@ export default memo(({state, show=false, onClose, onLink, onOff, onFind}:params)
|
|||||||
<View className={style.list}>
|
<View className={style.list}>
|
||||||
<ScrollView scrollY className={style.scroll}>
|
<ScrollView scrollY className={style.scroll}>
|
||||||
{
|
{
|
||||||
(state.devices&&state.devices.length > 0)&&state?.devices.map(item => {
|
(state.devices && state.devices.length > 0) && state?.devices.map((item) => {
|
||||||
return (
|
return (
|
||||||
<View className={style.item} onClick={() => onLink(item)}>
|
<View className={style.item} onClick={() => onLink(item)}>
|
||||||
<View>{item.name}</View>
|
<View>{item.name}</View>
|
||||||
{
|
{
|
||||||
(!state.connecting&&!state.connected)&&<View >链接</View>||
|
(!state.connecting && !state.connected) && <View >链接</View>
|
||||||
(state.connecting&&item.deviceId == state.connecting.deviceId)&&<View className={style.link_ing}>正在链接...</View>||
|
|| (state.connecting && item.deviceId == state.connecting.deviceId) && <View className={style.link_ing}>正在链接...</View>
|
||||||
(state.connected&&item.deviceId == state.connected.deviceId)&&<View className={style.link_success}>链接成功</View>
|
|| (state.connected && item.deviceId == state.connected.deviceId) && <View className={style.link_success}>链接成功</View>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
})||
|
})
|
||||||
<View className={style.noDevice}>
|
|| <View className={style.noDevice}>
|
||||||
{
|
{
|
||||||
(!state.discovering) && <>
|
(!state.discovering) && <>
|
||||||
<View>暂无设备,请按以下条件检查</View>
|
<View>暂无设备,请按以下条件检查</View>
|
||||||
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
|
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
|
||||||
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
|
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
|
||||||
<View className={style.n_item}>3.请打开手机定位</View>
|
<View className={style.n_item}>3.请打开手机定位</View>
|
||||||
</>||
|
</>
|
||||||
<View>设备搜索中</View>
|
|| <View>设备搜索中</View>
|
||||||
}
|
}
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
@ -60,9 +60,9 @@ export default memo(({state, show=false, onClose, onLink, onOff, onFind}:params)
|
|||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
{
|
{
|
||||||
state.connected&&<View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>断开链接</View>||
|
state.connected && <View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>断开链接</View>
|
||||||
(!state.connected&&state.discovering)&&<View className={`${style.footer} ${style.finding}`}>搜索中<Loading width={30} color='orange'/></View>||
|
|| (!state.connected && state.discovering) && <View className={`${style.footer} ${style.finding}`}>搜索中<Loading width={30} color="orange" /></View>
|
||||||
<View className={style.footer} onClick={onFind}>重新搜索</View>
|
|| <View className={style.footer} onClick={onFind}>重新搜索</View>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
<View className={style.mask} onClick={onCloseListener}></View>
|
<View className={style.mask} onClick={onCloseListener}></View>
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import classnames from 'classnames'
|
|||||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
type params = {
|
interface params {
|
||||||
onSelect?: () => void // 选择触发
|
onSelect?: () => void // 选择触发
|
||||||
onClose?: () => void // 取消触发
|
onClose?: () => void // 取消触发
|
||||||
status?: false | true // 是否选中
|
status?: false | true // 是否选中
|
||||||
@ -12,11 +12,12 @@ type params = {
|
|||||||
export default forwardRef(({ onSelect, onClose, status = false, disabled = false }: params, ref) => {
|
export default forwardRef(({ onSelect, onClose, status = false, disabled = false }: params, ref) => {
|
||||||
const [selected, SetSelected] = useState(false)
|
const [selected, SetSelected] = useState(false)
|
||||||
const onSelectEven = () => {
|
const onSelectEven = () => {
|
||||||
if (disabled) return false
|
if (disabled) { return false }
|
||||||
let res = !selected
|
const res = !selected
|
||||||
if (res) {
|
if (res) {
|
||||||
onSelect?.()
|
onSelect?.()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
onClose?.()
|
onClose?.()
|
||||||
}
|
}
|
||||||
SetSelected(res)
|
SetSelected(res)
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { View, Text } from "@tarojs/components"
|
import { Text, View } from '@tarojs/components'
|
||||||
import { memo } from "react"
|
import { memo } from 'react'
|
||||||
import style from "./index.module.scss"
|
import style from './index.module.scss'
|
||||||
|
|
||||||
type Params = {
|
interface Params {
|
||||||
onClose?: () => void,
|
onClose?: () => void
|
||||||
styleObj?: Object
|
styleObj?: Object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,8 @@ import { Input, View } from '@tarojs/components'
|
|||||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import Big from 'big.js'
|
import Big from 'big.js'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
type params = {
|
|
||||||
|
interface params {
|
||||||
minNum?: number // 最小值
|
minNum?: number // 最小值
|
||||||
maxNum?: number // 最大值
|
maxNum?: number // 最大值
|
||||||
step?: number // 步长
|
step?: number // 步长
|
||||||
@ -20,24 +21,24 @@ export default memo((props: params) => {
|
|||||||
|
|
||||||
function areEqual(prevProps: params, nextProps: params) {
|
function areEqual(prevProps: params, nextProps: params) {
|
||||||
return (
|
return (
|
||||||
prevProps.defaultNum == nextProps.defaultNum &&
|
prevProps.defaultNum == nextProps.defaultNum
|
||||||
prevProps.unit == nextProps.unit &&
|
&& prevProps.unit == nextProps.unit
|
||||||
prevProps.minNum == nextProps.minNum &&
|
&& prevProps.minNum == nextProps.minNum
|
||||||
prevProps.maxNum == nextProps.maxNum &&
|
&& prevProps.maxNum == nextProps.maxNum
|
||||||
prevProps.step == nextProps.step &&
|
&& prevProps.step == nextProps.step
|
||||||
prevProps.digits == nextProps.digits
|
&& prevProps.digits == nextProps.digits
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const Counter = memo((props: params) => {
|
const Counter = memo((props: params) => {
|
||||||
let { minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false } = props
|
const { minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false } = props
|
||||||
const [value, setValue] = useState<any>({ count: defaultNum })
|
const [value, setValue] = useState<any>({ count: defaultNum })
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// setValue({ count: defaultNum })
|
// setValue({ count: defaultNum })
|
||||||
// }, [defaultNum])
|
// }, [defaultNum])
|
||||||
console.log('1231231231231212')
|
console.log('1231231231231212')
|
||||||
const onPlus = () => {
|
const onPlus = () => {
|
||||||
if (disable) return false
|
if (disable) { return false }
|
||||||
let { count } = value
|
const { count } = value
|
||||||
let num_res = Big(count).add(step).toNumber()
|
let num_res = Big(count).add(step).toNumber()
|
||||||
num_res = num_res >= maxNum ? maxNum : num_res
|
num_res = num_res >= maxNum ? maxNum : num_res
|
||||||
num_res = formatDigits(num_res)
|
num_res = formatDigits(num_res)
|
||||||
@ -46,8 +47,8 @@ const Counter = memo((props: params) => {
|
|||||||
onClickBtn?.(parseFloat(num_res))
|
onClickBtn?.(parseFloat(num_res))
|
||||||
}
|
}
|
||||||
const minus = () => {
|
const minus = () => {
|
||||||
if (disable) return false
|
if (disable) { return false }
|
||||||
let { count } = value
|
const { count } = value
|
||||||
let num_res = Big(count).minus(step).toNumber()
|
let num_res = Big(count).minus(step).toNumber()
|
||||||
num_res = num_res < minNum ? minNum : num_res
|
num_res = num_res < minNum ? minNum : num_res
|
||||||
// setValue({ ...value, count: num_res })
|
// setValue({ ...value, count: num_res })
|
||||||
@ -57,21 +58,21 @@ const Counter = memo((props: params) => {
|
|||||||
|
|
||||||
// 保留小数
|
// 保留小数
|
||||||
const formatDigits = (num) => {
|
const formatDigits = (num) => {
|
||||||
num = num + ''
|
num = `${num}`
|
||||||
if (num.includes('.') && digits > 0) {
|
if (num.includes('.') && digits > 0) {
|
||||||
console.log('num::', num.includes('.'))
|
console.log('num::', num.includes('.'))
|
||||||
let res = num.split('.')
|
const res = num.split('.')
|
||||||
let last_num = res[1].substr(0, digits)
|
const last_num = res[1].substr(0, digits)
|
||||||
return res[0] + '.' + last_num
|
return `${res[0]}.${last_num}`
|
||||||
}
|
}
|
||||||
return parseFloat(num)
|
return parseFloat(num)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查数据
|
// 检查数据
|
||||||
const checkData = (val) => {
|
const checkData = (val) => {
|
||||||
let num = parseFloat(val)
|
const num = parseFloat(val)
|
||||||
if (num > maxNum) return maxNum
|
if (num > maxNum) { return maxNum }
|
||||||
if (num < minNum) return minNum
|
if (num < minNum) { return minNum }
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,13 +101,14 @@ const Counter = memo((props: params) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onBluerEven = (e) => {
|
const onBluerEven = (e) => {
|
||||||
let num = parseFloat(e.detail.value)
|
const num = parseFloat(e.detail.value)
|
||||||
if (!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
// setValue({ ...value, count })
|
// setValue({ ...value, count })
|
||||||
onBlue?.(count as number)
|
onBlue?.(count as number)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// setValue({ ...value, count: defaultNum })
|
// setValue({ ...value, count: defaultNum })
|
||||||
onBlue?.(minNum)
|
onBlue?.(minNum)
|
||||||
}
|
}
|
||||||
@ -121,9 +123,9 @@ const Counter = memo((props: params) => {
|
|||||||
value={String(props.defaultNum)}
|
value={String(props.defaultNum)}
|
||||||
onInput={onInputEven}
|
onInput={onInputEven}
|
||||||
onBlur={onBluerEven}
|
onBlur={onBluerEven}
|
||||||
type='digit'
|
type="digit"
|
||||||
disabled={disable}
|
disabled={disable}
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
/>
|
/>
|
||||||
<View className={styles.unit}>{unit}</View>
|
<View className={styles.unit}>{unit}</View>
|
||||||
|
|||||||
@ -2,7 +2,8 @@ import { CustomWrapper, Input, View } from '@tarojs/components'
|
|||||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import Big from 'big.js'
|
import Big from 'big.js'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
type params = {
|
|
||||||
|
interface params {
|
||||||
minNum?: number // 最小值
|
minNum?: number // 最小值
|
||||||
maxNum?: number // 最大值
|
maxNum?: number // 最大值
|
||||||
step?: number // 步长
|
step?: number // 步长
|
||||||
@ -20,7 +21,7 @@ export default memo((props: params) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const Counter = memo((props: params) => {
|
const Counter = memo((props: params) => {
|
||||||
let {
|
const {
|
||||||
minNum = 0,
|
minNum = 0,
|
||||||
maxNum = 10000,
|
maxNum = 10000,
|
||||||
step = 1,
|
step = 1,
|
||||||
@ -38,8 +39,8 @@ const Counter = memo((props: params) => {
|
|||||||
setValue({ count: defaultNum })
|
setValue({ count: defaultNum })
|
||||||
}, [defaultNum])
|
}, [defaultNum])
|
||||||
const onPlus = () => {
|
const onPlus = () => {
|
||||||
if (disabled) return false
|
if (disabled) { return false }
|
||||||
let count = value.count
|
const count = value.count
|
||||||
let num_res = Big(count).add(step).toNumber()
|
let num_res = Big(count).add(step).toNumber()
|
||||||
num_res = num_res >= maxNum ? maxNum : num_res
|
num_res = num_res >= maxNum ? maxNum : num_res
|
||||||
num_res = formatDigits(num_res)
|
num_res = formatDigits(num_res)
|
||||||
@ -48,12 +49,13 @@ const Counter = memo((props: params) => {
|
|||||||
onClickBtn?.(parseFloat(num_res))
|
onClickBtn?.(parseFloat(num_res))
|
||||||
}
|
}
|
||||||
const minus = () => {
|
const minus = () => {
|
||||||
if (disabled) return false
|
if (disabled) { return false }
|
||||||
let count = value.count
|
const count = value.count
|
||||||
let num_res = Big(count).minus(step).toNumber()
|
let num_res = Big(count).minus(step).toNumber()
|
||||||
if (returnZero) {
|
if (returnZero) {
|
||||||
num_res = num_res < minNum ? 0 : num_res
|
num_res = num_res < minNum ? 0 : num_res
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
num_res = num_res < minNum ? minNum : num_res
|
num_res = num_res < minNum ? minNum : num_res
|
||||||
}
|
}
|
||||||
setValue({ ...value, count: num_res })
|
setValue({ ...value, count: num_res })
|
||||||
@ -63,13 +65,14 @@ const Counter = memo((props: params) => {
|
|||||||
|
|
||||||
// 保留小数
|
// 保留小数
|
||||||
const formatDigits = (num) => {
|
const formatDigits = (num) => {
|
||||||
num = num + ''
|
num = `${num}`
|
||||||
if (num.includes('.')) {
|
if (num.includes('.')) {
|
||||||
let res = num.split('.')
|
const res = num.split('.')
|
||||||
if (digits > 0) {
|
if (digits > 0) {
|
||||||
let last_num = res[1].substr(0, digits)
|
const last_num = res[1].substr(0, digits)
|
||||||
return res[0] + '.' + last_num
|
return `${res[0]}.${last_num}`
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return res[0]
|
return res[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,54 +82,59 @@ const Counter = memo((props: params) => {
|
|||||||
|
|
||||||
// 检查数据
|
// 检查数据
|
||||||
const checkData = (val) => {
|
const checkData = (val) => {
|
||||||
let num = parseFloat(val)
|
const num = parseFloat(val)
|
||||||
if (num > maxNum) return maxNum
|
if (num > maxNum) { return maxNum }
|
||||||
if (num < minNum) return minNum
|
if (num < minNum) { return minNum }
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
const onInputEven = (e) => {
|
const onInputEven = (e) => {
|
||||||
let res = e.detail.value
|
const res = e.detail.value
|
||||||
if (res === '') {
|
if (res === '') {
|
||||||
onChange?.(minNum)
|
onChange?.(minNum)
|
||||||
} else if (!isNaN(Number(res))) {
|
}
|
||||||
|
else if (!isNaN(Number(res))) {
|
||||||
let count = formatDigits(res)
|
let count = formatDigits(res)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
onChange?.(parseFloat(count as string))
|
onChange?.(parseFloat(count as string))
|
||||||
} else {
|
}
|
||||||
let num = parseFloat(res)
|
else {
|
||||||
|
const num = parseFloat(res)
|
||||||
if (!isNaN(num)) {
|
if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
onChange?.(count as number)
|
onChange?.(count as number)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
onChange?.(defaultNum)
|
onChange?.(defaultNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onBluerEven = (e) => {
|
const onBluerEven = (e) => {
|
||||||
let num = parseFloat(e.detail.value)
|
const num = parseFloat(e.detail.value)
|
||||||
if (e.detail.value == '') {
|
if (e.detail.value == '') {
|
||||||
onBlue?.(minNum)
|
onBlue?.(minNum)
|
||||||
setValue({ count: minNum })
|
setValue({ count: minNum })
|
||||||
} else if (!isNaN(num)) {
|
}
|
||||||
|
else if (!isNaN(num)) {
|
||||||
let count = formatDigits(num)
|
let count = formatDigits(num)
|
||||||
count = checkData(count)
|
count = checkData(count)
|
||||||
setValue({ count })
|
setValue({ count })
|
||||||
onBlue?.(count as number)
|
onBlue?.(count as number)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setValue({ count: minNum })
|
setValue({ count: minNum })
|
||||||
onBlue?.(minNum)
|
onBlue?.(minNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<View className={styles.main} onClick={(e) => e.stopPropagation()}>
|
<View className={styles.main} onClick={e => e.stopPropagation()}>
|
||||||
<View className={styles.reduce} onClick={() => minus()}>
|
<View className={styles.reduce} onClick={() => minus()}>
|
||||||
-
|
-
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.input}>
|
<View className={styles.input}>
|
||||||
<Input type='digit' value={value.count} onInput={onInputEven} onBlur={onBluerEven} disabled={disabled} alwaysEmbed={true} cursorSpacing={150} />
|
<Input type="digit" value={value.count} onInput={onInputEven} onBlur={onBluerEven} disabled={disabled} alwaysEmbed cursorSpacing={150} />
|
||||||
<View className={styles.unit}>{unit}</View>
|
<View className={styles.unit}>{unit}</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.plus} onClick={() => onPlus()}>
|
<View className={styles.plus} onClick={() => onPlus()}>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { View } from "@tarojs/components";
|
import { View } from '@tarojs/components'
|
||||||
import { memo } from "react";
|
import { memo } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
export default memo(() => {
|
export default memo(() => {
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
import { Text, View } from "@tarojs/components"
|
import { Text, View } from '@tarojs/components'
|
||||||
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useState } from "react"
|
import Taro from '@tarojs/taro'
|
||||||
import {formatKbPrice} from '@/common/common'
|
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react'
|
||||||
import classnames from "classnames";
|
import classnames from 'classnames'
|
||||||
|
import AmountShow from '../amountShow'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import Taro from "@tarojs/taro";
|
import { formatKbPrice } from '@/common/common'
|
||||||
import AmountShow from "../amountShow";
|
|
||||||
|
|
||||||
type Param = {
|
interface Param {
|
||||||
style?: Object,
|
style?: Object
|
||||||
number?: number|string,
|
number?: number|string
|
||||||
title?: string,
|
title?: string
|
||||||
titleStatus?: true|false, //true 标题加大加深
|
titleStatus?: true|false // true 标题加大加深
|
||||||
numberStatus?: 0|1|2, //数字尺寸
|
numberStatus?: 0|1|2 // 数字尺寸
|
||||||
messageTitle?: string,
|
messageTitle?: string
|
||||||
messageWidth?: number,
|
messageWidth?: number
|
||||||
messageShow?: true|false,
|
messageShow?: true|false
|
||||||
numberFormat?: 'number'|'text' // 数字还是字符串
|
numberFormat?: 'number'|'text' // 数字还是字符串
|
||||||
}
|
}
|
||||||
export default memo(({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number' }: Param) => {
|
export default memo(({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number' }: Param) => {
|
||||||
@ -23,7 +23,7 @@ export default memo(({number = 0, titleStatus = true, title = '', messageTitle =
|
|||||||
setShow(false)
|
setShow(false)
|
||||||
}
|
}
|
||||||
const openShow = () => [
|
const openShow = () => [
|
||||||
setShow(true)
|
setShow(true),
|
||||||
]
|
]
|
||||||
|
|
||||||
const [style, setStyle] = useState<{ top: string }>()
|
const [style, setStyle] = useState<{ top: string }>()
|
||||||
@ -31,18 +31,19 @@ export default memo(({number = 0, titleStatus = true, title = '', messageTitle =
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (show) {
|
if (show) {
|
||||||
getDomDes('#message')
|
getDomDes('#message')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setStyle(() => ({ top: '0' }))
|
setStyle(() => ({ top: '0' }))
|
||||||
}
|
}
|
||||||
}, [show])
|
}, [show])
|
||||||
// 设置弹出层高度
|
// 设置弹出层高度
|
||||||
const getDomDes = (id) => {
|
const getDomDes = (id) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let query = Taro.createSelectorQuery();
|
const query = Taro.createSelectorQuery()
|
||||||
query.select(id).boundingClientRect(rect=>{
|
query.select(id).boundingClientRect((rect) => {
|
||||||
let height = rect.height * 2 + 15;
|
const height = rect.height * 2 + 15
|
||||||
setStyle((e) => ({...e, top: `-${height}rpx`, opacity: 1}))
|
setStyle(e => ({ ...e, top: `-${height}rpx`, opacity: 1 }))
|
||||||
}).exec();
|
}).exec()
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@ -51,7 +52,7 @@ export default memo(({number = 0, titleStatus = true, title = '', messageTitle =
|
|||||||
<View className={classnames(styles.order_price_text, titleStatus && styles.emphasis)} onClick={() => openShow()}>
|
<View className={classnames(styles.order_price_text, titleStatus && styles.emphasis)} onClick={() => openShow()}>
|
||||||
<Text>{title}</Text>
|
<Text>{title}</Text>
|
||||||
<View className={styles.iconfont_msg}>
|
<View className={styles.iconfont_msg}>
|
||||||
{show&&<View style={{...style, width: `${messageWidth}rpx`}} id='message' className={classnames(styles.message)}>{messageTitle}</View>}
|
{show && <View style={{ ...style, width: `${messageWidth}rpx` }} id="message" className={classnames(styles.message)}>{messageTitle}</View>}
|
||||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import { GetProductKindListApi } from '@/api/material'
|
|
||||||
import Popup, { Params as PopuParams } from '@/components/popup'
|
|
||||||
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||||
import { useDidShow } from '@tarojs/taro'
|
import { useDidShow } from '@tarojs/taro'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import { memo, useEffect, useRef, useState } from 'react'
|
import { memo, useEffect, useRef, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import Popup from '@/components/popup'
|
||||||
|
import type { Params as PopuParams } from '@/components/popup'
|
||||||
|
import { GetProductKindListApi } from '@/api/material'
|
||||||
|
|
||||||
type params = {
|
type params = {
|
||||||
onFiltr?: (val: object) => void // 确定搜索
|
onFiltr?: (val: object) => void // 确定搜索
|
||||||
@ -26,7 +27,7 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
|||||||
const { fetchData: kindFetchData } = GetProductKindListApi()
|
const { fetchData: kindFetchData } = GetProductKindListApi()
|
||||||
const [kindList, setKindList] = useState<any[]>([])
|
const [kindList, setKindList] = useState<any[]>([])
|
||||||
const getCategoryList = async() => {
|
const getCategoryList = async() => {
|
||||||
let { data } = await kindFetchData()
|
const { data } = await kindFetchData()
|
||||||
setKindList(data.list)
|
setKindList(data.list)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
|||||||
|
|
||||||
// 重置数据
|
// 重置数据
|
||||||
const onRestEven = () => {
|
const onRestEven = () => {
|
||||||
let res = {
|
const res = {
|
||||||
seriesName: '',
|
seriesName: '',
|
||||||
seriesId: '',
|
seriesId: '',
|
||||||
width: '',
|
width: '',
|
||||||
@ -70,7 +71,7 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popup position='right' show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
<Popup position="right" show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton>
|
||||||
<View className={styles.popup_main}>
|
<View className={styles.popup_main}>
|
||||||
<View className={styles.popup_title}>全部筛选</View>
|
<View className={styles.popup_title}>全部筛选</View>
|
||||||
<ScrollView scrollY className={styles.scroll}>
|
<ScrollView scrollY className={styles.scroll}>
|
||||||
@ -78,11 +79,12 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
|||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>系列</View>
|
<View className={styles.title}>系列</View>
|
||||||
<View className={styles.btn_list}>
|
<View className={styles.btn_list}>
|
||||||
{kindList.map((item) => (
|
{kindList.map(item => (
|
||||||
<View
|
<View
|
||||||
key={item.id}
|
key={item.id}
|
||||||
onClick={() => changeKind(item)}
|
onClick={() => changeKind(item)}
|
||||||
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}>
|
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}
|
||||||
|
>
|
||||||
{item.name}
|
{item.name}
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
@ -93,12 +95,12 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
|||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}>
|
<View className={styles.btn_width}>
|
||||||
<Input
|
<Input
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
value={filterObj.width}
|
value={filterObj.width}
|
||||||
onBlur={(e) => setFieldData(e, 'width')}
|
onBlur={e => setFieldData(e, 'width')}
|
||||||
placeholder='请输入幅宽'
|
placeholder="请输入幅宽"
|
||||||
placeholderStyle='font-size: 26rpx'
|
placeholderStyle="font-size: 26rpx"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.unit}>cm</View>
|
<View className={styles.unit}>cm</View>
|
||||||
@ -110,11 +112,11 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
|||||||
<View className={styles.btn_width}>
|
<View className={styles.btn_width}>
|
||||||
<Input
|
<Input
|
||||||
value={filterObj.weight}
|
value={filterObj.weight}
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
onBlur={(e) => setFieldData(e, 'weight')}
|
onBlur={e => setFieldData(e, 'weight')}
|
||||||
placeholder='请输入克重'
|
placeholder="请输入克重"
|
||||||
placeholderStyle='font-size: 26rpx'
|
placeholderStyle="font-size: 26rpx"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.unit}>kg</View>
|
<View className={styles.unit}>kg</View>
|
||||||
@ -123,11 +125,11 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
|||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>成分</View>
|
<View className={styles.title}>成分</View>
|
||||||
<View className={styles.btn_list_element}>
|
<View className={styles.btn_list_element}>
|
||||||
<Textarea placeholder='请输入' cursorSpacing={60} value={filterObj.element} onInput={(e) => setFieldData(e, 'element')} />
|
<Textarea placeholder="请输入" cursorSpacing={60} value={filterObj.element} onInput={e => setFieldData(e, 'element')} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className='common_safe_area_y'></View>
|
<View className="common_safe_area_y"></View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className={styles.btns_con}>
|
<View className={styles.btns_con}>
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import { GetProductKindListApi } from '@/api/material'
|
|
||||||
import Popup, { Params as PopuParams } from '@/components/popup'
|
|
||||||
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||||
import { useDidShow } from '@tarojs/taro'
|
import { useDidShow } from '@tarojs/taro'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import Popup from '@/components/popup'
|
||||||
|
import type { Params as PopuParams } from '@/components/popup'
|
||||||
|
import { GetProductKindListApi } from '@/api/material'
|
||||||
|
|
||||||
type params = {
|
type params = {
|
||||||
onFiltr?: (val: object) => void
|
onFiltr?: (val: object) => void
|
||||||
@ -24,7 +25,7 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
|||||||
const { fetchData: kindFetchData } = GetProductKindListApi()
|
const { fetchData: kindFetchData } = GetProductKindListApi()
|
||||||
const [kindList, setKindList] = useState<any[]>([])
|
const [kindList, setKindList] = useState<any[]>([])
|
||||||
const getCategoryList = async() => {
|
const getCategoryList = async() => {
|
||||||
let { data } = await kindFetchData()
|
const { data } = await kindFetchData()
|
||||||
setKindList(data.list)
|
setKindList(data.list)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,21 +63,22 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
|||||||
|
|
||||||
const setNumber = (e, field) => {
|
const setNumber = (e, field) => {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
let num = parseFloat(e.detail.value)
|
const num = parseFloat(e.detail.value)
|
||||||
if (isNaN(num)) {
|
if (isNaN(num)) {
|
||||||
filterObj[field] = null
|
filterObj[field] = null
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
filterObj[field] = parseFloat(num.toFixed(2))
|
filterObj[field] = parseFloat(num.toFixed(2))
|
||||||
}
|
}
|
||||||
setFilterObj({ ...filterObj })
|
setFilterObj({ ...filterObj })
|
||||||
}
|
}
|
||||||
|
|
||||||
const setElement = (e) => {
|
const setElement = (e) => {
|
||||||
let res = e.detail.value
|
const res = e.detail.value
|
||||||
setFilterObj({ ...filterObj, element: res })
|
setFilterObj({ ...filterObj, element: res })
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Popup position='right' show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
<Popup position="right" show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton>
|
||||||
<View className={styles.popup_main}>
|
<View className={styles.popup_main}>
|
||||||
<View className={styles.popup_title}>全部筛选</View>
|
<View className={styles.popup_title}>全部筛选</View>
|
||||||
<ScrollView scrollY className={styles.scroll}>
|
<ScrollView scrollY className={styles.scroll}>
|
||||||
@ -84,11 +86,12 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
|||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>系列</View>
|
<View className={styles.title}>系列</View>
|
||||||
<View className={styles.btn_list}>
|
<View className={styles.btn_list}>
|
||||||
{kindList.map((item) => (
|
{kindList.map(item => (
|
||||||
<View
|
<View
|
||||||
key={item.id}
|
key={item.id}
|
||||||
onClick={() => changeKind(item)}
|
onClick={() => changeKind(item)}
|
||||||
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}>
|
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}
|
||||||
|
>
|
||||||
{item.name}
|
{item.name}
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
@ -99,13 +102,13 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
|||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}>
|
<View className={styles.btn_width}>
|
||||||
<Input
|
<Input
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
value={filterObj.minWidth}
|
value={filterObj.minWidth}
|
||||||
type='digit'
|
type="digit"
|
||||||
onBlur={(e) => setNumber(e, 'minWidth')}
|
onBlur={e => setNumber(e, 'minWidth')}
|
||||||
placeholder='请输入幅宽'
|
placeholder="请输入幅宽"
|
||||||
placeholderStyle='font-size: 26rpx'
|
placeholderStyle="font-size: 26rpx"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.unit}>cm</View>
|
<View className={styles.unit}>cm</View>
|
||||||
@ -116,24 +119,24 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
|||||||
<View className={styles.btn_list_input}>
|
<View className={styles.btn_list_input}>
|
||||||
<View className={styles.btn_width}>
|
<View className={styles.btn_width}>
|
||||||
<Input
|
<Input
|
||||||
type='digit'
|
type="digit"
|
||||||
value={filterObj.minWeight}
|
value={filterObj.minWeight}
|
||||||
onBlur={(e) => setNumber(e, 'minWeight')}
|
onBlur={e => setNumber(e, 'minWeight')}
|
||||||
placeholder='自定义最低值'
|
placeholder="自定义最低值"
|
||||||
placeholderStyle='font-size: 26rpx'
|
placeholderStyle="font-size: 26rpx"
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Text>—</Text>
|
<Text>—</Text>
|
||||||
<View className={styles.btn_width}>
|
<View className={styles.btn_width}>
|
||||||
<Input
|
<Input
|
||||||
type='digit'
|
type="digit"
|
||||||
value={filterObj.maxWeight}
|
value={filterObj.maxWeight}
|
||||||
onBlur={(e) => setNumber(e, 'maxWeight')}
|
onBlur={e => setNumber(e, 'maxWeight')}
|
||||||
placeholder='自定义最高值'
|
placeholder="自定义最高值"
|
||||||
placeholderStyle='font-size: 26rpx'
|
placeholderStyle="font-size: 26rpx"
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@ -143,11 +146,11 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
|||||||
<View className={styles.popup_filter_item}>
|
<View className={styles.popup_filter_item}>
|
||||||
<View className={styles.title}>成分</View>
|
<View className={styles.title}>成分</View>
|
||||||
<View className={styles.btn_list_element}>
|
<View className={styles.btn_list_element}>
|
||||||
<Textarea placeholder='请输入' cursorSpacing={60} value={filterObj.element} onInput={(e) => setElement(e)} />
|
<Textarea placeholder="请输入" cursorSpacing={60} value={filterObj.element} onInput={e => setElement(e)} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className='common_safe_area_y'></View>
|
<View className="common_safe_area_y"></View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className={styles.btns_con}>
|
<View className={styles.btns_con}>
|
||||||
|
|||||||
@ -1,28 +1,29 @@
|
|||||||
import { ScrollView, View } from "@tarojs/components"
|
import { ScrollView, View } from '@tarojs/components'
|
||||||
import { memo, ReactNode, useMemo, useState } from "react"
|
import type { ReactNode } from 'react'
|
||||||
import style from "./index.module.scss"
|
import { memo, useMemo, useState } from 'react'
|
||||||
import DotLoading from "@/components/dotLoading"
|
import LoadingCard from '../loadingCard'
|
||||||
import LoadingCard from "../loadingCard"
|
import style from './index.module.scss'
|
||||||
|
import DotLoading from '@/components/dotLoading'
|
||||||
|
|
||||||
export type StatusParam = 0|1|2|3
|
export type StatusParam = 0|1|2|3
|
||||||
|
|
||||||
type Params = {
|
interface Params {
|
||||||
styleObj?: Object,
|
styleObj?: Object
|
||||||
selfonScrollToLower?: () => void,
|
selfonScrollToLower?: () => void
|
||||||
hasMore?: false|true,
|
hasMore?: false|true
|
||||||
moreStatus?: false|true,
|
moreStatus?: false|true
|
||||||
statusMore?: StatusParam // 0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
statusMore?: StatusParam // 0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||||
children?: ReactNode,
|
children?: ReactNode
|
||||||
lowerThresholdNum?: number,
|
lowerThresholdNum?: number
|
||||||
selfOnScrollToUpper?: () => void
|
selfOnScrollToUpper?: () => void
|
||||||
selfOnScroll?: (val: any) => void
|
selfOnScroll?: (val: any) => void
|
||||||
selfOnRefresherPulling?: () => void
|
selfOnRefresherPulling?: () => void
|
||||||
selfOnRefresherRefresh?: () => void
|
selfOnRefresherRefresh?: () => void
|
||||||
selfOnRefresherRestore?: () => void
|
selfOnRefresherRestore?: () => void
|
||||||
selfOnRefresherAbort?: () => void
|
selfOnRefresherAbort?: () => void
|
||||||
paddingBottom?: number,
|
paddingBottom?: number
|
||||||
refresherTriggered?: true|false,
|
refresherTriggered?: true|false
|
||||||
refresherEnabled?: true|false,
|
refresherEnabled?: true|false
|
||||||
}
|
}
|
||||||
export default memo(({
|
export default memo(({
|
||||||
styleObj,
|
styleObj,
|
||||||
@ -40,7 +41,7 @@ export default memo(({
|
|||||||
refresherTriggered = false,
|
refresherTriggered = false,
|
||||||
refresherEnabled = false,
|
refresherEnabled = false,
|
||||||
moreStatus = true,
|
moreStatus = true,
|
||||||
statusMore = 0
|
statusMore = 0,
|
||||||
}: Params) => {
|
}: Params) => {
|
||||||
const scrollToLower = () => {
|
const scrollToLower = () => {
|
||||||
selfonScrollToLower?.()
|
selfonScrollToLower?.()
|
||||||
@ -79,7 +80,7 @@ export default memo(({
|
|||||||
scrollY
|
scrollY
|
||||||
onScrollToLower={() => scrollToLower()}
|
onScrollToLower={() => scrollToLower()}
|
||||||
onScrollToUpper={() => scrollToUpper()}
|
onScrollToUpper={() => scrollToUpper()}
|
||||||
onScroll={(e) => scroll(e)}
|
onScroll={e => scroll(e)}
|
||||||
lowerThreshold={lowerThresholdNum}
|
lowerThreshold={lowerThresholdNum}
|
||||||
refresherEnabled={refresherEnabled}
|
refresherEnabled={refresherEnabled}
|
||||||
refresherTriggered={refresherTriggered}
|
refresherTriggered={refresherTriggered}
|
||||||
@ -87,21 +88,21 @@ export default memo(({
|
|||||||
onRefresherRefresh={() => refresherRefresh()}
|
onRefresherRefresh={() => refresherRefresh()}
|
||||||
onRefresherRestore={() => refresherRestore()}
|
onRefresherRestore={() => refresherRestore()}
|
||||||
onRefresherAbort={() => refresherAbort()}
|
onRefresherAbort={() => refresherAbort()}
|
||||||
refresherBackground ='#F8F8F8'
|
refresherBackground="#F8F8F8"
|
||||||
scrollTop={scrollTop}
|
scrollTop={scrollTop}
|
||||||
>
|
>
|
||||||
{!moreStatus && <>
|
{!moreStatus && <>
|
||||||
<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||||
{children}
|
{children}
|
||||||
</View>
|
</View>
|
||||||
</>||
|
</>
|
||||||
<>
|
|| <>
|
||||||
{(statusMore == 2 || statusMore == 3)&&<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
{(statusMore == 2 || statusMore == 3) && <View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||||
{children}
|
{children}
|
||||||
<View className={style.infinite_scroll}>
|
<View className={style.infinite_scroll}>
|
||||||
{
|
{
|
||||||
(statusMore == 2)&&<View className={style.loading_more}>加载中<DotLoading/></View>||
|
(statusMore == 2) && <View className={style.loading_more}>加载中<DotLoading /></View>
|
||||||
<View className={style.noMore}>没有更多数据了</View>
|
|| <View className={style.noMore}>没有更多数据了</View>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,15 +1,13 @@
|
|||||||
import { View } from "@tarojs/components"
|
import { View } from '@tarojs/components'
|
||||||
import { memo, useMemo } from "react"
|
import { memo, useMemo } from 'react'
|
||||||
import style from './index.module.scss'
|
import style from './index.module.scss'
|
||||||
export default memo(({width=60, color='#6190e8'}:{width?:number, color?:string}) => {
|
|
||||||
|
export default memo(({ width = 60, color = '#6190e8' }: { width?: number; color?: string }) => {
|
||||||
const styleObj = useMemo(() => {
|
const styleObj = useMemo(() => {
|
||||||
let obj = {}
|
let obj = {}
|
||||||
if(width > 0)
|
if (width > 0) { obj = { width: `${width}rpx`, height: `${width}rpx` } }
|
||||||
obj = {width: width + 'rpx', height:width + 'rpx'}
|
if (color) { obj = { ...obj, borderColor: `${color} transparent transparent` } }
|
||||||
if(color)
|
|
||||||
obj = {...obj, borderColor: color+' transparent transparent'}
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
}, [width, color])
|
}, [width, color])
|
||||||
console.log('loading:::')
|
console.log('loading:::')
|
||||||
return (
|
return (
|
||||||
@ -21,5 +19,4 @@ export default memo(({width=60, color='#6190e8'}:{width?:number, color?:string})
|
|||||||
<View style={styleObj} className={style.loading__ring}></View>
|
<View style={styleObj} className={style.loading__ring}></View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -1,17 +1,17 @@
|
|||||||
import { View } from "@tarojs/components"
|
import { View } from '@tarojs/components'
|
||||||
import Loading from "@/components/loading"
|
import { memo } from 'react'
|
||||||
import style from "./index.module.scss"
|
import style from './index.module.scss'
|
||||||
import { memo } from "react";
|
import Loading from '@/components/loading'
|
||||||
|
|
||||||
type Params = {
|
interface Params {
|
||||||
styleLoading?: Object,
|
styleLoading?: Object
|
||||||
title?: string,
|
title?: string
|
||||||
loadingIcon?: false|true
|
loadingIcon?: false|true
|
||||||
}
|
}
|
||||||
export default memo(({
|
export default memo(({
|
||||||
styleLoading = {},
|
styleLoading = {},
|
||||||
title = "加载中...", //显示的文字
|
title = '加载中...', // 显示的文字
|
||||||
loadingIcon = true //是否显示加载图标
|
loadingIcon = true, // 是否显示加载图标
|
||||||
}: Params) => {
|
}: Params) => {
|
||||||
console.log('loadingCard:::')
|
console.log('loadingCard:::')
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
import { MovableArea, MovableView, View } from '@tarojs/components'
|
import { MovableArea, MovableView, View } from '@tarojs/components'
|
||||||
import Taro, { useDidShow, useReady, useRouter } from '@tarojs/taro'
|
import Taro, { useDidShow, useReady, useRouter } from '@tarojs/taro'
|
||||||
import { ReactElement, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
import type { ReactElement } from 'react'
|
||||||
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import { GetShoppingCartApi } from '@/api/shopCart'
|
import { GetShoppingCartApi } from '@/api/shopCart'
|
||||||
import useCommonData from '@/use/useCommonData'
|
import useCommonData from '@/use/useCommonData'
|
||||||
import { useSelector } from '@/reducers/hooks'
|
import { useSelector } from '@/reducers/hooks'
|
||||||
|
|
||||||
type param = {
|
interface param {
|
||||||
children?: ReactElement | null
|
children?: ReactElement | null
|
||||||
onClick?: () => void
|
onClick?: () => void
|
||||||
}
|
}
|
||||||
@ -21,7 +22,7 @@ export default ({ children = null, onClick }: param) => {
|
|||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const res = Taro.getSystemInfoSync()
|
const res = Taro.getSystemInfoSync()
|
||||||
if (res.screenHeight) {
|
if (res.screenHeight) {
|
||||||
let ratio = 750 / res.screenWidth
|
const ratio = 750 / res.screenWidth
|
||||||
setScreenHeight(res.screenHeight * ratio - 460)
|
setScreenHeight(res.screenHeight * ratio - 460)
|
||||||
screenWidthRef.current = res.screenWidth / 2
|
screenWidthRef.current = res.screenWidth / 2
|
||||||
}
|
}
|
||||||
@ -40,11 +41,12 @@ export default ({ children = null, onClick }: param) => {
|
|||||||
<MovableView
|
<MovableView
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={styles.moveBtn}
|
className={styles.moveBtn}
|
||||||
direction='all'
|
direction="all"
|
||||||
inertia={true}
|
inertia
|
||||||
x='630rpx'
|
x="630rpx"
|
||||||
y={screenHeight + 'rpx'}
|
y={`${screenHeight}rpx`}
|
||||||
onTouchEnd={(e) => dragEnd(e)}>
|
onTouchEnd={e => dragEnd(e)}
|
||||||
|
>
|
||||||
<View className={classnames('iconfont', 'icon-gouwuche', styles.shop_icon)}></View>
|
<View className={classnames('iconfont', 'icon-gouwuche', styles.shop_icon)}></View>
|
||||||
{commonData.shopCount > 0 && <View className={styles.product_num}>{commonData.shopCount > 99 ? '99+' : commonData.shopCount}</View>}
|
{commonData.shopCount > 0 && <View className={styles.product_num}>{commonData.shopCount > 99 ? '99+' : commonData.shopCount}</View>}
|
||||||
</MovableView>
|
</MovableView>
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
import { CancelOrderApi, ReceiveOrderApi } from "@/api/order"
|
import { ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { alert } from "@/common/common"
|
import Taro from '@tarojs/taro'
|
||||||
import { ORDER_STATUS, SALE_MODE } from "@/common/enum"
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { ScrollView, Text, View } from "@tarojs/components"
|
|
||||||
import Taro from "@tarojs/taro"
|
|
||||||
import { useCallback, useRef, memo, useState, useEffect, useMemo } from "react"
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import { ORDER_STATUS, SALE_MODE } from '@/common/enum'
|
||||||
|
import { alert } from '@/common/common'
|
||||||
|
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
||||||
|
|
||||||
type Param = {
|
interface Param {
|
||||||
orderInfo: {
|
orderInfo: {
|
||||||
status: number, //订单状态
|
status: number // 订单状态
|
||||||
orderId: number, //订单id
|
orderId: number // 订单id
|
||||||
actual_amount: number, //实付金额
|
actual_amount: number // 实付金额
|
||||||
wait_pay_amount: number, //待付金额
|
wait_pay_amount: number // 待付金额
|
||||||
sale_mode: number // 订单类型
|
sale_mode: number // 订单类型
|
||||||
}|null,
|
}|null
|
||||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
SaleOrderStatusWaitingPayment,
|
SaleOrderStatusWaitingPayment,
|
||||||
SaleOrderStatusWaitingReceipt,
|
SaleOrderStatusWaitingReceipt,
|
||||||
SaleOrderStatusAlreadyReceipt,
|
SaleOrderStatusAlreadyReceipt,
|
||||||
SaleorderstatusWaitingPrePayment
|
SaleorderstatusWaitingPrePayment,
|
||||||
} = ORDER_STATUS
|
} = ORDER_STATUS
|
||||||
|
|
||||||
// 订单类型
|
// 订单类型
|
||||||
@ -48,59 +48,61 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
SaleOrderStatusArranged.value,
|
SaleOrderStatusArranged.value,
|
||||||
SaleOrderStatusWaitingPayment.value,
|
SaleOrderStatusWaitingPayment.value,
|
||||||
SaleOrderStatusWaitingDelivery.value], // 取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
SaleOrderStatusWaitingDelivery.value], // 取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||||
label: '取消订单'
|
label: '取消订单',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], // 去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], // 去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||||
label: '去付款'
|
label: '去付款',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
value: [SaleOrderStatusWaitingDelivery.value], // 申请退款按钮对应: 待发货
|
value: [SaleOrderStatusWaitingDelivery.value], // 申请退款按钮对应: 待发货
|
||||||
label: '申请退款'
|
label: '申请退款',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||||
label: '查看物流'
|
label: '查看物流',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5,
|
id: 5,
|
||||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], // 申请退货按钮对应: 待收货, 已收货, 已退款
|
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], // 申请退货按钮对应: 待收货, 已收货, 已退款
|
||||||
label: '申请退货'
|
label: '申请退货',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6,
|
id: 6,
|
||||||
value: [SaleOrderStatusWaitingReceipt.value], // 确认收货按钮对应: 待收货
|
value: [SaleOrderStatusWaitingReceipt.value], // 确认收货按钮对应: 待收货
|
||||||
label: '确认收货'
|
label: '确认收货',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 7,
|
id: 7,
|
||||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||||
label: '再次购买'
|
label: '再次购买',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 8,
|
id: 8,
|
||||||
value: [SaleOrderStatusBooking.value], // 按钮对应: 待接单
|
value: [SaleOrderStatusBooking.value], // 按钮对应: 待接单
|
||||||
label: '退款'
|
label: '退款',
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
// 判断是否显示该按钮
|
// 判断是否显示该按钮
|
||||||
const orderBtnsShow = (item) => {
|
const orderBtnsShow = (item) => {
|
||||||
if (orderInfo) {
|
if (orderInfo) {
|
||||||
if (item.id == 1) {
|
if (item.id == 1) {
|
||||||
// 取消订单按钮
|
// 取消订单按钮
|
||||||
return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款
|
return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款
|
||||||
} else if (item.id == 2) {
|
}
|
||||||
|
else if (item.id == 2) {
|
||||||
// 去付款按钮
|
// 去付款按钮
|
||||||
return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示
|
return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示
|
||||||
} else if(item.id == 3 ) {
|
}
|
||||||
|
else if (item.id == 3) {
|
||||||
// 申请退款, 只有大货才有
|
// 申请退款, 只有大货才有
|
||||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款
|
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款
|
||||||
} else if( item.id == 8) {
|
}
|
||||||
|
else if (item.id == 8) {
|
||||||
// 退款按钮(直接退款不用申请), 只有散剪和剪板有
|
// 退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款
|
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款
|
||||||
}
|
}
|
||||||
@ -112,20 +114,17 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 显示的按钮数组
|
// 显示的按钮数组
|
||||||
const orderBtnsShowList: {id: number, value: any, label: string}[] = useMemo(() => {
|
const orderBtnsShowList: { id: number; value: any; label: string }[] = useMemo(() => {
|
||||||
return orderBtnsList.current.filter(item => {
|
return orderBtnsList.current.filter((item) => {
|
||||||
return orderBtnsShow(item)
|
return orderBtnsShow(item)
|
||||||
})
|
})
|
||||||
}, [orderInfo])
|
}, [orderInfo])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 点击按钮操作
|
// 点击按钮操作
|
||||||
const submitBtns = (val, index) => {
|
const submitBtns = (val, index) => {
|
||||||
(val == 1) && cancelOrder(); // 取消订单按钮
|
(val == 1) && cancelOrder(); // 取消订单按钮
|
||||||
(val == 2) && onClick?.(2); // 去付款按钮
|
(val == 2) && onClick?.(2); // 去付款按钮
|
||||||
(val == 6)&&receiveOrder(); //确认收货
|
(val == 6) && receiveOrder() // 确认收货
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消订单
|
// 取消订单
|
||||||
@ -133,19 +132,21 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
const cancelOrder = () => {
|
const cancelOrder = () => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '要取消该订单吗?',
|
title: '要取消该订单吗?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
let res = await cancelFetchData({id: orderInfo?.orderId})
|
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
alert.success('取消成功')
|
alert.success('取消成功')
|
||||||
onClick?.(1)
|
onClick?.(1)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.none(res.msg)
|
alert.none(res.msg)
|
||||||
}
|
}
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,19 +156,21 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
console.log('123456')
|
console.log('123456')
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '确定收货?',
|
title: '确定收货?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
let res = await receiveOrderFetchData({sale_order_id: orderInfo?.orderId})
|
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
onClick?.(6)
|
onClick?.(6)
|
||||||
alert.success('收货成功')
|
alert.success('收货成功')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.error('收货失败')
|
alert.error('收货失败')
|
||||||
}
|
}
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +196,7 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
|
|
||||||
<View className={styles.list_scroll}>
|
<View className={styles.list_scroll}>
|
||||||
{orderBtnsShowList.map((item, index) =>
|
{orderBtnsShowList.map((item, index) =>
|
||||||
(index < 3)&&<View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
(index < 3) && <View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>,
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
|
||||||
import { alert, goLink } from '@/common/common'
|
|
||||||
import { ORDER_STATUS, SALE_MODE, SUBSCRIPTION_MESSAGE_SCENE } from '@/common/enum'
|
|
||||||
import { Text, View } from '@tarojs/components'
|
import { Text, View } from '@tarojs/components'
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { useRef, memo, useState, useMemo } from 'react'
|
import { memo, useMemo, useRef, useState } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import { ORDER_STATUS, SALE_MODE, SUBSCRIPTION_MESSAGE_SCENE } from '@/common/enum'
|
||||||
|
import { alert, goLink } from '@/common/common'
|
||||||
|
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
||||||
import { AddShoppingCartApi } from '@/api/shopCart'
|
import { AddShoppingCartApi } from '@/api/shopCart'
|
||||||
import { ApplyRefundApi } from '@/api/salesAfterOrder'
|
import { ApplyRefundApi } from '@/api/salesAfterOrder'
|
||||||
import { UseSubscriptionMessage } from '@/use/useCommon'
|
import { UseSubscriptionMessage } from '@/use/useCommon'
|
||||||
import { throttle } from '@/common/util'
|
import { throttle } from '@/common/util'
|
||||||
|
|
||||||
type Param = {
|
interface Param {
|
||||||
orderInfo: {
|
orderInfo: {
|
||||||
status: number // 订单状态
|
status: number // 订单状态
|
||||||
orderId: number // 订单id
|
orderId: number // 订单id
|
||||||
@ -46,7 +46,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
const { SaLeModeBulk, SaleModeLengthCut, SaLeModeWeightCut } = SALE_MODE
|
const { SaLeModeBulk, SaleModeLengthCut, SaLeModeWeightCut } = SALE_MODE
|
||||||
|
|
||||||
// 注册按钮, id:按钮id唯一,label:按钮名称,sort:排序数字越大越靠后,validatarFunc:验证
|
// 注册按钮, id:按钮id唯一,label:按钮名称,sort:排序数字越大越靠后,validatarFunc:验证
|
||||||
type orderBtnsListParams = { id: number; label: string; sort: number; validatarFunc: (val: typeof orderInfo) => any }
|
interface orderBtnsListParams { id: number; label: string; sort: number; validatarFunc: (val: typeof orderInfo) => any }
|
||||||
const orderBtnsList = useRef<orderBtnsListParams[]>([
|
const orderBtnsList = useRef<orderBtnsListParams[]>([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
@ -54,7 +54,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
sort: 1,
|
sort: 1,
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
// 在待发货之前没有付过款
|
// 在待发货之前没有付过款
|
||||||
let orderStatus = [
|
const orderStatus = [
|
||||||
SaleorderstatusWaitingPrePayment.value,
|
SaleorderstatusWaitingPrePayment.value,
|
||||||
SaleOrderStatusBooking.value,
|
SaleOrderStatusBooking.value,
|
||||||
SaleOrderStatusArranging.value,
|
SaleOrderStatusArranging.value,
|
||||||
@ -72,7 +72,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
sort: 100,
|
sort: 100,
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
// 只要没有付完款就显示
|
// 只要没有付完款就显示
|
||||||
let orderStatus = [
|
const orderStatus = [
|
||||||
SaleOrderStatusTaking.value,
|
SaleOrderStatusTaking.value,
|
||||||
SaleorderstatusWaitingPrePayment.value,
|
SaleorderstatusWaitingPrePayment.value,
|
||||||
SaleOrderStatusWaitingPayment.value,
|
SaleOrderStatusWaitingPayment.value,
|
||||||
@ -90,7 +90,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
sort: 5,
|
sort: 5,
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
// 大货在待发货付过款
|
// 大货在待发货付过款
|
||||||
let orderStatus = [SaleOrderStatusWaitingDelivery.value, SaleOrderStatusTaking.value]
|
const orderStatus = [SaleOrderStatusWaitingDelivery.value, SaleOrderStatusTaking.value]
|
||||||
return orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount > 0 && orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
return orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount > 0 && orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -99,7 +99,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
label: '申请退货',
|
label: '申请退货',
|
||||||
sort: 5,
|
sort: 5,
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
let orderStatus = [SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value]
|
const orderStatus = [SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value]
|
||||||
return orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
return orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -108,7 +108,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
label: '确认收货',
|
label: '确认收货',
|
||||||
sort: 10,
|
sort: 10,
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
let orderStatus = [SaleOrderStatusWaitingReceipt.value]
|
const orderStatus = [SaleOrderStatusWaitingReceipt.value]
|
||||||
return orderStatus.includes(orderInfo.status)
|
return orderStatus.includes(orderInfo.status)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -126,7 +126,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
sort: 5,
|
sort: 5,
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
// 散剪和剪板在待接单时付过款
|
// 散剪和剪板在待接单时付过款
|
||||||
let orderStatus = [SaleOrderStatusBooking.value]
|
const orderStatus = [SaleOrderStatusBooking.value]
|
||||||
return orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount > 0 && orderStatus.includes(orderInfo.status)
|
return orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount > 0 && orderStatus.includes(orderInfo.status)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -143,15 +143,15 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
label: '销售码单',
|
label: '销售码单',
|
||||||
sort: 9,
|
sort: 9,
|
||||||
validatarFunc: (orderInfo) => {
|
validatarFunc: (orderInfo) => {
|
||||||
if (orderInfo.sale_mode === 1 && showStatus == 'detail') return true
|
if (orderInfo.sale_mode === 1 && showStatus == 'detail') { return true }
|
||||||
if (orderInfo.sale_mode !== 1 && showStatus == 'detail') return orderInfo.is_should_collect_audit
|
if (orderInfo.sale_mode !== 1 && showStatus == 'detail') { return orderInfo.is_should_collect_audit }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
// 显示的按钮数组
|
// 显示的按钮数组
|
||||||
const orderBtnsShowList: orderBtnsListParams[] = useMemo(() => {
|
const orderBtnsShowList: orderBtnsListParams[] = useMemo(() => {
|
||||||
let list = orderBtnsList.current.filter((item) => {
|
const list = orderBtnsList.current.filter((item) => {
|
||||||
return item.validatarFunc(orderInfo)
|
return item.validatarFunc(orderInfo)
|
||||||
})
|
})
|
||||||
return list.sort((a, b) => a.sort - b.sort)
|
return list.sort((a, b) => a.sort - b.sort)
|
||||||
@ -165,15 +165,20 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
const submitBtns = throttle(async(val, index) => {
|
const submitBtns = throttle(async(val, index) => {
|
||||||
if (val == 1) {
|
if (val == 1) {
|
||||||
cancelOrder()
|
cancelOrder()
|
||||||
} else if (val == 6) {
|
}
|
||||||
|
else if (val == 6) {
|
||||||
receiveOrder()
|
receiveOrder()
|
||||||
} else if (val == 5) {
|
}
|
||||||
|
else if (val == 5) {
|
||||||
applyProduct()
|
applyProduct()
|
||||||
} else if (val == 3) {
|
}
|
||||||
|
else if (val == 3) {
|
||||||
bigApplyRefurn()
|
bigApplyRefurn()
|
||||||
} else if (val == 8) {
|
}
|
||||||
|
else if (val == 8) {
|
||||||
applyRefund()
|
applyRefund()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
onClick?.(val)
|
onClick?.(val)
|
||||||
}
|
}
|
||||||
}, 800)
|
}, 800)
|
||||||
@ -182,11 +187,12 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
const bigApplyRefurn = () => {
|
const bigApplyRefurn = () => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '要申请退款吗?',
|
title: '要申请退款吗?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||||
onClick?.(3)
|
onClick?.(3)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -198,16 +204,18 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
const cancelOrder = () => {
|
const cancelOrder = () => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '要取消该订单吗?',
|
title: '要取消该订单吗?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
let res = await cancelFetchData({ id: orderInfo?.orderId })
|
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
alert.success('取消成功')
|
alert.success('取消成功')
|
||||||
onClick?.(1)
|
onClick?.(1)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.none(res.msg)
|
alert.none(res.msg)
|
||||||
}
|
}
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -219,18 +227,20 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
const receiveOrder = async() => {
|
const receiveOrder = async() => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '确定收货?',
|
title: '确定收货?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
alert.showLoading('收货中', true)
|
alert.showLoading('收货中', true)
|
||||||
let res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
onClick?.(6)
|
onClick?.(6)
|
||||||
alert.success('收货成功')
|
alert.success('收货成功')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.error('收货失败')
|
alert.error('收货失败')
|
||||||
}
|
}
|
||||||
alert.hideLoading()
|
alert.hideLoading()
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -246,15 +256,17 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||||
alert.showLoading('申请中', true)
|
alert.showLoading('申请中', true)
|
||||||
let res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
|
const res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
alert.success('申请成功')
|
alert.success('申请成功')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.error('申请失败')
|
alert.error('申请失败')
|
||||||
}
|
}
|
||||||
alert.hideLoading()
|
alert.hideLoading()
|
||||||
onClick?.(8)
|
onClick?.(8)
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -263,7 +275,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
|||||||
|
|
||||||
// 申请退货
|
// 申请退货
|
||||||
const applyProduct = async() => {
|
const applyProduct = async() => {
|
||||||
if (!orderInfo?.av_return_roll) return alert.none('该订单没有可退条数')
|
if (!orderInfo?.av_return_roll) { return alert.none('该订单没有可退条数') }
|
||||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||||
goLink('/pages/applyAfterSales/index', { id: orderInfo?.orderId })
|
goLink('/pages/applyAfterSales/index', { id: orderInfo?.orderId })
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,19 @@
|
|||||||
import { View } from "@tarojs/components";
|
import { View } from '@tarojs/components'
|
||||||
import style from "./index.module.scss"
|
import classnames from 'classnames'
|
||||||
import classnames from "classnames";
|
import type { ReactNode } from 'react'
|
||||||
import { memo, ReactNode, useEffect, useMemo, useRef } from "react";
|
import { memo, useEffect, useMemo, useRef } from 'react'
|
||||||
import CloseBtnIcon from "@/components/closeBtn"
|
import style from './index.module.scss'
|
||||||
|
import CloseBtnIcon from '@/components/closeBtn'
|
||||||
|
|
||||||
export interface Params {
|
export interface Params {
|
||||||
title?: string, //标题
|
title?: string // 标题
|
||||||
show?: false|true, //显示显示弹窗
|
show?: false|true // 显示显示弹窗
|
||||||
showTitle?: false|true, //是否显示标题
|
showTitle?: false|true // 是否显示标题
|
||||||
onClose?:() => void, //关闭事件
|
onClose?: () => void // 关闭事件
|
||||||
children?: ReactNode, //插槽内容
|
children?: ReactNode // 插槽内容
|
||||||
// IconButton?: ReactNode, //
|
// IconButton?: ReactNode, //
|
||||||
showIconButton?: false|true, //是否显示关闭按钮
|
showIconButton?: false|true // 是否显示关闭按钮
|
||||||
position?: 'bottom'|'top'|'right', //弹出位置
|
position?: 'bottom'|'top'|'right' // 弹出位置
|
||||||
animationEnd?: () => void // 弹出动画结束
|
animationEnd?: () => void // 弹出动画结束
|
||||||
}
|
}
|
||||||
export default memo((
|
export default memo((
|
||||||
@ -24,16 +25,16 @@ export default memo((
|
|||||||
showIconButton = false,
|
showIconButton = false,
|
||||||
children,
|
children,
|
||||||
position = 'bottom',
|
position = 'bottom',
|
||||||
animationEnd
|
animationEnd,
|
||||||
}: Params) => {
|
}: Params) => {
|
||||||
|
|
||||||
const animationTime = useRef<any>(null)
|
const animationTime = useRef<any>(null)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (show) {
|
if (show) {
|
||||||
animationTime.current = setTimeout(() => {
|
animationTime.current = setTimeout(() => {
|
||||||
animationEnd?.()
|
animationEnd?.()
|
||||||
}, 260)
|
}, 260)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
clearTimeout(animationTime.current)
|
clearTimeout(animationTime.current)
|
||||||
}
|
}
|
||||||
}, [show])
|
}, [show])
|
||||||
@ -47,14 +48,14 @@ export default memo((
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View className={style.drawer_main}>
|
<View className={style.drawer_main}>
|
||||||
<View catchMove={true} className={`${style.drawer} ${show?style.drawer_active:''}` }>
|
<View catchMove className={`${style.drawer} ${show ? style.drawer_active : ''}`}>
|
||||||
<View
|
<View
|
||||||
className={classnames(style.drawer_mask, { [style.drawer_mask_active]: show })}
|
className={classnames(style.drawer_mask, { [style.drawer_mask_active]: show })}
|
||||||
onClick={() => onClose?.()}
|
onClick={() => onClose?.()}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
className={classnames(style.drawer_container, style['drawer_container_'+position], {[style.drawer_container_active]: show})}
|
className={classnames(style.drawer_container, style[`drawer_container_${position}`], { [style.drawer_container_active]: show })}
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={e => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
{showTitle && <View className={style.drawer_container_title}>{title}</View>}
|
{showTitle && <View className={style.drawer_container_title}>{title}</View>}
|
||||||
{showIconButton && <View className={style.common_close_btn_icon}>
|
{showIconButton && <View className={style.common_close_btn_icon}>
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { Image, View } from '@tarojs/components'
|
import { Image, View } from '@tarojs/components'
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { goLink } from '@/common/common'
|
|
||||||
import styles from './index.module.scss'
|
|
||||||
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
|
||||||
import LabAndImg from '../LabAndImg'
|
|
||||||
import { useCallback, useMemo } from 'react'
|
import { useCallback, useMemo } from 'react'
|
||||||
|
import LabAndImg from '../LabAndImg'
|
||||||
|
import styles from './index.module.scss'
|
||||||
|
import { goLink } from '@/common/common'
|
||||||
|
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||||
|
|
||||||
type Params = {
|
interface Params {
|
||||||
desStatus?: true | false
|
desStatus?: true | false
|
||||||
productList?: any[]
|
productList?: any[]
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ export default ({ desStatus = true, productList = [] }: Params) => {
|
|||||||
<View className={styles.tag}>{item.width}</View>
|
<View className={styles.tag}>{item.width}</View>
|
||||||
<View className={styles.tag_g}>{item.weight_density}</View>
|
<View className={styles.tag_g}>{item.weight_density}</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.introduce}>{item.craft + ';' + item.component}</View>
|
<View className={styles.introduce}>{`${item.craft};${item.component}`}</View>
|
||||||
{desStatus && <View className={styles.des}>{item.describe}</View>}
|
{desStatus && <View className={styles.des}>{item.describe}</View>}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { Input, View } from '@tarojs/components'
|
import { Input, View } from '@tarojs/components'
|
||||||
|
import classnames from 'classnames'
|
||||||
|
import { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import CloseBtn from '@/components/closeBtn'
|
import CloseBtn from '@/components/closeBtn'
|
||||||
import classnames from 'classnames'
|
|
||||||
import { debounce } from '@/common/util'
|
import { debounce } from '@/common/util'
|
||||||
import { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
|
||||||
|
|
||||||
type Params = {
|
interface Params {
|
||||||
clickOnSearch?: (val: string) => void
|
clickOnSearch?: (val: string) => void
|
||||||
disabled?: false | true
|
disabled?: false | true
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
@ -84,19 +84,21 @@ export default memo(
|
|||||||
'icon-sousuo',
|
'icon-sousuo',
|
||||||
styles.icon_a_sousuo1_self,
|
styles.icon_a_sousuo1_self,
|
||||||
placeIcon == 'inner' ? styles.icon_inner : styles.icon_out,
|
placeIcon == 'inner' ? styles.icon_inner : styles.icon_out,
|
||||||
)}></View>
|
)}
|
||||||
|
></View>
|
||||||
)}
|
)}
|
||||||
<Input
|
<Input
|
||||||
style={{ borderRadius }}
|
style={{ borderRadius }}
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
placeholderStyle='color:#ABABAB; font-size:26rpx'
|
placeholderStyle="color:#ABABAB; font-size:26rpx"
|
||||||
onConfirm={onSearch}
|
onConfirm={onSearch}
|
||||||
className={classnames(placeIcon == 'out' && styles.input_out)}
|
className={classnames(placeIcon == 'out' && styles.input_out)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={inputCon}
|
value={inputCon}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
onInput={(e) => onInputEven(e)}></Input>
|
onInput={e => onInputEven(e)}
|
||||||
|
></Input>
|
||||||
{!!inputCon && (
|
{!!inputCon && (
|
||||||
<View className={styles.search_closeBtn}>
|
<View className={styles.search_closeBtn}>
|
||||||
<CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />
|
<CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { Input, View } from '@tarojs/components'
|
import { Input, View } from '@tarojs/components'
|
||||||
import { memo, ReactHTMLElement, ReactNode, useDebugValue, useMemo } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
|
import { ReactHTMLElement, memo, useDebugValue, useMemo } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
type Params = {
|
interface Params {
|
||||||
showIcon?: false | true
|
showIcon?: false | true
|
||||||
disabled?: false | true
|
disabled?: false | true
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
@ -18,7 +19,7 @@ type Params = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default memo((props: Params) => {
|
export default memo((props: Params) => {
|
||||||
let {
|
const {
|
||||||
showTitle = true,
|
showTitle = true,
|
||||||
title = '标题',
|
title = '标题',
|
||||||
showIcon = false,
|
showIcon = false,
|
||||||
@ -31,14 +32,14 @@ export default memo((props: Params) => {
|
|||||||
titleStyle = {},
|
titleStyle = {},
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
let stylen = useMemo(() => {
|
const stylen = useMemo(() => {
|
||||||
if (!showBorder) {
|
if (!showBorder) {
|
||||||
return { borderBottom: 0 }
|
return { borderBottom: 0 }
|
||||||
}
|
}
|
||||||
return {}
|
return {}
|
||||||
}, [showBorder])
|
}, [showBorder])
|
||||||
return (
|
return (
|
||||||
<View className={styles.searchInput_main} style={{ height: height, ...stylen }}>
|
<View className={styles.searchInput_main} style={{ height, ...stylen }}>
|
||||||
{showTitle && (
|
{showTitle && (
|
||||||
<View className={styles.searchInput_title} style={titleStyle}>
|
<View className={styles.searchInput_title} style={titleStyle}>
|
||||||
{title}
|
{title}
|
||||||
@ -47,12 +48,12 @@ export default memo((props: Params) => {
|
|||||||
<View className={styles.searchInput_con}>
|
<View className={styles.searchInput_con}>
|
||||||
{(!props.children && (
|
{(!props.children && (
|
||||||
<Input
|
<Input
|
||||||
alwaysEmbed={true}
|
alwaysEmbed
|
||||||
cursorSpacing={150}
|
cursorSpacing={150}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
onClick={() => clickOnInput?.()}
|
onClick={() => clickOnInput?.()}
|
||||||
onInput={(e) => changeOnInput?.(e.detail.value)}
|
onInput={e => changeOnInput?.(e.detail.value)}
|
||||||
/>
|
/>
|
||||||
)) || <>{props.children}</>}
|
)) || <>{props.children}</>}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,14 +1,15 @@
|
|||||||
import { CustomWrapper, View } from '@tarojs/components'
|
import { CustomWrapper, View } from '@tarojs/components'
|
||||||
import { memo, useCallback, useMemo } from 'react'
|
import { memo, useCallback, useMemo } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
|
import Big from 'big.js'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import MCheckbox from '@/components/checkbox'
|
import MCheckbox from '@/components/checkbox'
|
||||||
import Counter from '@/components/counter'
|
import Counter from '@/components/counter'
|
||||||
import LabAndImg from '@/components/LabAndImg'
|
import LabAndImg from '@/components/LabAndImg'
|
||||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||||
import Big from 'big.js'
|
import type { saleModeType } from '@/common/enum'
|
||||||
import { saleModeType } from '@/common/enum'
|
|
||||||
type param = {
|
interface param {
|
||||||
sale_model: saleModeType
|
sale_model: saleModeType
|
||||||
onChangeSelect: (val: any) => any
|
onChangeSelect: (val: any) => any
|
||||||
onChangeCount: (val: any) => any
|
onChangeCount: (val: any) => any
|
||||||
@ -16,7 +17,7 @@ type param = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default memo((props: param) => {
|
export default memo((props: param) => {
|
||||||
let { onChangeCount, onChangeSelect, item, sale_model } = props
|
const { onChangeCount, onChangeSelect, item, sale_model } = props
|
||||||
|
|
||||||
const selectCallBack = useCallback(() => {
|
const selectCallBack = useCallback(() => {
|
||||||
onChangeSelect({ ...item, selected: true })
|
onChangeSelect({ ...item, selected: true })
|
||||||
@ -27,8 +28,8 @@ export default memo((props: param) => {
|
|||||||
const getLabAndImg = useCallback(() => {}, [])
|
const getLabAndImg = useCallback(() => {}, [])
|
||||||
const getInputValue = useCallback(
|
const getInputValue = useCallback(
|
||||||
(e) => {
|
(e) => {
|
||||||
let roll = item.sale_mode == 0 ? parseFloat(e) : 0
|
const roll = item.sale_mode == 0 ? parseFloat(e) : 0
|
||||||
let length = item.sale_mode != 0 ? parseFloat(new Big(parseFloat(e)).times(100)) : 0
|
const length = item.sale_mode != 0 ? parseFloat(new Big(parseFloat(e)).times(100)) : 0
|
||||||
onChangeCount({ ...item, roll, length })
|
onChangeCount({ ...item, roll, length })
|
||||||
},
|
},
|
||||||
[item],
|
[item],
|
||||||
@ -38,7 +39,7 @@ export default memo((props: param) => {
|
|||||||
}, [item])
|
}, [item])
|
||||||
|
|
||||||
const clickProduct = useCallback(() => {
|
const clickProduct = useCallback(() => {
|
||||||
if (sale_model == item.sale_mode) onChangeSelect({ ...item, selected: !item.selected })
|
if (sale_model == item.sale_mode) { onChangeSelect({ ...item, selected: !item.selected }) }
|
||||||
}, [item])
|
}, [item])
|
||||||
|
|
||||||
console.log('刷新2::', item)
|
console.log('刷新2::', item)
|
||||||
@ -78,7 +79,7 @@ export default memo((props: param) => {
|
|||||||
</View>
|
</View>
|
||||||
<View className={styles.count}>
|
<View className={styles.count}>
|
||||||
<View className={styles.des}>
|
<View className={styles.des}>
|
||||||
<View className={styles.subtitle}>{item.product_color_code + ' ' + item.product_color_name}</View>
|
<View className={styles.subtitle}>{`${item.product_color_code} ${item.product_color_name}`}</View>
|
||||||
<View className={styles.tag}>{item.sale_mode_name}</View>
|
<View className={styles.tag}>{item.sale_mode_name}</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.btn_count}>
|
<View className={styles.btn_count}>
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
import { Image, ScrollView, View } from '@tarojs/components'
|
import { Image, ScrollView, View } from '@tarojs/components'
|
||||||
import Popup from '@/components/popup'
|
|
||||||
import classnames from 'classnames'
|
|
||||||
import MCheckbox from '@/components/checkbox'
|
|
||||||
import LoadingCard from '@/components/loadingCard'
|
|
||||||
import InfiniteScroll from '@/components/infiniteScroll'
|
|
||||||
import styles from './index.module.scss'
|
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { alert, goLink } from '@/common/common'
|
import classnames from 'classnames'
|
||||||
import { GetShoppingCartApi, DelShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
|
||||||
import { setParam } from '@/common/system'
|
|
||||||
import { debounce, throttle } from '@/common/util'
|
|
||||||
import Counter from '../counter'
|
import Counter from '../counter'
|
||||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
|
||||||
import useCommonData from '@/use/useCommonData'
|
|
||||||
import BindSalesmanPopup from '../bindSalesmanPopup'
|
import BindSalesmanPopup from '../bindSalesmanPopup'
|
||||||
import LabAndImgShow from '../LabAndImgShow'
|
import LabAndImgShow from '../LabAndImgShow'
|
||||||
import LabAndImg from '../LabAndImg'
|
import LabAndImg from '../LabAndImg'
|
||||||
|
import styles from './index.module.scss'
|
||||||
|
import Popup from '@/components/popup'
|
||||||
|
import MCheckbox from '@/components/checkbox'
|
||||||
|
import LoadingCard from '@/components/loadingCard'
|
||||||
|
import InfiniteScroll from '@/components/infiniteScroll'
|
||||||
|
import { alert, goLink } from '@/common/common'
|
||||||
|
import { DelShoppingCartApi, GetShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
||||||
|
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||||
|
import { setParam } from '@/common/system'
|
||||||
|
import { debounce, throttle } from '@/common/util'
|
||||||
|
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
||||||
|
import useCommonData from '@/use/useCommonData'
|
||||||
|
|
||||||
type param = {
|
interface param {
|
||||||
show?: true | false
|
show?: true | false
|
||||||
onClose?: () => void
|
onClose?: () => void
|
||||||
intoStatus?: 'again' | 'shop'
|
intoStatus?: 'again' | 'shop'
|
||||||
@ -56,7 +56,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
list?.map((item) => {
|
list?.map((item) => {
|
||||||
if (selectIndex == item.sale_mode || selectIndex == -1) {
|
if (selectIndex == item.sale_mode || selectIndex == -1) {
|
||||||
checkboxData[item.id] = true
|
checkboxData[item.id] = true
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
checkboxData[item.id] = false
|
checkboxData[item.id] = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -69,7 +70,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const { fetchData } = GetShoppingCartApi()
|
const { fetchData } = GetShoppingCartApi()
|
||||||
const getShoppingCart = async() => {
|
const getShoppingCart = async() => {
|
||||||
const { data } = await fetchData()
|
const { data } = await fetchData()
|
||||||
let color_list = data.color_list || []
|
const color_list = data.color_list || []
|
||||||
setShopCount(color_list.length)
|
setShopCount(color_list.length)
|
||||||
initList(color_list)
|
initList(color_list)
|
||||||
setList(color_list)
|
setList(color_list)
|
||||||
@ -77,12 +78,12 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化全部数据默认勾选
|
// 初始化全部数据默认勾选
|
||||||
const [checkboxData, setCheckboxData] = useState<{ [index: number]: true | false }>({})
|
const [checkboxData, setCheckboxData] = useState<Record<number, true | false>>({})
|
||||||
const initStatus = useRef(false)
|
const initStatus = useRef(false)
|
||||||
const initList = (color_list) => {
|
const initList = (color_list) => {
|
||||||
if (initStatus.current) {
|
if (initStatus.current) {
|
||||||
color_list?.map((item) => {
|
color_list?.map((item) => {
|
||||||
if (selectIndex == item.sale_mode) checkboxData[item.id] = true
|
if (selectIndex == item.sale_mode) { checkboxData[item.id] = true }
|
||||||
})
|
})
|
||||||
initStatus.current = false
|
initStatus.current = false
|
||||||
}
|
}
|
||||||
@ -94,7 +95,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
if (!show) {
|
if (!show) {
|
||||||
setList([])
|
setList([])
|
||||||
setSelectIndex(default_sale_mode || 0)
|
setSelectIndex(default_sale_mode || 0)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
initStatus.current = true
|
initStatus.current = true
|
||||||
getShoppingCart()
|
getShoppingCart()
|
||||||
@ -117,7 +119,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const [selectStatus, setSelectStatus] = useState(false)
|
const [selectStatus, setSelectStatus] = useState(false)
|
||||||
const selectAll = () => {
|
const selectAll = () => {
|
||||||
list.map((item) => {
|
list.map((item) => {
|
||||||
if (selectIndex == item.sale_mode || selectIndex == -1) checkboxData[item.id] = !selectStatus
|
if (selectIndex == item.sale_mode || selectIndex == -1) { checkboxData[item.id] = !selectStatus }
|
||||||
})
|
})
|
||||||
setSelectStatus(!selectStatus)
|
setSelectStatus(!selectStatus)
|
||||||
setCheckboxData(() => ({ ...checkboxData }))
|
setCheckboxData(() => ({ ...checkboxData }))
|
||||||
@ -127,7 +129,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const selectCallBack = useCallback((item) => {
|
const selectCallBack = useCallback((item) => {
|
||||||
checkboxData[item.id] = true
|
checkboxData[item.id] = true
|
||||||
checkSelect()
|
checkSelect()
|
||||||
setCheckboxData((e) => ({ ...e, ...checkboxData }))
|
setCheckboxData(e => ({ ...e, ...checkboxData }))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
// checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||||
@ -137,7 +139,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
list?.map((item) => {
|
list?.map((item) => {
|
||||||
if (selectIndex == -1 || selectIndex == item.sale_mode) {
|
if (selectIndex == -1 || selectIndex == item.sale_mode) {
|
||||||
list_count++
|
list_count++
|
||||||
if (checkboxData[item.id]) select_count++
|
if (checkboxData[item.id]) { select_count++ }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setSelectStatus(select_count == list_count)
|
setSelectStatus(select_count == list_count)
|
||||||
@ -147,7 +149,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const colseCallBack = useCallback((item) => {
|
const colseCallBack = useCallback((item) => {
|
||||||
checkboxData[item.id] = false
|
checkboxData[item.id] = false
|
||||||
checkSelect()
|
checkSelect()
|
||||||
setCheckboxData((e) => ({ ...e, ...checkboxData }))
|
setCheckboxData(e => ({ ...e, ...checkboxData }))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// popup关闭
|
// popup关闭
|
||||||
@ -160,10 +162,10 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
||||||
const delSelect = () => {
|
const delSelect = () => {
|
||||||
getSelectId()
|
getSelectId()
|
||||||
if (selectIds.current.length <= 0) return alert.none('请选择要删除的面料!')
|
if (selectIds.current.length <= 0) { return alert.none('请选择要删除的面料!') }
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
content: '删除所选商品?',
|
content: '删除所选商品?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
const res = await delShopFetchData({ id: selectIds.current })
|
const res = await delShopFetchData({ id: selectIds.current })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
@ -172,13 +174,15 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
title: '成功',
|
title: '成功',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -214,7 +218,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
// 预估金额和总条数
|
// 预估金额和总条数
|
||||||
const estimatePrice = useMemo(() => {
|
const estimatePrice = useMemo(() => {
|
||||||
let estimate_amount = 0
|
let estimate_amount = 0
|
||||||
let product_list = new Set() //面料
|
const product_list = new Set() // 面料
|
||||||
let color_count = 0 // 颜色数量
|
let color_count = 0 // 颜色数量
|
||||||
let all_count = 0 // 总数量
|
let all_count = 0 // 总数量
|
||||||
list.map((item) => {
|
list.map((item) => {
|
||||||
@ -225,7 +229,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
all_count += item.sale_mode == 0 ? item.roll : item.length
|
all_count += item.sale_mode == 0 ? item.roll : item.length
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let all_count_text = selectIndex == 0 ? all_count + ' 条' : all_count / 100 + ' 米'
|
const all_count_text = selectIndex == 0 ? `${all_count} 条` : `${all_count / 100} 米`
|
||||||
return {
|
return {
|
||||||
price: Number(formatPriceDiv(estimate_amount)).toFixed(2),
|
price: Number(formatPriceDiv(estimate_amount)).toFixed(2),
|
||||||
countText: `已选 ${product_list.size} 种面料,${color_count} 个颜色,共 ${all_count_text}`,
|
countText: `已选 ${product_list.size} 种面料,${color_count} 个颜色,共 ${all_count_text}`,
|
||||||
@ -237,9 +241,9 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
||||||
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
||||||
const orderDetail = throttle(async() => {
|
const orderDetail = throttle(async() => {
|
||||||
let res = await useFetchData()
|
const res = await useFetchData()
|
||||||
if (res.data.order_access_status !== 3) {
|
if (res.data.order_access_status !== 3) {
|
||||||
if (res.data.order_access_status == 1) applyOrderAccessFetchData()
|
if (res.data.order_access_status == 1) { applyOrderAccessFetchData() }
|
||||||
setShowBindSalesman(() => true)
|
setShowBindSalesman(() => true)
|
||||||
onClose?.()
|
onClose?.()
|
||||||
return false
|
return false
|
||||||
@ -247,13 +251,15 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
getSelectId()
|
getSelectId()
|
||||||
if (selectIds.current.length == 0) {
|
if (selectIds.current.length == 0) {
|
||||||
alert.error('请选择面料')
|
alert.error('请选择面料')
|
||||||
} else {
|
}
|
||||||
let ids = selectIds.current.join('-')
|
else {
|
||||||
|
const ids = selectIds.current.join('-')
|
||||||
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
||||||
closePopup()
|
closePopup()
|
||||||
if (intoStatus == 'again') {
|
if (intoStatus == 'again') {
|
||||||
goLink('/pages/order/comfirm', {}, 'redirectTo')
|
goLink('/pages/order/comfirm', {}, 'redirectTo')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
goLink('/pages/order/comfirm')
|
goLink('/pages/order/comfirm')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,10 +269,10 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
||||||
const [UpdateShoppingCartLoading, setUpdateShoppingCartLoading] = useState(false)
|
const [UpdateShoppingCartLoading, setUpdateShoppingCartLoading] = useState(false)
|
||||||
const getInputValue = debounce(async(num, item) => {
|
const getInputValue = debounce(async(num, item) => {
|
||||||
let roll = item.sale_mode == 0 ? parseFloat(num) : 0
|
const roll = item.sale_mode == 0 ? parseFloat(num) : 0
|
||||||
let length = item.sale_mode != 0 ? parseFloat(num) * 100 : 0
|
const length = item.sale_mode != 0 ? parseFloat(num) * 100 : 0
|
||||||
setUpdateShoppingCartLoading(() => true)
|
setUpdateShoppingCartLoading(() => true)
|
||||||
let res = await fetchDataUpdateShoppingCart({ id: item.id, roll, length })
|
const res = await fetchDataUpdateShoppingCart({ id: item.id, roll, length })
|
||||||
setUpdateShoppingCartLoading(() => false)
|
setUpdateShoppingCartLoading(() => false)
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
getShoppingCart()
|
getShoppingCart()
|
||||||
@ -305,7 +311,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
<View
|
<View
|
||||||
key={item.value}
|
key={item.value}
|
||||||
onClick={() => selectProduct(item.value)}
|
onClick={() => selectProduct(item.value)}
|
||||||
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}>
|
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}
|
||||||
|
>
|
||||||
{item.title}
|
{item.title}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
@ -320,7 +327,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
key={item}
|
key={item}
|
||||||
className={classnames(styles.product_item, selectIndex != -1 && selectIndex != item.sale_mode && styles.no_product_item_select)}>
|
className={classnames(styles.product_item, selectIndex != -1 && selectIndex != item.sale_mode && styles.no_product_item_select)}
|
||||||
|
>
|
||||||
<View className={styles.checkbox}>
|
<View className={styles.checkbox}>
|
||||||
<MCheckbox
|
<MCheckbox
|
||||||
disabled={selectIndex != -1 && selectIndex != item.sale_mode}
|
disabled={selectIndex != -1 && selectIndex != item.sale_mode}
|
||||||
@ -347,16 +355,16 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
</View>
|
</View>
|
||||||
<View className={styles.count}>
|
<View className={styles.count}>
|
||||||
<View className={styles.des}>
|
<View className={styles.des}>
|
||||||
<View className={styles.subtitle}>{item.product_color_code + ' ' + item.product_color_name}</View>
|
<View className={styles.subtitle}>{`${item.product_color_code} ${item.product_color_name}`}</View>
|
||||||
<View className={styles.tag}>{item.sale_mode_name}</View>
|
<View className={styles.tag}>{item.sale_mode_name}</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.btn_count}>
|
<View className={styles.btn_count}>
|
||||||
<Counter
|
<Counter
|
||||||
onBlue={(e) => getInputValue(e, item)}
|
onBlue={e => getInputValue(e, item)}
|
||||||
defaultNum={formatCount(item)}
|
defaultNum={formatCount(item)}
|
||||||
step={selectList[selectIndex].step}
|
step={selectList[selectIndex].step}
|
||||||
digits={selectList[selectIndex].digits}
|
digits={selectList[selectIndex].digits}
|
||||||
onClickBtn={(e) => getInputValue(e, item)}
|
onClickBtn={e => getInputValue(e, item)}
|
||||||
unit={formatUnit(item)}
|
unit={formatUnit(item)}
|
||||||
minNum={selectList[selectIndex].minNum}
|
minNum={selectList[selectIndex].minNum}
|
||||||
maxNum={selectList[selectIndex].maxNum}
|
maxNum={selectList[selectIndex].maxNum}
|
||||||
|
|||||||
@ -1,33 +1,33 @@
|
|||||||
import { Image, ScrollView, View } from '@tarojs/components'
|
import { Image, ScrollView, View } from '@tarojs/components'
|
||||||
import Popup from '@/components/popup'
|
|
||||||
import classnames from 'classnames'
|
|
||||||
import MCheckbox from '@/components/checkbox'
|
|
||||||
import LoadingCard from '@/components/loadingCard'
|
|
||||||
import InfiniteScroll from '@/components/infiniteScroll'
|
|
||||||
import styles from './index.module.scss'
|
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState, useTransition } from 'react'
|
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { alert, goLink } from '@/common/common'
|
import classnames from 'classnames'
|
||||||
import { GetShoppingCartApi, DelShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
import { useCallback, useEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
|
||||||
import { setParam } from '@/common/system'
|
|
||||||
import { debounce, throttle } from '@/common/util'
|
|
||||||
import Counter from '../counter'
|
import Counter from '../counter'
|
||||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
|
||||||
import useCommonData from '@/use/useCommonData'
|
|
||||||
import BindSalesmanPopup from '../bindSalesmanPopup'
|
import BindSalesmanPopup from '../bindSalesmanPopup'
|
||||||
import LabAndImgShow from '../LabAndImgShow'
|
import LabAndImgShow from '../LabAndImgShow'
|
||||||
import LabAndImg from '../LabAndImg'
|
import LabAndImg from '../LabAndImg'
|
||||||
|
import styles from './index.module.scss'
|
||||||
import ProductItem from './components/productItem'
|
import ProductItem from './components/productItem'
|
||||||
import { saleModeType } from '@/common/enum'
|
import Popup from '@/components/popup'
|
||||||
|
import MCheckbox from '@/components/checkbox'
|
||||||
|
import LoadingCard from '@/components/loadingCard'
|
||||||
|
import InfiniteScroll from '@/components/infiniteScroll'
|
||||||
|
import { alert, goLink } from '@/common/common'
|
||||||
|
import { DelShoppingCartApi, GetShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
||||||
|
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||||
|
import { setParam } from '@/common/system'
|
||||||
|
import { debounce, throttle } from '@/common/util'
|
||||||
|
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
||||||
|
import useCommonData from '@/use/useCommonData'
|
||||||
|
import type { saleModeType } from '@/common/enum'
|
||||||
|
|
||||||
type param = {
|
interface param {
|
||||||
show?: true | false
|
show?: true | false
|
||||||
onClose?: () => void
|
onClose?: () => void
|
||||||
intoStatus?: 'again' | 'shop'
|
intoStatus?: 'again' | 'shop'
|
||||||
default_sale_mode?: saleModeType // 面料类型(0:大货, 1:剪版,2:散剪
|
default_sale_mode?: saleModeType // 面料类型(0:大货, 1:剪版,2:散剪
|
||||||
}
|
}
|
||||||
type modelClassType = {
|
interface modelClassType {
|
||||||
value: saleModeType
|
value: saleModeType
|
||||||
title: string
|
title: string
|
||||||
unit: string
|
unit: string
|
||||||
@ -69,12 +69,12 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const { getShopCount } = useCommonData()
|
const { getShopCount } = useCommonData()
|
||||||
|
|
||||||
// 获取所有数据数据
|
// 获取所有数据数据
|
||||||
const [list, setList] = useState<{ [id: number]: any }>({})
|
const [list, setList] = useState<Record<number, any>>({})
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const { fetchData: getShoppingFetchData } = GetShoppingCartApi()
|
const { fetchData: getShoppingFetchData } = GetShoppingCartApi()
|
||||||
const getShoppingCart = async() => {
|
const getShoppingCart = async() => {
|
||||||
const { data } = await getShoppingFetchData()
|
const { data } = await getShoppingFetchData()
|
||||||
let color_list = data.color_list || []
|
const color_list = data.color_list || []
|
||||||
initList(color_list)
|
initList(color_list)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
@ -83,8 +83,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const getShoppingCartInfo = async(item) => {
|
const getShoppingCartInfo = async(item) => {
|
||||||
const res = await getShoppingFetchData({ id: item.id })
|
const res = await getShoppingFetchData({ id: item.id })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
let info = res.data.color_list[0]
|
const info = res.data.color_list[0]
|
||||||
let newInfo = {
|
const newInfo = {
|
||||||
...item,
|
...item,
|
||||||
estimate_amount: info.estimate_amount,
|
estimate_amount: info.estimate_amount,
|
||||||
estimate_weight: info.estimate_weight,
|
estimate_weight: info.estimate_weight,
|
||||||
@ -95,7 +95,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
sale_price: info.sale_price,
|
sale_price: info.sale_price,
|
||||||
standard_price: info.standard_price,
|
standard_price: info.standard_price,
|
||||||
}
|
}
|
||||||
setList((e) => ({ ...e, [item['id']]: newInfo }))
|
setList(e => ({ ...e, [item.id]: newInfo }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
|
|
||||||
// 初始化全部数据默认勾选
|
// 初始化全部数据默认勾选
|
||||||
const initList = (color_list) => {
|
const initList = (color_list) => {
|
||||||
let obj = {}
|
const obj = {}
|
||||||
color_list?.map((item) => {
|
color_list?.map((item) => {
|
||||||
item.selected = selectIndex == item.sale_mode
|
item.selected = selectIndex == item.sale_mode
|
||||||
const { unit, eunit, step, digits, minNum, maxNum } = selectList[item.sale_mode]
|
const { unit, eunit, step, digits, minNum, maxNum } = selectList[item.sale_mode]
|
||||||
@ -120,10 +120,11 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
Object.values(list)?.map((item) => {
|
Object.values(list)?.map((item) => {
|
||||||
if (selectIndex == item.sale_mode) {
|
if (selectIndex == item.sale_mode) {
|
||||||
item.selected = true
|
item.selected = true
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
item.selected = false
|
item.selected = false
|
||||||
}
|
}
|
||||||
list[item['id']] = { ...item }
|
list[item.id] = { ...item }
|
||||||
})
|
})
|
||||||
setList(() => ({ ...list }))
|
setList(() => ({ ...list }))
|
||||||
}
|
}
|
||||||
@ -133,7 +134,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
if (!show) {
|
if (!show) {
|
||||||
setList({})
|
setList({})
|
||||||
setSelectIndex(default_sale_mode || 0)
|
setSelectIndex(default_sale_mode || 0)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
getShoppingCart()
|
getShoppingCart()
|
||||||
setShowBindSalesman(() => false)
|
setShowBindSalesman(() => false)
|
||||||
@ -151,7 +153,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
Object.values(list)?.map((item) => {
|
Object.values(list)?.map((item) => {
|
||||||
if (selectIndex == item.sale_mode) {
|
if (selectIndex == item.sale_mode) {
|
||||||
item.selected = !selectStatus
|
item.selected = !selectStatus
|
||||||
list[item['id']] = { ...item }
|
list[item.id] = { ...item }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setList(() => ({ ...list }))
|
setList(() => ({ ...list }))
|
||||||
@ -165,7 +167,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
Object.values(list)?.map((item) => {
|
Object.values(list)?.map((item) => {
|
||||||
if (selectIndex == item.sale_mode) {
|
if (selectIndex == item.sale_mode) {
|
||||||
list_count++
|
list_count++
|
||||||
if (item.selected) select_count++
|
if (item.selected) { select_count++ }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setSelectStatus(select_count == list_count)
|
setSelectStatus(select_count == list_count)
|
||||||
@ -178,7 +180,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
|
|
||||||
// 修改选择
|
// 修改选择
|
||||||
const onChangeSelect = useCallback((item) => {
|
const onChangeSelect = useCallback((item) => {
|
||||||
setList((e) => ({ ...e, [item.id]: { ...item } }))
|
setList(e => ({ ...e, [item.id]: { ...item } }))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// popup关闭
|
// popup关闭
|
||||||
@ -191,10 +193,10 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
||||||
const delSelect = () => {
|
const delSelect = () => {
|
||||||
getSelectId()
|
getSelectId()
|
||||||
if (selectIds.current.length <= 0) return alert.none('请选择要删除的面料!')
|
if (selectIds.current.length <= 0) { return alert.none('请选择要删除的面料!') }
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
content: '删除所选商品?',
|
content: '删除所选商品?',
|
||||||
success: async function (res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
const res = await delShopFetchData({ id: selectIds.current })
|
const res = await delShopFetchData({ id: selectIds.current })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
@ -204,13 +206,15 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
title: '成功',
|
title: '成功',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (res.cancel) {
|
}
|
||||||
|
else if (res.cancel) {
|
||||||
console.log('用户点击取消')
|
console.log('用户点击取消')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -231,7 +235,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
// 预估金额和总条数
|
// 预估金额和总条数
|
||||||
const estimatePrice = useMemo(() => {
|
const estimatePrice = useMemo(() => {
|
||||||
let estimate_amount = 0
|
let estimate_amount = 0
|
||||||
let product_list = new Set() //面料
|
const product_list = new Set() // 面料
|
||||||
let color_count = 0 // 颜色数量
|
let color_count = 0 // 颜色数量
|
||||||
let all_count = 0 // 总数量
|
let all_count = 0 // 总数量
|
||||||
Object.values(list)?.map((item) => {
|
Object.values(list)?.map((item) => {
|
||||||
@ -242,7 +246,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
all_count += item.sale_mode == 0 ? parseFloat(item.roll) : parseFloat(item.length)
|
all_count += item.sale_mode == 0 ? parseFloat(item.roll) : parseFloat(item.length)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let all_count_text = selectIndex == 0 ? all_count + ' 条' : all_count / 100 + ' 米'
|
const all_count_text = selectIndex == 0 ? `${all_count} 条` : `${all_count / 100} 米`
|
||||||
console.log('text::', list)
|
console.log('text::', list)
|
||||||
return {
|
return {
|
||||||
price: Number(formatPriceDiv(estimate_amount)).toFixed(2),
|
price: Number(formatPriceDiv(estimate_amount)).toFixed(2),
|
||||||
@ -255,9 +259,9 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
||||||
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
||||||
const orderDetail = throttle(async() => {
|
const orderDetail = throttle(async() => {
|
||||||
let res = await useFetchData()
|
const res = await useFetchData()
|
||||||
if (res.data.order_access_status !== 3) {
|
if (res.data.order_access_status !== 3) {
|
||||||
if (res.data.order_access_status == 1) applyOrderAccessFetchData()
|
if (res.data.order_access_status == 1) { applyOrderAccessFetchData() }
|
||||||
setShowBindSalesman(() => true)
|
setShowBindSalesman(() => true)
|
||||||
onClose?.()
|
onClose?.()
|
||||||
return false
|
return false
|
||||||
@ -265,13 +269,15 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
getSelectId()
|
getSelectId()
|
||||||
if (selectIds.current.length == 0) {
|
if (selectIds.current.length == 0) {
|
||||||
alert.error('请选择面料')
|
alert.error('请选择面料')
|
||||||
} else {
|
}
|
||||||
let ids = selectIds.current.join('-')
|
else {
|
||||||
|
const ids = selectIds.current.join('-')
|
||||||
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
||||||
closePopup()
|
closePopup()
|
||||||
if (intoStatus == 'again') {
|
if (intoStatus == 'again') {
|
||||||
goLink('/pages/order/comfirm', null, 'redirectTo')
|
goLink('/pages/order/comfirm', null, 'redirectTo')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
goLink('/pages/order/comfirm')
|
goLink('/pages/order/comfirm')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,12 +286,13 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
// 计数组件-当后端修改完成才修改前端显示
|
// 计数组件-当后端修改完成才修改前端显示
|
||||||
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
||||||
const getInputValue = debounce(async(item) => {
|
const getInputValue = debounce(async(item) => {
|
||||||
let res = await fetchDataUpdateShoppingCart({ id: item.id, roll: item.roll, length: item.length })
|
const res = await fetchDataUpdateShoppingCart({ id: item.id, roll: item.roll, length: item.length })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
console.log('item修改::', item)
|
console.log('item修改::', item)
|
||||||
getShoppingCartInfo(item)
|
getShoppingCartInfo(item)
|
||||||
} else {
|
}
|
||||||
setList((e) => ({ ...e }))
|
else {
|
||||||
|
setList(e => ({ ...e }))
|
||||||
}
|
}
|
||||||
}, 300)
|
}, 300)
|
||||||
|
|
||||||
@ -326,7 +333,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
|||||||
<View
|
<View
|
||||||
key={item.value}
|
key={item.value}
|
||||||
onClick={() => selectProduct(item.value)}
|
onClick={() => selectProduct(item.value)}
|
||||||
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}>
|
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}
|
||||||
|
>
|
||||||
{item.title}
|
{item.title}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
import { ScrollView, View } from '@tarojs/components'
|
import { ScrollView, View } from '@tarojs/components'
|
||||||
import React, { memo, ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
|
||||||
import styles from './index.module.scss'
|
|
||||||
import classnames from 'classnames'
|
|
||||||
import Taro, { getCurrentInstance, useReady, useRouter } from '@tarojs/taro'
|
import Taro, { getCurrentInstance, useReady, useRouter } from '@tarojs/taro'
|
||||||
import InfiniteScroll, { StatusParam } from '../infiniteScroll'
|
import type { ReactNode } from 'react'
|
||||||
|
import React, { memo, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||||
|
import classnames from 'classnames'
|
||||||
|
import type { StatusParam } from '../infiniteScroll'
|
||||||
|
import InfiniteScroll from '../infiniteScroll'
|
||||||
import LoadingCard from '../loadingCard'
|
import LoadingCard from '../loadingCard'
|
||||||
|
import styles from './index.module.scss'
|
||||||
import ProductClass from '@/pages/index/components/productClass'
|
import ProductClass from '@/pages/index/components/productClass'
|
||||||
import { GetClassList } from '@/api/material'
|
import { GetClassList } from '@/api/material'
|
||||||
|
|
||||||
type Params = {
|
interface Params {
|
||||||
list?: any[]
|
list?: any[]
|
||||||
defaultValue?: number | string
|
defaultValue?: number | string
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
@ -38,7 +40,7 @@ export default memo(
|
|||||||
statusMore = 0,
|
statusMore = 0,
|
||||||
selectClass,
|
selectClass,
|
||||||
}: Params) => {
|
}: Params) => {
|
||||||
let num_half = useRef(0)
|
const num_half = useRef(0)
|
||||||
|
|
||||||
const [selected, setSelected] = useState(defaultValue)
|
const [selected, setSelected] = useState(defaultValue)
|
||||||
const [tabId, setTabId] = useState('')
|
const [tabId, setTabId] = useState('')
|
||||||
@ -66,24 +68,25 @@ export default memo(
|
|||||||
|
|
||||||
const computeSelectTab = (index) => {
|
const computeSelectTab = (index) => {
|
||||||
if (index + 1 > num_half.current) {
|
if (index + 1 > num_half.current) {
|
||||||
let num = index + 1 - num_half.current
|
const num = index + 1 - num_half.current
|
||||||
setTabId(list[num].id.toString())
|
setTabId(list[num].id.toString())
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setTabId(list[0].id.toString())
|
setTabId(list[0].id.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Taro.nextTick(() => {
|
Taro.nextTick(() => {
|
||||||
let query = Taro.createSelectorQuery()
|
const query = Taro.createSelectorQuery()
|
||||||
query
|
query
|
||||||
.select('.side_bar_select')
|
.select('.side_bar_select')
|
||||||
.boundingClientRect((rect) => {
|
.boundingClientRect((rect) => {
|
||||||
console.log('rect::', rect)
|
console.log('rect::', rect)
|
||||||
let clientHeight = rect.height
|
const clientHeight = rect.height
|
||||||
let clientWidth = rect.width
|
const clientWidth = rect.width
|
||||||
let ratio = 750 / clientWidth
|
const ratio = 750 / clientWidth
|
||||||
let height = clientHeight * ratio
|
const height = clientHeight * ratio
|
||||||
num_half.current = Math.ceil(height / 2 / heightItem)
|
num_half.current = Math.ceil(height / 2 / heightItem)
|
||||||
console.log('num_half::', num_half)
|
console.log('num_half::', num_half)
|
||||||
init()
|
init()
|
||||||
@ -98,7 +101,7 @@ export default memo(
|
|||||||
const [classId, setClassId] = useState(-1)
|
const [classId, setClassId] = useState(-1)
|
||||||
const { fetchData } = GetClassList()
|
const { fetchData } = GetClassList()
|
||||||
const getClassData = async(id) => {
|
const getClassData = async(id) => {
|
||||||
let res = await fetchData({ id })
|
const res = await fetchData({ id })
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
if (res.data?.list.length > 0) {
|
if (res.data?.list.length > 0) {
|
||||||
res.data.list = [{ id: -1, name: '全部' }, ...res.data.list]
|
res.data.list = [{ id: -1, name: '全部' }, ...res.data.list]
|
||||||
@ -107,7 +110,7 @@ export default memo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selected) getClassData(selected)
|
if (selected) { getClassData(selected) }
|
||||||
}, [selected])
|
}, [selected])
|
||||||
|
|
||||||
const getSelectClass = (id) => {
|
const getSelectClass = (id) => {
|
||||||
@ -118,13 +121,14 @@ export default memo(
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View className={classnames(styles.sideBar_main, 'side_bar_select')}>
|
<View className={classnames(styles.sideBar_main, 'side_bar_select')}>
|
||||||
<ScrollView scrollWithAnimation={true} style={{ height }} className={styles.sideBar_select} scrollY scrollIntoView={`tab_${tabId}`}>
|
<ScrollView scrollWithAnimation style={{ height }} className={styles.sideBar_select} scrollY scrollIntoView={`tab_${tabId}`}>
|
||||||
{list?.map((item, index) => {
|
{list?.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<View className={styles.sideBar_select_title} id={`tab_${item.id}`} key={item.id} style={{ height: `${heightItem}rpx` }}>
|
<View className={styles.sideBar_select_title} id={`tab_${item.id}`} key={item.id} style={{ height: `${heightItem}rpx` }}>
|
||||||
<View
|
<View
|
||||||
className={classnames(styles.sideBar_select_title_item, { [styles.sideBar_select_title_select]: selected == item.id })}
|
className={classnames(styles.sideBar_select_title_item, { [styles.sideBar_select_title_select]: selected == item.id })}
|
||||||
onClick={() => clickEvent({ item, index })}>
|
onClick={() => clickEvent({ item, index })}
|
||||||
|
>
|
||||||
<View className={styles.title_con}>{item.name}</View>
|
<View className={styles.title_con}>{item.name}</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@ -134,7 +138,7 @@ export default memo(
|
|||||||
<View className={styles.sideBar_con} style={{ paddingTop: classList.length > 0 ? '90rpx' : '20rpx' }}>
|
<View className={styles.sideBar_con} style={{ paddingTop: classList.length > 0 ? '90rpx' : '20rpx' }}>
|
||||||
{classList.length > 0 && (
|
{classList.length > 0 && (
|
||||||
<View className={styles.product_class} style={{ height: openClass ? '100%' : '' }}>
|
<View className={styles.product_class} style={{ height: openClass ? '100%' : '' }}>
|
||||||
<ProductClass list={classList} open={openClass} onOpenClick={(val) => setOpenClass(val)} onSelect={getSelectClass} defaultSelectId={classId} />
|
<ProductClass list={classList} open={openClass} onOpenClick={val => setOpenClass(val)} onSelect={getSelectClass} defaultSelectId={classId} />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
<InfiniteScroll
|
<InfiniteScroll
|
||||||
@ -142,8 +146,9 @@ export default memo(
|
|||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
selfonScrollToLower={() => selfOnScrolltolower?.()}
|
selfonScrollToLower={() => selfOnScrolltolower?.()}
|
||||||
refresherTriggered={refresherTriggered}
|
refresherTriggered={refresherTriggered}
|
||||||
refresherEnabled={true}
|
refresherEnabled
|
||||||
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
|
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { View } from "@tarojs/components"
|
import { View } from '@tarojs/components'
|
||||||
import classnames from "classnames";
|
import classnames from 'classnames'
|
||||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
type params = {
|
interface params {
|
||||||
status?: 'top'|'bottom'|'none',
|
status?: 'top'|'bottom'|'none'
|
||||||
onChange?: (val:{status:string, value:string}) => void,
|
onChange?: (val: { status: string; value: string }) => void
|
||||||
sortValue?: {desc: string, asc: string} //排序规则,后端制定
|
sortValue?: { desc: string; asc: string } // 排序规则,后端制定
|
||||||
}
|
}
|
||||||
type sortParam = 'none'|'top'|'bottom'
|
type sortParam = 'none'|'top'|'bottom'
|
||||||
export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref) => {
|
export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref) => {
|
||||||
@ -14,7 +14,7 @@ export default forwardRef(({status = 'none', onChange, sortValue}: params,ref) =
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSortStatus(() => status)
|
setSortStatus(() => status)
|
||||||
}, [status])
|
}, [status])
|
||||||
const changeSort = ():{status:sortParam, value:string} => {
|
const changeSort = (): { status: sortParam; value: string } => {
|
||||||
let status: sortParam = 'none'
|
let status: sortParam = 'none'
|
||||||
let value = ''
|
let value = ''
|
||||||
if (sortStatus == 'none') {
|
if (sortStatus == 'none') {
|
||||||
@ -25,13 +25,13 @@ export default forwardRef(({status = 'none', onChange, sortValue}: params,ref) =
|
|||||||
status = 'bottom'
|
status = 'bottom'
|
||||||
value = sortValue?.desc!
|
value = sortValue?.desc!
|
||||||
}
|
}
|
||||||
if(sortStatus == 'bottom') status = 'none'
|
if (sortStatus == 'bottom') { status = 'none' }
|
||||||
setSortStatus(() => status)
|
setSortStatus(() => status)
|
||||||
onChange?.({ status, value })
|
onChange?.({ status, value })
|
||||||
return { status, value }
|
return { status, value }
|
||||||
}
|
}
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
changeSort
|
changeSort,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,30 +1,29 @@
|
|||||||
import { ScrollView, View } from "@tarojs/components";
|
import { ScrollView, View } from '@tarojs/components'
|
||||||
import { memo, useState, ReactNode, useEffect } from "react";
|
import type { ReactNode } from 'react'
|
||||||
import classnames from "classnames";
|
import { memo, useEffect, useState } from 'react'
|
||||||
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
|
interface ListProps {
|
||||||
type ListProps = {
|
title: string
|
||||||
title: string,
|
|
||||||
value: number
|
value: number
|
||||||
}
|
}
|
||||||
|
|
||||||
type Params = {
|
interface Params {
|
||||||
list?: ListProps[],
|
list?: ListProps[]
|
||||||
defaultValue?: number|string,
|
defaultValue?: number|string
|
||||||
children?: ReactNode,
|
children?: ReactNode
|
||||||
tabsOnClick?: (ListProps) => void,
|
tabsOnClick?: (ListProps) => void
|
||||||
style?:Object,
|
style?: Object
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(({ list = [], defaultValue = 0, tabsOnClick, style = {} }: Params) => {
|
export default memo(({ list = [], defaultValue = 0, tabsOnClick, style = {} }: Params) => {
|
||||||
|
|
||||||
const [selected, setSelected] = useState(defaultValue)
|
const [selected, setSelected] = useState(defaultValue)
|
||||||
const [tabId, setTabId] = useState('')
|
const [tabId, setTabId] = useState('')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const index = list?.findIndex(item => {
|
const index = list?.findIndex((item) => {
|
||||||
return item.value == defaultValue
|
return item.value == defaultValue
|
||||||
})
|
})
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
@ -33,7 +32,7 @@ export default memo(({list = [], defaultValue = 0, tabsOnClick, style={}}: Param
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const clickEvent = ({item, index}: {item:ListProps, index:number}) => {
|
const clickEvent = ({ item, index }: { item: ListProps; index: number }) => {
|
||||||
setSelected(item.value)
|
setSelected(item.value)
|
||||||
tabsOnClick?.(item)
|
tabsOnClick?.(item)
|
||||||
const num = index > 0 ? (index - 1) : 0
|
const num = index > 0 ? (index - 1) : 0
|
||||||
@ -42,7 +41,7 @@ export default memo(({list = [], defaultValue = 0, tabsOnClick, style={}}: Param
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View className={styles.tabs_main} id="tabs_main_ref">
|
<View className={styles.tabs_main} id="tabs_main_ref">
|
||||||
<ScrollView className={styles.tabs_scroll} scrollX scrollWithAnimation={true} scrollIntoView={`tabs_${tabId}`}>
|
<ScrollView className={styles.tabs_scroll} scrollX scrollWithAnimation scrollIntoView={`tabs_${tabId}`}>
|
||||||
<View className={styles.tabs_scroll}>
|
<View className={styles.tabs_scroll}>
|
||||||
{
|
{
|
||||||
list.map((item, index) => {
|
list.map((item, index) => {
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import {Textarea, View } from "@tarojs/components";
|
import { Textarea, View } from '@tarojs/components'
|
||||||
import { memo, useEffect, useMemo, useState } from "react";
|
import { memo, useEffect, useMemo, useState } from 'react'
|
||||||
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import classnames from "classnames";
|
|
||||||
|
|
||||||
// 其他说明
|
// 其他说明
|
||||||
type Param = {
|
interface Param {
|
||||||
title?: string,
|
title?: string
|
||||||
onChange?: (val: string) => void,
|
onChange?: (val: string) => void
|
||||||
placeholder?: string,
|
placeholder?: string
|
||||||
defaultValue?: string,
|
defaultValue?: string
|
||||||
onlyRead?: false|true
|
onlyRead?: false|true
|
||||||
}
|
}
|
||||||
export default memo(({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
|
export default memo(({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
|
||||||
@ -16,7 +16,7 @@ export default memo(({onChange, title = '', placeholder = '请输入', defaultVa
|
|||||||
number: 0,
|
number: 0,
|
||||||
value: '',
|
value: '',
|
||||||
count: 200,
|
count: 200,
|
||||||
show: false
|
show: false,
|
||||||
})
|
})
|
||||||
const getDesc = (value = '') => {
|
const getDesc = (value = '') => {
|
||||||
let res = value
|
let res = value
|
||||||
@ -32,16 +32,16 @@ export default memo(({onChange, title = '', placeholder = '请输入', defaultVa
|
|||||||
}, [defaultValue])
|
}, [defaultValue])
|
||||||
|
|
||||||
const toggleShowRealTextarea = (show) => {
|
const toggleShowRealTextarea = (show) => {
|
||||||
setDescData({...descData, show:show})
|
setDescData({ ...descData, show })
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<View className={styles.other_desc}>
|
<View className={styles.other_desc}>
|
||||||
<View className={styles.title}>{title}</View>
|
<View className={styles.title}>{title}</View>
|
||||||
<View className={styles.textarea}>
|
<View className={styles.textarea}>
|
||||||
{(descData.show && !onlyRead)&&<Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={(e) => getDesc(e.detail.value)}></Textarea>||
|
{(descData.show && !onlyRead) && <Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={e => getDesc(e.detail.value)}></Textarea>
|
||||||
<View className={classnames(styles.textarea_con_pretend, descData.value&&styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value||placeholder}</View>
|
|| <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || placeholder}</View>
|
||||||
}
|
}
|
||||||
<View className={styles.descDataNum}>{descData.number +'/'+ descData.count}</View>
|
<View className={styles.descDataNum}>{`${descData.number}/${descData.count}`}</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import Taro, { FC } from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { memo, useEffect, useState } from 'react'
|
|
||||||
import useUploadCDNImg from '@/use/useUploadImage'
|
|
||||||
import { Image, Text, View } from '@tarojs/components'
|
import { Image, Text, View } from '@tarojs/components'
|
||||||
import { formatImgUrl } from '@/common/fotmat'
|
import { FC, memo, useEffect, useState } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import useUploadCDNImg from '@/use/useUploadImage'
|
||||||
|
import { formatImgUrl } from '@/common/fotmat'
|
||||||
|
|
||||||
// 图片列表
|
// 图片列表
|
||||||
type ImageParam = {
|
interface ImageParam {
|
||||||
onChange?: (val: string[]) => void
|
onChange?: (val: string[]) => void
|
||||||
defaultList?: string[]
|
defaultList?: string[]
|
||||||
onlyRead?: false | true
|
onlyRead?: false | true
|
||||||
@ -22,8 +22,8 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
|
|||||||
|
|
||||||
// 上传图片
|
// 上传图片
|
||||||
const uploadImage = async() => {
|
const uploadImage = async() => {
|
||||||
let list: any = await getWxPhoto('after-sale', 5)
|
const list: any = await getWxPhoto('after-sale', 5)
|
||||||
let images: any[] = []
|
const images: any[] = []
|
||||||
list?.map((item) => {
|
list?.map((item) => {
|
||||||
images.push(item.url)
|
images.push(item.url)
|
||||||
})
|
})
|
||||||
@ -41,7 +41,7 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
|
|||||||
|
|
||||||
// 预览图片
|
// 预览图片
|
||||||
const showImage = () => {
|
const showImage = () => {
|
||||||
let list = imageList?.map((item) => {
|
const list = imageList?.map((item) => {
|
||||||
return formatImgUrl(item, '!w800')
|
return formatImgUrl(item, '!w800')
|
||||||
})
|
})
|
||||||
Taro.previewImage({
|
Taro.previewImage({
|
||||||
@ -54,7 +54,7 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
|
|||||||
<View className={styles.image_main}>
|
<View className={styles.image_main}>
|
||||||
{imageList?.map((item, index) => (
|
{imageList?.map((item, index) => (
|
||||||
<View className={styles.ImgItem}>
|
<View className={styles.ImgItem}>
|
||||||
<Image mode='aspectFill' src={formatImgUrl(item)} onClick={showImage}></Image>
|
<Image mode="aspectFill" src={formatImgUrl(item)} onClick={showImage}></Image>
|
||||||
{!onlyRead && <View onClick={() => delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}></View>}
|
{!onlyRead && <View onClick={() => delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}></View>}
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -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 { Button, Input, Text, Textarea, View } from '@tarojs/components'
|
||||||
import Taro, { setNavigationBarTitle, useRouter } from '@tarojs/taro'
|
import Taro, { setNavigationBarTitle, useRouter } from '@tarojs/taro'
|
||||||
import { useEffect, useState } from 'react'
|
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 './index.scss'
|
||||||
import { addressAddApi, addressDetailApi, addressEditApi } from '@/api/addressManager'
|
import { addressAddApi, addressDetailApi, addressEditApi } from '@/api/addressManager'
|
||||||
import useLogin from '@/use/useLogin'
|
import useLogin from '@/use/useLogin'
|
||||||
@ -15,7 +15,8 @@ export default () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (type == 'add') {
|
if (type == 'add') {
|
||||||
setNavigationBarTitle({ title: '新增收货地址' })
|
setNavigationBarTitle({ title: '新增收货地址' })
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
initalFormData()
|
initalFormData()
|
||||||
setNavigationBarTitle({ title: '编辑收货地址' })
|
setNavigationBarTitle({ title: '编辑收货地址' })
|
||||||
}
|
}
|
||||||
@ -31,7 +32,7 @@ export default () => {
|
|||||||
setFormData({
|
setFormData({
|
||||||
name: detail.data.name,
|
name: detail.data.name,
|
||||||
phone: detail.data.phone,
|
phone: detail.data.phone,
|
||||||
site: siteArray.map((item) => item.name).join(' '),
|
site: siteArray.map(item => item.name).join(' '),
|
||||||
siteArray: siteArray as any,
|
siteArray: siteArray as any,
|
||||||
district_id: detail.data.district_id,
|
district_id: detail.data.district_id,
|
||||||
address_detail: detail.data.address_detail,
|
address_detail: detail.data.address_detail,
|
||||||
@ -82,8 +83,8 @@ export default () => {
|
|||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
retrieval(formData, rules)
|
retrieval(formData, rules)
|
||||||
.then(async() => {
|
.then(async() => {
|
||||||
const result =
|
const result
|
||||||
type == 'add'
|
= type == 'add'
|
||||||
? await fetchData({
|
? await fetchData({
|
||||||
name: formData.name,
|
name: formData.name,
|
||||||
phone: formData.phone,
|
phone: formData.phone,
|
||||||
@ -103,7 +104,8 @@ export default () => {
|
|||||||
Taro.eventCenter.trigger('addressList:refresh')
|
Taro.eventCenter.trigger('addressList:refresh')
|
||||||
Taro.navigateBack()
|
Taro.navigateBack()
|
||||||
alert.success('保存成功')
|
alert.success('保存成功')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.error(result.msg)
|
alert.error(result.msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -126,51 +128,54 @@ export default () => {
|
|||||||
setFormData({
|
setFormData({
|
||||||
...formData,
|
...formData,
|
||||||
siteArray: ev,
|
siteArray: ev,
|
||||||
site: ev.map((item) => item.name + ' '),
|
site: ev.map(item => `${item.name} `),
|
||||||
district_id: ev[ev.length - 1]?.id,
|
district_id: ev[ev.length - 1]?.id,
|
||||||
})
|
})
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.error('请选择地址')
|
alert.error('请选择地址')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className='add-address'>
|
<View className="add-address">
|
||||||
<FromList
|
<FromList
|
||||||
onInput={(ev: any) => setFormData({ ...formData, name: ev.detail.value })}
|
onInput={(ev: any) => setFormData({ ...formData, name: ev.detail.value })}
|
||||||
value={formData['name']}
|
value={formData.name}
|
||||||
label='联系人'
|
label="联系人"
|
||||||
placeholder='请输入收货人姓名'
|
placeholder="请输入收货人姓名"
|
||||||
/>
|
/>
|
||||||
<FromList
|
<FromList
|
||||||
primordialType='number'
|
primordialType="number"
|
||||||
onInput={(ev: any) => setFormData({ ...formData, phone: ev.detail.value })}
|
onInput={(ev: any) => setFormData({ ...formData, phone: ev.detail.value })}
|
||||||
value={formData['phone']}
|
value={formData.phone}
|
||||||
label='联系方式'
|
label="联系方式"
|
||||||
placeholder='请输入联系方式'
|
placeholder="请输入联系方式"
|
||||||
/>
|
/>
|
||||||
<FromList value={formData['site']} onClick={() => setShowSiteModal(true)} label='收货地址' type='select' placeholder='请选择/省/市/区' />
|
<FromList value={formData.site} onClick={() => setShowSiteModal(true)} label="收货地址" type="select" placeholder="请选择/省/市/区" />
|
||||||
<FromList
|
<FromList
|
||||||
onInput={(ev: any) => setFormData({ ...formData, address_detail: ev.detail.value })}
|
onInput={(ev: any) => setFormData({ ...formData, address_detail: ev.detail.value })}
|
||||||
value={formData['address_detail']}
|
value={formData.address_detail}
|
||||||
label='详细地址'
|
label="详细地址"
|
||||||
type='textarea'
|
type="textarea"
|
||||||
placeholder='请输入详细地址(街道、门牌号等)'
|
placeholder="请输入详细地址(街道、门牌号等)"
|
||||||
/>
|
/>
|
||||||
<View className='add-address-default'>
|
<View className="add-address-default">
|
||||||
<Text>设为默认地址</Text>
|
<Text>设为默认地址</Text>
|
||||||
<View onClick={() => setFormData({ ...formData, is_default: !formData.is_default })}>
|
<View onClick={() => setFormData({ ...formData, is_default: !formData.is_default })}>
|
||||||
{formData.is_default ? (
|
{formData.is_default
|
||||||
<View className='add-address-default-active'>
|
? (
|
||||||
<Text className='iconfont icon-tick' />
|
<View className="add-address-default-active">
|
||||||
|
<Text className="iconfont icon-tick" />
|
||||||
</View>
|
</View>
|
||||||
) : (
|
)
|
||||||
<View className='add-address-default-noactive'></View>
|
: (
|
||||||
|
<View className="add-address-default-noactive"></View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Button style={{ background: hozon ? '#007aff' : '' }} hoverClass='none' className={`add-address-save`} onClick={handleSave}>
|
<Button style={{ background: hozon ? '#007aff' : '' }} hoverClass="none" className="add-address-save" onClick={handleSave}>
|
||||||
保存
|
保存
|
||||||
</Button>
|
</Button>
|
||||||
<Address addressOnChange={handleSetSite} defaultValue={formData.siteArray} addressOnClose={() => setShowSiteModal(false)} show={showSiteModal} />
|
<Address addressOnChange={handleSetSite} defaultValue={formData.siteArray} addressOnClose={() => setShowSiteModal(false)} show={showSiteModal} />
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
|
|
||||||
import AddressList from "@/components/AddressList"
|
import { Button, ScrollView, Text, View } from '@tarojs/components'
|
||||||
import useLogin from "@/use/useLogin"
|
import { stopPullDownRefresh, usePullDownRefresh } from '@tarojs/taro'
|
||||||
import { Button, ScrollView, Text, View } from "@tarojs/components"
|
import { useState } from 'react'
|
||||||
import { stopPullDownRefresh, usePullDownRefresh } from "@tarojs/taro"
|
import useLogin from '@/use/useLogin'
|
||||||
import { useState } from "react"
|
import AddressList from '@/components/AddressList'
|
||||||
import "./index.scss"
|
import './index.scss'
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
useLogin()
|
useLogin()
|
||||||
return (
|
return (
|
||||||
<View className="address-manager">
|
<View className="address-manager">
|
||||||
<AddressList refresherEnabled={true}/>
|
<AddressList refresherEnabled />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -1,29 +1,29 @@
|
|||||||
import { formatHashTag, formatImgUrl } from "@/common/fotmat";
|
import { Image, Text, View } from '@tarojs/components'
|
||||||
import Counter from "@/components/counter";
|
import type { FC } from 'react'
|
||||||
import MCheckbox from "@/components/checkbox";
|
import { memo, useCallback } from 'react'
|
||||||
import { Image, Text, View } from "@tarojs/components";
|
|
||||||
import { FC, memo, useCallback } from "react";
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||||
|
import Counter from '@/components/counter'
|
||||||
|
import MCheckbox from '@/components/checkbox'
|
||||||
|
|
||||||
type OrderParam = {
|
interface OrderParam {
|
||||||
list?: any[],
|
list?: any[]
|
||||||
sale_mode?: number,
|
sale_mode?: number
|
||||||
sale_mode_name?: string,
|
sale_mode_name?: string
|
||||||
unit?: string,
|
unit?: string
|
||||||
total_colors?: number,
|
total_colors?: number
|
||||||
total_fabrics?: number,
|
total_fabrics?: number
|
||||||
total_number?: number,
|
total_number?: number
|
||||||
status?: number, //订单状态
|
status?: number // 订单状态
|
||||||
av_return_product?: any[] // 申请售后列表
|
av_return_product?: any[] // 申请售后列表
|
||||||
}
|
}
|
||||||
|
|
||||||
type Param = {
|
interface Param {
|
||||||
order: OrderParam,
|
order: OrderParam
|
||||||
onSelectChange?: (val: {color_id:number, length: number, status: true|false, sale_order_detail_id:number}) => void
|
onSelectChange?: (val: { color_id: number; length: number; status: true|false; sale_order_detail_id: number }) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const kindeList: FC<Param> = memo(({ order, onSelectChange }) => {
|
const kindeList: FC<Param> = memo(({ order, onSelectChange }) => {
|
||||||
|
|
||||||
// checkbox选中回调
|
// checkbox选中回调
|
||||||
const selectCallBack = (colorItem) => {
|
const selectCallBack = (colorItem) => {
|
||||||
onSelectChange?.({ color_id: colorItem.product_color_id, length: colorItem.length, sale_order_detail_id: colorItem.sale_order_detail_id, status: true })
|
onSelectChange?.({ color_id: colorItem.product_color_id, length: colorItem.length, sale_order_detail_id: colorItem.sale_order_detail_id, status: true })
|
||||||
@ -31,7 +31,7 @@ const kindeList:FC<Param> = memo(({order, onSelectChange}) => {
|
|||||||
|
|
||||||
// checkbox关闭回调
|
// checkbox关闭回调
|
||||||
const colseCallBack = (colorItem) => {
|
const colseCallBack = (colorItem) => {
|
||||||
onSelectChange?.({color_id:colorItem.product_color_id, length:colorItem.length, status: false, sale_order_detail_id:colorItem.sale_order_detail_id,})
|
onSelectChange?.({ color_id: colorItem.product_color_id, length: colorItem.length, status: false, sale_order_detail_id: colorItem.sale_order_detail_id })
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -44,7 +44,7 @@ const kindeList:FC<Param> = memo(({order, onSelectChange}) => {
|
|||||||
<View className={styles.color_list}>
|
<View className={styles.color_list}>
|
||||||
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
||||||
<View className={styles.image}><Image src={formatImgUrl('')} /></View>
|
<View className={styles.image}><Image src={formatImgUrl('')} /></View>
|
||||||
<View className={styles.name_and_number}><Text>{colorItem.product_color_code + ' ' + colorItem.product_color_name}</Text><Text>x {colorItem.length/100} m</Text></View>
|
<View className={styles.name_and_number}><Text>{`${colorItem.product_color_code} ${colorItem.product_color_name}`}</Text><Text>x {colorItem.length / 100} m</Text></View>
|
||||||
<MCheckbox status={item.select} onSelect={() => selectCallBack(colorItem)} onClose={() => colseCallBack(colorItem)} />
|
<MCheckbox status={item.select} onSelect={() => selectCallBack(colorItem)} onClose={() => colseCallBack(colorItem)} />
|
||||||
</View>)}
|
</View>)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
import { formatHashTag, formatImgUrl } from "@/common/fotmat";
|
import { Image, Text, View } from '@tarojs/components'
|
||||||
import Counter from "@/components/counter";
|
import type { FC } from 'react'
|
||||||
import MCheckbox from "@/components/checkbox";
|
import { memo, useCallback } from 'react'
|
||||||
import { Image, Text, View } from "@tarojs/components";
|
|
||||||
import { FC, memo, useCallback } from "react";
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||||
|
import Counter from '@/components/counter'
|
||||||
|
import MCheckbox from '@/components/checkbox'
|
||||||
|
|
||||||
type OrderParam = {
|
interface OrderParam {
|
||||||
list?: any[],
|
list?: any[]
|
||||||
sale_mode?: number,
|
sale_mode?: number
|
||||||
sale_mode_name?: string,
|
sale_mode_name?: string
|
||||||
unit?: string,
|
unit?: string
|
||||||
total_colors?: number,
|
total_colors?: number
|
||||||
total_fabrics?: number,
|
total_fabrics?: number
|
||||||
total_number?: number,
|
total_number?: number
|
||||||
status?: number, //订单状态
|
status?: number // 订单状态
|
||||||
av_return_product?: any[] // 申请售后列表
|
av_return_product?: any[] // 申请售后列表
|
||||||
}
|
}
|
||||||
|
|
||||||
type Param = {
|
interface Param {
|
||||||
order: OrderParam,
|
order: OrderParam
|
||||||
onNumChange?: (val: any) => void
|
onNumChange?: (val: any) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
|
const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
|
||||||
|
|
||||||
// 计步器返回值
|
// 计步器返回值
|
||||||
const getCounterChange = useCallback((colorItem) => {
|
const getCounterChange = useCallback((colorItem) => {
|
||||||
return (number) => {
|
return (number) => {
|
||||||
@ -41,7 +41,7 @@ const kindeList:FC<Param> = memo(({order, onNumChange}) => {
|
|||||||
<View className={styles.color_list}>
|
<View className={styles.color_list}>
|
||||||
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
||||||
<View className={styles.image}><Image src={formatImgUrl('')} /></View>
|
<View className={styles.image}><Image src={formatImgUrl('')} /></View>
|
||||||
<View className={styles.name_and_number}><Text>{colorItem.product_color_code + ' ' + colorItem.product_color_name}</Text><Text>x {colorItem.roll}</Text></View>
|
<View className={styles.name_and_number}><Text>{`${colorItem.product_color_code} ${colorItem.product_color_name}`}</Text><Text>x {colorItem.roll}</Text></View>
|
||||||
<View className={styles.btn_count}>
|
<View className={styles.btn_count}>
|
||||||
<Counter maxNum={colorItem.roll} onChange={getCounterChange(colorItem)} />
|
<Counter maxNum={colorItem.roll} onChange={getCounterChange(colorItem)} />
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import {Textarea, View } from "@tarojs/components";
|
import { Textarea, View } from '@tarojs/components'
|
||||||
import { memo, useMemo, useState } from "react";
|
import { memo, useMemo, useState } from 'react'
|
||||||
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import classnames from "classnames";
|
|
||||||
|
|
||||||
// 其他说明
|
// 其他说明
|
||||||
type Param = {
|
interface Param {
|
||||||
onChange: (val: string) => void
|
onChange: (val: string) => void
|
||||||
}
|
}
|
||||||
export default memo(({ onChange }: Param) => {
|
export default memo(({ onChange }: Param) => {
|
||||||
@ -12,10 +12,10 @@ export default memo(({onChange}:Param) => {
|
|||||||
number: 0,
|
number: 0,
|
||||||
value: '',
|
value: '',
|
||||||
count: 200,
|
count: 200,
|
||||||
show: false
|
show: false,
|
||||||
})
|
})
|
||||||
const getDesc = (e) => {
|
const getDesc = (e) => {
|
||||||
let value = e.detail.value
|
const value = e.detail.value
|
||||||
let res = value
|
let res = value
|
||||||
if (value.length > descData.count) {
|
if (value.length > descData.count) {
|
||||||
res = value.slice(0, descData.count)
|
res = value.slice(0, descData.count)
|
||||||
@ -25,16 +25,16 @@ export default memo(({onChange}:Param) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const toggleShowRealTextarea = (show) => {
|
const toggleShowRealTextarea = (show) => {
|
||||||
setDescData({...descData, show:show})
|
setDescData({ ...descData, show })
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<View className={styles.other_desc}>
|
<View className={styles.other_desc}>
|
||||||
<View className={styles.title}>其他说明</View>
|
<View className={styles.title}>其他说明</View>
|
||||||
<View className={styles.textarea}>
|
<View className={styles.textarea}>
|
||||||
{descData.show&&<Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={(e) => getDesc(e)}></Textarea>||
|
{descData.show && <Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={e => getDesc(e)}></Textarea>
|
||||||
<View className={classnames(styles.textarea_con_pretend, descData.value&&styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value||'一般情况下选填,当退货说明=“其它问题”时,必填'}</View>
|
|| <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || '一般情况下选填,当退货说明=“其它问题”时,必填'}</View>
|
||||||
}
|
}
|
||||||
<View className={styles.descDataNum}>{descData.number +'/'+ descData.count}</View>
|
<View className={styles.descDataNum}>{`${descData.number}/${descData.count}`}</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
import Popup from "@/components/popup";
|
import { ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { ScrollView, Text, View } from "@tarojs/components";
|
import { memo, useEffect, useMemo, useState } from 'react'
|
||||||
import { memo, useEffect, useMemo, useState } from "react";
|
import classnames from 'classnames'
|
||||||
import classnames from "classnames";
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import Popup from '@/components/popup'
|
||||||
|
|
||||||
// 原因选择
|
// 原因选择
|
||||||
type Param = {id:number, name:string, typle?:number}
|
interface Param { id: number; name: string; typle?: number }
|
||||||
type ReasonInfoParam = {
|
interface ReasonInfoParam {
|
||||||
show?: boolean, //显示
|
show?: boolean // 显示
|
||||||
onClose?: () => void, //关闭
|
onClose?: () => void // 关闭
|
||||||
title?: string, //标题
|
title?: string // 标题
|
||||||
list?: {id:number, name:string, typle?:number, children?:Param[]}[], //数据列表
|
list?: { id: number; name: string; typle?: number; children?: Param[] }[] // 数据列表
|
||||||
onSelect?: (val: object) => void, //选择
|
onSelect?: (val: object) => void // 选择
|
||||||
defaultValue?: number, //默认选中
|
defaultValue?: number // 默认选中
|
||||||
}
|
}
|
||||||
export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
|
export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
|
||||||
const [hasNextData, setHasNextData] = useState(true) // 是否有下一级数据
|
const [hasNextData, setHasNextData] = useState(true) // 是否有下一级数据
|
||||||
const [selectData, setSelectData] = useState()
|
const [selectData, setSelectData] = useState()
|
||||||
const [headerList, setHeaderList] = useState<{id: number, name: string}[]>([])
|
const [headerList, setHeaderList] = useState<{ id: number; name: string }[]>([])
|
||||||
const onSelectData = (item) => {
|
const onSelectData = (item) => {
|
||||||
setHeaderList((e) => [...e, {id:item.id, name:item.name}])
|
setHeaderList(e => [...e, { id: item.id, name: item.name }])
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('headerList::', headerList)
|
console.log('headerList::', headerList)
|
||||||
@ -28,7 +28,7 @@ export default memo(({show = false, onClose, title = '', list = [], onSelect, de
|
|||||||
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
|
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
|
||||||
<View className={styles.reason_return_con}>
|
<View className={styles.reason_return_con}>
|
||||||
<View className={styles.reason_title}>
|
<View className={styles.reason_title}>
|
||||||
{headerList.map(item => {
|
{headerList.map((item) => {
|
||||||
return <Text key={item.id}>{item.name}</Text>
|
return <Text key={item.id}>{item.name}</Text>
|
||||||
})}
|
})}
|
||||||
{hasNextData && <Text>请选择</Text>}
|
{hasNextData && <Text>请选择</Text>}
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
import Popup from "@/components/popup";
|
import { ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { ScrollView, Text, View } from "@tarojs/components";
|
import { memo, useMemo } from 'react'
|
||||||
import { memo, useMemo } from "react";
|
import classnames from 'classnames'
|
||||||
import classnames from "classnames";
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import Popup from '@/components/popup'
|
||||||
|
|
||||||
// 原因选择
|
// 原因选择
|
||||||
type ReasonInfoParam = {
|
interface ReasonInfoParam {
|
||||||
show?: boolean, //显示
|
show?: boolean // 显示
|
||||||
onClose?: () => void, //关闭
|
onClose?: () => void // 关闭
|
||||||
title?: string, //标题
|
title?: string // 标题
|
||||||
list?: {id:number, name:string, typle?:number}[], //数据列表
|
list?: { id: number; name: string; typle?: number }[] // 数据列表
|
||||||
onSelect?: (val: object) => void, //选择
|
onSelect?: (val: object) => void // 选择
|
||||||
defaultValue?: number, //默认选中
|
defaultValue?: number // 默认选中
|
||||||
}
|
}
|
||||||
export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
|
export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
|
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
|
||||||
<View className={styles.reason_return_con}>
|
<View className={styles.reason_return_con}>
|
||||||
|
|||||||
@ -1,43 +1,42 @@
|
|||||||
import Popup from "@/components/popup";
|
import { ScrollView, Text, View } from '@tarojs/components'
|
||||||
import { ScrollView, Text, View } from "@tarojs/components";
|
import { Children, memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { Children, memo, useEffect, useMemo, useRef, useState } from "react";
|
import classnames from 'classnames'
|
||||||
import classnames from "classnames";
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import { ReturnExplainApi, ReturnReasonApi } from "@/api/salesAfterOrder";
|
import Popup from '@/components/popup'
|
||||||
|
import { ReturnExplainApi, ReturnReasonApi } from '@/api/salesAfterOrder'
|
||||||
|
|
||||||
// 原因选择
|
// 原因选择
|
||||||
type Param = {id:number, name:string, typle?:number}
|
interface Param { id: number; name: string; typle?: number }
|
||||||
type ReasonInfoParam = {
|
interface ReasonInfoParam {
|
||||||
show?: boolean, //显示
|
show?: boolean // 显示
|
||||||
onClose?: () => void, //关闭
|
onClose?: () => void // 关闭
|
||||||
title?: string, //标题
|
title?: string // 标题
|
||||||
list?: {id:number, name:string, typle?:number}[], //数据列表
|
list?: { id: number; name: string; typle?: number }[] // 数据列表
|
||||||
onSelect?: (val: object) => void, //选择
|
onSelect?: (val: object) => void // 选择
|
||||||
onHeaderSelect?: (val: object) => void, //点击头部标题
|
onHeaderSelect?: (val: object) => void // 点击头部标题
|
||||||
defaultValue?: number, //默认选中
|
defaultValue?: number // 默认选中
|
||||||
dataLength?: 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<typeof list>([])
|
const [initList, setInitList] = useState<typeof list>([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInitList(list)
|
setInitList(list)
|
||||||
}, [list])
|
}, [list])
|
||||||
const [selectIndex, setSelectIndex] = useState(1)
|
const [selectIndex, setSelectIndex] = useState(1)
|
||||||
const [headerList, setHeaderList] = useState<{id: number, name: string}[]>([])
|
const [headerList, setHeaderList] = useState<{ id: number; name: string }[]>([])
|
||||||
const onSelectData = (item) => {
|
const onSelectData = (item) => {
|
||||||
if (selectIndex <= dataLength) {
|
if (selectIndex <= dataLength) {
|
||||||
headerList[selectIndex - 1] = { id: item.id, name: item.name }
|
headerList[selectIndex - 1] = { id: item.id, name: item.name }
|
||||||
onSelect?.({ data: headerList, index: selectIndex })
|
onSelect?.({ data: headerList, index: selectIndex })
|
||||||
setSelectIndex(selectIndex == dataLength ? dataLength : selectIndex + 1)
|
setSelectIndex(selectIndex == dataLength ? dataLength : selectIndex + 1)
|
||||||
setHeaderList((e) => [...e])
|
setHeaderList(e => [...e])
|
||||||
if(selectIndex == dataLength) onClose?.()
|
if (selectIndex == dataLength) { onClose?.() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onHeaderClick = ({ val, index }) => {
|
const onHeaderClick = ({ val, index }) => {
|
||||||
let list = headerList.slice(0, index + 1)
|
const list = headerList.slice(0, index + 1)
|
||||||
setSelectIndex(index + 1)
|
setSelectIndex(index + 1)
|
||||||
setHeaderList(list)
|
setHeaderList(list)
|
||||||
onHeaderSelect?.({ data: val, index: index + 1 })
|
onHeaderSelect?.({ data: val, index: index + 1 })
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { Image, ScrollView, Text, View } from '@tarojs/components'
|
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 { FC, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import ReasonPopup from './components/reasonPopup'
|
import ReasonPopup from './components/reasonPopup'
|
||||||
import Taro, { useDidShow, useRouter } from '@tarojs/taro'
|
|
||||||
import { GetSaleOrderDetailApi } from '@/api/order'
|
|
||||||
import KindList from './components/kindList'
|
import KindList from './components/kindList'
|
||||||
import CutKindList from './components/cutkindList'
|
import CutKindList from './components/cutkindList'
|
||||||
|
import { GetSaleOrderDetailApi } from '@/api/order'
|
||||||
import { ReturnApplyOrderApi, ReturnExplainApi, ReturnGoodsStatusApi, ReturnReasonApi } from '@/api/salesAfterOrder'
|
import { ReturnApplyOrderApi, ReturnExplainApi, ReturnGoodsStatusApi, ReturnReasonApi } from '@/api/salesAfterOrder'
|
||||||
import { alert, goLink } from '@/common/common'
|
import { alert, goLink } from '@/common/common'
|
||||||
import UploadImage from '@/components/uploadImage'
|
import UploadImage from '@/components/uploadImage'
|
||||||
@ -45,7 +45,7 @@ export default () => {
|
|||||||
const { fetchData: getOrderFetchData } = GetSaleOrderDetailApi()
|
const { fetchData: getOrderFetchData } = GetSaleOrderDetailApi()
|
||||||
const getSaleOrderPreView = async() => {
|
const getSaleOrderPreView = async() => {
|
||||||
if (orderId.current) {
|
if (orderId.current) {
|
||||||
let res = await getOrderFetchData({ id: orderId.current })
|
const res = await getOrderFetchData({ id: orderId.current })
|
||||||
setOrderDetail(res.data)
|
setOrderDetail(res.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,54 +70,57 @@ export default () => {
|
|||||||
// 数据总量
|
// 数据总量
|
||||||
const dataCount = useMemo(() => {
|
const dataCount = useMemo(() => {
|
||||||
if (formatDetailOrder) {
|
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}`
|
return `${formatDetailOrder.av_total_fabrics}种面料,${formatDetailOrder.av_total_colors}种颜色,共${total_number}`
|
||||||
}
|
}
|
||||||
}, [formatDetailOrder])
|
}, [formatDetailOrder])
|
||||||
|
|
||||||
// 面料数据
|
// 面料数据
|
||||||
let roll_list = useRef({})
|
const roll_list = useRef({})
|
||||||
|
|
||||||
// 大货时获取计步器数据
|
// 大货时获取计步器数据
|
||||||
const getNumChange = useCallback((val) => {
|
const getNumChange = useCallback((val) => {
|
||||||
if (parseInt(val.number) > 0) {
|
if (parseInt(val.number) > 0) {
|
||||||
roll_list.current[val.color_id] = { product_roll: val.number, sale_order_detail_id: val.sale_order_detail_id }
|
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]
|
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) => {
|
const getSelectChange = useCallback((val) => {
|
||||||
if (val.status) {
|
if (val.status) {
|
||||||
roll_list.current[val.sale_order_detail_id] = { product_roll: val.length, sale_order_detail_id: val.sale_order_detail_id }
|
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]
|
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) => {
|
const getImageList = useCallback((list) => {
|
||||||
setSubmitData((e) => ({ ...e, fabric_piece_accessory_url: list }))
|
setSubmitData(e => ({ ...e, fabric_piece_accessory_url: list }))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// 其他说明
|
// 其他说明
|
||||||
const getOtherReason = useCallback((val) => {
|
const getOtherReason = useCallback((val) => {
|
||||||
setSubmitData((e) => ({ ...e, reason_describe: val }))
|
setSubmitData(e => ({ ...e, reason_describe: val }))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// 提交数据
|
// 提交数据
|
||||||
const { fetchData: fetchDataReturnApply } = ReturnApplyOrderApi()
|
const { fetchData: fetchDataReturnApply } = ReturnApplyOrderApi()
|
||||||
const onSubmitData = async() => {
|
const onSubmitData = async() => {
|
||||||
if (submitData.roll_list.length <= 0) return alert.none('请选择或输入退货颜色')
|
if (submitData.roll_list.length <= 0) { return alert.none('请选择或输入退货颜色') }
|
||||||
console.log('submitData::', submitData)
|
console.log('submitData::', submitData)
|
||||||
let res = await fetchDataReturnApply(submitData)
|
const res = await fetchDataReturnApply(submitData)
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
alert.success('申请成功')
|
alert.success('申请成功')
|
||||||
goLink('/pages/salesAfter/salesAfterList/index', {}, 'reLaunch')
|
goLink('/pages/salesAfter/salesAfterList/index', {}, 'reLaunch')
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
alert.error(res.msg)
|
alert.error(res.msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,11 +128,12 @@ export default () => {
|
|||||||
// 底部按钮
|
// 底部按钮
|
||||||
const onSubmit = throttle((val) => {
|
const onSubmit = throttle((val) => {
|
||||||
if (val == 2) {
|
if (val == 2) {
|
||||||
if (submitData.goods_status === '') return alert.error('请选择货物状况')
|
if (submitData.goods_status === '') { return alert.error('请选择货物状况') }
|
||||||
if (submitData.return_explain === '') return alert.error('请选择退货原因')
|
if (submitData.return_explain === '') { return alert.error('请选择退货原因') }
|
||||||
if (!submitData.return_explain && !submitData.reason_describe) return alert.error('请填写其他说明')
|
if (!submitData.return_explain && !submitData.reason_describe) { return alert.error('请填写其他说明') }
|
||||||
onSubmitData()
|
onSubmitData()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Taro.navigateBack()
|
Taro.navigateBack()
|
||||||
}
|
}
|
||||||
}, 600)
|
}, 600)
|
||||||
@ -150,28 +154,28 @@ export default () => {
|
|||||||
// 退货原因
|
// 退货原因
|
||||||
const { fetchData: fetchDataReturnReason } = ReturnReasonApi()
|
const { fetchData: fetchDataReturnReason } = ReturnReasonApi()
|
||||||
const getReturnReason = async() => {
|
const getReturnReason = async() => {
|
||||||
let res = await fetchDataReturnReason()
|
const res = await fetchDataReturnReason()
|
||||||
setReturnGoodsInfo((e) => res.data?.list)
|
setReturnGoodsInfo(e => res.data?.list)
|
||||||
}
|
}
|
||||||
// 售后退货说明
|
// 售后退货说明
|
||||||
const { fetchData: fetchDataReturnExplain } = ReturnExplainApi()
|
const { fetchData: fetchDataReturnExplain } = ReturnExplainApi()
|
||||||
const getReturnExplain = async(id) => {
|
const getReturnExplain = async(id) => {
|
||||||
let res = await fetchDataReturnExplain({ return_reason: id })
|
const res = await fetchDataReturnExplain({ return_reason: id })
|
||||||
setReturnGoodsInfo((e) => res.data?.list)
|
setReturnGoodsInfo(e => res.data?.list)
|
||||||
}
|
}
|
||||||
// 退货原因选择列表返回的数据
|
// 退货原因选择列表返回的数据
|
||||||
const [returnObj, setReturnObj] = useState<any>([])
|
const [returnObj, setReturnObj] = useState<any>([])
|
||||||
const onReturnSelect = useCallback((val) => {
|
const onReturnSelect = useCallback((val) => {
|
||||||
let res = val.data[val.data.length - 1]
|
const res = val.data[val.data.length - 1]
|
||||||
if (val.index == 1) {
|
if (val.index == 1) {
|
||||||
getReturnExplain(res.id)
|
getReturnExplain(res.id)
|
||||||
setReturnGoodsInfo(() => [])
|
setReturnGoodsInfo(() => [])
|
||||||
}
|
}
|
||||||
if (val.index == 2) setReturnObj(val.data)
|
if (val.index == 2) { setReturnObj(val.data) }
|
||||||
}, [])
|
}, [])
|
||||||
const onHeaderSelect = useCallback((val) => {
|
const onHeaderSelect = useCallback((val) => {
|
||||||
setReturnGoodsInfo((e) => [])
|
setReturnGoodsInfo(e => [])
|
||||||
if (val.index == 1) getReturnReason()
|
if (val.index == 1) { getReturnReason() }
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// 选择货物状况
|
// 选择货物状况
|
||||||
@ -180,8 +184,8 @@ export default () => {
|
|||||||
const [statusGoodsInfo, setStatusGoodsInfo] = useState([])
|
const [statusGoodsInfo, setStatusGoodsInfo] = useState([])
|
||||||
const { fetchData: fetchDataGoodsStatus } = ReturnGoodsStatusApi()
|
const { fetchData: fetchDataGoodsStatus } = ReturnGoodsStatusApi()
|
||||||
const getReturnGoodsStatus = async() => {
|
const getReturnGoodsStatus = async() => {
|
||||||
let res = await fetchDataGoodsStatus()
|
const res = await fetchDataGoodsStatus()
|
||||||
setStatusGoodsInfo((e) => res.data?.list)
|
setStatusGoodsInfo(e => res.data?.list)
|
||||||
}
|
}
|
||||||
const onShowStatus = () => {
|
const onShowStatus = () => {
|
||||||
setShowStatus(() => true)
|
setShowStatus(() => true)
|
||||||
@ -191,7 +195,7 @@ export default () => {
|
|||||||
setShowStatus(() => false)
|
setShowStatus(() => false)
|
||||||
}, [])
|
}, [])
|
||||||
const onStatusSelect = useCallback((val) => {
|
const onStatusSelect = useCallback((val) => {
|
||||||
let res = val.data[val.data.length - 1]
|
const res = val.data[val.data.length - 1]
|
||||||
setStatusInfo(res)
|
setStatusInfo(res)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@ -222,7 +226,7 @@ export default () => {
|
|||||||
<View className={styles.title}>退货原因</View>
|
<View className={styles.title}>退货原因</View>
|
||||||
<View className={styles.select} onClick={onShowReason}>
|
<View className={styles.select} onClick={onShowReason}>
|
||||||
<Text className={returnObj?.length > 0 && styles.selected}>
|
<Text className={returnObj?.length > 0 && styles.selected}>
|
||||||
{returnObj?.length > 0 ? returnObj[0]?.name + '/' + returnObj[1]?.name : '请选择'}
|
{returnObj?.length > 0 ? `${returnObj[0]?.name}/${returnObj[1]?.name}` : '请选择'}
|
||||||
</Text>
|
</Text>
|
||||||
<Text className={classnames(styles.miconfont, 'iconfont icon-a-moreback')}></Text>
|
<Text className={classnames(styles.miconfont, 'iconfont icon-a-moreback')}></Text>
|
||||||
</View>
|
</View>
|
||||||
@ -240,11 +244,11 @@ export default () => {
|
|||||||
<UploadImage onChange={getImageList} />
|
<UploadImage onChange={getImageList} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<TextareaEnhance onChange={getOtherReason} title='其他说明' />
|
<TextareaEnhance onChange={getOtherReason} title="其他说明" />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className='common_safe_area_y'></View>
|
<View className="common_safe_area_y"></View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.btns_con}>
|
<View className={styles.btns_con}>
|
||||||
<View className={styles.btns_two}>
|
<View className={styles.btns_two}>
|
||||||
@ -259,13 +263,13 @@ export default () => {
|
|||||||
<ReasonPopup
|
<ReasonPopup
|
||||||
show={showReason}
|
show={showReason}
|
||||||
onClose={closeReason}
|
onClose={closeReason}
|
||||||
title='退货原因'
|
title="退货原因"
|
||||||
list={returnGoodsInfo}
|
list={returnGoodsInfo}
|
||||||
onHeaderSelect={onHeaderSelect}
|
onHeaderSelect={onHeaderSelect}
|
||||||
onSelect={onReturnSelect}
|
onSelect={onReturnSelect}
|
||||||
dataLength={2}
|
dataLength={2}
|
||||||
/>
|
/>
|
||||||
<ReasonPopup show={showStatus} onClose={closeStatus} title='货物状况' list={statusGoodsInfo} onSelect={onStatusSelect} dataLength={1} />
|
<ReasonPopup show={showStatus} onClose={closeStatus} title="货物状况" list={statusGoodsInfo} onSelect={onStatusSelect} dataLength={1} />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user