diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 0000000..635452e --- /dev/null +++ b/.flowconfig @@ -0,0 +1,51 @@ +[ignore] + +# We fork some components by platform. +.*/*.web.js +.*/*.android.js + +# Some modules have their own node_modules with overlap +.*/node_modules/node-haste/.* + +# Ignore react-tools where there are overlaps, but don't ignore anything that +# react-native relies on +.*/node_modules/react-tools/src/React.js +.*/node_modules/react-tools/src/renderers/shared/event/EventPropagators.js +.*/node_modules/react-tools/src/renderers/shared/event/eventPlugins/ResponderEventPlugin.js +.*/node_modules/react-tools/src/shared/vendor/core/ExecutionEnvironment.js + +# Ignore commoner tests +.*/node_modules/commoner/test/.* + +# See https://github.com/facebook/flow/issues/442 +.*/react-tools/node_modules/commoner/lib/reader.js + +# Ignore jest +.*/node_modules/jest-cli/.* + +# Ignore Website +.*/website/.* + +[include] + +[libs] +node_modules/react-native/Libraries/react-native/react-native-interface.js + +[options] +module.system=haste + +munge_underscores=true + +module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' +module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub' + +suppress_type=$FlowIssue +suppress_type=$FlowFixMe +suppress_type=$FixMe + +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-6]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-6]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy + +[version] +0.16.0 diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..9b54d3e --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +bqseller \ No newline at end of file diff --git a/.idea/bqseller.iml b/.idea/bqseller.iml new file mode 100644 index 0000000..79194de --- /dev/null +++ b/.idea/bqseller.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..a817d12 --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/bqseller_node_modules.xml b/.idea/libraries/bqseller_node_modules.xml new file mode 100644 index 0000000..fd41df9 --- /dev/null +++ b/.idea/libraries/bqseller_node_modules.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..19f74da --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fa58b8f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..0af709c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1446453219318 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.watchmanconfig b/.watchmanconfig new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/README.md b/README.md index ef61030..9eb25d5 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,13 @@ ### 四、shopping-react-native demo -图片轮播使用的是三方组件react-native-swiper,我们启动npm命令行,在项目的根目录使用如下命令安装模块。 +使用的三方组件,我们启动npm命令行,在项目的根目录使用如下命令安装模块。 $ npm install react-native-swiper --save $ npm i react-timer-mixin --save + $ npm install react-native-store --save + $ npm install react-native-simple-store + $ npm install react-native-camera@latest --save//扫码 ### 实战内容 diff --git a/app/network/api.js b/app/network/api.js index fa5df19..85caf66 100644 --- a/app/network/api.js +++ b/app/network/api.js @@ -1,5 +1,5 @@ -var API_ADDRESS = 'http://lsy.api.bqmart.cn'; +var API_ADDRESS = 'http://test.api.bqmart.cn'; // var API_ADDRESS='https://api.bqmart.cn'; var DEBUG = true; // public static final String SERVERURL = "https://api.bqmart.cn"; @@ -9,6 +9,7 @@ var API = { getSmsCode:function (type) { return API_ADDRESS+'/sms/sendcode' }, + HOST: API_ADDRESS, LOGIN: API_ADDRESS + '/login/verifiycode', CATEGORYLIST: API_ADDRESS + '/stores/assortment', GOODSLIST: API_ADDRESS + '/goods/goodslist', @@ -16,6 +17,7 @@ var API = { ADDRESSLIST: API_ADDRESS + '/user/address', ORDERLIST: API_ADDRESS + '/user/order', COUPONLIST: API_ADDRESS + '/coupon/lists', -}; + GOODSDETAIL: API_ADDRESS + '/goods/goodsdetail', + }; module.exports = API; \ No newline at end of file diff --git a/app/page/common/dialog.js b/app/page/common/dialog.js new file mode 100644 index 0000000..e69de29 diff --git a/app/page/common/goods.js b/app/page/common/goods.js new file mode 100644 index 0000000..e69de29 diff --git a/app/page/goodsdetail.js b/app/page/goodsdetail.js new file mode 100644 index 0000000..2013810 --- /dev/null +++ b/app/page/goodsdetail.js @@ -0,0 +1,149 @@ +/** + * + * @authors Your Name (you@example.org) + * @date 2015-10-18 14:38:47 + * @version $Id$ + */ +'use strict'; +var React = require('react-native'); + + +var Global = require('../util/global'); +var API = require('../network/api'); +var Util = require('../util/util'); +var Loading = require('./loading'); +var HTMLView = require('react-native-htmlview'); + +var { + StyleSheet, + View, + Text, + Image, + TouchableHighlight, + ScrollView, + } = React; + +var resultsCache = { + dataForOrder: [], + nextPageNumberForQuery: {}, + totalForQuery: {}, + pageIndex:1, +}; + +var GoodsDetail = React.createClass({ + getInitialState: function() { + return { + goods:null, + }; + }, + + componentDidMount: function() { + var intent = this.props.intent; + this.setState({ + goods: intent, + }); + this._fetchGoods(intent.spec_id); + }, + + _fetchGoods:function (spec_id) { + + var thiz = this; + Util.post(API.GOODSDETAIL,{'spec_id':spec_id},function (ret){ + if(ret.code==0){ + thiz.setState({ + goods: ret.data, + }); + }else{ + alert(ret.msg); + } + }); + }, + render: function() { + var goods = this.state.goods; + if(!goods){ + return + } + var htmlContent = goods.description||""; + return ( + + + + 商品名称:{goods.goods_name} + 倍全价:{goods.shichang} + + 品牌:{goods.brand} + + 商品图文详情 + {htmlContent} + + + + ); + }, +}); + + +var styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor:'#f9f9f9', + marginBottom:100, + }, + thumb: { + width: 60, + height: 60, + marginRight: 10 + }, + line1:{ + height:1, + backgroundColor:'#dadce2' + }, + line10:{ + height:10, + backgroundColor:'#ebeef1' + }, + textprimary:{ + fontSize:18, + color:'#4a4d52', + }, + textsecond:{ + fontSize:18, + color:'#929aa2', + }, + textPrice:{ + fontSize:18, + color:'#fb7e00', + }, + marginTop10:{ + marginTop:15, + }, + paddingLeftRight:{ + paddingLeft:10, + paddingRight:10, + }, + scrollSpinner: { + marginVertical: 20, + }, + rowSeparator: { + backgroundColor: 'rgba(0, 0, 0, 0.1)', + height: 10, + }, + rowSeparatorHide: { + opacity: 0.0, + }, + line:{ + height:1, + backgroundColor: '#eef0f3', + }, + row: { + flexDirection: 'row', + }, +}); + +module.exports = GoodsDetail; \ No newline at end of file diff --git a/app/page/home.js b/app/page/home.js index d6932d0..4d98115 100644 --- a/app/page/home.js +++ b/app/page/home.js @@ -113,7 +113,7 @@ var home = React.createClass({ fetch(url) .then((response) => response.json()) .then((responseData) => { - this.setState({//在React的工作流程中,setState会触发一次重绘 + this.setState({ banners: responseData.result.banners, services: responseData.result.services, advs:responseData.result.advs, diff --git a/app/page/home/SlideBanner.js b/app/page/home/SlideBanner.js new file mode 100644 index 0000000..0e0bfbd --- /dev/null +++ b/app/page/home/SlideBanner.js @@ -0,0 +1,43 @@ + + +var React = require('react-native'); +var Swiper = require('react-native-swiper'); +var Loading = require('../loading'); +var Web = require('../web'); +var Styles = require('./style'); + +var { + Image, + TouchableHighlight, + } = React; + +//参数的传递使用props +var Slider = React.createClass({ + + _loadWeb:function(title,loadurl){ + this.props.navigator.push({ + title: title, + component: Web, + passProps:{ + url: loadurl, + } + }); + }, + + render: function(){ + var thiz = this; + return ( + + {this.props.banners.map(function(banner){ + return ( + thiz._loadWeb(banner.title,banner.url)}> + + + ); + })} + + ); + } +}); + +module.exports = Slider; \ No newline at end of file diff --git a/app/page/home/adview.js b/app/page/home/adview.js new file mode 100644 index 0000000..0850f17 --- /dev/null +++ b/app/page/home/adview.js @@ -0,0 +1,48 @@ +'use strict'; + +var React = require('react-native'); +var Styles = require('./style'); + +var Web = require('../web'); + +var { + View, + Image, + TouchableHighlight, + } = React; + +var ADViews = React.createClass({ + + _loadWeb:function(title,loadurl){ + this.props.navigator.push({ + title: title, + component: Web, + passProps:{ + url: loadurl, + } + }); + }, + + render: function() { + var advViews = []; + var advs = this.props.advs; + for(var i = 0; i < advs.length; i++){ + var ad = advs[i]; + advViews.push( + this._loadWeb(ad.title,ad.url)}> + + + + + + ); + }; + return ( + + {advViews} + + ); + } +}); + +module.exports = ADViews; \ No newline at end of file diff --git a/app/page/home/bqservice.js b/app/page/home/bqservice.js new file mode 100644 index 0000000..06f1fe4 --- /dev/null +++ b/app/page/home/bqservice.js @@ -0,0 +1,79 @@ +'use strict'; +var React = require('react-native'); +var Util = require('../../util/util'); +var { + View, + Text, + StyleSheet, + TouchableHighlight, + Image, + } = React; + +//每个单项组件 +var ItemBlock = React.createClass({ + render: function() { + + var item = this.props.service; + return ( + + + {item.title} + + ); + } +}); + +var BqService = React.createClass({ + render: function(){ + var collumnNum = this.props.collumnNum; + var services = this.props.services; + var itemWidth = Math.floor(Util.size.width/collumnNum); + var size ={ + width:itemWidth, + height: itemWidth*0.75, + }; + + var itemviews = []; + + for(var ii = 0;ii + + + ); + } + + return( + + {itemviews} + + ); + }, +}); + +var styles = StyleSheet.create({ + container:{ + flexDirection:'row', + flexWrap:'wrap', + }, + center:{ + justifyContent:'center', + alignItems:'center', + }, + itemBlock:{ + //backgroundColor:'red', + borderRadius:5, + }, + font18:{ + fontSize:14, + color:'#333333', + marginTop:5, + }, + image: { + width:50, + height:50, + resizeMode: Image.resizeMode.contain, + }, +}); + +module.exports = BqService; \ No newline at end of file diff --git a/app/page/home/hotgoods.js b/app/page/home/hotgoods.js new file mode 100644 index 0000000..1cbac3a --- /dev/null +++ b/app/page/home/hotgoods.js @@ -0,0 +1,130 @@ +'use strict'; +var React = require('react-native'); +var Util = require('../../util/util'); +var GoodsDetail = require('../goodsdetail'); + +var { + View, + Text, + StyleSheet, + TouchableHighlight, + Image, + } = React; + +//每个单项组件 +var Product = React.createClass({ + render: function() { + + var item = this.props.data; + var itemWidth =this.props.itemWidth; + var itemsize ={ + width:itemWidth, + }; + var imagesize ={ + width:itemWidth-10, + height: itemWidth-10, + }; + return ( + + + {item.goods_name} + + 倍全价: + {item.price} + + + + ); + } +}); + +var HotGoods = React.createClass({ + _goodsDetail:function (product) { + this.props.navigator.push({ + title: '商品详情', + rightButtonTitle:'分享', + component: GoodsDetail, + passProps:{ + intent: product, + } + }); + }, + + render: function(){ + var collumnNum = this.props.collumnNum; + var products = this.props.hotgoods; + var itemWidth = Math.floor((Util.size.width)/collumnNum); + var size ={ + width:itemWidth, + height: itemWidth*1.25, + }; + var itemviews = []; + for(var ii = 0;iithis._goodsDetail(product)}> + + + + + ); + } + + return( + + {itemviews} + + ); + }, +}); + +var styles = StyleSheet.create({ + container:{ + flexDirection:'row', + justifyContent:'space-between', + backgroundColor:'#f5f5f5', + flexWrap:'wrap', + + }, + center:{ + justifyContent:'center', + alignItems:'center', + }, + itemBlock:{ + backgroundColor:'white', + padding:5, + }, + row:{ + flexDirection:'row', + }, + flex1:{ + flex:1, + }, + marginTop4:{ + marginTop:4, + }, + font_goodsname:{ + fontSize:12, + color:'#333333', + height:26, + }, + font_bqprice:{ + fontSize:16, + color:'#ee7700', + }, + image: { + paddingLeft:5, + paddingRight:5, + paddingTop:5, + paddingBottom:5, + resizeMode: Image.resizeMode.stretch,//拉伸 + }, + image_add:{ + width:25, + height:25, + }, +}); + +module.exports = HotGoods; \ No newline at end of file diff --git a/app/page/home/index.js b/app/page/home/index.js new file mode 100644 index 0000000..d1abf99 --- /dev/null +++ b/app/page/home/index.js @@ -0,0 +1,115 @@ +/** + * Sample React Native App + * https://github.com/facebook/react-native + */ +'use strict'; + +var React = require('react-native'); +var Styles = require('./style'); + +var API = require('../../network/api'); +var Util = require('../../util/util'); +var Global = require('../../util/global'); +var Loading = require('../loading'); +var Web = require('../web'); + +//自定义组件 +var Slider = require('./slidebanner'); +var ADViews = require('./adview'); +var BqService = require('./bqservice'); +var HotGoods = require('./hotgoods'); + +//下拉刷新 +var { + RefresherListView, + LoadingBarIndicator +} = require('react-native-refresher'); + +var { + Text, + View, + Image, + ScrollView, + ListView, + TouchableHighlight, +} = React; + +var home = React.createClass({ + getInitialState: function() { + return { + store_id: 8805, + loaded:false, + banners:[], + services:[], + hotgoods:[], + advs:[], + }; + }, + + componentDidMount: function() { + this.getStoreMunu(); + }, + + getStoreMunu:function(){ + var store_id=this.state.store_id; + var p9 = "app"; + var url ="https://api.bqmart.cn/stores/menu.json?store_id=8805&p9=app"; + fetch(url) + .then((response) => response.json()) + .then((responseData) => { + this.setState({ + banners: responseData.result.banners, + services: responseData.result.services, + advs:responseData.result.advs, + loaded:true, + }); + this.getRecommendation(); + }) + .done(); + }, + + getRecommendation:function(){ + var storeid = this.state.store_id; + var url = "https://api.bqmart.cn/goods/relatedrecommend.json?store_id=8805&type=seckill&page=1&limit=40"; + fetch(url) + .then((response) => response.json()) + .then((responseData) => { + this.setState({ + hotgoods:responseData.result, + }); + }).done(); + }, + + renderContent: function() { + if(!this.state.loaded){ + return ( LOADING ); + } + return ( + + + + + + + 精品推荐 + + + + + ); + }, + + render: function() { + if(!this.state.loaded){ + return + } + return this.renderContent(); + }, +}); + +module.exports = home; diff --git a/app/page/home/style.js b/app/page/home/style.js new file mode 100644 index 0000000..6f50fb7 --- /dev/null +++ b/app/page/home/style.js @@ -0,0 +1,75 @@ +/** + * + * @authors Your Name (you@example.org) + * @date 2015-10-19 18:32:08 + * @version $Id$ + */ +'use strict'; +var React = require('react-native'); + +var { + StyleSheet, + Image, +} = React; + +var styles = StyleSheet.create({ + container: { + marginBottom:115, + }, + //slider + row:{ + flexDirection:'row', + }, + wrapper: { + height:125, + }, + flex1:{ + flex:1, + }, + center:{ + alignItems:'center', + justifyContent: 'center', + }, + slide: { + height:125, + resizeMode: Image.resizeMode.stretch, + }, + adv: { + height:145, + resizeMode: Image.resizeMode.stretch, + }, + hotLine:{ + height:1, + backgroundColor:'#333333', + }, + hottitle:{ + fontSize: 16, + textAlign: 'center', + }, + container_bqservice:{ + padding:10, + }, + inputRow:{ + flexDirection:'row', + alignItems:'center', + justifyContent: 'center', + marginBottom:10, + }, + welcome: { + fontSize: 20, + textAlign: 'center', + margin: 10, + }, + instructions: { + textAlign: 'center', + color: '#333333', + marginBottom: 5, + }, + itemRow:{ + flexDirection:'row', + marginBottom:2, + }, + +}); + +module.exports = styles; \ No newline at end of file diff --git a/app/page/index.js b/app/page/index.js new file mode 100644 index 0000000..080a30a --- /dev/null +++ b/app/page/index.js @@ -0,0 +1,179 @@ +/** + * Sample React Native App + * https://github.com/facebook/react-native + */ +'use strict'; + +var React = require('react-native'); +var Login = require('./login'); +var Home = require('./home/index'); +var Market = require('./market/index'); +var ShoppingCart = require('./shoppingcart'); +var Me = require('./me'); +var Search = require('./search/search'); +var Scan = require('./search/search'); +var { + StyleSheet, + Text, + View, + TabBarIOS, + NavigatorIOS, +} = React; + +// StatusBarIOS.setStyle('light-content'); + +var index = React.createClass({ + getInitialState: function() { + return{ + selectedTab:'home', + lastTab:'home', + store_id:8805, + showIndex: { + height:0, + opacity:0 + }, + }; + }, + + _selectTab: function(newTabName){ + var currentTab = this.state.selectedTab; + if(currentTab!=newTabName){ + this.setState({ + lastTab:currentTab, + }); + } + this.setState({ + selectedTab:newTabName, + }); + }, + + _search: function () { + this._selectTab('search'); + }, + + _scan: function () { + this._selectTab('scan'); + }, + + _addNavigator: function(component, title){ + var data = null; + if(this.state.selectedTab ==='home'||this.state.selectedTab==='market'){ + return this._search(), + leftButtonTitle:"扫一扫", + onLeftButtonPress:() => this._scan(), + passProps:{ + data: data + } + }} />; + } + + return ; + }, + + _renderLogin:function(){ + return ( + + ); + }, + + _renderNewTab: function (component, title) { + + var lastTab = this.state.lastTab; + + return this._selectTab(lastTab), + leftButtonTitle:"返回", + passProps:{ + data: this.state.store_id + } + }} />; + }, + + render: function() { + + if(this.state.selectedTab ==='search'){ + return this._renderNewTab(Search,'搜索'); + }else if(this.state.selectedTab ==='scan'){ + return this._renderNewTab(Scan,'扫一扫'); + } + + return ( + + + {this._addNavigator(Home,'首页')} + + + + {this._addNavigator(Market,'闪送超市')} + + + + {this._addNavigator(ShoppingCart,'购物车')} + + + + {this._addNavigator(Me,'个人中心')} + + + + ); + } +}); + + +module.exports = index; + diff --git a/app/page/login.js b/app/page/login.js index dff913a..3d340e4 100644 --- a/app/page/login.js +++ b/app/page/login.js @@ -7,38 +7,51 @@ var React = require('react-native'); var API = require('../network/api'); var Util = require('../util/util'); -var user_id ="1234"; -var access_token="12345"; +var TimerMixin = require('react-timer-mixin'); +var Store = require('react-native-simple-store'); var { AppRegistry, StyleSheet, Text, + Image, View, TouchableHighlight, TextInput, } = React; var login = React.createClass({ + mixins: [TimerMixin], + getInitialState: function() { return { phone: "", code: "", logined: false, - secondsElapsed: -1, + secondsElapsed: 0, }; }, + componentDidMount: function() { + Store.get('user').then((userdata)=>{ + this.setState({ + phone:userdata.user_name, + })}); + }, + tick: function() { - if(this.state.secondsElapsed==-1){ - this.setState({secondsElapsed: 10}); - }else if(this.state.secondsElapsed==0){ - clearInterval(interval); - this.setState({secondsElapsed: -1}); - }else { - this.setState({secondsElapsed: this.state.secondsElapsed -1}); - clearInterval(interval); + var secondsElapsed = this.state.secondsElapsed-1; + if(secondsElapsed==0){ + this.setState({secondsElapsed: 0}); + return; } + this.setTimeout( + () => { + this.setState({secondsElapsed: secondsElapsed}); + this.tick(); + }, + 500 + ); }, getCode: function() { @@ -47,10 +60,13 @@ var login = React.createClass({ alert("请输入正确的手机号码"); return; } + var thiz = this; Util.post(API.getSmsCode(),{'tel':phone,'type':'verifiycode'},function (ret){ - alert(ret.msg); if(ret.code==0){ + thiz.setState({secondsElapsed: 60}); + thiz.tick(); } + Util.log(ret.msg); }); }, @@ -65,32 +81,23 @@ var login = React.createClass({ alert("验证码为4位数字"); return; } - /*alert(this.state.logined); - Util.get(API.login()+"?user_name="+phone+"&code="+code+"&type=verifiycode",function (ret){ - - if(ret.code==0){ - // alert('登陆成功-'); - alert(this.state.logined); - this.setState({logined:true});//无效 - - }else{ - alert(ret.msg); - } - });*/ - fetch(API.login()+"?user_name="+phone+"&code="+code+"&type=verifiycode") + fetch(API.LOGIN+"?user_name="+phone+"&code="+code+"&type=verifiycode") .then((response) => response.json()) .then((responseData) => { if(responseData.code==0){ - user_id=responseData.data.user_id; - access_token=responseData.data.access_token; - this.setState({logined:true}); + this._loginSucc(responseData.data); + }else{ + alert("验证码错误"); } - alert(responseData.msg); }) .done(); }, + _loginSucc:function(userData){ + this.props.loginResult(userData); + }, + logout:function(){ this.setState({logined:false}); }, @@ -109,38 +116,47 @@ var login = React.createClass({ 欢迎你:user_id:{user_id} access_token:{access_token} 退出 - + ); }, renderLogin:function(){ + + var getCode_text = this.state.secondsElapsed==0?'获取验证码':(this.state.secondsElapsed+'秒后重试'); + return ( - - - 手机号 - this.setState({phone: text})}/> - - - - 验证码 - this.setState({code: text})}/> - - 获取验证码 - + + + 用户登陆 + + 手机号 + this.setState({phone: text})}/> + + + + 验证码 + this.setState({code: text})}/> + + {getCode_text} + + + + + 登录 + - - - 登录 - - test:{this.state.secondsElapsed}秒 - ); + ); }, render: function() { @@ -153,12 +169,21 @@ var login = React.createClass({ var styles = StyleSheet.create({ container: { - marginTop:50, - backgroundColor: '#57a84a', + flex:1, + }, + loginform:{ + backgroundColor:'#00000000', paddingLeft:40, paddingRight:40, - paddingTop:90, + }, + transparent:{ + backgroundColor:'#00000000', + }, + title: { + color:'#ffffff', + fontSize:20, flex:1, + textAlign:'center', }, action:{ height:50, @@ -180,6 +205,7 @@ var styles = StyleSheet.create({ marginRight:10, }, inputRow:{ + backgroundColor:'00000000', flexDirection:'row', alignItems:'center', justifyContent:'center', @@ -187,6 +213,7 @@ var styles = StyleSheet.create({ input:{ height:35, borderColor:'#ccc', + color:'#fff', flex:1, fontSize:14, }, @@ -196,7 +223,6 @@ var styles = StyleSheet.create({ color:'ffffff' }, btn:{ - marginTop:10, height:35, backgroundColor:'#4d796e', justifyContent:'center', diff --git a/app/page/market.js b/app/page/market.js deleted file mode 100644 index 9bd7252..0000000 --- a/app/page/market.js +++ /dev/null @@ -1,187 +0,0 @@ -/** - * - * @authors Your Name (you@example.org) - * @date 2015-10-18 14:38:47 - * @version $Id$ - */ -'use strict'; -var React = require('react-native'); -var Global = require('../util/global'); -var API = require('../network/api'); -var Util = require('../util/util'); -var Loading = require('./loading'); - -var { - View, - Text, - Image, - ListView, - StyleSheet, - TouchableHighlight, -} = React; - - -var Market = React.createClass({ - getInitialState: function() { - return { - categoryIndex:0, - - categoryList:{ - dataSource:new ListView.DataSource({rowHasChanged:(row1,row2) =>row1!==row2}), - loaded:false, - }, - goodsList:{ - dataSource:new ListView.DataSource({rowHasChanged:(row1,row2) =>row1!==row2}), - loaded:false, - }, - }; - }, - - componentDidMount: function() { - this._fetchData(); - }, -//加载网络数据 - _fetchData: function() { - var thiz = this; - var thizDataSource = thiz.state.categoryList.dataSource; - Util.post(API.CATEGORYLIST,{'store_id':'8805'}, - function (ret){ - if(ret.code==0&&ret.data.assortment.length>0){ - thiz.setState({ - categoryList:{ - dataSource: thizDataSource.cloneWithRows(ret.data.assortment), - loaded:true, - }, - }); - thiz._fetchGoodsByCategory(ret.data.assortment[0].cate_id); - } - }); - }, - - _fetchGoodsByCategory:function(category_id){ - var thiz = this; - var thizDataSource = thiz.state.categoryList.dataSource; - var params={ - 'store_id':8805, - 'page':1, - 'limit':30, - 'cate_id':category_id - }; - Util.post(API.GOODSLIST,params, - function (ret){ - thiz.setState({ - goodsList:{ - dataSource: thizDataSource.cloneWithRows(ret.data), - loaded:true, - }, - }); - }); - }, - - _rowPressed:function(rowID,cate_id){ - this.setState({ - categoryIndex:rowID, - }); - this._fetchGoodsByCategory(cate_id); - }, - - _renderCategoryItem:function(rowData, sectionID, rowID){ - var selected= rowID!=this.state.categoryIndex; - return( - this._rowPressed(rowID,rowData.cate_id)}> - {rowData.cate_name} - - ); - }, - - _renderGoodsList:function(rowData, sectionID, rowID){ - return ( - - - - - {rowData.goods_name} - - 倍全价: - {rowData.shichang} - - - - - - - - ); - }, - - render: function() { - if(!this.state.categoryList.loaded){ - return - }; - - return ( - - - - - ); - }, -}); - -var styles = StyleSheet.create({ - container: { - flex: 1, - flexDirection:'row', - backgroundColor:'#eef0f3', - paddingBottom:68, - }, - category:{ - justifyContent: 'center', - alignItems: 'center', - height:50, - }, - category_bg_select:{ - backgroundColor:'#d7ead6', - }, - category_bg_normal:{ - backgroundColor:'#ffffff', - }, - thumb: { - width: 70, - height: 70, - marginRight: 10 - }, - line:{ - backgroundColor:'#eef0f3', - height:1, - }, - textContainer: { - flex: 1 - }, - price: { - fontSize: 25, - fontWeight: 'bold', - color: '#48BBEC' - }, - title: { - fontSize: 20, - color: '#656565' - }, - rowContainer: { - flexDirection: 'row', - padding: 10, - height:90, - justifyContent: 'center', - } -}); - -module.exports = Market; \ No newline at end of file diff --git a/app/page/market/category.js b/app/page/market/category.js new file mode 100644 index 0000000..1642460 --- /dev/null +++ b/app/page/market/category.js @@ -0,0 +1,78 @@ +/** + * + * @authors Your Name (you@example.org) + * @date 2015-10-18 14:38:47 + * @version $Id$ + */ +'use strict'; +var React = require('react-native'); +var Styles = require('./category_style'); + +var { + View, + Text, + ListView, + TouchableHighlight, +} = React; + +var Category = React.createClass({ + + getInitialState:function(){ + var ds = new ListView.DataSource({rowHasChanged:(row1,row2) =>row1!==row2}); + return { + categoryIndex:0, + dataSource:ds.cloneWithRows(this._genRows(0)), + loaded:false, + }; + }, + + _genRows:function(index: number):Array{ + var holderList = []; + for (var ii = 0; ii < this.props.categoryList.length; ii++) { + holderList[ii] = ii == index; + }; + return holderList; + }, + + _rowPressed:function(rowID: number, cate_id: number){ + this.props.onSelect(rowID,cate_id); + this.setState( + { + categoryIndex:rowID, + dataSource:this.state.dataSource.cloneWithRows(this._genRows(rowID)), + }); + }, + + renderSeparator:function(){ + return ; + }, + + renderCategoryItem:function(rowData: Object, sectionID: number, rowID: number ){ + var cate = this.props.categoryList[rowID]; + var selected = this.state.categoryIndex == rowID; + var styles_bg = selected?Styles.category_bg_select:Styles.category_bg_normal; + + return( + this._rowPressed(rowID,cate.cate_id)}> + {cate.cate_name} + + ); + }, + + render: function() { + return ( + + + + ); + }, + +}); + +module.exports = Category; \ No newline at end of file diff --git a/app/page/market/category_style.js b/app/page/market/category_style.js new file mode 100644 index 0000000..6198b5c --- /dev/null +++ b/app/page/market/category_style.js @@ -0,0 +1,40 @@ +/** + * + * @authors Your Name (you@example.org) + * @date 2015-10-18 14:38:47 + * @version $Id$ + */ +'use strict'; +var React = require('react-native'); + +var { + View, + Text, + ListView, + StyleSheet, + TouchableHighlight, +} = React; + +var styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor:'#eef0f3', + }, + category:{ + justifyContent: 'center', + alignItems: 'center', + height:50, + }, + category_bg_select:{ + backgroundColor:'#d7ead6', + }, + category_bg_normal:{ + backgroundColor:'#ffffff', + }, + line:{ + backgroundColor:'#eef0f3', + height:1, + }, +}); + +module.exports = styles; \ No newline at end of file diff --git a/app/page/market/goodslist.js b/app/page/market/goodslist.js new file mode 100644 index 0000000..e69de29 diff --git a/app/page/market/index.js b/app/page/market/index.js new file mode 100644 index 0000000..e1b402a --- /dev/null +++ b/app/page/market/index.js @@ -0,0 +1,219 @@ +/** + * + * @authors Your Name (you@example.org) + * @date 2015-10-18 14:38:47 + * @version $Id$ + */ +'use strict'; +var React = require('react-native'); + +var Global = require('../../util/global'); +var API = require('../../network/api'); +var Util = require('../../util/util'); +var Loading = require('../loading'); +var Category = require('./category'); + +var { + View, + Text, + Image, + ListView, + StyleSheet, + Platform, + TouchableHighlight, + ActivityIndicatorIOS, + ProgressBarAndroid, +} = React; + +var resultsCache = { + dataForCategory: {}, + dataForGoods: {}, + totalForGoods: {}, +}; + +var Market = React.createClass({ + getInitialState: function() { + return { + store_id:8805, + goodsList:{ + dataSource:new ListView.DataSource({rowHasChanged:(row1,row2) =>row1!==row2}), + loaded:false, + loadingmore:false, + }, + }; + }, + + componentDidMount: function() { + this._fetchData(); + }, + +//加载网络数据 + _fetchData: function() { + var thiz = this; + var thizDataSource = thiz.state.dataSource; + Util.post(API.CATEGORYLIST,{'store_id':'8805'}, + function (ret){ + if(ret.code==0&&ret.data.assortment.length>0){ + resultsCache.dataForCategory= ret.data.assortment; + thiz.setState({ + loaded:true, + }); + thiz._fetchGoodsByCategory(ret.data.assortment[0].cate_id); + } + }); + }, + + _fetchGoodsByCategory:function(category_id: number){ + var thiz = this; + var thizDataSource = thiz.state.goodsList.dataSource; + + var params={ + 'store_id':8805, + 'page':1, + 'limit':30, + 'cate_id':category_id + }; + Util.post(API.GOODSLIST,params, + function (ret){ + thiz._setGoodsList(ret.data); + }); + }, + + _setGoodsList: function (goodsList:Array){ + var thizDataSource = this.state.goodsList.dataSource; + this.setState({ + goodsList:{ + dataSource: thizDataSource.cloneWithRows(goodsList), + loaded:true, + }, + }); + }, + + _selectCategory:function (rowID: number, cate_id: number){ + this._fetchGoodsByCategory(cate_id); + }, + + renderSeparator: function(sectionID: number,rowID: number,adjacentRowHighlighted: boolean) { + var style = styles.rowSeparator; + if (adjacentRowHighlighted) { + style = [style, styles.rowSeparatorHide]; + } + return ( + + ); + }, + + renderFooter: function() { + if(this.state.goodsList.loadingmore){ + if (Platform.OS === 'ios') { + return ; + } else { + return ( + + + ); + } + }else{ + return 全部商品加载完毕; + } + }, + + _renderGoodsList:function(rowData: Object, sectionID: number | string, rowID: number | string){ + return ( + + + + + {rowData.goods_name} + + 倍全价: + {rowData.shichang} + + + + + + + ); + }, + + render: function() { + if(!this.state.loaded){ + return + }; + + var goodsListLoading = null; + if(!this.state.goodsList.loaded){ + goodsListLoading = ; + } + + return ( + + + + + {goodsListLoading} + + + + ); + }, +}); + +var styles = StyleSheet.create({ + container: { + flex: 1, + flexDirection:'row', + backgroundColor:'#eef0f3', + marginBottom:120, + }, + rowSeparator: { + backgroundColor: 'rgba(0, 0, 0, 0.1)', + height: 1, + marginLeft: 4, + }, + rowSeparatorHide: { + opacity: 0.0, + }, + scrollSpinner: { + marginVertical: 20, + }, + thumb: { + width: 70, + height: 70, + marginRight: 10 + }, + line:{ + backgroundColor:'#eef0f3', + height:1, + }, + textContainer: { + flex: 1 + }, + price: { + fontSize: 25, + fontWeight: 'bold', + color: '#48BBEC' + }, + title: { + fontSize: 20, + color: '#656565' + }, + rowContainer: { + flexDirection: 'row', + padding: 10, + height:90, + justifyContent: 'center', + } +}); + +module.exports = Market; \ No newline at end of file diff --git a/app/page/me.js b/app/page/me.js index f71c350..48d002f 100644 --- a/app/page/me.js +++ b/app/page/me.js @@ -10,13 +10,18 @@ var AddresManager = require('./address/addresslist'); var OrderManager = require('./order/orderlist'); var CouponManager = require('./coupon/couponlist'); var ShellManager = require('./shell/shell'); +var store = require('react-native-simple-store'); + + var { StyleSheet, View, Text, ScrollView, Image, + LinkingIOS, TouchableHighlight, + ActionSheetIOS, NavigatorIOS, } = React; @@ -34,7 +39,7 @@ var MenuItem = React.createClass({ + source={require(this.props.icon)} /> {this.props.title} @@ -46,10 +51,15 @@ var MenuItem = React.createClass({ var Me = React.createClass({ getInitialState: function() { return { + user:null, }; }, componentDidMount: function() { + store.get('user').then((userdata)=>{ + this.setState({ + user:userdata, + })}); }, _addNavigator: function(component, title){ @@ -63,30 +73,57 @@ var Me = React.createClass({ }); }, + _call:function(){ + LinkingIOS.openURL('tel://4007008780'); + }, + render: function() { var thiz = this; + var name=""; + if(this.state.user){ + name = this.state.user.user_name; + } return ( - - 13488789409 + + + + {name} + + - - - + + this._call()}> + 拨打客服400-700-8780 + + ); }, @@ -97,10 +134,16 @@ var styles = StyleSheet.create({ flex: 1, }, center:{ - flex: 1, alignItems:'center', justifyContent: 'center', }, + userName:{ + color:'#ffffff', + fontSize:20, + }, + transparent:{ + backgroundColor:'#00000000', + }, header: { height: 100, }, @@ -109,16 +152,11 @@ var styles = StyleSheet.create({ width:20, resizeMode: Image.resizeMode.contain, }, - priceContainer: { - padding: 5, - left: 0, - height: 30, - shadowColor: 'black', - shadowOffset: {height: 2, width: 1 }, - shadowOpacity: 0.2, - shadowRadius: 1, + logoSize: { + height:40, + width:40, + resizeMode: Image.resizeMode.contain, }, - }); module.exports = Me; \ No newline at end of file diff --git a/app/page/order/orderlist.js b/app/page/order/orderlist.js index b6c356c..0ce643b 100644 --- a/app/page/order/orderlist.js +++ b/app/page/order/orderlist.js @@ -6,24 +6,42 @@ */ 'use strict'; var React = require('react-native'); + + var Global = require('../../util/global'); var API = require('../../network/api'); var Util = require('../../util/util'); var Loading = require('../loading'); +var PAGESIZE = 6; + var { StyleSheet, View, Text, Image, ListView, + Platform, + TouchableHighlight, + ActivityIndicatorIOS, + ProgressBarAndroid, } = React; -var Market = React.createClass({ + +var resultsCache = { + dataForOrder: [], + nextPageNumberForQuery: {}, + totalForQuery: {}, + pageIndex:1, +}; + +var OrderList = React.createClass({ getInitialState: function() { return { dataSource:new ListView.DataSource({rowHasChanged:(row1,row2) =>row1!==row2}), loaded:false, + loadingMore:false, + isLoadingTail:false, }; }, @@ -34,19 +52,70 @@ var Market = React.createClass({ _getOrderList:function(pageIndex){ var params = Global.user; params.page=pageIndex; - params.limit=30; + params.limit=PAGESIZE; var thiz = this; Util.post(API.ORDERLIST,Global.user, function (ret){ if(ret.code==0&&ret.data.length>0){ + for(var ii=0 ; ii< ret.data.length ; ii++){ + resultsCache.dataForOrder.push(ret.data[ii]); + } + alert(resultsCache.dataForOrder.length+","+resultsCache.pageIndex); thiz.setState({ - dataSource: thiz.state.dataSource.cloneWithRows(ret.data), + dataSource: thiz.state.dataSource.cloneWithRows(resultsCache.dataForOrder), loaded:true, + loadingMore:false, }); } }); }, + onEndReached: function() { + var query = this.state.filter; + if (!this.hasMore||this.state.loadingMore || this.state.isLoadingTail) { + // We're already fetching or have all the elements so noop + return; + } + alert("loading data"); + this.setState({ + isLoadingTail: true, + loadingMore:true, + }); + resultsCache.pageIndex++; + setTimeout(() => this._getOrderList(resultsCache.pageIndex), 1000) + }, + + renderSeparator: function(sectionID: number,rowID: number,adjacentRowHighlighted: boolean) { + var style = styles.rowSeparator; + if (adjacentRowHighlighted) { + style = [style, styles.rowSeparatorHide]; + } + return ( + + ); + }, + + hasMore:function(){ + return resultsCache.dataForOrder.length!=resultsCache.pageIndex*PAGESIZE; + }, + + renderFooter: function() { + if (!this.state.isLoadingTail) { + return ; + } + + + if (Platform.OS === 'ios') { + return ; + } else { + return ( + + + + ); + } + }, + _renderListItem:function(rowData){ var imageViews = []; var goods = rowData.orders_goods; @@ -56,7 +125,7 @@ var Market = React.createClass({ }; } return ( - + {rowData.title} @@ -87,6 +156,10 @@ var Market = React.createClass({ return ( @@ -98,12 +171,23 @@ var styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#eef0f3', + marginBottom:110, }, thumb: { width: 60, height: 60, marginRight: 10 }, + scrollSpinner: { + marginVertical: 20, + }, + rowSeparator: { + backgroundColor: 'rgba(0, 0, 0, 0.1)', + height: 10, + }, + rowSeparatorHide: { + opacity: 0.0, + }, line:{ height:1, backgroundColor: '#eef0f3', @@ -113,4 +197,4 @@ var styles = StyleSheet.create({ }, }); -module.exports = Market; \ No newline at end of file +module.exports = OrderList; \ No newline at end of file diff --git a/app/page/order/style.js b/app/page/order/style.js new file mode 100644 index 0000000..20b958c --- /dev/null +++ b/app/page/order/style.js @@ -0,0 +1 @@ +style.js \ No newline at end of file diff --git a/app/page/scan/index.js b/app/page/scan/index.js new file mode 100644 index 0000000..a2f695d --- /dev/null +++ b/app/page/scan/index.js @@ -0,0 +1,95 @@ +/** + * + * @authors Your Name (you@example.org) + * @date 2015-10-18 14:38:47 + * @version $Id$ + */ +'use strict'; +var React = require('react-native'); + + +var Global = require('../../util/global'); +var API = require('../../network/api'); +var Util = require('../../util/util'); +var Loading = require('../loading'); + +var PAGESIZE = 6; + +var { + StyleSheet, + View, + Text, + Image, + ListView, + Platform, + TouchableHighlight, + ActivityIndicatorIOS, + ProgressBarAndroid, + } = React; + + +var resultsCache = { + dataForOrder: [], + nextPageNumberForQuery: {}, + totalForQuery: {}, + pageIndex:1, +}; + +var Search = React.createClass({ + getInitialState: function() { + return { + dataSource:new ListView.DataSource({rowHasChanged:(row1,row2) =>row1!==row2}), + loaded:false, + }; + }, + + componentDidMount: function() { + + }, + + render: function() { + return ( + + 新模块 + + + ); + }, +}); + +var styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#eef0f3', + }, + thumb: { + width: 60, + height: 60, + marginRight: 10 + }, + scrollSpinner: { + marginVertical: 20, + }, + rowSeparator: { + backgroundColor: 'rgba(0, 0, 0, 0.1)', + height: 10, + }, + rowSeparatorHide: { + opacity: 0.0, + }, + line:{ + height:1, + backgroundColor: '#eef0f3', + }, + row: { + flexDirection: 'row', + }, +}); + +module.exports = Search; \ No newline at end of file diff --git a/app/page/search/search.js b/app/page/search/search.js new file mode 100644 index 0000000..a2f695d --- /dev/null +++ b/app/page/search/search.js @@ -0,0 +1,95 @@ +/** + * + * @authors Your Name (you@example.org) + * @date 2015-10-18 14:38:47 + * @version $Id$ + */ +'use strict'; +var React = require('react-native'); + + +var Global = require('../../util/global'); +var API = require('../../network/api'); +var Util = require('../../util/util'); +var Loading = require('../loading'); + +var PAGESIZE = 6; + +var { + StyleSheet, + View, + Text, + Image, + ListView, + Platform, + TouchableHighlight, + ActivityIndicatorIOS, + ProgressBarAndroid, + } = React; + + +var resultsCache = { + dataForOrder: [], + nextPageNumberForQuery: {}, + totalForQuery: {}, + pageIndex:1, +}; + +var Search = React.createClass({ + getInitialState: function() { + return { + dataSource:new ListView.DataSource({rowHasChanged:(row1,row2) =>row1!==row2}), + loaded:false, + }; + }, + + componentDidMount: function() { + + }, + + render: function() { + return ( + + 新模块 + + + ); + }, +}); + +var styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#eef0f3', + }, + thumb: { + width: 60, + height: 60, + marginRight: 10 + }, + scrollSpinner: { + marginVertical: 20, + }, + rowSeparator: { + backgroundColor: 'rgba(0, 0, 0, 0.1)', + height: 10, + }, + rowSeparatorHide: { + opacity: 0.0, + }, + line:{ + height:1, + backgroundColor: '#eef0f3', + }, + row: { + flexDirection: 'row', + }, +}); + +module.exports = Search; \ No newline at end of file diff --git a/app/page/search/style.js b/app/page/search/style.js new file mode 100644 index 0000000..6f50fb7 --- /dev/null +++ b/app/page/search/style.js @@ -0,0 +1,75 @@ +/** + * + * @authors Your Name (you@example.org) + * @date 2015-10-19 18:32:08 + * @version $Id$ + */ +'use strict'; +var React = require('react-native'); + +var { + StyleSheet, + Image, +} = React; + +var styles = StyleSheet.create({ + container: { + marginBottom:115, + }, + //slider + row:{ + flexDirection:'row', + }, + wrapper: { + height:125, + }, + flex1:{ + flex:1, + }, + center:{ + alignItems:'center', + justifyContent: 'center', + }, + slide: { + height:125, + resizeMode: Image.resizeMode.stretch, + }, + adv: { + height:145, + resizeMode: Image.resizeMode.stretch, + }, + hotLine:{ + height:1, + backgroundColor:'#333333', + }, + hottitle:{ + fontSize: 16, + textAlign: 'center', + }, + container_bqservice:{ + padding:10, + }, + inputRow:{ + flexDirection:'row', + alignItems:'center', + justifyContent: 'center', + marginBottom:10, + }, + welcome: { + fontSize: 20, + textAlign: 'center', + margin: 10, + }, + instructions: { + textAlign: 'center', + color: '#333333', + marginBottom: 5, + }, + itemRow:{ + flexDirection:'row', + marginBottom:2, + }, + +}); + +module.exports = styles; \ No newline at end of file diff --git a/app/page/serviceitem.js b/app/page/serviceitem.js deleted file mode 100644 index 888a9bf..0000000 --- a/app/page/serviceitem.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; -var React = require('react-native'); -var { - View, - Text, - StyleSheet, - TouchableHighlight, - Image, -} = React; - -//每个单项组件 -var ItemBlock = React.createClass({ - render: function() { - var size ={ - width: parseInt(this.props.width), - height: parseInt(this.props.width*0.7) - }; - var item = this.props.service; - return ( - - - {item.title} - - ); - } -}); - -var styles = StyleSheet.create({ -itemBlock:{ - justifyContent:'center', - alignItems:'center', - borderRadius:5, - }, - font18:{ - fontSize:14, - color:'#333333', - marginTop:5, - }, - image: { - width:50, - height:50, - resizeMode: Image.resizeMode.contain, - }, -}); - -module.exports = ItemBlock; \ No newline at end of file diff --git a/app/page/web.js b/app/page/web.js index 4b5c95d..e96594e 100644 --- a/app/page/web.js +++ b/app/page/web.js @@ -6,7 +6,7 @@ */ 'use strict'; var React = require('react-native'); - +var HTMLView = require('react-native-htmlview'); var { StyleSheet, View, diff --git a/app/util/util.js b/app/util/util.js index 24b3132..acaedfe 100644 --- a/app/util/util.js +++ b/app/util/util.js @@ -46,6 +46,14 @@ var Util = { }).done(); }, + log:function (obj){ + var description = ""; + for(var i in obj){ + var property=obj[i]; + description+=i+" = "+property+"\n"; + } + alert(description); + }, //Key key: 'HSHHSGSGGSTWSYWSYUSUWSHWBS-REACT-NATIVE' diff --git a/index.android.js b/index.android.js index 2ba40eb..7f2f076 100644 --- a/index.android.js +++ b/index.android.js @@ -6,7 +6,7 @@ var React = require('react-native'); var Login = require('./app/page/login'); -var Home = require('./app/page/home'); +var Home = require('./app/page/home/index'); var { AppRegistry, diff --git a/index.ios.js b/index.ios.js index 53e93a9..fce4e60 100644 --- a/index.ios.js +++ b/index.ios.js @@ -6,124 +6,49 @@ var React = require('react-native'); var Login = require('./app/page/login'); -var Home = require('./app/page/home'); -var Market = require('./app/page/market'); -var ShoppingCart = require('./app/page/shoppingcart'); -var Me = require('./app/page/me'); +var Index = require('./app/page/index'); +var store = require('react-native-simple-store'); var { AppRegistry, - StyleSheet, - Text, - View, - TabBarIOS, - NavigatorIOS, } = React; // StatusBarIOS.setStyle('light-content'); -var bqseller = React.createClass({ +var app = React.createClass({ getInitialState: function() { return{ - selectedTab:'home', logined:false, - showIndex: { - height:0, - opacity:0 - }, }; }, - _selectTab: function(tabName){ - this.setState({ - selectedTab:tabName, - }); + _renderLogin:function(){ + return ( + this._loginSucc(userData)}/> + ); }, - _addNavigator: function(component, title){ - var data = null; - return ; + _loginSucc:function(userData){ + store.save('user', userData); + this.setState({ + logined:true, + }); }, - _renderLogin:function(){ + _renderIndex:function(){ return ( - + ); }, render: function() { - return ( - - - {this._addNavigator(Home,'首页')} - - - - {this._addNavigator(Market,'闪送超市')} - - - - {this._addNavigator(ShoppingCart,'购物车')} - - - - {this._addNavigator(Me,'个人中心')} - - - - ); - } -}); - -var styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#EE7700', - }, - row:{ - flexDirection:'row', + if(this.state.logined){ + return this._renderIndex(); + }else{ + return this._renderLogin(); + } }, - title:{ - color: '#ffffff', - }, - actionBar: { - height:49, - alignItems:'center', - justifyContent: 'center', - backgroundColor: '#6bb967', - } + }); -AppRegistry.registerComponent('bqseller', () => bqseller); +AppRegistry.registerComponent('bqseller', () => app); diff --git a/ios/bqseller/Images.xcassets/Contents.json b/ios/bqseller/Images.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/ios/bqseller/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_goods_add.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_goods_add.imageset/Contents.json index 158392c..0a98cc4 100644 --- a/ios/bqseller/Images.xcassets/ic_goods_add.imageset/Contents.json +++ b/ios/bqseller/Images.xcassets/ic_goods_add.imageset/Contents.json @@ -2,15 +2,17 @@ "images" : [ { "idiom" : "universal", - "scale" : "1x", - "filename" : "ic_goods_add.png" + "filename" : "ic_goods_add-1.png", + "scale" : "1x" }, { "idiom" : "universal", + "filename" : "ic_goods_add.png", "scale" : "2x" }, { "idiom" : "universal", + "filename" : "ic_goods_add-2.png", "scale" : "3x" } ], diff --git a/ios/bqseller/Images.xcassets/ic_goods_add.imageset/ic_goods_add-1.png b/ios/bqseller/Images.xcassets/ic_goods_add.imageset/ic_goods_add-1.png new file mode 100644 index 0000000..38f9464 Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_goods_add.imageset/ic_goods_add-1.png differ diff --git a/ios/bqseller/Images.xcassets/ic_goods_add.imageset/ic_goods_add-2.png b/ios/bqseller/Images.xcassets/ic_goods_add.imageset/ic_goods_add-2.png new file mode 100644 index 0000000..38f9464 Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_goods_add.imageset/ic_goods_add-2.png differ diff --git a/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/Contents.json index 7a9675e..8872bda 100644 --- a/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/Contents.json +++ b/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/Contents.json @@ -2,15 +2,17 @@ "images" : [ { "idiom" : "universal", - "scale" : "1x", - "filename" : "ic_goods_reduce.png" + "filename" : "ic_goods_reduce-1.png", + "scale" : "1x" }, { "idiom" : "universal", + "filename" : "ic_goods_reduce.png", "scale" : "2x" }, { "idiom" : "universal", + "filename" : "ic_goods_reduce-2.png", "scale" : "3x" } ], diff --git a/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/ic_goods_reduce-1.png b/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/ic_goods_reduce-1.png new file mode 100644 index 0000000..03cdfc8 Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/ic_goods_reduce-1.png differ diff --git a/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/ic_goods_reduce-2.png b/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/ic_goods_reduce-2.png new file mode 100644 index 0000000..03cdfc8 Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_goods_reduce.imageset/ic_goods_reduce-2.png differ diff --git a/ios/bqseller/Images.xcassets/ic_left_about.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_left_about.imageset/Contents.json new file mode 100644 index 0000000..aae78d5 --- /dev/null +++ b/ios/bqseller/Images.xcassets/ic_left_about.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_left_about.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "ic_left_about.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "ic_left_about.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_left_about.imageset/ic_left_about.png b/ios/bqseller/Images.xcassets/ic_left_about.imageset/ic_left_about.png new file mode 100644 index 0000000..cef6ad5 Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_left_about.imageset/ic_left_about.png differ diff --git a/ios/bqseller/Images.xcassets/ic_left_addr.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_left_addr.imageset/Contents.json new file mode 100644 index 0000000..cf8f6ec --- /dev/null +++ b/ios/bqseller/Images.xcassets/ic_left_addr.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "ic_left_addr.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_left_addr.imageset/ic_left_addr.png b/ios/bqseller/Images.xcassets/ic_left_addr.imageset/ic_left_addr.png new file mode 100644 index 0000000..4d65b6c Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_left_addr.imageset/ic_left_addr.png differ diff --git a/ios/bqseller/Images.xcassets/ic_left_coupon.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_left_coupon.imageset/Contents.json new file mode 100644 index 0000000..b31832a --- /dev/null +++ b/ios/bqseller/Images.xcassets/ic_left_coupon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_left_coupon.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_left_coupon.imageset/ic_left_coupon.png b/ios/bqseller/Images.xcassets/ic_left_coupon.imageset/ic_left_coupon.png new file mode 100644 index 0000000..fce8c7b Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_left_coupon.imageset/ic_left_coupon.png differ diff --git a/ios/bqseller/Images.xcassets/ic_left_order.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_left_order.imageset/Contents.json new file mode 100644 index 0000000..2d6776f --- /dev/null +++ b/ios/bqseller/Images.xcassets/ic_left_order.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_left_order.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_left_order.imageset/ic_left_order.png b/ios/bqseller/Images.xcassets/ic_left_order.imageset/ic_left_order.png new file mode 100644 index 0000000..57e4d5a Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_left_order.imageset/ic_left_order.png differ diff --git a/ios/bqseller/Images.xcassets/ic_left_service.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_left_service.imageset/Contents.json new file mode 100644 index 0000000..9252d89 --- /dev/null +++ b/ios/bqseller/Images.xcassets/ic_left_service.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_left_service.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_left_service.imageset/ic_left_service.png b/ios/bqseller/Images.xcassets/ic_left_service.imageset/ic_left_service.png new file mode 100644 index 0000000..88a38bf Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_left_service.imageset/ic_left_service.png differ diff --git a/ios/bqseller/Images.xcassets/ic_left_setting.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_left_setting.imageset/Contents.json new file mode 100644 index 0000000..395edcb --- /dev/null +++ b/ios/bqseller/Images.xcassets/ic_left_setting.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_left_setting.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_left_setting.imageset/ic_left_setting.png b/ios/bqseller/Images.xcassets/ic_left_setting.imageset/ic_left_setting.png new file mode 100644 index 0000000..56b1896 Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_left_setting.imageset/ic_left_setting.png differ diff --git a/ios/bqseller/Images.xcassets/ic_left_shell.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_left_shell.imageset/Contents.json new file mode 100644 index 0000000..e825757 --- /dev/null +++ b/ios/bqseller/Images.xcassets/ic_left_shell.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_left_shell.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_left_shell.imageset/ic_left_shell.png b/ios/bqseller/Images.xcassets/ic_left_shell.imageset/ic_left_shell.png new file mode 100644 index 0000000..1453a2e Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_left_shell.imageset/ic_left_shell.png differ diff --git a/ios/bqseller/Images.xcassets/ic_logo_circle.imageset/Contents.json b/ios/bqseller/Images.xcassets/ic_logo_circle.imageset/Contents.json new file mode 100644 index 0000000..404f11c --- /dev/null +++ b/ios/bqseller/Images.xcassets/ic_logo_circle.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_logo_circle.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/bqseller/Images.xcassets/ic_logo_circle.imageset/ic_logo_circle.png b/ios/bqseller/Images.xcassets/ic_logo_circle.imageset/ic_logo_circle.png new file mode 100644 index 0000000..a752115 Binary files /dev/null and b/ios/bqseller/Images.xcassets/ic_logo_circle.imageset/ic_logo_circle.png differ diff --git a/package.json b/package.json index 6a52180..3e19857 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ }, "dependencies": { "react-native": "^0.12.0", + "react-native-htmlview": "^0.2.0", "react-native-refresher": "^0.1.1", + "react-native-store": "0.0.9", "react-native-swiper": "^1.3.0", "react-timer-mixin": "^0.13.3" } diff --git a/screenshot/rn1.png b/screenshot/rn1.png index 6f44c7b..543debe 100644 Binary files a/screenshot/rn1.png and b/screenshot/rn1.png differ diff --git a/screenshot/rn2.png b/screenshot/rn2.png index ade3f00..4ef1115 100644 Binary files a/screenshot/rn2.png and b/screenshot/rn2.png differ diff --git a/screenshot/rn3.png b/screenshot/rn3.png index a1ce0fb..86d96a8 100644 Binary files a/screenshot/rn3.png and b/screenshot/rn3.png differ diff --git a/screenshot/rn4.png b/screenshot/rn4.png index 6cdb9be..42a63b7 100644 Binary files a/screenshot/rn4.png and b/screenshot/rn4.png differ