39 changed files with 697 additions and 583 deletions
@ -1,3 +1,4 @@ |
|||||||
|
|
||||||
|
// export const VUE_APP_API_URL = 'http://natapp.xinxintuan.co/api';
|
||||||
export const VUE_APP_API_URL = 'https://h5api.dayouqiantu.cn/api'; |
export const VUE_APP_API_URL = 'https://h5api.dayouqiantu.cn/api'; |
||||||
export const VUE_APP_RESOURCES_URL = 'https://h5.dayouqiantu.cn/static'; |
export const VUE_APP_RESOURCES_URL = 'https://h5.dayouqiantu.cn/static'; |
||||||
|
@ -1,340 +1,329 @@ |
|||||||
<template> |
<template> |
||||||
<view class="register absolute"> |
<view class="register absolute"> |
||||||
<view class="shading"> |
<view class="shading"> |
||||||
<view class="pictrue acea-row row-center-wrapper"> |
<view class="pictrue acea-row row-center-wrapper"> |
||||||
<image src="@/static/images/logo.png" /> |
<image src="@/static/images/logo.png" /> |
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||
<view class="whiteBg" v-if="formItem === 1"> |
<view class="whiteBg" v-if="formItem === 1"> |
||||||
<view class="title acea-row row-center-wrapper"> |
<view class="title acea-row row-center-wrapper"> |
||||||
<view class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList" @click="navTap(index)" |
<view |
||||||
:key="index">{{ item }}</view> |
class="item" |
||||||
</view> |
:class="current === index ? 'on' : ''" |
||||||
<view class="list" :hidden="current !== 0"> |
v-for="(item, index) in navList" |
||||||
<form @submit.prevent="submit"> |
@click="navTap(index)" |
||||||
<view class="item"> |
:key="index" |
||||||
<view class="acea-row row-between-wrapper"> |
>{{ item }}</view> |
||||||
<!-- <svg class="icon" aria-hidden="true"> |
</view> |
||||||
|
<view class="list" :hidden="current !== 0"> |
||||||
|
<form @submit.prevent="submit"> |
||||||
|
<view class="item"> |
||||||
|
<view class="acea-row row-between-wrapper"> |
||||||
|
<!-- <svg class="icon" aria-hidden="true"> |
||||||
<use xlink:href="#icon-phone_" /> |
<use xlink:href="#icon-phone_" /> |
||||||
</svg> --> |
</svg>--> |
||||||
<input type="text" placeholder="输入手机号码" v-model="account" required /> |
<input type="text" placeholder="输入手机号码" v-model="account" required /> |
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||
<view class="item"> |
<view class="item"> |
||||||
<view class="acea-row row-between-wrapper"> |
<view class="acea-row row-between-wrapper"> |
||||||
<!-- <svg class="icon" aria-hidden="true"> |
<!-- <svg class="icon" aria-hidden="true"> |
||||||
<use xlink:href="#icon-code_" /> |
<use xlink:href="#icon-code_" /> |
||||||
</svg> --> |
</svg>--> |
||||||
<input type="password" placeholder="填写登录密码" v-model="password" 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"> |
||||||
<!-- <svg class="icon" aria-hidden="true"> |
<!-- <svg class="icon" aria-hidden="true"> |
||||||
<use xlink:href="#icon-phone_" /> |
<use xlink:href="#icon-phone_" /> |
||||||
</svg> --> |
</svg>--> |
||||||
<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="align-left"> |
<view class="align-left"> |
||||||
<!-- <svg class="icon" aria-hidden="true"> |
<!-- <svg class="icon" aria-hidden="true"> |
||||||
<use xlink:href="#icon-code_1" /> |
<use xlink:href="#icon-code_1" /> |
||||||
</svg> --> |
</svg>--> |
||||||
<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' : ''" @click="code">{{ text }}</button> |
<button |
||||||
</view> |
class="code" |
||||||
</view> |
:disabled="disabled" |
||||||
</view> |
:class="disabled === true ? 'on' : ''" |
||||||
<view class="logon" @click="loginMobile" :hidden="current !== 1">登录</view> |
@click="code" |
||||||
<view class="logon" @click="submit" :hidden="current === 1">登录</view> |
>{{ text }}</button> |
||||||
<view class="tip"> |
</view> |
||||||
没有账号? |
</view> |
||||||
<text @click="formItem = 2" class="font-color-red">立即注册</text> |
</view> |
||||||
</view> |
<view class="logon" @click="loginMobile" :hidden="current !== 1">登录</view> |
||||||
</view> |
<view class="logon" @click="submit" :hidden="current === 1">登录</view> |
||||||
<view class="whiteBg" v-else> |
<view class="tip"> |
||||||
<view class="title">注册账号</view> |
没有账号? |
||||||
<view class="list"> |
<text @click="formItem = 2" class="font-color-red">立即注册</text> |
||||||
<view class="item"> |
</view> |
||||||
<view> |
</view> |
||||||
<!-- <svg class="icon" aria-hidden="true"> |
<view class="whiteBg" v-else> |
||||||
|
<view class="title">注册账号</view> |
||||||
|
<view class="list"> |
||||||
|
<view class="item"> |
||||||
|
<view> |
||||||
|
<!-- <svg class="icon" aria-hidden="true"> |
||||||
<use xlink:href="#icon-phone_" /> |
<use xlink:href="#icon-phone_" /> |
||||||
</svg> --> |
</svg>--> |
||||||
<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="align-left"> |
<view class="align-left"> |
||||||
<!-- <svg class="icon" aria-hidden="true"> |
<!-- <svg class="icon" aria-hidden="true"> |
||||||
<use xlink:href="#icon-code_1" /> |
<use xlink:href="#icon-code_1" /> |
||||||
</svg> --> |
</svg>--> |
||||||
<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' : ''" @click="code">{{ text }}</button> |
<button |
||||||
</view> |
class="code" |
||||||
</view> |
:disabled="disabled" |
||||||
<view class="item"> |
:class="disabled === true ? 'on' : ''" |
||||||
<view> |
@click="code" |
||||||
<!-- <svg class="icon" aria-hidden="true"> |
>{{ text }}</button> |
||||||
|
</view> |
||||||
|
</view> |
||||||
|
<view class="item"> |
||||||
|
<view> |
||||||
|
<!-- <svg class="icon" aria-hidden="true"> |
||||||
<use xlink:href="#icon-code_" /> |
<use xlink:href="#icon-code_" /> |
||||||
</svg> --> |
</svg>--> |
||||||
<input type="password" placeholder="填写您的登录密码" v-model="password" /> |
<input type="password" placeholder="填写您的登录密码" v-model="password" /> |
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||
<view class="item"> |
<view class="item"> |
||||||
<view> |
<view> |
||||||
<!-- <svg class="icon" aria-hidden="true"> |
<!-- <svg class="icon" aria-hidden="true"> |
||||||
<use xlink:href="#icon-phone_" /> |
<use xlink:href="#icon-phone_" /> |
||||||
</svg> --> |
</svg>--> |
||||||
<input type="text" placeholder="输入邀请码" v-model="inviteCode" /> |
<input type="text" placeholder="输入邀请码" v-model="inviteCode" /> |
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||
<view class="logon" @click="register">注册</view> |
<view class="logon" @click="register">注册</view> |
||||||
<view class="tip"> |
<view class="tip"> |
||||||
已有账号? |
已有账号? |
||||||
<text @click="formItem = 1" class="font-color-red">立即登录</text> |
<text @click="formItem = 1" class="font-color-red">立即登录</text> |
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||
<view class="bottom"></view> |
<view class="bottom"></view> |
||||||
</view> |
</view> |
||||||
</template> |
</template> |
||||||
<script> |
<script> |
||||||
import sendVerifyCode from "@/mixins/SendVerifyCode"; |
import sendVerifyCode from "@/mixins/SendVerifyCode"; |
||||||
import { |
import { login, loginMobile, registerVerify, register } from "@/api/user"; |
||||||
login, |
import attrs, { required, alpha_num, chs_phone } from "@/utils/validate"; |
||||||
loginMobile, |
import { validatorDefaultCatch } from "@/utils/dialog"; |
||||||
registerVerify, |
import dayjs from "dayjs"; |
||||||
register |
import cookie from "@/utils/store/cookie"; |
||||||
} from "@/api/user"; |
|
||||||
import attrs, { |
|
||||||
required, |
|
||||||
alpha_num, |
|
||||||
chs_phone |
|
||||||
} from "@/utils/validate"; |
|
||||||
import { |
|
||||||
validatorDefaultCatch |
|
||||||
} from "@/utils/dialog"; |
|
||||||
import dayjs from "dayjs"; |
|
||||||
import cookie from "@/utils/store/cookie"; |
|
||||||
|
|
||||||
import { |
import { handleGetUserInfo } from "@/utils"; |
||||||
handleGetUserInfo |
|
||||||
} from '@/utils' |
|
||||||
|
|
||||||
const BACK_URL = "login_back_url"; |
const BACK_URL = "login_back_url"; |
||||||
|
|
||||||
export default { |
export default { |
||||||
name: "Login", |
name: "Login", |
||||||
mixins: [sendVerifyCode], |
mixins: [sendVerifyCode], |
||||||
data: function() { |
data: function() { |
||||||
return { |
return { |
||||||
navList: ["账号登录"], |
navList: ["账号登录"], |
||||||
current: 0, |
current: 0, |
||||||
account: "", |
account: "", |
||||||
password: "", |
password: "", |
||||||
captcha: "", |
captcha: "", |
||||||
inviteCode:"", |
inviteCode: "", |
||||||
formItem: 1, |
formItem: 1, |
||||||
type: "login" |
type: "login" |
||||||
}; |
}; |
||||||
}, |
}, |
||||||
methods: { |
methods: { |
||||||
async loginMobile() { |
async loginMobile() { |
||||||
var that = this; |
var that = this; |
||||||
const { |
const { account, captcha } = that; |
||||||
account, |
try { |
||||||
captcha |
await that |
||||||
} = that; |
.$validator({ |
||||||
try { |
account: [ |
||||||
await that |
required(required.message("手机号码")), |
||||||
.$validator({ |
chs_phone(chs_phone.message()) |
||||||
account: [ |
], |
||||||
required(required.message("手机号码")), |
captcha: [ |
||||||
chs_phone(chs_phone.message()) |
required(required.message("验证码")), |
||||||
], |
alpha_num(alpha_num.message("验证码")) |
||||||
captcha: [ |
] |
||||||
required(required.message("验证码")), |
}) |
||||||
alpha_num(alpha_num.message("验证码")) |
.validate({ |
||||||
] |
account, |
||||||
}) |
captcha |
||||||
.validate({ |
}); |
||||||
account, |
} catch (e) { |
||||||
captcha |
return validatorDefaultCatch(e); |
||||||
}); |
} |
||||||
} catch (e) { |
loginMobile({ |
||||||
return validatorDefaultCatch(e); |
phone: that.account, |
||||||
} |
captcha: that.captcha, |
||||||
loginMobile({ |
spread: cookie.get("spread") |
||||||
phone: that.account, |
}) |
||||||
captcha: that.captcha, |
.then(res => { |
||||||
spread: cookie.get("spread") |
var data = res.data; |
||||||
}) |
that.$store.commit("LOGIN", data.token, dayjs(data.expires_time)); |
||||||
.then(res => { |
handleGetUserInfo(); |
||||||
var data = res.data; |
}) |
||||||
that.$store.commit("LOGIN", data.token, dayjs(data.expires_time)); |
.catch(err => { |
||||||
handleGetUserInfo() |
uni.showToast({ |
||||||
}) |
title: err.msg || err.response.data.msg|| err.response.data.message, |
||||||
.catch(err => { |
icon: "none", |
||||||
uni.showToast({ |
duration: 2000 |
||||||
title: err.msg || err.response.data.msg, |
}); |
||||||
icon: 'none', |
}); |
||||||
duration: 2000 |
}, |
||||||
}); |
async register() { |
||||||
}); |
var that = this; |
||||||
}, |
const { account, captcha, password } = that; |
||||||
async register() { |
try { |
||||||
var that = this; |
await that |
||||||
const { |
.$validator({ |
||||||
account, |
account: [ |
||||||
captcha, |
required(required.message("手机号码")), |
||||||
password |
chs_phone(chs_phone.message()) |
||||||
} = that; |
], |
||||||
try { |
captcha: [ |
||||||
await that |
required(required.message("验证码")), |
||||||
.$validator({ |
alpha_num(alpha_num.message("验证码")) |
||||||
account: [ |
], |
||||||
required(required.message("手机号码")), |
password: [ |
||||||
chs_phone(chs_phone.message()) |
required(required.message("密码")), |
||||||
], |
attrs.range([6, 16], attrs.range.message("密码")), |
||||||
captcha: [ |
alpha_num(alpha_num.message("密码")) |
||||||
required(required.message("验证码")), |
] |
||||||
alpha_num(alpha_num.message("验证码")) |
}) |
||||||
], |
.validate({ |
||||||
password: [ |
account, |
||||||
required(required.message("密码")), |
captcha, |
||||||
attrs.range([6, 16], attrs.range.message("密码")), |
password |
||||||
alpha_num(alpha_num.message("密码")) |
}); |
||||||
] |
} catch (e) { |
||||||
}) |
return validatorDefaultCatch(e); |
||||||
.validate({ |
} |
||||||
account, |
register({ |
||||||
captcha, |
account: that.account, |
||||||
password |
captcha: that.captcha, |
||||||
}); |
password: that.password, |
||||||
} catch (e) { |
inviteCode: that.inviteCode, |
||||||
return validatorDefaultCatch(e); |
spread: cookie.get("spread") |
||||||
} |
}) |
||||||
register({ |
.then(res => { |
||||||
account: that.account, |
uni.showToast({ |
||||||
captcha: that.captcha, |
title: res.msg, |
||||||
password: that.password, |
icon: "success", |
||||||
inviteCode: that.inviteCode, |
duration: 2000 |
||||||
spread: cookie.get("spread") |
}); |
||||||
}) |
that.formItem = 1; |
||||||
.then(res => { |
}) |
||||||
uni.showToast({ |
.catch(err => { |
||||||
title: res.msg, |
uni.showToast({ |
||||||
icon: "success", |
title: err.msg || err.response.data.msg|| err.response.data.message, |
||||||
duration: 2000 |
icon: "none", |
||||||
}); |
duration: 2000 |
||||||
that.formItem = 1; |
}); |
||||||
}) |
}); |
||||||
.catch(err => { |
}, |
||||||
uni.showToast({ |
async code() { |
||||||
title: err.msg || err.response.data.msg, |
var that = this; |
||||||
icon: "none", |
const { account } = that; |
||||||
duration: 2000 |
try { |
||||||
}); |
await that |
||||||
}); |
.$validator({ |
||||||
}, |
account: [ |
||||||
async code() { |
required(required.message("手机号码")), |
||||||
var that = this; |
chs_phone(chs_phone.message()) |
||||||
const { |
] |
||||||
account |
}) |
||||||
} = that; |
.validate({ |
||||||
try { |
account |
||||||
await that |
}); |
||||||
.$validator({ |
} catch (e) { |
||||||
account: [ |
return validatorDefaultCatch(e); |
||||||
required(required.message("手机号码")), |
} |
||||||
chs_phone(chs_phone.message()) |
if (that.formItem == 2) that.type = "register"; |
||||||
] |
await registerVerify({ |
||||||
}) |
phone: that.account, |
||||||
.validate({ |
type: that.type |
||||||
account |
}) |
||||||
}); |
.then(res => { |
||||||
} catch (e) { |
uni.showToast({ |
||||||
return validatorDefaultCatch(e); |
title: res.msg, |
||||||
} |
icon: "success", |
||||||
if (that.formItem == 2) that.type = "register"; |
duration: 2000 |
||||||
await registerVerify({ |
}); |
||||||
phone: that.account, |
that.sendCode(); |
||||||
type: that.type |
}) |
||||||
}) |
.catch(err => { |
||||||
.then(res => { |
uni.showToast({ |
||||||
uni.showToast({ |
title: err.msg || err.response.data.msg|| err.response.data.message, |
||||||
title: res.msg, |
icon: "none", |
||||||
icon: "success", |
duration: 2000 |
||||||
duration: 2000 |
}); |
||||||
}); |
}); |
||||||
that.sendCode(); |
}, |
||||||
}) |
navTap: function(index) { |
||||||
.catch(err => { |
this.current = index; |
||||||
uni.showToast({ |
}, |
||||||
title: err.msg || err.response.data.msg, |
async submit() { |
||||||
icon: "none", |
const { account, password } = this; |
||||||
duration: 2000 |
try { |
||||||
}); |
await this.$validator({ |
||||||
}); |
account: [ |
||||||
}, |
required(required.message("账号")), |
||||||
navTap: function(index) { |
attrs.range([5, 16], attrs.range.message("账号")), |
||||||
this.current = index; |
alpha_num(alpha_num.message("账号")) |
||||||
}, |
], |
||||||
async submit() { |
password: [ |
||||||
const { |
required(required.message("密码")), |
||||||
account, |
attrs.range([6, 16], attrs.range.message("密码")), |
||||||
password |
alpha_num(alpha_num.message("密码")) |
||||||
} = this; |
] |
||||||
try { |
}).validate({ |
||||||
await this.$validator({ |
account, |
||||||
account: [ |
password |
||||||
required(required.message("账号")), |
}); |
||||||
attrs.range([5, 16], attrs.range.message("账号")), |
} catch (e) { |
||||||
alpha_num(alpha_num.message("账号")) |
return validatorDefaultCatch(e); |
||||||
], |
} |
||||||
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({ |
login({ |
||||||
username: account, |
username: account, |
||||||
password, |
password, |
||||||
spread: cookie.get("spread") |
spread: cookie.get("spread") |
||||||
}) |
}) |
||||||
.then(({ |
.then(({ data }) => { |
||||||
data |
this.$store.commit("LOGIN", data.token, dayjs(data.expires_time)); |
||||||
}) => { |
handleGetUserInfo(); |
||||||
this.$store.commit("LOGIN", data.token, dayjs(data.expires_time)); |
// let replace=this.$yroute.query.replace |
||||||
handleGetUserInfo() |
// if(replace){ |
||||||
// 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 => { |
||||||
uni.showToast({ |
console.log(err); |
||||||
title: err.msg || err.response.data.msg, |
uni.showToast({ |
||||||
icon: "none", |
title: err.msg || err.response.data.msg|| err.response.data.message, |
||||||
duration: 2000 |
icon: "none", |
||||||
}); |
duration: 2000 |
||||||
}); |
}); |
||||||
} |
}); |
||||||
} |
} |
||||||
}; |
} |
||||||
|
}; |
||||||
</script> |
</script> |
||||||
|
Loading…
Reference in new issue