From f557f688d55230c7f3f45bdedec4be947e192b39 Mon Sep 17 00:00:00 2001 From: hupeng Date: Sat, 23 Mar 2019 17:39:58 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[=E7=BC=96=E8=AF=91][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E7=BB=99release=E6=89=93=E5=8C=85=E6=B7=BB=E5=8A=A0=E7=9B=B8?= =?UTF-8?q?=E5=BA=94=E7=9A=84key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 4 ++++ android/app/screenAd.keystore | Bin 0 -> 2234 bytes android/gradle.properties | 4 ++++ 3 files changed, 8 insertions(+) create mode 100644 android/app/screenAd.keystore diff --git a/android/app/build.gradle b/android/app/build.gradle index 2b56ef0..4be194d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -140,6 +140,10 @@ android { buildConfigField "String", "CODEPUSH_KEY", "\"9rYZYySFD0ryN5wCD9YmjJkT55Kf4ksvOXqog\"" minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + storeFile file(MYAPP_RELEASE_STORE_FILE) + storePassword MYAPP_RELEASE_STORE_PASSWORD + keyAlias MYAPP_RELEASE_KEY_ALIAS + keyPassword MYAPP_RELEASE_KEY_PASSWORD } product.initWith(release) product { diff --git a/android/app/screenAd.keystore b/android/app/screenAd.keystore new file mode 100644 index 0000000000000000000000000000000000000000..198693b557de17435d0bdb09f31428e3161df146 GIT binary patch literal 2234 zcmchYc{J4f8^`B6GsX;egdt0I5rfRwcQuymOHxW0*|#xCmZ%ufG*KgDEa65G*||5% zkZT!HLJCEe#+v2I)>waY?(f{+x#!&ff9G?a&pFTQJbygT`#k6U94sF!gFqlKJAl6e ze$6Y)$A{qQ%?1H4W)xIGAPx|Q1l_~%z_^rP02Dxj`2c_e1SLV|KReNWAGYz#Q>}lO zqza3j7IxA>A<8=vT`TK*(N*bp)~(o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A5}Ut;3{jr)ibT5q{Cg3we!(g zUZk+a`T7!1`f(V!ocS`9S4nSLOyp;HWxWi=%izv+6}Y0qapPAJ{e;DajFq68GYU!a z;~kWIJqqSUhnB>+#OfQ7(+7TodjjCJyn8i@jk~U%`#a70C z9_F6UY7}U~nl{IWzGp>p{kga;S4&?B-$zV=Api&{l*UM6#M!GL&I3IP6?p8h>>(e= zO%}erhhv>I=Pq|StG4z zqkih_MJ6mtb*?d*oB^@X!BMNaZco4sH%{6dMXZ5%_%7&g6y1Daj^HF0`Rypd^VPL3 z^WxFEu63doIOr`2w)vLV@qL4B@jU6!*ZD)RD49}L`08Uimm?cnQdclEb+*527 zQLNd1YbeiE7{xf}?{ezPHNJ;3!`qmGzEPu{LJD8GJ)}6{)`|&@#$r${^Sj@oPqoWS on(@Pz$Fiq}>l}e)hDwok%C*&*S#twwUsmtQxF~wr&(^g60Qn!%`~Uy| literal 0 HcmV?d00001 diff --git a/android/gradle.properties b/android/gradle.properties index 89e0d99..02964c3 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -16,3 +16,7 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true +MYAPP_RELEASE_STORE_FILE=screenAd.keystore +MYAPP_RELEASE_KEY_ALIAS=screenAd +MYAPP_RELEASE_STORE_PASSWORD=formall2019 +MYAPP_RELEASE_KEY_PASSWORD=formall2019 \ No newline at end of file From 97f7fb11843a79bd1176d90c7a1f52d99755c747 Mon Sep 17 00:00:00 2001 From: hupeng Date: Sat, 23 Mar 2019 18:07:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[=E7=BC=96=E8=AF=91][=E4=BF=AE=E6=94=B9]:re?= =?UTF-8?q?lease=E7=BC=96=E8=AF=91=E9=97=AE=E9=A2=98=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 4be194d..2389d50 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -128,6 +128,16 @@ android { include "armeabi-v7a", "x86", "arm64-v8a" } } + signingConfigs { + release { + if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) { + storeFile file(MYAPP_RELEASE_STORE_FILE) + storePassword MYAPP_RELEASE_STORE_PASSWORD + keyAlias MYAPP_RELEASE_KEY_ALIAS + keyPassword MYAPP_RELEASE_KEY_PASSWORD + } + } + } buildTypes { debug { buildConfigField "String", "API_HOST", "\"https://mall.youlane.cn/\"" @@ -140,10 +150,7 @@ android { buildConfigField "String", "CODEPUSH_KEY", "\"9rYZYySFD0ryN5wCD9YmjJkT55Kf4ksvOXqog\"" minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - storeFile file(MYAPP_RELEASE_STORE_FILE) - storePassword MYAPP_RELEASE_STORE_PASSWORD - keyAlias MYAPP_RELEASE_KEY_ALIAS - keyPassword MYAPP_RELEASE_KEY_PASSWORD + signingConfig signingConfigs.release } product.initWith(release) product { From fa199cdb38f7c0e31d52a7bb5974fb5260f59da1 Mon Sep 17 00:00:00 2001 From: hupeng Date: Mon, 25 Mar 2019 11:56:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[=E6=98=BE=E7=A4=BA][=E4=BF=AE=E5=A4=8D]:?= =?UTF-8?q?=E6=97=A0=E5=B9=BF=E5=91=8A=E6=97=B6=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/App.js b/App.js index cd5a098..4bd6627 100644 --- a/App.js +++ b/App.js @@ -237,6 +237,8 @@ codePushStatusDidChange(syncStatus) { this.setState({adDataList : result.data.list}); if (this.updateContent()) { this.setState({contentDisplayStatus: true}) + } else { + this.setState({errorMessage : errorMsg.ERR_NO_DATA}); } } else { this.setState({contentDisplayStatus: false}) From a5f81efe3d6409bbbcc7dca7835b5918c74cbbe7 Mon Sep 17 00:00:00 2001 From: hupeng Date: Fri, 21 Jun 2019 15:04:14 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[=E9=80=9A=E4=BF=A1][=E4=BF=AE=E5=A4=8D]:?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E5=A2=9E=E5=8A=A0=E8=B6=85=E6=97=B6=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.js | 44 +++++++++++++++++++++++++++++++------------- HttpUtils.js | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/App.js b/App.js index 75b2b31..e9145c5 100644 --- a/App.js +++ b/App.js @@ -89,6 +89,9 @@ var heartConfig = { pageChangeInterval:10, } +var requestFailedCount = 0; +var versionInfo = ''; + export default class MyPage extends Component { constructor(props) { super(props); @@ -122,8 +125,10 @@ codePushUpdate() { CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING) .then((metadata: LocalPackage) => { this.setState({ versionInfo: metadata ? metadata.appVersion +'b'+NativeModules.BuildConfig.versionCode+"-" + metadata.label : "Unknown"}); + versionInfo = this.state.versionInfo; }, (error: any) => { this.setState({ versionInfo: "Unknown"}); + versionInfo = this.state.versionInfo; }); } @@ -186,9 +191,10 @@ codePushStatusDidChange(syncStatus) { } hbRequest() { - return HttpUtils.post(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/heartbeat?deviceId=' - +encodeURIComponent(this.state.macAddress), - {version:this.state.versionInfo}) + return HttpUtils.post(NativeModules.BuildConfig.apiHost + + 'api/wxDeviceScreenAd/heartbeat?deviceId=' + + encodeURIComponent(this.state.macAddress), + {version:this.state.versionInfo}) .then(result => { if (result.code == 200) { let config = JSON.parse(result.data.config); @@ -223,7 +229,8 @@ codePushStatusDidChange(syncStatus) { }) .catch(error => { - this.setState({ errorMessage : error.message}); + requestFailedCount++ + this.setState({ versionInfo: versionInfo+`[${requestFailedCount}]`}); }) } @@ -232,9 +239,12 @@ codePushStatusDidChange(syncStatus) { this.setState({errorMessage : errMsg}); } - getAdDataList() { - return HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/list?deviceId='+encodeURIComponent(this.state.macAddress)+'&pageNum=1&pageSize=1000') - .then((result) => { + getAdDataList(first) { + HttpUtils.get(NativeModules.BuildConfig.apiHost + + 'api/wxDeviceScreenAd/list?deviceId=' + + encodeURIComponent(this.state.macAddress) + + '&pageNum=1&pageSize=1000') + .then(result => { if (result.code != 200) { this.showErrMsg(result.message+'\n'+this.state.macAddress); } else if (result.data.list) { @@ -249,11 +259,19 @@ codePushStatusDidChange(syncStatus) { } }) .catch(error => { - this.showErrMsg(error.message); + if (first) { + this.showErrMsg(error.message); + } + else { + requestFailedCount++ + this.setState({ versionInfo: versionInfo+`[${requestFailedCount}]`}); + } }) } getBaseInfo() { - return HttpUtils.get(NativeModules.BuildConfig.apiHost + 'api/wxDeviceScreenAd/info?deviceId='+encodeURIComponent(this.state.macAddress)) + HttpUtils.get(NativeModules.BuildConfig.apiHost + + 'api/wxDeviceScreenAd/info?deviceId=' + + encodeURIComponent(this.state.macAddress)) .then(result => { if (result.code != 200) { this.showErrMsg(result.message+'\n'+this.state.macAddress); @@ -296,7 +314,7 @@ async routine() { try { if (getAdDataCount<=0) { - await this.getAdDataList() + await this.getAdDataList(false) getAdDataCount = heartConfig.dataRefreshInterval } else if (hbRequestCount<=0) { await this.hbRequest() @@ -311,12 +329,12 @@ async routine() { } } else { await this.getBaseInfo() - await this.getAdDataList() + await this.getAdDataList(true) } pageChangeCount = heartConfig.pageChangeInterval } } catch(e){ - this.setState({ versionInfo: this.state.versionInfo+'[E]'}); + this.setState({ versionInfo: versionInfo+'[E]'}); } setTimeout(()=>{ @@ -326,7 +344,7 @@ async routine() { async startAd() { await this.getBaseInfo() - await this.getAdDataList() + await this.getAdDataList(true) await this.hbRequest() hbRequestCount = heartConfig.heartbeatInterval; diff --git a/HttpUtils.js b/HttpUtils.js index 5c8ac5b..be59d85 100644 --- a/HttpUtils.js +++ b/HttpUtils.js @@ -1,16 +1,30 @@ export default class HttpUtil { + /** * 利用 Promise 的 get 方式请求 * @param url * @returns {Promise} */ static get(url) { - return new Promise((resolve, reject) => { + request = new Promise((resolve, reject) => { fetch(url) .then(response => response.json()) .then(result => resolve(result)) - }) + }).catch(e => reject(e.message)); + + const timeoutRequest = new Promise((resolve, reject) => { + setTimeout(reject, 30000, 'Request timeout'); + }); + + return Promise + .race([request, timeoutRequest]) + .then(res => { + return res + }, m => { + throw new Error(m); + }); + } /** @@ -20,7 +34,7 @@ export default class HttpUtil { * @returns {Promise} */ static post(url, params) { - return new Promise((resolve, reject) => { + request = new Promise((resolve, reject) => { fetch(url, { method: 'POST', headers: { @@ -28,10 +42,23 @@ export default class HttpUtil { 'Content-Type': 'application/json' }, body: JSON.stringify(params) - }) - .then(response => response.json()) - .then(result => resolve(result)) - }) + }).then(response => response.json()) + .then(result => resolve(result)) + }).catch(e => reject(e.message)); + + const timeoutRequest = new Promise((resolve, reject) => { + setTimeout(reject, 30000, 'Request timeout'); + }); + + return Promise + .race([request, timeoutRequest]) + .then(res => { + return res + }, m => { + throw new Error(m); + }); + } + }