From 4912b7267f7073b4a6ccaca63bc25be0a8f1758f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=8A=E9=87=8C?= <1227971437@qq.com> Date: Mon, 12 Apr 2021 16:09:05 +0800 Subject: [PATCH] =?UTF-8?q?data=E5=8F=98=E9=87=8F=E6=8F=90=E5=8F=96?= =?UTF-8?q?=E5=88=B0mixin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-login-page/common/loginPage.mixin.js | 52 +++++++++++++++++++ .../uni-login-page/pages/index/index.vue | 25 --------- .../uni-login-page/pages/index/phone-code.vue | 30 +++-------- .../uni-login-page/pages/index/pwd-login.vue | 29 ----------- .../pages/index/pwd-retrieve.vue | 44 +--------------- 5 files changed, 59 insertions(+), 121 deletions(-) diff --git a/uni_modules/uni-login-page/common/loginPage.mixin.js b/uni_modules/uni-login-page/common/loginPage.mixin.js index 3e02d854..20ad828e 100644 --- a/uni_modules/uni-login-page/common/loginPage.mixin.js +++ b/uni_modules/uni-login-page/common/loginPage.mixin.js @@ -10,6 +10,58 @@ let mixin = { url:helpPage }) }, + data(){ + return { + // 用户协议页面跳转 + link: [{ + text: '用户协议', + to: '/pages/ucenter/agree-list/service/service' + }, { + text: '隐私政策', + to: '/pages/ucenter/agree-list/privacy/privacy' + }], + formData:{ + phone:'', + code:'', + pwd:'' + }, + rules: { + phone:{ + rules:[{ + required: true, + errorMessage: '请输入手机号', + }, + { + pattern: /^1\d{10}$/, + errorMessage: '手机号格式不正确', + } + ] + }, + code: { + rules: [{ + required: true, + errorMessage: '请输入验证码', + }, + { + pattern: /^.{6}$/, + errorMessage: '请输入6位验证码', + } + ] + }, + pwd:{ + rules: [{ + required: true, + errorMessage: '请输入密码', + }, + { + pattern: /^.{6,20}$/, + errorMessage: '密码应为6到20位', + } + ] + } + } + } + }, methods:{ ...mapMutations({ setUserInfo: 'user/login' diff --git a/uni_modules/uni-login-page/pages/index/index.vue b/uni_modules/uni-login-page/pages/index/index.vue index 847586d4..42e2b93b 100644 --- a/uni_modules/uni-login-page/pages/index/index.vue +++ b/uni_modules/uni-login-page/pages/index/index.vue @@ -45,33 +45,8 @@ mixins:[mixin], data() { return { - link: [{ - text: '用户协议', - to: '/pages/ucenter/agree-list/service/service' - }, { - text: '隐私政策', - to: '/pages/ucenter/agree-list/privacy/privacy' - }], phoneArea: ['+86'], currenPhoneArea: '+86', - - formData: { - phone: '' - }, - rules: { - // 对phone字段进行必填验证 - phone: { - rules: [{ - required: true, - errorMessage: '请输入手机号', - }, - { - pattern: /^1\d{10}$/, - errorMessage: '手机号格式不正确', - } - ] - } - } } }, onLoad() { diff --git a/uni_modules/uni-login-page/pages/index/phone-code.vue b/uni_modules/uni-login-page/pages/index/phone-code.vue index 5288f3d5..60988933 100644 --- a/uni_modules/uni-login-page/pages/index/phone-code.vue +++ b/uni_modules/uni-login-page/pages/index/phone-code.vue @@ -11,7 +11,7 @@ @@ -30,41 +30,23 @@ mixins:[mixin], data() { return { - phoneNumber: '', - phoneCode: '', - currenPhoneArea: '', - formData:{ - code:'' - }, - rules: { - code: { - rules: [{ - required: true, - errorMessage: '请输入验证码', - }, - { - pattern: /^.{6}$/, - errorMessage: '请输入6位验证码', - } - ] - } - } + currenPhoneArea: '', } }, computed: { tipText() { - return `验证码已通过短信发送至${this.currenPhoneArea} ${this.phoneNumber}。`; + return `验证码已通过短信发送至${this.currenPhoneArea} ${this.formData.phone}。`; }, canSubmit() { let reg_phone = /^1\d{10}$/; let reg_code = /^\d{6}$/; - let isPhone = reg_phone.test(this.phoneNumber); + let isPhone = reg_phone.test(this.formData.phone); let isCode = reg_code.test(this.formData.code); return isPhone && isCode; } }, onLoad({phoneNumber,phoneArea}) { - this.phoneNumber = phoneNumber; + this.formData.phone = phoneNumber; this.currenPhoneArea = '+' + Number(phoneArea); }, onReady() { @@ -80,7 +62,7 @@ "data": { "action": "loginBySms", "params":{ - "mobile":this.phoneNumber, + "mobile":this.formData.phone, "code":this.formData.code } }, diff --git a/uni_modules/uni-login-page/pages/index/pwd-login.vue b/uni_modules/uni-login-page/pages/index/pwd-login.vue index 201ae835..a94fadfc 100644 --- a/uni_modules/uni-login-page/pages/index/pwd-login.vue +++ b/uni_modules/uni-login-page/pages/index/pwd-login.vue @@ -49,35 +49,6 @@ }], phoneArea: ['+86'], currenPhoneArea: '+86', - - formData: { - phone: '', - pwd:'' - }, - rules: { - phone: { - rules: [{ - required: true, - errorMessage: '请输入手机号', - }, - { - pattern: /^1\d{10}$/, - errorMessage: '手机号格式不正确', - } - ] - }, - pwd:{ - rules: [{ - required: true, - errorMessage: '请输入密码', - }, - { - pattern: /^.{6,20}$/, - errorMessage: '密码应为6到20位', - } - ] - } - } } }, computed: { diff --git a/uni_modules/uni-login-page/pages/index/pwd-retrieve.vue b/uni_modules/uni-login-page/pages/index/pwd-retrieve.vue index 0d1c6e7d..66823f0a 100644 --- a/uni_modules/uni-login-page/pages/index/pwd-retrieve.vue +++ b/uni_modules/uni-login-page/pages/index/pwd-retrieve.vue @@ -33,49 +33,7 @@ import mixin from '../../common/loginPage.mixin.js'; mixins:[mixin], data() { return { - password: '', - currenPhoneArea: '', - - formData:{ - phone:'', - code:'', - pwd:'' - }, - rules: { - phone:{ - rules:[{ - required: true, - errorMessage: '请输入手机号', - }, - { - pattern: /^1\d{10}$/, - errorMessage: '手机号格式不正确', - } - ] - }, - code: { - rules: [{ - required: true, - errorMessage: '请输入验证码', - }, - { - pattern: /^.{6}$/, - errorMessage: '请输入6位验证码', - } - ] - }, - pwd:{ - rules: [{ - required: true, - errorMessage: '请输入密码', - }, - { - pattern: /^.{6,20}$/, - errorMessage: '密码应为6到20位', - } - ] - } - } + currenPhoneArea: '', } }, computed: { -- GitLab