1.创建MineHeaderView.js

/**
* 个人中心头部内容
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
TouchableOpacity
} from 'react-native'; // 导入系统类
var Dimensions = require('Dimensions');
var screenW = Dimensions.get('window').width; // ES5
var HeaderView = React.createClass({
render() {
return (
<View style={styles.container}>
{this.renderTopView()}
{this.renderBottomView()}
</View>
);
}, renderTopView(){
return(
<View style={styles.topViewStyle}>
<Image source={{uri:'see'}} style={styles.leftIconStyle} />
<View style={styles.conterViewStyle}>
<Text style={{fontSize:18,color:'white',fontWeight:'bold'}}>京东电商</Text>
<Image source={{uri:'avatar_vip'}} style={{width:17,height:17}} />
</View>
<Image source={{uri:'icon_cell_rightArrow'}} style={{width:8,height:13,marginRight:8}} />
</View>
)
},
renderBottomView(){
return(
<View style={styles.bottomViewStyle}>
{this.renderBottomItem()}
</View>
)
}, renderBottomItem(){
// 组件数组
var items = [];
// 数据
var dataArr = [{'number':'100', 'title':'购物券'},{'number':'12', 'title':'评价'},{'number':'50', 'title':'收藏'}];
// 遍历创建组件转入数组
for (var i=0;i<dataArr.length;i++){
var data = dataArr[i];
items.push(
<TouchableOpacity key={i}>
<View style={styles.bottomInnerViewStyle}>
<Text style={{color:'white'}}>{data.number}</Text>
<Text style={{color:'white'}}>{data.title}</Text>
</View>
</TouchableOpacity>
);
}
return items;
},
}); const styles = StyleSheet.create({
container: {
height:200,
backgroundColor:'rgb(255,96,0)'
},
topViewStyle:{
flexDirection:'row',
marginTop:80,
alignItems:'center',
justifyContent:'space-around'
},
leftIconStyle:{
width:70,
height:70,
borderRadius:35,
borderWidth:3,
borderColor:'rgba(0,0,0,0.2)',
},
conterViewStyle:{
flexDirection:'row',
width:screenW * 0.6,
},
bottomViewStyle:{
flexDirection:'row',
position:'absolute',
bottom:0,
},
bottomInnerViewStyle:{
width:(screenW/3)+1,
height:40,
backgroundColor:'rgba(255,255,255,0.4)', justifyContent:'center',
alignItems:'center', borderRightWidth:1,
borderRightColor:'white'
}
}); // 输出
module.exports = HeaderView;

2.Mine.js使用这个组件

/**
* 我的
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
ScrollView
} from 'react-native'; /*======导入外部组件类======*/
var MyCell = require('./CommonMyCell');
var MiddleView = require('./MineMiddleView');
var HeaderView = require('./MineHeaderView'); // ES5
var Mine = React.createClass({
render() {
return (
<ScrollView style={styles.scrollViewStyle}>
<HeaderView />
<View style={{marginTop:20}}>
<MyCell
leftIconName="collect"
leftTitle="我的订单"
rightTitle="查看全部订单"
/>
<MiddleView />
</View>
<View style={{marginTop:20}}>
<MyCell
leftIconName="draft"
leftTitle="钱包"
rightTitle="账号余额:¥100.88"
/>
</View>
<View style={{marginTop:20}}>
<MyCell
leftIconName="voucher"
leftTitle="抵用券"
rightTitle="10张"
/>
</View>
<View style={{marginTop:20}}>
<MyCell
leftIconName="mall"
leftTitle="积分商城"
rightTitle=""
/>
</View>
<View style={{marginTop:20}}>
<MyCell
leftIconName="recommend"
leftTitle="今日推荐"
rightTitle=""
/>
</View>
</ScrollView>
);
}
}); const styles = StyleSheet.create({
scrollViewStyle:{ }
}); // 输出
module.exports = Mine;

3.效果图

React Native商城项目实战11 - 个人中心头部内容的更多相关文章

  1. React Native商城项目实战10 - 个人中心中间内容设置

    1.新建一个MineMiddleView.js,专门用于构建中间的内容 /** * 个人中心中间内容设置 */ import React, { Component } from 'react'; im ...

  2. React Native商城项目实战09 - 个人中心自定义cell

    1.新建组件CommonMyCell.js /** * 个人中心自定义cell */ import React, { Component } from 'react'; import { AppReg ...

  3. React Native商城项目实战12 - 首页头部内容

    1.HomeTopView为首页头部内容,HomeTopListView为HomeTopView子视图. 2.HomeTopView.js /** * 首页头部内容 */ import React, ...

  4. React Native商城项目实战04 - 封装TabNavigator.Item的创建

    1.Main.js /** * 主页面 */ import React, { Component } from 'react'; import { StyleSheet, Text, View, Im ...

  5. React Native商城项目实战02 - 主要框架部分(tabBar)

    1.安装插件,cd到项目根目录下执行: $ npm i react-native-tab-navigator --save 2.主框架文件Main.js /** * 主页面 */ import Rea ...

  6. React Native商城项目实战01 - 初始化设置

    1.创建项目 $ react-native init BuyDemo 2.导入图片资源 安卓:把文件夹放到/android/app/src/main/res/目录下,如图: iOS: Xcode打开工 ...

  7. React Native商城项目实战07 - 设置“More”界面导航条

    1.More/More.js /** * 更多 */ import React, { Component } from 'react'; import { AppRegistry, StyleShee ...

  8. React Native商城项目实战05 - 设置首页的导航条

    1.Home.js /** * 首页 */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Te ...

  9. React Native商城项目实战06 - 设置安卓中的启动页

    1.Main 目录下新建LaunchImage.js: /** * 启动页 */ import React, { Component } from 'react'; import { AppRegis ...

随机推荐

  1. ubuntu 配置 tftp 服务器

    一. 安装 tftp 1.1. 安装 tftp 所需的软件. a. 安装 tftp-hpa,tftpd-hpa,前者是客户端,后者是服务程序, 在终端下输入 sudo apt-get install ...

  2. 4-2如何判断字符串a是否以字符串b开头或结尾

    1.相关介绍 1.1修改文件权限和查看文件权限 在windows平台实验时 os.chmod()无法将文件权限修改为可执行,暂不深究如何实现.在linux平台进行测试. (1)创建三个文件 pytho ...

  3. HDU 1594 find the max

    数序问题. 题意是说 一个数列 a1,a2,--ai,--an;  x=i , y = ai:找两个点斜率绝对值.!最大. 第一次没找绝对值,--认真读题. .. x 每次加1 . 仅仅须要找 相邻的 ...

  4. redis的线程模型 与 压力测试

    当客户端与ServerSocket产生连接时,会产生一个 AE_REABLE / AE_WRITABL 事件, 多个Socket可能并发产生不同的事件,IO多路复用程序会监听这些Socket,按照顺序 ...

  5. luogu P5338 [TJOI2019]甲苯先生的滚榜

    传送门 首先,排名系统,一看就知道是原题,可以上平衡树来维护 然后考虑一种比较朴素的想法,因为我们要知道排名在一个人前面的人数,也就是AC数比他多的人数+AC数一样并且罚时少的人数,所以考虑维护那两个 ...

  6. UDP即时小通信

    package 第十二章; import java.io.IOException; import java.net.*; public class UDPServer { /*** * * @para ...

  7. ssm中web配置各框架的配置文件路径方式

    一.在web文件中配置 使用逗号隔开 二.在applicationContext.xml文件中配置或引用 以下是引用方式 注: <import />标签要放在所有bean配置的最前面.  

  8. Cockpit- Linux 服务器管理接口

    Cockpit- Linux 服务器管理接口 功能 它包含 systemd 服务管理器. 有一个用于故障排除和日志分析的 Journal 日志查看器. 包括 LVM 在内的存储配置比以前任何时候都要简 ...

  9. MySQL存储过程、触发器、自定义函数、事务

    1.存储过程 MySQL中存储过程的参数中有IN.OUT.INOUT类型,但是函数的参数只能是IN类型的. “in” 参数:跟 C 语言的函数参数的值传递类似, MySQL 存储过程内部可能会修改此参 ...

  10. egon消失的一天,空虚寂寞冷,苑模块的时间

    一.时间模块time python有三种表达时间的形式:时间戳.格式化字符串输出和元组. 时间戳:从1970年1月1日00:00:00开始按秒计算的偏移量,返回值是一个float型. 格式化字符串输出 ...