7145d1c6 by 华明祺

手机登录

1 parent 023f830b
......@@ -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 user = res.data.user
uni.setStorageSync('userName', user.userName)
switch (user.dept.deptType) {
case '1':// 中跆协
uni.setStorageSync('userType', '1')
break
case '2':// 省
case '3':
uni.setStorageSync('userType', '2')
break
case '6':// 道馆
uni.setStorageSync('userType', '4')
break
default:// 市、区
uni.setStorageSync('userType', '3')
break
}
delete user.dept
uni.setStorageSync('user', JSON.stringify(user))
})
}
export {
getNowOpenId,
wxLogin,
......@@ -215,6 +268,8 @@ export {
checkUserAuth,
initData,
getCodeImg,
getSmsCode,
h5Login,
h5LoginAuto
h5LoginAuto,
loginByPhone
}
......
<template>
<view class="page">
<view>
<view class="welcome">您好!<br />欢迎使用中跆协会员管理系统</view>
<view class="flexbox">
<view>添加会员</view>
<view>会员缴费</view>
<view>缴费审核</view>
</view>
</view>
<uni-section padding>
<uni-grid :column="4" :show-border="false" :square="false" @change="change">
<uni-grid-item v-for="(item ,index) in list" :index="index" :key="index">
<view class="grid-item-box">
<image class="image" :src="item.url" mode="aspectFill" />
<text class="text">{{item.text}}</text>
<view v-if="item.badge" class="grid-dot">
<uni-badge :text="item.badge" :type="item.type" />
</view>
</view>
</uni-grid-item>
</uni-grid>
</uni-section>
<uni-section title="待办提醒" padding>
<template v-slot:right>
<text @click="goMsgList" class="more">更多></text>
</template>
<view class="msglist">
<view class="msgitem" v-for="n in 4">
<text class="dot" :class="n.isRead?'done':''"></text>
<view class="tt esp">你有一条会员缴费等待审批,点击前去处理!</view>
<view class="date">2023-09-23</view>
</view>
</view>
</uni-section>
</view>
<view class="page">
<view>
<view class="welcome">您好!<br />欢迎使用中跆协会员管理系统</view>
<view class="flexbox">
<view>添加会员</view>
<view>会员缴费</view>
<view>缴费审核</view>
</view>
</view>
<uni-section padding>
<uni-grid :column="4" :show-border="false" :square="false" @change="change">
<uni-grid-item v-for="(item ,index) in list" :index="index" :key="index">
<view class="grid-item-box">
<image class="image" :src="item.url" mode="aspectFill" />
<text class="text">{{item.text}}</text>
<view v-if="item.badge" class="grid-dot">
<uni-badge :text="item.badge" :type="item.type" />
</view>
</view>
</uni-grid-item>
</uni-grid>
</uni-section>
<uni-section title="待办提醒" padding>
<template v-slot:right>
<text @click="goMsgList" class="more">更多></text>
</template>
<view class="msglist">
<view class="msgitem" v-for="n in 4">
<text class="dot" :class="n.isRead?'done':''"></text>
<view class="tt esp">你有一条会员缴费等待审批,点击前去处理!</view>
<view class="date">2023-09-23</view>
</view>
</view>
</uni-section>
</view>
</template>
<script setup>
import * as api from '@/common/api.js';
import * as loginServer from '@/common/login.js';
import {
getWxUser,
getWxUserPhone
} from '@/common/login.js';
import {
onLoad,
onShow,
onReady,
onShareAppMessage,
onShareTimeline,
onPullDownRefresh
} from '@dcloudio/uni-app';
import {
ref,
getCurrentInstance
} from 'vue';
const {
proxy
} = getCurrentInstance()
const app = getApp();
let proId;
let goPath;
const svId = ref(null);
const list = ref([{
url: '/static/c1.png',
text: '会员调动',
badge: '0',
type: "primary"
},
{
url: '/static/c2.png',
text: '调动审核',
badge: '1',
type: "success"
},
{
url: '/static/c3.png',
text: '级位考试申请',
badge: '99',
type: "warning"
},
{
url: '/static/c4.png',
text: '级位考试审核',
badge: '2',
type: "error"
},
{
url: '/static/c5.png',
text: '段位考试申请'
},
{
url: '/static/c6.png',
text: '段位考试审核'
},
{
url: '/static/c7.png',
text: '级位证书发送'
},
{
url: '/static/c8.png',
text: '段位证书发送'
}
]);
onShow(() => {
if (app.globalData.isLogin) {
init();
} else {
import * as api from '@/common/api.js';
import * as loginServer from '@/common/login.js';
import {
getWxUser,
getWxUserPhone
} from '@/common/login.js';
import {
onLoad,
onShow,
onReady,
onShareAppMessage,
onShareTimeline,
onPullDownRefresh
} from '@dcloudio/uni-app';
import {
ref,
getCurrentInstance
} from 'vue';
const {
proxy
} = getCurrentInstance()
const app = getApp();
let proId;
let goPath;
const svId = ref(null);
const list = ref([{
url: '/static/c1.png',
text: '会员调动',
badge: '0',
type: "primary"
},
{
url: '/static/c2.png',
text: '调动审核',
badge: '1',
type: "success"
},
{
url: '/static/c3.png',
text: '级位考试申请',
badge: '99',
type: "warning"
},
{
url: '/static/c4.png',
text: '级位考试审核',
badge: '2',
type: "error"
},
{
url: '/static/c5.png',
text: '段位考试申请'
},
{
url: '/static/c6.png',
text: '段位考试审核'
},
{
url: '/static/c7.png',
text: '级位证书发送'
},
{
url: '/static/c8.png',
text: '段位证书发送'
}
]);
onShow(() => {
if (app.globalData.isLogin) {
init();
} else {
app.firstLoadCallback = () => {
init();
};
}
})
onLoad(option => {
if (option.scene) {
proId = decodeURIComponent(option.scene);
} else {
proId = option.proId;
}
});
function gologin(){
let path = '/pages/index/login';
uni.navigateTo({
url: path
});
}
function goCenter() {
let path = '/pages/usercenter/usercenter';
if (checkUserPhone(path)) {
uni.navigateTo({
url: path
});
}
}
function init() {
}
function goMsgList(){
app.firstLoadCallback = () => {
init();
};
}
})
onLoad(option => {
if (option.scene) {
proId = decodeURIComponent(option.scene);
} else {
proId = option.proId;
}
});
function gologin(){
let path = '/pages/index/login';
uni.navigateTo({
url: path
});
}
function goCenter() {
let path = '/pages/usercenter/usercenter';
if (checkUserPhone(path)) {
uni.navigateTo({
url: path
});
}
}
function init() {
uni.showToast({
title:uni.getStorageSync('userType')
})
}
function goMsgList(){
}
function goItem(item) {
if (item.path) {
let path = item.path
// if (checkUserPhone(path)) {
uni.navigateTo({
url: item.path
});
// }
} else {
uni.showToast({
title: `暂未开放`,
icon: 'none'
});
}
}
}
function goItem(item) {
if (item.path) {
let path = item.path
// if (checkUserPhone(path)) {
uni.navigateTo({
url: item.path
});
// }
} else {
uni.showToast({
title: `暂未开放`,
icon: 'none'
});
}
}
</script>
<style scope lang="scss">
.welcome{padding: 55rpx;
......
......@@ -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!