CourseDetails.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import React, { Component } from "react";
  9. import {
  10. StyleSheet,
  11. Text,
  12. View,
  13. Image,
  14. ScrollView,
  15. FlatList
  16. } from "react-native";
  17. import VideoExplain from './components/VideoExplain'
  18. import CourseListRow from './components/CourseListRow'
  19. import CourseListLine from './components/CourseListLine'
  20. import Comment from './components/Comment'
  21. import Order from './components/Order'
  22. import courseDetails from './services/courseDetails'
  23. export default class CourseDetails extends Component {
  24. componentDidMount() {
  25. const { courseId } = this.props.navigation.state.params;
  26. console.log(courseId)
  27. courseDetails.getCourseDetails(courseId).success(res => {
  28. console.log('列表',res.data)
  29. this.setState({
  30. courseList: 222
  31. })
  32. });
  33. }
  34. state = {
  35. fullStyle: {},
  36. lefts: 0,
  37. courseList: 111
  38. }
  39. render() {
  40. return (
  41. <View style={{backgroundColor: '#F0F1F5', width: '100%', height: '100%', position: 'relative'}}>
  42. <ScrollView>
  43. <View>
  44. <VideoExplain
  45. full={this.full.bind(this)}
  46. title={'同步辅导语文一年级下册'}
  47. details={'汉字,作为象形文字,是中华文化的载体,本课程从甲骨文开始,让孩子爱上识字爱上文字的美。了解文字…'}
  48. uri={'http://chimee.org/vod/1.mp4'}
  49. dataList={ this.state.courseList }
  50. videoback={this.back.bind(this) }
  51. />
  52. </View>
  53. <View style={ this.state.fullStyle }>
  54. <CourseListRow title={'课件'}></CourseListRow>
  55. <CourseListLine title={'课件'}></CourseListLine>
  56. <Comment title={ '全部评论' }></Comment>
  57. </View>
  58. </ScrollView>
  59. <Order left={ this.state.lefts }></Order>
  60. </View>
  61. );
  62. }
  63. back(){
  64. this.props.navigation.goBack()
  65. }
  66. full(isFull){
  67. if(isFull) {
  68. // 全屏时隐藏多余的view
  69. this.setState({
  70. fullStyle: {},
  71. lefts: 0
  72. })
  73. }else {
  74. // 全屏时隐藏多余的view
  75. this.setState({
  76. fullStyle: {
  77. display: 'none'
  78. },
  79. lefts: '-100%'
  80. })
  81. }
  82. }
  83. }
  84. const styles = StyleSheet.create({
  85. });