Toggle navigation
Toggle navigation
This project
Loading...
Sign in
罗广聪
/
ProtectGod
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
罗广聪
2017-09-30 17:17:11 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ea465a995ffe543e175165a59c98d41b7852fa36
ea465a99
1 parent
48dfd115
删除
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
9 deletions
src/pages/Customer/edit.js
src/pages/Customer/index.js
src/pages/Customer/edit.js
View file @
ea465a9
...
...
@@ -13,6 +13,7 @@ import {
Modal
,
Alert
,
AlertIOS
,
AsyncStorage
,
TouchableHighlight
}
from
"react-native"
;
import
{
StackNavigator
,
TabNavigator
}
from
"react-navigation"
;
...
...
@@ -23,6 +24,7 @@ export default class Edit extends Component {
super
(
props
);
this
.
state
=
{
USER_ID
:
""
,
IS_LOGIN
:
""
,
customer_id
:
this
.
props
.
navigation
.
state
.
params
.
item
.
id
,
name
:
""
,
age
:
""
,
...
...
@@ -35,12 +37,28 @@ export default class Edit extends Component {
};
}
componentWillMount
()
{
this
.
getAsyncStorage
();
console
.
log
(
"customer_id"
,
this
.
state
.
customer_id
);
console
.
log
(
"回调是啥?"
,
this
.
props
.
navigation
);
this
.
getItemInfo
();
}
componentDidMount
()
{}
getAsyncStorage
()
{
const
that
=
this
;
const
{
USER_ID
,
customersList
}
=
this
.
state
;
AsyncStorage
.
multiGet
([
"IS_LOGIN"
,
"USER_ID"
],
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
err
);
}
that
.
setState
({
IS_LOGIN
:
result
[
0
][
1
],
USER_ID
:
result
[
1
][
1
]
!=
null
?
result
[
1
][
1
]
:
""
});
});
}
getItemInfo
()
{
const
that
=
this
;
const
{
customer_id
}
=
this
.
state
;
...
...
@@ -69,7 +87,7 @@ export default class Edit extends Component {
submit
()
{
const
that
=
this
;
const
{
customer_id
}
=
this
.
state
;
const
{
goBack
}
=
this
.
props
.
navigation
;
const
{
goBack
,
state
}
=
this
.
props
.
navigation
;
post
(
`/test/insurance/contact/update/
${
customer_id
}
`
,
{
...
...
@@ -94,12 +112,15 @@ export default class Edit extends Component {
delete
()
{
const
that
=
this
;
const
{
customer_id
}
=
this
.
state
;
const
{
state
,
goBack
}
=
this
.
props
.
navigation
;
post
(
`/test/insurance/contact/del/
${
customer_id
}
`
,
{},
res
=>
{
console
.
log
(
"修改客户个人信息"
,
res
);
Alert
.
alert
(
"删除成功"
,
null
,
()
=>
goBack
());
Alert
.
alert
(
"删除成功"
,
null
,
()
=>
{
goBack
();
});
},
err
=>
{
Alert
.
alert
(
err
);
...
...
@@ -299,7 +320,23 @@ export default class Edit extends Component {
<
/TouchableOpacity
>
<
TouchableOpacity
onPress
=
{()
=>
{
Alert
.
alert
(
"确认删除该客户?"
,
""
,
[
{
text
:
"取消"
,
onPress
:
()
=>
{}
},
{
text
:
"确认"
,
onPress
:
()
=>
{
this
.
delete
();
}
}
],
{
cancelable
:
false
}
);
}}
style
=
{
styles
.
deleteBtn
}
>
...
...
src/pages/Customer/index.js
View file @
ea465a9
...
...
@@ -33,8 +33,7 @@ export default class Customer extends Component {
this
.
getAsyncStorage
();
}
componentDidMount
()
{
}
componentDidMount
()
{}
getAllPhone
()
{
const
{
navigate
}
=
this
.
props
.
navigation
;
...
...
@@ -58,7 +57,7 @@ export default class Customer extends Component {
getAsyncStorage
()
{
const
that
=
this
;
const
{
USER_ID
,
customersList
}
=
this
.
state
;
const
{
USER_ID
,
customersList
}
=
this
.
state
;
AsyncStorage
.
multiGet
([
"IS_LOGIN"
,
"USER_ID"
],
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -69,19 +68,19 @@ export default class Customer extends Component {
USER_ID
:
result
[
1
][
1
]
!=
null
?
result
[
1
][
1
]
:
""
},
()
=>
{
console
.
log
(
that
.
state
.
USER_ID
)
console
.
log
(
that
.
state
.
USER_ID
)
;
post
(
`/test/insurance/contact/get/
${
that
.
state
.
USER_ID
}
`
,
{},
res
=>
{
console
.
log
(
"通信录返回值"
,
res
);
that
.
setState
({
hasCustomer
:
true
,
customersList
:
res
.
data
.
contacts
})
})
;
},
err
=>
{
console
.
log
(
"通信录err"
,
err
);
Alert
.
alert
(
err
);
}
);
}
...
...
@@ -160,7 +159,11 @@ export default class Customer extends Component {
<
TouchableOpacity
key
=
{
index
}
style
=
{
styles
.
mainCustomerItem
}
onPress
=
{()
=>
navigate
(
"CustomerEdit"
,{
item
:
item
})}
onPress
=
{()
=>
navigate
(
"CustomerEdit"
,
{
item
:
item
,
refreshCallback
:
this
.
getAsyncStorage
})}
>
<
Text
style
=
{
styles
.
mainCustomerItemText
}
>
{
item
.
name
}
<
/Text
>
<
Image
...
...
Please
register
or
login
to post a comment