4c11fc3e by 杨炀

Merge commit '77c7322e'

2 parents 882dddb0 77c7322e
......@@ -28,9 +28,8 @@ function pcLogin(data) {
method: 'post',
params: data
}).then((res) => {
uni.setStorageSync('userName', data.username)
uni.setStorageSync('token', 'Bearer ' + res.data.token)
})
}).then(getInfo)
}
function h5Login(userName) {
......@@ -42,7 +41,7 @@ function h5Login(userName) {
}
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
})
}).then(getInfo)
}
function h5LoginAuto() {
......@@ -205,6 +204,60 @@ function getCodeImg() {
})
}
// 代退图形认证的获取手机验证码
function getSmsCode(data) {
return request({
url: '/captchaSmsWithCaptchaImage',
method: 'post',
params: data
})
}
function loginByPhone(phonenumber, code) {
const data = {
phonenumber,
code
}
return request({
url: '/userLoginByPhone',
method: 'post',
params: data
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
}).then(getInfo)
}
// 获取用户详细信息
function getInfo() {
return request({
url: '/getInfo',
method: 'get'
}).then(res => {
const app = getApp()
const user = res.data.user
uni.setStorageSync('userName', user.userName)
switch (user.dept.deptType) {
case '1': // 中跆协
app.globalData.userType = '1'
break
case '2': // 省
case '3':
app.globalData.userType = '2'
break
case '6': // 道馆
app.globalData.userType = '4'
break
default: // 市、区
app.globalData.userType = '3'
break
}
app.globalData.userInfo = user
})
}
export {
getNowOpenId,
wxLogin,
......@@ -215,6 +268,8 @@ export {
checkUserAuth,
initData,
getCodeImg,
getSmsCode,
h5Login,
h5LoginAuto
h5LoginAuto,
loginByPhone
}
......
......@@ -31,17 +31,20 @@
<form v-if="isActive==1">
<view class="round-input-item">
<image class="icon" src="@/static/login/tag01@2x.png"></image>
<input placeholder="请输入手机号" />
<uni-easyinput placeholder="请输入手机号" v-model="form2.telNo" />
</view>
<view class="round-input-item">
<image class="icon" src="@/static/login/tag02@2x.png"></image>
<input placeholder="图形验证码" />
<image />
<uni-easyinput placeholder="图形验证码" v-model="form2.captcha" />
<image :src="codeUrl" @click="getCode" />
</view>
<view class="round-input-item">
<image class="icon" src="@/static/login/tag04@2x.png"></image>
<input placeholder="短信验证码" />
<text>获取验证码</text>
<uni-easyinput placeholder="短信验证码" v-model="form2.code" />
<text v-if="!countDown.start" @click="getCaptchaSms">获取验证码</text>
<uni-countdown v-if="countDown.start" color="#014A9F" :show-day="false" :show-hour="false"
:show-min="false" @timeup="timeup" :start="countDown.start"
:second="countDown.second"></uni-countdown>
</view>
</form>
......@@ -68,9 +71,9 @@
</view>
<image class="ren2" src="@/static/login/ren2.png" />
<view class="fixedagree">
<image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image>
<!-- <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image>
<image v-else src="@/static/login/xz2@2x.png"></image>
<view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view>
<view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view> -->
</view>
</view>
</template>
......@@ -82,8 +85,10 @@ import {
} from 'vue'
import {
getCodeImg,
pcLogin
getCodeImg,
getSmsCode,
pcLogin,
loginByPhone
} from '@/common/login.js'
const isActive = ref(0)
......@@ -96,6 +101,16 @@ const form = ref({
code: null,
uuid: null
})
const form2 = ref({
telNo: null,
captcha: null,
code: null,
uuid: null
})
const countDown = ref({
start: false,
second: 60
})
const app = getApp()
......@@ -113,14 +128,61 @@ function changeAgree(item) {
}
function login() {
pcLogin(form.value)
.then(() => {
app.globalData.isLogin = true
uni.redirectTo({
url: '/pages/index/index'
if (isActive.value == 0) {
if (!form.value.username) {
uni.showToast({
title: '账号不能为空',
icon: 'none'
})
})
.catch(getCode)
return
}
if (!form.value.password) {
uni.showToast({
title: '密码不能为空',
icon: 'none'
})
return
}
if (!form.value.code) {
uni.showToast({
title: '验证码不能为空',
icon: 'none'
})
return
}
pcLogin(form.value)
.then(() => {
app.globalData.isLogin = true
uni.redirectTo({
url: '/pages/index/index'
})
})
.catch(getCode)
} else if (isActive.value == 1) {
if (!form2.value.telNo) {
uni.showToast({
title: '手机号不能为空',
icon: 'none'
})
return
}
if (!form2.value.code) {
uni.showToast({
title: '短信验证码不能为空',
icon: 'none'
})
return
}
loginByPhone(form2.value.telNo,form2.value.code)
.then(() => {
app.globalData.isLogin = true
uni.redirectTo({
url: '/pages/index/index'
})
})
}
}
function goRegister() {
......@@ -134,8 +196,46 @@ function getCode() {
getCodeImg().then((res) => {
codeUrl.value = 'data:image/gif;base64,' + res.data.img
form.value.uuid = res.data.uuid
form2.value.uuid = res.data.uuid
})
}
// 发送短信验证码
function getCaptchaSms() {
if (!form2.value.telNo) {
uni.showToast({
title: '手机号不能为空',
icon: 'none'
})
return
}
if (!form2.value.captcha) {
uni.showToast({
title: '图形验证码不能为空',
icon: 'none'
})
return
}
getSmsCode({
uuid: form2.value.uuid,
telNo: form2.value.telNo,
code: form2.value.captcha
}).then(res => {
uni.showToast({
title: '短信验证码下发成功',
icon: 'none'
})
countDown.value.start = true
}).catch(getCode)
}
function timeup() {
countDown.value.start = false
countDown.value.second = 60
getCode()
}
</script>
<style scoped lang="scss">
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!