Showing
1 changed file
with
27 additions
and
5 deletions
| @@ -11,7 +11,8 @@ import { | @@ -11,7 +11,8 @@ import { | ||
| 11 | ListView, | 11 | ListView, |
| 12 | Share, | 12 | Share, |
| 13 | TouchableOpacity, | 13 | TouchableOpacity, |
| 14 | - AsyncStorage | 14 | + AsyncStorage, |
| 15 | + Alert | ||
| 15 | } from "react-native"; | 16 | } from "react-native"; |
| 16 | import { StackNavigator, TabNavigator } from "react-navigation"; | 17 | import { StackNavigator, TabNavigator } from "react-navigation"; |
| 17 | import post from "../utils/fetch"; | 18 | import post from "../utils/fetch"; |
| @@ -56,6 +57,19 @@ export default class ArticleTemplate extends Component { | @@ -56,6 +57,19 @@ export default class ArticleTemplate extends Component { | ||
| 56 | 57 | ||
| 57 | share() { | 58 | share() { |
| 58 | const that = this; | 59 | const that = this; |
| 60 | + AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => { | ||
| 61 | + if (err) { | ||
| 62 | + console.error(err); | ||
| 63 | + } | ||
| 64 | + that.setState( | ||
| 65 | + { | ||
| 66 | + IS_LOGIN: result[0][1], | ||
| 67 | + USER_ID: result[1][1] != null ? result[1][1] : "" | ||
| 68 | + }, | ||
| 69 | + () => { | ||
| 70 | + if (that.state.IS_LOGIN != "yes") { | ||
| 71 | + Alert.alert("请先登录账号"); | ||
| 72 | + } else { | ||
| 59 | Share.share( | 73 | Share.share( |
| 60 | { | 74 | { |
| 61 | title: "保护神", | 75 | title: "保护神", |
| @@ -63,17 +77,25 @@ export default class ArticleTemplate extends Component { | @@ -63,17 +77,25 @@ export default class ArticleTemplate extends Component { | ||
| 63 | url: | 77 | url: |
| 64 | that.state.type == "home" | 78 | that.state.type == "home" |
| 65 | ? `https://devpay.brae.co/insurance.html?uid=${this.state | 79 | ? `https://devpay.brae.co/insurance.html?uid=${this.state |
| 66 | - .USER_ID}&tid=${this.state.id}` | 80 | + .USER_ID}&tid=${that.state.id}` |
| 67 | : `https://devpay.brae.co/insurance.html?uid=${this.state | 81 | : `https://devpay.brae.co/insurance.html?uid=${this.state |
| 68 | - .USER_ID}&sid=${this.state.id}` | 82 | + .USER_ID}&sid=${that.state.id}` |
| 69 | }, | 83 | }, |
| 70 | { | 84 | { |
| 71 | - excludedActivityTypes: ["com.apple.UIKit.activity.PostToTwitter"], | 85 | + excludedActivityTypes: [ |
| 86 | + "com.apple.UIKit.activity.PostToTwitter" | ||
| 87 | + ], | ||
| 72 | tintColor: "green" | 88 | tintColor: "green" |
| 73 | } | 89 | } |
| 74 | ) | 90 | ) |
| 75 | .then(that._showResult) | 91 | .then(that._showResult) |
| 76 | - .catch(error => this.setState({ result: "error: " + error.message })); | 92 | + .catch(error => |
| 93 | + this.setState({ result: "error: " + error.message }) | ||
| 94 | + ); | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + ); | ||
| 98 | + }); | ||
| 77 | } | 99 | } |
| 78 | 100 | ||
| 79 | getAsyncStorage() { | 101 | getAsyncStorage() { |
-
Please register or login to post a comment