Commit 976e2a75 authored by 罗超's avatar 罗超

调整

parent 4326f227
...@@ -18,7 +18,7 @@ export function login(data) { ...@@ -18,7 +18,7 @@ export function login(data) {
*/ */
export function parsePhone(data) { export function parsePhone(data) {
return request({ return request({
url: '/AppletLogin/GetGuestWeiXinMobile', url: '/Login/LoginByAuthorize',
method: 'post', method: 'post',
data data
}) })
......
...@@ -145,30 +145,27 @@ ...@@ -145,30 +145,27 @@
}); });
data.showLogin = false; //防止多次点击登录 data.showLogin = false; //防止多次点击登录
let res = await parsePhone({ let res = await parsePhone({
code,
encryptedData, encryptedData,
iv, iv
code
}) })
if (res && res.Data.phoneNumber) { console.log(res)
console.log('dsadas', res) if (res && res.Data.UserMobile) {
data.obj.phoneNum = res.Data.phoneNumber // console.log('dsadas', res)
// data.obj.phoneNum = '18328620563' // data.obj.phoneNum = res.Data.UserMobile
data.obj.openid = res.Data.openid // that.phoneNumLogin()
data.obj.unionid = res.Data.unionid // let obj = {
that.phoneNumLogin() // Account: data.obj.phoneNum,
let obj = { // WeChatName: data.obj.Name,
Account: data.obj.phoneNum, // WeChatPhoto: data.obj.Photo,
WeChatName: data.obj.Name, // OpenId: data.obj.openid,
WeChatPhoto: data.obj.Photo, // unionid: data.obj.unionid,
OpenId: data.obj.openid, // }
unionid: data.obj.unionid, uni.setStorageSync("userInfo", res.Data);
} uni.reLaunch({
try { url:'/pages/index/index'
uni.setStorageSync("temporarydh", obj); })
} catch (e) {
console.log(e, 'eeeeeee')
}
} else { } else {
Toast.fail("授权失败,请重新授权") Toast.fail("授权失败,请重新授权")
data.showLogin = true; //防止多次点击登录 data.showLogin = true; //防止多次点击登录
...@@ -176,40 +173,40 @@ ...@@ -176,40 +173,40 @@
} }
}, },
//手机号授权登录 //手机号授权登录
async phoneNumLogin() { // async phoneNumLogin() {
let res = await phoneLogin({ // let res = await phoneLogin({
Account: data.obj.phoneNum, // Account: data.obj.phoneNum,
OpenId: data.obj.openid, // OpenId: data.obj.openid,
unionid: data.obj.unionid, // unionid: data.obj.unionid,
}) // })
if (res.Code == 1) { // if (res.Code == 1) {
uni.hideLoading(); // uni.hideLoading();
data.showLogin = true; //防止多次点击登录 // data.showLogin = true; //防止多次点击登录
res.Data.Account = data.obj.phoneNum; // res.Data.Account = data.obj.phoneNum;
uni.setStorageSync("userInfo", res.Data); // uni.setStorageSync("userInfo", res.Data);
Toast.success("登录成功"); // Toast.success("登录成功");
setTimeout(()=>{ // setTimeout(()=>{
emit('success') // emit('success')
},1000) // },1000)
data.showPhone = false // data.showPhone = false
uni.showTabBar() // uni.showTabBar()
} else { // } else {
data.showLogin = true; //防止多次点击登录 // data.showLogin = true; //防止多次点击登录
data.showPhone = false // data.showPhone = false
if (currentRoute == "pages/index/index") { // if (currentRoute == "pages/index/index") {
uni.showTabBar() //手机授权弹窗出现 隐藏tabbar // uni.showTabBar() //手机授权弹窗出现 隐藏tabbar
} // }
uni.hideLoading(); // uni.hideLoading();
if (res.Data.Error == -1) { //如果没找到电话号码 就跳入登录 // if (res.Data.Error == -1) { //如果没找到电话号码 就跳入登录
// setTimeout(() => { // // setTimeout(() => {
// uni.reLaunch({ // // uni.reLaunch({
// url: '/pages/login/login' // // url: '/pages/login/login'
// }); // // });
// }, 1000); // // }, 1000);
} // }
} // }
} // }
}; };
onMounted(() => { onMounted(() => {
......
...@@ -13,22 +13,38 @@ ...@@ -13,22 +13,38 @@
<view class="login-title"> <view class="login-title">
账号登录 账号登录
</view> </view>
<view style="margin:60rpx auto;text-align: center;">
<div style="display: inline-block;" @click="changeTypeHandler(1)">
<image :class="{'login-grey-avatar':userLoginType==2}" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653894192000_645.png" mode="widthFix" style="width:142rpx;"></image>
<view style="color: #282828;font-size: 24rpx;font-weight: 800;">
学员
</view>
</div>
<div style="display: inline-block;margin-left:148rpx;" @click="changeTypeHandler(2)">
<image :class="{'login-grey-avatar':userLoginType==1}" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1653894197000_691.png" mode="widthFix" style="width:142rpx;"></image>
<view style="color: #282828;font-size: 24rpx;font-weight: 800;">
教师
</view>
</div>
</view>
<view class="main"> <view class="main">
<van-cell-group> <van-cell-group>
<van-field :value="Account" placeholder="请输入用户名" clearable input-align="center" @input="usernameInput"> <van-field :value="Account" placeholder="请输入预留手机号" clearable input-align="center" @input="usernameInput">
</van-field> </van-field>
<van-field :value="Password" password placeholder="请输入密码" clearable input-align="center" @input="passwordInput"> <van-field :value="Password" v-if="userLoginType==2" password placeholder="请输入密码" clearable input-align="center" @input="passwordInput">
</van-field> </van-field>
</van-cell-group> </van-cell-group>
</view> </view>
<view class="btnBox" @click="login"> <view class="btnBox" @click="login">
立即登录 <van-loading color="#f5f5f5" v-if="loading" />
<text v-else>立即登录</text>
</view> </view>
<view class="login-bottom"> <view class="login-bottom">
<view class="login-bottom-text" @click="back">返回</view> <view class="login-bottom-text" @click="back">返回</view>
<!-- <view class="login-bottom-text">忘记密码</view> --> <!-- <view class="login-bottom-text">忘记密码</view> -->
</view> </view>
</view> </view>
<van-toast id="van-toast" />
</view> </view>
</template> </template>
...@@ -71,9 +87,17 @@ ...@@ -71,9 +87,17 @@
openid: "", openid: "",
code: "", code: "",
show: false, show: false,
userLoginType:1, //1为学员,2为老师
loading:false
}); });
let methods = { let methods = {
changeTypeHandler(t){
data.userLoginType=t
if(t==1){
msg.Password =''
}
},
usernameInput(val) { usernameInput(val) {
msg.Account = val.detail; msg.Account = val.detail;
}, },
...@@ -87,31 +111,43 @@ ...@@ -87,31 +111,43 @@
}, },
jumpPage() { jumpPage() {
uni.reLaunch({ uni.reLaunch({
url: "/pages/index/index", url: data.userLoginType==1?"/pages/index/index":'/pages/index/workSituation',
}); });
clearTimeout(); //clearTimeout();
}, },
async login() { async login() {
if(data.loading) return;
data.loading=true
if (msg.Account == "" || !msg.Account) { if (msg.Account == "" || !msg.Account) {
Toast.fail("请输入账号"); Toast.fail("请输入账号");
data.loading=true
return; return;
} }
if (msg.Password == "" || !msg.Password) { if ((msg.Password == "" || !msg.Password) && data.userLoginType==2) {
Toast.fail("请输入密码"); Toast.fail("请输入密码");
data.loading=true
return; return;
} }
let res = await this.$request('/Login/Login', msg).then(res=>{ let url=data.userLoginType==2?'/Login/Login':'/Login/LoginByAccount'
let res = await this.$request(url, msg).then(res=>{
if(res.Code==1){ if(res.Code==1){
res.Data.Account = msg.Account; if((res.Data.AccountType==1 && data.userLoginType==2) ||res.Data.AccountType==2 && data.userLoginType==1){
uni.setStorageSync("userInfo", res.Data); res.Data.Account = msg.Account;
Toast.success("登录成功"); uni.setStorageSync("userInfo", res.Data);
setTimeout(() => { Toast.success("登录成功");
let data = uni.getStorageSync("userInfo"); setTimeout(() => {
if (data) { let data = uni.getStorageSync("userInfo");
that.jumpPage(); if (data) {
} that.jumpPage();
}, 1000); }
}, 1000);
}else{
data.loading=false
Toast.fail("账号类型选择错误,请根据真实身份选择")
}
} }
}).catch(e=>{
data.loading=false
}) })
}, },
}; };
...@@ -166,7 +202,7 @@ ...@@ -166,7 +202,7 @@
display: inline-block; display: inline-block;
} }
.login-bottom{ .login-bottom{
margin-bottom: 136rpx; margin-bottom: 100rpx;
text-align: center; text-align: center;
} }
.login-title{ .login-title{
...@@ -198,11 +234,17 @@ ...@@ -198,11 +234,17 @@
background: -ms-linear-gradient(top, #C41726 0%,#831D1C 100%); background: -ms-linear-gradient(top, #C41726 0%,#831D1C 100%);
background: linear-gradient(top bottom, #C41726 0%,#831D1C 100%); background: linear-gradient(top bottom, #C41726 0%,#831D1C 100%);
} }
.login-grey-avatar{
-webkit-filter: grayscale(100%);
}
.main { .main {
height: 250rpx; height: 250rpx;
box-sizing: border-box; box-sizing: border-box;
vertical-align: middle;
padding: 0 0; padding: 0 0;
display: flex;
flex-direction: column;
justify-content: center;
} }
/deep/.van-cell { /deep/.van-cell {
height: 88rpx; height: 88rpx;
...@@ -217,12 +259,15 @@ ...@@ -217,12 +259,15 @@
overflow: hidden; overflow: hidden;
margin: 0 auto; margin: 0 auto;
margin-top: 26rpx; margin-top: 26rpx;
margin-bottom: 110rpx; margin-bottom: 30rpx;
background-color: #C91727; background-color: #C91727;
font-size: 30rpx; font-size: 30rpx;
font-weight: 500; font-weight: 500;
color: #FFFFFF; color: #FFFFFF;
text-align: center; text-align: center;
line-height: 88rpx; /* line-height: 88rpx; */
display: flex;
flex-direction: column;
justify-content: center;
} }
</style> </style>
//请求教育接口 //请求教育接口
let host = '' let host = ''
if (process.env.NODE_ENV === "development") { if (process.env.NODE_ENV === "development") {
host = 'http://192.168.10.46:8900/api' host = 'http://192.168.10.36:8082/api'
// host = 'http://192.168.10.65:8085/api' // host = 'http://192.168.10.65:8085/api'
} else { } else {
host = 'https://eduapi.oytour.com/api' host = 'https://eduapi.oytour.com/api'
...@@ -32,9 +32,9 @@ let request = (param) => { ...@@ -32,9 +32,9 @@ let request = (param) => {
icon: "none", icon: "none",
}); });
uni.removeStorageSync('userInfo'); uni.removeStorageSync('userInfo');
// uni.reLaunch({ uni.reLaunch({
// url:"/pages/login/login" url:"/pages/login/login"
// }) })
reject() reject()
}else{ }else{
uni.showToast({ uni.showToast({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment