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