Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wecom-sidebar
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanghuihui
wecom-sidebar
Commits
78a4e998
Commit
78a4e998
authored
Dec 28, 2021
by
Aivs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:接口调试
parent
467f6487
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
201 additions
and
44 deletions
+201
-44
index.ts
src/api/index.ts
+29
-0
home.css
src/css/home.css
+58
-4
Home.tsx
src/pages/Home.tsx
+10
-3
findCustom.tsx
src/pages/findCustom.tsx
+104
-37
No files found.
src/api/index.ts
View file @
78a4e998
...
@@ -67,5 +67,34 @@ export const fetchSignatures = async () => {
...
@@ -67,5 +67,34 @@ export const fetchSignatures = async () => {
// alert(JSON.stringify(response))
// alert(JSON.stringify(response))
return
response
.
data
.
data
;
return
response
.
data
.
data
;
}
}
// 获取客户信息
export
const
getBaseInfoByWxId
=
async
(
params
:
any
)
=>
{
const
response
=
await
api
.
get
(
'/user_center/getBaseInfoByWxId'
,
{
params
})
// alert(JSON.stringify(response))
return
response
.
data
;
}
// 查找用户信息
export
const
selectUserBase
=
async
(
params
:
any
)
=>
{
const
response
=
await
api
.
get
(
'/user_center/selectUserBase'
,
{
params
})
return
response
.
data
;
}
// 关联客户
export
const
linkData
=
async
(
params
:
any
)
=>
{
const
response
=
await
api
.
get
(
'/user_center/linkData'
,
{
params
})
return
response
.
data
;
}
// 取消关联客户
export
const
unlinkData
=
async
(
params
:
any
)
=>
{
const
response
=
await
api
.
get
(
'/user_center/unlinkData'
,
{
params
})
return
response
.
data
;
}
export
default
api
export
default
api
src/css/home.css
View file @
78a4e998
p
{
.flex
p
{
margin
:
0
;
margin
:
0
;
padding
:
0
;
padding
:
0
;
}
}
...
@@ -175,6 +175,60 @@ p{
...
@@ -175,6 +175,60 @@ p{
border
:
1px
solid
#D9D9D9
;
border
:
1px
solid
#D9D9D9
;
}
}
.avatar
{
.avatar
{
width
:
60px
;
display
:
block
;
height
:
60px
;
width
:
56px
;
}
height
:
56px
;
\ No newline at end of file
border-radius
:
4px
;
}
.search
{
padding
:
10px
;
}
.cancel
{
font-size
:
17px
;
font-weight
:
400
;
color
:
#467DB9
;
line-height
:
24px
;
margin-left
:
20px
;
}
.searchInt
{
width
:
80%
!important
;
}
.content
{
padding
:
10px
20px
;
}
.customItem
{
width
:
100%
;
height
:
204px
;
background
:
#FFFFFF
;
box-shadow
:
0px
0px
14px
0px
rgba
(
168
,
168
,
168
,
0.3
);
border-radius
:
6px
;
border
:
1px
solid
#D9D9D9
;
padding
:
20px
;
margin-bottom
:
20px
;
}
.w100
{
width
:
100%
;
align-items
:
flex-start
;
}
.leftItem
{
font-size
:
14px
;
font-weight
:
400
;
color
:
#9B9B9B
;
line-height
:
22px
}
.ant-tabs
>
.ant-tabs-nav
,
.ant-tabs
>
div
>
.ant-tabs-nav
{
padding-left
:
20px
;
}
.mgt
{
margin-top
:
84px
;
}
.customName
{
font-size
:
24px
;
font-weight
:
500
;
color
:
#2D3034
;
line-height
:
34px
;
}
.leftItem
.customFhone
{
font-size
:
17px
;
margin-bottom
:
18px
;
}
src/pages/Home.tsx
View file @
78a4e998
import
React
,
{
FC
,
useEffect
,
useState
}
from
"react"
;
import
React
,
{
FC
,
useEffect
,
useState
}
from
"react"
;
import
Cookies
from
"js-cookie"
;
import
Cookies
from
"js-cookie"
;
import
{
fetchUser
}
from
"../api"
;
import
{
fetchUser
,
getBaseInfoByWxId
}
from
"../api"
;
import
{
Spin
,
Form
,
Input
,
Button
,
Select
,
Radio
,
Tag
}
from
"antd"
;
import
{
Spin
,
Form
,
Input
,
Button
,
Select
,
Radio
,
Tag
}
from
"antd"
;
import
{
SearchOutlined
}
from
'@ant-design/icons'
;
import
{
SearchOutlined
}
from
'@ant-design/icons'
;
import
'./../css/home.css'
import
'./../css/home.css'
...
@@ -114,8 +114,15 @@ const tailLayout = {
...
@@ -114,8 +114,15 @@ const tailLayout = {
const
getExternalUserInfo
=
async
()
=>
{
const
getExternalUserInfo
=
async
()
=>
{
const
res
=
await
jsSdk
.
invoke
<
{
userId
?:
string
}
>
(
'getCurExternalContact'
,
{})
const
res
=
await
jsSdk
.
invoke
<
{
userId
?:
string
}
>
(
'getCurExternalContact'
,
{})
// alert(JSON.stringify(res))
// alert(JSON.stringify(res))
debugger
if
(
!
res
||
!
res
.
userId
)
return
if
(
!
res
||
!
res
.
userId
)
return
let
data
:
any
=
{
wxId
:
res
.
userId
}
const
userInfo
=
await
getBaseInfoByWxId
(
data
)
console
.
log
(
userInfo
.
data
.
userInfo
)
debugger
if
(
userInfo
.
data
.
userInfo
){
setCustomInfo
({...
userInfo
.
data
.
userInfo
})
}
console
.
log
(
'外部联系人 ID'
,
res
.
userId
);
console
.
log
(
'外部联系人 ID'
,
res
.
userId
);
debugger
debugger
...
@@ -172,7 +179,7 @@ const tailLayout = {
...
@@ -172,7 +179,7 @@ const tailLayout = {
<
Form
{
...
layout
}
name=
"control-hooks"
onFinish=
{
onFinish
}
initialValues=
{
customInfo
}
>
<
Form
{
...
layout
}
name=
"control-hooks"
onFinish=
{
onFinish
}
initialValues=
{
customInfo
}
>
{
!
customInfoEdit
?(<
div
className=
"flex spaceBetween showt"
>
{
!
customInfoEdit
?(<
div
className=
"flex spaceBetween showt"
>
<
span
>
{
customInfo
.
realName
||
'-'
}
</
span
>
<
span
>
{
customInfo
.
realName
||
'-'
}
</
span
>
<
div
className=
'grad'
>
{
customInfo
.
account_level
}
</
div
>
<
div
className=
'grad'
>
{
customInfo
.
account_level
||
'重要客户'
}
</
div
>
</
div
>):
(
''
)
}
</
div
>):
(
''
)
}
{
customInfoEdit
?(
{
customInfoEdit
?(
<
Form
.
Item
name=
"realName"
label=
"客户名称"
>
<
Form
.
Item
name=
"realName"
label=
"客户名称"
>
...
...
src/pages/findCustom.tsx
View file @
78a4e998
import
*
as
React
from
'react'
import
*
as
React
from
'react'
import
{
useCallback
,
useState
}
from
'react'
import
{
useCallback
,
useEffect
,
useState
}
from
'react'
import
{
jsSdk
}
from
"../index"
;
import
{
jsSdk
}
from
"../index"
;
import
{
Button
,
Input
,
Table
,
Tabs
,
Space
}
from
"antd"
;
import
{
Button
,
Input
,
Table
,
Tabs
,
Space
}
from
"antd"
;
import
{
SearchOutlined
}
from
'@ant-design/icons'
;
import
{
selectUserBase
,
linkData
,
unlinkData
}
from
"../api"
;
const
{
TextArea
}
=
Input
const
{
TextArea
}
=
Input
const
{
TabPane
}
=
Tabs
;
const
{
TabPane
}
=
Tabs
;
...
@@ -38,33 +40,23 @@ const Actions: React.FC = () => {
...
@@ -38,33 +40,23 @@ const Actions: React.FC = () => {
title
:
'操作'
,
title
:
'操作'
,
align
:
'center'
,
align
:
'center'
,
dataIndex
:
'action'
,
dataIndex
:
'action'
,
render
:
(
text
:
string
,
record
:
any
)
=>
(
//
render: (text:string, record:any) => (
<
Space
size=
"middle"
>
//
<Space size="middle">
{
record
.
link
?
//
{record.link?
<
Button
type=
"primary"
danger
onClick=
{
unlink
.
bind
(
this
,
record
)
}
>
取消关联
</
Button
>:
//
<Button type="primary" danger onClick={unlink.bind(this,record)}>取消关联</Button>:
<
Button
type=
"primary"
onClick=
{
link
.
bind
(
this
,
record
)
}
>
关联
</
Button
>
}
//
<Button type="primary" onClick={link.bind(this,record)}>关联</Button>}
</
Space
>
//
</Space>
),
//
),
}
}
])
])
const
[
list
Data
,
setListData
]
=
useState
<
any
>
([
const
[
list
Query
,
setListQuery
]
=
useState
<
any
>
(
{
{
key
:
'1'
,
mobileOrUserName
:
''
,
name
:
'John Brown'
,
page
:
1
,
avatar
:
'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF'
,
limit
:
10
phone
:
'13323232323'
,
org
:
'行知'
,
link
:
true
},
{
key
:
'2'
,
name
:
'John Brown2'
,
avatar
:
'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF'
,
phone
:
'13323232323'
,
org
:
'行知'
,
link
:
false
}
}
])
)
const
[
listData
,
setListData
]
=
useState
<
any
>
([])
const
[
tabs
]
=
useState
<
any
>
([
'客户档案'
,
'纷享销客'
,
'戈友好物'
,
'戈友圈'
])
const
[
tabs
]
=
useState
<
any
>
([
'客户档案'
,
'纷享销客'
,
'戈友好物'
,
'戈友圈'
])
// const tabIndex ='0'
// const tabIndex ='0'
const
[
tabIndex
,
setTabindex
]
=
useState
(
'0'
)
const
[
tabIndex
,
setTabindex
]
=
useState
(
'0'
)
...
@@ -82,12 +74,31 @@ const Actions: React.FC = () => {
...
@@ -82,12 +74,31 @@ const Actions: React.FC = () => {
// })
// })
}
}
//关联
//关联
const
link
=
(
value
:
any
,
e
:
any
)
=>
{
const
link
=
async
(
value
:
any
,
index
:
any
)
=>
{
console
.
log
(
e
)
const
res
=
await
jsSdk
.
invoke
<
{
userId
?:
string
}
>
(
'getCurExternalContact'
,
{})
if
(
!
res
||
!
res
.
userId
)
return
let
data
:
any
=
{
wxId
:
res
.
userId
,
userId
:
value
.
id
}
const
linkdata
=
await
linkData
(
data
)
if
(
linkdata
.
data
===
'bind OK'
){
let
data
=
listData
data
[
index
].
islink
=
true
setListData
([...
data
])
}
}
}
//取消关联
//取消关联
const
unlink
=
(
value
:
any
,
e
:
any
)
=>
{
const
unlink
=
async
(
value
:
any
,
index
:
any
)
=>
{
console
.
log
(
e
,
value
)
const
res
=
await
jsSdk
.
invoke
<
{
userId
?:
string
}
>
(
'getCurExternalContact'
,
{})
// alert(JSON.stringify(res))
debugger
if
(
!
res
||
!
res
.
userId
)
return
let
data
:
any
=
{
wxId
:
res
.
userId
,
userId
:
value
.
id
}
const
linkdata
=
await
unlinkData
(
data
)
console
.
log
(
linkdata
)
if
(
linkdata
.
data
===
'unlink OK'
){
let
data
=
listData
data
[
index
].
islink
=
false
setListData
([...
data
])
}
}
}
const
sendMsg
=
useCallback
(
async
()
=>
{
const
sendMsg
=
useCallback
(
async
()
=>
{
if
(
!
msg
)
alert
(
'消息不能为空'
)
if
(
!
msg
)
alert
(
'消息不能为空'
)
...
@@ -99,19 +110,75 @@ const Actions: React.FC = () => {
...
@@ -99,19 +110,75 @@ const Actions: React.FC = () => {
}
}
});
});
},
[
msg
])
},
[
msg
])
const
getUserBase
=
async
()
=>
{
const
res
=
await
jsSdk
.
invoke
<
{
userId
?:
string
}
>
(
'getCurExternalContact'
,
{})
if
(
!
res
||
!
res
.
userId
)
return
let
data
:
any
=
{...
listQuery
}
data
.
wxId
=
res
.
userId
const
baseItem
=
await
selectUserBase
(
data
)
console
.
log
(
baseItem
)
if
(
baseItem
.
data
.
data
)
setListData
([...
baseItem
.
data
.
data
])
}
const
inputChange
=
(
e
:
any
)
=>
{
let
Query
=
{...
listQuery
}
Query
.
mobileOrUserName
=
e
.
target
.
value
setListQuery
(
Query
)
}
const
getInput
=
(
e
:
any
)
=>
{
if
(
e
.
key
===
'Enter'
)
{
getUserBase
()
}
}
useEffect
(()
=>
{
getUserBase
()
},
[])
return
(
return
(
<
div
>
<
div
>
<
Tabs
defaultActiveKey=
{
tabIndex
}
onChange=
{
callback
.
bind
(
this
)
}
>
<
div
className=
"flex search"
>
<
Input
className=
'searchInt'
allowClear
placeholder=
"请输入客户信息"
prefix=
{
<
SearchOutlined
/>
}
onChange=
{
inputChange
}
onKeyDown=
{
getInput
}
/>
{
/* <Button size='small'>取消</Button> */
}
<
div
className=
"cancel"
>
取消
</
div
>
</
div
>
<
Tabs
defaultActiveKey=
{
tabIndex
}
onChange=
{
callback
.
bind
(
this
)
}
>
{
{
tabs
.
map
((
item
:
any
,
idx
:
number
)
=>
<
TabPane
tab=
{
item
}
key=
{
idx
}
>
tabs
.
map
((
item
:
any
,
idx
:
number
)
=>
<
Table
columns=
{
columns
}
<
TabPane
tab=
{
item
}
key=
{
idx
}
>
dataSource=
{
listData
}
<
div
className=
"content"
>
scroll=
{
{
x
:
300
}
}
{
listData
.
map
((
list
:
any
,
index
:
number
)
=>
bordered
<
div
className=
"customItem"
>
/>
<
div
className=
"flex spaceBetween w100"
>
</
TabPane
>)
<
div
className=
"leftItem"
>
<
p
className=
'customName'
>
{
list
.
realName
}
</
p
>
<
p
className=
'customFhone'
>
{
list
.
mobileNumber
}
</
p
>
<
p
className=
"detail"
>
{
list
.
sex
===
1
?
'男'
:
'女'
}
</
p
>
<
p
className=
"detail"
>
{
list
.
email
}
</
p
>
<
p
className=
"detail"
>
身份证
</
p
>
<
p
className=
"detail"
>
{
list
.
idNumber
}
</
p
>
</
div
>
<
div
className=
"rightItem"
>
{
list
.
avatar
?<
img
src=
{
list
.
avatar
}
className=
'avatar'
alt=
""
/>:(
<
div
className=
"avatar"
></
div
>
)
}
<
div
className=
"mgt"
>
{
list
.
islink
?
<
Button
type=
"primary"
size=
'small'
danger
onClick=
{
unlink
.
bind
(
this
,
list
,
index
)
}
>
取消关联
</
Button
>:
<
Button
type=
"primary"
size=
'small'
onClick=
{
link
.
bind
(
this
,
list
,
index
)
}
>
关联客户
</
Button
>
}
</
div
>
</
div
>
</
div
>
</
div
>
)
}
</
div
>
{
/* <Table
columns={columns}
dataSource={listData}
scroll={{ x: 300 }}
bordered
/> */
}
</
TabPane
>
)
}
}
</
Tabs
>
</
Tabs
>
</
div
>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment