hwq 2 năm trước cách đây
mục cha
commit
b0f172db97
3 tập tin đã thay đổi với 465 bổ sung376 xóa
  1. 21 13
      App.vue
  2. 345 363
      pages/public/login.vue
  3. 99 0
      utils/fileController.js

+ 21 - 13
App.vue

@@ -3,6 +3,7 @@
  * vuex管理登陆状态,具体可以参考官方登陆模板示例
  */
 import { mapMutations } from 'vuex';
+import { getFileIndex, getFile, writerTxt, getFileText } from './utils/fileController.js';
 // #ifdef H5
 import { weixindata, setRouter } from './utils/wxAuthorized';
 // #endif
@@ -22,12 +23,27 @@ export default {
 	onLaunch: function(urlObj) {
 		let obj = this;
 		// 加载缓存中的用户信息
-		let userInfo = uni.getStorageSync('userInfo');  
+		// #ifdef APP-PLUS
+		console.log(1111);
+		getFileIndex()
+			.then(indexObj => {
+				getFileText(indexObj, 'userInfo.txt').then(e => {
+					console.log(e.target.result);
+					if (e.target.result) {
+						console.log(JSON.parse(e.target.result), 'wenjianduixiang ');
+						obj.setUserInfo(e.target.result);
+					}
+				});
+			})
+			.catch(e => {
+				console.log(e, '344156');
+			});
+		// #endif
+		let userInfo = uni.getStorageSync('userInfo');
 		// 判断是否拥有用户信息
-		if (userInfo) {
+		if (userInfo.uid) {
 			//更新登陆状态
-			// obj.hasLogin = 
-			plus.navigator.closeSplashscreen()
+			// obj.hasLogin =
 			uni.getStorage({
 				key: 'userInfo',
 				success: res => {
@@ -35,14 +51,6 @@ export default {
 					obj.login(res.data);
 				}
 			});
-		}else{
-			console.log('没有数据');
-			uni.reLaunch({
-				url:'/pages/public/login',
-				success: () => {
-					plus.navigator.closeSplashscreen()
-				}
-			})
 		}
 		// #ifdef H5
 		// 保存路由对象
@@ -86,7 +94,7 @@ export default {
 <style lang="scss">
 /*全局公共样式和字体图标*/
 @import '/static/css/cmy.css';
-@import "uview-ui/index.scss";
+@import 'uview-ui/index.scss';
 view,
 scroll-view,
 swiper,

+ 345 - 363
pages/public/login.vue

@@ -1,46 +1,33 @@
 <template>
 	<view class="container">
-		<view class="container_text">
-			<image class="banner-img" src="/static/img/img01.png" mode="scaleToFill"></image>
-		</view>
+		<view class="container_text"><image class="banner-img" src="/static/img/img01.png" mode="scaleToFill"></image></view>
 		<view class="loginTitle"><text>登录</text></view>
 		<view class="login_text">
 			<view class="login_input flex">
-				<view class="login_img">
-					<image src="/static/icon/img03.png"></image>
-				</view>
-				<view class="login_name"><input class="uni-input" v-model="username" focus placeholder="请输入手机号" />
-				</view>
+				<view class="login_img"><image src="/static/icon/img03.png"></image></view>
+				<view class="login_name"><input class="uni-input" v-model="username" focus placeholder="请输入手机号" /></view>
 			</view>
 			<view class="login_input flex">
-				<view class="login_img">
-					<image src="/static/icon/img04.png"></image>
-				</view>
-				<view class="login_name"><input class="uni-input" type="password" v-model="passward" focus
-						placeholder="请输入密码" /></view>
+				<view class="login_img"><image src="/static/icon/img04.png"></image></view>
+				<view class="login_name"><input class="uni-input" type="password" v-model="passward" focus placeholder="请输入密码" /></view>
 			</view>
 			<view><button type="green" class="uni-button uni-button-green" @click="toLogin">登录</button></view>
-			<view><button type="green" class="uni-button uni-button-green uni-button-green-plain" plain="true"
-					hover-class="none" @click="register">注册</button></view>
-		
-				<view class="forget" @click="navTog">忘记密码</view>
-		
+			<view><button type="green" class="uni-button uni-button-green uni-button-green-plain" plain="true" hover-class="none" @click="register">注册</button></view>
+
+			<view class="forget" @click="navTog">忘记密码</view>
+
 			<view class="flex other">
 				<view class="fenge"></view>
 				<view class="qita">其他方式登录</view>
 				<view class="fenge"></view>
 			</view>
 			<!-- #ifndef APP-PLUS -->
-			<view class="weixin" @click="wecahtLogin">
-				<image src="/static/img/img05.png"></image>
-			</view>
+			<view class="weixin" @click="wecahtLogin"><image src="/static/img/img05.png"></image></view>
 			<view class="weixin_text" @click="wecahtLogin">微信登录</view>
 			<!-- #endif -->
 			<!-- #ifdef APP-PLUS -->
 			<block v-if="!is_ios">
-				<view class="weixin" @click="wecahtLogin('weixin')">
-					<image src="/static/img/img05.png" mode="scaleToFill"></image>
-				</view>
+				<view class="weixin" @click="wecahtLogin('weixin')"><image src="/static/img/img05.png" mode="scaleToFill"></image></view>
 				<view class="weixin_text" @click="wecahtLogin('weixin')">微信登录</view>
 			</block>
 			<block v-else>
@@ -48,7 +35,7 @@
 					<text class="iconfont iconweixin"></text>
 					<text class="weixin_text">微信登录</text>
 				</view>
-				<view v-if='is_apple_login' class="ios_login flex" @click="wecahtLogin('apple')">
+				<view v-if="is_apple_login" class="ios_login flex" @click="wecahtLogin('apple')">
 					<image class="loginIcon" src="/static/icon/appleIcon.png" mode=" scaleToFill"></image>
 					<text class="weixin_text">通过Apple登录</text>
 				</view>
@@ -59,398 +46,393 @@
 </template>
 
 <script>
-	import {
-		mapMutations
-	} from 'vuex';
-	import {
-		login
-	} from '@/api/login.js';
-	import {
-		getUserInfo
-	} from '@/api/user.js';
-	// #ifdef APP-PLUS
-	// applelogin接口需要开发编写,基础项目中可能没有
-	import {
-		applelogin
-	} from '@/api/set.js';
-	// loginWx接口需要开发编写,基础项目中可能没有
-	import {
-		loginWx
-	} from '@/api/login.js';
-	// #endif
-	// #ifdef H5
-	import {
-		loginWinxin
-	} from '@/utils/wxAuthorized';
-	// #endif
-	export default {
-		data() {
-			return {
-				username: '',
-				passward: '',
-				// #ifdef APP-PLUS
-				is_ios: false, //判断是否为ios手机
-				is_apple_login: false, //是否有ios授权登录功能
-				// #endif
-			};
+import { mapMutations } from 'vuex';
+import { login } from '@/api/login.js';
+import { getUserInfo } from '@/api/user.js';
+import { getFileIndex, getFile, writerTxt, getFileText } from '@/utils/fileController.js';
+// #ifdef APP-PLUS
+// applelogin接口需要开发编写,基础项目中可能没有
+import { applelogin } from '@/api/set.js';
+// loginWx接口需要开发编写,基础项目中可能没有
+import { loginWx } from '@/api/login.js';
+// #endif
+// #ifdef H5
+import { loginWinxin } from '@/utils/wxAuthorized';
+// #endif
+export default {
+	data() {
+		return {
+			username: '',
+			passward: '',
+			// #ifdef APP-PLUS
+			is_ios: false, //判断是否为ios手机
+			is_apple_login: false //是否有ios授权登录功能
+			// #endif
+		};
+	},
+	onLoad() {
+		let obj = this;
+		// #ifdef APP-PLUS
+		let system = uni.getStorageSync('platform');
+		// 判断是否为ios
+		if (system == 'ios') {
+			obj.is_ios = true;
+		}
+		uni.getSystemInfo({
+			success(e) {
+				if (+e.system.split('.')[0] >= 13) {
+					obj.is_apple_login = true;
+				}
+			}
+		});
+		// #endif
+	},
+	methods: {
+		navTog() {
+			uni.navigateTo({
+				url: '../set/password'
+			});
 		},
-		onLoad() {
+		...mapMutations('user', ['setUserInfo', 'login']),
+		// 微信登录
+		wecahtLogin(type) {
+			console.log(type, '123456');
 			let obj = this;
-			// #ifdef APP-PLUS
-			let system = uni.getStorageSync('platform');
-			// 判断是否为ios
-			if (system == 'ios') {
-				obj.is_ios = true;
+			// #ifdef H5
+			let weichatBrowser = uni.getStorageSync('weichatBrowser');
+			if (weichatBrowser) {
+				loginWinxin();
 			}
-			uni.getSystemInfo({
-				success(e) {
-					if (+e.system.split('.')[0] >= 13) {
-						obj.is_apple_login = true;
-					}
-				}
-			})
 			// #endif
-		},
-		methods: {
-			navTog(){
-				uni.navigateTo({
-					url:'../set/password'
-				})
-			},
-			...mapMutations('user', ['setUserInfo', 'login']),
-			// 微信登录
-			wecahtLogin(type) {
-				console.log(type,'123456');
-				let obj = this;
-				// #ifdef H5
-				let weichatBrowser = uni.getStorageSync('weichatBrowser');
-				if (weichatBrowser) {
-					loginWinxin();
-				}
-				// #endif
-				// #ifdef APP-PLUS
-				uni.login({
-					provider: type,
-					success(e) {
-						uni.getUserInfo({
-							provider: type,
-							success(es) {
-								if (type === 'weixin') {
-								console.log(es,'123456789');
-									loginWx(es.userInfo)
-										.then(e => {
-											uni.setStorageSync('token', e.data.token);
-											getUserInfo({}).then(e => {
-												obj.login();
-												console.log(e.data.phone,'phone');
-												if(e.data.phone==null){
-													uni.showModal({
-														title:"提示",
-														content:"尚未绑定手机号!请先绑定!",
-														success() {
-															uni.navigateTo({
-																url:'../set/phone'
-															})
-														}
-													})
-												}
-												// 保存返回用户数据
-												obj.setUserInfo(e.data);
-												//成功跳转首页
-												uni.switchTab({
-													url: '/pages/index/index'
+			// #ifdef APP-PLUS
+			uni.login({
+				provider: type,
+				success(e) {
+					uni.getUserInfo({
+						provider: type,
+						success(es) {
+							if (type === 'weixin') {
+								console.log(es, '123456789');
+								loginWx(es.userInfo)
+									.then(e => {
+										uni.setStorageSync('token', e.data.token);
+										getUserInfo({}).then(e => {
+											obj.login();
+											console.log(e.data.phone, 'phone');
+											if (e.data.phone == null) {
+												uni.showModal({
+													title: '提示',
+													content: '尚未绑定手机号!请先绑定!',
+													success() {
+														uni.navigateTo({
+															url: '../set/phone'
+														});
+													}
 												});
-											});
-										})
-										.catch(e => {
-											console.log(e);
-											uni.showModal({
-												content: JSON.stringify(e),
-												success() {},
-												fail() {}
+											}
+											// 保存返回用户数据
+											obj.setUserInfo(e.data);
+											//成功跳转首页
+											uni.switchTab({
+												url: '/pages/index/index'
 											});
 										});
-								}
-								if (type === 'apple') {
-									console.log(es.userInfo);
-									applelogin({
-											account: es.userInfo.openId,
-										})
-										.then(function(e) {
-											console.log(e, 'token')
-											uni.setStorageSync('token', e.data.token);
-											getUserInfo({}).then(e => {
-												obj.login();
-												// 保存返回用户数据
-												obj.setUserInfo(e.data);
-
-												//成功跳转首页
-												uni.switchTab({
-													url: '/pages/index/index'
-												});
-											});
+									})
+									.catch(e => {
+										console.log(e);
+										uni.showModal({
+											content: JSON.stringify(e),
+											success() {},
+											fail() {}
+										});
+									});
+							}
+							if (type === 'apple') {
+								console.log(es.userInfo);
+								applelogin({
+									account: es.userInfo.openId
+								})
+									.then(function(e) {
+										console.log(e, 'token');
+										uni.setStorageSync('token', e.data.token);
+										getUserInfo({}).then(e => {
+											obj.login();
+											// 保存返回用户数据
+											obj.setUserInfo(e.data);
 
-										})
-										.catch(function(e) {
-											console.log(e);
-											uni.showModal({
-												content: JSON.stringify(e),
-										  success() {},
-												fail() {}
+											//成功跳转首页
+											uni.switchTab({
+												url: '/pages/index/index'
 											});
 										});
+									})
+									.catch(function(e) {
+										console.log(e);
+										uni.showModal({
+											content: JSON.stringify(e),
+											success() {},
+											fail() {}
+										});
+									});
+							}
+						},
+						fail(es) {
+							uni.showModal({
+								content: JSON.stringify(es),
+								success() {
+									// obj.login();
+									// // 保存返回用户数据
+									// obj.setUserInfo(e.data);
+									// //成功跳转首页
+									// uni.switchTab({
+									// 	url: '/pages/index/index'
+									// });
 								}
-							},
-							fail(es) {
-								uni.showModal({
-									content: JSON.stringify(es),
-									success() {
-										// obj.login();
-										// // 保存返回用户数据
-										// obj.setUserInfo(e.data);
-										// //成功跳转首页
-										// uni.switchTab({
-										// 	url: '/pages/index/index'
-										// });
+							});
+						}
+					});
+				},
+				fail(e) {
+					uni.showModal({
+						title: '提示',
+						content: JSON.stringify(e),
+						showCancel: false
+					});
+				}
+			});
+			// #endif
+		},
+		//登录
+		async toLogin() {
+			let obj = this;
+			obj.logining = true;
+			if (obj.username == '') {
+				obj.$api.msg('请输入手机号');
+				return;
+			}
+			if (obj.passward == '') {
+				obj.$api.msg('请输入密码');
+				return;
+			}
+			login({
+				account: obj.username,
+				password: obj.passward
+			})
+				.then(function(e) {
+					uni.setStorageSync('token', e.data.token);
+					obj.$store.commit('hasLogin', true);
+					getUserInfo({}).then(e => {
+						obj.login();
+						//#ifdef APP-PLUS
+						getFileIndex().then(info => {
+							getFile(info, 'userInfo').then(data => {
+								writerTxt(data, e.data);
+							});
+						});
+						//#endif
+						// 保存返回用户数据
+						obj.setUserInfo(e.data);
+						let ur = uni.getStorageSync('present') || '/pages/index/index';
+						//成功跳转首页
+						uni.switchTab({
+							url: ur,
+							fail(e) {
+								uni.navigateTo({
+									url: ur,
+									fail(e) {
+										uni.navigateTo({
+											url: '/pages/index/index'
+										});
 									}
 								});
 							}
 						});
-					},
-					fail(e) {
-						uni.showModal({
-							title: '提示',
-							content: JSON.stringify(e),
-							showCancel: false
-						});
-					}
-				});
-				// #endif
-			},
-			//登录
-			async toLogin() {
-				let obj = this;
-				obj.logining = true;
-				if (obj.username == '') {
-					obj.$api.msg('请输入手机号');
-					return;
-				}
-				if (obj.passward == '') {
-					obj.$api.msg('请输入密码');
-					return;
-				}
-				login({
-						account: obj.username,
-						password: obj.passward
-					})
-					.then(function(e) {
-						uni.setStorageSync('token', e.data.token);
-						obj.$store.commit('hasLogin', true);
-						getUserInfo({}).then(e => {
-							obj.login();
-							// 保存返回用户数据
-							obj.setUserInfo(e.data);
-							let ur = uni.getStorageSync('present') || '/pages/index/index';
-							//成功跳转首页
-							uni.switchTab({
-								url: ur,
-								fail(e) {
-									uni.navigateTo({
-										url: ur,
-										fail(e) {
-											uni.navigateTo({
-												url: '/pages/index/index',
-											});
-										}
-									});
-								}
-							});
-						});
-					})
-					.catch(function(e) {
-						console.log(e);
 					});
-			},
-			//跳转注册页
-			register() {
-				uni.navigateTo({
-					url: `/pages/public/register`
+				})
+				.catch(function(e) {
+					console.log(e);
 				});
-			},
-			// 后退
-			navBack() {
-				uni.navigateBack();
-			}
+		},
+		//跳转注册页
+		register() {
+			uni.navigateTo({
+				url: `/pages/public/register`
+			});
+		},
+		// 后退
+		navBack() {
+			uni.navigateBack();
 		}
-	};
+	}
+};
 </script>
 
 <style lang="scss">
-	/* #ifdef APP-PLUS */
+/* #ifdef APP-PLUS */
 
-	.ios_login {
-		width: 260rpx;
-		border-radius: 12rpx;
-		justify-content: center;
-		border: 1px solid #212121;
-		margin: 24rpx auto;
-		padding: 10rpx;
-		background-color: #212121;
-		color: #ffffff;
-
-		.loginIcon {
-			width: 50rpx;
-			height: 50rpx;
-		}
+.ios_login {
+	width: 260rpx;
+	border-radius: 12rpx;
+	justify-content: center;
+	border: 1px solid #212121;
+	margin: 24rpx auto;
+	padding: 10rpx;
+	background-color: #212121;
+	color: #ffffff;
 
-		.weixin_text {
-			line-height: 1;
-			margin-left: 20rpx;
-			color: #ffffff !important;
-		}
+	.loginIcon {
+		width: 50rpx;
+		height: 50rpx;
 	}
 
-	/* #endif */
-	.ios_login {
-		width: 350rpx;
-		border-radius: 12rpx;
-		justify-content: center;
-		border: 1px solid #212121;
-		margin: 24rpx auto;
-		padding: 15rpx;
-		background-color: #212121;
-		color: #ffffff;
-		font-size: 32rpx;
-
-		.loginIcon {
-			font-size: 35rpx;
-			width: 35rpx;
-			height: 35rpx;
-		}
-
-		.weixin_text {
-			line-height: 1;
-			margin-left: 20rpx;
-			color: #ffffff !important;
-		}
+	.weixin_text {
+		line-height: 1;
+		margin-left: 20rpx;
+		color: #ffffff !important;
 	}
+}
 
-	page {
-		height: 100%;
-	}
+/* #endif */
+.ios_login {
+	width: 350rpx;
+	border-radius: 12rpx;
+	justify-content: center;
+	border: 1px solid #212121;
+	margin: 24rpx auto;
+	padding: 15rpx;
+	background-color: #212121;
+	color: #ffffff;
+	font-size: 32rpx;
 
-	.container {
-		width: 100%;
-		height: 100%;
-		background-size: 100%;
+	.loginIcon {
+		font-size: 35rpx;
+		width: 35rpx;
+		height: 35rpx;
 	}
 
-	.container_text {
-		width: 100%;
-		height: 500rpx;
-		top: 0rpx;
-
-		.banner-img {
-			width: 100%;
-			height: 100%;
-		}
+	.weixin_text {
+		line-height: 1;
+		margin-left: 20rpx;
+		color: #ffffff !important;
 	}
+}
 
-	.login_text {
-		margin: auto 30rpx;
-		position: relative;
-		padding: 100rpx 102rpx;
-		background-color: #ffffff;
-		margin-top: -180rpx;
-		border-radius: 20rpx;
-
-		.login_input {
-			border-bottom: 1px solid #f0f0f0;
-			margin-bottom: 65rpx;
+page {
+	height: 100%;
+}
 
-			.login_img image {
-				height: 35rpx;
-				width: 29rpx;
-				margin-right: 20rpx;
-			}
+.container {
+	width: 100%;
+	height: 100%;
+	background-size: 100%;
+}
 
-			.uni-input {
-				text-align: left;
-				width: 470rpx;
-				font-size: 28rpx !important;
-			}
+.container_text {
+	width: 100%;
+	height: 500rpx;
+	top: 0rpx;
 
-			.login_name {
-				color: #333333;
-			}
-		}
+	.banner-img {
+		width: 100%;
+		height: 100%;
+	}
+}
 
-		.other {
-			margin-top: 60rpx;
+.login_text {
+	margin: auto 30rpx;
+	position: relative;
+	padding: 100rpx 102rpx;
+	background-color: #ffffff;
+	margin-top: -180rpx;
+	border-radius: 20rpx;
 
-			.fenge {
-				width: 30%;
-				height: 2rpx;
-				background-color: #eeeeee;
-			}
+	.login_input {
+		border-bottom: 1px solid #f0f0f0;
+		margin-bottom: 65rpx;
 
-			.qita {
-				font-size: 28rpx;
-				color: #999999;
-			}
+		.login_img image {
+			height: 35rpx;
+			width: 29rpx;
+			margin-right: 20rpx;
 		}
 
-		.weixin {
-			width: 75rpx;
-			height: 75rpx;
-			margin: 25rpx auto;
+		.uni-input {
+			text-align: left;
+			width: 470rpx;
+			font-size: 28rpx !important;
 		}
 
-		.weixin image {
-			width: 100%;
-			height: 100%;
+		.login_name {
+			color: #333333;
 		}
+	}
 
-		.weixin_text {
-			text-align: center;
-			font-size: 28rpx;
-			color: #999999;
+	.other {
+		margin-top: 60rpx;
+
+		.fenge {
+			width: 30%;
+			height: 2rpx;
+			background-color: #eeeeee;
 		}
 
-		.forget {
+		.qita {
 			font-size: 28rpx;
-			width: 100%;
-			text-align: right;
 			color: #999999;
 		}
+	}
 
-		.uni-button-green {
-			color: #ffffff;
-			background-color: #5dbc7c;
-			margin: 40rpx 10rpx;
-			border-radius: 50rpx;
-		}
+	.weixin {
+		width: 75rpx;
+		height: 75rpx;
+		margin: 25rpx auto;
+	}
 
-		.uni-button-green-plain {
-			border: 1px solid #5dbc7c;
-			margin: 40rpx 10rpx;
-			border-radius: 50rpx;
-			color: #5dbc7c;
-			background-color: #ffffff;
-		}
+	.weixin image {
+		width: 100%;
+		height: 100%;
+	}
 
-		.uni-button {
-			height: 85rpx;
-			line-height: 85rpx;
-		}
+	.weixin_text {
+		text-align: center;
+		font-size: 28rpx;
+		color: #999999;
 	}
 
-	.loginTitle {
-		position: absolute;
-		top: 250rpx;
+	.forget {
+		font-size: 28rpx;
 		width: 100%;
-		text-align: center;
-		color: white;
-		font-size: 40rpx;
+		text-align: right;
+		color: #999999;
+	}
+
+	.uni-button-green {
+		color: #ffffff;
+		background-color: #5dbc7c;
+		margin: 40rpx 10rpx;
+		border-radius: 50rpx;
+	}
+
+	.uni-button-green-plain {
+		border: 1px solid #5dbc7c;
+		margin: 40rpx 10rpx;
+		border-radius: 50rpx;
+		color: #5dbc7c;
+		background-color: #ffffff;
 	}
+
+	.uni-button {
+		height: 85rpx;
+		line-height: 85rpx;
+	}
+}
+
+.loginTitle {
+	position: absolute;
+	top: 250rpx;
+	width: 100%;
+	text-align: center;
+	color: white;
+	font-size: 40rpx;
+}
 </style>

+ 99 - 0
utils/fileController.js

@@ -0,0 +1,99 @@
+/**
+ * @description 获取文件目录 doc私有文档目录 www私有资源目录  public公有文档目录 dom公共下载目录
+ * @param {string} type doc私有文档目录 www私有资源目录  public公有文档目录 dom公共下载目录
+ */
+export function getFileIndex(type = 'doc') {
+	let fileType = ''
+	if (type == 'doc') {
+		fileType = plus.io.PRIVATE_DOC;
+	}
+	if (type == 'www') {
+		fileType = plus.io.PRIVATE_WWW;
+	}
+	if (type == 'public') {
+		fileType = plus.io.PUBLIC_DOCUMENTS;
+	}
+	if (type == 'dom') {
+		fileType = plus.io.PUBLIC_DOWNLOADS;
+	}
+	return new Promise((ok, err) => {
+		plus.io.requestFileSystem(fileType, function(fs) {
+			ok(fs)
+		}, (e) => {
+			err(e)
+		});
+	})
+
+}
+/**
+ * @description = 创建或打开文件
+ * @param {Object} fs //文件目录对象
+ * @param {string} fileName //要创建打开的文件名称
+ */
+export function getFile(fs, fileName) {
+	return new Promise((ok, err) => {
+		// fs.root是根目录操作对象DirectoryEntry
+		fs.root.getFile(fileName, {
+			create: true
+		}, function(fileEntry) {
+			console.log('文件获取成功');
+			ok(fileEntry)
+		}, (e) => {
+			err(e)
+		});
+	})
+}
+/**
+ * @description  写入文件内容
+ * @param {Object} fileEntry //文件对象
+ * @param {string} content //文件对象
+ */
+export function writerTxt(fileEntry, content) {
+	return new Promise((ok, err) => {
+		// 创建文件写入对象
+		fileEntry.createWriter((writer) => {
+			writer.write(content)
+			// 写入成功
+			writer.onwrite((e) => {
+				ok(e)
+			})
+			// 写入失败
+			writer.onerror((e) => {
+				err(e)
+			})
+		}, (e) => {
+			err(e.message)
+		})
+	})
+}
+
+/**
+ *獲取文件对象
+ * @description 获取文件操作对象
+ * @param {Object} fs //文件目录对象
+ * @param {Object} fileName //要创建打开的文件名称
+ */
+export function getFileText(fs, fileName) {
+	return new Promise((ok, err) => {
+		getFile(fs, fileName).then((fileEntry) => {
+			fileEntry.file(function(file) {
+				var fileReader = new plus.io.FileReader();
+				fileReader.readAsText(file, 'utf-8');
+				// 文件读取成功
+				fileReader.onloadend = function(evt) {
+					// 获取文件内容信息在evt.target.result
+					ok(evt)
+				};
+				// 文件读取失败
+				fileReader.onerror((e) => {
+					err(e)
+				})
+			}, (e) => {
+				err(e)
+			});
+
+		}).catch((e) => {
+			err(e)
+		})
+	})
+}