Limengbo il y a 5 ans
Parent
commit
8f41c84296

+ 17 - 0
android/.project

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>efunbox_mobile_8</name>
+	<comment>Project android created by Buildship.</comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+	</natures>
+</projectDescription>

+ 2 - 0
android/.settings/org.eclipse.buildship.core.prefs

@@ -0,0 +1,2 @@
+connection.project.dir=
+eclipse.preferences.version=1

+ 6 - 0
android/app/.classpath

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
+	<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
+	<classpathentry kind="output" path="bin/default"/>
+</classpath>

+ 23 - 0
android/app/.project

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>app</name>
+	<comment>Project app created by Buildship.</comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+	</natures>
+</projectDescription>

+ 2 - 0
android/app/.settings/org.eclipse.buildship.core.prefs

@@ -0,0 +1,2 @@
+connection.project.dir=..
+eclipse.preferences.version=1

+ 3 - 0
android/app/src/main/java/com/edufound/mobile/Util/AndroidUtil.java

@@ -13,6 +13,8 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
 import com.facebook.react.bridge.ReactMethod;
 import com.facebook.react.bridge.WritableMap;
 import com.facebook.react.modules.core.DeviceEventManagerModule;
+import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
+import com.theweflex.react.WeChatModule;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -57,6 +59,7 @@ public class AndroidUtil extends ReactContextBaseJavaModule {
         getReactApplicationContext().startActivity(intent);
     }
 
+
     @ReactMethod
     public void testJS() {
         WritableMap event = Arguments.createMap();

Fichier diff supprimé car celui-ci est trop grand
+ 864 - 676
pages/components/PersonalInfo.js


+ 305 - 292
pages/components/SchedulePage.js

@@ -6,302 +6,315 @@
  * @flow
  */
 
-import React, { Component } from "react";
+import React, { Component } from 'react';
 import {
-  Platform,
-  StyleSheet,
-  Text,
-  View,
-  Image,
-  TouchableOpacity,
-  ImageBackground,
-  FlatList,
-  findNodeHandle,
-  UIManager,
-  StatusBar,
-  BackHandler,
-  Button,
-  DeviceEventEmitter
-} from "react-native";
-import Orientation from "react-native-orientation";
-import AndroidUtil from "../../util/AndroidUtil";
-import BasePage from "../BasePage";
-import CourseTitle from "./CourseTitle";
-import SharedDialog from "./SharedDialog";
-import ScheduleFlatItem from "./ScheduleFlatItem";
-import CusVideo from "./CusVideo";
-import ScheduleUrl from '../services/schedule'
-
+	Platform,
+	StyleSheet,
+	Text,
+	View,
+	Image,
+	TouchableOpacity,
+	ImageBackground,
+	FlatList,
+	findNodeHandle,
+	UIManager,
+	StatusBar,
+	BackHandler,
+	Button,
+	DeviceEventEmitter
+} from 'react-native';
+import Orientation from 'react-native-orientation';
+import AndroidUtil from '../../util/AndroidUtil';
+import BasePage from '../BasePage';
+import CourseTitle from './CourseTitle';
+import SharedDialog from './SharedDialog';
+import ScheduleFlatItem from './ScheduleFlatItem';
+import CusVideo from './CusVideo';
+import ScheduleUrl from '../services/schedule';
+import wechat from '../utils/wechat';
 
 export default class SchedulePage extends BasePage {
-  constructor(props) {
-    super(props);
-    this.state = {
-      statusbar_hidden: false,
-      video_show: false,
-      x: 0.0,
-      y: 0.0,
-      videoImg_flex: 1,
-      videoImage_width: 0,
-      videoImage_height: 0,
-      videoImage_x: 0.0,
-      videoImage_y: 0.0,
-      video_uri:
-        "https://www.apple.com/105/media/cn/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-cn-20170912_1280x720h.mp4",
-      title_height: "9%",
-      video_frame_height: "32%",
-      seat_height: "2%",
-      flatlist_height: "60%",
-      isFull: false,
-      playing_key: 0,
-      scheduleTitle: '',
-      wareList: [],
-      colorList: [
-        '#FFBC3D',
-        '#FB5B76',
-        '#EC48E1',
-        '#39D6B9',
-        '#3397F0'
-      ]
-    };
-  }
-
-  render() {
-    return (
-      <View
-        style={{
-          flex: 1
-        }}
-      >
-        <StatusBar
-          // backgroundColor={"transparent"}
-          barStyle={"dark-content"}
-          backgroundColor={"white"}
-          translucent={false}
-          hidden={this.state.statusbar_hidden}
-        />
+	constructor(props) {
+		super(props);
+		this.state = {
+			statusbar_hidden: false,
+			video_show: false,
+			x: 0.0,
+			y: 0.0,
+			videoImg_flex: 1,
+			videoImage_width: 0,
+			videoImage_height: 0,
+			videoImage_x: 0.0,
+			videoImage_y: 0.0,
+			video_uri:
+				'https://www.apple.com/105/media/cn/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-cn-20170912_1280x720h.mp4',
+			title_height: '9%',
+			video_frame_height: '32%',
+			seat_height: '2%',
+			flatlist_height: '60%',
+			isFull: false,
+			playing_key: 0,
+			scheduleTitle: '',
+			wareList: [],
+			colorList: [ '#FFBC3D', '#FB5B76', '#EC48E1', '#39D6B9', '#3397F0' ]
+		};
+	}
 
-        <View
-          style={{
-            flex: 1,
-            backgroundColor: "#F3F3F3",
-            justifyContent: "center",
-            alignItems: "center"
-          }}
-        >
-          <View
-            style={{
-              height: this.state.title_height,
-              backgroundColor: "white"
-            }}
-          >
-            <CourseTitle
-              width={this.getWindowWidth()}
-              title={this.state.scheduleTitle}
-              lefttype={1}
-              righttype={1}
-              textcolor={"#231F20"}
-              backPress={() => this.goBack()}
-              // backPress={() => alert("左侧按钮")}
-              rightPress={this.showSharedDialog.bind(this)}
-            />
-          </View>
-          <View
-            style={{
-              height: this.state.video_frame_height,
-              width: "100%"
-            }}
-          >
-            <Image
-              source={{
-                uri:
-                  "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"
-              }}
-              style={{
-                width: "100%",
-                height: "100%"
-              }}
-              ref={c => {
-                this.video_image = c;
-              }}
-            />
-          </View>
-          <View
-            style={{
-              height: this.state.seat_height
-            }}
-          />
-          <View
-            style={{
-              height: this.state.flatlist_height,
-              justifyContent: "center",
-              alignItems: "center",
-              width: "100%"
-            }}
-          >
-            <FlatList
-              ItemSeparatorComponent={() => (
-                <View
-                  style={{
-                    height: 10
-                  }}
-                />
-              )}
-              ListFooterComponent={() => (
-                <View
-                  style={{
-                    height: 30
-                  }}
-                />
-              )}
-              renderItem={({ item }) => {
-                return this.loadFlatItem(item);
-              }}
-              keyExtractor={(item, index) => item.id.toString()}
-              horizontal={false}
-              data={this.state.wareList}
-            />
-          </View>
-        </View>
-        <CusVideo
-          show={this.state.video_show}
-          uri={this.state.video_uri}
-          ref={view => (this.video = view)}
-          needback={false}
-          videofullScreenPlayer={this.fullScreenPlayer.bind(this)}
-          onError={this.onError.bind(this)}
-          onEnd={this.onEnd.bind(this)}
-          style={{
-            left: this.state.x,
-            top: this.state.y,
-            width: this.state.video_width,
-            height: this.state.video_height,
-            overflow: "hidden",
-            position: "absolute"
-          }}
-        />
-        <SharedDialog ref={view => (this.shareddialog = view)} />
-      </View>
-    );
-  }
-  loadFlatItem(data) {
-    return (
-      <ScheduleFlatItem
-        width={this.getWindowWidth() * 0.9}
-        height={50}
-        data={data}
-        onPress={() => this.changeUrl(data)}
-      />
-    );
-  }
+	render() {
+		return (
+			<View
+				style={{
+					flex: 1
+				}}
+			>
+				<StatusBar
+					// backgroundColor={"transparent"}
+					barStyle={'dark-content'}
+					backgroundColor={'white'}
+					translucent={false}
+					hidden={this.state.statusbar_hidden}
+				/>
 
-  componentWillMount() {
-    BackHandler.addEventListener("hardwareBackPress", this.onBackAndroid);
-  }
-  componentWillUnmount() {
-    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;
-    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);
-  }
-  onBackAndroid = () => {
-    if (this.state.isFull) {
-      return true;
-    } else {
-    }
-  };
-  onError() {
-    alert("播放器异常");
-    this.setState({
-      video_show: false
-    });
-  }
-  onEnd() {
-    alert("播放结束");
-    this.setState({
-      video_show: false
-    });
-    this.video.refreshVideo();
-  }
-  fullScreenPlayer() {
-    if (!this.state.isFull) {
-      Orientation.lockToLandscape();
-      this.setState({
-        video_frame_height: "100%",
-        statusbar_hidden: true,
-        isFull: true,
-        x: 0,
-        y: 0,
-        video_width: "100%",
-        video_height: "100%"
-      });
-    } else {
-      Orientation.lockToPortrait();
-      this.setState({
-        video_frame_height: "32%",
-        x: this.state.videoImage_x,
-        y: this.state.videoImage_y,
-        video_width: this.state.videoImage_width,
-        video_height: this.state.videoImage_height,
-        statusbar_hidden: false,
-        isFull: false
-      });
-    }
-  }
-  changeUrl(data) {
-    //切换视频并且播放
-    // alert(url);
-    // if (this.state.playing_key == data.key) {
-    //   return;
-    // }
-    const handle = findNodeHandle(this.video_image);
-    setTimeout(() => {
-      UIManager.measure(handle, (x, y, width, height, pageX, pageY) => {
-        this.setState({
-          x: pageX,
-          y: pageY,
-          video_width: width,
-          video_height: height,
-          videoImage_width: width,
-          videoImage_height: height,
-          videoImage_x: pageX,
-          videoImage_y: pageY,
-          video_show: true,
-          video_uri: data.playUrl,
-          playing_key: data.key
-        });
-      });
-    }, 0);
+				<View
+					style={{
+						flex: 1,
+						backgroundColor: '#F3F3F3',
+						justifyContent: 'center',
+						alignItems: 'center'
+					}}
+				>
+					<View
+						style={{
+							height: this.state.title_height,
+							backgroundColor: 'white'
+						}}
+					>
+						<CourseTitle
+							width={this.getWindowWidth()}
+							title={this.state.scheduleTitle}
+							lefttype={1}
+							righttype={1}
+							textcolor={'#231F20'}
+							backPress={() => this.goBack()}
+							// backPress={() => alert("左侧按钮")}
+							rightPress={this.showSharedDialog.bind(this)}
+						/>
+					</View>
+					<View
+						style={{
+							height: this.state.video_frame_height,
+							width: '100%'
+						}}
+					>
+						<Image
+							source={{
+								uri:
+									'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'
+							}}
+							style={{
+								width: '100%',
+								height: '100%'
+							}}
+							ref={(c) => {
+								this.video_image = c;
+							}}
+						/>
+					</View>
+					<View
+						style={{
+							height: this.state.seat_height
+						}}
+					/>
+					<View
+						style={{
+							height: this.state.flatlist_height,
+							justifyContent: 'center',
+							alignItems: 'center',
+							width: '100%'
+						}}
+					>
+						<FlatList
+							ItemSeparatorComponent={() => (
+								<View
+									style={{
+										height: 10
+									}}
+								/>
+							)}
+							ListFooterComponent={() => (
+								<View
+									style={{
+										height: 30
+									}}
+								/>
+							)}
+							renderItem={({ item }) => {
+								return this.loadFlatItem(item);
+							}}
+							keyExtractor={(item, index) => item.id.toString()}
+							horizontal={false}
+							data={this.state.wareList}
+						/>
+					</View>
+				</View>
+				<CusVideo
+					show={this.state.video_show}
+					uri={this.state.video_uri}
+					ref={(view) => (this.video = view)}
+					needback={false}
+					videofullScreenPlayer={this.fullScreenPlayer.bind(this)}
+					onError={this.onError.bind(this)}
+					onEnd={this.onEnd.bind(this)}
+					style={{
+						left: this.state.x,
+						top: this.state.y,
+						width: this.state.video_width,
+						height: this.state.video_height,
+						overflow: 'hidden',
+						position: 'absolute'
+					}}
+				/>
+				<SharedDialog
+					ref={(view) => (this.shareddialog = view)}
+					friend={this.sharedfriend.bind(this)}
+					CircleOfFriends={this.sharedcircel.bind(this)}
+				/>
+			</View>
+		);
+	}
+	loadFlatItem(data) {
+		return (
+			<ScheduleFlatItem
+				width={this.getWindowWidth() * 0.9}
+				height={50}
+				data={data}
+				onPress={() => this.changeUrl(data)}
+			/>
+		);
+	}
 
-    this.video.start();
-  }
+	componentWillMount() {
+		BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
+	}
+	componentWillUnmount() {
+		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;
+		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);
+	}
+	onBackAndroid = () => {
+		if (this.state.isFull) {
+			return true;
+		} else {
+		}
+	};
+	onError() {
+		alert('播放器异常');
+		this.setState({
+			video_show: false
+		});
+	}
+	onEnd() {
+		alert('播放结束');
+		this.setState({
+			video_show: false
+		});
+		this.video.refreshVideo();
+	}
+	fullScreenPlayer() {
+		if (!this.state.isFull) {
+			Orientation.lockToLandscape();
+			this.setState({
+				video_frame_height: '100%',
+				statusbar_hidden: true,
+				isFull: true,
+				x: 0,
+				y: 0,
+				video_width: '100%',
+				video_height: '100%'
+			});
+		} else {
+			Orientation.lockToPortrait();
+			this.setState({
+				video_frame_height: '32%',
+				x: this.state.videoImage_x,
+				y: this.state.videoImage_y,
+				video_width: this.state.videoImage_width,
+				video_height: this.state.videoImage_height,
+				statusbar_hidden: false,
+				isFull: false
+			});
+		}
+	}
+	changeUrl(data) {
+		//切换视频并且播放
+		// alert(url);
+		// if (this.state.playing_key == data.key) {
+		//   return;
+		// }
+		const handle = findNodeHandle(this.video_image);
+		setTimeout(() => {
+			UIManager.measure(handle, (x, y, width, height, pageX, pageY) => {
+				this.setState({
+					x: pageX,
+					y: pageY,
+					video_width: width,
+					video_height: height,
+					videoImage_width: width,
+					videoImage_height: height,
+					videoImage_x: pageX,
+					videoImage_y: pageY,
+					video_show: true,
+					video_uri: data.playUrl,
+					playing_key: data.key
+				});
+			});
+		}, 0);
+		this.video.start();
+	}
+	sharedfriend() {
+		wechat.shareToSessionNews(
+			'标题测试',
+			'标题内容',
+			'http://www.ncloud.hk/email-signature-262x100.png',
+			'http://www.baidu.com'
+		);
+	}
+	sharedcircel() {
+		wechat.shareToTimelineNews(
+			'标题测试',
+			'标题内容',
+			'http://www.ncloud.hk/email-signature-262x100.png',
+			'http://www.baidu.com'
+		);
+	}
 }

+ 216 - 223
pages/components/SharedDialog.js

@@ -6,236 +6,229 @@
  * @flow
  */
 
-import React, { Component } from "react";
+import React, { Component } from 'react';
 import {
-  Platform,
-  StyleSheet,
-  Text,
-  View,
-  Image,
-  TouchableOpacity,
-  ImageBackground,
-  TextInput,
-  Button,
-  StatusBar,
-  Modal,
-  TouchableHighlight,
-  DeviceEventEmitter
-} from "react-native";
-import wechat from "../utils/wechat";
+	Platform,
+	StyleSheet,
+	Text,
+	View,
+	Image,
+	TouchableOpacity,
+	ImageBackground,
+	TextInput,
+	Button,
+	StatusBar,
+	Modal,
+	TouchableHighlight,
+	DeviceEventEmitter
+} from 'react-native';
+
 type Props = {};
 export default class SharedDialog extends Component<Props> {
-  state = {
-    modalVisible: false
-  };
+	state = {
+		modalVisible: false
+	};
 
-  setModalVisible(visible) {
-    this.setState({
-      modalVisible: visible
-    });
-  }
+	setModalVisible(visible) {
+		this.setState({
+			modalVisible: visible
+		});
+	}
 
-  render() {
-    return (
-      <Modal
-        animationType="slide"
-        transparent={true}
-        visible={this.state.modalVisible}
-        onRequestClose={() => {
-          this.setState({ modalVisible: false });
-        }}
-      >
-        <View
-          style={{
-            flex: 1,
-            flexDirection: "column"
-          }}
-        >
-          <TouchableOpacity
-            style={{
-              flex: 3.5,
-              backgroundColor: "rgba(0, 0, 0, 0.5)",
-              width: "100%"
-            }}
-            activeOpacity={1}
-            onPress={() => this.setState({ modalVisible: false })}
-          >
-            <View
-              style={{
-                flex: 3.5,
-                width: "100%"
-              }}
-            />
-          </TouchableOpacity>
-          <View
-            style={{
-              flex: 1,
-              width: "100%"
-            }}
-          >
-            <View
-              style={{
-                flex: 1.5,
-                width: "100%",
-                flexDirection: "row",
-                backgroundColor: "white"
-              }}
-            >
-              <View
-                style={{
-                  flex: 1,
-                  width: "100%",
-                  alignItems: "center",
-                  justifyContent: "center"
-                }}
-              >
-                <View
-                  style={{
-                    height: 2,
-                    left: 40,
-                    backgroundColor: "#979797",
-                    width: "60%"
-                  }}
-                />
-              </View>
-              <View
-                style={{
-                  flex: 1,
-                  width: "100%",
-                  alignItems: "center",
-                  justifyContent: "center"
-                }}
-              >
-                <Text
-                  style={{
-                    fontSize: 18,
-                    color: "black"
-                  }}
-                >
-                  分享
-                </Text>
-              </View>
-              <View
-                style={{
-                  flex: 1,
-                  alignItems: "center",
-                  justifyContent: "center",
-                  width: "100%"
-                }}
-              >
-                <View
-                  style={{
-                    height: 2,
-                    right: 40,
-                    backgroundColor: "#979797",
-                    width: "60%"
-                  }}
-                />
-              </View>
-            </View>
-            <View
-              style={{
-                flex: 2,
-                backgroundColor: "white",
-                flexDirection: "row",
-                justifyContent: "center",
-                width: "100%"
-              }}
-            >
-              <View
-                style={{
-                  flex: 1,
-                  alignItems: "center"
-                }}
-              >
-                <TouchableOpacity
-                  activeOpacity={1}
-                  onPress={this.wechat.bind(this)}
-                >
-                  <View
-                    style={{
-                      flexDirection: "column",
-                      alignItems: "center",
-                      justifyContent: "center",
-                      left: 40
-                    }}
-                  >
-                    <Image
-                      style={{
-                        height: 43,
-                        width: 43
-                      }}
-                      source={require("../images/share/wechat.png")}
-                    />
-                    <Text
-                      style={{
-                        fontSize: 16,
-                        color: "black"
-                      }}
-                    >
-                      发给到群/好友
-                    </Text>
-                  </View>
-                </TouchableOpacity>
-              </View>
-              <View style={{ flex: 0.3 }} />
-              <View
-                style={{
-                  flex: 1
-                }}
-              >
-                <TouchableOpacity
-                  activeOpacity={1}
-                  onPress={this.circle.bind(this)}
-                >
-                  <View
-                    style={{
-                      flexDirection: "column",
-                      alignItems: "center",
-                      justifyContent: "center",
-                      right: 40
-                    }}
-                  >
-                    <Image
-                      style={{
-                        height: 43,
-                        width: 43
-                      }}
-                      source={require("../images/share/circle.png")}
-                    />
-                    <Text
-                      style={{
-                        fontSize: 16,
-                        color: "black"
-                      }}
-                    >
-                      发朋友圈
-                    </Text>
-                  </View>
-                </TouchableOpacity>
-              </View>
-            </View>
-          </View>
-        </View>
-      </Modal>
-    );
-  }
+	render() {
+		return (
+			<Modal
+				animationType="slide"
+				transparent={true}
+				visible={this.state.modalVisible}
+				onRequestClose={() => {
+					this.setState({ modalVisible: false });
+				}}
+			>
+				<View
+					style={{
+						flex: 1,
+						flexDirection: 'column'
+					}}
+				>
+					<TouchableOpacity
+						style={{
+							flex: 3.5,
+							backgroundColor: 'rgba(0, 0, 0, 0.5)',
+							width: '100%'
+						}}
+						activeOpacity={1}
+						onPress={() => this.setState({ modalVisible: false })}
+					>
+						<View
+							style={{
+								flex: 3.5,
+								width: '100%'
+							}}
+						/>
+					</TouchableOpacity>
+					<View
+						style={{
+							flex: 1,
+							width: '100%'
+						}}
+					>
+						<View
+							style={{
+								flex: 1.5,
+								width: '100%',
+								flexDirection: 'row',
+								backgroundColor: 'white'
+							}}
+						>
+							<View
+								style={{
+									flex: 1,
+									width: '100%',
+									alignItems: 'center',
+									justifyContent: 'center'
+								}}
+							>
+								<View
+									style={{
+										height: 2,
+										left: 40,
+										backgroundColor: '#979797',
+										width: '60%'
+									}}
+								/>
+							</View>
+							<View
+								style={{
+									flex: 1,
+									width: '100%',
+									alignItems: 'center',
+									justifyContent: 'center'
+								}}
+							>
+								<Text
+									style={{
+										fontSize: 18,
+										color: 'black'
+									}}
+								>
+									分享
+								</Text>
+							</View>
+							<View
+								style={{
+									flex: 1,
+									alignItems: 'center',
+									justifyContent: 'center',
+									width: '100%'
+								}}
+							>
+								<View
+									style={{
+										height: 2,
+										right: 40,
+										backgroundColor: '#979797',
+										width: '60%'
+									}}
+								/>
+							</View>
+						</View>
+						<View
+							style={{
+								flex: 2,
+								backgroundColor: 'white',
+								flexDirection: 'row',
+								justifyContent: 'center',
+								width: '100%'
+							}}
+						>
+							<View
+								style={{
+									flex: 1,
+									alignItems: 'center'
+								}}
+							>
+								<TouchableOpacity activeOpacity={1} onPress={this.wechat.bind(this)}>
+									<View
+										style={{
+											flexDirection: 'column',
+											alignItems: 'center',
+											justifyContent: 'center',
+											left: 40
+										}}
+									>
+										<Image
+											style={{
+												height: 43,
+												width: 43
+											}}
+											source={require('../images/share/wechat.png')}
+										/>
+										<Text
+											style={{
+												fontSize: 16,
+												color: 'black'
+											}}
+										>
+											发给到群/好友
+										</Text>
+									</View>
+								</TouchableOpacity>
+							</View>
+							<View style={{ flex: 0.3 }} />
+							<View
+								style={{
+									flex: 1
+								}}
+							>
+								<TouchableOpacity activeOpacity={1} onPress={this.circle.bind(this)}>
+									<View
+										style={{
+											flexDirection: 'column',
+											alignItems: 'center',
+											justifyContent: 'center',
+											right: 40
+										}}
+									>
+										<Image
+											style={{
+												height: 43,
+												width: 43
+											}}
+											source={require('../images/share/circle.png')}
+										/>
+										<Text
+											style={{
+												fontSize: 16,
+												color: 'black'
+											}}
+										>
+											发朋友圈
+										</Text>
+									</View>
+								</TouchableOpacity>
+							</View>
+						</View>
+					</View>
+				</View>
+			</Modal>
+		);
+	}
 
-  wechat() {
-    this.setModalVisible(false);
-    wechat.shareToSessionText("测试测试测试shareToSessionText");
-    // wechat.wechatLogin();
-  }
-  circle() {
-    this.setModalVisible(false);
-    wechat.shareToTimelineText("测试测试测试");
-  }
+	wechat() {
+		this.setModalVisible(false);
+		this.props.friend();
+	}
+	circle() {
+		this.setModalVisible(false);
+		this.props.CircleOfFriends();
+	}
 
-  setModalVisible(visible) {
-    this.setState({
-      modalVisible: visible
-    });
-  }
+	setModalVisible(visible) {
+		this.setState({
+			modalVisible: visible
+		});
+	}
 }
 
 /***

BIN
pages/images/userInfo/phone.png


BIN
pages/images/userInfo/phone@2x.png


BIN
pages/images/userInfo/phone@3x.png


BIN
pages/images/userInfo/wechat.png


BIN
pages/images/userInfo/wechat@2x.png


BIN
pages/images/userInfo/wechat@3x.png


+ 12 - 3
pages/services/user.js

@@ -1,6 +1,6 @@
-import APIConfig from "./api.js";
-import efunRequest from "../utils/efunRequest";
-import request from "../utils/request";
+import APIConfig from './api.js';
+import efunRequest from '../utils/efunRequest';
+import request from '../utils/request';
 
 export default class user {
   static update_UserInfo(opts) {
@@ -13,4 +13,13 @@ export default class user {
       method: 'get'
     });
   }
+	static update_UserInfo(opts) {
+		console.log('opts', opts);
+		return request(APIConfig.getUserUrl(``), opts);
+	}
+
+	static bind_wechat(opts) {
+		console.log('opts', opts);
+		return request(APIConfig.getUserUrl(`/wechatBind`), opts);
+	}
 }

+ 168 - 110
pages/utils/wechat.js

@@ -1,116 +1,136 @@
-import * as WeChat from "react-native-wechat";
+import * as WeChat from 'react-native-wechat';
+import request from '../utils/request';
+import AndroidUtil from '../../util/AndroidUtil';
 
 /**
     public static String WX_APPID = "wx51acc19c8f7a0f6f";
     public static String WX_SECRET = "e830d45f497025041269ef6221140c3d";
  */
-WeChat.registerApp("wx51acc19c8f7a0f6f");
+WeChat.registerApp('wx51acc19c8f7a0f6f');
 export default class wechat {
-  static wechatLogin() {
-    WeChat.sendAuthRequest("snsapi_userinfo").then(result => {
-      console.log(result);
-    });
-  }
+	//登录方法
+	static wechatLogin(callback) {
+		WeChat.isWXAppInstalled().then((isInstalled) => {
+			if (isInstalled) {
+				WeChat.sendAuthRequest('snsapi_userinfo').then((result) => {
+					var object = JSON.parse(JSON.stringify(result));
+					var loginUrl =
+						'https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx51acc19c8f7a0f6f&secret=e830d45f497025041269ef6221140c3d&code=' +
+						object['code'] +
+						'&grant_type=authorization_code';
+					request(loginUrl).then((res) => {
+						// console.log('code请求下一步返回结果:' + res['openid']);
+						// callback(res);
+						var getUserUrl =
+							'https://api.weixin.qq.com/sns/userinfo?access_token=' +
+							res['access_token'] +
+							'&openid=' +
+							res['openid'];
+						console.log('getUserUrl:' + getUserUrl);
+						request(getUserUrl).then((user) => {
+							callback(user);
+						});
+					});
+				});
+			} else {
+				alert('请安装微信');
+			}
+		});
+	}
 
-  /**
+	/**
    * 好友文字分享
    * @param  {string} descriptiontext      测试微信好友分享的文本内容
    */
-  static shareToSessionText(descriptiontext) {
-    WeChat.isWXAppInstalled().then(isInstalled => {
-      if (isInstalled) {
-        WeChat.shareToSession({
-          type: "text",
-          description: descriptiontext
-        }).catch(error => {
-          console.log(error.message);
-        });
-      } else {
-        alert("请安装微信");
-      }
-    });
-  }
+	static shareToSessionText(descriptiontext) {
+		WeChat.isWXAppInstalled().then((isInstalled) => {
+			if (isInstalled) {
+				WeChat.shareToSession({
+					type: 'text',
+					description: descriptiontext
+				})
+					.then((result) => {
+						console.log(result);
+					})
+					.catch((error) => {
+						error(error.message);
+					});
+			} else {
+				alert('请安装微信');
+			}
+		});
+	}
 
-  /**
+	/**
    * 微信好友分享链接
    * @param  {string} title_text            分享的标题
    * @param  {string} description_text      分享的标题内容
    * @param  {string} thumbImage_url       分享的标题图片
    * @param  {string} webpageUrl_url       分享的链接
    */
-  static shareToSessionNews(
-    title_text,
-    description_text,
-    thumbImage_url,
-    webpageUrl_url
-  ) {
-    WeChat.isWXAppInstalled().then(isInstalled => {
-      if (isInstalled) {
-        WeChat.shareToSession({
-          title: title,
-          description: description,
-          thumbImage: thumbImage,
-          type: "news",
-          webpageUrl: webpageUrl
-        }).catch(error => {
-          alert(error.message);
-        });
-      } else {
-        alert("请安装微信");
-      }
-    });
-  }
+	static shareToSessionNews(title_text, description_text, thumbImage_url, webpageUrl_url) {
+		WeChat.isWXAppInstalled().then((isInstalled) => {
+			if (isInstalled) {
+				WeChat.shareToSession({
+					title: title_text,
+					description: description_text,
+					thumbImage: thumbImage_url,
+					type: 'news',
+					webpageUrl: webpageUrl_url
+				}).catch((error) => {
+					alert(error.message);
+				});
+			} else {
+				alert('请安装微信');
+			}
+		});
+	}
 
-  /**
+	/**
    * 微信朋友圈分享的文本
    * @param  {string} description_text      测试微信朋友圈分享的文本内容
    */
-  static shareToTimelineText(description_text) {
-    WeChat.isWXAppInstalled().then(isInstalled => {
-      if (isInstalled) {
-        WeChat.shareToTimeline({
-          type: "text",
-          description: description_text
-        }).catch(error => {
-          console.log(error.message);
-        });
-      } else {
-        alert("请安装微信");
-      }
-    });
-  }
+	static shareToTimelineText(description_text) {
+		WeChat.isWXAppInstalled().then((isInstalled) => {
+			if (isInstalled) {
+				WeChat.shareToTimeline({
+					type: 'text',
+					description: description_text
+				}).catch((error) => {
+					console.log(error.message);
+				});
+			} else {
+				alert('请安装微信');
+			}
+		});
+	}
 
-  /**
-   * 微信好友分享链接
+	/**
+   * 微信朋友圈分享链接
    * @param  {string} title_text            分享的标题
    * @param  {string} description_text      分享的标题内容
    * @param  {string} thumbImage_url       分享的标题图片
    * @param  {string} webpageUrl_url       分享的链接
    */
-  static shareToTimelineNews(
-    title_text,
-    description_text,
-    thumbImage_url,
-    webpageUrl_url
-  ) {
-    WeChat.isWXAppInstalled().then(isInstalled => {
-      if (isInstalled) {
-        WeChat.shareToTimeline({
-          title: title_text,
-          description: description_text,
-          thumbImage: thumbImage_url,
-          type: "news",
-          webpageUrl: webpageUrl_url
-        }).catch(error => {
-          console.log(error.message);
-        });
-      } else {
-        alert("请安装微信");
-      }
-    });
-  }
+	static shareToTimelineNews(title_text, description_text, thumbImage_url, webpageUrl_url) {
+		WeChat.isWXAppInstalled().then((isInstalled) => {
+			if (isInstalled) {
+				WeChat.shareToTimeline({
+					title: title_text,
+					description: description_text,
+					thumbImage: thumbImage_url,
+					type: 'news',
+					webpageUrl: webpageUrl_url
+				}).catch((error) => {
+					console.log(error.message);
+				});
+			} else {
+				alert('请安装微信');
+			}
+		});
+	}
 
-  /**
+	/**
    * 微信支付
    * @param  {string} partnerId          商家向财付通申请的商家id
    * @param  {string} prepayId           预支付订单
@@ -119,29 +139,67 @@ export default class wechat {
    * @param  {string} package            商家根据财付通文档填写的数据和签名
    * @param  {string} sign               商家根据微信开放平台文档对数据做的签名
    */
-  static pay(partnerId, prepayId, nonceStr, timeStamp, packages, sign) {
-    WeChat.isWXAppInstalled().then(isInstalled => {
-      if (isInstalled) {
-        WeChat.pay({
-          partnerId: partnerId, // 商家向财付通申请的商家id
-          prepayId: prepayId, // 预支付订单
-          nonceStr: nonceStr, // 随机串,防重发
-          timeStamp: timeStamp, // 时间戳,防重发.
-          package: packages, // "Sign=WXPay", // 商家根据财付通文档填写的数据和签名
-          sign: sign // 商家根据微信开放平台文档对数据做的签名
-        })
-          .then(requestJson => {
-            //支付成功回调
-            if (requestJson.errCode == "0") {
-              //回调成功处理
-            }
-          })
-          .catch(err => {
-            alert("支付失败");
-          });
-      } else {
-        alert("请安装微信");
-      }
-    });
-  }
+	static pay(partnerId, prepayId, nonceStr, timeStamp, packages, sign) {
+		WeChat.isWXAppInstalled().then((isInstalled) => {
+			if (isInstalled) {
+				WeChat.pay({
+					partnerId: partnerId, // 商家向财付通申请的商家id
+					prepayId: prepayId, // 预支付订单
+					nonceStr: nonceStr, // 随机串,防重发
+					timeStamp: timeStamp, // 时间戳,防重发.
+					package: packages, // "Sign=WXPay", // 商家根据财付通文档填写的数据和签名
+					sign: sign // 商家根据微信开放平台文档对数据做的签名
+				})
+					.then((requestJson) => {
+						//支付成功回调
+						if (requestJson.errCode == '0') {
+							//回调成功处理
+						}
+					})
+					.catch((err) => {
+						alert('支付失败');
+					});
+			} else {
+				alert('请安装微信');
+			}
+		});
+	}
+
+	//跳转小程序(需要改 react-native-wechat插件 1.删除react-native-android默认的jar包,直接引用微信官网的包。2.在react-native-wechat插件的index.js中,增加toMiniProgram方法)
+	static toMiniProgram(programId, path) {
+		WeChat.toMiniProgram(programId, path);
+	}
 }
+
+/***
+
+  //github:https://github.com/yorkie/react-native-wechat
+  使用方法:
+  1.登录使用方法,返回object
+ 		wechat.wechatLogin((user) => {
+					console.log('openid:' + user['openid']);
+					console.log('unionid:' + user['unionid']);
+					console.log('nickname:' + user['nickname']);
+					console.log('sex:' + user['sex']);
+					console.log('avatar:' + user['province'] + '--' + user['city']);
+				});
+	2.跳转小程序方法
+		wechat.toMiniProgram('gh_d81480f7a2fd', '');
+
+
+    //微信各种分享方法传参定义
+    {
+    type {Number} type of this message. Can be {news|text|imageUrl|imageFile|imageResource|video|audio|file}
+    thumbImage {String} Thumb image of the message, which can be a uri or a resource id.
+    description {String} The description about the sharing.
+    webpageUrl {String} Required if type equals news. The webpage link to share.
+    imageUrl {String} Provide a remote image if type equals image.
+    videoUrl {String} Provide a remote video if type equals video.
+    usicUrl {String} Provide a remote music if type equals audio.
+    filePath {String} Provide a local file if type equals file.
+    fileExtension {String} Provide the file type if type equals file.
+    }
+
+
+
+ */