CourseDetails.js 2.6 KB

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