diff --git a/pages.json b/pages.json index e310355..ee80869 100644 --- a/pages.json +++ b/pages.json @@ -25,7 +25,8 @@ } }, { - "path": "pages/user/RetrievePassword/index", + // "path": "pages/user/RetrievePassword/index", + "path": "pages/user/ChangePassword/index", "style": { "navigationBarTitleText": "重置密码" } diff --git a/pages/user/ChangePassword/index.vue b/pages/user/ChangePassword/index.vue index e5c0a2d..0d65353 100644 --- a/pages/user/ChangePassword/index.vue +++ b/pages/user/ChangePassword/index.vue @@ -1,9 +1,12 @@ - + + + diff --git a/pages/user/Login/index.vue b/pages/user/Login/index.vue index d81905b..8f4aebc 100644 --- a/pages/user/Login/index.vue +++ b/pages/user/Login/index.vue @@ -5,40 +5,50 @@ {{ item }} +
- + + v-model="account" required/> + + {{ clockText }} + - + - + + - + - + + + + + + - 登录 - 登录 + --> + + 手机号登录 + 登录 - 没有账号? + 第一次使用? 立即注册
@@ -124,22 +134,21 @@ mixins: [sendVerifyCode], data: function () { return { - navList: ["手机号登录"], + // navList: ["手机号登录", "密码登录"], + navList: ["手机号登录",], current: 0, account: "", password: "", captcha: "", inviteCode: "", formItem: 1, - type: "login" + type: "login", + timer: null, + clock: 60, + clockText: '获取验证码' }; }, methods: { - checkPhone(e) { - if (e.target.value.length === 11) { - console.log('手机号') - } - }, async loginMobile() { var that = this; const { @@ -166,16 +175,18 @@ return validatorDefaultCatch(e); } loginMobile({ - phone: that.account, + account: that.account, captcha: that.captcha, spread: cookie.get("spread") }) - .then(res => { + .then(res => { var data = res.data; that.$store.commit("login", data.token, dayjs(data.expires_time)); + that.$store.dispatch('userInfo', true) handleGetUserInfo(); }) .catch(err => { + console.log(err) uni.showToast({ title: err.msg || err.response.data.msg || err.response.data.message, icon: "none", @@ -183,157 +194,215 @@ }); }); }, - async register() { - var that = this; - const { - account, - captcha, - password - } = that; - try { - await that - .$validator({ - account: [ - required(required.message("手机号码")), - chs_phone(chs_phone.message()) - ], - captcha: [ - required(required.message("验证码")), - alpha_num(alpha_num.message("验证码")) - ], - password: [ - required(required.message("密码")), - attrs.range([6, 16], attrs.range.message("密码")), - alpha_num(alpha_num.message("密码")) - ] - }) - .validate({ - account, - captcha, - password - }); - } catch (e) { - return validatorDefaultCatch(e); - } - register({ - account: that.account, - captcha: that.captcha, - password: that.password, - inviteCode: that.inviteCode, - spread: cookie.get("spread") - }) - .then(res => { - uni.showToast({ - title: res.msg, - icon: "success", - duration: 2000 - }); - that.formItem = 1; - }) - .catch(err => { - uni.showToast({ - title: err.msg || err.response.data.msg || err.response.data.message, - icon: "none", - duration: 2000 - }); - }); - }, - // 获取验证码 - async code() { - var that = this; - const { - account - } = that; - try { - await that - .$validator({ - account: [ - required(required.message("手机号码")), - chs_phone(chs_phone.message()) - ] - }) - .validate({ - account - }); - } catch (e) { - return validatorDefaultCatch(e); - } - if (that.formItem == 2) that.type = "register"; - await registerVerify({ - phone: that.account, - type: that.type - }) - .then(res => { - uni.showToast({ - title: res.msg, - icon: "success", - duration: 2000 - }); - that.sendCode(); - }) - .catch(err => { - uni.showToast({ - title: err.msg || err.response.data.msg || err.response.data.message, - icon: "none", - duration: 2000 - }); - }); - }, - navTap: function (index) { - this.current = index; - }, - async submit() { - const { - account, - password - } = this; - try { - await this.$validator({ - account: [ - required(required.message("账号")), - attrs.range([5, 16], attrs.range.message("账号")), - alpha_num(alpha_num.message("账号")) - ], - password: [ - required(required.message("密码")), - attrs.range([6, 16], attrs.range.message("密码")), - alpha_num(alpha_num.message("密码")) - ] - }).validate({ - account, - password - }); - } catch (e) { - return validatorDefaultCatch(e); - } - - login({ - username: account, - password, - spread: cookie.get("spread") - }) - .then(({ - data - }) => { - this.$store.commit("login", data.token, dayjs(data.expires_time)); - handleGetUserInfo(); - // let replace=this.$yroute.query.replace - // if(replace){ + async register() { + var that = this; + const { + account, + captcha, + password + } = that; + try { + await that + .$validator({ + account: [ + required(required.message("手机号码")), + chs_phone(chs_phone.message()) + ], + captcha: [ + required(required.message("验证码")), + alpha_num(alpha_num.message("验证码")) + ], + password: [ + required(required.message("密码")), + attrs.range([6, 16], attrs.range.message("密码")), + alpha_num(alpha_num.message("密码")) + ] + }) + .validate({ + account, + captcha, + password + }); + } catch (e) { + return validatorDefaultCatch(e); + } + register({ + account: that.account, + captcha: that.captcha, + password: that.password, + inviteCode: that.inviteCode, + spread: cookie.get("spread") + }) + .then(res => { + uni.showToast({ + title: res.msg, + icon: "success", + duration: 2000 + }); + that.formItem = 1; + }) + .catch(err => { + uni.showToast({ + title: err.msg || err.response.data.msg || err.response.data.message, + icon: "none", + duration: 2000 + }); + }); + }, + // 获取验证码 + async code() { + const { + account + } = this; + try { + await this + .$validator({ + account: [ + required(required.message("手机号码")), + chs_phone(chs_phone.message()) + ] + }) + .validate({ + account + }); + } catch (e) { + return validatorDefaultCatch(e); + } + if (this.formItem == 2) this.type = "register"; + this.showCode() + }, + // 手机号登录获取验证码 + async sendCode () { + const { + account + } = this; + try { + await this + .$validator({ + account: [ + required(required.message("手机号码")), + chs_phone(chs_phone.message()) + ] + }) + .validate({ + account + }); + } catch (e) { + return validatorDefaultCatch(e); + } + // 倒计时 + if (this.clock !== 60) { + return + } + this.clock-- + this.clockText = `${this.clock} 秒` + this.timer = setInterval(() => { + if (parseInt(this.clock) === 1) { + clearTimeout(this.timer) + this.clock = 60 + this.clockText = '获取验证码' + return + } + this.clock-- + if (this.clock < 10) this.clock = `0${this.clock}` + this.clockText = `${this.clock} 秒` + }, 1000) + this.showCode() + }, + // 验证码请求 + showCode() { + return registerVerify({ + phone: this.account, + type: this.type + }) + .then(res => { + uni.showToast({ + title: res.msg, + icon: "success", + duration: 2000 + }); + this.sendCode(); + }) + .catch(err => { + uni.showToast({ + title: err.msg || err.response.data.msg || err.response.data.message, + icon: "none", + duration: 2000 + }); + }); + }, + navTap(index) { this.current = index; }, + async submit() { + const { + account, + password + } = this; + try { + await this.$validator({ + account: [ + required(required.message("账号")), + attrs.range([5, 16], attrs.range.message("账号")), + alpha_num(alpha_num.message("账号")) + ], + password: [ + required(required.message("密码")), + attrs.range([6, 16], attrs.range.message("密码")), + alpha_num(alpha_num.message("密码")) + ] + }).validate({ + account, + password + }); + } catch (e) { + return validatorDefaultCatch(e); + } + // 账号密码登录 + login({ + username: account, + password, + spread: cookie.get("spread") + }) + .then(({ + data + }) => { + this.$store.commit("login", data.token, dayjs(data.expires_time)); + handleGetUserInfo(); + // let replace=this.$yroute.query.replace + // if(replace){ - // } - // this.$yrouter.replace({ - // path: this.$yroute.query.replace || '/pages/home/index' - // }); - }) - .catch(err => { - console.log(err); - uni.showToast({ - title: err.msg || err.response.data.msg || err.response.data.message, - icon: "none", - duration: 2000 - }); - }); - } + // } + // this.$yrouter.replace({ + // path: this.$yroute.query.replace || '/pages/home/index' + // }); + }) + .catch(err => { + console.log(err); + uni.showToast({ + title: err.msg || err.response.data.msg || err.response.data.message, + icon: "none", + duration: 2000 + }); + }); + } } }; + + diff --git a/pages/user/PersonalData/index.vue b/pages/user/PersonalData/index.vue index 9444bb1..e976475 100644 --- a/pages/user/PersonalData/index.vue +++ b/pages/user/PersonalData/index.vue @@ -1,58 +1,56 @@