Browse Source

解决冲突

Limengbo 5 years ago
parent
commit
057bfd6495

+ 13 - 0
android/app/src/main/AndroidManifest.xml

@@ -61,6 +61,19 @@
             android:name=".wxapi.WXPayEntryActivity"
             android:exported="true"
             android:label="@string/app_name" />
+        <activity
+            android:name="com.alipay.sdk.app.H5PayActivity"
+            android:configChanges="orientation|keyboardHidden|navigation|screenSize"
+            android:exported="false"
+            android:screenOrientation="behind"
+            android:windowSoftInputMode="adjustResize|stateHidden"></activity>
+        <activity
+            android:name="com.alipay.sdk.app.H5AuthActivity"
+            android:configChanges="orientation|keyboardHidden|navigation"
+            android:exported="false"
+            android:screenOrientation="behind"
+            android:windowSoftInputMode="adjustResize|stateHidden"></activity>
+
     </application>
 
 </manifest>

File diff suppressed because it is too large
+ 115 - 0
android/app/src/main/assets/index.android.bundle


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


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


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


+ 48 - 2
pages/Login.js

@@ -24,7 +24,7 @@ export default class Login extends BasePage {
 			<View style={styles.wrapper}>
 				<StatusBar backgroundColor={'white'} translucent={true} barStyle={'dark-content'} />
 				<View style={styles.jump}>
-					<TouchableOpacity style={styles.jumpBtn}>
+					<TouchableOpacity style={styles.jumpBtn} onPress={this.jumpBtn.bind(this)}>
 						<Text style={styles.jumpText}>跳过</Text>
 						<Image source={require('./images/common/arrowRight.png')} />
 					</TouchableOpacity>
@@ -174,6 +174,52 @@ export default class Login extends BasePage {
 		}
 	}
 
+	jumpBtn() {
+		let option = {
+			method: 'POST',
+			body: {
+				channel: '006',
+				deviceCode: this.state.deviceCode,
+				openId: '',
+				unionId: '',
+				avatar: '',
+				sex: '',
+				nickName: ''
+			}
+		};
+		http_user.jumpLogin(option).then((result) => {
+			if (result.code == 200) {
+				//登陆成功了,可以存储用户数据到本地
+				console.log('====================================');
+				console.log('jumpLogin-result:', result);
+				console.log('====================================');
+				var usermap = new Map();
+				usermap.set('isVisitor', result.data.isVisitor);
+				usermap.set('birthday', result.data.user.birthday);
+				usermap.set('channel', result.data.user.channel);
+				usermap.set('city', result.data.user.city);
+				usermap.set('country', result.data.user.country);
+				usermap.set('eid', result.data.user.eid);
+				usermap.set('gmtCreated', result.data.user.gmtCreated);
+				usermap.set('gmtModified', result.data.user.gmtModified);
+				usermap.set('grade', result.data.user.grade);
+				usermap.set('mobile', result.data.user.mobile);
+				usermap.set('nickName', result.data.user.nickName);
+				usermap.set('province', result.data.user.province);
+				usermap.set('school', result.data.user.school);
+				usermap.set('sex', result.data.user.sex);
+				usermap.set('status', result.data.user.status);
+				usermap.set('uid', result.data.user.uid);
+				usermap.set('ageGroup', result.data.user.ageGroup);
+				usermap.set('avatar', result.data.user.avatar);
+				this.saveUserInfo(commonutil.mapToJson(usermap));
+				this.clearPageToNext('SchoolAge');
+			} else {
+				ToastAndroid.show(result.message, ToastAndroid.SHORT);
+			}
+		});
+	}
+
 	wechatLogin() {
 		wechat.wechatLogin((user) => {
 			let option = {
@@ -184,7 +230,7 @@ export default class Login extends BasePage {
 					openId: user['openid'],
 					unionId: user['unionid'],
 					avatar: user['headimgurl'],
-					sex: +user['sex'],
+					sex: user['sex'],
 					nickName: user['nickname']
 				}
 			};

+ 0 - 7
pages/PersonalInfo.js

@@ -713,9 +713,6 @@ export default class PersonalInfo extends BasePage {
 							uri: this.state.file_user_data.get('avatar')
 						}
 					});
-					console.log('====================================');
-					console.log('加载头像路径了..');
-					console.log('====================================');
 				}
 				if (this.state.phone == null || this.state.phone === '') {
 					this.setState({
@@ -860,10 +857,6 @@ export default class PersonalInfo extends BasePage {
 			//微信
 			case 7:
 				wechat.wechatLogin((result) => {
-					console.log('openid:' + result['openid']);
-					console.log('unionid:' + result['unionid']);
-					console.log('nickname:' + result['nickname']);
-					console.log('sex:' + result['sex']);
 					let opts = {
 						method: 'PUT',
 						body: {

+ 110 - 42
pages/buy/buy.js

@@ -13,6 +13,9 @@ import {
 	TouchableHighlight,
 	DeviceEventEmitter,
 	ScrollView,
+	BackHandler,
+	ToastAndroid,
+	StatusBar,
 	Modal,
 	Animated,
 	TextInput
@@ -22,19 +25,31 @@ import Dimensions from '../utils/dimensions';
 import TopicTitle from '../components/TopicTitle';
 import CourseTitle from '../components/CourseTitle';
 import wechat from '../utils/wechat';
-import aliPay from '../utils/aliPay';
+import PayServer from '../services/Pay';
+import Alipay from 'react-native-yunpeng-alipay';
 
 export default class Buy extends BasePage {
 	state = {
 		shopData: [
-			{ title: '1个月', originPrice: '199', price: '49' },
-			{ title: '12个月', originPrice: '499', price: '199' }
+			{
+				appCode: '',
+				days: 0,
+				gmtCreated: 0,
+				gmtModified: 0,
+				id: 0,
+				title: '',
+				originalPrice: '',
+				payType: 1,
+				price: '',
+				sort: 0
+			}
 		],
 		currentTapindex: 0,
 		slideAnim: new Animated.Value(-150),
 		ifDialogShow: false,
 		payType: 1,
-		ticketPrice: 0
+		ticketPrice: 0,
+		useTicket: false
 	};
 	itemTap = (index) => {
 		this.setState({
@@ -57,11 +72,12 @@ export default class Buy extends BasePage {
 					¥{item.price}元
 				</Text>
 				<Text style={this.state.currentTapindex === index ? styles.originPriceTap : styles.originPrice}>
-					原价:¥{item.originPrice}
+					原价:¥{item.originalPrice}
 				</Text>
 			</TouchableOpacity>
 		);
 	};
+
 	dialogComeout = (index) => {
 		if (index) {
 			this.setState(
@@ -71,14 +87,14 @@ export default class Buy extends BasePage {
 				() => {
 					Animated.timing(this.state.slideAnim, {
 						toValue: 0,
-						duration: 300
+						duration: 100
 					}).start();
 				}
 			);
 		} else {
 			Animated.timing(this.state.slideAnim, {
 				toValue: -150,
-				duration: 200
+				duration: 100
 			}).start();
 			setTimeout(() => {
 				this.setState({
@@ -99,11 +115,35 @@ export default class Buy extends BasePage {
 			}
 		);
 	};
+	componentWillMount() {
+		//获取订购数据信息
+		this.getMember();
+		BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
+	}
+	componentWillUnmount() {
+		BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
+	}
+	onBackAndroid = () => {
+		if (this.state.ifDialogShow) {
+			this.dialogComeout(false);
+		} else {
+			this.goBack();
+		}
+		return true;
+	};
+
+	async getMember() {
+		await PayServer.getMember().then((result) => {
+			this.setState({
+				shopData: result.data
+			});
+		});
+	}
 	choseTicket = () => {
 		this.toNextPage('Ticket', { choseTicketCallBack: this.choseTicketCallBack.bind(this) });
 	};
 	choseTicketCallBack(item) {
-		/**
+		/**item参数
          * 	type: 1,
 			price: 12,
 			num: 6,
@@ -111,42 +151,75 @@ export default class Buy extends BasePage {
          * 
          */
 		this.setState({
-			ticketPrice: item.price
+			ticketPrice: item.price,
+			useTicket: true
 		});
 	}
+
+	getPrice(old_price) {
+		return parseInt(old_price) - parseInt(this.state.ticketPrice) < 0
+			? 0
+			: parseInt(old_price) - parseInt(this.state.ticketPrice);
+	}
 	pay = () => {
+		let data = this.state.shopData[this.state.currentTapindex];
 		switch (this.state.payType) {
 			case 1:
-				//微信支付
-				wechat.pay();
+				let params = {
+					productCode: data.id,
+					type: '0',
+					preferentialIds: '',
+					useVoucher: this.state.useTicket
+				};
+
+				PayServer.payByWechat(params).then((result) => {
+					wechat.pay(
+						result.data.partnerid,
+						result.data.prepayid,
+						result.data.noncestr,
+						result.data.timestamp,
+						result.data.package,
+						result.data.sign,
+						(result) => {
+							ToastAndroid.show('支付成功', ToastAndroid.SHORT);
+							// console.log('wechat result', result);
+						}
+					);
+				});
+
 				break;
 			case 2:
 				//阿里支付
-				let params = {
-					partner: 'asdfasdf', //app_id
-					seller_id: '115681592@qq.com', //下单账号,用的芮总QQ邮箱,人家说没有可不填,但为了代表下单身份才用芮总QQ邮箱的
-					out_trade_no: 'ALIPAY15307684880120000000001', //第三方订单号
-					subject: '描述',
-					body: '',
-					total_fee: '0.01', //价格
-					notify_url: 'http://xx.xx.xx.xx/api/0/alipay/alipayCallback', //回调地址
-					service: 'm.pay',
-					payment_type: '1',
-					_input_charset: 'utf-8',
-					it_b_pay: '30m',
-					sign: 'sdfasdf', //签名
-					sign_type: 'RSA'
+				let params_ali = {
+					productCode: data.id,
+					type: '0',
+					preferentialIds: '',
+					useVoucher: this.state.useTicket
 				};
-				aliPay.pay(params);
+				//先请求后台给支付数据
+				PayServer.payByAli(params_ali).then((result) => {
+					Alipay.pay(result.data.response).then(
+						function(data) {
+							//成功
+							console.log(data);
+						},
+						function(err) {
+							//失败
+							console.log(err);
+						}
+					);
+				});
 				break;
 		}
 	};
 	render() {
 		return (
 			<View style={{ flex: 1 }}>
+				<StatusBar barStyle={'dark-content'} backgroundColor={'white'} translucent={true} />
 				<View
 					style={{
-						height: 30,
+						height: 50,
+						backgroundColor: 'white',
 						marginTop: 30
 					}}
 				>
@@ -165,6 +238,13 @@ export default class Buy extends BasePage {
 					<View>{this.state.shopData.map((item, index) => this.renderItem(item, index))}</View>
 				</View>
 				<View style={{ flex: 0.01, backgroundColor: 'rgba(242, 242, 242, 1)' }} />
+				<TouchableOpacity style={styles.payment} activeOpacity={1} onPress={this.choseTicket.bind(this)}>
+					<Text style={styles.left}>使用抵用券</Text>
+					<View style={styles.right}>
+						<Text style={styles.method}>-¥{this.state.ticketPrice}元</Text>
+						<Image source={require('../images/common/arrowRight.png')} />
+					</View>
+				</TouchableOpacity>
 				<TouchableOpacity style={styles.payment} activeOpacity={1} onPress={() => this.dialogComeout(true)}>
 					<Text style={styles.left}>支付方式</Text>
 					<View style={styles.right}>
@@ -177,13 +257,6 @@ export default class Buy extends BasePage {
 						<Image source={require('../images/common/arrowRight.png')} />
 					</View>
 				</TouchableOpacity>
-				<TouchableOpacity style={styles.payment} activeOpacity={1} onPress={this.choseTicket.bind(this)}>
-					<Text style={styles.left}>使用抵用券</Text>
-					<View style={styles.right}>
-						<Text style={styles.method}>-¥{this.state.ticketPrice}元</Text>
-						<Image source={require('../images/common/arrowRight.png')} />
-					</View>
-				</TouchableOpacity>
 				<View style={{ flex: 0.01, backgroundColor: 'rgba(242, 242, 242, 1)' }} />
 				<View>
 					<Text style={{ fontSize: 14, width: '100%', textAlignVertical: 'center', textAlign: 'center' }}>
@@ -194,8 +267,7 @@ export default class Buy extends BasePage {
 					{this.state.ticketPrice > 0 ? (
 						(price = (
 							<Text style={styles.bottomLeft}>
-								¥{parseInt(this.state.shopData[this.state.currentTapindex].price) -
-									parseInt(this.state.ticketPrice)}元
+								¥{this.getPrice(this.state.shopData[this.state.currentTapindex].price)}元
 							</Text>
 						))
 					) : (
@@ -214,12 +286,7 @@ export default class Buy extends BasePage {
 						style={{ ...styles.dialog }}
 						underlayColor={0.1}
 					>
-						<Animated.View
-							style={{ ...styles.payMethod, bottom: this.state.slideAnim }}
-							onPress={() => {
-								alert(12311);
-							}}
-						>
+						<Animated.View style={{ ...styles.payMethod, bottom: this.state.slideAnim }} onPress={() => {}}>
 							<Text style={styles.payText}>选择支付方式</Text>
 							<TouchableOpacity
 								activeOpacity={0.9}
@@ -248,6 +315,7 @@ export default class Buy extends BasePage {
 								) : null}
 							</TouchableOpacity>
 							{/* <TextInput style={styles.payDialog} /> */}
+							<View style={{ flex: 0.2 }} />
 						</Animated.View>
 					</TouchableHighlight>
 				) : null}

+ 125 - 45
pages/buy/ticket.js

@@ -12,53 +12,78 @@ import {
 	FlatList,
 	TouchableHighlight,
 	DeviceEventEmitter,
+	StatusBar,
 	ScrollView,
 	ImageBackground
 } from 'react-native';
 import BasePage from '../BasePage';
 import Dimensions from '../utils/dimensions';
+import CourseTitle from '../components/CourseTitle';
+import PayServer from '../services/Pay';
 
 export default class Ticket extends BasePage {
 	state = {
-		data: [
-			{
-				type: 1,
-				price: 12,
-				num: 6,
-				time: '2019-12-12'
-			},
-			{
-				type: 1,
-				price: 33,
-				num: 9,
-				time: '2019-12-12'
-			},
-			{
-				type: 2,
-				price: 50,
-				limit: '199',
-				time: '2019-12-12'
-			}
-		]
+		ticket_data: []
 	};
 	renderItem = (item, index) => {
 		return (
-			<View>
+			<View style={{}}>
 				{item.type === 1 ? (
 					// 抵用券
-					<TouchableOpacity onPress={() => this.userdiscount(item)} activeOpacity={1}>
-						<ImageBackground source={require('../images/ticket/discount-bg.png')} style={styles.type1}>
+					<TouchableOpacity
+						onPress={() => this.userdiscount(item)}
+						activeOpacity={1}
+						style={{ width: '100%', justifyContent: 'center', alignItems: 'center' }}
+					>
+						<ImageBackground
+							source={require('../images/ticket/discount-bg.png')}
+							style={styles.type1}
+							imageStyle={{ resizeMode: 'contain' }}
+						>
+							<View style={{ flex: 0.3 }} />
 							<View style={styles.topInfo}>
+								<View style={{ flex: 0.5 }} />
 								<View style={styles.left2}>
 									<Text style={styles.price}>¥{item.price}</Text>
 									<Text style={styles.type}>抵用券</Text>
 								</View>
-
+								<View style={{ flex: 0.2 }} />
 								<View style={styles.right2}>
-									<Text style={styles.greyText}>购买{item.num}个单课程的奖励</Text>
+									<Text style={{ fontSize: 16, color: 'rgba(22, 22, 22, 1)' }}>
+										购买{item.num}个单课程的奖励
+									</Text>
 									<Text style={styles.greyText}>有效期:{item.time}</Text>
 								</View>
+								<View
+									style={{
+										flex: 0.4,
+										marginRight: 50,
+										marginTop: 20
+									}}
+								>
+									<ImageBackground
+										source={require('../images/ticket/button-bg.png')}
+										style={{
+											width: 85,
+											height: 27,
+											justifyContent: 'center'
+										}}
+									>
+										<Text
+											style={{
+												fontSize: 16,
+												color: 'white',
+												textAlign: 'center',
+												textAlignVertical: 'center'
+											}}
+										>
+											立即使用
+										</Text>
+									</ImageBackground>
+								</View>
+								<View style={{ flex: 1 }} />
 							</View>
+							<View style={{ flex: 0.2 }} />
 							<View style={styles.bottomInfo}>
 								<Text style={styles.greyText}>注:开通会员时方可使用</Text>
 								<Text style={styles.blueText}>查看订单</Text>
@@ -67,7 +92,11 @@ export default class Ticket extends BasePage {
 					</TouchableOpacity>
 				) : (
 					// 优惠券
-					<ImageBackground source={require('../images/ticket/coupon-bg.png')} style={styles.type2}>
+					<ImageBackground
+						source={require('../images/ticket/coupon-bg.png')}
+						style={styles.type2}
+						imageStyle={{ resizeMode: 'center' }}
+					>
 						<View style={styles.left2}>
 							<Text style={styles.price}>¥{item.price}</Text>
 							<Text style={styles.type}>优惠券</Text>
@@ -84,14 +113,62 @@ export default class Ticket extends BasePage {
 	};
 	render() {
 		return (
-			<FlatList
-				data={this.state.data}
-				horizontal={false}
-				renderItem={({ item, index }) => this.renderItem(item, index)}
-				keyExtractor={(item, index) => index.toString()}
-			/>
+			<View style={{ flex: 1 }}>
+				<StatusBar barStyle={'dark-content'} backgroundColor={'white'} translucent={true} />
+				<View
+					style={{
+						height: 50,
+						backgroundColor: 'white',
+						marginTop: 30
+					}}
+				>
+					<CourseTitle
+						width={this.getWindowWidth()}
+						title="抵用券"
+						lefttype={1}
+						textcolor={'#231F20'}
+						backPress={() => this.goBack()}
+						// backPress={() => alert("左侧按钮")}
+					/>
+				</View>
+				<View style={{ flex: 0.1, backgroundColor: 'rgba(242, 242, 242, 1)' }} />
+				<View style={{ flex: 5, backgroundColor: 'rgba(242, 242, 242, 1)' }}>
+					{this.state.ticket_data.length > 0 ? (
+						<FlatList
+							data={this.state.ticket_data}
+							horizontal={false}
+							renderItem={({ item, index }) => this.renderItem(item, index)}
+							keyExtractor={(item, index) => index.toString()}
+						/>
+					) : (
+						<Text
+							style={{ height: '100%', width: '100%', textAlign: 'center', textAlignVertical: 'center' }}
+						>
+							还没有获取到抵用券
+						</Text>
+					)}
+				</View>
+			</View>
 		);
 	}
+	componentWillMount() {
+		//获取用户优惠券信息
+		this.getVoucher();
+	}
+
+	async getVoucher() {
+		await PayServer.getVoucher().then((result) => {
+			console.log('====================================');
+			console.log('getVoucher', result);
+			console.log('====================================');
+			if (result.data.length == 0) {
+			} else {
+				this.setState({
+					ticket_data: result.data
+				});
+			}
+		});
+	}
 
 	userdiscount = (item) => {
 		if (this.props.navigation.state.params != undefined) {
@@ -103,23 +180,22 @@ export default class Ticket extends BasePage {
 
 const styles = StyleSheet.create({
 	type1: {
-		width: 343,
-		height: 144,
+		width: '100%',
+		height: 154,
 		flexDirection: 'column',
-		justifyContent: 'space-between',
-		alignItems: 'center',
-		paddingTop: 12,
-		paddingBottom: 14
+		justifyContent: 'center',
+		// paddingHorizontal: 70,
+		alignItems: 'center'
 	},
 	type2: {
-		width: 343,
+		width: '100%',
 		height: 100,
 		flexDirection: 'row',
-		justifyContent: 'flex-start',
-		alignItems: 'center',
-		paddingLeft: 27
+		justifyContent: 'center',
+		alignItems: 'center'
 	},
 	left2: {
+		flex: 1.2,
 		flexDirection: 'column'
 	},
 	price: {
@@ -133,15 +209,19 @@ const styles = StyleSheet.create({
 		fontWeight: '500'
 	},
 	right2: {
-		flexDirection: 'column'
+		flex: 3.5,
+		flexDirection: 'column',
+		marginTop: 10
 	},
 	topInfo: {
+		flex: 1,
 		flexDirection: 'row',
 		alignItems: 'center'
 	},
 	bottomInfo: {
-		width: '100%',
-		paddingHorizontal: 12,
+		width: '90%',
+		flex: 1,
+		// paddingHorizontal: 12,
 		flexDirection: 'row',
 		alignItems: 'center',
 		justifyContent: 'space-between'

+ 8 - 9
pages/components/MainPage.js

@@ -39,7 +39,7 @@ export default class MainPage extends BasePage {
 		}
 	}
 
-	 updateRender(index) {
+	updateRender(index) {
 		// LibraryUrl.getIndex(index).success(res => {
 
 		// }).fail(() => {
@@ -53,6 +53,7 @@ export default class MainPage extends BasePage {
 			const hotCourse = res.data.hotCourse;
 			const recommend = res.data.recommend; //全部课程
 			const banner = res.data.banner; //轮播图
+			const pageCode = res.data.pageCode;
 			// const listData = [];
 			// for(let item in res.data){
 			//   console.log(item)
@@ -70,7 +71,8 @@ export default class MainPage extends BasePage {
 				schedule,
 				recommend,
 				banner,
-				scheduleWeek
+				scheduleWeek,
+				pageCode
 			});
 			console.log(this.state.banner);
 		});
@@ -125,9 +127,6 @@ export default class MainPage extends BasePage {
 	}
 
 	switchGrade = (index) => {
-		console.log('====================================');
-		console.log('switchGrade:' + index);
-		console.log('====================================');
 		const obj = this.state.switchList[index];
 		this.setState({
 			currentSwitch: obj
@@ -189,7 +188,7 @@ export default class MainPage extends BasePage {
 					uri={this.state.avatar}
 					width={400}
 					height={150}
-					username= {this.state.username}
+					username={this.state.username}
 					isVip={this.state.isVip}
 					onPress={() => this.toNextPage('userCenter')}
 				/>
@@ -251,7 +250,7 @@ export default class MainPage extends BasePage {
 						height: Dimensions.getHeight(86),
 						marginRight: 12
 					}}
-					onPress={() => this.toNextPage('SchedulePage', { id })}
+					onPress={() => this.toNextPage('SchedulePage', { pagecode: this.state.pageCode })}
 					key={index}
 					activeOpacity={1}
 				>
@@ -481,11 +480,11 @@ export default class MainPage extends BasePage {
 				console.log(commonutil.mapToJson(this.state.file_user_data));
 				var ageGroup = this.state.file_user_data.get('ageGroup');
 				const username = this.state.file_user_data.get('nickName');
-				const avatar =  this.state.file_user_data.get('avatar');
+				const avatar = this.state.file_user_data.get('avatar');
 				this.setState({
 					username,
 					avatar
-				})
+				});
 				var ageindex = 0;
 				if (ageGroup === 'PRESCHOOL') {
 					ageindex = 0;

+ 5 - 5
pages/components/SchedulePage.js

@@ -200,12 +200,12 @@ export default class SchedulePage extends BasePage {
 		BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
 	}
 	componentDidMount() {
-		const { id } = this.props.navigation.state.params;
-		alert(id);
+		let pagecode = this.props.navigation.state.params.pagecode;
+		alert(pagecode);
 		let colorTemp = '';
 		let colorIndexTemp = 0;
 		const colorList = this.state.colorList;
-		ScheduleUrl.getSchedule('KINDERGARTEN').success((res) => {
+		ScheduleUrl.getSchedule(pagecode).success((res) => {
 			res.data.wareList.forEach((item, index) => {
 				if (index === 0) {
 					colorTemp = item.subTitle;
@@ -306,7 +306,7 @@ export default class SchedulePage extends BasePage {
 			'标题测试',
 			'标题内容',
 			'http://www.ncloud.hk/email-signature-262x100.png',
-			'http://www.baidu.com'
+			'http://www.efunbox.cn'
 		);
 	}
 	sharedcircel() {
@@ -314,7 +314,7 @@ export default class SchedulePage extends BasePage {
 			'标题测试',
 			'标题内容',
 			'http://www.ncloud.hk/email-signature-262x100.png',
-			'http://www.baidu.com'
+			'http://www.efunbox.cn'
 		);
 	}
 }

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


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


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


+ 43 - 0
pages/services/Pay.js

@@ -0,0 +1,43 @@
+import APIConfig from './api.js';
+import efunRequest from '../utils/efunRequest';
+import request from '../utils/request';
+import commonUitl from '../utils/commonutil';
+
+export default class PayUtil {
+	static async getMember() {
+		return request(APIConfig.getMemberUrl() + '?appCode=' + commonUitl.getAppCode(), { method: 'GET' });
+	}
+
+	static async getVoucher() {
+		return request(APIConfig.getVoucherUrl(), { method: 'GET' });
+	}
+
+	static async payByAli(params) {
+		return request(
+			APIConfig.getPayUrl() +
+				'/aliPay/pay?productCode=' +
+				params.productCode +
+				'&type=' +
+				params.type +
+				'&preferentialIds=' +
+				params.preferentialIds +
+				'&useVoucher=' +
+				params.useVoucher,
+			{ method: 'GET' }
+		);
+	}
+	static async payByWechat(params) {
+		return request(
+			APIConfig.getPayUrl() +
+				'/wxPay/prePay?productCode=' +
+				params.productCode +
+				'&type=' +
+				params.type +
+				'&preferentialIds=' +
+				params.preferentialIds +
+				'&useVoucher=' +
+				params.useVoucher,
+			{ method: 'GET' }
+		);
+	}
+}

+ 13 - 1
pages/services/api.js

@@ -2,7 +2,10 @@ const url = {
 	library_url: 'http://ott80testlibrary.yifangjiaoyu.cn/mobile/page',
 	schedule_url: 'http://ott80test-schedule.yifangjiaoyu.cn/mobile/schedule/',
 	user_url: 'http://ott80test-base.yifangjiaoyu.cn/mobile/user',
-	upload_img: 'http://ott80test-base.yifangjiaoyu.cn/file/upload'
+	upload_img: 'http://ott80test-base.yifangjiaoyu.cn/file/upload',
+	get_member: 'http://ott80test-trade.yifangjiaoyu.cn/customer/order/member',
+	pay_url: 'http://ott80test-trade.yifangjiaoyu.cn/mobile',
+	get_voucher: 'http://ott80test-trade.yifangjiaoyu.cn/mobile/voucher'
 };
 
 export default class APIConfig {
@@ -20,4 +23,13 @@ export default class APIConfig {
 	static getUploadImg() {
 		return url.upload_img;
 	}
+	static getPayUrl() {
+		return url.pay_url;
+	}
+	static getMemberUrl() {
+		return url.get_member;
+	}
+	static getVoucherUrl() {
+		return url.get_voucher;
+	}
 }

+ 4 - 0
pages/services/user.js

@@ -86,6 +86,10 @@ export default class user {
 	static wechatLogin(opts) {
 		return request(APIConfig.getUserUrl(``), opts);
 	}
+	//跳过
+	static jumpLogin(opts) {
+		return request(APIConfig.getUserUrl(``), opts);
+	}
 }
 
 async function getuid() {

+ 278 - 293
pages/userCenter.js

@@ -1,304 +1,289 @@
 /*
  * 个人中心页面
  */
-import React, { Component } from "react";
+import React, { Component } from 'react';
 import {
-  Platform,
-  StyleSheet,
-  Text,
-  View,
-  Image,
-  TouchableOpacity,
-  ImageBackground,
-  Button,
-  StatusBar,
-  Modal,
-  TouchableHighlight,
-  DeviceEventEmitter,
-  ScrollView
-} from "react-native";
-import BasePage from "./BasePage";
-import Dimensions from "./utils/dimensions";
-import ShopBox from "./components/ShopBox";
-import TopicTitle from "./components/TopicTitle";
-import ScrollRow from "./components/ScrollRow";
-import CourseTitle from "./components/CourseTitle";
-import user from "./services/user";
+	Platform,
+	StyleSheet,
+	Text,
+	View,
+	Image,
+	TouchableOpacity,
+	ImageBackground,
+	Button,
+	StatusBar,
+	Modal,
+	TouchableHighlight,
+	DeviceEventEmitter,
+	ScrollView
+} from 'react-native';
+import BasePage from './BasePage';
+import Dimensions from './utils/dimensions';
+import ShopBox from './components/ShopBox';
+import TopicTitle from './components/TopicTitle';
+import ScrollRow from './components/ScrollRow';
+import CourseTitle from './components/CourseTitle';
+import user from './services/user';
+import commonUtil from './utils/commonutil';
 
 export default class userCenter extends BasePage {
-  componentDidMount() {
-    //触发更新
-    this.refreshSubScription = DeviceEventEmitter.addListener('infoback', () => {
-      user.userMember().then(res => {
-        console.log("个人列表", res);
-        // 收藏
-        const favoritesList = res.data.favoritesList;
-        //观看记录
-        const playLogList = res.data.playLogList;
-        // 用户消息
-        const user = res.data.user;
-        // VIP
-        const vip = res.data.vip;
-        this.setState({
-            favoritesList,
-            playLogList,
-            user,
-            vip
-        });
-      });
-    })
-    DeviceEventEmitter.emit('infoback')
-  }
-  componentWillUnmount(){
-    this.refreshSubScription.remove();
-  }
-  state = {
-    nickName: "初始昵称",
-    user: {},
-    ifDiscount: true,
-    isVIP: false,
-    btnArr: [
-      {
-        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")
-    },
-    favoritesList: [],
-    playLogList: [],
-    vip: false
-  };
-  renderBtn = (item, index) => {
-    return (
-      <TouchableOpacity
-        key={index}
-        onPress={() => this.goTo(`${item.goTo}`)}
-        style={{ display: "flex", justifyContent: "space-between" }}
-      >
-        <View style={styles.btnItem}>
-          <Image source={item.icon} style={styles.btnIcon} />
-          <Text style={styles.btnTitle}>{item.title}</Text>
-        </View>
-      </TouchableOpacity>
-    );
-  };
-  goBack() {
-    //返回上一页
-    this.props.navigation.goBack();
-  }
-  render() {
-    return (
-      <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 }}
-          >
-            <StatusBar
-              backgroundColor={"transparent"}
-              barStyle={"dark-content"}
-              // backgroundColor={"white"}
-              translucent={true}
-              hidden={false}
-            />
-            <View
-              style={{
-                height: 30,
-                // backgroundColor: "white"
-                marginTop: 20
-              }}
-            >
-              <CourseTitle
-                width={this.getWindowWidth()}
-                title="个人中心"
-                lefttype={2}
-                righttype={2}
-                textcolor={"#fff"}
-                backPress={() => this.goBack()}
-                // backgroundColor={"transparent"}
-                // rightPress={this.showSharedDialog.bind(this)}
-              />
-            </View>     
-            <View style={styles.userInfo}>
-              <TouchableOpacity onPress={() => this.goTo(`PersonalInfo`)}>
-                <Image
-                  style={styles.userAvatar}
-                  source={{ uri: this.state.user.avatar }}
-                />
-              </TouchableOpacity>
+	componentDidMount() {
+		//触发更新
+		this.refreshSubScription = DeviceEventEmitter.addListener('infoback', () => {
+			user.userMember().then((res) => {
+				console.log('个人列表', res);
+				// 收藏
+				const favoritesList = res.data.favoritesList;
+				//观看记录
+				const playLogList = res.data.playLogList;
+				// 用户消息
+				const user = res.data.user;
+				// VIP
+				const vip = res.data.vip;
+				this.setState({
+					favoritesList,
+					playLogList,
+					user,
+					vip
+				});
+			});
+		});
+		DeviceEventEmitter.emit('infoback');
+	}
+	componentWillUnmount() {
+		this.refreshSubScription.remove();
+	}
+	state = {
+		nickName: '初始昵称',
+		user: {},
+		ifDiscount: true,
+		isVIP: false,
+		btnArr: [
+			{
+				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: 'Phone'
+			}
+		],
+		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')
+		},
+		favoritesList: [],
+		playLogList: [],
+		vip: false
+	};
+	renderBtn = (item, index) => {
+		return (
+			<TouchableOpacity
+				key={index}
+				onPress={() => this.goTo(`${item.goTo}`)}
+				style={{ display: 'flex', justifyContent: 'space-between' }}
+			>
+				<View style={styles.btnItem}>
+					<Image source={item.icon} style={styles.btnIcon} />
+					<Text style={styles.btnTitle}>{item.title}</Text>
+				</View>
+			</TouchableOpacity>
+		);
+	};
+	goBack() {
+		//返回上一页
+		this.props.navigation.goBack();
+	}
+	render() {
+		return (
+			<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 }}
+					>
+						<StatusBar
+							backgroundColor={'transparent'}
+							barStyle={'dark-content'}
+							// backgroundColor={"white"}
+							translucent={true}
+							hidden={false}
+						/>
+						<View
+							style={{
+								height: 30,
+								// backgroundColor: "white"
+								marginTop: 20
+							}}
+						>
+							<CourseTitle
+								width={this.getWindowWidth()}
+								title="个人中心"
+								lefttype={2}
+								righttype={2}
+								textcolor={'#fff'}
+								backPress={() => this.goBack()}
+								// backgroundColor={"transparent"}
+								// rightPress={this.showSharedDialog.bind(this)}
+							/>
+						</View>
+						<View style={styles.userInfo}>
+							<TouchableOpacity onPress={() => this.goTo(`PersonalInfo`)}>
+								<Image style={styles.userAvatar} source={{ uri: this.state.user.avatar }} />
+							</TouchableOpacity>
 
-              <View style={styles.userRight}>
-                <View style={styles.userName}>
-                  <Text style={styles.userNameText}>
-                    {this.state.user.nickName}
-                  </Text>
-                  {this.state.vip ? (
-                    <Image
-                      style={styles.vipTag}
-                      source={require("./images/common/vip.png")}
-                    />
-                  ) : null}
-                </View>
-                {this.state.vip ? null : (
-                  <View style={styles.userName}>
-                    <Text style={styles.vipSologan}>开通vip</Text>
-                  </View>
-                )}
-              </View>
-            </View>
-            <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}>
-          <ShopBox
-            data={this.state.shopData}
-            discount={this.state.discount}
-            nav={this.props.navigation.navigate}
-          />
-        </View>
-        <View style={styles.recordSection}>
-          <TopicTitle title={"观看记录"} ifTubeShow={true} />
-          <ScrollRow
-            itemWidth={106}
-            itemHeight={153}
-            data={this.state.playLogList}
-          />
-        </View>
-        <View style={styles.collectSection}>
-          <TopicTitle title={"我的收藏"} ifTubeShow={true} />
-          <ScrollRow
-            itemWidth={106}
-            itemHeight={150}
-            data={this.state.favoritesList}
-          />
-        </View>
-      </ScrollView>
-    );
-  }
-  goTo(index) {
-    this.toNextPage(index);
-  }
+							<View style={styles.userRight}>
+								<View style={styles.userName}>
+									<Text style={styles.userNameText}>{this.state.user.nickName}</Text>
+									{this.state.vip ? (
+										<Image style={styles.vipTag} source={require('./images/common/vip.png')} />
+									) : null}
+								</View>
+								{this.state.vip ? null : (
+									<View style={styles.userName}>
+										<Text style={styles.vipSologan}>开通vip</Text>
+									</View>
+								)}
+							</View>
+						</View>
+						<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}>
+					<ShopBox
+						data={this.state.shopData}
+						discount={this.state.discount}
+						nav={this.props.navigation.navigate}
+					/>
+				</View>
+				<View style={styles.recordSection}>
+					<TopicTitle title={'观看记录'} ifTubeShow={true} />
+					<ScrollRow itemWidth={106} itemHeight={153} data={this.state.playLogList} />
+				</View>
+				<View style={styles.collectSection}>
+					<TopicTitle title={'我的收藏'} ifTubeShow={true} />
+					<ScrollRow itemWidth={106} itemHeight={150} data={this.state.favoritesList} />
+				</View>
+			</ScrollView>
+		);
+	}
+	goTo(index) {
+		if (index === 'Phone') {
+			commonUtil.callPhone('15810271473');
+		} else {
+			this.toNextPage(index);
+		}
+	}
 }
 
 const styles = StyleSheet.create({
-  topSection: {
-    height: 250,
-    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: {
-    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'
-  },
-  recordSection: {
-    width: Dimensions.width,
-    height: 235
-    // backgroundColor: 'blue'
-  },
-  collectSection: {
-    width: Dimensions.width,
-    height: 255,
-    marginBottom: 20
-    // backgroundColor: 'yellow'
-  }
+	topSection: {
+		height: 250,
+		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: {
+		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'
+	},
+	recordSection: {
+		width: Dimensions.width,
+		height: 235
+		// backgroundColor: 'blue'
+	},
+	collectSection: {
+		width: Dimensions.width,
+		height: 255,
+		marginBottom: 20
+		// backgroundColor: 'yellow'
+	}
 });

+ 0 - 33
pages/utils/aliPay.js

@@ -1,33 +0,0 @@
-import Alipay from 'react-native-yunpeng-alipay';
-
-export default class aliPay {
-	/**
-   * 支付宝支付
-   * @param  {Object} params_body 参数Object  {partner:"",seller_id:"",out_trade_no:"",subject:"",body:"",total_fee:"",notify_url:"",service:"",payment_type:"",_input_charset:"",it_b_pay:"",sign:"",sign_type:""}
-  
-   */
-
-	static pay(params_body) {
-		let data = 'partner=' + params_body.partner + '&';
-		'seller_id=' + params_body.seller_id + '&';
-		'out_trade_no=' + params_body.out_trade_no + '&';
-		'subject=' + params_body.subject + '&';
-		'body=' + params_body.body + '&';
-		'total_fee=' + params_body.total_fee + '&';
-		'notify_url=' + params_body.notify_url + '&';
-		'service=' + params_body.service + '&';
-		'payment_type=' + params_body.payment_type + '&';
-		'_input_charset=' + params_body._input_charset + '&';
-		'it_b_pay=' + params_body.it_b_pay + '&';
-		'sign=' + params_body.sign + '&';
-		'sign_type=' + params_body.sign_type;
-		Alipay.pay(data).then(
-			function(data) {
-				console.log(data);
-			},
-			function(err) {
-				console.log(err);
-			}
-		);
-	}
-}

+ 34 - 0
pages/utils/commonutil.js

@@ -1,4 +1,11 @@
+import { Linking, Alert } from 'react-native';
+
 export default class commonutil {
+	//获取appCode
+	static getAppCode() {
+		return '1006';
+	}
+
 	//验证手机号
 	static isPoneAvailable(str) {
 		let myreg = /^[1][0-9]{10}$/;
@@ -44,4 +51,31 @@ export default class commonutil {
 	static jsonToMap(jsonStr) {
 		return this.objToStrMap(JSON.parse(jsonStr));
 	}
+
+	//调用打电话功能
+	static callPhone(phone) {
+		// let tel = '1008611'; // 目标电话
+		Alert.alert('提示', phone, [
+			{
+				text: '取消',
+				onPress: () => {
+					console.log('取消');
+				}
+			},
+			{
+				text: '确定',
+				onPress: () => {
+					Linking.canOpenURL('tel:' + phone)
+						.then((supported) => {
+							if (!supported) {
+								console.log('Can not handle tel:' + phone);
+							} else {
+								return Linking.openURL('tel:' + phone);
+							}
+						})
+						.catch((error) => console.log('tel error', error));
+				}
+			}
+		]);
+	}
 }

+ 188 - 175
pages/utils/efunRequest.js

@@ -2,180 +2,193 @@
 // 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;
-        // 异步获取的
-        this.uid = storage.load({
-            key: 'uid'
-        })
-    }
-
-    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'));
-        this.xmlHTTPRequest.setRequestHeader('uid', this.uid ? this.uid : '');
-
-
-        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;
-    }
+	constructor() {
+		this._url = '';
+		this._params = {};
+		this._data = {};
+		this._header = {};
+		this.xmlHTTPRequest = null;
+		this._onSuccess = null;
+		this._onFailed = null;
+		this._deserialize = null;
+		// 异步获取的
+		this.uid = this.getuid();
+	}
+	async getuid() {
+		const userinfo = await storage
+			.load({
+				key: 'userInfo'
+			})
+			.catch((error) => {
+				return '';
+			});
+		if (userinfo === '') {
+			return '';
+		}
+		return JSON.parse(userinfo).uid;
+	}
+	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')
+		);
+		console.log('====================================');
+		console.log('uid', this.uid);
+		console.log('====================================');
+		this.xmlHTTPRequest.setRequestHeader('uid', this.uid ? this.uid : '');
+
+		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;
+export default efunRequest;

+ 7 - 6
pages/utils/wechat.js

@@ -141,7 +141,7 @@ export default class wechat {
    * @param  {string} package            商家根据财付通文档填写的数据和签名
    * @param  {string} sign               商家根据微信开放平台文档对数据做的签名
    */
-	static pay(partnerId, prepayId, nonceStr, timeStamp, packages, sign) {
+	static pay(partnerId, prepayId, nonceStr, timeStamp, packages, sign, callback) {
 		WeChat.isWXAppInstalled().then((isInstalled) => {
 			if (isInstalled) {
 				WeChat.pay({
@@ -153,13 +153,14 @@ export default class wechat {
 					sign: sign // 商家根据微信开放平台文档对数据做的签名
 				})
 					.then((requestJson) => {
-						//支付成功回调
-						if (requestJson.errCode == '0') {
-							//回调成功处理
-						}
+						// //支付成功回调
+						// if (requestJson.errCode == '0') {
+						// 	//回调成功处理
+						// }
+						callback(requestJson);
 					})
 					.catch((err) => {
-						alert('支付失败');
+						alert('支付失败:' + err);
 					});
 			} else {
 				alert('请安装微信');