CourseDetails.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. courseDetails.getCourseDetails(courseId).success(res => {
  27. console.log('列表',res.data)
  28. const courseList = res.data.course;
  29. const wareList = res.data.wareList;
  30. this.setState({
  31. courseList,
  32. wareList
  33. })
  34. });
  35. }
  36. state = {
  37. fullStyle: {},
  38. lefts: 0,
  39. courseList: {},
  40. wareList: {},
  41. uri: 'http://chimee.org/vod/1.mp4'
  42. }
  43. render() {
  44. return (
  45. <View style={{backgroundColor: '#F0F1F5', width: '100%', height: '100%', position: 'relative'}}>
  46. <ScrollView>
  47. <View>
  48. <VideoExplain
  49. full={this.full.bind(this)}
  50. uri={ this.state.uri }
  51. dataList={ this.state.courseList }
  52. ref={view => (this.video = view)} //设置ID
  53. videoback={this.back.bind(this) }
  54. />
  55. </View>
  56. <View style={ this.state.fullStyle }>
  57. <CourseListRow title={'课件'} wareList={ this.state.wareList} changeUri={ this.changeUri.bind(this) }></CourseListRow>
  58. {/* <CourseListLine title={'课件'} wareList={ this.state.wareList}></CourseListLine> */}
  59. <Comment title={ '全部评论' }></Comment>
  60. </View>
  61. </ScrollView>
  62. <Order left={ this.state.lefts }></Order>
  63. </View>
  64. );
  65. }
  66. back(){
  67. this.props.navigation.goBack()
  68. }
  69. full(isFull){
  70. if(isFull) {
  71. // 全屏时隐藏多余的view
  72. this.setState({
  73. fullStyle: {},
  74. lefts: 0
  75. })
  76. }else {
  77. // 全屏时隐藏多余的view
  78. this.setState({
  79. fullStyle: {
  80. display: 'none'
  81. },
  82. lefts: '-100%'
  83. })
  84. }
  85. }
  86. changeUri(uri) {
  87. console.log(uri)
  88. this.setState({
  89. uri
  90. })
  91. // 开始播放
  92. this.video.start();
  93. }
  94. }
  95. const styles = StyleSheet.create({
  96. });