From bc9e43f8ea94027f5825b62169c091f24e4368f7 Mon Sep 17 00:00:00 2001
From: Haiyi <1021441632@qq.com>
Date: Tue, 25 Oct 2022 17:39:37 +0800
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=E5=AE=A2=E6=88=B7=E7=AE=A1?=
=?UTF-8?q?=E7=90=8670%?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
iconfont.json | 2 +-
project.private.config.json | 7 ++
src/components/AddressList/index.scss | 107 ++++++++++++------
src/components/AddressList/index.tsx | 30 +++--
src/components/iconfont/iconfont.tsx | 10 +-
src/pages/customerDetails/index.tsx | 66 +++++++----
src/pages/customerEditor/index.tsx | 45 ++++----
.../components/ItemList/index.tsx | 19 ++--
src/pages/customerManagement/index.tsx | 12 +-
src/pages/index/index.tsx | 49 ++++++--
src/pages/searchPage/index.tsx | 45 ++++++--
11 files changed, 270 insertions(+), 122 deletions(-)
diff --git a/iconfont.json b/iconfont.json
index 9be1c6a..8a9d6f7 100644
--- a/iconfont.json
+++ b/iconfont.json
@@ -1,5 +1,5 @@
{
- "symbol_url": "http//at.alicdn.com/t/c/font_3619513_j3kxbij3zac.js",
+ "symbol_url": "http://at.alicdn.com/t/c/font_3619513_kvbg4xjpk7.js",
"save_dir": "./src/components/iconfont",
"trim_icon_prefix": "",
"default_icon_size": 36,
diff --git a/project.private.config.json b/project.private.config.json
index 158d507..719c841 100644
--- a/project.private.config.json
+++ b/project.private.config.json
@@ -183,6 +183,13 @@
"query": "",
"launchMode": "default",
"scene": null
+ },
+ {
+ "name": "",
+ "pathName": "pages/customerDetails/index",
+ "query": "purchaser_id=1674",
+ "launchMode": "default",
+ "scene": null
}
]
}
diff --git a/src/components/AddressList/index.scss b/src/components/AddressList/index.scss
index 1224a8e..1a7e147 100644
--- a/src/components/AddressList/index.scss
+++ b/src/components/AddressList/index.scss
@@ -1,45 +1,55 @@
-.address-scroll-view{
+.address-scroll-view {
height: 100%;
box-sizing: border-box;
position: relative;
- scroll-view{
+
+ scroll-view {
height: 100%;
box-sizing: border-box;
}
- .address-scroll-view-content{
+
+ .address-scroll-view-content {
padding-bottom: 300px;
}
- .address-list{
+
+ .address-list {
width: 704px;
- height: 156px;
+ padding-bottom: 24px;
+ // height: 156px;
background: #ffffff;
border-radius: 20px;
- box-shadow: 2px 4px 12px 0px rgba(0,0,0,0.16);
+ box-shadow: 2px 4px 12px 0px rgba(0, 0, 0, 0.16);
padding: 30px;
box-sizing: border-box;
margin: 18px auto 0;
border: 1px solid #ffffff;
- border: 1px solid rgba(0,0,0,0.16);
+ border: 1px solid rgba(0, 0, 0, 0.16);
}
- .address-active{
+
+ .address-active {
border: 1px solid #68b4ff;
- box-shadow: 0px 0px 10px 0px rgba(0,122,255,0.27);
+ box-shadow: 0px 0px 10px 0px rgba(0, 122, 255, 0.27);
}
- .address-list:first-child{
+
+ .address-list:first-child {
margin-top: 0;
}
- .address-list-last{
+
+ .address-list-last {
margin-bottom: 300px;
}
- .address-user{
+
+ .address-user {
font-size: 28px;
font-family: Microsoft YaHei, Microsoft YaHei-Bold;
font-weight: 700;
text-align: left;
color: #000000;
- display: flex;align-items: center;
+ display: flex;
+ align-items: center;
}
- .address-list-default{
+
+ .address-list-default {
width: 58px;
height: 28px;
background: #cde5ff;
@@ -51,36 +61,45 @@
margin-left: 30px;
}
- .address-list-phone{
- font-size: 24px;
+
+ .address-list-phone {
+ font-size: 28px;
font-weight: 400;
- color: #ababab;
- margin-left: 30px;
+ color: #000000;
+ margin-left: 16px;
+ margin-right: 16px;
}
- .address-edit{
+
+ .address-edit {
padding: 10px;
}
- .address-edit .icon-bianji{
+
+ .address-edit .icon-bianji {
font-size: 40px;
}
- .address-list-info{
- font-size: 24px;
+ .address-list-info {
+ font-size: 28px;
font-weight: 400;
- color: #3c3c3c;
+ color: #000000;
display: flex;
- width: 100%;
+ width: 557px;
}
- .address-list-info view{
- max-width: 60%;
- text-overflow: ellipsis;
- overflow: hidden;white-space: nowrap;
+
+ .address-list-info view {
+ max-width: 557px;
+ // text-overflow: ellipsis;
+ // overflow: hidden;
+ // white-space: nowrap;
}
- .address-list-bottom{
- display: flex;justify-content: space-between;
+
+ .address-list-bottom {
+ display: flex;
+ justify-content: space-between;
margin-top: 18px;
}
- .add-address{
+
+ .add-address {
width: 668px;
height: 82px;
background: #007aff;
@@ -88,11 +107,16 @@
font-size: 32px;
font-weight: 400;
color: #ffffff;
- display: flex;align-items: center;justify-content: center;
- position: absolute;bottom: 100px;left: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ position: absolute;
+ bottom: 100px;
+ left: 50%;
transform: translateX(-50%);
}
- .address-no-data{
+
+ .address-no-data {
font-size: 24px;
font-weight: 400;
text-align: center;
@@ -101,4 +125,19 @@
padding-top: 40%;
box-sizing: border-box;
}
+
+ .line {
+ margin-top: 16px;
+ width: 100%;
+ height: 1px;
+ background: #000000;
+ opacity: 0.1;
+ }
+
+ .bottom-font {
+ margin-top: 16px;
+ font-size: 28px;
+ font-weight: 400;
+ color: #000000;
+ }
}
\ No newline at end of file
diff --git a/src/components/AddressList/index.tsx b/src/components/AddressList/index.tsx
index 47e4018..4da0e8b 100644
--- a/src/components/AddressList/index.tsx
+++ b/src/components/AddressList/index.tsx
@@ -1,6 +1,6 @@
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
-import { memo, useEffect, useState } from "react"
+import { memo, useEffect, useState, forwardRef, useImperativeHandle } from "react"
import "./index.scss"
import { mppurchaseraddresslist } from "@/api/addressList"
import { alert } from "@/common/common"
@@ -18,7 +18,10 @@ interface Params {
}
// 地址列表
-const AddressList = memo((props: Params) => {
+const AddressList = memo(forwardRef((props: Params, AddressListRef) => {
+
+
+
const { addButtonEnabled = true, focusBorderEnabled = false } = props;
const { fetchData, state } = mppurchaseraddresslist()
// 获取数据
@@ -36,14 +39,14 @@ const AddressList = memo((props: Params) => {
})
}
}
- useEffect(() => {
+ useDidShow(() => {
getData();
// 监听刷新
Taro.eventCenter.on("addressList:refresh", getData);
return () => {
Taro.eventCenter.off("addressList:refresh", getData);
}
- }, [])
+ })
// 处理刷新
const [refreshState, setRefreshState] = useState(false);
const handleRefresh = async () => {
@@ -100,6 +103,10 @@ const AddressList = memo((props: Params) => {
}
}
+ useImperativeHandle(AddressListRef, () => ({
+ getData
+ }))
+
return (
@@ -113,25 +120,28 @@ const AddressList = memo((props: Params) => {
handleSelect(item, index)} className={`address-list ${focusId == item.id && 'address-active'}`}>
{item.name}
+ {item.phone}
{
- item.is_default ? 默认 :
- {item.phone.replace(item.phone.substring(3, 7), "****")}
+ item.is_default && 默认
+
}
- {item.province_name + item.city_name + item.district_name}
+ {item.province_name + item.city_name + item.district_name + item.address_detail}
{/* {item.address_detail} */}
- {
+ {/* {
item.is_default && {item.phone.replace(item.phone.substring(3, 7), "****")}
- }
+ } */}
e.stopPropagation()} url={`/pages/addAddress/index?type=edit&id=${item.id}&&purchaser_id=${Number(props.purchaser_id)}`} hoverClass="none" className="address-edit">
{/* */}
+
+ 加工厂:佛山纺织工厂
);
}) :
@@ -142,6 +152,6 @@ const AddressList = memo((props: Params) => {
{addButtonEnabled && 添加收货地址}
)
-})
+}))
export default AddressList;
\ No newline at end of file
diff --git a/src/components/iconfont/iconfont.tsx b/src/components/iconfont/iconfont.tsx
index 3bfbf65..1a2bb9a 100644
--- a/src/components/iconfont/iconfont.tsx
+++ b/src/components/iconfont/iconfont.tsx
@@ -24,7 +24,7 @@ function hex2rgb(hex) {
return "rgb(" + rgb.join(",") + ")";
}
-export type IconNames = 'icon-zhankai1' | 'icon-shouqi1' | 'icon-shouhou1' | 'icon-cangku1' | 'icon-saoma' | 'icon-dizhi1' | 'icon-huodaofukuan' | 'icon-yufukuan1' | 'icon-yue' | 'icon-zidingyi' | 'icon-jinetiaozheng' | 'icon-tuikuan1' | 'icon-zhankai' | 'icon-shouqi' | 'icon-lujing' | 'icon-jizhumima' | 'icon-a-jizhumima' | 'icon-weixindenglu' | 'icon-kehuxinxi' | 'icon-yewuyuanqizi' | 'icon-chakanquanbukehu' | 'icon-biyan' | 'icon-bianji' | 'icon-daikuan' | 'icon-cangku' | 'icon-guanlidingdan' | 'icon-mima' | 'icon-guanbi' | 'icon-jianshao' | 'icon-dingwei' | 'icon-saomiao' | 'icon-peihuo' | 'icon-shaixuan' | 'icon-paiming' | 'icon-shanchusousuoxinxi' | 'icon-shijian' | 'icon-sousuo' | 'icon-shouhou' | 'icon-sousuofanhui' | 'icon-sousuoshanchu' | 'icon-tuikuan' | 'icon-tishi' | 'icon-xianxiahuizong' | 'icon-xinzeng' | 'icon-yonghuming' | 'icon-yanjing' | 'icon-yufukuan' | 'icon-wodekefu' | 'icon-dizhi' | 'icon-shouhouzhongxin' | 'icon-wodeshoucang' | 'icon-shoukuanliebiao' | 'icon-madanguanli' | 'icon-qusechazhao' | 'icon-pandiansaoma' | 'icon-yaoqingma' | 'icon-duizhang' | 'icon-tihuoliebiao' | 'icon-yangpinduibi' | 'icon-yansequyang' | 'icon-fahuoliebiao' | 'icon-yuncangkucun' | 'icon-xiaoshou' | 'icon-qianzhicangkucun' | 'icon-lingquseka' | 'icon-gouwu1' | 'icon-dingdan1' | 'icon-gerenzhongxin1' | 'icon-shouye1' | 'icon-gerenzhongxin' | 'icon-dingdan' | 'icon-shouye' | 'icon-gouwu';
+export type IconNames = 'icon-dianhua' | 'icon-peibu' | 'icon-zhankai1' | 'icon-shouqi1' | 'icon-shouhou1' | 'icon-cangku1' | 'icon-saoma' | 'icon-dizhi1' | 'icon-huodaofukuan' | 'icon-yufukuan1' | 'icon-yue' | 'icon-zidingyi' | 'icon-jinetiaozheng' | 'icon-tuikuan1' | 'icon-zhankai' | 'icon-shouqi' | 'icon-lujing' | 'icon-jizhumima' | 'icon-a-jizhumima' | 'icon-weixindenglu' | 'icon-kehuxinxi' | 'icon-yewuyuanqizi' | 'icon-chakanquanbukehu' | 'icon-biyan' | 'icon-bianji' | 'icon-daikuan' | 'icon-cangku' | 'icon-guanlidingdan' | 'icon-mima' | 'icon-guanbi' | 'icon-jianshao' | 'icon-dingwei' | 'icon-saomiao' | 'icon-peihuo' | 'icon-shaixuan' | 'icon-paiming' | 'icon-shanchusousuoxinxi' | 'icon-shijian' | 'icon-sousuo' | 'icon-shouhou' | 'icon-sousuofanhui' | 'icon-sousuoshanchu' | 'icon-tuikuan' | 'icon-tishi' | 'icon-xianxiahuizong' | 'icon-xinzeng' | 'icon-yonghuming' | 'icon-yanjing' | 'icon-yufukuan' | 'icon-wodekefu' | 'icon-dizhi' | 'icon-shouhouzhongxin' | 'icon-wodeshoucang' | 'icon-shoukuanliebiao' | 'icon-madanguanli' | 'icon-qusechazhao' | 'icon-pandiansaoma' | 'icon-yaoqingma' | 'icon-duizhang' | 'icon-tihuoliebiao' | 'icon-yangpinduibi' | 'icon-yansequyang' | 'icon-fahuoliebiao' | 'icon-yuncangkucun' | 'icon-xiaoshou' | 'icon-qianzhicangkucun' | 'icon-lingquseka' | 'icon-gouwu1' | 'icon-dingdan1' | 'icon-gerenzhongxin1' | 'icon-shouye1' | 'icon-gerenzhongxin' | 'icon-dingdan' | 'icon-shouye' | 'icon-gouwu';
type PropsType = {
name: IconNames;
@@ -82,7 +82,13 @@ const IconFont:FC = ({
className={classnames(icon, customClassName)}
/>
)} */}
- {/* icon-zhankai1 */}
+ {/* icon-dianhua */}
+
+ { name === 'icon-dianhua' && () }
+{/* icon-peibu */}
+
+ { name === 'icon-peibu' && () }
+{/* icon-zhankai1 */}
{ name === 'icon-zhankai1' && () }
{/* icon-shouqi1 */}
diff --git a/src/pages/customerDetails/index.tsx b/src/pages/customerDetails/index.tsx
index a21b6d2..b76d3c9 100644
--- a/src/pages/customerDetails/index.tsx
+++ b/src/pages/customerDetails/index.tsx
@@ -7,19 +7,34 @@ import Popup from '@/components/popup'
import { debounce } from '@/common/util'
import { alert } from '@/common/common'
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
-import { ClientListApi } from '@/api/order'
import Tabs from "./components/tabs"
import Form from "./components/form"
import AddressList from "@/components/AddressList"
import TagPopup from './components/tagPopup';
import { goLink } from '@/common/common'
-
+import { mppurchaser } from '@/api/customer'
export default () => {
const router = useRouter()
const [status, setstatus] = useState(1)
+ useDidShow(() => {
+ getInfo()
+ })
+ const [infoObj, setinfoObj] = useState()
+ const { fetchData: getDesc } = mppurchaser()
+ const getInfo = async () => {
+ Taro.showLoading({
+ title: '请稍等...',
+ mask: true
+ })
+ const res = await getDesc({ id: router.params.purchaser_id })
+ setinfoObj(res.data)
+ Taro.hideLoading()
+ }
+
//顶部栏
+ const AddressListRef = useRef()
const [TarBarList, setTarBarList] = useState([{ id: 1, name: '基础信息', showBorder: true }, { id: 2, name: '收货地址', showBorder: false }])
const handChose = (item) => {
TarBarList.map(it => {
@@ -34,6 +49,11 @@ export default () => {
// setOrderData(() => ({ list: [], total: 0 }))
// setSearchField((val) => ({ ...val, size: 10, status: item.id }))
})
+ if (item.id == 2) {
+ Taro.nextTick(() => {
+ AddressListRef.current?.getData()
+ })
+ }
}
const [showPopup, setshowPopup] = useState(false)
@@ -41,48 +61,48 @@ export default () => {
- 欧
+ {infoObj?.name?.[0]}
- 欧阳斌峰
- 133****7761
+ {infoObj?.name}
+ {infoObj?.phone}
二批
- 二批
+ {infoObj?.sale_user_name}
setshowPopup(true)}>
+
标签
- goLink('/pages/customerEditor/index?id=' + router.params.purchaser_id)}>{'编辑 >'}
+ goLink('/pages/customerEditor/index?id=' + router.params.purchaser_id + '&type=edit')}>{'编辑 >'}
handChose?.(item)}>
{
status === 1 &&
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
{
status === 2 &&
-
+
}
setshowPopup(false)}>
diff --git a/src/pages/customerEditor/index.tsx b/src/pages/customerEditor/index.tsx
index 6fbf159..94c369d 100644
--- a/src/pages/customerEditor/index.tsx
+++ b/src/pages/customerEditor/index.tsx
@@ -2,7 +2,7 @@ import { View, Button } from '@tarojs/components'
import React, { useCallback, memo, useEffect, useMemo, useRef, useState, ReactNode } from 'react'
import styles from "./index.module.scss"
import classnames from "classnames";
-import Taro, { usePullDownRefresh, useRouter, useDidShow } from '@tarojs/taro';
+import Taro, { usePullDownRefresh, useRouter, useDidShow, setNavigationBarTitle } from '@tarojs/taro';
import Popup from '@/components/popup'
import { debounce } from '@/common/util'
import { alert, goLink } from '@/common/common'
@@ -22,26 +22,34 @@ export default () => {
//默认业务员
useDidShow(() => {
- let userInfo = Taro.getStorageSync('userInfo')
+ if (router.params.type === 'add') {
+ setNavigationBarTitle({ title: "新增客户" })
+ } else {
+ getInfo()
+ setNavigationBarTitle({ title: "客户编辑" })
+ }
+ let userInfo = JSON.parse(Taro.getStorageSync('userInfo'))
//获取选择的客户
let pages = Taro.getCurrentPages();
let currPage = pages[pages.length - 1]; // 获取当前页面
- if (currPage.data?.saleuserId) {
+ //判断是否有跳转选择业务员
+ if (currPage.data?.saleuserId && currPage.data?.saleuserId !== '') {
setformData((e) => ({
...e,
- sale_user_id: currPage.data?.saleuserId ? currPage.data?.saleuserId : userInfo?.user_id,
- sale_user_name: currPage.data?.saleuserName ? currPage.data?.saleuserName : userInfo?.user_name,
+ sale_user_id: currPage.data?.saleuserId,
+ sale_user_name: currPage.data?.saleuserName
+ }))
+ }
+ //默认业务员
+ if (currPage.data?.saleuserId == null) {
+ setformData((e) => ({
+ ...e,
+ sale_user_id: userInfo?.user_id,
+ sale_user_name: userInfo?.user_name,
}))
}
})
- useEffect(() => {
- getInfo()
- }, [])
-
-
-
-
const { fetchData: getDesc } = mppurchaser()
const getInfo = async () => {
Taro.showLoading({
@@ -69,6 +77,7 @@ export default () => {
addressName: res.data?.province_name + res.data?.city_name + res.data?.district_name,
address_detail: res.data?.address_detail,
purchaser_type: res.data?.purchaser_type,
+ district_id: res.data?.district_id
// remark: res.data?.remark
})
Taro.hideLoading()
@@ -100,17 +109,17 @@ export default () => {
//客户类型数组
const [list, setlist] = useState([
{
- id: 0,
+ id: 1,
name: '布行',
check: false
},
{
- id: 1,
+ id: 2,
name: '二批',
check: false
},
{
- id: 2,
+ id: 3,
name: '制衣厂',
check: false
},
@@ -147,7 +156,7 @@ export default () => {
})
if (ev.length === 3) {
setShowSiteModal(false)
- setformData((val) => ({ ...val, addressName: ev[0]?.name + ev[1]?.name + ev[2]?.name || '', }))
+ setformData((val) => ({ ...val, addressName: ev[0]?.name + ev[1]?.name + ev[2]?.name || '', district_id: ev[2]?.id }))
}
}
@@ -158,10 +167,8 @@ export default () => {
const isDisabled = useMemo(() => {
let empty: any = null;
if (typeof (formData) == 'undefined') return
- console.log(formData, 12313)
for (const key in formData) {
if (formData.hasOwnProperty(key)) {
- console.log('formData[key]=>', formData[key])
if (formData[key] !== '' && typeof (formData[key]) !== 'undefined') {
empty = false
} else {
@@ -170,7 +177,6 @@ export default () => {
}
}
}
- console.log(empty, 1111)
return empty;
}, [formData])
@@ -188,6 +194,7 @@ export default () => {
address_detail: '',
purchaser_type: '',
remark: '',
+ district_id: ''
})
}
diff --git a/src/pages/customerManagement/components/ItemList/index.tsx b/src/pages/customerManagement/components/ItemList/index.tsx
index e0af1bc..b085f8a 100644
--- a/src/pages/customerManagement/components/ItemList/index.tsx
+++ b/src/pages/customerManagement/components/ItemList/index.tsx
@@ -12,7 +12,8 @@ interface Props {
export default memo((props: Props) => {
- const handPhone = () => {
+ const handPhone = (e) => {
+ e.stopPropagation()
Taro.makePhoneCall({
phoneNumber: props.obj?.phone
})
@@ -28,27 +29,27 @@ export default memo((props: Props) => {
handNav()}>
- 欧
+ {props.obj.name[0]}
- 欧阳斌峰
- 133****7761
+ {props.obj.name}
+ {props.obj.phone}
二批
- 二批
+ {props.obj.sale_user_name}
- handPhone()}>
-
+ handPhone(e)}>
+
联系TA
- 广东省广州市海珠区
- 更新时间:2022-09-20 17:10
+ {props.obj.default_address.province_name + props.obj.default_address.city_name + props.obj.default_address.district_name}
+ 更新时间:{formatDateTime(props.obj.recent_order_time)}
)
diff --git a/src/pages/customerManagement/index.tsx b/src/pages/customerManagement/index.tsx
index f62c2dc..f0fe3ba 100644
--- a/src/pages/customerManagement/index.tsx
+++ b/src/pages/customerManagement/index.tsx
@@ -15,7 +15,7 @@ import Search from '@/components/search'
import ItemLiist from "./components/ItemList"
import InfiniteScroll from '@/components/infiniteScroll'
import { ClientListApi } from '@/api/order'
-
+import { goLink } from '@/common/common'
export default () => {
const [searchField, setSearchField] = useState<{ page: number; size: number; order_no: string }>({
@@ -42,9 +42,9 @@ export default () => {
//输入了搜索关键字
const getSearchData = useCallback((e) => {
- // pageNum.current.page = 1
- // setOrderData(() => ({ list: [], total: 0 }))
- // setSearchField((val) => ({ ...val, order_no: e, size: 10 }))
+ pageNum.current.page = 1
+ setOrderData(() => ({ list: [], total: 0 }))
+ setSearchField((val) => ({ ...val, order_no: e, size: 10 }))
}, [])
//数据加载状态
@@ -92,7 +92,7 @@ export default () => {
- 共 36 个客户
+ 共 {orderData?.total || 0} 个客户
{
- 新建用户
+ goLink('/pages/customerEditor/index?type=add')}>新建用户
)
diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx
index 06f04e1..2f4f097 100644
--- a/src/pages/index/index.tsx
+++ b/src/pages/index/index.tsx
@@ -14,11 +14,28 @@ import { dataLoadingStatus } from '@/common/util'
import Taro, { useDidShow } from '@tarojs/taro'
import { getFilterData } from '@/common/util'
import userInfo from '@/reducers/userInfo'
+import { ClientListApi } from '@/api/order'
export default () => {
+
useEffect(() => {
categoryList()
+ getClient()
}, [])
+ //获取客户
+ const [clienList, setclienList] = useState([])
+ const { fetchData: listFetchData } = ClientListApi()
+ const getClient = async () => {
+ const res = await listFetchData({
+ page: 1, size: 10
+ })
+ setclientObj({
+ clientId: res.data.list.length > 0 ? res.data.list[0]?.id : -1,
+ clientName: res.data.list.length > 0 ? res.data.list[0]?.name : '',
+ })
+ setclienList([...res.data.list])
+ }
+
//获取面料种类
const [kindData, setKindData] = useState({ list: [], defaultId: 0 })
const { fetchData } = kindListApi()
@@ -107,7 +124,6 @@ export default () => {
const [goodObj, setGoodsobj] = useState({})
//点击对应商品显示购物车
const showCart = async (item) => {
- console.log(item, 6666)
setSearchObj((e) => ({ ...e, goodsId: item.id }))
setShowShopCart(true)
setGoodsobj(item)
@@ -200,16 +216,7 @@ export default () => {
clientId: -1,
clientName: ''
})
- useDidShow(() => {
- //获取选择的客户
- let pages = Taro.getCurrentPages();
- let currPage = pages[pages.length - 1]; // 获取当前页面
- setclientObj({
- clientId: currPage.data?.clientId,
- clientName: currPage.data?.clientName,
- })
- })
//加入购物车
const { fetchData: preViewFetch, } = mpshoppingCartproductColorlist()
@@ -289,9 +296,29 @@ export default () => {
useEffect(() => {
setGoodlist(goodList)
- console.log(goodList, 'goodListgoodList')
}, [goodList])
+
+ useDidShow(() => {
+ //获取选择的客户
+ let pages = Taro.getCurrentPages();
+ let currPage = pages[pages.length - 1]; // 获取当前页面
+ //判断是否有跳转选择客户
+ if (currPage.data?.clientId && currPage.data?.clientId !== '') {
+ setclientObj({
+ clientId: currPage.data?.clientId,
+ clientName: currPage.data?.clientName,
+ })
+ }
+ //默认客户
+ if (currPage.data?.clientId == null) {
+ setclientObj({
+ clientId: clienList.length > 0 ? clienList[0]?.id : - 1,
+ clientName: clienList.length > 0 ? clienList[0]?.name : '',
+ })
+ }
+ })
+
return (
// setShowShopCart(showShopCart)}>
diff --git a/src/pages/searchPage/index.tsx b/src/pages/searchPage/index.tsx
index 95a84e8..b2a8b85 100644
--- a/src/pages/searchPage/index.tsx
+++ b/src/pages/searchPage/index.tsx
@@ -16,25 +16,52 @@ import {
mpsearchHistory
} from "@/api/order"
import { getFilterData } from '@/common/util'
-
+import { ClientListApi } from '@/api/order'
export default memo(() => {
+ useEffect(() => {
+ getClient()
+ }, [])
const [clientObj, setclientObj] = useState({
clientId: -1,
clientName: ''
})
- useDidShow(() => {
+ //获取客户
+ const [clienList, setclienList] = useState([])
+ const { fetchData: listFetchData } = ClientListApi()
+ const getClient = async () => {
+ const res = await listFetchData({
+ page: 1, size: 10
+ })
+ setclientObj({
+ clientId: res.data.list.length > 0 ? res.data.list[0]?.id : -1,
+ clientName: res.data.list.length > 0 ? res.data.list[0]?.name : '',
+ })
+ setclienList([...res.data.list])
+ }
+
+ useDidShow(() => {
//获取选择的客户
let pages = Taro.getCurrentPages();
let currPage = pages[pages.length - 1]; // 获取当前页面
- setclientObj({
- clientId: currPage.data?.clientId,
- clientName: currPage.data?.clientName,
- })
+ //判断是否有跳转选择客户
+ if (currPage.data?.clientId && currPage.data?.clientId !== '') {
+ setclientObj({
+ clientId: currPage.data?.clientId,
+ clientName: currPage.data?.clientName,
+ })
+ }
+ //默认客户
+ if (currPage.data?.clientId == null) {
+ setclientObj({
+ clientId: clienList.length > 0 ? clienList[0]?.id : - 1,
+ clientName: clienList.length > 0 ? clienList[0]?.name : '',
+ })
+ }
})
@@ -298,6 +325,9 @@ export default memo(() => {
setGoodlist([...goodList])
}
+ //选择中后的值到输入框
+ const [defaultvalue, setdefaultvalue] = useState('')
+
//点击关键字搜索内容
const handItem = (item) => {
Taro.showLoading({
@@ -311,6 +341,7 @@ export default memo(() => {
Taro.hideLoading()
}
})
+ setdefaultvalue(item.search_key)
}
//点击返回文字
const handBack = () => {
@@ -319,7 +350,7 @@ export default memo(() => {
}
return (
-
+
back()}>取消