Browse Source

'渲染课程表'

Rorschach 6 năm trước cách đây
mục cha
commit
201bd1f4d7

+ 2 - 2
pages/components/MainPage.js

@@ -445,8 +445,8 @@ const styles = StyleSheet.create({
     paddingRight: 10,
   },
   rightBtnIcon: {
-    width: 14,
-    height: 14
+    width: 15,
+    height: 15
   },
   rightBtnText: {
     color: '#151515',

+ 5 - 12
pages/components/ScheduleFlatItem.js

@@ -12,18 +12,11 @@ import {
   DeviceEventEmitter
 } from "react-native";
 
-/** 因没有图,所以Image先用颜色代替,有图可替换 */
-const instructions = Platform.select({
-  ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
-  android:
-    "Double tap R on your keyboard to reload,\n" +
-    "Shake or press menu button for dev menu"
-});
 
-type Props = {};
 var width = Dimensions.get("window").width;
 var height = Dimensions.get("window").height;
-export default class ScheduleFlatItem extends Component<Props> {
+
+export default class ScheduleFlatItem extends Component {
   render() {
     return (
       <TouchableOpacity activeOpacity={1} onPress={this.props.onPress}>
@@ -49,7 +42,7 @@ export default class ScheduleFlatItem extends Component<Props> {
             <View
               style={{
                 flex: 2.5,
-                backgroundColor: this.props.data.typecolor,
+                backgroundColor: this.props.data.subColor,
                 width: "95%",
                 height: "70%",
                 alignItems: "center",
@@ -57,7 +50,7 @@ export default class ScheduleFlatItem extends Component<Props> {
                 borderRadius: 20
               }}
             >
-              <Text style={{ color: "white" }}>{this.props.data.typename}</Text>
+              <Text style={{ color: "white",fontSize: 12, }}>{this.props.data.subTitle}</Text>
             </View>
             <View style={{ flex: 0.5 }} />
             <View
@@ -69,7 +62,7 @@ export default class ScheduleFlatItem extends Component<Props> {
               }}
             >
               <Text style={{ textAlign: "left" }}>
-                {this.props.data.videoname}
+                {this.props.data.title}
               </Text>
             </View>
             <View

+ 42 - 84
pages/components/SchedulePage.js

@@ -30,14 +30,9 @@ import CourseTitle from "./CourseTitle";
 import SharedDialog from "./SharedDialog";
 import ScheduleFlatItem from "./ScheduleFlatItem";
 import CusVideo from "./CusVideo";
-const instructions = Platform.select({
-  ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
-  android:
-    "Double tap R on your keyboard to reload,\n" +
-    "Shake or press menu button for dev menu"
-});
+import ScheduleUrl from '../services/schedule'
+
 
-type Props = {};
 export default class SchedulePage extends BasePage {
   constructor(props) {
     super(props);
@@ -58,7 +53,16 @@ export default class SchedulePage extends BasePage {
       seat_height: "2%",
       flatlist_height: "60%",
       isFull: false,
-      playing_key: 0
+      playing_key: 0,
+      scheduleTitle: '',
+      wareList: [],
+      colorList: [
+        '#FFBC3D',
+        '#FB5B76',
+        '#EC48E1',
+        '#39D6B9',
+        '#3397F0'
+      ]
     };
   }
 
@@ -93,7 +97,7 @@ export default class SchedulePage extends BasePage {
           >
             <CourseTitle
               width={this.getWindowWidth()}
-              title="第12周 爱上幼儿园"
+              title={this.state.scheduleTitle}
               lefttype={1}
               righttype={1}
               textcolor={"#231F20"}
@@ -153,81 +157,9 @@ export default class SchedulePage extends BasePage {
               renderItem={({ item }) => {
                 return this.loadFlatItem(item);
               }}
-              keyExtractor={(item, index) => item.key.toString()}
+              keyExtractor={(item, index) => item.id.toString()}
               horizontal={false}
-              data={[
-                {
-                  key: 1,
-                  typecolor: "#74E0FF",
-                  typename: "习惯养成",
-                  videoname: "碗里不剩一粒米",
-                  videourl: "碗里不剩一粒米xxxx"
-                },
-                {
-                  key: 2,
-                  typecolor: "#FB5B76",
-                  typename: "品格礼仪",
-                  videoname: "我有很多朋友",
-                  videourl: "我有很多朋友xxxx"
-                },
-                {
-                  key: 3,
-                  typecolor: "#EC48E1",
-                  typename: "自我保护",
-                  videoname: "小猫喵喵叫",
-                  videourl: "小猫喵喵叫xxxx"
-                },
-                {
-                  key: 4,
-                  typecolor: "#39D6B9",
-                  typename: "亲子游戏",
-                  videoname: "安静的睡前游戏-全家人都睡了",
-                  videourl: "安静的睡前游戏xxxx"
-                },
-                {
-                  key: 5,
-                  typecolor: "#3397F0",
-                  typename: "欢乐音乐",
-                  videoname: "小鸡捉虫子",
-                  videourl: "小鸡捉虫子xxxx"
-                },
-                {
-                  key: 11,
-                  typecolor: "#74E0FF",
-                  typename: "习惯养成",
-                  videoname: "碗里不剩一粒米",
-                  videourl: "碗里不剩一粒米xxxx"
-                },
-                {
-                  key: 12,
-                  typecolor: "#FB5B76",
-                  typename: "品格礼仪",
-                  videoname: "我有很多朋友",
-                  videourl: "我有很多朋友xxxx"
-                },
-                {
-                  key: 13,
-                  typecolor: "#EC48E1",
-                  typename: "自我保护",
-                  videoname: "小猫喵喵叫",
-                  videourl: "小猫喵喵叫xxxx"
-                },
-                {
-                  key: 14,
-                  typecolor: "#39D6B9",
-                  typename: "亲子游戏",
-                  videoname: "安静的睡前游戏-全家人都睡了",
-                  videourl:
-                    "https://www.apple.com/105/media/cn/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-cn-20170912_1280x720h.mp4"
-                },
-                {
-                  key: 15,
-                  typecolor: "#3397F0",
-                  typename: "欢乐音乐",
-                  videoname: "小鸡捉虫子",
-                  videourl: "http://chimee.org/vod/1.mp4"
-                }
-              ]}
+              data={this.state.wareList}
             />
           </View>
         </View>
@@ -269,6 +201,32 @@ export default class SchedulePage extends BasePage {
   componentWillUnmount() {
     BackHandler.removeEventListener("hardwareBackPress", this.onBackAndroid);
   }
+  componentDidMount() {
+    let colorTemp = '';
+    let colorIndexTemp = 0;
+    const colorList = this.state.colorList;
+    ScheduleUrl.getSchedule('KINDERGARTEN').success(res => {
+      res.data.wareList.forEach((item, index) => {
+        if (index === 0) {
+          colorTemp = item.subTitle;
+        }
+        if (item.subTitle === colorTemp) {
+          item.subColor = colorList[colorIndexTemp];
+        } else {
+          colorIndexTemp++;
+          if (colorIndexTemp > colorList.length - 1) {
+            colorIndexTemp = 0
+          }
+          colorTemp = item.subTitle;
+          item.subColor = colorList[colorIndexTemp];
+        }
+      })
+      this.setState({
+        scheduleTitle: res.data.category.title,
+        wareList: res.data.wareList
+      })
+    })
+  }
   showSharedDialog() {
     this.video.pause();
     this.shareddialog.setModalVisible(true);
@@ -336,7 +294,7 @@ export default class SchedulePage extends BasePage {
           videoImage_x: pageX,
           videoImage_y: pageY,
           video_show: true,
-          video_uri: data.videourl,
+          video_uri: data.playUrl,
           playing_key: data.key
         });
       });

+ 1 - 0
pages/components/ScrollRow.js

@@ -28,6 +28,7 @@ export default class ScrollRow extends Component {
                 data={this.props.data}
                 horizontal={true}
                 renderItem={({ item, separators }) => this.renderItem(item, separators)}
+                keyExtractor={(item, index) => index.toString()}
             />
         )
     }

+ 8 - 5
pages/services/api.js

@@ -1,14 +1,17 @@
+
 const url = {
-    library_url: 'http://ott80testlibrary.yifangjiaoyu.cn/mobile/page'
+    library_url: 'http://ott80testlibrary.yifangjiaoyu.cn/mobile/page',
+    schedule_url: 'http://ott80test-schedule.yifangjiaoyu.cn/mobile/schedule/'
 }
 
 
 export default class APIConfig {
-    constructor(props){
-        this.library_url = 'http://ott80testlibrary.yifangjiaoyu.cn/mobile/page'
-    }
+    
     static getLibraryUrl(path){
-        console.log(url.library_url + path)
         return url.library_url + path
     }
+    static getScheduleUrl(path){
+        console.log(33333,url.schedule_url + path)
+        return url.schedule_url + path
+    }
 } 

+ 1 - 4
pages/services/library.js

@@ -3,13 +3,10 @@ import efunRequest from '../utils/efunRequest'
 
 export default class LibraryUrl {
     
-    static aabbcc(){
-        alert(123)
-    }
     static getIndex(ageGroup) {
-        console.log(ageGroup)
         return efunRequest.getHttpRequest().url(APIConfig.getLibraryUrl(`/category`)).params({
             ageGroup
         }).get();
     }
+    
 }

+ 16 - 0
pages/services/schedule.js

@@ -0,0 +1,16 @@
+import APIConfig from './api.js';
+import efunRequest from '../utils/efunRequest'
+
+export default class ScheduleUrl {
+    
+    static getSchedule(code) {
+        console.log(22222,efunRequest.getHttpRequest().url(APIConfig.getScheduleUrl(`/ware`)).params({
+            code
+        }))
+        return efunRequest.getHttpRequest().url(APIConfig.getScheduleUrl(`/ware`)).params({
+            code
+        }).get();
+    }
+    
+
+}