1.加密crypto-js
安装:npm install crypto-js --save
//DES加密
encryptByDES(message,key) {
var CryptoJS= require("crypto-js");
var keyHex= CryptoJS.enc.Utf8.parse(key);
var encrypted= CryptoJS.DES.encrypt(message, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return encrypted.toString();
}
//转码并且传参(parameter是要加密的内容,'DES_KEY'是加密的密码)
encodeURIComponent(this.encryptByDES(parameter,'DES_KEY'));
2.自定义页面返回样式
static navigationOptions = ({navigation}) => ({
headerTitle: ("返回"),
tabBarVisible: false,
headerLeft:(
<Button transparent style={SettingStyle.Back} onPress{()=>navigation.state.params.navigatePressBack()}>
<Image style={SettingStyle.headerBack} source={require('./../../../../images/header/fanhui.png')} />
</Button>
)
})
componentDidMount () {
this.props.navigation.setParams({navigatePressBack:this.goBack});
}
goBack = () => {
const { goBack,navigate } = this.props.navigation
goBack ()
}