diff --git a/.eslintrc b/.eslintrc index a996343..14f6bd7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -14,8 +14,6 @@ "import/no-commonjs": "off", "react/display-name": "off", "no-use-before-define": "off", - "@typescript-eslint/no-use-before-define": [ - "error" - ] + "@typescript-eslint/no-use-before-define": "warn" } } \ No newline at end of file diff --git a/src/components/FromList/index.scss b/src/components/FromList/index.scss index ffed035..5d1d331 100644 --- a/src/components/FromList/index.scss +++ b/src/components/FromList/index.scss @@ -1,13 +1,14 @@ .form-list { display: flex; - justify-content: space-between; margin: 30px 30px 0; + border-bottom: 1px solid rgba(0, 0, 0, 0.1); .form-list-label { font-size: 28px; font-weight: 700; - color: #000000; + color: rgba(0, 0, 0, 0.8); margin-top: 20px; + margin-right: 64px; } .form-list-label-required::before { content: '*'; @@ -58,7 +59,7 @@ // flex: 0 0 auto; min-height: 100%; width: 100%; - color: #000000; + color: rgba(0, 0, 0, 0.8); } .form-list-right textarea { height: 186px; diff --git a/src/components/codeSelect/index.module.scss b/src/components/codeSelect/index.module.scss new file mode 100644 index 0000000..e28734e --- /dev/null +++ b/src/components/codeSelect/index.module.scss @@ -0,0 +1,47 @@ +.code_list { + position: fixed; + font-size: 32px; + color: #fff; + .code_list__card { + position: absolute; + width: 306px; + background-color: #fff; + color: #337fff; + top: -290px; + right: 0; + padding: 20px; + font-size: 28px; + box-sizing: border-box; + border-radius: 16px; + overflow: hidden; + transition: width 1s ease-in-out; + .code_list__card--item { + display: flex; + align-items: center; + &:nth-last-child(n + 2) { + margin-bottom: 48px; + } + text { + margin-left: 16px; + } + } + } + .code_list--text { + width: 100px; + height: 100px; + background-color: #3372ff; + text-align: center; + line-height: 100px; + font-size: 28px; + border-radius: 50%; + } +} +.mask { + position: fixed; + top: 0; + left: 0; + background: #000000; + opacity: 0.08; + width: 100vw; + height: 100vh; +} diff --git a/src/components/codeSelect/index.tsx b/src/components/codeSelect/index.tsx new file mode 100644 index 0000000..e741f87 --- /dev/null +++ b/src/components/codeSelect/index.tsx @@ -0,0 +1,38 @@ +import { MovableView, Text, View } from '@tarojs/components' +import { useState } from 'react' +import classnames from 'classnames' +import IconFont from '../iconfont/iconfont' +import styles from './index.module.scss' +import { goLink } from '@/common/common' + +interface param { + y: number +} +export default ({ y }: param) => { + const [screenHeight, setScreenHeight] = useState({ + customer_service_y: 0, + code_list_y: 0, + }) + const [showCode, setShowCode] = useState(false) + + return (<> + {showCode && setShowCode(!showCode)}>} + + {showCode && + + + 原始码单预览 + + goLink('/pages/codeList/index')}> + + 自定义码单预览 + + + + 编辑自定义码单 + + } + setShowCode(!showCode)}>码单 + + ) +} diff --git a/src/components/moveBtn copy/index.tsx b/src/components/moveBtn copy/index.tsx index 980c0ea..8215048 100644 --- a/src/components/moveBtn copy/index.tsx +++ b/src/components/moveBtn copy/index.tsx @@ -3,13 +3,13 @@ import Taro, { useDidShow, useReady, useRouter } from '@tarojs/taro' import type { ReactElement } from 'react' import { useEffect, useLayoutEffect, useRef, useState } from 'react' import classnames from 'classnames' +import Customer from '../customer' import styles from './index.module.scss' import { GetShoppingCartApi } from '@/api/shopCart' import useCommonData from '@/use/useCommonData' import { useSelector } from '@/reducers/hooks' import { alert } from '@/common/common' import { formatImgUrl } from '@/common/fotmat' -import Customer from '../customer' type ShowStatus = 'shop'|'customer'|'order' interface param { diff --git a/src/components/moveBtn/index.tsx b/src/components/moveBtn/index.tsx index adafd84..497a4b8 100644 --- a/src/components/moveBtn/index.tsx +++ b/src/components/moveBtn/index.tsx @@ -3,15 +3,16 @@ import Taro, { useDidShow, useReady, useRouter } from '@tarojs/taro' import type { ReactElement } from 'react' import { useEffect, useLayoutEffect, useRef, useState } from 'react' import classnames from 'classnames' +import Customer from '../customer' +import CodeSelect from '../codeSelect' import styles from './index.module.scss' import { GetShoppingCartApi } from '@/api/shopCart' import useCommonData from '@/use/useCommonData' import { useSelector } from '@/reducers/hooks' import { alert } from '@/common/common' import { formatImgUrl } from '@/common/fotmat' -import Customer from '../customer' -type ShowStatus = 'shop'|'customer'|'order' +type ShowStatus = 'shop'|'customer'|'order'|'code' interface param { children?: ReactElement | null onShopClick?: () => void @@ -25,7 +26,7 @@ const MoveBtn = ({ children = null, onShopClick, showList = [], messageTitle = ' // 获取购物车数据数量 const { getShopCount, commonData } = useCommonData() - const [screenHeight, setScreenHeight] = useState<{ shop?: number; customer?: number; order?: number }>({ + const [screenHeight, setScreenHeight] = useState<{ shop?: number; customer?: number; order?: number; code?: number }>({ shop: 0, customer: 0, order: 0, @@ -38,7 +39,7 @@ const MoveBtn = ({ children = null, onShopClick, showList = [], messageTitle = ' if (res.screenHeight) { const ratio = 750 / res.screenWidth const num = res.screenHeight * ratio - setScreenHeight(() => ({ shop: num - 460, customer: num - 580, order: num - 700 })) + setScreenHeight(() => ({ shop: num - 460, customer: num - 580, order: num - 700, code: num - 820 })) screenWidthRef.current = res.screenWidth / 2 } setShowMoveBtn(true) @@ -81,7 +82,7 @@ const MoveBtn = ({ children = null, onShopClick, showList = [], messageTitle = ' {commonData.shopCount > 0 && {commonData.shopCount > 99 ? '99+' : commonData.shopCount}} } {onShow('order') && set_customer_service_show(true) } + onClick={() => set_customer_service_show(true)} className={classnames(styles.moveBtn, styles.no_bg_moveBtn)} direction="all" inertia @@ -100,6 +101,7 @@ const MoveBtn = ({ children = null, onShopClick, showList = [], messageTitle = ' > } + {onShow('code') && } ) diff --git a/src/components/nameLabel/index.module.scss b/src/components/nameLabel/index.module.scss new file mode 100644 index 0000000..29f6add --- /dev/null +++ b/src/components/nameLabel/index.module.scss @@ -0,0 +1,9 @@ +.name { + width: 78px; + height: 78px; + background: linear-gradient(337deg, #7bb7ff 0%, #4581ff 100%); + border-radius: 50%; + color: #fff; + text-align: center; + line-height: 78px; +} diff --git a/src/components/nameLabel/index.tsx b/src/components/nameLabel/index.tsx new file mode 100644 index 0000000..a7d65f3 --- /dev/null +++ b/src/components/nameLabel/index.tsx @@ -0,0 +1,14 @@ +import { View } from '@tarojs/components' +import { useMemo } from 'react' +import styles from './index.module.scss' + +interface Param { + name: string +} +export default ({ name = '' }: Param) => { + const nameLabel = useMemo(() => { + if (!name) { return '' } + return name.toString()[0] + }, [name]) + return {nameLabel} +} diff --git a/src/pages/codeList/components/companyItem/index.tsx b/src/pages/codeList/components/companyItem/index.tsx index d62d39e..5202304 100644 --- a/src/pages/codeList/components/companyItem/index.tsx +++ b/src/pages/codeList/components/companyItem/index.tsx @@ -1,13 +1,19 @@ import { Text, View } from '@tarojs/components' import styles from './index.module.scss' import IconFont from '@/components/iconfont/iconfont' +import NameLabel from '@/components/nameLabel' +import { goLink } from '@/common/common' -export default () => { - return - +export interface CompanyParam { + value: { title: string; purchaser_name: string; id: number; phone: string } +} +export default (props: CompanyParam) => { + const { value } = props + return goLink(`/pages/weightListAdd/index?type=edit&id=${value.id}`)}> + - 布郡纺织有限公司 - 杨翰俊 131****4873 + {value?.title } + {`${value?.purchaser_name} ${value?.phone}`} diff --git a/src/pages/codeList/components/companyModel/index.tsx b/src/pages/codeList/components/companyModel/index.tsx index 3fb7abe..2fda695 100644 --- a/src/pages/codeList/components/companyModel/index.tsx +++ b/src/pages/codeList/components/companyModel/index.tsx @@ -1,18 +1,34 @@ import { Text, View } from '@tarojs/components' +import { useEffect, useState } from 'react' +import type { CompanyParam } from '../companyItem' import CompanyItem from '../companyItem' import styles from './index.module.scss' import Search from '@/components/search' +import { weightListApi } from '@/api/weightList' +import { goLink } from '@/common/common' export default () => { + const { fetchData } = weightListApi() + const [list, setList] = useState([]) + useEffect(() => { + (async() => { + const res = await fetchData() + setList(() => res.data?.list) + })() + }, []) return - + {list?.map((item) => { + return + + + })} - 新建抬头 + goLink('/pages/weightListAdd/index?type=add')}>新建抬头 } diff --git a/src/pages/order/components/movableAreaBtn/index copy.tsx b/src/pages/order/components/movableAreaBtn/index copy.tsx new file mode 100644 index 0000000..97c4c9d --- /dev/null +++ b/src/pages/order/components/movableAreaBtn/index copy.tsx @@ -0,0 +1,69 @@ +import { Button, MovableArea, MovableView, Text, View } from '@tarojs/components' +import Taro, { useReady } from '@tarojs/taro' +import type { ReactElement } from 'react' +import { useEffect, useLayoutEffect, useRef, useState } from 'react' +import classnames from 'classnames' +import styles from './index.module.scss' +import IconFont from '@/components/iconfont/iconfont' +import { goLink } from '@/common/common' + +interface param { + children?: ReactElement | null + orderInfo?: any +} +const MovableAreaBtn = ({ children = null, orderInfo }: param) => { + const [screenHeight, setScreenHeight] = useState({ + customer_service_y: 0, + code_list_y: 0, + }) + useEffect(() => { + Taro.nextTick(() => { + const res = Taro.getSystemInfoSync() + if (res.screenHeight) { + const ratio = 750 / res.screenWidth + setScreenHeight(() => ({ customer_service_y: res.screenHeight * ratio - 600, code_list_y: res.screenHeight * ratio - 800 })) + } + }) + }, []) + + const [showCode, setShowCode] = useState(false) + + return ( + + {children} + + + + + + + {showCode && setShowCode(!showCode)}>} + + + {showCode && + + + 原始码单预览 + + goLink('/pages/codeList/index')}> + + 自定义码单预览 + + + + 编辑自定义码单 + + } + setShowCode(!showCode)}>码单 + + + ) +} + +export default MovableAreaBtn diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index cc238f8..ad33c21 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -287,7 +287,7 @@ const Order = () => { [orderDetail], ) return ( - + {(orderDetail?.status != SaleorderstatusWaitingPrePayment.value && ) || ( diff --git a/src/pages/weightList/components/companyItem/index.module.scss b/src/pages/weightList/components/companyItem/index.module.scss index aed10d4..e13df9c 100644 --- a/src/pages/weightList/components/companyItem/index.module.scss +++ b/src/pages/weightList/components/companyItem/index.module.scss @@ -8,15 +8,7 @@ padding: 0 24px; align-items: center; box-sizing: border-box; - .name { - width: 78px; - height: 78px; - background: linear-gradient(337deg, #7bb7ff 0%, #4581ff 100%); - border-radius: 50%; - color: #fff; - text-align: center; - line-height: 78px; - } + .desc { display: flex; flex-direction: column; diff --git a/src/pages/weightList/components/companyItem/index.tsx b/src/pages/weightList/components/companyItem/index.tsx index 71ec425..99d8c15 100644 --- a/src/pages/weightList/components/companyItem/index.tsx +++ b/src/pages/weightList/components/companyItem/index.tsx @@ -2,14 +2,15 @@ import { Text, View } from '@tarojs/components' import styles from './index.module.scss' import IconFont from '@/components/iconfont/iconfont' import { goLink } from '@/common/common' +import NameLabel from '@/components/nameLabel' -interface Param { +export interface CompanyParam { value: { title: string; purchaser_name: string; id: number; phone: string } } -export default (props: Param) => { +export default (props: CompanyParam) => { const { value } = props return goLink(`/pages/weightListAdd/index?type=edit&id=${value.id}`)}> - {value?.title || ''} + {value?.title } {`${value?.purchaser_name} ${value?.phone}`} diff --git a/src/pages/weightListAdd/index.tsx b/src/pages/weightListAdd/index.tsx index 52da835..cb43b64 100644 --- a/src/pages/weightListAdd/index.tsx +++ b/src/pages/weightListAdd/index.tsx @@ -1,7 +1,7 @@ import { Button, Input, Text, Textarea, View } from '@tarojs/components' -import Taro, { setNavigationBarTitle, useRouter } from '@tarojs/taro' +import Taro, { setNavigationBarTitle, showModal, useRouter } from '@tarojs/taro' import { useEffect, useState } from 'react' -import { weightAddApi, weightDetailApi, weightEditApi } from '@/api/weightList' +import { weightAddApi, weightDeleteApi, weightDetailApi, weightEditApi } from '@/api/weightList' import FromList from '@/components/FromList' import { alert, retrieval } from '@/common/common' import './index.scss' @@ -13,7 +13,7 @@ export default () => { useEffect(() => { if (type == 'add') { setNavigationBarTitle({ title: '添加码单信息' }) - } + } else { initalFormData() setNavigationBarTitle({ title: '修改码单信息' }) @@ -81,7 +81,7 @@ export default () => { Taro.eventCenter.trigger('weightList:refresh') Taro.navigateBack() alert.success('保存成功') - } + } else { alert.error(result.msg) } @@ -100,44 +100,78 @@ export default () => { } }, [formData]) + const { fetchData: deleteFetch } = weightDeleteApi() + const handleDelete = () => { + showModal(({ + title: '提示', + content: '是否删除码单?', + async success(ev) { + if (ev.confirm) { + const result = await deleteFetch({ id: formData.id }) + if (result.success) { + alert.success('删除成功') + Taro.eventCenter.trigger('weightList:refresh') + Taro.navigateBack() + } + } + }, + })) + } + const handleUpdate = () => { + if (type === 'add') { + setFormData(() => ({ title: '', purchaser_name: '', phone: '', is_default: false, id: 0 })) + } + else { + handleDelete() + } + } + return ( setFormData({ ...formData, title: ev.detail.value })} value={formData.title} - label="抬头" + label="公司抬头" placeholder="请输入码单显示抬头信息" /> setFormData({ ...formData, purchaser_name: ev.detail.value })} value={formData.purchaser_name} - label="客户" + label="客户名称" placeholder="请输入码单显示客户名称" /> setFormData({ ...formData, phone: ev.detail.value })} value={formData.phone} - label="联系方式" + label="电话号码" placeholder="请输入码单显示联系号码" /> - 设为默认地址 + 设为默认抬头 setFormData({ ...formData, is_default: !formData.is_default })}> - {formData.is_default + {formData.is_default ? ( - ) + ) : ( )} + + + + + + + - ) }