Преглед изворни кода

'首页调接口渲染等'

Rorschach пре 5 година
родитељ
комит
bf970a6d6a
47 измењених фајлова са 929 додато и 223 уклоњено
  1. 6 2
      App.js
  2. 0 27
      android/app/src/main/assets/index.android.bundle
  3. 7 21
      package-lock.json
  4. 102 0
      pages/buy/order.js
  5. 158 0
      pages/buy/ticket.js
  6. 154 103
      pages/components/MainPage.js
  7. 3 20
      pages/components/ScrollRow.js
  8. 128 0
      pages/components/ShopBox.js
  9. 15 18
      pages/components/Swiper.js
  10. 0 1
      pages/components/TopicTitle.js
  11. BIN
      pages/images/shopBox/arrow.png
  12. BIN
      pages/images/shopBox/arrow@2x.png
  13. BIN
      pages/images/shopBox/arrow@3x.png
  14. BIN
      pages/images/shopBox/discount.png
  15. BIN
      pages/images/shopBox/left.png
  16. BIN
      pages/images/shopBox/left@2x.png
  17. BIN
      pages/images/shopBox/left@3x.png
  18. BIN
      pages/images/shopBox/right.png
  19. BIN
      pages/images/shopBox/right@2x.png
  20. BIN
      pages/images/shopBox/right@3x.png
  21. BIN
      pages/images/ticket/coupon-bg.png
  22. BIN
      pages/images/ticket/coupon-bg@2x.png
  23. BIN
      pages/images/ticket/coupon-bg@3x.png
  24. BIN
      pages/images/ticket/discount-bg.png
  25. BIN
      pages/images/ticket/discount-bg@2x.png
  26. BIN
      pages/images/ticket/discount-bg@3x.png
  27. BIN
      pages/images/userCenter/customer.png
  28. BIN
      pages/images/userCenter/customer@2x.png
  29. BIN
      pages/images/userCenter/customer@3x.png
  30. BIN
      pages/images/userCenter/discount.png
  31. BIN
      pages/images/userCenter/discount@2x.png
  32. BIN
      pages/images/userCenter/discount@3x.png
  33. BIN
      pages/images/userCenter/gift.png
  34. BIN
      pages/images/userCenter/gift@2x.png
  35. BIN
      pages/images/userCenter/gift@3x.png
  36. BIN
      pages/images/userCenter/left.png
  37. BIN
      pages/images/userCenter/order.png
  38. BIN
      pages/images/userCenter/order@2x.png
  39. BIN
      pages/images/userCenter/order@3x.png
  40. BIN
      pages/images/userCenter/service.png
  41. BIN
      pages/images/userCenter/service@2x.png
  42. BIN
      pages/images/userCenter/service@3x.png
  43. 14 0
      pages/services/api.js
  44. 15 0
      pages/services/library.js
  45. 148 27
      pages/userCenter.js
  46. 4 4
      pages/utils/dimensions.js
  47. 175 0
      pages/utils/efunRequest.js

+ 6 - 2
App.js

@@ -25,6 +25,8 @@ import SchedulePage from "./pages/components/SchedulePage";
 import PersonalInfo from "./pages/components/PersonalInfo";
 import CourseDetails from "./pages/CourseDetails";
 import userCenter from "./pages/userCenter";
+import Order from './pages/buy/order'
+import Ticket from './pages/buy/ticket'
 
 const RootNavigator = createStackNavigator(
   {
@@ -34,10 +36,12 @@ const RootNavigator = createStackNavigator(
     SchedulePage: { screen: SchedulePage },
     PersonalInfo: { screen: PersonalInfo },
     userCenter: { screen: userCenter },
-    CourseDetails: { screen: CourseDetails}
+    CourseDetails: { screen: CourseDetails },
+    Order: { screen: Order },
+    Ticket: { screen: Ticket },
   },
   {
-    initialRouteName: "SchoolAge",
+    initialRouteName: "MainPage",
     headerMode: "null"
   }
 );

Разлика између датотеке није приказан због своје велике величине
+ 0 - 27
android/app/src/main/assets/index.android.bundle


+ 7 - 21
package-lock.json

@@ -2832,13 +2832,11 @@
         },
         "balanced-match": {
           "version": "1.0.0",
-          "bundled": true,
-          "optional": true
+          "bundled": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
-          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -2851,18 +2849,15 @@
         },
         "code-point-at": {
           "version": "1.1.0",
-          "bundled": true,
-          "optional": true
+          "bundled": true
         },
         "concat-map": {
           "version": "0.0.1",
-          "bundled": true,
-          "optional": true
+          "bundled": true
         },
         "console-control-strings": {
           "version": "1.1.0",
-          "bundled": true,
-          "optional": true
+          "bundled": true
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -2965,8 +2960,7 @@
         },
         "inherits": {
           "version": "2.0.3",
-          "bundled": true,
-          "optional": true
+          "bundled": true
         },
         "ini": {
           "version": "1.3.5",
@@ -2976,7 +2970,6 @@
         "is-fullwidth-code-point": {
           "version": "1.0.0",
           "bundled": true,
-          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -2989,20 +2982,17 @@
         "minimatch": {
           "version": "3.0.4",
           "bundled": true,
-          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
         },
         "minimist": {
           "version": "0.0.8",
-          "bundled": true,
-          "optional": true
+          "bundled": true
         },
         "minipass": {
           "version": "2.3.5",
           "bundled": true,
-          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.2",
             "yallist": "^3.0.0"
@@ -3019,7 +3009,6 @@
         "mkdirp": {
           "version": "0.5.1",
           "bundled": true,
-          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -3092,8 +3081,7 @@
         },
         "number-is-nan": {
           "version": "1.0.1",
-          "bundled": true,
-          "optional": true
+          "bundled": true
         },
         "object-assign": {
           "version": "4.1.1",
@@ -3103,7 +3091,6 @@
         "once": {
           "version": "1.4.0",
           "bundled": true,
-          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -3209,7 +3196,6 @@
         "string-width": {
           "version": "1.0.2",
           "bundled": true,
-          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",

+ 102 - 0
pages/buy/order.js

@@ -0,0 +1,102 @@
+/* 
+ * 
+*/
+import React, { Component } from "react";
+import {
+    Platform,
+    StyleSheet,
+    Text,
+    View,
+    Image,
+    TouchableOpacity,
+    FlatList,
+    TouchableHighlight,
+    DeviceEventEmitter,
+    ScrollView
+} from "react-native";
+import BasePage from "../BasePage";
+import Dimensions from '../utils/dimensions';
+import TopicTitle from '../components/TopicTitle';
+
+export default class Order extends BasePage {
+    state = {
+        data: {
+            title: '学前课程', list: [
+                { title: '生活好榜样', time: '2019-10-01' },
+                { title: '生活好榜样2', time: '2019-10-01' },
+                { title: '生活好榜样3', time: '2019-10-01' },
+                { title: '生活好榜样第二期', time: '2019-10-01' },
+            ]
+        }
+
+    };
+    renderItem = (item, index) => {
+        return (
+            <View>
+                {
+                    index === 0
+                        ?
+                        <TopicTitle title={this.state.data.title} ifTubeShow={true} />
+                        :
+                        null
+                }
+                <View style={styles.item}>
+                    <View style={styles.left}>
+                        <Text style={styles.title}>{item.title}</Text>
+                        <Text style={styles.time}>有效期:{item.time}</Text>
+                    </View>
+                    <View style={styles.right}>
+                        <Text style={styles.study}>去学习</Text>
+                    </View>
+                </View>
+            </View>
+        )
+    }
+    render() {
+        return (
+            <FlatList
+
+                data={this.state.data.list}
+                horizontal={false}
+                renderItem={({ item, index }) => this.renderItem(item, index)}
+                keyExtractor={(item, index) => index.toString()}
+            />
+        )
+    }
+}
+
+const styles = StyleSheet.create({
+    item: {
+        width: Dimensions.width,
+        height: Dimensions.getHeight(79),
+        flexDirection: 'row',
+        justifyContent: 'space-between',
+        alignItems: 'center',
+        paddingHorizontal: 14,
+        borderTopWidth: 1,
+        borderColor: '#f0f1f5'
+    },
+    left: {
+        flexDirection: 'column'
+    },
+    title: {
+        fontSize: 18,
+        color: '#151515'
+    },
+    time: {
+        fontSize: 14,
+        color: '#555'
+    },
+    right: {
+        width: Dimensions.getWidth(83),
+        height: Dimensions.getHeight(27),
+        borderRadius: 14,
+        backgroundColor: '#ffae59',
+        justifyContent: 'center',
+        alignItems: 'center'
+    },
+    study: {
+        color: '#fff',
+        fontSize: 16
+    }
+})

+ 158 - 0
pages/buy/ticket.js

@@ -0,0 +1,158 @@
+/* 
+ * 
+*/
+import React, { Component } from "react";
+import {
+    Platform,
+    StyleSheet,
+    Text,
+    View,
+    Image,
+    TouchableOpacity,
+    FlatList,
+    TouchableHighlight,
+    DeviceEventEmitter,
+    ScrollView,
+    ImageBackground
+} from "react-native";
+import BasePage from "../BasePage";
+import Dimensions from '../utils/dimensions';
+
+export default class Ticket extends BasePage {
+    state = {
+        data: [
+            {
+                type: 1,
+                price: 12,
+                num: 6,
+                time: '2019-12-12'
+            },
+            {
+                type: 2,
+                price: 50,
+                limit: '199',
+                time: '2019-12-12'
+            }
+        ]
+    };
+    renderItem = (item, index) => {
+
+        return (
+            <View>
+                {
+                    item.type === 1
+                        ? // 抵用券
+                        <ImageBackground
+                            source={require('../images/ticket/discount-bg.png')}
+                            style={styles.type1}
+                        >
+                            <View style={styles.topInfo}>
+                                <View style={styles.left2}>
+                                    <Text style={styles.price}>
+                                        ¥{item.price}
+                                    </Text>
+                                    <Text style={styles.type}>抵用券</Text>
+                                </View>
+
+                                <View style={styles.right2}>
+                                    <Text style={styles.greyText}>购买{item.num}个单课程的奖励</Text>
+                                    <Text style={styles.greyText}>有效期:{item.time}</Text>
+                                </View>
+
+                            </View>
+                            <View style={styles.bottomInfo}>
+                                <Text style={styles.greyText}>注:开通会员时方可使用</Text>
+                                <Text style={styles.blueText}>查看订单</Text>
+                            </View>
+                        </ImageBackground>
+                        : // 优惠券
+                        <ImageBackground
+                            source={require('../images/ticket/coupon-bg.png')}
+                            style={styles.type2}
+                        >
+                            <View style={styles.left2}>
+                                <Text style={styles.price}>
+                                    ¥{item.price}
+                                </Text>
+                                <Text style={styles.type}>优惠券</Text>
+                            </View>
+
+                            <View style={styles.right2}>
+                                <Text style={styles.greyText}>满{item.limit}可用</Text>
+                                <Text style={styles.greyText}>有效期:{item.time}</Text>
+                            </View>
+                        </ImageBackground>
+                }
+            </View>
+
+        )
+    }
+    render() {
+        return (
+            <FlatList
+
+                data={this.state.data}
+                horizontal={false}
+                renderItem={({ item, index }) => this.renderItem(item, index)}
+                keyExtractor={(item, index) => index.toString()}
+            />
+        )
+    }
+}
+
+const styles = StyleSheet.create({
+    type1: {
+        width: 343,
+        height: 144,
+        flexDirection: 'column',
+        justifyContent: 'space-between',
+        alignItems: 'center',
+        paddingTop: 12,
+        paddingBottom: 14
+    },
+    type2: {
+        width: 343,
+        height: 100,
+        flexDirection: 'row',
+        justifyContent: 'flex-start',
+        alignItems: 'center',
+        paddingLeft: 27
+    },
+    left2: {
+        flexDirection: 'column',
+
+    },
+    price: {
+        color: '#ff6d2f',
+        fontSize: 19,
+        fontWeight: '500'
+    },
+    type: {
+        color: '#ff6d2f',
+        fontSize: 18,
+        fontWeight: '500'
+    },
+    right2: {
+        flexDirection: 'column'
+
+    },
+    topInfo: {
+        flexDirection: 'row',
+        alignItems: 'center'
+    },
+    bottomInfo: {
+        width: '100%',
+        paddingHorizontal: 12,
+        flexDirection: 'row',
+        alignItems: 'center',
+        justifyContent: 'space-between'
+    },
+    greyText: {
+        fontSize: 14,
+        color: '#888'
+    },
+    blueText: {
+        color: '#4a90e2',
+        fontSize: 14
+    }
+})

+ 154 - 103
pages/components/MainPage.js

@@ -32,57 +32,101 @@ import MySwiper from "./Swiper";
 import Dimensions from '../utils/dimensions';
 import TopicTitle from './TopicTitle';
 import ScrollRow from "./ScrollRow";
-// import console from 'console';
+import LibraryUrl from '../services/library'
+import { ScrollView } from "react-native-gesture-handler";
 
 export default class MainPage extends BasePage {
   constructor(props) {
     super(props);
   }
 
+  componentDidMount() {
+    LibraryUrl.getIndex('PRESCHOOL').success(res => {
+      console.log(res)
+      const monthTopicTitle = res.data.monthTopic.zone.title;
+      const monthTopicScroll = res.data.monthTopic.zoneCourseVOList;
+      const schedule = res.data.schedule;
+      const hotCourse = res.data.hotCourse;
+      const recommend = res.data.recommend; //全部课程
+      const banner = res.data.banner; //轮播图
+      // const listData = [];
+      // for(let item in res.data){
+      //   console.log(item)
+      //   listData.push(1)
+      // }
+      // console.log(typeof listData)
+      // console.log(listData)
+      // console.log(listData.length)
+      this.setState({
+        // listData: listData.length? listData : [],
+        hotCourse,
+        monthTopicTitle,
+        monthTopicScroll,
+        schedule,
+        recommend,
+        banner
+      })
+      console.log(this.state.banner)
+    })
+  }
+
   state = {
     grade: '大学',
     text: '小伙子',
     ifGradeMenuShow: false,
     fadeAnim: new Animated.Value(0),
+    schedule: [],
+    recommend: [],
+    listData: [],
+    banner:[]
   }
 
   render() {
+    // const abc =Object.keys(this.state.data).map((k)=>this.state.data[k])
     return (
-        <View style={{ flex: 1 }} onPress={this.hideGradeMenu}>
-          {/* 尝试切换为sectionList 分组显示 */}
-          <SectionList
-            sections={sectionData}
-            renderItem={({ item }) => {
-              return this.loadFlatItem(item);
-            }}
-            keyExtractor={(item, index) => item.key.toString()}
-            ListHeaderComponent={() => this.headerorfooterComponent()}
-            renderSectionHeader={this.sectionTitle}
-            onScroll={this.hideGradeMenu}
-          />
-          {
-            this.state.ifGradeMenuShow ? (
-              <Animated.View
-                style={{
-                  ...styles.callUpGrade,
-                  opacity: this.state.fadeAnim
-                }}>
-                <View style={styles.gradeItem}>
-                  <Text style={styles.gradeText}>小学</Text>
-                </View>
-                <View style={styles.gradeItemMid}>
-                  <Text style={styles.gradeText}>学前</Text>
-                </View>
-                <View style={styles.gradeItem}>
-                  <Text style={styles.gradeText}>中学</Text>
-                </View>
-              </Animated.View>
-            ) : (
-                null
-              )
+      <View style={{ flex: 1 }} onPress={this.hideGradeMenu}>
+        {/* <SectionList     sectionList组件 性能好 但是针对当前布局是否有要用的必要,以后可能迭代
+          sections={this.state.listData}
+          renderItem={({ item }) => {
+            return this.loadFlatItem(item);
+          }}
+          keyExtractor={(item, index) => item.key.toString()}
+          ListHeaderComponent={() => this.headerorfooterComponent()}
+          renderSectionHeader={this.sectionTitle}
+          onScroll={this.hideGradeMenu}
+        /> */}
+        <ScrollView style={{ height: Dimensions.height }} >
+          {this.headerorfooterComponent()}
+          {this.getSwiperElement()}
+          {this.getScheduleElement()}
+          {this.getMonthTopic()}
+          {this.getHotCourse()}
+          {this.getAllCourses()}
+        </ScrollView>
 
-          }
-        </View>
+        {
+          this.state.ifGradeMenuShow ? (
+            <Animated.View
+              style={{
+                ...styles.callUpGrade,
+                opacity: this.state.fadeAnim
+              }}>
+              <View style={styles.gradeItem}>
+                <Text style={styles.gradeText}>小学</Text>
+              </View>
+              <View style={styles.gradeItemMid}>
+                <Text style={styles.gradeText}>学前</Text>
+              </View>
+              <View style={styles.gradeItem}>
+                <Text style={styles.gradeText}>中学</Text>
+              </View>
+            </Animated.View>
+          ) : (
+              null
+            )
+
+        }
+      </View>
     );
   }
 
@@ -128,7 +172,6 @@ export default class MainPage extends BasePage {
   }
   // 渲染轮播图
   getSwiperElement() {
-    console.log('进入swiper')
     return (
       <View
         style={{
@@ -137,12 +180,10 @@ export default class MainPage extends BasePage {
           justifyContent: "center",
           alignItems: "center",
           flexDirection: "row",
-          // backgroundColor: 'red'
         }}
       >
         <View
           style={{
-            // width: Dimensions.width,
             width: Dimensions.getWidth(358),
             height: Dimensions.getDp(153),
             justifyContent: "center",
@@ -153,17 +194,16 @@ export default class MainPage extends BasePage {
             autoplay={true}
             loop={true}
             ifShowMiddle={true}
+            data={this.state.banner}
           />
         </View>
       </View>
     );
   }
   // 渲染课程表
-  getScheduleElement(data) {
-    let arr = [];
-    let index = 0;
-    for (let item of data.item.icon_item) {
-      arr.push(
+  getScheduleElement() {
+    let renderScheduleItem = (item, index) => {
+      return (
         <TouchableOpacity
           style={{ width: 172, height: 86, marginRight: 12 }}
           onPress={() => {
@@ -174,7 +214,7 @@ export default class MainPage extends BasePage {
         >
           <Image
             source={{
-              uri: item.icon
+              uri: item.boothContent
             }}
             key={index}
             style={{
@@ -186,18 +226,7 @@ export default class MainPage extends BasePage {
             }}
           />
         </TouchableOpacity>
-      );
-      if (index < data.item.icon_item.length - 1) {
-        arr.push(
-          <View
-            key={item.name}
-            style={{
-              flex: 0.1
-            }}
-          />
-        );
-      }
-      index++;
+      )
     }
     return (
       <View
@@ -205,7 +234,6 @@ export default class MainPage extends BasePage {
           flex: 1,
           flexDirection: "column",
           height: 160,
-          // backgroundColor: 'blue'
         }}
       >
         <TopicTitle title={'课程表:第一周'} ifTubeShow={true} />
@@ -213,78 +241,101 @@ export default class MainPage extends BasePage {
           style={{
             flex: 2,
             flexDirection: "row",
-            // backgroundColor: 'green',
             alignItems: 'center',
             paddingLeft: 10
           }}
         >
-          {arr}
+          {this.state.schedule.map((item, index) => renderScheduleItem(item, index))}
         </View>
       </View>
     );
   }
-  // 渲染每一个块儿
+  // 渲染月主题
+  getMonthTopic() {
+    return (
+      <View style={{
+        flex: 1,
+        height: 225,
+      }}>
+        <TopicTitle title={this.state.monthTopicTitle} summary={'每天30分钟'} ifTubeShow={true} />
+        <ScrollRow itemWidth={352} itemHeight={153} data={this.state.monthTopicScroll} />
+      </View>
+
+    );
+  }
+  // 渲染热门课程
+  getHotCourse() {
+    return (
+      <View style={{
+        flex: 1,
+        height: 220,
+      }}>
+        <TopicTitle title={'热门课程'} ifTubeShow={true} />
+        <ScrollRow itemWidth={106} itemHeight={150} data={this.state.hotCourse} />
+      </View>
+    )
+  }
+  // 渲染全部课程
+  getAllCourses() {
+    return (
+      <View>
+        {this.state.recommend.map((item, index) => {
+          return (
+            <View
+              style={{
+                flex: 1,
+                height: 240,
+              }}
+              key={index}
+            >
+              {index === 0
+                ?
+                null
+                :
+                <View style={{ width: Dimensions.width, height: 4, backgroundColor: '#f0f1f5' }}></View>
+              }
+              <TopicTitle title={item.zone.title} />
+              <ScrollRow itemWidth={106} itemHeight={150} data={item.zoneCourseVOList} />
+            </View>
+          )
+        })}
+      </View>
+
+
+    )
+  }
+  // 渲染每一个块儿  sectionList组件的data,没有用到,以后可能会用
   loadFlatItem(data) {
-    console.log(data)
-    console.log(data.typea)
-    switch (data.typea) {
+
+
+    switch (data.title) {
       // 轮播图
-      case 1:
-        console.log(1)
+      case 'banner':
         return this.getSwiperElement();
         break;
       // 课程表
-      case 2:
-        console.log(2)
-        return this.getScheduleElement(data);
+      case 'schedule':
+        return this.getScheduleElement();
         break;
       // 大图主题
-      case 3:
-        console.log(3)
-        return (
-          <View style={{
-            flex: 1,
-            height: 225,
-          }}>
-            <TopicTitle title={'五月主题:五月主题,去看看不同的世界'} summary={'每天30分钟'} ifTubeShow={true} />
-            <ScrollRow itemWidth={352} itemHeight={153} />
-          </View>
-
-        );
+      case 'monthTopic':
+        return this.getMonthTopic();
         break;
       // 热门课程
-      case 4:
-        return (
-          <View style={{
-            flex: 1,
-            height: 220,
-          }}>
-            <TopicTitle title={'热门广场'} ifTubeShow={true} />
-            <ScrollRow itemWidth={106} itemHeight={150} />
-          </View>
-        )
+      case 'hotCourse':
+        return this.getHotCourse();
         break;
-      case 5:
-        return (
-          <View style={{
-            flex: 1,
-            height: 240,
-          }}>
-            <TopicTitle title={'生活好榜样'} summary={'死数据不是动态渲染'} />
-            <ScrollRow itemWidth={106} itemHeight={150} />
-          </View>
-        )
+      case 'recommend':
+        return this.getAllCourses();
         break;
       default:
         break;
     }
   }
-  // 渲染每一个section的title
+  // 渲染每一个section的title  sectionList组件的data,没有用到,以后可能会用
   sectionTitle = (info) => {
-    console.log(info)
     switch (info.section.title) {
       case 'operation':
-        console.log('进入运营区头部', info.section.title)
         return (
           <View
             style={{

+ 3 - 20
pages/components/ScrollRow.js

@@ -23,25 +23,7 @@ export default class ScrollRow extends Component {
         return (
             <FlatList
 
-                data={[{
-                    summary: 'Title Text', key: 'item1', icon:
-                        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
-                }, {
-                    summary: 'Title Text', key: 'item2', icon:
-                        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
-                }, {
-                    summary: 'Title Text', key: 'item3', icon:
-                        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
-                }, {
-                    summary: 'Title Text', key: 'item4', icon:
-                        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
-                }, {
-                    title: 'Title Text', key: 'item5', icon:
-                        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
-                }, {
-                    summary: 'Title Text', key: 'item6', icon:
-                        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
-                }]}
+                data={this.props.data}
                 horizontal={true}
                 renderItem={({ item, separators }) => this.renderItem(item, separators)}
             />
@@ -73,7 +55,8 @@ export default class ScrollRow extends Component {
                 }}>
                     <Image
                         source={{
-                            uri: item.icon
+                            uri: item.zoneCourse ? item.zoneCourse.iconImg : item.boothContent
+                            // uri: item.icon
                         }}
                         style={{
                             borderRadius: 10,

+ 128 - 0
pages/components/ShopBox.js

@@ -0,0 +1,128 @@
+/** 
+ * @param: 
+ *      data: 商品列表
+ *      discount: 优惠信息
+ */
+
+import React, { Component } from "react";
+import {
+    StyleSheet,
+    Text,
+    View,
+    Image,
+    TouchableOpacity,
+    ImageBackground,
+} from "react-native";
+import Dimensions from '../utils/dimensions'
+
+const styles = StyleSheet.create({
+    bigWrapper: {
+        flexDirection: 'column',
+    },
+    wrapper: {
+        // width: Dimensions.width,
+        // height: 45,
+        justifyContent: "center",
+        flexDirection: 'row',
+        justifyContent: 'space-around',
+        paddingHorizontal: 7
+    },
+    item: {
+        width: Dimensions.width * 168 / 375,
+        height: Dimensions.width * 168 / 375 * 120 / 168,
+        paddingLeft: 10
+    },
+    title: {
+        fontSize: 20,
+        color: '#fff',
+        marginTop: 15,
+    },
+    line2: {
+        flexDirection: 'row',
+        alignItems: 'center',
+        // marginTop: 3
+    },
+    price: {
+        fontSize: 24,
+        color: '#fff',
+        fontWeight: 'bold',
+        marginRight: 5
+    },
+    originPrice: {
+        fontSize: 11,
+        color: '#fff',
+        textDecorationLine: 'line-through'
+    },
+    line3: {
+        alignItems: 'center',
+        flexDirection: 'row',
+        marginTop: 8
+    },
+    buy: {
+        fontSize: 18,
+        color: '#fff'
+    },
+    discount: {
+        width: Dimensions.width,
+        alignItems: 'center',
+        justifyContent: 'center',
+        height: 100
+    },
+    discountIcon: {
+        width: Dimensions.width * 343 / 375,
+        height: Dimensions.width * 343 / 375 * 80 / 343
+    }
+
+})
+
+export default class ShopBox extends Component {
+
+    renderGoods = (item, index) => {
+        return (
+            <ImageBackground
+                source={item.background}
+                style={styles.item}
+                key={index}
+            >
+                <Text
+                    style={styles.title}
+                >{item.title}</Text>
+                <View
+                    style={styles.line2}
+                >
+                    <Text style={styles.price}>¥{item.price}</Text>
+                    <Text style={styles.originPrice}>原价: {item.originPrice}</Text>
+                </View>
+                <View
+                    style={styles.line3}
+                >
+                    <Text style={styles.buy}>立即购买</Text>
+                    <Image
+                        source={require('../images/shopBox/arrow.png')}
+                        style={styles.arrow}
+                    />
+
+                </View>
+            </ImageBackground>
+        )
+    }
+
+    render() {
+
+        return (
+            <View style={styles.bigWrapper}>
+                <View style={styles.wrapper}>
+                    {this.props.data.map((item, index) => this.renderGoods(item, index))}
+                </View>
+                <View style={styles.discount}>
+                    <Image
+                        source={this.props.discount.icon}
+                        stytle={styles.discountIcon}
+                    />
+                </View>
+
+            </View>
+
+        );
+    }
+}

+ 15 - 18
pages/components/Swiper.js

@@ -21,6 +21,7 @@ const dotActive = <View style={{ backgroundColor: '#fff', width: 8, height: 8, b
 export default class Swipers extends Component {
 
   render() {
+    console.log(this.props)
     return (
       <Swiper
         style={styles.wrapper}
@@ -34,24 +35,20 @@ export default class Swipers extends Component {
         dot={dotRegular}
         activeDot={dotActive}
       >
-        <View style={styles.slide}>
-          <Image
-            source={{
-              uri:
-                "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
-            }}
-            style={styles.img}
-          />
-        </View>
-        <View style={styles.slide}>
-          <Image
-            source={{
-              uri:
-                "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
-            }}
-            style={styles.img}
-          />
-        </View>
+        {
+          this.props.data.map((item, index) => {
+            return (
+              <View style={styles.slide} key={index}>
+                <Image
+                  source={{
+                    uri: item.boothContent
+                  }}
+                  style={styles.img}
+                />
+              </View>
+            )
+          })
+        }
       </Swiper>
     );
   }

+ 0 - 1
pages/components/TopicTitle.js

@@ -65,7 +65,6 @@ export default class TopicTitle extends Component {
             tube = 1
         }
         const tubeColor = this.props.tubeColor ? this.props.tubeColor : '#ffd101';
-        console.log('背景色', this.props)
         return (
             <View
                 style={{

BIN
pages/images/shopBox/arrow.png


BIN
pages/images/shopBox/arrow@2x.png


BIN
pages/images/shopBox/arrow@3x.png


BIN
pages/images/shopBox/discount.png


BIN
pages/images/shopBox/left.png


BIN
pages/images/shopBox/left@2x.png


BIN
pages/images/shopBox/left@3x.png


BIN
pages/images/shopBox/right.png


BIN
pages/images/shopBox/right@2x.png


BIN
pages/images/shopBox/right@3x.png


BIN
pages/images/ticket/coupon-bg.png


BIN
pages/images/ticket/coupon-bg@2x.png


BIN
pages/images/ticket/coupon-bg@3x.png


BIN
pages/images/ticket/discount-bg.png


BIN
pages/images/ticket/discount-bg@2x.png


BIN
pages/images/ticket/discount-bg@3x.png


BIN
pages/images/userCenter/customer.png


BIN
pages/images/userCenter/customer@2x.png


BIN
pages/images/userCenter/customer@3x.png


BIN
pages/images/userCenter/discount.png


BIN
pages/images/userCenter/discount@2x.png


BIN
pages/images/userCenter/discount@3x.png


BIN
pages/images/userCenter/gift.png


BIN
pages/images/userCenter/gift@2x.png


BIN
pages/images/userCenter/gift@3x.png


BIN
pages/images/userCenter/left.png


BIN
pages/images/userCenter/order.png


BIN
pages/images/userCenter/order@2x.png


BIN
pages/images/userCenter/order@3x.png


BIN
pages/images/userCenter/service.png


BIN
pages/images/userCenter/service@2x.png


BIN
pages/images/userCenter/service@3x.png


+ 14 - 0
pages/services/api.js

@@ -0,0 +1,14 @@
+const url = {
+    library_url: 'http://ott80testlibrary.yifangjiaoyu.cn/mobile/page'
+}
+
+
+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
+    }
+} 

+ 15 - 0
pages/services/library.js

@@ -0,0 +1,15 @@
+import APIConfig from './api.js';
+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();
+    }
+}

+ 148 - 27
pages/userCenter.js

@@ -18,28 +18,58 @@ import {
     ScrollView
 } from "react-native";
 import BasePage from "./BasePage";
-import Dimensions from './utils/dimensions'
+import Dimensions from './utils/dimensions';
+import ShopBox from "./components/ShopBox";
+import TopicTitle from './components/TopicTitle';
+import ScrollRow from './components/ScrollRow';
 
 export default class userCenter extends BasePage {
     state = {
         nickName: "初始昵称",
-        schoolName: "未设置",
+        user: {
+            nickName: '啊啊啊',
+            avatar: 'https://gss2.bdstatic.com/-fo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=043fea1806f431adbcd2443f730dcb92/f636afc379310a550591d17ebd4543a983261086.jpg'
+        },
         ifDiscount: true,
         isVIP: false,
         btnArr: [
-            { title: '订单', icon: 'https://facebook.github.io/react-native/docs/assets/favicon.png' },
-            { title: '优惠券', icon: 'https://facebook.github.io/react-native/docs/assets/favicon.png' },
-            { title: '活动', icon: 'https://facebook.github.io/react-native/docs/assets/favicon.png' },
-            { title: '客服', icon: 'https://facebook.github.io/react-native/docs/assets/favicon.png' },
-        ]
+            { title: '订单', icon: require('./images/userCenter/order.png'),goTo: 'Order' },
+            { title: '抵用券', icon: require('./images/userCenter/discount.png'),goTo: 'Ticket' },
+            { title: '客服', icon: require('./images/userCenter/service.png'),goTo: 'Order' },
+        ],
+        shopData: [
+            { title: '1个月', originPrice: '199', price: '49', background: require('./images/shopBox/left.png') },
+            { title: '12个月', originPrice: '499', price: '199', background: require('./images/shopBox/right.png') }
+        ],
+        discount: { title: '限时秒杀', icon: require('./images/shopBox/discount.png') },
+        courseSroll: [{
+            summary: 'Title Text', key: 'item1', icon:
+                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
+        }, {
+            summary: 'Title Text', key: 'item2', icon:
+                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
+        }, {
+            summary: 'Title Text', key: 'item3', icon:
+                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
+        }, {
+            summary: 'Title Text', key: 'item4', icon:
+                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
+        }, {
+            title: 'Title Text', key: 'item5', icon:
+                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
+        }, {
+            summary: 'Title Text', key: 'item6', icon:
+                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
+        }]
+
+
     };
-    render() {
-        let btnRender = null;
-        this.state.btnArr.forEach((item) => {
-            btnRender + (
+    renderBtn = (item, index) => {
+        return (
+            <TouchableOpacity key={index} onPress={() => this.goTo(`${item.goTo}`)}>
                 <View style={styles.btnItem}>
                     <Image
-                        source={{ uri: item.icon }}
+                        source={item.icon}
                         style={styles.btnIcon}
                     />
                     <Text
@@ -48,32 +78,58 @@ export default class userCenter extends BasePage {
                         {item.title}
                     </Text>
                 </View>
-            )
-        })
+            </TouchableOpacity>
+        )
+    }
+    render() {
         return (
-            <ScrollView style={{ height: 1000, overflow: 'scroll' }}>
+
+            <ScrollView style={{ height: 1100, overflow: 'scroll', backgroundColor: '#fff' }}>
                 <View style={styles.topSection}>
                     <ImageBackground
                         source={
                             require('./images/userCenter/top-bg.png')
                         }
-                        style={{width: '100%',height: 203}}
+                        style={{ width: '100%', height: 203 }}
                     >
                         <View style={styles.userInfo}>
-                            
+                            <Image style={styles.userAvatar} source={{ uri: this.state.user.avatar }} />
+                            <View style={styles.userRight}>
+                                <View style={styles.userName}>
+                                    <Text style={styles.userNameText}>{this.state.user.nickName}</Text>
+                                    <Image style={styles.vipTag} source={require('./images/common/vip.png')}></Image>
+                                </View>
+                                <View style={styles.userName}>
+                                    <Text style={styles.vipSologan}>开通vip</Text>
+                                </View>
+                            </View>
                         </View>
-                        <View style={styles.btnBox}>
-                            {btnRender}
+                        <View style={styles.btnBoxWrapper}>
+                            <View style={styles.btnBox}>
+                                {this.state.btnArr.map((item, index) => this.renderBtn(item, index))}
+                            </View>
                         </View>
+
                     </ImageBackground>
 
                 </View>
-                <View style={styles.discountSection}></View>
-                <View style={styles.recordSection}></View>
-                <View style={styles.collectSection}></View>
+                <View style={styles.discountSection}>
+                    <ShopBox data={this.state.shopData} discount={this.state.discount} />
+                </View>
+                <View style={styles.recordSection}>
+                    <TopicTitle title={'观看记录'} ifTubeShow={true} />
+                    <ScrollRow itemWidth={106} itemHeight={153} data={this.state.courseSroll} />
+                </View>
+                <View style={styles.collectSection}>
+                    <TopicTitle title={'我的课程'} ifTubeShow={true} />
+                    <ScrollRow itemWidth={106} itemHeight={153} data={this.state.courseSroll} />
+                </View>
             </ScrollView>
         )
     }
+    goTo(index){
+        this.toNextPage(index)
+    }
 }
 
 const styles = StyleSheet.create({
@@ -82,19 +138,84 @@ const styles = StyleSheet.create({
         width: Dimensions.width,
         // backgroundColor: 'red'
     },
+    userInfo: {
+        width: Dimensions.width,
+        height: 70,
+        flexDirection: 'row',
+        justifyContent: 'flex-start',
+        alignItems: 'center',
+    },
+    userAvatar: {
+        width: 67,
+        height: 67,
+        borderRadius: 55,
+        marginHorizontal: 12
+    },
+    userRight: {
+        flexDirection: 'column',
+    },
+    userName: {
+        flexDirection: 'row',
+        alignItems: 'center',
+    },
+    userNameText: {
+        fontSize: 18,
+        color: '#fff',
+        fontWeight: '500',
+        marginRight: 9
+    },
+    vipSologan: {
+        fontSize: 14,
+        color: '#fff',
+    },
+    btnBoxWrapper: {
+        width: Dimensions.width,
+        alignItems: 'center',
+        marginTop: 16
+    },
+    btnBox: {
+        width: Dimensions.width * 343 / 375,
+        height: 100,
+        borderRadius: 10,
+        shadowColor: '#000',
+        // shadowOffset: 1,
+        shadowOpacity: 2,
+        shadowRadius: 5,
+        elevation: 4,
+        backgroundColor: '#fff',
+        justifyContent: 'space-around',
+        flexDirection: 'row',
+    },
+    btnItem: {
+        width: 48,
+        height: '100%',
+        flexDirection: 'column',
+        justifyContent: 'center',
+        alignItems: 'center'
+    },
+    btnIcon: {
+        width: 36,
+        height: 24,
+        marginBottom: 7
+    },
+    btnTitle: {
+        color: '#3f3f3f',
+        fontSize: 16,
+    },
     discountSection: {
         width: Dimensions.width,
-        height: 242,
-        backgroundColor: 'green'
+        // height: 242,
+        // backgroundColor: 'green'
     },
     recordSection: {
         width: Dimensions.width,
         height: 235,
-        backgroundColor: 'blue'
+        // backgroundColor: 'blue'
     },
     collectSection: {
         width: Dimensions.width,
         height: 235,
-        backgroundColor: 'yellow'
-    }
+        // backgroundColor: 'yellow'
+    },
+
 })

+ 4 - 4
pages/utils/dimensions.js

@@ -24,11 +24,11 @@ export default Dimensions  = {
 	getFontSize:function(size){
 		return size*fontScale;
 	},
-	getWidth:function(width){
-		return width*widthScale;
+	getWidth:function(px){
+		return  width * px /375;
 	},
-	getHeight:function(height){
-		return height*fontScale;
+	getHeight:function(px){
+		return width / 375 * px ;
 	},
 	/* px转dp */
 	getDp: px => PixelRatio.roundToNearestPixel(px),

+ 175 - 0
pages/utils/efunRequest.js

@@ -0,0 +1,175 @@
+//http 网络请求封装类(和业务相关的代码请不要写进这个类中)
+// import UserDataStorage from './UserDataStorage';
+
+class efunRequest {
+
+    constructor() {
+        this._url = '';
+        this._params = {};
+        this._data = {};
+        this._header = {};
+        this.xmlHTTPRequest = null;
+        this._onSuccess = null;
+        this._onFailed = null;
+        this._deserialize = null;
+    }
+
+    request(method) {
+
+        const paramStr = () => {
+            if (!this._params) {
+                return ''
+            }
+            var pstr = '';
+            for (let key in this._params) {
+                pstr += `${key}=${this._params[key]}&`;
+            }
+            return pstr.slice(0, -1);
+        }
+
+        this.xmlHTTPRequest = new XMLHttpRequest();
+        this.xmlHTTPRequest.open(method, this._url + '?' + paramStr(), true);
+        this.xmlHTTPRequest.setRequestHeader('Content-Type', 'application/' + (method == 'POST' || method == 'PUT' ? 'x-www-form-urlencoded' : 'text'));
+
+        for (let key in this._header) {
+            this.xmlHTTPRequest.setRequestHeader(key, this._header[key]);
+        }
+
+        this.xmlHTTPRequest.onreadystatechange = () => {
+            this.whenResponse();
+        }
+
+        var sendBody = null;
+        if (this._data && (method == 'POST' || method == 'PUT')) {
+            var arr = new Array();
+            var i = 0;
+            for (var attr in this._data) {
+                arr[i] = encodeURIComponent(attr) + '=' + encodeURIComponent(this._data[attr]);
+                i++;
+            }
+            sendBody = '&' + arr.join('&');
+        }
+        this.xmlHTTPRequest.send(sendBody);
+        return this;
+    }
+
+    get() {
+        this.request('GET');
+        return this;
+    }
+
+    post() {
+        this.request('POST');
+        return this;
+    }
+
+    put() {
+        this.request('PUT');
+        return this;
+    }
+
+    delete() {
+        this.request('DELETE');
+        return this;
+    }
+
+    whenResponse() {
+        if (this.xmlHTTPRequest.readyState != 4) {
+            return;
+        }
+
+        if (this._deserialize) {
+            this._deserialize(this.xmlHTTPRequest.responseText, this);
+            return;
+        }
+
+        let cb = this.xmlHTTPRequest.status == 200 ? this._onSuccess : this._onFailed;
+        if (!cb) {
+            return;
+        }
+        cb(this.xmlHTTPRequest.status, this.xmlHTTPRequest.responseText);
+    }
+
+    success(callback) {
+        this._onSuccess = callback;
+        return this;
+    }
+
+    fail(callback) {
+        this._onFailed = callback;
+        return this;
+    }
+
+    header(obj, rewrite) {
+        if (rewrite) {
+            this._header = obj;
+        } else {
+            for (let key in obj) {
+                this._header[key] = obj[key];
+            }
+        }
+        return this;
+    }
+
+    params(obj) {
+        this._params = obj;
+        return this;
+    }
+
+    data(obj) {
+        this._data = obj;
+        return this;
+    }
+
+    url(str) {
+        this._url = str;
+        return this;
+    }
+
+    responseDeserialize(func) {
+        this._deserialize = func;
+        return this;
+    }
+
+    static getHttpRequest() {
+        let request = new efunRequest();
+        // if (UserDataStorage.getToken()) {
+        //     request.header({
+        //         'Authentication': UserDataStorage.getToken()
+        //     });
+        // }
+        request.responseDeserialize(function (res, req) {
+            function callFailed(data) {
+                if (req._onFailed) {
+                    req._onFailed(data);
+                }
+            }
+
+            function callSuccess(data) {
+                if (req._onSuccess) {
+                    req._onSuccess(data);
+                }
+            }
+
+            let rObj = null;
+            try {
+                rObj = JSON.parse(res);
+            } catch (e) {
+                callFailed(e);
+                return;
+            }
+            if (req.xmlHTTPRequest.status != 200) {
+                callFailed(rObj);
+                return;
+            }
+            if (!rObj.success) {
+                callFailed(rObj);
+                return;
+            }
+            callSuccess(rObj);
+        });
+        return request;
+    }
+}
+
+export default efunRequest;