| @@ -1,13 +1,16 @@ | |||||
| import React, { Component } from 'react'; | import React, { Component } from 'react'; | ||||
| import { | |||||
| import { | |||||
| Platform, | |||||
| StyleSheet, | StyleSheet, | ||||
| Text, | Text, | ||||
| View, | View, | ||||
| Image, | Image, | ||||
| ImageBackground, | ImageBackground, | ||||
| NativeModules | |||||
| } from 'react-native'; | } from 'react-native'; | ||||
| //引用插件 | //引用插件 | ||||
| import Package from './package.json' | import Package from './package.json' | ||||
| import HttpUtils from './HttpUtils.js'; | import HttpUtils from './HttpUtils.js'; | ||||
| @@ -16,7 +19,9 @@ import DeviceInfo from "react-native-device-info"; | |||||
| import * as Animatable from 'react-native-animatable'; | import * as Animatable from 'react-native-animatable'; | ||||
| contentItemDefault = { | |||||
| var testMac = '11:AA:33:BB:44' | |||||
| var contentItemDefault = { | |||||
| type:0, | type:0, | ||||
| subType:0, | subType:0, | ||||
| qrcode:[], | qrcode:[], | ||||
| @@ -30,17 +35,15 @@ contentItemDefault = { | |||||
| } | } | ||||
| } | } | ||||
| baseInfoDefault = { | |||||
| var baseInfoDefault = { | |||||
| imgUrlH:'', | imgUrlH:'', | ||||
| imgQrcodeWeapp:'', | imgQrcodeWeapp:'', | ||||
| imgQrcodeWemp:'' | imgQrcodeWemp:'' | ||||
| } | } | ||||
| curAdIndex = 0; | |||||
| testMac = '11:AA:33:BB:44' | |||||
| var curAdIndex = 0; | |||||
| errorMsg = { | |||||
| var errorMsg = { | |||||
| ERR_MAC_GET:'MAC地址获取错误', | ERR_MAC_GET:'MAC地址获取错误', | ||||
| ERR_DATA_GET:'数据获取错误' | ERR_DATA_GET:'数据获取错误' | ||||
| @@ -59,7 +62,7 @@ export default class MyPage extends Component { | |||||
| contentDisplayStatus:false, | contentDisplayStatus:false, | ||||
| syncMessage: "INIT" , | |||||
| syncMessage: "Init" , | |||||
| errorMessage: 'Loading...', | errorMessage: 'Loading...', | ||||
| progress: { | progress: { | ||||
| @@ -67,7 +70,7 @@ export default class MyPage extends Component { | |||||
| totalBytes:0 | totalBytes:0 | ||||
| }, | }, | ||||
| macAddress: '', | macAddress: '', | ||||
| versionInfo:'UNKNOWN' | |||||
| versionInfo:'Unknown' | |||||
| }; | }; | ||||
| } | } | ||||
| @@ -127,7 +130,7 @@ codePushStatusDidChange(syncStatus) { | |||||
| } | } | ||||
| hbRequest() { | hbRequest() { | ||||
| HttpUtils.post('https://mall.youlane.cn/api/wxDeviceScreenAd/heartbeat?deviceId=' | |||||
| HttpUtils.post(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/heartbeat?deviceId=' | |||||
| +encodeURIComponent(this.state.macAddress), | +encodeURIComponent(this.state.macAddress), | ||||
| {version:this.state.versionInfo}) | {version:this.state.versionInfo}) | ||||
| .then(result => { | .then(result => { | ||||
| @@ -137,7 +140,7 @@ codePushStatusDidChange(syncStatus) { | |||||
| } | } | ||||
| getAdDataList() { | getAdDataList() { | ||||
| HttpUtils.get('https://mall.youlane.cn/api/wxDeviceScreenAd/list?deviceId='+encodeURIComponent(this.state.macAddress)+'&pageNum=1&pageSize=1000') | |||||
| HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/list?deviceId='+encodeURIComponent(this.state.macAddress)+'&pageNum=1&pageSize=1000') | |||||
| .then(result => { | .then(result => { | ||||
| if (result.code != 200) { | if (result.code != 200) { | ||||
| this.setState({errorMessage : result.message}); | this.setState({errorMessage : result.message}); | ||||
| @@ -159,7 +162,7 @@ codePushStatusDidChange(syncStatus) { | |||||
| } | } | ||||
| getBaseInfo() { | getBaseInfo() { | ||||
| HttpUtils.get('https://mall.youlane.cn/api/wxDeviceScreenAd/info?deviceId='+encodeURIComponent(this.state.macAddress)) | |||||
| HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/info?deviceId='+encodeURIComponent(this.state.macAddress)) | |||||
| .then(result => { | .then(result => { | ||||
| if (result.code != 200) { | if (result.code != 200) { | ||||
| this.setState({errorMessage : result.message}); | this.setState({errorMessage : result.message}); | ||||
| @@ -131,16 +131,24 @@ android { | |||||
| buildTypes { | buildTypes { | ||||
| debug { | debug { | ||||
| buildConfigField "String", "API_HOST", "\"https://mall.youlane.cn/\"" | buildConfigField "String", "API_HOST", "\"https://mall.youlane.cn/\"" | ||||
| buildConfigField "String", "CODEPUSH_HOST", "\"http://202.165.179.86:3333/\"" | |||||
| buildConfigField "String", "CODEPUSH_HOST", "\"http://mall.youlane.cn:3333/\"" | |||||
| buildConfigField "String", "CODEPUSH_KEY", "\"8snO1yoHlvhEtBjr02zTr3g1comw4ksvOXqog\"" | buildConfigField "String", "CODEPUSH_KEY", "\"8snO1yoHlvhEtBjr02zTr3g1comw4ksvOXqog\"" | ||||
| } | } | ||||
| release { | release { | ||||
| buildConfigField "String", "API_HOST", "\"https://admin.malls.iformall.com/\"" | |||||
| buildConfigField "String", "CODEPUSH_HOST", "\"http://202.165.179.86:3333/\"" | |||||
| buildConfigField "String", "API_HOST", "\"https://admintest.malls.iformall.com/\"" | |||||
| buildConfigField "String", "CODEPUSH_HOST", "\"http://mall.youlane.cn:3333/\"" | |||||
| buildConfigField "String", "CODEPUSH_KEY", "\"9rYZYySFD0ryN5wCD9YmjJkT55Kf4ksvOXqog\"" | buildConfigField "String", "CODEPUSH_KEY", "\"9rYZYySFD0ryN5wCD9YmjJkT55Kf4ksvOXqog\"" | ||||
| minifyEnabled enableProguardInReleaseBuilds | minifyEnabled enableProguardInReleaseBuilds | ||||
| proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" | ||||
| } | } | ||||
| product.initWith(release) | |||||
| product { | |||||
| buildConfigField "String", "API_HOST", "\"https://admin.malls.iformall.com/\"" | |||||
| buildConfigField "String", "CODEPUSH_HOST", "\"http://admin.malls.iformall.com:3333/\"" | |||||
| buildConfigField "String", "CODEPUSH_KEY", "\"9rYZYySFD0ryN5wCD9YmjJkT55Kf4ksvOXqog\"" | |||||
| matchingFallbacks = ['product', 'release'] | |||||
| } | |||||
| } | } | ||||
| // applicationVariants are e.g. debug, release | // applicationVariants are e.g. debug, release | ||||
| applicationVariants.all { variant -> | applicationVariants.all { variant -> | ||||
| @@ -4,6 +4,9 @@ import android.app.Application; | |||||
| import com.facebook.react.ReactApplication; | import com.facebook.react.ReactApplication; | ||||
| import org.reactnative.camera.RNCameraPackage; | import org.reactnative.camera.RNCameraPackage; | ||||
| import com.facebook.react.bridge.ReactApplicationContext; | |||||
| import com.facebook.react.bridge.ReactContextBaseJavaModule; | |||||
| import com.learnium.RNDeviceInfo.RNDeviceInfo; | import com.learnium.RNDeviceInfo.RNDeviceInfo; | ||||
| import com.microsoft.codepush.react.CodePush; | import com.microsoft.codepush.react.CodePush; | ||||
| import com.facebook.react.ReactNativeHost; | import com.facebook.react.ReactNativeHost; | ||||
| @@ -14,6 +17,8 @@ import com.facebook.soloader.SoLoader; | |||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import java.util.List; | import java.util.List; | ||||
| public class MainApplication extends Application implements ReactApplication { | public class MainApplication extends Application implements ReactApplication { | ||||
| private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { | ||||
| @@ -31,14 +36,16 @@ public class MainApplication extends Application implements ReactApplication { | |||||
| @Override | @Override | ||||
| protected List<ReactPackage> getPackages() { | protected List<ReactPackage> getPackages() { | ||||
| return Arrays.<ReactPackage>asList( | return Arrays.<ReactPackage>asList( | ||||
| new MainReactPackage(), | |||||
| new RNCameraPackage(), | |||||
| new RNDeviceInfo(), new CodePush( | |||||
| BuildConfig.CODEPUSH_KEY, | |||||
| getApplicationContext(), | |||||
| BuildConfig.DEBUG, | |||||
| BuildConfig.CODEPUSH_HOST | |||||
| ) | |||||
| new MainReactPackage(), | |||||
| new RNCameraPackage(), | |||||
| new RNBuildConfigPackage(), | |||||
| new RNDeviceInfo(), | |||||
| new CodePush( | |||||
| BuildConfig.CODEPUSH_KEY, | |||||
| getApplicationContext(), | |||||
| BuildConfig.DEBUG, | |||||
| BuildConfig.CODEPUSH_HOST | |||||
| ) | |||||
| ); | ); | ||||
| } | } | ||||
| @@ -0,0 +1,36 @@ | |||||
| package com.screenad; | |||||
| import android.content.pm.PackageManager; | |||||
| import com.facebook.react.bridge.ReactApplicationContext; | |||||
| import com.facebook.react.bridge.ReactContextBaseJavaModule; | |||||
| import com.facebook.react.bridge.ReactMethod; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| import javax.annotation.Nullable; | |||||
| public class RNBuildConfig extends ReactContextBaseJavaModule { | |||||
| public RNBuildConfig(ReactApplicationContext reactContext) { | |||||
| super(reactContext); | |||||
| } | |||||
| @Override | |||||
| public String getName() { | |||||
| return "BuildConfig"; | |||||
| } | |||||
| @Override | |||||
| public @Nullable | |||||
| Map<String, Object> getConstants() { | |||||
| HashMap<String, Object> constants = new HashMap<String, Object>(); | |||||
| constants.put("apiHost", BuildConfig.API_HOST); | |||||
| constants.put("buildType", BuildConfig.BUILD_TYPE); | |||||
| constants.put("versionCode", BuildConfig.VERSION_CODE); | |||||
| constants.put("versionName", BuildConfig.VERSION_NAME); | |||||
| return constants; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,31 @@ | |||||
| package com.screenad; | |||||
| import com.facebook.react.ReactPackage; | |||||
| import com.facebook.react.bridge.JavaScriptModule; | |||||
| import com.facebook.react.bridge.NativeModule; | |||||
| import com.facebook.react.bridge.ReactApplicationContext; | |||||
| import com.facebook.react.uimanager.ViewManager; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Collections; | |||||
| import java.util.List; | |||||
| public class RNBuildConfigPackage implements ReactPackage { | |||||
| @Override | |||||
| public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | |||||
| return Collections.emptyList(); | |||||
| } | |||||
| @Override | |||||
| public List<NativeModule> createNativeModules( | |||||
| ReactApplicationContext reactContext) { | |||||
| List<NativeModule> modules = new ArrayList<>(); | |||||
| modules.add(new RNBuildConfig(reactContext)); | |||||
| return modules; | |||||
| } | |||||
| // Deprecated RN 0.47 | |||||
| public List<Class<? extends JavaScriptModule>> createJSModules() { | |||||
| return Collections.emptyList(); | |||||
| } | |||||
| } | |||||