|
|
|
@ -25,7 +25,6 @@ |
|
|
|
</fui-input> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view style="width: 95%;height: 30rpx;"></view> |
|
|
|
<view style="width: 95%;margin:30rpx auto;"> |
|
|
|
<fui-input |
|
|
|
@click="picker_show_loginType=true" |
|
|
|
@ -64,6 +63,8 @@ import apiRoute from '@/api/apiRoute.js'; |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
inited: false, // 添加标记位控制 init 只执行一次 |
|
|
|
|
|
|
|
password: true, |
|
|
|
user: '', //账户 |
|
|
|
password1: '', //密码 |
|
|
|
@ -86,6 +87,13 @@ export default { |
|
|
|
} |
|
|
|
], |
|
|
|
picker_show_loginType:false,//是否显示下拉窗组件 |
|
|
|
|
|
|
|
|
|
|
|
path_arr:{ |
|
|
|
'1':'/pages/coach/home/index',//教练 |
|
|
|
'2':'/pages/market/index/index',//销售 |
|
|
|
'3':'/pages/student/index/index',//学员 |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(options) { |
|
|
|
@ -94,14 +102,21 @@ export default { |
|
|
|
this.loginType_str = selectedItem ? selectedItem.text : '未知类型'; |
|
|
|
// uni.hideHomeButton() |
|
|
|
// console.log(uni.getStorageSync('um_id')) |
|
|
|
this.init() |
|
|
|
// 防止 onShow 触发后重复 init |
|
|
|
if (!this.inited) { |
|
|
|
this.openViewHome() |
|
|
|
this.inited = true |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
async init(){ |
|
|
|
//条件编译 微信小程序 |
|
|
|
//#ifdef MP-WEIXIN |
|
|
|
await this.getMiNiWxOpenId() |
|
|
|
//#endif |
|
|
|
}, |
|
|
|
input(e) { |
|
|
|
console.log(e) |
|
|
|
//console.log(e) |
|
|
|
}, |
|
|
|
change() { |
|
|
|
this.password = !this.password |
|
|
|
@ -172,6 +187,7 @@ export default { |
|
|
|
'login_type': 2, |
|
|
|
'mini_wx_openid':this.mini_wx_openid,//微信小程序openid |
|
|
|
} |
|
|
|
res = await apiRoute.xy_login(params) |
|
|
|
} |
|
|
|
|
|
|
|
if(!res.code){ |
|
|
|
@ -259,11 +275,44 @@ export default { |
|
|
|
this.password1= '123123' //密码 |
|
|
|
}else{ |
|
|
|
//学生端 |
|
|
|
this.user= '' //账户 |
|
|
|
this.password1= '' //密码 |
|
|
|
this.user= '15335526445' //账户 |
|
|
|
this.password1= '123123' //密码 |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
//检测首页是否正确跳转-不正确则进行重定向 |
|
|
|
async openViewHome() { |
|
|
|
const userType = String(uni.getStorageSync('userType') || ''); |
|
|
|
const token = uni.getStorageSync('token') || '' |
|
|
|
|
|
|
|
if(!userType || !token){ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
const pages = getCurrentPages(); |
|
|
|
const currentPage = pages[pages.length - 1]; |
|
|
|
const thisPath = '/' + currentPage.route; |
|
|
|
|
|
|
|
|
|
|
|
const openPath = this.path_arr[userType]; |
|
|
|
|
|
|
|
console.log('当前路径:', thisPath); |
|
|
|
console.log('用户类型:', userType); |
|
|
|
console.log('应跳转路径:', openPath); |
|
|
|
|
|
|
|
if (thisPath !== openPath) { |
|
|
|
// 如果不是正确的首页路径,则跳转到对应角色首页 |
|
|
|
uni.setStorageSync('tabBerIndex', 0) |
|
|
|
|
|
|
|
// 使用 redirectTo 替代 navigateTo,避免页面栈堆积 |
|
|
|
uni.redirectTo({ |
|
|
|
url: openPath |
|
|
|
}); |
|
|
|
return |
|
|
|
} |
|
|
|
// 如果是正确的路径,交给 onShow 控制初始化 |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|