Explorar el Código

Merge branch 'master' of http://gogs.efunbox.cn/Rorschach/efunbox-mobile-8

zhangmengjie hace 5 años
padre
commit
5520806c5b

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 70 - 0
android/app/src/main/assets/index.android.bundle


BIN
android/app/src/main/res/drawable-mdpi/pages_images_common_alipay.png


BIN
android/app/src/main/res/drawable-xhdpi/pages_images_common_alipay.png


BIN
android/app/src/main/res/drawable-xxhdpi/pages_images_common_alipay.png


+ 2 - 4
pages/BasePage.js

@@ -45,12 +45,10 @@ export default class BasePage extends Component<Props> {
     return width;
   }
 
-  toNextPage= (params) => {
+  toNextPage= (params,obj) => {
     //跳转之前移除当前界面的监听
     this.removeListener();
-    console.log('跳转参数',params)
-    console.log(this.props)
-    this.props.navigation.navigate(params);
+    this.props.navigation.navigate(params,obj);
   }
   Toast(params) {
     AndroidUtil.showToast(params, AndroidUtil.SHORT);

+ 14 - 3
pages/CourseDetails.js

@@ -35,18 +35,29 @@ export default class CourseDetails extends Component {
         wareList
       })
     });
+    courseDetails.getPostsList(courseId).success(res => {
+      console.log('评论列表', res.data)
+      const postsList = res.data.list;
+      console.log(postsList)
+      this.setState({
+        postsList,
+      })
+    }).fail(error => {
+      console.log('失败', error)
+    })
   }
   state = {
     fullStyle: {},
     lefts: 0,
     courseList: {},
     wareList: {},
+    postsList: [],
     uri: 'http://chimee.org/vod/1.mp4'
   }
   render() {
     return (
       <View style={{backgroundColor: '#F0F1F5', width: '100%', height: '100%', position: 'relative'}}>
-        <ScrollView>
+        <ScrollView keyboardShouldPersistTaps="handled">
           <View>
             <VideoExplain 
             full={this.full.bind(this)}
@@ -59,10 +70,10 @@ export default class CourseDetails extends Component {
           <View style={ this.state.fullStyle }>
             <CourseListRow title={'课件'} wareList={ this.state.wareList} changeUri={ this.changeUri.bind(this) }></CourseListRow>
             {/* <CourseListLine title={'课件'} wareList={ this.state.wareList}></CourseListLine> */}
-            <Comment title={ '全部评论' }></Comment>
+            <Comment title={ '全部评论' }  postsList={ this.state.postsList } courseId= { this.state.courseList.id }></Comment>
           </View> 
         </ScrollView>
-        <Order left={ this.state.lefts }></Order>
+        {/* <Order left={ this.state.lefts }></Order> */}
       </View>
     );
   }

+ 110 - 26
pages/components/Comment.js

@@ -7,16 +7,24 @@ import {
   TextInput,
   TouchableOpacity
 } from "react-native";
-
+import courseDetails from '../services/courseDetails'
 export default class Comment extends Component {
   constructor(props) {
     super(props);
     this.state = { 
       text: '',
       input: false,
-      default: '写评论'
+      default: '写评论',
+      postsList: [],
+      postsId: ''
     };
   }
+  componentWillReceiveProps(nextProps) {
+    console.log('--------', nextProps)
+    this.setState({
+      postsList: nextProps.postsList
+    })
+  }
   render() {
     return (
       <View style={styles.courseComment}>
@@ -29,28 +37,11 @@ export default class Comment extends Component {
             </View>
           </TouchableOpacity>
         </View>
-        <View style={[ styles.padding ]}>
-          <View style={[ styles.title ]}>
-            <View style={[ styles.center ]}>
-                <Image style={[styles.headImg ]}></Image>
-                <View>
-                  <Text style={{ fontSize: 16, color: '#373737' }}>小幸运</Text>
-                  <Text style={{ fontSize: 14, color: '#7F7F7F' } }>2019-07-05</Text>
-                </View>
-            </View>
-            <View style={[ styles.center ]}>
-              <Image source={require('../images/courseDetails/reply.png')} style={styles.reply} />
-              <Text>回复</Text>
-            </View>
-          </View>
-          <View style={ styles.padding }>
-            <Text>爱上识字爱上文字的美,了解文字,幽默风趣的画风,动画识字展示让识字更有趣,跟喜欢。</Text>
-          </View>
-          <View style={[ styles.padding, styles.column ]}>
-            <Text style={ styles.color }>卡通小熊</Text>
-            <Text>爱上识字爱上文字的美,了解文字,幽默风趣的画风,动画识字展示让识字更有趣,跟喜欢。</Text>
-          </View>
-        </View>
+        { 
+          this.state.postsList.map((item, index) => 
+            this.listRender(item, index) 
+          ) 
+        }
         {
             this.state.input ?
             <View style={[ styles.input, this.state.fullStyle]}>
@@ -63,7 +54,7 @@ export default class Comment extends Component {
               autoFocus = {true}
               defaultValue= {this.state.default}
             />
-            <Text style={{ color: '#58A8FA', fontSize: 18}}>发送</Text>
+            <Text style={{ color: '#58A8FA', fontSize: 18}} onPress={() => this.send()}>发送</Text>
           </View>
           :
           null
@@ -71,10 +62,103 @@ export default class Comment extends Component {
       </View>
     );
   }
-  comments() {
+  listRender(item, index) {
+    return (
+      <View style={[ styles.padding ]} key={ index }>
+        <View style={[ styles.title ]}>
+          <View style={[ styles.center ]}>
+              <Image style={[styles.headImg ]}></Image>
+              <View>
+                <Text style={{ fontSize: 16, color: '#373737' }}>{item.posts.columnNames}</Text>
+                <Text style={{ fontSize: 14, color: '#7F7F7F' } }>2019-07-05</Text>
+              </View>
+          </View>
+          <TouchableOpacity onPress={() => this.comments(item.posts.id)}>
+            <View style={[ styles.center ]}>
+              <Image source={require('../images/courseDetails/reply.png')} style={styles.reply} />
+              <Text>回复</Text>
+            </View>
+          </TouchableOpacity>
+      </View>
+      <View style={ styles.padding }>
+        <Text>{item.posts.content}</Text>
+      </View>
+      { 
+        item.replies.map((items, indexs) => 
+          this.repliesList(items, indexs) 
+        ) 
+      }
+    </View>
+    )
+  }
+  repliesList (items, indexs) {
+    return (
+      <View style={[ styles.padding, styles.column ]}  key={ indexs }>
+        <Text style={ styles.color }>卡通小熊</Text>
+        <Text>{ items.content }</Text>
+      </View>
+    )
+  }
+  comments(id) {
     this.setState({
       input: true
     })
+    if (id) {
+      this.setState({
+        postsId: id
+      })
+    }
+  }
+  send() {
+    const columnId = this.props.courseId;
+    const content = this.state.text;
+    const postsId = this.state.postsId;
+    console.log(postsId)
+    if (!content) {
+      alert('请输入内容')
+      return false
+    }
+    if (!postsId) {
+      courseDetails.addCommentList({
+        columnId,
+        columnNames: "卡通小熊",
+        content
+      }).then(res => {
+        console.log(res)
+        if ( res.code == 200) {
+          courseDetails.getPostsList(columnId).success(res => {
+            const postsList = res.data.list;
+            this.setState({
+              input: false,
+              postsList,
+              text: ''
+            })
+          }).fail(error => {
+            console.log('失败', error)
+          })
+        }
+      }).catch( err => console.log(err))
+    }else {
+      courseDetails.addReplyList({
+        postsId,
+        content
+      }).then(res => {
+        console.log(res)
+        if ( res.code == 200) {
+          courseDetails.getPostsList(columnId).success(res => {
+            const postsList = res.data.list;
+            console.log('==========', postsList)
+            this.setState({
+              input: false,
+              postsList,
+              text: ''
+            })
+          }).fail(error => {
+            console.log('失败', error)
+          })
+        }
+      }).catch( err => console.log(err))
+    }
   }
 }
 

+ 72 - 31
pages/components/MainPage.js

@@ -41,7 +41,11 @@ export default class MainPage extends BasePage {
   }
 
   componentDidMount() {
-    LibraryUrl.getIndex('PRESCHOOL').success(res => {
+    this.updateRender('PRIMARY_SCHOOL')
+  }
+
+  updateRender(index) {
+    LibraryUrl.getIndex(index).success(res => {
       console.log(res)
       const monthTopicTitle = res.data.monthTopic.zone.title;
       const monthTopicScroll = res.data.monthTopic.zoneCourseVOList;
@@ -57,6 +61,7 @@ export default class MainPage extends BasePage {
       // console.log(typeof listData)
       // console.log(listData)
       // console.log(listData.length)
+      let scheduleWeek = schedule[0].featureMap ? schedule[0].featureMap.weekSeq : '1'
       this.setState({
         // listData: listData.length? listData : [],
         hotCourse,
@@ -64,9 +69,12 @@ export default class MainPage extends BasePage {
         monthTopicScroll,
         schedule,
         recommend,
-        banner
+        banner,
+        scheduleWeek
       })
       console.log(this.state.banner)
+    }).fail(() => {
+      alert(1111)
     })
   }
 
@@ -79,24 +87,28 @@ export default class MainPage extends BasePage {
     recommend: [],
     listData: [],
     banner: [],
-    currentSwitch: { title: '学前', param: 'PRESCHOOL' },
+    currentSwitch: { title: '小学', param: 'PRIMARY_SCHOOL' },
     switchList: [
-      { title: '幼儿园', param: 'KINDERGARTEN' },
+      // { title: '幼儿园', param: 'KINDERGARTEN' },
       { title: '学前', param: 'PRESCHOOL' },
       { title: '小学', param: 'PRIMARY_SCHOOL' },
       { title: '中学', param: 'MIDDLE_SCHOOL' },
-    ]
+    ],
+    scheduleWeek: '1'
   }
 
   renderBtn = (item, index) => {
     return (
-      this.state.currentSwitch.param === item.param
-        ?
-        null
-        :
-        <TouchableOpacity onPress={() => this.switchGrade(index)} key={index} style={index === 1 ? styles.gradeItemMid : styles.gradeItem}>
-          <Text style={styles.gradeText}>{item.title}</Text>
-        </TouchableOpacity>
+      // this.state.currentSwitch.param === item.param
+      //   ?
+      //   null
+      //   :
+      //   <TouchableOpacity onPress={() => this.switchGrade(index)} key={index} style={index === 1 ? styles.gradeItemMid : styles.gradeItem}>
+      //     <Text style={styles.gradeText}>{item.title}</Text>
+      //   </TouchableOpacity>
+      <TouchableOpacity onPress={() => this.switchGrade(index)} key={index} style={index === 1 ? styles.gradeItemMid : styles.gradeItem}>
+        <Text style={styles.gradeText}>{item.title}</Text>
+      </TouchableOpacity>
     )
   }
 
@@ -106,6 +118,8 @@ export default class MainPage extends BasePage {
       currentSwitch: obj
     })
     this.hideGradeMenu()
+    // if (obj.param === this.state.currentSwitch.param) return
+    this.updateRender(obj.param)
   }
 
   render() {
@@ -122,7 +136,7 @@ export default class MainPage extends BasePage {
           renderSectionHeader={this.sectionTitle}
           onScroll={this.hideGradeMenu}
         /> */}
-        <ScrollView style={{ height: Dimensions.height }} showsVerticalScrollIndicator = {false} onScroll={this.hideGradeMenu} >
+        <ScrollView style={{ height: Dimensions.height }} showsVerticalScrollIndicator={false} onScroll={this.hideGradeMenu} >
           {this.headerorfooterComponent()}
           {this.getSwiperElement()}
           {this.getScheduleElement()}
@@ -138,15 +152,6 @@ export default class MainPage extends BasePage {
                 ...styles.callUpGrade,
                 opacity: this.state.fadeAnim
               }}>
-              {/* <TouchableOpacity style={styles.gradeItem}>
-                <Text style={styles.gradeText}>小学</Text>
-              </TouchableOpacity>
-              <TouchableOpacity style={styles.gradeItemMid}>
-                <Text style={styles.gradeText}>学前</Text>
-              </TouchableOpacity>
-              <TouchableOpacity style={styles.gradeItem}>
-                <Text style={styles.gradeText}>中学</Text>
-              </TouchableOpacity> */}
               {this.state.switchList.map((item, index) => this.renderBtn(item, index))}
             </Animated.View>
           ) : (
@@ -231,6 +236,7 @@ export default class MainPage extends BasePage {
   // 渲染课程表
   getScheduleElement() {
     let renderScheduleItem = (item, index) => {
+      const id = item.boothId
       return (
         <TouchableOpacity
           style={{
@@ -238,23 +244,50 @@ export default class MainPage extends BasePage {
             height: Dimensions.getHeight(86),
             marginRight: 12
           }}
-          onPress={() => this.toNextPage('SchedulePage')}
+          onPress={() => this.toNextPage('SchedulePage',{id})}
           key={index}
           activeOpacity={1}
         >
-          <Image
+          <ImageBackground
             source={{
               uri: item.boothContent
             }}
             key={index}
             style={{
               flex: 1,
-              justifyContent: "center",
-              alignItems: "center",
+              // justifyContent: "center",
+              // alignItems: "center",
               borderRadius: 10
-
             }}
-          />
+          >
+            {
+              item.operationContent === 'KINDERGARTE'
+                ?
+                null
+                :
+                <View style={{
+                  width: Dimensions.getWidth(90),
+                  height: Dimensions.getHeight(45),
+                  marginLeft: Dimensions.getWidth(15),
+                  marginTop: Dimensions.getHeight(15),
+
+                  justifyContent: 'center',
+                  alignItems: 'center'
+                }}>
+                  <Text style={{
+                    color: '#fff',
+                    fontSize: 18,
+                  }}>{item.title}</Text>
+                  <Text
+                    style={{
+                      color: '#fff',
+                      fontSize: 18,
+                    }}
+                  >{item.summary}</Text>
+                </View>
+            }
+
+          </ImageBackground>
         </TouchableOpacity>
       )
     }
@@ -266,8 +299,8 @@ export default class MainPage extends BasePage {
           height: Dimensions.getHeight(160),
         }}
       >
-        <TopicTitle title={'课程表:第一周'} ifTubeShow={true} />
-        <View
+        <TopicTitle title={`课程表:第${this.state.scheduleWeek}周`} ifTubeShow={true} />
+        {/* <View
           style={{
             flex: 2,
             flexDirection: "row",
@@ -276,7 +309,15 @@ export default class MainPage extends BasePage {
           }}
         >
           {this.state.schedule.map((item, index) => renderScheduleItem(item, index))}
-        </View>
+        </View> */}
+        <FlatList
+          data={this.state.schedule}
+          horizontal={true}
+          style={{ paddingLeft: '3.2%' }}
+          renderItem={({ item, index }) => renderScheduleItem(item, index)}
+          keyExtractor={(item, index) => index.toString()}
+          showsHorizontalScrollIndicator={false}
+        />
       </View>
     );
   }

+ 2 - 0
pages/components/SchedulePage.js

@@ -202,6 +202,8 @@ export default class SchedulePage extends BasePage {
     BackHandler.removeEventListener("hardwareBackPress", this.onBackAndroid);
   }
   componentDidMount() {
+    const { id } = this.props.navigation.state.params;
+    alert(id)
     let colorTemp = '';
     let colorIndexTemp = 0;
     const colorList = this.state.colorList;

+ 32 - 0
pages/components/VideoExplain.js

@@ -23,6 +23,7 @@ import CusVideo from "./CusVideo";
 // 获取屏幕宽高
 import { Dimensions } from 'react-native'
 const { height, width } =  Dimensions.get('window');
+import courseDetails from '../services/courseDetails'
 
 export default class VideoExplain extends Component {
   state = {
@@ -36,6 +37,26 @@ export default class VideoExplain extends Component {
     isCollect: true,
     numberLine: 2
   };
+  componentWillReceiveProps(nextProps) {
+    console.log(nextProps.dataList.id)
+    const targetCode = nextProps.dataList.id;
+    courseDetails.getisFavorites({
+      targetCode,
+    }).then(res => {
+      console.log('--------', res)
+      if (res.code == 200 && res.data) {
+        this.setState({
+          collectImage: require('../images/courseDetails/have_collect.png'),
+          isCollect: false
+        })
+      }else {
+        this.setState({
+          collectImage: require('../images/courseDetails/collect.png'),
+          isCollect: true
+        })
+      }
+    }).catch(error => console.log(error))
+  }
 
   render() {
     return (
@@ -161,6 +182,17 @@ export default class VideoExplain extends Component {
         isCollect: true
       })
     }
+    const targetCode = this.props.dataList.id;
+    const templateCode = this.props.dataList.templateCode;
+    const title = this.props.dataList.title;
+    courseDetails.setFavorites({
+      targetCode,
+      templateCode,
+      title,
+      "iconImg": ""
+    }).then(res => {
+      console.log(res)
+    }).catch(error => console.log(error))
   }
   // 分享
   share() {

+ 82 - 3
pages/services/courseDetails.js

@@ -2,7 +2,86 @@ import APIConfig from './api.js';
 import efunRequest from '../utils/efunRequest'
 
 export default class CourseDetails {
-    static getCourseDetails(courseId) {
-      return efunRequest.getHttpRequest().url(`http://ott80testlibrary.yifangjiaoyu.cn/mobile/course/${courseId}`).get();
-    }
+  // 获取课程详细信息
+  static getCourseDetails(courseId) {
+    return efunRequest.getHttpRequest().url(`http://ott80testlibrary.yifangjiaoyu.cn/mobile/course/${courseId}`).get();
+  }
+  // 获取评论列表
+  static getPostsList(columnId) {
+    console.log(columnId)
+    return efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`).header({
+      uid: ''
+    }).params({
+      columnId,
+      pageNo: '',
+      pageSize: ''
+    }).get();
+  }
+  // 收藏
+  static setFavorites(data) {
+    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites`,{
+      method:"POST",
+      headers:{
+        "Accept": "application/json",
+        "Content-Type": "application/json",
+        "uid": ""
+      },
+      body: JSON.stringify(data),
+    })
+    .then((response)=>response.json())
+    // return efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites`).header({
+    //   "Accept" : "application/json",
+    //   "Content-Type" : "application/json",
+    //   "uid": ""
+    // }).data(data).post();
+  }
+  // 获取是否收藏
+  static getisFavorites(data) {
+    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/favorites/isFavorites`,{
+      method:"POST",
+      headers:{
+        "Accept": "application/json",
+        "Content-Type": "application/json",
+        "uid": ""
+      },
+      body: JSON.stringify(data),
+    })
+    .then((response)=>response.json())
+  }
+  // 写评论 
+  static addCommentList(data) {
+    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`,{
+      method:"POST",
+      headers:{
+        "Accept": "application/json",
+        "Content-Type": "application/json",
+        "uid": ""
+      },
+      body: JSON.stringify(data),
+    })
+    .then((response)=>response.json())
+    // return efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`).header({
+    //   "Accept" : "application/json",
+    //   "Content-Type" : "application/json",
+    //   "uid": ""
+    // }).data(data).post();
+  }
+  // 输入评论
+  static addReplyList(data) {
+    return fetch(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts/reply`,{
+      method:"POST",
+      headers:{
+        "Accept": "application/json",
+        "Content-Type": "application/json",
+        "uid": ""
+      },
+      body: JSON.stringify(data),
+    })
+    .then((response)=>response.json())
+    // return efunRequest.getHttpRequest().url(`http://ott80test-base.yifangjiaoyu.cn/mobile/posts`).header({
+    //   "Accept" : "application/json",
+    //   "Content-Type" : "application/json",
+    //   "uid": ""
+    // }).data(data).post();
+  }
 }