Jelajahi Sumber

switch account

lhl 2 tahun lalu
induk
melakukan
c8b40cb6da
9 mengubah file dengan 698 tambahan dan 68 penghapusan
  1. 2 2
      manifest.json
  2. 13 0
      pages.json
  3. 28 15
      pages/users/login/index.vue
  4. 580 0
      pages/users/switch_account/index.vue
  5. 4 3
      pages/users/user_bill/index.vue
  6. 33 16
      pages/users/user_set/index.vue
  7. TEMPAT SAMPAH
      static/images/add.png
  8. TEMPAT SAMPAH
      static/images/sc.png
  9. 38 32
      utils/io.js

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "易博优购",
     "appid" : "__UNI__331F6F8",
     "description" : "易博优购",
-    "versionName" : "1.4.9",
-    "versionCode" : 149,
+    "versionName" : "1.5.0",
+    "versionCode" : 150,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {

+ 13 - 0
pages.json

@@ -651,6 +651,19 @@
 						}
 					}
 				},
+				// #ifdef APP-PLUS
+				{
+					"path": "switch_account/index",
+					"style": {
+						"navigationBarTitleText": "切换账号",
+						"app-plus": {
+							"titleNView": {
+								"type": "default"
+							}
+						}
+					}
+				},
+				// #endif
 				{
 					"path": "promoter-list/index",
 					"style": {

+ 28 - 15
pages/users/login/index.vue

@@ -147,7 +147,8 @@
 		},
 		mixins: [sendVerifyCode, colors],
 		data: function() {
-			return {
+			return {
+				menList: [],
 				inAnimation: false,
 				protocol: false,
 				navList: ["快速登录", "账号登录"],
@@ -186,11 +187,11 @@
 			uni.getSystemInfo({
 				success: (res) => {
 					if (res.platform.toLowerCase() == 'ios' && this.getSystem(res.system)) {
-						self.appleShow = true
+						self.appleShow = true;
 					}
 				}
 			});
-			this.sspread = this.$Cache.get("spread")
+			this.sspread = this.$Cache.get("spread");
 		},
 		mounted: function() {
 			// this.getCode();
@@ -199,9 +200,9 @@
 		},
 		methods: {
 			domainTap(){
-				let url = 'https://www.miit.gov.cn/'
+				let url = 'https://www.miit.gov.cn/';
 				// #ifdef H5
-				window.location.href = 'https://www.miit.gov.cn/'
+				window.location.href = 'https://www.miit.gov.cn/';
 				// #endif
 				// #ifdef APP-PLUS || MP
 				plus.runtime.openURL(
@@ -228,7 +229,7 @@
 			},
 			// 苹果登录
 			appleLogin() {
-				let self = this
+				let self = this;
 				this.account = ''
 				this.captcha = ''
 				if (!self.protocol) {
@@ -648,13 +649,20 @@
 							uni.reLaunch({
 								url: backUrl
 							});
-							// that.setMen({
-							// 	avatar: res.data.avatar,
-							// 	uid: res.data.uid,
-							// 	nickname: res.data.nickname,
-							// 	account: that.account,
-							// 	password: that.password,
-							// })
+							// #ifdef APP-PLUS
+							let hj = uni.getSystemInfoSync().platform;
+							if(hj == 'android') {
+								that.setMen({
+									// avatar: res.data.avatar,
+									// uid: res.data.uid,
+									// nickname: res.data.nickname,
+									account: that.account,
+									password: that.password,
+								})
+							}
+							
+							// #endif
+							
 							
 						}).catch(error => {
 							this.keyLock = true
@@ -680,12 +688,17 @@
 						// res 读取的文件内容
 						console.log('读取结果:',res)
 						if(!res) {
-							that.$io.storage("MenList.json", data)
+							let arr = []
+							arr.push(data)
+							that.$io.storage("MenList.json", arr)
 						}
 					}).catch(err => {
 						// 找不到该文件就写入一个空白文件。
-						that.$io.storage("MenList.json", date)
 						console.log(err, "err")
+						let arr = []
+						arr.push(data)
+						that.$io.storage("MenList.json", arr)
+						
 					})
 				}catch(e){
 					//TODO handle the exception

+ 580 - 0
pages/users/switch_account/index.vue

@@ -0,0 +1,580 @@
+<template>
+	<view class="content" :style="colorStyle">
+		<view class="tit">
+			轻触头像以切换帐号
+		</view>
+		<!-- 当前账号 -->
+		<view class="account-wrap">
+			<image :src="'../../../static/images/f.png'" mode="" class="u-logo"></image>
+			<view class="u-info">
+				<view class="info-name">
+					{{userInfo.phone}}
+				</view>
+				<!-- <view class="info-id">
+					UID:{{userInfo.uid}}
+				</view> -->
+			</view>
+			<view class="set">
+				<view class="new-use">
+					<text></text>当前使用
+				</view>
+			</view>
+		</view>
+		<!-- 账号列表 -->
+		<template v-for="(item,index) in menList">
+			<view class="account-wrap" v-if="item.account != userInfo.phone">
+				<image v-if="item.avatar" :src="item.avatar" mode="" class="u-logo" @click="login(item)"></image>
+				<image v-else src="../../../static/images/f.png" mode="" class="u-logo" @click="login(item)"></image>
+				<view class="u-info">
+					<view class="info-name">
+						{{item.account}}
+					</view>
+					<view class="info-id" v-if="item.uid">
+						UID:{{item.uid}}
+					</view>
+				</view>
+				<view class="set">
+					<image src="../../../static/images/sc.png" mode="" @click="scAccount(item,index)"></image>
+				</view>
+			</view>
+		</template>
+		<!-- 添加账号 -->
+		<view class="account-wrap" @click="openAdd" v-if="menList.length < maxAccountNum">
+			<image src="../../../static/images/add.png" mode="" class="add"></image>
+			<view class="u-info">
+				添加帐号
+			</view>
+			<view class="set">
+			</view>
+		</view>
+		<!-- 添加账号弹窗 -->
+		<uni-popup type="center" ref="add">
+			<view class="whiteBg" >
+				<view class="tips">
+					<view class="tips-btn on">
+						<view>添加账号</view>
+						<!-- <view class="line"></view> -->
+					</view>
+				</view>
+				<view class="list">
+					<!-- <form @submit.prevent="submit"> -->
+						<view class="item">
+							<view class="acea-row row-middle">
+								<image src="../static/phone_1.png" class="itemImg-add"></image>
+								<input type="text" placeholder="输入手机号码" v-model="account" maxlength="11" required />
+							</view>
+						</view>
+						<view class="item">
+							<view class="acea-row row-middle">
+								<image src="../static/code_1.png" class="item-img"></image>
+								<input type="password" placeholder="填写登录密码" v-model="password" required />
+							</view>
+						</view>
+
+					<!-- </form> -->
+				</view>
+				<view class="logon" @click="addAccount">添加账号</view>
+				
+			</view>
+		</uni-popup>
+		<view class="tipaddress" v-show="isCancellation">
+			<view class="top"></view>
+			<view class="bottom">
+				<view class="font1">是否确认删除</view>
+				<view class="font2">当前记录将被删除,您确认要删除吗?</view>
+				<view class="btn">
+					<view class="cancellation-btn btn-sty flex-aj-center" @tap="cancelUser">删除</view>
+					<view class="cancel btn-sty flex-aj-center" @tap="isCancellation = false">
+						取消
+					</view>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import colors from '@/mixins/color.js';
+	import {
+		loginH5,
+		loginMobile,
+		registerVerify,
+		register,
+		getCodeApi,
+		getUserInfo,
+		appleLogin
+	} from "@/api/user";
+		const BACK_URL = "login_back_url";
+	export default {
+		mixins: [colors],
+		data() {
+			return {
+				isCancellation: false,
+				menList: [],
+				userInfo: {},
+				account: '',
+				password: '',
+				maxAccountNum: 6,
+				scitem: {},
+				scindex: '',
+				keyLock: true
+			}
+		},
+		onLoad() {
+			this.getUserInfo()
+			this.getMenList()
+		},
+		onShow() {
+
+		},
+		onReachBottom() {
+
+		},
+		onReady() {
+
+		},
+		methods: {
+			// 删除账号
+			cancelUser() {
+				let that = this;
+				that.menList.splice(that.scindex,1);
+				that.isCancellation = false;
+				try{
+					that.$io.storage("MenList.json", that.menList);
+				}catch(e){
+					console.log(e)
+					//TODO handle the exception
+				}
+				
+			},
+			// 打开删除弹窗
+			scAccount(item,index) {
+				this.scitem = item;
+				this.scindex = index;
+				this.isCancellation = true;
+			},
+			// 添加账号
+			addAccount() {
+				let that = this;
+				if (!that.account) {
+					return that.$util.Tips({
+						title: '请输入手机号码'
+					});
+				}
+				if (!/^1(2|3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
+					title: '请输入正确的手机号码'
+				});
+				if (!that.password) {
+					return that.$util.Tips({
+						title: '请填写登录密码'
+					});
+				}
+				// for(let i = 0;i=)
+				let i = false;
+				this.menList.forEach(item => {
+					if(item.account == that.account) {
+						i = true
+					}
+				})
+				if(!i) {
+					try{
+						that.menList.push({
+							account: that.account,
+							password: that.password
+						})
+						that.$io.storage("MenList.json", that.menList).then(e => {
+							console.log('结果返回:',e)
+							that.account = ''
+							that.password = ''
+						});
+					}catch(e){
+						
+					}
+				}else {
+					return that.$util.Tips({
+						title: '当前账号已存在'
+					});
+				}
+				
+				that.$refs.add.close()
+			},
+			// 打开添加弹窗
+			openAdd() {
+				this.$refs.add.open();
+			},
+			getUserInfo() {
+				let that = this;
+				getUserInfo().then(res => {
+					that.userInfo = res.data;
+				});
+			},
+			getMenList() {
+				let that = this;
+				try {
+					that.$io.read("MenList.json").then(res => {
+						// res 读取的文件内容
+						that.menList = JSON.parse(res);
+					}).catch(err => {
+						// 找不到该文件就写入一个空白文件。
+						// that.$io.storage("MenList.json", []);
+						console.log(err, "err");
+					})
+				} catch (e) {
+
+					console.log(e);
+				}
+
+			},
+			login(item) {
+				try{
+					let that = this;
+					if (that.keyLock) {
+						that.keyLock = !that.keyLock
+					} else {
+						return that.$util.Tips({
+							title: '请勿重复点击'
+						});
+					}
+					loginH5({
+							account: item.account,
+							password: item.password,
+						})
+						.then(({
+							data
+						}) => {
+							console.log('登录成功:',data)
+							that.$store.commit("LOGIN", {
+								'token': data.token,
+								'time': data.expires_time - that.$Cache.time()
+							});
+							let backUrl = "/pages/user/index";
+							that.$Cache.clear(BACK_URL);
+							getUserInfo().then(res => {
+								console.log('获取用户信息成功:',res)
+								that.keyLock = true
+								that.$store.commit("SETUID", res.data.uid);
+								that.$store.commit("UPDATE_USERINFO", res.data);
+								console.log('开始跳转:')
+								uni.reLaunch({
+									url: backUrl
+								});
+								console.log('跳转结束:')
+							}).catch(error => {
+								this.keyLock = true
+							})
+						})
+						.catch(e => {
+							this.keyLock = true
+							that.$util.Tips({
+								title: e
+							});
+						});
+				}catch(e){
+					//TODO handle the exception
+					console.log('错误:',e)
+				}
+				
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	.main-color {
+		color: var(--view-theme);
+	}
+	.tit {
+		font-size: 36rpx;
+		text-align: center;
+		font-weight: bold;
+		padding: 100rpx 0;
+	}
+
+	.account-wrap {
+		width: 690rpx;
+		height: 150rpx;
+		margin: auto;
+		margin-bottom: 20rpx;
+		background-color: #fff;
+		display: flex;
+		justify-content: flex-start;
+		align-items: center;
+		padding: 30rpx;
+		border-radius: 20rpx;
+
+		.u-logo {
+			width: 90rpx;
+			height: 90rpx;
+			border-radius: 50%;
+			flex-shrink: 0;
+		}
+
+		.add {
+			width: 90rpx;
+			height: 90rpx;
+			flex-shrink: 0;
+		}
+
+		.u-info {
+			flex-grow: 1;
+			display: flex;
+			flex-direction: column;
+			justify-content: space-around;
+			align-items: flex-start;
+			padding-left: 25rpx;
+			font-size: 28rpx;
+			color: #999;
+
+			.info-id {
+				color: #999;
+			}
+
+			.info-name {
+				font-weight: bold;
+				font-size: 36rpx;
+				color: #333333;
+				
+			}
+		}
+
+		.set {
+			width: 140rpx;
+			display: flex;
+			align-items: center;
+			justify-content: center;
+
+			.new-use {
+				font-size: 28rpx;
+				font-weight: bold;
+
+				text {
+					display: inline-block;
+					width: 20rpx;
+					height: 20rpx;
+					background-color: #08c05f;
+					border-radius: 50%;
+					margin-right: 10rpx;
+				}
+			}
+
+			image {
+				width: 32rpx;
+				height: 32rpx;
+			}
+		}
+	}
+	.whiteBg {
+		background-color: #fff;
+		margin: -30rpx 56rpx 0rpx 56rpx;
+		box-shadow: 0px 2px 14px 0px rgba(0, 0, 0, 0.08);
+		border-radius: 8px;
+		padding: 60rpx;
+	
+		.tips {
+			display: flex;
+			align-items: center;
+			justify-content: center;
+			height: 50rpx;
+			margin: 40rpx;
+			color: #999;
+	
+			.tips-btn {
+				margin: 0 31rpx 0 48rpx;
+				color: #999999;
+				font-weight: bold;
+				font-size: 32rpx;
+	
+	
+				/* Safari 与 Chrome */
+				.line {
+					width: 80rpx;
+					height: 6rpx;
+					background: linear-gradient(135deg, var(--view-minorColor) 0%, var(--view-theme) 100%);
+					border-radius: 2px;
+					margin: 10rpx auto 0 auto;
+					animation: myfirst .3s;
+					-webkit-animation: myfirst .3s;
+				}
+	
+				.none {
+					width: 80rpx;
+					background: #fff;
+					height: 6rpx;
+				}
+			}
+	
+			@keyframes myfirst {
+				0% {
+					width: 0rpx;
+				}
+	
+				100% {
+					width: 80rpx;
+				}
+			}
+	
+			@-webkit-keyframes myfirst
+	
+			/* Safari 与 Chrome */
+				{
+				0% {
+					width: 0rpx;
+				}
+	
+				100% {
+					width: 80rpx;
+				}
+			}
+	
+			.tips-btn.on {
+				font-size: 36rpx;
+				color: var(--view-theme);
+			}
+		}
+	
+		.list {
+			border-radius: 16rpx;
+			overflow: hidden;
+	
+			.forgetPwd {
+				text-align: right;
+				margin-top: 10rpx;
+				color: #666666;
+				font-size: 24rpx;
+			}
+	
+			.item {
+				border-bottom: 1px solid #F0F0F0;
+				background: #fff;
+	
+				.row-middle {
+					position: relative;
+					padding: 16rpx 25rpx;
+	
+					input {
+						flex: 1;
+						font-size: 28rpx;
+						height: 80rpx;
+					}
+					.spread {
+						flex: 1;
+						font-size: 28rpx;
+						height: 80rpx;
+					}
+					.code {
+						position: absolute;
+						right: 30rpx;
+						top: 50%;
+						color: var(--view-theme);
+						font-size: 26rpx;
+						transform: translateY(-50%);
+					}
+				}
+			}
+		}
+	
+		.logon {
+			display: flex;
+			align-items: center;
+			justify-content: center;
+			width: 100%;
+			height: 86rpx;
+			margin-top: 48rpx;
+			background: linear-gradient(135deg, var(--view-minorColor) 0%, var(--view-theme) 100%);
+			border-radius: 120rpx;
+			color: #FFFFFF;
+			font-size: 30rpx;
+		}
+	}
+	.code img {
+		width: 100%;
+		height: 100%;
+	}
+	
+	.acea-row.row-middle {
+		input {
+			margin-left: 20rpx;
+			display: block;
+		}
+	}
+	.itemImg-add {
+	  width: 24rpx;
+	   height: 34rpx;
+	}
+	.item-img {
+	  width: 28rpx; 
+	  height: 32rpx;
+	}
+	.tipaddress {
+		position: fixed;
+		left: 13%;
+		top: 25%;
+		// margin-left: -283rpx;
+		width: 560rpx;
+		height: 614rpx;
+		background-color: #fff;
+		border-radius: 10rpx;
+		z-index: 100;
+		text-align: center;
+	
+		.top {
+			width: 560rpx;
+			height: 270rpx;
+			border-top-left-radius: 10rpx;
+			border-top-right-radius: 10rpx;
+			background-image: url('../../../static/images/address.png');
+			background-repeat: round;
+			background-color: #E93323;
+	
+			.tipsphoto {
+				display: inline-block;
+				width: 200rpx;
+				height: 200rpx;
+				margin-top: 73rpx;
+			}
+		}
+	
+		.bottom {
+			font-size: 32rpx;
+			font-weight: 400;
+	
+			.font1 {
+	
+				font-size: 36rpx;
+				font-weight: 600;
+				color: #333333;
+				margin: 32rpx 0rpx 22rpx;
+			}
+	
+			.font2 {
+				color: #666666;
+				margin-bottom: 48rpx;
+			}
+	
+			.btn {
+				display: flex;
+				margin: 0 20rpx;
+	
+				.btn-sty {
+					height: 82rpx;
+					border-radius: 42rpx;
+					line-height: 82rpx;
+					padding: 24rpx 78rpx;
+					margin: 0 auto;
+				}
+	
+				.cancellation-btn {
+					background-color: #F5F5F5;
+					color: #333333;
+				}
+	
+				.cancel {
+					color: #FFFFFF;
+					background: linear-gradient(90deg, #F67A38 0%, #F11B09 100%);
+				}
+	
+			}
+		}
+	
+	}
+</style>

+ 4 - 3
pages/users/user_bill/index.vue

@@ -11,9 +11,10 @@
 					<view class='item'>
 						<view class='data'>{{item.time}}</view>
 						<view class='listn'>
-							<view class='itemn acea-row row-between-wrapper' v-for="(vo,indexn) in item.child" :key="indexn">
-								<view>
-									<view class='name line1'>{{vo.title}}</view>
+							<view class='itemn acea-row row-between-wrapper' v-for="(vo,indexn) in item.child" :key="indexn" style="min-height: 100%;height: auto;">
+								<view style="max-width: 70%;">
+									<view class='name line1'>{{vo.title}}</view>
+									<view>{{vo.mark}}</view>
 									<view>{{vo.add_time}}</view>
 								</view>
 								<view class='num' v-if="vo.pm">+{{vo.number}}</view>

+ 33 - 16
pages/users/user_set/index.vue

@@ -14,6 +14,14 @@
 			<view class="iconfont icon-xiangyou"></view>
 		</navigator>
 		<view class="list">
+			<!-- #ifdef APP-PLUS -->
+			<view class="item acea-row row-between-wrapper" v-if="hj == 'android'">
+				<view>切换账号</view>
+				<view hover-class="none" class="input grab" @click="getMenList()">
+					点击切换账号<text class="iconfont icon-xiangyou"></text>
+				</view>
+			</view>
+			<!-- #endif -->
 			<view class="item acea-row row-between-wrapper" v-if="userInfo.link_uid">
 				<view>节点</view>
 				<view hover-class="none" class="input grab">
@@ -171,9 +179,15 @@
 		mapGetters
 	} from "vuex";
 	export default {
-		computed: mapGetters(['isLogin']),
+		computed: {
+			...mapGetters(['isLogin']),
+			hj() {
+				return uni.getSystemInfoSync().platform;
+			}
+		},
 		data() {
 			return {
+				menList: [],
 				userInfo: {},
 				isShowAuth: false
 			}
@@ -216,21 +230,24 @@
 			},
 			// 获取用户列表
 			getMenList() {
-				let that = this
-				try{
-					that.$io.read("MenList.json").then(res => {
-						// res 读取的文件内容
-						console.log(res)
-					}).catch(err => {
-						// 找不到该文件就写入一个空白文件。
-						that.$io.storage("MenList.json", [])
-						console.log(err, "err")
-					})
-				}catch(e){
-					//TODO handle the exception
-					console.log(e)
-				}
-				
+				uni.navigateTo({
+					url:'/pages/users/switch_account/index'
+				})
+				// let that = this;
+				// try {
+				// 	that.$io.read("MenList.json").then(res => {
+				// 		// res 读取的文件内容
+				// 		that.menList = JSON.parse(res);
+				// 	}).catch(err => {
+				// 		// 找不到该文件就写入一个空白文件。
+				// 		// that.$io.storage("MenList.json", []);
+				// 		console.log(err, "err");
+				// 	})
+				// } catch (e) {
+					
+				// 	console.log(e);
+				// }
+
 			}
 		}
 	}

TEMPAT SAMPAH
static/images/add.png


TEMPAT SAMPAH
static/images/sc.png


+ 38 - 32
utils/io.js

@@ -1,36 +1,42 @@
 export default {
-	storage(addr,data) {
-		plus.io.requestFileSystem(
-			plus.io.PUBLIC_DOCUMENTS, // 程序公用文档目录常量
-			fs => {
-				// 创建或打开文件, fs.root是根目录操作对象,直接fs表示当前操作对象
-				fs.root.getFile(
-					addr, {
-						create: true // 文件不存在则创建
-					},
-					fileEntry => {
-						// 文件在手机中的路径
-						//console.log(fileEntry.fullPath)
-						fileEntry.createWriter(writer => {
-							// 写入文件成功完成的回调函数
-							writer.onwrite = e => {
-								console.log('写入成功');
-							};
-							// 向文件中写入数据
-							writer.write(
-								JSON.stringify(data)
-							);
-						});
-					},
-					e => {
-						console.log('getFile failed: ' + e.message);
-					}
-				);
-			},
-			e => {
-				console.log(e.message);
-			}
-		);
+	storage(addr,data) {
+		return new Promise((resolve, reject) => {
+			plus.io.requestFileSystem(
+				plus.io.PUBLIC_DOCUMENTS, // 程序公用文档目录常量
+				fs => {
+					// 创建或打开文件, fs.root是根目录操作对象,直接fs表示当前操作对象
+					fs.root.getFile(
+						addr, {
+							create: true // 文件不存在则创建
+						},
+						fileEntry => {
+							// 文件在手机中的路径
+							//console.log(fileEntry.fullPath)
+							fileEntry.createWriter(writer => {
+								// 写入文件成功完成的回调函数
+								writer.onwrite = e => {
+									resolve(e)
+									console.log('写入成功');
+								};
+								// 向文件中写入数据
+								writer.write(
+									JSON.stringify(data)
+								);
+							});
+						},
+						e => {
+							reject(e)
+							console.log('getFile failed: ' + e.message);
+						}
+					);
+				},
+				e => {
+					reject(e);
+					console.log(e.message);
+				}
+			);
+		})
+		
 	},
 	read(addr) {
 		let that = this;