yuanyiming hai 1 ano
pai
achega
397c5d46c1
Modificáronse 1 ficheiros con 64 adicións e 20 borrados
  1. 64 20
      pages/login/login.vue

+ 64 - 20
pages/login/login.vue

@@ -1,23 +1,27 @@
 <template>
 	<view class="login">
 		<statusBar :item='navBarData'></statusBar>
-		
+
 		<view class="img">
 			<image src="http://43.139.158.220:5007/img/static/yym/image7.png" mode="aspectFill"></image>
 		</view>
 
 		<view class="mid">
-			
+
 			<!-- <radio value="r1" @click="radioCheck" size="10" :checked="isOK" /> -->
 			<view class="" style="position: relative;padding-left:30rpx;">
 				我已阅读并同意<text>《教育小程序服务条款》</text>和 <text>《 隐私协议》</text>新用户自动注册
 				<view class="quan" @click="isDui">
-					<image v-if="isShow" class="dui" src="http://43.139.158.220:5007/img/static/yym/dui.png" mode="aspectFill"></image>
+					<image v-if="isShow" class="dui" src="http://43.139.158.220:5007/img/static/yym/dui.png"
+						mode="aspectFill"></image>
 				</view>
 			</view>
 		</view>
 
-		<button class="btn" @click="gotoIndex">一键登录</button>
+		<button class="btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
+			<image class="avatar" :src="avatarUrl"></image>
+		</button>
+		<!-- <button class="btn" @click="gotoIndex">一键登录</button> -->
 		<!-- <button class="btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">一键登录</button> -->
 		<view class="footer" @click="goto">
 			<text>手机号登录/账号密码登录</text>
@@ -29,27 +33,50 @@
 	export default {
 		data() {
 			return {
+				avatarUrl: 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
 				isOK: false,
 				navBarData: {
 					title: '首页',
 					btn: 1 //判断是否显示返回按钮
 				},
-				isMsg:0,
-				isShow:false
+				isMsg: 0,
+				isShow: false
 			};
 		},
 		methods: {
-			 getPhoneNumber (e) {
-			    console.log(e.detail.code)  // 动态令牌
-			    console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
-			    console.log(e.detail.errno)  // 错误码(失败时返回)
-			  },
+			onChooseAvatar(e) {
+				console.log(e);
+				const {
+					avatarUrl
+				} = e.detail
+				this.avatarUrl = avatarUrl
+
+				//对临时图片链接进行base64编码
+				var avatarUrl_base64 = 'data:image/jpeg;base64,' + wx.getFileSystemManager().readFileSync(this.avatarUrl,
+					'base64')
+				console.log(avatarUrl_base64);
+
+
+				uni.request({
+					url: 'http://localhost:3001/login2',
+					method: 'POST',
+					data: avatarUrl_base64,
+					success(res) {
+						console.log(res);
+					}
+				})
+			},
+			getPhoneNumber(e) {
+				console.log(e.detail.code) // 动态令牌
+				console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
+				console.log(e.detail.errno) // 错误码(失败时返回)
+			},
 			gotoIndex() {
-					const value = uni.setStorageSync('login', '1');
-					
-					uni.switchTab({
-						url: '/pages/index/index'
-					})
+				const value = uni.setStorageSync('login', '1');
+
+				// uni.switchTab({
+				// 	url: '/pages/index/index'
+				// })
 				// if(this.isMsg==1){
 				// 	uni.setStorageSync('msgLogin', '1');
 				// 	uni.switchTab({
@@ -70,13 +97,13 @@
 			radioCheck() {
 				this.isOK = !this.isOK
 			},
-			isDui(){
-				this.isShow=!this.isShow
+			isDui() {
+				this.isShow = !this.isShow
 			}
 		},
 		onLoad(opt) {
 			console.log(opt);
-			this.isMsg=opt.id
+			this.isMsg = opt.id
 		}
 	}
 </script>
@@ -86,6 +113,18 @@
 		background-color: #ffffff;
 		height: 100vh;
 
+		.avatar-wrapper {
+			width: 300rpx;
+			background-color: #fff;
+			margin: auto;
+		}
+
+		.avatar {
+			width: 60rpx;
+			height: 60rpx;
+
+		}
+
 		.img {
 			// padding: 10vh 0;
 			padding-top: 10vh;
@@ -93,7 +132,7 @@
 			width: 750rpx;
 			display: flex;
 			justify-content: center;
-			
+
 			image {
 				width: 200rpx;
 				height: 200rpx;
@@ -123,6 +162,7 @@
 				display: flex;
 				justify-content: center;
 				align-items: center;
+
 				.dui {
 					width: 32rpx;
 					height: 32rpx;
@@ -139,6 +179,10 @@
 			color: #ffffff;
 			border-radius: 30px;
 			margin: 30rpx 55rpx;
+			padding: 10rpx 0;
+			display: flex;
+			align-items: center;
+			justify-content: center;
 			// padding: 0rpx 10rpx;
 			font-size: 16px;
 		}