master
parent
34e1b67815
commit
6f3879e77c
@ -1,282 +1,282 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<image class="cbg" :src="base.imgHost('login-top.png')"></image>
|
||||
<view class="login">
|
||||
<image class="login-logo" :src="base.imgHost('login-logo.png')"></image>
|
||||
<view class="login-form">
|
||||
<view>
|
||||
<u-input :custom-style="inputStyle" :clearable="false" v-model="form.mobile"
|
||||
placeholder="手机号"></u-input>
|
||||
</view>
|
||||
<view class="sendmsg">
|
||||
<u-input v-model="form.code" :custom-style="inputSendStyle" :clearable="false"
|
||||
placeholder="验证码"></u-input>
|
||||
<view @click="getSmsCode" class="send" :class="{'hasSend':hasSend}">{{hasSend?'已发送':'获取验证码'}}<text
|
||||
v-if="hasSend">({{count}}s)</text></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="login-btn">
|
||||
<view @click="handleMsgLogin">{{ bindingComplete && fromBooking ? '返回场地预约' : bindingComplete && fromSupply ? '返回供需对接' : '登录' }}</view>
|
||||
</view>
|
||||
<view class="login-links">
|
||||
<view class="login-msg" @click="toRegister">注册账号</view>
|
||||
<view class="login-msg" @click="goHome">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { returnToSupply } from '@/common/supplyIdentity.js'
|
||||
import { returnToSurvey } from '@/common/surveyNavigation.js'
|
||||
export default {
|
||||
data() {
|
||||
return { fromSupply: false, fromBooking: false,
|
||||
survey_id: '',
|
||||
binding: false,
|
||||
bindingComplete: false,
|
||||
hasSend: false,
|
||||
isDonate:false,
|
||||
count: 60,
|
||||
inputStyle: {
|
||||
'padding': '0rpx 30rpx',
|
||||
'height': '80rpx',
|
||||
'border': '1rpx solid #dad8d8;',
|
||||
'border-radius': '20rpx'
|
||||
},
|
||||
inputSendStyle: {
|
||||
'padding': '0rpx 30rpx',
|
||||
'height': '80rpx',
|
||||
'border': '1rpx solid #dad8d8;',
|
||||
'border-radius': '20rpx 0 0 20rpx'
|
||||
},
|
||||
form: {
|
||||
mobile: '',
|
||||
code: '',
|
||||
},
|
||||
sendTimer: null,
|
||||
type: 'me'
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.fromSupply = options.from_supply === '1'
|
||||
this.fromBooking = options.from_booking === '1'
|
||||
if (/^1[3-9]\d{9}$/.test(String(options.mobile || ''))) this.form.mobile = String(options.mobile)
|
||||
this.survey_id = /^\d+$/.test(String(options.survey_id || '')) ? String(options.survey_id) : ''
|
||||
this.type = options.id ? 'course' : 'me'
|
||||
this.isDonate = options.isDonate?true:false
|
||||
},
|
||||
onUnload() {
|
||||
if (this.sendTimer) {
|
||||
clearInterval(this.sendTimer);
|
||||
this.sendTimer = null
|
||||
}
|
||||
},
|
||||
onHide() {
|
||||
if (this.sendTimer) {
|
||||
clearInterval(this.sendTimer);
|
||||
this.sendTimer = null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getSmsCode() {
|
||||
if (this.hasSend) {
|
||||
return
|
||||
}
|
||||
if (this.base.isNull(this.form.mobile)) {
|
||||
this.base.toast('手机号码不能为空')
|
||||
return
|
||||
}
|
||||
if (!this.base.isMobile(this.form.mobile)) {
|
||||
this.base.toast('手机号码错误')
|
||||
return
|
||||
}
|
||||
let that = this
|
||||
this.$u.api.sendSms({
|
||||
mobile: this.form.mobile
|
||||
}).then(res => {
|
||||
this.base.toast("发送成功")
|
||||
this.hasSend = true
|
||||
this.sendTimer = setInterval(function() {
|
||||
if (that.count > 1) {
|
||||
that.count--
|
||||
} else {
|
||||
clearInterval(that.sendTimer);
|
||||
that.sendTimer = null
|
||||
that.count = 60
|
||||
that.hasSend = false;
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
},
|
||||
handleMsgLogin() {
|
||||
if (this.binding) return
|
||||
if (this.bindingComplete && (this.fromSupply || this.fromBooking)) return returnToSupply(this).catch(() => this.base.toast('返回页面失败,请重试'))
|
||||
if (this.bindingComplete && this.survey_id) {
|
||||
this.binding = true
|
||||
return returnToSurvey(this.survey_id).catch(() => this.base.toast('返回问卷失败,请重试')).finally(() => { this.binding = false })
|
||||
}
|
||||
if (this.base.isNull(this.form.mobile)) {
|
||||
this.base.toast('请输入手机号')
|
||||
return
|
||||
}
|
||||
if (this.base.isNull(this.form.code)) {
|
||||
this.base.toast('请输入验证码')
|
||||
return
|
||||
}
|
||||
let that = this
|
||||
this.binding = true
|
||||
return this.$u.api.checkMobile({
|
||||
mobile: this.form.mobile,
|
||||
code: this.form.code
|
||||
}).then(async res => {
|
||||
if (!res || !res.token) throw new Error('绑定未成功')
|
||||
this.bindingComplete = true
|
||||
this.$u.vuex('vuex_token', res.token)
|
||||
this.base.toast('绑定成功')
|
||||
if (that.sendTimer) {
|
||||
clearInterval(that.sendTimer);
|
||||
that.hasSend = false;
|
||||
}
|
||||
uni.removeStorageSync("stbc1_lifeData")
|
||||
uni.setStorageSync("stbc1_lifeData", {
|
||||
'vuex_token': res.token
|
||||
})
|
||||
|
||||
if (that.fromSupply || that.fromBooking) { await returnToSupply(that) } else if (that.survey_id) {
|
||||
await returnToSurvey(that.survey_id)
|
||||
} else if (that.type == 'course') {
|
||||
uni.switchTab({
|
||||
url: '/pages/course/index'
|
||||
})
|
||||
} else if (that.isDonate) {
|
||||
uni.redirectTo({
|
||||
url: '/packages/donate/index'
|
||||
})
|
||||
} else {
|
||||
uni.switchTab({
|
||||
url: '/pages/me/index'
|
||||
})
|
||||
}
|
||||
// this.$u.api.user().then(res => {
|
||||
// this.$u.vuex('vuex_user', res.user)
|
||||
|
||||
// })
|
||||
}).catch(() => {
|
||||
this.base.toast(this.bindingComplete ? (this.fromBooking ? '登录已成功,返回场地预约失败,请重试' : this.fromSupply ? '登录已成功,返回供需对接失败,请重试' : '绑定已成功,返回问卷失败,请重试') : '绑定未完成,请检查提示后重试')
|
||||
}).finally(() => { this.binding = false })
|
||||
},
|
||||
toRegister() {
|
||||
uni.redirectTo({
|
||||
url: '/packages/register/index' + (this.fromBooking ? '?from_booking=1' : this.fromSupply ? '?from_supply=1' : this.survey_id ? '?survey_id=' + this.survey_id : '')
|
||||
})
|
||||
},
|
||||
goHome() {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
overflow: scroll;
|
||||
background: #fefcf7;
|
||||
position: relative;
|
||||
|
||||
.cbg {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 509rpx;
|
||||
height: 369rpx;
|
||||
}
|
||||
|
||||
.login {
|
||||
width: 590rpx;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
&-logo {
|
||||
width: 345rpx;
|
||||
height: 72rpx;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&-form {
|
||||
margin: 100rpx 0;
|
||||
|
||||
&>view {
|
||||
border-radius: 20rpx;
|
||||
|
||||
&:first-child {
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.sendmsg {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
u-input {
|
||||
width: calc(100% - 200rpx);
|
||||
|
||||
}
|
||||
|
||||
.send {
|
||||
background: #c69c6d;
|
||||
color: #fff;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 0 20rpx 20rpx 0;
|
||||
width: 200rpx;
|
||||
text-align: center;
|
||||
border: 1px solid #c69c6d;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.hasSend {
|
||||
background: #dad8d8;
|
||||
color: #333;
|
||||
border: 1px solid #dad8d8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-btn {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
&>view {
|
||||
width: 70%;
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
color: #fff;
|
||||
background: linear-gradient(to right, #e4cdb4, #c69c6d);
|
||||
border-radius: 30rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
&-msg {
|
||||
padding: 20rpx 20rpx;
|
||||
color: #0d0398;
|
||||
}
|
||||
|
||||
&-links {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
<template>
|
||||
<view class="container">
|
||||
<image class="cbg" :src="base.imgHost('login-top.png')"></image>
|
||||
<view class="login">
|
||||
<image class="login-logo" :src="base.imgHost('login-logo.png')"></image>
|
||||
<view class="login-form">
|
||||
<view>
|
||||
<u-input :custom-style="inputStyle" :clearable="false" v-model="form.mobile"
|
||||
placeholder="手机号"></u-input>
|
||||
</view>
|
||||
<view class="sendmsg">
|
||||
<u-input v-model="form.code" :custom-style="inputSendStyle" :clearable="false"
|
||||
placeholder="验证码"></u-input>
|
||||
<view @click="getSmsCode" class="send" :class="{'hasSend':hasSend}">{{hasSend?'已发送':'获取验证码'}}<text
|
||||
v-if="hasSend">({{count}}s)</text></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="login-btn">
|
||||
<view @click="handleMsgLogin">{{ bindingComplete && fromBooking ? '返回场地预约' : bindingComplete && fromSupply ? '返回供需对接' : '登录' }}</view>
|
||||
</view>
|
||||
<view class="login-links">
|
||||
<view class="login-msg" @click="toRegister">注册账号</view>
|
||||
<view class="login-msg" @click="goHome">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { returnToSupply } from '@/common/supplyIdentity.js'
|
||||
import { returnToSurvey } from '@/common/surveyNavigation.js'
|
||||
export default {
|
||||
data() {
|
||||
return { fromSupply: false, fromBooking: false,
|
||||
survey_id: '',
|
||||
binding: false,
|
||||
bindingComplete: false,
|
||||
hasSend: false,
|
||||
isDonate:false,
|
||||
count: 60,
|
||||
inputStyle: {
|
||||
'padding': '0rpx 30rpx',
|
||||
'height': '80rpx',
|
||||
'border': '1rpx solid #dad8d8;',
|
||||
'border-radius': '20rpx'
|
||||
},
|
||||
inputSendStyle: {
|
||||
'padding': '0rpx 30rpx',
|
||||
'height': '80rpx',
|
||||
'border': '1rpx solid #dad8d8;',
|
||||
'border-radius': '20rpx 0 0 20rpx'
|
||||
},
|
||||
form: {
|
||||
mobile: '',
|
||||
code: '',
|
||||
},
|
||||
sendTimer: null,
|
||||
type: 'me'
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.fromSupply = options.from_supply === '1'
|
||||
this.fromBooking = options.from_booking === '1'
|
||||
if (/^1[3-9]\d{9}$/.test(String(options.mobile || ''))) this.form.mobile = String(options.mobile)
|
||||
this.survey_id = /^\d+$/.test(String(options.survey_id || '')) ? String(options.survey_id) : ''
|
||||
this.type = options.id ? 'course' : 'me'
|
||||
this.isDonate = options.isDonate?true:false
|
||||
},
|
||||
onUnload() {
|
||||
if (this.sendTimer) {
|
||||
clearInterval(this.sendTimer);
|
||||
this.sendTimer = null
|
||||
}
|
||||
},
|
||||
onHide() {
|
||||
if (this.sendTimer) {
|
||||
clearInterval(this.sendTimer);
|
||||
this.sendTimer = null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getSmsCode() {
|
||||
if (this.hasSend) {
|
||||
return
|
||||
}
|
||||
if (this.base.isNull(this.form.mobile)) {
|
||||
this.base.toast('手机号码不能为空')
|
||||
return
|
||||
}
|
||||
if (!this.base.isMobile(this.form.mobile)) {
|
||||
this.base.toast('手机号码错误')
|
||||
return
|
||||
}
|
||||
let that = this
|
||||
this.$u.api.sendSms({
|
||||
mobile: this.form.mobile
|
||||
}).then(res => {
|
||||
this.base.toast("发送成功")
|
||||
this.hasSend = true
|
||||
this.sendTimer = setInterval(function() {
|
||||
if (that.count > 1) {
|
||||
that.count--
|
||||
} else {
|
||||
clearInterval(that.sendTimer);
|
||||
that.sendTimer = null
|
||||
that.count = 60
|
||||
that.hasSend = false;
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
},
|
||||
handleMsgLogin() {
|
||||
if (this.binding) return
|
||||
if (this.bindingComplete && (this.fromSupply || this.fromBooking)) return returnToSupply(this).catch(() => this.base.toast('返回页面失败,请重试'))
|
||||
if (this.bindingComplete && this.survey_id) {
|
||||
this.binding = true
|
||||
return returnToSurvey(this.survey_id).catch(() => this.base.toast('返回问卷失败,请重试')).finally(() => { this.binding = false })
|
||||
}
|
||||
if (this.base.isNull(this.form.mobile)) {
|
||||
this.base.toast('请输入手机号')
|
||||
return
|
||||
}
|
||||
if (this.base.isNull(this.form.code)) {
|
||||
this.base.toast('请输入验证码')
|
||||
return
|
||||
}
|
||||
let that = this
|
||||
this.binding = true
|
||||
return this.$u.api.checkMobile({
|
||||
mobile: this.form.mobile,
|
||||
code: this.form.code
|
||||
}).then(async res => {
|
||||
if (!res || !res.token) throw new Error('绑定未成功')
|
||||
this.bindingComplete = true
|
||||
this.$u.vuex('vuex_token', res.token)
|
||||
this.base.toast('绑定成功')
|
||||
if (that.sendTimer) {
|
||||
clearInterval(that.sendTimer);
|
||||
that.hasSend = false;
|
||||
}
|
||||
uni.removeStorageSync("stbc1_lifeData")
|
||||
uni.setStorageSync("stbc1_lifeData", {
|
||||
'vuex_token': res.token
|
||||
})
|
||||
|
||||
if (that.fromSupply || that.fromBooking) { await returnToSupply(that) } else if (that.survey_id) {
|
||||
await returnToSurvey(that.survey_id)
|
||||
} else if (that.type == 'course') {
|
||||
uni.switchTab({
|
||||
url: '/pages/course/index'
|
||||
})
|
||||
} else if (that.isDonate) {
|
||||
uni.redirectTo({
|
||||
url: '/packages/donate/index'
|
||||
})
|
||||
} else {
|
||||
uni.switchTab({
|
||||
url: '/pages/me/index'
|
||||
})
|
||||
}
|
||||
// this.$u.api.user().then(res => {
|
||||
// this.$u.vuex('vuex_user', res.user)
|
||||
|
||||
// })
|
||||
}).catch(() => {
|
||||
this.base.toast(this.bindingComplete ? (this.fromBooking ? '登录已成功,返回场地预约失败,请重试' : this.fromSupply ? '登录已成功,返回供需对接失败,请重试' : '绑定已成功,返回问卷失败,请重试') : '绑定未完成,请检查提示后重试')
|
||||
}).finally(() => { this.binding = false })
|
||||
},
|
||||
toRegister() {
|
||||
uni.redirectTo({
|
||||
url: '/packages/register/index' + (this.fromBooking ? '?from_booking=1' : this.fromSupply ? '?from_supply=1' : this.survey_id ? '?survey_id=' + this.survey_id : '')
|
||||
})
|
||||
},
|
||||
goHome() {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
overflow: scroll;
|
||||
background: #fefcf7;
|
||||
position: relative;
|
||||
|
||||
.cbg {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 509rpx;
|
||||
height: 369rpx;
|
||||
}
|
||||
|
||||
.login {
|
||||
width: 590rpx;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
&-logo {
|
||||
width: 345rpx;
|
||||
height: 72rpx;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&-form {
|
||||
margin: 100rpx 0;
|
||||
|
||||
&>view {
|
||||
border-radius: 20rpx;
|
||||
|
||||
&:first-child {
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.sendmsg {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
u-input {
|
||||
width: calc(100% - 200rpx);
|
||||
|
||||
}
|
||||
|
||||
.send {
|
||||
background: #c69c6d;
|
||||
color: #fff;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 0 20rpx 20rpx 0;
|
||||
width: 200rpx;
|
||||
text-align: center;
|
||||
border: 1px solid #c69c6d;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.hasSend {
|
||||
background: #dad8d8;
|
||||
color: #333;
|
||||
border: 1px solid #dad8d8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-btn {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
&>view {
|
||||
width: 70%;
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
color: #fff;
|
||||
background: linear-gradient(to right, #e4cdb4, #c69c6d);
|
||||
border-radius: 30rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
&-msg {
|
||||
padding: 20rpx 20rpx;
|
||||
color: #0d0398;
|
||||
}
|
||||
|
||||
&-links {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in new issue