|
|
@ -5,40 +5,50 @@ |
|
|
|
<view class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList" |
|
|
|
<view class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList" |
|
|
|
@click="navTap(index)" :key="index">{{ item }}</view> |
|
|
|
@click="navTap(index)" :key="index">{{ item }}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 手机号登录 --> |
|
|
|
<view class="list" :hidden="current !== 0"> |
|
|
|
<view class="list" :hidden="current !== 0"> |
|
|
|
<form @submit.prevent="submit"> |
|
|
|
<form @submit.prevent="submit"> |
|
|
|
<view class="item"> |
|
|
|
<view class="item getPhoneCode"> |
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
<input type="text" placeholder="输入手机号码" |
|
|
|
<input type="text" placeholder="输入手机号码" |
|
|
|
v-model="account" required |
|
|
|
v-model="account" required/> |
|
|
|
@input="checkPhone"/> |
|
|
|
|
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="phoneCode" @click="sendCode"> |
|
|
|
|
|
|
|
{{ clockText }} |
|
|
|
|
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="item" v-if="account.length === 11"> |
|
|
|
<view class="item"> |
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
<input type="password" placeholder="填写登录密码" v-model="password" required /> |
|
|
|
<input type="text" placeholder="请输入验证码" v-model="captcha" required /> |
|
|
|
|
|
|
|
<!-- <input type="password" placeholder="填写登录密码" v-model="password" required /> --> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</form> |
|
|
|
</form> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<!-- <view class="list" :hidden="current !== 1"> |
|
|
|
<!-- 账号密码登录 --> |
|
|
|
|
|
|
|
<view class="list" :hidden="current !== 1"> |
|
|
|
<view class="item"> |
|
|
|
<view class="item"> |
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
<input type="text" placeholder="输入手机号码" v-model="account" /> |
|
|
|
<input type="text" placeholder="输入手机号码" v-model="account" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="item"> |
|
|
|
<view class="item"> |
|
|
|
|
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
|
|
|
|
<input type="text" placeholder="输入密码" v-model="password" /> |
|
|
|
|
|
|
|
</view> |
|
|
|
|
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- <view class="item"> |
|
|
|
<view class="align-left"> |
|
|
|
<view class="align-left"> |
|
|
|
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" /> |
|
|
|
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" /> |
|
|
|
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" |
|
|
|
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" |
|
|
|
@click="code">{{ text }}</button> |
|
|
|
@click="code">{{ text }}</button> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> --> |
|
|
|
</view> --> |
|
|
|
</view> |
|
|
|
<view class="logon" @click="loginMobile" :hidden="current !== 1">登录</view> |
|
|
|
<view class="logon" @click="loginMobile" :hidden="current === 1">手机号登录</view> |
|
|
|
<view class="logon" @click="submit" :hidden="current === 1">登录</view> |
|
|
|
<view class="logon" @click="submit" :hidden="current !== 1">登录</view> |
|
|
|
<view class="tip"> |
|
|
|
<view class="tip"> |
|
|
|
没有账号? |
|
|
|
第一次使用? |
|
|
|
<text @click="formItem = 2" class="font-color-red">立即注册</text> |
|
|
|
<text @click="formItem = 2" class="font-color-red">立即注册</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -124,22 +134,21 @@ |
|
|
|
mixins: [sendVerifyCode], |
|
|
|
mixins: [sendVerifyCode], |
|
|
|
data: function () { |
|
|
|
data: function () { |
|
|
|
return { |
|
|
|
return { |
|
|
|
navList: ["手机号登录"], |
|
|
|
// navList: ["手机号登录", "密码登录"], |
|
|
|
|
|
|
|
navList: ["手机号登录",], |
|
|
|
current: 0, |
|
|
|
current: 0, |
|
|
|
account: "", |
|
|
|
account: "", |
|
|
|
password: "", |
|
|
|
password: "", |
|
|
|
captcha: "", |
|
|
|
captcha: "", |
|
|
|
inviteCode: "", |
|
|
|
inviteCode: "", |
|
|
|
formItem: 1, |
|
|
|
formItem: 1, |
|
|
|
type: "login" |
|
|
|
type: "login", |
|
|
|
|
|
|
|
timer: null, |
|
|
|
|
|
|
|
clock: 60, |
|
|
|
|
|
|
|
clockText: '获取验证码' |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
checkPhone(e) { |
|
|
|
|
|
|
|
if (e.target.value.length === 11) { |
|
|
|
|
|
|
|
console.log('手机号') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
async loginMobile() { |
|
|
|
async loginMobile() { |
|
|
|
var that = this; |
|
|
|
var that = this; |
|
|
|
const { |
|
|
|
const { |
|
|
@ -166,16 +175,18 @@ |
|
|
|
return validatorDefaultCatch(e); |
|
|
|
return validatorDefaultCatch(e); |
|
|
|
} |
|
|
|
} |
|
|
|
loginMobile({ |
|
|
|
loginMobile({ |
|
|
|
phone: that.account, |
|
|
|
account: that.account, |
|
|
|
captcha: that.captcha, |
|
|
|
captcha: that.captcha, |
|
|
|
spread: cookie.get("spread") |
|
|
|
spread: cookie.get("spread") |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
.then(res => { |
|
|
|
var data = res.data; |
|
|
|
var data = res.data; |
|
|
|
that.$store.commit("login", data.token, dayjs(data.expires_time)); |
|
|
|
that.$store.commit("login", data.token, dayjs(data.expires_time)); |
|
|
|
|
|
|
|
that.$store.dispatch('userInfo', true) |
|
|
|
handleGetUserInfo(); |
|
|
|
handleGetUserInfo(); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
.catch(err => { |
|
|
|
|
|
|
|
console.log(err) |
|
|
|
uni.showToast({ |
|
|
|
uni.showToast({ |
|
|
|
title: err.msg || err.response.data.msg || err.response.data.message, |
|
|
|
title: err.msg || err.response.data.msg || err.response.data.message, |
|
|
|
icon: "none", |
|
|
|
icon: "none", |
|
|
@ -183,157 +194,215 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
async register() { |
|
|
|
async register() { |
|
|
|
var that = this; |
|
|
|
var that = this; |
|
|
|
const { |
|
|
|
const { |
|
|
|
account, |
|
|
|
account, |
|
|
|
captcha, |
|
|
|
captcha, |
|
|
|
password |
|
|
|
password |
|
|
|
} = that; |
|
|
|
} = that; |
|
|
|
try { |
|
|
|
try { |
|
|
|
await that |
|
|
|
await that |
|
|
|
.$validator({ |
|
|
|
.$validator({ |
|
|
|
account: [ |
|
|
|
account: [ |
|
|
|
required(required.message("手机号码")), |
|
|
|
required(required.message("手机号码")), |
|
|
|
chs_phone(chs_phone.message()) |
|
|
|
chs_phone(chs_phone.message()) |
|
|
|
], |
|
|
|
], |
|
|
|
captcha: [ |
|
|
|
captcha: [ |
|
|
|
required(required.message("验证码")), |
|
|
|
required(required.message("验证码")), |
|
|
|
alpha_num(alpha_num.message("验证码")) |
|
|
|
alpha_num(alpha_num.message("验证码")) |
|
|
|
], |
|
|
|
], |
|
|
|
password: [ |
|
|
|
password: [ |
|
|
|
required(required.message("密码")), |
|
|
|
required(required.message("密码")), |
|
|
|
attrs.range([6, 16], attrs.range.message("密码")), |
|
|
|
attrs.range([6, 16], attrs.range.message("密码")), |
|
|
|
alpha_num(alpha_num.message("密码")) |
|
|
|
alpha_num(alpha_num.message("密码")) |
|
|
|
] |
|
|
|
] |
|
|
|
}) |
|
|
|
}) |
|
|
|
.validate({ |
|
|
|
.validate({ |
|
|
|
account, |
|
|
|
account, |
|
|
|
captcha, |
|
|
|
captcha, |
|
|
|
password |
|
|
|
password |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
return validatorDefaultCatch(e); |
|
|
|
return validatorDefaultCatch(e); |
|
|
|
} |
|
|
|
} |
|
|
|
register({ |
|
|
|
register({ |
|
|
|
account: that.account, |
|
|
|
account: that.account, |
|
|
|
captcha: that.captcha, |
|
|
|
captcha: that.captcha, |
|
|
|
password: that.password, |
|
|
|
password: that.password, |
|
|
|
inviteCode: that.inviteCode, |
|
|
|
inviteCode: that.inviteCode, |
|
|
|
spread: cookie.get("spread") |
|
|
|
spread: cookie.get("spread") |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(res => { |
|
|
|
.then(res => { |
|
|
|
uni.showToast({ |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg, |
|
|
|
title: res.msg, |
|
|
|
icon: "success", |
|
|
|
icon: "success", |
|
|
|
duration: 2000 |
|
|
|
duration: 2000 |
|
|
|
}); |
|
|
|
}); |
|
|
|
that.formItem = 1; |
|
|
|
that.formItem = 1; |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
.catch(err => { |
|
|
|
uni.showToast({ |
|
|
|
uni.showToast({ |
|
|
|
title: err.msg || err.response.data.msg || err.response.data.message, |
|
|
|
title: err.msg || err.response.data.msg || err.response.data.message, |
|
|
|
icon: "none", |
|
|
|
icon: "none", |
|
|
|
duration: 2000 |
|
|
|
duration: 2000 |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 获取验证码 |
|
|
|
// 获取验证码 |
|
|
|
async code() { |
|
|
|
async code() { |
|
|
|
var that = this; |
|
|
|
const { |
|
|
|
const { |
|
|
|
account |
|
|
|
account |
|
|
|
} = this; |
|
|
|
} = that; |
|
|
|
try { |
|
|
|
try { |
|
|
|
await this |
|
|
|
await that |
|
|
|
.$validator({ |
|
|
|
.$validator({ |
|
|
|
account: [ |
|
|
|
account: [ |
|
|
|
required(required.message("手机号码")), |
|
|
|
required(required.message("手机号码")), |
|
|
|
chs_phone(chs_phone.message()) |
|
|
|
chs_phone(chs_phone.message()) |
|
|
|
] |
|
|
|
] |
|
|
|
}) |
|
|
|
}) |
|
|
|
.validate({ |
|
|
|
.validate({ |
|
|
|
account |
|
|
|
account |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
return validatorDefaultCatch(e); |
|
|
|
return validatorDefaultCatch(e); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.formItem == 2) this.type = "register"; |
|
|
|
if (that.formItem == 2) that.type = "register"; |
|
|
|
this.showCode() |
|
|
|
await registerVerify({ |
|
|
|
}, |
|
|
|
phone: that.account, |
|
|
|
// 手机号登录获取验证码 |
|
|
|
type: that.type |
|
|
|
async sendCode () { |
|
|
|
}) |
|
|
|
const { |
|
|
|
.then(res => { |
|
|
|
account |
|
|
|
uni.showToast({ |
|
|
|
} = this; |
|
|
|
title: res.msg, |
|
|
|
try { |
|
|
|
icon: "success", |
|
|
|
await this |
|
|
|
duration: 2000 |
|
|
|
.$validator({ |
|
|
|
}); |
|
|
|
account: [ |
|
|
|
that.sendCode(); |
|
|
|
required(required.message("手机号码")), |
|
|
|
}) |
|
|
|
chs_phone(chs_phone.message()) |
|
|
|
.catch(err => { |
|
|
|
] |
|
|
|
uni.showToast({ |
|
|
|
}) |
|
|
|
title: err.msg || err.response.data.msg || err.response.data.message, |
|
|
|
.validate({ |
|
|
|
icon: "none", |
|
|
|
account |
|
|
|
duration: 2000 |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (e) { |
|
|
|
}); |
|
|
|
return validatorDefaultCatch(e); |
|
|
|
}, |
|
|
|
} |
|
|
|
navTap: function (index) { |
|
|
|
// 倒计时 |
|
|
|
this.current = index; |
|
|
|
if (this.clock !== 60) { |
|
|
|
}, |
|
|
|
return |
|
|
|
async submit() { |
|
|
|
} |
|
|
|
const { |
|
|
|
this.clock-- |
|
|
|
account, |
|
|
|
this.clockText = `${this.clock} 秒` |
|
|
|
password |
|
|
|
this.timer = setInterval(() => { |
|
|
|
} = this; |
|
|
|
if (parseInt(this.clock) === 1) { |
|
|
|
try { |
|
|
|
clearTimeout(this.timer) |
|
|
|
await this.$validator({ |
|
|
|
this.clock = 60 |
|
|
|
account: [ |
|
|
|
this.clockText = '获取验证码' |
|
|
|
required(required.message("账号")), |
|
|
|
return |
|
|
|
attrs.range([5, 16], attrs.range.message("账号")), |
|
|
|
} |
|
|
|
alpha_num(alpha_num.message("账号")) |
|
|
|
this.clock-- |
|
|
|
], |
|
|
|
if (this.clock < 10) this.clock = `0${this.clock}` |
|
|
|
password: [ |
|
|
|
this.clockText = `${this.clock} 秒` |
|
|
|
required(required.message("密码")), |
|
|
|
}, 1000) |
|
|
|
attrs.range([6, 16], attrs.range.message("密码")), |
|
|
|
this.showCode() |
|
|
|
alpha_num(alpha_num.message("密码")) |
|
|
|
}, |
|
|
|
] |
|
|
|
// 验证码请求 |
|
|
|
}).validate({ |
|
|
|
showCode() { |
|
|
|
account, |
|
|
|
return registerVerify({ |
|
|
|
password |
|
|
|
phone: this.account, |
|
|
|
}); |
|
|
|
type: this.type |
|
|
|
} catch (e) { |
|
|
|
}) |
|
|
|
return validatorDefaultCatch(e); |
|
|
|
.then(res => { |
|
|
|
} |
|
|
|
uni.showToast({ |
|
|
|
|
|
|
|
title: res.msg, |
|
|
|
login({ |
|
|
|
icon: "success", |
|
|
|
username: account, |
|
|
|
duration: 2000 |
|
|
|
password, |
|
|
|
}); |
|
|
|
spread: cookie.get("spread") |
|
|
|
this.sendCode(); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(({ |
|
|
|
.catch(err => { |
|
|
|
data |
|
|
|
uni.showToast({ |
|
|
|
}) => { |
|
|
|
title: err.msg || err.response.data.msg || err.response.data.message, |
|
|
|
this.$store.commit("login", data.token, dayjs(data.expires_time)); |
|
|
|
icon: "none", |
|
|
|
handleGetUserInfo(); |
|
|
|
duration: 2000 |
|
|
|
// let replace=this.$yroute.query.replace |
|
|
|
}); |
|
|
|
// if(replace){ |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
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({ |
|
|
|
// this.$yrouter.replace({ |
|
|
|
// path: this.$yroute.query.replace || '/pages/home/index' |
|
|
|
// path: this.$yroute.query.replace || '/pages/home/index' |
|
|
|
// }); |
|
|
|
// }); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
.catch(err => { |
|
|
|
console.log(err); |
|
|
|
console.log(err); |
|
|
|
uni.showToast({ |
|
|
|
uni.showToast({ |
|
|
|
title: err.msg || err.response.data.msg || err.response.data.message, |
|
|
|
title: err.msg || err.response.data.msg || err.response.data.message, |
|
|
|
icon: "none", |
|
|
|
icon: "none", |
|
|
|
duration: 2000 |
|
|
|
duration: 2000 |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|
|
|
|
|
.register .whiteBg .title .item{ |
|
|
|
|
|
|
|
border-bottom: 2px solid; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.register .whiteBg .title .item.on{ |
|
|
|
|
|
|
|
border-bottom-color: #f35749; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.getPhoneCode{ |
|
|
|
|
|
|
|
display: flex; |
|
|
|
|
|
|
|
justify-content: space-between; |
|
|
|
|
|
|
|
.phoneCode{ |
|
|
|
|
|
|
|
color: #FFFFFF; |
|
|
|
|
|
|
|
background-color: #f35749; |
|
|
|
|
|
|
|
padding: 12rpx; |
|
|
|
|
|
|
|
border-radius: 30rpx; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</style> |
|
|
|