Ver a proveniência

Merge commit 'refs/tags/jenkins-front-end-screenad-189-v105^{}' into release

tags/jenkins-front-end-screenad-190-v32^0
hupeng há 5 anos
ascendente
cometimento
da7f39d74b
5 ficheiros alterados com 104 adições e 93 eliminações
  1. +104
    -86
      App.js
  2. +0
    -1
      android/app/build.gradle
  3. +0
    -2
      android/app/src/main/java/com/screenad/MainApplication.java
  4. +0
    -2
      android/settings.gradle
  5. +0
    -2
      package.json

+ 104
- 86
App.js Ver ficheiro

@@ -17,31 +17,9 @@ import Package from './package.json'
import HttpUtils from './HttpUtils.js'; import HttpUtils from './HttpUtils.js';
import CodePush from "react-native-code-push"; import CodePush from "react-native-code-push";
import DeviceInfo from "react-native-device-info"; import DeviceInfo from "react-native-device-info";
import RNFetchBlob from 'react-native-fetch-blob';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
import {CachedImage,ImageCache} from "react-native-img-cache";
var testMac = 'FF:FF:FF:FF:FF:FF' var testMac = 'FF:FF:FF:FF:FF:FF'


var contentItemDefault = {
type:0,
subType:0,
qrcode:[],
target:{
coverImg:'',
title:'',
subTitle:'',
priceStr:'',
salePriceStr:'',
remark:'',
}
}

var baseInfoDefault = {
imgUrlH:'',
imgQrcodeWeapp:'',
imgQrcodeWemp:''
}

var curAdIndex = 0; var curAdIndex = 0;
var errorMsg = { var errorMsg = {
ERR_MAC_GET:'设备编号获取错误', ERR_MAC_GET:'设备编号获取错误',
@@ -77,6 +55,8 @@ var animationThemes = [
} }
] ]


var timer = null;

var hbRequestCount var hbRequestCount
var getAdDataCount var getAdDataCount
var pageChangeCount var pageChangeCount
@@ -92,11 +72,20 @@ var heartConfig = {
var requestFailedCount = 0; var requestFailedCount = 0;
var versionInfo = ''; var versionInfo = '';



let codePushOptions = {
//设置检查更新的频率
//ON_APP_RESUME APP恢复到前台的时候
//ON_APP_START APP开启的时候
//MANUAL 手动检查
checkFrequency : CodePush.CheckFrequency.ON_APP_START
};

export default class MyPage extends Component { export default class MyPage extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
baseInfo: baseInfoDefault,
baseInfo: null,
contentItem0:null, contentItem0:null,
contentItem1:null, contentItem1:null,
contentItem2:null, contentItem2:null,
@@ -108,30 +97,32 @@ export default class MyPage extends Component {
receivedBytes:0, receivedBytes:0,
totalBytes:0 totalBytes:0
}, },
updating:true,
macAddress: '', macAddress: '',
versionInfo:'未知' versionInfo:'未知'
}; };
} }


//更新函数 //更新函数
codePushUpdate() {
CodePush.allowRestart();
CodePush.sync(
{ mandatoryInstallMode: CodePush.InstallMode.IMMEDIATE,
installMode: CodePush.InstallMode.IMMEDIATE},
this.codePushStatusDidChange.bind(this),
this.codePushDownloadDidProgress.bind(this)
);

CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING)
.then((metadata: LocalPackage) => {
this.setState({ versionInfo: metadata ? 'b'+NativeModules.BuildConfig.versionCode+"-" + metadata.label : 'b'+ NativeModules.BuildConfig.versionCode});
versionInfo = this.state.versionInfo;
}, (error: any) => {
this.setState({ versionInfo: "Unknown"});
versionInfo = this.state.versionInfo;
});
async codePushUpdate() {

await CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING)
.then((metadata: LocalPackage) => {
this.setState({ versionInfo: metadata ? 'b'+NativeModules.BuildConfig.versionCode+"-" + metadata.label : 'b'+ NativeModules.BuildConfig.versionCode});
versionInfo = this.state.versionInfo;
}, (error: any) => {
this.setState({ versionInfo: "Unknown"});
versionInfo = this.state.versionInfo;
});
await CodePush.disallowRestart();
await CodePush.sync(
{ mandatoryInstallMode: CodePush.InstallMode.IMMEDIATE,
installMode: CodePush.InstallMode.IMMEDIATE},
this.codePushStatusDidChange.bind(this),
this.codePushDownloadDidProgress.bind(this)
);
await CodePush.allowRestart();
} }




@@ -151,22 +142,23 @@ codePushStatusDidChange(syncStatus) {
this.setState({ syncMessage: "安装更新" }); this.setState({ syncMessage: "安装更新" });
break; break;
case CodePush.SyncStatus.UP_TO_DATE: case CodePush.SyncStatus.UP_TO_DATE:
this.setState({ syncMessage: "已更新到最新程序", progress: false });
this.setState({ syncMessage: "已更新到最新程序", updating: false });
break; break;
case CodePush.SyncStatus.UPDATE_IGNORED: case CodePush.SyncStatus.UPDATE_IGNORED:
this.setState({ syncMessage: "更新被取消", progress: false });
this.setState({ syncMessage: "更新被取消", updating: false });
break; break;
case CodePush.SyncStatus.UPDATE_INSTALLED: case CodePush.SyncStatus.UPDATE_INSTALLED:
this.setState({ syncMessage: "更新已安装,重启应用后生效", progress: false });
this.setState({ syncMessage: "更新已安装,重启应用后生效", updating: false });
break; break;
case CodePush.SyncStatus.UNKNOWN_ERROR: case CodePush.SyncStatus.UNKNOWN_ERROR:
this.setState({ syncMessage: "未知错误", progress: false });
this.setState({ syncMessage: "未知错误", updating: false });
break; break;
} }
} }
codePushDownloadDidProgress(progress) { codePushDownloadDidProgress(progress) {
this.setState({ progress }); this.setState({ progress });
} }

// 列表滚动 // 列表滚动
updateContent() { updateContent() {
if (adDataList.length <=0) if (adDataList.length <=0)
@@ -250,7 +242,6 @@ codePushStatusDidChange(syncStatus) {
if (result.code != 200) { if (result.code != 200) {
this.showErrMsg(result.message+'\n'+this.state.macAddress); this.showErrMsg(result.message+'\n'+this.state.macAddress);
} else if (result.data.list) { } else if (result.data.list) {
ImageCache.get().clear();
adDataList = result.data.list; adDataList = result.data.list;
if (this.updateContent()) { if (this.updateContent()) {
this.setState({contentDisplayStatus: true}) this.setState({contentDisplayStatus: true})
@@ -271,7 +262,7 @@ codePushStatusDidChange(syncStatus) {
} }
}) })
} }
getBaseInfo() {
getBaseInfo() {
HttpUtils.get(NativeModules.BuildConfig.apiHost HttpUtils.get(NativeModules.BuildConfig.apiHost
+ 'api/wxDeviceScreenAd/info?deviceId=' + 'api/wxDeviceScreenAd/info?deviceId='
+ encodeURIComponent(this.state.macAddress)) + encodeURIComponent(this.state.macAddress))
@@ -310,7 +301,13 @@ componentDidMount() {
}) })
} }


routine() {
componentWillUnmount(){
if (timer)
clearTimeout(timer)
}


async routine() {
hbRequestCount -=1; hbRequestCount -=1;
getAdDataCount -=1; getAdDataCount -=1;
pageChangeCount -=1; pageChangeCount -=1;
@@ -325,14 +322,16 @@ routine() {
} }


if (pageChangeCount <= 0) { //页面切换间隔 if (pageChangeCount <= 0) { //页面切换间隔
if (this.state.contentDisplayStatus) {
if (this.state.contentDisplayStatus && this.state.baseInfo) {
this.setState({ contentDisplayStatus: false}) this.setState({ contentDisplayStatus: false})
if (this.updateContent()) { if (this.updateContent()) {
this.setState({ contentDisplayStatus: true}) this.setState({ contentDisplayStatus: true})
} }
} else { } else {
this.getBaseInfo()
this.getAdDataList(true)
await this.getBaseInfo()
await this.getAdDataList(true)
getAdDataCount = heartConfig.dataRefreshInterval
hbRequestCount = heartConfig.heartbeatInterval
} }
pageChangeCount = heartConfig.pageChangeInterval pageChangeCount = heartConfig.pageChangeInterval
} }
@@ -340,23 +339,16 @@ routine() {
this.setState({ versionInfo: versionInfo+'[E]'}); this.setState({ versionInfo: versionInfo+'[E]'});
} }


setTimeout(()=>{
timer = setTimeout(()=>{
this.routine(); this.routine();
},1000); },1000);
} }


async startAd() {
this.getBaseInfo()
this.getAdDataList(true)
this.hbRequest()
hbRequestCount = heartConfig.heartbeatInterval;
getAdDataCount =heartConfig.dataRefreshInterval;
pageChangeCount =heartConfig.pageChangeInterval;

setTimeout(()=>{
this.routine();
},1000);
startAd() {
hbRequestCount = 0;
getAdDataCount = 0;
pageChangeCount = 0;
this.routine();
} }


getContentViewItemUplayer(contentItem) { getContentViewItemUplayer(contentItem) {
@@ -410,7 +402,7 @@ getContentViewItem(contentItem, annomation) {
<ImageBackground source={require('./image/item-background.png')} resizeMode='center' style={styles.contentItemDownLayer} > <ImageBackground source={require('./image/item-background.png')} resizeMode='center' style={styles.contentItemDownLayer} >
{/* 列表 */} {/* 列表 */}
<View style={styles.contentItemTop}> <View style={styles.contentItemTop}>
<CachedImage source={{uri: contentItem.coverImg}} resizeMode='cover' style={styles.contentItemTopCoverImg} />
<Image source={{uri: contentItem.coverImg}} resizeMode='cover' style={styles.contentItemTopCoverImg} />
<View style={styles.contentItemTopDetail}> <View style={styles.contentItemTopDetail}>
{/* 券的title */} {/* 券的title */}
<Text style={styles.contentItemTopDetailTitle} numberOfLines={2} ellipsizeMode="tail">{contentItem.target.title}</Text> <Text style={styles.contentItemTopDetailTitle} numberOfLines={2} ellipsizeMode="tail">{contentItem.target.title}</Text>
@@ -427,7 +419,7 @@ getContentViewItem(contentItem, annomation) {
</View> </View>
</View> </View>
{/* <Image source={{uri:'data:image/png;base64,'+contentItem.qrcode}} resizeMode='contain' style={styles.contentItemTopQrcode} /> */} {/* <Image source={{uri:'data:image/png;base64,'+contentItem.qrcode}} resizeMode='contain' style={styles.contentItemTopQrcode} /> */}
<CachedImage source={{uri:contentItem.target.qrCode}} resizeMode='contain' style={styles.contentItemTopQrcode} />
<Image source={{uri:contentItem.target.qrCode}} resizeMode='contain' style={styles.contentItemTopQrcode} />
</View> </View>
{/* 优惠券底部商户名称 */} {/* 优惠券底部商户名称 */}
<View style={styles.contentItemBottom}> <View style={styles.contentItemBottom}>
@@ -469,46 +461,72 @@ getUpdateView() {
); );
} }


render() {

if (this.state.progress) {
return this.getUpdateView();
}

getAdView(){
if (this.state.baseInfo) {
return (
<ImageBackground style={styles.background} resizeMode='center' source={require('./image/background.png')}>
{/* 头部title二维码开始 */}
<View style={styles.title}>
<View style={styles.titleImagePlace}>
<Image source={require('./image/title.png')} resizeMode='center' style={styles.titleImage} />
</View>
<ImageBackground source={require('./image/title-qrcode.png') } resizeMode='center' style={styles.titleQrcodeBonder} >
<View style={styles.titleQrcodePlacehold}></View>
<Image source={{uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.titleQrcode} />
<View style={styles.titleQrcodePlacehold}></View>
</ImageBackground>
</View>
{/* 券列表展示列表开始 */}
{this.getContentView()}
{/* 底部商场信息展示开始 */}
<View style={styles.bottom}>
<View style={styles.bottomLogoBackground}>
<Image source={{ uri: this.state.baseInfo.imgUrlH}} resizeMode='contain' style={styles.bottomLogo} />
</View>
<View style={styles.bottomQrcode1Background}>
<Image source={{ uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.bottomQrcode1} />
<Text style={styles.bottomQrcode1Str}>小程序</Text>
</View>
<View style={styles.bottomQrcode2Background}>
<Image source={{ uri: this.state.baseInfo.imgQrcodeWemp}} resizeMode='center' style={styles.bottomQrcode2} />
<Text style={styles.bottomQrcode1Str}>公众号</Text>
</View>
<Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text>
</View>
</ImageBackground>
);}
else {
return ( return (
<ImageBackground style={styles.background} resizeMode='center' source={require('./image/background.png')}> <ImageBackground style={styles.background} resizeMode='center' source={require('./image/background.png')}>
{/* 头部title二维码开始 */} {/* 头部title二维码开始 */}
<View style={styles.title}> <View style={styles.title}>
<View style={styles.titleImagePlace}>
<Image source={require('./image/title.png')} resizeMode='center' style={styles.titleImage} />
</View>
<ImageBackground source={require('./image/title-qrcode.png') } resizeMode='center' style={styles.titleQrcodeBonder} >
<View style={styles.titleQrcodePlacehold}></View>
<Image source={{uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.titleQrcode} />
<View style={styles.titleQrcodePlacehold}></View>
</ImageBackground>
</View> </View>
{/* 券列表展示列表开始 */} {/* 券列表展示列表开始 */}
{this.getContentView()} {this.getContentView()}
{/* 底部商场信息展示开始 */} {/* 底部商场信息展示开始 */}
<View style={styles.bottom}> <View style={styles.bottom}>
<View style={styles.bottomLogoBackground}> <View style={styles.bottomLogoBackground}>
<Image source={{ uri: this.state.baseInfo.imgUrlH}} resizeMode='contain' style={styles.bottomLogo} />
</View> </View>
<View style={styles.bottomQrcode1Background}> <View style={styles.bottomQrcode1Background}>
<Image source={{ uri: this.state.baseInfo.imgQrcodeWeapp}} resizeMode='center' style={styles.bottomQrcode1} />
<Text style={styles.bottomQrcode1Str}>小程序</Text>
</View> </View>
<View style={styles.bottomQrcode2Background}> <View style={styles.bottomQrcode2Background}>
<Image source={{ uri: this.state.baseInfo.imgQrcodeWemp}} resizeMode='center' style={styles.bottomQrcode2} />
<Text style={styles.bottomQrcode1Str}>公众号</Text>
</View> </View>
<Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text> <Text style={styles.bottomPlacehold}>{this.state.versionInfo}</Text>
</View> </View>
</ImageBackground> </ImageBackground>
); );
} }
}

}

render() {

if (this.state.updating) {
return this.getUpdateView();
}
return this.getAdView();
}
}


const styles = StyleSheet.create({ const styles = StyleSheet.create({
updatePage:{ updatePage:{


+ 0
- 1
android/app/build.gradle Ver ficheiro

@@ -181,7 +181,6 @@ android {
} }


dependencies { dependencies {
implementation project(':react-native-fetch-blob')
implementation project(':react-native-camera') implementation project(':react-native-camera')
implementation project(':react-native-device-info') implementation project(':react-native-device-info')
implementation project(':react-native-code-push') implementation project(':react-native-code-push')


+ 0
- 2
android/app/src/main/java/com/screenad/MainApplication.java Ver ficheiro

@@ -3,7 +3,6 @@ package com.screenad;
import android.app.Application; import android.app.Application;


import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.RNFetchBlob.RNFetchBlobPackage;
import org.reactnative.camera.RNCameraPackage; import org.reactnative.camera.RNCameraPackage;


import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
@@ -38,7 +37,6 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList( return Arrays.<ReactPackage>asList(
new MainReactPackage(), new MainReactPackage(),
new RNFetchBlobPackage(),
new RNCameraPackage(), new RNCameraPackage(),
new RNBuildConfigPackage(), new RNBuildConfigPackage(),
new RNDeviceInfo(), new RNDeviceInfo(),


+ 0
- 2
android/settings.gradle Ver ficheiro

@@ -1,6 +1,4 @@
rootProject.name = 'screenAd' rootProject.name = 'screenAd'
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':react-native-camera' include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android') project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':react-native-device-info' include ':react-native-device-info'


+ 0
- 2
package.json Ver ficheiro

@@ -13,8 +13,6 @@
"react-native-camera": "^1.12.0", "react-native-camera": "^1.12.0",
"react-native-code-push": "^5.6.0", "react-native-code-push": "^5.6.0",
"react-native-device-info": "^2.1.2", "react-native-device-info": "^2.1.2",
"react-native-fetch-blob": "^0.10.8",
"react-native-img-cache": "^1.6.0",
"react-native-swiper": "^1.5.14", "react-native-swiper": "^1.5.14",
"rn-fetch-blob": "^0.10.15" "rn-fetch-blob": "^0.10.15"
}, },


Carregando…
Cancelar
Guardar