IndexBanner.js 4.89 KB
/**
 * Created by mac on 2017/5/7.
 */
import React, {Component} from "react";
import {Image, StyleSheet, Text, TouchableOpacity, View} from "react-native";
import {height, width} from "../../utils/getSize";
// import Carousel from "react-native-looped-carousel";
import PropTypes from 'prop-types';
// export default class IndexBanner extends Component {
//   // static contextTypes = {
//   //   navigator: PropTypes.object,
//   // };
//
//   constructor() {
//     super();
//     this.state = {
//       adList: []
//     };
//   }
//
//
//   // 渲染顶部跑马灯
//   render() {
//     if(this.props.data.length === 0) {
//       return (
//         <View style={{height: 75}}>
//         </View>
//       );
//     }
//     return (
//       <View>
//         <Carousel style={{width: width, height: width*0.46667}}
//                   activeDotColor="white"
//                   autoplay
//                   bullets
//                   delay={2000}
//                   bulletsContainerStyle={{width: 40, marginTop: 10}}
//                   bulletStyle={{
//                     height: 7,
//                     width: 7,
//                     borderRadius: 3.5,
//                     backgroundColor: '#dddddd',
//                     borderWidth: 0,
//                     margin: 5
//                   }}
//                   chosenBulletStyle={{
//                     height: 7,
//                     width: 7,
//                     borderRadius: 3.5,
//                     backgroundColor: 'white',
//                     borderWidth: 0,
//                     margin: 5
//                   }}
//         >
//           {
//             this.props.data.map((v, i) =>
//               <TouchableOpacity key={v.id} onPress={() => toPage(this, v.objectType, v.objectId)}>
//                 <Image style={{width: width, height: width*0.46667}} resizeMode="stretch" source={{uri: v.pictureUrl+'?x-oss-process=image/resize,w_750,h_350/quality,q_90'}}/>
//               </TouchableOpacity>
//             )
//           }
//         </Carousel>
//       </View>
//     )
//   };
// }

// 跳转至某页面,类型+ID
export function toPage(that, type, id){
  if (type === "ARTICLE") {
    // 跳转至文章页面
    // that.context.navigator.push({location: '/column/detail', passProps: {id: id}})
  } else if (type === "CATEGORY") {
    // 跳转至文章列表页面
    // that.context.navigator.push({location: '/column/anego', passProps: {id: id}})
  } else if (type === "COURSE") {
      // console.warn("classgrade" + global.moment(new Date()).format('HH:mm:ss'));
    // 跳转至课程页面
    that.push('ClassGrade',{id: id, type: "payNoAlready"});
    // that.context.navigator.push({location: "/video/classgrade", passProps: {id: id, type: "payNoAlready"}})
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'rgb(241,242,243)',
  },
  text: {
    color: '#fff',
    fontSize: 30,
    fontWeight: 'bold',
  },
  columnHori: {
    height: 110,
    backgroundColor: 'white',
    flexDirection: 'row',
  },
  columnHoriOne: {
    width: 50,
    marginLeft: 15,
    marginRight: 15,
    alignItems: 'center',
    justifyContent: 'center',
  },
  columnText: {
    fontSize: 12,
    color: '#333333'
  },
  img: {
    width: 50,
    height: 50,
    marginBottom: 10
  },
  content: {
    marginTop: 10,
  },
  titleBar: {
    height: 44,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    backgroundColor: 'white',
    paddingLeft: 15,
    paddingRight: 15,
    borderWidth: 1,
    borderLeftWidth: 0,
    borderTopWidth: 0,
    borderBottomWidth: 1,
    borderRightWidth: 0,
    borderBottomColor: '#dddddd'
  },
  titleLeft: {
    flexDirection: 'row',
    height: 44,
    alignItems: 'center'
  },
  titleRight: {
    flexDirection: 'row',
    height: 44,
    alignItems: 'center'
  },
  iconBod: {
    width: 14,
    height: 14,
    backgroundColor: 'black',
    marginRight: 5,
  },
  fontTitleText: {
    fontSize: 14,
    color: '#333333'
  },
  fontTitleInfo: {
    fontSize: 14,
    color: '#333333',

  },
  fontTitle: {},
  titleBorder: {
    borderWidth: 1,
    borderLeftWidth: 1,
    borderTopWidth: 0,
    borderBottomWidth: 0,
    borderRightWidth: 0,
    height: 14,
    marginHorizontal: 5,
  },
  moreText: {
    fontSize: 12,
    color: "#999999",
    marginRight: 10
  },
  body: {
    flex: 1,
    paddingRight: 7.5,
    paddingLeft: 7.5,
    backgroundColor: '#FFFFFF',
    flexWrap: 'wrap',
    flexDirection: 'row',
    marginTop: 1
  },
  bodyBlock: {
    marginTop: 10,
    marginBottom: 10,
    marginLeft: 7.5,
    marginRight: 7.5,
    flexDirection: 'column',
    height: 150
  },
  imgBig: {

    height: 95,
    borderRadius: 5,
    overflow: "hidden"
  },
  fontBlockTitle: {
    fontSize: 15,
    color: '#333333',
    fontWeight: 'bold',
    marginTop: 10,
    marginBottom: 10
  },
  fontBlockInfo: {
    fontSize: 10,
    color: "#999999"
  }
});