罗广聪

发布按钮的条件判断

... ... @@ -115,7 +115,10 @@ const ProtectGod = StackNavigator(
ProductTemplate: { screen: ProductTemplate },
ArticleTemplate: { screen: ArticleTemplate },
Details: { screen: Details },
Release: { screen: Release },
Release: {
screen: Release,
navigationOptions: { headerTitle: "发布" }
},
Discover: { screen: Discover },
AIBegin: {
screen: AIBegin,
... ... @@ -140,7 +143,7 @@ const ProtectGod = StackNavigator(
HealthResult: {
screen: HealthResult,
navigationOptions: { headerTitle: "健康问卷" }
},
}
},
{
navigationOptions: {
... ...
... ... @@ -19,6 +19,8 @@ export default class Home extends Component {
this.state = {
gridData: {
title: ["角色", "建议产品", "建议保额", "保险年限", "缴费期限", "年缴保费"],
actor: "父亲",
age: "42岁",
products: [
{
name: "成人意外险",
... ...
... ... @@ -7,15 +7,30 @@ import {
ScrollView,
TouchableOpacity,
Image,
AsyncStorage,
Alert,
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
import Details from "./details";
export default class InsuranceCircle extends Component {
static navigationOptions = {
// headerRight: this._rightBtn()
}
static navigationOptions = ({ navigation }) => {
const { state, setParams, navigate } = navigation;
// console.log("保圈页面-发布", state);
return {
headerRight: (
<TouchableOpacity
style={{ marginRight: 13 }}
onPress={() => state.params.testLoginAndGo()}
>
<Image
source={require("../../assets/circle/ic_announce.png")}
style={{ width: 19, height: 19 }}
/>
</TouchableOpacity>
)
};
};
constructor(props) {
super(props);
this.state = {
... ... @@ -23,37 +38,68 @@ export default class InsuranceCircle extends Component {
IS_LOGIN: "",
USER_ID: "",
NICKNAME: "",
PROFESSION: "",
PROFESSION: ""
};
}
componentWillMount() {
this.getAsyncStorage();
// this.getAsyncStorage();
this.getArticles();
}
_rightBtn() {
return (
<TouchableOpacity style={{marginRight: 13}} onPress={() => {}}>
<Image source={require("../../assets/circle/ic_announce.png")} style={{width: 19,height: 19}} />
</TouchableOpacity>
)
componentDidMount() {
this.props.navigation.setParams({
testLoginAndGo: this.testLoginAndGo.bind(this)
});
}
testLoginAndGo() {
const that = this;
const { navigate } = this.props.navigation;
console.log("为何是underfined?",this);
// this.getAsyncStorage();
AsyncStorage.multiGet(
["IS_LOGIN", "USER_ID", "NICKNAME", "PROFESSION"],
(err, result) => {
if (err) {
console.error(err);
}
console.log("点击登录后的值", result);
that.setState({
IS_LOGIN: result[0][1],
USER_ID: result[1][1] != null ? result[1][1] : "",
NICKNAME: result[2][1] != null ? result[2][1] : "",
PROFESSION: result[3][1] != null ? result[3][1] : ""
},() => {
if (this.state.IS_LOGIN == 'yes') {
navigate("Release");
} else {
Alert.alert("请先登录账号");
}
});
}
);
// if (this.state.IS_LOGIN == 'yes') {
// navigate("Release");
// } else {
// Alert.alert("请先登录账号");
// }
}
getAsyncStorage() {
const that = this;
AsyncStorage.multiGet(["IS_LOGIN","USER_ID","NICKNAME","PROFESSION"],(err, result) => {
if (err) {
console.error(err);
AsyncStorage.multiGet(
["IS_LOGIN", "USER_ID", "NICKNAME", "PROFESSION"],
(err, result) => {
if (err) {
console.error(err);
}
console.log("点击登录后的值", result);
that.setState({
IS_LOGIN: result[0][1],
USER_ID: result[1][1] != null ? result[1][1] : "",
NICKNAME: result[2][1] != null ? result[2][1] : "",
PROFESSION: result[3][1] != null ? result[3][1] : ""
});
}
console.log("点击登录后的值",result)
that.setState({
IS_LOGIN: result[0][1],
USER_ID: (result[1][1] != null) ? result[1][1] : "",
NICKNAME: (result[2][1] != null) ? result[2][1] : "",
PROFESSION: (result[3][1] != null) ? result[3][1] : "",
})
})
);
}
getArticles() {
... ... @@ -78,7 +124,7 @@ export default class InsuranceCircle extends Component {
alert(respJson.cnmsg);
} else {
that.setState({
ListData: respJson.data.data,
ListData: respJson.data.data
});
console.log("state.ListData", this.state.ListData);
}
... ...