<template>
|
<view class="cp-flex-col page">
|
<view class="cp-flex-col cp-justify-start cp-items-center cp-relative group">
|
<navigator url="reg">
|
<view class="cp-flex-col cp-justify-start cp-items-center text-wrapper"><text class="font_1">注册</text></view>
|
</navigator>
|
<view class="cp-flex-col section space-y-56 pos_2">
|
<text class="cp-self-center font_1 text"> {{ config.site_title }} </text>
|
<view class="cp-flex-col space-y-31">
|
<view class="cp-flex-col space-y-27">
|
<view class="cp-flex-row cp-items-center section_2 space-x-19">
|
<image class="image_2" src="../../static/login/b17f7f0690876b2c1c9f62a06ee82d02.png" />
|
<!-- <text class="font_2 text_2">手机号/邮箱</text> -->
|
<input v-model="username" type="text" class="font_2 text_2" placeholder="手机号">
|
</view>
|
<view class="cp-flex-row cp-justify-between cp-items-center section_3">
|
<view class="cp-flex-row cp-items-center space-x-17">
|
<image class="cp-shrink-0 image_3" src="../../static/login/532d85c2bb2b38c49a37446e1b76def1.png" />
|
<input v-model="password" type="password" class="font_2 text_3" placeholder="密码">
|
</view>
|
<!-- <image class="image_4" src="../../static/login/acde9f55d278d771fe4bb0c73271082f.png" /> -->
|
</view>
|
</view>
|
<view class="cp-flex-col group_2 space-y-32">
|
<!-- <text class="cp-self-end text_4">验证码登陆</text> -->
|
<view @click="submit" class="cp-flex-col cp-justify-start cp-items-center button"><text class="text_5">登陆</text></view>
|
</view>
|
</view>
|
</view>
|
<view class="cp-flex-col cp-justify-start cp-items-center image-wrapper pos">
|
<image class="image" :src="config.logo" />
|
</view>
|
</view>
|
<view class="cp-flex-row cp-justify-center cp-items-center group_3">
|
<view class="section_4"></view>
|
<text class="font_1 text_6">快捷登录</text>
|
<view class="section_4 view"></view>
|
</view>
|
<view class="cp-flex-row cp-justify-between cp-self-center equal-division" @click="nologin">
|
<image class="equal-division-item" src="../../static/login/ff05399c7d6e9e083474a6bec24440d2.png" />
|
<image class="equal-division-item" src="../../static/login/513984f2eeec8266766b5d1bedf4386f.png" />
|
<image class="equal-division-item" src="../../static/login/32d84522d79c35d58299896595991b54.png" />
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {mapState,mapMutations} from 'vuex'
|
import mixin from "@/mixin/checkLoaded";
|
export default {
|
mixins: [mixin],
|
data() {
|
return {
|
show:true,
|
timer:null,
|
count:'',
|
username:'',
|
password:'',
|
isPass:true,//是否账号密码登录
|
array:['+86','+85','+101','+102'],
|
index:0,
|
key:'',
|
code:'',
|
mpWxCode:''
|
}
|
},
|
computed:{
|
...mapState(['config', 'tabbar'])
|
},
|
onLoad(op) {
|
// #ifdef MP
|
if(op.quickLogin){
|
this.mpPreLogin()
|
}
|
let provider = '';
|
// #ifdef MP-WEIXIN
|
provider = 'weixin';
|
// #endif
|
// #ifdef MP-QQ
|
provider = 'qq';
|
// #endif
|
uni.login({
|
provider: provider,
|
success: (res) => {
|
console.log(res)
|
if(res.errMsg == 'login:ok'){
|
this.mpWxCode = res.code
|
}
|
}
|
})
|
// #endif
|
},
|
methods: {
|
nologin() {
|
this.$failToast('待开放...')
|
},
|
mpPreLogin(){
|
let provider = '';
|
// #ifdef MP-WEIXIN
|
provider = 'weixin';
|
// #endif
|
// #ifdef MP-QQ
|
provider = 'qq';
|
// #endif
|
uni.showLoading({title:'请稍等...'})
|
uni.login({
|
provider: provider,
|
success: (res) => {
|
console.log(res)
|
if(res.errMsg == 'login:ok'){
|
// this.mpWxCode = res.code
|
let api = '/api/member/wxMpQuickLogin';
|
// #ifdef MP-WEIXIN
|
api = '/api/member/wxMpQuickLogin'
|
// #endif
|
// #ifdef MP-QQ
|
api = '/api/member/qqMpQuickLogin'
|
// #endif
|
|
this.$request(api,'POST',{
|
code:res.code
|
}).then(ret => {
|
console.log(ret)
|
uni.hideLoading()
|
if(ret.status == 200){
|
uni.showToast({
|
title:"登录成功"
|
})
|
ret.data.token = ret.token
|
uni.setStorageSync('userInfo',ret.data);
|
uni.setStorageSync('token',ret.token)
|
this.login(ret.data)
|
|
if(!ret.data.mobile){
|
uni.showModal({
|
title:"绑定手机",
|
content:"绑定手机号就可以发布内容啦!",
|
cancelText:"先跳过",
|
confirmText:"去绑定",
|
success: (rs) => {
|
if(rs.confirm){
|
uni.redirectTo({
|
url:'../regiester/regiester?bindMob=1'
|
})
|
}else{
|
uni.switchTab({
|
url:"../index/index"
|
})
|
}
|
}
|
})
|
}else{
|
uni.navigateBack({
|
delta:1
|
})
|
}
|
}
|
})
|
}
|
|
}
|
});
|
},
|
async getValidate(){
|
if(!(/^1(3|4|5|7|8)\d{9}$/.test(this.username))){
|
uni.showToast({
|
title:"请输入正确的手机号码",
|
icon:"none"
|
})
|
return false;
|
}
|
const TIME_COUNT = 60;
|
if (!this.timer) {
|
this.count = TIME_COUNT;
|
this.show = false;
|
//此处写提交获取验证码的请求
|
this.$request("/api/base/smsbao","GET",{mobile:this.username}).then(res=>{
|
if(res.status == 200){
|
uni.showToast({
|
title:res.msg,
|
icon:"none"
|
})
|
this.timer = setInterval(() => {
|
if (this.count > 0 && this.count <= TIME_COUNT) {
|
this.count--;
|
} else {
|
this.show = true;
|
clearInterval(this.timer);
|
this.timer = null;
|
}
|
}, 1000)
|
this.key = res.key
|
}else{
|
uni.showToast({
|
title:res.msg,
|
icon:"none"
|
})
|
}
|
}).catch(err=>{
|
this.$failToast()
|
})
|
this.timer = setInterval(() => {
|
if (this.count > 0 && this.count <= TIME_COUNT) {
|
this.count--;
|
} else {
|
this.show = true;
|
clearInterval(this.timer);
|
this.timer = null;
|
}
|
}, 1000)
|
}
|
},
|
click1(){
|
this.isPass?this.isPass = false : this.isPass = true
|
},
|
click2(){
|
uni.navigateTo({
|
url:"../regiester/regiester"
|
})
|
},
|
bindPickerChange(e){
|
this.index = e.target.value
|
},
|
submit(){
|
uni.showLoading({})
|
//账号密码登录
|
if(this.isPass){
|
if(!this.password || !this.username){
|
uni.hideLoading()
|
return
|
}
|
this.$request("/api/Member/login","POST",{
|
mobile:this.username,passwd:this.password
|
}).then(res=>{
|
console.log(res)
|
if(res.status == 200){
|
uni.hideLoading()
|
uni.showToast({
|
title:"登录成功"
|
})
|
res.data.token = res.token
|
uni.setStorageSync('userInfo',res.data);
|
uni.setStorageSync('token',res.token)
|
this.login(res.data)
|
setTimeout(() => {
|
uni.redirectTo({
|
url: this.tabbar.list[0].pagePath
|
})
|
}, 800);
|
} else {
|
uni.hideLoading()
|
uni.showToast({
|
title:res.msg,
|
icon:'none'
|
})
|
}
|
}).catch(err=>{
|
uni.hideLoading()
|
this.$failToast(err)
|
// console.log(err)
|
})
|
}else{
|
if(!this.code || !this.username || !this.key){
|
uni.hideLoading()
|
this.$failToast('参数错误')
|
return
|
}
|
this.$request("/api/member/validateLogin","POST",{
|
mobile:this.username,code:this.code,key:this.key
|
}).then(res=>{
|
console.log(res)
|
uni.hideLoading()
|
if(res.status == 200){
|
uni.showToast({
|
title:"登录成功"
|
})
|
res.data.token = res.token
|
uni.setStorageSync('userInfo',res.data);
|
uni.setStorageSync('token',res.token)
|
this.login(res.data)
|
setTimeout(() => {
|
uni.redirectTo({
|
url: this.tabbar.list[0].pagePath
|
})
|
}, 800);
|
}else if (res.status == 201){
|
uni.showToast({
|
title:res.msg,
|
icon:'none'
|
})
|
}
|
}).catch(err=>{
|
uni.hideLoading()
|
this.$failToast(err)
|
// console.log(err)
|
})
|
}
|
},
|
async wxMpLogin(e){
|
console.log(e)
|
uni.showLoading({})
|
// let [err,ret] = await uni.login({
|
// provider:'weixin'
|
// })
|
// console.log(ret)
|
if(!this.mpWxCode){
|
uni.hideLoading()
|
this.$failToast('第三方登录失败')
|
return
|
}
|
this.$request('/api/member/wxMpLogin','POST',{
|
code: this.mpWxCode,
|
encryptedData: e.detail.encryptedData,
|
iv: e.detail.iv
|
}).then(res => {
|
console.log(res)
|
if(res.status == 200){
|
uni.hideLoading()
|
uni.showToast({
|
title:"登录成功"
|
})
|
res.data.token = res.token
|
uni.setStorageSync('userInfo',res.data);
|
uni.setStorageSync('token',res.token)
|
this.login(res.data)
|
|
if(!res.data.mobile){
|
uni.showModal({
|
title:"绑定手机",
|
content:"绑定手机号就可以发布内容啦!",
|
cancelText:"先跳过",
|
confirmText:"去绑定",
|
success: (res) => {
|
if(res.confirm){
|
uni.redirectTo({
|
url:'../regiester/regiester?bindMob=1'
|
})
|
}else{
|
uni.switchTab({
|
url:"../index/index"
|
})
|
}
|
}
|
})
|
}else{
|
setTimeout(function() {
|
uni.switchTab({
|
url:"../index/index"
|
})
|
}, 800);
|
}
|
}else if (res.status == 201){
|
uni.showToast({
|
title:res.msg,
|
icon:'none'
|
})
|
}
|
})
|
},
|
async qqMpLogin(e){
|
console.log(e)
|
uni.showLoading({})
|
// let [err,ret] = await uni.login({
|
// provider:'qq'
|
// })
|
// console.log(ret)
|
if(!this.mpWxCode){
|
uni.hideLoading()
|
this.$failToast('第三方登录失败')
|
return
|
}
|
let user = e.detail.userInfo
|
this.$request('/api/member/qqMpLogin','POST',{
|
code: this.mpWxCode,
|
parent_id:'',
|
...user
|
}).then(res => {
|
console.log(res)
|
uni.hideLoading()
|
if(res.status == 200){
|
uni.hideLoading()
|
uni.showToast({
|
title:"登录成功"
|
})
|
res.data.token = res.token
|
uni.setStorageSync('userInfo',res.data);
|
uni.setStorageSync('token',res.token)
|
this.login(res.data)
|
|
if(!res.data.mobile){
|
uni.showModal({
|
title:"绑定手机",
|
content:"绑定手机号就可以发布内容啦!",
|
cancelText:"先跳过",
|
confirmText:"去绑定",
|
success: (res) => {
|
if(res.confirm){
|
uni.redirectTo({
|
url:'../regiester/regiester?bindMob=1'
|
})
|
}else{
|
uni.switchTab({
|
url:"../index/index"
|
})
|
}
|
}
|
})
|
}else{
|
setTimeout(function() {
|
uni.switchTab({
|
url:"../index/index"
|
})
|
}, 800);
|
}
|
}else if (res.status == 201){
|
uni.showToast({
|
title:res.msg,
|
icon:'none'
|
})
|
}
|
})
|
},
|
...mapMutations(['login'])
|
}
|
}
|
</script>
|
|
<style scoped lang="css">
|
|
html {
|
font-size: 16px;
|
}
|
|
body {
|
margin: 0;
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
|
'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
|
-webkit-font-smoothing: antialiased;
|
-moz-osx-font-smoothing: grayscale;
|
}
|
|
view,
|
image,
|
text {
|
box-sizing: border-box;
|
flex-shrink: 0;
|
}
|
|
#app {
|
width: 100vw;
|
height: 100vh;
|
}
|
|
.cp-flex-row {
|
display: flex;
|
flex-direction: row;
|
}
|
|
.cp-flex-col {
|
display: flex;
|
flex-direction: column;
|
}
|
|
.cp-justify-start {
|
justify-content: flex-start;
|
}
|
|
.cp-justify-end {
|
justify-content: flex-end;
|
}
|
|
.cp-justify-center {
|
justify-content: center;
|
}
|
|
.cp-justify-between {
|
justify-content: space-between;
|
}
|
|
.cp-justify-around {
|
justify-content: space-around;
|
}
|
|
.cp-justify-evenly {
|
justify-content: space-evenly;
|
}
|
|
.cp-items-start {
|
align-items: flex-start;
|
}
|
|
.cp-items-end {
|
align-items: flex-end;
|
}
|
|
.cp-items-center {
|
align-items: center;
|
}
|
|
.cp-items-baseline {
|
align-items: baseline;
|
}
|
|
.cp-items-stretch {
|
align-items: stretch;
|
}
|
|
.cp-self-start {
|
align-self: flex-start;
|
}
|
|
.cp-self-end {
|
align-self: flex-end;
|
}
|
|
.cp-self-center {
|
align-self: center;
|
}
|
|
.cp-self-baseline {
|
align-self: baseline;
|
}
|
|
.cp-self-stretch {
|
align-self: stretch;
|
}
|
|
.cp-flex-1 {
|
flex: 1 1 0%;
|
}
|
|
.cp-flex-auto {
|
flex: 1 1 auto;
|
}
|
|
.cp-grow {
|
flex-grow: 1;
|
}
|
|
.cp-grow-0 {
|
flex-grow: 0;
|
}
|
|
.cp-shrink {
|
flex-shrink: 1;
|
}
|
|
.cp-shrink-0 {
|
flex-shrink: 0;
|
}
|
|
.cp-relative {
|
position: relative;
|
}
|
.page {
|
padding: 127rpx 34rpx 218rpx;
|
background-image: linear-gradient(66deg, #6186fe 0%, #a23aff 100%);
|
width: 100%;
|
overflow-y: auto;
|
overflow-x: hidden;
|
height: 100vh;
|
}
|
|
.group {
|
padding-top: 650rpx;
|
}
|
|
.text-wrapper {
|
padding: 147rpx 0 21rpx;
|
background-color: #ffffff75;
|
border-radius: 30rpx;
|
width: 473rpx;
|
}
|
|
.font_1 {
|
font-size: 30rpx;
|
font-family: HiraginoSansGB;
|
line-height: 28rpx;
|
color: #ffffff;
|
}
|
|
.section {
|
padding: 118rpx 40rpx 38rpx;
|
background-color: #ffffff;
|
border-radius: 20rpx;
|
width: 536rpx;
|
}
|
|
.space-y-56>view:not(:first-child),
|
.space-y-56>text:not(:first-child),
|
.space-y-56>image:not(:first-child) {
|
margin-top: 56rpx;
|
}
|
|
.pos_2 {
|
position: absolute;
|
left: 50%;
|
top: 280rpx;
|
transform: translateX(-50%);
|
}
|
|
.text {
|
color: #333333;
|
line-height: 29rpx;
|
}
|
|
.space-y-31>view:not(:first-child),
|
.space-y-31>text:not(:first-child),
|
.space-y-31>image:not(:first-child) {
|
margin-top: 31rpx;
|
}
|
|
.space-y-27>view:not(:first-child),
|
.space-y-27>text:not(:first-child),
|
.space-y-27>image:not(:first-child) {
|
margin-top: 27rpx;
|
}
|
|
.section_2 {
|
padding: 14rpx 22rpx 10rpx;
|
border-radius: 30rpx;
|
background-image: url('../../static/login/02fdccc95ea34e937ec1edcee2d69b21.png');
|
background-size: 100% 100%;
|
background-repeat: no-repeat;
|
}
|
|
.space-x-19>view:not(:first-child),
|
.space-x-19>text:not(:first-child),
|
.space-x-19>image:not(:first-child) {
|
margin-left: 19rpx;
|
}
|
|
.image_2 {
|
width: 38rpx;
|
height: 45rpx;
|
}
|
|
.font_2 {
|
font-size: 24rpx;
|
font-family: HiraginoSansGB;
|
color: #666666;
|
}
|
|
.text_2 {
|
margin-right: 222rpx;
|
line-height: 25rpx;
|
}
|
|
.section_3 {
|
padding: 11rpx 22rpx 6rpx;
|
border-radius: 30rpx;
|
background-image: url('../../static/login/02fdccc95ea34e937ec1edcee2d69b21.png');
|
background-size: 100% 100%;
|
background-repeat: no-repeat;
|
}
|
|
.space-x-17>view:not(:first-child),
|
.space-x-17>text:not(:first-child),
|
.space-x-17>image:not(:first-child) {
|
margin-left: 17rpx;
|
}
|
|
.image_3 {
|
width: 41rpx;
|
height: 52rpx;
|
}
|
|
.text_3 {
|
line-height: 23rpx;
|
}
|
|
.image_4 {
|
width: 26rpx;
|
height: 15rpx;
|
}
|
|
.group_2 {
|
padding: 0 11rpx;
|
}
|
|
.space-y-32>view:not(:first-child),
|
.space-y-32>text:not(:first-child),
|
.space-y-32>image:not(:first-child) {
|
margin-top: 32rpx;
|
}
|
|
.text_4 {
|
color: #666666;
|
font-size: 20rpx;
|
font-family: HiraginoSansGB;
|
line-height: 22rpx;
|
text-decoration: underline;
|
}
|
|
.button {
|
padding: 16rpx 0;
|
background-image: linear-gradient(212deg, #6384fe 0%, #a13bff 100%);
|
border-radius: 30rpx;
|
width: 434rpx;
|
}
|
|
.text_5 {
|
color: #ffffff;
|
font-size: 36rpx;
|
font-family: HiraginoSansGB;
|
line-height: 33rpx;
|
}
|
|
.image-wrapper {
|
padding: 58rpx 0 63rpx;
|
background-image: url('../../static/login/0316f830b076fd836291cfb192b3ef65.png');
|
background-size: 100% 100%;
|
background-repeat: no-repeat;
|
width: 199rpx;
|
}
|
|
.pos {
|
position: absolute;
|
left: 50%;
|
top: 180rpx;
|
transform: translateX(-50%);
|
}
|
|
.image {
|
width: 147rpx;
|
height: 78rpx;
|
}
|
|
.group_3 {
|
margin-top: 93rpx;
|
}
|
|
.section_4 {
|
opacity: 0.5;
|
width: 217rpx;
|
height: 1rpx;
|
border: solid 1rpx #ffffff;
|
}
|
|
.text_6 {
|
margin-left: 20rpx;
|
}
|
|
.view {
|
margin-left: 15rpx;
|
}
|
|
.equal-division {
|
margin-top: 73rpx;
|
width: 421rpx;
|
}
|
|
.equal-division-item {
|
margin: 2rpx 0;
|
width: 70.5rpx;
|
height: 63rpx;
|
}
|
</style>
|