| @@ -47,7 +47,8 @@ var errorMsg = { | |||||
| ERR_MAC_GET:'设备编号获取错误', | ERR_MAC_GET:'设备编号获取错误', | ||||
| ERR_START_AD:'广告播放系统错误', | ERR_START_AD:'广告播放系统错误', | ||||
| ERR_DATA_GET:'广告数据获取错误', | ERR_DATA_GET:'广告数据获取错误', | ||||
| ERR_HEARTBEAT:'设备心跳数据错误' | |||||
| ERR_HEARTBEAT:'设备心跳数据错误', | |||||
| ERR_NO_DATA:'暂无优惠信息' | |||||
| } | } | ||||
| var animationThemes = [ | var animationThemes = [ | ||||
| // 滑入 | // 滑入 | ||||
| @@ -223,49 +224,48 @@ codePushStatusDidChange(syncStatus) { | |||||
| }) | }) | ||||
| .catch(error => { | .catch(error => { | ||||
| this.setState({ errorMessage : error}); | |||||
| this.setState({ errorMessage : error.message}); | |||||
| }) | }) | ||||
| } | } | ||||
| showErrMsg(errMsg) { | |||||
| this.setState({contentDisplayStatus: false}) | |||||
| this.setState({errorMessage : errMsg}); | |||||
| } | |||||
| getAdDataList() { | getAdDataList() { | ||||
| HttpUtils.get(NativeModules.BuildConfig.apiHost + '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({contentDisplayStatus: false}) | |||||
| this.setState({errorMessage : result.message+'\n'+this.state.macAddress}); | |||||
| this.showErrMsg(result.message+'\n'+this.state.macAddress); | |||||
| } else if (result.data.list) { | } else if (result.data.list) { | ||||
| this.setState({adDataList : result.data.list}); | this.setState({adDataList : result.data.list}); | ||||
| if (this.updateContent()) { | if (this.updateContent()) { | ||||
| this.setState({contentDisplayStatus: true}) | this.setState({contentDisplayStatus: true}) | ||||
| } else { | } else { | ||||
| this.setState({errorMessage : errorMsg.ERR_NO_DATA}); | |||||
| this.showErrMsg(errorMsg.ERR_NO_DATA); | |||||
| } | } | ||||
| } else { | } else { | ||||
| this.setState({contentDisplayStatus: false}) | |||||
| this.setState({errorMessage : errorMsg.ERR_DATA_GET}); | |||||
| this.showErrMsg(errorMsg.ERR_DATA_GET); | |||||
| } | } | ||||
| }) | }) | ||||
| .catch(error => { | .catch(error => { | ||||
| this.setState({contentDisplayStatus: false}) | |||||
| this.setState({errorMessage : error.message}); | |||||
| this.showErrMsg(error.message); | |||||
| }) | }) | ||||
| } | } | ||||
| getBaseInfo() { | getBaseInfo() { | ||||
| 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 => { | .then(result => { | ||||
| if (result.code != 200) { | if (result.code != 200) { | ||||
| this.setState({contentDisplayStatus: false}) | |||||
| this.setState({errorMessage : result.message+'\n'+this.state.macAddress}); | |||||
| this.showErrMsg(result.message+'\n'+this.state.macAddress); | |||||
| } else if (result.data) { | } else if (result.data) { | ||||
| this.setState({baseInfo:result.data}); | this.setState({baseInfo:result.data}); | ||||
| } else { | } else { | ||||
| this.setState({contentDisplayStatus: false}) | |||||
| this.setState({errorMessage : errorMsg.ERR_DATA_GET}); | |||||
| this.showErrMsg(errorMsg.ERR_DATA_GET); | |||||
| } | } | ||||
| }) | }) | ||||
| .catch(error => { | .catch(error => { | ||||
| this.setState({contentDisplayStatus: false}) | |||||
| this.setState({errorMessage : error.message}); | |||||
| this.showErrMsg(error.message); | |||||
| }) | }) | ||||
| } | } | ||||
| @@ -279,16 +279,14 @@ componentDidMount() { | |||||
| this.setState({macAddress : this.testMac}) | this.setState({macAddress : this.testMac}) | ||||
| this.startAd() | this.startAd() | ||||
| } else { | } else { | ||||
| this.setState({ contentDisplayStatus: false}) | |||||
| this.setState({ errorMessage : errorMsg.ERR_MAC_GET}); | |||||
| this.showErrMsg(errorMsg.ERR_MAC_GET); | |||||
| } | } | ||||
| } else { | } else { | ||||
| this.setState({macAddress : mac}) | this.setState({macAddress : mac}) | ||||
| this.startAd() | this.startAd() | ||||
| } | } | ||||
| }).catch(e => { | }).catch(e => { | ||||
| this.setState({ contentDisplayStatus: false}) | |||||
| this.setState({ errorMessage : errorMsg.ERR_START_AD}); | |||||
| this.showErrMsg(errorMsg.ERR_START_AD); | |||||
| }) | }) | ||||
| } | } | ||||