Sfoglia il codice sorgente

Merge branch 'master' of http://gogs.efunbox.cn/Rorschach/efunbox-mobile-8

Rorschach 5 anni fa
parent
commit
8f5c90f911
2 ha cambiato i file con 53 aggiunte e 1 eliminazioni
  1. 2 1
      pages/components/PersonalInfo.js
  2. 51 0
      pages/utils/asyncStorage.js

+ 2 - 1
pages/components/PersonalInfo.js

@@ -31,6 +31,7 @@ import GradeSelectionModal from "./GradeSelectionModal";
 import Header from "./Header";
 import PersonalInfoDialog from "./PersonalInfoDialog";
 import { NavigationActions, StackActions } from "react-navigation";
+import asyncStorage from "../utils/asyncStorage";
 type Props = {};
 
 export default class PersonalInfo extends BasePage {
@@ -110,7 +111,6 @@ export default class PersonalInfo extends BasePage {
                   style={{ flex: 4 }}
                   width={this.getWindowWidth()}
                   title="个人信息"
-                  backPress={() => this.goBack()}
                   lefttype={2}
                   righttype={0}
                   textcolor={"white"}
@@ -625,6 +625,7 @@ export default class PersonalInfo extends BasePage {
       case 4:
         this.dialog.setInfo("我的学校", "学校名称");
         this.dialog.setModalVisible(true, 2);
+
         break;
       case 5:
         this.gradeselectionModal.setModalVisible(true);

+ 51 - 0
pages/utils/asyncStorage.js

@@ -0,0 +1,51 @@
+import { AsyncStorage } from "react-native";
+export default class DeviceStorage {
+  static get(key) {
+    return AsyncStorage.getItem(key).then(value => {
+      const jsonValue = JSON.parse(value);
+      return jsonValue;
+    });
+  }
+  static save(key, value) {
+    return AsyncStorage.setItem(key, JSON.stringify(value));
+  }
+  static update(key, value) {
+    return DeviceStorage.get(key).then(item => {
+      value =
+        typeof value === "string" ? value : Object.assign({}, item, value);
+      return AsyncStorage.setItem(key, JSON.stringify(value));
+    });
+  }
+  static delete(key) {
+    return AsyncStorage.removeItem(key);
+  }
+}
+
+/**
+    使用方法:
+    1.先引用asyncStorage.js文件
+    2.调用方法
+    
+
+
+    //获取
+     asyncStorage.get("birthday").then(birthday => {
+          if (birthday == null || birthday == "") {
+            consle.log("birthday is null");
+          } else {
+            alert("birthday:" + birthday);
+          }
+        });
+
+
+    //存储
+      asyncStorage.save("birthday", this.state.birthday_time);
+
+
+    //更新
+    asyncStorage.update("birthday","this.state.birthday_time");
+
+    //删除
+    asyncStorage.delete("birthday");
+
+ */