🌈 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": {
|
||||
"react/jsx-uses-react": "off",
|
||||
"react/react-in-jsx-scope": "off"
|
||||
},
|
||||
"plugins": [""]
|
||||
"no-console": "off",
|
||||
"@typescript-eslint/no-shadow": "off",
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
"eqeqeq": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"import/first": "off",
|
||||
"react/no-children-prop": "off",
|
||||
"import/no-commonjs": "off"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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: [
|
||||
['taro', {
|
||||
framework: 'react',
|
||||
ts: true
|
||||
}]
|
||||
]
|
||||
ts: true,
|
||||
}],
|
||||
],
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
NODE_ENV: '"development"',
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
const path = require('path')
|
||||
const childProcess = require('child_process')
|
||||
const versions =
|
||||
childProcess.execSync('git rev-parse --abbrev-ref HEAD', {
|
||||
|
||||
const versions
|
||||
= childProcess.execSync('git rev-parse --abbrev-ref HEAD', {
|
||||
encoding: 'utf8',
|
||||
}) != 'HEAD\n'
|
||||
? childProcess.execSync('git rev-parse --abbrev-ref HEAD', {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
encoding: 'utf8',
|
||||
})
|
||||
: childProcess.execSync('git describe --tags --abbrev=0', {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
encoding: 'utf8',
|
||||
})
|
||||
const CURRENT_GITHASH = childProcess.execSync('git rev-parse --short HEAD', {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
@ -109,7 +110,7 @@ const config = {
|
||||
// },
|
||||
}
|
||||
|
||||
module.exports = function (merge) {
|
||||
module.exports = function(merge) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return merge({}, config, require('./dev'))
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
NODE_ENV: '"pre"',
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
NODE_ENV: '"production"',
|
||||
|
||||
4
global.d.ts
vendored
4
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 '*.gif'
|
||||
@ -19,4 +19,4 @@ declare namespace NodeJS {
|
||||
|
||||
declare const CURRENT_VERSION: string
|
||||
declare const CURRENT_GITHASH: string
|
||||
declare const CURRENT_ENV: string
|
||||
declare const CURRENT_ENV: string
|
||||
|
||||
15
package.json
15
package.json
@ -8,6 +8,7 @@
|
||||
"typescript": true,
|
||||
"css": "sass"
|
||||
},
|
||||
"author": "",
|
||||
"scripts": {
|
||||
"build:weapp": "taro build --type weapp",
|
||||
"build:swan": "taro build --type swan",
|
||||
@ -31,14 +32,15 @@
|
||||
"dev:weapp:pre": "cross-env NODE_ENV=pre npm run build:weapp -- --watch",
|
||||
"build:weapp:open": "taro build --type weapp --open",
|
||||
"build:weapp:upload": "taro build --type weapp --upload",
|
||||
"build:weapp:preview": "taro build --type weapp --preview"
|
||||
"build:weapp:preview": "taro build --type weapp --preview",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 3 versions",
|
||||
"Android >= 4.1",
|
||||
"ios >= 8"
|
||||
],
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.7",
|
||||
"@tarojs/components": "3.5.6",
|
||||
@ -59,6 +61,7 @@
|
||||
"tarojs": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@aaronghx/eslint-config-react": "^0.1.11",
|
||||
"@babel/core": "^7.8.0",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
|
||||
"@tarojs/plugin-mini-ci": "3.5.6",
|
||||
@ -67,15 +70,11 @@
|
||||
"@types/qs": "^6.9.7",
|
||||
"@types/react": "^18.0.0",
|
||||
"@types/webpack-env": "^1.13.6",
|
||||
"@typescript-eslint/eslint-plugin": "^4.15.1",
|
||||
"@typescript-eslint/parser": "^4.15.1",
|
||||
"babel-preset-taro": "3.5.6",
|
||||
"classnames": "^2.3.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-config-taro": "3.5.6",
|
||||
"eslint-plugin-import": "^2.12.0",
|
||||
"eslint-plugin-react": "^7.8.2",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"react-refresh": "0.11.0",
|
||||
"stylelint": "9.3.0",
|
||||
"typescript": "^4.1.0",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 获取行政地区列表
|
||||
*/
|
||||
export const GetAddressListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/district/list`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
export const GetAddressListApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/district/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const addressListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/address/list`,
|
||||
url: '/v1/mall/address/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -17,7 +17,7 @@ export const addressListApi = () => {
|
||||
*/
|
||||
export const addressAddApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/address`,
|
||||
url: '/v1/mall/address',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
@ -28,7 +28,7 @@ export const addressAddApi = () => {
|
||||
*/
|
||||
export const addressDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/address`,
|
||||
url: '/v1/mall/address',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -39,7 +39,7 @@ export const addressDetailApi = () => {
|
||||
*/
|
||||
export const addressEditApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/address`,
|
||||
url: '/v1/mall/address',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -50,7 +50,7 @@ export const addressEditApi = () => {
|
||||
*/
|
||||
export const addressDeleteApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/address`,
|
||||
url: '/v1/mall/address',
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const GetBannerList = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/carouselBanner/list`,
|
||||
url: '/v1/mall/carouselBanner/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const GetSignApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/cdn/token`,
|
||||
url: '/v1/mall/cdn/token',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,34 +1,34 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 企业认证信息获取
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const certificationDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/company/authentication`,
|
||||
method: "get",
|
||||
})
|
||||
export const certificationDetailApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/company/authentication',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业认证信息提交
|
||||
* @returns
|
||||
* 企业认证信息提交
|
||||
* @returns
|
||||
*/
|
||||
export const certificationSaveApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/company/authentication`,
|
||||
method: "put",
|
||||
})
|
||||
export const certificationSaveApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/company/authentication',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业认证类型枚举列表
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const certificationTypeListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/companyAuthenticationType`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
export const certificationTypeListApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/enum/companyAuthenticationType',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const companyDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/company/info`,
|
||||
url: '/v1/mall/company/info',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -17,7 +17,7 @@ export const companyDetailApi = () => {
|
||||
*/
|
||||
export const companyUpdateApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/company/info`,
|
||||
url: '/v1/mall/company/info',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const creditInfoApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/credit`,
|
||||
url: '/v1/mall/credit',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -17,7 +17,7 @@ export const creditInfoApi = () => {
|
||||
*/
|
||||
export const creditListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/credit/list`,
|
||||
url: '/v1/mall/credit/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const depositInfoApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/rechargeApplication`,
|
||||
url: '/v1/mall/rechargeApplication',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -17,7 +17,7 @@ export const depositInfoApi = () => {
|
||||
*/
|
||||
export const depositListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/rechargeApplication/list`,
|
||||
url: '/v1/mall/rechargeApplication/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -28,7 +28,7 @@ export const depositListApi = () => {
|
||||
*/
|
||||
export const depositDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/rechargeApplication/order`,
|
||||
url: '/v1/mall/rechargeApplication/order',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const FavoriteListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/favorite/list`,
|
||||
url: '/v1/mall/favorite/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -17,7 +17,7 @@ export const FavoriteListApi = () => {
|
||||
*/
|
||||
export const CreateFavoriteApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/favorite`,
|
||||
url: '/v1/mall/favorite',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
@ -28,7 +28,7 @@ export const CreateFavoriteApi = () => {
|
||||
*/
|
||||
export const DelFavoriteApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/favorite`,
|
||||
url: '/v1/mall/favorite',
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
||||
@ -39,7 +39,7 @@ export const DelFavoriteApi = () => {
|
||||
*/
|
||||
export const UpdateFavoriteApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/favorite`,
|
||||
url: '/v1/mall/favorite',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -50,7 +50,7 @@ export const UpdateFavoriteApi = () => {
|
||||
*/
|
||||
export const AddFavoriteApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/favorite/product`,
|
||||
url: '/v1/mall/favorite/product',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
@ -61,7 +61,7 @@ export const AddFavoriteApi = () => {
|
||||
*/
|
||||
export const DelFavoriteProductApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/favorite/product`,
|
||||
url: '/v1/mall/favorite/product',
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
||||
@ -72,7 +72,7 @@ export const DelFavoriteProductApi = () => {
|
||||
*/
|
||||
export const DetailFavoriteProductApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/favorite`,
|
||||
url: '/v1/mall/favorite',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -83,7 +83,7 @@ export const DetailFavoriteProductApi = () => {
|
||||
*/
|
||||
export const MoveFavoriteProductApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/favorite/product`,
|
||||
url: '/v1/mall/favorite/product',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const LoginApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/login`,
|
||||
url: '/v1/mall/login',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const GetCategoryList = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/category/list`,
|
||||
url: '/v1/mall/category/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -17,7 +17,7 @@ export const GetCategoryList = () => {
|
||||
*/
|
||||
export const GetProductKindListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v2/mall/product/kind/list`,
|
||||
url: '/v2/mall/product/kind/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -28,7 +28,7 @@ export const GetProductKindListApi = () => {
|
||||
*/
|
||||
export const GetProductListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v2/mall/product/list`,
|
||||
url: '/v2/mall/product/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -38,7 +38,7 @@ export const GetProductListApi = () => {
|
||||
*/
|
||||
export const GetClassList = () => {
|
||||
return useRequest({
|
||||
url: `/v2/mall/product/kind/sub/list`,
|
||||
url: '/v2/mall/product/kind/sub/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -49,7 +49,7 @@ export const GetClassList = () => {
|
||||
*/
|
||||
export const GetProductDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/product`,
|
||||
url: '/v1/mall/product',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -60,7 +60,7 @@ export const GetProductDetailApi = () => {
|
||||
*/
|
||||
export const GetLabProductApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/product/color/absorb/match`,
|
||||
url: '/v1/mall/product/color/absorb/match',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 获取面料颜色列表
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const GetColorList = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/product/color/list`,
|
||||
method: "get",
|
||||
})
|
||||
return useRequest({
|
||||
url: '/v1/mall/product/color/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,26 +1,26 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 获取用户资产
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const userassets = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/assets`,
|
||||
method: "get",
|
||||
})
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/assets',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
//取色对比
|
||||
// 取色对比
|
||||
export const productabsorbcontrast = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/product/color/absorb/contrast`,
|
||||
method: "get",
|
||||
})
|
||||
return useRequest({
|
||||
url: '/v1/mall/product/color/absorb/contrast',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
//订单统计
|
||||
// 订单统计
|
||||
export const userorderStatistics = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/orderStatistics`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/orderStatistics',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,13 +6,13 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const GetPayCode = () => {
|
||||
return useRequest({
|
||||
url: `/xima-caphtml/caphtml`,
|
||||
url: '/xima-caphtml/caphtml',
|
||||
base_url: CAP_HTML_TO_IMAGE_BASE_URL,
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
//本地获取二维码
|
||||
// 本地获取二维码
|
||||
// export const GetPayCode = () => {
|
||||
// return useRequest({
|
||||
// url: `/caphtml`,
|
||||
@ -26,7 +26,7 @@ export const GetPayCode = () => {
|
||||
*/
|
||||
export const GetReturnPayCode = () => {
|
||||
return useRequest({
|
||||
url: `/xima-caphtml/caphtml-return`,
|
||||
url: '/xima-caphtml/caphtml-return',
|
||||
base_url: CAP_HTML_TO_IMAGE_BASE_URL,
|
||||
method: 'post',
|
||||
})
|
||||
|
||||
@ -5,7 +5,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const SaleOrderApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder`,
|
||||
url: '/v1/mall/saleOrder',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
@ -15,7 +15,7 @@ export const SaleOrderApi = () => {
|
||||
*/
|
||||
export const SaleOrderPreViewApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/preView`,
|
||||
url: '/v1/mall/saleOrder/preView',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -25,7 +25,7 @@ export const SaleOrderPreViewApi = () => {
|
||||
*/
|
||||
export const GetSaleOrderDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/detail`,
|
||||
url: '/v1/mall/saleOrder/detail',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -35,7 +35,7 @@ export const GetSaleOrderDetailApi = () => {
|
||||
*/
|
||||
export const EditSaleOrderRemarkApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/remark`,
|
||||
url: '/v1/mall/saleOrder/remark',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -45,7 +45,7 @@ export const EditSaleOrderRemarkApi = () => {
|
||||
*/
|
||||
export const EditSaleOrderAddressApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/address`,
|
||||
url: '/v1/mall/saleOrder/address',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -55,7 +55,7 @@ export const EditSaleOrderAddressApi = () => {
|
||||
*/
|
||||
export const EditSaleOrderShipmentModeApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/shipmentMode`,
|
||||
url: '/v1/mall/saleOrder/shipmentMode',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -65,7 +65,7 @@ export const EditSaleOrderShipmentModeApi = () => {
|
||||
*/
|
||||
export const GetOrderStatusListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/sale/order/status`,
|
||||
url: '/v1/mall/enum/sale/order/status',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -75,7 +75,7 @@ export const GetOrderStatusListApi = () => {
|
||||
*/
|
||||
export const GetOrderListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/list`,
|
||||
url: '/v1/mall/saleOrder/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -85,7 +85,7 @@ export const GetOrderListApi = () => {
|
||||
*/
|
||||
export const CancelOrderApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/cancel`,
|
||||
url: '/v1/mall/saleOrder/cancel',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -95,7 +95,7 @@ export const CancelOrderApi = () => {
|
||||
*/
|
||||
export const ReceiveOrderApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/receive`,
|
||||
url: '/v1/mall/saleOrder/receive',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -105,7 +105,7 @@ export const ReceiveOrderApi = () => {
|
||||
*/
|
||||
export const OrderStatusListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/filterSaleOrderStatus`,
|
||||
url: '/v1/mall/enum/filterSaleOrderStatus',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const GetOrderPayApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/orderPayment/orderPaymentMethodInfo`,
|
||||
url: '/v1/mall/orderPayment/orderPaymentMethodInfo',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -15,7 +15,7 @@ export const GetOrderPayApi = () => {
|
||||
*/
|
||||
export const SubmitOrderPayApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/orderPayment/orderPaymentSubmission`,
|
||||
url: '/v1/mall/orderPayment/orderPaymentSubmission',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
@ -25,7 +25,7 @@ export const SubmitOrderPayApi = () => {
|
||||
*/
|
||||
export const GetPrepayOrderPayApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/orderPayment/preCollectOrder/orderPaymentMethodInfo`,
|
||||
url: '/v1/mall/orderPayment/preCollectOrder/orderPaymentMethodInfo',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -35,7 +35,7 @@ export const GetPrepayOrderPayApi = () => {
|
||||
*/
|
||||
export const SubmitPrepayOrderPayApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/orderPayment/preCollectOrder/orderPaymentSubmission`,
|
||||
url: '/v1/mall/orderPayment/preCollectOrder/orderPaymentSubmission',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,122 +1,121 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 售后订单列表
|
||||
*/
|
||||
export const GetSaleOrderListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/returnApplyOrder/list`,
|
||||
method: "get",
|
||||
})
|
||||
return useRequest({
|
||||
url: '/v1/mall/returnApplyOrder/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请售后订单
|
||||
*/
|
||||
export const ReturnApplyOrderApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/returnApplyOrder`,
|
||||
method: "post",
|
||||
})
|
||||
export const ReturnApplyOrderApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/returnApplyOrder',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消退货/退款
|
||||
*/
|
||||
export const ReturnApplyOrderCancelApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/returnApplyOrder/cancel`,
|
||||
method: "post",
|
||||
})
|
||||
export const ReturnApplyOrderCancelApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/returnApplyOrder/cancel',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后订单详情
|
||||
*/
|
||||
export const SaleOrderOrderDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/returnApplyOrder`,
|
||||
method: "get",
|
||||
})
|
||||
export const SaleOrderOrderDetailApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/returnApplyOrder',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 物流上传
|
||||
*/
|
||||
export const ReturnApplyLogisticsApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/returnApplyOrder/upload`,
|
||||
method: "put",
|
||||
})
|
||||
export const ReturnApplyLogisticsApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/returnApplyOrder/upload',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 售后货物状况
|
||||
*/
|
||||
export const ReturnGoodsStatusApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/return/goodsStatus`,
|
||||
method: "get",
|
||||
})
|
||||
export const ReturnGoodsStatusApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/enum/return/goodsStatus',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后退货原因
|
||||
*/
|
||||
export const ReturnReasonApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/returnOrder/returnReason`,
|
||||
method: "get",
|
||||
})
|
||||
export const ReturnReasonApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/enum/returnOrder/returnReason',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后退货原因
|
||||
*/
|
||||
export const ReturnExplainApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/returnExplain`,
|
||||
method: "get",
|
||||
})
|
||||
export const ReturnExplainApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/enum/returnExplain',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退款
|
||||
*/
|
||||
export const ApplyRefundApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/returnApplyOrder`,
|
||||
method: "post",
|
||||
})
|
||||
export const ApplyRefundApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/returnApplyOrder',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后订单状态列表
|
||||
*/
|
||||
export const RefundOrderSatausApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/filterReturnStage`,
|
||||
method: "get",
|
||||
})
|
||||
export const RefundOrderSatausApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/enum/filterReturnStage',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款说明
|
||||
*/
|
||||
export const RefundExplainApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/refundExplain`,
|
||||
method: "get",
|
||||
})
|
||||
export const RefundExplainApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/enum/refundExplain',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后记录
|
||||
*/
|
||||
export const ReturnRecordApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/saleOrder/return`,
|
||||
method: "get",
|
||||
})
|
||||
export const ReturnRecordApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/saleOrder/return',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,33 +1,31 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 获取热门搜索
|
||||
*/
|
||||
export const GetHotSearchApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/hotSearch/list`,
|
||||
method: "get",
|
||||
})
|
||||
export const GetHotSearchApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/hotSearch/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取历史搜索
|
||||
*/
|
||||
export const GetSearchHistoryApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/searchHistory/list`,
|
||||
method: "get",
|
||||
})
|
||||
export const GetSearchHistoryApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/searchHistory/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加搜索关键字
|
||||
*/
|
||||
export const AddSearchHistoryApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/searchHistory`,
|
||||
method: "post",
|
||||
})
|
||||
}
|
||||
export const AddSearchHistoryApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/searchHistory',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,31 +1,31 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 分享短码
|
||||
*/
|
||||
export const GetShortCodeApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/shortCode/add`,
|
||||
method: "post",
|
||||
})
|
||||
export const GetShortCodeApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/shortCode/add',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析短码
|
||||
*/
|
||||
export const AnalysisShortCodeApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/shortCode`,
|
||||
method: "get",
|
||||
})
|
||||
export const AnalysisShortCodeApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/shortCode',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定上下级
|
||||
*/
|
||||
export const BindShortCodeApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/shortCode/bind`,
|
||||
method: "post",
|
||||
})
|
||||
}
|
||||
return useRequest({
|
||||
url: '/v1/mall/shortCode/bind',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import { useRequest } from '@/use/useHttp'
|
||||
*/
|
||||
export const GetShoppingCartApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/shoppingCart/productColor`,
|
||||
url: '/v1/mall/shoppingCart/productColor',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -17,7 +17,7 @@ export const GetShoppingCartApi = () => {
|
||||
*/
|
||||
export const AddShoppingCartApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/shoppingCart/productColor/list`,
|
||||
url: '/v1/mall/shoppingCart/productColor/list',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
@ -28,7 +28,7 @@ export const AddShoppingCartApi = () => {
|
||||
*/
|
||||
export const DelShoppingCartApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/shoppingCart/productColor`,
|
||||
url: '/v1/mall/shoppingCart/productColor',
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
||||
@ -39,7 +39,7 @@ export const DelShoppingCartApi = () => {
|
||||
*/
|
||||
export const UpdateShoppingCartApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/shoppingCart/productColor`,
|
||||
url: '/v1/mall/shoppingCart/productColor',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 获取专题列表
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const GetSubjectList = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/subject/list`,
|
||||
method: "get",
|
||||
})
|
||||
return useRequest({
|
||||
url: '/v1/mall/subject/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
110
src/api/user.ts
110
src/api/user.ts
@ -1,110 +1,110 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
/**
|
||||
* 解密用户微信信息
|
||||
*/
|
||||
export const GetWxUserInfoApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/decrypt`,
|
||||
method: "post",
|
||||
})
|
||||
export const GetWxUserInfoApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/decrypt',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取后台返回的用户信息
|
||||
*/
|
||||
export const GetAdminUserInfoApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/info`,
|
||||
method: "get",
|
||||
})
|
||||
export const GetAdminUserInfoApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/info',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取后台返回的用户手机号码信息
|
||||
*/
|
||||
export const GetPhoneNumberApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/phoneNumber`,
|
||||
method: "post",
|
||||
})
|
||||
export const GetPhoneNumberApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/phoneNumber',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户昵称
|
||||
*/
|
||||
export const realNameUpdateApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user`,
|
||||
method: "put",
|
||||
})
|
||||
export const realNameUpdateApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/user',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司类型|企业类型 下拉列表
|
||||
*/
|
||||
export const companyTypeApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/enum/purchaserType`,
|
||||
method: "get",
|
||||
})
|
||||
return useRequest({
|
||||
url: '/v1/mall/enum/purchaserType',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 头像更改
|
||||
*/
|
||||
export const portraitUpdateApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/avatar`,
|
||||
method: "put",
|
||||
})
|
||||
export const portraitUpdateApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/avatar',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定公司
|
||||
*/
|
||||
export const BindingCompanyApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/binding/company`,
|
||||
method: "put",
|
||||
})
|
||||
export const BindingCompanyApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/binding/company',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请下单权限
|
||||
*/
|
||||
export const ApplyOrderAccessApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/orderAccess/apply`,
|
||||
method: "post",
|
||||
})
|
||||
export const ApplyOrderAccessApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/orderAccess/apply',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅模板id
|
||||
*/
|
||||
export const SubscriptionMessageApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/subscriptionMessage`,
|
||||
method: "get",
|
||||
})
|
||||
export const SubscriptionMessageApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/subscriptionMessage',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 邀请码获取业务员信息
|
||||
*/
|
||||
export const GetInvitationInfoApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/invitationInfo`,
|
||||
method: "get",
|
||||
})
|
||||
export const GetInvitationInfoApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/invitationInfo',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定业务员
|
||||
*/
|
||||
export const BindInvitationInfoApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user/bindInvitationCode`,
|
||||
method: "post",
|
||||
})
|
||||
export const BindInvitationInfoApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/user/bindInvitationCode',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,56 +1,56 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
import { useRequest } from '@/use/useHttp'
|
||||
|
||||
/**
|
||||
* 码单列表获取
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const weightListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title/list`,
|
||||
method: "get",
|
||||
})
|
||||
export const weightListApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/title/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 码单添加
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const weightAddApi = () => {
|
||||
export const weightAddApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title`,
|
||||
method: "post",
|
||||
url: '/v1/mall/title',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 码单详情
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const weightDetailApi = () => {
|
||||
export const weightDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title`,
|
||||
method: "get",
|
||||
url: '/v1/mall/title',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 码单编辑
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const weightEditApi = () => {
|
||||
export const weightEditApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title`,
|
||||
method: "put",
|
||||
url: '/v1/mall/title',
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 码单删除
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export const weightDeleteApi = () => {
|
||||
export const weightDeleteApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title`,
|
||||
method: "delete",
|
||||
url: '/v1/mall/title',
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
||||
|
||||
@ -23,164 +23,164 @@ export default {
|
||||
text: '我的',
|
||||
iconPath: './styles/tabbar/my.png',
|
||||
selectedIconPath: './styles/tabbar/my_selected.png',
|
||||
}
|
||||
},
|
||||
],
|
||||
'color': '#707070',
|
||||
'selectedColor': '#2680EB',
|
||||
'backgroundColor': '#fff',
|
||||
'borderStyle': 'white'
|
||||
color: '#707070',
|
||||
selectedColor: '#2680EB',
|
||||
backgroundColor: '#fff',
|
||||
borderStyle: 'white',
|
||||
},
|
||||
subPackages: [
|
||||
{
|
||||
root: "pages/search",
|
||||
root: 'pages/search',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/classList",
|
||||
root: 'pages/classList',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/details",
|
||||
root: 'pages/details',
|
||||
pages: [
|
||||
"index",
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/searchList",
|
||||
root: 'pages/searchList',
|
||||
pages: [
|
||||
"searchList",
|
||||
"hightSearchList",
|
||||
"search"
|
||||
]
|
||||
'searchList',
|
||||
'hightSearchList',
|
||||
'search',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/userEdit",
|
||||
root: 'pages/userEdit',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/addressManager",
|
||||
root: 'pages/addressManager',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/addressAdd",
|
||||
root: 'pages/addressAdd',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/company",
|
||||
root: 'pages/company',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/weightList",
|
||||
root: 'pages/weightList',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/weightListAdd",
|
||||
root: 'pages/weightListAdd',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/order",
|
||||
root: 'pages/order',
|
||||
pages: [
|
||||
"index",
|
||||
"comfirm",
|
||||
"orderList/index"
|
||||
]
|
||||
'index',
|
||||
'comfirm',
|
||||
'orderList/index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/editOrder",
|
||||
root: 'pages/editOrder',
|
||||
pages: [
|
||||
"index",
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/subjectList",
|
||||
root: 'pages/subjectList',
|
||||
pages: [
|
||||
"index",
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/creditLine",
|
||||
root: 'pages/creditLine',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/creditUsed",
|
||||
root: 'pages/creditUsed',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/depositBeforehandDetail",
|
||||
root: 'pages/depositBeforehandDetail',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/depositBeforehand",
|
||||
root: 'pages/depositBeforehand',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/depositList",
|
||||
root: 'pages/depositList',
|
||||
pages: [
|
||||
"index"
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/salesAfter",
|
||||
root: 'pages/salesAfter',
|
||||
pages: [
|
||||
"index",
|
||||
"salesAfterList/index"
|
||||
]
|
||||
'index',
|
||||
'salesAfterList/index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/certification",
|
||||
root: 'pages/certification',
|
||||
pages: [
|
||||
"index",
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/applyAfterSales",
|
||||
root: 'pages/applyAfterSales',
|
||||
pages: [
|
||||
"index",
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/collection",
|
||||
root: 'pages/collection',
|
||||
pages: [
|
||||
"index",
|
||||
"collectionClass/index"
|
||||
]
|
||||
'index',
|
||||
'collectionClass/index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/sampleComparison",
|
||||
root: 'pages/sampleComparison',
|
||||
pages: [
|
||||
"index",
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
{
|
||||
root: "pages/bindSalesman",
|
||||
root: 'pages/bindSalesman',
|
||||
pages: [
|
||||
"index",
|
||||
]
|
||||
'index',
|
||||
],
|
||||
},
|
||||
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
16
src/app.tsx
16
src/app.tsx
@ -1,7 +1,7 @@
|
||||
import { FC } from 'react'
|
||||
import ContextBlueTooth from '@/use/contextBlueTooth'
|
||||
import type { FC } from 'react'
|
||||
import { Provider } from 'react-redux'
|
||||
import configStore from './store'
|
||||
import ContextBlueTooth from '@/use/contextBlueTooth'
|
||||
import './app.scss'
|
||||
import Taro, { onAppShow, useDidShow } from '@tarojs/taro'
|
||||
import { shareShop } from './common/util'
|
||||
@ -12,21 +12,21 @@ const App: FC = (params) => {
|
||||
withShareTicket: true,
|
||||
})
|
||||
|
||||
//分享
|
||||
// 分享
|
||||
shareShop()
|
||||
|
||||
//检查版本更新
|
||||
// 检查版本更新
|
||||
onAppShow(() => {
|
||||
const updateManager = Taro.getUpdateManager()
|
||||
updateManager.onCheckForUpdate(function (res) {
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
// 请求完新版本信息的回调
|
||||
console.log('版本信息:', res.hasUpdate)
|
||||
})
|
||||
updateManager.onUpdateReady(function () {
|
||||
updateManager.onUpdateReady(() => {
|
||||
Taro.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
success: function (res) {
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||
updateManager.applyUpdate()
|
||||
@ -34,7 +34,7 @@ const App: FC = (params) => {
|
||||
},
|
||||
})
|
||||
})
|
||||
updateManager.onUpdateFailed(function () {
|
||||
updateManager.onUpdateFailed(() => {
|
||||
console.log('新版本更新失败')
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,86 +1,76 @@
|
||||
module.exports = function(lab1, lab2){
|
||||
|
||||
var rgb2labArray1 = lab1;
|
||||
var rgb2labArray2 = lab2;
|
||||
|
||||
var l1 = rgb2labArray1[0];
|
||||
var a1 = rgb2labArray1[1];
|
||||
var b1 = rgb2labArray1[2];
|
||||
|
||||
var l2 = rgb2labArray2[0];
|
||||
var a2 = rgb2labArray2[1];
|
||||
var b2 = rgb2labArray2[2];
|
||||
|
||||
|
||||
var avg_lp = (l1 + l2) / 2;
|
||||
var c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2));
|
||||
var c2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2));
|
||||
var avg_c = (c1 + c2) / 2;
|
||||
var g = (1- Math.sqrt(Math.pow(avg_c, 7) / (Math.pow(avg_c, 7) + Math.pow(25, 7)))) / 2;
|
||||
|
||||
var a1p = a1 * (1 + g);
|
||||
var a2p = a2 * (1 + g);
|
||||
|
||||
var c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2));
|
||||
var c2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b2, 2));
|
||||
|
||||
var avg_cp = (c1p + c2p) / 2;
|
||||
|
||||
var h1p = rad2deg(Math.atan2(b1, a1p));
|
||||
if(h1p < 0){
|
||||
|
||||
h1p = h1p + 360;
|
||||
}
|
||||
|
||||
var h2p = rad2deg(Math.atan2(b2, a2p));
|
||||
if(h2p < 0){
|
||||
|
||||
h2p = h2p + 360;
|
||||
}
|
||||
|
||||
var avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2;
|
||||
|
||||
var t = 1 - 0.17 * Math.cos(deg2rad(avg_hp - 30)) + 0.24 * Math.cos(deg2rad(2 * avg_hp)) + 0.32 * Math.cos(deg2rad(3 * avg_hp + 6)) - 0.2 * Math.cos(deg2rad(4 * avg_hp - 63))
|
||||
|
||||
var delta_hp = h2p - h1p;
|
||||
if(Math.abs(delta_hp) > 180){
|
||||
if (h2p <= h1p) {
|
||||
delta_hp += 360;
|
||||
}
|
||||
else {
|
||||
delta_hp -= 360;
|
||||
}
|
||||
}
|
||||
|
||||
var delta_lp = l2 - l1;
|
||||
var delta_cp = c2p - c1p;
|
||||
|
||||
delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2);
|
||||
|
||||
var s_l = 1 + ((0.015 * Math.pow(avg_lp - 50, 2)) / Math.sqrt(20 + Math.pow(avg_lp - 50, 2)));
|
||||
var s_c = 1 + 0.045 * avg_cp
|
||||
var s_h = 1 + 0.015 * avg_cp * t;
|
||||
|
||||
var delta_ro = 30 * Math.exp( - (Math.pow((avg_hp - 275) / 25, 2)));
|
||||
var r_c = 2 * Math.sqrt(Math.pow(avg_cp, 7) / (Math.pow(avg_cp, 7) + Math.pow(25, 7)));
|
||||
var r_t = -r_c * Math.sin(2 * deg2rad(delta_ro));
|
||||
|
||||
var kl = 1, kc =1, kh = 1;
|
||||
module.exports = function(lab1, lab2) {
|
||||
const rgb2labArray1 = lab1
|
||||
const rgb2labArray2 = lab2
|
||||
|
||||
var delta_e = Math.sqrt(Math.pow(delta_lp / (kl * s_l), 2) + Math.pow(delta_cp / (kc * s_c), 2) + Math.pow(delta_hp / (kh * s_h), 2) + r_t * (delta_cp / (kc * s_c)) * (delta_hp / (kh * s_h)))
|
||||
const l1 = rgb2labArray1[0]
|
||||
const a1 = rgb2labArray1[1]
|
||||
const b1 = rgb2labArray1[2]
|
||||
|
||||
return delta_e
|
||||
|
||||
|
||||
function rad2deg(rad){
|
||||
|
||||
return 360 * rad / (2 * Math.PI);
|
||||
}
|
||||
function deg2rad(deg){
|
||||
|
||||
return (2 * Math.PI * deg) / 360;
|
||||
}
|
||||
const l2 = rgb2labArray2[0]
|
||||
const a2 = rgb2labArray2[1]
|
||||
const b2 = rgb2labArray2[2]
|
||||
|
||||
const avg_lp = (l1 + l2) / 2
|
||||
const c1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2))
|
||||
const c2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2))
|
||||
const avg_c = (c1 + c2) / 2
|
||||
const g = (1 - Math.sqrt(Math.pow(avg_c, 7) / (Math.pow(avg_c, 7) + Math.pow(25, 7)))) / 2
|
||||
|
||||
const a1p = a1 * (1 + g)
|
||||
const a2p = a2 * (1 + g)
|
||||
|
||||
const c1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b1, 2))
|
||||
const c2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b2, 2))
|
||||
|
||||
const avg_cp = (c1p + c2p) / 2
|
||||
|
||||
let h1p = rad2deg(Math.atan2(b1, a1p))
|
||||
if (h1p < 0) {
|
||||
h1p = h1p + 360
|
||||
}
|
||||
|
||||
let h2p = rad2deg(Math.atan2(b2, a2p))
|
||||
if (h2p < 0) {
|
||||
h2p = h2p + 360
|
||||
}
|
||||
|
||||
const avg_hp = Math.abs(h1p - h2p) > 180 ? (h1p + h2p + 360) / 2 : (h1p + h1p) / 2
|
||||
|
||||
const t = 1 - 0.17 * Math.cos(deg2rad(avg_hp - 30)) + 0.24 * Math.cos(deg2rad(2 * avg_hp)) + 0.32 * Math.cos(deg2rad(3 * avg_hp + 6)) - 0.2 * Math.cos(deg2rad(4 * avg_hp - 63))
|
||||
|
||||
let delta_hp = h2p - h1p
|
||||
if (Math.abs(delta_hp) > 180) {
|
||||
if (h2p <= h1p) {
|
||||
delta_hp += 360
|
||||
}
|
||||
else {
|
||||
delta_hp -= 360
|
||||
}
|
||||
}
|
||||
|
||||
const delta_lp = l2 - l1
|
||||
const delta_cp = c2p - c1p
|
||||
|
||||
delta_hp = 2 * Math.sqrt(c1p * c2p) * Math.sin(deg2rad(delta_hp) / 2)
|
||||
|
||||
const s_l = 1 + ((0.015 * Math.pow(avg_lp - 50, 2)) / Math.sqrt(20 + Math.pow(avg_lp - 50, 2)))
|
||||
const s_c = 1 + 0.045 * avg_cp
|
||||
const s_h = 1 + 0.015 * avg_cp * t
|
||||
|
||||
const delta_ro = 30 * Math.exp(-(Math.pow((avg_hp - 275) / 25, 2)))
|
||||
const r_c = 2 * Math.sqrt(Math.pow(avg_cp, 7) / (Math.pow(avg_cp, 7) + Math.pow(25, 7)))
|
||||
const r_t = -r_c * Math.sin(2 * deg2rad(delta_ro))
|
||||
|
||||
const kl = 1; const kc = 1; const kh = 1
|
||||
|
||||
const delta_e = Math.sqrt(Math.pow(delta_lp / (kl * s_l), 2) + Math.pow(delta_cp / (kc * s_c), 2) + Math.pow(delta_hp / (kh * s_h), 2) + r_t * (delta_cp / (kc * s_c)) * (delta_hp / (kh * s_h)))
|
||||
|
||||
return delta_e
|
||||
|
||||
function rad2deg(rad) {
|
||||
return 360 * rad / (2 * Math.PI)
|
||||
}
|
||||
function deg2rad(deg) {
|
||||
return (2 * Math.PI * deg) / 360
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -4,10 +4,10 @@ import XyzCom from './xyz'
|
||||
import ColorDiff from './colorDiff'
|
||||
|
||||
export const toRgb = (lab) => {
|
||||
let xyz = LabCom.xyz(lab)
|
||||
return XyzCom.rgb(xyz)
|
||||
const xyz = LabCom.xyz(lab)
|
||||
return XyzCom.rgb(xyz)
|
||||
}
|
||||
|
||||
export const Ediff = (lab1, lab2) => {
|
||||
return ColorDiff(lab1, lab2)
|
||||
}
|
||||
return ColorDiff(lab1, lab2)
|
||||
}
|
||||
|
||||
@ -1,54 +1,54 @@
|
||||
|
||||
var xyz = require('./xyz');
|
||||
const xyz = require('./xyz')
|
||||
|
||||
module.exports = {
|
||||
name: 'lab',
|
||||
min: [0,-100,-100],
|
||||
max: [100,100,100],
|
||||
channel: ['lightness', 'a', 'b'],
|
||||
alias: ['LAB', 'cielab'],
|
||||
name: 'lab',
|
||||
min: [0, -100, -100],
|
||||
max: [100, 100, 100],
|
||||
channel: ['lightness', 'a', 'b'],
|
||||
alias: ['LAB', 'cielab'],
|
||||
|
||||
xyz: function(lab) {
|
||||
var l = lab[0],
|
||||
a = lab[1],
|
||||
b = lab[2],
|
||||
x, y, z, y2;
|
||||
xyz(lab) {
|
||||
const l = lab[0]
|
||||
const a = lab[1]
|
||||
const b = lab[2]
|
||||
let x; let y; let z; let y2
|
||||
|
||||
if (l <= 8) {
|
||||
y = (l * 100) / 903.3;
|
||||
y2 = (7.787 * (y / 100)) + (16 / 116);
|
||||
} else {
|
||||
y = 100 * Math.pow((l + 16) / 116, 3);
|
||||
y2 = Math.pow(y / 100, 1/3);
|
||||
}
|
||||
if (l <= 8) {
|
||||
y = (l * 100) / 903.3
|
||||
y2 = (7.787 * (y / 100)) + (16 / 116)
|
||||
}
|
||||
else {
|
||||
y = 100 * Math.pow((l + 16) / 116, 3)
|
||||
y2 = Math.pow(y / 100, 1 / 3)
|
||||
}
|
||||
|
||||
x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3);
|
||||
x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3)
|
||||
|
||||
z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3);
|
||||
z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3)
|
||||
|
||||
return [x, y, z];
|
||||
}
|
||||
};
|
||||
return [x, y, z]
|
||||
},
|
||||
}
|
||||
|
||||
// extend xyz
|
||||
xyz.lab = function(xyz) {
|
||||
let x = xyz[0]
|
||||
let y = xyz[1]
|
||||
let z = xyz[2]
|
||||
let l; let a; let b
|
||||
|
||||
//extend xyz
|
||||
xyz.lab = function(xyz){
|
||||
var x = xyz[0],
|
||||
y = xyz[1],
|
||||
z = xyz[2],
|
||||
l, a, b;
|
||||
x /= 95.047
|
||||
y /= 100
|
||||
z /= 108.883
|
||||
|
||||
x /= 95.047;
|
||||
y /= 100;
|
||||
z /= 108.883;
|
||||
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116)
|
||||
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116)
|
||||
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116)
|
||||
|
||||
x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
|
||||
y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
|
||||
z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
|
||||
l = (116 * y) - 16
|
||||
a = 500 * (x - y)
|
||||
b = 200 * (y - z)
|
||||
|
||||
l = (116 * y) - 16;
|
||||
a = 500 * (x - y);
|
||||
b = 200 * (y - z);
|
||||
|
||||
return [l, a, b];
|
||||
};
|
||||
return [l, a, b]
|
||||
}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: 'rgb',
|
||||
min: [0,0,0],
|
||||
max: [255,255,255],
|
||||
channel: ['red', 'green', 'blue'],
|
||||
alias: ['RGB']
|
||||
};
|
||||
name: 'rgb',
|
||||
min: [0, 0, 0],
|
||||
max: [255, 255, 255],
|
||||
channel: ['red', 'green', 'blue'],
|
||||
alias: ['RGB'],
|
||||
}
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
|
||||
var rgb = require('./rgb');
|
||||
|
||||
var xyz = {
|
||||
name: 'xyz',
|
||||
min: [0,0,0],
|
||||
channel: ['X','Y','Z'],
|
||||
alias: ['XYZ', 'ciexyz', 'cie1931']
|
||||
};
|
||||
const rgb = require('./rgb')
|
||||
|
||||
const xyz = {
|
||||
name: 'xyz',
|
||||
min: [0, 0, 0],
|
||||
channel: ['X', 'Y', 'Z'],
|
||||
alias: ['XYZ', 'ciexyz', 'cie1931'],
|
||||
}
|
||||
|
||||
/**
|
||||
* Whitepoint reference values with observer/illuminant
|
||||
@ -15,57 +14,55 @@ var xyz = {
|
||||
* http://en.wikipedia.org/wiki/Standard_illuminant
|
||||
*/
|
||||
xyz.whitepoint = {
|
||||
//1931 2°
|
||||
2: {
|
||||
//incadescent
|
||||
A:[109.85, 100, 35.585],
|
||||
// B:[],
|
||||
C: [98.074, 100, 118.232],
|
||||
D50: [96.422, 100, 82.521],
|
||||
D55: [95.682, 100, 92.149],
|
||||
//daylight
|
||||
D65: [95.045592705167, 100, 108.9057750759878],
|
||||
D75: [94.972, 100, 122.638],
|
||||
//flourescent
|
||||
// F1: [],
|
||||
F2: [99.187, 100, 67.395],
|
||||
// F3: [],
|
||||
// F4: [],
|
||||
// F5: [],
|
||||
// F6:[],
|
||||
F7: [95.044, 100, 108.755],
|
||||
// F8: [],
|
||||
// F9: [],
|
||||
// F10: [],
|
||||
F11: [100.966, 100, 64.370],
|
||||
// F12: [],
|
||||
E: [100,100,100]
|
||||
},
|
||||
|
||||
//1964 10°
|
||||
10: {
|
||||
//incadescent
|
||||
A:[111.144, 100, 35.200],
|
||||
C: [97.285, 100, 116.145],
|
||||
D50: [96.720, 100, 81.427],
|
||||
D55: [95.799, 100, 90.926],
|
||||
//daylight
|
||||
D65: [94.811, 100, 107.304],
|
||||
D75: [94.416, 100, 120.641],
|
||||
//flourescent
|
||||
F2: [103.280, 100, 69.026],
|
||||
F7: [95.792, 100, 107.687],
|
||||
F11: [103.866, 100, 65.627],
|
||||
E: [100,100,100]
|
||||
}
|
||||
};
|
||||
// 1931 2°
|
||||
2: {
|
||||
// incadescent
|
||||
A: [109.85, 100, 35.585],
|
||||
// B:[],
|
||||
C: [98.074, 100, 118.232],
|
||||
D50: [96.422, 100, 82.521],
|
||||
D55: [95.682, 100, 92.149],
|
||||
// daylight
|
||||
D65: [95.045592705167, 100, 108.9057750759878],
|
||||
D75: [94.972, 100, 122.638],
|
||||
// flourescent
|
||||
// F1: [],
|
||||
F2: [99.187, 100, 67.395],
|
||||
// F3: [],
|
||||
// F4: [],
|
||||
// F5: [],
|
||||
// F6:[],
|
||||
F7: [95.044, 100, 108.755],
|
||||
// F8: [],
|
||||
// F9: [],
|
||||
// F10: [],
|
||||
F11: [100.966, 100, 64.370],
|
||||
// F12: [],
|
||||
E: [100, 100, 100],
|
||||
},
|
||||
|
||||
// 1964 10°
|
||||
10: {
|
||||
// incadescent
|
||||
A: [111.144, 100, 35.200],
|
||||
C: [97.285, 100, 116.145],
|
||||
D50: [96.720, 100, 81.427],
|
||||
D55: [95.799, 100, 90.926],
|
||||
// daylight
|
||||
D65: [94.811, 100, 107.304],
|
||||
D75: [94.416, 100, 120.641],
|
||||
// flourescent
|
||||
F2: [103.280, 100, 69.026],
|
||||
F7: [95.792, 100, 107.687],
|
||||
F11: [103.866, 100, 65.627],
|
||||
E: [100, 100, 100],
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Top values are the whitepoint’s top values, default are D65
|
||||
*/
|
||||
xyz.max = xyz.whitepoint[2].D65;
|
||||
|
||||
xyz.max = xyz.whitepoint[2].D65
|
||||
|
||||
/**
|
||||
* Transform xyz to rgb
|
||||
@ -74,39 +71,40 @@ xyz.max = xyz.whitepoint[2].D65;
|
||||
*
|
||||
* @return {Array} RGB values
|
||||
*/
|
||||
xyz.rgb = function (_xyz, white) {
|
||||
//FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then
|
||||
white = white || xyz.whitepoint[2].E;
|
||||
xyz.rgb = function(_xyz, white) {
|
||||
// FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then
|
||||
white = white || xyz.whitepoint[2].E
|
||||
|
||||
var x = _xyz[0] / white[0],
|
||||
y = _xyz[1] / white[1],
|
||||
z = _xyz[2] / white[2],
|
||||
r, g, b;
|
||||
const x = _xyz[0] / white[0]
|
||||
const y = _xyz[1] / white[1]
|
||||
const z = _xyz[2] / white[2]
|
||||
let r; let g; let b
|
||||
|
||||
// assume sRGB
|
||||
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
||||
r = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293);
|
||||
g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175);
|
||||
b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878);
|
||||
// assume sRGB
|
||||
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
||||
r = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293)
|
||||
g = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175)
|
||||
b = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878)
|
||||
|
||||
r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
|
||||
: r = (r * 12.92);
|
||||
r = r > 0.0031308
|
||||
? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
|
||||
: r = (r * 12.92)
|
||||
|
||||
g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
|
||||
: g = (g * 12.92);
|
||||
g = g > 0.0031308
|
||||
? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
|
||||
: g = (g * 12.92)
|
||||
|
||||
b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
|
||||
: b = (b * 12.92);
|
||||
b = b > 0.0031308
|
||||
? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
|
||||
: b = (b * 12.92)
|
||||
|
||||
r = Math.min(Math.max(0, r), 1);
|
||||
g = Math.min(Math.max(0, g), 1);
|
||||
b = Math.min(Math.max(0, b), 1);
|
||||
r = Math.min(Math.max(0, r), 1)
|
||||
g = Math.min(Math.max(0, g), 1)
|
||||
b = Math.min(Math.max(0, b), 1)
|
||||
|
||||
return [r * 255, g * 255, b * 255];
|
||||
return [r * 255, g * 255, b * 255]
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* RGB to XYZ
|
||||
*
|
||||
@ -115,24 +113,22 @@ xyz.rgb = function (_xyz, white) {
|
||||
* @return {Array} XYZ channels
|
||||
*/
|
||||
rgb.xyz = function(rgb, white) {
|
||||
var r = rgb[0] / 255,
|
||||
g = rgb[1] / 255,
|
||||
b = rgb[2] / 255;
|
||||
let r = rgb[0] / 255
|
||||
let g = rgb[1] / 255
|
||||
let b = rgb[2] / 255
|
||||
|
||||
// assume sRGB
|
||||
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
|
||||
g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
|
||||
b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
|
||||
// assume sRGB
|
||||
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92)
|
||||
g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92)
|
||||
b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92)
|
||||
|
||||
var x = (r * 0.41239079926595) + (g * 0.35758433938387) + (b * 0.18048078840183);
|
||||
var y = (r * 0.21263900587151) + (g * 0.71516867876775) + (b * 0.072192315360733);
|
||||
var z = (r * 0.019330818715591) + (g * 0.11919477979462) + (b * 0.95053215224966);
|
||||
const x = (r * 0.41239079926595) + (g * 0.35758433938387) + (b * 0.18048078840183)
|
||||
const y = (r * 0.21263900587151) + (g * 0.71516867876775) + (b * 0.072192315360733)
|
||||
const z = (r * 0.019330818715591) + (g * 0.11919477979462) + (b * 0.95053215224966)
|
||||
|
||||
white = white || xyz.whitepoint[2].E;
|
||||
white = white || xyz.whitepoint[2].E
|
||||
|
||||
return [x * white[0], y * white[1], z * white[2]];
|
||||
};
|
||||
return [x * white[0], y * white[1], z * white[2]]
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = xyz;
|
||||
module.exports = xyz
|
||||
|
||||
@ -1,146 +1,141 @@
|
||||
import { uint32ToUint8Array, uint8ArrayToHex } from "./utils";
|
||||
import { uint32ToUint8Array, uint8ArrayToHex } from './utils'
|
||||
|
||||
export class Command {
|
||||
// 测量序号
|
||||
static measureId = 1;
|
||||
// 测量序号
|
||||
static measureId = 1
|
||||
|
||||
// 命令完整响应的长度
|
||||
responseSize = 0;
|
||||
// 命令发送的数据
|
||||
content = new Uint8Array(0);
|
||||
// 命令响应的数据
|
||||
response = new Uint8Array(0);
|
||||
// 等待响应的超时时间
|
||||
timeout = 3000;
|
||||
// 发送的数据是否需要生成和校验值
|
||||
needSign = true;
|
||||
|
||||
// 命令完整响应的长度
|
||||
responseSize = 0
|
||||
// 命令发送的数据
|
||||
content = new Uint8Array(0)
|
||||
// 命令响应的数据
|
||||
response = new Uint8Array(0)
|
||||
// 等待响应的超时时间
|
||||
timeout = 3000
|
||||
// 发送的数据是否需要生成和校验值
|
||||
needSign = true
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {Uint8Array|ArrayBuffer|number[]} content
|
||||
* @param {number} responseSize
|
||||
* @param {number} timeout
|
||||
* @param {number} responseSize
|
||||
* @param {number} timeout
|
||||
* @param {boolean} needSign
|
||||
*/
|
||||
constructor(content, responseSize, timeout = 3000, needSign = true) {
|
||||
if (content instanceof Uint8Array) {
|
||||
this.content = content;
|
||||
} else {
|
||||
this.content = new Uint8Array(content);
|
||||
}
|
||||
this.responseSize = responseSize;
|
||||
if (typeof timeout === 'number' && timeout >= 0) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
this.needSign = needSign;
|
||||
constructor(content, responseSize, timeout = 3000, needSign = true) {
|
||||
if (content instanceof Uint8Array) {
|
||||
this.content = content
|
||||
}
|
||||
else {
|
||||
this.content = new Uint8Array(content)
|
||||
}
|
||||
|
||||
/**
|
||||
this.responseSize = responseSize
|
||||
if (typeof timeout === 'number' && timeout >= 0) {
|
||||
this.timeout = timeout
|
||||
}
|
||||
this.needSign = needSign
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个 ArrayBuffer 数组, 用于发送
|
||||
* @returns {ArrayBuffer[]}
|
||||
*/
|
||||
get data() {
|
||||
if (this.content.length === 0) throw new Error('正文内容不能为空');
|
||||
const data = [];
|
||||
const b = new Uint8Array(this.content.buffer);
|
||||
if (this.needSign) {
|
||||
b[b.length - 1] = Command.getSign(b);
|
||||
}
|
||||
for (let i = 0; i < b.length; i += 20) {
|
||||
data.push(b.slice(i, i + 20).buffer);
|
||||
}
|
||||
return data;
|
||||
get data() {
|
||||
if (this.content.length === 0) { throw new Error('正文内容不能为空') }
|
||||
const data = []
|
||||
const b = new Uint8Array(this.content.buffer)
|
||||
if (this.needSign) {
|
||||
b[b.length - 1] = Command.getSign(b)
|
||||
}
|
||||
|
||||
/** 是否接收完成 */
|
||||
get isComplete() {
|
||||
return this.response.length >= this.responseSize;
|
||||
for (let i = 0; i < b.length; i += 20) {
|
||||
data.push(b.slice(i, i + 20).buffer)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
/** 是否有效 */
|
||||
get isValid() {
|
||||
return Command.getSign(this.response) === this.response[this.response.length - 1];
|
||||
}
|
||||
/** 是否接收完成 */
|
||||
get isComplete() {
|
||||
return this.response.length >= this.responseSize
|
||||
}
|
||||
|
||||
/**
|
||||
/** 是否有效 */
|
||||
get isValid() {
|
||||
return Command.getSign(this.response) === this.response[this.response.length - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充响应数组
|
||||
* @param {ArrayBuffer} buffer
|
||||
* @param {ArrayBuffer} buffer
|
||||
*/
|
||||
fillResponse(buffer) {
|
||||
this.response = new Uint8Array([...this.response, ...(new Uint8Array(buffer))]);
|
||||
}
|
||||
fillResponse(buffer) {
|
||||
this.response = new Uint8Array([...this.response, ...(new Uint8Array(buffer))])
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取和校验值
|
||||
* @param {ArrayBuffer|Uint8Array} buffer
|
||||
* @param {ArrayBuffer|Uint8Array} buffer
|
||||
*/
|
||||
static getSign(buffer) {
|
||||
const _b = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
||||
let sum = 0;
|
||||
_b.slice(0, _b.length - 1).forEach(i => sum += i);
|
||||
return new Uint8Array([sum])[0];
|
||||
}
|
||||
static getSign(buffer) {
|
||||
const _b = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer)
|
||||
let sum = 0
|
||||
_b.slice(0, _b.length - 1).forEach(i => sum += i)
|
||||
return new Uint8Array([sum])[0]
|
||||
}
|
||||
|
||||
// 唤醒命令
|
||||
static WakeUp = new Command([0xf0], 0, 0, false);
|
||||
// 唤醒命令
|
||||
static WakeUp = new Command([0xF0], 0, 0, false)
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取测量命令
|
||||
* @param {number} mode
|
||||
* @param {number} mode
|
||||
*/
|
||||
static measure(mode = 0) {
|
||||
Command.measureId += 1;
|
||||
const measureId = uint32ToUint8Array(Command.measureId);
|
||||
return new Command([0xbb, 1, mode, ...measureId, 0, 0xff, 0], 10, 1500);
|
||||
}
|
||||
static measure(mode = 0) {
|
||||
Command.measureId += 1
|
||||
const measureId = uint32ToUint8Array(Command.measureId)
|
||||
return new Command([0xBB, 1, mode, ...measureId, 0, 0xFF, 0], 10, 1500)
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取测量数据 (Lab)
|
||||
* @param {number} mode
|
||||
* @param {number} mode
|
||||
*/
|
||||
static getLab(mode = 0) {
|
||||
return new Command([0xbb, 3, mode, 0, 0, 0, 0, 0, 0xff, 0], 20, 1500);
|
||||
}
|
||||
static getLab(mode = 0) {
|
||||
return new Command([0xBB, 3, mode, 0, 0, 0, 0, 0, 0xFF, 0], 20, 1500)
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取测量数据 (RGB)
|
||||
* @param {number} mode
|
||||
* @param {number} mode
|
||||
*/
|
||||
static getRGB(mode = 0) {
|
||||
return new Command([0xbb, 4, mode, 0, 0, 0, 0, 0, 0xff, 0], 20, 1500);
|
||||
}
|
||||
static getRGB(mode = 0) {
|
||||
return new Command([0xBB, 4, mode, 0, 0, 0, 0, 0, 0xFF, 0], 20, 1500)
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取测量的光谱数据
|
||||
* @param {number} mode
|
||||
*/
|
||||
static getSpectral(mode = 0) {
|
||||
return new Command([0xbb, 2, 0x10 + mode, 0, 0, 0 ,0 ,0, 0xff, 0], 200, 5000);
|
||||
}
|
||||
static getSpectral(mode = 0) {
|
||||
return new Command([0xBB, 2, 0x10 + mode, 0, 0, 0, 0, 0, 0xFF, 0], 200, 5000)
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 白校准
|
||||
* @param {number} check 是否判断校准成功 1 判断 0 不判断
|
||||
*/
|
||||
static whiteCalibrate(check = 1) {
|
||||
return new Command([0xbb, 0x11, check, 0, 0, 0, 0, 0, 0xff, 0], 10, 1500);
|
||||
}
|
||||
static whiteCalibrate(check = 1) {
|
||||
return new Command([0xBB, 0x11, check, 0, 0, 0, 0, 0, 0xFF, 0], 10, 1500)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 黑校准
|
||||
* @param {number} check 是否判断校准成功
|
||||
*/
|
||||
static blackCalibrate(check = 1) {
|
||||
return new Command([0xbb, 0x10, check, 0, 0, 0, 0, 0, 0xff, 0], 10, 1500);
|
||||
}
|
||||
static blackCalibrate(check = 1) {
|
||||
return new Command([0xBB, 0x10, check, 0, 0, 0, 0, 0, 0xFF, 0], 10, 1500)
|
||||
}
|
||||
|
||||
/** 获取校准状态 */
|
||||
static GetCalibrationInf = new Command([0xBB, 0x1E, 0, 0, 0, 0, 0, 0, 0xFF, 0], 20, 1500)
|
||||
|
||||
/** 获取校准状态 */
|
||||
static GetCalibrationInf = new Command([0xbb, 0x1e, 0, 0, 0, 0, 0, 0, 0xff, 0], 20, 1500);
|
||||
|
||||
|
||||
|
||||
static GetDeviceInf = new Command([0xbb, 0x12, 0x01, 0, 0, 0, 0, 0, 0xff, 0], 200, 5000);
|
||||
}
|
||||
static GetDeviceInf = new Command([0xBB, 0x12, 0x01, 0, 0, 0, 0, 0, 0xFF, 0], 200, 5000)
|
||||
}
|
||||
|
||||
@ -1,70 +1,65 @@
|
||||
/**
|
||||
* Uint32 转 Uint8 数组
|
||||
* @param {number} n
|
||||
* @param {number} n
|
||||
*/
|
||||
export function uint32ToUint8Array(n) {
|
||||
return new Uint8Array(new Uint32Array([n]).buffer);
|
||||
return new Uint8Array(new Uint32Array([n]).buffer)
|
||||
}
|
||||
|
||||
/**
|
||||
* Uint8 数组 转 Float32
|
||||
* @param {Uint8Array} raw
|
||||
* @param {Uint8Array} raw
|
||||
*/
|
||||
export function uint8ArrayToFloat32(raw) {
|
||||
return new Float32Array(raw.buffer)[0];
|
||||
return new Float32Array(raw.buffer)[0]
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uint8 数组 转 Uint16
|
||||
* @param {Uint8Array} raw
|
||||
* @param {Uint8Array} raw
|
||||
*/
|
||||
export function uint8ArrayToUint16(raw) {
|
||||
return new Uint16Array(raw.buffer)[0];
|
||||
return new Uint16Array(raw.buffer)[0]
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uint8 数组转 Uint32
|
||||
* @param {Uint8Array} raw
|
||||
* @returns
|
||||
* @param {Uint8Array} raw
|
||||
* @returns
|
||||
*/
|
||||
export function uint8ArrayToUnit32(raw) {
|
||||
return new Uint32Array(raw.buffer)[0];
|
||||
return new Uint32Array(raw.buffer)[0]
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 等待指定时长
|
||||
* @param {number} duration
|
||||
* @param {number} duration
|
||||
*/
|
||||
export function waitFor(duration) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, duration);
|
||||
});
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, duration)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* uint8 数组转 hex 字符串
|
||||
* @param {Uint8Array} raw
|
||||
* @param {Uint8Array} raw
|
||||
*/
|
||||
export function uint8ArrayToHex(raw) {
|
||||
const s = [];
|
||||
raw.forEach(i => {
|
||||
const b = i.toString(16);
|
||||
s.push(b.length > 1 ? b : `0${b}`);
|
||||
});
|
||||
return s.join(' ');
|
||||
const s = []
|
||||
raw.forEach((i) => {
|
||||
const b = i.toString(16)
|
||||
s.push(b.length > 1 ? b : `0${b}`)
|
||||
})
|
||||
return s.join(' ')
|
||||
}
|
||||
|
||||
|
||||
// 二进制转字符串(ascii)
|
||||
export function bufferToString(buffer) {
|
||||
let str = "";
|
||||
for (let code of buffer) {
|
||||
if (code === 0) break;
|
||||
str += utf82string(code);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
let str = ''
|
||||
for (const code of buffer) {
|
||||
if (code === 0) { break }
|
||||
str += utf82string(code)
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import Qs from 'qs'
|
||||
* @param type false 跳转普通页面,true 跳转tabbar页面
|
||||
*/
|
||||
type ParamLink = 'navigateTo' | 'switchTab' | 'reLaunch' | 'redirectTo'
|
||||
export const goLink = (path: string = '', params: object | null = null, way: ParamLink = 'navigateTo') => {
|
||||
export const goLink = (path = '', params: object | null = null, way: ParamLink = 'navigateTo') => {
|
||||
if (path) {
|
||||
// let params_str = Qs_.stringify(params || {}, { encode: false })
|
||||
// path = params_str ? path + '?' + params_str : path
|
||||
@ -18,17 +18,18 @@ export const goLink = (path: string = '', params: object | null = null, way: Par
|
||||
}
|
||||
const setUrlQuery = (options: { url: string; query: object | null }) => {
|
||||
let { url, query } = options
|
||||
if (!url) return ''
|
||||
if (!url) { return '' }
|
||||
if (query) {
|
||||
let queryArr: any[] = []
|
||||
const queryArr: any[] = []
|
||||
for (const key in query) {
|
||||
if (query.hasOwnProperty(key)) {
|
||||
queryArr.push(`${key}=${query[key]}`)
|
||||
}
|
||||
}
|
||||
if (url.indexOf('?') !== -1) {
|
||||
if (url.includes('?')) {
|
||||
url = `${url}&${queryArr.join('&')}`
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
url = `${url}?${queryArr.join('&')}`
|
||||
}
|
||||
}
|
||||
@ -42,12 +43,15 @@ const setUrlQuery = (options: { url: string; query: object | null }) => {
|
||||
export const isEmptyObject = (object: any) => {
|
||||
if (object == undefined || object == null || Number.isNaN(object)) {
|
||||
return true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (object.constructor == Object) {
|
||||
return Reflect.ownKeys(object).length == 0
|
||||
} else if (object.constructor == Array) {
|
||||
}
|
||||
else if (object.constructor == Array) {
|
||||
return object.length == 0
|
||||
} else if (object.constructor == String) {
|
||||
}
|
||||
else if (object.constructor == String) {
|
||||
return object == ''
|
||||
}
|
||||
}
|
||||
@ -56,7 +60,7 @@ export const isEmptyObject = (object: any) => {
|
||||
|
||||
/**
|
||||
* 表单检索
|
||||
* @param data
|
||||
* @param data
|
||||
* @param rules = {
|
||||
account: [{
|
||||
message: "请输入正确的用户名",
|
||||
@ -70,25 +74,27 @@ export const isEmptyObject = (object: any) => {
|
||||
// regex: /\d/
|
||||
}]
|
||||
};
|
||||
* @param message
|
||||
* @returns
|
||||
* @param message
|
||||
* @returns
|
||||
*/
|
||||
export const retrieval = (data: any, rules?: Object, message: string = '请填写完信息') => {
|
||||
export const retrieval = (data: any, rules?: Object, message = '请填写完信息') => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (rules) {
|
||||
const keys = Reflect.ownKeys(rules)
|
||||
const result = keys.some((key: any) => {
|
||||
for (let item of (rules as any)[key]) {
|
||||
for (const item of (rules as any)[key]) {
|
||||
let _res = false
|
||||
if (item.validator) {
|
||||
if (item.validator(data[key], item)) {
|
||||
_res = true
|
||||
}
|
||||
} else if (item.regex) {
|
||||
}
|
||||
else if (item.regex) {
|
||||
if (!item.regex.test(data[key])) {
|
||||
_res = true
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (isEmptyObject(data[key])) {
|
||||
_res = true
|
||||
}
|
||||
@ -100,7 +106,8 @@ export const retrieval = (data: any, rules?: Object, message: string = '请填
|
||||
if (result) {
|
||||
reject(message)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const keys = Reflect.ownKeys(data)
|
||||
if (keys.some((key: any) => isEmptyObject(data[key]))) {
|
||||
reject(message)
|
||||
|
||||
@ -18,27 +18,27 @@ export const BASE_URL = CURRENT_BASE_URL
|
||||
|
||||
// CDN
|
||||
// 生成密钥
|
||||
export const GET_UPLOAD_SIGN = `/upyun/getsign` // 请求签名 url
|
||||
export const UPLOAD_CDN_URL = `https://v0.api.upyun.com/`
|
||||
export const GET_UPLOAD_SIGN = '/upyun/getsign' // 请求签名 url
|
||||
export const UPLOAD_CDN_URL = 'https://v0.api.upyun.com/'
|
||||
|
||||
// cdn
|
||||
export const IMG_CND_Prefix = CURRENT_ENV.includes('production') ? 'https://cdn.zzfzyc.com' : 'https://test.cdn.zzfzyc.com'
|
||||
// export const IMG_CND_Prefix = CURRENT_ENV.includes('production') ? 'https://cdn.zzfzyc.com' : 'https://cdn.zzfzyc.com'
|
||||
|
||||
//在线支付图片baseUrl
|
||||
// 在线支付图片baseUrl
|
||||
export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_CAP_HTML_TO_IMAGE_BASE_URL
|
||||
// export const CAP_HTML_TO_IMAGE_BASE_URL = 'http://192.168.1.127:8081'
|
||||
|
||||
// 上传图片视频
|
||||
export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}`
|
||||
|
||||
//appid
|
||||
// appid
|
||||
export const WX_APPID = 'wx68d92d7cbf0b6963'
|
||||
|
||||
//支付码单跳转链接
|
||||
// 支付码单跳转链接
|
||||
export const PAY_H5_CODE_URL = CURRENT_PAY_H5_CODE_URL
|
||||
|
||||
//场景值
|
||||
// 场景值
|
||||
export const SCENE = {
|
||||
SearchScene: 0, //商城面料搜索
|
||||
SearchScene: 0, // 商城面料搜索
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
//订单状态枚举
|
||||
// 订单状态枚举
|
||||
export const ORDER_STATUS = {
|
||||
SaleorderstatusWaitingPrePayment: { value: 10, label: '预付款' }, // 预付款
|
||||
SaleOrderStatusBooking: { value: 0, label: '待接单' }, // 待接单
|
||||
SaleOrderStatusArranging: { value: 1, label: '配布中' }, // 配布中
|
||||
SaleOrderStatusArranged: { value: 2, label: '已配布' }, // 已配布
|
||||
SaleOrderStatusWaitingPayment: { value: 7, label: '待付款' }, // 待付款
|
||||
SaleOrderStatusTaking: { value: 11, label: '提货中' }, //提货中
|
||||
SaleOrderStatusTaking: { value: 11, label: '提货中' }, // 提货中
|
||||
SaleOrderStatusWaitingDelivery: { value: 3, label: '待发货' }, // 待发货
|
||||
SaleOrderStatusWaitingReceipt: { value: 8, label: '待收货' }, // 待收货
|
||||
SaleOrderStatusAlreadyReceipt: { value: 9, label: '已收货' }, // 已收货
|
||||
@ -14,7 +14,7 @@ export const ORDER_STATUS = {
|
||||
SaleOrderStatusCancel: { value: 5, label: '已取消' }, // 已取消
|
||||
}
|
||||
|
||||
//售后单状态枚举
|
||||
// 售后单状态枚举
|
||||
export const AFTER_ORDER_STATUS = {
|
||||
ReturnStageApplying: { value: 0, label: '申请中' }, // 申请中
|
||||
ReturnStageWaitCheck: { value: 1, label: '退货中' }, // 退货中
|
||||
@ -26,7 +26,7 @@ export const AFTER_ORDER_STATUS = {
|
||||
ReturnStageRejected: { value: 7, label: '已拒绝' }, // 已拒绝
|
||||
}
|
||||
|
||||
//支付方式
|
||||
// 支付方式
|
||||
export const PAYMENT_METHOD = {
|
||||
PaymentMethodPreDeposit: { value: 2, label: '预存款' },
|
||||
PaymentMethodAccountPeriod: { value: 3, label: '账期' },
|
||||
@ -35,7 +35,7 @@ export const PAYMENT_METHOD = {
|
||||
PaymentMethodCashOnDelivery: { value: 5, label: '货到付款' },
|
||||
}
|
||||
|
||||
//订单类型
|
||||
// 订单类型
|
||||
export const SALE_MODE = {
|
||||
SaLeModeBulk: { value: 0, label: '大货' },
|
||||
SaleModeLengthCut: { value: 1, label: '剪版' },
|
||||
@ -43,20 +43,20 @@ export const SALE_MODE = {
|
||||
}
|
||||
export type saleModeType = 0 | 1 | 2
|
||||
|
||||
//分享场景枚举
|
||||
// 分享场景枚举
|
||||
export const SHARE_SCENE = {
|
||||
ShareDetail: { value: 1, label: '详情分享' },
|
||||
SharePage: { value: 2, label: '页面分享' },
|
||||
}
|
||||
|
||||
//订阅消息
|
||||
// 订阅消息
|
||||
export const SUBSCRIPTION_MESSAGE_SCENE = {
|
||||
SubmitOrder: { value: 1, label: '确认下单' },
|
||||
ToPay: { value: 2, label: '去付款' },
|
||||
ApplyGoods: { value: 3, label: '申请退款' },
|
||||
}
|
||||
|
||||
//应收单退款状态枚举
|
||||
// 应收单退款状态枚举
|
||||
export const REFUND_STATUS = {
|
||||
ShouldCollectOrderRefundTypeUnknown: { value: 0, label: '未知退款' },
|
||||
ShouldCollectOrderRefundTypeAdvanceReceiptRefund: { value: 1, label: '预收退款' },
|
||||
@ -64,7 +64,7 @@ export const REFUND_STATUS = {
|
||||
ShouldCollectOrderRefundTypeSalesRefund: { value: 3, label: '销售退款' },
|
||||
}
|
||||
|
||||
//申请单退款状态枚举
|
||||
// 申请单退款状态枚举
|
||||
export const REFUND_STATUS_ORDER = {
|
||||
ReturnApplyOrderTypeAdvanceReceiptRefund: { value: 2, label: '预收退款' }, // 预收退款
|
||||
ReturnApplyOrderTypeReturnForRefund: { value: 1, label: '退货退款' }, // 退货退款
|
||||
|
||||
@ -20,7 +20,8 @@ export const formatRemoveHashTag = (val = '') => {
|
||||
export const formatHashTag = (code = '', name = '', mode = 'both') => {
|
||||
if (mode == 'both') {
|
||||
return `${formatRemoveHashTag(code)}# ${name}`
|
||||
} else if (mode == 'name') {
|
||||
}
|
||||
else if (mode == 'name') {
|
||||
return `${name}`
|
||||
}
|
||||
}
|
||||
@ -40,7 +41,7 @@ export const weightDigit = 1000
|
||||
* @returns
|
||||
*/
|
||||
export const formatPriceDiv = (val, digit = Digit, priceStatus = false) => {
|
||||
let res = strip(Number(val / digit)) || 0
|
||||
const res = strip(Number(val / digit)) || 0
|
||||
return priceStatus ? numberWithCommas({ number: res }) : res
|
||||
}
|
||||
/**
|
||||
@ -72,13 +73,13 @@ export const formatWeightDiv = (val, digit = weightDigit) => {
|
||||
|
||||
export const formatDateTime = (val, fmt = 'YYYY-MM-DD HH:mm:ss') => {
|
||||
if (val) {
|
||||
let time = new Date(val)
|
||||
let Y = time.getFullYear()
|
||||
let M = time.getMonth() + 1
|
||||
let d = time.getDate()
|
||||
let h = time.getHours()
|
||||
let m = time.getMinutes()
|
||||
let s = time.getSeconds()
|
||||
const time = new Date(val)
|
||||
const Y = time.getFullYear()
|
||||
const M = time.getMonth() + 1
|
||||
const d = time.getDate()
|
||||
const h = time.getHours()
|
||||
const m = time.getMinutes()
|
||||
const s = time.getSeconds()
|
||||
|
||||
fmt = fmt
|
||||
.replace('YYYY', Y)
|
||||
@ -89,7 +90,8 @@ export const formatDateTime = (val, fmt = 'YYYY-MM-DD HH:mm:ss') => {
|
||||
.replace('ss', s.toString().padStart(2, '0'))
|
||||
|
||||
return fmt
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return val
|
||||
}
|
||||
}
|
||||
@ -120,17 +122,18 @@ export const formatMillionYuan = (num, digit = 10000) => {
|
||||
* @returns
|
||||
*/
|
||||
export const toDecimal2 = (x) => {
|
||||
var f = parseFloat(x)
|
||||
let f = parseFloat(x)
|
||||
if (isNaN(f)) {
|
||||
return 0
|
||||
}
|
||||
f = f + ''
|
||||
let index = f.lastIndexOf('.')
|
||||
f = `${f}`
|
||||
const index = f.lastIndexOf('.')
|
||||
if (index >= 0) {
|
||||
let decimal = f.substring(index + 1)
|
||||
const decimal = f.substring(index + 1)
|
||||
if (decimal.length == 1) {
|
||||
f = f.substring(0, index + 1) + decimal + '0'
|
||||
} else {
|
||||
f = `${f.substring(0, index + 1) + decimal}0`
|
||||
}
|
||||
else {
|
||||
f = f.substring(0, index + 1) + decimal.substring(0, 2)
|
||||
}
|
||||
}
|
||||
@ -146,8 +149,9 @@ export const toDecimal2 = (x) => {
|
||||
export const formatImgUrl = (url, suffix = '!w200') => {
|
||||
if (url) {
|
||||
return url.includes('http') ? url + suffix : IMG_CND_Prefix + url + suffix
|
||||
} else {
|
||||
return IMG_CND_Prefix + '/mall/no_img.png'
|
||||
}
|
||||
else {
|
||||
return `${IMG_CND_Prefix}/mall/no_img.png`
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,11 +164,13 @@ export const formatImgUrl = (url, suffix = '!w200') => {
|
||||
*/
|
||||
export const isLabImage = (imgurl, rgb, suffix = '!w200') => {
|
||||
if (imgurl) {
|
||||
return { status: 1, value: IMG_CND_Prefix + '/' + imgurl + suffix }
|
||||
} else if (rgb.r != 0 || rgb.g != 0 || rgb.b != 0) {
|
||||
return { status: 1, value: `${IMG_CND_Prefix}/${imgurl}${suffix}` }
|
||||
}
|
||||
else if (rgb.r != 0 || rgb.g != 0 || rgb.b != 0) {
|
||||
return { status: 2, value: rgb }
|
||||
} else {
|
||||
return { status: 3, value: IMG_CND_Prefix + '/mall/no_img.png' }
|
||||
}
|
||||
else {
|
||||
return { status: 3, value: `${IMG_CND_Prefix}/mall/no_img.png` }
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +183,8 @@ export const numberWithCommas = ({ number = 0, digit = 2 }) => {
|
||||
if (!isNaN(Number(number))) {
|
||||
// return parseFloat(number).toFixed(digit).replace(/^\B(?<!\.\d*)(?=(\d{3})+(?!\d))$/g, ",");
|
||||
return parseFloat(number).toLocaleString('zh', { minimumFractionDigits: digit })
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 0.0
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
import Taro from "@tarojs/taro"
|
||||
import { BASE_URL } from "../constant"
|
||||
import Taro from '@tarojs/taro'
|
||||
import { BASE_URL } from '../constant'
|
||||
|
||||
//解析短码(主要用于右上角按钮分享)
|
||||
// 解析短码(主要用于右上角按钮分享)
|
||||
export const analysisShortCodeApi = (val) => {
|
||||
//解析短码
|
||||
Taro.request({
|
||||
url:BASE_URL+'/v1/mall/shortCode',
|
||||
method:"GET",
|
||||
data:{md5_key: val},
|
||||
success:(res) => {
|
||||
if(res.data.code == 0) {
|
||||
//绑定上下级
|
||||
bindParent(res.data.data.share_user_id)
|
||||
}
|
||||
}
|
||||
})
|
||||
// 解析短码
|
||||
Taro.request({
|
||||
url: `${BASE_URL}/v1/mall/shortCode`,
|
||||
method: 'GET',
|
||||
data: { md5_key: val },
|
||||
success: (res) => {
|
||||
if (res.data.code == 0) {
|
||||
// 绑定上下级
|
||||
bindParent(res.data.data.share_user_id)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//绑定上下级
|
||||
// 绑定上下级
|
||||
const bindParent = (share_user_id) => {
|
||||
//绑定上下级
|
||||
Taro.request({
|
||||
url:BASE_URL+'/v1/mall/shortCode/bind',
|
||||
method:"POST",
|
||||
data:{share_user_id: share_user_id},
|
||||
success:(res) => {
|
||||
if(res.data.code == 0) {
|
||||
//绑定上下级
|
||||
}
|
||||
// 绑定上下级
|
||||
Taro.request({
|
||||
url: `${BASE_URL}/v1/mall/shortCode/bind`,
|
||||
method: 'POST',
|
||||
data: { share_user_id },
|
||||
success: (res) => {
|
||||
if (res.data.code == 0) {
|
||||
// 绑定上下级
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
/**
|
||||
* 设置 系统 本地存储
|
||||
* @param {Object} systemInfo
|
||||
* @param {Object} systemInfo
|
||||
*/
|
||||
export const setSystem = (systemInfo) => {
|
||||
Taro.setStorageSync('system', JSON.stringify(systemInfo))
|
||||
@ -19,7 +18,7 @@ export const getSystem = () => {
|
||||
|
||||
/**
|
||||
* 设置 小程序 本地存储
|
||||
* @param {Object} systemInfo
|
||||
* @param {Object} systemInfo
|
||||
*/
|
||||
export const setAccountInfo = (systemInfo) => {
|
||||
Taro.setStorageSync('accountInfo', JSON.stringify(systemInfo))
|
||||
@ -35,9 +34,9 @@ export const getAccountInfo = () => {
|
||||
|
||||
/**
|
||||
* 设置 参数本地存储
|
||||
* @param {Object} info
|
||||
* @param {Object} info
|
||||
*/
|
||||
export const setParam = (info:Object) => {
|
||||
export const setParam = (info: Object) => {
|
||||
Taro.setStorageSync('params', JSON.stringify(info))
|
||||
}
|
||||
|
||||
@ -46,5 +45,5 @@ export const setParam = (info:Object) => {
|
||||
*/
|
||||
export const getParam = () => {
|
||||
const res = Taro.getStorageSync('params') || null
|
||||
return res?JSON.parse(res):null
|
||||
return res ? JSON.parse(res) : null
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import { formatImgUrl } from './fotmat'
|
||||
import { analysisShortCodeApi } from './shortCode'
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
/**
|
||||
* 防抖
|
||||
@ -11,7 +11,7 @@ import Taro from '@tarojs/taro'
|
||||
export const debounce = (fn, delay) => {
|
||||
let timer: any = null
|
||||
return (...param) => {
|
||||
if (timer) clearTimeout(timer)
|
||||
if (timer) { clearTimeout(timer) }
|
||||
timer = setTimeout(() => {
|
||||
fn(...param)
|
||||
}, delay)
|
||||
@ -27,7 +27,7 @@ export const debounce = (fn, delay) => {
|
||||
export const throttle = (fn, delay) => {
|
||||
let pre = 0
|
||||
return (...params) => {
|
||||
let now = new Date().getTime()
|
||||
const now = new Date().getTime()
|
||||
if (now - pre > delay) {
|
||||
fn(...params)
|
||||
pre = now
|
||||
@ -42,14 +42,15 @@ export const throttle = (fn, delay) => {
|
||||
* @returns
|
||||
*/
|
||||
export const getFilterData = (val = {}, arr: string[] = []) => {
|
||||
let res = {}
|
||||
for (let key in val) {
|
||||
const res = {}
|
||||
for (const key in val) {
|
||||
if (val[key] !== undefined && val[key] !== null && val[key] !== '' && !arr.includes(key)) {
|
||||
if (typeof val[key] == 'number') {
|
||||
if (!isNaN(val[key])) {
|
||||
res[key] = val[key]
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
res[key] = val[key]
|
||||
}
|
||||
}
|
||||
@ -63,24 +64,26 @@ export const getFilterData = (val = {}, arr: string[] = []) => {
|
||||
*/
|
||||
export const copyObject = (object) => {
|
||||
if (object.constructor == Object) {
|
||||
let keys = Object.keys(object)
|
||||
let newObject = {}
|
||||
const keys = Object.keys(object)
|
||||
const newObject = {}
|
||||
keys.map((key) => {
|
||||
newObject[key] = copyObject(object[key])
|
||||
})
|
||||
return newObject
|
||||
} else if (object.constructor == Array) {
|
||||
}
|
||||
else if (object.constructor == Array) {
|
||||
return object.map((item) => {
|
||||
return copyObject(item)
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return object
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} suffix
|
||||
*
|
||||
* @param {*} suffix
|
||||
* !w80
|
||||
!w100
|
||||
!w160
|
||||
@ -94,23 +97,26 @@ export const screenshot = (url, suffix = '!w200') => {
|
||||
return url + suffix
|
||||
}
|
||||
|
||||
//获取数据加载状态 //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
// 获取数据加载状态 //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
export const dataLoadingStatus = ({ list = [], total = 0, status = false }: { list: any[]; total: number; status: true | false }) => {
|
||||
if (list.length == 0 && status) {
|
||||
return 0
|
||||
} else if (list.length == 0 && !status) {
|
||||
}
|
||||
else if (list.length == 0 && !status) {
|
||||
return 1
|
||||
} else if (list.length < total) {
|
||||
}
|
||||
else if (list.length < total) {
|
||||
return 2
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 3
|
||||
}
|
||||
}
|
||||
|
||||
//全局分享监听
|
||||
// 全局分享监听
|
||||
export const shareShop = () => {
|
||||
const page = Taro.getCurrentInstance().page
|
||||
//当有分享参数时,绑定上下级
|
||||
// 当有分享参数时,绑定上下级
|
||||
if (page && page.options?.share) {
|
||||
analysisShortCodeApi(page.options.share)
|
||||
}
|
||||
@ -119,16 +125,17 @@ export const shareShop = () => {
|
||||
let path = ''
|
||||
let title = ''
|
||||
let imageUrl = ''
|
||||
let sortCode = Taro.getStorageSync('sort_code') ? JSON.parse(Taro.getStorageSync('sort_code')) : ''
|
||||
let pageInfo: any = page
|
||||
//商品详情分享
|
||||
const sortCode = Taro.getStorageSync('sort_code') ? JSON.parse(Taro.getStorageSync('sort_code')) : ''
|
||||
const pageInfo: any = page
|
||||
// 商品详情分享
|
||||
if (pageInfo.route === 'pages/details/index') {
|
||||
path = `/pages/details/index?share=${sortCode.shareShortDetail.code}`
|
||||
title = sortCode.shareShortDetail.title
|
||||
imageUrl = sortCode.shareShortDetail.img
|
||||
} else {
|
||||
path =
|
||||
pageInfo.route === 'pages/user/index'
|
||||
}
|
||||
else {
|
||||
path
|
||||
= pageInfo.route === 'pages/user/index'
|
||||
? `/pages/user/index?share=${sortCode.shareShortPage.code}`
|
||||
: `/pages/index/index?share=${sortCode.shareShortPage.code}`
|
||||
title = sortCode.shareShortPage.title
|
||||
|
||||
@ -1,80 +1,82 @@
|
||||
|
||||
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import "./index.scss"
|
||||
import {addressListApi,addressDeleteApi} from "@/api/addressManager"
|
||||
import { alert } from "@/common/common"
|
||||
import Taro, { showModal } from "@tarojs/taro"
|
||||
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import './index.scss'
|
||||
import { addressDeleteApi, addressListApi } from '@/api/addressManager'
|
||||
import { alert } from '@/common/common'
|
||||
import Taro, { showModal } from '@tarojs/taro'
|
||||
|
||||
interface Params{
|
||||
refresherEnabled?: boolean,//是否开启刷新
|
||||
onSelect?: (item:any,index:number)=>void,//列表选择
|
||||
addButtonEnabled?: boolean, //是否显示添加按钮
|
||||
focusBorderEnabled?: boolean, //焦点显示蓝色边框
|
||||
id?: number, //默认选择值
|
||||
refresherEnabled?: boolean// 是否开启刷新
|
||||
onSelect?: (item: any, index: number) => void// 列表选择
|
||||
addButtonEnabled?: boolean // 是否显示添加按钮
|
||||
focusBorderEnabled?: boolean // 焦点显示蓝色边框
|
||||
id?: number // 默认选择值
|
||||
}
|
||||
|
||||
// 地址列表
|
||||
const AddressList = memo((props:Params)=>{
|
||||
const {addButtonEnabled=true,focusBorderEnabled=false} = props;
|
||||
const {fetchData, state} = addressListApi()
|
||||
const AddressList = memo((props: Params) => {
|
||||
const { addButtonEnabled = true, focusBorderEnabled = false } = props
|
||||
const { fetchData, state } = addressListApi()
|
||||
// 获取数据
|
||||
const getData = async ()=>{
|
||||
const result = await fetchData();
|
||||
if(props.id){
|
||||
setFocusId(props.id as any);
|
||||
}else{
|
||||
result.data.list?.every(item=>{
|
||||
if(item.is_default){
|
||||
setFocusId(item.id);
|
||||
return false;
|
||||
const getData = async() => {
|
||||
const result = await fetchData()
|
||||
if (props.id) {
|
||||
setFocusId(props.id as any)
|
||||
}
|
||||
else {
|
||||
result.data.list?.every((item) => {
|
||||
if (item.is_default) {
|
||||
setFocusId(item.id)
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
useEffect(()=>{
|
||||
getData();
|
||||
useEffect(() => {
|
||||
getData()
|
||||
// 监听刷新
|
||||
Taro.eventCenter.on("addressList:refresh", getData);
|
||||
return ()=>{
|
||||
Taro.eventCenter.off("addressList:refresh", getData);
|
||||
Taro.eventCenter.on('addressList:refresh', getData)
|
||||
return () => {
|
||||
Taro.eventCenter.off('addressList:refresh', getData)
|
||||
}
|
||||
},[])
|
||||
}, [])
|
||||
// 处理刷新
|
||||
const [refreshState, setRefreshState] = useState(false);
|
||||
const handleRefresh = async ()=>{
|
||||
setRefreshState(true);
|
||||
await getData();
|
||||
setRefreshState(false);
|
||||
const [refreshState, setRefreshState] = useState(false)
|
||||
const handleRefresh = async() => {
|
||||
setRefreshState(true)
|
||||
await getData()
|
||||
setRefreshState(false)
|
||||
}
|
||||
const data = Array.from({length:15});
|
||||
const data = Array.from({ length: 15 })
|
||||
// 焦点
|
||||
const [focusId, setFocusId] = useState();
|
||||
const [focusId, setFocusId] = useState()
|
||||
// 列表选择
|
||||
const handleSelect = (item: any, index: number)=>{
|
||||
props.onSelect&&props.onSelect(item,index);
|
||||
if(focusBorderEnabled){
|
||||
setFocusId(item?.id);
|
||||
const handleSelect = (item: any, index: number) => {
|
||||
props.onSelect && props.onSelect(item, index)
|
||||
if (focusBorderEnabled) {
|
||||
setFocusId(item?.id)
|
||||
}
|
||||
}
|
||||
// 删除地址
|
||||
const {fetchData: deleteFetch} = addressDeleteApi()
|
||||
const handleDelete = (item:any)=>{
|
||||
const { fetchData: deleteFetch } = addressDeleteApi()
|
||||
const handleDelete = (item: any) => {
|
||||
showModal(({
|
||||
title: "提示",
|
||||
content: "是否删除地址?",
|
||||
async success(ev){
|
||||
if(ev.confirm){
|
||||
const result = await deleteFetch({id:item.id});
|
||||
if(result.success){
|
||||
alert.success("删除成功");
|
||||
getData();
|
||||
}else{
|
||||
alert.success(result.msg);
|
||||
title: '提示',
|
||||
content: '是否删除地址?',
|
||||
async success(ev) {
|
||||
if (ev.confirm) {
|
||||
const result = await deleteFetch({ id: item.id })
|
||||
if (result.success) {
|
||||
alert.success('删除成功')
|
||||
getData()
|
||||
}
|
||||
else {
|
||||
alert.success(result.msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
@ -83,42 +85,43 @@ const AddressList = memo((props:Params)=>{
|
||||
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
|
||||
<View className="address-scroll-view-content">
|
||||
{
|
||||
state?.data?.list?.length>0?
|
||||
state?.data?.list?.map((item,index)=>{
|
||||
// data.length>0?
|
||||
// data.map((item,index)=>{
|
||||
return(
|
||||
<View onLongPress={()=>handleDelete(item)} onClick={()=>handleSelect(item,index)} className={`address-list ${focusId==item.id&&'address-active'}`}>
|
||||
<View className="address-user">
|
||||
{item.name}
|
||||
{
|
||||
item.is_default?<Text className="address-list-default">默认</Text>:
|
||||
<Text className="address-list-phone">{item.phone.replace(item.phone.substring(3,7), "****")}</Text>
|
||||
}
|
||||
</View>
|
||||
<View className="address-list-bottom">
|
||||
<View className="address-list-info">
|
||||
<View>{item.province_name+item.city_name+item.district_name}
|
||||
{/* {item.address_detail} */}
|
||||
</View>
|
||||
state?.data?.list?.length > 0
|
||||
? state?.data?.list?.map((item, index) => {
|
||||
// data.length>0?
|
||||
// data.map((item,index)=>{
|
||||
return (
|
||||
<View onLongPress={() => handleDelete(item)} onClick={() => handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}>
|
||||
<View className="address-user">
|
||||
{item.name}
|
||||
{
|
||||
item.is_default&&<Text className="address-list-phone">{item.phone.replace(item.phone.substring(3,7), "****")}</Text>
|
||||
item.is_default
|
||||
? <Text className="address-list-default">默认</Text>
|
||||
: <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), '****')}</Text>
|
||||
}
|
||||
</View>
|
||||
<Navigator onClick={e=>e.stopPropagation()} url={`/pages/addressAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="address-edit">
|
||||
<Text className="iconfont icon-bianji"></Text>
|
||||
</Navigator>
|
||||
<View className="address-list-bottom">
|
||||
<View className="address-list-info">
|
||||
<View>{item.province_name + item.city_name + item.district_name}
|
||||
{/* {item.address_detail} */}
|
||||
</View>
|
||||
{
|
||||
item.is_default && <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), '****')}</Text>
|
||||
}
|
||||
</View>
|
||||
<Navigator onClick={e => e.stopPropagation()} url={`/pages/addressAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="address-edit">
|
||||
<Text className="iconfont icon-bianji"></Text>
|
||||
</Navigator>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}):
|
||||
<View className="address-no-data">暂未添加地址</View>
|
||||
)
|
||||
})
|
||||
: <View className="address-no-data">暂未添加地址</View>
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
{addButtonEnabled&&<Navigator url="/pages/addressAdd/index?type=add" hoverClass="none" className="add-address">添加收货地址</Navigator>}
|
||||
{addButtonEnabled && <Navigator url="/pages/addressAdd/index?type=add" hoverClass="none" className="add-address">添加收货地址</Navigator>}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
export default AddressList;
|
||||
export default AddressList
|
||||
|
||||
@ -3,15 +3,15 @@ import { memo } from 'react'
|
||||
import './index.scss'
|
||||
|
||||
interface ListParams {
|
||||
label: string //左边label
|
||||
label: string // 左边label
|
||||
onInput?: (ev: Object) => void // 输入框输入
|
||||
onClick?: () => any //点击列表
|
||||
onClick?: () => any // 点击列表
|
||||
placeholder?: string // 提示文本
|
||||
children?: any // 插槽
|
||||
type?: string // 类型:1.input,2.textarea,3.select,
|
||||
primordialType?: 'text' | 'number' | 'idcard' | 'digit'
|
||||
value?: any
|
||||
style?: object //整行样式
|
||||
style?: object // 整行样式
|
||||
labelStyle?: object // label样式
|
||||
contentStyle?: object
|
||||
required?: boolean
|
||||
@ -22,40 +22,44 @@ const FromList = memo((props: ListParams) => {
|
||||
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props
|
||||
|
||||
return (
|
||||
<View style={style} className='form-list'>
|
||||
<View style={style} className="form-list">
|
||||
<View style={labelStyle} className={`form-list-label ${required && 'form-list-label-required'}`}>
|
||||
{props.label}
|
||||
</View>
|
||||
<View onClick={props?.onClick} className='form-list-right'>
|
||||
<View onClick={props?.onClick} className="form-list-right">
|
||||
{props.children ?? (
|
||||
<View style={contentStyle} onClick={props?.onClick} className='form-list-right-meet'>
|
||||
{type == 'input' ? (
|
||||
<View className='form-list-input'>
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
cursorSpacing={150}
|
||||
value={value}
|
||||
placeholder-class='phcolor'
|
||||
type={props.primordialType || 'text'}
|
||||
onInput={props?.onInput}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
{value && (
|
||||
<View>
|
||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
) : 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>}
|
||||
<View className='form-list-right-enter'>
|
||||
<Text className='iconfont icon-a-moreback'></Text>
|
||||
<View style={contentStyle} onClick={props?.onClick} className="form-list-right-meet">
|
||||
{type == 'input'
|
||||
? (
|
||||
<View className="form-list-input">
|
||||
<Input
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
value={value}
|
||||
placeholder-class="phcolor"
|
||||
type={props.primordialType || 'text'}
|
||||
onInput={props?.onInput}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
{value && (
|
||||
<View>
|
||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
)
|
||||
: 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>}
|
||||
<View className="form-list-right-enter">
|
||||
<Text className="iconfont icon-a-moreback"></Text>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
@ -3,14 +3,14 @@ import { memo } from 'react'
|
||||
import './index.scss'
|
||||
|
||||
interface ListParams {
|
||||
label: string //左边label
|
||||
label: string // 左边label
|
||||
onInput?: (ev: Object) => void // 输入框输入
|
||||
onClick?: () => any //点击列表
|
||||
onClick?: () => any // 点击列表
|
||||
placeholder?: string // 提示文本
|
||||
children?: any // 插槽
|
||||
type?: string // 类型:1.input,2.textarea,3.select
|
||||
value?: any
|
||||
style?: object //整行样式
|
||||
style?: object // 整行样式
|
||||
labelStyle?: object // label样式
|
||||
contentStyle?: object
|
||||
required?: boolean
|
||||
@ -22,37 +22,41 @@ const FromList = memo((props: ListParams) => {
|
||||
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false, showIcon = true } = props
|
||||
|
||||
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'}`}>
|
||||
{props.label}
|
||||
</View>
|
||||
<View onClick={props?.onClick} className='From-list-certification-right'>
|
||||
<View onClick={props?.onClick} className="From-list-certification-right">
|
||||
{props.children ?? (
|
||||
<View style={contentStyle} onClick={props?.onClick} className='From-list-certification-right-meet'>
|
||||
{type == 'input' ? (
|
||||
<View className='From-list-certification-input'>
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
cursorSpacing={150}
|
||||
value={value}
|
||||
placeholder-class='phcolor'
|
||||
onInput={props?.onInput}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
{value && (
|
||||
<View>
|
||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' />
|
||||
</View>
|
||||
<View style={contentStyle} onClick={props?.onClick} className="From-list-certification-right-meet">
|
||||
{type == 'input'
|
||||
? (
|
||||
<View className="From-list-certification-input">
|
||||
<Input
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
value={value}
|
||||
placeholder-class="phcolor"
|
||||
onInput={props?.onInput}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
{value && (
|
||||
<View>
|
||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
: 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>}
|
||||
<View className="From-list-certification-right-enter">{showIcon && <Text className="iconfont icon-a-moreback"></Text>}</View>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
) : 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>}
|
||||
<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 { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import { alert, isEmptyObject } from '@/common/common'
|
||||
|
||||
@ -23,7 +24,7 @@ export default (props: Params) => {
|
||||
getData({ moreStatus: true }, { moreStatus: true })
|
||||
}
|
||||
}, [query])
|
||||
const getData = async (startStatus, endStatus) => {
|
||||
const getData = async(startStatus, endStatus) => {
|
||||
const tRefreshDataRef = refreshDataRef.current as any
|
||||
setRefreshData({
|
||||
...tRefreshDataRef,
|
||||
@ -44,7 +45,8 @@ export default (props: Params) => {
|
||||
...endStatus,
|
||||
loading: false,
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setData({
|
||||
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,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.none(result.msg)
|
||||
setRefreshData({
|
||||
...tRefreshDataRef,
|
||||
@ -83,8 +86,8 @@ export default (props: Params) => {
|
||||
})
|
||||
const dataRef = useRef({})
|
||||
// 下拉刷新
|
||||
const handleRefresh = async () => {
|
||||
let tRefreshData = refreshDataRef.current as any
|
||||
const handleRefresh = async() => {
|
||||
const tRefreshData = refreshDataRef.current as any
|
||||
setRefreshData({
|
||||
...tRefreshData,
|
||||
page: 1,
|
||||
@ -93,9 +96,9 @@ export default (props: Params) => {
|
||||
getData({ refreshStatus: true, moreStatus: false }, { refreshStatus: false, moreStatus: true })
|
||||
}
|
||||
// 加载更多
|
||||
const handleMoreLoad = async () => {
|
||||
let t = dataRef.current as any
|
||||
let tRefreshData = refreshDataRef.current as any
|
||||
const handleMoreLoad = async() => {
|
||||
const t = dataRef.current as any
|
||||
const tRefreshData = refreshDataRef.current as any
|
||||
if (t.list.length < t.total) {
|
||||
setRefreshData({
|
||||
...tRefreshData,
|
||||
@ -112,19 +115,20 @@ export default (props: Params) => {
|
||||
)
|
||||
}
|
||||
}
|
||||
//数据加载状态
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: data.list, total: data.total, status: refreshData.loading })
|
||||
}, [refreshData.loading])
|
||||
|
||||
return (
|
||||
<InfiniteScroll
|
||||
refresherEnabled={true}
|
||||
refresherEnabled
|
||||
refresherTriggered={refreshData.refreshStatus}
|
||||
moreStatus={refreshData.moreStatus}
|
||||
selfOnRefresherRefresh={handleRefresh}
|
||||
selfonScrollToLower={handleMoreLoad}
|
||||
statusMore={statusMore}>
|
||||
statusMore={statusMore}
|
||||
>
|
||||
{props.children}
|
||||
</InfiniteScroll>
|
||||
)
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
import { formatImgUrl, formatRemoveHashTag } from '@/common/fotmat'
|
||||
import Preview from '@/pages/details/components/preview'
|
||||
import { Image, View } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import LabAndImgShow from '../LabAndImgShow'
|
||||
import styles from './index.module.scss'
|
||||
import Preview from '@/pages/details/components/preview'
|
||||
import { formatImgUrl, formatRemoveHashTag } from '@/common/fotmat'
|
||||
|
||||
//该组件宽高为100%需调整外层元素宽高
|
||||
type Param = {
|
||||
// 该组件宽高为100%需调整外层元素宽高
|
||||
interface Param {
|
||||
value: {
|
||||
texture_url?: string //纹理图路径
|
||||
lab?: { l: number; a: number; b: number } //lab
|
||||
rgb?: { r: number; g: number; b: number } //rgb
|
||||
texture_url?: string // 纹理图路径
|
||||
lab?: { l: number; a: number; b: number } // lab
|
||||
rgb?: { r: number; g: number; b: number } // rgb
|
||||
title?: string
|
||||
}
|
||||
showStatus?: true | false
|
||||
@ -21,18 +21,19 @@ type Param = {
|
||||
export default memo(({ value, onClick, showStatus = false, round = false, name = '' }: Param) => {
|
||||
const [imgs, setImgs] = useState<string>('')
|
||||
|
||||
//lab是否都是0
|
||||
// lab是否都是0
|
||||
const rgbStyle = useMemo(() => {
|
||||
if (value?.lab && (value?.lab.l || value?.lab.a || value?.lab.b)) {
|
||||
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null
|
||||
}
|
||||
}, [value])
|
||||
|
||||
useEffect(() => {
|
||||
if (value?.texture_url) {
|
||||
let imgs = value.texture_url.split(',').map((item) => {
|
||||
const imgs = value.texture_url.split(',').map((item) => {
|
||||
return formatImgUrl(item)
|
||||
})
|
||||
setImgs(() => imgs[0])
|
||||
@ -46,7 +47,7 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
||||
|
||||
const onShowLabAndImg = (e) => {
|
||||
onClick?.(value)
|
||||
if (!showStatus) return false
|
||||
if (!showStatus) { return false }
|
||||
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}>
|
||||
{value.texture_url && (
|
||||
<Image
|
||||
mode='aspectFill'
|
||||
mode="aspectFill"
|
||||
src={imgs}
|
||||
onError={(e) => checkLoad(e)}
|
||||
onError={e => checkLoad(e)}
|
||||
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 && (
|
||||
<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>}
|
||||
</View>
|
||||
|
||||
@ -1,39 +1,40 @@
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
import { View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
|
||||
export type colorParams = {
|
||||
export interface colorParams {
|
||||
value?: {
|
||||
texture_url?: string //纹理图路径
|
||||
lab?: { l: number; a: number; b: number } //lab
|
||||
rgb?: { r: number; g: number; b: number } //rgb
|
||||
title?: string //标题
|
||||
texture_url?: string // 纹理图路径
|
||||
lab?: { l: number; a: number; b: number } // lab
|
||||
rgb?: { r: number; g: number; b: number } // rgb
|
||||
title?: string // 标题
|
||||
}
|
||||
show?: false | true
|
||||
onClose?: () => void
|
||||
showNumber?: number //图片显示张数,0不限制
|
||||
showNumber?: number // 图片显示张数,0不限制
|
||||
}
|
||||
export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) => {
|
||||
useEffect(() => {
|
||||
if (show && rgbStyle) setLabShow(() => true)
|
||||
if (show && value?.texture_url) onShowImage()
|
||||
if (!show) setLabShow(() => false)
|
||||
if (show && rgbStyle) { setLabShow(() => true) }
|
||||
if (show && value?.texture_url) { onShowImage() }
|
||||
if (!show) { setLabShow(() => false) }
|
||||
}, [show])
|
||||
|
||||
//显示颜色
|
||||
// 显示颜色
|
||||
const [labShow, setLabShow] = useState(false)
|
||||
//lab是否都是0
|
||||
// lab是否都是0
|
||||
const rgbStyle = useMemo(() => {
|
||||
if (value?.lab && (value.lab.l || value.lab.a || value.lab.b)) {
|
||||
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null
|
||||
}
|
||||
}, [value])
|
||||
|
||||
//显示图片
|
||||
// 显示图片
|
||||
const onShowImage = () => {
|
||||
onClose?.()
|
||||
let res: string[] = []
|
||||
@ -42,7 +43,7 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
||||
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({
|
||||
current: n_res[0],
|
||||
urls: n_res,
|
||||
@ -52,7 +53,7 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
||||
return (
|
||||
<>
|
||||
{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.rgb} style={rgbStyle!}></View>
|
||||
<View className={styles.name}>{value?.title}</View>
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
|
||||
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
|
||||
import { memo } from "react"
|
||||
import "./index.scss"
|
||||
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import './index.scss'
|
||||
|
||||
interface Params{
|
||||
text: String,//提示信息
|
||||
text: String// 提示信息
|
||||
}
|
||||
|
||||
// 消息提示
|
||||
const Message = memo((props:Params)=>{
|
||||
const Message = memo((props: Params) => {
|
||||
return (
|
||||
<View className="message-custom-tips">
|
||||
<Text className="iconfont icon-zhuyi"></Text> {props.text}
|
||||
@ -16,4 +16,4 @@ const Message = memo((props:Params)=>{
|
||||
)
|
||||
})
|
||||
|
||||
export default Message;
|
||||
export default Message
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
import Popup from '@/components/popup'
|
||||
import { Input, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import TextareaEnhance from '@/components/textareaEnhance'
|
||||
import { CreateFavoriteApi, FavoriteListApi } from '@/api/favorite'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { getFilterData } from '@/common/util'
|
||||
|
||||
//原因选择
|
||||
type ReasonInfoParam = {
|
||||
show?: boolean //显示
|
||||
onClose?: () => void //关闭
|
||||
// 原因选择
|
||||
interface ReasonInfoParam {
|
||||
show?: boolean // 显示
|
||||
onClose?: () => void // 关闭
|
||||
onAdd?: (val: any) => void
|
||||
}
|
||||
export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
|
||||
//获取列表
|
||||
// 获取列表
|
||||
const [list, setList] = useState([])
|
||||
const { fetchData: fetchDataList } = FavoriteListApi()
|
||||
const getFavoriteList = async () => {
|
||||
let res = await fetchDataList(getFilterData())
|
||||
const getFavoriteList = async() => {
|
||||
const res = await fetchDataList(getFilterData())
|
||||
setList(() => res.data.list)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (show) getFavoriteList()
|
||||
if (show) { getFavoriteList() }
|
||||
}, [show])
|
||||
|
||||
const onCreate = () => {
|
||||
|
||||
@ -1,218 +1,218 @@
|
||||
import { ScrollView, Text, View } from "@tarojs/components";
|
||||
import { memo, ReactHTMLElement, useEffect, useRef, useState } from "react";
|
||||
import Drawer from "@/components/popup";
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { GetAddressListApi } from "@/api/addressList";
|
||||
import { alert } from "@/common/common";
|
||||
import { ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import React, { ReactHTMLElement, memo, useEffect, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Drawer from '@/components/popup'
|
||||
import { GetAddressListApi } from '@/api/addressList'
|
||||
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}
|
||||
|
||||
type Params = {
|
||||
addressOnSelect?: (val:DefaultValueParm[]) => void,
|
||||
addressOnChange?: (val:DefaultValueParm[]) => void,
|
||||
addressOnClose?: () => void,
|
||||
show?: true|false,
|
||||
defaultValue?:DefaultValueParm[]
|
||||
selectStatus?: false|true, //false不需要选择完整地址,true需要选择完整地址
|
||||
interface Params {
|
||||
addressOnSelect?: (val: DefaultValueParm[]) => void
|
||||
addressOnChange?: (val: DefaultValueParm[]) => void
|
||||
addressOnClose?: () => void
|
||||
show?: true|false
|
||||
defaultValue?: DefaultValueParm[]
|
||||
selectStatus?: false|true // false不需要选择完整地址,true需要选择完整地址
|
||||
}
|
||||
|
||||
type AddresParam = {
|
||||
ad_code?: string,
|
||||
id?: number,
|
||||
level?: number,
|
||||
level_name?: string,
|
||||
name?: string,
|
||||
parent_id?: number,
|
||||
|
||||
}
|
||||
interface AddresParam {
|
||||
ad_code?: string
|
||||
id?: number
|
||||
level?: number
|
||||
level_name?: string
|
||||
name?: string
|
||||
parent_id?: number
|
||||
|
||||
}
|
||||
|
||||
export default memo(({
|
||||
addressOnSelect,
|
||||
addressOnChange,
|
||||
addressOnClose,
|
||||
show = false,
|
||||
defaultValue = [],
|
||||
selectStatus = true
|
||||
addressOnSelect,
|
||||
addressOnChange,
|
||||
addressOnClose,
|
||||
show = false,
|
||||
defaultValue = [],
|
||||
selectStatus = true,
|
||||
}: Params) => {
|
||||
//省
|
||||
const provinceList = useRef<AddresParam[]>([])
|
||||
//市
|
||||
const cityList = useRef<AddresParam[]>([])
|
||||
//区
|
||||
const areaList = useRef<AddresParam[]>([])
|
||||
|
||||
const [list, setList] = useState<AddresParam[]>([])
|
||||
const [selectIndex, setSelectIndex] = useState(0) //0 省, 1 市,2 区
|
||||
const [selectId, setSelectId] = useState(1) //选中的id
|
||||
const [selectArr, setSelectArr] = useState<DefaultValueParm[]>([]) //选中的省市区
|
||||
const [cityStatus, setCityStatus] = useState(false) //城市是否存在
|
||||
const [areaStatus, setAreaStatus] = useState(false) //区镇是否存在
|
||||
const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) //确认按钮是否可用
|
||||
// 省
|
||||
const provinceList = useRef<AddresParam[]>([])
|
||||
// 市
|
||||
const cityList = useRef<AddresParam[]>([])
|
||||
// 区
|
||||
const areaList = useRef<AddresParam[]>([])
|
||||
|
||||
const [bottomStyle, setBottomStyle] = useState({width:'100rpx',left:'0rpx'}) //底部滚动条样式
|
||||
const [list, setList] = useState<AddresParam[]>([])
|
||||
const [selectIndex, setSelectIndex] = useState(0) // 0 省, 1 市,2 区
|
||||
const [selectId, setSelectId] = useState(1) // 选中的id
|
||||
const [selectArr, setSelectArr] = useState<DefaultValueParm[]>([]) // 选中的省市区
|
||||
const [cityStatus, setCityStatus] = useState(false) // 城市是否存在
|
||||
const [areaStatus, setAreaStatus] = useState(false) // 区镇是否存在
|
||||
const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) // 确认按钮是否可用
|
||||
|
||||
useEffect(() => {
|
||||
if(selectArr.length == 0) {
|
||||
setSelectArr(defaultValue)
|
||||
if(defaultValue.length > 1) setCityStatus(true)
|
||||
if(defaultValue.length > 2) setAreaStatus(true)
|
||||
if(defaultValue.length > 0) setConfirmBtnStatus(true)
|
||||
}
|
||||
}, [defaultValue])
|
||||
const [bottomStyle, setBottomStyle] = useState<React.CSSProperties>({ width: '100rpx', left: '0rpx' }) // 底部滚动条样式
|
||||
|
||||
|
||||
//获取地址
|
||||
const {fetchData} = GetAddressListApi()
|
||||
useEffect(() => {
|
||||
getProvince()
|
||||
}, [])
|
||||
|
||||
//选中内容
|
||||
const selectItem = (item) => {
|
||||
setSelectId(item.id)
|
||||
if(selectIndex == 0) {
|
||||
setSelectArr([{name:item.name, id:item.id, level:item.level}])
|
||||
getCity(item.id)
|
||||
setAreaStatus(false)
|
||||
setCityStatus(false)
|
||||
} else if(selectIndex == 1){
|
||||
setSelectArr([selectArr[0], {name:item.name, id:item.id, level:item.level}])
|
||||
area(item.id)
|
||||
} else {
|
||||
setSelectArr([selectArr[0], selectArr[1], {name:item.name, id:item.id, level:item.level}])
|
||||
getDomDes('#address_tab_2')
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (selectArr.length == 0) {
|
||||
setSelectArr(defaultValue)
|
||||
if (defaultValue.length > 1) { setCityStatus(true) }
|
||||
if (defaultValue.length > 2) { setAreaStatus(true) }
|
||||
if (defaultValue.length > 0) { setConfirmBtnStatus(true) }
|
||||
}
|
||||
}, [defaultValue])
|
||||
|
||||
//地址数据
|
||||
useEffect(() => {
|
||||
if(selectArr && selectArr.length > 0)
|
||||
addressOnChange?.(selectArr)
|
||||
}, [selectArr])
|
||||
|
||||
//选中标题
|
||||
const onSelectIndex = (index) => {
|
||||
setSelectIndex(index)
|
||||
const selectid = selectArr[index]?selectArr[index].id:0
|
||||
setSelectId(selectid as number)
|
||||
if(index == 0) {
|
||||
getProvince()
|
||||
} else if (index == 1) {
|
||||
const id = selectArr[0]?.id
|
||||
getCity(id)
|
||||
} else {
|
||||
const id = selectArr[1]?.id
|
||||
area(id)
|
||||
}
|
||||
// 获取地址
|
||||
const { fetchData } = GetAddressListApi()
|
||||
useEffect(() => {
|
||||
getProvince()
|
||||
}, [])
|
||||
|
||||
// 选中内容
|
||||
const selectItem = (item) => {
|
||||
setSelectId(item.id)
|
||||
if (selectIndex == 0) {
|
||||
setSelectArr([{ name: item.name, id: item.id, level: item.level }])
|
||||
getCity(item.id)
|
||||
setAreaStatus(false)
|
||||
setCityStatus(false)
|
||||
}
|
||||
|
||||
|
||||
//获取省
|
||||
const getProvince = async () => {
|
||||
let res = await fetchData({parent_id: 1})
|
||||
provinceList.current = res.data.list||[]
|
||||
if(provinceList.current.length > 0) {
|
||||
setSelectIndex(0)
|
||||
setList(() => provinceList.current)
|
||||
getDomDes('#address_tab_0')
|
||||
}
|
||||
else if (selectIndex == 1) {
|
||||
setSelectArr([selectArr[0], { name: item.name, id: item.id, level: item.level }])
|
||||
area(item.id)
|
||||
}
|
||||
|
||||
//获取市
|
||||
const getCity = async (id) => {
|
||||
let res = await fetchData({parent_id: id})
|
||||
cityList.current = res.data.list||[]
|
||||
if(cityList.current.length > 0) {
|
||||
setSelectIndex(1)
|
||||
setList(() => cityList.current)
|
||||
setCityStatus(true)
|
||||
getDomDes('#address_tab_1')
|
||||
setConfirmBtnStatus(false)
|
||||
} else {
|
||||
setConfirmBtnStatus(true)
|
||||
setCityStatus(false)
|
||||
}
|
||||
else {
|
||||
setSelectArr([selectArr[0], selectArr[1], { name: item.name, id: item.id, level: item.level }])
|
||||
getDomDes('#address_tab_2')
|
||||
}
|
||||
}
|
||||
|
||||
//获取区
|
||||
const area = async (id) => {
|
||||
let res = await fetchData({parent_id: id})
|
||||
areaList.current = res.data.list||[]
|
||||
if(areaList.current.length > 0) {
|
||||
setSelectIndex(2)
|
||||
setList(() => areaList.current)
|
||||
setAreaStatus(true)
|
||||
getDomDes('#address_tab_2')
|
||||
setConfirmBtnStatus(false)
|
||||
} else {
|
||||
setConfirmBtnStatus(true)
|
||||
setAreaStatus(false)
|
||||
}
|
||||
// 地址数据
|
||||
useEffect(() => {
|
||||
if (selectArr && selectArr.length > 0) { addressOnChange?.(selectArr) }
|
||||
}, [selectArr])
|
||||
|
||||
// 选中标题
|
||||
const onSelectIndex = (index) => {
|
||||
setSelectIndex(index)
|
||||
const selectid = selectArr[index] ? selectArr[index].id : 0
|
||||
setSelectId(selectid as number)
|
||||
if (index == 0) {
|
||||
getProvince()
|
||||
}
|
||||
|
||||
//确定按钮
|
||||
const submitSelect = () => {
|
||||
addressOnClose?.()
|
||||
addressOnSelect?.(selectArr)
|
||||
else if (index == 1) {
|
||||
const id = selectArr[0]?.id
|
||||
getCity(id)
|
||||
}
|
||||
|
||||
//获取省市区宽度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
let query = Taro.createSelectorQuery();
|
||||
query.select(id).boundingClientRect(rect=>{
|
||||
let left = rect.left;
|
||||
let clientWidth = rect.width;
|
||||
console.log(clientWidth)
|
||||
setBottomStyle({
|
||||
width: clientWidth + 'px',
|
||||
left: left + 'px'
|
||||
})
|
||||
}).exec();
|
||||
}, 100)
|
||||
else {
|
||||
const id = selectArr[1]?.id
|
||||
area(id)
|
||||
}
|
||||
}
|
||||
|
||||
//点击标题栏
|
||||
const selectTab = (index) => {
|
||||
onSelectIndex(index)
|
||||
getDomDes('#address_tab_'+index)
|
||||
// 获取省
|
||||
const getProvince = async() => {
|
||||
const res = await fetchData({ parent_id: 1 })
|
||||
provinceList.current = res.data.list || []
|
||||
if (provinceList.current.length > 0) {
|
||||
setSelectIndex(0)
|
||||
setList(() => provinceList.current)
|
||||
getDomDes('#address_tab_0')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer showTitle={false} show={show} onClose={submitSelect}>
|
||||
<View className={styles.address_main}>
|
||||
<View className={styles.address_title}>
|
||||
<View onClick={() => addressOnClose?.()}>取消</View>
|
||||
<View onClick={() => submitSelect()}>确定</View>
|
||||
// 获取市
|
||||
const getCity = async(id) => {
|
||||
const res = await fetchData({ parent_id: id })
|
||||
cityList.current = res.data.list || []
|
||||
if (cityList.current.length > 0) {
|
||||
setSelectIndex(1)
|
||||
setList(() => cityList.current)
|
||||
setCityStatus(true)
|
||||
getDomDes('#address_tab_1')
|
||||
setConfirmBtnStatus(false)
|
||||
}
|
||||
else {
|
||||
setConfirmBtnStatus(true)
|
||||
setCityStatus(false)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取区
|
||||
const area = async(id) => {
|
||||
const res = await fetchData({ parent_id: id })
|
||||
areaList.current = res.data.list || []
|
||||
if (areaList.current.length > 0) {
|
||||
setSelectIndex(2)
|
||||
setList(() => areaList.current)
|
||||
setAreaStatus(true)
|
||||
getDomDes('#address_tab_2')
|
||||
setConfirmBtnStatus(false)
|
||||
}
|
||||
else {
|
||||
setConfirmBtnStatus(true)
|
||||
setAreaStatus(false)
|
||||
}
|
||||
}
|
||||
|
||||
// 确定按钮
|
||||
const submitSelect = () => {
|
||||
addressOnClose?.()
|
||||
addressOnSelect?.(selectArr)
|
||||
}
|
||||
|
||||
// 获取省市区宽度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
const query = Taro.createSelectorQuery()
|
||||
query.select(id).boundingClientRect((rect) => {
|
||||
const left = rect.left
|
||||
const clientWidth = rect.width
|
||||
console.log(clientWidth)
|
||||
setBottomStyle({
|
||||
width: `${clientWidth}px`,
|
||||
left: `${left}px`,
|
||||
})
|
||||
}).exec()
|
||||
}, 100)
|
||||
}
|
||||
|
||||
// 点击标题栏
|
||||
const selectTab = (index) => {
|
||||
onSelectIndex(index)
|
||||
getDomDes(`#address_tab_${index}`)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer showTitle={false} show={show} onClose={submitSelect}>
|
||||
<View className={styles.address_main}>
|
||||
<View className={styles.address_title}>
|
||||
<View onClick={() => addressOnClose?.()}>取消</View>
|
||||
<View onClick={() => submitSelect()}>确定</View>
|
||||
</View>
|
||||
<View className={styles.address_select}>
|
||||
<View id="address_tab_0" onClick={() => selectTab(0)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 0) })}>{selectArr[0] ? selectArr[0].name : '请选择'}</View>
|
||||
{cityStatus && <View id="address_tab_1" onClick={() => selectTab(1)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 1) })}>{selectArr[1] ? selectArr[1].name : '请选择'}</View>}
|
||||
{areaStatus && <View id="address_tab_2" onClick={() => selectTab(2)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 2) })}>{selectArr[2] ? selectArr[2].name : '请选择'}</View>}
|
||||
<View style={bottomStyle} className={styles.bottom_index}></View>
|
||||
</View>
|
||||
<View className={styles.address_list}>
|
||||
<ScrollView scrollY className={styles.address_scroll}>
|
||||
<View className={styles.address_scroll_list}>
|
||||
{list.map((item) => {
|
||||
return (
|
||||
<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>
|
||||
{(selectArr[selectIndex]?.id == item.id) && <View className={`iconfont icon-tick ${styles.address_iconfont}`}></View>}
|
||||
</View>
|
||||
<View className={styles.address_select}>
|
||||
<View id="address_tab_0" onClick={() => selectTab(0)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 0)})}>{selectArr[0]?selectArr[0].name:'请选择'}</View>
|
||||
{cityStatus&&<View id="address_tab_1" onClick={() => selectTab(1)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 1)})}>{selectArr[1]?selectArr[1].name:'请选择'}</View>}
|
||||
{areaStatus&&<View id="address_tab_2" onClick={() => selectTab(2)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 2)})}>{selectArr[2]?selectArr[2].name:'请选择'}</View>}
|
||||
<View style={bottomStyle} className={styles.bottom_index}></View>
|
||||
</View>
|
||||
<View className={styles.address_list}>
|
||||
<ScrollView scrollY className={styles.address_scroll}>
|
||||
<View className={styles.address_scroll_list}>
|
||||
{list.map(item => {
|
||||
return (
|
||||
<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>
|
||||
{(selectArr[selectIndex]?.id == item.id)&&<View className={`iconfont icon-tick ${styles.address_iconfont}` }></View>}
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</View>
|
||||
</Drawer>
|
||||
</>
|
||||
)
|
||||
})
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</View>
|
||||
</Drawer>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,202 +1,205 @@
|
||||
import { CancelOrderApi, ReceiveOrderApi } from "@/api/order"
|
||||
import { alert } from "@/common/common"
|
||||
import { ORDER_STATUS, SALE_MODE } from "@/common/enum"
|
||||
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 { ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
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 = {
|
||||
orderInfo: {
|
||||
status: number, //订单状态
|
||||
orderId: number, //订单id
|
||||
actual_amount: number, //实付金额
|
||||
wait_pay_amount: number, //待付金额
|
||||
sale_mode: number //订单类型
|
||||
}|null,
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
interface Param {
|
||||
orderInfo: {
|
||||
status: number // 订单状态
|
||||
orderId: number // 订单id
|
||||
actual_amount: number // 实付金额
|
||||
wait_pay_amount: number // 待付金额
|
||||
sale_mode: number // 订单类型
|
||||
}|null
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
export default memo(({orderInfo, onClick}:Param) => {
|
||||
//订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment
|
||||
} = ORDER_STATUS
|
||||
export default memo(({ orderInfo, onClick }: Param) => {
|
||||
// 订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment,
|
||||
} = ORDER_STATUS
|
||||
|
||||
//订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//订单按钮按订单状态归类, value是该订单状态,可能该按钮会出现
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value], //取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], //去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [SaleOrderStatusWaitingDelivery.value], //申请退款按钮对应: 待发货
|
||||
label: '申请退款'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], //申请退货按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [SaleOrderStatusWaitingReceipt.value], //确认收货按钮对应: 待收货
|
||||
label: '确认收货'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [SaleOrderStatusWaitingReceipt.value,SaleOrderStatusAlreadyReceipt.value,SaleOrderStatusComplete.value,SaleOrderStatusRefund.value], //再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
value: [SaleOrderStatusBooking.value], //按钮对应: 待接单
|
||||
label: '退款'
|
||||
},
|
||||
])
|
||||
|
||||
// 订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//判断是否显示该按钮
|
||||
const orderBtnsShow = (item) => {
|
||||
if(orderInfo) {
|
||||
if(item.id == 1) {
|
||||
//取消订单按钮
|
||||
return( orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) //在待发货之前没有付过款
|
||||
} else if (item.id == 2) {
|
||||
//去付款按钮
|
||||
return( orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) //只要没有付完款就显示
|
||||
} else if(item.id == 3 ) {
|
||||
//申请退款, 只有大货才有
|
||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //大货在待发货付过款
|
||||
} else if( item.id == 8) {
|
||||
//退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //散剪和剪板在待接单时付过款
|
||||
}
|
||||
else {
|
||||
//其他按钮
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
// 订单按钮按订单状态归类, value是该订单状态,可能该按钮会出现
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value], // 取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], // 去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [SaleOrderStatusWaitingDelivery.value], // 申请退款按钮对应: 待发货
|
||||
label: '申请退款',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], // 申请退货按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [SaleOrderStatusWaitingReceipt.value], // 确认收货按钮对应: 待收货
|
||||
label: '确认收货',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
value: [SaleOrderStatusBooking.value], // 按钮对应: 待接单
|
||||
label: '退款',
|
||||
},
|
||||
])
|
||||
|
||||
// 判断是否显示该按钮
|
||||
const orderBtnsShow = (item) => {
|
||||
if (orderInfo) {
|
||||
if (item.id == 1) {
|
||||
// 取消订单按钮
|
||||
return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款
|
||||
}
|
||||
else if (item.id == 2) {
|
||||
// 去付款按钮
|
||||
return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示
|
||||
}
|
||||
else if (item.id == 3) {
|
||||
// 申请退款, 只有大货才有
|
||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款
|
||||
}
|
||||
else if (item.id == 8) {
|
||||
// 退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款
|
||||
}
|
||||
else {
|
||||
// 其他按钮
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示的按钮数组
|
||||
const orderBtnsShowList: { id: number; value: any; label: string }[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter((item) => {
|
||||
return orderBtnsShow(item)
|
||||
})
|
||||
}, [orderInfo])
|
||||
|
||||
// 点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
(val == 1) && cancelOrder(); // 取消订单按钮
|
||||
(val == 2) && onClick?.(2); // 去付款按钮
|
||||
(val == 6) && receiveOrder() // 确认收货
|
||||
}
|
||||
|
||||
// 取消订单
|
||||
const { fetchData: cancelFetchData } = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//显示的按钮数组
|
||||
const orderBtnsShowList: {id: number, value: any, label: string}[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter(item => {
|
||||
return orderBtnsShow(item)
|
||||
})
|
||||
}, [orderInfo])
|
||||
// 确认订单
|
||||
const { fetchData: receiveOrderFetchData } = ReceiveOrderApi()
|
||||
const receiveOrder = async() => {
|
||||
console.log('123456')
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
}
|
||||
else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3) && <View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(true)}>更多</Text>
|
||||
{showMore && <View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) && <View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
</View>}
|
||||
</View>}
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
(val == 1)&&cancelOrder(); //取消订单按钮
|
||||
(val == 2)&&onClick?.(2); //去付款按钮
|
||||
(val == 6)&&receiveOrder(); //确认收货
|
||||
|
||||
}
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3) && <View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>,
|
||||
)}
|
||||
</View>
|
||||
|
||||
//取消订单
|
||||
const {fetchData: cancelFetchData} = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({id: orderInfo?.orderId})
|
||||
if(res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//确认订单
|
||||
const {fetchData: receiveOrderFetchData} = ReceiveOrderApi()
|
||||
const receiveOrder = async () => {
|
||||
console.log('123456')
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await receiveOrderFetchData({sale_order_id: orderInfo?.orderId})
|
||||
if(res.success){
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
} else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return {top:`-${(orderBtnsShowList.length - 3)*70 + 10}rpx`, left: `-${10}rpx`}
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3)&&<View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(true)}>更多</Text>
|
||||
{showMore&&<View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) &&<View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
</View>}
|
||||
</View>}
|
||||
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3)&&<View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
})
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
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 Taro from '@tarojs/taro'
|
||||
import { useRef, memo, useState, useMemo } from 'react'
|
||||
import { memo, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
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 { throttle } from '@/common/util'
|
||||
|
||||
type Param = {
|
||||
interface Param {
|
||||
orderInfo: {
|
||||
stage: number //售后状态
|
||||
sale_mode: number //订单类型
|
||||
type: number //1退货,2退款
|
||||
return_apply_order_id: number //售后申请单
|
||||
is_quality_check: true | false //质检结果
|
||||
stage: number // 售后状态
|
||||
sale_mode: number // 订单类型
|
||||
type: number // 1退货,2退款
|
||||
return_apply_order_id: number // 售后申请单
|
||||
is_quality_check: true | false // 质检结果
|
||||
}
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
fixedBottom?: true | false //是否固定在底部
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
fixedBottom?: true | false // 是否固定在底部
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
//售后订单状态
|
||||
const { ReturnStageApplying, ReturnStageWaitCheck, ReturnStageReturned, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund } =
|
||||
AFTER_ORDER_STATUS
|
||||
// 售后订单状态
|
||||
const { ReturnStageApplying, ReturnStageWaitCheck, ReturnStageReturned, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund }
|
||||
= AFTER_ORDER_STATUS
|
||||
|
||||
const {
|
||||
ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款
|
||||
@ -31,15 +31,14 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
ReturnApplyOrderTypeSalesRefund, // 销售退款
|
||||
} = 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[]>([
|
||||
{
|
||||
id: 8,
|
||||
label: '申请记录',
|
||||
validatarFunc: (orderInfo) => {
|
||||
if (orderInfo.sale_mode !== 1)
|
||||
return [ReturnStageQualityCheckPendingRefund.value, ReturnStageServiceOrderPendingRefund.value, ReturnStageReturned.value].includes(orderInfo.stage)
|
||||
if (orderInfo.sale_mode !== 1) { return [ReturnStageQualityCheckPendingRefund.value, ReturnStageServiceOrderPendingRefund.value, ReturnStageReturned.value].includes(orderInfo.stage) }
|
||||
return false
|
||||
},
|
||||
},
|
||||
@ -47,8 +46,7 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
id: 1,
|
||||
label: '取消退货',
|
||||
validatarFunc: (orderInfo) => {
|
||||
if (orderInfo?.sale_mode != 1 && orderInfo.type == ReturnApplyOrderTypeReturnForRefund.value)
|
||||
return [ReturnStageApplying.value, ReturnStageWaitCheck.value].includes(orderInfo.stage)
|
||||
if (orderInfo?.sale_mode != 1 && orderInfo.type == ReturnApplyOrderTypeReturnForRefund.value) { return [ReturnStageApplying.value, ReturnStageWaitCheck.value].includes(orderInfo.stage) }
|
||||
return false
|
||||
},
|
||||
},
|
||||
@ -70,9 +68,8 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
id: 6,
|
||||
label: '取消退款',
|
||||
validatarFunc: (orderInfo) => {
|
||||
if (orderInfo?.sale_mode != 1 && orderInfo.type != ReturnApplyOrderTypeReturnForRefund.value)
|
||||
return [ReturnStageApplying.value, ReturnStageServiceOrderPendingRefund.value]?.includes(orderInfo.stage)
|
||||
if (orderInfo?.sale_mode == 1) return [ReturnStageApplying.value].includes(orderInfo.stage)
|
||||
if (orderInfo?.sale_mode != 1 && orderInfo.type != ReturnApplyOrderTypeReturnForRefund.value) { return [ReturnStageApplying.value, ReturnStageServiceOrderPendingRefund.value]?.includes(orderInfo.stage) }
|
||||
if (orderInfo?.sale_mode == 1) { return [ReturnStageApplying.value].includes(orderInfo.stage) }
|
||||
return false
|
||||
},
|
||||
},
|
||||
@ -80,52 +77,56 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
id: 7,
|
||||
label: '退款码单',
|
||||
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
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
//显示的按钮数组
|
||||
// 显示的按钮数组
|
||||
const orderBtnsShowList: any[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter((item) => {
|
||||
return item.validatarFunc(orderInfo)
|
||||
})
|
||||
}, [orderInfo])
|
||||
|
||||
//点击按钮操作
|
||||
// 点击按钮操作
|
||||
const submitBtns = throttle((val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder({ title: '要取消退货吗?', val })
|
||||
} else if (val == 6) {
|
||||
}
|
||||
else if (val == 6) {
|
||||
cancelOrder({ title: '要取消退款吗?', val })
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 600)
|
||||
|
||||
//取消退货/退款
|
||||
// 取消退货/退款
|
||||
const { fetchData: returnApplyOrderCancelFetchData } = ReturnApplyOrderCancelApi()
|
||||
const cancelOrder = ({ title = '', val }) => {
|
||||
Taro.showModal({
|
||||
title,
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
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) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(val)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//显示更多按钮
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { memo, useCallback } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { numberWithCommas } from "@/common/fotmat";
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import { memo, useCallback } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import { numberWithCommas } from '@/common/fotmat'
|
||||
|
||||
type Param = {
|
||||
number: number, //数字
|
||||
status: 0|1|2 //0 小型,1中型,2大
|
||||
interface Param {
|
||||
number: number // 数字
|
||||
status: 0|1|2 // 0 小型,1中型,2大
|
||||
}
|
||||
export default memo(({number = 0, status = 1}:Param) => {
|
||||
const priceDom = useCallback(() => {
|
||||
let res = number.toFixed(2).split('.')
|
||||
let int_num = parseInt(res[0]) + ''
|
||||
let decimals_num = res[1]
|
||||
return (
|
||||
<>
|
||||
<Text className={styles.price_text}>¥</Text>
|
||||
<Text className={styles.price_text}>{numberWithCommas({number:int_num, digit:0})}</Text>
|
||||
<Text className={styles.price_text}>.{decimals_num}</Text>
|
||||
</>
|
||||
)
|
||||
}, [number])
|
||||
export default memo(({ number = 0, status = 1 }: Param) => {
|
||||
const priceDom = useCallback(() => {
|
||||
const res = number.toFixed(2).split('.')
|
||||
const int_num = `${parseInt(res[0])}`
|
||||
const decimals_num = res[1]
|
||||
return (
|
||||
<View className={classnames(styles.order_price_num, status==1&&styles.emphasis_num, status==2&&styles.emphasis_num_big)} >
|
||||
{priceDom()}
|
||||
</View>
|
||||
<>
|
||||
<Text className={styles.price_text}>¥</Text>
|
||||
<Text className={styles.price_text}>{numberWithCommas({ number: int_num, digit: 0 })}</Text>
|
||||
<Text className={styles.price_text}>.{decimals_num}</Text>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}, [number])
|
||||
return (
|
||||
<View className={classnames(styles.order_price_num, status == 1 && styles.emphasis_num, status == 2 && styles.emphasis_num_big)} >
|
||||
{priceDom()}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
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 { GetBannerList } from '@/api/banner'
|
||||
import styles from './index.module.scss'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
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[]
|
||||
swiperOnClick?: (val: item) => void
|
||||
style?: Object
|
||||
}
|
||||
export default (props: params) => {
|
||||
let { swiperOnClick, style = {} } = props
|
||||
const { swiperOnClick, style = {} } = props
|
||||
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const { fetchData, state } = GetBannerList()
|
||||
@ -22,15 +22,16 @@ export default (props: params) => {
|
||||
getData()
|
||||
}, [])
|
||||
|
||||
const getData = async () => {
|
||||
const getData = async() => {
|
||||
const res = await fetchData()
|
||||
setList(res.data?.list)
|
||||
}
|
||||
|
||||
const skipTo = (item) => {
|
||||
if (item.jump_type == 2 || item.jump_type == 0) {
|
||||
goLink(item.link + '&title=' + item.title)
|
||||
} else {
|
||||
goLink(`${item.link}&title=${item.title}`)
|
||||
}
|
||||
else {
|
||||
goLink(item.link)
|
||||
}
|
||||
}
|
||||
@ -41,12 +42,12 @@ export default (props: params) => {
|
||||
|
||||
return (
|
||||
<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) => {
|
||||
return (
|
||||
<SwiperItem key={item.id}>
|
||||
<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>
|
||||
</SwiperItem>
|
||||
)
|
||||
|
||||
@ -1,51 +1,50 @@
|
||||
import { Image, Swiper, SwiperItem, Text, View } from "@tarojs/components"
|
||||
import styles from './index.module.scss'
|
||||
import { formatImgUrl } from "@/common/fotmat"
|
||||
import Taro from "@tarojs/taro";
|
||||
import { goLink } from "@/common/common";
|
||||
import { Image, Swiper, SwiperItem, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import styles from './index.module.scss'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
import { goLink } from '@/common/common'
|
||||
|
||||
type params = {
|
||||
show?: true|false,
|
||||
onClose?: () => void
|
||||
interface params {
|
||||
show?: true|false
|
||||
onClose?: () => void
|
||||
}
|
||||
export default ({show, onClose}:params) => {
|
||||
const onCustomer = async () => {
|
||||
let res = await Taro.showModal({
|
||||
title: '是否拨打服务热线',
|
||||
confirmText: '拨打',
|
||||
content: '(0757) 8270 6695',
|
||||
cancelText: '取消',
|
||||
})
|
||||
if(res.confirm) {
|
||||
Taro.makePhoneCall({
|
||||
phoneNumber: '(0757)82706695'
|
||||
})
|
||||
}
|
||||
export default ({ show, onClose }: params) => {
|
||||
const onCustomer = async() => {
|
||||
const res = await Taro.showModal({
|
||||
title: '是否拨打服务热线',
|
||||
confirmText: '拨打',
|
||||
content: '(0757) 8270 6695',
|
||||
cancelText: '取消',
|
||||
})
|
||||
if (res.confirm) {
|
||||
Taro.makePhoneCall({
|
||||
phoneNumber: '(0757)82706695',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onConfirm = () => {
|
||||
onClose?.()
|
||||
goLink('/pages/bindSalesman/index')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{show&&<View className={styles.bindSalesman_main}>
|
||||
<View className={styles.bindSalesman_pop}>
|
||||
<View className={styles.bindSalesman_header}>
|
||||
<Image src={formatImgUrl('/mall/invite_code_top.png', '!w400')} mode="aspectFill"/>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_message}>
|
||||
<Text>提示</Text>
|
||||
<Text>暂未开通下单权限功能,稍后有客服联系您,请注意接收电话。</Text>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_operation}>
|
||||
<View className={styles.btns} onClick={() => onConfirm()}>输入邀请码</View>
|
||||
<View className={styles.btns} onClick={() => onCustomer()}>联系客服</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_mask} onClick={onClose}></View>
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
|
||||
}
|
||||
const onConfirm = () => {
|
||||
onClose?.()
|
||||
goLink('/pages/bindSalesman/index')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{show && <View className={styles.bindSalesman_main}>
|
||||
<View className={styles.bindSalesman_pop}>
|
||||
<View className={styles.bindSalesman_header}>
|
||||
<Image src={formatImgUrl('/mall/invite_code_top.png', '!w400')} mode="aspectFill" />
|
||||
</View>
|
||||
<View className={styles.bindSalesman_message}>
|
||||
<Text>提示</Text>
|
||||
<Text>暂未开通下单权限功能,稍后有客服联系您,请注意接收电话。</Text>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_operation}>
|
||||
<View className={styles.btns} onClick={() => onConfirm()}>输入邀请码</View>
|
||||
<View className={styles.btns} onClick={() => onCustomer()}>联系客服</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_mask} onClick={onClose}></View>
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,93 +1,93 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useState } from "react";
|
||||
import Taro, { useDidShow } from "@tarojs/taro";
|
||||
import {useBluetooth} from "@/use/contextBlueTooth"
|
||||
import SearchInput from "@/components/searchInput";
|
||||
import Popup from "@/components/bluetooth/Popup"
|
||||
import classnames from "classnames";
|
||||
import styles from "./css/linkBlueTooth.module.scss"
|
||||
import useCheckAuthorize from "@/use/useCheckAuthorize";
|
||||
import { View } from '@tarojs/components'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './css/linkBlueTooth.module.scss'
|
||||
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||
import SearchInput from '@/components/searchInput'
|
||||
import Popup from '@/components/bluetooth/Popup'
|
||||
import useCheckAuthorize from '@/use/useCheckAuthorize'
|
||||
|
||||
export default memo(() => {
|
||||
const {state, init, startScan, connect, disconnect} = useBluetooth()
|
||||
const { state, init, startScan, connect, disconnect } = useBluetooth()
|
||||
|
||||
const {check} = useCheckAuthorize({scope:'scope.bluetooth', msg:'请开启小程序蓝牙权限'})
|
||||
const { check } = useCheckAuthorize({ scope: 'scope.bluetooth', msg: '请开启小程序蓝牙权限' })
|
||||
|
||||
useEffect(() => {
|
||||
init()
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
init()
|
||||
}, [])
|
||||
|
||||
const [linkStatus, setLinkStatus] = useState(1)
|
||||
useEffect(() => {
|
||||
if(!state.available) {
|
||||
setLinkStatus(1)
|
||||
} else if(state.available&&state.connected?.name) {
|
||||
setLinkStatus(3)
|
||||
} else {
|
||||
setLinkStatus(2)
|
||||
}
|
||||
}, [state.available, state.connected])
|
||||
|
||||
const linkName = useMemo(() => {
|
||||
return state.connected?.localName||''
|
||||
}, [state.connected])
|
||||
|
||||
//链接设备
|
||||
const onLinkListen = (item) => {
|
||||
if(!state.connected&&!state.connecting)
|
||||
connect(item)
|
||||
const [linkStatus, setLinkStatus] = useState(1)
|
||||
useEffect(() => {
|
||||
if (!state.available) {
|
||||
setLinkStatus(1)
|
||||
}
|
||||
else if (state.available && state.connected?.name) {
|
||||
setLinkStatus(3)
|
||||
}
|
||||
else {
|
||||
setLinkStatus(2)
|
||||
}
|
||||
}, [state.available, state.connected])
|
||||
|
||||
const [popupShow, setPopupShow] = useState(false)
|
||||
//显示设备列表
|
||||
const onFindDevice = () => {
|
||||
check().then(res => {
|
||||
if(linkStatus == 1) {
|
||||
Taro.showToast({
|
||||
title:'请打开手机蓝牙',
|
||||
icon:'none'
|
||||
})
|
||||
} else {
|
||||
setPopupShow(true)
|
||||
onFindEven()
|
||||
}
|
||||
const linkName = useMemo(() => {
|
||||
return state.connected?.localName || ''
|
||||
}, [state.connected])
|
||||
|
||||
// 链接设备
|
||||
const onLinkListen = (item) => {
|
||||
if (!state.connected && !state.connecting) { connect(item) }
|
||||
}
|
||||
|
||||
const [popupShow, setPopupShow] = useState(false)
|
||||
// 显示设备列表
|
||||
const onFindDevice = () => {
|
||||
check().then((res) => {
|
||||
if (linkStatus == 1) {
|
||||
Taro.showToast({
|
||||
title: '请打开手机蓝牙',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
const onFindEven = () => {
|
||||
if(!state.discovering&&!state.connected&&!state.connecting)
|
||||
startScan()
|
||||
}
|
||||
}
|
||||
else {
|
||||
setPopupShow(true)
|
||||
onFindEven()
|
||||
}
|
||||
})
|
||||
}
|
||||
const onFindEven = () => {
|
||||
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
|
||||
}
|
||||
|
||||
//断开链接
|
||||
const onDisconnect = () => {
|
||||
disconnect()
|
||||
setPopupShow(false)
|
||||
}
|
||||
// 断开链接
|
||||
const onDisconnect = () => {
|
||||
disconnect()
|
||||
setPopupShow(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.main}>
|
||||
<SearchInput title="蓝牙设备" showIcon={true}>
|
||||
<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>
|
||||
{
|
||||
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 == 3&&<View className={classnames(styles.link_name)}>{linkName}</View>
|
||||
}
|
||||
</View>
|
||||
</SearchInput>
|
||||
<Popup
|
||||
state={state}
|
||||
show={popupShow}
|
||||
onClose={() => setPopupShow(false)}
|
||||
onLink={item => onLinkListen(item)}
|
||||
onOff={onDisconnect}
|
||||
onFind={onFindEven}
|
||||
/>
|
||||
</View>
|
||||
</>
|
||||
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<View className={styles.main}>
|
||||
<SearchInput title="蓝牙设备" showIcon>
|
||||
<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>
|
||||
{
|
||||
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 == 3 && <View className={classnames(styles.link_name)}>{linkName}</View>
|
||||
}
|
||||
</View>
|
||||
</SearchInput>
|
||||
<Popup
|
||||
state={state}
|
||||
show={popupShow}
|
||||
onClose={() => setPopupShow(false)}
|
||||
onLink={item => onLinkListen(item)}
|
||||
onOff={onDisconnect}
|
||||
onFind={onFindEven}
|
||||
/>
|
||||
</View>
|
||||
</>
|
||||
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,73 +1,73 @@
|
||||
import { ScrollView, View } from "@tarojs/components"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import Loading from "@/components/loading"
|
||||
import style from "./css/popup.module.scss"
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import style from './css/popup.module.scss'
|
||||
import Loading from '@/components/loading'
|
||||
|
||||
interface params {
|
||||
state: any,
|
||||
show: Boolean,
|
||||
onClose: (Boolean) => void,
|
||||
onLink: (any) => void,
|
||||
children?: React.ReactNode
|
||||
onOff: () => void,
|
||||
onFind: () => void,
|
||||
state: any
|
||||
show: Boolean
|
||||
onClose: (Boolean) => void
|
||||
onLink: (any) => void
|
||||
children?: React.ReactNode
|
||||
onOff: () => void
|
||||
onFind: () => void
|
||||
}
|
||||
|
||||
export default memo(({state, show=false, onClose, onLink, onOff, onFind}:params) => {
|
||||
const [popupShow, setPopupShow] = useState(show)
|
||||
useEffect(() => {
|
||||
setPopupShow(show)
|
||||
}, [show])
|
||||
const onCloseListener = () => {
|
||||
onClose(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
popupShow&&<View className={style.popup}>
|
||||
<View className={style.content}>
|
||||
<View className={style.title}>搜索设备</View>
|
||||
<View className={style.list}>
|
||||
<ScrollView scrollY className={style.scroll}>
|
||||
{
|
||||
(state.devices&&state.devices.length > 0)&&state?.devices.map(item => {
|
||||
return (
|
||||
<View className={style.item} onClick={() => onLink(item)}>
|
||||
<View>{item.name}</View>
|
||||
{
|
||||
(!state.connecting&&!state.connected)&&<View >链接</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>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})||
|
||||
<View className={style.noDevice}>
|
||||
{
|
||||
(!state.discovering)&& <>
|
||||
<View>暂无设备,请按以下条件检查</View>
|
||||
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
|
||||
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
|
||||
<View className={style.n_item}>3.请打开手机定位</View>
|
||||
</>||
|
||||
<View>设备搜索中</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
|
||||
const [popupShow, setPopupShow] = useState(show)
|
||||
useEffect(() => {
|
||||
setPopupShow(show)
|
||||
}, [show])
|
||||
const onCloseListener = () => {
|
||||
onClose(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
popupShow && <View className={style.popup}>
|
||||
<View className={style.content}>
|
||||
<View className={style.title}>搜索设备</View>
|
||||
<View className={style.list}>
|
||||
<ScrollView scrollY className={style.scroll}>
|
||||
{
|
||||
(state.devices && state.devices.length > 0) && state?.devices.map((item) => {
|
||||
return (
|
||||
<View className={style.item} onClick={() => onLink(item)}>
|
||||
<View>{item.name}</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>||
|
||||
<View className={style.footer} onClick={onFind}>重新搜索</View>
|
||||
(!state.connecting && !state.connected) && <View >链接</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>
|
||||
}
|
||||
</View>
|
||||
<View className={style.mask} onClick={onCloseListener}></View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|| <View className={style.noDevice}>
|
||||
{
|
||||
(!state.discovering) && <>
|
||||
<View>暂无设备,请按以下条件检查</View>
|
||||
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
|
||||
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
|
||||
<View className={style.n_item}>3.请打开手机定位</View>
|
||||
</>
|
||||
|| <View>设备搜索中</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
|
||||
}
|
||||
</ScrollView>
|
||||
</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>
|
||||
|| <View className={style.footer} onClick={onFind}>重新搜索</View>
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
</View>
|
||||
<View className={style.mask} onClick={onCloseListener}></View>
|
||||
</View>
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -3,20 +3,21 @@ import classnames from 'classnames'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type params = {
|
||||
onSelect?: () => void //选择触发
|
||||
onClose?: () => void //取消触发
|
||||
status?: false | true //是否选中
|
||||
disabled?: false | true //是否禁用
|
||||
interface params {
|
||||
onSelect?: () => void // 选择触发
|
||||
onClose?: () => void // 取消触发
|
||||
status?: false | true // 是否选中
|
||||
disabled?: false | true // 是否禁用
|
||||
}
|
||||
export default forwardRef(({ onSelect, onClose, status = false, disabled = false }: params, ref) => {
|
||||
const [selected, SetSelected] = useState(false)
|
||||
const onSelectEven = () => {
|
||||
if (disabled) return false
|
||||
let res = !selected
|
||||
if (disabled) { return false }
|
||||
const res = !selected
|
||||
if (res) {
|
||||
onSelect?.()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
onClose?.()
|
||||
}
|
||||
SetSelected(res)
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
import { View, Text } from "@tarojs/components"
|
||||
import { memo } from "react"
|
||||
import style from "./index.module.scss"
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import style from './index.module.scss'
|
||||
|
||||
type Params = {
|
||||
onClose?: () => void,
|
||||
styleObj?: Object
|
||||
interface Params {
|
||||
onClose?: () => void
|
||||
styleObj?: Object
|
||||
}
|
||||
|
||||
export default memo(({onClose, styleObj = {}}:Params) => {
|
||||
return (
|
||||
<View
|
||||
style={styleObj}
|
||||
className={style.icon_a_cuowuwrong_self}
|
||||
onClick={onClose}
|
||||
>
|
||||
<Text className={`iconfont icon-qingkong ${style.icon_a_btn}`}></Text>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
export default memo(({ onClose, styleObj = {} }: Params) => {
|
||||
return (
|
||||
<View
|
||||
style={styleObj}
|
||||
className={style.icon_a_cuowuwrong_self}
|
||||
onClick={onClose}
|
||||
>
|
||||
<Text className={`iconfont icon-qingkong ${style.icon_a_btn}`}></Text>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
import { Input, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Big from 'big.js'
|
||||
import styles from './index.module.scss'
|
||||
type params = {
|
||||
minNum?: number //最小值
|
||||
maxNum?: number //最大值
|
||||
step?: number //步长
|
||||
defaultNum?: number //默认值
|
||||
digits?: number //多少位小数
|
||||
import styles from './index.module.scss'
|
||||
|
||||
interface params {
|
||||
minNum?: number // 最小值
|
||||
maxNum?: number // 最大值
|
||||
step?: number // 步长
|
||||
defaultNum?: number // 默认值
|
||||
digits?: number // 多少位小数
|
||||
onChange?: (val: number) => void
|
||||
onBlue?: (val: number) => void //失去焦点触发
|
||||
onBlue?: (val: number) => void // 失去焦点触发
|
||||
onClickBtn?: (val: number) => void
|
||||
unit?: string
|
||||
disable?: true | false //是否禁用
|
||||
disable?: true | false // 是否禁用
|
||||
}
|
||||
export default memo((props: params) => {
|
||||
return <Counter {...props}></Counter>
|
||||
@ -20,24 +21,24 @@ export default memo((props: params) => {
|
||||
|
||||
function areEqual(prevProps: params, nextProps: params) {
|
||||
return (
|
||||
prevProps.defaultNum == nextProps.defaultNum &&
|
||||
prevProps.unit == nextProps.unit &&
|
||||
prevProps.minNum == nextProps.minNum &&
|
||||
prevProps.maxNum == nextProps.maxNum &&
|
||||
prevProps.step == nextProps.step &&
|
||||
prevProps.digits == nextProps.digits
|
||||
prevProps.defaultNum == nextProps.defaultNum
|
||||
&& prevProps.unit == nextProps.unit
|
||||
&& prevProps.minNum == nextProps.minNum
|
||||
&& prevProps.maxNum == nextProps.maxNum
|
||||
&& prevProps.step == nextProps.step
|
||||
&& prevProps.digits == nextProps.digits
|
||||
)
|
||||
}
|
||||
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 })
|
||||
// useEffect(() => {
|
||||
// setValue({ count: defaultNum })
|
||||
// }, [defaultNum])
|
||||
console.log('1231231231231212')
|
||||
const onPlus = () => {
|
||||
if (disable) return false
|
||||
let { count } = value
|
||||
if (disable) { return false }
|
||||
const { count } = value
|
||||
let num_res = Big(count).add(step).toNumber()
|
||||
num_res = num_res >= maxNum ? maxNum : num_res
|
||||
num_res = formatDigits(num_res)
|
||||
@ -46,8 +47,8 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
const minus = () => {
|
||||
if (disable) return false
|
||||
let { count } = value
|
||||
if (disable) { return false }
|
||||
const { count } = value
|
||||
let num_res = Big(count).minus(step).toNumber()
|
||||
num_res = num_res < minNum ? minNum : num_res
|
||||
// setValue({ ...value, count: num_res })
|
||||
@ -55,23 +56,23 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
|
||||
//保留小数
|
||||
// 保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = num + ''
|
||||
num = `${num}`
|
||||
if (num.includes('.') && digits > 0) {
|
||||
console.log('num::', num.includes('.'))
|
||||
let res = num.split('.')
|
||||
let last_num = res[1].substr(0, digits)
|
||||
return res[0] + '.' + last_num
|
||||
const res = num.split('.')
|
||||
const last_num = res[1].substr(0, digits)
|
||||
return `${res[0]}.${last_num}`
|
||||
}
|
||||
return parseFloat(num)
|
||||
}
|
||||
|
||||
//检查数据
|
||||
// 检查数据
|
||||
const checkData = (val) => {
|
||||
let num = parseFloat(val)
|
||||
if (num > maxNum) return maxNum
|
||||
if (num < minNum) return minNum
|
||||
const num = parseFloat(val)
|
||||
if (num > maxNum) { return maxNum }
|
||||
if (num < minNum) { return minNum }
|
||||
return val
|
||||
}
|
||||
|
||||
@ -100,13 +101,14 @@ const Counter = memo((props: params) => {
|
||||
}
|
||||
|
||||
const onBluerEven = (e) => {
|
||||
let num = parseFloat(e.detail.value)
|
||||
const num = parseFloat(e.detail.value)
|
||||
if (!isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
// setValue({ ...value, count })
|
||||
onBlue?.(count as number)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// setValue({ ...value, count: defaultNum })
|
||||
onBlue?.(minNum)
|
||||
}
|
||||
@ -121,9 +123,9 @@ const Counter = memo((props: params) => {
|
||||
value={String(props.defaultNum)}
|
||||
onInput={onInputEven}
|
||||
onBlur={onBluerEven}
|
||||
type='digit'
|
||||
type="digit"
|
||||
disabled={disable}
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
/>
|
||||
<View className={styles.unit}>{unit}</View>
|
||||
|
||||
@ -1,26 +1,27 @@
|
||||
import { CustomWrapper, Input, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Big from 'big.js'
|
||||
import styles from './index.module.scss'
|
||||
type params = {
|
||||
minNum?: number //最小值
|
||||
maxNum?: number //最大值
|
||||
step?: number //步长
|
||||
defaultNum?: number //默认值
|
||||
digits?: number //多少位小数
|
||||
import styles from './index.module.scss'
|
||||
|
||||
interface params {
|
||||
minNum?: number // 最小值
|
||||
maxNum?: number // 最大值
|
||||
step?: number // 步长
|
||||
defaultNum?: number // 默认值
|
||||
digits?: number // 多少位小数
|
||||
onChange?: (val: number) => void
|
||||
onBlue?: (val: number) => void //失去焦点触发
|
||||
onBlue?: (val: number) => void // 失去焦点触发
|
||||
onClickBtn?: (val: number) => void
|
||||
unit?: string
|
||||
disabled?: true | false //是否禁用
|
||||
returnZero?: true | false //少于最小值时是否归0
|
||||
disabled?: true | false // 是否禁用
|
||||
returnZero?: true | false // 少于最小值时是否归0
|
||||
}
|
||||
export default memo((props: params) => {
|
||||
return <Counter {...props}></Counter>
|
||||
})
|
||||
|
||||
const Counter = memo((props: params) => {
|
||||
let {
|
||||
const {
|
||||
minNum = 0,
|
||||
maxNum = 10000,
|
||||
step = 1,
|
||||
@ -38,8 +39,8 @@ const Counter = memo((props: params) => {
|
||||
setValue({ count: defaultNum })
|
||||
}, [defaultNum])
|
||||
const onPlus = () => {
|
||||
if (disabled) return false
|
||||
let count = value.count
|
||||
if (disabled) { return false }
|
||||
const count = value.count
|
||||
let num_res = Big(count).add(step).toNumber()
|
||||
num_res = num_res >= maxNum ? maxNum : num_res
|
||||
num_res = formatDigits(num_res)
|
||||
@ -48,12 +49,13 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
const minus = () => {
|
||||
if (disabled) return false
|
||||
let count = value.count
|
||||
if (disabled) { return false }
|
||||
const count = value.count
|
||||
let num_res = Big(count).minus(step).toNumber()
|
||||
if (returnZero) {
|
||||
num_res = num_res < minNum ? 0 : num_res
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
num_res = num_res < minNum ? minNum : num_res
|
||||
}
|
||||
setValue({ ...value, count: num_res })
|
||||
@ -61,15 +63,16 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
|
||||
//保留小数
|
||||
// 保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = num + ''
|
||||
num = `${num}`
|
||||
if (num.includes('.')) {
|
||||
let res = num.split('.')
|
||||
const res = num.split('.')
|
||||
if (digits > 0) {
|
||||
let last_num = res[1].substr(0, digits)
|
||||
return res[0] + '.' + last_num
|
||||
} else {
|
||||
const last_num = res[1].substr(0, digits)
|
||||
return `${res[0]}.${last_num}`
|
||||
}
|
||||
else {
|
||||
return res[0]
|
||||
}
|
||||
}
|
||||
@ -77,56 +80,61 @@ const Counter = memo((props: params) => {
|
||||
return parseFloat(num)
|
||||
}
|
||||
|
||||
//检查数据
|
||||
// 检查数据
|
||||
const checkData = (val) => {
|
||||
let num = parseFloat(val)
|
||||
if (num > maxNum) return maxNum
|
||||
if (num < minNum) return minNum
|
||||
const num = parseFloat(val)
|
||||
if (num > maxNum) { return maxNum }
|
||||
if (num < minNum) { return minNum }
|
||||
return val
|
||||
}
|
||||
|
||||
const onInputEven = (e) => {
|
||||
let res = e.detail.value
|
||||
const res = e.detail.value
|
||||
if (res === '') {
|
||||
onChange?.(minNum)
|
||||
} else if (!isNaN(Number(res))) {
|
||||
}
|
||||
else if (!isNaN(Number(res))) {
|
||||
let count = formatDigits(res)
|
||||
count = checkData(count)
|
||||
onChange?.(parseFloat(count as string))
|
||||
} else {
|
||||
let num = parseFloat(res)
|
||||
}
|
||||
else {
|
||||
const num = parseFloat(res)
|
||||
if (!isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
onChange?.(count as number)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
onChange?.(defaultNum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onBluerEven = (e) => {
|
||||
let num = parseFloat(e.detail.value)
|
||||
const num = parseFloat(e.detail.value)
|
||||
if (e.detail.value == '') {
|
||||
onBlue?.(minNum)
|
||||
setValue({ count: minNum })
|
||||
} else if (!isNaN(num)) {
|
||||
}
|
||||
else if (!isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
setValue({ count })
|
||||
onBlue?.(count as number)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setValue({ count: minNum })
|
||||
onBlue?.(minNum)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<View className={styles.main} onClick={(e) => e.stopPropagation()}>
|
||||
<View className={styles.main} onClick={e => e.stopPropagation()}>
|
||||
<View className={styles.reduce} onClick={() => minus()}>
|
||||
-
|
||||
</View>
|
||||
<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>
|
||||
<View className={styles.plus} onClick={() => onPlus()}>
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
export default memo(() => {
|
||||
return (
|
||||
<>
|
||||
<View className={styles.load_box}>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
return (
|
||||
<>
|
||||
<View className={styles.load_box}>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,64 +1,65 @@
|
||||
import { Text, View } from "@tarojs/components"
|
||||
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useState } from "react"
|
||||
import {formatKbPrice} from '@/common/common'
|
||||
import classnames from "classnames";
|
||||
import styles from './index.module.scss'
|
||||
import Taro from "@tarojs/taro";
|
||||
import AmountShow from "../amountShow";
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import AmountShow from '../amountShow'
|
||||
import styles from './index.module.scss'
|
||||
import { formatKbPrice } from '@/common/common'
|
||||
|
||||
type Param = {
|
||||
style?: Object,
|
||||
number?: number|string,
|
||||
title?: string,
|
||||
titleStatus?: true|false, //true 标题加大加深
|
||||
numberStatus?: 0|1|2, //数字尺寸
|
||||
messageTitle?: string,
|
||||
messageWidth?: number,
|
||||
messageShow?: true|false,
|
||||
numberFormat?: 'number'|'text' //数字还是字符串
|
||||
interface Param {
|
||||
style?: Object
|
||||
number?: number|string
|
||||
title?: string
|
||||
titleStatus?: true|false // true 标题加大加深
|
||||
numberStatus?: 0|1|2 // 数字尺寸
|
||||
messageTitle?: string
|
||||
messageWidth?: number
|
||||
messageShow?: true|false
|
||||
numberFormat?: 'number'|'text' // 数字还是字符串
|
||||
}
|
||||
export default memo(({number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number'}:Param) => {
|
||||
const [show, setShow] = useState(messageShow)
|
||||
const onClose = () => {
|
||||
setShow(false)
|
||||
}
|
||||
const openShow = () => [
|
||||
setShow(true)
|
||||
]
|
||||
export default memo(({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number' }: Param) => {
|
||||
const [show, setShow] = useState(messageShow)
|
||||
const onClose = () => {
|
||||
setShow(false)
|
||||
}
|
||||
const openShow = () => [
|
||||
setShow(true),
|
||||
]
|
||||
|
||||
const [style, setStyle] = useState<{top: string}>()
|
||||
const [style, setStyle] = useState<{ top: string }>()
|
||||
|
||||
useEffect(() => {
|
||||
if(show) {
|
||||
getDomDes('#message')
|
||||
} else {
|
||||
setStyle(() => ({top: '0'}))
|
||||
}
|
||||
}, [show])
|
||||
//设置弹出层高度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
let query = Taro.createSelectorQuery();
|
||||
query.select(id).boundingClientRect(rect=>{
|
||||
let height = rect.height * 2 + 15;
|
||||
setStyle((e) => ({...e, top: `-${height}rpx`, opacity: 1}))
|
||||
}).exec();
|
||||
}, 0)
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
getDomDes('#message')
|
||||
}
|
||||
else {
|
||||
setStyle(() => ({ top: '0' }))
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.order_price}>
|
||||
<View className={classnames(styles.order_price_text, titleStatus&&styles.emphasis)} onClick={() => openShow()}>
|
||||
<Text>{title}</Text>
|
||||
<View className={styles.iconfont_msg}>
|
||||
{show&&<View style={{...style, width: `${messageWidth}rpx`}} id='message' className={classnames(styles.message)}>{messageTitle}</View>}
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
||||
</View>
|
||||
</View>
|
||||
{numberFormat == 'number' && <AmountShow status={numberStatus} number={(number as number / 100)}/>}
|
||||
{(numberFormat == 'text') && <View className={styles.refund_destination}>{number}</View>}
|
||||
{show&&<View className={styles.close} catchMove onClick={onClose}></View>}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}, [show])
|
||||
// 设置弹出层高度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
const query = Taro.createSelectorQuery()
|
||||
query.select(id).boundingClientRect((rect) => {
|
||||
const height = rect.height * 2 + 15
|
||||
setStyle(e => ({ ...e, top: `-${height}rpx`, opacity: 1 }))
|
||||
}).exec()
|
||||
}, 0)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.order_price}>
|
||||
<View className={classnames(styles.order_price_text, titleStatus && styles.emphasis)} onClick={() => openShow()}>
|
||||
<Text>{title}</Text>
|
||||
<View className={styles.iconfont_msg}>
|
||||
{show && <View style={{ ...style, width: `${messageWidth}rpx` }} id="message" className={classnames(styles.message)}>{messageTitle}</View>}
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
||||
</View>
|
||||
</View>
|
||||
{numberFormat == 'number' && <AmountShow status={numberStatus} number={(number as number / 100)} />}
|
||||
{(numberFormat == 'text') && <View className={styles.refund_destination}>{number}</View>}
|
||||
{show && <View className={styles.close} catchMove onClick={onClose}></View>}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
import { GetProductKindListApi } from '@/api/material'
|
||||
import Popup, { Params as PopuParams } from '@/components/popup'
|
||||
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||
import { useDidShow } from '@tarojs/taro'
|
||||
import classnames from 'classnames'
|
||||
import { memo, useEffect, useRef, useState } from 'react'
|
||||
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 = {
|
||||
onFiltr?: (val: object) => void //确定搜索
|
||||
onRest?: (val: Object) => void //重置
|
||||
onFiltr?: (val: object) => void // 确定搜索
|
||||
onRest?: (val: Object) => void // 重置
|
||||
} & PopuParams
|
||||
export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
//搜索条件
|
||||
// 搜索条件
|
||||
const [filterObj, setFilterObj] = useState({
|
||||
seriesName: '',
|
||||
seriesId: '',
|
||||
@ -22,11 +23,11 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
|
||||
const selectFieldValue = useRef({ width: '幅宽', weight: '克重', element: '成分', seriesName: '系列' })
|
||||
|
||||
//获取系列
|
||||
// 获取系列
|
||||
const { fetchData: kindFetchData } = GetProductKindListApi()
|
||||
const [kindList, setKindList] = useState<any[]>([])
|
||||
const getCategoryList = async () => {
|
||||
let { data } = await kindFetchData()
|
||||
const getCategoryList = async() => {
|
||||
const { data } = await kindFetchData()
|
||||
setKindList(data.list)
|
||||
}
|
||||
|
||||
@ -34,7 +35,7 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
show && getCategoryList()
|
||||
}, [show])
|
||||
|
||||
//切换系列
|
||||
// 切换系列
|
||||
const changeKind = (e) => {
|
||||
setFilterObj({ ...filterObj, seriesId: e.id, seriesName: e.name })
|
||||
}
|
||||
@ -43,9 +44,9 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
onClose?.()
|
||||
}
|
||||
|
||||
//重置数据
|
||||
// 重置数据
|
||||
const onRestEven = () => {
|
||||
let res = {
|
||||
const res = {
|
||||
seriesName: '',
|
||||
seriesId: '',
|
||||
width: '',
|
||||
@ -57,20 +58,20 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
onClose?.()
|
||||
}
|
||||
|
||||
//提交搜索
|
||||
// 提交搜索
|
||||
const onVerify = () => {
|
||||
onFiltr?.({ data: filterObj, field: selectFieldValue.current })
|
||||
onClose?.()
|
||||
}
|
||||
|
||||
//获取幅宽或克重输入值或成分
|
||||
// 获取幅宽或克重输入值或成分
|
||||
const setFieldData = (e, field) => {
|
||||
filterObj[field] = e.detail.value
|
||||
setFilterObj({ ...filterObj })
|
||||
}
|
||||
|
||||
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_title}>全部筛选</View>
|
||||
<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.title}>系列</View>
|
||||
<View className={styles.btn_list}>
|
||||
{kindList.map((item) => (
|
||||
{kindList.map(item => (
|
||||
<View
|
||||
key={item.id}
|
||||
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}
|
||||
</View>
|
||||
))}
|
||||
@ -93,12 +95,12 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
<View className={styles.btn_list_input}>
|
||||
<View className={styles.btn_width}>
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
value={filterObj.width}
|
||||
onBlur={(e) => setFieldData(e, 'width')}
|
||||
placeholder='请输入幅宽'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
onBlur={e => setFieldData(e, 'width')}
|
||||
placeholder="请输入幅宽"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
/>
|
||||
</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}>
|
||||
<Input
|
||||
value={filterObj.weight}
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
onBlur={(e) => setFieldData(e, 'weight')}
|
||||
placeholder='请输入克重'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
onBlur={e => setFieldData(e, 'weight')}
|
||||
placeholder="请输入克重"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
/>
|
||||
</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.title}>成分</View>
|
||||
<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 className='common_safe_area_y'></View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View className={styles.btns_con}>
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
import { GetProductKindListApi } from '@/api/material'
|
||||
import Popup, { Params as PopuParams } from '@/components/popup'
|
||||
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||
import { useDidShow } from '@tarojs/taro'
|
||||
import classnames from 'classnames'
|
||||
import { useEffect, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import type { Params as PopuParams } from '@/components/popup'
|
||||
import { GetProductKindListApi } from '@/api/material'
|
||||
|
||||
type params = {
|
||||
onFiltr?: (val: object) => void
|
||||
} & PopuParams
|
||||
export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
//搜索条件
|
||||
// 搜索条件
|
||||
const [filterObj, setFilterObj] = useState({
|
||||
seriesId: '',
|
||||
minWidth: '',
|
||||
@ -20,11 +21,11 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
element: '',
|
||||
})
|
||||
|
||||
//获取系列
|
||||
// 获取系列
|
||||
const { fetchData: kindFetchData } = GetProductKindListApi()
|
||||
const [kindList, setKindList] = useState<any[]>([])
|
||||
const getCategoryList = async () => {
|
||||
let { data } = await kindFetchData()
|
||||
const getCategoryList = async() => {
|
||||
const { data } = await kindFetchData()
|
||||
setKindList(data.list)
|
||||
}
|
||||
|
||||
@ -32,7 +33,7 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
show && getCategoryList()
|
||||
}, [show])
|
||||
|
||||
//切换系列
|
||||
// 切换系列
|
||||
const changeKind = (e) => {
|
||||
setFilterObj({ ...filterObj, seriesId: e.id })
|
||||
}
|
||||
@ -62,21 +63,22 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
|
||||
const setNumber = (e, field) => {
|
||||
console.log(e)
|
||||
let num = parseFloat(e.detail.value)
|
||||
const num = parseFloat(e.detail.value)
|
||||
if (isNaN(num)) {
|
||||
filterObj[field] = null
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
filterObj[field] = parseFloat(num.toFixed(2))
|
||||
}
|
||||
setFilterObj({ ...filterObj })
|
||||
}
|
||||
|
||||
const setElement = (e) => {
|
||||
let res = e.detail.value
|
||||
const res = e.detail.value
|
||||
setFilterObj({ ...filterObj, element: res })
|
||||
}
|
||||
return (
|
||||
<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_title}>全部筛选</View>
|
||||
<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.title}>系列</View>
|
||||
<View className={styles.btn_list}>
|
||||
{kindList.map((item) => (
|
||||
{kindList.map(item => (
|
||||
<View
|
||||
key={item.id}
|
||||
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}
|
||||
</View>
|
||||
))}
|
||||
@ -99,13 +102,13 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
<View className={styles.btn_list_input}>
|
||||
<View className={styles.btn_width}>
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
value={filterObj.minWidth}
|
||||
type='digit'
|
||||
onBlur={(e) => setNumber(e, 'minWidth')}
|
||||
placeholder='请输入幅宽'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
type="digit"
|
||||
onBlur={e => setNumber(e, 'minWidth')}
|
||||
placeholder="请输入幅宽"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
/>
|
||||
</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_width}>
|
||||
<Input
|
||||
type='digit'
|
||||
type="digit"
|
||||
value={filterObj.minWeight}
|
||||
onBlur={(e) => setNumber(e, 'minWeight')}
|
||||
placeholder='自定义最低值'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
alwaysEmbed={true}
|
||||
onBlur={e => setNumber(e, 'minWeight')}
|
||||
placeholder="自定义最低值"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
/>
|
||||
</View>
|
||||
<Text>—</Text>
|
||||
<View className={styles.btn_width}>
|
||||
<Input
|
||||
type='digit'
|
||||
type="digit"
|
||||
value={filterObj.maxWeight}
|
||||
onBlur={(e) => setNumber(e, 'maxWeight')}
|
||||
placeholder='自定义最高值'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
alwaysEmbed={true}
|
||||
onBlur={e => setNumber(e, 'maxWeight')}
|
||||
placeholder="自定义最高值"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
/>
|
||||
</View>
|
||||
@ -143,11 +146,11 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
<View className={styles.popup_filter_item}>
|
||||
<View className={styles.title}>成分</View>
|
||||
<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 className='common_safe_area_y'></View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View className={styles.btns_con}>
|
||||
|
||||
@ -1,117 +1,118 @@
|
||||
import { ScrollView, View } from "@tarojs/components"
|
||||
import { memo, ReactNode, useMemo, useState } from "react"
|
||||
import style from "./index.module.scss"
|
||||
import DotLoading from "@/components/dotLoading"
|
||||
import LoadingCard from "../loadingCard"
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useMemo, useState } from 'react'
|
||||
import LoadingCard from '../loadingCard'
|
||||
import style from './index.module.scss'
|
||||
import DotLoading from '@/components/dotLoading'
|
||||
|
||||
export type StatusParam = 0|1|2|3
|
||||
|
||||
type Params = {
|
||||
styleObj?: Object,
|
||||
selfonScrollToLower?: () => void,
|
||||
hasMore?: false|true,
|
||||
moreStatus?: false|true,
|
||||
statusMore?: StatusParam //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
children?: ReactNode,
|
||||
lowerThresholdNum?: number,
|
||||
selfOnScrollToUpper?:() => void
|
||||
selfOnScroll?:(val:any) => void
|
||||
selfOnRefresherPulling?: () => void
|
||||
selfOnRefresherRefresh?: () => void
|
||||
selfOnRefresherRestore?: () => void
|
||||
selfOnRefresherAbort?: () => void
|
||||
paddingBottom?: number,
|
||||
refresherTriggered?: true|false,
|
||||
refresherEnabled?: true|false,
|
||||
interface Params {
|
||||
styleObj?: Object
|
||||
selfonScrollToLower?: () => void
|
||||
hasMore?: false|true
|
||||
moreStatus?: false|true
|
||||
statusMore?: StatusParam // 0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
children?: ReactNode
|
||||
lowerThresholdNum?: number
|
||||
selfOnScrollToUpper?: () => void
|
||||
selfOnScroll?: (val: any) => void
|
||||
selfOnRefresherPulling?: () => void
|
||||
selfOnRefresherRefresh?: () => void
|
||||
selfOnRefresherRestore?: () => void
|
||||
selfOnRefresherAbort?: () => void
|
||||
paddingBottom?: number
|
||||
refresherTriggered?: true|false
|
||||
refresherEnabled?: true|false
|
||||
}
|
||||
export default memo(({
|
||||
styleObj,
|
||||
selfonScrollToLower,
|
||||
selfOnScrollToUpper,
|
||||
selfOnScroll,
|
||||
selfOnRefresherPulling,
|
||||
selfOnRefresherRefresh,
|
||||
selfOnRefresherRestore,
|
||||
selfOnRefresherAbort,
|
||||
hasMore=true,
|
||||
children,
|
||||
lowerThresholdNum = 5,
|
||||
paddingBottom = 0,
|
||||
refresherTriggered = false,
|
||||
refresherEnabled = false,
|
||||
moreStatus = true,
|
||||
statusMore = 0
|
||||
styleObj,
|
||||
selfonScrollToLower,
|
||||
selfOnScrollToUpper,
|
||||
selfOnScroll,
|
||||
selfOnRefresherPulling,
|
||||
selfOnRefresherRefresh,
|
||||
selfOnRefresherRestore,
|
||||
selfOnRefresherAbort,
|
||||
hasMore = true,
|
||||
children,
|
||||
lowerThresholdNum = 5,
|
||||
paddingBottom = 0,
|
||||
refresherTriggered = false,
|
||||
refresherEnabled = false,
|
||||
moreStatus = true,
|
||||
statusMore = 0,
|
||||
}: Params) => {
|
||||
const scrollToLower = () => {
|
||||
selfonScrollToLower?.()
|
||||
}
|
||||
const scrollToUpper = () => {
|
||||
selfOnScrollToUpper?.()
|
||||
}
|
||||
const scroll = (e) => {
|
||||
selfOnScroll?.(e)
|
||||
}
|
||||
const refresherPulling = () => {
|
||||
selfOnRefresherPulling?.()
|
||||
}
|
||||
const refresherRefresh = () => {
|
||||
selfOnRefresherRefresh?.()
|
||||
}
|
||||
const refresherRestore = () => {
|
||||
selfOnRefresherRestore?.()
|
||||
}
|
||||
const refresherAbort = () => {
|
||||
selfOnRefresherAbort?.()
|
||||
}
|
||||
const scrollToLower = () => {
|
||||
selfonScrollToLower?.()
|
||||
}
|
||||
const scrollToUpper = () => {
|
||||
selfOnScrollToUpper?.()
|
||||
}
|
||||
const scroll = (e) => {
|
||||
selfOnScroll?.(e)
|
||||
}
|
||||
const refresherPulling = () => {
|
||||
selfOnRefresherPulling?.()
|
||||
}
|
||||
const refresherRefresh = () => {
|
||||
selfOnRefresherRefresh?.()
|
||||
}
|
||||
const refresherRestore = () => {
|
||||
selfOnRefresherRestore?.()
|
||||
}
|
||||
const refresherAbort = () => {
|
||||
selfOnRefresherAbort?.()
|
||||
}
|
||||
|
||||
//返回顶部
|
||||
const scrollTop = useMemo(() => {
|
||||
if(statusMore == 0) {
|
||||
return 0.1
|
||||
}
|
||||
},[statusMore])
|
||||
// 返回顶部
|
||||
const scrollTop = useMemo(() => {
|
||||
if (statusMore == 0) {
|
||||
return 0.1
|
||||
}
|
||||
}, [statusMore])
|
||||
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
style={styleObj}
|
||||
className={style.scroll_main}
|
||||
scrollY
|
||||
onScrollToLower={() => scrollToLower()}
|
||||
onScrollToUpper={() => scrollToUpper()}
|
||||
onScroll={(e) => scroll(e)}
|
||||
lowerThreshold={lowerThresholdNum}
|
||||
refresherEnabled = {refresherEnabled}
|
||||
refresherTriggered = {refresherTriggered}
|
||||
onRefresherPulling = {() => refresherPulling()}
|
||||
onRefresherRefresh = {() => refresherRefresh()}
|
||||
onRefresherRestore = {() => refresherRestore()}
|
||||
onRefresherAbort = {() => refresherAbort()}
|
||||
refresherBackground ='#F8F8F8'
|
||||
scrollTop={scrollTop}
|
||||
>
|
||||
{!moreStatus&&<>
|
||||
<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
</>||
|
||||
<>
|
||||
{(statusMore == 2 || statusMore == 3)&&<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
||||
{children}
|
||||
<View className={style.infinite_scroll}>
|
||||
{
|
||||
(statusMore == 2)&&<View className={style.loading_more}>加载中<DotLoading/></View>||
|
||||
<View className={style.noMore}>没有更多数据了</View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
{(statusMore == 0)&&<LoadingCard/>}
|
||||
{(statusMore == 1)&&<LoadingCard loadingIcon={false} title="暂无数据"/>}
|
||||
</>}
|
||||
|
||||
<View className="common_safe_area_y"></View>
|
||||
</ScrollView>
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
style={styleObj}
|
||||
className={style.scroll_main}
|
||||
scrollY
|
||||
onScrollToLower={() => scrollToLower()}
|
||||
onScrollToUpper={() => scrollToUpper()}
|
||||
onScroll={e => scroll(e)}
|
||||
lowerThreshold={lowerThresholdNum}
|
||||
refresherEnabled={refresherEnabled}
|
||||
refresherTriggered={refresherTriggered}
|
||||
onRefresherPulling={() => refresherPulling()}
|
||||
onRefresherRefresh={() => refresherRefresh()}
|
||||
onRefresherRestore={() => refresherRestore()}
|
||||
onRefresherAbort={() => refresherAbort()}
|
||||
refresherBackground="#F8F8F8"
|
||||
scrollTop={scrollTop}
|
||||
>
|
||||
{!moreStatus && <>
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|| <>
|
||||
{(statusMore == 2 || statusMore == 3) && <View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
<View className={style.infinite_scroll}>
|
||||
{
|
||||
(statusMore == 2) && <View className={style.loading_more}>加载中<DotLoading /></View>
|
||||
|| <View className={style.noMore}>没有更多数据了</View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
{(statusMore == 0) && <LoadingCard />}
|
||||
{(statusMore == 1) && <LoadingCard loadingIcon={false} title="暂无数据" />}
|
||||
</>}
|
||||
|
||||
<View className="common_safe_area_y"></View>
|
||||
</ScrollView>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,25 +1,22 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import { memo, useMemo } from "react"
|
||||
import style from './index.module.scss'
|
||||
export default memo(({width=60, color='#6190e8'}:{width?:number, color?:string}) => {
|
||||
const styleObj = useMemo(() => {
|
||||
let obj = {}
|
||||
if(width > 0)
|
||||
obj = {width: width + 'rpx', height:width + 'rpx'}
|
||||
if(color)
|
||||
obj = {...obj, borderColor: color+' transparent transparent'}
|
||||
return obj
|
||||
|
||||
}, [width, color])
|
||||
console.log('loading:::')
|
||||
return (
|
||||
<View className={style.loading}
|
||||
style={styleObj}
|
||||
>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
</View>
|
||||
)
|
||||
|
||||
})
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo, useMemo } from 'react'
|
||||
import style from './index.module.scss'
|
||||
|
||||
export default memo(({ width = 60, color = '#6190e8' }: { width?: number; color?: string }) => {
|
||||
const styleObj = useMemo(() => {
|
||||
let obj = {}
|
||||
if (width > 0) { obj = { width: `${width}rpx`, height: `${width}rpx` } }
|
||||
if (color) { obj = { ...obj, borderColor: `${color} transparent transparent` } }
|
||||
return obj
|
||||
}, [width, color])
|
||||
console.log('loading:::')
|
||||
return (
|
||||
<View className={style.loading}
|
||||
style={styleObj}
|
||||
>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,25 +1,25 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import Loading from "@/components/loading"
|
||||
import style from "./index.module.scss"
|
||||
import { memo } from "react";
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import style from './index.module.scss'
|
||||
import Loading from '@/components/loading'
|
||||
|
||||
type Params = {
|
||||
styleLoading?: Object,
|
||||
title?: string,
|
||||
loadingIcon?: false|true
|
||||
interface Params {
|
||||
styleLoading?: Object
|
||||
title?: string
|
||||
loadingIcon?: false|true
|
||||
}
|
||||
export default memo(({
|
||||
styleLoading = {},
|
||||
title = "加载中...", //显示的文字
|
||||
loadingIcon = true //是否显示加载图标
|
||||
}:Params) => {
|
||||
console.log('loadingCard:::')
|
||||
return (
|
||||
<>
|
||||
<View className={style.loadingCard_main}>
|
||||
{loadingIcon&&<Loading/>}
|
||||
<View className={style.loading_text}>{title}</View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
styleLoading = {},
|
||||
title = '加载中...', // 显示的文字
|
||||
loadingIcon = true, // 是否显示加载图标
|
||||
}: Params) => {
|
||||
console.log('loadingCard:::')
|
||||
return (
|
||||
<>
|
||||
<View className={style.loadingCard_main}>
|
||||
{loadingIcon && <Loading />}
|
||||
<View className={style.loading_text}>{title}</View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
import { MovableArea, MovableView, View } from '@tarojs/components'
|
||||
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 styles from './index.module.scss'
|
||||
import { GetShoppingCartApi } from '@/api/shopCart'
|
||||
import useCommonData from '@/use/useCommonData'
|
||||
import { useSelector } from '@/reducers/hooks'
|
||||
|
||||
type param = {
|
||||
interface param {
|
||||
children?: ReactElement | null
|
||||
onClick?: () => void
|
||||
}
|
||||
export default ({ children = null, onClick }: param) => {
|
||||
//获取购物车数据数量
|
||||
// 获取购物车数据数量
|
||||
const { getShopCount, commonData } = useCommonData()
|
||||
|
||||
const [screenHeight, setScreenHeight] = useState(0)
|
||||
@ -21,7 +22,7 @@ export default ({ children = null, onClick }: param) => {
|
||||
useLayoutEffect(() => {
|
||||
const res = Taro.getSystemInfoSync()
|
||||
if (res.screenHeight) {
|
||||
let ratio = 750 / res.screenWidth
|
||||
const ratio = 750 / res.screenWidth
|
||||
setScreenHeight(res.screenHeight * ratio - 460)
|
||||
screenWidthRef.current = res.screenWidth / 2
|
||||
}
|
||||
@ -40,11 +41,12 @@ export default ({ children = null, onClick }: param) => {
|
||||
<MovableView
|
||||
onClick={onClick}
|
||||
className={styles.moveBtn}
|
||||
direction='all'
|
||||
inertia={true}
|
||||
x='630rpx'
|
||||
y={screenHeight + 'rpx'}
|
||||
onTouchEnd={(e) => dragEnd(e)}>
|
||||
direction="all"
|
||||
inertia
|
||||
x="630rpx"
|
||||
y={`${screenHeight}rpx`}
|
||||
onTouchEnd={e => dragEnd(e)}
|
||||
>
|
||||
<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>}
|
||||
</MovableView>
|
||||
|
||||
@ -1,202 +1,205 @@
|
||||
import { CancelOrderApi, ReceiveOrderApi } from "@/api/order"
|
||||
import { alert } from "@/common/common"
|
||||
import { ORDER_STATUS, SALE_MODE } from "@/common/enum"
|
||||
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 { ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
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 = {
|
||||
orderInfo: {
|
||||
status: number, //订单状态
|
||||
orderId: number, //订单id
|
||||
actual_amount: number, //实付金额
|
||||
wait_pay_amount: number, //待付金额
|
||||
sale_mode: number //订单类型
|
||||
}|null,
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
interface Param {
|
||||
orderInfo: {
|
||||
status: number // 订单状态
|
||||
orderId: number // 订单id
|
||||
actual_amount: number // 实付金额
|
||||
wait_pay_amount: number // 待付金额
|
||||
sale_mode: number // 订单类型
|
||||
}|null
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
export default memo(({orderInfo, onClick}:Param) => {
|
||||
//订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment
|
||||
} = ORDER_STATUS
|
||||
export default memo(({ orderInfo, onClick }: Param) => {
|
||||
// 订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment,
|
||||
} = ORDER_STATUS
|
||||
|
||||
//订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//订单按钮按订单状态归类, value是该订单状态,可能该按钮会出现
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value], //取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], //去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [SaleOrderStatusWaitingDelivery.value], //申请退款按钮对应: 待发货
|
||||
label: '申请退款'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], //申请退货按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [SaleOrderStatusWaitingReceipt.value], //确认收货按钮对应: 待收货
|
||||
label: '确认收货'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [SaleOrderStatusWaitingReceipt.value,SaleOrderStatusAlreadyReceipt.value,SaleOrderStatusComplete.value,SaleOrderStatusRefund.value], //再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
value: [SaleOrderStatusBooking.value], //按钮对应: 待接单
|
||||
label: '退款'
|
||||
},
|
||||
])
|
||||
|
||||
// 订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//判断是否显示该按钮
|
||||
const orderBtnsShow = (item) => {
|
||||
if(orderInfo) {
|
||||
if(item.id == 1) {
|
||||
//取消订单按钮
|
||||
return( orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) //在待发货之前没有付过款
|
||||
} else if (item.id == 2) {
|
||||
//去付款按钮
|
||||
return( orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) //只要没有付完款就显示
|
||||
} else if(item.id == 3 ) {
|
||||
//申请退款, 只有大货才有
|
||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //大货在待发货付过款
|
||||
} else if( item.id == 8) {
|
||||
//退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //散剪和剪板在待接单时付过款
|
||||
}
|
||||
else {
|
||||
//其他按钮
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
// 订单按钮按订单状态归类, value是该订单状态,可能该按钮会出现
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value], // 取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], // 去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [SaleOrderStatusWaitingDelivery.value], // 申请退款按钮对应: 待发货
|
||||
label: '申请退款',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], // 申请退货按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [SaleOrderStatusWaitingReceipt.value], // 确认收货按钮对应: 待收货
|
||||
label: '确认收货',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
value: [SaleOrderStatusBooking.value], // 按钮对应: 待接单
|
||||
label: '退款',
|
||||
},
|
||||
])
|
||||
|
||||
// 判断是否显示该按钮
|
||||
const orderBtnsShow = (item) => {
|
||||
if (orderInfo) {
|
||||
if (item.id == 1) {
|
||||
// 取消订单按钮
|
||||
return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款
|
||||
}
|
||||
else if (item.id == 2) {
|
||||
// 去付款按钮
|
||||
return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示
|
||||
}
|
||||
else if (item.id == 3) {
|
||||
// 申请退款, 只有大货才有
|
||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款
|
||||
}
|
||||
else if (item.id == 8) {
|
||||
// 退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款
|
||||
}
|
||||
else {
|
||||
// 其他按钮
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示的按钮数组
|
||||
const orderBtnsShowList: { id: number; value: any; label: string }[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter((item) => {
|
||||
return orderBtnsShow(item)
|
||||
})
|
||||
}, [orderInfo])
|
||||
|
||||
// 点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
(val == 1) && cancelOrder(); // 取消订单按钮
|
||||
(val == 2) && onClick?.(2); // 去付款按钮
|
||||
(val == 6) && receiveOrder() // 确认收货
|
||||
}
|
||||
|
||||
// 取消订单
|
||||
const { fetchData: cancelFetchData } = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//显示的按钮数组
|
||||
const orderBtnsShowList: {id: number, value: any, label: string}[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter(item => {
|
||||
return orderBtnsShow(item)
|
||||
})
|
||||
}, [orderInfo])
|
||||
// 确认订单
|
||||
const { fetchData: receiveOrderFetchData } = ReceiveOrderApi()
|
||||
const receiveOrder = async() => {
|
||||
console.log('123456')
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
}
|
||||
else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3) && <View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(true)}>更多</Text>
|
||||
{showMore && <View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) && <View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
</View>}
|
||||
</View>}
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
(val == 1)&&cancelOrder(); //取消订单按钮
|
||||
(val == 2)&&onClick?.(2); //去付款按钮
|
||||
(val == 6)&&receiveOrder(); //确认收货
|
||||
|
||||
}
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3) && <View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>,
|
||||
)}
|
||||
</View>
|
||||
|
||||
//取消订单
|
||||
const {fetchData: cancelFetchData} = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({id: orderInfo?.orderId})
|
||||
if(res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//确认订单
|
||||
const {fetchData: receiveOrderFetchData} = ReceiveOrderApi()
|
||||
const receiveOrder = async () => {
|
||||
console.log('123456')
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await receiveOrderFetchData({sale_order_id: orderInfo?.orderId})
|
||||
if(res.success){
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
} else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return {top:`-${(orderBtnsShowList.length - 3)*70 + 10}rpx`, left: `-${10}rpx`}
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3)&&<View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(true)}>更多</Text>
|
||||
{showMore&&<View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) &&<View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
</View>}
|
||||
</View>}
|
||||
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3)&&<View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
})
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
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 Taro from '@tarojs/taro'
|
||||
import { useRef, memo, useState, useMemo } from 'react'
|
||||
import { memo, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
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 { ApplyRefundApi } from '@/api/salesAfterOrder'
|
||||
import { UseSubscriptionMessage } from '@/use/useCommon'
|
||||
import { throttle } from '@/common/util'
|
||||
|
||||
type Param = {
|
||||
interface Param {
|
||||
orderInfo: {
|
||||
status: number //订单状态
|
||||
orderId: number //订单id
|
||||
actual_amount: number //实付金额
|
||||
wait_pay_amount: number //待付金额
|
||||
sale_mode: number //订单类型
|
||||
av_return_roll?: number //可退数量
|
||||
is_return?: true | false //是否申请了售后
|
||||
is_should_collect_audit?: true | false //应收单是否审核
|
||||
status: number // 订单状态
|
||||
orderId: number // 订单id
|
||||
actual_amount: number // 实付金额
|
||||
wait_pay_amount: number // 待付金额
|
||||
sale_mode: number // 订单类型
|
||||
av_return_roll?: number // 可退数量
|
||||
is_return?: true | false // 是否申请了售后
|
||||
is_should_collect_audit?: true | false // 应收单是否审核
|
||||
}
|
||||
showStatus?: 'detail' | 'list' //订单详情,订单列表
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
showStatus?: 'detail' | 'list' // 订单详情,订单列表
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
//订单状态枚举
|
||||
// 订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
@ -42,19 +42,19 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
SaleOrderStatusTaking,
|
||||
} = ORDER_STATUS
|
||||
|
||||
//订单类型
|
||||
// 订单类型
|
||||
const { SaLeModeBulk, SaleModeLengthCut, SaLeModeWeightCut } = SALE_MODE
|
||||
|
||||
//注册按钮, id:按钮id唯一,label:按钮名称,sort:排序数字越大越靠后,validatarFunc:验证
|
||||
type orderBtnsListParams = { id: number; label: string; sort: number; validatarFunc: (val: typeof orderInfo) => any }
|
||||
// 注册按钮, id:按钮id唯一,label:按钮名称,sort:排序数字越大越靠后,validatarFunc:验证
|
||||
interface orderBtnsListParams { id: number; label: string; sort: number; validatarFunc: (val: typeof orderInfo) => any }
|
||||
const orderBtnsList = useRef<orderBtnsListParams[]>([
|
||||
{
|
||||
id: 1,
|
||||
label: '取消订单',
|
||||
sort: 1,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//在待发货之前没有付过款
|
||||
let orderStatus = [
|
||||
// 在待发货之前没有付过款
|
||||
const orderStatus = [
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
@ -71,8 +71,8 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '去付款',
|
||||
sort: 100,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//只要没有付完款就显示
|
||||
let orderStatus = [
|
||||
// 只要没有付完款就显示
|
||||
const orderStatus = [
|
||||
SaleOrderStatusTaking.value,
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
@ -89,8 +89,8 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '申请退款',
|
||||
sort: 5,
|
||||
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)
|
||||
},
|
||||
},
|
||||
@ -99,7 +99,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '申请退货',
|
||||
sort: 5,
|
||||
validatarFunc: (orderInfo) => {
|
||||
let orderStatus = [SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value]
|
||||
const orderStatus = [SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value]
|
||||
return orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
||||
},
|
||||
},
|
||||
@ -108,7 +108,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '确认收货',
|
||||
sort: 10,
|
||||
validatarFunc: (orderInfo) => {
|
||||
let orderStatus = [SaleOrderStatusWaitingReceipt.value]
|
||||
const orderStatus = [SaleOrderStatusWaitingReceipt.value]
|
||||
return orderStatus.includes(orderInfo.status)
|
||||
},
|
||||
},
|
||||
@ -125,8 +125,8 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '退款',
|
||||
sort: 5,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//散剪和剪板在待接单时付过款
|
||||
let orderStatus = [SaleOrderStatusBooking.value]
|
||||
// 散剪和剪板在待接单时付过款
|
||||
const orderStatus = [SaleOrderStatusBooking.value]
|
||||
return orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount > 0 && orderStatus.includes(orderInfo.status)
|
||||
},
|
||||
},
|
||||
@ -143,132 +143,144 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '销售码单',
|
||||
sort: 9,
|
||||
validatarFunc: (orderInfo) => {
|
||||
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 true }
|
||||
if (orderInfo.sale_mode !== 1 && showStatus == 'detail') { return orderInfo.is_should_collect_audit }
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
//显示的按钮数组
|
||||
// 显示的按钮数组
|
||||
const orderBtnsShowList: orderBtnsListParams[] = useMemo(() => {
|
||||
let list = orderBtnsList.current.filter((item) => {
|
||||
const list = orderBtnsList.current.filter((item) => {
|
||||
return item.validatarFunc(orderInfo)
|
||||
})
|
||||
return list.sort((a, b) => a.sort - b.sort)
|
||||
}, [orderInfo])
|
||||
|
||||
//小程序订阅
|
||||
// 小程序订阅
|
||||
const { ApplyGoods } = SUBSCRIPTION_MESSAGE_SCENE
|
||||
const { openSubscriptionMessage } = UseSubscriptionMessage()
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = throttle(async (val, index) => {
|
||||
// 点击按钮操作
|
||||
const submitBtns = throttle(async(val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder()
|
||||
} else if (val == 6) {
|
||||
}
|
||||
else if (val == 6) {
|
||||
receiveOrder()
|
||||
} else if (val == 5) {
|
||||
}
|
||||
else if (val == 5) {
|
||||
applyProduct()
|
||||
} else if (val == 3) {
|
||||
}
|
||||
else if (val == 3) {
|
||||
bigApplyRefurn()
|
||||
} else if (val == 8) {
|
||||
}
|
||||
else if (val == 8) {
|
||||
applyRefund()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 800)
|
||||
|
||||
//大货申请退款
|
||||
// 大货申请退款
|
||||
const bigApplyRefurn = () => {
|
||||
Taro.showModal({
|
||||
title: '要申请退款吗?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
onClick?.(3)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//取消订单
|
||||
// 取消订单
|
||||
const { fetchData: cancelFetchData } = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//确认订单
|
||||
// 确认订单
|
||||
const { fetchData: receiveOrderFetchData } = ReceiveOrderApi()
|
||||
const receiveOrder = async () => {
|
||||
const receiveOrder = async() => {
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
alert.showLoading('收货中', true)
|
||||
let res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//退款
|
||||
// 退款
|
||||
const { fetchData: fetchDataApplyRefund } = ApplyRefundApi()
|
||||
const applyRefund = async () => {
|
||||
const applyRefund = async() => {
|
||||
Taro.showModal({
|
||||
title: '确定退款?',
|
||||
success: async function async(res) {
|
||||
if (res.confirm) {
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
alert.showLoading('申请中', true)
|
||||
let res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
|
||||
const res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('申请成功')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('申请失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
onClick?.(8)
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//申请退货
|
||||
const applyProduct = async () => {
|
||||
if (!orderInfo?.av_return_roll) return alert.none('该订单没有可退条数')
|
||||
// 申请退货
|
||||
const applyProduct = async() => {
|
||||
if (!orderInfo?.av_return_roll) { return alert.none('该订单没有可退条数') }
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
goLink('/pages/applyAfterSales/index', { id: orderInfo?.orderId })
|
||||
}
|
||||
|
||||
//显示更多按钮
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
|
||||
@ -1,74 +1,75 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import style from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import { memo, ReactNode, useEffect, useMemo, useRef } from "react";
|
||||
import CloseBtnIcon from "@/components/closeBtn"
|
||||
import { View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useEffect, useMemo, useRef } from 'react'
|
||||
import style from './index.module.scss'
|
||||
import CloseBtnIcon from '@/components/closeBtn'
|
||||
|
||||
export interface Params {
|
||||
title?: string, //标题
|
||||
show?: false|true, //显示显示弹窗
|
||||
showTitle?: false|true, //是否显示标题
|
||||
onClose?:() => void, //关闭事件
|
||||
children?: ReactNode, //插槽内容
|
||||
// IconButton?: ReactNode, //
|
||||
showIconButton?: false|true, //是否显示关闭按钮
|
||||
position?: 'bottom'|'top'|'right', //弹出位置
|
||||
animationEnd?: () => void //弹出动画结束
|
||||
title?: string // 标题
|
||||
show?: false|true // 显示显示弹窗
|
||||
showTitle?: false|true // 是否显示标题
|
||||
onClose?: () => void // 关闭事件
|
||||
children?: ReactNode // 插槽内容
|
||||
// IconButton?: ReactNode, //
|
||||
showIconButton?: false|true // 是否显示关闭按钮
|
||||
position?: 'bottom'|'top'|'right' // 弹出位置
|
||||
animationEnd?: () => void // 弹出动画结束
|
||||
}
|
||||
export default memo((
|
||||
{
|
||||
title = '标题',
|
||||
show = false,
|
||||
showTitle = true,
|
||||
onClose,
|
||||
showIconButton = false,
|
||||
children,
|
||||
position = 'bottom',
|
||||
animationEnd
|
||||
}:Params) => {
|
||||
|
||||
const animationTime = useRef<any>(null)
|
||||
useEffect(() => {
|
||||
if(show) {
|
||||
animationTime.current = setTimeout(() => {
|
||||
animationEnd?.()
|
||||
}, 260)
|
||||
} else {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
}, [show])
|
||||
{
|
||||
title = '标题',
|
||||
show = false,
|
||||
showTitle = true,
|
||||
onClose,
|
||||
showIconButton = false,
|
||||
children,
|
||||
position = 'bottom',
|
||||
animationEnd,
|
||||
}: Params) => {
|
||||
const animationTime = useRef<any>(null)
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
animationTime.current = setTimeout(() => {
|
||||
animationEnd?.()
|
||||
}, 260)
|
||||
}
|
||||
else {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
}, [show])
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={style.drawer_main}>
|
||||
<View catchMove={true} className={`${style.drawer} ${show?style.drawer_active:''}` }>
|
||||
<View
|
||||
className={classnames(style.drawer_mask, {[style.drawer_mask_active]: show})}
|
||||
onClick={() => onClose?.()}
|
||||
>
|
||||
<View
|
||||
className={classnames(style.drawer_container, style['drawer_container_'+position], {[style.drawer_container_active]: show})}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{showTitle&&<View className={style.drawer_container_title}>{title}</View>}
|
||||
{showIconButton&&<View className={style.common_close_btn_icon}>
|
||||
<CloseBtnIcon onClose={() => onClose?.()}/>
|
||||
</View>}
|
||||
|
||||
<View className={style.drawer_container_context}>
|
||||
{show&&children}
|
||||
</View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={style.drawer_main}>
|
||||
<View catchMove className={`${style.drawer} ${show ? style.drawer_active : ''}`}>
|
||||
<View
|
||||
className={classnames(style.drawer_mask, { [style.drawer_mask_active]: show })}
|
||||
onClick={() => onClose?.()}
|
||||
>
|
||||
<View
|
||||
className={classnames(style.drawer_container, style[`drawer_container_${position}`], { [style.drawer_container_active]: show })}
|
||||
onClick={e => e.stopPropagation()}
|
||||
>
|
||||
{showTitle && <View className={style.drawer_container_title}>{title}</View>}
|
||||
{showIconButton && <View className={style.common_close_btn_icon}>
|
||||
<CloseBtnIcon onClose={() => onClose?.()} />
|
||||
</View>}
|
||||
|
||||
<View className={style.drawer_container_context}>
|
||||
{show && children}
|
||||
</View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { Image, View } from '@tarojs/components'
|
||||
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 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
|
||||
productList?: any[]
|
||||
}
|
||||
@ -35,7 +35,7 @@ export default ({ desStatus = true, productList = [] }: Params) => {
|
||||
<View className={styles.tag}>{item.width}</View>
|
||||
<View className={styles.tag_g}>{item.weight_density}</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>}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
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 CloseBtn from '@/components/closeBtn'
|
||||
import classnames from 'classnames'
|
||||
import { debounce } from '@/common/util'
|
||||
import { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
||||
|
||||
type Params = {
|
||||
interface Params {
|
||||
clickOnSearch?: (val: string) => void
|
||||
disabled?: false | true
|
||||
placeholder?: string
|
||||
@ -16,7 +16,7 @@ type Params = {
|
||||
showBtn?: false | true
|
||||
btnStyle?: Object
|
||||
btnTitle?: string
|
||||
debounceTime?: number //防抖时间,不设默认为零
|
||||
debounceTime?: number // 防抖时间,不设默认为零
|
||||
defaultValue?: string
|
||||
borderRadius?: string
|
||||
}
|
||||
@ -25,17 +25,17 @@ export default memo(
|
||||
forwardRef(
|
||||
(
|
||||
{
|
||||
clickOnSearch, //点击筛选按钮触发
|
||||
changeOnSearch, //输入文字触发
|
||||
disabled = false, //是否禁用
|
||||
clickOnSearch, // 点击筛选按钮触发
|
||||
changeOnSearch, // 输入文字触发
|
||||
disabled = false, // 是否禁用
|
||||
placeholder = '输入搜索内容',
|
||||
showIcon = true, //是否显示关闭图标
|
||||
showBtn = false, //是否显示搜索按钮
|
||||
showIcon = true, // 是否显示关闭图标
|
||||
showBtn = false, // 是否显示搜索按钮
|
||||
btnStyle = {},
|
||||
placeIcon = 'inner', //搜索图标位置:inner在里面,out在外面
|
||||
btnTitle = '搜索', //搜索文字
|
||||
debounceTime = 0, //防抖时间,不设默认为零
|
||||
defaultValue = '', //默认值
|
||||
placeIcon = 'inner', // 搜索图标位置:inner在里面,out在外面
|
||||
btnTitle = '搜索', // 搜索文字
|
||||
debounceTime = 0, // 防抖时间,不设默认为零
|
||||
defaultValue = '', // 默认值
|
||||
borderRadius = '50rpx',
|
||||
}: Params,
|
||||
ref,
|
||||
@ -84,19 +84,21 @@ export default memo(
|
||||
'icon-sousuo',
|
||||
styles.icon_a_sousuo1_self,
|
||||
placeIcon == 'inner' ? styles.icon_inner : styles.icon_out,
|
||||
)}></View>
|
||||
)}
|
||||
></View>
|
||||
)}
|
||||
<Input
|
||||
style={{ borderRadius }}
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
placeholderStyle='color:#ABABAB; font-size:26rpx'
|
||||
placeholderStyle="color:#ABABAB; font-size:26rpx"
|
||||
onConfirm={onSearch}
|
||||
className={classnames(placeIcon == 'out' && styles.input_out)}
|
||||
disabled={disabled}
|
||||
value={inputCon}
|
||||
placeholder={placeholder}
|
||||
onInput={(e) => onInputEven(e)}></Input>
|
||||
onInput={e => onInputEven(e)}
|
||||
></Input>
|
||||
{!!inputCon && (
|
||||
<View className={styles.search_closeBtn}>
|
||||
<CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
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'
|
||||
|
||||
type Params = {
|
||||
interface Params {
|
||||
showIcon?: false | true
|
||||
disabled?: false | true
|
||||
placeholder?: string
|
||||
@ -18,7 +19,7 @@ type Params = {
|
||||
}
|
||||
|
||||
export default memo((props: Params) => {
|
||||
let {
|
||||
const {
|
||||
showTitle = true,
|
||||
title = '标题',
|
||||
showIcon = false,
|
||||
@ -31,14 +32,14 @@ export default memo((props: Params) => {
|
||||
titleStyle = {},
|
||||
} = props
|
||||
|
||||
let stylen = useMemo(() => {
|
||||
const stylen = useMemo(() => {
|
||||
if (!showBorder) {
|
||||
return { borderBottom: 0 }
|
||||
}
|
||||
return {}
|
||||
}, [showBorder])
|
||||
return (
|
||||
<View className={styles.searchInput_main} style={{ height: height, ...stylen }}>
|
||||
<View className={styles.searchInput_main} style={{ height, ...stylen }}>
|
||||
{showTitle && (
|
||||
<View className={styles.searchInput_title} style={titleStyle}>
|
||||
{title}
|
||||
@ -47,12 +48,12 @@ export default memo((props: Params) => {
|
||||
<View className={styles.searchInput_con}>
|
||||
{(!props.children && (
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
onClick={() => clickOnInput?.()}
|
||||
onInput={(e) => changeOnInput?.(e.detail.value)}
|
||||
onInput={e => changeOnInput?.(e.detail.value)}
|
||||
/>
|
||||
)) || <>{props.children}</>}
|
||||
</View>
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
import { CustomWrapper, View } from '@tarojs/components'
|
||||
import { memo, useCallback, useMemo } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import Big from 'big.js'
|
||||
import styles from './index.module.scss'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import Counter from '@/components/counter'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import Big from 'big.js'
|
||||
import { saleModeType } from '@/common/enum'
|
||||
type param = {
|
||||
import type { saleModeType } from '@/common/enum'
|
||||
|
||||
interface param {
|
||||
sale_model: saleModeType
|
||||
onChangeSelect: (val: any) => any
|
||||
onChangeCount: (val: any) => any
|
||||
@ -16,7 +17,7 @@ type param = {
|
||||
}
|
||||
|
||||
export default memo((props: param) => {
|
||||
let { onChangeCount, onChangeSelect, item, sale_model } = props
|
||||
const { onChangeCount, onChangeSelect, item, sale_model } = props
|
||||
|
||||
const selectCallBack = useCallback(() => {
|
||||
onChangeSelect({ ...item, selected: true })
|
||||
@ -27,8 +28,8 @@ export default memo((props: param) => {
|
||||
const getLabAndImg = useCallback(() => {}, [])
|
||||
const getInputValue = useCallback(
|
||||
(e) => {
|
||||
let roll = item.sale_mode == 0 ? parseFloat(e) : 0
|
||||
let length = item.sale_mode != 0 ? parseFloat(new Big(parseFloat(e)).times(100)) : 0
|
||||
const roll = item.sale_mode == 0 ? parseFloat(e) : 0
|
||||
const length = item.sale_mode != 0 ? parseFloat(new Big(parseFloat(e)).times(100)) : 0
|
||||
onChangeCount({ ...item, roll, length })
|
||||
},
|
||||
[item],
|
||||
@ -38,20 +39,20 @@ export default memo((props: param) => {
|
||||
}, [item])
|
||||
|
||||
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])
|
||||
|
||||
console.log('刷新2::', item)
|
||||
|
||||
//格式化金额
|
||||
// 格式化金额
|
||||
const formatPirce = useCallback((price) => {
|
||||
return Number(formatPriceDiv(price))
|
||||
}, [])
|
||||
//格式化数量
|
||||
// 格式化数量
|
||||
const formatCount = useCallback((item) => {
|
||||
return item.sale_mode == 0 ? item.roll : item.length / 100
|
||||
}, [])
|
||||
//格式化单位
|
||||
// 格式化单位
|
||||
const formatUnit = useCallback((item) => {
|
||||
return item.sale_mode == 0 ? '条' : '米'
|
||||
}, [])
|
||||
@ -78,7 +79,7 @@ export default memo((props: param) => {
|
||||
</View>
|
||||
<View className={styles.count}>
|
||||
<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>
|
||||
<View className={styles.btn_count}>
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
import { Image, ScrollView, View } from '@tarojs/components'
|
||||
import Popup from '@/components/popup'
|
||||
import classnames from 'classnames'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import styles from './index.module.scss'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { GetShoppingCartApi, DelShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import { setParam } from '@/common/system'
|
||||
import { debounce, throttle } from '@/common/util'
|
||||
import classnames from 'classnames'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Counter from '../counter'
|
||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
||||
import useCommonData from '@/use/useCommonData'
|
||||
import BindSalesmanPopup from '../bindSalesmanPopup'
|
||||
import LabAndImgShow from '../LabAndImgShow'
|
||||
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
|
||||
onClose?: () => void
|
||||
intoStatus?: 'again' | 'shop'
|
||||
default_sale_mode?: number //面料类型(0:大货, 1:剪版,2:散剪
|
||||
default_sale_mode?: number // 面料类型(0:大货, 1:剪版,2:散剪
|
||||
}
|
||||
export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
|
||||
const selectList = [
|
||||
@ -32,7 +32,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
{ value: 2, title: '散剪', unit: '米', eunit: 'kg', step: 1, digits: 2, minNum: 3, maxNum: 100000, defaultNum: 3 },
|
||||
]
|
||||
|
||||
//切换面料类型
|
||||
// 切换面料类型
|
||||
const [selectIndex, setSelectIndex] = useState(default_sale_mode || 0)
|
||||
const selectProduct = (index: number) => {
|
||||
setSelectIndex(index)
|
||||
@ -48,53 +48,55 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
|
||||
const MCheckboxRef = useRef(null)
|
||||
|
||||
//获取购物车数据数量
|
||||
// 获取购物车数据数量
|
||||
const { setShopCount } = useCommonData()
|
||||
|
||||
//重置勾选数据
|
||||
// 重置勾选数据
|
||||
const resetList = () => {
|
||||
list?.map((item) => {
|
||||
if (selectIndex == item.sale_mode || selectIndex == -1) {
|
||||
checkboxData[item.id] = true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
checkboxData[item.id] = false
|
||||
}
|
||||
})
|
||||
setCheckboxData(() => ({ ...checkboxData }))
|
||||
}
|
||||
|
||||
//获取数据
|
||||
// 获取数据
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { fetchData } = GetShoppingCartApi()
|
||||
const getShoppingCart = async () => {
|
||||
const getShoppingCart = async() => {
|
||||
const { data } = await fetchData()
|
||||
let color_list = data.color_list || []
|
||||
const color_list = data.color_list || []
|
||||
setShopCount(color_list.length)
|
||||
initList(color_list)
|
||||
setList(color_list)
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
//初始化全部数据默认勾选
|
||||
const [checkboxData, setCheckboxData] = useState<{ [index: number]: true | false }>({})
|
||||
// 初始化全部数据默认勾选
|
||||
const [checkboxData, setCheckboxData] = useState<Record<number, true | false>>({})
|
||||
const initStatus = useRef(false)
|
||||
const initList = (color_list) => {
|
||||
if (initStatus.current) {
|
||||
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
|
||||
}
|
||||
setCheckboxData(() => checkboxData)
|
||||
}
|
||||
|
||||
//显示是展示数据
|
||||
// 显示是展示数据
|
||||
useEffect(() => {
|
||||
if (!show) {
|
||||
setList([])
|
||||
setSelectIndex(default_sale_mode || 0)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setLoading(true)
|
||||
initStatus.current = true
|
||||
getShoppingCart()
|
||||
@ -113,57 +115,57 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
setShowPopup(show)
|
||||
}, [show])
|
||||
|
||||
//全选反选
|
||||
// 全选反选
|
||||
const [selectStatus, setSelectStatus] = useState(false)
|
||||
const selectAll = () => {
|
||||
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)
|
||||
setCheckboxData(() => ({ ...checkboxData }))
|
||||
}
|
||||
|
||||
//checkbox选中回调
|
||||
// checkbox选中回调
|
||||
const selectCallBack = useCallback((item) => {
|
||||
checkboxData[item.id] = true
|
||||
checkSelect()
|
||||
setCheckboxData((e) => ({ ...e, ...checkboxData }))
|
||||
setCheckboxData(e => ({ ...e, ...checkboxData }))
|
||||
}, [])
|
||||
|
||||
//checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||
// checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||
const checkSelect = () => {
|
||||
let list_count = 0
|
||||
let select_count = 0
|
||||
list?.map((item) => {
|
||||
if (selectIndex == -1 || selectIndex == item.sale_mode) {
|
||||
list_count++
|
||||
if (checkboxData[item.id]) select_count++
|
||||
if (checkboxData[item.id]) { select_count++ }
|
||||
}
|
||||
})
|
||||
setSelectStatus(select_count == list_count)
|
||||
}
|
||||
|
||||
//checkbox关闭回调
|
||||
// checkbox关闭回调
|
||||
const colseCallBack = useCallback((item) => {
|
||||
checkboxData[item.id] = false
|
||||
checkSelect()
|
||||
setCheckboxData((e) => ({ ...e, ...checkboxData }))
|
||||
setCheckboxData(e => ({ ...e, ...checkboxData }))
|
||||
}, [])
|
||||
|
||||
//popup关闭
|
||||
// popup关闭
|
||||
const closePopup = () => {
|
||||
onClose?.()
|
||||
setShowPopup(false)
|
||||
}
|
||||
|
||||
//删除购物车内容
|
||||
// 删除购物车内容
|
||||
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
||||
const delSelect = () => {
|
||||
getSelectId()
|
||||
if (selectIds.current.length <= 0) return alert.none('请选择要删除的面料!')
|
||||
if (selectIds.current.length <= 0) { return alert.none('请选择要删除的面料!') }
|
||||
Taro.showModal({
|
||||
content: '删除所选商品?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await delShopFetchData({ id: selectIds.current })
|
||||
if (res.success) {
|
||||
@ -172,20 +174,22 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
title: '成功',
|
||||
icon: 'success',
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//获取面料选中的id
|
||||
// 获取面料选中的id
|
||||
const selectIds = useRef<number[]>([])
|
||||
const getSelectId = () => {
|
||||
selectIds.current = []
|
||||
@ -196,27 +200,27 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
}
|
||||
|
||||
//格式化金额
|
||||
// 格式化金额
|
||||
const formatPirce = useCallback((price) => {
|
||||
return Number(formatPriceDiv(price))
|
||||
}, [])
|
||||
|
||||
//格式化数量
|
||||
// 格式化数量
|
||||
const formatCount = useCallback((item) => {
|
||||
return item.sale_mode == 0 ? item.roll : item.length / 100
|
||||
}, [])
|
||||
|
||||
//格式化单位
|
||||
// 格式化单位
|
||||
const formatUnit = useCallback((item) => {
|
||||
return item.sale_mode == 0 ? '条' : '米'
|
||||
}, [])
|
||||
|
||||
//预估金额和总条数
|
||||
// 预估金额和总条数
|
||||
const estimatePrice = useMemo(() => {
|
||||
let estimate_amount = 0
|
||||
let product_list = new Set() //面料
|
||||
let color_count = 0 //颜色数量
|
||||
let all_count = 0 //总数量
|
||||
const product_list = new Set() // 面料
|
||||
let color_count = 0 // 颜色数量
|
||||
let all_count = 0 // 总数量
|
||||
list.map((item) => {
|
||||
if (checkboxData[item.id]) {
|
||||
estimate_amount += item.estimate_amount
|
||||
@ -225,7 +229,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
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 {
|
||||
price: Number(formatPriceDiv(estimate_amount)).toFixed(2),
|
||||
countText: `已选 ${product_list.size} 种面料,${color_count} 个颜色,共 ${all_count_text}`,
|
||||
@ -233,13 +237,13 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
}
|
||||
}, [list, checkboxData])
|
||||
|
||||
//去结算
|
||||
// 去结算
|
||||
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
||||
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
||||
const orderDetail = throttle(async () => {
|
||||
let res = await useFetchData()
|
||||
const orderDetail = throttle(async() => {
|
||||
const res = await useFetchData()
|
||||
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)
|
||||
onClose?.()
|
||||
return false
|
||||
@ -247,36 +251,38 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
getSelectId()
|
||||
if (selectIds.current.length == 0) {
|
||||
alert.error('请选择面料')
|
||||
} else {
|
||||
let ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) //临时存储
|
||||
}
|
||||
else {
|
||||
const ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
||||
closePopup()
|
||||
if (intoStatus == 'again') {
|
||||
goLink('/pages/order/comfirm', {}, 'redirectTo')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
goLink('/pages/order/comfirm')
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
|
||||
//计数组件-当后端修改完成才修改前端显示
|
||||
// 计数组件-当后端修改完成才修改前端显示
|
||||
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
||||
const [UpdateShoppingCartLoading, setUpdateShoppingCartLoading] = useState(false)
|
||||
const getInputValue = debounce(async (num, item) => {
|
||||
let roll = item.sale_mode == 0 ? parseFloat(num) : 0
|
||||
let length = item.sale_mode != 0 ? parseFloat(num) * 100 : 0
|
||||
const getInputValue = debounce(async(num, item) => {
|
||||
const roll = item.sale_mode == 0 ? parseFloat(num) : 0
|
||||
const length = item.sale_mode != 0 ? parseFloat(num) * 100 : 0
|
||||
setUpdateShoppingCartLoading(() => true)
|
||||
let res = await fetchDataUpdateShoppingCart({ id: item.id, roll, length })
|
||||
const res = await fetchDataUpdateShoppingCart({ id: item.id, roll, length })
|
||||
setUpdateShoppingCartLoading(() => false)
|
||||
if (res.success) {
|
||||
getShoppingCart()
|
||||
}
|
||||
}, 300)
|
||||
|
||||
//绑定业务员和电话号码
|
||||
// 绑定业务员和电话号码
|
||||
const [showBindSalesman, setShowBindSalesman] = useState(false)
|
||||
|
||||
//显示图片弹窗
|
||||
// 显示图片弹窗
|
||||
const [showLabImage, setShowLabImage] = useState(false)
|
||||
const [labImageValue, setLabImageValue] = useState()
|
||||
const getLabAndImg = useCallback((val) => {
|
||||
@ -305,7 +311,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
<View
|
||||
key={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}
|
||||
</View>
|
||||
)
|
||||
@ -320,7 +327,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
return (
|
||||
<View
|
||||
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}>
|
||||
<MCheckbox
|
||||
disabled={selectIndex != -1 && selectIndex != item.sale_mode}
|
||||
@ -347,16 +355,16 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
</View>
|
||||
<View className={styles.count}>
|
||||
<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>
|
||||
<View className={styles.btn_count}>
|
||||
<Counter
|
||||
onBlue={(e) => getInputValue(e, item)}
|
||||
onBlue={e => getInputValue(e, item)}
|
||||
defaultNum={formatCount(item)}
|
||||
step={selectList[selectIndex].step}
|
||||
digits={selectList[selectIndex].digits}
|
||||
onClickBtn={(e) => getInputValue(e, item)}
|
||||
onClickBtn={e => getInputValue(e, item)}
|
||||
unit={formatUnit(item)}
|
||||
minNum={selectList[selectIndex].minNum}
|
||||
maxNum={selectList[selectIndex].maxNum}
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
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 { alert, goLink } from '@/common/common'
|
||||
import { GetShoppingCartApi, DelShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import { setParam } from '@/common/system'
|
||||
import { debounce, throttle } from '@/common/util'
|
||||
import classnames from 'classnames'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||
import Counter from '../counter'
|
||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
||||
import useCommonData from '@/use/useCommonData'
|
||||
import BindSalesmanPopup from '../bindSalesmanPopup'
|
||||
import LabAndImgShow from '../LabAndImgShow'
|
||||
import LabAndImg from '../LabAndImg'
|
||||
import styles from './index.module.scss'
|
||||
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
|
||||
onClose?: () => void
|
||||
intoStatus?: 'again' | 'shop'
|
||||
default_sale_mode?: saleModeType //面料类型(0:大货, 1:剪版,2:散剪
|
||||
default_sale_mode?: saleModeType // 面料类型(0:大货, 1:剪版,2:散剪
|
||||
}
|
||||
type modelClassType = {
|
||||
interface modelClassType {
|
||||
value: saleModeType
|
||||
title: string
|
||||
unit: string
|
||||
@ -47,7 +47,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
|
||||
const [isPending, startTransition] = useTransition()
|
||||
|
||||
//切换面料类型
|
||||
// 切换面料类型
|
||||
const [selectIndex, setSelectIndex] = useState<saleModeType>(default_sale_mode || 0)
|
||||
const selectProduct = (index: 0 | 1 | 2) => {
|
||||
setSelectIndex(index)
|
||||
@ -65,26 +65,26 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
}, [selectIndex])
|
||||
|
||||
//获取购物车数据数量
|
||||
// 获取购物车数据数量
|
||||
const { getShopCount } = useCommonData()
|
||||
|
||||
//获取所有数据数据
|
||||
const [list, setList] = useState<{ [id: number]: any }>({})
|
||||
// 获取所有数据数据
|
||||
const [list, setList] = useState<Record<number, any>>({})
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { fetchData: getShoppingFetchData } = GetShoppingCartApi()
|
||||
const getShoppingCart = async () => {
|
||||
const getShoppingCart = async() => {
|
||||
const { data } = await getShoppingFetchData()
|
||||
let color_list = data.color_list || []
|
||||
const color_list = data.color_list || []
|
||||
initList(color_list)
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
//更新单条数据
|
||||
const getShoppingCartInfo = async (item) => {
|
||||
// 更新单条数据
|
||||
const getShoppingCartInfo = async(item) => {
|
||||
const res = await getShoppingFetchData({ id: item.id })
|
||||
if (res.success) {
|
||||
let info = res.data.color_list[0]
|
||||
let newInfo = {
|
||||
const info = res.data.color_list[0]
|
||||
const newInfo = {
|
||||
...item,
|
||||
estimate_amount: info.estimate_amount,
|
||||
estimate_weight: info.estimate_weight,
|
||||
@ -95,7 +95,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
sale_price: info.sale_price,
|
||||
standard_price: info.standard_price,
|
||||
}
|
||||
setList((e) => ({ ...e, [item['id']]: newInfo }))
|
||||
setList(e => ({ ...e, [item.id]: newInfo }))
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,9 +103,9 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
return Object.values(list)
|
||||
}, [list])
|
||||
|
||||
//初始化全部数据默认勾选
|
||||
// 初始化全部数据默认勾选
|
||||
const initList = (color_list) => {
|
||||
let obj = {}
|
||||
const obj = {}
|
||||
color_list?.map((item) => {
|
||||
item.selected = selectIndex == item.sale_mode
|
||||
const { unit, eunit, step, digits, minNum, maxNum } = selectList[item.sale_mode]
|
||||
@ -115,25 +115,27 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
setList(() => ({ ...obj }))
|
||||
}
|
||||
|
||||
//重置勾选数据
|
||||
// 重置勾选数据
|
||||
const resetList = () => {
|
||||
Object.values(list)?.map((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
item.selected = true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
item.selected = false
|
||||
}
|
||||
list[item['id']] = { ...item }
|
||||
list[item.id] = { ...item }
|
||||
})
|
||||
setList(() => ({ ...list }))
|
||||
}
|
||||
|
||||
//显示时展示数据
|
||||
// 显示时展示数据
|
||||
useEffect(() => {
|
||||
if (!show) {
|
||||
setList({})
|
||||
setSelectIndex(default_sale_mode || 0)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setLoading(true)
|
||||
getShoppingCart()
|
||||
setShowBindSalesman(() => false)
|
||||
@ -145,56 +147,56 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
setShowPopup(show)
|
||||
}, [show])
|
||||
|
||||
//全选反选
|
||||
// 全选反选
|
||||
const [selectStatus, setSelectStatus] = useState(false)
|
||||
const selectAll = () => {
|
||||
Object.values(list)?.map((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
item.selected = !selectStatus
|
||||
list[item['id']] = { ...item }
|
||||
list[item.id] = { ...item }
|
||||
}
|
||||
})
|
||||
setList(() => ({ ...list }))
|
||||
setSelectStatus(!selectStatus)
|
||||
}
|
||||
|
||||
//checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||
// checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||
useEffect(() => {
|
||||
let list_count = 0
|
||||
let select_count = 0
|
||||
Object.values(list)?.map((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
list_count++
|
||||
if (item.selected) select_count++
|
||||
if (item.selected) { select_count++ }
|
||||
}
|
||||
})
|
||||
setSelectStatus(select_count == list_count)
|
||||
}, [list])
|
||||
|
||||
//修改数量
|
||||
// 修改数量
|
||||
const onChangeCount = useCallback((item) => {
|
||||
getInputValue(item)
|
||||
}, [])
|
||||
|
||||
//修改选择
|
||||
// 修改选择
|
||||
const onChangeSelect = useCallback((item) => {
|
||||
setList((e) => ({ ...e, [item.id]: { ...item } }))
|
||||
setList(e => ({ ...e, [item.id]: { ...item } }))
|
||||
}, [])
|
||||
|
||||
//popup关闭
|
||||
// popup关闭
|
||||
const closePopup = () => {
|
||||
onClose?.()
|
||||
setShowPopup(false)
|
||||
}
|
||||
|
||||
//删除购物车内容
|
||||
// 删除购物车内容
|
||||
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
||||
const delSelect = () => {
|
||||
getSelectId()
|
||||
if (selectIds.current.length <= 0) return alert.none('请选择要删除的面料!')
|
||||
if (selectIds.current.length <= 0) { return alert.none('请选择要删除的面料!') }
|
||||
Taro.showModal({
|
||||
content: '删除所选商品?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await delShopFetchData({ id: selectIds.current })
|
||||
if (res.success) {
|
||||
@ -204,20 +206,22 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
title: '成功',
|
||||
icon: 'success',
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//获取面料选中的id
|
||||
// 获取面料选中的id
|
||||
const selectIds = useRef<number[]>([])
|
||||
const getSelectId = () => {
|
||||
selectIds.current = []
|
||||
@ -228,12 +232,12 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
}
|
||||
|
||||
//预估金额和总条数
|
||||
// 预估金额和总条数
|
||||
const estimatePrice = useMemo(() => {
|
||||
let estimate_amount = 0
|
||||
let product_list = new Set() //面料
|
||||
let color_count = 0 //颜色数量
|
||||
let all_count = 0 //总数量
|
||||
const product_list = new Set() // 面料
|
||||
let color_count = 0 // 颜色数量
|
||||
let all_count = 0 // 总数量
|
||||
Object.values(list)?.map((item) => {
|
||||
if (item.selected) {
|
||||
estimate_amount += item.estimate_amount
|
||||
@ -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)
|
||||
}
|
||||
})
|
||||
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)
|
||||
return {
|
||||
price: Number(formatPriceDiv(estimate_amount)).toFixed(2),
|
||||
@ -251,13 +255,13 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
}
|
||||
}, [list])
|
||||
|
||||
//去结算
|
||||
// 去结算
|
||||
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
||||
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
||||
const orderDetail = throttle(async () => {
|
||||
let res = await useFetchData()
|
||||
const orderDetail = throttle(async() => {
|
||||
const res = await useFetchData()
|
||||
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)
|
||||
onClose?.()
|
||||
return false
|
||||
@ -265,34 +269,37 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
getSelectId()
|
||||
if (selectIds.current.length == 0) {
|
||||
alert.error('请选择面料')
|
||||
} else {
|
||||
let ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) //临时存储
|
||||
}
|
||||
else {
|
||||
const ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
||||
closePopup()
|
||||
if (intoStatus == 'again') {
|
||||
goLink('/pages/order/comfirm', null, 'redirectTo')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
goLink('/pages/order/comfirm')
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
|
||||
//计数组件-当后端修改完成才修改前端显示
|
||||
// 计数组件-当后端修改完成才修改前端显示
|
||||
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
||||
const getInputValue = debounce(async (item) => {
|
||||
let res = await fetchDataUpdateShoppingCart({ id: item.id, roll: item.roll, length: item.length })
|
||||
const getInputValue = debounce(async(item) => {
|
||||
const res = await fetchDataUpdateShoppingCart({ id: item.id, roll: item.roll, length: item.length })
|
||||
if (res.success) {
|
||||
console.log('item修改::', item)
|
||||
getShoppingCartInfo(item)
|
||||
} else {
|
||||
setList((e) => ({ ...e }))
|
||||
}
|
||||
else {
|
||||
setList(e => ({ ...e }))
|
||||
}
|
||||
}, 300)
|
||||
|
||||
//绑定业务员和电话号码
|
||||
// 绑定业务员和电话号码
|
||||
const [showBindSalesman, setShowBindSalesman] = useState(false)
|
||||
|
||||
//显示图片弹窗
|
||||
// 显示图片弹窗
|
||||
const [showLabImage, setShowLabImage] = useState(false)
|
||||
const [labImageValue, setLabImageValue] = useState()
|
||||
const getLabAndImg = useCallback((val) => {
|
||||
@ -326,7 +333,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
<View
|
||||
key={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}
|
||||
</View>
|
||||
)
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
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 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 styles from './index.module.scss'
|
||||
import ProductClass from '@/pages/index/components/productClass'
|
||||
import { GetClassList } from '@/api/material'
|
||||
|
||||
type Params = {
|
||||
interface Params {
|
||||
list?: any[]
|
||||
defaultValue?: number | string
|
||||
children?: ReactNode
|
||||
@ -38,7 +40,7 @@ export default memo(
|
||||
statusMore = 0,
|
||||
selectClass,
|
||||
}: Params) => {
|
||||
let num_half = useRef(0)
|
||||
const num_half = useRef(0)
|
||||
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
@ -66,24 +68,25 @@ export default memo(
|
||||
|
||||
const computeSelectTab = (index) => {
|
||||
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())
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setTabId(list[0].id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
Taro.nextTick(() => {
|
||||
let query = Taro.createSelectorQuery()
|
||||
const query = Taro.createSelectorQuery()
|
||||
query
|
||||
.select('.side_bar_select')
|
||||
.boundingClientRect((rect) => {
|
||||
console.log('rect::', rect)
|
||||
let clientHeight = rect.height
|
||||
let clientWidth = rect.width
|
||||
let ratio = 750 / clientWidth
|
||||
let height = clientHeight * ratio
|
||||
const clientHeight = rect.height
|
||||
const clientWidth = rect.width
|
||||
const ratio = 750 / clientWidth
|
||||
const height = clientHeight * ratio
|
||||
num_half.current = Math.ceil(height / 2 / heightItem)
|
||||
console.log('num_half::', num_half)
|
||||
init()
|
||||
@ -92,13 +95,13 @@ export default memo(
|
||||
})
|
||||
}, [])
|
||||
|
||||
//二级面料系列分类
|
||||
// 二级面料系列分类
|
||||
const [openClass, setOpenClass] = useState(false)
|
||||
const [classList, setClassList] = useState([])
|
||||
const [classId, setClassId] = useState(-1)
|
||||
const { fetchData } = GetClassList()
|
||||
const getClassData = async (id) => {
|
||||
let res = await fetchData({ id })
|
||||
const getClassData = async(id) => {
|
||||
const res = await fetchData({ id })
|
||||
if (res.success) {
|
||||
if (res.data?.list.length > 0) {
|
||||
res.data.list = [{ id: -1, name: '全部' }, ...res.data.list]
|
||||
@ -107,7 +110,7 @@ export default memo(
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
if (selected) getClassData(selected)
|
||||
if (selected) { getClassData(selected) }
|
||||
}, [selected])
|
||||
|
||||
const getSelectClass = (id) => {
|
||||
@ -118,13 +121,14 @@ export default memo(
|
||||
return (
|
||||
<>
|
||||
<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) => {
|
||||
return (
|
||||
<View className={styles.sideBar_select_title} id={`tab_${item.id}`} key={item.id} style={{ height: `${heightItem}rpx` }}>
|
||||
<View
|
||||
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>
|
||||
</View>
|
||||
@ -134,7 +138,7 @@ export default memo(
|
||||
<View className={styles.sideBar_con} style={{ paddingTop: classList.length > 0 ? '90rpx' : '20rpx' }}>
|
||||
{classList.length > 0 && (
|
||||
<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>
|
||||
)}
|
||||
<InfiniteScroll
|
||||
@ -142,8 +146,9 @@ export default memo(
|
||||
hasMore={hasMore}
|
||||
selfonScrollToLower={() => selfOnScrolltolower?.()}
|
||||
refresherTriggered={refresherTriggered}
|
||||
refresherEnabled={true}
|
||||
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
|
||||
refresherEnabled
|
||||
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}
|
||||
>
|
||||
{children}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
||||
@ -1,45 +1,45 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import classnames from "classnames";
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import { View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type params = {
|
||||
status?: 'top'|'bottom'|'none',
|
||||
onChange?: (val:{status:string, value:string}) => void,
|
||||
sortValue?: {desc: string, asc: string} //排序规则,后端制定
|
||||
interface params {
|
||||
status?: 'top'|'bottom'|'none'
|
||||
onChange?: (val: { status: string; value: string }) => void
|
||||
sortValue?: { desc: string; asc: string } // 排序规则,后端制定
|
||||
}
|
||||
type sortParam = 'none'|'top'|'bottom'
|
||||
export default forwardRef(({status = 'none', onChange, sortValue}: params,ref) => {
|
||||
const [sortStatus, setSortStatus] = useState<sortParam>()
|
||||
useEffect(() => {
|
||||
setSortStatus(() => status)
|
||||
}, [status])
|
||||
const changeSort = ():{status:sortParam, value:string} => {
|
||||
let status:sortParam = 'none'
|
||||
let value = ''
|
||||
if(sortStatus == 'none') {
|
||||
status = 'top'
|
||||
value = sortValue?.asc!
|
||||
}
|
||||
if(sortStatus == 'top') {
|
||||
status = 'bottom'
|
||||
value = sortValue?.desc!
|
||||
}
|
||||
if(sortStatus == 'bottom') status = 'none'
|
||||
setSortStatus(() => status)
|
||||
onChange?.({status, value})
|
||||
return {status, value}
|
||||
export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref) => {
|
||||
const [sortStatus, setSortStatus] = useState<sortParam>()
|
||||
useEffect(() => {
|
||||
setSortStatus(() => status)
|
||||
}, [status])
|
||||
const changeSort = (): { status: sortParam; value: string } => {
|
||||
let status: sortParam = 'none'
|
||||
let value = ''
|
||||
if (sortStatus == 'none') {
|
||||
status = 'top'
|
||||
value = sortValue?.asc!
|
||||
}
|
||||
useImperativeHandle(ref, () => ({
|
||||
changeSort
|
||||
}))
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.click} onClick={changeSort}>
|
||||
<View className={classnames(styles.top, sortStatus == 'top'&&styles.selected)} ></View>
|
||||
<View className={classnames(styles.bottom, sortStatus == 'bottom'&&styles.selected)}></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
if (sortStatus == 'top') {
|
||||
status = 'bottom'
|
||||
value = sortValue?.desc!
|
||||
}
|
||||
if (sortStatus == 'bottom') { status = 'none' }
|
||||
setSortStatus(() => status)
|
||||
onChange?.({ status, value })
|
||||
return { status, value }
|
||||
}
|
||||
useImperativeHandle(ref, () => ({
|
||||
changeSort,
|
||||
}))
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.click} onClick={changeSort}>
|
||||
<View className={classnames(styles.top, sortStatus == 'top' && styles.selected)} ></View>
|
||||
<View className={classnames(styles.bottom, sortStatus == 'bottom' && styles.selected)}></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,61 +1,60 @@
|
||||
import { ScrollView, View } from "@tarojs/components";
|
||||
import { memo, useState, ReactNode, useEffect } from "react";
|
||||
import classnames from "classnames";
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
|
||||
type ListProps = {
|
||||
title: string,
|
||||
value: number
|
||||
interface ListProps {
|
||||
title: string
|
||||
value: number
|
||||
}
|
||||
|
||||
type Params = {
|
||||
list?: ListProps[],
|
||||
defaultValue?: number|string,
|
||||
children?: ReactNode,
|
||||
tabsOnClick?: (ListProps) => void,
|
||||
style?:Object,
|
||||
interface Params {
|
||||
list?: ListProps[]
|
||||
defaultValue?: number|string
|
||||
children?: ReactNode
|
||||
tabsOnClick?: (ListProps) => void
|
||||
style?: Object
|
||||
|
||||
}
|
||||
|
||||
export default memo(({list = [], defaultValue = 0, tabsOnClick, style={}}: Params) => {
|
||||
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
export default memo(({ list = [], defaultValue = 0, tabsOnClick, style = {} }: Params) => {
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
const index = list?.findIndex(item => {
|
||||
return item.value == defaultValue
|
||||
})
|
||||
if(index !== -1) {
|
||||
const num = index > 0?( index - 1) : 0
|
||||
setTabId(list[num].value.toString())
|
||||
}
|
||||
}, [])
|
||||
|
||||
const clickEvent = ({item, index}: {item:ListProps, index:number}) => {
|
||||
setSelected(item.value)
|
||||
tabsOnClick?.(item)
|
||||
const num = index > 0?( index - 1) : 0
|
||||
setTabId(list[num].value.toString())
|
||||
useEffect(() => {
|
||||
const index = list?.findIndex((item) => {
|
||||
return item.value == defaultValue
|
||||
})
|
||||
if (index !== -1) {
|
||||
const num = index > 0 ? (index - 1) : 0
|
||||
setTabId(list[num].value.toString())
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.tabs_main} id="tabs_main_ref">
|
||||
<ScrollView className={styles.tabs_scroll} scrollX scrollWithAnimation={true} scrollIntoView={`tabs_${tabId}`}>
|
||||
<View className={styles.tabs_scroll}>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View key={item.value} id={`tabs_${item.value}`} className={styles.tabs_item} onClick={() => clickEvent({item,index})}>
|
||||
<View className={classnames(styles.tabs_item_con, {[styles.tabs_item_select]:selected == item.value})}>{item.title}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}, [])
|
||||
|
||||
const clickEvent = ({ item, index }: { item: ListProps; index: number }) => {
|
||||
setSelected(item.value)
|
||||
tabsOnClick?.(item)
|
||||
const num = index > 0 ? (index - 1) : 0
|
||||
setTabId(list[num].value.toString())
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.tabs_main} id="tabs_main_ref">
|
||||
<ScrollView className={styles.tabs_scroll} scrollX scrollWithAnimation scrollIntoView={`tabs_${tabId}`}>
|
||||
<View className={styles.tabs_scroll}>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View key={item.value} id={`tabs_${item.value}`} className={styles.tabs_item} onClick={() => clickEvent({ item, index })}>
|
||||
<View className={classnames(styles.tabs_item_con, { [styles.tabs_item_select]: selected == item.value })}>{item.title}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,48 +1,48 @@
|
||||
import {Textarea, View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useState } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { Textarea, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
//其他说明
|
||||
type Param = {
|
||||
title?: string,
|
||||
onChange?: (val: string) => void,
|
||||
placeholder?: string,
|
||||
defaultValue?: string,
|
||||
onlyRead?: false|true
|
||||
// 其他说明
|
||||
interface Param {
|
||||
title?: string
|
||||
onChange?: (val: string) => void
|
||||
placeholder?: string
|
||||
defaultValue?: string
|
||||
onlyRead?: false|true
|
||||
}
|
||||
export default memo(({onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false}:Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
show: false
|
||||
})
|
||||
const getDesc = (value = '') => {
|
||||
let res = value
|
||||
if(value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
export default memo(({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
show: false,
|
||||
})
|
||||
const getDesc = (value = '') => {
|
||||
let res = value
|
||||
if (value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({ ...descData, number: res.length, value: res })
|
||||
onChange?.(res)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const toggleShowRealTextarea = (show) => {
|
||||
setDescData({ ...descData, show })
|
||||
}
|
||||
return (
|
||||
<View className={styles.other_desc}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
<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>
|
||||
|| <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || placeholder}</View>
|
||||
}
|
||||
setDescData({...descData, number:res.length, value: res})
|
||||
onChange?.(res)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const toggleShowRealTextarea = (show) => {
|
||||
setDescData({...descData, show:show})
|
||||
}
|
||||
return (
|
||||
<View className={styles.other_desc}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
<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>||
|
||||
<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>
|
||||
</View>
|
||||
)
|
||||
<View className={styles.descDataNum}>{`${descData.number}/${descData.count}`}</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import Taro, { FC } from '@tarojs/taro'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import useUploadCDNImg from '@/use/useUploadImage'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
import { FC, memo, useEffect, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import useUploadCDNImg from '@/use/useUploadImage'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
|
||||
//图片列表
|
||||
type ImageParam = {
|
||||
// 图片列表
|
||||
interface ImageParam {
|
||||
onChange?: (val: string[]) => void
|
||||
defaultList?: string[]
|
||||
onlyRead?: false | true
|
||||
@ -20,28 +20,28 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
|
||||
setImageLise(defaultList || [])
|
||||
}, [defaultList])
|
||||
|
||||
//上传图片
|
||||
const uploadImage = async () => {
|
||||
let list: any = await getWxPhoto('after-sale', 5)
|
||||
let images: any[] = []
|
||||
// 上传图片
|
||||
const uploadImage = async() => {
|
||||
const list: any = await getWxPhoto('after-sale', 5)
|
||||
const images: any[] = []
|
||||
list?.map((item) => {
|
||||
images.push(item.url)
|
||||
})
|
||||
setImageLise([...imageList, ...images])
|
||||
}
|
||||
//删除图片
|
||||
// 删除图片
|
||||
const delImage = (index) => {
|
||||
imageList.splice(index, 1)
|
||||
setImageLise(() => [...imageList])
|
||||
}
|
||||
//监听上传的图片变化
|
||||
// 监听上传的图片变化
|
||||
useEffect(() => {
|
||||
onChange?.(imageList)
|
||||
}, [imageList])
|
||||
|
||||
//预览图片
|
||||
// 预览图片
|
||||
const showImage = () => {
|
||||
let list = imageList?.map((item) => {
|
||||
const list = imageList?.map((item) => {
|
||||
return formatImgUrl(item, '!w800')
|
||||
})
|
||||
Taro.previewImage({
|
||||
@ -54,7 +54,7 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
|
||||
<View className={styles.image_main}>
|
||||
{imageList?.map((item, index) => (
|
||||
<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>}
|
||||
</View>
|
||||
))}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
export const SET_SHOPCOUNT = 'set_shopCount'
|
||||
export const CLEAR_SHOPCOUNT = 'clear_shopCount'
|
||||
export const STORAGE_SHOPCOUNT = 'storage_shopcount'
|
||||
export const STORAGE_SHOPCOUNT = 'storage_shopcount'
|
||||
|
||||
@ -8,4 +8,4 @@ export const CLEAR_SESSIONKEY = 'clearSessionkey'
|
||||
export const CLEAR_USERINFO = 'clearUserInfo'
|
||||
export const CLEAR_ADMINUSERINFO = 'clearAdminUserInfo'
|
||||
export const CLEAR_SORTCODE = 'clearSortCode'
|
||||
export const LOGIN_STATUS = 'loginStatus'
|
||||
export const LOGIN_STATUS = 'loginStatus'
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { alert, retrieval } from '@/common/common'
|
||||
import Address from '@/components/address'
|
||||
import FromList from '@/components/FromList'
|
||||
import { Button, Input, Text, Textarea, View } from '@tarojs/components'
|
||||
import Taro, { setNavigationBarTitle, useRouter } from '@tarojs/taro'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { alert, retrieval } from '@/common/common'
|
||||
import Address from '@/components/address'
|
||||
import FromList from '@/components/FromList'
|
||||
import './index.scss'
|
||||
import { addressAddApi, addressDetailApi, addressEditApi } from '@/api/addressManager'
|
||||
import useLogin from '@/use/useLogin'
|
||||
@ -15,14 +15,15 @@ export default () => {
|
||||
useEffect(() => {
|
||||
if (type == 'add') {
|
||||
setNavigationBarTitle({ title: '新增收货地址' })
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
initalFormData()
|
||||
setNavigationBarTitle({ title: '编辑收货地址' })
|
||||
}
|
||||
}, [])
|
||||
// 获取编辑地址信息
|
||||
const { fetchData: getFromData } = addressDetailApi()
|
||||
const initalFormData = async () => {
|
||||
const initalFormData = async() => {
|
||||
const detail = await getFromData({ id })
|
||||
const { province_id, province_name, city_id, city_name, district_id, district_name } = detail.data
|
||||
const siteArray = [{ id: province_id, name: province_name }]
|
||||
@ -31,7 +32,7 @@ export default () => {
|
||||
setFormData({
|
||||
name: detail.data.name,
|
||||
phone: detail.data.phone,
|
||||
site: siteArray.map((item) => item.name).join(' '),
|
||||
site: siteArray.map(item => item.name).join(' '),
|
||||
siteArray: siteArray as any,
|
||||
district_id: detail.data.district_id,
|
||||
address_detail: detail.data.address_detail,
|
||||
@ -81,29 +82,30 @@ export default () => {
|
||||
}
|
||||
const handleSave = () => {
|
||||
retrieval(formData, rules)
|
||||
.then(async () => {
|
||||
const result =
|
||||
type == 'add'
|
||||
.then(async() => {
|
||||
const result
|
||||
= type == 'add'
|
||||
? await fetchData({
|
||||
name: formData.name,
|
||||
phone: formData.phone,
|
||||
district_id: formData.district_id,
|
||||
address_detail: formData.address_detail,
|
||||
is_default: formData.is_default,
|
||||
})
|
||||
name: formData.name,
|
||||
phone: formData.phone,
|
||||
district_id: formData.district_id,
|
||||
address_detail: formData.address_detail,
|
||||
is_default: formData.is_default,
|
||||
})
|
||||
: await editFetch({
|
||||
name: formData.name,
|
||||
phone: formData.phone,
|
||||
district_id: formData.district_id,
|
||||
address_detail: formData.address_detail,
|
||||
is_default: formData.is_default,
|
||||
id: formData.id,
|
||||
})
|
||||
name: formData.name,
|
||||
phone: formData.phone,
|
||||
district_id: formData.district_id,
|
||||
address_detail: formData.address_detail,
|
||||
is_default: formData.is_default,
|
||||
id: formData.id,
|
||||
})
|
||||
if (result.success) {
|
||||
Taro.eventCenter.trigger('addressList:refresh')
|
||||
Taro.navigateBack()
|
||||
alert.success('保存成功')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error(result.msg)
|
||||
}
|
||||
})
|
||||
@ -126,51 +128,54 @@ export default () => {
|
||||
setFormData({
|
||||
...formData,
|
||||
siteArray: ev,
|
||||
site: ev.map((item) => item.name + ' '),
|
||||
site: ev.map(item => `${item.name} `),
|
||||
district_id: ev[ev.length - 1]?.id,
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('请选择地址')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<View className='add-address'>
|
||||
<View className="add-address">
|
||||
<FromList
|
||||
onInput={(ev: any) => setFormData({ ...formData, name: ev.detail.value })}
|
||||
value={formData['name']}
|
||||
label='联系人'
|
||||
placeholder='请输入收货人姓名'
|
||||
value={formData.name}
|
||||
label="联系人"
|
||||
placeholder="请输入收货人姓名"
|
||||
/>
|
||||
<FromList
|
||||
primordialType='number'
|
||||
primordialType="number"
|
||||
onInput={(ev: any) => setFormData({ ...formData, phone: ev.detail.value })}
|
||||
value={formData['phone']}
|
||||
label='联系方式'
|
||||
placeholder='请输入联系方式'
|
||||
value={formData.phone}
|
||||
label="联系方式"
|
||||
placeholder="请输入联系方式"
|
||||
/>
|
||||
<FromList value={formData['site']} onClick={() => setShowSiteModal(true)} label='收货地址' type='select' placeholder='请选择/省/市/区' />
|
||||
<FromList value={formData.site} onClick={() => setShowSiteModal(true)} label="收货地址" type="select" placeholder="请选择/省/市/区" />
|
||||
<FromList
|
||||
onInput={(ev: any) => setFormData({ ...formData, address_detail: ev.detail.value })}
|
||||
value={formData['address_detail']}
|
||||
label='详细地址'
|
||||
type='textarea'
|
||||
placeholder='请输入详细地址(街道、门牌号等)'
|
||||
value={formData.address_detail}
|
||||
label="详细地址"
|
||||
type="textarea"
|
||||
placeholder="请输入详细地址(街道、门牌号等)"
|
||||
/>
|
||||
<View className='add-address-default'>
|
||||
<View className="add-address-default">
|
||||
<Text>设为默认地址</Text>
|
||||
<View onClick={() => setFormData({ ...formData, is_default: !formData.is_default })}>
|
||||
{formData.is_default ? (
|
||||
<View className='add-address-default-active'>
|
||||
<Text className='iconfont icon-tick' />
|
||||
</View>
|
||||
) : (
|
||||
<View className='add-address-default-noactive'></View>
|
||||
)}
|
||||
{formData.is_default
|
||||
? (
|
||||
<View className="add-address-default-active">
|
||||
<Text className="iconfont icon-tick" />
|
||||
</View>
|
||||
)
|
||||
: (
|
||||
<View className="add-address-default-noactive"></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>
|
||||
<Address addressOnChange={handleSetSite} defaultValue={formData.siteArray} addressOnClose={() => setShowSiteModal(false)} show={showSiteModal} />
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
|
||||
import AddressList from "@/components/AddressList"
|
||||
import useLogin from "@/use/useLogin"
|
||||
import { Button, ScrollView, Text, View } from "@tarojs/components"
|
||||
import { stopPullDownRefresh, usePullDownRefresh } from "@tarojs/taro"
|
||||
import { useState } from "react"
|
||||
import "./index.scss"
|
||||
import { Button, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { stopPullDownRefresh, usePullDownRefresh } from '@tarojs/taro'
|
||||
import { useState } from 'react'
|
||||
import useLogin from '@/use/useLogin'
|
||||
import AddressList from '@/components/AddressList'
|
||||
import './index.scss'
|
||||
|
||||
export default ()=>{
|
||||
export default () => {
|
||||
useLogin()
|
||||
return (
|
||||
<View className="address-manager">
|
||||
<AddressList refresherEnabled={true}/>
|
||||
<AddressList refresherEnabled />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,56 +1,56 @@
|
||||
import { formatHashTag, formatImgUrl } from "@/common/fotmat";
|
||||
import Counter from "@/components/counter";
|
||||
import MCheckbox from "@/components/checkbox";
|
||||
import { Image, Text, View } from "@tarojs/components";
|
||||
import { FC, memo, useCallback } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useCallback } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||
import Counter from '@/components/counter'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
|
||||
type OrderParam = {
|
||||
list?: any[],
|
||||
sale_mode?: number,
|
||||
sale_mode_name?: string,
|
||||
unit?: string,
|
||||
total_colors?: number,
|
||||
total_fabrics?: number,
|
||||
total_number?: number,
|
||||
status?: number, //订单状态
|
||||
av_return_product?: any[] //申请售后列表
|
||||
interface OrderParam {
|
||||
list?: any[]
|
||||
sale_mode?: number
|
||||
sale_mode_name?: string
|
||||
unit?: string
|
||||
total_colors?: number
|
||||
total_fabrics?: number
|
||||
total_number?: number
|
||||
status?: number // 订单状态
|
||||
av_return_product?: any[] // 申请售后列表
|
||||
}
|
||||
|
||||
type Param = {
|
||||
order: OrderParam,
|
||||
onSelectChange?: (val: {color_id:number, length: number, status: true|false, sale_order_detail_id:number}) => void
|
||||
interface Param {
|
||||
order: OrderParam
|
||||
onSelectChange?: (val: { color_id: number; length: number; status: true|false; sale_order_detail_id: number }) => void
|
||||
}
|
||||
|
||||
const kindeList:FC<Param> = memo(({order, onSelectChange}) => {
|
||||
const kindeList: FC<Param> = memo(({ order, onSelectChange }) => {
|
||||
// checkbox选中回调
|
||||
const selectCallBack = (colorItem) => {
|
||||
onSelectChange?.({ color_id: colorItem.product_color_id, length: colorItem.length, sale_order_detail_id: colorItem.sale_order_detail_id, status: true })
|
||||
}
|
||||
|
||||
//checkbox选中回调
|
||||
const selectCallBack = (colorItem) => {
|
||||
onSelectChange?.({color_id:colorItem.product_color_id, length:colorItem.length, sale_order_detail_id:colorItem.sale_order_detail_id, status: true})
|
||||
}
|
||||
// checkbox关闭回调
|
||||
const colseCallBack = (colorItem) => {
|
||||
onSelectChange?.({ color_id: colorItem.product_color_id, length: colorItem.length, status: false, sale_order_detail_id: colorItem.sale_order_detail_id })
|
||||
}
|
||||
|
||||
//checkbox关闭回调
|
||||
const colseCallBack = (colorItem) => {
|
||||
onSelectChange?.({color_id:colorItem.product_color_id, length:colorItem.length, status: false, sale_order_detail_id:colorItem.sale_order_detail_id,})
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.apply_after_sales_list}>
|
||||
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item} >
|
||||
<View className={styles.apply_after_sales_title}>
|
||||
<View className={styles.tag}>{order.sale_mode_name}</View>
|
||||
<View className={styles.title}>{formatHashTag(item.product_code, item.product_name)}</View>
|
||||
</View>
|
||||
<View className={styles.color_list}>
|
||||
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
||||
<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>
|
||||
<MCheckbox status={item.select} onSelect={() => selectCallBack(colorItem)} onClose={() => colseCallBack(colorItem)}/>
|
||||
</View>)}
|
||||
</View>
|
||||
</View>)}
|
||||
return (
|
||||
<View className={styles.apply_after_sales_list}>
|
||||
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item} >
|
||||
<View className={styles.apply_after_sales_title}>
|
||||
<View className={styles.tag}>{order.sale_mode_name}</View>
|
||||
<View className={styles.title}>{formatHashTag(item.product_code, item.product_name)}</View>
|
||||
</View>
|
||||
)
|
||||
<View className={styles.color_list}>
|
||||
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
||||
<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>
|
||||
<MCheckbox status={item.select} onSelect={() => selectCallBack(colorItem)} onClose={() => colseCallBack(colorItem)} />
|
||||
</View>)}
|
||||
</View>
|
||||
</View>)}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
export default kindeList
|
||||
export default kindeList
|
||||
|
||||
@ -1,55 +1,55 @@
|
||||
import { formatHashTag, formatImgUrl } from "@/common/fotmat";
|
||||
import Counter from "@/components/counter";
|
||||
import MCheckbox from "@/components/checkbox";
|
||||
import { Image, Text, View } from "@tarojs/components";
|
||||
import { FC, memo, useCallback } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useCallback } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||
import Counter from '@/components/counter'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
|
||||
type OrderParam = {
|
||||
list?: any[],
|
||||
sale_mode?: number,
|
||||
sale_mode_name?: string,
|
||||
unit?: string,
|
||||
total_colors?: number,
|
||||
total_fabrics?: number,
|
||||
total_number?: number,
|
||||
status?: number, //订单状态
|
||||
av_return_product?: any[] //申请售后列表
|
||||
interface OrderParam {
|
||||
list?: any[]
|
||||
sale_mode?: number
|
||||
sale_mode_name?: string
|
||||
unit?: string
|
||||
total_colors?: number
|
||||
total_fabrics?: number
|
||||
total_number?: number
|
||||
status?: number // 订单状态
|
||||
av_return_product?: any[] // 申请售后列表
|
||||
}
|
||||
|
||||
type Param = {
|
||||
order: OrderParam,
|
||||
onNumChange?: (val:any) => void
|
||||
interface Param {
|
||||
order: OrderParam
|
||||
onNumChange?: (val: any) => void
|
||||
}
|
||||
|
||||
const kindeList:FC<Param> = memo(({order, onNumChange}) => {
|
||||
const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
|
||||
// 计步器返回值
|
||||
const getCounterChange = useCallback((colorItem) => {
|
||||
return (number) => {
|
||||
onNumChange?.({ number, color_id: colorItem.product_color_id, sale_order_detail_id: colorItem.sale_order_detail_id })
|
||||
}
|
||||
}, [order])
|
||||
|
||||
//计步器返回值
|
||||
const getCounterChange = useCallback((colorItem) => {
|
||||
return (number) => {
|
||||
onNumChange?.({number, color_id: colorItem.product_color_id, sale_order_detail_id:colorItem.sale_order_detail_id})
|
||||
}
|
||||
}, [order])
|
||||
|
||||
return (
|
||||
<View className={styles.apply_after_sales_list}>
|
||||
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item}>
|
||||
<View className={styles.apply_after_sales_title}>
|
||||
<View className={styles.tag}>{order.sale_mode_name}</View>
|
||||
<View className={styles.title}>{formatHashTag(item.product_code, item.product_name)}</View>
|
||||
</View>
|
||||
<View className={styles.color_list}>
|
||||
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
||||
<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.btn_count}>
|
||||
<Counter maxNum={colorItem.roll} onChange={getCounterChange(colorItem)}/>
|
||||
</View>
|
||||
</View>)}
|
||||
</View>
|
||||
</View>)}
|
||||
return (
|
||||
<View className={styles.apply_after_sales_list}>
|
||||
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item}>
|
||||
<View className={styles.apply_after_sales_title}>
|
||||
<View className={styles.tag}>{order.sale_mode_name}</View>
|
||||
<View className={styles.title}>{formatHashTag(item.product_code, item.product_name)}</View>
|
||||
</View>
|
||||
)
|
||||
<View className={styles.color_list}>
|
||||
{item?.av_product_color?.map(colorItem => <View className={styles.color_item}>
|
||||
<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.btn_count}>
|
||||
<Counter maxNum={colorItem.roll} onChange={getCounterChange(colorItem)} />
|
||||
</View>
|
||||
</View>)}
|
||||
</View>
|
||||
</View>)}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
export default kindeList
|
||||
export default kindeList
|
||||
|
||||
@ -1,41 +1,41 @@
|
||||
import {Textarea, View } from "@tarojs/components";
|
||||
import { memo, useMemo, useState } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { Textarea, View } from '@tarojs/components'
|
||||
import { memo, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
//其他说明
|
||||
type Param = {
|
||||
onChange: (val: string) => void
|
||||
// 其他说明
|
||||
interface Param {
|
||||
onChange: (val: string) => void
|
||||
}
|
||||
export default memo(({onChange}:Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
show: false
|
||||
})
|
||||
const getDesc = (e) => {
|
||||
let value = e.detail.value
|
||||
let res = value
|
||||
if(value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({...descData, number:res.length, value: res})
|
||||
onChange?.(res)
|
||||
export default memo(({ onChange }: Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
show: false,
|
||||
})
|
||||
const getDesc = (e) => {
|
||||
const value = e.detail.value
|
||||
let res = value
|
||||
if (value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({ ...descData, number: res.length, value: res })
|
||||
onChange?.(res)
|
||||
}
|
||||
|
||||
const toggleShowRealTextarea = (show) => {
|
||||
setDescData({...descData, show:show})
|
||||
}
|
||||
return (
|
||||
<View className={styles.other_desc}>
|
||||
<View className={styles.title}>其他说明</View>
|
||||
<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>||
|
||||
<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>
|
||||
</View>
|
||||
)
|
||||
const toggleShowRealTextarea = (show) => {
|
||||
setDescData({ ...descData, show })
|
||||
}
|
||||
return (
|
||||
<View className={styles.other_desc}>
|
||||
<View className={styles.title}>其他说明</View>
|
||||
<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>
|
||||
|| <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>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@ -1,44 +1,44 @@
|
||||
import Popup from "@/components/popup";
|
||||
import { ScrollView, Text, View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useState } from "react";
|
||||
import classnames from "classnames";
|
||||
import styles from './index.module.scss'
|
||||
import { ScrollView, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
|
||||
//原因选择
|
||||
type Param = {id:number, name:string, typle?:number}
|
||||
type ReasonInfoParam = {
|
||||
show?: boolean, //显示
|
||||
onClose?: () => void, //关闭
|
||||
title?: string, //标题
|
||||
list?: {id:number, name:string, typle?:number, children?:Param[]}[], //数据列表
|
||||
onSelect?: (val: object) => void, //选择
|
||||
defaultValue?: number, //默认选中
|
||||
// 原因选择
|
||||
interface Param { id: number; name: string; typle?: number }
|
||||
interface ReasonInfoParam {
|
||||
show?: boolean // 显示
|
||||
onClose?: () => void // 关闭
|
||||
title?: string // 标题
|
||||
list?: { id: number; name: string; typle?: number; children?: Param[] }[] // 数据列表
|
||||
onSelect?: (val: object) => void // 选择
|
||||
defaultValue?: number // 默认选中
|
||||
}
|
||||
export default memo(({show = false, onClose, title = '', list = [], onSelect, defaultValue}: ReasonInfoParam) => {
|
||||
const [hasNextData, setHasNextData] = useState(true) //是否有下一级数据
|
||||
const [selectData, setSelectData] = useState()
|
||||
const [headerList, setHeaderList] = useState<{id: number, name: string}[]>([])
|
||||
const onSelectData = (item) => {
|
||||
setHeaderList((e) => [...e, {id:item.id, name:item.name}])
|
||||
}
|
||||
useEffect(() => {
|
||||
console.log('headerList::', headerList)
|
||||
}, [headerList])
|
||||
return (
|
||||
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
|
||||
<View className={styles.reason_return_con}>
|
||||
<View className={styles.reason_title}>
|
||||
{headerList.map(item => {
|
||||
return <Text key={item.id}>{item.name}</Text>
|
||||
})}
|
||||
{hasNextData&&<Text>请选择</Text>}
|
||||
</View>
|
||||
<ScrollView scrollY className={styles.reason_scroll}>
|
||||
<View className={styles.reason_list}>
|
||||
{list.map(item => <View onClick={() => onSelectData(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name}</View> )}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
})
|
||||
export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
|
||||
const [hasNextData, setHasNextData] = useState(true) // 是否有下一级数据
|
||||
const [selectData, setSelectData] = useState()
|
||||
const [headerList, setHeaderList] = useState<{ id: number; name: string }[]>([])
|
||||
const onSelectData = (item) => {
|
||||
setHeaderList(e => [...e, { id: item.id, name: item.name }])
|
||||
}
|
||||
useEffect(() => {
|
||||
console.log('headerList::', headerList)
|
||||
}, [headerList])
|
||||
return (
|
||||
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
|
||||
<View className={styles.reason_return_con}>
|
||||
<View className={styles.reason_title}>
|
||||
{headerList.map((item) => {
|
||||
return <Text key={item.id}>{item.name}</Text>
|
||||
})}
|
||||
{hasNextData && <Text>请选择</Text>}
|
||||
</View>
|
||||
<ScrollView scrollY className={styles.reason_scroll}>
|
||||
<View className={styles.reason_list}>
|
||||
{list.map(item => <View onClick={() => onSelectData(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue && styles.select_item)}>{item.name}</View>)}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
})
|
||||
|
||||
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