|
@@ -17,7 +17,7 @@
|
|
|
<text class="area-val">{{ from.areaCode ? `+${from.areaCode}` : '国家地区'}}</text>
|
|
|
<image class="select-area" src="../static/img/img_26.png" mode="aspectFit"></image>
|
|
|
</view>
|
|
|
- <input v-model="from.user_string" class="item-input" type="text"
|
|
|
+ <input v-model="from.user_string" class="item-input" type="number"
|
|
|
placeholder-class="placeholder-class" placeholder="请输入手机号">
|
|
|
</view>
|
|
|
<view class="from-item" v-show="registerType === 2">
|
|
@@ -25,12 +25,12 @@
|
|
|
placeholder-class="placeholder-class" placeholder="请输入邮箱号">
|
|
|
</view>
|
|
|
<view class="from-item">
|
|
|
- <input class="item-input" v-model="from.password.code" type="text"
|
|
|
+ <input class="item-input" v-model="from.code" type="number"
|
|
|
placeholder-class="placeholder-class" placeholder="验证码">
|
|
|
<text class="item-code" @click.stop="getCode()">{{ CodeText }}</text>
|
|
|
</view>
|
|
|
<view class="from-item">
|
|
|
- <input class="item-input" v-model="from.password" :type="showPass ? 'number' : 'password'"
|
|
|
+ <input class="item-input" v-model="from.password" :type="showPass ? 'text' : 'password'"
|
|
|
placeholder-class="placeholder-class" placeholder="请输入密码">
|
|
|
<view class="pass-icon-box" @click.stop="showPass = !showPass">
|
|
|
<image v-show="!showPass" class="pass-icon" src="../static/img/img_25.png" mode="aspectFit">
|
|
@@ -50,7 +50,7 @@
|
|
|
mode="aspectFit">
|
|
|
</image>
|
|
|
</view>
|
|
|
- 我已阅读并同意<text class="agreement-name">《服务与隐私条款》</text>
|
|
|
+ 我已阅读并同意<text class="agreement-name" @click.stop="readAgreementContent()">《服务与隐私条款》</text>
|
|
|
</view>
|
|
|
|
|
|
|
|
@@ -67,6 +67,10 @@
|
|
|
Api_getEmailCode,
|
|
|
Api_getSmsSend
|
|
|
} from "@/api/index.js"
|
|
|
+ import {
|
|
|
+ validPassword,
|
|
|
+ validPositiveIntegerZero
|
|
|
+ } from "@/utils/validate.js"
|
|
|
export default {
|
|
|
name: 'register',
|
|
|
data() {
|
|
@@ -81,21 +85,81 @@
|
|
|
areaCode: 86,
|
|
|
code: '',
|
|
|
extension_code: ''
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ timeInterval: null
|
|
|
};
|
|
|
},
|
|
|
onLoad(opt) {
|
|
|
this.from.extension_code = opt?.extension_code || ''
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 校验
|
|
|
+ verifyVal(type, val) {
|
|
|
+ let status = true,
|
|
|
+ msg = ''
|
|
|
+ switch (type) {
|
|
|
+ case 'phone':
|
|
|
+ status = validPositiveIntegerZero(val);
|
|
|
+ msg = '手机号码格式错误';
|
|
|
+ break;
|
|
|
+ case 'email':
|
|
|
+ status = val ? true : false;
|
|
|
+ msg = '请输入邮箱号'
|
|
|
+ break;
|
|
|
+ case 'code':
|
|
|
+ status = val ? true : false;
|
|
|
+ msg = '请输入验证码';
|
|
|
+ break;
|
|
|
+ case 'password':
|
|
|
+ status = validPassword(val);
|
|
|
+ msg = '密码须同时包含数字,大小写字母,且大于8位'
|
|
|
+ break;
|
|
|
+ case 'extension_code':
|
|
|
+ status = val ? true : false;
|
|
|
+ msg = '请填写验证码'
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!status) {
|
|
|
+ console.log('msg = ', msg)
|
|
|
+ uni.showToast({
|
|
|
+ title: msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return status
|
|
|
+ },
|
|
|
+
|
|
|
+ readAgreementContent() {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/agreement'
|
|
|
+ })
|
|
|
+ },
|
|
|
setRegisterType(type) {
|
|
|
this.from.user_string = '';
|
|
|
this.registerType = type;
|
|
|
},
|
|
|
+
|
|
|
+ // validPassword
|
|
|
+
|
|
|
getCode() {
|
|
|
if (this.CodeText !== '获取验证码') {
|
|
|
return false
|
|
|
}
|
|
|
+ if (this.registerType === 1) {
|
|
|
+ if (!this.verifyVal('phone', this.from.user_string) || this.from.user_string.length !== 11) {
|
|
|
+
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!this.verifyVal('email', this.from.user_string)) {
|
|
|
+
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
let Api_ = '',
|
|
|
obj = {};
|
|
|
obj.user_string = this.from.user_string;
|
|
@@ -103,7 +167,7 @@
|
|
|
case 1:
|
|
|
// 手机号 - 获取验证码
|
|
|
Api_ = Api_getSmsSend;
|
|
|
- obj.area_code = this.areaCode;
|
|
|
+ obj.area_code = this.from.areaCode;
|
|
|
break;
|
|
|
case 2:
|
|
|
// 邮箱 - 获取验证码
|
|
@@ -111,6 +175,8 @@
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
if (Api_) {
|
|
|
Api_(obj).then(res => {
|
|
@@ -135,9 +201,28 @@
|
|
|
},
|
|
|
submitRegister() {
|
|
|
if (this.readAgreement) {
|
|
|
+ if (this.registerType === 1) {
|
|
|
+ if (!this.verifyVal('phone', this.from.user_string) || this.from.user_string.length !== 11) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!this.verifyVal('email', this.from.user_string)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!this.verifyVal('code', this.from.code)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!this.verifyVal('password', this.from.password)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!this.verifyVal('extension_code', this.from.extension_code)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
const obj = {
|
|
|
user_string: this.from.user_string,
|
|
|
password: this.from.password,
|
|
|
+ re_password: this.from.password,
|
|
|
extension_code: this.from.extension_code,
|
|
|
code: this.from.code,
|
|
|
type: this.registerType === 1 ? 'mogile' : ' email'
|
|
@@ -195,11 +280,8 @@
|
|
|
background-color: #fff;
|
|
|
border-radius: 20rpx;
|
|
|
padding-bottom: 63rpx;
|
|
|
-
|
|
|
- // <view class="from-lable">
|
|
|
- // <text class="lable-title">手机注册</text>
|
|
|
- // <text class="lable-title">邮箱注册</text>
|
|
|
- // </view>
|
|
|
+ margin-top: 46rpx;
|
|
|
+
|
|
|
.from-lable {
|
|
|
width: 100%;
|
|
|
display: flex;
|