🌈 style(eslint): 修复eslint的报错❌
This commit is contained in:
parent
d93b66e7d5
commit
639112c038
3
global.d.ts
vendored
3
global.d.ts
vendored
@ -20,3 +20,6 @@ declare namespace NodeJS {
|
||||
declare const CURRENT_VERSION: string
|
||||
declare const CURRENT_GITHASH: string
|
||||
declare const CURRENT_ENV: string
|
||||
declare const CURRENT_BASE_URL: string
|
||||
declare const CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: string
|
||||
declare const CURRENT_PAY_H5_CODE_URL: string
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import Taro, { onAppShow, useDidShow } from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import { Provider } from 'react-redux'
|
||||
import configStore from './store'
|
||||
import { shareShop } from './common/util'
|
||||
import ContextBlueTooth from '@/use/contextBlueTooth'
|
||||
import './app.scss'
|
||||
import Taro, { onAppShow, useDidShow } from '@tarojs/taro'
|
||||
import { shareShop } from './common/util'
|
||||
|
||||
const store = configStore()
|
||||
const App: FC = (params) => {
|
||||
const App: FC = (params: { children?: React.ReactNode }) => {
|
||||
Taro.showShareMenu({
|
||||
withShareTicket: true,
|
||||
})
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import Qs from 'qs'
|
||||
|
||||
const setUrlQuery = (options: { url: string; query: object | null }) => {
|
||||
let { url, query } = options
|
||||
if (!url) { return '' }
|
||||
if (query) {
|
||||
const queryArr: any[] = []
|
||||
for (const key in query) {
|
||||
if (query.hasOwnProperty(key)) {
|
||||
queryArr.push(`${key}=${query[key]}`)
|
||||
}
|
||||
}
|
||||
if (url.includes('?')) {
|
||||
url = `${url}&${queryArr.join('&')}`
|
||||
}
|
||||
else {
|
||||
url = `${url}?${queryArr.join('&')}`
|
||||
}
|
||||
}
|
||||
return url
|
||||
}
|
||||
/**
|
||||
* 跳转
|
||||
* @param path
|
||||
@ -16,25 +35,6 @@ export const goLink = (path = '', params: object | null = null, way: ParamLink =
|
||||
Taro[way]({ url: path })
|
||||
}
|
||||
}
|
||||
const setUrlQuery = (options: { url: string; query: object | null }) => {
|
||||
let { url, query } = options
|
||||
if (!url) { return '' }
|
||||
if (query) {
|
||||
const queryArr: any[] = []
|
||||
for (const key in query) {
|
||||
if (query.hasOwnProperty(key)) {
|
||||
queryArr.push(`${key}=${query[key]}`)
|
||||
}
|
||||
}
|
||||
if (url.includes('?')) {
|
||||
url = `${url}&${queryArr.join('&')}`
|
||||
}
|
||||
else {
|
||||
url = `${url}?${queryArr.join('&')}`
|
||||
}
|
||||
}
|
||||
return url
|
||||
}
|
||||
/**
|
||||
* 判断对象为空
|
||||
* @param object
|
||||
@ -43,14 +43,14 @@ const setUrlQuery = (options: { url: string; query: object | null }) => {
|
||||
export const isEmptyObject = (object: any) => {
|
||||
if (object == undefined || object == null || Number.isNaN(object)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (object.constructor == Object) {
|
||||
return Reflect.ownKeys(object).length == 0
|
||||
}
|
||||
}
|
||||
else if (object.constructor == Array) {
|
||||
return object.length == 0
|
||||
}
|
||||
}
|
||||
else if (object.constructor == String) {
|
||||
return object == ''
|
||||
}
|
||||
@ -88,12 +88,12 @@ export const retrieval = (data: any, rules?: Object, message = '请填写完信
|
||||
if (item.validator(data[key], item)) {
|
||||
_res = true
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.regex) {
|
||||
if (!item.regex.test(data[key])) {
|
||||
_res = true
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isEmptyObject(data[key])) {
|
||||
_res = true
|
||||
@ -106,7 +106,7 @@ export const retrieval = (data: any, rules?: Object, message = '请填写完信
|
||||
if (result) {
|
||||
reject(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const keys = Reflect.ownKeys(data)
|
||||
if (keys.some((key: any) => isEmptyObject(data[key]))) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export const BASE_URL = CURRENT_BASE_URL
|
||||
// export const BASE_URL = CURRENT_BASE_URL
|
||||
// export const BASE_URL = `http://192.168.0.75:50001/lymarket`
|
||||
// export const BASE_URL = `http://192.168.0.89:50001/lymarket`
|
||||
// export const BASE_URL = `http://10.0.0.5:50001/lymarket`
|
||||
@ -13,7 +13,7 @@ export const BASE_URL = CURRENT_BASE_URL
|
||||
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
|
||||
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
|
||||
// export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添
|
||||
// export const BASE_URL = `http://192.168.1.28:50002/lymarket` // 婷
|
||||
export const BASE_URL = 'http://192.168.1.28:50002/lymarket' // 婷
|
||||
// export const BASE_URL = `http://192.168.1.42:50002/lymarket` // 杰
|
||||
|
||||
// CDN
|
||||
@ -20,14 +20,36 @@ export const formatRemoveHashTag = (val = '') => {
|
||||
export const formatHashTag = (code = '', name = '', mode = 'both') => {
|
||||
if (mode == 'both') {
|
||||
return `${formatRemoveHashTag(code)}# ${name}`
|
||||
}
|
||||
}
|
||||
else if (mode == 'name') {
|
||||
return `${name}`
|
||||
}
|
||||
}
|
||||
|
||||
const Digit = 10 * 10
|
||||
|
||||
/**
|
||||
* 精度
|
||||
* @param {*} num
|
||||
* @param {*} precision
|
||||
* @returns
|
||||
*/
|
||||
export const strip = (num, precision = 12) => {
|
||||
return +parseFloat(num.toPrecision(precision))
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {千位分割付} number
|
||||
* @returns
|
||||
*/
|
||||
export const numberWithCommas = ({ number = 0, digit = 2 }) => {
|
||||
if (!Number.isNaN(Number(number))) {
|
||||
// return parseFloat(number).toFixed(digit).replace(/^\B(?<!\.\d*)(?=(\d{3})+(?!\d))$/g, ",");
|
||||
return parseFloat(number).toLocaleString('zh', { minimumFractionDigits: digit })
|
||||
}
|
||||
else {
|
||||
return 0.0
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 重量 进退位 单位
|
||||
*/
|
||||
@ -90,32 +112,12 @@ export const formatDateTime = (val, fmt = 'YYYY-MM-DD HH:mm:ss') => {
|
||||
.replace('ss', s.toString().padStart(2, '0'))
|
||||
|
||||
return fmt
|
||||
}
|
||||
}
|
||||
else {
|
||||
return val
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 精度
|
||||
* @param {*} num
|
||||
* @param {*} precision
|
||||
* @returns
|
||||
*/
|
||||
export const strip = (num, precision = 12) => {
|
||||
return +parseFloat(num.toPrecision(precision))
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换金额单位
|
||||
* @param {*} num 金额 / 数值
|
||||
* @param {*} digit 转换单位
|
||||
* @returns
|
||||
*/
|
||||
export const formatMillionYuan = (num, digit = 10000) => {
|
||||
return num / digit > 1 ? { num: toDecimal2(num / digit), million: true } : { num, million: false }
|
||||
}
|
||||
|
||||
/**
|
||||
* 数值保留两位小数
|
||||
* @param {*} x
|
||||
@ -123,7 +125,7 @@ export const formatMillionYuan = (num, digit = 10000) => {
|
||||
*/
|
||||
export const toDecimal2 = (x) => {
|
||||
let f = parseFloat(x)
|
||||
if (isNaN(f)) {
|
||||
if (Number.isNaN(f)) {
|
||||
return 0
|
||||
}
|
||||
f = `${f}`
|
||||
@ -132,14 +134,22 @@ export const toDecimal2 = (x) => {
|
||||
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.substring(0, 2)
|
||||
}
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换金额单位
|
||||
* @param {*} num 金额 / 数值
|
||||
* @param {*} digit 转换单位
|
||||
* @returns
|
||||
*/
|
||||
export const formatMillionYuan = (num, digit = 10000) => {
|
||||
return num / digit > 1 ? { num: toDecimal2(num / digit), million: true } : { num, million: false }
|
||||
}
|
||||
/**
|
||||
* 格式化图片路径
|
||||
* @param {*} url
|
||||
@ -149,7 +159,7 @@ 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`
|
||||
}
|
||||
@ -165,26 +175,11 @@ 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: 2, value: rgb }
|
||||
}
|
||||
}
|
||||
else {
|
||||
return { status: 3, value: `${IMG_CND_Prefix}/mall/no_img.png` }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {千位分割付} number
|
||||
* @returns
|
||||
*/
|
||||
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 {
|
||||
return 0.0
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,10 +46,10 @@ export const getFilterData = (val = {}, arr: string[] = []) => {
|
||||
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])) {
|
||||
if (!Number.isNaN(val[key])) {
|
||||
res[key] = val[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
res[key] = val[key]
|
||||
}
|
||||
@ -66,16 +66,16 @@ export const copyObject = (object) => {
|
||||
if (object.constructor == Object) {
|
||||
const keys = Object.keys(object)
|
||||
const newObject = {}
|
||||
keys.map((key) => {
|
||||
keys.forEach((key) => {
|
||||
newObject[key] = copyObject(object[key])
|
||||
})
|
||||
return newObject
|
||||
}
|
||||
}
|
||||
else if (object.constructor == Array) {
|
||||
return object.map((item) => {
|
||||
return copyObject(item)
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
return object
|
||||
}
|
||||
@ -101,13 +101,13 @@ export const screenshot = (url, suffix = '!w200') => {
|
||||
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) {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
else if (list.length < total) {
|
||||
return 2
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 3
|
||||
}
|
||||
@ -132,7 +132,7 @@ export const shareShop = () => {
|
||||
path = `/pages/details/index?share=${sortCode.shareShortDetail.code}`
|
||||
title = sortCode.shareShortDetail.title
|
||||
imageUrl = sortCode.shareShortDetail.img
|
||||
}
|
||||
}
|
||||
else {
|
||||
path
|
||||
= pageInfo.route === 'pages/user/index'
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
|
||||
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro, { showModal } from '@tarojs/taro'
|
||||
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// 是否开启刷新
|
||||
@ -15,15 +15,18 @@ interface Params{
|
||||
}
|
||||
|
||||
// 地址列表
|
||||
const AddressList = memo((props: Params) => {
|
||||
const AddressList = (props: Params) => {
|
||||
const { addButtonEnabled = true, focusBorderEnabled = false } = props
|
||||
const { fetchData, state } = addressListApi()
|
||||
|
||||
// 焦点
|
||||
const [focusId, setFocusId] = useState()
|
||||
// 获取数据
|
||||
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) {
|
||||
@ -50,8 +53,6 @@ const AddressList = memo((props: Params) => {
|
||||
setRefreshState(false)
|
||||
}
|
||||
const data = Array.from({ length: 15 })
|
||||
// 焦点
|
||||
const [focusId, setFocusId] = useState()
|
||||
// 列表选择
|
||||
const handleSelect = (item: any, index: number) => {
|
||||
props.onSelect && props.onSelect(item, index)
|
||||
@ -71,7 +72,7 @@ const AddressList = memo((props: Params) => {
|
||||
if (result.success) {
|
||||
alert.success('删除成功')
|
||||
getData()
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.success(result.msg)
|
||||
}
|
||||
@ -90,11 +91,11 @@ const AddressList = memo((props: Params) => {
|
||||
// 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 key={item.id} onLongPress={() => handleDelete(item)} onClick={() => handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}>
|
||||
<View className="address-user">
|
||||
{item.name}
|
||||
{
|
||||
item.is_default
|
||||
item.is_default
|
||||
? <Text className="address-list-default">默认</Text>
|
||||
: <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), '****')}</Text>
|
||||
}
|
||||
@ -122,6 +123,6 @@ const AddressList = memo((props: Params) => {
|
||||
{addButtonEnabled && <Navigator url="/pages/addressAdd/index?type=add" hoverClass="none" className="add-address">添加收货地址</Navigator>}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default AddressList
|
||||
export default memo(AddressList)
|
||||
|
||||
@ -16,9 +16,7 @@ interface ListParams {
|
||||
contentStyle?: object
|
||||
required?: boolean
|
||||
}
|
||||
|
||||
// 表单列表
|
||||
const FromList = memo((props: ListParams) => {
|
||||
const FromList = (props: ListParams) => {
|
||||
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props
|
||||
|
||||
return (
|
||||
@ -29,7 +27,7 @@ const FromList = memo((props: ListParams) => {
|
||||
<View onClick={props?.onClick} className="form-list-right">
|
||||
{props.children ?? (
|
||||
<View style={contentStyle} onClick={props?.onClick} className="form-list-right-meet">
|
||||
{type == 'input'
|
||||
{type == 'input'
|
||||
? (
|
||||
<View className="form-list-input">
|
||||
<Input
|
||||
@ -47,11 +45,11 @@ const FromList = memo((props: ListParams) => {
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
: type == 'textarea'
|
||||
)
|
||||
: 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>}
|
||||
@ -65,7 +63,6 @@ const FromList = memo((props: ListParams) => {
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const A = () => {}
|
||||
export default FromList
|
||||
export default memo(FromList)
|
||||
|
||||
@ -16,9 +16,7 @@ interface ListParams {
|
||||
required?: boolean
|
||||
showIcon?: boolean // 是否显示右边的箭头,type=select
|
||||
}
|
||||
|
||||
// 表单列表
|
||||
const FromList = memo((props: ListParams) => {
|
||||
const FromListCertification = (props: ListParams) => {
|
||||
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false, showIcon = true } = props
|
||||
|
||||
return (
|
||||
@ -29,7 +27,7 @@ const FromList = memo((props: ListParams) => {
|
||||
<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'
|
||||
{type == 'input'
|
||||
? (
|
||||
<View className="From-list-certification-input">
|
||||
<Input
|
||||
@ -46,11 +44,11 @@ const FromList = memo((props: ListParams) => {
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
: type == 'textarea'
|
||||
)
|
||||
: 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>}
|
||||
@ -62,7 +60,6 @@ const FromList = memo((props: ListParams) => {
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const A = () => {}
|
||||
export default FromList
|
||||
export default memo(FromListCertification)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
@ -10,20 +10,22 @@ interface Params {
|
||||
fetchData: (data: object) => any
|
||||
change?: (data: any) => void
|
||||
}
|
||||
|
||||
export default (props: Params) => {
|
||||
const InfiniteScrollPaging = (props: Params) => {
|
||||
const { query = {} } = props
|
||||
useEffect(() => {
|
||||
refreshDataRef.current = refreshData
|
||||
dataRef.current = data
|
||||
getData({ moreStatus: true }, { moreStatus: true })
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
if (!isEmptyObject(query)) {
|
||||
setData({ list: [], total: 0 })
|
||||
getData({ moreStatus: true }, { moreStatus: true })
|
||||
}
|
||||
}, [query])
|
||||
const refreshDataRef = useRef({})
|
||||
// 渲染(数据)
|
||||
const [data, setData] = useState({
|
||||
list: [],
|
||||
total: 0,
|
||||
})
|
||||
// 加载刷新数据
|
||||
const [refreshData, setRefreshData] = useState({
|
||||
refreshStatus: false,
|
||||
moreStatus: false,
|
||||
page: 1,
|
||||
size: 10,
|
||||
loading: false,
|
||||
})
|
||||
const getData = async(startStatus, endStatus) => {
|
||||
const tRefreshDataRef = refreshDataRef.current as any
|
||||
setRefreshData({
|
||||
@ -45,7 +47,7 @@ export default (props: Params) => {
|
||||
...endStatus,
|
||||
loading: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
setData({
|
||||
list: result.data.list,
|
||||
@ -59,7 +61,7 @@ export default (props: Params) => {
|
||||
loading: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.none(result.msg)
|
||||
setRefreshData({
|
||||
@ -70,20 +72,7 @@ export default (props: Params) => {
|
||||
})
|
||||
}
|
||||
}
|
||||
// 加载刷新数据
|
||||
const [refreshData, setRefreshData] = useState({
|
||||
refreshStatus: false,
|
||||
moreStatus: false,
|
||||
page: 1,
|
||||
size: 10,
|
||||
loading: false,
|
||||
})
|
||||
const refreshDataRef = useRef({})
|
||||
// 渲染(数据)
|
||||
const [data, setData] = useState({
|
||||
list: [],
|
||||
total: 0,
|
||||
})
|
||||
|
||||
const dataRef = useRef({})
|
||||
// 下拉刷新
|
||||
const handleRefresh = async() => {
|
||||
@ -119,7 +108,17 @@ export default (props: Params) => {
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: data.list, total: data.total, status: refreshData.loading })
|
||||
}, [refreshData.loading])
|
||||
|
||||
useEffect(() => {
|
||||
refreshDataRef.current = refreshData
|
||||
dataRef.current = data
|
||||
getData({ moreStatus: true }, { moreStatus: true })
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
if (!isEmptyObject(query)) {
|
||||
setData({ list: [], total: 0 })
|
||||
getData({ moreStatus: true }, { moreStatus: true })
|
||||
}
|
||||
}, [query])
|
||||
return (
|
||||
<InfiniteScroll
|
||||
refresherEnabled
|
||||
@ -127,9 +126,11 @@ export default (props: Params) => {
|
||||
moreStatus={refreshData.moreStatus}
|
||||
selfOnRefresherRefresh={handleRefresh}
|
||||
selfonScrollToLower={handleMoreLoad}
|
||||
statusMore={statusMore}
|
||||
statusMore={statusMore}
|
||||
>
|
||||
{props.children}
|
||||
</InfiniteScroll>
|
||||
)
|
||||
}
|
||||
|
||||
export default InfiniteScrollPaging
|
||||
|
||||
@ -18,14 +18,14 @@ interface Param {
|
||||
round?: boolean
|
||||
name?: string
|
||||
}
|
||||
export default memo(({ value, onClick, showStatus = false, round = false, name = '' }: Param) => {
|
||||
const LabAndImg = ({ value, onClick, showStatus = false, round = false, name = '' }: Param) => {
|
||||
const [imgs, setImgs] = useState<string>('')
|
||||
|
||||
// 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 {
|
||||
return null
|
||||
}
|
||||
@ -64,7 +64,7 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
||||
src={imgs}
|
||||
onError={e => checkLoad(e)}
|
||||
className={styles.labAndImg_image}
|
||||
style={{ borderRadius: round ? '50%' : '' }}
|
||||
style={{ borderRadius: round ? '50%' : '' }}
|
||||
></Image>
|
||||
)}
|
||||
{!value.texture_url && rgbStyle && <View className={styles.boxColor} style={{ ...rgbStyle, borderRadius: round ? '50%' : '' }}></View>}
|
||||
@ -76,4 +76,5 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
||||
<LabAndImgShow value={value} show={labAndImgShow} onClose={closeLabAndImgShow} />
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(LabAndImg)
|
||||
|
||||
@ -15,20 +15,14 @@ export interface colorParams {
|
||||
onClose?: () => void
|
||||
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) }
|
||||
}, [show])
|
||||
|
||||
const LabAndImgShow = ({ value, show = false, onClose, showNumber = 1 }: colorParams) => {
|
||||
// 显示颜色
|
||||
const [labShow, setLabShow] = useState(false)
|
||||
// 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 {
|
||||
return null
|
||||
}
|
||||
@ -49,7 +43,11 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
||||
urls: n_res,
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (show && rgbStyle) { setLabShow(() => true) }
|
||||
if (show && value?.texture_url) { onShowImage() }
|
||||
if (!show) { setLabShow(() => false) }
|
||||
}, [show])
|
||||
return (
|
||||
<>
|
||||
{labShow && (
|
||||
@ -63,3 +61,5 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default LabAndImgShow
|
||||
|
||||
@ -8,12 +8,12 @@ interface Params{
|
||||
}
|
||||
|
||||
// 消息提示
|
||||
const Message = memo((props: Params) => {
|
||||
const Message = (props: Params) => {
|
||||
return (
|
||||
<View className="message-custom-tips">
|
||||
<Text className="iconfont icon-zhuyi"></Text> {props.text}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default Message
|
||||
export default memo(Message)
|
||||
|
||||
@ -14,7 +14,7 @@ interface ReasonInfoParam {
|
||||
onClose?: () => void // 关闭
|
||||
onAdd?: (val: any) => void
|
||||
}
|
||||
export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
|
||||
const AddCollection = ({ show = false, onClose, onAdd }: ReasonInfoParam) => {
|
||||
// 获取列表
|
||||
const [list, setList] = useState([])
|
||||
const { fetchData: fetchDataList } = FavoriteListApi()
|
||||
@ -42,8 +42,8 @@ export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
|
||||
</View>
|
||||
</View>
|
||||
<ScrollView scrollY className={styles.scrollView}>
|
||||
{list?.map((item: any) => (
|
||||
<View onClick={() => onAdd?.(item)} className={styles.collection_item}>
|
||||
{list?.map((item: any, index) => (
|
||||
<View key={index} onClick={() => onAdd?.(item)} className={styles.collection_item}>
|
||||
<View className={styles.name}>
|
||||
{item.name}
|
||||
<Text>({item.product_color_list?.length || 0})</Text>
|
||||
@ -55,4 +55,5 @@ export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(AddCollection)
|
||||
|
||||
@ -27,8 +27,7 @@ interface AddresParam {
|
||||
parent_id?: number
|
||||
|
||||
}
|
||||
|
||||
export default memo(({
|
||||
const Address = ({
|
||||
addressOnSelect,
|
||||
addressOnChange,
|
||||
addressOnClose,
|
||||
@ -64,52 +63,22 @@ export default memo(({
|
||||
|
||||
// 获取地址
|
||||
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')
|
||||
}
|
||||
// 获取省市区宽度
|
||||
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)
|
||||
}
|
||||
|
||||
// 地址数据
|
||||
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 getProvince = async() => {
|
||||
const res = await fetchData({ parent_id: 1 })
|
||||
@ -160,28 +129,54 @@ export default memo(({
|
||||
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 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 selectTab = (index) => {
|
||||
onSelectIndex(index)
|
||||
getDomDes(`#address_tab_${index}`)
|
||||
}
|
||||
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 && selectArr.length > 0) { addressOnChange?.(selectArr) }
|
||||
}, [selectArr])
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -200,9 +195,9 @@ export default memo(({
|
||||
<View className={styles.address_list}>
|
||||
<ScrollView scrollY className={styles.address_scroll}>
|
||||
<View className={styles.address_scroll_list}>
|
||||
{list.map((item) => {
|
||||
{list.map((item, index) => {
|
||||
return (
|
||||
<View onClick={() => selectItem(item)} className={classnames(styles.address_list_item, { [styles.addresst_select]: (selectId == item.id) })}>
|
||||
<View key={index} 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>
|
||||
@ -215,4 +210,5 @@ export default memo(({
|
||||
</Drawer>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(Address)
|
||||
|
||||
@ -19,8 +19,7 @@ interface Param {
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
fixedBottom?: true | false // 是否固定在底部
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
const AfterOrderBtns = ({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
// 售后订单状态
|
||||
const { ReturnStageApplying, ReturnStageWaitCheck, ReturnStageReturned, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund }
|
||||
= AFTER_ORDER_STATUS
|
||||
@ -90,19 +89,6 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
})
|
||||
}, [orderInfo])
|
||||
|
||||
// 点击按钮操作
|
||||
const submitBtns = throttle((val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder({ title: '要取消退货吗?', val })
|
||||
}
|
||||
else if (val == 6) {
|
||||
cancelOrder({ title: '要取消退款吗?', val })
|
||||
}
|
||||
else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 600)
|
||||
|
||||
// 取消退货/退款
|
||||
const { fetchData: returnApplyOrderCancelFetchData } = ReturnApplyOrderCancelApi()
|
||||
const cancelOrder = ({ title = '', val }) => {
|
||||
@ -114,18 +100,29 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(val)
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 点击按钮操作
|
||||
const submitBtns = throttle((val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder({ title: '要取消退货吗?', val })
|
||||
}
|
||||
else if (val == 6) {
|
||||
cancelOrder({ title: '要取消退款吗?', val })
|
||||
}
|
||||
else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 600)
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
@ -174,4 +171,5 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
)}
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(AfterOrderBtns)
|
||||
|
||||
@ -8,7 +8,7 @@ interface Param {
|
||||
number: number // 数字
|
||||
status: 0|1|2 // 0 小型,1中型,2大
|
||||
}
|
||||
export default memo(({ number = 0, status = 1 }: Param) => {
|
||||
const AmountShow = ({ number = 0, status = 1 }: Param) => {
|
||||
const priceDom = useCallback(() => {
|
||||
const res = number.toFixed(2).split('.')
|
||||
const int_num = `${parseInt(res[0])}`
|
||||
@ -26,4 +26,5 @@ export default memo(({ number = 0, status = 1 }: Param) => {
|
||||
{priceDom()}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(AmountShow)
|
||||
|
||||
@ -12,16 +12,12 @@ interface params {
|
||||
swiperOnClick?: (val: item) => void
|
||||
style?: Object
|
||||
}
|
||||
export default (props: params) => {
|
||||
const Banner = (props: params) => {
|
||||
const { swiperOnClick, style = {} } = props
|
||||
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const { fetchData, state } = GetBannerList()
|
||||
|
||||
useEffect(() => {
|
||||
getData()
|
||||
}, [])
|
||||
|
||||
const getData = async() => {
|
||||
const res = await fetchData()
|
||||
setList(res.data?.list)
|
||||
@ -30,7 +26,7 @@ export default (props: params) => {
|
||||
const skipTo = (item) => {
|
||||
if (item.jump_type == 2 || item.jump_type == 0) {
|
||||
goLink(`${item.link}&title=${item.title}`)
|
||||
}
|
||||
}
|
||||
else {
|
||||
goLink(item.link)
|
||||
}
|
||||
@ -39,7 +35,9 @@ export default (props: params) => {
|
||||
const showDot = useMemo(() => {
|
||||
return list.length > 1
|
||||
}, [list])
|
||||
|
||||
useEffect(() => {
|
||||
getData()
|
||||
}, [])
|
||||
return (
|
||||
<View className={styles.swiper_con} style={style}>
|
||||
<Swiper className={styles.xswiper} indicatorColor="#ccc" indicatorActiveColor="#fff" circular indicatorDots={showDot} autoplay>
|
||||
@ -56,3 +54,5 @@ export default (props: params) => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Banner
|
||||
|
||||
@ -8,7 +8,7 @@ interface params {
|
||||
show?: true|false
|
||||
onClose?: () => void
|
||||
}
|
||||
export default ({ show, onClose }: params) => {
|
||||
const BindSalesmanPopup = ({ show, onClose }: params) => {
|
||||
const onCustomer = async() => {
|
||||
const res = await Taro.showModal({
|
||||
title: '是否拨打服务热线',
|
||||
@ -46,5 +46,7 @@ export default ({ show, onClose }: params) => {
|
||||
<View className={styles.bindSalesman_mask} onClick={onClose}></View>
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default BindSalesmanPopup
|
||||
|
||||
@ -8,7 +8,7 @@ import SearchInput from '@/components/searchInput'
|
||||
import Popup from '@/components/bluetooth/Popup'
|
||||
import useCheckAuthorize from '@/use/useCheckAuthorize'
|
||||
|
||||
export default memo(() => {
|
||||
const LinkBlueTooth = () => {
|
||||
const { state, init, startScan, connect, disconnect } = useBluetooth()
|
||||
|
||||
const { check } = useCheckAuthorize({ scope: 'scope.bluetooth', msg: '请开启小程序蓝牙权限' })
|
||||
@ -21,10 +21,10 @@ export default memo(() => {
|
||||
useEffect(() => {
|
||||
if (!state.available) {
|
||||
setLinkStatus(1)
|
||||
}
|
||||
}
|
||||
else if (state.available && state.connected?.name) {
|
||||
setLinkStatus(3)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setLinkStatus(2)
|
||||
}
|
||||
@ -40,6 +40,9 @@ export default memo(() => {
|
||||
}
|
||||
|
||||
const [popupShow, setPopupShow] = useState(false)
|
||||
const onFindEven = () => {
|
||||
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
|
||||
}
|
||||
// 显示设备列表
|
||||
const onFindDevice = () => {
|
||||
check().then((res) => {
|
||||
@ -48,16 +51,13 @@ export default memo(() => {
|
||||
title: '请打开手机蓝牙',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
setPopupShow(true)
|
||||
onFindEven()
|
||||
}
|
||||
})
|
||||
}
|
||||
const onFindEven = () => {
|
||||
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
|
||||
}
|
||||
|
||||
// 断开链接
|
||||
const onDisconnect = () => {
|
||||
@ -72,9 +72,11 @@ export default memo(() => {
|
||||
<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>
|
||||
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> : null
|
||||
}
|
||||
</View>
|
||||
</SearchInput>
|
||||
@ -89,5 +91,6 @@ export default memo(() => {
|
||||
</View>
|
||||
</>
|
||||
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
export default memo(LinkBlueTooth)
|
||||
|
||||
@ -12,8 +12,7 @@ interface params {
|
||||
onOff: () => void
|
||||
onFind: () => void
|
||||
}
|
||||
|
||||
export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
|
||||
const Bluetooth = ({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
|
||||
const [popupShow, setPopupShow] = useState(show)
|
||||
useEffect(() => {
|
||||
setPopupShow(show)
|
||||
@ -31,38 +30,46 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
|
||||
<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>
|
||||
}
|
||||
(state.devices && state.devices.length > 0)
|
||||
? state?.devices.map((item, key) => {
|
||||
return (
|
||||
<View key={key} 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>
|
||||
: null
|
||||
}
|
||||
</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>
|
||||
</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>
|
||||
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>
|
||||
@ -70,4 +77,5 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(Bluetooth)
|
||||
|
||||
@ -9,14 +9,14 @@ interface params {
|
||||
status?: false | true // 是否选中
|
||||
disabled?: false | true // 是否禁用
|
||||
}
|
||||
export default forwardRef(({ onSelect, onClose, status = false, disabled = false }: params, ref) => {
|
||||
const Checkbox = ({ onSelect, onClose, status = false, disabled = false }: params, ref) => {
|
||||
const [selected, SetSelected] = useState(false)
|
||||
const onSelectEven = () => {
|
||||
if (disabled) { return false }
|
||||
const res = !selected
|
||||
if (res) {
|
||||
onSelect?.()
|
||||
}
|
||||
}
|
||||
else {
|
||||
onClose?.()
|
||||
}
|
||||
@ -37,4 +37,5 @@ export default forwardRef(({ onSelect, onClose, status = false, disabled = false
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default forwardRef(Checkbox)
|
||||
|
||||
@ -6,8 +6,7 @@ interface Params {
|
||||
onClose?: () => void
|
||||
styleObj?: Object
|
||||
}
|
||||
|
||||
export default memo(({ onClose, styleObj = {} }: Params) => {
|
||||
const CloseBtn = ({ onClose, styleObj = {} }: Params) => {
|
||||
return (
|
||||
<View
|
||||
style={styleObj}
|
||||
@ -17,4 +16,5 @@ export default memo(({ onClose, styleObj = {} }: Params) => {
|
||||
<Text className={`iconfont icon-qingkong ${style.icon_a_btn}`}></Text>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(CloseBtn)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
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'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
interface params {
|
||||
minNum?: number // 最小值
|
||||
@ -16,11 +16,8 @@ interface params {
|
||||
disabled?: true | false // 是否禁用
|
||||
returnZero?: true | false // 少于最小值时是否归0
|
||||
}
|
||||
export default memo((props: params) => {
|
||||
return <Counter {...props}></Counter>
|
||||
})
|
||||
|
||||
const Counter = memo((props: params) => {
|
||||
const CounterDisplayName = (props: params) => {
|
||||
const {
|
||||
minNum = 0,
|
||||
maxNum = 10000,
|
||||
@ -35,6 +32,22 @@ const Counter = memo((props: params) => {
|
||||
disabled = false,
|
||||
} = props
|
||||
const [value, setValue] = useState<any>({ count: defaultNum })
|
||||
// 保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = `${num}`
|
||||
if (num.includes('.')) {
|
||||
const res = num.split('.')
|
||||
if (digits > 0) {
|
||||
const last_num = res[1].substr(0, digits)
|
||||
return `${res[0]}.${last_num}`
|
||||
}
|
||||
else {
|
||||
return res[0]
|
||||
}
|
||||
}
|
||||
|
||||
return parseFloat(num)
|
||||
}
|
||||
useEffect(() => {
|
||||
setValue({ count: defaultNum })
|
||||
}, [defaultNum])
|
||||
@ -54,7 +67,7 @@ const Counter = memo((props: params) => {
|
||||
let num_res = Big(count).minus(step).toNumber()
|
||||
if (returnZero) {
|
||||
num_res = num_res < minNum ? 0 : num_res
|
||||
}
|
||||
}
|
||||
else {
|
||||
num_res = num_res < minNum ? minNum : num_res
|
||||
}
|
||||
@ -63,23 +76,6 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
|
||||
// 保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = `${num}`
|
||||
if (num.includes('.')) {
|
||||
const res = num.split('.')
|
||||
if (digits > 0) {
|
||||
const last_num = res[1].substr(0, digits)
|
||||
return `${res[0]}.${last_num}`
|
||||
}
|
||||
else {
|
||||
return res[0]
|
||||
}
|
||||
}
|
||||
|
||||
return parseFloat(num)
|
||||
}
|
||||
|
||||
// 检查数据
|
||||
const checkData = (val) => {
|
||||
const num = parseFloat(val)
|
||||
@ -92,19 +88,19 @@ const Counter = memo((props: params) => {
|
||||
const res = e.detail.value
|
||||
if (res === '') {
|
||||
onChange?.(minNum)
|
||||
}
|
||||
else if (!isNaN(Number(res))) {
|
||||
}
|
||||
else if (!Number.isNaN(Number(res))) {
|
||||
let count = formatDigits(res)
|
||||
count = checkData(count)
|
||||
onChange?.(parseFloat(count as string))
|
||||
}
|
||||
}
|
||||
else {
|
||||
const num = parseFloat(res)
|
||||
if (!isNaN(num)) {
|
||||
if (!Number.isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
onChange?.(count as number)
|
||||
}
|
||||
}
|
||||
else {
|
||||
onChange?.(defaultNum)
|
||||
}
|
||||
@ -116,13 +112,13 @@ const Counter = memo((props: params) => {
|
||||
if (e.detail.value == '') {
|
||||
onBlue?.(minNum)
|
||||
setValue({ count: minNum })
|
||||
}
|
||||
else if (!isNaN(num)) {
|
||||
}
|
||||
else if (!Number.isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
setValue({ count })
|
||||
onBlue?.(count as number)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setValue({ count: minNum })
|
||||
onBlue?.(minNum)
|
||||
@ -142,4 +138,9 @@ const Counter = memo((props: params) => {
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
const Counter = memo(CounterDisplayName)
|
||||
const CounterWithMemo = (props: params) => {
|
||||
return <Counter {...props}></Counter>
|
||||
}
|
||||
export default memo(CounterWithMemo)
|
||||
|
||||
@ -2,7 +2,7 @@ import { View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
export default memo(() => {
|
||||
const DotLoading = () => {
|
||||
return (
|
||||
<>
|
||||
<View className={styles.load_box}>
|
||||
@ -14,4 +14,5 @@ export default memo(() => {
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(DotLoading)
|
||||
|
||||
@ -17,7 +17,7 @@ interface Param {
|
||||
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 EstimeatedAmount = ({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number' }: Param) => {
|
||||
const [show, setShow] = useState(messageShow)
|
||||
const onClose = () => {
|
||||
setShow(false)
|
||||
@ -28,14 +28,6 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
|
||||
|
||||
const [style, setStyle] = useState<{ top: string }>()
|
||||
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
getDomDes('#message')
|
||||
}
|
||||
else {
|
||||
setStyle(() => ({ top: '0' }))
|
||||
}
|
||||
}, [show])
|
||||
// 设置弹出层高度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
@ -46,6 +38,14 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
|
||||
}).exec()
|
||||
}, 0)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
getDomDes('#message')
|
||||
}
|
||||
else {
|
||||
setStyle(() => ({ top: '0' }))
|
||||
}
|
||||
}, [show])
|
||||
return (
|
||||
<>
|
||||
<View className={styles.order_price}>
|
||||
@ -62,4 +62,5 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(EstimeatedAmount)
|
||||
|
||||
@ -11,7 +11,7 @@ type params = {
|
||||
onFiltr?: (val: object) => void // 确定搜索
|
||||
onRest?: (val: Object) => void // 重置
|
||||
} & PopuParams
|
||||
export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
const Filter = ({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
// 搜索条件
|
||||
const [filterObj, setFilterObj] = useState({
|
||||
seriesName: '',
|
||||
@ -145,4 +145,5 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(Filter)
|
||||
|
||||
@ -4,13 +4,13 @@ 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 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 FilterV2 = ({ onClose, onFiltr, show = false }: params) => {
|
||||
// 搜索条件
|
||||
const [filterObj, setFilterObj] = useState({
|
||||
seriesId: '',
|
||||
@ -64,9 +64,9 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
const setNumber = (e, field) => {
|
||||
console.log(e)
|
||||
const num = parseFloat(e.detail.value)
|
||||
if (isNaN(num)) {
|
||||
if (Number.isNaN(num)) {
|
||||
filterObj[field] = null
|
||||
}
|
||||
}
|
||||
else {
|
||||
filterObj[field] = parseFloat(num.toFixed(2))
|
||||
}
|
||||
@ -90,7 +90,7 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
<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>
|
||||
@ -167,3 +167,5 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
</Popup>
|
||||
)
|
||||
}
|
||||
|
||||
export default FilterV2
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import type { ReactNode } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useMemo, useState } from 'react'
|
||||
import LoadingCard from '../loadingCard'
|
||||
import style from './index.module.scss'
|
||||
@ -25,7 +25,7 @@ interface Params {
|
||||
refresherTriggered?: true|false
|
||||
refresherEnabled?: true|false
|
||||
}
|
||||
export default memo(({
|
||||
const InfiniteScroll = ({
|
||||
styleObj,
|
||||
selfonScrollToLower,
|
||||
selfOnScrollToUpper,
|
||||
@ -91,28 +91,31 @@ export default memo(({
|
||||
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="暂无数据" />}
|
||||
</>}
|
||||
{!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>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(InfiniteScroll)
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo, useMemo } from 'react'
|
||||
import style from './index.module.scss'
|
||||
import style from './index.module.scss'
|
||||
|
||||
export default memo(({ width = 60, color = '#6190e8' }: { width?: number; color?: string }) => {
|
||||
const Loading = ({ 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
|
||||
return obj
|
||||
}, [width, color])
|
||||
console.log('loading:::')
|
||||
return (
|
||||
@ -18,5 +18,6 @@ export default memo(({ width = 60, color = '#6190e8' }: { width?: number; color?
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
export default memo(Loading)
|
||||
|
||||
@ -8,7 +8,7 @@ interface Params {
|
||||
title?: string
|
||||
loadingIcon?: false|true
|
||||
}
|
||||
export default memo(({
|
||||
const LoadingCard = ({
|
||||
styleLoading = {},
|
||||
title = '加载中...', // 显示的文字
|
||||
loadingIcon = true, // 是否显示加载图标
|
||||
@ -22,4 +22,5 @@ export default memo(({
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(LoadingCard)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { MovableArea, MovableView, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, useReady, useRouter } from '@tarojs/taro'
|
||||
import type { ReactElement } from 'react'
|
||||
import type { ReactElement } from 'react'
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
@ -12,7 +12,7 @@ interface param {
|
||||
children?: ReactElement | null
|
||||
onClick?: () => void
|
||||
}
|
||||
export default ({ children = null, onClick }: param) => {
|
||||
const MoveBtn = ({ children = null, onClick }: param) => {
|
||||
// 获取购物车数据数量
|
||||
const { getShopCount, commonData } = useCommonData()
|
||||
|
||||
@ -45,7 +45,7 @@ export default ({ children = null, onClick }: param) => {
|
||||
inertia
|
||||
x="630rpx"
|
||||
y={`${screenHeight}rpx`}
|
||||
onTouchEnd={e => dragEnd(e)}
|
||||
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>}
|
||||
@ -53,3 +53,5 @@ export default ({ children = null, onClick }: param) => {
|
||||
</MovableArea>
|
||||
)
|
||||
}
|
||||
|
||||
export default MoveBtn
|
||||
|
||||
@ -25,8 +25,7 @@ interface Param {
|
||||
showStatus?: 'detail' | 'list' // 订单详情,订单列表
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
const OrderBtns = ({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
// 订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
@ -161,28 +160,6 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
const { ApplyGoods } = SUBSCRIPTION_MESSAGE_SCENE
|
||||
const { openSubscriptionMessage } = UseSubscriptionMessage()
|
||||
|
||||
// 点击按钮操作
|
||||
const submitBtns = throttle(async(val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder()
|
||||
}
|
||||
else if (val == 6) {
|
||||
receiveOrder()
|
||||
}
|
||||
else if (val == 5) {
|
||||
applyProduct()
|
||||
}
|
||||
else if (val == 3) {
|
||||
bigApplyRefurn()
|
||||
}
|
||||
else if (val == 8) {
|
||||
applyRefund()
|
||||
}
|
||||
else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 800)
|
||||
|
||||
// 大货申请退款
|
||||
const bigApplyRefurn = () => {
|
||||
Taro.showModal({
|
||||
@ -191,7 +168,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
if (res.confirm) {
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
onClick?.(3)
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
@ -210,11 +187,11 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
@ -234,12 +211,12 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
if (res.success) {
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
@ -259,13 +236,13 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
const res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('申请成功')
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.error('申请失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
onClick?.(8)
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
@ -285,7 +262,27 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
// 点击按钮操作
|
||||
const submitBtns = throttle(async(val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder()
|
||||
}
|
||||
else if (val == 6) {
|
||||
receiveOrder()
|
||||
}
|
||||
else if (val == 5) {
|
||||
applyProduct()
|
||||
}
|
||||
else if (val == 3) {
|
||||
bigApplyRefurn()
|
||||
}
|
||||
else if (val == 8) {
|
||||
applyRefund()
|
||||
}
|
||||
else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 800)
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{orderBtnsShowList.length > 3 && (
|
||||
@ -321,4 +318,5 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(OrderBtns)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import type { ReactNode } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useEffect, useMemo, useRef } from 'react'
|
||||
import style from './index.module.scss'
|
||||
import CloseBtnIcon from '@/components/closeBtn'
|
||||
@ -16,7 +16,7 @@ export interface Params {
|
||||
position?: 'bottom'|'top'|'right' // 弹出位置
|
||||
animationEnd?: () => void // 弹出动画结束
|
||||
}
|
||||
export default memo((
|
||||
const Popup = (
|
||||
{
|
||||
title = '标题',
|
||||
show = false,
|
||||
@ -26,14 +26,14 @@ export default memo((
|
||||
children,
|
||||
position = 'bottom',
|
||||
animationEnd,
|
||||
}: Params) => {
|
||||
}: Params) => {
|
||||
const animationTime = useRef<any>(null)
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
animationTime.current = setTimeout(() => {
|
||||
animationEnd?.()
|
||||
}, 260)
|
||||
}
|
||||
}
|
||||
else {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
@ -72,4 +72,5 @@ export default memo((
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(Popup)
|
||||
|
||||
@ -10,7 +10,7 @@ interface Params {
|
||||
desStatus?: true | false
|
||||
productList?: any[]
|
||||
}
|
||||
export default ({ desStatus = true, productList = [] }: Params) => {
|
||||
const Product = ({ desStatus = true, productList = [] }: Params) => {
|
||||
const labAndImgObj = useCallback(
|
||||
(item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
@ -21,7 +21,7 @@ export default ({ desStatus = true, productList = [] }: Params) => {
|
||||
<View className={styles.products_list}>
|
||||
{productList?.map((item) => {
|
||||
return (
|
||||
<View className={styles.products_item} onClick={() => goLink(`/pages/details/index?id=${item.id}`)}>
|
||||
<View key={item.id} className={styles.products_item} onClick={() => goLink(`/pages/details/index?id=${item.id}`)}>
|
||||
<View className={styles.item_img}>
|
||||
<LabAndImg value={labAndImgObj(item)} />
|
||||
<View className={styles.num}>{item.product_color_count}色</View>
|
||||
@ -44,3 +44,5 @@ export default ({ desStatus = true, productList = [] }: Params) => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Product
|
||||
|
||||
@ -20,99 +20,95 @@ interface Params {
|
||||
defaultValue?: string
|
||||
borderRadius?: string
|
||||
}
|
||||
const Search = (
|
||||
{
|
||||
clickOnSearch, // 点击筛选按钮触发
|
||||
changeOnSearch, // 输入文字触发
|
||||
disabled = false, // 是否禁用
|
||||
placeholder = '输入搜索内容',
|
||||
showIcon = true, // 是否显示关闭图标
|
||||
showBtn = false, // 是否显示搜索按钮
|
||||
btnStyle = {},
|
||||
placeIcon = 'inner', // 搜索图标位置:inner在里面,out在外面
|
||||
btnTitle = '搜索', // 搜索文字
|
||||
debounceTime = 0, // 防抖时间,不设默认为零
|
||||
defaultValue = '', // 默认值
|
||||
borderRadius = '50rpx',
|
||||
}: Params,
|
||||
ref,
|
||||
) => {
|
||||
const [inputCon, setInputCon] = useState('')
|
||||
const debounceTimeRef = useRef(0)
|
||||
useEffect(() => {
|
||||
setInputCon(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
useEffect(() => {
|
||||
debounceTimeRef.current = debounceTime
|
||||
}, [debounceTime])
|
||||
|
||||
const clearInput = () => {
|
||||
setInputCon('')
|
||||
changeOnSearch?.('')
|
||||
}
|
||||
|
||||
const changeData = debounce((value) => {
|
||||
setInputCon(value)
|
||||
changeOnSearch?.(value)
|
||||
}, debounceTimeRef.current)
|
||||
const onInputEven = (e) => {
|
||||
const value = e.detail.value
|
||||
changeData(value)
|
||||
}
|
||||
const onSearch = () => {
|
||||
clickOnSearch?.(inputCon)
|
||||
}
|
||||
useImperativeHandle(ref, () => ({
|
||||
clearInput,
|
||||
}))
|
||||
return (
|
||||
<>
|
||||
<View className={styles.search_main}>
|
||||
<View className={styles.search_con}>
|
||||
{showIcon && (
|
||||
<View
|
||||
className={classnames(
|
||||
'iconfont',
|
||||
'icon-sousuo',
|
||||
styles.icon_a_sousuo1_self,
|
||||
placeIcon == 'inner' ? styles.icon_inner : styles.icon_out,
|
||||
)}
|
||||
></View>
|
||||
)}
|
||||
<Input
|
||||
style={{ borderRadius }}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
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>
|
||||
{!!inputCon && (
|
||||
<View className={styles.search_closeBtn}>
|
||||
<CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
{showBtn && (
|
||||
<View style={btnStyle} className={styles.btn} onClick={onSearch}>
|
||||
{btnTitle}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default memo(
|
||||
forwardRef(
|
||||
(
|
||||
{
|
||||
clickOnSearch, // 点击筛选按钮触发
|
||||
changeOnSearch, // 输入文字触发
|
||||
disabled = false, // 是否禁用
|
||||
placeholder = '输入搜索内容',
|
||||
showIcon = true, // 是否显示关闭图标
|
||||
showBtn = false, // 是否显示搜索按钮
|
||||
btnStyle = {},
|
||||
placeIcon = 'inner', // 搜索图标位置:inner在里面,out在外面
|
||||
btnTitle = '搜索', // 搜索文字
|
||||
debounceTime = 0, // 防抖时间,不设默认为零
|
||||
defaultValue = '', // 默认值
|
||||
borderRadius = '50rpx',
|
||||
}: Params,
|
||||
ref,
|
||||
) => {
|
||||
const [inputCon, setInputCon] = useState('')
|
||||
const debounceTimeRef = useRef(0)
|
||||
useEffect(() => {
|
||||
setInputCon(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
useEffect(() => {
|
||||
debounceTimeRef.current = debounceTime
|
||||
}, [debounceTime])
|
||||
|
||||
const onInputEven = (e) => {
|
||||
const value = e.detail.value
|
||||
changeData(value)
|
||||
}
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
clearInput,
|
||||
}))
|
||||
|
||||
const clearInput = () => {
|
||||
setInputCon('')
|
||||
changeOnSearch?.('')
|
||||
}
|
||||
|
||||
const changeData = debounce((value) => {
|
||||
setInputCon(value)
|
||||
changeOnSearch?.(value)
|
||||
}, debounceTimeRef.current)
|
||||
|
||||
const onSearch = () => {
|
||||
clickOnSearch?.(inputCon)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.search_main}>
|
||||
<View className={styles.search_con}>
|
||||
{showIcon && (
|
||||
<View
|
||||
className={classnames(
|
||||
'iconfont',
|
||||
'icon-sousuo',
|
||||
styles.icon_a_sousuo1_self,
|
||||
placeIcon == 'inner' ? styles.icon_inner : styles.icon_out,
|
||||
)}
|
||||
></View>
|
||||
)}
|
||||
<Input
|
||||
style={{ borderRadius }}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
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>
|
||||
{!!inputCon && (
|
||||
<View className={styles.search_closeBtn}>
|
||||
<CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
{showBtn && (
|
||||
<View style={btnStyle} className={styles.btn} onClick={onSearch}>
|
||||
{btnTitle}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
},
|
||||
Search,
|
||||
),
|
||||
)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Input, View } from '@tarojs/components'
|
||||
import type { ReactNode } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { ReactHTMLElement, memo, useDebugValue, useMemo } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
@ -17,8 +17,7 @@ interface Params {
|
||||
titleStyle?: Object
|
||||
styleObj?: Object
|
||||
}
|
||||
|
||||
export default memo((props: Params) => {
|
||||
const SearchInput = (props: Params) => {
|
||||
const {
|
||||
showTitle = true,
|
||||
title = '标题',
|
||||
@ -60,4 +59,5 @@ export default memo((props: Params) => {
|
||||
{showIcon && <View className={`iconfont icon-jiantou ${styles.icon_more_self}`}></View>}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(SearchInput)
|
||||
|
||||
@ -7,7 +7,7 @@ import MCheckbox from '@/components/checkbox'
|
||||
import Counter from '@/components/counter'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import type { saleModeType } from '@/common/enum'
|
||||
import type { saleModeType } from '@/common/enum'
|
||||
|
||||
interface param {
|
||||
sale_model: saleModeType
|
||||
@ -15,8 +15,7 @@ interface param {
|
||||
onChangeCount: (val: any) => any
|
||||
item: any
|
||||
}
|
||||
|
||||
export default memo((props: param) => {
|
||||
const ProductItem = (props: param) => {
|
||||
const { onChangeCount, onChangeSelect, item, sale_model } = props
|
||||
|
||||
const selectCallBack = useCallback(() => {
|
||||
@ -99,4 +98,5 @@ export default memo((props: param) => {
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ProductItem)
|
||||
|
||||
@ -25,7 +25,7 @@ interface param {
|
||||
intoStatus?: 'again' | 'shop'
|
||||
default_sale_mode?: number // 面料类型(0:大货, 1:剪版,2:散剪
|
||||
}
|
||||
export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
|
||||
const ShowCartCopy = ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
|
||||
const selectList = [
|
||||
{ value: 0, title: '大货', unit: '条', eunit: 'kg', step: 1, digits: 0, minNum: 1, maxNum: 100000, defaultNum: 1 },
|
||||
{ value: 1, title: '剪板', unit: '米', eunit: 'm', step: 1, digits: 2, minNum: 0.5, maxNum: 9.99, defaultNum: 1 },
|
||||
@ -56,7 +56,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
list?.map((item) => {
|
||||
if (selectIndex == item.sale_mode || selectIndex == -1) {
|
||||
checkboxData[item.id] = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
checkboxData[item.id] = false
|
||||
}
|
||||
@ -95,7 +95,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
if (!show) {
|
||||
setList([])
|
||||
setSelectIndex(default_sale_mode || 0)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setLoading(true)
|
||||
initStatus.current = true
|
||||
@ -174,14 +174,14 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
title: '成功',
|
||||
icon: 'success',
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
@ -251,14 +251,14 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
getSelectId()
|
||||
if (selectIds.current.length == 0) {
|
||||
alert.error('请选择面料')
|
||||
}
|
||||
}
|
||||
else {
|
||||
const ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
||||
closePopup()
|
||||
if (intoStatus == 'again') {
|
||||
goLink('/pages/order/comfirm', {}, 'redirectTo')
|
||||
}
|
||||
}
|
||||
else {
|
||||
goLink('/pages/order/comfirm')
|
||||
}
|
||||
@ -311,7 +311,7 @@ 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>
|
||||
@ -327,7 +327,7 @@ 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
|
||||
@ -416,3 +416,5 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default ShowCartCopy
|
||||
|
||||
@ -38,7 +38,7 @@ interface modelClassType {
|
||||
defaultNum: number
|
||||
eunit: string
|
||||
}
|
||||
export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
|
||||
const ShopCart = ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
|
||||
const selectList: modelClassType[] = [
|
||||
{ value: 0, title: '大货', unit: '条', eunit: 'kg', step: 1, digits: 0, minNum: 1, maxNum: 100000, defaultNum: 1 },
|
||||
{ value: 1, title: '剪板', unit: '米', eunit: 'm', step: 1, digits: 2, minNum: 0.5, maxNum: 9.99, defaultNum: 1 },
|
||||
@ -58,13 +58,6 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
}
|
||||
}, [default_sale_mode])
|
||||
|
||||
useEffect(() => {
|
||||
startTransition(() => {
|
||||
resetList()
|
||||
setSelectStatus(true)
|
||||
})
|
||||
}, [selectIndex])
|
||||
|
||||
// 获取购物车数据数量
|
||||
const { getShopCount } = useCommonData()
|
||||
|
||||
@ -72,12 +65,6 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
const [list, setList] = useState<Record<number, any>>({})
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { fetchData: getShoppingFetchData } = GetShoppingCartApi()
|
||||
const getShoppingCart = async() => {
|
||||
const { data } = await getShoppingFetchData()
|
||||
const color_list = data.color_list || []
|
||||
initList(color_list)
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
// 更新单条数据
|
||||
const getShoppingCartInfo = async(item) => {
|
||||
@ -106,7 +93,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
// 初始化全部数据默认勾选
|
||||
const initList = (color_list) => {
|
||||
const obj = {}
|
||||
color_list?.map((item) => {
|
||||
color_list?.forEach((item) => {
|
||||
item.selected = selectIndex == item.sale_mode
|
||||
const { unit, eunit, step, digits, minNum, maxNum } = selectList[item.sale_mode]
|
||||
item = { ...item, unit, eunit, step, digits, minNum, maxNum }
|
||||
@ -114,13 +101,18 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
setList(() => ({ ...obj }))
|
||||
}
|
||||
|
||||
const getShoppingCart = async() => {
|
||||
const { data } = await getShoppingFetchData()
|
||||
const color_list = data.color_list || []
|
||||
initList(color_list)
|
||||
setLoading(false)
|
||||
}
|
||||
// 重置勾选数据
|
||||
const resetList = () => {
|
||||
Object.values(list)?.map((item) => {
|
||||
Object.values(list)?.forEach((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
item.selected = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
item.selected = false
|
||||
}
|
||||
@ -129,12 +121,14 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
setList(() => ({ ...list }))
|
||||
}
|
||||
|
||||
// 绑定业务员和电话号码
|
||||
const [showBindSalesman, setShowBindSalesman] = useState(false)
|
||||
// 显示时展示数据
|
||||
useEffect(() => {
|
||||
if (!show) {
|
||||
setList({})
|
||||
setSelectIndex(default_sale_mode || 0)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setLoading(true)
|
||||
getShoppingCart()
|
||||
@ -150,7 +144,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
// 全选反选
|
||||
const [selectStatus, setSelectStatus] = useState(false)
|
||||
const selectAll = () => {
|
||||
Object.values(list)?.map((item) => {
|
||||
Object.values(list)?.forEach((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
item.selected = !selectStatus
|
||||
list[item.id] = { ...item }
|
||||
@ -164,7 +158,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
useEffect(() => {
|
||||
let list_count = 0
|
||||
let select_count = 0
|
||||
Object.values(list)?.map((item) => {
|
||||
Object.values(list)?.forEach((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
list_count++
|
||||
if (item.selected) { select_count++ }
|
||||
@ -172,7 +166,18 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
setSelectStatus(select_count == list_count)
|
||||
}, [list])
|
||||
|
||||
// 计数组件-当后端修改完成才修改前端显示
|
||||
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
||||
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 }))
|
||||
}
|
||||
}, 300)
|
||||
// 修改数量
|
||||
const onChangeCount = useCallback((item) => {
|
||||
getInputValue(item)
|
||||
@ -188,7 +193,16 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
onClose?.()
|
||||
setShowPopup(false)
|
||||
}
|
||||
|
||||
// 获取面料选中的id
|
||||
const selectIds = useRef<number[]>([])
|
||||
const getSelectId = () => {
|
||||
selectIds.current = []
|
||||
Object.values(list)?.forEach((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
item.selected && selectIds.current.push(item.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
// 删除购物车内容
|
||||
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
||||
const delSelect = () => {
|
||||
@ -206,14 +220,14 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
title: '成功',
|
||||
icon: 'success',
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
@ -221,24 +235,13 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
}
|
||||
|
||||
// 获取面料选中的id
|
||||
const selectIds = useRef<number[]>([])
|
||||
const getSelectId = () => {
|
||||
selectIds.current = []
|
||||
Object.values(list)?.map((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
item.selected && selectIds.current.push(item.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 预估金额和总条数
|
||||
const estimatePrice = useMemo(() => {
|
||||
let estimate_amount = 0
|
||||
const product_list = new Set() // 面料
|
||||
let color_count = 0 // 颜色数量
|
||||
let all_count = 0 // 总数量
|
||||
Object.values(list)?.map((item) => {
|
||||
Object.values(list)?.forEach((item) => {
|
||||
if (item.selected) {
|
||||
estimate_amount += item.estimate_amount
|
||||
product_list.add(item.product_id)
|
||||
@ -256,10 +259,10 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
}, [list])
|
||||
|
||||
// 去结算
|
||||
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
||||
const { fetchData: FetchData } = GetAdminUserInfoApi()
|
||||
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
||||
const orderDetail = throttle(async() => {
|
||||
const res = await useFetchData()
|
||||
const res = await FetchData()
|
||||
if (res.data.order_access_status !== 3) {
|
||||
if (res.data.order_access_status == 1) { applyOrderAccessFetchData() }
|
||||
setShowBindSalesman(() => true)
|
||||
@ -269,36 +272,20 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
getSelectId()
|
||||
if (selectIds.current.length == 0) {
|
||||
alert.error('请选择面料')
|
||||
}
|
||||
}
|
||||
else {
|
||||
const ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
||||
closePopup()
|
||||
if (intoStatus == 'again') {
|
||||
goLink('/pages/order/comfirm', null, 'redirectTo')
|
||||
}
|
||||
}
|
||||
else {
|
||||
goLink('/pages/order/comfirm')
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
|
||||
// 计数组件-当后端修改完成才修改前端显示
|
||||
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
||||
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 }))
|
||||
}
|
||||
}, 300)
|
||||
|
||||
// 绑定业务员和电话号码
|
||||
const [showBindSalesman, setShowBindSalesman] = useState(false)
|
||||
|
||||
// 显示图片弹窗
|
||||
const [showLabImage, setShowLabImage] = useState(false)
|
||||
const [labImageValue, setLabImageValue] = useState()
|
||||
@ -314,7 +301,12 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
onClose?.()
|
||||
goLink('/pages/index/index', null, 'switchTab')
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
startTransition(() => {
|
||||
resetList()
|
||||
setSelectStatus(true)
|
||||
})
|
||||
}, [selectIndex])
|
||||
return (
|
||||
<View className={styles.shop_cart_main}>
|
||||
<Popup showTitle={false} show={showPopup} onClose={() => closePopup()}>
|
||||
@ -333,7 +325,7 @@ 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>
|
||||
@ -346,7 +338,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
<InfiniteScroll moreStatus={false}>
|
||||
<View className={styles.product_list}>
|
||||
{listData?.map((item) => {
|
||||
return <ProductItem sale_model={selectIndex} onChangeCount={onChangeCount} onChangeSelect={onChangeSelect} item={item} />
|
||||
return <ProductItem key={item.id} sale_model={selectIndex} onChangeCount={onChangeCount} onChangeSelect={onChangeSelect} item={item} />
|
||||
})}
|
||||
</View>
|
||||
</InfiniteScroll>
|
||||
@ -388,3 +380,4 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
</View>
|
||||
)
|
||||
}
|
||||
export default ShopCart
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import Taro, { getCurrentInstance, useReady, useRouter } from '@tarojs/taro'
|
||||
import type { ReactNode } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import React, { memo, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import type { StatusParam } from '../infiniteScroll'
|
||||
import type { StatusParam } from '../infiniteScroll'
|
||||
import InfiniteScroll from '../infiniteScroll'
|
||||
import LoadingCard from '../loadingCard'
|
||||
import styles from './index.module.scss'
|
||||
@ -24,136 +24,133 @@ interface Params {
|
||||
statusMore?: StatusParam
|
||||
selectClass?: (val: number) => void
|
||||
}
|
||||
const SideBar = ({
|
||||
list = [],
|
||||
defaultValue = 0,
|
||||
height = '100vh',
|
||||
sideBarOnClick,
|
||||
children,
|
||||
heightItem = 108,
|
||||
refresherTriggered = false,
|
||||
selfOnRefresherRefresh,
|
||||
selfOnScrolltolower,
|
||||
hasMore = true,
|
||||
statusMore = 0,
|
||||
selectClass,
|
||||
}: Params) => {
|
||||
const num_half = useRef(0)
|
||||
|
||||
export default memo(
|
||||
({
|
||||
list = [],
|
||||
defaultValue = 0,
|
||||
height = '100vh',
|
||||
sideBarOnClick,
|
||||
children,
|
||||
heightItem = 108,
|
||||
refresherTriggered = false,
|
||||
selfOnRefresherRefresh,
|
||||
selfOnScrolltolower,
|
||||
hasMore = true,
|
||||
statusMore = 0,
|
||||
selectClass,
|
||||
}: Params) => {
|
||||
const num_half = useRef(0)
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
setSelected(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const init = () => {
|
||||
const index = list?.findIndex((item) => {
|
||||
return item.id == defaultValue
|
||||
})
|
||||
if (index !== -1) {
|
||||
computeSelectTab(index)
|
||||
}
|
||||
const computeSelectTab = (index) => {
|
||||
if (index + 1 > num_half.current) {
|
||||
const num = index + 1 - num_half.current
|
||||
setTabId(list[num].id.toString())
|
||||
}
|
||||
else {
|
||||
setTabId(list[0].id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
const clickEvent = ({ item, index }: { item; index: number }) => {
|
||||
setSelected(item.id)
|
||||
sideBarOnClick?.(item)
|
||||
// 二级面料系列分类
|
||||
const [openClass, setOpenClass] = useState(false)
|
||||
const [classList, setClassList] = useState([])
|
||||
const [classId, setClassId] = useState(-1)
|
||||
const { fetchData } = GetClassList()
|
||||
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]
|
||||
}
|
||||
setClassList(() => res.data?.list)
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
if (selected) { getClassData(selected) }
|
||||
}, [selected])
|
||||
|
||||
const getSelectClass = (id) => {
|
||||
selectClass?.(id)
|
||||
setClassId(() => id)
|
||||
}
|
||||
|
||||
const init = () => {
|
||||
const index = list?.findIndex((item) => {
|
||||
return item.id == defaultValue
|
||||
})
|
||||
if (index !== -1) {
|
||||
computeSelectTab(index)
|
||||
setClassId(-1)
|
||||
selectClass?.(-1)
|
||||
}
|
||||
}
|
||||
|
||||
const computeSelectTab = (index) => {
|
||||
if (index + 1 > num_half.current) {
|
||||
const num = index + 1 - num_half.current
|
||||
setTabId(list[num].id.toString())
|
||||
}
|
||||
else {
|
||||
setTabId(list[0].id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
Taro.nextTick(() => {
|
||||
const query = Taro.createSelectorQuery()
|
||||
query
|
||||
.select('.side_bar_select')
|
||||
.boundingClientRect((rect) => {
|
||||
console.log('rect::', rect)
|
||||
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()
|
||||
})
|
||||
.exec()
|
||||
})
|
||||
}, [])
|
||||
|
||||
// 二级面料系列分类
|
||||
const [openClass, setOpenClass] = useState(false)
|
||||
const [classList, setClassList] = useState([])
|
||||
const [classId, setClassId] = useState(-1)
|
||||
const { fetchData } = GetClassList()
|
||||
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]
|
||||
}
|
||||
setClassList(() => res.data?.list)
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
if (selected) { getClassData(selected) }
|
||||
}, [selected])
|
||||
|
||||
const getSelectClass = (id) => {
|
||||
selectClass?.(id)
|
||||
setClassId(() => id)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={classnames(styles.sideBar_main, 'side_bar_select')}>
|
||||
<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 })}
|
||||
>
|
||||
<View className={styles.title_con}>{item.name}</View>
|
||||
</View>
|
||||
const clickEvent = ({ item, index }: { item; index: number }) => {
|
||||
setSelected(item.id)
|
||||
sideBarOnClick?.(item)
|
||||
computeSelectTab(index)
|
||||
setClassId(-1)
|
||||
selectClass?.(-1)
|
||||
}
|
||||
useEffect(() => {
|
||||
setSelected(defaultValue)
|
||||
}, [defaultValue])
|
||||
useEffect(() => {
|
||||
Taro.nextTick(() => {
|
||||
const query = Taro.createSelectorQuery()
|
||||
query
|
||||
.select('.side_bar_select')
|
||||
.boundingClientRect((rect) => {
|
||||
console.log('rect::', rect)
|
||||
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()
|
||||
})
|
||||
.exec()
|
||||
})
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
<View className={classnames(styles.sideBar_main, 'side_bar_select')}>
|
||||
<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 })}
|
||||
>
|
||||
<View className={styles.title_con}>{item.name}</View>
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</ScrollView>
|
||||
<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} />
|
||||
</View>
|
||||
)}
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
hasMore={hasMore}
|
||||
selfonScrollToLower={() => selfOnScrolltolower?.()}
|
||||
refresherTriggered={refresherTriggered}
|
||||
refresherEnabled
|
||||
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}
|
||||
>
|
||||
{children}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</ScrollView>
|
||||
<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} />
|
||||
</View>
|
||||
)}
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
hasMore={hasMore}
|
||||
selfonScrollToLower={() => selfOnScrolltolower?.()}
|
||||
refresherTriggered={refresherTriggered}
|
||||
refresherEnabled
|
||||
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}
|
||||
>
|
||||
{children}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
},
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default memo(
|
||||
SideBar,
|
||||
)
|
||||
|
||||
@ -9,7 +9,7 @@ interface params {
|
||||
sortValue?: { desc: string; asc: string } // 排序规则,后端制定
|
||||
}
|
||||
type sortParam = 'none'|'top'|'bottom'
|
||||
export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref) => {
|
||||
const SortBtn = ({ status = 'none', onChange, sortValue }: params, ref) => {
|
||||
const [sortStatus, setSortStatus] = useState<sortParam>()
|
||||
useEffect(() => {
|
||||
setSortStatus(() => status)
|
||||
@ -19,11 +19,11 @@ export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref
|
||||
let value = ''
|
||||
if (sortStatus == 'none') {
|
||||
status = 'top'
|
||||
value = sortValue?.asc!
|
||||
value = sortValue?.asc as string
|
||||
}
|
||||
if (sortStatus == 'top') {
|
||||
status = 'bottom'
|
||||
value = sortValue?.desc!
|
||||
value = sortValue?.desc as string
|
||||
}
|
||||
if (sortStatus == 'bottom') { status = 'none' }
|
||||
setSortStatus(() => status)
|
||||
@ -42,4 +42,5 @@ export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default forwardRef(SortBtn)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import type { ReactNode } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
@ -17,8 +17,7 @@ interface Params {
|
||||
style?: Object
|
||||
|
||||
}
|
||||
|
||||
export default memo(({ list = [], defaultValue = 0, tabsOnClick, style = {} }: Params) => {
|
||||
const Tabs = ({ list = [], defaultValue = 0, tabsOnClick, style = {} }: Params) => {
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
|
||||
@ -57,4 +56,5 @@ export default memo(({ list = [], defaultValue = 0, tabsOnClick, style = {} }: P
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(Tabs)
|
||||
|
||||
@ -11,7 +11,7 @@ interface Param {
|
||||
defaultValue?: string
|
||||
onlyRead?: false|true
|
||||
}
|
||||
export default memo(({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
|
||||
const TextareaEnhance = ({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
@ -38,11 +38,13 @@ export default memo(({ onChange, title = '', placeholder = '请输入', defaultV
|
||||
<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>
|
||||
{(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>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(TextareaEnhance)
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
|
||||
import { Button, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { stopPullDownRefresh, usePullDownRefresh } from '@tarojs/taro'
|
||||
import { useState } from 'react'
|
||||
import { View } from '@tarojs/components'
|
||||
import useLogin from '@/use/useLogin'
|
||||
import AddressList from '@/components/AddressList'
|
||||
import './index.scss'
|
||||
|
||||
export default () => {
|
||||
const AddressManager = () => {
|
||||
useLogin()
|
||||
return (
|
||||
<View className="address-manager">
|
||||
<AddressList refresherEnabled />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default AddressManager
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useCallback } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||
@ -23,7 +23,7 @@ interface Param {
|
||||
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> = ({ 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 })
|
||||
@ -36,13 +36,13 @@ const kindeList: FC<Param> = memo(({ order, onSelectChange }) => {
|
||||
|
||||
return (
|
||||
<View className={styles.apply_after_sales_list}>
|
||||
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item} >
|
||||
{order?.av_return_product?.map((item, index) => <View className={styles.apply_after_sales_item} key={index}>
|
||||
<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}>
|
||||
{item?.av_product_color?.map((colorItem, key) => <View className={styles.color_item} key={key}>
|
||||
<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)} />
|
||||
@ -51,6 +51,6 @@ const kindeList: FC<Param> = memo(({ order, onSelectChange }) => {
|
||||
</View>)}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default kindeList
|
||||
export default memo(KindeList)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useCallback } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||
@ -23,7 +23,7 @@ interface Param {
|
||||
onNumChange?: (val: any) => void
|
||||
}
|
||||
|
||||
const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
|
||||
const KindeList: FC<Param> = ({ order, onNumChange }) => {
|
||||
// 计步器返回值
|
||||
const getCounterChange = useCallback((colorItem) => {
|
||||
return (number) => {
|
||||
@ -33,13 +33,13 @@ const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
|
||||
|
||||
return (
|
||||
<View className={styles.apply_after_sales_list}>
|
||||
{order?.av_return_product?.map(item => <View className={styles.apply_after_sales_item}>
|
||||
{order?.av_return_product?.map((item, index) => <View className={styles.apply_after_sales_item} key={index}>
|
||||
<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}>
|
||||
{item?.av_product_color?.map((colorItem, key) => <View className={styles.color_item} key={key}>
|
||||
<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}>
|
||||
@ -50,6 +50,6 @@ const kindeList: FC<Param> = memo(({ order, onNumChange }) => {
|
||||
</View>)}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default kindeList
|
||||
export default memo(KindeList)
|
||||
|
||||
@ -7,7 +7,7 @@ import styles from './index.module.scss'
|
||||
interface Param {
|
||||
onChange: (val: string) => void
|
||||
}
|
||||
export default memo(({ onChange }: Param) => {
|
||||
const OtherReason = ({ onChange }: Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
@ -31,11 +31,13 @@ export default memo(({ onChange }: Param) => {
|
||||
<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>
|
||||
{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>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(OtherReason)
|
||||
|
||||
@ -17,7 +17,7 @@ interface ReasonInfoParam {
|
||||
defaultValue?: number // 默认选中
|
||||
dataLength?: number // 可显示的数据列数
|
||||
}
|
||||
export default memo(({ show = false, onClose, title = '', list = [], onSelect, onHeaderSelect, defaultValue, dataLength = 1 }: ReasonInfoParam) => {
|
||||
const ReasonPopup = ({ show = false, onClose, title = '', list = [], onSelect, onHeaderSelect, defaultValue, dataLength = 1 }: ReasonInfoParam) => {
|
||||
const [initList, setInitList] = useState<typeof list>([])
|
||||
|
||||
useEffect(() => {
|
||||
@ -59,4 +59,5 @@ export default memo(({ show = false, onClose, title = '', list = [], onSelect, o
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ReasonPopup)
|
||||
|
||||
@ -19,11 +19,8 @@ enum returnStatus {
|
||||
goods_status = 2, // 状况
|
||||
return_explain = 3, // 说明
|
||||
}
|
||||
export default () => {
|
||||
const ApplyAfterSales = () => {
|
||||
useLogin()
|
||||
useDidShow(() => {
|
||||
getSaleOrderPreView()
|
||||
})
|
||||
|
||||
const router = useRouter()
|
||||
const orderId = useRef<number>(Number(router.params.id))
|
||||
@ -50,13 +47,9 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 监听获取到的数据
|
||||
useEffect(() => {
|
||||
if (orderDetail) {
|
||||
formatData()
|
||||
}
|
||||
}, [orderDetail])
|
||||
|
||||
useDidShow(() => {
|
||||
getSaleOrderPreView()
|
||||
})
|
||||
// 格式化数据格式
|
||||
const [formatDetailOrder, setFormatDetailOrder] = useState<any>() // 格式化后的数据
|
||||
const formatData = () => {
|
||||
@ -82,18 +75,23 @@ export default () => {
|
||||
const getNumChange = useCallback((val) => {
|
||||
if (parseInt(val.number) > 0) {
|
||||
roll_list.current[val.color_id] = { product_roll: val.number, sale_order_detail_id: val.sale_order_detail_id }
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete roll_list.current[val.color_id]
|
||||
}
|
||||
setSubmitData(e => ({ ...e, roll_list: Object.values(roll_list.current) }))
|
||||
}, [])
|
||||
|
||||
// 监听获取到的数据
|
||||
useEffect(() => {
|
||||
if (orderDetail) {
|
||||
formatData()
|
||||
}
|
||||
}, [orderDetail])
|
||||
// 散剪和剪板
|
||||
const getSelectChange = useCallback((val) => {
|
||||
if (val.status) {
|
||||
roll_list.current[val.sale_order_detail_id] = { product_roll: val.length, sale_order_detail_id: val.sale_order_detail_id }
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete roll_list.current[val.sale_order_detail_id]
|
||||
}
|
||||
@ -119,7 +117,7 @@ export default () => {
|
||||
if (res.success) {
|
||||
alert.success('申请成功')
|
||||
goLink('/pages/salesAfter/salesAfterList/index', {}, 'reLaunch')
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.error(res.msg)
|
||||
}
|
||||
@ -132,7 +130,7 @@ export default () => {
|
||||
if (submitData.return_explain === '') { return alert.error('请选择退货原因') }
|
||||
if (!submitData.return_explain && !submitData.reason_describe) { return alert.error('请填写其他说明') }
|
||||
onSubmitData()
|
||||
}
|
||||
}
|
||||
else {
|
||||
Taro.navigateBack()
|
||||
}
|
||||
@ -144,9 +142,6 @@ export default () => {
|
||||
const onShowReason = () => {
|
||||
setShowReason(true)
|
||||
}
|
||||
useEffect(() => {
|
||||
getReturnReason()
|
||||
}, [])
|
||||
|
||||
// 请求获取到的数据
|
||||
const [returnGoodsInfo, setReturnGoodsInfo] = useState([])
|
||||
@ -157,6 +152,9 @@ export default () => {
|
||||
const res = await fetchDataReturnReason()
|
||||
setReturnGoodsInfo(e => res.data?.list)
|
||||
}
|
||||
useEffect(() => {
|
||||
getReturnReason()
|
||||
}, [])
|
||||
// 售后退货说明
|
||||
const { fetchData: fetchDataReturnExplain } = ReturnExplainApi()
|
||||
const getReturnExplain = async(id) => {
|
||||
@ -273,3 +271,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplyAfterSales
|
||||
|
||||
@ -11,10 +11,10 @@ interface params {
|
||||
onClose?: () => void
|
||||
saleMan?: string
|
||||
}
|
||||
export default ({ show = false, saleMan = '', onClose }: params) => {
|
||||
const SuccessBind = ({ show = false, saleMan = '', onClose }: params) => {
|
||||
const onClick = async() => {
|
||||
onClose?.()
|
||||
goLink('/pages/index/index', {}, 'switchTab')
|
||||
goLink('/pages/index/index', {}, 'switchTab')
|
||||
}
|
||||
const onCloseEven = () => {
|
||||
onClose?.()
|
||||
@ -35,5 +35,7 @@ export default ({ show = false, saleMan = '', onClose }: params) => {
|
||||
<View className={styles.bindSalesman_mask} onClick={onCloseEven}></View>
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default SuccessBind
|
||||
|
||||
@ -11,13 +11,9 @@ import CloseBtn from '@/components/closeBtn'
|
||||
import { BindInvitationInfoApi, GetInvitationInfoApi } from '@/api/user'
|
||||
import { debounce, getFilterData, throttle } from '@/common/util'
|
||||
|
||||
export default () => {
|
||||
const BindSalesman = () => {
|
||||
useLogin()
|
||||
|
||||
useEffect(() => {
|
||||
onClipboardData()
|
||||
}, [])
|
||||
|
||||
const [submitData, setSubmitData] = useState({
|
||||
invitation_code: '',
|
||||
})
|
||||
@ -71,7 +67,9 @@ export default () => {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
onClipboardData()
|
||||
}, [])
|
||||
return (
|
||||
<View className={styles.bindSalesmanPage_main}>
|
||||
<View className={styles.header_image}>
|
||||
@ -113,3 +111,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default BindSalesman
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import Popup from '@/components/popup'
|
||||
import './SelectEnterpriseType.scss'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import { certificationTypeListApi } from '@/api/certification'
|
||||
|
||||
interface Params{
|
||||
confirm?: (selected: any) => void // 确定
|
||||
}
|
||||
|
||||
export default forwardRef((props: Params, ref) => {
|
||||
const SelectEnterpriseType = (props: Params, ref) => {
|
||||
const [modalShow, setModalShow] = useState(false)
|
||||
// 获取认证信息
|
||||
const { fetchData, state } = certificationTypeListApi()
|
||||
@ -53,4 +52,5 @@ export default forwardRef((props: Params, ref) => {
|
||||
</Popup>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default forwardRef(SelectEnterpriseType)
|
||||
|
||||
@ -13,22 +13,9 @@ import { IMG_CND_Prefix } from '@/common/constant'
|
||||
import { useSelector } from '@/reducers/hooks'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
const Certification = () => {
|
||||
const { getAdminUserInfo } = useLogin()
|
||||
const { adminUserInfo } = useSelector(state => state.userInfo)
|
||||
useEffect(() => {
|
||||
initalFormData()
|
||||
}, [])
|
||||
// 获取认证信息
|
||||
const { fetchData: getFromData } = certificationDetailApi()
|
||||
const initalFormData = async() => {
|
||||
const detail = await getFromData()
|
||||
setFormData({
|
||||
...detail.data ?? {},
|
||||
legal_person_identity_url: detail?.data?.legal_person_identity_url ?? [],
|
||||
// business_license_url: "https://test.cdn.zzfzyc.com/mall/827082e888860dd9da10f0fbb0ac3cf023081456.png"
|
||||
} as any)
|
||||
}
|
||||
// 保存
|
||||
const [formData, setFormData] = useState({
|
||||
authentication_type: 0,
|
||||
@ -40,6 +27,20 @@ export default () => {
|
||||
legal_person_identity_url: [],
|
||||
name: '',
|
||||
})
|
||||
// 获取认证信息
|
||||
const { fetchData: getFromData } = certificationDetailApi()
|
||||
const initalFormData = async() => {
|
||||
const detail = await getFromData()
|
||||
setFormData({
|
||||
...detail.data ?? {},
|
||||
legal_person_identity_url: detail?.data?.legal_person_identity_url ?? [],
|
||||
// business_license_url: "https://test.cdn.zzfzyc.com/mall/827082e888860dd9da10f0fbb0ac3cf023081456.png"
|
||||
} as any)
|
||||
}
|
||||
useEffect(() => {
|
||||
initalFormData()
|
||||
}, [])
|
||||
|
||||
const rules = {
|
||||
// authentication_type: [{
|
||||
// message: "请选择认证类型"
|
||||
@ -79,7 +80,7 @@ export default () => {
|
||||
getAdminUserInfo()
|
||||
Taro.navigateBack()
|
||||
alert.success('保存成功')
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.error(result.msg)
|
||||
}
|
||||
@ -113,7 +114,7 @@ export default () => {
|
||||
const result = await getWxPhoto('mall')
|
||||
if (text == 'business_license_url') {
|
||||
formData.business_license_url = IMG_CND_Prefix + (result as any).url
|
||||
}
|
||||
}
|
||||
else {
|
||||
formData.legal_person_identity_url[text] = IMG_CND_Prefix + (result as any).url as never
|
||||
}
|
||||
@ -201,3 +202,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Certification
|
||||
|
||||
@ -11,12 +11,15 @@ import { DelFavoriteProductApi, DetailFavoriteProductApi, MoveFavoriteProductApi
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import AddCollection from '@/components/addCollection'
|
||||
|
||||
export default () => {
|
||||
const CollectionClass = () => {
|
||||
const router = useRouter()
|
||||
|
||||
// 获取收藏夹面料
|
||||
const { fetchData: fetchDataDetailFavoriteProduct } = DetailFavoriteProductApi()
|
||||
const [colorInfo, setColorInfo] = useState<any>({})
|
||||
|
||||
// 获取搜索数据
|
||||
const [searchData, setSearchData] = useState({ id: 0, code_or_name: '' })
|
||||
const getFavoriteInfo = async() => {
|
||||
const res = await fetchDataDetailFavoriteProduct(searchData)
|
||||
if (res.success) {
|
||||
@ -27,8 +30,6 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取搜索数据
|
||||
const [searchData, setSearchData] = useState({ id: 0, code_or_name: '' })
|
||||
const onSearch = useCallback((e) => {
|
||||
setSearchData(val => ({ ...val, code_or_name: e }))
|
||||
}, [])
|
||||
@ -53,26 +54,17 @@ export default () => {
|
||||
|
||||
// 全选反选
|
||||
const [allSelectStatus, setAllSelectStatus] = useState(false)
|
||||
const selectCallBack = useCallback(() => {
|
||||
setAllSelectStatus(() => true)
|
||||
setSelectStatus(1)
|
||||
}, [])
|
||||
const colseCallBack = useCallback(() => {
|
||||
setAllSelectStatus(() => false)
|
||||
setSelectStatus(3)
|
||||
}, [])
|
||||
|
||||
const [selectStatus, setSelectStatus] = useState<1 | 2 | 3>(3)
|
||||
useEffect(() => {
|
||||
if (colorInfo.product_color_list?.length) {
|
||||
if (ids.length == colorInfo.product_color_list.length) {
|
||||
setSelectStatus(1)
|
||||
setAllSelectStatus(true)
|
||||
}
|
||||
}
|
||||
else if (ids.length > 0 && ids.length < colorInfo.product_color_list.length) {
|
||||
setSelectStatus(2)
|
||||
setAllSelectStatus(false)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setSelectStatus(3)
|
||||
setAllSelectStatus(false)
|
||||
@ -84,7 +76,14 @@ export default () => {
|
||||
const closeCollection = useCallback(() => {
|
||||
setCollectionShow(false)
|
||||
}, [])
|
||||
|
||||
const selectCallBack = useCallback(() => {
|
||||
setAllSelectStatus(() => true)
|
||||
setSelectStatus(1)
|
||||
}, [])
|
||||
const colseCallBack = useCallback(() => {
|
||||
setAllSelectStatus(() => false)
|
||||
setSelectStatus(3)
|
||||
}, [])
|
||||
// 移动面料
|
||||
const { fetchData: fetchDataMoveFavoriteProduct } = MoveFavoriteProductApi()
|
||||
const onAdd = async(val) => {
|
||||
@ -145,3 +144,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default CollectionClass
|
||||
|
||||
@ -17,7 +17,7 @@ interface ReasonInfoParam {
|
||||
name: string
|
||||
} // 默认数据
|
||||
}
|
||||
export default memo(({ show = false, onClose, onSuccess, defaultValue }: ReasonInfoParam) => {
|
||||
const CreatePopup = ({ show = false, onClose, onSuccess, defaultValue }: ReasonInfoParam) => {
|
||||
const submitData = useRef({
|
||||
name: '',
|
||||
remark: '',
|
||||
@ -36,7 +36,7 @@ export default memo(({ show = false, onClose, onSuccess, defaultValue }: ReasonI
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
submitData.current = { name: defaultValue?.name!, remark: defaultValue?.remark! }
|
||||
submitData.current = { name: defaultValue?.name as string, remark: defaultValue?.remark as string }
|
||||
}, [defaultValue])
|
||||
return (
|
||||
<Popup show={show} title="新建收藏夹" onClose={onClose}>
|
||||
@ -71,4 +71,5 @@ export default memo(({ show = false, onClose, onSuccess, defaultValue }: ReasonI
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(CreatePopup)
|
||||
|
||||
@ -13,7 +13,7 @@ interface Params {
|
||||
selectStatus?: 1|2|3 // 1全选,2不做处理,3全清空
|
||||
openCheckBox?: true|false // 是否开启选择
|
||||
}
|
||||
export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = false }: Params) => {
|
||||
const Product = ({ productList, onSelectIds, selectStatus = 2, openCheckBox = false }: Params) => {
|
||||
const [list, setList] = useState<any[]>([])
|
||||
useEffect(() => {
|
||||
setList(() => productList || [])
|
||||
@ -21,22 +21,12 @@ export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = fal
|
||||
|
||||
useEffect(() => {
|
||||
if (list.length && selectStatus != 2) {
|
||||
list.map((item) => {
|
||||
list.forEach((item) => {
|
||||
item.check = (selectStatus == 1)
|
||||
})
|
||||
setList(() => [...list])
|
||||
}
|
||||
}, [selectStatus])
|
||||
|
||||
const onChangeSelect = (item) => {
|
||||
if (item.check) {
|
||||
onClose(item)
|
||||
}
|
||||
else {
|
||||
onSelect(item)
|
||||
}
|
||||
}
|
||||
|
||||
}, [selectStatus])
|
||||
// 选中和取消选中
|
||||
const onSelect = (item) => {
|
||||
item.check = true
|
||||
@ -46,11 +36,19 @@ export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = fal
|
||||
item.check = false
|
||||
setList(() => ([...list]))
|
||||
}
|
||||
const onChangeSelect = (item) => {
|
||||
if (item.check) {
|
||||
onClose(item)
|
||||
}
|
||||
else {
|
||||
onSelect(item)
|
||||
}
|
||||
}
|
||||
|
||||
// 监听数据变化
|
||||
useEffect(() => {
|
||||
const ids: number[] = []
|
||||
list.map((item) => {
|
||||
list.forEach((item) => {
|
||||
if (item.check) { ids.push(item.product_id) }
|
||||
})
|
||||
onSelectIds?.(ids)
|
||||
@ -58,8 +56,8 @@ export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = fal
|
||||
|
||||
return (
|
||||
<View className={styles.products_list}>
|
||||
{list?.map((item) => {
|
||||
return <View className={styles.products_item} onClick={() => openCheckBox ? onChangeSelect(item) : goLink(`/pages/details/index?id=${item.product_id}`)}>
|
||||
{list?.map((item, index) => {
|
||||
return <View key={index} className={styles.products_item} onClick={() => openCheckBox ? onChangeSelect(item) : goLink(`/pages/details/index?id=${item.product_id}`)}>
|
||||
{openCheckBox && <View className={styles.checkbox} onClick={e => e.stopPropagation()}>
|
||||
<MCheckbox status={item.check} onSelect={() => onSelect(item)} onClose={() => onClose(item)} />
|
||||
</View>}
|
||||
@ -81,3 +79,5 @@ export default ({ productList, onSelectIds, selectStatus = 2, openCheckBox = fal
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Product
|
||||
|
||||
@ -16,14 +16,14 @@ interface ReasonInfoParam {
|
||||
onDelete?: () => void // 删除
|
||||
|
||||
}
|
||||
export default memo(({ show = false, onClose, onUpdate, onBatchManagement, onDelete }: ReasonInfoParam) => {
|
||||
const UpdatePopup = ({ show = false, onClose, onUpdate, onBatchManagement, onDelete }: ReasonInfoParam) => {
|
||||
const onClickEven = (val) => {
|
||||
if (val == 1) {
|
||||
onUpdate?.()
|
||||
}
|
||||
}
|
||||
else if (val == 2) {
|
||||
onBatchManagement?.()
|
||||
}
|
||||
}
|
||||
else {
|
||||
onDelete?.()
|
||||
}
|
||||
@ -46,4 +46,5 @@ export default memo(({ show = false, onClose, onUpdate, onBatchManagement, onDel
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(UpdatePopup)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import Taro, { useDidHide, useDidShow } from '@tarojs/taro'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import Product from './components/product'
|
||||
@ -10,25 +11,15 @@ import { getFilterData } from '@/common/util'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { CreateFavoriteApi, DelFavoriteApi, FavoriteListApi, UpdateFavoriteApi } from '@/api/favorite'
|
||||
import useLogin from '@/use/useLogin'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
|
||||
export default () => {
|
||||
const Collection = () => {
|
||||
useLogin()
|
||||
const changeOpenCon = (item) => {
|
||||
item.openStatus = !item.openStatus
|
||||
setList(e => [...e])
|
||||
}
|
||||
useDidShow(() => {
|
||||
getFavoriteList()
|
||||
})
|
||||
|
||||
// 获取搜索数据
|
||||
const [searchData, setSearchData] = useState('')
|
||||
const onSearch = useCallback((e) => {
|
||||
setSearchData(() => e)
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
getFavoriteList()
|
||||
}, [searchData])
|
||||
|
||||
// 获取列表
|
||||
const [list, setList] = useState([])
|
||||
@ -37,18 +28,32 @@ export default () => {
|
||||
const res = await fetchDataList(getFilterData({ name: searchData }))
|
||||
setList(() => res.data.list)
|
||||
}
|
||||
|
||||
const changeOpenCon = (item) => {
|
||||
item.openStatus = !item.openStatus
|
||||
setList(e => [...e])
|
||||
}
|
||||
useDidShow(() => {
|
||||
getFavoriteList()
|
||||
})
|
||||
// 创建收藏夹
|
||||
const [collectioinShow, setCollectioinShow] = useState(false)
|
||||
const closeCollection = useCallback(() => {
|
||||
setCollectioinShow(false)
|
||||
}, [])
|
||||
|
||||
// 更多编辑
|
||||
const [initData, setInitData] = useState({
|
||||
remark: '',
|
||||
name: '',
|
||||
id: 0,
|
||||
})
|
||||
const creatShow = () => {
|
||||
setCollectioinShow(true)
|
||||
setInitData(() => ({ remark: '', name: '', id: 0 }))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getFavoriteList()
|
||||
}, [searchData])
|
||||
// 新增
|
||||
const { fetchData } = CreateFavoriteApi()
|
||||
const onCreate = async(submitData) => {
|
||||
@ -63,12 +68,6 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 更多编辑
|
||||
const [initData, setInitData] = useState({
|
||||
remark: '',
|
||||
name: '',
|
||||
id: 0,
|
||||
})
|
||||
const selectInfo = useRef<any>(null)
|
||||
const [updateShow, setUpdateShow] = useState(false)
|
||||
const closeUpdate = useCallback(() => {
|
||||
@ -149,7 +148,7 @@ export default () => {
|
||||
<View className={styles.miconfont_con} onClick={creatShow}><Text className={classnames(styles.miconfont, 'iconfont icon-jia')}></Text></View>
|
||||
</View>
|
||||
<View className={styles.class_list}>
|
||||
{list?.map((item: any) => <View className={styles.class_item}>
|
||||
{list?.map((item: any, key) => <View className={styles.class_item} key={key}>
|
||||
<View key={item.id} className={styles.class_title} onClick={() => changeOpenCon(item)}>
|
||||
<Text className={classnames(styles.miconfont_left, 'iconfont icon-a-moreback', item.openStatus ? styles.miconfont_open : styles.miconfont_close)}></Text>
|
||||
<View className={styles.title}>{item.name}
|
||||
@ -167,3 +166,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Collection
|
||||
|
||||
@ -9,26 +9,12 @@ import { companyDetailApi, companyUpdateApi } from '@/api/company'
|
||||
import './index.scss'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
const Company = () => {
|
||||
useLogin()
|
||||
const [showSiteModal, setShowSiteModal] = useState(false)
|
||||
const handleSelectSite = () => {
|
||||
setShowSiteModal(true)
|
||||
}
|
||||
// 获取公司信息
|
||||
const { fetchData: getFromData } = companyDetailApi()
|
||||
const getData = async() => {
|
||||
const result = await getFromData()
|
||||
console.log(result.data, '===')
|
||||
|
||||
setFormData({
|
||||
...result.data,
|
||||
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
getData()
|
||||
}, [])
|
||||
// 保存
|
||||
const [formData, setFormData] = useState({
|
||||
address_detail: '',
|
||||
@ -46,6 +32,21 @@ export default () => {
|
||||
site: '',
|
||||
siteArray: [],
|
||||
})
|
||||
// 获取公司信息
|
||||
const { fetchData: getFromData } = companyDetailApi()
|
||||
const getData = async() => {
|
||||
const result = await getFromData()
|
||||
console.log(result.data, '===')
|
||||
|
||||
setFormData({
|
||||
...result.data,
|
||||
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
getData()
|
||||
}, [])
|
||||
|
||||
const rules = {
|
||||
company_name: [{
|
||||
message: '请输入公司名称',
|
||||
@ -145,7 +146,9 @@ export default () => {
|
||||
|
||||
<Button style={{ background: hozon ? '#007aff' : '' }} hoverClass="none" className="save-button" onClick={handleSave}>保存</Button>
|
||||
{/* <Address addressOnClose={()=>setShowSiteModal(false)} show={showSiteModal}/> */}
|
||||
<Address addressOnSelect={handleSetSite} defaultValue={[{ name: '广东省', id: 193, level: 2 }, { name: '佛山市', id: 202, level: 3 }, { name: '高明区', id: 204, level: 4 }]} addressOnClose={() => setShowSiteModal(false)} show={showSiteModal} />
|
||||
<Address addressOnSelect={handleSetSite} defaultValue={[{ name: '广东省', id: 193, level: 2 }, { name: '佛山市', id: 202, level: 3 }, { name: '高明区', id: 204, level: 4 }]} addressOnClose={() => setShowSiteModal(false)} show={showSiteModal} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Company
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
import { Button, Canvas, Navigator, ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro, { useReady } from '@tarojs/taro'
|
||||
import { useEffect, useState } from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import AddressList from '@/components/AddressList'
|
||||
import { creditInfoApi } from '@/api/creditLine'
|
||||
import './index.scss'
|
||||
@ -10,12 +10,109 @@ import { formatDateTime, formatPriceDiv } from '@/common/fotmat'
|
||||
import Message from '@/components/Message'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
interface ProgressType {
|
||||
progress: number
|
||||
style: Record<string, any>
|
||||
}
|
||||
const Progress = (props: ProgressType) => {
|
||||
const getCanvas = () => {
|
||||
// const percentage = props.progress??0;
|
||||
const percentage = props.progress || 0
|
||||
const query = Taro.createSelectorQuery()
|
||||
query.select('#myCanvas').fields({ node: true, size: true }).exec((res) => {
|
||||
const canvas = res[0]?.node
|
||||
if (canvas) {
|
||||
const ctx = canvas.getContext('2d')
|
||||
const { windowHeight, windowWidth } = Taro.getSystemInfoSync()
|
||||
const dpr = 750 / windowWidth
|
||||
canvas.width = res[0].width * dpr
|
||||
canvas.height = res[0].height * dpr
|
||||
const r = canvas.width / 2
|
||||
ctx.translate(r, r)
|
||||
|
||||
// 白色大圆
|
||||
ctx.beginPath()
|
||||
ctx.fillStyle = 'white'
|
||||
ctx.shadowBlur = 20
|
||||
ctx.shadowColor = '#cde5ff'
|
||||
ctx.arc(0, 0, 100, 0, 2 * Math.PI, false)
|
||||
ctx.fill()
|
||||
|
||||
// 刻度
|
||||
const my_minute = Math.PI * 2 / 60
|
||||
const my_second = Math.PI * 2 / 60
|
||||
ctx.strokeStyle = '#F59F5D'
|
||||
ctx.lineWidth = 2
|
||||
ctx.beginPath()
|
||||
for (let i = 0; i < 15; i++) {
|
||||
ctx.save()
|
||||
ctx.rotate(i * 4 * my_minute)
|
||||
ctx.moveTo(r - 45, 0)
|
||||
ctx.lineTo(r - 40, 0)
|
||||
ctx.stroke()
|
||||
ctx.restore()
|
||||
}
|
||||
|
||||
// 白色小圆
|
||||
ctx.beginPath()
|
||||
ctx.fillStyle = 'white'
|
||||
ctx.shadowBlur = 20
|
||||
ctx.shadowColor = 'rgba(204,204,204,0.50)'
|
||||
ctx.arc(0, 0, 74, 0, 2 * Math.PI, false)
|
||||
ctx.fill()
|
||||
|
||||
// 文字
|
||||
ctx.beginPath()
|
||||
ctx.restore()
|
||||
|
||||
ctx.fillStyle = props.style?.cir?.color// "#007aff";
|
||||
ctx.font = '42px Cambria, Cambria-Bold'
|
||||
ctx.textAlign = 'center'
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.fillText(`${percentage}%`, 0, 0)
|
||||
|
||||
// 蓝色的圆
|
||||
if (percentage > 0) {
|
||||
ctx.beginPath()
|
||||
ctx.lineWidth = 25
|
||||
ctx.lineCap = 'round'
|
||||
const gad = ctx.createLinearGradient(100, 0, 0, 100)
|
||||
gad.addColorStop(0, props.style?.cir?.background?.start[0])
|
||||
gad.addColorStop(1, props.style?.cir?.background?.start[1])
|
||||
ctx.strokeStyle = gad
|
||||
ctx.arc(0, 0, 104, -Math.PI * 0.5, 2 * Math.PI / 100 * ((percentage < 50 ? percentage : 50) - 25), false)
|
||||
ctx.stroke()
|
||||
}
|
||||
|
||||
if (percentage > 50) {
|
||||
ctx.beginPath()
|
||||
const gad2 = ctx.createLinearGradient(0, -100, 0, 0)
|
||||
gad2.addColorStop(0, props.style?.cir?.background?.end[0])
|
||||
gad2.addColorStop(1, props.style?.cir?.background?.start[1])
|
||||
ctx.strokeStyle = gad2
|
||||
ctx.arc(0, 0, 104, Math.PI * 0.4, 2 * Math.PI / 100 * (percentage - 25), false)
|
||||
ctx.stroke()
|
||||
}
|
||||
}
|
||||
else {
|
||||
getCanvas()
|
||||
}
|
||||
})
|
||||
}
|
||||
useReady(() => {
|
||||
getCanvas()
|
||||
})
|
||||
useEffect(() => {
|
||||
if (props.progress != 0) {
|
||||
getCanvas()
|
||||
}
|
||||
}, [props.progress])
|
||||
return <Canvas type="2d" id="myCanvas" />
|
||||
}
|
||||
const CreditLine = () => {
|
||||
useLogin()
|
||||
const userInfo = useSelector(state => state.userInfo)
|
||||
useEffect(() => {
|
||||
getData()
|
||||
}, [])
|
||||
|
||||
const { fetchData, state } = creditInfoApi()
|
||||
const [data, setData] = useState({
|
||||
credit_quota_used_line: [0, '00'],
|
||||
@ -39,6 +136,11 @@ export default () => {
|
||||
})
|
||||
// 获取数据
|
||||
const getData = async() => {
|
||||
const convertPrice = (data) => {
|
||||
const t = data.toString().split('.')
|
||||
t[1] = t[1] ? t[1].padEnd(2, 0) : '00'
|
||||
return t
|
||||
}
|
||||
const result = await fetchData()
|
||||
const credit_quota_used_line = convertPrice(formatPriceDiv(result.data.credit_quota_used_line))
|
||||
const credit_quota_line = convertPrice(formatPriceDiv(result.data.credit_quota_line))
|
||||
@ -113,12 +215,10 @@ export default () => {
|
||||
credit_quota_end_time: formatDateTime(result.data?.credit_quota_end_time, 'YYYY-MM-DD'),
|
||||
})
|
||||
}
|
||||
const convertPrice = (data) => {
|
||||
const t = data.toString().split('.')
|
||||
t[1] = t[1] ? t[1].padEnd(2, 0) : '00'
|
||||
return t
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getData()
|
||||
}, [])
|
||||
return (
|
||||
<View className="credit-line">
|
||||
<Message text="暂不支持线上申请授权,请联系平台客服。" />
|
||||
@ -154,98 +254,4 @@ export default () => {
|
||||
)
|
||||
}
|
||||
|
||||
const Progress = (props) => {
|
||||
useEffect(() => {
|
||||
if (props.progress != 0) {
|
||||
getCanvas()
|
||||
}
|
||||
}, [props.progress])
|
||||
const getCanvas = () => {
|
||||
// const percentage = props.progress??0;
|
||||
const percentage = props.progress || 0
|
||||
const query = Taro.createSelectorQuery()
|
||||
query.select('#myCanvas').fields({ node: true, size: true }).exec((res) => {
|
||||
const canvas = res[0]?.node
|
||||
if (canvas) {
|
||||
const ctx = canvas.getContext('2d')
|
||||
const { windowHeight, windowWidth } = Taro.getSystemInfoSync()
|
||||
const dpr = 750 / windowWidth
|
||||
canvas.width = res[0].width * dpr
|
||||
canvas.height = res[0].height * dpr
|
||||
const r = canvas.width / 2
|
||||
ctx.translate(r, r)
|
||||
|
||||
// 白色大圆
|
||||
ctx.beginPath()
|
||||
ctx.fillStyle = 'white'
|
||||
ctx.shadowBlur = 20
|
||||
ctx.shadowColor = '#cde5ff'
|
||||
ctx.arc(0, 0, 100, 0, 2 * Math.PI, false)
|
||||
ctx.fill()
|
||||
|
||||
// 刻度
|
||||
const my_minute = Math.PI * 2 / 60
|
||||
const my_second = Math.PI * 2 / 60
|
||||
ctx.strokeStyle = '#F59F5D'
|
||||
ctx.lineWidth = 2
|
||||
ctx.beginPath()
|
||||
for (let i = 0; i < 15; i++) {
|
||||
ctx.save()
|
||||
ctx.rotate(i * 4 * my_minute)
|
||||
ctx.moveTo(r - 45, 0)
|
||||
ctx.lineTo(r - 40, 0)
|
||||
ctx.stroke()
|
||||
ctx.restore()
|
||||
}
|
||||
|
||||
// 白色小圆
|
||||
ctx.beginPath()
|
||||
ctx.fillStyle = 'white'
|
||||
ctx.shadowBlur = 20
|
||||
ctx.shadowColor = 'rgba(204,204,204,0.50)'
|
||||
ctx.arc(0, 0, 74, 0, 2 * Math.PI, false)
|
||||
ctx.fill()
|
||||
|
||||
// 文字
|
||||
ctx.beginPath()
|
||||
ctx.restore()
|
||||
|
||||
ctx.fillStyle = props.style?.cir?.color// "#007aff";
|
||||
ctx.font = '42px Cambria, Cambria-Bold'
|
||||
ctx.textAlign = 'center'
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.fillText(`${percentage}%`, 0, 0)
|
||||
|
||||
// 蓝色的圆
|
||||
if (percentage > 0) {
|
||||
ctx.beginPath()
|
||||
ctx.lineWidth = 25
|
||||
ctx.lineCap = 'round'
|
||||
const gad = ctx.createLinearGradient(100, 0, 0, 100)
|
||||
gad.addColorStop(0, props.style?.cir?.background?.start[0])
|
||||
gad.addColorStop(1, props.style?.cir?.background?.start[1])
|
||||
ctx.strokeStyle = gad
|
||||
ctx.arc(0, 0, 104, -Math.PI * 0.5, 2 * Math.PI / 100 * ((percentage < 50 ? percentage : 50) - 25), false)
|
||||
ctx.stroke()
|
||||
}
|
||||
|
||||
if (percentage > 50) {
|
||||
ctx.beginPath()
|
||||
const gad2 = ctx.createLinearGradient(0, -100, 0, 0)
|
||||
gad2.addColorStop(0, props.style?.cir?.background?.end[0])
|
||||
gad2.addColorStop(1, props.style?.cir?.background?.start[1])
|
||||
ctx.strokeStyle = gad2
|
||||
ctx.arc(0, 0, 104, Math.PI * 0.4, 2 * Math.PI / 100 * (percentage - 25), false)
|
||||
ctx.stroke()
|
||||
}
|
||||
}
|
||||
else {
|
||||
getCanvas()
|
||||
}
|
||||
})
|
||||
}
|
||||
useReady(() => {
|
||||
getCanvas()
|
||||
})
|
||||
return <Canvas type="2d" id="myCanvas" />
|
||||
}
|
||||
export default CreditLine
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import InfiniteScrollPaging from '@/components/InfiniteScrollPaging'
|
||||
import { Button, Canvas, ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro, { useReady } from '@tarojs/taro'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { creditListApi } from '@/api/creditLine'
|
||||
import './index.scss'
|
||||
import classnames from 'classnames'
|
||||
import { creditListApi } from '@/api/creditLine'
|
||||
import InfiniteScrollPaging from '@/components/InfiniteScrollPaging'
|
||||
import { formatDateTime, formatPriceDiv, toDecimal2 } from '@/common/fotmat'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
const CreditUsed = () => {
|
||||
useLogin()
|
||||
const { fetchData, state } = creditListApi()
|
||||
// 渲染(数据)
|
||||
@ -172,3 +172,5 @@ export default () => {
|
||||
// </View>
|
||||
// )
|
||||
// }
|
||||
|
||||
export default CreditUsed
|
||||
|
||||
@ -8,7 +8,7 @@ import { formatPriceDiv, toDecimal2 } from '@/common/fotmat'
|
||||
import Message from '@/components/Message'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
const DepositBeforehand = () => {
|
||||
useLogin()
|
||||
const { fetchData, state } = depositInfoApi()
|
||||
const getData = async() => {
|
||||
@ -65,3 +65,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default DepositBeforehand
|
||||
|
||||
@ -8,7 +8,35 @@ import { creditListApi } from '@/api/creditLine'
|
||||
import './index.scss'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
const TimeLine = () => {
|
||||
return (
|
||||
<View className="deposit-timeline">
|
||||
<View className="deposit-timeline-item">
|
||||
<View className="deposit-timeline-item-left"></View>
|
||||
<View className="deposit-timeline-item-right">
|
||||
<View className="deposit-timeline-item-title">申请提交</View>
|
||||
<View className="deposit-timeline-item-date">2022-04-24 16:10:11</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="deposit-timeline-item">
|
||||
<View className="deposit-timeline-item-left"></View>
|
||||
<View className="deposit-timeline-item-right">
|
||||
<View className="deposit-timeline-item-title">申请提交</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="deposit-timeline-item">
|
||||
<View className="deposit-timeline-item-success">
|
||||
<Text className="iconfont icon-tick" />
|
||||
</View>
|
||||
<View className="deposit-timeline-item-right">
|
||||
<View className="deposit-timeline-item-title">申请提交</View>
|
||||
<View className="deposit-timeline-item-date">2022-04-24 16:10:11</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>)
|
||||
}
|
||||
|
||||
const DepositBeforehandDetail = () => {
|
||||
useLogin()
|
||||
return (
|
||||
<View className="deposit-detail">
|
||||
@ -58,30 +86,4 @@ export default () => {
|
||||
)
|
||||
}
|
||||
|
||||
const TimeLine = () => {
|
||||
return (
|
||||
<View className="deposit-timeline">
|
||||
<View className="deposit-timeline-item">
|
||||
<View className="deposit-timeline-item-left"></View>
|
||||
<View className="deposit-timeline-item-right">
|
||||
<View className="deposit-timeline-item-title">申请提交</View>
|
||||
<View className="deposit-timeline-item-date">2022-04-24 16:10:11</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="deposit-timeline-item">
|
||||
<View className="deposit-timeline-item-left"></View>
|
||||
<View className="deposit-timeline-item-right">
|
||||
<View className="deposit-timeline-item-title">申请提交</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="deposit-timeline-item">
|
||||
<View className="deposit-timeline-item-success">
|
||||
<Text className="iconfont icon-tick" />
|
||||
</View>
|
||||
<View className="deposit-timeline-item-right">
|
||||
<View className="deposit-timeline-item-title">申请提交</View>
|
||||
<View className="deposit-timeline-item-date">2022-04-24 16:10:11</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>)
|
||||
}
|
||||
export default DepositBeforehandDetail
|
||||
|
||||
@ -8,7 +8,7 @@ import './index.scss'
|
||||
import { formatDateTime, formatPriceDiv } from '@/common/fotmat'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
const DepositList = () => {
|
||||
useLogin()
|
||||
const { fetchData, state } = depositListApi()
|
||||
// 渲染(数据)
|
||||
@ -56,3 +56,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default DepositList
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Input, View } from '@tarojs/components'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Big from 'big.js'
|
||||
import styles from './index.module.scss'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
interface params {
|
||||
minNum?: number // 最小值
|
||||
@ -15,9 +15,19 @@ interface params {
|
||||
unit?: string
|
||||
otherData?: any
|
||||
}
|
||||
export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', otherData }: params) => {
|
||||
const Counter = ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', otherData }: params) => {
|
||||
const [value, setValue] = useState<any>({ count: defaultNum })
|
||||
|
||||
// 保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = `${num}`
|
||||
if (num.includes('.') && digits > 0) {
|
||||
console.log('num::', num.includes('.'))
|
||||
const res = num.split('.')
|
||||
const last_num = res[1].substr(0, digits)
|
||||
return `${res[0]}.${last_num}`
|
||||
}
|
||||
return parseFloat(num)
|
||||
}
|
||||
const onPlus = () => {
|
||||
const { count } = value
|
||||
let num_res = Big(count).add(step).toNumber()
|
||||
@ -36,18 +46,6 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
|
||||
onClickBtn?.(parseFloat(num_res), otherData)
|
||||
}
|
||||
|
||||
// 保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = `${num}`
|
||||
if (num.includes('.') && digits > 0) {
|
||||
console.log('num::', num.includes('.'))
|
||||
const res = num.split('.')
|
||||
const last_num = res[1].substr(0, digits)
|
||||
return `${res[0]}.${last_num}`
|
||||
}
|
||||
return parseFloat(num)
|
||||
}
|
||||
|
||||
// 检查数据
|
||||
const checkData = (val) => {
|
||||
const num = parseFloat(val)
|
||||
@ -61,21 +59,21 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
|
||||
if (res === '') {
|
||||
setValue({ ...value, count: minNum })
|
||||
onChange?.(minNum, otherData)
|
||||
}
|
||||
else if (!isNaN(Number(res))) {
|
||||
}
|
||||
else if (!Number.isNaN(Number(res))) {
|
||||
let count = formatDigits(res)
|
||||
count = checkData(count)
|
||||
setValue({ ...value, count })
|
||||
onChange?.(parseFloat(count as string), otherData)
|
||||
}
|
||||
}
|
||||
else {
|
||||
const num = parseFloat(res)
|
||||
if (!isNaN(num)) {
|
||||
if (!Number.isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
setValue({ ...value, count })
|
||||
onChange?.(count as number, otherData)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setValue({ ...value, count: defaultNum })
|
||||
onChange?.(defaultNum, otherData)
|
||||
@ -85,12 +83,12 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
|
||||
|
||||
const onBluerEven = () => {
|
||||
const num = parseFloat(value.count)
|
||||
if (!isNaN(num)) {
|
||||
if (!Number.isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
setValue({ ...value, count })
|
||||
onBlue?.(count as number, otherData)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setValue({ ...value, count: defaultNum })
|
||||
onBlue?.(defaultNum, otherData)
|
||||
@ -111,3 +109,5 @@ export default ({ minNum = 0, maxNum = 100, step = 1, digits = 0, defaultNum = 0
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Counter
|
||||
|
||||
@ -25,7 +25,7 @@ interface param {
|
||||
title?: string
|
||||
productId?: number
|
||||
}
|
||||
export default memo(({ show = false, onClose, title = '', productId = 0 }: param) => {
|
||||
const OrderCount = ({ show = false, onClose, title = '', productId = 0 }: param) => {
|
||||
const { adminUserInfo } = useSelector(state => state.userInfo)
|
||||
|
||||
const [selectList, _] = useState([
|
||||
@ -46,39 +46,11 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
},
|
||||
])
|
||||
const [selectIndex, setSelectIndex] = useState(0)
|
||||
const selectProduct = (index: number) => {
|
||||
condition.current.code_or_name = null
|
||||
getColorList()
|
||||
setSelectIndex(() => index)
|
||||
}
|
||||
|
||||
// 重置数据
|
||||
useEffect(() => {
|
||||
setSearchShow(false)
|
||||
}, [selectIndex])
|
||||
|
||||
// 获取面料颜色列表
|
||||
const { fetchData: colorFetchData, state: colorState } = GetColorList()
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const condition = useRef({ physical_warehouse: adminUserInfo?.physical_warehouse, sale_mode: selectIndex, product_id: 0, code_or_name: null })
|
||||
const getColorList = async() => {
|
||||
const { data } = await colorFetchData(getFilterData(condition.current))
|
||||
const lists = initList(data.list)
|
||||
setList(() => [...lists])
|
||||
}
|
||||
const [showPopup, setShowPopup] = useState(false)
|
||||
|
||||
// 显示获取
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
setSelectIndex(0)
|
||||
condition.current.code_or_name = null
|
||||
setSearchShow(false)
|
||||
condition.current.product_id = productId
|
||||
getColorList()
|
||||
}
|
||||
setShowPopup(show)
|
||||
}, [show])
|
||||
|
||||
// 初始化列表数据
|
||||
const initList = useCallback((list) => {
|
||||
@ -89,6 +61,18 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
})
|
||||
return newList
|
||||
}, [])
|
||||
const getColorList = async() => {
|
||||
const { data } = await colorFetchData(getFilterData(condition.current))
|
||||
const lists = initList(data.list)
|
||||
setList(() => [...lists])
|
||||
}
|
||||
const [showPopup, setShowPopup] = useState(false)
|
||||
|
||||
const selectProduct = (index: number) => {
|
||||
condition.current.code_or_name = null
|
||||
getColorList()
|
||||
setSelectIndex(() => index)
|
||||
}
|
||||
|
||||
// 卸载数据
|
||||
useEffect(() => {
|
||||
@ -115,7 +99,7 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
let kindCount = 0
|
||||
const color_list: any[] = []
|
||||
let color_list_info = {}
|
||||
list.map((item) => {
|
||||
list.forEach((item) => {
|
||||
if (item.count > 0) {
|
||||
sumCount = Big(sumCount).add(item.count).toNumber()
|
||||
kindCount++
|
||||
@ -147,7 +131,21 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
const changeSearchShow = () => {
|
||||
setSearchShow(true)
|
||||
}
|
||||
|
||||
// 显示获取
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
setSelectIndex(0)
|
||||
condition.current.code_or_name = null
|
||||
setSearchShow(false)
|
||||
condition.current.product_id = productId
|
||||
getColorList()
|
||||
}
|
||||
setShowPopup(show)
|
||||
}, [show])
|
||||
// 重置数据
|
||||
useEffect(() => {
|
||||
setSearchShow(false)
|
||||
}, [selectIndex])
|
||||
// 添加购物车
|
||||
const { getShopCount } = useCommonData()
|
||||
const { getSelfUserInfo } = UseLogin()
|
||||
@ -155,7 +153,7 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
const addShopCart = async() => {
|
||||
try {
|
||||
await getSelfUserInfo()
|
||||
}
|
||||
}
|
||||
catch (msg) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
@ -181,7 +179,7 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
})
|
||||
getShopCount()
|
||||
onClose?.()
|
||||
}
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
@ -228,9 +226,7 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
const closeLabImgShow = useCallback(() => {
|
||||
setShowLabImage(() => false)
|
||||
}, [])
|
||||
|
||||
// 虚拟滚动
|
||||
const Rows = memo(({ id, index, style, data }: any) => {
|
||||
const Rows = ({ id, index, style, data }: any) => {
|
||||
const item = data[index]
|
||||
return (
|
||||
<>
|
||||
@ -269,7 +265,9 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
)) || <View className={styles.item}></View>}
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
// 虚拟滚动
|
||||
const RowsWithMemo = memo(Rows)
|
||||
|
||||
const [virtualHeight, setVirtualheight] = useState(400)
|
||||
const getHeight = () => {
|
||||
@ -305,7 +303,7 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
<View
|
||||
key={index}
|
||||
onClick={() => selectProduct(index)}
|
||||
className={classnames(styles.search_item, selectIndex == index && styles.search_item_select)}
|
||||
className={classnames(styles.search_item, selectIndex == index && styles.search_item_select)}
|
||||
>
|
||||
{item.title}
|
||||
</View>
|
||||
@ -339,9 +337,9 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
itemData={list} /* 渲染列表的数据 */
|
||||
itemCount={searchShow ? list.length + 1 : list.length} /* 渲染列表的长度 */
|
||||
itemSize={100} /* 列表单项的高度 */
|
||||
overscanCount={1}
|
||||
overscanCount={1}
|
||||
>
|
||||
{Rows}
|
||||
{RowsWithMemo}
|
||||
</VirtualList>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
@ -367,4 +365,5 @@ export default memo(({ show = false, onClose, title = '', productId = 0 }: param
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(OrderCount)
|
||||
|
||||
@ -7,7 +7,7 @@ export interface colorParams {
|
||||
show?: false|true
|
||||
onClose?: () => void
|
||||
}
|
||||
export default ({ value, show = false, onClose }: colorParams) => {
|
||||
const Preview = ({ value, show = false, onClose }: colorParams) => {
|
||||
return (
|
||||
<>
|
||||
{show && <View className={styles.main} catch-move="true" onClick={() => onClose?.()}>
|
||||
@ -18,4 +18,6 @@ export default ({ value, show = false, onClose }: colorParams) => {
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Preview
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
|
||||
export default memo(() => {
|
||||
const ProductItem = () => {
|
||||
return (
|
||||
<View>
|
||||
<View className={styles.item} key={item.id}>
|
||||
@ -43,4 +43,5 @@ export default memo(() => {
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ProductItem)
|
||||
|
||||
@ -8,8 +8,7 @@ interface item { title: string; img: string; url: string; id: number }
|
||||
interface params {
|
||||
list?: item[]
|
||||
}
|
||||
|
||||
export default ({ list = [] }: params) => {
|
||||
const SwiperComp = ({ list = [] }: params) => {
|
||||
const [pageIndex, setPageIndex] = useState(1)
|
||||
const pageRef = useRef<any>(null)
|
||||
|
||||
@ -36,9 +35,9 @@ export default ({ list = [] }: params) => {
|
||||
<View className={styles.swiper}>
|
||||
{list.length > 0 && (
|
||||
<Swiper className={styles.swiper_item} circular onAnimationFinish={e => swiperChange(e)}>
|
||||
{list?.map((item) => {
|
||||
{list?.map((item, key) => {
|
||||
return (
|
||||
<SwiperItem>
|
||||
<SwiperItem key={key}>
|
||||
<View className={styles.image_item} onClick={onShowImage}>
|
||||
<Image mode="aspectFill" src={formatImgUrl(item, '!w400')}></Image>
|
||||
</View>
|
||||
@ -55,3 +54,5 @@ export default ({ list = [] }: params) => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default SwiperComp
|
||||
|
||||
@ -26,13 +26,19 @@ interface Params {
|
||||
swiperOnClick?: (val: item) => void
|
||||
style?: Object
|
||||
}
|
||||
export default (props: Params) => {
|
||||
const Details = (props: Params) => {
|
||||
const { getPhoneNumber, userInfo } = useLogin()
|
||||
|
||||
// 获取参数(有两种参数:1.商品id, 2.页面分享)
|
||||
const router = useRouter()
|
||||
const [params, setParams] = useState({ id: '', share: null })
|
||||
|
||||
// 解析短码参数
|
||||
const { fetchData: fetchDataAnalysisShortCode } = AnalysisShortCodeApi()
|
||||
const analysisShortCode = async() => {
|
||||
const res = await fetchDataAnalysisShortCode({ md5_key: router.params.share })
|
||||
setParams({ id: res.data.product_id, share: res.data })
|
||||
}
|
||||
// 判断是否是分享过来的参数
|
||||
const judgeParam = async() => {
|
||||
if (router.params.id) {
|
||||
@ -42,29 +48,9 @@ export default (props: Params) => {
|
||||
analysisShortCode()
|
||||
}
|
||||
}
|
||||
|
||||
// 解析短码参数
|
||||
const { fetchData: fetchDataAnalysisShortCode } = AnalysisShortCodeApi()
|
||||
const analysisShortCode = async() => {
|
||||
const res = await fetchDataAnalysisShortCode({ md5_key: router.params.share })
|
||||
setParams({ id: res.data.product_id, share: res.data })
|
||||
}
|
||||
|
||||
// 获取购物车数据数量
|
||||
const { getShopCount, commonData } = useCommonData()
|
||||
|
||||
useDidShow(() => {
|
||||
judgeParam()
|
||||
setShowCart(false)
|
||||
getShopCount()
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (params.id) {
|
||||
getProductDetail()
|
||||
}
|
||||
}, [params])
|
||||
|
||||
// 获取数据
|
||||
const [productInfo, setProductInfo] = useState<any>({})
|
||||
const { fetchData } = GetProductDetailApi()
|
||||
@ -74,13 +60,6 @@ export default (props: Params) => {
|
||||
Taro.stopPullDownRefresh()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (productInfo.code) {
|
||||
getShortCode()
|
||||
setCollectStatus(() => productInfo.is_favorite)
|
||||
}
|
||||
}, [productInfo])
|
||||
|
||||
// 面料名称
|
||||
const productName = useMemo(() => {
|
||||
return formatHashTag(productInfo.code, productInfo.name)
|
||||
@ -112,7 +91,17 @@ export default (props: Params) => {
|
||||
const img = formatImgUrl(shareImg, '!w400')
|
||||
setSortCode({ ...userObj.sort_code, shareShortDetail: { title: productName as string, code: resDetail.md5_key, img } })
|
||||
}
|
||||
useDidShow(() => {
|
||||
judgeParam()
|
||||
setShowCart(false)
|
||||
getShopCount()
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (params.id) {
|
||||
getProductDetail()
|
||||
}
|
||||
}, [params])
|
||||
// 授权手机号和下单
|
||||
const placeOrder = async(status = 'to_phone', e: any = {}) => {
|
||||
if (!productInfo.id) { return false }
|
||||
@ -136,14 +125,7 @@ export default (props: Params) => {
|
||||
const [collectStatus, setCollectStatus] = useState(false)
|
||||
const [collectionShow, setCollectionShow] = useState(false)
|
||||
const { fetchData: addFavoritefetchData } = AddFavoriteApi()
|
||||
const openCollection = () => {
|
||||
if (productInfo.is_favorite) {
|
||||
delFavoriteProduct()
|
||||
}
|
||||
else {
|
||||
setCollectionShow(true)
|
||||
}
|
||||
}
|
||||
|
||||
const onAdd = useCallback(
|
||||
async(val) => {
|
||||
const res = await addFavoritefetchData({ favorite_id: val.id, product_id: Number(params.id) })
|
||||
@ -160,6 +142,13 @@ export default (props: Params) => {
|
||||
},
|
||||
[params],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (productInfo.code) {
|
||||
getShortCode()
|
||||
setCollectStatus(() => productInfo.is_favorite)
|
||||
}
|
||||
}, [productInfo])
|
||||
const closeCollection = useCallback(() => {
|
||||
setCollectionShow(false)
|
||||
}, [])
|
||||
@ -173,7 +162,14 @@ export default (props: Params) => {
|
||||
alert.none('已取消收藏')
|
||||
}
|
||||
}
|
||||
|
||||
const openCollection = () => {
|
||||
if (productInfo.is_favorite) {
|
||||
delFavoriteProduct()
|
||||
}
|
||||
else {
|
||||
setCollectionShow(true)
|
||||
}
|
||||
}
|
||||
// 页面下拉刷新
|
||||
usePullDownRefresh(() => {
|
||||
getProductDetail()
|
||||
@ -288,3 +284,5 @@ export default (props: Params) => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Details
|
||||
|
||||
@ -7,7 +7,7 @@ interface Param {
|
||||
onSelect?: (val: number) => void
|
||||
defaultValue?: 0|1|2
|
||||
}
|
||||
export default memo(({ onSelect, defaultValue = 0 }: Param) => {
|
||||
const ShipmentMode = ({ onSelect, defaultValue = 0 }: Param) => {
|
||||
// 收货方法 0:没选择, 1:自提,2:物流
|
||||
const shipmentMode = useRef([
|
||||
{ value: 1, label: '上门自提', selected: false },
|
||||
@ -24,9 +24,10 @@ export default memo(({ onSelect, defaultValue = 0 }: Param) => {
|
||||
return (
|
||||
<View className={styles.order_title}>
|
||||
<Text>收货方式</Text>
|
||||
{shipmentMode.current.map((item) => {
|
||||
return <View className={classnames(styles.order_status, (selectValue == item.value) && styles.order_status_selected)} onClick={() => selectShipmentMode(item.value)}>{item.label}</View>
|
||||
{shipmentMode.current.map((item, key) => {
|
||||
return <View key={key} className={classnames(styles.order_status, (selectValue == item.value) && styles.order_status_selected)} onClick={() => selectShipmentMode(item.value)}>{item.label}</View>
|
||||
})}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ShipmentMode)
|
||||
|
||||
@ -10,7 +10,7 @@ import { getParam } from '@/common/system'
|
||||
import { EditSaleOrderAddressApi, EditSaleOrderShipmentModeApi } from '@/api/order'
|
||||
import useLogin from '@/use/useLogin'
|
||||
|
||||
export default () => {
|
||||
const EditOrder = () => {
|
||||
useLogin()
|
||||
// 获取临时传递的数据
|
||||
const params = getParam()
|
||||
@ -91,3 +91,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default EditOrder
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { Image, View } from '@tarojs/components'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
export default () => {
|
||||
const Product = () => {
|
||||
return (
|
||||
<View className={styles.products_list}>
|
||||
{new Array(10).fill('').map((item) => {
|
||||
{new Array(10).fill('').map((item, index) => {
|
||||
return (
|
||||
<View className={styles.products_item}>
|
||||
<View key={index} className={styles.products_item}>
|
||||
<View className={styles.item_img}>
|
||||
<Image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp01%2F1ZZQ214233446-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651827249&t=b2fc2a3672dc8ced9e0f37ce7e2ff901" />
|
||||
<View className={styles.num}>230色</View>
|
||||
@ -28,3 +28,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Product
|
||||
|
||||
@ -13,7 +13,7 @@ interface Param {
|
||||
|
||||
type ParamProduct = Omit<Param, 'open'>
|
||||
|
||||
export default (option: Param) => {
|
||||
const ProductClass = (option: Param) => {
|
||||
const { open = false, onOpenClick, onSelect, list, defaultSelectId } = option
|
||||
const getSelect = useCallback((id) => {
|
||||
onSelect?.(id)
|
||||
@ -68,7 +68,7 @@ const ProductClassLine = memo((option: ParamProduct) => {
|
||||
<View
|
||||
id={`tabs_${item.id}`}
|
||||
className={classnames(styles.product_class_item, item.id == selectInfo.selected ? styles.product_class_item_selected : '')}
|
||||
onClick={() => clickEvent({ item, index })}
|
||||
onClick={() => clickEvent({ item, index })}
|
||||
>
|
||||
{item.name}
|
||||
</View>
|
||||
@ -100,10 +100,11 @@ const ProductClassBlock = (option: ParamProduct & { open: boolean }) => {
|
||||
<View className={styles.product_class_block_con}>
|
||||
<ScrollView scrollY className={styles.product_class_scroll}>
|
||||
<View className={styles.product_class_list}>
|
||||
{list?.map(item => (
|
||||
{list?.map((item, index) => (
|
||||
<View
|
||||
key={index}
|
||||
className={classnames(styles.product_class_item, item.id == selectInfo ? styles.product_class_item_selected : '')}
|
||||
onClick={() => clickEvent(item)}
|
||||
onClick={() => clickEvent(item)}
|
||||
>
|
||||
{item.name}
|
||||
</View>
|
||||
@ -119,3 +120,5 @@ const ProductClassBlock = (option: ParamProduct & { open: boolean }) => {
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProductClass
|
||||
|
||||
@ -14,23 +14,8 @@ import { GetProductKindListApi, GetProductListApi } from '@/api/material'
|
||||
import useLogin from '@/use/useLogin'
|
||||
import { dataLoadingStatus } from '@/common/util'
|
||||
|
||||
export default () => {
|
||||
const Index = () => {
|
||||
useLogin()
|
||||
useEffect(() => {
|
||||
categoryList()
|
||||
}, [])
|
||||
|
||||
// 获取面料种类
|
||||
const [kindData, setKindData] = useState<any>({ list: [], defaultId: 0 })
|
||||
const { fetchData } = GetProductKindListApi()
|
||||
const categoryList = async() => {
|
||||
const res = await fetchData()
|
||||
if (res.data?.list) {
|
||||
setKindData({ ...kindData, list: res.data.list, defaultId: res.data.list[0].id })
|
||||
setFiltrate({ ...filtrate, product_kind_id: res.data.list[0].id })
|
||||
product_kind_id_ref.current = res.data.list[0].id
|
||||
}
|
||||
}
|
||||
|
||||
// 获取面料列表
|
||||
const product_kind_id_ref = useRef(0)
|
||||
@ -39,16 +24,6 @@ export default () => {
|
||||
const [filtrate, setFiltrate] = useState({ product_kind_id: 0, size: 5, page: 1 })
|
||||
const pageNum = useRef({ size: filtrate.size, page: filtrate.page })
|
||||
const { fetchData: productFetchData, state: productState } = GetProductListApi()
|
||||
// 获取数据方法
|
||||
const getProductList = async() => {
|
||||
const { data, total } = await productFetchData(filtrate)
|
||||
setProductData({ ...productData, list: data.list, total })
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
// 监听查询条件
|
||||
useEffect(() => {
|
||||
if (filtrate.product_kind_id) { getProductList() }
|
||||
}, [filtrate])
|
||||
|
||||
// 点击面料类型
|
||||
const getProductKindId = useCallback((e) => {
|
||||
@ -95,7 +70,30 @@ export default () => {
|
||||
product_kind_id_next_ref.current = id
|
||||
setFiltrate(list => ({ ...list, size: 5, product_kind_id: kind_id }))
|
||||
}, [])
|
||||
|
||||
// 获取面料种类
|
||||
const [kindData, setKindData] = useState<any>({ list: [], defaultId: 0 })
|
||||
const { fetchData } = GetProductKindListApi()
|
||||
const categoryList = async() => {
|
||||
const res = await fetchData()
|
||||
if (res.data?.list) {
|
||||
setKindData({ ...kindData, list: res.data.list, defaultId: res.data.list[0].id })
|
||||
setFiltrate({ ...filtrate, product_kind_id: res.data.list[0].id })
|
||||
product_kind_id_ref.current = res.data.list[0].id
|
||||
}
|
||||
}
|
||||
// 获取数据方法
|
||||
const getProductList = async() => {
|
||||
const { data, total } = await productFetchData(filtrate)
|
||||
setProductData({ ...productData, list: data.list, total })
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
// 监听查询条件
|
||||
useEffect(() => {
|
||||
if (filtrate.product_kind_id) { getProductList() }
|
||||
}, [filtrate])
|
||||
useEffect(() => {
|
||||
categoryList()
|
||||
}, [])
|
||||
return (
|
||||
<MoveBtn onClick={() => setShowShopCart(!showShopCart)}>
|
||||
<View className={styles.main}>
|
||||
@ -130,3 +128,5 @@ export default () => {
|
||||
</MoveBtn>
|
||||
)
|
||||
}
|
||||
|
||||
export default Index
|
||||
|
||||
@ -17,7 +17,7 @@ import { SUBSCRIPTION_MESSAGE_SCENE } from '@/common/enum'
|
||||
import { UseSubscriptionMessage } from '@/use/useCommon'
|
||||
import { throttle } from '@/common/util'
|
||||
|
||||
export default () => {
|
||||
const Comfirm = () => {
|
||||
const [showDesc, setShowDesc] = useState(false)
|
||||
// 下单信息
|
||||
interface OrderParams { address_id?: number; remark?: string; sale_mode?: number; shipment_mode?: number; list?: any[] }
|
||||
@ -30,6 +30,15 @@ export default () => {
|
||||
}
|
||||
const param = getParam()
|
||||
const idsAndSaleModel = useRef<orderPreParam>({ shopping_cart_product_color_list: [], sale_mode: 0 })
|
||||
// 获取销售预览订单
|
||||
const [preViewOrder, setPreViewOrder] = useState<any>() // 获取到的原始数据
|
||||
const { fetchData } = SaleOrderPreViewApi()
|
||||
const getSaleOrderPreView = async() => {
|
||||
if (idsAndSaleModel.current.shopping_cart_product_color_list?.length > 0) {
|
||||
const res = await fetchData(idsAndSaleModel.current)
|
||||
setPreViewOrder(res.data)
|
||||
}
|
||||
}
|
||||
useDidShow(async() => {
|
||||
idsAndSaleModel.current = { shopping_cart_product_color_list: [], sale_mode: 0 } // 初始化
|
||||
idsAndSaleModel.current.sale_mode = Number(param?.sale_mode)
|
||||
@ -42,29 +51,6 @@ export default () => {
|
||||
setSubmitOrderData(val => ({ ...val, sale_mode: param?.sale_mode }))
|
||||
})
|
||||
|
||||
// 获取销售预览订单
|
||||
const [preViewOrder, setPreViewOrder] = useState<any>() // 获取到的原始数据
|
||||
const { fetchData } = SaleOrderPreViewApi()
|
||||
const getSaleOrderPreView = async() => {
|
||||
if (idsAndSaleModel.current.shopping_cart_product_color_list?.length > 0) {
|
||||
const res = await fetchData(idsAndSaleModel.current)
|
||||
setPreViewOrder(res.data)
|
||||
}
|
||||
}
|
||||
|
||||
// 监听获取到的数据
|
||||
useEffect(() => {
|
||||
if (preViewOrder) {
|
||||
formatData()
|
||||
getDataList()
|
||||
setSubmitOrderData(val => ({
|
||||
...val,
|
||||
address_id: preViewOrder.default_address.id,
|
||||
shipment_mode: preViewOrder.shipment_mode || 2,
|
||||
}))
|
||||
}
|
||||
}, [preViewOrder])
|
||||
|
||||
// 格式化数据格式
|
||||
const [formatPreViewOrder, setFormatPreViewOrder] = useState<any>() // 格式化后的数据
|
||||
const formatData = () => {
|
||||
@ -105,8 +91,8 @@ export default () => {
|
||||
// 获取提交格式数据列表
|
||||
const getDataList = () => {
|
||||
const list: { shopping_cart_product_color_id: number }[] = []
|
||||
preViewOrder.product_list?.map((item) => {
|
||||
item.product_colors?.map((colorItem) => {
|
||||
preViewOrder.product_list?.forEach((item) => {
|
||||
item.product_colors?.forEach((colorItem) => {
|
||||
list.push({ shopping_cart_product_color_id: colorItem.id })
|
||||
})
|
||||
})
|
||||
@ -167,7 +153,7 @@ export default () => {
|
||||
const res = await saleOrderFetchData(submitOrderData)
|
||||
if (res.success) {
|
||||
goLink('/pages/order/index', { id: res.data.id }, 'redirectTo')
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
@ -178,7 +164,18 @@ export default () => {
|
||||
usePullDownRefresh(() => {
|
||||
getSaleOrderPreView()
|
||||
})
|
||||
|
||||
// 监听获取到的数据
|
||||
useEffect(() => {
|
||||
if (preViewOrder) {
|
||||
formatData()
|
||||
getDataList()
|
||||
setSubmitOrderData(val => ({
|
||||
...val,
|
||||
address_id: preViewOrder.default_address.id,
|
||||
shipment_mode: preViewOrder.shipment_mode || 2,
|
||||
}))
|
||||
}
|
||||
}, [preViewOrder])
|
||||
return (
|
||||
<View className={styles.order_main}>
|
||||
<AddressInfoDetail orderInfo={defaultAddress} onSelect={getAddress} onChangeShipmentMode={selectShipmentMode} status={1} />
|
||||
@ -208,3 +205,5 @@ export default () => {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default Comfirm
|
||||
|
||||
@ -19,14 +19,9 @@ interface Param {
|
||||
defaultValue?: AddressInfoParam|null // 默认值
|
||||
disabled?: false|true // true禁用后只用于展示
|
||||
}
|
||||
|
||||
export default memo(({ onSelect, defaultValue = null, disabled = false }: Param) => {
|
||||
const AddressInfo = ({ onSelect, defaultValue = null, disabled = false }: Param) => {
|
||||
const [showAddressList, setShowAddressList] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setUserInfo(() => defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
// 选择地址
|
||||
const [userInfo, setUserInfo] = useState<any>()
|
||||
const getAddress = useCallback((val) => {
|
||||
@ -43,25 +38,28 @@ export default memo(({ onSelect, defaultValue = null, disabled = false }: Param)
|
||||
const changeShow = () => {
|
||||
if (!disabled) { setShowAddressList(() => true) }
|
||||
}
|
||||
useEffect(() => {
|
||||
setUserInfo(() => defaultValue)
|
||||
}, [defaultValue])
|
||||
return (
|
||||
<View>
|
||||
<View className={styles.order_address} onClick={() => changeShow()}>
|
||||
<View className={classnames(styles.order_address_icon, 'iconfont icon-daohang')}></View>
|
||||
{!userInfo
|
||||
&& <>
|
||||
<View className={styles.order_address_text_no}>请选择收货地址及信息</View>
|
||||
<View className={classnames(styles.order_address_more_icon, 'iconfont icon-a-moreback')}></View>
|
||||
</>
|
||||
|| <>
|
||||
<View className={styles.order_address_text_con}>
|
||||
<View className={styles.order_address_text_name}>
|
||||
<Text>{userInfo?.name}</Text>
|
||||
<Text>{userInfo?.phone}</Text>
|
||||
</View>
|
||||
<View className={styles.order_address_text_title}>{formatAddress}</View>
|
||||
</View>
|
||||
<View className={styles.updateBtn}>修改</View>
|
||||
</>}
|
||||
? <>
|
||||
<View className={styles.order_address_text_no}>请选择收货地址及信息</View>
|
||||
<View className={classnames(styles.order_address_more_icon, 'iconfont icon-a-moreback')}></View>
|
||||
</>
|
||||
: <>
|
||||
<View className={styles.order_address_text_con}>
|
||||
<View className={styles.order_address_text_name}>
|
||||
<Text>{userInfo?.name}</Text>
|
||||
<Text>{userInfo?.phone}</Text>
|
||||
</View>
|
||||
<View className={styles.order_address_text_title}>{formatAddress}</View>
|
||||
</View>
|
||||
<View className={styles.updateBtn}>修改</View>
|
||||
</>}
|
||||
</View>
|
||||
{!disabled && <Popup show={showAddressList} showTitle={false} onClose={() => setShowAddressList(false)}>
|
||||
<View className={styles.order_address_list}>
|
||||
@ -71,4 +69,5 @@ export default memo(({ onSelect, defaultValue = null, disabled = false }: Param)
|
||||
</Popup>}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(AddressInfo)
|
||||
|
||||
@ -46,194 +46,190 @@ const {
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusCancel,
|
||||
} = ORDER_STATUS
|
||||
const AddressInfoDetail = ({ onSelect, onChangeShipmentMode, orderInfo, status = 2, disabled = false, onLogistics }: Param, ref) => {
|
||||
const [addressInfo, setAddressInfo] = useState<any>()
|
||||
const { fetchData: addressFetchData } = EditSaleOrderAddressApi()
|
||||
|
||||
export default memo(
|
||||
forwardRef(({ onSelect, onChangeShipmentMode, orderInfo, status = 2, disabled = false, onLogistics }: Param, ref) => {
|
||||
const [addressInfo, setAddressInfo] = useState<any>()
|
||||
useEffect(() => {
|
||||
if (orderInfo) {
|
||||
setReceivingStatus(() => orderInfo.shipment_mode || 2)
|
||||
setAddressInfo(() => orderInfo)
|
||||
}
|
||||
}, [orderInfo])
|
||||
// 打开地址列表
|
||||
const [showAddressList, setShowAddressList] = useState(false)
|
||||
|
||||
// 打开地址列表
|
||||
const [showAddressList, setShowAddressList] = useState(false)
|
||||
const changeShow = () => {
|
||||
if (receivingStatus == 2 && !logisticsShow && limitEdit()) { setShowAddressList(() => true) }
|
||||
// 收货方法,1:自提,2物流
|
||||
const [receivingStatus, setReceivingStatus] = useState(2)
|
||||
|
||||
// 当没有地址时获取地址列表中的第一个数据
|
||||
const { fetchData: addressListFetchData } = addressListApi()
|
||||
const getAddressListOne = async() => {
|
||||
if (orderInfo?.address_detail) { return true }
|
||||
const res = await addressListFetchData()
|
||||
if (res.data.list && res.data.list?.length > 0) {
|
||||
const info = res.data.list[0]
|
||||
await addressFetchData({ id: orderInfo?.id, address_id: info.id })
|
||||
setAddressInfo(e => ({ ...e, ...info, target_user_name: info.name, target_user_phone: info.phone }))
|
||||
return true
|
||||
}
|
||||
|
||||
// 把内部方法提供给外部
|
||||
useImperativeHandle(ref, () => ({
|
||||
changeShow,
|
||||
}))
|
||||
|
||||
// 收货方法,1:自提,2物流
|
||||
const [receivingStatus, setReceivingStatus] = useState(2)
|
||||
const { fetchData: shipmentModeFetchData } = EditSaleOrderShipmentModeApi()
|
||||
const onReceivingStatus = async(value, e) => {
|
||||
e.stopPropagation()
|
||||
if (limitEdit()) { changeReceivingStatus(value) }
|
||||
else {
|
||||
Taro.showModal({
|
||||
content: '您还没有地址,请前去新增地址',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
goLink('/pages/addressManager/index')
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
const { fetchData: shipmentModeFetchData } = EditSaleOrderShipmentModeApi()
|
||||
|
||||
// 当没有地址时获取地址列表中的第一个数据
|
||||
const { fetchData: addressListFetchData } = addressListApi()
|
||||
const getAddressListOne = async() => {
|
||||
if (orderInfo?.address_detail) { return true }
|
||||
const res = await addressListFetchData()
|
||||
if (res.data.list && res.data.list?.length > 0) {
|
||||
const info = res.data.list[0]
|
||||
await addressFetchData({ id: orderInfo?.id, address_id: info.id })
|
||||
setAddressInfo(e => ({ ...e, ...info, target_user_name: info.name, target_user_phone: info.phone }))
|
||||
return true
|
||||
}
|
||||
else {
|
||||
Taro.showModal({
|
||||
content: '您还没有地址,请前去新增地址',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
goLink('/pages/addressManager/index')
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
return false
|
||||
}
|
||||
const changeReceivingStatus = debounce(async(value) => {
|
||||
if (!orderInfo || value == receivingStatus) { return false }
|
||||
if (status == 1) {
|
||||
onChangeShipmentMode?.(value)
|
||||
setReceivingStatus(value)
|
||||
return false
|
||||
}
|
||||
|
||||
const changeReceivingStatus = debounce(async(value) => {
|
||||
if (!orderInfo || value == receivingStatus) { return false }
|
||||
if (status == 1) {
|
||||
onChangeShipmentMode?.(value)
|
||||
setReceivingStatus(value)
|
||||
return false
|
||||
}
|
||||
if (value == 2) {
|
||||
const res = await getAddressListOne()
|
||||
if (!res) { return false }
|
||||
}
|
||||
alert.loading('正在修改')
|
||||
const res = await shipmentModeFetchData({ id: orderInfo.id, shipment_mode: value })
|
||||
if (res.success) {
|
||||
alert.success('收货方式修改成功')
|
||||
onChangeShipmentMode?.(value)
|
||||
setReceivingStatus(() => value)
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}, 300)
|
||||
|
||||
// 修改地址
|
||||
const [addressId, setAddressId] = useState(0)
|
||||
const { fetchData: addressFetchData } = EditSaleOrderAddressApi()
|
||||
const getAddress = async(value) => {
|
||||
if (!orderInfo) { return false }
|
||||
if (status == 1) {
|
||||
setShowAddressList(() => false)
|
||||
setAddressId(value.id)
|
||||
setAddressInfo(e => ({ ...e, ...value, target_user_name: value.name, target_user_phone: value.phone }))
|
||||
onSelect?.(value)
|
||||
return false
|
||||
}
|
||||
alert.loading('正在修改')
|
||||
const res = await addressFetchData({ id: orderInfo.id, address_id: value.id })
|
||||
if (res.success) {
|
||||
alert.success('地址修改成功')
|
||||
onSelect?.(value)
|
||||
setShowAddressList(() => false)
|
||||
setAddressId(value.id)
|
||||
setAddressInfo(e => ({ ...e, ...value, target_user_name: value.name, target_user_phone: value.phone }))
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
if (value == 2) {
|
||||
const res = await getAddressListOne()
|
||||
if (!res) { return false }
|
||||
}
|
||||
|
||||
// 根据订单状态判断是否可修改
|
||||
const limitEdit = () => {
|
||||
const res = [
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
].includes(orderInfo?.status as number)
|
||||
if (!res && status != 1) { alert.none('该订单状态不能修改地址!') }
|
||||
return status == 1 ? true : res
|
||||
alert.loading('正在修改')
|
||||
const res = await shipmentModeFetchData({ id: orderInfo.id, shipment_mode: value })
|
||||
if (res.success) {
|
||||
alert.success('收货方式修改成功')
|
||||
onChangeShipmentMode?.(value)
|
||||
setReceivingStatus(() => value)
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}, 300)
|
||||
|
||||
// 根据订单状态判断是否显示物流
|
||||
const logisticsShowList = [
|
||||
SaleOrderStatusWaitingReceipt.value,
|
||||
SaleOrderStatusAlreadyReceipt.value,
|
||||
SaleOrderStatusComplete.value,
|
||||
SaleOrderStatusRefund.value,
|
||||
]
|
||||
const logisticsShow = useMemo(() => {
|
||||
return logisticsShowList.includes(orderInfo?.status as number)
|
||||
}, [orderInfo])
|
||||
// 修改地址
|
||||
const [addressId, setAddressId] = useState(0)
|
||||
const getAddress = async(value) => {
|
||||
if (!orderInfo) { return false }
|
||||
if (status == 1) {
|
||||
setShowAddressList(() => false)
|
||||
setAddressId(value.id)
|
||||
setAddressInfo(e => ({ ...e, ...value, target_user_name: value.name, target_user_phone: value.phone }))
|
||||
onSelect?.(value)
|
||||
return false
|
||||
}
|
||||
alert.loading('正在修改')
|
||||
const res = await addressFetchData({ id: orderInfo.id, address_id: value.id })
|
||||
if (res.success) {
|
||||
alert.success('地址修改成功')
|
||||
onSelect?.(value)
|
||||
setShowAddressList(() => false)
|
||||
setAddressId(value.id)
|
||||
setAddressInfo(e => ({ ...e, ...value, target_user_name: value.name, target_user_phone: value.phone }))
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
|
||||
// 地址格式
|
||||
const formatAddress = useMemo(() => {
|
||||
if (receivingStatus == 2) {
|
||||
return addressInfo?.address_detail ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
|
||||
}
|
||||
else {
|
||||
return addressInfo?.take_goods_address
|
||||
}
|
||||
}, [receivingStatus, addressInfo])
|
||||
|
||||
return (
|
||||
<View>
|
||||
<View className={styles.order_address} onClick={() => changeShow()}>
|
||||
<View className={classnames(styles.order_address_icon, 'iconfont', receivingStatus == 2 ? 'icon-daohang' : 'icon-fahuo')}></View>
|
||||
<View className={styles.order_address_text_con}>
|
||||
<View className={styles.order_address_text_title}>
|
||||
<Text className={classnames(styles.address_text, styles.address_text_no)}>{formatAddress || '请选择收货地址及信息'}</Text>
|
||||
{receivingStatus == 2 && !logisticsShow && <Text className={classnames(styles.moreIconfont, 'iconfont icon-a-moreback')}></Text>}
|
||||
</View>
|
||||
<View className={styles.order_address_text_name}>
|
||||
<Text>{receivingStatus == 1 ? '谭先生' : addressInfo?.target_user_name}</Text>
|
||||
<Text>{receivingStatus == 1 ? addressInfo?.take_goods_phone : addressInfo?.target_user_phone}</Text>
|
||||
</View>
|
||||
// 根据订单状态判断是否可修改
|
||||
const limitEdit = () => {
|
||||
const res = [
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
].includes(orderInfo?.status as number)
|
||||
if (!res && status != 1) { alert.none('该订单状态不能修改地址!') }
|
||||
return status == 1 ? true : res
|
||||
}
|
||||
const onReceivingStatus = async(value, e) => {
|
||||
e.stopPropagation()
|
||||
if (limitEdit()) { changeReceivingStatus(value) }
|
||||
}
|
||||
// 根据订单状态判断是否显示物流
|
||||
const logisticsShowList = [
|
||||
SaleOrderStatusWaitingReceipt.value,
|
||||
SaleOrderStatusAlreadyReceipt.value,
|
||||
SaleOrderStatusComplete.value,
|
||||
SaleOrderStatusRefund.value,
|
||||
]
|
||||
const logisticsShow = useMemo(() => {
|
||||
return logisticsShowList.includes(orderInfo?.status as number)
|
||||
}, [orderInfo])
|
||||
const changeShow = () => {
|
||||
if (receivingStatus == 2 && !logisticsShow && limitEdit()) { setShowAddressList(() => true) }
|
||||
}
|
||||
// 地址格式
|
||||
const formatAddress = useMemo(() => {
|
||||
if (receivingStatus == 2) {
|
||||
return addressInfo?.address_detail ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
|
||||
}
|
||||
else {
|
||||
return addressInfo?.take_goods_address
|
||||
}
|
||||
}, [receivingStatus, addressInfo])
|
||||
useEffect(() => {
|
||||
if (orderInfo) {
|
||||
setReceivingStatus(() => orderInfo.shipment_mode || 2)
|
||||
setAddressInfo(() => orderInfo)
|
||||
}
|
||||
}, [orderInfo])
|
||||
// 把内部方法提供给外部
|
||||
useImperativeHandle(ref, () => ({
|
||||
changeShow,
|
||||
}))
|
||||
return (
|
||||
<View>
|
||||
<View className={styles.order_address} onClick={() => changeShow()}>
|
||||
<View className={classnames(styles.order_address_icon, 'iconfont', receivingStatus == 2 ? 'icon-daohang' : 'icon-fahuo')}></View>
|
||||
<View className={styles.order_address_text_con}>
|
||||
<View className={styles.order_address_text_title}>
|
||||
<Text className={classnames(styles.address_text, styles.address_text_no)}>{formatAddress || '请选择收货地址及信息'}</Text>
|
||||
{receivingStatus == 2 && !logisticsShow && <Text className={classnames(styles.moreIconfont, 'iconfont icon-a-moreback')}></Text>}
|
||||
</View>
|
||||
{(!logisticsShow && (
|
||||
<View className={styles.updateBtn}>
|
||||
<View className={styles.updateBtn_list}>
|
||||
<View
|
||||
className={classnames(styles.updateBtn_item, receivingStatus == 1 && styles.updateBtn_item_select)}
|
||||
onClick={e => onReceivingStatus(1, e)}
|
||||
>
|
||||
<View className={styles.order_address_text_name}>
|
||||
<Text>{receivingStatus == 1 ? '谭先生' : addressInfo?.target_user_name}</Text>
|
||||
<Text>{receivingStatus == 1 ? addressInfo?.take_goods_phone : addressInfo?.target_user_phone}</Text>
|
||||
</View>
|
||||
</View>
|
||||
{(!logisticsShow && (
|
||||
<View className={styles.updateBtn}>
|
||||
<View className={styles.updateBtn_list}>
|
||||
<View
|
||||
className={classnames(styles.updateBtn_item, receivingStatus == 1 && styles.updateBtn_item_select)}
|
||||
onClick={e => onReceivingStatus(1, e)}
|
||||
>
|
||||
自提
|
||||
</View>
|
||||
<View
|
||||
className={classnames(styles.updateBtn_item, receivingStatus == 2 && styles.updateBtn_item_select)}
|
||||
onClick={e => onReceivingStatus(2, e)}
|
||||
>
|
||||
物流
|
||||
</View>
|
||||
</View>
|
||||
<View style={{ transform: receivingStatus == 1 ? 'translateX(0)' : 'translateX(100%)' }} className={classnames(styles.updateBtn_select)}></View>
|
||||
<View
|
||||
className={classnames(styles.updateBtn_item, receivingStatus == 2 && styles.updateBtn_item_select)}
|
||||
onClick={e => onReceivingStatus(2, e)}
|
||||
>
|
||||
物流
|
||||
</View>
|
||||
</View>
|
||||
))
|
||||
<View style={{ transform: receivingStatus == 1 ? 'translateX(0)' : 'translateX(100%)' }} className={classnames(styles.updateBtn_select)}></View>
|
||||
</View>
|
||||
))
|
||||
|| (orderInfo?.status != SaleOrderStatusRefund.value && (
|
||||
<View className={styles.logisticsBtn} onClick={onLogistics}>
|
||||
查看物流
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
<Popup show={showAddressList} showTitle={false} onClose={() => setShowAddressList(false)}>
|
||||
<View className={styles.order_address_list}>
|
||||
<View className={styles.order_address_title}>请选择收货地址</View>
|
||||
<View className={styles.addressList_con}>
|
||||
<AddressList onSelect={getAddress} id={addressId} />
|
||||
</View>
|
||||
</View>
|
||||
</Popup>
|
||||
</View>
|
||||
)
|
||||
}),
|
||||
<Popup show={showAddressList} showTitle={false} onClose={() => setShowAddressList(false)}>
|
||||
<View className={styles.order_address_list}>
|
||||
<View className={styles.order_address_title}>请选择收货地址</View>
|
||||
<View className={styles.addressList_con}>
|
||||
<AddressList onSelect={getAddress} id={addressId} />
|
||||
</View>
|
||||
</View>
|
||||
</Popup>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
export default memo(
|
||||
forwardRef(AddressInfoDetail),
|
||||
)
|
||||
|
||||
@ -23,8 +23,7 @@ interface Param {
|
||||
status: number // 订单状态
|
||||
}
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo, onRefresh }: Param) => {
|
||||
const AdvanceOrderState = ({ orderInfo, onRefresh }: Param) => {
|
||||
const { showTime, onStart, timeStatus } = useTimeCountDown()
|
||||
|
||||
// 订单状态枚举
|
||||
@ -68,4 +67,5 @@ export default memo(({ orderInfo, onRefresh }: Param) => {
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(AdvanceOrderState)
|
||||
|
||||
@ -7,7 +7,7 @@ interface Param {
|
||||
number: number // 数字
|
||||
status: 0|1|2 // 0 小型,1中型,2大
|
||||
}
|
||||
export default memo(({ number = 0, status = 1 }: Param) => {
|
||||
const AmountShow = ({ number = 0, status = 1 }: Param) => {
|
||||
const priceDom = useCallback(() => {
|
||||
const res = number.toFixed(2).split('.')
|
||||
const int_num = `${parseInt(res[0])}`
|
||||
@ -25,4 +25,5 @@ export default memo(({ number = 0, status = 1 }: Param) => {
|
||||
{priceDom()}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(AmountShow)
|
||||
|
||||
@ -14,7 +14,7 @@ interface Param {
|
||||
orderId?: number
|
||||
onSuccess?: () => void
|
||||
}
|
||||
export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
|
||||
const ApplyRefund = ({ show, onClose, orderId, onSuccess }: Param) => {
|
||||
// 提交的数据
|
||||
const submitData = useRef({
|
||||
return_explain: 0,
|
||||
@ -22,13 +22,6 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
|
||||
reason_describe: '',
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (show && orderId) {
|
||||
submitData.current.sale_order_id = orderId
|
||||
refundExplain()
|
||||
}
|
||||
}, [orderId, show])
|
||||
|
||||
// 申请退款
|
||||
const { fetchData } = ApplyRefundApi()
|
||||
const getApplyRefund = async() => {
|
||||
@ -37,7 +30,7 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
|
||||
if (res.success) {
|
||||
alert.success('申请成功')
|
||||
onSuccess?.()
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.error('申请失败')
|
||||
}
|
||||
@ -51,12 +44,6 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
|
||||
const res = await refundExplainFetchdata()
|
||||
setList(() => res.data.list)
|
||||
}
|
||||
const [reason, setReason] = useState({ id: 0, name: '' })
|
||||
const reasonSelect = useCallback((e) => {
|
||||
setReason({ ...reason, name: e.name, id: e.id })
|
||||
submitData.current.return_explain = e.id
|
||||
closeReason()
|
||||
}, [])
|
||||
|
||||
// 备注
|
||||
const getOtherReason = useCallback((val) => {
|
||||
@ -68,12 +55,17 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
|
||||
const closeReason = useCallback(() => {
|
||||
setShowReason(false)
|
||||
}, [])
|
||||
|
||||
const [reason, setReason] = useState({ id: 0, name: '' })
|
||||
const reasonSelect = useCallback((e) => {
|
||||
setReason({ ...reason, name: e.name, id: e.id })
|
||||
submitData.current.return_explain = e.id
|
||||
closeReason()
|
||||
}, [])
|
||||
// 提交
|
||||
const onSubmit = (val) => {
|
||||
if (val == 2) {
|
||||
getApplyRefund()
|
||||
}
|
||||
}
|
||||
else {
|
||||
onClose?.()
|
||||
submitData.current = {
|
||||
@ -83,7 +75,12 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (show && orderId) {
|
||||
submitData.current.sale_order_id = orderId
|
||||
refundExplain()
|
||||
}
|
||||
}, [orderId, show])
|
||||
return (
|
||||
<>
|
||||
<Popup show={show} title="申请退款" onClose={onClose}>
|
||||
@ -111,4 +108,5 @@ export default memo(({ show, onClose, orderId, onSuccess }: Param) => {
|
||||
<ReasonPopup defaultValue={reason.id} show={showReason} onClose={closeReason} list={list} title="退款说明" onSelect={reasonSelect} />
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ApplyRefund)
|
||||
|
||||
@ -17,7 +17,7 @@ interface Param {
|
||||
messageWidth?: number
|
||||
messageShow?: true|false
|
||||
}
|
||||
export default memo(({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageHeight = 70, messageWidth = 430, messageShow = false }: Param) => {
|
||||
const EstimatedAmount = ({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageHeight = 70, messageWidth = 430, messageShow = false }: Param) => {
|
||||
const [show, setShow] = useState(messageShow)
|
||||
const onClose = () => {
|
||||
setShow(false)
|
||||
@ -28,14 +28,6 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
|
||||
|
||||
const [style, setStyle] = useState<{ top: string }>()
|
||||
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
getDomDes('#message')
|
||||
}
|
||||
else {
|
||||
setStyle(() => ({ top: '0' }))
|
||||
}
|
||||
}, [show])
|
||||
// 设置弹出层高度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
@ -46,6 +38,14 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
|
||||
}).exec()
|
||||
}, 0)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
getDomDes('#message')
|
||||
}
|
||||
else {
|
||||
setStyle(() => ({ top: '0' }))
|
||||
}
|
||||
}, [show])
|
||||
return (
|
||||
<>
|
||||
<View className={styles.order_price}>
|
||||
@ -61,4 +61,5 @@ export default memo(({ number = 0, titleStatus = true, title = '', messageTitle
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(EstimatedAmount)
|
||||
|
||||
@ -28,8 +28,7 @@ interface Param {
|
||||
order: OrderParam
|
||||
comfirm?: boolean // 是否是确认订单页面使用
|
||||
}
|
||||
|
||||
export default memo(({ order, comfirm = false }: Param) => {
|
||||
const KindList = ({ order, comfirm = false }: Param) => {
|
||||
const {
|
||||
SaleOrderStatusBooking, // 待接单
|
||||
SaleOrderStatusArranging, // 配布中
|
||||
@ -171,12 +170,12 @@ export default memo(({ order, comfirm = false }: Param) => {
|
||||
(weight) => {
|
||||
if (order.sale_mode == 2) {
|
||||
const showWeight = [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusBooking.value, SaleOrderStatusArranging.value].includes(order.status)
|
||||
return showWeight
|
||||
return showWeight
|
||||
? (
|
||||
<View className={styles.order_list_item_price_dg}>
|
||||
; <Text>≈{formatWeightDiv(weight)}kg</Text>
|
||||
</View>
|
||||
)
|
||||
)
|
||||
: (
|
||||
<></>
|
||||
)
|
||||
@ -239,4 +238,5 @@ export default memo(({ order, comfirm = false }: Param) => {
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(KindList)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Button, MovableArea, MovableView, View } from '@tarojs/components'
|
||||
import Taro, { useReady } from '@tarojs/taro'
|
||||
import type { ReactElement } from 'react'
|
||||
import type { ReactElement } from 'react'
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
@ -9,7 +9,7 @@ interface param {
|
||||
children?: ReactElement | null
|
||||
orderInfo?: any
|
||||
}
|
||||
export default ({ children = null, orderInfo }: param) => {
|
||||
const MovableAreaBtn = ({ children = null, orderInfo }: param) => {
|
||||
const [screenHeight, setScreenHeight] = useState(0)
|
||||
const screenWidthRef = useRef(0)
|
||||
useLayoutEffect(() => {
|
||||
@ -31,10 +31,12 @@ export default ({ children = null, orderInfo }: param) => {
|
||||
openType="contact"
|
||||
sendMessageTitle={orderInfo?.order_no}
|
||||
showMessageCard
|
||||
sendMessagePath={`/pages/order/index?id=${orderInfo?.id}`}
|
||||
sendMessagePath={`/pages/order/index?id=${orderInfo?.id}`}
|
||||
></Button>
|
||||
</View>
|
||||
</MovableView>
|
||||
</MovableArea>
|
||||
)
|
||||
}
|
||||
|
||||
export default MovableAreaBtn
|
||||
|
||||
@ -17,7 +17,7 @@ interface Param {
|
||||
transfer_remittance_account: string
|
||||
}
|
||||
}
|
||||
export default memo(({ show = true, onClose, offlineInfo }: Param) => {
|
||||
const OfflinePay = ({ show = true, onClose, offlineInfo }: Param) => {
|
||||
// 复制功能
|
||||
const clipboardData = () => {
|
||||
Taro.setClipboardData({
|
||||
@ -53,4 +53,5 @@ export default memo(({ show = true, onClose, offlineInfo }: Param) => {
|
||||
</View>
|
||||
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(OfflinePay)
|
||||
|
||||
@ -24,8 +24,7 @@ interface Param {
|
||||
account_period_time?: string // 还款日期
|
||||
}
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => {
|
||||
const OrderState = ({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => {
|
||||
useEffect(() => {
|
||||
console.log('orderInfo33::', orderInfo)
|
||||
}, [orderInfo])
|
||||
@ -51,7 +50,7 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s
|
||||
<>
|
||||
{(dataList?.length > 0) && <View className={styles.order_flow_state}>
|
||||
<View className={classnames(styles.order_status_list, showMore && styles.order_status_list_show)}>
|
||||
{dataList.map((item, index) => <View className={styles.order_status_item}>
|
||||
{dataList.map((item, index) => <View className={styles.order_status_item} key={index}>
|
||||
{(dataList.length > 1) && <View className={classnames(styles.order_status_tail, (index == 0) && styles.order_status_tail_end)}></View>}
|
||||
{(dataList.length != (index + 1)) && <View className={styles.order_status_line}></View>}
|
||||
<View className={styles.order_status_content}>
|
||||
@ -62,7 +61,7 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s
|
||||
</View>)}
|
||||
</View>
|
||||
{(dataList.length > 2) && <View className={styles.more} onClick={() => changeMore()}>
|
||||
<Text>{showMore && '收起详情' || '点击查看详情'}</Text>
|
||||
<Text>{showMore ? '收起详情' : '点击查看详情'}</Text>
|
||||
<Text className={classnames('iconfont icon-a-moreback', styles.miconfonts, showMore && styles.open_miconfonts)}></Text>
|
||||
</View>}
|
||||
<View className={styles.image_tag}>
|
||||
@ -76,4 +75,5 @@ export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, s
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(OrderState)
|
||||
|
||||
@ -7,7 +7,7 @@ import { REFUND_STATUS_ORDER } from '@/common/enum'
|
||||
interface Param {
|
||||
status?: number
|
||||
}
|
||||
export default memo(({ status = 0 }: Param) => {
|
||||
const OrderStatusTag = ({ status = 0 }: Param) => {
|
||||
const {
|
||||
ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款
|
||||
ReturnApplyOrderTypeReturnForRefund, // 退货退款
|
||||
@ -21,4 +21,5 @@ export default memo(({ status = 0 }: Param) => {
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(OrderStatusTag)
|
||||
|
||||
@ -34,7 +34,7 @@ interface OrderInfo {
|
||||
}
|
||||
|
||||
type PayStatus = 1 | 2 | 3 | 4 | 5 | null // 1:预存款, 2:账期,3:线下汇款, 4:扫码支付, 5:货到付款
|
||||
export default memo(({ show = false, onClose, orderInfo, onSubmitSuccess }: Param) => {
|
||||
const Payment = ({ show = false, onClose, orderInfo, onSubmitSuccess }: Param) => {
|
||||
// 支付方式枚举
|
||||
const { PaymentMethodPreDeposit, PaymentMethodAccountPeriod, PaymentMethodCashOnDelivery } = PAYMENT_METHOD
|
||||
// 订单状态枚举
|
||||
@ -69,7 +69,7 @@ export default memo(({ show = false, onClose, orderInfo, onSubmitSuccess }: Para
|
||||
// 有应收单id时用应收单获取数据
|
||||
const { data } = await orderFetchData({ id: orderInfo?.should_collect_order_id })
|
||||
setPayInfo(() => data)
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 用预付单id获取支付信息
|
||||
const { data } = await prepayOrderFetchData({ id: orderInfo?.pre_collect_order_id })
|
||||
@ -125,14 +125,14 @@ export default memo(({ show = false, onClose, orderInfo, onSubmitSuccess }: Para
|
||||
let res: any = null
|
||||
if (orderInfo?.should_collect_order_id) {
|
||||
res = await submitFetchData(submitData)
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = await submitPrepayOrderFetchData(submitData)
|
||||
}
|
||||
if (res.success) {
|
||||
alert.success('支付成功')
|
||||
onSubmitSuccess?.()
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
@ -264,4 +264,5 @@ export default memo(({ show = false, onClose, orderInfo, onSubmitSuccess }: Para
|
||||
<ScanPay orderInfo={onlinePayData} show={scanPayShow} onClose={() => setScanPayShow(false)} />
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(Payment)
|
||||
|
||||
@ -13,7 +13,7 @@ interface ReasonInfoParam {
|
||||
onSelect?: (val: object) => void // 选择
|
||||
defaultValue?: number // 默认选中
|
||||
}
|
||||
export default memo(({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
|
||||
const ReasonPopup = ({ show = false, onClose, title = '', list = [], onSelect, defaultValue }: ReasonInfoParam) => {
|
||||
return (
|
||||
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
|
||||
<View className={styles.reason_return_con}>
|
||||
@ -26,4 +26,5 @@ export default memo(({ show = false, onClose, title = '', list = [], onSelect, d
|
||||
</View>
|
||||
</Popup>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ReasonPopup)
|
||||
|
||||
@ -8,17 +8,13 @@ interface Param {
|
||||
onSave?: (val: string) => void
|
||||
defaultValue?: string
|
||||
}
|
||||
export default ({ onBlur, onSave, defaultValue = '' }: Param) => {
|
||||
const Remark = ({ onBlur, onSave, defaultValue = '' }: Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const getDesc = (value) => {
|
||||
let res = value
|
||||
if (value.length > descData.count) {
|
||||
@ -30,6 +26,9 @@ export default ({ onBlur, onSave, defaultValue = '' }: Param) => {
|
||||
const setSave = () => {
|
||||
onSave?.(descData.value)
|
||||
}
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
return (
|
||||
<View className={styles.order_popup}>
|
||||
<View className={styles.order_popup_title}>编辑备注</View>
|
||||
@ -40,4 +39,5 @@ export default ({ onBlur, onSave, defaultValue = '' }: Param) => {
|
||||
<View className={styles.order_save_address} onClick={() => setSave()}>保存</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default Remark
|
||||
|
||||
@ -19,7 +19,7 @@ interface Param {
|
||||
onSubmit?: () => void
|
||||
id?: number
|
||||
}
|
||||
export default memo(({ show, onClose, onSubmit, id }: Param) => {
|
||||
const ReturnRecord = ({ show, onClose, onSubmit, id }: Param) => {
|
||||
// 搜索参数
|
||||
const searchField = useRef({
|
||||
page: 1,
|
||||
@ -27,13 +27,6 @@ export default memo(({ show, onClose, onSubmit, id }: Param) => {
|
||||
sale_order_id: 0,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (show && id) {
|
||||
searchField.current.sale_order_id = id
|
||||
getOrderList()
|
||||
}
|
||||
}, [show, id])
|
||||
|
||||
const userInfo = useSelector(state => state.userInfo)
|
||||
|
||||
// 获取售后订单列表
|
||||
@ -83,12 +76,17 @@ export default memo(({ show, onClose, onSubmit, id }: Param) => {
|
||||
const onscroll = useCallback((e) => {
|
||||
if (e.detail.scrollTop > 20) {
|
||||
setScrollStatus(true)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setScrollStatus(false)
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (show && id) {
|
||||
searchField.current.sale_order_id = id
|
||||
getOrderList()
|
||||
}
|
||||
}, [show, id])
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading })
|
||||
@ -162,4 +160,5 @@ export default memo(({ show, onClose, onSubmit, id }: Param) => {
|
||||
</Popup>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ReturnRecord)
|
||||
|
||||
@ -30,14 +30,32 @@ interface ListParam {
|
||||
total_price: string
|
||||
weight_error: string
|
||||
}
|
||||
export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
const ScanPay = ({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
const [detail, setDetail] = useState<any>()
|
||||
// 收货地址
|
||||
const address = (addressInfo) => {
|
||||
if (addressInfo?.shipment_mode == 2) {
|
||||
return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
|
||||
}
|
||||
else {
|
||||
return addressInfo?.take_goods_address
|
||||
}
|
||||
}
|
||||
|
||||
// 收件人
|
||||
const userName = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : ''
|
||||
}
|
||||
|
||||
// 手机号
|
||||
const userPhone = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone
|
||||
}
|
||||
useEffect(() => {
|
||||
if (orderInfo) {
|
||||
const lists: ListParam[] = []
|
||||
orderInfo.product_list?.map((pitem) => {
|
||||
pitem?.product_colors?.map((citem) => {
|
||||
orderInfo.product_list?.forEach((pitem) => {
|
||||
pitem?.product_colors?.forEach((citem) => {
|
||||
lists.push({
|
||||
product_code: formatRemoveHashTag(pitem.code),
|
||||
product_name: pitem.name,
|
||||
@ -96,26 +114,6 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
}
|
||||
}, [orderInfo, show])
|
||||
|
||||
// 收货地址
|
||||
const address = (addressInfo) => {
|
||||
if (addressInfo?.shipment_mode == 2) {
|
||||
return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
|
||||
}
|
||||
else {
|
||||
return addressInfo?.take_goods_address
|
||||
}
|
||||
}
|
||||
|
||||
// 收件人
|
||||
const userName = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : ''
|
||||
}
|
||||
|
||||
// 手机号
|
||||
const userPhone = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone
|
||||
}
|
||||
|
||||
// 获取支付二维码
|
||||
const [payCodeImage, setPayCodeImage] = useState<string>('')
|
||||
const fileData = useRef({
|
||||
@ -148,10 +146,6 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
scope: 'scope.writePhotosAlbum',
|
||||
msg: '您没授权,无法保存图片',
|
||||
})
|
||||
const saveImageCheck = async() => {
|
||||
const res = await check()
|
||||
res && saveImage()
|
||||
}
|
||||
|
||||
// 保存图片
|
||||
const saveImage = () => {
|
||||
@ -166,7 +160,10 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const saveImageCheck = async() => {
|
||||
const res = await check()
|
||||
res && saveImage()
|
||||
}
|
||||
// 预览图片
|
||||
const showImage = () => {
|
||||
console.log('fileData.current.filePath::', fileData.current.filePath)
|
||||
@ -201,4 +198,5 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
</Popup>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ScanPay)
|
||||
|
||||
@ -29,9 +29,80 @@ interface ListParam {
|
||||
total_price: string
|
||||
weight_error: string
|
||||
}
|
||||
export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
const ScanPayCheck = ({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
const [detail, setDetail] = useState<any>()
|
||||
|
||||
// 收货地址
|
||||
const address = (addressInfo) => {
|
||||
if (addressInfo?.shipment_mode == 2) {
|
||||
return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
|
||||
}
|
||||
else {
|
||||
return addressInfo?.take_goods_address
|
||||
}
|
||||
}
|
||||
|
||||
// 收件人
|
||||
const userName = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : ''
|
||||
}
|
||||
|
||||
// 手机号
|
||||
const userPhone = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone
|
||||
}
|
||||
|
||||
// 获取支付二维码
|
||||
const [payCodeImage, setPayCodeImage] = useState<string>('')
|
||||
const fileData = useRef({
|
||||
filePath: '',
|
||||
base64: '',
|
||||
})
|
||||
const { fetchData, state } = GetPayCode()
|
||||
const getCore = async() => {
|
||||
const res = await fetchData(detail)
|
||||
const base64 = res.data.base64
|
||||
setPayCodeImage(() => base64)
|
||||
const time = new Date().valueOf()
|
||||
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || []
|
||||
const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}`
|
||||
fileData.current.filePath = filePath
|
||||
fileData.current.base64 = bodyData
|
||||
const save = Taro.getFileSystemManager()
|
||||
save.writeFile({
|
||||
filePath: fileData.current.filePath,
|
||||
data: fileData.current.base64,
|
||||
encoding: 'base64',
|
||||
})
|
||||
}
|
||||
|
||||
// 保存图片
|
||||
const saveImage = () => {
|
||||
alert.loading('正在保存图片')
|
||||
Taro.saveImageToPhotosAlbum({
|
||||
filePath: fileData.current.filePath,
|
||||
success() {
|
||||
alert.success('图片保存成功')
|
||||
},
|
||||
fail(err) {
|
||||
console.log('err::', err)
|
||||
},
|
||||
})
|
||||
}
|
||||
// 检查是否开启保存图片权限
|
||||
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
|
||||
const saveImageCheck = async() => {
|
||||
const res = await check()
|
||||
res && saveImage()
|
||||
}
|
||||
// 预览图片
|
||||
const showImage = () => {
|
||||
console.log('fileData.current.filePath::', fileData.current.filePath)
|
||||
Taro.previewImage({
|
||||
current: fileData.current.filePath, // 当前显示
|
||||
urls: [fileData.current.filePath], // 需要预览的图片http链接列表
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
getCore()
|
||||
@ -41,8 +112,8 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
useEffect(() => {
|
||||
if (orderInfo) {
|
||||
const lists: ListParam[] = []
|
||||
orderInfo.product_list?.map((pitem) => {
|
||||
pitem?.product_colors?.map((citem) => {
|
||||
orderInfo.product_list?.forEach((pitem) => {
|
||||
pitem?.product_colors?.forEach((citem) => {
|
||||
lists.push({
|
||||
product_code: formatRemoveHashTag(pitem.code),
|
||||
product_name: pitem.name,
|
||||
@ -98,81 +169,6 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
}))
|
||||
}
|
||||
}, [orderInfo])
|
||||
|
||||
// 收货地址
|
||||
const address = (addressInfo) => {
|
||||
if (addressInfo?.shipment_mode == 2) {
|
||||
return addressInfo?.province_name ? addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail : ''
|
||||
}
|
||||
else {
|
||||
return addressInfo?.take_goods_address
|
||||
}
|
||||
}
|
||||
|
||||
// 收件人
|
||||
const userName = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_name : ''
|
||||
}
|
||||
|
||||
// 手机号
|
||||
const userPhone = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2 ? orderInfo.target_user_phone : orderInfo.take_goods_phone
|
||||
}
|
||||
|
||||
// 获取支付二维码
|
||||
const [payCodeImage, setPayCodeImage] = useState<string>('')
|
||||
const fileData = useRef({
|
||||
filePath: '',
|
||||
base64: '',
|
||||
})
|
||||
const { fetchData, state } = GetPayCode()
|
||||
const getCore = async() => {
|
||||
const res = await fetchData(detail)
|
||||
const base64 = res.data.base64
|
||||
setPayCodeImage(() => base64)
|
||||
const time = new Date().valueOf()
|
||||
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || []
|
||||
const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}`
|
||||
fileData.current.filePath = filePath
|
||||
fileData.current.base64 = bodyData
|
||||
const save = Taro.getFileSystemManager()
|
||||
save.writeFile({
|
||||
filePath: fileData.current.filePath,
|
||||
data: fileData.current.base64,
|
||||
encoding: 'base64',
|
||||
})
|
||||
}
|
||||
|
||||
// 检查是否开启保存图片权限
|
||||
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
|
||||
const saveImageCheck = async() => {
|
||||
const res = await check()
|
||||
res && saveImage()
|
||||
}
|
||||
|
||||
// 保存图片
|
||||
const saveImage = () => {
|
||||
alert.loading('正在保存图片')
|
||||
Taro.saveImageToPhotosAlbum({
|
||||
filePath: fileData.current.filePath,
|
||||
success() {
|
||||
alert.success('图片保存成功')
|
||||
},
|
||||
fail(err) {
|
||||
console.log('err::', err)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 预览图片
|
||||
const showImage = () => {
|
||||
console.log('fileData.current.filePath::', fileData.current.filePath)
|
||||
Taro.previewImage({
|
||||
current: fileData.current.filePath, // 当前显示
|
||||
urls: [fileData.current.filePath], // 需要预览的图片http链接列表
|
||||
})
|
||||
}
|
||||
|
||||
// 复制功能
|
||||
return (
|
||||
<View className={styles.scanPay_main}>
|
||||
@ -194,4 +190,5 @@ export default memo(({ show = true, onClose, company, orderInfo }: Param) => {
|
||||
</Popup>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ScanPayCheck)
|
||||
|
||||
@ -6,7 +6,7 @@ import styles from './index.module.scss'
|
||||
interface Param {
|
||||
onSelect?: (val: number) => void
|
||||
}
|
||||
export default memo(({ onSelect }: Param) => {
|
||||
const ShipmentMode = ({ onSelect }: Param) => {
|
||||
// 收货方法 1:自提,2:物流
|
||||
const shipmentMode = useRef([
|
||||
{ value: 1, label: '上门自提', selected: false },
|
||||
@ -20,9 +20,10 @@ export default memo(({ onSelect }: Param) => {
|
||||
return (
|
||||
<View className={styles.order_title}>
|
||||
<Text>收货方式</Text>
|
||||
{shipmentMode.current.map((item) => {
|
||||
return <View className={classnames(styles.order_status, (selectValue == item.value) && styles.order_status_selected)} onClick={() => selectShipmentMode(item.value)}>{item.label}</View>
|
||||
{shipmentMode.current.map((item, key) => {
|
||||
return <View key={key} className={classnames(styles.order_status, (selectValue == item.value) && styles.order_status_selected)} onClick={() => selectShipmentMode(item.value)}>{item.label}</View>
|
||||
})}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(ShipmentMode)
|
||||
|
||||
@ -2,7 +2,7 @@ import { Text, View } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import { formatKbPrice } from '@/common/common'
|
||||
import { formatKbPrice } from '@/common/common'
|
||||
|
||||
interface Param {
|
||||
style?: Object
|
||||
@ -10,7 +10,7 @@ interface Param {
|
||||
priceTitle: string // 描述
|
||||
|
||||
}
|
||||
export default memo(({ style, number = 0, priceTitle = '' }: Param) => {
|
||||
const SubmitOrderBtn = ({ style, number = 0, priceTitle = '' }: Param) => {
|
||||
const priceDom = useCallback(() => {
|
||||
const res = number.toFixed(2).split('.')
|
||||
const int_num = `${parseInt(res[0])}`
|
||||
@ -36,4 +36,5 @@ export default memo(({ style, number = 0, priceTitle = '' }: Param) => {
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(SubmitOrderBtn)
|
||||
|
||||
@ -8,7 +8,7 @@ interface Param {
|
||||
onCheck?: () => void
|
||||
onCustom?: () => void
|
||||
}
|
||||
export default memo(({ onCheck, onCustom }: Param) => {
|
||||
const WeightMemo = ({ onCheck, onCustom }: Param) => {
|
||||
return (
|
||||
<View className={styles.weight_memo}>
|
||||
<View className={styles.weight_memo_item} onClick={() => onCheck?.()}>
|
||||
@ -33,4 +33,5 @@ export default memo(({ onCheck, onCustom }: Param) => {
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(WeightMemo)
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import useLogin from '@/use/useLogin'
|
||||
import { MovableArea, Text, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import classnames from 'classnames'
|
||||
@ -14,6 +13,7 @@ import Remark from './components/remark'
|
||||
import ReturnRecord from './components/returnRecord'
|
||||
import ScanPayCheck from './components/scanPayCheck'
|
||||
import styles from './index.module.scss'
|
||||
import useLogin from '@/use/useLogin'
|
||||
import ShopCart from '@/components/shopCart'
|
||||
import SearchInput from '@/components/searchInput'
|
||||
import Popup from '@/components/popup'
|
||||
@ -25,14 +25,11 @@ import { SubscriptionMessageApi } from '@/api/user'
|
||||
import { AddShoppingCartApi } from '@/api/shopCart'
|
||||
import { EditSaleOrderRemarkApi, GetSaleOrderDetailApi } from '@/api/order'
|
||||
|
||||
export default () => {
|
||||
const Order = () => {
|
||||
useLogin()
|
||||
const [showDesc, setShowDesc] = useState(false)
|
||||
const router = useRouter()
|
||||
const orderId = useRef<number>(Number(router.params.id))
|
||||
useDidShow(() => {
|
||||
getSaleOrderPreView()
|
||||
})
|
||||
|
||||
// 订单状态枚举
|
||||
const {
|
||||
@ -50,6 +47,13 @@ export default () => {
|
||||
const firstOpen = useRef(true)
|
||||
const [orderDetail, setOrderDetail] = useState<any>() // 获取到的原始数据
|
||||
const { fetchData: getOrderFetchData } = GetSaleOrderDetailApi()
|
||||
const [orderRemark, setOrderRemark] = useState('')
|
||||
|
||||
// 去付款
|
||||
const [payMentShow, setPayMentShow] = useState(false)
|
||||
const toPay = () => {
|
||||
setPayMentShow(true)
|
||||
}
|
||||
const getSaleOrderPreView = async() => {
|
||||
if (orderId.current) {
|
||||
const res = await getOrderFetchData({ id: orderId.current })
|
||||
@ -65,11 +69,6 @@ export default () => {
|
||||
// Taro.hideToast()
|
||||
}
|
||||
|
||||
// 监听获取到的数据
|
||||
useEffect(() => {
|
||||
if (orderDetail) { formatData() }
|
||||
}, [orderDetail])
|
||||
|
||||
// 格式化数据格式
|
||||
const [formatDetailOrder, setFormatDetailOrder] = useState<any>() // 格式化后的数据
|
||||
const formatData = () => {
|
||||
@ -116,14 +115,13 @@ export default () => {
|
||||
|
||||
// 订单备注
|
||||
const { fetchData: remarkFetchData } = EditSaleOrderRemarkApi()
|
||||
const [orderRemark, setOrderRemark] = useState('')
|
||||
const getRemark = useCallback(async(e) => {
|
||||
setOrderRemark(() => e)
|
||||
const res = await remarkFetchData({ remark: e, id: orderId.current })
|
||||
if (res.success) {
|
||||
getSaleOrderPreView()
|
||||
alert.success('提交成功')
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert.error(res.msg)
|
||||
}
|
||||
@ -143,12 +141,6 @@ export default () => {
|
||||
setShowDesc(() => true)
|
||||
}
|
||||
|
||||
// 去付款
|
||||
const [payMentShow, setPayMentShow] = useState(false)
|
||||
const toPay = () => {
|
||||
setPayMentShow(true)
|
||||
}
|
||||
|
||||
// 打开地址修改
|
||||
const addressRef = useRef<any>(null)
|
||||
|
||||
@ -162,53 +154,24 @@ export default () => {
|
||||
getSaleOrderPreView()
|
||||
}, [orderDetail])
|
||||
|
||||
// 获取底部按钮点击, 获取按钮状态
|
||||
const orderStateClick = useCallback(
|
||||
(val) => {
|
||||
if (val == 1 || val == 6 || val == 8) {
|
||||
getSaleOrderPreView()
|
||||
}
|
||||
else if (val == 2) {
|
||||
// 待付款
|
||||
toPay()
|
||||
}
|
||||
else if (val == 3) {
|
||||
// 申请退款
|
||||
if (!orderDetail?.av_return_roll) { return alert.none('该订单已申请过退款') }
|
||||
setRefundShow(true)
|
||||
}
|
||||
else if (val == 7) {
|
||||
// 再购
|
||||
addShopCart()
|
||||
}
|
||||
else if (val == 9) {
|
||||
// 售后记录
|
||||
onReturnRecordShow()
|
||||
}
|
||||
else if (val == 10) {
|
||||
setShowScanPayCheck(true)
|
||||
}
|
||||
},
|
||||
[orderDetail],
|
||||
)
|
||||
|
||||
// 页面下拉刷新
|
||||
usePullDownRefresh(() => {
|
||||
getSaleOrderPreView()
|
||||
})
|
||||
|
||||
useDidShow(() => {
|
||||
getSaleOrderPreView()
|
||||
})
|
||||
// 关闭支付弹窗
|
||||
const closePayShow = useCallback(() => {
|
||||
setPayMentShow(() => false)
|
||||
}, [orderDetail])
|
||||
// 支付成功
|
||||
const onPaySuccess = useCallback(() => {
|
||||
alert.success('支付成功')
|
||||
getSaleOrderPreView()
|
||||
closePayShow()
|
||||
}, [orderDetail])
|
||||
|
||||
// 关闭支付弹窗
|
||||
const closePayShow = useCallback(() => {
|
||||
setPayMentShow(() => false)
|
||||
}, [orderDetail])
|
||||
|
||||
// 按钮所需数据
|
||||
const orderInfo = useMemo(() => {
|
||||
return {
|
||||
@ -251,11 +214,11 @@ export default () => {
|
||||
const { fetchData: addFetchData } = AddShoppingCartApi()
|
||||
const addShopCart = async() => {
|
||||
const color_list: { product_color_id: number; roll?: number; length?: number }[] = []
|
||||
orderDetail?.product_list.map((pitem) => {
|
||||
orderDetail?.product_list.forEach((pitem) => {
|
||||
pitem?.product_colors.map((citem) => {
|
||||
if (orderDetail?.sale_mode == 0) {
|
||||
return color_list.push({ product_color_id: citem.id, roll: citem.roll })
|
||||
}
|
||||
}
|
||||
else {
|
||||
return color_list.push({ product_color_id: citem.id, length: citem.length })
|
||||
}
|
||||
@ -270,7 +233,7 @@ export default () => {
|
||||
title: '已加入购物车',
|
||||
})
|
||||
setShowCart(true)
|
||||
}
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
@ -278,7 +241,10 @@ export default () => {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 监听获取到的数据
|
||||
useEffect(() => {
|
||||
if (orderDetail) { formatData() }
|
||||
}, [orderDetail])
|
||||
// 显示售后记录
|
||||
const [returnRecordShow, setReturnRecordShow] = useState(false)
|
||||
const onReturnRecordShow = useCallback(() => {
|
||||
@ -290,7 +256,35 @@ export default () => {
|
||||
|
||||
// 显示
|
||||
const [showScanPayCheck, setShowScanPayCheck] = useState(false)
|
||||
|
||||
// 获取底部按钮点击, 获取按钮状态
|
||||
const orderStateClick = useCallback(
|
||||
(val) => {
|
||||
if (val == 1 || val == 6 || val == 8) {
|
||||
getSaleOrderPreView()
|
||||
}
|
||||
else if (val == 2) {
|
||||
// 待付款
|
||||
toPay()
|
||||
}
|
||||
else if (val == 3) {
|
||||
// 申请退款
|
||||
if (!orderDetail?.av_return_roll) { return alert.none('该订单已申请过退款') }
|
||||
setRefundShow(true)
|
||||
}
|
||||
else if (val == 7) {
|
||||
// 再购
|
||||
addShopCart()
|
||||
}
|
||||
else if (val == 9) {
|
||||
// 售后记录
|
||||
onReturnRecordShow()
|
||||
}
|
||||
else if (val == 10) {
|
||||
setShowScanPayCheck(true)
|
||||
}
|
||||
},
|
||||
[orderDetail],
|
||||
)
|
||||
return (
|
||||
<MovableAreaBtn orderInfo={orderDetail}>
|
||||
<View className={styles.order_main}>
|
||||
@ -352,3 +346,4 @@ export default () => {
|
||||
</MovableAreaBtn>
|
||||
)
|
||||
}
|
||||
export default Order
|
||||
|
||||
@ -39,7 +39,7 @@ interface Param {
|
||||
}
|
||||
onClickBtn?: (val: { status: number; orderInfo: Param['value'] }) => void
|
||||
}
|
||||
export default memo(({ value, onClickBtn }: Param) => {
|
||||
const Order = ({ value, onClickBtn }: Param) => {
|
||||
const userInfo = useSelector(state => state.userInfo)
|
||||
// 对应数量
|
||||
const formatCount = useCallback(
|
||||
@ -89,7 +89,7 @@ export default memo(({ value, onClickBtn }: Param) => {
|
||||
const orderStatus = useMemo(() => {
|
||||
if (value.status == SaleOrderStatusWaitingReceipt.value && value.shipment_mode == 1) {
|
||||
return '待提货'
|
||||
}
|
||||
}
|
||||
else {
|
||||
return value?.status_name
|
||||
}
|
||||
@ -161,4 +161,5 @@ export default memo(({ value, onClickBtn }: Param) => {
|
||||
<OrderBtns orderInfo={orderInfo} onClick={orderBtnsClick} showStatus="list" />
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(Order)
|
||||
|
||||
@ -8,7 +8,7 @@ interface Param {
|
||||
defaultId?: number
|
||||
onSelect?: (val: number) => void
|
||||
}
|
||||
export default memo(({ list = [], defaultId = -1, onSelect }: Param) => {
|
||||
const OrderStatusList = ({ list = [], defaultId = -1, onSelect }: Param) => {
|
||||
const [selectInfo, setSelectInfo] = useState({
|
||||
selected: -1, // 当前选中的id
|
||||
tabId: '', // 需要滚动到的id
|
||||
@ -39,7 +39,7 @@ export default memo(({ list = [], defaultId = -1, onSelect }: Param) => {
|
||||
key={item.id}
|
||||
id={`tabs_${item.id}`}
|
||||
onClick={() => clickEvent({ item, index })}
|
||||
className={classnames(styles.order_status_item, selectInfo.selected == item.id && styles.selected)}
|
||||
className={classnames(styles.order_status_item, selectInfo.selected == item.id && styles.selected)}
|
||||
>
|
||||
{item.name}
|
||||
</View>
|
||||
@ -49,4 +49,5 @@ export default memo(({ list = [], defaultId = -1, onSelect }: Param) => {
|
||||
</ScrollView>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(OrderStatusList)
|
||||
|
||||
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