🌈 style(eslint): 新增eslint规则
This commit is contained in:
@@ -1,80 +1,82 @@
|
||||
|
||||
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import "./index.scss"
|
||||
import {addressListApi,addressDeleteApi} from "@/api/addressManager"
|
||||
import { alert } from "@/common/common"
|
||||
import Taro, { showModal } from "@tarojs/taro"
|
||||
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import './index.scss'
|
||||
import { addressDeleteApi, addressListApi } from '@/api/addressManager'
|
||||
import { alert } from '@/common/common'
|
||||
import Taro, { showModal } from '@tarojs/taro'
|
||||
|
||||
interface Params{
|
||||
refresherEnabled?: boolean,//是否开启刷新
|
||||
onSelect?: (item:any,index:number)=>void,//列表选择
|
||||
addButtonEnabled?: boolean, //是否显示添加按钮
|
||||
focusBorderEnabled?: boolean, //焦点显示蓝色边框
|
||||
id?: number, //默认选择值
|
||||
refresherEnabled?: boolean// 是否开启刷新
|
||||
onSelect?: (item: any, index: number) => void// 列表选择
|
||||
addButtonEnabled?: boolean // 是否显示添加按钮
|
||||
focusBorderEnabled?: boolean // 焦点显示蓝色边框
|
||||
id?: number // 默认选择值
|
||||
}
|
||||
|
||||
// 地址列表
|
||||
const AddressList = memo((props:Params)=>{
|
||||
const {addButtonEnabled=true,focusBorderEnabled=false} = props;
|
||||
const {fetchData, state} = addressListApi()
|
||||
const AddressList = memo((props: Params) => {
|
||||
const { addButtonEnabled = true, focusBorderEnabled = false } = props
|
||||
const { fetchData, state } = addressListApi()
|
||||
// 获取数据
|
||||
const getData = async ()=>{
|
||||
const result = await fetchData();
|
||||
if(props.id){
|
||||
setFocusId(props.id as any);
|
||||
}else{
|
||||
result.data.list?.every(item=>{
|
||||
if(item.is_default){
|
||||
setFocusId(item.id);
|
||||
return false;
|
||||
const getData = async() => {
|
||||
const result = await fetchData()
|
||||
if (props.id) {
|
||||
setFocusId(props.id as any)
|
||||
}
|
||||
else {
|
||||
result.data.list?.every((item) => {
|
||||
if (item.is_default) {
|
||||
setFocusId(item.id)
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
useEffect(()=>{
|
||||
getData();
|
||||
useEffect(() => {
|
||||
getData()
|
||||
// 监听刷新
|
||||
Taro.eventCenter.on("addressList:refresh", getData);
|
||||
return ()=>{
|
||||
Taro.eventCenter.off("addressList:refresh", getData);
|
||||
Taro.eventCenter.on('addressList:refresh', getData)
|
||||
return () => {
|
||||
Taro.eventCenter.off('addressList:refresh', getData)
|
||||
}
|
||||
},[])
|
||||
}, [])
|
||||
// 处理刷新
|
||||
const [refreshState, setRefreshState] = useState(false);
|
||||
const handleRefresh = async ()=>{
|
||||
setRefreshState(true);
|
||||
await getData();
|
||||
setRefreshState(false);
|
||||
const [refreshState, setRefreshState] = useState(false)
|
||||
const handleRefresh = async() => {
|
||||
setRefreshState(true)
|
||||
await getData()
|
||||
setRefreshState(false)
|
||||
}
|
||||
const data = Array.from({length:15});
|
||||
const data = Array.from({ length: 15 })
|
||||
// 焦点
|
||||
const [focusId, setFocusId] = useState();
|
||||
const [focusId, setFocusId] = useState()
|
||||
// 列表选择
|
||||
const handleSelect = (item: any, index: number)=>{
|
||||
props.onSelect&&props.onSelect(item,index);
|
||||
if(focusBorderEnabled){
|
||||
setFocusId(item?.id);
|
||||
const handleSelect = (item: any, index: number) => {
|
||||
props.onSelect && props.onSelect(item, index)
|
||||
if (focusBorderEnabled) {
|
||||
setFocusId(item?.id)
|
||||
}
|
||||
}
|
||||
// 删除地址
|
||||
const {fetchData: deleteFetch} = addressDeleteApi()
|
||||
const handleDelete = (item:any)=>{
|
||||
const { fetchData: deleteFetch } = addressDeleteApi()
|
||||
const handleDelete = (item: any) => {
|
||||
showModal(({
|
||||
title: "提示",
|
||||
content: "是否删除地址?",
|
||||
async success(ev){
|
||||
if(ev.confirm){
|
||||
const result = await deleteFetch({id:item.id});
|
||||
if(result.success){
|
||||
alert.success("删除成功");
|
||||
getData();
|
||||
}else{
|
||||
alert.success(result.msg);
|
||||
title: '提示',
|
||||
content: '是否删除地址?',
|
||||
async success(ev) {
|
||||
if (ev.confirm) {
|
||||
const result = await deleteFetch({ id: item.id })
|
||||
if (result.success) {
|
||||
alert.success('删除成功')
|
||||
getData()
|
||||
}
|
||||
else {
|
||||
alert.success(result.msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -83,42 +85,43 @@ const AddressList = memo((props:Params)=>{
|
||||
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
|
||||
<View className="address-scroll-view-content">
|
||||
{
|
||||
state?.data?.list?.length>0?
|
||||
state?.data?.list?.map((item,index)=>{
|
||||
// data.length>0?
|
||||
// data.map((item,index)=>{
|
||||
return(
|
||||
<View onLongPress={()=>handleDelete(item)} onClick={()=>handleSelect(item,index)} className={`address-list ${focusId==item.id&&'address-active'}`}>
|
||||
<View className="address-user">
|
||||
{item.name}
|
||||
{
|
||||
item.is_default?<Text className="address-list-default">默认</Text>:
|
||||
<Text className="address-list-phone">{item.phone.replace(item.phone.substring(3,7), "****")}</Text>
|
||||
}
|
||||
</View>
|
||||
<View className="address-list-bottom">
|
||||
<View className="address-list-info">
|
||||
<View>{item.province_name+item.city_name+item.district_name}
|
||||
{/* {item.address_detail} */}
|
||||
</View>
|
||||
state?.data?.list?.length > 0
|
||||
? state?.data?.list?.map((item, index) => {
|
||||
// data.length>0?
|
||||
// data.map((item,index)=>{
|
||||
return (
|
||||
<View onLongPress={() => handleDelete(item)} onClick={() => handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}>
|
||||
<View className="address-user">
|
||||
{item.name}
|
||||
{
|
||||
item.is_default&&<Text className="address-list-phone">{item.phone.replace(item.phone.substring(3,7), "****")}</Text>
|
||||
item.is_default
|
||||
? <Text className="address-list-default">默认</Text>
|
||||
: <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), '****')}</Text>
|
||||
}
|
||||
</View>
|
||||
<Navigator onClick={e=>e.stopPropagation()} url={`/pages/addressAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="address-edit">
|
||||
<Text className="iconfont icon-bianji"></Text>
|
||||
</Navigator>
|
||||
<View className="address-list-bottom">
|
||||
<View className="address-list-info">
|
||||
<View>{item.province_name + item.city_name + item.district_name}
|
||||
{/* {item.address_detail} */}
|
||||
</View>
|
||||
{
|
||||
item.is_default && <Text className="address-list-phone">{item.phone.replace(item.phone.substring(3, 7), '****')}</Text>
|
||||
}
|
||||
</View>
|
||||
<Navigator onClick={e => e.stopPropagation()} url={`/pages/addressAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="address-edit">
|
||||
<Text className="iconfont icon-bianji"></Text>
|
||||
</Navigator>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}):
|
||||
<View className="address-no-data">暂未添加地址</View>
|
||||
)
|
||||
})
|
||||
: <View className="address-no-data">暂未添加地址</View>
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
{addButtonEnabled&&<Navigator url="/pages/addressAdd/index?type=add" hoverClass="none" className="add-address">添加收货地址</Navigator>}
|
||||
{addButtonEnabled && <Navigator url="/pages/addressAdd/index?type=add" hoverClass="none" className="add-address">添加收货地址</Navigator>}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
export default AddressList;
|
||||
export default AddressList
|
||||
|
||||
@@ -3,15 +3,15 @@ import { memo } from 'react'
|
||||
import './index.scss'
|
||||
|
||||
interface ListParams {
|
||||
label: string //左边label
|
||||
label: string // 左边label
|
||||
onInput?: (ev: Object) => void // 输入框输入
|
||||
onClick?: () => any //点击列表
|
||||
onClick?: () => any // 点击列表
|
||||
placeholder?: string // 提示文本
|
||||
children?: any // 插槽
|
||||
type?: string // 类型:1.input,2.textarea,3.select,
|
||||
primordialType?: 'text' | 'number' | 'idcard' | 'digit'
|
||||
value?: any
|
||||
style?: object //整行样式
|
||||
style?: object // 整行样式
|
||||
labelStyle?: object // label样式
|
||||
contentStyle?: object
|
||||
required?: boolean
|
||||
@@ -22,40 +22,44 @@ const FromList = memo((props: ListParams) => {
|
||||
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false } = props
|
||||
|
||||
return (
|
||||
<View style={style} className='form-list'>
|
||||
<View style={style} className="form-list">
|
||||
<View style={labelStyle} className={`form-list-label ${required && 'form-list-label-required'}`}>
|
||||
{props.label}
|
||||
</View>
|
||||
<View onClick={props?.onClick} className='form-list-right'>
|
||||
<View onClick={props?.onClick} className="form-list-right">
|
||||
{props.children ?? (
|
||||
<View style={contentStyle} onClick={props?.onClick} className='form-list-right-meet'>
|
||||
{type == 'input' ? (
|
||||
<View className='form-list-input'>
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
cursorSpacing={150}
|
||||
value={value}
|
||||
placeholder-class='phcolor'
|
||||
type={props.primordialType || 'text'}
|
||||
onInput={props?.onInput}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
{value && (
|
||||
<View>
|
||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
) : type == 'textarea' ? (
|
||||
<Textarea value={value} placeholder-class='phcolor' onInput={props?.onInput} placeholder={props.placeholder} />
|
||||
) : (
|
||||
<>
|
||||
{props.value ? <View>{value}</View> : <View className='form-list-right-placeholder'>{props.placeholder}</View>}
|
||||
<View className='form-list-right-enter'>
|
||||
<Text className='iconfont icon-a-moreback'></Text>
|
||||
<View style={contentStyle} onClick={props?.onClick} className="form-list-right-meet">
|
||||
{type == 'input'
|
||||
? (
|
||||
<View className="form-list-input">
|
||||
<Input
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
value={value}
|
||||
placeholder-class="phcolor"
|
||||
type={props.primordialType || 'text'}
|
||||
onInput={props?.onInput}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
{value && (
|
||||
<View>
|
||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
)
|
||||
: type == 'textarea'
|
||||
? (
|
||||
<Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />
|
||||
)
|
||||
: (
|
||||
<>
|
||||
{props.value ? <View>{value}</View> : <View className="form-list-right-placeholder">{props.placeholder}</View>}
|
||||
<View className="form-list-right-enter">
|
||||
<Text className="iconfont icon-a-moreback"></Text>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
@@ -3,14 +3,14 @@ import { memo } from 'react'
|
||||
import './index.scss'
|
||||
|
||||
interface ListParams {
|
||||
label: string //左边label
|
||||
label: string // 左边label
|
||||
onInput?: (ev: Object) => void // 输入框输入
|
||||
onClick?: () => any //点击列表
|
||||
onClick?: () => any // 点击列表
|
||||
placeholder?: string // 提示文本
|
||||
children?: any // 插槽
|
||||
type?: string // 类型:1.input,2.textarea,3.select
|
||||
value?: any
|
||||
style?: object //整行样式
|
||||
style?: object // 整行样式
|
||||
labelStyle?: object // label样式
|
||||
contentStyle?: object
|
||||
required?: boolean
|
||||
@@ -22,37 +22,41 @@ const FromList = memo((props: ListParams) => {
|
||||
const { type = 'input', value = '', style = {}, labelStyle = {}, contentStyle = {}, required = false, showIcon = true } = props
|
||||
|
||||
return (
|
||||
<View style={style} className='From-list-certification'>
|
||||
<View style={style} className="From-list-certification">
|
||||
<View style={labelStyle} className={`From-list-certification-label ${required && 'From-list-certification-label-required'}`}>
|
||||
{props.label}
|
||||
</View>
|
||||
<View onClick={props?.onClick} className='From-list-certification-right'>
|
||||
<View onClick={props?.onClick} className="From-list-certification-right">
|
||||
{props.children ?? (
|
||||
<View style={contentStyle} onClick={props?.onClick} className='From-list-certification-right-meet'>
|
||||
{type == 'input' ? (
|
||||
<View className='From-list-certification-input'>
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
cursorSpacing={150}
|
||||
value={value}
|
||||
placeholder-class='phcolor'
|
||||
onInput={props?.onInput}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
{value && (
|
||||
<View>
|
||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className='iconfont icon-qingkong' />
|
||||
</View>
|
||||
<View style={contentStyle} onClick={props?.onClick} className="From-list-certification-right-meet">
|
||||
{type == 'input'
|
||||
? (
|
||||
<View className="From-list-certification-input">
|
||||
<Input
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
value={value}
|
||||
placeholder-class="phcolor"
|
||||
onInput={props?.onInput}
|
||||
placeholder={props.placeholder}
|
||||
/>
|
||||
{value && (
|
||||
<View>
|
||||
<Text onClick={() => props.onInput && props.onInput({ detail: { value: '' } })} className="iconfont icon-qingkong" />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
: type == 'textarea'
|
||||
? (
|
||||
<Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />
|
||||
)
|
||||
: (
|
||||
<>
|
||||
{props.value ? <View>{value}</View> : <View className="From-list-certification-right-placeholder">{props.placeholder}</View>}
|
||||
<View className="From-list-certification-right-enter">{showIcon && <Text className="iconfont icon-a-moreback"></Text>}</View>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
) : type == 'textarea' ? (
|
||||
<Textarea value={value} placeholder-class='phcolor' onInput={props?.onInput} placeholder={props.placeholder} />
|
||||
) : (
|
||||
<>
|
||||
{props.value ? <View>{value}</View> : <View className='From-list-certification-right-placeholder'>{props.placeholder}</View>}
|
||||
<View className='From-list-certification-right-enter'>{showIcon && <Text className='iconfont icon-a-moreback'></Text>}</View>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import { alert, isEmptyObject } from '@/common/common'
|
||||
|
||||
@@ -23,7 +24,7 @@ export default (props: Params) => {
|
||||
getData({ moreStatus: true }, { moreStatus: true })
|
||||
}
|
||||
}, [query])
|
||||
const getData = async (startStatus, endStatus) => {
|
||||
const getData = async(startStatus, endStatus) => {
|
||||
const tRefreshDataRef = refreshDataRef.current as any
|
||||
setRefreshData({
|
||||
...tRefreshDataRef,
|
||||
@@ -44,7 +45,8 @@ export default (props: Params) => {
|
||||
...endStatus,
|
||||
loading: false,
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setData({
|
||||
list: result.data.list,
|
||||
// list: tRefreshDataRef.page>1?(dataRef.current as any).list.concat(result.data.list):result.data.list,
|
||||
@@ -57,7 +59,8 @@ export default (props: Params) => {
|
||||
loading: false,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.none(result.msg)
|
||||
setRefreshData({
|
||||
...tRefreshDataRef,
|
||||
@@ -83,8 +86,8 @@ export default (props: Params) => {
|
||||
})
|
||||
const dataRef = useRef({})
|
||||
// 下拉刷新
|
||||
const handleRefresh = async () => {
|
||||
let tRefreshData = refreshDataRef.current as any
|
||||
const handleRefresh = async() => {
|
||||
const tRefreshData = refreshDataRef.current as any
|
||||
setRefreshData({
|
||||
...tRefreshData,
|
||||
page: 1,
|
||||
@@ -93,9 +96,9 @@ export default (props: Params) => {
|
||||
getData({ refreshStatus: true, moreStatus: false }, { refreshStatus: false, moreStatus: true })
|
||||
}
|
||||
// 加载更多
|
||||
const handleMoreLoad = async () => {
|
||||
let t = dataRef.current as any
|
||||
let tRefreshData = refreshDataRef.current as any
|
||||
const handleMoreLoad = async() => {
|
||||
const t = dataRef.current as any
|
||||
const tRefreshData = refreshDataRef.current as any
|
||||
if (t.list.length < t.total) {
|
||||
setRefreshData({
|
||||
...tRefreshData,
|
||||
@@ -112,19 +115,20 @@ export default (props: Params) => {
|
||||
)
|
||||
}
|
||||
}
|
||||
//数据加载状态
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: data.list, total: data.total, status: refreshData.loading })
|
||||
}, [refreshData.loading])
|
||||
|
||||
return (
|
||||
<InfiniteScroll
|
||||
refresherEnabled={true}
|
||||
refresherEnabled
|
||||
refresherTriggered={refreshData.refreshStatus}
|
||||
moreStatus={refreshData.moreStatus}
|
||||
selfOnRefresherRefresh={handleRefresh}
|
||||
selfonScrollToLower={handleMoreLoad}
|
||||
statusMore={statusMore}>
|
||||
statusMore={statusMore}
|
||||
>
|
||||
{props.children}
|
||||
</InfiniteScroll>
|
||||
)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { formatImgUrl, formatRemoveHashTag } from '@/common/fotmat'
|
||||
import Preview from '@/pages/details/components/preview'
|
||||
import { Image, View } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import LabAndImgShow from '../LabAndImgShow'
|
||||
import styles from './index.module.scss'
|
||||
import Preview from '@/pages/details/components/preview'
|
||||
import { formatImgUrl, formatRemoveHashTag } from '@/common/fotmat'
|
||||
|
||||
//该组件宽高为100%需调整外层元素宽高
|
||||
type Param = {
|
||||
// 该组件宽高为100%需调整外层元素宽高
|
||||
interface Param {
|
||||
value: {
|
||||
texture_url?: string //纹理图路径
|
||||
lab?: { l: number; a: number; b: number } //lab
|
||||
rgb?: { r: number; g: number; b: number } //rgb
|
||||
texture_url?: string // 纹理图路径
|
||||
lab?: { l: number; a: number; b: number } // lab
|
||||
rgb?: { r: number; g: number; b: number } // rgb
|
||||
title?: string
|
||||
}
|
||||
showStatus?: true | false
|
||||
@@ -21,18 +21,19 @@ type Param = {
|
||||
export default memo(({ value, onClick, showStatus = false, round = false, name = '' }: Param) => {
|
||||
const [imgs, setImgs] = useState<string>('')
|
||||
|
||||
//lab是否都是0
|
||||
// lab是否都是0
|
||||
const rgbStyle = useMemo(() => {
|
||||
if (value?.lab && (value?.lab.l || value?.lab.a || value?.lab.b)) {
|
||||
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null
|
||||
}
|
||||
}, [value])
|
||||
|
||||
useEffect(() => {
|
||||
if (value?.texture_url) {
|
||||
let imgs = value.texture_url.split(',').map((item) => {
|
||||
const imgs = value.texture_url.split(',').map((item) => {
|
||||
return formatImgUrl(item)
|
||||
})
|
||||
setImgs(() => imgs[0])
|
||||
@@ -46,7 +47,7 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
||||
|
||||
const onShowLabAndImg = (e) => {
|
||||
onClick?.(value)
|
||||
if (!showStatus) return false
|
||||
if (!showStatus) { return false }
|
||||
setLabAndImgShow(true)
|
||||
}
|
||||
|
||||
@@ -59,15 +60,16 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
||||
<View className={styles.labAndImg_main} style={{ borderRadius: round ? '50%' : '' }} onClick={onShowLabAndImg}>
|
||||
{value.texture_url && (
|
||||
<Image
|
||||
mode='aspectFill'
|
||||
mode="aspectFill"
|
||||
src={imgs}
|
||||
onError={(e) => checkLoad(e)}
|
||||
onError={e => checkLoad(e)}
|
||||
className={styles.labAndImg_image}
|
||||
style={{ borderRadius: round ? '50%' : '' }}></Image>
|
||||
style={{ borderRadius: round ? '50%' : '' }}
|
||||
></Image>
|
||||
)}
|
||||
{!value.texture_url && rgbStyle && <View className={styles.boxColor} style={{ ...rgbStyle, borderRadius: round ? '50%' : '' }}></View>}
|
||||
{!value.texture_url && !rgbStyle && (
|
||||
<Image mode='aspectFill' src={formatImgUrl('')} className={styles.labAndImg_image} style={{ borderRadius: round ? '50%' : '' }}></Image>
|
||||
<Image mode="aspectFill" src={formatImgUrl('')} className={styles.labAndImg_image} style={{ borderRadius: round ? '50%' : '' }}></Image>
|
||||
)}
|
||||
{name && <View className={styles.labAndImg_name}>{name}</View>}
|
||||
</View>
|
||||
|
||||
@@ -1,39 +1,40 @@
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
import { View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
|
||||
export type colorParams = {
|
||||
export interface colorParams {
|
||||
value?: {
|
||||
texture_url?: string //纹理图路径
|
||||
lab?: { l: number; a: number; b: number } //lab
|
||||
rgb?: { r: number; g: number; b: number } //rgb
|
||||
title?: string //标题
|
||||
texture_url?: string // 纹理图路径
|
||||
lab?: { l: number; a: number; b: number } // lab
|
||||
rgb?: { r: number; g: number; b: number } // rgb
|
||||
title?: string // 标题
|
||||
}
|
||||
show?: false | true
|
||||
onClose?: () => void
|
||||
showNumber?: number //图片显示张数,0不限制
|
||||
showNumber?: number // 图片显示张数,0不限制
|
||||
}
|
||||
export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) => {
|
||||
useEffect(() => {
|
||||
if (show && rgbStyle) setLabShow(() => true)
|
||||
if (show && value?.texture_url) onShowImage()
|
||||
if (!show) setLabShow(() => false)
|
||||
if (show && rgbStyle) { setLabShow(() => true) }
|
||||
if (show && value?.texture_url) { onShowImage() }
|
||||
if (!show) { setLabShow(() => false) }
|
||||
}, [show])
|
||||
|
||||
//显示颜色
|
||||
// 显示颜色
|
||||
const [labShow, setLabShow] = useState(false)
|
||||
//lab是否都是0
|
||||
// lab是否都是0
|
||||
const rgbStyle = useMemo(() => {
|
||||
if (value?.lab && (value.lab.l || value.lab.a || value.lab.b)) {
|
||||
return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null
|
||||
}
|
||||
}, [value])
|
||||
|
||||
//显示图片
|
||||
// 显示图片
|
||||
const onShowImage = () => {
|
||||
onClose?.()
|
||||
let res: string[] = []
|
||||
@@ -42,7 +43,7 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
||||
return formatImgUrl(item)
|
||||
})
|
||||
}
|
||||
let n_res = showNumber == 0 ? res : res?.splice(0, showNumber)
|
||||
const n_res = showNumber == 0 ? res : res?.splice(0, showNumber)
|
||||
Taro.previewImage({
|
||||
current: n_res[0],
|
||||
urls: n_res,
|
||||
@@ -52,7 +53,7 @@ export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) =
|
||||
return (
|
||||
<>
|
||||
{labShow && (
|
||||
<View className={styles.main} catch-move='true' onClick={() => onClose?.()}>
|
||||
<View className={styles.main} catch-move="true" onClick={() => onClose?.()}>
|
||||
<View className={styles.con}>
|
||||
<View className={styles.rgb} style={rgbStyle!}></View>
|
||||
<View className={styles.name}>{value?.title}</View>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
|
||||
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
|
||||
import { memo } from "react"
|
||||
import "./index.scss"
|
||||
import { Button, Navigator, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import './index.scss'
|
||||
|
||||
interface Params{
|
||||
text: String,//提示信息
|
||||
text: String// 提示信息
|
||||
}
|
||||
|
||||
// 消息提示
|
||||
const Message = memo((props:Params)=>{
|
||||
const Message = memo((props: Params) => {
|
||||
return (
|
||||
<View className="message-custom-tips">
|
||||
<Text className="iconfont icon-zhuyi"></Text> {props.text}
|
||||
@@ -16,4 +16,4 @@ const Message = memo((props:Params)=>{
|
||||
)
|
||||
})
|
||||
|
||||
export default Message;
|
||||
export default Message
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import Popup from '@/components/popup'
|
||||
import { Input, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import TextareaEnhance from '@/components/textareaEnhance'
|
||||
import { CreateFavoriteApi, FavoriteListApi } from '@/api/favorite'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { getFilterData } from '@/common/util'
|
||||
|
||||
//原因选择
|
||||
type ReasonInfoParam = {
|
||||
show?: boolean //显示
|
||||
onClose?: () => void //关闭
|
||||
// 原因选择
|
||||
interface ReasonInfoParam {
|
||||
show?: boolean // 显示
|
||||
onClose?: () => void // 关闭
|
||||
onAdd?: (val: any) => void
|
||||
}
|
||||
export default memo(({ show = false, onClose, onAdd }: ReasonInfoParam) => {
|
||||
//获取列表
|
||||
// 获取列表
|
||||
const [list, setList] = useState([])
|
||||
const { fetchData: fetchDataList } = FavoriteListApi()
|
||||
const getFavoriteList = async () => {
|
||||
let res = await fetchDataList(getFilterData())
|
||||
const getFavoriteList = async() => {
|
||||
const res = await fetchDataList(getFilterData())
|
||||
setList(() => res.data.list)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (show) getFavoriteList()
|
||||
if (show) { getFavoriteList() }
|
||||
}, [show])
|
||||
|
||||
const onCreate = () => {
|
||||
|
||||
+194
-194
@@ -1,218 +1,218 @@
|
||||
import { ScrollView, Text, View } from "@tarojs/components";
|
||||
import { memo, ReactHTMLElement, useEffect, useRef, useState } from "react";
|
||||
import Drawer from "@/components/popup";
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { GetAddressListApi } from "@/api/addressList";
|
||||
import { alert } from "@/common/common";
|
||||
import { ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import React, { ReactHTMLElement, memo, useEffect, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Drawer from '@/components/popup'
|
||||
import { GetAddressListApi } from '@/api/addressList'
|
||||
import { alert } from '@/common/common'
|
||||
|
||||
interface DefaultValueParm { name: string; id: string|number; level?: number|string }
|
||||
|
||||
type DefaultValueParm = {name: string, id:string|number, level?: number|string}
|
||||
|
||||
type Params = {
|
||||
addressOnSelect?: (val:DefaultValueParm[]) => void,
|
||||
addressOnChange?: (val:DefaultValueParm[]) => void,
|
||||
addressOnClose?: () => void,
|
||||
show?: true|false,
|
||||
defaultValue?:DefaultValueParm[]
|
||||
selectStatus?: false|true, //false不需要选择完整地址,true需要选择完整地址
|
||||
interface Params {
|
||||
addressOnSelect?: (val: DefaultValueParm[]) => void
|
||||
addressOnChange?: (val: DefaultValueParm[]) => void
|
||||
addressOnClose?: () => void
|
||||
show?: true|false
|
||||
defaultValue?: DefaultValueParm[]
|
||||
selectStatus?: false|true // false不需要选择完整地址,true需要选择完整地址
|
||||
}
|
||||
|
||||
type AddresParam = {
|
||||
ad_code?: string,
|
||||
id?: number,
|
||||
level?: number,
|
||||
level_name?: string,
|
||||
name?: string,
|
||||
parent_id?: number,
|
||||
|
||||
}
|
||||
interface AddresParam {
|
||||
ad_code?: string
|
||||
id?: number
|
||||
level?: number
|
||||
level_name?: string
|
||||
name?: string
|
||||
parent_id?: number
|
||||
|
||||
}
|
||||
|
||||
export default memo(({
|
||||
addressOnSelect,
|
||||
addressOnChange,
|
||||
addressOnClose,
|
||||
show = false,
|
||||
defaultValue = [],
|
||||
selectStatus = true
|
||||
addressOnSelect,
|
||||
addressOnChange,
|
||||
addressOnClose,
|
||||
show = false,
|
||||
defaultValue = [],
|
||||
selectStatus = true,
|
||||
}: Params) => {
|
||||
//省
|
||||
const provinceList = useRef<AddresParam[]>([])
|
||||
//市
|
||||
const cityList = useRef<AddresParam[]>([])
|
||||
//区
|
||||
const areaList = useRef<AddresParam[]>([])
|
||||
|
||||
const [list, setList] = useState<AddresParam[]>([])
|
||||
const [selectIndex, setSelectIndex] = useState(0) //0 省, 1 市,2 区
|
||||
const [selectId, setSelectId] = useState(1) //选中的id
|
||||
const [selectArr, setSelectArr] = useState<DefaultValueParm[]>([]) //选中的省市区
|
||||
const [cityStatus, setCityStatus] = useState(false) //城市是否存在
|
||||
const [areaStatus, setAreaStatus] = useState(false) //区镇是否存在
|
||||
const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) //确认按钮是否可用
|
||||
// 省
|
||||
const provinceList = useRef<AddresParam[]>([])
|
||||
// 市
|
||||
const cityList = useRef<AddresParam[]>([])
|
||||
// 区
|
||||
const areaList = useRef<AddresParam[]>([])
|
||||
|
||||
const [bottomStyle, setBottomStyle] = useState({width:'100rpx',left:'0rpx'}) //底部滚动条样式
|
||||
const [list, setList] = useState<AddresParam[]>([])
|
||||
const [selectIndex, setSelectIndex] = useState(0) // 0 省, 1 市,2 区
|
||||
const [selectId, setSelectId] = useState(1) // 选中的id
|
||||
const [selectArr, setSelectArr] = useState<DefaultValueParm[]>([]) // 选中的省市区
|
||||
const [cityStatus, setCityStatus] = useState(false) // 城市是否存在
|
||||
const [areaStatus, setAreaStatus] = useState(false) // 区镇是否存在
|
||||
const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) // 确认按钮是否可用
|
||||
|
||||
useEffect(() => {
|
||||
if(selectArr.length == 0) {
|
||||
setSelectArr(defaultValue)
|
||||
if(defaultValue.length > 1) setCityStatus(true)
|
||||
if(defaultValue.length > 2) setAreaStatus(true)
|
||||
if(defaultValue.length > 0) setConfirmBtnStatus(true)
|
||||
}
|
||||
}, [defaultValue])
|
||||
const [bottomStyle, setBottomStyle] = useState<React.CSSProperties>({ width: '100rpx', left: '0rpx' }) // 底部滚动条样式
|
||||
|
||||
|
||||
//获取地址
|
||||
const {fetchData} = GetAddressListApi()
|
||||
useEffect(() => {
|
||||
getProvince()
|
||||
}, [])
|
||||
|
||||
//选中内容
|
||||
const selectItem = (item) => {
|
||||
setSelectId(item.id)
|
||||
if(selectIndex == 0) {
|
||||
setSelectArr([{name:item.name, id:item.id, level:item.level}])
|
||||
getCity(item.id)
|
||||
setAreaStatus(false)
|
||||
setCityStatus(false)
|
||||
} else if(selectIndex == 1){
|
||||
setSelectArr([selectArr[0], {name:item.name, id:item.id, level:item.level}])
|
||||
area(item.id)
|
||||
} else {
|
||||
setSelectArr([selectArr[0], selectArr[1], {name:item.name, id:item.id, level:item.level}])
|
||||
getDomDes('#address_tab_2')
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (selectArr.length == 0) {
|
||||
setSelectArr(defaultValue)
|
||||
if (defaultValue.length > 1) { setCityStatus(true) }
|
||||
if (defaultValue.length > 2) { setAreaStatus(true) }
|
||||
if (defaultValue.length > 0) { setConfirmBtnStatus(true) }
|
||||
}
|
||||
}, [defaultValue])
|
||||
|
||||
//地址数据
|
||||
useEffect(() => {
|
||||
if(selectArr && selectArr.length > 0)
|
||||
addressOnChange?.(selectArr)
|
||||
}, [selectArr])
|
||||
|
||||
//选中标题
|
||||
const onSelectIndex = (index) => {
|
||||
setSelectIndex(index)
|
||||
const selectid = selectArr[index]?selectArr[index].id:0
|
||||
setSelectId(selectid as number)
|
||||
if(index == 0) {
|
||||
getProvince()
|
||||
} else if (index == 1) {
|
||||
const id = selectArr[0]?.id
|
||||
getCity(id)
|
||||
} else {
|
||||
const id = selectArr[1]?.id
|
||||
area(id)
|
||||
}
|
||||
// 获取地址
|
||||
const { fetchData } = GetAddressListApi()
|
||||
useEffect(() => {
|
||||
getProvince()
|
||||
}, [])
|
||||
|
||||
// 选中内容
|
||||
const selectItem = (item) => {
|
||||
setSelectId(item.id)
|
||||
if (selectIndex == 0) {
|
||||
setSelectArr([{ name: item.name, id: item.id, level: item.level }])
|
||||
getCity(item.id)
|
||||
setAreaStatus(false)
|
||||
setCityStatus(false)
|
||||
}
|
||||
|
||||
|
||||
//获取省
|
||||
const getProvince = async () => {
|
||||
let res = await fetchData({parent_id: 1})
|
||||
provinceList.current = res.data.list||[]
|
||||
if(provinceList.current.length > 0) {
|
||||
setSelectIndex(0)
|
||||
setList(() => provinceList.current)
|
||||
getDomDes('#address_tab_0')
|
||||
}
|
||||
else if (selectIndex == 1) {
|
||||
setSelectArr([selectArr[0], { name: item.name, id: item.id, level: item.level }])
|
||||
area(item.id)
|
||||
}
|
||||
|
||||
//获取市
|
||||
const getCity = async (id) => {
|
||||
let res = await fetchData({parent_id: id})
|
||||
cityList.current = res.data.list||[]
|
||||
if(cityList.current.length > 0) {
|
||||
setSelectIndex(1)
|
||||
setList(() => cityList.current)
|
||||
setCityStatus(true)
|
||||
getDomDes('#address_tab_1')
|
||||
setConfirmBtnStatus(false)
|
||||
} else {
|
||||
setConfirmBtnStatus(true)
|
||||
setCityStatus(false)
|
||||
}
|
||||
else {
|
||||
setSelectArr([selectArr[0], selectArr[1], { name: item.name, id: item.id, level: item.level }])
|
||||
getDomDes('#address_tab_2')
|
||||
}
|
||||
}
|
||||
|
||||
//获取区
|
||||
const area = async (id) => {
|
||||
let res = await fetchData({parent_id: id})
|
||||
areaList.current = res.data.list||[]
|
||||
if(areaList.current.length > 0) {
|
||||
setSelectIndex(2)
|
||||
setList(() => areaList.current)
|
||||
setAreaStatus(true)
|
||||
getDomDes('#address_tab_2')
|
||||
setConfirmBtnStatus(false)
|
||||
} else {
|
||||
setConfirmBtnStatus(true)
|
||||
setAreaStatus(false)
|
||||
}
|
||||
// 地址数据
|
||||
useEffect(() => {
|
||||
if (selectArr && selectArr.length > 0) { addressOnChange?.(selectArr) }
|
||||
}, [selectArr])
|
||||
|
||||
// 选中标题
|
||||
const onSelectIndex = (index) => {
|
||||
setSelectIndex(index)
|
||||
const selectid = selectArr[index] ? selectArr[index].id : 0
|
||||
setSelectId(selectid as number)
|
||||
if (index == 0) {
|
||||
getProvince()
|
||||
}
|
||||
|
||||
//确定按钮
|
||||
const submitSelect = () => {
|
||||
addressOnClose?.()
|
||||
addressOnSelect?.(selectArr)
|
||||
else if (index == 1) {
|
||||
const id = selectArr[0]?.id
|
||||
getCity(id)
|
||||
}
|
||||
|
||||
//获取省市区宽度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
let query = Taro.createSelectorQuery();
|
||||
query.select(id).boundingClientRect(rect=>{
|
||||
let left = rect.left;
|
||||
let clientWidth = rect.width;
|
||||
console.log(clientWidth)
|
||||
setBottomStyle({
|
||||
width: clientWidth + 'px',
|
||||
left: left + 'px'
|
||||
})
|
||||
}).exec();
|
||||
}, 100)
|
||||
else {
|
||||
const id = selectArr[1]?.id
|
||||
area(id)
|
||||
}
|
||||
}
|
||||
|
||||
//点击标题栏
|
||||
const selectTab = (index) => {
|
||||
onSelectIndex(index)
|
||||
getDomDes('#address_tab_'+index)
|
||||
// 获取省
|
||||
const getProvince = async() => {
|
||||
const res = await fetchData({ parent_id: 1 })
|
||||
provinceList.current = res.data.list || []
|
||||
if (provinceList.current.length > 0) {
|
||||
setSelectIndex(0)
|
||||
setList(() => provinceList.current)
|
||||
getDomDes('#address_tab_0')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer showTitle={false} show={show} onClose={submitSelect}>
|
||||
<View className={styles.address_main}>
|
||||
<View className={styles.address_title}>
|
||||
<View onClick={() => addressOnClose?.()}>取消</View>
|
||||
<View onClick={() => submitSelect()}>确定</View>
|
||||
// 获取市
|
||||
const getCity = async(id) => {
|
||||
const res = await fetchData({ parent_id: id })
|
||||
cityList.current = res.data.list || []
|
||||
if (cityList.current.length > 0) {
|
||||
setSelectIndex(1)
|
||||
setList(() => cityList.current)
|
||||
setCityStatus(true)
|
||||
getDomDes('#address_tab_1')
|
||||
setConfirmBtnStatus(false)
|
||||
}
|
||||
else {
|
||||
setConfirmBtnStatus(true)
|
||||
setCityStatus(false)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取区
|
||||
const area = async(id) => {
|
||||
const res = await fetchData({ parent_id: id })
|
||||
areaList.current = res.data.list || []
|
||||
if (areaList.current.length > 0) {
|
||||
setSelectIndex(2)
|
||||
setList(() => areaList.current)
|
||||
setAreaStatus(true)
|
||||
getDomDes('#address_tab_2')
|
||||
setConfirmBtnStatus(false)
|
||||
}
|
||||
else {
|
||||
setConfirmBtnStatus(true)
|
||||
setAreaStatus(false)
|
||||
}
|
||||
}
|
||||
|
||||
// 确定按钮
|
||||
const submitSelect = () => {
|
||||
addressOnClose?.()
|
||||
addressOnSelect?.(selectArr)
|
||||
}
|
||||
|
||||
// 获取省市区宽度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
const query = Taro.createSelectorQuery()
|
||||
query.select(id).boundingClientRect((rect) => {
|
||||
const left = rect.left
|
||||
const clientWidth = rect.width
|
||||
console.log(clientWidth)
|
||||
setBottomStyle({
|
||||
width: `${clientWidth}px`,
|
||||
left: `${left}px`,
|
||||
})
|
||||
}).exec()
|
||||
}, 100)
|
||||
}
|
||||
|
||||
// 点击标题栏
|
||||
const selectTab = (index) => {
|
||||
onSelectIndex(index)
|
||||
getDomDes(`#address_tab_${index}`)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer showTitle={false} show={show} onClose={submitSelect}>
|
||||
<View className={styles.address_main}>
|
||||
<View className={styles.address_title}>
|
||||
<View onClick={() => addressOnClose?.()}>取消</View>
|
||||
<View onClick={() => submitSelect()}>确定</View>
|
||||
</View>
|
||||
<View className={styles.address_select}>
|
||||
<View id="address_tab_0" onClick={() => selectTab(0)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 0) })}>{selectArr[0] ? selectArr[0].name : '请选择'}</View>
|
||||
{cityStatus && <View id="address_tab_1" onClick={() => selectTab(1)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 1) })}>{selectArr[1] ? selectArr[1].name : '请选择'}</View>}
|
||||
{areaStatus && <View id="address_tab_2" onClick={() => selectTab(2)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 2) })}>{selectArr[2] ? selectArr[2].name : '请选择'}</View>}
|
||||
<View style={bottomStyle} className={styles.bottom_index}></View>
|
||||
</View>
|
||||
<View className={styles.address_list}>
|
||||
<ScrollView scrollY className={styles.address_scroll}>
|
||||
<View className={styles.address_scroll_list}>
|
||||
{list.map((item) => {
|
||||
return (
|
||||
<View onClick={() => selectItem(item)} className={classnames(styles.address_list_item, { [styles.addresst_select]: (selectId == item.id) })}>
|
||||
<View className={styles.address_list_item_name}>{item.name}</View>
|
||||
{(selectArr[selectIndex]?.id == item.id) && <View className={`iconfont icon-tick ${styles.address_iconfont}`}></View>}
|
||||
</View>
|
||||
<View className={styles.address_select}>
|
||||
<View id="address_tab_0" onClick={() => selectTab(0)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 0)})}>{selectArr[0]?selectArr[0].name:'请选择'}</View>
|
||||
{cityStatus&&<View id="address_tab_1" onClick={() => selectTab(1)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 1)})}>{selectArr[1]?selectArr[1].name:'请选择'}</View>}
|
||||
{areaStatus&&<View id="address_tab_2" onClick={() => selectTab(2)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 2)})}>{selectArr[2]?selectArr[2].name:'请选择'}</View>}
|
||||
<View style={bottomStyle} className={styles.bottom_index}></View>
|
||||
</View>
|
||||
<View className={styles.address_list}>
|
||||
<ScrollView scrollY className={styles.address_scroll}>
|
||||
<View className={styles.address_scroll_list}>
|
||||
{list.map(item => {
|
||||
return (
|
||||
<View onClick={() => selectItem(item)} className={classnames(styles.address_list_item, {[styles.addresst_select]:(selectId == item.id)})}>
|
||||
<View className={styles.address_list_item_name}>{item.name}</View>
|
||||
{(selectArr[selectIndex]?.id == item.id)&&<View className={`iconfont icon-tick ${styles.address_iconfont}` }></View>}
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</View>
|
||||
</Drawer>
|
||||
</>
|
||||
)
|
||||
})
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</View>
|
||||
</Drawer>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,202 +1,205 @@
|
||||
import { CancelOrderApi, ReceiveOrderApi } from "@/api/order"
|
||||
import { alert } from "@/common/common"
|
||||
import { ORDER_STATUS, SALE_MODE } from "@/common/enum"
|
||||
import { ScrollView, Text, View } from "@tarojs/components"
|
||||
import Taro from "@tarojs/taro"
|
||||
import { useCallback, useRef, memo, useState, useEffect, useMemo } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import { ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { ORDER_STATUS, SALE_MODE } from '@/common/enum'
|
||||
import { alert } from '@/common/common'
|
||||
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
||||
|
||||
type Param = {
|
||||
orderInfo: {
|
||||
status: number, //订单状态
|
||||
orderId: number, //订单id
|
||||
actual_amount: number, //实付金额
|
||||
wait_pay_amount: number, //待付金额
|
||||
sale_mode: number //订单类型
|
||||
}|null,
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
interface Param {
|
||||
orderInfo: {
|
||||
status: number // 订单状态
|
||||
orderId: number // 订单id
|
||||
actual_amount: number // 实付金额
|
||||
wait_pay_amount: number // 待付金额
|
||||
sale_mode: number // 订单类型
|
||||
}|null
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
export default memo(({orderInfo, onClick}:Param) => {
|
||||
//订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment
|
||||
} = ORDER_STATUS
|
||||
export default memo(({ orderInfo, onClick }: Param) => {
|
||||
// 订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment,
|
||||
} = ORDER_STATUS
|
||||
|
||||
//订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//订单按钮按订单状态归类, value是该订单状态,可能该按钮会出现
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value], //取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], //去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [SaleOrderStatusWaitingDelivery.value], //申请退款按钮对应: 待发货
|
||||
label: '申请退款'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], //申请退货按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [SaleOrderStatusWaitingReceipt.value], //确认收货按钮对应: 待收货
|
||||
label: '确认收货'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [SaleOrderStatusWaitingReceipt.value,SaleOrderStatusAlreadyReceipt.value,SaleOrderStatusComplete.value,SaleOrderStatusRefund.value], //再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
value: [SaleOrderStatusBooking.value], //按钮对应: 待接单
|
||||
label: '退款'
|
||||
},
|
||||
])
|
||||
|
||||
// 订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//判断是否显示该按钮
|
||||
const orderBtnsShow = (item) => {
|
||||
if(orderInfo) {
|
||||
if(item.id == 1) {
|
||||
//取消订单按钮
|
||||
return( orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) //在待发货之前没有付过款
|
||||
} else if (item.id == 2) {
|
||||
//去付款按钮
|
||||
return( orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) //只要没有付完款就显示
|
||||
} else if(item.id == 3 ) {
|
||||
//申请退款, 只有大货才有
|
||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //大货在待发货付过款
|
||||
} else if( item.id == 8) {
|
||||
//退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //散剪和剪板在待接单时付过款
|
||||
}
|
||||
else {
|
||||
//其他按钮
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
// 订单按钮按订单状态归类, value是该订单状态,可能该按钮会出现
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value], // 取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], // 去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [SaleOrderStatusWaitingDelivery.value], // 申请退款按钮对应: 待发货
|
||||
label: '申请退款',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], // 申请退货按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [SaleOrderStatusWaitingReceipt.value], // 确认收货按钮对应: 待收货
|
||||
label: '确认收货',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
value: [SaleOrderStatusBooking.value], // 按钮对应: 待接单
|
||||
label: '退款',
|
||||
},
|
||||
])
|
||||
|
||||
// 判断是否显示该按钮
|
||||
const orderBtnsShow = (item) => {
|
||||
if (orderInfo) {
|
||||
if (item.id == 1) {
|
||||
// 取消订单按钮
|
||||
return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款
|
||||
}
|
||||
else if (item.id == 2) {
|
||||
// 去付款按钮
|
||||
return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示
|
||||
}
|
||||
else if (item.id == 3) {
|
||||
// 申请退款, 只有大货才有
|
||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款
|
||||
}
|
||||
else if (item.id == 8) {
|
||||
// 退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款
|
||||
}
|
||||
else {
|
||||
// 其他按钮
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示的按钮数组
|
||||
const orderBtnsShowList: { id: number; value: any; label: string }[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter((item) => {
|
||||
return orderBtnsShow(item)
|
||||
})
|
||||
}, [orderInfo])
|
||||
|
||||
// 点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
(val == 1) && cancelOrder(); // 取消订单按钮
|
||||
(val == 2) && onClick?.(2); // 去付款按钮
|
||||
(val == 6) && receiveOrder() // 确认收货
|
||||
}
|
||||
|
||||
// 取消订单
|
||||
const { fetchData: cancelFetchData } = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//显示的按钮数组
|
||||
const orderBtnsShowList: {id: number, value: any, label: string}[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter(item => {
|
||||
return orderBtnsShow(item)
|
||||
})
|
||||
}, [orderInfo])
|
||||
// 确认订单
|
||||
const { fetchData: receiveOrderFetchData } = ReceiveOrderApi()
|
||||
const receiveOrder = async() => {
|
||||
console.log('123456')
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
}
|
||||
else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3) && <View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(true)}>更多</Text>
|
||||
{showMore && <View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) && <View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
</View>}
|
||||
</View>}
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
(val == 1)&&cancelOrder(); //取消订单按钮
|
||||
(val == 2)&&onClick?.(2); //去付款按钮
|
||||
(val == 6)&&receiveOrder(); //确认收货
|
||||
|
||||
}
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3) && <View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>,
|
||||
)}
|
||||
</View>
|
||||
|
||||
//取消订单
|
||||
const {fetchData: cancelFetchData} = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({id: orderInfo?.orderId})
|
||||
if(res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//确认订单
|
||||
const {fetchData: receiveOrderFetchData} = ReceiveOrderApi()
|
||||
const receiveOrder = async () => {
|
||||
console.log('123456')
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await receiveOrderFetchData({sale_order_id: orderInfo?.orderId})
|
||||
if(res.success){
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
} else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return {top:`-${(orderBtnsShowList.length - 3)*70 + 10}rpx`, left: `-${10}rpx`}
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3)&&<View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(true)}>更多</Text>
|
||||
{showMore&&<View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) &&<View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
</View>}
|
||||
</View>}
|
||||
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3)&&<View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
})
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import { alert } from '@/common/common'
|
||||
import { AFTER_ORDER_STATUS, ORDER_STATUS, REFUND_STATUS_ORDER, SALE_MODE } from '@/common/enum'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useRef, memo, useState, useMemo } from 'react'
|
||||
import { memo, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import { AFTER_ORDER_STATUS, ORDER_STATUS, REFUND_STATUS_ORDER, SALE_MODE } from '@/common/enum'
|
||||
import { alert } from '@/common/common'
|
||||
import { ReturnApplyOrderCancelApi } from '@/api/salesAfterOrder'
|
||||
import { throttle } from '@/common/util'
|
||||
|
||||
type Param = {
|
||||
interface Param {
|
||||
orderInfo: {
|
||||
stage: number //售后状态
|
||||
sale_mode: number //订单类型
|
||||
type: number //1退货,2退款
|
||||
return_apply_order_id: number //售后申请单
|
||||
is_quality_check: true | false //质检结果
|
||||
stage: number // 售后状态
|
||||
sale_mode: number // 订单类型
|
||||
type: number // 1退货,2退款
|
||||
return_apply_order_id: number // 售后申请单
|
||||
is_quality_check: true | false // 质检结果
|
||||
}
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
fixedBottom?: true | false //是否固定在底部
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
fixedBottom?: true | false // 是否固定在底部
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
//售后订单状态
|
||||
const { ReturnStageApplying, ReturnStageWaitCheck, ReturnStageReturned, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund } =
|
||||
AFTER_ORDER_STATUS
|
||||
// 售后订单状态
|
||||
const { ReturnStageApplying, ReturnStageWaitCheck, ReturnStageReturned, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund }
|
||||
= AFTER_ORDER_STATUS
|
||||
|
||||
const {
|
||||
ReturnApplyOrderTypeAdvanceReceiptRefund, // 预收退款
|
||||
@@ -31,15 +31,14 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
ReturnApplyOrderTypeSalesRefund, // 销售退款
|
||||
} = REFUND_STATUS_ORDER
|
||||
|
||||
//注册按钮
|
||||
type orderBtnsListParams = { id: number; label: string; validatarFunc: (val: typeof orderInfo) => any }
|
||||
// 注册按钮
|
||||
interface orderBtnsListParams { id: number; label: string; validatarFunc: (val: typeof orderInfo) => any }
|
||||
const orderBtnsList = useRef<orderBtnsListParams[]>([
|
||||
{
|
||||
id: 8,
|
||||
label: '申请记录',
|
||||
validatarFunc: (orderInfo) => {
|
||||
if (orderInfo.sale_mode !== 1)
|
||||
return [ReturnStageQualityCheckPendingRefund.value, ReturnStageServiceOrderPendingRefund.value, ReturnStageReturned.value].includes(orderInfo.stage)
|
||||
if (orderInfo.sale_mode !== 1) { return [ReturnStageQualityCheckPendingRefund.value, ReturnStageServiceOrderPendingRefund.value, ReturnStageReturned.value].includes(orderInfo.stage) }
|
||||
return false
|
||||
},
|
||||
},
|
||||
@@ -47,8 +46,7 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
id: 1,
|
||||
label: '取消退货',
|
||||
validatarFunc: (orderInfo) => {
|
||||
if (orderInfo?.sale_mode != 1 && orderInfo.type == ReturnApplyOrderTypeReturnForRefund.value)
|
||||
return [ReturnStageApplying.value, ReturnStageWaitCheck.value].includes(orderInfo.stage)
|
||||
if (orderInfo?.sale_mode != 1 && orderInfo.type == ReturnApplyOrderTypeReturnForRefund.value) { return [ReturnStageApplying.value, ReturnStageWaitCheck.value].includes(orderInfo.stage) }
|
||||
return false
|
||||
},
|
||||
},
|
||||
@@ -70,9 +68,8 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
id: 6,
|
||||
label: '取消退款',
|
||||
validatarFunc: (orderInfo) => {
|
||||
if (orderInfo?.sale_mode != 1 && orderInfo.type != ReturnApplyOrderTypeReturnForRefund.value)
|
||||
return [ReturnStageApplying.value, ReturnStageServiceOrderPendingRefund.value]?.includes(orderInfo.stage)
|
||||
if (orderInfo?.sale_mode == 1) return [ReturnStageApplying.value].includes(orderInfo.stage)
|
||||
if (orderInfo?.sale_mode != 1 && orderInfo.type != ReturnApplyOrderTypeReturnForRefund.value) { return [ReturnStageApplying.value, ReturnStageServiceOrderPendingRefund.value]?.includes(orderInfo.stage) }
|
||||
if (orderInfo?.sale_mode == 1) { return [ReturnStageApplying.value].includes(orderInfo.stage) }
|
||||
return false
|
||||
},
|
||||
},
|
||||
@@ -80,52 +77,56 @@ export default memo(({ orderInfo, onClick, fixedBottom = true }: Param) => {
|
||||
id: 7,
|
||||
label: '退款码单',
|
||||
validatarFunc: (orderInfo) => {
|
||||
if (ReturnStageReturned.value == orderInfo.stage && orderInfo?.sale_mode === 0) return true
|
||||
if (ReturnStageReturned.value == orderInfo.stage && orderInfo?.sale_mode === 0) { return true }
|
||||
return false
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
//显示的按钮数组
|
||||
// 显示的按钮数组
|
||||
const orderBtnsShowList: any[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter((item) => {
|
||||
return item.validatarFunc(orderInfo)
|
||||
})
|
||||
}, [orderInfo])
|
||||
|
||||
//点击按钮操作
|
||||
// 点击按钮操作
|
||||
const submitBtns = throttle((val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder({ title: '要取消退货吗?', val })
|
||||
} else if (val == 6) {
|
||||
}
|
||||
else if (val == 6) {
|
||||
cancelOrder({ title: '要取消退款吗?', val })
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 600)
|
||||
|
||||
//取消退货/退款
|
||||
// 取消退货/退款
|
||||
const { fetchData: returnApplyOrderCancelFetchData } = ReturnApplyOrderCancelApi()
|
||||
const cancelOrder = ({ title = '', val }) => {
|
||||
Taro.showModal({
|
||||
title,
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
let res = await returnApplyOrderCancelFetchData({ id: orderInfo?.return_apply_order_id })
|
||||
const res = await returnApplyOrderCancelFetchData({ id: orderInfo?.return_apply_order_id })
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(val)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//显示更多按钮
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { memo, useCallback } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { numberWithCommas } from "@/common/fotmat";
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import { memo, useCallback } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import { numberWithCommas } from '@/common/fotmat'
|
||||
|
||||
type Param = {
|
||||
number: number, //数字
|
||||
status: 0|1|2 //0 小型,1中型,2大
|
||||
interface Param {
|
||||
number: number // 数字
|
||||
status: 0|1|2 // 0 小型,1中型,2大
|
||||
}
|
||||
export default memo(({number = 0, status = 1}:Param) => {
|
||||
const priceDom = useCallback(() => {
|
||||
let res = number.toFixed(2).split('.')
|
||||
let int_num = parseInt(res[0]) + ''
|
||||
let decimals_num = res[1]
|
||||
return (
|
||||
<>
|
||||
<Text className={styles.price_text}>¥</Text>
|
||||
<Text className={styles.price_text}>{numberWithCommas({number:int_num, digit:0})}</Text>
|
||||
<Text className={styles.price_text}>.{decimals_num}</Text>
|
||||
</>
|
||||
)
|
||||
}, [number])
|
||||
export default memo(({ number = 0, status = 1 }: Param) => {
|
||||
const priceDom = useCallback(() => {
|
||||
const res = number.toFixed(2).split('.')
|
||||
const int_num = `${parseInt(res[0])}`
|
||||
const decimals_num = res[1]
|
||||
return (
|
||||
<View className={classnames(styles.order_price_num, status==1&&styles.emphasis_num, status==2&&styles.emphasis_num_big)} >
|
||||
{priceDom()}
|
||||
</View>
|
||||
<>
|
||||
<Text className={styles.price_text}>¥</Text>
|
||||
<Text className={styles.price_text}>{numberWithCommas({ number: int_num, digit: 0 })}</Text>
|
||||
<Text className={styles.price_text}>.{decimals_num}</Text>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}, [number])
|
||||
return (
|
||||
<View className={classnames(styles.order_price_num, status == 1 && styles.emphasis_num, status == 2 && styles.emphasis_num_big)} >
|
||||
{priceDom()}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { Image, Swiper, SwiperItem, View } from '@tarojs/components'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { goLink } from '@/common/common'
|
||||
import { GetBannerList } from '@/api/banner'
|
||||
import styles from './index.module.scss'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
|
||||
type item = { title: string; img: string; url: string; id: number }
|
||||
interface item { title: string; img: string; url: string; id: number }
|
||||
|
||||
type params = {
|
||||
interface params {
|
||||
list?: item[]
|
||||
swiperOnClick?: (val: item) => void
|
||||
style?: Object
|
||||
}
|
||||
export default (props: params) => {
|
||||
let { swiperOnClick, style = {} } = props
|
||||
const { swiperOnClick, style = {} } = props
|
||||
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const { fetchData, state } = GetBannerList()
|
||||
@@ -22,15 +22,16 @@ export default (props: params) => {
|
||||
getData()
|
||||
}, [])
|
||||
|
||||
const getData = async () => {
|
||||
const getData = async() => {
|
||||
const res = await fetchData()
|
||||
setList(res.data?.list)
|
||||
}
|
||||
|
||||
const skipTo = (item) => {
|
||||
if (item.jump_type == 2 || item.jump_type == 0) {
|
||||
goLink(item.link + '&title=' + item.title)
|
||||
} else {
|
||||
goLink(`${item.link}&title=${item.title}`)
|
||||
}
|
||||
else {
|
||||
goLink(item.link)
|
||||
}
|
||||
}
|
||||
@@ -41,12 +42,12 @@ export default (props: params) => {
|
||||
|
||||
return (
|
||||
<View className={styles.swiper_con} style={style}>
|
||||
<Swiper className={styles.xswiper} indicatorColor='#ccc' indicatorActiveColor='#fff' circular indicatorDots={showDot} autoplay>
|
||||
<Swiper className={styles.xswiper} indicatorColor="#ccc" indicatorActiveColor="#fff" circular indicatorDots={showDot} autoplay>
|
||||
{list?.map((item) => {
|
||||
return (
|
||||
<SwiperItem key={item.id}>
|
||||
<View className={styles.image_item} onClick={() => skipTo(item)}>
|
||||
<Image mode='aspectFill' src={formatImgUrl(item.prev_view_url, '!w800')}></Image>
|
||||
<Image mode="aspectFill" src={formatImgUrl(item.prev_view_url, '!w800')}></Image>
|
||||
</View>
|
||||
</SwiperItem>
|
||||
)
|
||||
|
||||
@@ -1,51 +1,50 @@
|
||||
import { Image, Swiper, SwiperItem, Text, View } from "@tarojs/components"
|
||||
import styles from './index.module.scss'
|
||||
import { formatImgUrl } from "@/common/fotmat"
|
||||
import Taro from "@tarojs/taro";
|
||||
import { goLink } from "@/common/common";
|
||||
import { Image, Swiper, SwiperItem, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import styles from './index.module.scss'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
import { goLink } from '@/common/common'
|
||||
|
||||
type params = {
|
||||
show?: true|false,
|
||||
onClose?: () => void
|
||||
interface params {
|
||||
show?: true|false
|
||||
onClose?: () => void
|
||||
}
|
||||
export default ({show, onClose}:params) => {
|
||||
const onCustomer = async () => {
|
||||
let res = await Taro.showModal({
|
||||
title: '是否拨打服务热线',
|
||||
confirmText: '拨打',
|
||||
content: '(0757) 8270 6695',
|
||||
cancelText: '取消',
|
||||
})
|
||||
if(res.confirm) {
|
||||
Taro.makePhoneCall({
|
||||
phoneNumber: '(0757)82706695'
|
||||
})
|
||||
}
|
||||
export default ({ show, onClose }: params) => {
|
||||
const onCustomer = async() => {
|
||||
const res = await Taro.showModal({
|
||||
title: '是否拨打服务热线',
|
||||
confirmText: '拨打',
|
||||
content: '(0757) 8270 6695',
|
||||
cancelText: '取消',
|
||||
})
|
||||
if (res.confirm) {
|
||||
Taro.makePhoneCall({
|
||||
phoneNumber: '(0757)82706695',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onConfirm = () => {
|
||||
onClose?.()
|
||||
goLink('/pages/bindSalesman/index')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{show&&<View className={styles.bindSalesman_main}>
|
||||
<View className={styles.bindSalesman_pop}>
|
||||
<View className={styles.bindSalesman_header}>
|
||||
<Image src={formatImgUrl('/mall/invite_code_top.png', '!w400')} mode="aspectFill"/>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_message}>
|
||||
<Text>提示</Text>
|
||||
<Text>暂未开通下单权限功能,稍后有客服联系您,请注意接收电话。</Text>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_operation}>
|
||||
<View className={styles.btns} onClick={() => onConfirm()}>输入邀请码</View>
|
||||
<View className={styles.btns} onClick={() => onCustomer()}>联系客服</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_mask} onClick={onClose}></View>
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
|
||||
}
|
||||
const onConfirm = () => {
|
||||
onClose?.()
|
||||
goLink('/pages/bindSalesman/index')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{show && <View className={styles.bindSalesman_main}>
|
||||
<View className={styles.bindSalesman_pop}>
|
||||
<View className={styles.bindSalesman_header}>
|
||||
<Image src={formatImgUrl('/mall/invite_code_top.png', '!w400')} mode="aspectFill" />
|
||||
</View>
|
||||
<View className={styles.bindSalesman_message}>
|
||||
<Text>提示</Text>
|
||||
<Text>暂未开通下单权限功能,稍后有客服联系您,请注意接收电话。</Text>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_operation}>
|
||||
<View className={styles.btns} onClick={() => onConfirm()}>输入邀请码</View>
|
||||
<View className={styles.btns} onClick={() => onCustomer()}>联系客服</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.bindSalesman_mask} onClick={onClose}></View>
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useState } from "react";
|
||||
import Taro, { useDidShow } from "@tarojs/taro";
|
||||
import {useBluetooth} from "@/use/contextBlueTooth"
|
||||
import SearchInput from "@/components/searchInput";
|
||||
import Popup from "@/components/bluetooth/Popup"
|
||||
import classnames from "classnames";
|
||||
import styles from "./css/linkBlueTooth.module.scss"
|
||||
import useCheckAuthorize from "@/use/useCheckAuthorize";
|
||||
import { View } from '@tarojs/components'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './css/linkBlueTooth.module.scss'
|
||||
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||
import SearchInput from '@/components/searchInput'
|
||||
import Popup from '@/components/bluetooth/Popup'
|
||||
import useCheckAuthorize from '@/use/useCheckAuthorize'
|
||||
|
||||
export default memo(() => {
|
||||
const {state, init, startScan, connect, disconnect} = useBluetooth()
|
||||
const { state, init, startScan, connect, disconnect } = useBluetooth()
|
||||
|
||||
const {check} = useCheckAuthorize({scope:'scope.bluetooth', msg:'请开启小程序蓝牙权限'})
|
||||
const { check } = useCheckAuthorize({ scope: 'scope.bluetooth', msg: '请开启小程序蓝牙权限' })
|
||||
|
||||
useEffect(() => {
|
||||
init()
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
init()
|
||||
}, [])
|
||||
|
||||
const [linkStatus, setLinkStatus] = useState(1)
|
||||
useEffect(() => {
|
||||
if(!state.available) {
|
||||
setLinkStatus(1)
|
||||
} else if(state.available&&state.connected?.name) {
|
||||
setLinkStatus(3)
|
||||
} else {
|
||||
setLinkStatus(2)
|
||||
}
|
||||
}, [state.available, state.connected])
|
||||
|
||||
const linkName = useMemo(() => {
|
||||
return state.connected?.localName||''
|
||||
}, [state.connected])
|
||||
|
||||
//链接设备
|
||||
const onLinkListen = (item) => {
|
||||
if(!state.connected&&!state.connecting)
|
||||
connect(item)
|
||||
const [linkStatus, setLinkStatus] = useState(1)
|
||||
useEffect(() => {
|
||||
if (!state.available) {
|
||||
setLinkStatus(1)
|
||||
}
|
||||
else if (state.available && state.connected?.name) {
|
||||
setLinkStatus(3)
|
||||
}
|
||||
else {
|
||||
setLinkStatus(2)
|
||||
}
|
||||
}, [state.available, state.connected])
|
||||
|
||||
const [popupShow, setPopupShow] = useState(false)
|
||||
//显示设备列表
|
||||
const onFindDevice = () => {
|
||||
check().then(res => {
|
||||
if(linkStatus == 1) {
|
||||
Taro.showToast({
|
||||
title:'请打开手机蓝牙',
|
||||
icon:'none'
|
||||
})
|
||||
} else {
|
||||
setPopupShow(true)
|
||||
onFindEven()
|
||||
}
|
||||
const linkName = useMemo(() => {
|
||||
return state.connected?.localName || ''
|
||||
}, [state.connected])
|
||||
|
||||
// 链接设备
|
||||
const onLinkListen = (item) => {
|
||||
if (!state.connected && !state.connecting) { connect(item) }
|
||||
}
|
||||
|
||||
const [popupShow, setPopupShow] = useState(false)
|
||||
// 显示设备列表
|
||||
const onFindDevice = () => {
|
||||
check().then((res) => {
|
||||
if (linkStatus == 1) {
|
||||
Taro.showToast({
|
||||
title: '请打开手机蓝牙',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
const onFindEven = () => {
|
||||
if(!state.discovering&&!state.connected&&!state.connecting)
|
||||
startScan()
|
||||
}
|
||||
}
|
||||
else {
|
||||
setPopupShow(true)
|
||||
onFindEven()
|
||||
}
|
||||
})
|
||||
}
|
||||
const onFindEven = () => {
|
||||
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
|
||||
}
|
||||
|
||||
//断开链接
|
||||
const onDisconnect = () => {
|
||||
disconnect()
|
||||
setPopupShow(false)
|
||||
}
|
||||
// 断开链接
|
||||
const onDisconnect = () => {
|
||||
disconnect()
|
||||
setPopupShow(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.main}>
|
||||
<SearchInput title="蓝牙设备" showIcon={true}>
|
||||
<View className={styles.bluetooth_link} onClick={onFindDevice}>
|
||||
<View className={classnames(styles.link_status, linkStatus == 3 &&styles.link_statused, linkStatus == 2&&styles.link_statused_no)}></View>
|
||||
{
|
||||
linkStatus == 1&&<View className={classnames(styles.link_name, styles.link_name_no)}>请开启蓝牙</View>||
|
||||
linkStatus == 2&&<View className={classnames(styles.link_name,styles.link_name_no_link) }>未连接设备</View>||
|
||||
linkStatus == 3&&<View className={classnames(styles.link_name)}>{linkName}</View>
|
||||
}
|
||||
</View>
|
||||
</SearchInput>
|
||||
<Popup
|
||||
state={state}
|
||||
show={popupShow}
|
||||
onClose={() => setPopupShow(false)}
|
||||
onLink={item => onLinkListen(item)}
|
||||
onOff={onDisconnect}
|
||||
onFind={onFindEven}
|
||||
/>
|
||||
</View>
|
||||
</>
|
||||
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<View className={styles.main}>
|
||||
<SearchInput title="蓝牙设备" showIcon>
|
||||
<View className={styles.bluetooth_link} onClick={onFindDevice}>
|
||||
<View className={classnames(styles.link_status, linkStatus == 3 && styles.link_statused, linkStatus == 2 && styles.link_statused_no)}></View>
|
||||
{
|
||||
linkStatus == 1 && <View className={classnames(styles.link_name, styles.link_name_no)}>请开启蓝牙</View>
|
||||
|| linkStatus == 2 && <View className={classnames(styles.link_name, styles.link_name_no_link)}>未连接设备</View>
|
||||
|| linkStatus == 3 && <View className={classnames(styles.link_name)}>{linkName}</View>
|
||||
}
|
||||
</View>
|
||||
</SearchInput>
|
||||
<Popup
|
||||
state={state}
|
||||
show={popupShow}
|
||||
onClose={() => setPopupShow(false)}
|
||||
onLink={item => onLinkListen(item)}
|
||||
onOff={onDisconnect}
|
||||
onFind={onFindEven}
|
||||
/>
|
||||
</View>
|
||||
</>
|
||||
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
import { ScrollView, View } from "@tarojs/components"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import Loading from "@/components/loading"
|
||||
import style from "./css/popup.module.scss"
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import style from './css/popup.module.scss'
|
||||
import Loading from '@/components/loading'
|
||||
|
||||
interface params {
|
||||
state: any,
|
||||
show: Boolean,
|
||||
onClose: (Boolean) => void,
|
||||
onLink: (any) => void,
|
||||
children?: React.ReactNode
|
||||
onOff: () => void,
|
||||
onFind: () => void,
|
||||
state: any
|
||||
show: Boolean
|
||||
onClose: (Boolean) => void
|
||||
onLink: (any) => void
|
||||
children?: React.ReactNode
|
||||
onOff: () => void
|
||||
onFind: () => void
|
||||
}
|
||||
|
||||
export default memo(({state, show=false, onClose, onLink, onOff, onFind}:params) => {
|
||||
const [popupShow, setPopupShow] = useState(show)
|
||||
useEffect(() => {
|
||||
setPopupShow(show)
|
||||
}, [show])
|
||||
const onCloseListener = () => {
|
||||
onClose(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
popupShow&&<View className={style.popup}>
|
||||
<View className={style.content}>
|
||||
<View className={style.title}>搜索设备</View>
|
||||
<View className={style.list}>
|
||||
<ScrollView scrollY className={style.scroll}>
|
||||
{
|
||||
(state.devices&&state.devices.length > 0)&&state?.devices.map(item => {
|
||||
return (
|
||||
<View className={style.item} onClick={() => onLink(item)}>
|
||||
<View>{item.name}</View>
|
||||
{
|
||||
(!state.connecting&&!state.connected)&&<View >链接</View>||
|
||||
(state.connecting&&item.deviceId == state.connecting.deviceId)&&<View className={style.link_ing}>正在链接...</View>||
|
||||
(state.connected&&item.deviceId == state.connected.deviceId)&&<View className={style.link_success}>链接成功</View>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})||
|
||||
<View className={style.noDevice}>
|
||||
{
|
||||
(!state.discovering)&& <>
|
||||
<View>暂无设备,请按以下条件检查</View>
|
||||
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
|
||||
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
|
||||
<View className={style.n_item}>3.请打开手机定位</View>
|
||||
</>||
|
||||
<View>设备搜索中</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
|
||||
const [popupShow, setPopupShow] = useState(show)
|
||||
useEffect(() => {
|
||||
setPopupShow(show)
|
||||
}, [show])
|
||||
const onCloseListener = () => {
|
||||
onClose(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
popupShow && <View className={style.popup}>
|
||||
<View className={style.content}>
|
||||
<View className={style.title}>搜索设备</View>
|
||||
<View className={style.list}>
|
||||
<ScrollView scrollY className={style.scroll}>
|
||||
{
|
||||
(state.devices && state.devices.length > 0) && state?.devices.map((item) => {
|
||||
return (
|
||||
<View className={style.item} onClick={() => onLink(item)}>
|
||||
<View>{item.name}</View>
|
||||
{
|
||||
state.connected&&<View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>断开链接</View>||
|
||||
(!state.connected&&state.discovering)&&<View className={`${style.footer} ${style.finding}`}>搜索中<Loading width={30} color='orange'/></View>||
|
||||
<View className={style.footer} onClick={onFind}>重新搜索</View>
|
||||
(!state.connecting && !state.connected) && <View >链接</View>
|
||||
|| (state.connecting && item.deviceId == state.connecting.deviceId) && <View className={style.link_ing}>正在链接...</View>
|
||||
|| (state.connected && item.deviceId == state.connected.deviceId) && <View className={style.link_success}>链接成功</View>
|
||||
}
|
||||
</View>
|
||||
<View className={style.mask} onClick={onCloseListener}></View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|| <View className={style.noDevice}>
|
||||
{
|
||||
(!state.discovering) && <>
|
||||
<View>暂无设备,请按以下条件检查</View>
|
||||
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
|
||||
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
|
||||
<View className={style.n_item}>3.请打开手机定位</View>
|
||||
</>
|
||||
|| <View>设备搜索中</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
{
|
||||
state.connected && <View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>断开链接</View>
|
||||
|| (!state.connected && state.discovering) && <View className={`${style.footer} ${style.finding}`}>搜索中<Loading width={30} color="orange" /></View>
|
||||
|| <View className={style.footer} onClick={onFind}>重新搜索</View>
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
</View>
|
||||
<View className={style.mask} onClick={onCloseListener}></View>
|
||||
</View>
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -3,20 +3,21 @@ import classnames from 'classnames'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type params = {
|
||||
onSelect?: () => void //选择触发
|
||||
onClose?: () => void //取消触发
|
||||
status?: false | true //是否选中
|
||||
disabled?: false | true //是否禁用
|
||||
interface params {
|
||||
onSelect?: () => void // 选择触发
|
||||
onClose?: () => void // 取消触发
|
||||
status?: false | true // 是否选中
|
||||
disabled?: false | true // 是否禁用
|
||||
}
|
||||
export default forwardRef(({ onSelect, onClose, status = false, disabled = false }: params, ref) => {
|
||||
const [selected, SetSelected] = useState(false)
|
||||
const onSelectEven = () => {
|
||||
if (disabled) return false
|
||||
let res = !selected
|
||||
if (disabled) { return false }
|
||||
const res = !selected
|
||||
if (res) {
|
||||
onSelect?.()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
onClose?.()
|
||||
}
|
||||
SetSelected(res)
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { View, Text } from "@tarojs/components"
|
||||
import { memo } from "react"
|
||||
import style from "./index.module.scss"
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import style from './index.module.scss'
|
||||
|
||||
type Params = {
|
||||
onClose?: () => void,
|
||||
styleObj?: Object
|
||||
interface Params {
|
||||
onClose?: () => void
|
||||
styleObj?: Object
|
||||
}
|
||||
|
||||
export default memo(({onClose, styleObj = {}}:Params) => {
|
||||
return (
|
||||
<View
|
||||
style={styleObj}
|
||||
className={style.icon_a_cuowuwrong_self}
|
||||
onClick={onClose}
|
||||
>
|
||||
<Text className={`iconfont icon-qingkong ${style.icon_a_btn}`}></Text>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
export default memo(({ onClose, styleObj = {} }: Params) => {
|
||||
return (
|
||||
<View
|
||||
style={styleObj}
|
||||
className={style.icon_a_cuowuwrong_self}
|
||||
onClick={onClose}
|
||||
>
|
||||
<Text className={`iconfont icon-qingkong ${style.icon_a_btn}`}></Text>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { Input, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Big from 'big.js'
|
||||
import styles from './index.module.scss'
|
||||
type params = {
|
||||
minNum?: number //最小值
|
||||
maxNum?: number //最大值
|
||||
step?: number //步长
|
||||
defaultNum?: number //默认值
|
||||
digits?: number //多少位小数
|
||||
import styles from './index.module.scss'
|
||||
|
||||
interface params {
|
||||
minNum?: number // 最小值
|
||||
maxNum?: number // 最大值
|
||||
step?: number // 步长
|
||||
defaultNum?: number // 默认值
|
||||
digits?: number // 多少位小数
|
||||
onChange?: (val: number) => void
|
||||
onBlue?: (val: number) => void //失去焦点触发
|
||||
onBlue?: (val: number) => void // 失去焦点触发
|
||||
onClickBtn?: (val: number) => void
|
||||
unit?: string
|
||||
disable?: true | false //是否禁用
|
||||
disable?: true | false // 是否禁用
|
||||
}
|
||||
export default memo((props: params) => {
|
||||
return <Counter {...props}></Counter>
|
||||
@@ -20,24 +21,24 @@ export default memo((props: params) => {
|
||||
|
||||
function areEqual(prevProps: params, nextProps: params) {
|
||||
return (
|
||||
prevProps.defaultNum == nextProps.defaultNum &&
|
||||
prevProps.unit == nextProps.unit &&
|
||||
prevProps.minNum == nextProps.minNum &&
|
||||
prevProps.maxNum == nextProps.maxNum &&
|
||||
prevProps.step == nextProps.step &&
|
||||
prevProps.digits == nextProps.digits
|
||||
prevProps.defaultNum == nextProps.defaultNum
|
||||
&& prevProps.unit == nextProps.unit
|
||||
&& prevProps.minNum == nextProps.minNum
|
||||
&& prevProps.maxNum == nextProps.maxNum
|
||||
&& prevProps.step == nextProps.step
|
||||
&& prevProps.digits == nextProps.digits
|
||||
)
|
||||
}
|
||||
const Counter = memo((props: params) => {
|
||||
let { minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false } = props
|
||||
const { minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false } = props
|
||||
const [value, setValue] = useState<any>({ count: defaultNum })
|
||||
// useEffect(() => {
|
||||
// setValue({ count: defaultNum })
|
||||
// }, [defaultNum])
|
||||
console.log('1231231231231212')
|
||||
const onPlus = () => {
|
||||
if (disable) return false
|
||||
let { count } = value
|
||||
if (disable) { return false }
|
||||
const { count } = value
|
||||
let num_res = Big(count).add(step).toNumber()
|
||||
num_res = num_res >= maxNum ? maxNum : num_res
|
||||
num_res = formatDigits(num_res)
|
||||
@@ -46,8 +47,8 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
const minus = () => {
|
||||
if (disable) return false
|
||||
let { count } = value
|
||||
if (disable) { return false }
|
||||
const { count } = value
|
||||
let num_res = Big(count).minus(step).toNumber()
|
||||
num_res = num_res < minNum ? minNum : num_res
|
||||
// setValue({ ...value, count: num_res })
|
||||
@@ -55,23 +56,23 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
|
||||
//保留小数
|
||||
// 保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = num + ''
|
||||
num = `${num}`
|
||||
if (num.includes('.') && digits > 0) {
|
||||
console.log('num::', num.includes('.'))
|
||||
let res = num.split('.')
|
||||
let last_num = res[1].substr(0, digits)
|
||||
return res[0] + '.' + last_num
|
||||
const res = num.split('.')
|
||||
const last_num = res[1].substr(0, digits)
|
||||
return `${res[0]}.${last_num}`
|
||||
}
|
||||
return parseFloat(num)
|
||||
}
|
||||
|
||||
//检查数据
|
||||
// 检查数据
|
||||
const checkData = (val) => {
|
||||
let num = parseFloat(val)
|
||||
if (num > maxNum) return maxNum
|
||||
if (num < minNum) return minNum
|
||||
const num = parseFloat(val)
|
||||
if (num > maxNum) { return maxNum }
|
||||
if (num < minNum) { return minNum }
|
||||
return val
|
||||
}
|
||||
|
||||
@@ -100,13 +101,14 @@ const Counter = memo((props: params) => {
|
||||
}
|
||||
|
||||
const onBluerEven = (e) => {
|
||||
let num = parseFloat(e.detail.value)
|
||||
const num = parseFloat(e.detail.value)
|
||||
if (!isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
// setValue({ ...value, count })
|
||||
onBlue?.(count as number)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// setValue({ ...value, count: defaultNum })
|
||||
onBlue?.(minNum)
|
||||
}
|
||||
@@ -121,9 +123,9 @@ const Counter = memo((props: params) => {
|
||||
value={String(props.defaultNum)}
|
||||
onInput={onInputEven}
|
||||
onBlur={onBluerEven}
|
||||
type='digit'
|
||||
type="digit"
|
||||
disabled={disable}
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
/>
|
||||
<View className={styles.unit}>{unit}</View>
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
import { CustomWrapper, Input, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Big from 'big.js'
|
||||
import styles from './index.module.scss'
|
||||
type params = {
|
||||
minNum?: number //最小值
|
||||
maxNum?: number //最大值
|
||||
step?: number //步长
|
||||
defaultNum?: number //默认值
|
||||
digits?: number //多少位小数
|
||||
import styles from './index.module.scss'
|
||||
|
||||
interface params {
|
||||
minNum?: number // 最小值
|
||||
maxNum?: number // 最大值
|
||||
step?: number // 步长
|
||||
defaultNum?: number // 默认值
|
||||
digits?: number // 多少位小数
|
||||
onChange?: (val: number) => void
|
||||
onBlue?: (val: number) => void //失去焦点触发
|
||||
onBlue?: (val: number) => void // 失去焦点触发
|
||||
onClickBtn?: (val: number) => void
|
||||
unit?: string
|
||||
disabled?: true | false //是否禁用
|
||||
returnZero?: true | false //少于最小值时是否归0
|
||||
disabled?: true | false // 是否禁用
|
||||
returnZero?: true | false // 少于最小值时是否归0
|
||||
}
|
||||
export default memo((props: params) => {
|
||||
return <Counter {...props}></Counter>
|
||||
})
|
||||
|
||||
const Counter = memo((props: params) => {
|
||||
let {
|
||||
const {
|
||||
minNum = 0,
|
||||
maxNum = 10000,
|
||||
step = 1,
|
||||
@@ -38,8 +39,8 @@ const Counter = memo((props: params) => {
|
||||
setValue({ count: defaultNum })
|
||||
}, [defaultNum])
|
||||
const onPlus = () => {
|
||||
if (disabled) return false
|
||||
let count = value.count
|
||||
if (disabled) { return false }
|
||||
const count = value.count
|
||||
let num_res = Big(count).add(step).toNumber()
|
||||
num_res = num_res >= maxNum ? maxNum : num_res
|
||||
num_res = formatDigits(num_res)
|
||||
@@ -48,12 +49,13 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
const minus = () => {
|
||||
if (disabled) return false
|
||||
let count = value.count
|
||||
if (disabled) { return false }
|
||||
const count = value.count
|
||||
let num_res = Big(count).minus(step).toNumber()
|
||||
if (returnZero) {
|
||||
num_res = num_res < minNum ? 0 : num_res
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
num_res = num_res < minNum ? minNum : num_res
|
||||
}
|
||||
setValue({ ...value, count: num_res })
|
||||
@@ -61,15 +63,16 @@ const Counter = memo((props: params) => {
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
|
||||
//保留小数
|
||||
// 保留小数
|
||||
const formatDigits = (num) => {
|
||||
num = num + ''
|
||||
num = `${num}`
|
||||
if (num.includes('.')) {
|
||||
let res = num.split('.')
|
||||
const res = num.split('.')
|
||||
if (digits > 0) {
|
||||
let last_num = res[1].substr(0, digits)
|
||||
return res[0] + '.' + last_num
|
||||
} else {
|
||||
const last_num = res[1].substr(0, digits)
|
||||
return `${res[0]}.${last_num}`
|
||||
}
|
||||
else {
|
||||
return res[0]
|
||||
}
|
||||
}
|
||||
@@ -77,56 +80,61 @@ const Counter = memo((props: params) => {
|
||||
return parseFloat(num)
|
||||
}
|
||||
|
||||
//检查数据
|
||||
// 检查数据
|
||||
const checkData = (val) => {
|
||||
let num = parseFloat(val)
|
||||
if (num > maxNum) return maxNum
|
||||
if (num < minNum) return minNum
|
||||
const num = parseFloat(val)
|
||||
if (num > maxNum) { return maxNum }
|
||||
if (num < minNum) { return minNum }
|
||||
return val
|
||||
}
|
||||
|
||||
const onInputEven = (e) => {
|
||||
let res = e.detail.value
|
||||
const res = e.detail.value
|
||||
if (res === '') {
|
||||
onChange?.(minNum)
|
||||
} else if (!isNaN(Number(res))) {
|
||||
}
|
||||
else if (!isNaN(Number(res))) {
|
||||
let count = formatDigits(res)
|
||||
count = checkData(count)
|
||||
onChange?.(parseFloat(count as string))
|
||||
} else {
|
||||
let num = parseFloat(res)
|
||||
}
|
||||
else {
|
||||
const num = parseFloat(res)
|
||||
if (!isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
onChange?.(count as number)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
onChange?.(defaultNum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onBluerEven = (e) => {
|
||||
let num = parseFloat(e.detail.value)
|
||||
const num = parseFloat(e.detail.value)
|
||||
if (e.detail.value == '') {
|
||||
onBlue?.(minNum)
|
||||
setValue({ count: minNum })
|
||||
} else if (!isNaN(num)) {
|
||||
}
|
||||
else if (!isNaN(num)) {
|
||||
let count = formatDigits(num)
|
||||
count = checkData(count)
|
||||
setValue({ count })
|
||||
onBlue?.(count as number)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setValue({ count: minNum })
|
||||
onBlue?.(minNum)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<View className={styles.main} onClick={(e) => e.stopPropagation()}>
|
||||
<View className={styles.main} onClick={e => e.stopPropagation()}>
|
||||
<View className={styles.reduce} onClick={() => minus()}>
|
||||
-
|
||||
</View>
|
||||
<View className={styles.input}>
|
||||
<Input type='digit' value={value.count} onInput={onInputEven} onBlur={onBluerEven} disabled={disabled} alwaysEmbed={true} cursorSpacing={150} />
|
||||
<Input type="digit" value={value.count} onInput={onInputEven} onBlur={onBluerEven} disabled={disabled} alwaysEmbed cursorSpacing={150} />
|
||||
<View className={styles.unit}>{unit}</View>
|
||||
</View>
|
||||
<View className={styles.plus} onClick={() => onPlus()}>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
export default memo(() => {
|
||||
return (
|
||||
<>
|
||||
<View className={styles.load_box}>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
return (
|
||||
<>
|
||||
<View className={styles.load_box}>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
<View className={styles.load_box_item}></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,64 +1,65 @@
|
||||
import { Text, View } from "@tarojs/components"
|
||||
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useState } from "react"
|
||||
import {formatKbPrice} from '@/common/common'
|
||||
import classnames from "classnames";
|
||||
import styles from './index.module.scss'
|
||||
import Taro from "@tarojs/taro";
|
||||
import AmountShow from "../amountShow";
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import AmountShow from '../amountShow'
|
||||
import styles from './index.module.scss'
|
||||
import { formatKbPrice } from '@/common/common'
|
||||
|
||||
type Param = {
|
||||
style?: Object,
|
||||
number?: number|string,
|
||||
title?: string,
|
||||
titleStatus?: true|false, //true 标题加大加深
|
||||
numberStatus?: 0|1|2, //数字尺寸
|
||||
messageTitle?: string,
|
||||
messageWidth?: number,
|
||||
messageShow?: true|false,
|
||||
numberFormat?: 'number'|'text' //数字还是字符串
|
||||
interface Param {
|
||||
style?: Object
|
||||
number?: number|string
|
||||
title?: string
|
||||
titleStatus?: true|false // true 标题加大加深
|
||||
numberStatus?: 0|1|2 // 数字尺寸
|
||||
messageTitle?: string
|
||||
messageWidth?: number
|
||||
messageShow?: true|false
|
||||
numberFormat?: 'number'|'text' // 数字还是字符串
|
||||
}
|
||||
export default memo(({number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number'}:Param) => {
|
||||
const [show, setShow] = useState(messageShow)
|
||||
const onClose = () => {
|
||||
setShow(false)
|
||||
}
|
||||
const openShow = () => [
|
||||
setShow(true)
|
||||
]
|
||||
export default memo(({ number = 0, titleStatus = true, title = '', messageTitle = '', numberStatus = 1, messageWidth = 430, messageShow = false, numberFormat = 'number' }: Param) => {
|
||||
const [show, setShow] = useState(messageShow)
|
||||
const onClose = () => {
|
||||
setShow(false)
|
||||
}
|
||||
const openShow = () => [
|
||||
setShow(true),
|
||||
]
|
||||
|
||||
const [style, setStyle] = useState<{top: string}>()
|
||||
const [style, setStyle] = useState<{ top: string }>()
|
||||
|
||||
useEffect(() => {
|
||||
if(show) {
|
||||
getDomDes('#message')
|
||||
} else {
|
||||
setStyle(() => ({top: '0'}))
|
||||
}
|
||||
}, [show])
|
||||
//设置弹出层高度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
let query = Taro.createSelectorQuery();
|
||||
query.select(id).boundingClientRect(rect=>{
|
||||
let height = rect.height * 2 + 15;
|
||||
setStyle((e) => ({...e, top: `-${height}rpx`, opacity: 1}))
|
||||
}).exec();
|
||||
}, 0)
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
getDomDes('#message')
|
||||
}
|
||||
else {
|
||||
setStyle(() => ({ top: '0' }))
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.order_price}>
|
||||
<View className={classnames(styles.order_price_text, titleStatus&&styles.emphasis)} onClick={() => openShow()}>
|
||||
<Text>{title}</Text>
|
||||
<View className={styles.iconfont_msg}>
|
||||
{show&&<View style={{...style, width: `${messageWidth}rpx`}} id='message' className={classnames(styles.message)}>{messageTitle}</View>}
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
||||
</View>
|
||||
</View>
|
||||
{numberFormat == 'number' && <AmountShow status={numberStatus} number={(number as number / 100)}/>}
|
||||
{(numberFormat == 'text') && <View className={styles.refund_destination}>{number}</View>}
|
||||
{show&&<View className={styles.close} catchMove onClick={onClose}></View>}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}, [show])
|
||||
// 设置弹出层高度
|
||||
const getDomDes = (id) => {
|
||||
setTimeout(() => {
|
||||
const query = Taro.createSelectorQuery()
|
||||
query.select(id).boundingClientRect((rect) => {
|
||||
const height = rect.height * 2 + 15
|
||||
setStyle(e => ({ ...e, top: `-${height}rpx`, opacity: 1 }))
|
||||
}).exec()
|
||||
}, 0)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.order_price}>
|
||||
<View className={classnames(styles.order_price_text, titleStatus && styles.emphasis)} onClick={() => openShow()}>
|
||||
<Text>{title}</Text>
|
||||
<View className={styles.iconfont_msg}>
|
||||
{show && <View style={{ ...style, width: `${messageWidth}rpx` }} id="message" className={classnames(styles.message)}>{messageTitle}</View>}
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhushi')}></Text>
|
||||
</View>
|
||||
</View>
|
||||
{numberFormat == 'number' && <AmountShow status={numberStatus} number={(number as number / 100)} />}
|
||||
{(numberFormat == 'text') && <View className={styles.refund_destination}>{number}</View>}
|
||||
{show && <View className={styles.close} catchMove onClick={onClose}></View>}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import { GetProductKindListApi } from '@/api/material'
|
||||
import Popup, { Params as PopuParams } from '@/components/popup'
|
||||
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||
import { useDidShow } from '@tarojs/taro'
|
||||
import classnames from 'classnames'
|
||||
import { memo, useEffect, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import type { Params as PopuParams } from '@/components/popup'
|
||||
import { GetProductKindListApi } from '@/api/material'
|
||||
|
||||
type params = {
|
||||
onFiltr?: (val: object) => void //确定搜索
|
||||
onRest?: (val: Object) => void //重置
|
||||
onFiltr?: (val: object) => void // 确定搜索
|
||||
onRest?: (val: Object) => void // 重置
|
||||
} & PopuParams
|
||||
export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
//搜索条件
|
||||
// 搜索条件
|
||||
const [filterObj, setFilterObj] = useState({
|
||||
seriesName: '',
|
||||
seriesId: '',
|
||||
@@ -22,11 +23,11 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
|
||||
const selectFieldValue = useRef({ width: '幅宽', weight: '克重', element: '成分', seriesName: '系列' })
|
||||
|
||||
//获取系列
|
||||
// 获取系列
|
||||
const { fetchData: kindFetchData } = GetProductKindListApi()
|
||||
const [kindList, setKindList] = useState<any[]>([])
|
||||
const getCategoryList = async () => {
|
||||
let { data } = await kindFetchData()
|
||||
const getCategoryList = async() => {
|
||||
const { data } = await kindFetchData()
|
||||
setKindList(data.list)
|
||||
}
|
||||
|
||||
@@ -34,7 +35,7 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
show && getCategoryList()
|
||||
}, [show])
|
||||
|
||||
//切换系列
|
||||
// 切换系列
|
||||
const changeKind = (e) => {
|
||||
setFilterObj({ ...filterObj, seriesId: e.id, seriesName: e.name })
|
||||
}
|
||||
@@ -43,9 +44,9 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
onClose?.()
|
||||
}
|
||||
|
||||
//重置数据
|
||||
// 重置数据
|
||||
const onRestEven = () => {
|
||||
let res = {
|
||||
const res = {
|
||||
seriesName: '',
|
||||
seriesId: '',
|
||||
width: '',
|
||||
@@ -57,20 +58,20 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
onClose?.()
|
||||
}
|
||||
|
||||
//提交搜索
|
||||
// 提交搜索
|
||||
const onVerify = () => {
|
||||
onFiltr?.({ data: filterObj, field: selectFieldValue.current })
|
||||
onClose?.()
|
||||
}
|
||||
|
||||
//获取幅宽或克重输入值或成分
|
||||
// 获取幅宽或克重输入值或成分
|
||||
const setFieldData = (e, field) => {
|
||||
filterObj[field] = e.detail.value
|
||||
setFilterObj({ ...filterObj })
|
||||
}
|
||||
|
||||
return (
|
||||
<Popup position='right' show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
||||
<Popup position="right" show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton>
|
||||
<View className={styles.popup_main}>
|
||||
<View className={styles.popup_title}>全部筛选</View>
|
||||
<ScrollView scrollY className={styles.scroll}>
|
||||
@@ -78,11 +79,12 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
<View className={styles.popup_filter_item}>
|
||||
<View className={styles.title}>系列</View>
|
||||
<View className={styles.btn_list}>
|
||||
{kindList.map((item) => (
|
||||
{kindList.map(item => (
|
||||
<View
|
||||
key={item.id}
|
||||
onClick={() => changeKind(item)}
|
||||
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}>
|
||||
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}
|
||||
>
|
||||
{item.name}
|
||||
</View>
|
||||
))}
|
||||
@@ -93,12 +95,12 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
<View className={styles.btn_list_input}>
|
||||
<View className={styles.btn_width}>
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
value={filterObj.width}
|
||||
onBlur={(e) => setFieldData(e, 'width')}
|
||||
placeholder='请输入幅宽'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
onBlur={e => setFieldData(e, 'width')}
|
||||
placeholder="请输入幅宽"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
/>
|
||||
</View>
|
||||
<View className={styles.unit}>cm</View>
|
||||
@@ -110,11 +112,11 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
<View className={styles.btn_width}>
|
||||
<Input
|
||||
value={filterObj.weight}
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
onBlur={(e) => setFieldData(e, 'weight')}
|
||||
placeholder='请输入克重'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
onBlur={e => setFieldData(e, 'weight')}
|
||||
placeholder="请输入克重"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
/>
|
||||
</View>
|
||||
<View className={styles.unit}>kg</View>
|
||||
@@ -123,11 +125,11 @@ export default memo(({ onClose, onFiltr, show = false, onRest }: params) => {
|
||||
<View className={styles.popup_filter_item}>
|
||||
<View className={styles.title}>成分</View>
|
||||
<View className={styles.btn_list_element}>
|
||||
<Textarea placeholder='请输入' cursorSpacing={60} value={filterObj.element} onInput={(e) => setFieldData(e, 'element')} />
|
||||
<Textarea placeholder="请输入" cursorSpacing={60} value={filterObj.element} onInput={e => setFieldData(e, 'element')} />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='common_safe_area_y'></View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View className={styles.btns_con}>
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { GetProductKindListApi } from '@/api/material'
|
||||
import Popup, { Params as PopuParams } from '@/components/popup'
|
||||
import { Input, ScrollView, Text, Textarea, View } from '@tarojs/components'
|
||||
import { useDidShow } from '@tarojs/taro'
|
||||
import classnames from 'classnames'
|
||||
import { useEffect, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import type { Params as PopuParams } from '@/components/popup'
|
||||
import { GetProductKindListApi } from '@/api/material'
|
||||
|
||||
type params = {
|
||||
onFiltr?: (val: object) => void
|
||||
} & PopuParams
|
||||
export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
//搜索条件
|
||||
// 搜索条件
|
||||
const [filterObj, setFilterObj] = useState({
|
||||
seriesId: '',
|
||||
minWidth: '',
|
||||
@@ -20,11 +21,11 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
element: '',
|
||||
})
|
||||
|
||||
//获取系列
|
||||
// 获取系列
|
||||
const { fetchData: kindFetchData } = GetProductKindListApi()
|
||||
const [kindList, setKindList] = useState<any[]>([])
|
||||
const getCategoryList = async () => {
|
||||
let { data } = await kindFetchData()
|
||||
const getCategoryList = async() => {
|
||||
const { data } = await kindFetchData()
|
||||
setKindList(data.list)
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
show && getCategoryList()
|
||||
}, [show])
|
||||
|
||||
//切换系列
|
||||
// 切换系列
|
||||
const changeKind = (e) => {
|
||||
setFilterObj({ ...filterObj, seriesId: e.id })
|
||||
}
|
||||
@@ -62,21 +63,22 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
|
||||
const setNumber = (e, field) => {
|
||||
console.log(e)
|
||||
let num = parseFloat(e.detail.value)
|
||||
const num = parseFloat(e.detail.value)
|
||||
if (isNaN(num)) {
|
||||
filterObj[field] = null
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
filterObj[field] = parseFloat(num.toFixed(2))
|
||||
}
|
||||
setFilterObj({ ...filterObj })
|
||||
}
|
||||
|
||||
const setElement = (e) => {
|
||||
let res = e.detail.value
|
||||
const res = e.detail.value
|
||||
setFilterObj({ ...filterObj, element: res })
|
||||
}
|
||||
return (
|
||||
<Popup position='right' show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton={true}>
|
||||
<Popup position="right" show={show} showTitle={false} onClose={() => onCloseEven()} showIconButton>
|
||||
<View className={styles.popup_main}>
|
||||
<View className={styles.popup_title}>全部筛选</View>
|
||||
<ScrollView scrollY className={styles.scroll}>
|
||||
@@ -84,11 +86,12 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
<View className={styles.popup_filter_item}>
|
||||
<View className={styles.title}>系列</View>
|
||||
<View className={styles.btn_list}>
|
||||
{kindList.map((item) => (
|
||||
{kindList.map(item => (
|
||||
<View
|
||||
key={item.id}
|
||||
onClick={() => changeKind(item)}
|
||||
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}>
|
||||
className={classnames(styles.btn_item, filterObj.seriesId == item.id && styles.select_btn_item)}
|
||||
>
|
||||
{item.name}
|
||||
</View>
|
||||
))}
|
||||
@@ -99,13 +102,13 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
<View className={styles.btn_list_input}>
|
||||
<View className={styles.btn_width}>
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
value={filterObj.minWidth}
|
||||
type='digit'
|
||||
onBlur={(e) => setNumber(e, 'minWidth')}
|
||||
placeholder='请输入幅宽'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
type="digit"
|
||||
onBlur={e => setNumber(e, 'minWidth')}
|
||||
placeholder="请输入幅宽"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
/>
|
||||
</View>
|
||||
<View className={styles.unit}>cm</View>
|
||||
@@ -116,24 +119,24 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
<View className={styles.btn_list_input}>
|
||||
<View className={styles.btn_width}>
|
||||
<Input
|
||||
type='digit'
|
||||
type="digit"
|
||||
value={filterObj.minWeight}
|
||||
onBlur={(e) => setNumber(e, 'minWeight')}
|
||||
placeholder='自定义最低值'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
alwaysEmbed={true}
|
||||
onBlur={e => setNumber(e, 'minWeight')}
|
||||
placeholder="自定义最低值"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
/>
|
||||
</View>
|
||||
<Text>—</Text>
|
||||
<View className={styles.btn_width}>
|
||||
<Input
|
||||
type='digit'
|
||||
type="digit"
|
||||
value={filterObj.maxWeight}
|
||||
onBlur={(e) => setNumber(e, 'maxWeight')}
|
||||
placeholder='自定义最高值'
|
||||
placeholderStyle='font-size: 26rpx'
|
||||
alwaysEmbed={true}
|
||||
onBlur={e => setNumber(e, 'maxWeight')}
|
||||
placeholder="自定义最高值"
|
||||
placeholderStyle="font-size: 26rpx"
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
/>
|
||||
</View>
|
||||
@@ -143,11 +146,11 @@ export default ({ onClose, onFiltr, show = false }: params) => {
|
||||
<View className={styles.popup_filter_item}>
|
||||
<View className={styles.title}>成分</View>
|
||||
<View className={styles.btn_list_element}>
|
||||
<Textarea placeholder='请输入' cursorSpacing={60} value={filterObj.element} onInput={(e) => setElement(e)} />
|
||||
<Textarea placeholder="请输入" cursorSpacing={60} value={filterObj.element} onInput={e => setElement(e)} />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='common_safe_area_y'></View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View className={styles.btns_con}>
|
||||
|
||||
@@ -1,117 +1,118 @@
|
||||
import { ScrollView, View } from "@tarojs/components"
|
||||
import { memo, ReactNode, useMemo, useState } from "react"
|
||||
import style from "./index.module.scss"
|
||||
import DotLoading from "@/components/dotLoading"
|
||||
import LoadingCard from "../loadingCard"
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useMemo, useState } from 'react'
|
||||
import LoadingCard from '../loadingCard'
|
||||
import style from './index.module.scss'
|
||||
import DotLoading from '@/components/dotLoading'
|
||||
|
||||
export type StatusParam = 0|1|2|3
|
||||
|
||||
type Params = {
|
||||
styleObj?: Object,
|
||||
selfonScrollToLower?: () => void,
|
||||
hasMore?: false|true,
|
||||
moreStatus?: false|true,
|
||||
statusMore?: StatusParam //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
children?: ReactNode,
|
||||
lowerThresholdNum?: number,
|
||||
selfOnScrollToUpper?:() => void
|
||||
selfOnScroll?:(val:any) => void
|
||||
selfOnRefresherPulling?: () => void
|
||||
selfOnRefresherRefresh?: () => void
|
||||
selfOnRefresherRestore?: () => void
|
||||
selfOnRefresherAbort?: () => void
|
||||
paddingBottom?: number,
|
||||
refresherTriggered?: true|false,
|
||||
refresherEnabled?: true|false,
|
||||
interface Params {
|
||||
styleObj?: Object
|
||||
selfonScrollToLower?: () => void
|
||||
hasMore?: false|true
|
||||
moreStatus?: false|true
|
||||
statusMore?: StatusParam // 0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
children?: ReactNode
|
||||
lowerThresholdNum?: number
|
||||
selfOnScrollToUpper?: () => void
|
||||
selfOnScroll?: (val: any) => void
|
||||
selfOnRefresherPulling?: () => void
|
||||
selfOnRefresherRefresh?: () => void
|
||||
selfOnRefresherRestore?: () => void
|
||||
selfOnRefresherAbort?: () => void
|
||||
paddingBottom?: number
|
||||
refresherTriggered?: true|false
|
||||
refresherEnabled?: true|false
|
||||
}
|
||||
export default memo(({
|
||||
styleObj,
|
||||
selfonScrollToLower,
|
||||
selfOnScrollToUpper,
|
||||
selfOnScroll,
|
||||
selfOnRefresherPulling,
|
||||
selfOnRefresherRefresh,
|
||||
selfOnRefresherRestore,
|
||||
selfOnRefresherAbort,
|
||||
hasMore=true,
|
||||
children,
|
||||
lowerThresholdNum = 5,
|
||||
paddingBottom = 0,
|
||||
refresherTriggered = false,
|
||||
refresherEnabled = false,
|
||||
moreStatus = true,
|
||||
statusMore = 0
|
||||
styleObj,
|
||||
selfonScrollToLower,
|
||||
selfOnScrollToUpper,
|
||||
selfOnScroll,
|
||||
selfOnRefresherPulling,
|
||||
selfOnRefresherRefresh,
|
||||
selfOnRefresherRestore,
|
||||
selfOnRefresherAbort,
|
||||
hasMore = true,
|
||||
children,
|
||||
lowerThresholdNum = 5,
|
||||
paddingBottom = 0,
|
||||
refresherTriggered = false,
|
||||
refresherEnabled = false,
|
||||
moreStatus = true,
|
||||
statusMore = 0,
|
||||
}: Params) => {
|
||||
const scrollToLower = () => {
|
||||
selfonScrollToLower?.()
|
||||
}
|
||||
const scrollToUpper = () => {
|
||||
selfOnScrollToUpper?.()
|
||||
}
|
||||
const scroll = (e) => {
|
||||
selfOnScroll?.(e)
|
||||
}
|
||||
const refresherPulling = () => {
|
||||
selfOnRefresherPulling?.()
|
||||
}
|
||||
const refresherRefresh = () => {
|
||||
selfOnRefresherRefresh?.()
|
||||
}
|
||||
const refresherRestore = () => {
|
||||
selfOnRefresherRestore?.()
|
||||
}
|
||||
const refresherAbort = () => {
|
||||
selfOnRefresherAbort?.()
|
||||
}
|
||||
const scrollToLower = () => {
|
||||
selfonScrollToLower?.()
|
||||
}
|
||||
const scrollToUpper = () => {
|
||||
selfOnScrollToUpper?.()
|
||||
}
|
||||
const scroll = (e) => {
|
||||
selfOnScroll?.(e)
|
||||
}
|
||||
const refresherPulling = () => {
|
||||
selfOnRefresherPulling?.()
|
||||
}
|
||||
const refresherRefresh = () => {
|
||||
selfOnRefresherRefresh?.()
|
||||
}
|
||||
const refresherRestore = () => {
|
||||
selfOnRefresherRestore?.()
|
||||
}
|
||||
const refresherAbort = () => {
|
||||
selfOnRefresherAbort?.()
|
||||
}
|
||||
|
||||
//返回顶部
|
||||
const scrollTop = useMemo(() => {
|
||||
if(statusMore == 0) {
|
||||
return 0.1
|
||||
}
|
||||
},[statusMore])
|
||||
// 返回顶部
|
||||
const scrollTop = useMemo(() => {
|
||||
if (statusMore == 0) {
|
||||
return 0.1
|
||||
}
|
||||
}, [statusMore])
|
||||
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
style={styleObj}
|
||||
className={style.scroll_main}
|
||||
scrollY
|
||||
onScrollToLower={() => scrollToLower()}
|
||||
onScrollToUpper={() => scrollToUpper()}
|
||||
onScroll={(e) => scroll(e)}
|
||||
lowerThreshold={lowerThresholdNum}
|
||||
refresherEnabled = {refresherEnabled}
|
||||
refresherTriggered = {refresherTriggered}
|
||||
onRefresherPulling = {() => refresherPulling()}
|
||||
onRefresherRefresh = {() => refresherRefresh()}
|
||||
onRefresherRestore = {() => refresherRestore()}
|
||||
onRefresherAbort = {() => refresherAbort()}
|
||||
refresherBackground ='#F8F8F8'
|
||||
scrollTop={scrollTop}
|
||||
>
|
||||
{!moreStatus&&<>
|
||||
<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
</>||
|
||||
<>
|
||||
{(statusMore == 2 || statusMore == 3)&&<View style={{paddingBottom:paddingBottom + 'rpx'}} className={style.scrollViewCon}>
|
||||
{children}
|
||||
<View className={style.infinite_scroll}>
|
||||
{
|
||||
(statusMore == 2)&&<View className={style.loading_more}>加载中<DotLoading/></View>||
|
||||
<View className={style.noMore}>没有更多数据了</View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
{(statusMore == 0)&&<LoadingCard/>}
|
||||
{(statusMore == 1)&&<LoadingCard loadingIcon={false} title="暂无数据"/>}
|
||||
</>}
|
||||
|
||||
<View className="common_safe_area_y"></View>
|
||||
</ScrollView>
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
style={styleObj}
|
||||
className={style.scroll_main}
|
||||
scrollY
|
||||
onScrollToLower={() => scrollToLower()}
|
||||
onScrollToUpper={() => scrollToUpper()}
|
||||
onScroll={e => scroll(e)}
|
||||
lowerThreshold={lowerThresholdNum}
|
||||
refresherEnabled={refresherEnabled}
|
||||
refresherTriggered={refresherTriggered}
|
||||
onRefresherPulling={() => refresherPulling()}
|
||||
onRefresherRefresh={() => refresherRefresh()}
|
||||
onRefresherRestore={() => refresherRestore()}
|
||||
onRefresherAbort={() => refresherAbort()}
|
||||
refresherBackground="#F8F8F8"
|
||||
scrollTop={scrollTop}
|
||||
>
|
||||
{!moreStatus && <>
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|| <>
|
||||
{(statusMore == 2 || statusMore == 3) && <View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
<View className={style.infinite_scroll}>
|
||||
{
|
||||
(statusMore == 2) && <View className={style.loading_more}>加载中<DotLoading /></View>
|
||||
|| <View className={style.noMore}>没有更多数据了</View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
{(statusMore == 0) && <LoadingCard />}
|
||||
{(statusMore == 1) && <LoadingCard loadingIcon={false} title="暂无数据" />}
|
||||
</>}
|
||||
|
||||
<View className="common_safe_area_y"></View>
|
||||
</ScrollView>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import { memo, useMemo } from "react"
|
||||
import style from './index.module.scss'
|
||||
export default memo(({width=60, color='#6190e8'}:{width?:number, color?:string}) => {
|
||||
const styleObj = useMemo(() => {
|
||||
let obj = {}
|
||||
if(width > 0)
|
||||
obj = {width: width + 'rpx', height:width + 'rpx'}
|
||||
if(color)
|
||||
obj = {...obj, borderColor: color+' transparent transparent'}
|
||||
return obj
|
||||
|
||||
}, [width, color])
|
||||
console.log('loading:::')
|
||||
return (
|
||||
<View className={style.loading}
|
||||
style={styleObj}
|
||||
>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
</View>
|
||||
)
|
||||
|
||||
})
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo, useMemo } from 'react'
|
||||
import style from './index.module.scss'
|
||||
|
||||
export default memo(({ width = 60, color = '#6190e8' }: { width?: number; color?: string }) => {
|
||||
const styleObj = useMemo(() => {
|
||||
let obj = {}
|
||||
if (width > 0) { obj = { width: `${width}rpx`, height: `${width}rpx` } }
|
||||
if (color) { obj = { ...obj, borderColor: `${color} transparent transparent` } }
|
||||
return obj
|
||||
}, [width, color])
|
||||
console.log('loading:::')
|
||||
return (
|
||||
<View className={style.loading}
|
||||
style={styleObj}
|
||||
>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
<View style={styleObj} className={style.loading__ring}></View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import Loading from "@/components/loading"
|
||||
import style from "./index.module.scss"
|
||||
import { memo } from "react";
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import style from './index.module.scss'
|
||||
import Loading from '@/components/loading'
|
||||
|
||||
type Params = {
|
||||
styleLoading?: Object,
|
||||
title?: string,
|
||||
loadingIcon?: false|true
|
||||
interface Params {
|
||||
styleLoading?: Object
|
||||
title?: string
|
||||
loadingIcon?: false|true
|
||||
}
|
||||
export default memo(({
|
||||
styleLoading = {},
|
||||
title = "加载中...", //显示的文字
|
||||
loadingIcon = true //是否显示加载图标
|
||||
}:Params) => {
|
||||
console.log('loadingCard:::')
|
||||
return (
|
||||
<>
|
||||
<View className={style.loadingCard_main}>
|
||||
{loadingIcon&&<Loading/>}
|
||||
<View className={style.loading_text}>{title}</View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
styleLoading = {},
|
||||
title = '加载中...', // 显示的文字
|
||||
loadingIcon = true, // 是否显示加载图标
|
||||
}: Params) => {
|
||||
console.log('loadingCard:::')
|
||||
return (
|
||||
<>
|
||||
<View className={style.loadingCard_main}>
|
||||
{loadingIcon && <Loading />}
|
||||
<View className={style.loading_text}>{title}</View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { MovableArea, MovableView, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, useReady, useRouter } from '@tarojs/taro'
|
||||
import { ReactElement, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import type { ReactElement } from 'react'
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import { GetShoppingCartApi } from '@/api/shopCart'
|
||||
import useCommonData from '@/use/useCommonData'
|
||||
import { useSelector } from '@/reducers/hooks'
|
||||
|
||||
type param = {
|
||||
interface param {
|
||||
children?: ReactElement | null
|
||||
onClick?: () => void
|
||||
}
|
||||
export default ({ children = null, onClick }: param) => {
|
||||
//获取购物车数据数量
|
||||
// 获取购物车数据数量
|
||||
const { getShopCount, commonData } = useCommonData()
|
||||
|
||||
const [screenHeight, setScreenHeight] = useState(0)
|
||||
@@ -21,7 +22,7 @@ export default ({ children = null, onClick }: param) => {
|
||||
useLayoutEffect(() => {
|
||||
const res = Taro.getSystemInfoSync()
|
||||
if (res.screenHeight) {
|
||||
let ratio = 750 / res.screenWidth
|
||||
const ratio = 750 / res.screenWidth
|
||||
setScreenHeight(res.screenHeight * ratio - 460)
|
||||
screenWidthRef.current = res.screenWidth / 2
|
||||
}
|
||||
@@ -40,11 +41,12 @@ export default ({ children = null, onClick }: param) => {
|
||||
<MovableView
|
||||
onClick={onClick}
|
||||
className={styles.moveBtn}
|
||||
direction='all'
|
||||
inertia={true}
|
||||
x='630rpx'
|
||||
y={screenHeight + 'rpx'}
|
||||
onTouchEnd={(e) => dragEnd(e)}>
|
||||
direction="all"
|
||||
inertia
|
||||
x="630rpx"
|
||||
y={`${screenHeight}rpx`}
|
||||
onTouchEnd={e => dragEnd(e)}
|
||||
>
|
||||
<View className={classnames('iconfont', 'icon-gouwuche', styles.shop_icon)}></View>
|
||||
{commonData.shopCount > 0 && <View className={styles.product_num}>{commonData.shopCount > 99 ? '99+' : commonData.shopCount}</View>}
|
||||
</MovableView>
|
||||
|
||||
@@ -1,202 +1,205 @@
|
||||
import { CancelOrderApi, ReceiveOrderApi } from "@/api/order"
|
||||
import { alert } from "@/common/common"
|
||||
import { ORDER_STATUS, SALE_MODE } from "@/common/enum"
|
||||
import { ScrollView, Text, View } from "@tarojs/components"
|
||||
import Taro from "@tarojs/taro"
|
||||
import { useCallback, useRef, memo, useState, useEffect, useMemo } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import { ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { ORDER_STATUS, SALE_MODE } from '@/common/enum'
|
||||
import { alert } from '@/common/common'
|
||||
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
||||
|
||||
type Param = {
|
||||
orderInfo: {
|
||||
status: number, //订单状态
|
||||
orderId: number, //订单id
|
||||
actual_amount: number, //实付金额
|
||||
wait_pay_amount: number, //待付金额
|
||||
sale_mode: number //订单类型
|
||||
}|null,
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
interface Param {
|
||||
orderInfo: {
|
||||
status: number // 订单状态
|
||||
orderId: number // 订单id
|
||||
actual_amount: number // 实付金额
|
||||
wait_pay_amount: number // 待付金额
|
||||
sale_mode: number // 订单类型
|
||||
}|null
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
export default memo(({orderInfo, onClick}:Param) => {
|
||||
//订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment
|
||||
} = ORDER_STATUS
|
||||
export default memo(({ orderInfo, onClick }: Param) => {
|
||||
// 订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
SaleOrderStatusArranged,
|
||||
SaleOrderStatusWaitingDelivery,
|
||||
SaleOrderStatusComplete,
|
||||
SaleOrderStatusRefund,
|
||||
SaleOrderStatusWaitingPayment,
|
||||
SaleOrderStatusWaitingReceipt,
|
||||
SaleOrderStatusAlreadyReceipt,
|
||||
SaleorderstatusWaitingPrePayment,
|
||||
} = ORDER_STATUS
|
||||
|
||||
//订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//订单按钮按订单状态归类, value是该订单状态,可能该按钮会出现
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value], //取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], //去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [SaleOrderStatusWaitingDelivery.value], //申请退款按钮对应: 待发货
|
||||
label: '申请退款'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], //取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], //申请退货按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货'
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [SaleOrderStatusWaitingReceipt.value], //确认收货按钮对应: 待收货
|
||||
label: '确认收货'
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [SaleOrderStatusWaitingReceipt.value,SaleOrderStatusAlreadyReceipt.value,SaleOrderStatusComplete.value,SaleOrderStatusRefund.value], //再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
value: [SaleOrderStatusBooking.value], //按钮对应: 待接单
|
||||
label: '退款'
|
||||
},
|
||||
])
|
||||
|
||||
// 订单类型
|
||||
const {
|
||||
SaLeModeBulk,
|
||||
SaleModeLengthCut,
|
||||
SaLeModeWeightCut,
|
||||
} = SALE_MODE
|
||||
|
||||
//判断是否显示该按钮
|
||||
const orderBtnsShow = (item) => {
|
||||
if(orderInfo) {
|
||||
if(item.id == 1) {
|
||||
//取消订单按钮
|
||||
return( orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) //在待发货之前没有付过款
|
||||
} else if (item.id == 2) {
|
||||
//去付款按钮
|
||||
return( orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) //只要没有付完款就显示
|
||||
} else if(item.id == 3 ) {
|
||||
//申请退款, 只有大货才有
|
||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //大货在待发货付过款
|
||||
} else if( item.id == 8) {
|
||||
//退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) //散剪和剪板在待接单时付过款
|
||||
}
|
||||
else {
|
||||
//其他按钮
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
// 订单按钮按订单状态归类, value是该订单状态,可能该按钮会出现
|
||||
const orderBtnsList = useRef([
|
||||
{
|
||||
id: 1,
|
||||
value: [SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
SaleOrderStatusArranged.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
SaleOrderStatusWaitingDelivery.value], // 取消订单按钮对应: 待接单,配布中,已配布, 待付款, 待发货
|
||||
label: '取消订单',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: [SaleorderstatusWaitingPrePayment.value, SaleOrderStatusWaitingPayment.value, SaleOrderStatusWaitingDelivery.value, SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value], // 去付款按钮对应:待付款, 待发货, 待收货, 已收货, 已完成
|
||||
label: '去付款',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: [SaleOrderStatusWaitingDelivery.value], // 申请退款按钮对应: 待发货
|
||||
label: '申请退款',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 取消订单按钮对应: 待收货, 已收货, 已完成, 已退款
|
||||
label: '查看物流',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value], // 申请退货按钮对应: 待收货, 已收货, 已退款
|
||||
label: '申请退货',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
value: [SaleOrderStatusWaitingReceipt.value], // 确认收货按钮对应: 待收货
|
||||
label: '确认收货',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
value: [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value], // 再次购买按钮对应: 待收货,已收货,已完成, 已退款
|
||||
label: '再次购买',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
value: [SaleOrderStatusBooking.value], // 按钮对应: 待接单
|
||||
label: '退款',
|
||||
},
|
||||
])
|
||||
|
||||
// 判断是否显示该按钮
|
||||
const orderBtnsShow = (item) => {
|
||||
if (orderInfo) {
|
||||
if (item.id == 1) {
|
||||
// 取消订单按钮
|
||||
return (orderInfo.actual_amount == 0 && item.value.includes(orderInfo.status)) // 在待发货之前没有付过款
|
||||
}
|
||||
else if (item.id == 2) {
|
||||
// 去付款按钮
|
||||
return (orderInfo.wait_pay_amount != 0 && item.value.includes(orderInfo.status)) // 只要没有付完款就显示
|
||||
}
|
||||
else if (item.id == 3) {
|
||||
// 申请退款, 只有大货才有
|
||||
return (orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 大货在待发货付过款
|
||||
}
|
||||
else if (item.id == 8) {
|
||||
// 退款按钮(直接退款不用申请), 只有散剪和剪板有
|
||||
return (orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount != 0 && item.value.includes(orderInfo.status)) // 散剪和剪板在待接单时付过款
|
||||
}
|
||||
else {
|
||||
// 其他按钮
|
||||
return item.value.includes(orderInfo.status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示的按钮数组
|
||||
const orderBtnsShowList: { id: number; value: any; label: string }[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter((item) => {
|
||||
return orderBtnsShow(item)
|
||||
})
|
||||
}, [orderInfo])
|
||||
|
||||
// 点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
(val == 1) && cancelOrder(); // 取消订单按钮
|
||||
(val == 2) && onClick?.(2); // 去付款按钮
|
||||
(val == 6) && receiveOrder() // 确认收货
|
||||
}
|
||||
|
||||
// 取消订单
|
||||
const { fetchData: cancelFetchData } = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//显示的按钮数组
|
||||
const orderBtnsShowList: {id: number, value: any, label: string}[] = useMemo(() => {
|
||||
return orderBtnsList.current.filter(item => {
|
||||
return orderBtnsShow(item)
|
||||
})
|
||||
}, [orderInfo])
|
||||
// 确认订单
|
||||
const { fetchData: receiveOrderFetchData } = ReceiveOrderApi()
|
||||
const receiveOrder = async() => {
|
||||
console.log('123456')
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
}
|
||||
else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3) && <View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(true)}>更多</Text>
|
||||
{showMore && <View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) && <View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
</View>}
|
||||
</View>}
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
(val == 1)&&cancelOrder(); //取消订单按钮
|
||||
(val == 2)&&onClick?.(2); //去付款按钮
|
||||
(val == 6)&&receiveOrder(); //确认收货
|
||||
|
||||
}
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3) && <View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>,
|
||||
)}
|
||||
</View>
|
||||
|
||||
//取消订单
|
||||
const {fetchData: cancelFetchData} = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({id: orderInfo?.orderId})
|
||||
if(res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//确认订单
|
||||
const {fetchData: receiveOrderFetchData} = ReceiveOrderApi()
|
||||
const receiveOrder = async () => {
|
||||
console.log('123456')
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
let res = await receiveOrderFetchData({sale_order_id: orderInfo?.orderId})
|
||||
if(res.success){
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
} else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return {top:`-${(orderBtnsShowList.length - 3)*70 + 10}rpx`, left: `-${10}rpx`}
|
||||
}, [orderBtnsShowList])
|
||||
|
||||
return (
|
||||
<View className={styles.btns_list}>
|
||||
{(orderBtnsShowList.length > 3)&&<View className={styles.more}>
|
||||
<Text onClick={() => setShowMore(true)}>更多</Text>
|
||||
{showMore&&<View className={styles.more_con}>
|
||||
<View className={styles.more_list} style={styleTop}>
|
||||
{orderBtnsShowList.map((item, index) => {
|
||||
return ((index >= 3) &&<View className={styles.more_item} key={item.id} onClick={() => submitBtns(item.id, index)}>{item.label}</View>)
|
||||
})}
|
||||
</View>
|
||||
<View className={styles.more_bg} catchMove onClick={() => setShowMore(false)}></View>
|
||||
</View>}
|
||||
</View>}
|
||||
|
||||
<View className={styles.list_scroll}>
|
||||
{orderBtnsShowList.map((item, index) =>
|
||||
(index < 3)&&<View key={item.id} className={styles.btns_item} onClick={() => submitBtns(item.id, index)}>{item.label}</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
})
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { ORDER_STATUS, SALE_MODE, SUBSCRIPTION_MESSAGE_SCENE } from '@/common/enum'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useRef, memo, useState, useMemo } from 'react'
|
||||
import { memo, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import { ORDER_STATUS, SALE_MODE, SUBSCRIPTION_MESSAGE_SCENE } from '@/common/enum'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { CancelOrderApi, ReceiveOrderApi } from '@/api/order'
|
||||
import { AddShoppingCartApi } from '@/api/shopCart'
|
||||
import { ApplyRefundApi } from '@/api/salesAfterOrder'
|
||||
import { UseSubscriptionMessage } from '@/use/useCommon'
|
||||
import { throttle } from '@/common/util'
|
||||
|
||||
type Param = {
|
||||
interface Param {
|
||||
orderInfo: {
|
||||
status: number //订单状态
|
||||
orderId: number //订单id
|
||||
actual_amount: number //实付金额
|
||||
wait_pay_amount: number //待付金额
|
||||
sale_mode: number //订单类型
|
||||
av_return_roll?: number //可退数量
|
||||
is_return?: true | false //是否申请了售后
|
||||
is_should_collect_audit?: true | false //应收单是否审核
|
||||
status: number // 订单状态
|
||||
orderId: number // 订单id
|
||||
actual_amount: number // 实付金额
|
||||
wait_pay_amount: number // 待付金额
|
||||
sale_mode: number // 订单类型
|
||||
av_return_roll?: number // 可退数量
|
||||
is_return?: true | false // 是否申请了售后
|
||||
is_should_collect_audit?: true | false // 应收单是否审核
|
||||
}
|
||||
showStatus?: 'detail' | 'list' //订单详情,订单列表
|
||||
onClick?: (val: number) => void //点击后触发的事件,返回订单状态
|
||||
showStatus?: 'detail' | 'list' // 订单详情,订单列表
|
||||
onClick?: (val: number) => void // 点击后触发的事件,返回订单状态
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
//订单状态枚举
|
||||
// 订单状态枚举
|
||||
const {
|
||||
SaleOrderStatusBooking,
|
||||
SaleOrderStatusArranging,
|
||||
@@ -42,19 +42,19 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
SaleOrderStatusTaking,
|
||||
} = ORDER_STATUS
|
||||
|
||||
//订单类型
|
||||
// 订单类型
|
||||
const { SaLeModeBulk, SaleModeLengthCut, SaLeModeWeightCut } = SALE_MODE
|
||||
|
||||
//注册按钮, id:按钮id唯一,label:按钮名称,sort:排序数字越大越靠后,validatarFunc:验证
|
||||
type orderBtnsListParams = { id: number; label: string; sort: number; validatarFunc: (val: typeof orderInfo) => any }
|
||||
// 注册按钮, id:按钮id唯一,label:按钮名称,sort:排序数字越大越靠后,validatarFunc:验证
|
||||
interface orderBtnsListParams { id: number; label: string; sort: number; validatarFunc: (val: typeof orderInfo) => any }
|
||||
const orderBtnsList = useRef<orderBtnsListParams[]>([
|
||||
{
|
||||
id: 1,
|
||||
label: '取消订单',
|
||||
sort: 1,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//在待发货之前没有付过款
|
||||
let orderStatus = [
|
||||
// 在待发货之前没有付过款
|
||||
const orderStatus = [
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusBooking.value,
|
||||
SaleOrderStatusArranging.value,
|
||||
@@ -71,8 +71,8 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '去付款',
|
||||
sort: 100,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//只要没有付完款就显示
|
||||
let orderStatus = [
|
||||
// 只要没有付完款就显示
|
||||
const orderStatus = [
|
||||
SaleOrderStatusTaking.value,
|
||||
SaleorderstatusWaitingPrePayment.value,
|
||||
SaleOrderStatusWaitingPayment.value,
|
||||
@@ -89,8 +89,8 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '申请退款',
|
||||
sort: 5,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//大货在待发货付过款
|
||||
let orderStatus = [SaleOrderStatusWaitingDelivery.value, SaleOrderStatusTaking.value]
|
||||
// 大货在待发货付过款
|
||||
const orderStatus = [SaleOrderStatusWaitingDelivery.value, SaleOrderStatusTaking.value]
|
||||
return orderInfo.sale_mode == SaLeModeBulk.value && orderInfo.actual_amount > 0 && orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
||||
},
|
||||
},
|
||||
@@ -99,7 +99,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '申请退货',
|
||||
sort: 5,
|
||||
validatarFunc: (orderInfo) => {
|
||||
let orderStatus = [SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value]
|
||||
const orderStatus = [SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusRefund.value]
|
||||
return orderInfo.av_return_roll && orderStatus.includes(orderInfo.status)
|
||||
},
|
||||
},
|
||||
@@ -108,7 +108,7 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '确认收货',
|
||||
sort: 10,
|
||||
validatarFunc: (orderInfo) => {
|
||||
let orderStatus = [SaleOrderStatusWaitingReceipt.value]
|
||||
const orderStatus = [SaleOrderStatusWaitingReceipt.value]
|
||||
return orderStatus.includes(orderInfo.status)
|
||||
},
|
||||
},
|
||||
@@ -125,8 +125,8 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '退款',
|
||||
sort: 5,
|
||||
validatarFunc: (orderInfo) => {
|
||||
//散剪和剪板在待接单时付过款
|
||||
let orderStatus = [SaleOrderStatusBooking.value]
|
||||
// 散剪和剪板在待接单时付过款
|
||||
const orderStatus = [SaleOrderStatusBooking.value]
|
||||
return orderInfo.sale_mode != SaLeModeBulk.value && orderInfo.actual_amount > 0 && orderStatus.includes(orderInfo.status)
|
||||
},
|
||||
},
|
||||
@@ -143,132 +143,144 @@ export default memo(({ orderInfo, showStatus = 'detail', onClick }: Param) => {
|
||||
label: '销售码单',
|
||||
sort: 9,
|
||||
validatarFunc: (orderInfo) => {
|
||||
if (orderInfo.sale_mode === 1 && showStatus == 'detail') return true
|
||||
if (orderInfo.sale_mode !== 1 && showStatus == 'detail') return orderInfo.is_should_collect_audit
|
||||
if (orderInfo.sale_mode === 1 && showStatus == 'detail') { return true }
|
||||
if (orderInfo.sale_mode !== 1 && showStatus == 'detail') { return orderInfo.is_should_collect_audit }
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
//显示的按钮数组
|
||||
// 显示的按钮数组
|
||||
const orderBtnsShowList: orderBtnsListParams[] = useMemo(() => {
|
||||
let list = orderBtnsList.current.filter((item) => {
|
||||
const list = orderBtnsList.current.filter((item) => {
|
||||
return item.validatarFunc(orderInfo)
|
||||
})
|
||||
return list.sort((a, b) => a.sort - b.sort)
|
||||
}, [orderInfo])
|
||||
|
||||
//小程序订阅
|
||||
// 小程序订阅
|
||||
const { ApplyGoods } = SUBSCRIPTION_MESSAGE_SCENE
|
||||
const { openSubscriptionMessage } = UseSubscriptionMessage()
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = throttle(async (val, index) => {
|
||||
// 点击按钮操作
|
||||
const submitBtns = throttle(async(val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder()
|
||||
} else if (val == 6) {
|
||||
}
|
||||
else if (val == 6) {
|
||||
receiveOrder()
|
||||
} else if (val == 5) {
|
||||
}
|
||||
else if (val == 5) {
|
||||
applyProduct()
|
||||
} else if (val == 3) {
|
||||
}
|
||||
else if (val == 3) {
|
||||
bigApplyRefurn()
|
||||
} else if (val == 8) {
|
||||
}
|
||||
else if (val == 8) {
|
||||
applyRefund()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
onClick?.(val)
|
||||
}
|
||||
}, 800)
|
||||
|
||||
//大货申请退款
|
||||
// 大货申请退款
|
||||
const bigApplyRefurn = () => {
|
||||
Taro.showModal({
|
||||
title: '要申请退款吗?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
onClick?.(3)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//取消订单
|
||||
// 取消订单
|
||||
const { fetchData: cancelFetchData } = CancelOrderApi()
|
||||
const cancelOrder = () => {
|
||||
Taro.showModal({
|
||||
title: '要取消该订单吗?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
let res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
const res = await cancelFetchData({ id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('取消成功')
|
||||
onClick?.(1)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//确认订单
|
||||
// 确认订单
|
||||
const { fetchData: receiveOrderFetchData } = ReceiveOrderApi()
|
||||
const receiveOrder = async () => {
|
||||
const receiveOrder = async() => {
|
||||
Taro.showModal({
|
||||
title: '确定收货?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
alert.showLoading('收货中', true)
|
||||
let res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
const res = await receiveOrderFetchData({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
onClick?.(6)
|
||||
alert.success('收货成功')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('收货失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//退款
|
||||
// 退款
|
||||
const { fetchData: fetchDataApplyRefund } = ApplyRefundApi()
|
||||
const applyRefund = async () => {
|
||||
const applyRefund = async() => {
|
||||
Taro.showModal({
|
||||
title: '确定退款?',
|
||||
success: async function async(res) {
|
||||
if (res.confirm) {
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
alert.showLoading('申请中', true)
|
||||
let res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
|
||||
const res = await fetchDataApplyRefund({ sale_order_id: orderInfo?.orderId })
|
||||
if (res.success) {
|
||||
alert.success('申请成功')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('申请失败')
|
||||
}
|
||||
alert.hideLoading()
|
||||
onClick?.(8)
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//申请退货
|
||||
const applyProduct = async () => {
|
||||
if (!orderInfo?.av_return_roll) return alert.none('该订单没有可退条数')
|
||||
// 申请退货
|
||||
const applyProduct = async() => {
|
||||
if (!orderInfo?.av_return_roll) { return alert.none('该订单没有可退条数') }
|
||||
await openSubscriptionMessage({ orderId: orderInfo?.orderId, scenes: ApplyGoods.value })
|
||||
goLink('/pages/applyAfterSales/index', { id: orderInfo?.orderId })
|
||||
}
|
||||
|
||||
//显示更多按钮
|
||||
// 显示更多按钮
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const styleTop = useMemo(() => {
|
||||
return { top: `-${(orderBtnsShowList.length - 3) * 70 + 10}rpx`, left: `-${10}rpx` }
|
||||
|
||||
@@ -1,74 +1,75 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import style from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import { memo, ReactNode, useEffect, useMemo, useRef } from "react";
|
||||
import CloseBtnIcon from "@/components/closeBtn"
|
||||
import { View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useEffect, useMemo, useRef } from 'react'
|
||||
import style from './index.module.scss'
|
||||
import CloseBtnIcon from '@/components/closeBtn'
|
||||
|
||||
export interface Params {
|
||||
title?: string, //标题
|
||||
show?: false|true, //显示显示弹窗
|
||||
showTitle?: false|true, //是否显示标题
|
||||
onClose?:() => void, //关闭事件
|
||||
children?: ReactNode, //插槽内容
|
||||
// IconButton?: ReactNode, //
|
||||
showIconButton?: false|true, //是否显示关闭按钮
|
||||
position?: 'bottom'|'top'|'right', //弹出位置
|
||||
animationEnd?: () => void //弹出动画结束
|
||||
title?: string // 标题
|
||||
show?: false|true // 显示显示弹窗
|
||||
showTitle?: false|true // 是否显示标题
|
||||
onClose?: () => void // 关闭事件
|
||||
children?: ReactNode // 插槽内容
|
||||
// IconButton?: ReactNode, //
|
||||
showIconButton?: false|true // 是否显示关闭按钮
|
||||
position?: 'bottom'|'top'|'right' // 弹出位置
|
||||
animationEnd?: () => void // 弹出动画结束
|
||||
}
|
||||
export default memo((
|
||||
{
|
||||
title = '标题',
|
||||
show = false,
|
||||
showTitle = true,
|
||||
onClose,
|
||||
showIconButton = false,
|
||||
children,
|
||||
position = 'bottom',
|
||||
animationEnd
|
||||
}:Params) => {
|
||||
|
||||
const animationTime = useRef<any>(null)
|
||||
useEffect(() => {
|
||||
if(show) {
|
||||
animationTime.current = setTimeout(() => {
|
||||
animationEnd?.()
|
||||
}, 260)
|
||||
} else {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
}, [show])
|
||||
{
|
||||
title = '标题',
|
||||
show = false,
|
||||
showTitle = true,
|
||||
onClose,
|
||||
showIconButton = false,
|
||||
children,
|
||||
position = 'bottom',
|
||||
animationEnd,
|
||||
}: Params) => {
|
||||
const animationTime = useRef<any>(null)
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
animationTime.current = setTimeout(() => {
|
||||
animationEnd?.()
|
||||
}, 260)
|
||||
}
|
||||
else {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
}, [show])
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={style.drawer_main}>
|
||||
<View catchMove={true} className={`${style.drawer} ${show?style.drawer_active:''}` }>
|
||||
<View
|
||||
className={classnames(style.drawer_mask, {[style.drawer_mask_active]: show})}
|
||||
onClick={() => onClose?.()}
|
||||
>
|
||||
<View
|
||||
className={classnames(style.drawer_container, style['drawer_container_'+position], {[style.drawer_container_active]: show})}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{showTitle&&<View className={style.drawer_container_title}>{title}</View>}
|
||||
{showIconButton&&<View className={style.common_close_btn_icon}>
|
||||
<CloseBtnIcon onClose={() => onClose?.()}/>
|
||||
</View>}
|
||||
|
||||
<View className={style.drawer_container_context}>
|
||||
{show&&children}
|
||||
</View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
clearTimeout(animationTime.current)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={style.drawer_main}>
|
||||
<View catchMove className={`${style.drawer} ${show ? style.drawer_active : ''}`}>
|
||||
<View
|
||||
className={classnames(style.drawer_mask, { [style.drawer_mask_active]: show })}
|
||||
onClick={() => onClose?.()}
|
||||
>
|
||||
<View
|
||||
className={classnames(style.drawer_container, style[`drawer_container_${position}`], { [style.drawer_container_active]: show })}
|
||||
onClick={e => e.stopPropagation()}
|
||||
>
|
||||
{showTitle && <View className={style.drawer_container_title}>{title}</View>}
|
||||
{showIconButton && <View className={style.common_close_btn_icon}>
|
||||
<CloseBtnIcon onClose={() => onClose?.()} />
|
||||
</View>}
|
||||
|
||||
<View className={style.drawer_container_context}>
|
||||
{show && children}
|
||||
</View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Image, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { goLink } from '@/common/common'
|
||||
import styles from './index.module.scss'
|
||||
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||
import LabAndImg from '../LabAndImg'
|
||||
import { useCallback, useMemo } from 'react'
|
||||
import LabAndImg from '../LabAndImg'
|
||||
import styles from './index.module.scss'
|
||||
import { goLink } from '@/common/common'
|
||||
import { formatHashTag, formatImgUrl } from '@/common/fotmat'
|
||||
|
||||
type Params = {
|
||||
interface Params {
|
||||
desStatus?: true | false
|
||||
productList?: any[]
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export default ({ desStatus = true, productList = [] }: Params) => {
|
||||
<View className={styles.tag}>{item.width}</View>
|
||||
<View className={styles.tag_g}>{item.weight_density}</View>
|
||||
</View>
|
||||
<View className={styles.introduce}>{item.craft + ';' + item.component}</View>
|
||||
<View className={styles.introduce}>{`${item.craft};${item.component}`}</View>
|
||||
{desStatus && <View className={styles.des}>{item.describe}</View>}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Input, View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import CloseBtn from '@/components/closeBtn'
|
||||
import classnames from 'classnames'
|
||||
import { debounce } from '@/common/util'
|
||||
import { forwardRef, memo, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
||||
|
||||
type Params = {
|
||||
interface Params {
|
||||
clickOnSearch?: (val: string) => void
|
||||
disabled?: false | true
|
||||
placeholder?: string
|
||||
@@ -16,7 +16,7 @@ type Params = {
|
||||
showBtn?: false | true
|
||||
btnStyle?: Object
|
||||
btnTitle?: string
|
||||
debounceTime?: number //防抖时间,不设默认为零
|
||||
debounceTime?: number // 防抖时间,不设默认为零
|
||||
defaultValue?: string
|
||||
borderRadius?: string
|
||||
}
|
||||
@@ -25,17 +25,17 @@ export default memo(
|
||||
forwardRef(
|
||||
(
|
||||
{
|
||||
clickOnSearch, //点击筛选按钮触发
|
||||
changeOnSearch, //输入文字触发
|
||||
disabled = false, //是否禁用
|
||||
clickOnSearch, // 点击筛选按钮触发
|
||||
changeOnSearch, // 输入文字触发
|
||||
disabled = false, // 是否禁用
|
||||
placeholder = '输入搜索内容',
|
||||
showIcon = true, //是否显示关闭图标
|
||||
showBtn = false, //是否显示搜索按钮
|
||||
showIcon = true, // 是否显示关闭图标
|
||||
showBtn = false, // 是否显示搜索按钮
|
||||
btnStyle = {},
|
||||
placeIcon = 'inner', //搜索图标位置:inner在里面,out在外面
|
||||
btnTitle = '搜索', //搜索文字
|
||||
debounceTime = 0, //防抖时间,不设默认为零
|
||||
defaultValue = '', //默认值
|
||||
placeIcon = 'inner', // 搜索图标位置:inner在里面,out在外面
|
||||
btnTitle = '搜索', // 搜索文字
|
||||
debounceTime = 0, // 防抖时间,不设默认为零
|
||||
defaultValue = '', // 默认值
|
||||
borderRadius = '50rpx',
|
||||
}: Params,
|
||||
ref,
|
||||
@@ -84,19 +84,21 @@ export default memo(
|
||||
'icon-sousuo',
|
||||
styles.icon_a_sousuo1_self,
|
||||
placeIcon == 'inner' ? styles.icon_inner : styles.icon_out,
|
||||
)}></View>
|
||||
)}
|
||||
></View>
|
||||
)}
|
||||
<Input
|
||||
style={{ borderRadius }}
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
placeholderStyle='color:#ABABAB; font-size:26rpx'
|
||||
placeholderStyle="color:#ABABAB; font-size:26rpx"
|
||||
onConfirm={onSearch}
|
||||
className={classnames(placeIcon == 'out' && styles.input_out)}
|
||||
disabled={disabled}
|
||||
value={inputCon}
|
||||
placeholder={placeholder}
|
||||
onInput={(e) => onInputEven(e)}></Input>
|
||||
onInput={e => onInputEven(e)}
|
||||
></Input>
|
||||
{!!inputCon && (
|
||||
<View className={styles.search_closeBtn}>
|
||||
<CloseBtn onClose={() => clearInput()} styleObj={{ width: '20rpx', height: '20rpx', backgroundColor: '#fff', border: '0' }} />
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Input, View } from '@tarojs/components'
|
||||
import { memo, ReactHTMLElement, ReactNode, useDebugValue, useMemo } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { ReactHTMLElement, memo, useDebugValue, useMemo } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type Params = {
|
||||
interface Params {
|
||||
showIcon?: false | true
|
||||
disabled?: false | true
|
||||
placeholder?: string
|
||||
@@ -18,7 +19,7 @@ type Params = {
|
||||
}
|
||||
|
||||
export default memo((props: Params) => {
|
||||
let {
|
||||
const {
|
||||
showTitle = true,
|
||||
title = '标题',
|
||||
showIcon = false,
|
||||
@@ -31,14 +32,14 @@ export default memo((props: Params) => {
|
||||
titleStyle = {},
|
||||
} = props
|
||||
|
||||
let stylen = useMemo(() => {
|
||||
const stylen = useMemo(() => {
|
||||
if (!showBorder) {
|
||||
return { borderBottom: 0 }
|
||||
}
|
||||
return {}
|
||||
}, [showBorder])
|
||||
return (
|
||||
<View className={styles.searchInput_main} style={{ height: height, ...stylen }}>
|
||||
<View className={styles.searchInput_main} style={{ height, ...stylen }}>
|
||||
{showTitle && (
|
||||
<View className={styles.searchInput_title} style={titleStyle}>
|
||||
{title}
|
||||
@@ -47,12 +48,12 @@ export default memo((props: Params) => {
|
||||
<View className={styles.searchInput_con}>
|
||||
{(!props.children && (
|
||||
<Input
|
||||
alwaysEmbed={true}
|
||||
alwaysEmbed
|
||||
cursorSpacing={150}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
onClick={() => clickOnInput?.()}
|
||||
onInput={(e) => changeOnInput?.(e.detail.value)}
|
||||
onInput={e => changeOnInput?.(e.detail.value)}
|
||||
/>
|
||||
)) || <>{props.children}</>}
|
||||
</View>
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { CustomWrapper, View } from '@tarojs/components'
|
||||
import { memo, useCallback, useMemo } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import Big from 'big.js'
|
||||
import styles from './index.module.scss'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import Counter from '@/components/counter'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import Big from 'big.js'
|
||||
import { saleModeType } from '@/common/enum'
|
||||
type param = {
|
||||
import type { saleModeType } from '@/common/enum'
|
||||
|
||||
interface param {
|
||||
sale_model: saleModeType
|
||||
onChangeSelect: (val: any) => any
|
||||
onChangeCount: (val: any) => any
|
||||
@@ -16,7 +17,7 @@ type param = {
|
||||
}
|
||||
|
||||
export default memo((props: param) => {
|
||||
let { onChangeCount, onChangeSelect, item, sale_model } = props
|
||||
const { onChangeCount, onChangeSelect, item, sale_model } = props
|
||||
|
||||
const selectCallBack = useCallback(() => {
|
||||
onChangeSelect({ ...item, selected: true })
|
||||
@@ -27,8 +28,8 @@ export default memo((props: param) => {
|
||||
const getLabAndImg = useCallback(() => {}, [])
|
||||
const getInputValue = useCallback(
|
||||
(e) => {
|
||||
let roll = item.sale_mode == 0 ? parseFloat(e) : 0
|
||||
let length = item.sale_mode != 0 ? parseFloat(new Big(parseFloat(e)).times(100)) : 0
|
||||
const roll = item.sale_mode == 0 ? parseFloat(e) : 0
|
||||
const length = item.sale_mode != 0 ? parseFloat(new Big(parseFloat(e)).times(100)) : 0
|
||||
onChangeCount({ ...item, roll, length })
|
||||
},
|
||||
[item],
|
||||
@@ -38,20 +39,20 @@ export default memo((props: param) => {
|
||||
}, [item])
|
||||
|
||||
const clickProduct = useCallback(() => {
|
||||
if (sale_model == item.sale_mode) onChangeSelect({ ...item, selected: !item.selected })
|
||||
if (sale_model == item.sale_mode) { onChangeSelect({ ...item, selected: !item.selected }) }
|
||||
}, [item])
|
||||
|
||||
console.log('刷新2::', item)
|
||||
|
||||
//格式化金额
|
||||
// 格式化金额
|
||||
const formatPirce = useCallback((price) => {
|
||||
return Number(formatPriceDiv(price))
|
||||
}, [])
|
||||
//格式化数量
|
||||
// 格式化数量
|
||||
const formatCount = useCallback((item) => {
|
||||
return item.sale_mode == 0 ? item.roll : item.length / 100
|
||||
}, [])
|
||||
//格式化单位
|
||||
// 格式化单位
|
||||
const formatUnit = useCallback((item) => {
|
||||
return item.sale_mode == 0 ? '条' : '米'
|
||||
}, [])
|
||||
@@ -78,7 +79,7 @@ export default memo((props: param) => {
|
||||
</View>
|
||||
<View className={styles.count}>
|
||||
<View className={styles.des}>
|
||||
<View className={styles.subtitle}>{item.product_color_code + ' ' + item.product_color_name}</View>
|
||||
<View className={styles.subtitle}>{`${item.product_color_code} ${item.product_color_name}`}</View>
|
||||
<View className={styles.tag}>{item.sale_mode_name}</View>
|
||||
</View>
|
||||
<View className={styles.btn_count}>
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import { Image, ScrollView, View } from '@tarojs/components'
|
||||
import Popup from '@/components/popup'
|
||||
import classnames from 'classnames'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import styles from './index.module.scss'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { GetShoppingCartApi, DelShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import { setParam } from '@/common/system'
|
||||
import { debounce, throttle } from '@/common/util'
|
||||
import classnames from 'classnames'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Counter from '../counter'
|
||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
||||
import useCommonData from '@/use/useCommonData'
|
||||
import BindSalesmanPopup from '../bindSalesmanPopup'
|
||||
import LabAndImgShow from '../LabAndImgShow'
|
||||
import LabAndImg from '../LabAndImg'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { DelShoppingCartApi, GetShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import { setParam } from '@/common/system'
|
||||
import { debounce, throttle } from '@/common/util'
|
||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
||||
import useCommonData from '@/use/useCommonData'
|
||||
|
||||
type param = {
|
||||
interface param {
|
||||
show?: true | false
|
||||
onClose?: () => void
|
||||
intoStatus?: 'again' | 'shop'
|
||||
default_sale_mode?: number //面料类型(0:大货, 1:剪版,2:散剪
|
||||
default_sale_mode?: number // 面料类型(0:大货, 1:剪版,2:散剪
|
||||
}
|
||||
export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode }: param) => {
|
||||
const selectList = [
|
||||
@@ -32,7 +32,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
{ value: 2, title: '散剪', unit: '米', eunit: 'kg', step: 1, digits: 2, minNum: 3, maxNum: 100000, defaultNum: 3 },
|
||||
]
|
||||
|
||||
//切换面料类型
|
||||
// 切换面料类型
|
||||
const [selectIndex, setSelectIndex] = useState(default_sale_mode || 0)
|
||||
const selectProduct = (index: number) => {
|
||||
setSelectIndex(index)
|
||||
@@ -48,53 +48,55 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
|
||||
const MCheckboxRef = useRef(null)
|
||||
|
||||
//获取购物车数据数量
|
||||
// 获取购物车数据数量
|
||||
const { setShopCount } = useCommonData()
|
||||
|
||||
//重置勾选数据
|
||||
// 重置勾选数据
|
||||
const resetList = () => {
|
||||
list?.map((item) => {
|
||||
if (selectIndex == item.sale_mode || selectIndex == -1) {
|
||||
checkboxData[item.id] = true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
checkboxData[item.id] = false
|
||||
}
|
||||
})
|
||||
setCheckboxData(() => ({ ...checkboxData }))
|
||||
}
|
||||
|
||||
//获取数据
|
||||
// 获取数据
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { fetchData } = GetShoppingCartApi()
|
||||
const getShoppingCart = async () => {
|
||||
const getShoppingCart = async() => {
|
||||
const { data } = await fetchData()
|
||||
let color_list = data.color_list || []
|
||||
const color_list = data.color_list || []
|
||||
setShopCount(color_list.length)
|
||||
initList(color_list)
|
||||
setList(color_list)
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
//初始化全部数据默认勾选
|
||||
const [checkboxData, setCheckboxData] = useState<{ [index: number]: true | false }>({})
|
||||
// 初始化全部数据默认勾选
|
||||
const [checkboxData, setCheckboxData] = useState<Record<number, true | false>>({})
|
||||
const initStatus = useRef(false)
|
||||
const initList = (color_list) => {
|
||||
if (initStatus.current) {
|
||||
color_list?.map((item) => {
|
||||
if (selectIndex == item.sale_mode) checkboxData[item.id] = true
|
||||
if (selectIndex == item.sale_mode) { checkboxData[item.id] = true }
|
||||
})
|
||||
initStatus.current = false
|
||||
}
|
||||
setCheckboxData(() => checkboxData)
|
||||
}
|
||||
|
||||
//显示是展示数据
|
||||
// 显示是展示数据
|
||||
useEffect(() => {
|
||||
if (!show) {
|
||||
setList([])
|
||||
setSelectIndex(default_sale_mode || 0)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setLoading(true)
|
||||
initStatus.current = true
|
||||
getShoppingCart()
|
||||
@@ -113,57 +115,57 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
setShowPopup(show)
|
||||
}, [show])
|
||||
|
||||
//全选反选
|
||||
// 全选反选
|
||||
const [selectStatus, setSelectStatus] = useState(false)
|
||||
const selectAll = () => {
|
||||
list.map((item) => {
|
||||
if (selectIndex == item.sale_mode || selectIndex == -1) checkboxData[item.id] = !selectStatus
|
||||
if (selectIndex == item.sale_mode || selectIndex == -1) { checkboxData[item.id] = !selectStatus }
|
||||
})
|
||||
setSelectStatus(!selectStatus)
|
||||
setCheckboxData(() => ({ ...checkboxData }))
|
||||
}
|
||||
|
||||
//checkbox选中回调
|
||||
// checkbox选中回调
|
||||
const selectCallBack = useCallback((item) => {
|
||||
checkboxData[item.id] = true
|
||||
checkSelect()
|
||||
setCheckboxData((e) => ({ ...e, ...checkboxData }))
|
||||
setCheckboxData(e => ({ ...e, ...checkboxData }))
|
||||
}, [])
|
||||
|
||||
//checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||
// checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||
const checkSelect = () => {
|
||||
let list_count = 0
|
||||
let select_count = 0
|
||||
list?.map((item) => {
|
||||
if (selectIndex == -1 || selectIndex == item.sale_mode) {
|
||||
list_count++
|
||||
if (checkboxData[item.id]) select_count++
|
||||
if (checkboxData[item.id]) { select_count++ }
|
||||
}
|
||||
})
|
||||
setSelectStatus(select_count == list_count)
|
||||
}
|
||||
|
||||
//checkbox关闭回调
|
||||
// checkbox关闭回调
|
||||
const colseCallBack = useCallback((item) => {
|
||||
checkboxData[item.id] = false
|
||||
checkSelect()
|
||||
setCheckboxData((e) => ({ ...e, ...checkboxData }))
|
||||
setCheckboxData(e => ({ ...e, ...checkboxData }))
|
||||
}, [])
|
||||
|
||||
//popup关闭
|
||||
// popup关闭
|
||||
const closePopup = () => {
|
||||
onClose?.()
|
||||
setShowPopup(false)
|
||||
}
|
||||
|
||||
//删除购物车内容
|
||||
// 删除购物车内容
|
||||
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
||||
const delSelect = () => {
|
||||
getSelectId()
|
||||
if (selectIds.current.length <= 0) return alert.none('请选择要删除的面料!')
|
||||
if (selectIds.current.length <= 0) { return alert.none('请选择要删除的面料!') }
|
||||
Taro.showModal({
|
||||
content: '删除所选商品?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await delShopFetchData({ id: selectIds.current })
|
||||
if (res.success) {
|
||||
@@ -172,20 +174,22 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
title: '成功',
|
||||
icon: 'success',
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//获取面料选中的id
|
||||
// 获取面料选中的id
|
||||
const selectIds = useRef<number[]>([])
|
||||
const getSelectId = () => {
|
||||
selectIds.current = []
|
||||
@@ -196,27 +200,27 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
}
|
||||
|
||||
//格式化金额
|
||||
// 格式化金额
|
||||
const formatPirce = useCallback((price) => {
|
||||
return Number(formatPriceDiv(price))
|
||||
}, [])
|
||||
|
||||
//格式化数量
|
||||
// 格式化数量
|
||||
const formatCount = useCallback((item) => {
|
||||
return item.sale_mode == 0 ? item.roll : item.length / 100
|
||||
}, [])
|
||||
|
||||
//格式化单位
|
||||
// 格式化单位
|
||||
const formatUnit = useCallback((item) => {
|
||||
return item.sale_mode == 0 ? '条' : '米'
|
||||
}, [])
|
||||
|
||||
//预估金额和总条数
|
||||
// 预估金额和总条数
|
||||
const estimatePrice = useMemo(() => {
|
||||
let estimate_amount = 0
|
||||
let product_list = new Set() //面料
|
||||
let color_count = 0 //颜色数量
|
||||
let all_count = 0 //总数量
|
||||
const product_list = new Set() // 面料
|
||||
let color_count = 0 // 颜色数量
|
||||
let all_count = 0 // 总数量
|
||||
list.map((item) => {
|
||||
if (checkboxData[item.id]) {
|
||||
estimate_amount += item.estimate_amount
|
||||
@@ -225,7 +229,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
all_count += item.sale_mode == 0 ? item.roll : item.length
|
||||
}
|
||||
})
|
||||
let all_count_text = selectIndex == 0 ? all_count + ' 条' : all_count / 100 + ' 米'
|
||||
const all_count_text = selectIndex == 0 ? `${all_count} 条` : `${all_count / 100} 米`
|
||||
return {
|
||||
price: Number(formatPriceDiv(estimate_amount)).toFixed(2),
|
||||
countText: `已选 ${product_list.size} 种面料,${color_count} 个颜色,共 ${all_count_text}`,
|
||||
@@ -233,13 +237,13 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
}
|
||||
}, [list, checkboxData])
|
||||
|
||||
//去结算
|
||||
// 去结算
|
||||
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
||||
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
||||
const orderDetail = throttle(async () => {
|
||||
let res = await useFetchData()
|
||||
const orderDetail = throttle(async() => {
|
||||
const res = await useFetchData()
|
||||
if (res.data.order_access_status !== 3) {
|
||||
if (res.data.order_access_status == 1) applyOrderAccessFetchData()
|
||||
if (res.data.order_access_status == 1) { applyOrderAccessFetchData() }
|
||||
setShowBindSalesman(() => true)
|
||||
onClose?.()
|
||||
return false
|
||||
@@ -247,36 +251,38 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
getSelectId()
|
||||
if (selectIds.current.length == 0) {
|
||||
alert.error('请选择面料')
|
||||
} else {
|
||||
let ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) //临时存储
|
||||
}
|
||||
else {
|
||||
const ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
||||
closePopup()
|
||||
if (intoStatus == 'again') {
|
||||
goLink('/pages/order/comfirm', {}, 'redirectTo')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
goLink('/pages/order/comfirm')
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
|
||||
//计数组件-当后端修改完成才修改前端显示
|
||||
// 计数组件-当后端修改完成才修改前端显示
|
||||
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
||||
const [UpdateShoppingCartLoading, setUpdateShoppingCartLoading] = useState(false)
|
||||
const getInputValue = debounce(async (num, item) => {
|
||||
let roll = item.sale_mode == 0 ? parseFloat(num) : 0
|
||||
let length = item.sale_mode != 0 ? parseFloat(num) * 100 : 0
|
||||
const getInputValue = debounce(async(num, item) => {
|
||||
const roll = item.sale_mode == 0 ? parseFloat(num) : 0
|
||||
const length = item.sale_mode != 0 ? parseFloat(num) * 100 : 0
|
||||
setUpdateShoppingCartLoading(() => true)
|
||||
let res = await fetchDataUpdateShoppingCart({ id: item.id, roll, length })
|
||||
const res = await fetchDataUpdateShoppingCart({ id: item.id, roll, length })
|
||||
setUpdateShoppingCartLoading(() => false)
|
||||
if (res.success) {
|
||||
getShoppingCart()
|
||||
}
|
||||
}, 300)
|
||||
|
||||
//绑定业务员和电话号码
|
||||
// 绑定业务员和电话号码
|
||||
const [showBindSalesman, setShowBindSalesman] = useState(false)
|
||||
|
||||
//显示图片弹窗
|
||||
// 显示图片弹窗
|
||||
const [showLabImage, setShowLabImage] = useState(false)
|
||||
const [labImageValue, setLabImageValue] = useState()
|
||||
const getLabAndImg = useCallback((val) => {
|
||||
@@ -305,7 +311,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
<View
|
||||
key={item.value}
|
||||
onClick={() => selectProduct(item.value)}
|
||||
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}>
|
||||
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}
|
||||
>
|
||||
{item.title}
|
||||
</View>
|
||||
)
|
||||
@@ -320,7 +327,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
return (
|
||||
<View
|
||||
key={item}
|
||||
className={classnames(styles.product_item, selectIndex != -1 && selectIndex != item.sale_mode && styles.no_product_item_select)}>
|
||||
className={classnames(styles.product_item, selectIndex != -1 && selectIndex != item.sale_mode && styles.no_product_item_select)}
|
||||
>
|
||||
<View className={styles.checkbox}>
|
||||
<MCheckbox
|
||||
disabled={selectIndex != -1 && selectIndex != item.sale_mode}
|
||||
@@ -347,16 +355,16 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
</View>
|
||||
<View className={styles.count}>
|
||||
<View className={styles.des}>
|
||||
<View className={styles.subtitle}>{item.product_color_code + ' ' + item.product_color_name}</View>
|
||||
<View className={styles.subtitle}>{`${item.product_color_code} ${item.product_color_name}`}</View>
|
||||
<View className={styles.tag}>{item.sale_mode_name}</View>
|
||||
</View>
|
||||
<View className={styles.btn_count}>
|
||||
<Counter
|
||||
onBlue={(e) => getInputValue(e, item)}
|
||||
onBlue={e => getInputValue(e, item)}
|
||||
defaultNum={formatCount(item)}
|
||||
step={selectList[selectIndex].step}
|
||||
digits={selectList[selectIndex].digits}
|
||||
onClickBtn={(e) => getInputValue(e, item)}
|
||||
onClickBtn={e => getInputValue(e, item)}
|
||||
unit={formatUnit(item)}
|
||||
minNum={selectList[selectIndex].minNum}
|
||||
maxNum={selectList[selectIndex].maxNum}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
import { Image, ScrollView, View } from '@tarojs/components'
|
||||
import Popup from '@/components/popup'
|
||||
import classnames from 'classnames'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import styles from './index.module.scss'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { GetShoppingCartApi, DelShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import { setParam } from '@/common/system'
|
||||
import { debounce, throttle } from '@/common/util'
|
||||
import classnames from 'classnames'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||
import Counter from '../counter'
|
||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
||||
import useCommonData from '@/use/useCommonData'
|
||||
import BindSalesmanPopup from '../bindSalesmanPopup'
|
||||
import LabAndImgShow from '../LabAndImgShow'
|
||||
import LabAndImg from '../LabAndImg'
|
||||
import styles from './index.module.scss'
|
||||
import ProductItem from './components/productItem'
|
||||
import { saleModeType } from '@/common/enum'
|
||||
import Popup from '@/components/popup'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { DelShoppingCartApi, GetShoppingCartApi, UpdateShoppingCartApi } from '@/api/shopCart'
|
||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from '@/common/fotmat'
|
||||
import { setParam } from '@/common/system'
|
||||
import { debounce, throttle } from '@/common/util'
|
||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from '@/api/user'
|
||||
import useCommonData from '@/use/useCommonData'
|
||||
import type { saleModeType } from '@/common/enum'
|
||||
|
||||
type param = {
|
||||
interface param {
|
||||
show?: true | false
|
||||
onClose?: () => void
|
||||
intoStatus?: 'again' | 'shop'
|
||||
default_sale_mode?: saleModeType //面料类型(0:大货, 1:剪版,2:散剪
|
||||
default_sale_mode?: saleModeType // 面料类型(0:大货, 1:剪版,2:散剪
|
||||
}
|
||||
type modelClassType = {
|
||||
interface modelClassType {
|
||||
value: saleModeType
|
||||
title: string
|
||||
unit: string
|
||||
@@ -47,7 +47,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
|
||||
const [isPending, startTransition] = useTransition()
|
||||
|
||||
//切换面料类型
|
||||
// 切换面料类型
|
||||
const [selectIndex, setSelectIndex] = useState<saleModeType>(default_sale_mode || 0)
|
||||
const selectProduct = (index: 0 | 1 | 2) => {
|
||||
setSelectIndex(index)
|
||||
@@ -65,26 +65,26 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
}, [selectIndex])
|
||||
|
||||
//获取购物车数据数量
|
||||
// 获取购物车数据数量
|
||||
const { getShopCount } = useCommonData()
|
||||
|
||||
//获取所有数据数据
|
||||
const [list, setList] = useState<{ [id: number]: any }>({})
|
||||
// 获取所有数据数据
|
||||
const [list, setList] = useState<Record<number, any>>({})
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { fetchData: getShoppingFetchData } = GetShoppingCartApi()
|
||||
const getShoppingCart = async () => {
|
||||
const getShoppingCart = async() => {
|
||||
const { data } = await getShoppingFetchData()
|
||||
let color_list = data.color_list || []
|
||||
const color_list = data.color_list || []
|
||||
initList(color_list)
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
//更新单条数据
|
||||
const getShoppingCartInfo = async (item) => {
|
||||
// 更新单条数据
|
||||
const getShoppingCartInfo = async(item) => {
|
||||
const res = await getShoppingFetchData({ id: item.id })
|
||||
if (res.success) {
|
||||
let info = res.data.color_list[0]
|
||||
let newInfo = {
|
||||
const info = res.data.color_list[0]
|
||||
const newInfo = {
|
||||
...item,
|
||||
estimate_amount: info.estimate_amount,
|
||||
estimate_weight: info.estimate_weight,
|
||||
@@ -95,7 +95,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
sale_price: info.sale_price,
|
||||
standard_price: info.standard_price,
|
||||
}
|
||||
setList((e) => ({ ...e, [item['id']]: newInfo }))
|
||||
setList(e => ({ ...e, [item.id]: newInfo }))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,9 +103,9 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
return Object.values(list)
|
||||
}, [list])
|
||||
|
||||
//初始化全部数据默认勾选
|
||||
// 初始化全部数据默认勾选
|
||||
const initList = (color_list) => {
|
||||
let obj = {}
|
||||
const obj = {}
|
||||
color_list?.map((item) => {
|
||||
item.selected = selectIndex == item.sale_mode
|
||||
const { unit, eunit, step, digits, minNum, maxNum } = selectList[item.sale_mode]
|
||||
@@ -115,25 +115,27 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
setList(() => ({ ...obj }))
|
||||
}
|
||||
|
||||
//重置勾选数据
|
||||
// 重置勾选数据
|
||||
const resetList = () => {
|
||||
Object.values(list)?.map((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
item.selected = true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
item.selected = false
|
||||
}
|
||||
list[item['id']] = { ...item }
|
||||
list[item.id] = { ...item }
|
||||
})
|
||||
setList(() => ({ ...list }))
|
||||
}
|
||||
|
||||
//显示时展示数据
|
||||
// 显示时展示数据
|
||||
useEffect(() => {
|
||||
if (!show) {
|
||||
setList({})
|
||||
setSelectIndex(default_sale_mode || 0)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setLoading(true)
|
||||
getShoppingCart()
|
||||
setShowBindSalesman(() => false)
|
||||
@@ -145,56 +147,56 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
setShowPopup(show)
|
||||
}, [show])
|
||||
|
||||
//全选反选
|
||||
// 全选反选
|
||||
const [selectStatus, setSelectStatus] = useState(false)
|
||||
const selectAll = () => {
|
||||
Object.values(list)?.map((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
item.selected = !selectStatus
|
||||
list[item['id']] = { ...item }
|
||||
list[item.id] = { ...item }
|
||||
}
|
||||
})
|
||||
setList(() => ({ ...list }))
|
||||
setSelectStatus(!selectStatus)
|
||||
}
|
||||
|
||||
//checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||
// checkbox选中判断是否全部选中,全部选中后是全选,否则反选
|
||||
useEffect(() => {
|
||||
let list_count = 0
|
||||
let select_count = 0
|
||||
Object.values(list)?.map((item) => {
|
||||
if (selectIndex == item.sale_mode) {
|
||||
list_count++
|
||||
if (item.selected) select_count++
|
||||
if (item.selected) { select_count++ }
|
||||
}
|
||||
})
|
||||
setSelectStatus(select_count == list_count)
|
||||
}, [list])
|
||||
|
||||
//修改数量
|
||||
// 修改数量
|
||||
const onChangeCount = useCallback((item) => {
|
||||
getInputValue(item)
|
||||
}, [])
|
||||
|
||||
//修改选择
|
||||
// 修改选择
|
||||
const onChangeSelect = useCallback((item) => {
|
||||
setList((e) => ({ ...e, [item.id]: { ...item } }))
|
||||
setList(e => ({ ...e, [item.id]: { ...item } }))
|
||||
}, [])
|
||||
|
||||
//popup关闭
|
||||
// popup关闭
|
||||
const closePopup = () => {
|
||||
onClose?.()
|
||||
setShowPopup(false)
|
||||
}
|
||||
|
||||
//删除购物车内容
|
||||
// 删除购物车内容
|
||||
const { fetchData: delShopFetchData } = DelShoppingCartApi()
|
||||
const delSelect = () => {
|
||||
getSelectId()
|
||||
if (selectIds.current.length <= 0) return alert.none('请选择要删除的面料!')
|
||||
if (selectIds.current.length <= 0) { return alert.none('请选择要删除的面料!') }
|
||||
Taro.showModal({
|
||||
content: '删除所选商品?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await delShopFetchData({ id: selectIds.current })
|
||||
if (res.success) {
|
||||
@@ -204,20 +206,22 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
title: '成功',
|
||||
icon: 'success',
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//获取面料选中的id
|
||||
// 获取面料选中的id
|
||||
const selectIds = useRef<number[]>([])
|
||||
const getSelectId = () => {
|
||||
selectIds.current = []
|
||||
@@ -228,12 +232,12 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
})
|
||||
}
|
||||
|
||||
//预估金额和总条数
|
||||
// 预估金额和总条数
|
||||
const estimatePrice = useMemo(() => {
|
||||
let estimate_amount = 0
|
||||
let product_list = new Set() //面料
|
||||
let color_count = 0 //颜色数量
|
||||
let all_count = 0 //总数量
|
||||
const product_list = new Set() // 面料
|
||||
let color_count = 0 // 颜色数量
|
||||
let all_count = 0 // 总数量
|
||||
Object.values(list)?.map((item) => {
|
||||
if (item.selected) {
|
||||
estimate_amount += item.estimate_amount
|
||||
@@ -242,7 +246,7 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
all_count += item.sale_mode == 0 ? parseFloat(item.roll) : parseFloat(item.length)
|
||||
}
|
||||
})
|
||||
let all_count_text = selectIndex == 0 ? all_count + ' 条' : all_count / 100 + ' 米'
|
||||
const all_count_text = selectIndex == 0 ? `${all_count} 条` : `${all_count / 100} 米`
|
||||
console.log('text::', list)
|
||||
return {
|
||||
price: Number(formatPriceDiv(estimate_amount)).toFixed(2),
|
||||
@@ -251,13 +255,13 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
}
|
||||
}, [list])
|
||||
|
||||
//去结算
|
||||
// 去结算
|
||||
const { fetchData: useFetchData } = GetAdminUserInfoApi()
|
||||
const { fetchData: applyOrderAccessFetchData } = ApplyOrderAccessApi()
|
||||
const orderDetail = throttle(async () => {
|
||||
let res = await useFetchData()
|
||||
const orderDetail = throttle(async() => {
|
||||
const res = await useFetchData()
|
||||
if (res.data.order_access_status !== 3) {
|
||||
if (res.data.order_access_status == 1) applyOrderAccessFetchData()
|
||||
if (res.data.order_access_status == 1) { applyOrderAccessFetchData() }
|
||||
setShowBindSalesman(() => true)
|
||||
onClose?.()
|
||||
return false
|
||||
@@ -265,34 +269,37 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
getSelectId()
|
||||
if (selectIds.current.length == 0) {
|
||||
alert.error('请选择面料')
|
||||
} else {
|
||||
let ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) //临时存储
|
||||
}
|
||||
else {
|
||||
const ids = selectIds.current.join('-')
|
||||
setParam({ ids, sale_mode: selectIndex }) // 临时存储
|
||||
closePopup()
|
||||
if (intoStatus == 'again') {
|
||||
goLink('/pages/order/comfirm', null, 'redirectTo')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
goLink('/pages/order/comfirm')
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
|
||||
//计数组件-当后端修改完成才修改前端显示
|
||||
// 计数组件-当后端修改完成才修改前端显示
|
||||
const { fetchData: fetchDataUpdateShoppingCart } = UpdateShoppingCartApi()
|
||||
const getInputValue = debounce(async (item) => {
|
||||
let res = await fetchDataUpdateShoppingCart({ id: item.id, roll: item.roll, length: item.length })
|
||||
const getInputValue = debounce(async(item) => {
|
||||
const res = await fetchDataUpdateShoppingCart({ id: item.id, roll: item.roll, length: item.length })
|
||||
if (res.success) {
|
||||
console.log('item修改::', item)
|
||||
getShoppingCartInfo(item)
|
||||
} else {
|
||||
setList((e) => ({ ...e }))
|
||||
}
|
||||
else {
|
||||
setList(e => ({ ...e }))
|
||||
}
|
||||
}, 300)
|
||||
|
||||
//绑定业务员和电话号码
|
||||
// 绑定业务员和电话号码
|
||||
const [showBindSalesman, setShowBindSalesman] = useState(false)
|
||||
|
||||
//显示图片弹窗
|
||||
// 显示图片弹窗
|
||||
const [showLabImage, setShowLabImage] = useState(false)
|
||||
const [labImageValue, setLabImageValue] = useState()
|
||||
const getLabAndImg = useCallback((val) => {
|
||||
@@ -326,7 +333,8 @@ export default ({ show = false, onClose, intoStatus = 'shop', default_sale_mode
|
||||
<View
|
||||
key={item.value}
|
||||
onClick={() => selectProduct(item.value)}
|
||||
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}>
|
||||
className={classnames(styles.search_item, selectIndex == item.value && styles.search_item_select)}
|
||||
>
|
||||
{item.title}
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import React, { memo, ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import Taro, { getCurrentInstance, useReady, useRouter } from '@tarojs/taro'
|
||||
import InfiniteScroll, { StatusParam } from '../infiniteScroll'
|
||||
import type { ReactNode } from 'react'
|
||||
import React, { memo, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import type { StatusParam } from '../infiniteScroll'
|
||||
import InfiniteScroll from '../infiniteScroll'
|
||||
import LoadingCard from '../loadingCard'
|
||||
import styles from './index.module.scss'
|
||||
import ProductClass from '@/pages/index/components/productClass'
|
||||
import { GetClassList } from '@/api/material'
|
||||
|
||||
type Params = {
|
||||
interface Params {
|
||||
list?: any[]
|
||||
defaultValue?: number | string
|
||||
children?: ReactNode
|
||||
@@ -38,7 +40,7 @@ export default memo(
|
||||
statusMore = 0,
|
||||
selectClass,
|
||||
}: Params) => {
|
||||
let num_half = useRef(0)
|
||||
const num_half = useRef(0)
|
||||
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
@@ -66,24 +68,25 @@ export default memo(
|
||||
|
||||
const computeSelectTab = (index) => {
|
||||
if (index + 1 > num_half.current) {
|
||||
let num = index + 1 - num_half.current
|
||||
const num = index + 1 - num_half.current
|
||||
setTabId(list[num].id.toString())
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setTabId(list[0].id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
Taro.nextTick(() => {
|
||||
let query = Taro.createSelectorQuery()
|
||||
const query = Taro.createSelectorQuery()
|
||||
query
|
||||
.select('.side_bar_select')
|
||||
.boundingClientRect((rect) => {
|
||||
console.log('rect::', rect)
|
||||
let clientHeight = rect.height
|
||||
let clientWidth = rect.width
|
||||
let ratio = 750 / clientWidth
|
||||
let height = clientHeight * ratio
|
||||
const clientHeight = rect.height
|
||||
const clientWidth = rect.width
|
||||
const ratio = 750 / clientWidth
|
||||
const height = clientHeight * ratio
|
||||
num_half.current = Math.ceil(height / 2 / heightItem)
|
||||
console.log('num_half::', num_half)
|
||||
init()
|
||||
@@ -92,13 +95,13 @@ export default memo(
|
||||
})
|
||||
}, [])
|
||||
|
||||
//二级面料系列分类
|
||||
// 二级面料系列分类
|
||||
const [openClass, setOpenClass] = useState(false)
|
||||
const [classList, setClassList] = useState([])
|
||||
const [classId, setClassId] = useState(-1)
|
||||
const { fetchData } = GetClassList()
|
||||
const getClassData = async (id) => {
|
||||
let res = await fetchData({ id })
|
||||
const getClassData = async(id) => {
|
||||
const res = await fetchData({ id })
|
||||
if (res.success) {
|
||||
if (res.data?.list.length > 0) {
|
||||
res.data.list = [{ id: -1, name: '全部' }, ...res.data.list]
|
||||
@@ -107,7 +110,7 @@ export default memo(
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
if (selected) getClassData(selected)
|
||||
if (selected) { getClassData(selected) }
|
||||
}, [selected])
|
||||
|
||||
const getSelectClass = (id) => {
|
||||
@@ -118,13 +121,14 @@ export default memo(
|
||||
return (
|
||||
<>
|
||||
<View className={classnames(styles.sideBar_main, 'side_bar_select')}>
|
||||
<ScrollView scrollWithAnimation={true} style={{ height }} className={styles.sideBar_select} scrollY scrollIntoView={`tab_${tabId}`}>
|
||||
<ScrollView scrollWithAnimation style={{ height }} className={styles.sideBar_select} scrollY scrollIntoView={`tab_${tabId}`}>
|
||||
{list?.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.sideBar_select_title} id={`tab_${item.id}`} key={item.id} style={{ height: `${heightItem}rpx` }}>
|
||||
<View
|
||||
className={classnames(styles.sideBar_select_title_item, { [styles.sideBar_select_title_select]: selected == item.id })}
|
||||
onClick={() => clickEvent({ item, index })}>
|
||||
onClick={() => clickEvent({ item, index })}
|
||||
>
|
||||
<View className={styles.title_con}>{item.name}</View>
|
||||
</View>
|
||||
</View>
|
||||
@@ -134,7 +138,7 @@ export default memo(
|
||||
<View className={styles.sideBar_con} style={{ paddingTop: classList.length > 0 ? '90rpx' : '20rpx' }}>
|
||||
{classList.length > 0 && (
|
||||
<View className={styles.product_class} style={{ height: openClass ? '100%' : '' }}>
|
||||
<ProductClass list={classList} open={openClass} onOpenClick={(val) => setOpenClass(val)} onSelect={getSelectClass} defaultSelectId={classId} />
|
||||
<ProductClass list={classList} open={openClass} onOpenClick={val => setOpenClass(val)} onSelect={getSelectClass} defaultSelectId={classId} />
|
||||
</View>
|
||||
)}
|
||||
<InfiniteScroll
|
||||
@@ -142,8 +146,9 @@ export default memo(
|
||||
hasMore={hasMore}
|
||||
selfonScrollToLower={() => selfOnScrolltolower?.()}
|
||||
refresherTriggered={refresherTriggered}
|
||||
refresherEnabled={true}
|
||||
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
|
||||
refresherEnabled
|
||||
selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}
|
||||
>
|
||||
{children}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import classnames from "classnames";
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import { View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type params = {
|
||||
status?: 'top'|'bottom'|'none',
|
||||
onChange?: (val:{status:string, value:string}) => void,
|
||||
sortValue?: {desc: string, asc: string} //排序规则,后端制定
|
||||
interface params {
|
||||
status?: 'top'|'bottom'|'none'
|
||||
onChange?: (val: { status: string; value: string }) => void
|
||||
sortValue?: { desc: string; asc: string } // 排序规则,后端制定
|
||||
}
|
||||
type sortParam = 'none'|'top'|'bottom'
|
||||
export default forwardRef(({status = 'none', onChange, sortValue}: params,ref) => {
|
||||
const [sortStatus, setSortStatus] = useState<sortParam>()
|
||||
useEffect(() => {
|
||||
setSortStatus(() => status)
|
||||
}, [status])
|
||||
const changeSort = ():{status:sortParam, value:string} => {
|
||||
let status:sortParam = 'none'
|
||||
let value = ''
|
||||
if(sortStatus == 'none') {
|
||||
status = 'top'
|
||||
value = sortValue?.asc!
|
||||
}
|
||||
if(sortStatus == 'top') {
|
||||
status = 'bottom'
|
||||
value = sortValue?.desc!
|
||||
}
|
||||
if(sortStatus == 'bottom') status = 'none'
|
||||
setSortStatus(() => status)
|
||||
onChange?.({status, value})
|
||||
return {status, value}
|
||||
export default forwardRef(({ status = 'none', onChange, sortValue }: params, ref) => {
|
||||
const [sortStatus, setSortStatus] = useState<sortParam>()
|
||||
useEffect(() => {
|
||||
setSortStatus(() => status)
|
||||
}, [status])
|
||||
const changeSort = (): { status: sortParam; value: string } => {
|
||||
let status: sortParam = 'none'
|
||||
let value = ''
|
||||
if (sortStatus == 'none') {
|
||||
status = 'top'
|
||||
value = sortValue?.asc!
|
||||
}
|
||||
useImperativeHandle(ref, () => ({
|
||||
changeSort
|
||||
}))
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.click} onClick={changeSort}>
|
||||
<View className={classnames(styles.top, sortStatus == 'top'&&styles.selected)} ></View>
|
||||
<View className={classnames(styles.bottom, sortStatus == 'bottom'&&styles.selected)}></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
if (sortStatus == 'top') {
|
||||
status = 'bottom'
|
||||
value = sortValue?.desc!
|
||||
}
|
||||
if (sortStatus == 'bottom') { status = 'none' }
|
||||
setSortStatus(() => status)
|
||||
onChange?.({ status, value })
|
||||
return { status, value }
|
||||
}
|
||||
useImperativeHandle(ref, () => ({
|
||||
changeSort,
|
||||
}))
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.click} onClick={changeSort}>
|
||||
<View className={classnames(styles.top, sortStatus == 'top' && styles.selected)} ></View>
|
||||
<View className={classnames(styles.bottom, sortStatus == 'bottom' && styles.selected)}></View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,61 +1,60 @@
|
||||
import { ScrollView, View } from "@tarojs/components";
|
||||
import { memo, useState, ReactNode, useEffect } from "react";
|
||||
import classnames from "classnames";
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
|
||||
type ListProps = {
|
||||
title: string,
|
||||
value: number
|
||||
interface ListProps {
|
||||
title: string
|
||||
value: number
|
||||
}
|
||||
|
||||
type Params = {
|
||||
list?: ListProps[],
|
||||
defaultValue?: number|string,
|
||||
children?: ReactNode,
|
||||
tabsOnClick?: (ListProps) => void,
|
||||
style?:Object,
|
||||
interface Params {
|
||||
list?: ListProps[]
|
||||
defaultValue?: number|string
|
||||
children?: ReactNode
|
||||
tabsOnClick?: (ListProps) => void
|
||||
style?: Object
|
||||
|
||||
}
|
||||
|
||||
export default memo(({list = [], defaultValue = 0, tabsOnClick, style={}}: Params) => {
|
||||
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
export default memo(({ list = [], defaultValue = 0, tabsOnClick, style = {} }: Params) => {
|
||||
const [selected, setSelected] = useState(defaultValue)
|
||||
const [tabId, setTabId] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
const index = list?.findIndex(item => {
|
||||
return item.value == defaultValue
|
||||
})
|
||||
if(index !== -1) {
|
||||
const num = index > 0?( index - 1) : 0
|
||||
setTabId(list[num].value.toString())
|
||||
}
|
||||
}, [])
|
||||
|
||||
const clickEvent = ({item, index}: {item:ListProps, index:number}) => {
|
||||
setSelected(item.value)
|
||||
tabsOnClick?.(item)
|
||||
const num = index > 0?( index - 1) : 0
|
||||
setTabId(list[num].value.toString())
|
||||
useEffect(() => {
|
||||
const index = list?.findIndex((item) => {
|
||||
return item.value == defaultValue
|
||||
})
|
||||
if (index !== -1) {
|
||||
const num = index > 0 ? (index - 1) : 0
|
||||
setTabId(list[num].value.toString())
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.tabs_main} id="tabs_main_ref">
|
||||
<ScrollView className={styles.tabs_scroll} scrollX scrollWithAnimation={true} scrollIntoView={`tabs_${tabId}`}>
|
||||
<View className={styles.tabs_scroll}>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View key={item.value} id={`tabs_${item.value}`} className={styles.tabs_item} onClick={() => clickEvent({item,index})}>
|
||||
<View className={classnames(styles.tabs_item_con, {[styles.tabs_item_select]:selected == item.value})}>{item.title}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
}, [])
|
||||
|
||||
const clickEvent = ({ item, index }: { item: ListProps; index: number }) => {
|
||||
setSelected(item.value)
|
||||
tabsOnClick?.(item)
|
||||
const num = index > 0 ? (index - 1) : 0
|
||||
setTabId(list[num].value.toString())
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.tabs_main} id="tabs_main_ref">
|
||||
<ScrollView className={styles.tabs_scroll} scrollX scrollWithAnimation scrollIntoView={`tabs_${tabId}`}>
|
||||
<View className={styles.tabs_scroll}>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View key={item.value} id={`tabs_${item.value}`} className={styles.tabs_item} onClick={() => clickEvent({ item, index })}>
|
||||
<View className={classnames(styles.tabs_item_con, { [styles.tabs_item_select]: selected == item.value })}>{item.title}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
import {Textarea, View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useState } from "react";
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { Textarea, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
//其他说明
|
||||
type Param = {
|
||||
title?: string,
|
||||
onChange?: (val: string) => void,
|
||||
placeholder?: string,
|
||||
defaultValue?: string,
|
||||
onlyRead?: false|true
|
||||
// 其他说明
|
||||
interface Param {
|
||||
title?: string
|
||||
onChange?: (val: string) => void
|
||||
placeholder?: string
|
||||
defaultValue?: string
|
||||
onlyRead?: false|true
|
||||
}
|
||||
export default memo(({onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false}:Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
show: false
|
||||
})
|
||||
const getDesc = (value = '') => {
|
||||
let res = value
|
||||
if(value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
export default memo(({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
show: false,
|
||||
})
|
||||
const getDesc = (value = '') => {
|
||||
let res = value
|
||||
if (value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({ ...descData, number: res.length, value: res })
|
||||
onChange?.(res)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const toggleShowRealTextarea = (show) => {
|
||||
setDescData({ ...descData, show })
|
||||
}
|
||||
return (
|
||||
<View className={styles.other_desc}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
<View className={styles.textarea}>
|
||||
{(descData.show && !onlyRead) && <Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={e => getDesc(e.detail.value)}></Textarea>
|
||||
|| <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || placeholder}</View>
|
||||
}
|
||||
setDescData({...descData, number:res.length, value: res})
|
||||
onChange?.(res)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const toggleShowRealTextarea = (show) => {
|
||||
setDescData({...descData, show:show})
|
||||
}
|
||||
return (
|
||||
<View className={styles.other_desc}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
<View className={styles.textarea}>
|
||||
{(descData.show && !onlyRead)&&<Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={(e) => getDesc(e.detail.value)}></Textarea>||
|
||||
<View className={classnames(styles.textarea_con_pretend, descData.value&&styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value||placeholder}</View>
|
||||
}
|
||||
<View className={styles.descDataNum}>{descData.number +'/'+ descData.count}</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
<View className={styles.descDataNum}>{`${descData.number}/${descData.count}`}</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import Taro, { FC } from '@tarojs/taro'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import useUploadCDNImg from '@/use/useUploadImage'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
import { FC, memo, useEffect, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import useUploadCDNImg from '@/use/useUploadImage'
|
||||
import { formatImgUrl } from '@/common/fotmat'
|
||||
|
||||
//图片列表
|
||||
type ImageParam = {
|
||||
// 图片列表
|
||||
interface ImageParam {
|
||||
onChange?: (val: string[]) => void
|
||||
defaultList?: string[]
|
||||
onlyRead?: false | true
|
||||
@@ -20,28 +20,28 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
|
||||
setImageLise(defaultList || [])
|
||||
}, [defaultList])
|
||||
|
||||
//上传图片
|
||||
const uploadImage = async () => {
|
||||
let list: any = await getWxPhoto('after-sale', 5)
|
||||
let images: any[] = []
|
||||
// 上传图片
|
||||
const uploadImage = async() => {
|
||||
const list: any = await getWxPhoto('after-sale', 5)
|
||||
const images: any[] = []
|
||||
list?.map((item) => {
|
||||
images.push(item.url)
|
||||
})
|
||||
setImageLise([...imageList, ...images])
|
||||
}
|
||||
//删除图片
|
||||
// 删除图片
|
||||
const delImage = (index) => {
|
||||
imageList.splice(index, 1)
|
||||
setImageLise(() => [...imageList])
|
||||
}
|
||||
//监听上传的图片变化
|
||||
// 监听上传的图片变化
|
||||
useEffect(() => {
|
||||
onChange?.(imageList)
|
||||
}, [imageList])
|
||||
|
||||
//预览图片
|
||||
// 预览图片
|
||||
const showImage = () => {
|
||||
let list = imageList?.map((item) => {
|
||||
const list = imageList?.map((item) => {
|
||||
return formatImgUrl(item, '!w800')
|
||||
})
|
||||
Taro.previewImage({
|
||||
@@ -54,7 +54,7 @@ const PictureItem: FC<ImageParam> = memo(({ onChange, defaultList, onlyRead = fa
|
||||
<View className={styles.image_main}>
|
||||
{imageList?.map((item, index) => (
|
||||
<View className={styles.ImgItem}>
|
||||
<Image mode='aspectFill' src={formatImgUrl(item)} onClick={showImage}></Image>
|
||||
<Image mode="aspectFill" src={formatImgUrl(item)} onClick={showImage}></Image>
|
||||
{!onlyRead && <View onClick={() => delImage(index)} className={classnames(styles.miconfont_close, 'iconfont icon-qingkong')}></View>}
|
||||
</View>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user