Переглянути джерело

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

Limengbo 5 роки тому
батько
коміт
e34c23565d

+ 7 - 2
android/app/build.gradle

@@ -73,7 +73,7 @@ import com.android.build.OutputFile
  */
 
 project.ext.react = [
-    entryFile: "index.js"
+        entryFile: "index.js"
 ]
 
 apply from: "../../node_modules/react-native/react.gradle"
@@ -117,6 +117,9 @@ android {
             keyPassword MYAPP_RELEASE_KEY_PASSWORD
         }
     }
+    sourceSets.main {
+        jniLibs.srcDir 'libs'
+    }
     splits {
         abi {
             reset()
@@ -137,7 +140,7 @@ android {
         variant.outputs.each { output ->
             // For each separate APK per architecture, set a unique version code as described here:
             // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
-            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
+            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
             def abi = output.getFilter(OutputFile.ABI)
             if (abi != null) {  // null for the universal-debug, universal-release variants
                 output.versionCodeOverride =
@@ -148,6 +151,7 @@ android {
 }
 
 dependencies {
+    implementation project(':react-native-wechat')
     implementation project(':react-native-image-picker')
     implementation project(':react-native-orientation')
     implementation project(':react-native-video')
@@ -156,6 +160,7 @@ dependencies {
     implementation fileTree(dir: "libs", include: ["*.jar"])
     implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
     implementation "com.facebook.react:react-native:+"  // From node_modules
+
 }
 
 // Run this once to be able to run the application with BUCK

+ 3 - 0
android/app/proguard-rules.pro

@@ -15,3 +15,6 @@
 #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
 #   public *;
 #}
+-keep class com.tencent.mm.sdk.** {
+  *;
+}

+ 10 - 0
android/app/src/main/AndroidManifest.xml

@@ -49,6 +49,16 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+        <activity
+            android:name=".wxapi.WXEntryActivity"
+            android:label="@string/app_name"
+            android:exported="true"
+            />
+        <activity
+            android:name=".wxapi.WXPayEntryActivity"
+            android:label="@string/app_name"
+            android:exported="true"
+            />
     </application>
 
 </manifest>

+ 3 - 1
android/app/src/main/java/com/edufound/MainApplication.java

@@ -13,6 +13,7 @@ import com.facebook.soloader.SoLoader;
 import com.github.yamill.orientation.OrientationPackage;
 import com.imagepicker.ImagePickerPackage;
 import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
+import com.theweflex.react.WeChatPackage;
 
 import java.util.Arrays;
 import java.util.List;
@@ -34,7 +35,8 @@ public class MainApplication extends Application implements ReactApplication {
                     new CustomPackage(),
                     new ReactVideoPackage(),
                     new OrientationPackage(),
-                    new ImagePickerPackage()
+                    new ImagePickerPackage(),
+                    new WeChatPackage()
             );
         }
 

+ 2 - 0
android/settings.gradle

@@ -1,4 +1,6 @@
 rootProject.name = 'efunbox_mobile_8'
+include ':react-native-wechat'
+project(':react-native-wechat').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wechat/android')
 include ':react-native-image-picker'
 project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
 include ':react-native-orientation'

+ 28 - 0
ios/efunbox_mobile_8.xcodeproj/project.pbxproj

@@ -44,6 +44,8 @@
 		9CB969D57DBB44968F57230A /* libRCTVideo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D361E312399E41ABA1C9CF77 /* libRCTVideo.a */; };
 		BE43474A85F54112A6EA6E37 /* libRCTOrientation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 977DC2E26A1E45688924C43C /* libRCTOrientation.a */; };
 		E7126B830D54449191E5A4A3 /* libRNImagePicker.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D4C934671D884A4AAA31603D /* libRNImagePicker.a */; };
+		EBD8BAD03DF74C0E96E4D170 /* libRCTWeChat.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F42902D7FF684CA6A48558A1 /* libRCTWeChat.a */; };
+		D3F60855D8FF4C4A9C5D4ACA /* RCTWeChatTests.xctest in Resources */ = {isa = PBXBuildFile; fileRef = 7411A64812B4434AAAD1DBB5 /* RCTWeChatTests.xctest */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -360,6 +362,9 @@
 		977DC2E26A1E45688924C43C /* libRCTOrientation.a */ = {isa = PBXFileReference; name = "libRCTOrientation.a"; path = "libRCTOrientation.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
 		B11B05F3205C483583EB7421 /* RNImagePicker.xcodeproj */ = {isa = PBXFileReference; name = "RNImagePicker.xcodeproj"; path = "../node_modules/react-native-image-picker/ios/RNImagePicker.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
 		D4C934671D884A4AAA31603D /* libRNImagePicker.a */ = {isa = PBXFileReference; name = "libRNImagePicker.a"; path = "libRNImagePicker.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
+		593F0F0596BC4EB7996A9D21 /* RCTWeChat.xcodeproj */ = {isa = PBXFileReference; name = "RCTWeChat.xcodeproj"; path = "../node_modules/react-native-wechat/ios/RCTWeChat.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
+		F42902D7FF684CA6A48558A1 /* libRCTWeChat.a */ = {isa = PBXFileReference; name = "libRCTWeChat.a"; path = "libRCTWeChat.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
+		7411A64812B4434AAAD1DBB5 /* RCTWeChatTests.xctest */ = {isa = PBXFileReference; name = "RCTWeChatTests.xctest"; path = "RCTWeChatTests.xctest"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.cfbundle; explicitFileType = undefined; includeInIndex = 0; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -392,6 +397,8 @@
 				9CB969D57DBB44968F57230A /* libRCTVideo.a in Frameworks */,
 				BE43474A85F54112A6EA6E37 /* libRCTOrientation.a in Frameworks */,
 				E7126B830D54449191E5A4A3 /* libRNImagePicker.a in Frameworks */,
+				EBD8BAD03DF74C0E96E4D170 /* libRCTWeChat.a in Frameworks */,
+				D3F60855D8FF4C4A9C5D4ACA /* RCTWeChatTests.xctest in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -586,6 +593,7 @@
 				C6CF52A56D1E43279554ACA6 /* RCTVideo.xcodeproj */,
 				13F318D169DD4BA79CB54ED5 /* RCTOrientation.xcodeproj */,
 				B11B05F3205C483583EB7421 /* RNImagePicker.xcodeproj */,
+				593F0F0596BC4EB7996A9D21 /* RCTWeChat.xcodeproj */,
 			);
 			name = Libraries;
 			sourceTree = "<group>";
@@ -1218,6 +1226,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1225,6 +1235,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-video\ios/**",
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
+					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 				);
 			};
 			name = Debug;
@@ -1251,6 +1262,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1258,6 +1271,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-video\ios/**",
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
+					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 				);
 			};
 			name = Release;
@@ -1284,6 +1298,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-video\ios/**",
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
+					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 				);
 			};
 			name = Debug;
@@ -1309,6 +1324,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-video\ios/**",
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
+					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 				);
 			};
 			name = Release;
@@ -1343,6 +1359,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1350,6 +1368,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-video\ios/**",
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
+					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 				);
 			};
 			name = Debug;
@@ -1384,6 +1403,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1391,6 +1412,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-video\ios/**",
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
+					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 				);
 			};
 			name = Release;
@@ -1424,6 +1446,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1431,6 +1455,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-video\ios/**",
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
+					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 				);
 			};
 			name = Debug;
@@ -1464,6 +1489,8 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1471,6 +1498,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-video\ios/**",
 					"$(SRCROOT)\..\node_modules\react-native-orientation\iOS\RCTOrientation/**",
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
+					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 				);
 			};
 			name = Release;

+ 13 - 0
package-lock.json

@@ -2391,6 +2391,11 @@
       "resolved": "https://registry.npm.taobao.org/eventemitter3/download/eventemitter3-3.1.0.tgz",
       "integrity": "sha1-CQtNbNvWRe0Qv3UNS1QHlC17oWM="
     },
+    "events": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npm.taobao.org/events/download/events-1.0.2.tgz",
+      "integrity": "sha1-dYSdz+k9EPsFfDAFWv29UdBqjiQ="
+    },
     "exec-sh": {
       "version": "0.2.2",
       "resolved": "https://registry.npm.taobao.org/exec-sh/download/exec-sh-0.2.2.tgz",
@@ -7152,6 +7157,14 @@
         "react-timer-mixin": "^0.13.4"
       }
     },
+    "react-native-wechat": {
+      "version": "1.9.10",
+      "resolved": "https://registry.npm.taobao.org/react-native-wechat/download/react-native-wechat-1.9.10.tgz",
+      "integrity": "sha1-6eJqumDs8X2HihcEcTbLjSIwVrs=",
+      "requires": {
+        "events": "1.0.2"
+      }
+    },
     "react-navigation": {
       "version": "3.9.1",
       "resolved": "https://registry.npm.taobao.org/react-navigation/download/react-navigation-3.9.1.tgz",

+ 1 - 0
package.json

@@ -21,6 +21,7 @@
     "react-native-swiper": "^1.5.14",
     "react-native-video": "^4.4.1",
     "react-native-web": "^0.11.2",
+    "react-native-wechat": "^1.9.10",
     "react-navigation": "^3.9.1"
   },
   "devDependencies": {

+ 4 - 1
pages/components/PersonalInfo.js

@@ -684,9 +684,12 @@ export default class PersonalInfo extends BasePage {
   }
 
   updateUserInfo(formData) {
+    console.log(formData)
     let opts = {
       method: "PUT", //请求方法
-      body: formData //请求体
+      body: {
+        nickName: '测试测试'
+      }
     };
     user.update_UserInfo(opts).then(res => {
       console.log(res);

+ 2 - 2
pages/components/SharedDialog.js

@@ -22,7 +22,7 @@ import {
   TouchableHighlight,
   DeviceEventEmitter
 } from "react-native";
-
+import wechat from "../utils/wechat";
 type Props = {};
 export default class SharedDialog extends Component<Props> {
   state = {
@@ -222,7 +222,7 @@ export default class SharedDialog extends Component<Props> {
   }
 
   wechat() {
-    alert("wechat");
+    wechat.shareToSession("测试1", "测试1111111111111");
   }
   circle() {
     alert("circle");

+ 1 - 1
pages/services/user.js

@@ -4,7 +4,7 @@ import request from "../utils/request";
 
 export default class user {
   static update_UserInfo(opts) {
-    console.log(opts);
+    console.log('opts',opts);
     return request(APIConfig.getUserUrl(``), opts);
   }
 }

+ 48 - 7
pages/utils/request.js

@@ -2,6 +2,7 @@
  * 检查HTTP请求状态
  */
 function checkStatus(response) {
+    console.log('res1',response)
     if (response.status >= 200 && response.status < 300) {
         return response;
     }
@@ -29,8 +30,9 @@ function checkAPIDatas(data) {
 }
 
 function checkAPIError(err) {
-    const code = err.response.code;
-    const status = err.response.status;
+    console.log('err',err)
+    // const code = err.response.code;
+    // const status = err.response.status;
     // const { url, type, oStatus, statusText } = err.response;
     // Message.error(`地址:${url} 类型:${type} 状态:${oStatus} 信息:${statusText}`, 10);
     return {
@@ -47,17 +49,55 @@ function checkAPIError(err) {
  * @return {object}           An object containing either "data" or "err"
  */
 
-const request = async (url, options,callBack) => {
+const request = async (url, options) => {
+    // global.storage.save({
+    //     key:'token',
+    //     data: '123123123123',
+    //     expires: null
+    // });
     if (options) {
         const method = options.method.toUpperCase();
+        // switch(method){
+        //     case 'POST':
+        //             options.headers = {
+        //                 'Accept': 'application/json',
+        //                 'Content-Type': '"Content-Type": "application/json',
+        //                 "uid": 'c2e13090a563447c8744a8c03171d1db',
+        //                 'token': await storage.load({
+        //                     key: 'token'
+        //                 })
+        //             };
+        //         break;
+        //     case 'PUT':
+        //             options.headers = {
+        //                 'Accept': 'application/json',
+        //                 'Content-Type': 'application/x-www-form-urlencoded',
+        //                 "uid": 'c2e13090a563447c8744a8c03171d1db',
+        //                 // 'token': await storage.load({
+        //                 //     key: 'token'
+        //                 // })
+        //             };
+        //         break;
+        //         default:
+        //                 options.headers = {
+        //                     'token': await storage.load({
+        //                         key: 'token'
+        //                     })
+        //                 };
+        //             break;
+        // }
+        const token = await storage.load({
+            key: 'token'
+        });
         if (method === 'POST' || method === 'PATCH' || method === 'DELETE' || method === 'PUT') {
             options.headers = {
+                'Accept': 'application/json',
                 'Content-Type': 'application/json',
-                'token': await storage.load({
-                    key: 'token'
-                })
+                "uid": 'c2e13090a563447c8744a8c03171d1db',
+                'token': token?  token : null
             };
-        } else {
+            options.body = JSON.stringify(options.body)
+        }else {
             options.headers = {
                 'token': await storage.load({
                     key: 'token'
@@ -65,6 +105,7 @@ const request = async (url, options,callBack) => {
             };
         }
     }
+    console.log('options',options)
     return fetch(url, options)
         .then(checkStatus)
         .then(parseJSON)

+ 27 - 0
pages/utils/wechat.js

@@ -0,0 +1,27 @@
+import * as WeChat from "react-native-wechat";
+
+/**
+    public static String WX_APPID = "wx51acc19c8f7a0f6f";
+    public static String WX_SECRET = "e830d45f497025041269ef6221140c3d";
+ */
+WeChat.registerApp("wx51acc19c8f7a0f6f");
+export default class wechat {
+  componentWillMount() {}
+
+  //文字好友分享
+  static shareToSession(text, description) {
+    console.log("123123123123123");
+    WeChat.isWXAppInstalled().then(isInstalled => {
+      if (isInstalled) {
+        WeChat.shareToSession({
+          type: "text",
+          description: "测试微信好友分享的文本内容"
+        }).catch(error => {
+          console.log(error.message);
+        });
+      } else {
+        alert("请安装微信");
+      }
+    });
+  }
+}