lhl 2 years ago
parent
commit
ff47ac282c
5 changed files with 217 additions and 171 deletions
  1. 15 0
      api/login.js
  2. 1 1
      manifest.json
  3. 1 1
      pages/public/login.vue
  4. 200 169
      pages/public/register.vue
  5. BIN
      static/icon/goto.png

+ 15 - 0
api/login.js

@@ -71,4 +71,19 @@ export function gologin(data) {
 		data
 	})
 }
+
+export function getYzm(data) {
+	return request({
+		url: '/api/Login/sendcode',
+		method: 'POST',
+		data
+	})
+}
+export function zc(data) {
+	return request({
+		url: '/api/Login/upregister',
+		method: 'POST',
+		data
+	})
+}
  

+ 1 - 1
manifest.json

@@ -76,7 +76,7 @@
                     "target" : "http://heyu.frp.liuniu946.com",
                     // "changeOrigin": true,
                     "pathRewrite" : {
-                        "/api" : "" // rewrite path
+                        "/api" : "/" // rewrite path
                     }
                 }
             }

+ 1 - 1
pages/public/login.vue

@@ -94,7 +94,7 @@
 					console.log(res)
 					obj.loadingType = 'no'
 				}).catch(err => {
-					console.log(res)
+					console.log(err)
 					obj.loadingType = 'no'
 				})
 			},

+ 200 - 169
pages/public/register.vue

@@ -1,5 +1,5 @@
-<template>
-	<view class="container">
+<template>
+	<view class="container">
 		<view class="wjmm" style="text-align: right;padding-right: 30rpx;font-size: 36rpx;" @click="dl()">
 			登錄
 		</view>
@@ -7,180 +7,205 @@
 			郵箱
 		</view>
 		<input type="text" class="shuru" placeholder="請翰入郵箱" v-model="email">
-		<view class="tit" >
+		<view class="tit">
 			獲取郵箱驗證碼
 		</view>
-		<view class="flex" style="width: 673rpx;justify-content: space-between;margin: auto;border:1px solid red;">
-			<input type="password" class=" yzm" placeholder="請翰入密碼" v-model="email">
+		<view class="flex" style="width: 673rpx;justify-content: space-between;margin: auto;">
+			<input type="text" class=" yzm" placeholder="請翰入密碼" v-model="code">
 			<view class="code yzmbtn" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
 		</view>
-		
-		<view class="tit" >
+
+		<view class="tit">
 			密碼
 		</view>
-		<input type="password" class="shuru" placeholder="請翰入密碼" v-model="email">
+		<input type="password" class="shuru" placeholder="請翰入密碼" v-model="lpwd">
 		<view class="tit">
 			確認密碼
 		</view>
-		<input type="password" class="shuru" placeholder="請翰入密碼" v-model="email">
-		<view class="tit" >
+		<input type="password" class="shuru" placeholder="請翰入密碼" v-model="relpwd">
+		<view class="tit">
 			邀請碼
 		</view>
-		<input type="text" class="shuru" placeholder="請翰入邀請碼" v-model="email">
-		<!-- <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="phone" 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="password" 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="repassword" focus placeholder="请重复输入密码" /></view>
-			</view>
-			<view class="login_input flex" style="display: none;">
-				<view class="login_img"><image src="/static/icon/img07.png"></image></view>
-				<view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
-			</view>
-			<view class="login_input flex">
-				<view class="login_img"><image src="/static/icon/img06.png"></image></view>
-				<view class="login_name flex">
-					<input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
-					<view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
-				</view>
-			</view>
-			<view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
-			<view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view>
-		</view> -->
-	</view>
-</template>
-<script>
-import { register, verify } from '@/api/login.js';
-export default {
-	data() {
-		return {
-			phone: '', //用户
-			password: '', //密码
-			repassword: '',
-			invitation: '', //邀请码
-			code: '', //验证码
-			time: '', //保存倒计时对象
-			countDown: 0 ,//倒计时
-		};
-	},
-	onLoad() {
-		// 获取扫码邀请人id
-		this.invitation = uni.getStorageSync('spread')||'';
-	},
-	watch: {
-		// 监听倒计时
-		countDown(i) {
-			if (i == 0) {
-				clearInterval(this.time);
-			}
-		}
-	},
-	methods: {
-		dl() {
-			uni.navigateTo({
-				url: '/pages/public/login'
-			})
-		},
-		// 注册
-		register() {
-			let obj = this;
-			if (obj.phone == '') {
-				obj.$api.msg('请输入电话号码');
-				return;
-			}
-			if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.phone)) {
-				obj.$api.msg('请输入正确的手机号');
-				return;
-			}
-			if (obj.password == '') {
-				obj.$api.msg('请输入密码');
-				return;
-			}
-			if (obj.repassword == '') {
-				obj.$api.msg('请再次输入密码');
-				return;
-			}
-			if (obj.repassword != obj.password) {
-				obj.$api.msg('两次密码不正确');
-				return;
-			}
-			// if ((obj.invitation = '')) {
-			// 	obj.$api.msg('请输入邀请码');
-			// 	return;
-			// }
-			// if (obj.code == '') {
-			// 	obj.$api.msg('请输入验证码');
-			// 	return;
-			// }
-			register({
-				account: obj.phone, //账号
-				// captcha: obj.code, //验证码
-				password: obj.password ,//密码
-				spread:this.invitation//上级推广人
-			}).then(function(e) {
-				uni.showToast({
-					title:'注册成功',
-					duration:2000,
-					position:'top'
-				});
-				setTimeout(function () {
-					uni.navigateTo({
-						url: '/pages/public/login'
-					});
-				},1000)
-				
-			});
-			//调用注册接口,成功跳转登录页
-		},
-		//发送验证码
-		verification() {
-			let obj = this;
-			if (this.phone == '') {
-				this.$api.msg('请输入电话号码');
-				return;
-			}
-			if (this.phone.length < 11) {
-				this.$api.msg('请输入正确的手机号');
-				return;
-			}
-			// 判断是否在倒计时
-			if (obj.countDown > 0) {
-				return false;
-			} else {
-				obj.countDown = 60;
-				obj.time = setInterval(() => {
-					obj.countDown--;
-				}, 1000);
-				//调用验证码接口
-				verify({
-					phone: obj.phone,
-					type: 'register'
-				})
-					.then(({ data }) => {})
-					.catch(err => {
-						console.log(err);
-					});
-			}
-		},
-		login() {
-			//返回登录
-			uni.navigateTo({
-				url: '/pages/public/login'
-			});
-		}
-	}
-};
-</script>
-
-<style lang="scss">
-page {
+		<input type="text" class="shuru" placeholder="請翰入邀請碼" v-model="invit">
+		<view class="flex" style="justify-content: space-between;padding: 50rpx 30rpx;align-items: flex-start;">
+			<view class="">
+				注冊即表示同意 <text style="color: #fcd535;">用戶服務協議</text>
+			</view>
+			<image src="../../static/icon/goto.png" mode="" style="width: 97rpx;height: 97rpx;" @click="register()"></image>
+		</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="phone" 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="password" 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="repassword" focus placeholder="请重复输入密码" /></view>
+			</view>
+			<view class="login_input flex" style="display: none;">
+				<view class="login_img"><image src="/static/icon/img07.png"></image></view>
+				<view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
+			</view>
+			<view class="login_input flex">
+				<view class="login_img"><image src="/static/icon/img06.png"></image></view>
+				<view class="login_name flex">
+					<input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
+					<view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
+				</view>
+			</view>
+			<view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
+			<view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view>
+		</view> -->
+	</view>
+</template>
+<script>
+	import {
+		register,
+		verify,
+		getYzm,
+		zc
+	} from '@/api/login.js';
+	export default {
+		data() {
+			return {
+				loaded: false,
+				lpwd: '',
+				relpwd: '',
+				invit: '',
+				email: '',
+				phone: '', //用户
+				password: '', //密码
+				repassword: '',
+				invitation: '', //邀请码
+				code: '', //验证码
+				time: '', //保存倒计时对象
+				countDown: 0, //倒计时
+			};
+		},
+		onLoad() {
+			// 获取扫码邀请人id
+			this.invitation = uni.getStorageSync('spread') || '';
+		},
+		watch: {
+			// 监听倒计时
+			countDown(i) {
+				if (i == 0) {
+					clearInterval(this.time);
+				}
+			}
+		},
+		methods: {
+			dl() {
+				uni.navigateTo({
+					url: '/pages/public/login'
+				})
+			},
+			// 注册
+			register() {
+				let obj = this;
+				if(obj.loaded) {
+					return
+				}
+				if (obj.email == '') {
+					obj.$api.msg('請輸入郵箱');
+					return;
+				}
+				if (obj.lpwd == '') {
+					obj.$api.msg('請輸入密碼');
+					return;
+				}
+				if (obj.relpwd == '') {
+					obj.$api.msg('請再次輸入密碼');
+					return;
+				}
+				if (obj.relpwd != obj.lpwd) {
+					obj.$api.msg('兩次密碼不一致');
+					return;
+				}
+				// if ((obj.invitation = '')) {
+				// 	obj.$api.msg('请输入邀请码');
+				// 	return;
+				// }
+				if (obj.code == '') {
+					obj.$api.msg('请输入验证码');
+					return;
+				}
+				obj.loaded = true
+				zc({
+					email: obj.email,
+					lpwd: obj.lpwd,
+					invit: obj.invit,
+					phone: obj.phone,
+					yincang: 1,
+					ecode: obj.code
+				}).then(function(e) {
+					obj.loaded = false
+					uni.showToast({
+						title: '注册成功',
+						duration: 2000,
+						position: 'top'
+					});
+					setTimeout(function() {
+						uni.navigateTo({
+							url: '/pages/public/login'
+						});
+					}, 1000)
+
+				}).catch(err => {
+					obj.loaded = true
+				});
+				//调用注册接口,成功跳转登录页
+			},
+			isEmailAvailable(obj) {
+				let email = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
+				if (!email.test(obj)) {
+					return false;
+				}
+				return true;
+			},
+			//发送验证码
+			verification() {
+				let obj = this;
+				if (!obj.isEmailAvailable(obj.email)) {
+					return obj.$api.msg('請輸入正確的郵箱!')
+				}
+				// 判断是否在倒计时
+				if (obj.countDown > 0) {
+					return false;
+				} else {
+					obj.countDown = 60;
+					obj.time = setInterval(() => {
+						obj.countDown--;
+					}, 1000);
+					//调用验证码接口
+					getYzm({
+							email: obj.email,
+							// type: 'register'
+						})
+						.then(({
+							data
+						}) => {})
+						.catch(err => {
+							console.log(err);
+						});
+				}
+			},
+			login() {
+				//返回登录
+				uni.navigateTo({
+					url: '/pages/public/login'
+				});
+			}
+		}
+	};
+</script>
+
+<style lang="scss">
+	page {
 		height: 100%;
 		background-color: #fff;
 		font-size: 32rpx;
@@ -201,9 +226,11 @@ page {
 		padding-left: 30rpx;
 		text-align: 95rpx;
 	}
+
 	.tit {
-		padding:40rpx 48rpx 20rpx;
+		padding: 40rpx 48rpx 20rpx;
 	}
+
 	.gologin {
 		width: 204rpx;
 		height: 98rpx;
@@ -212,13 +239,18 @@ page {
 		text-align: center;
 		border-radius: 20rpx;
 	}
+
 	.wjmm {
 		color: #fcd535;
-	}
+	}
+
 	.yzm {
 		width: 400rpx;
 		height: 95rpx;
+		padding-left: 30rpx;
+		background-color: #f5f5f5;
 	}
+
 	.yzmbtn {
 		width: 234rpx;
 		height: 95rpx;
@@ -226,6 +258,5 @@ page {
 		text-align: center;
 		line-height: 95rpx;
 		color: #fcd535;
-	}
+	}
 </style>
-

BIN
static/icon/goto.png