李双庆 1 year ago
parent
commit
3d55755fb6
  1. 15
      api/apiRoute.js
  2. 59
      pages/student/index/index.vue
  3. 59
      pages/student/login/login.vue

15
api/apiRoute.js

@ -403,7 +403,20 @@ export default {
//↓↓↓↓↓↓↓↓↓↓↓↓-----学生接口相关-----↓↓↓↓↓↓↓↓↓↓↓↓
//学生登陆接口
xy_login(data = {}) {
let url = '/customerResourcesAuth/login'
return http.post(url, data).then(res => {
return res;
})
},
//学生详情
xy_memberInfo(data = {}) {
let url = '/customerResourcesAuth/info'
return http.get(url, data).then(res => {
return res;
})
},

59
pages/student/index/index.vue

@ -6,7 +6,7 @@
<view class="head">
<view class="head-img">
<!-- <fui-avatar width="136" :src="$util.img(member_info.headimg)"></fui-avatar> -->
<image class="pic" :src="$util.img(member_info.headimg)"></image>
<image class="pic" :src="member_info.memberHasOne ? member_info.memberHasOne.headimg : $util.img('/uniapp_src/static/images/common/yong_hu.png')"></image>
<view class="head-text">{{member_info.name}}</view>
</view>
</view>
@ -123,6 +123,8 @@
<script>
import {Api_url} from "@/common/config";
import apiRoute from '@/api/apiRoute.js';
import memberApi from '@/api/member.js';
import AQTabber from "@/components/AQ/AQTabber.vue"
export default {
@ -131,12 +133,15 @@
},
data() {
return {
inited: false, // 添加标记位控制 init 只执行一次
//上传接口地址
uploadApiUrl: ``,
uploadImageApiUrl: `${Api_url}/file/image`,
uploadVideoApiUrl: `${Api_url}/file/video`,
member_info: [],
member_info: {},//学生信息
assignmentsList: [],//作业列表
jobAssignmentsInfo: [],//待完成的作业
@ -168,23 +173,27 @@
}
},
onLoad() {
this.openViewHome()//检测首页是否正确跳转-不正确则进行重定向
},
onShow(){
this.openViewHome()//检测首页是否正确跳转-不正确则进行重定向
// 防止 onShow 触发后重复 init
if (!this.inited) {
this.init()
this.inited = true
}
},
methods: {
//初始化
//学生页面初始化
async init(){
this.member_init()
await this.member_init()
this.getMemberIndex()
this.getList()
this.getJobAssignmentsInfo()
},
//检测首页是否正确跳转-不正确则进行重定向
async openViewHome(){
async openViewHome_COPY(){
//获取当前页面路径
let pages = getCurrentPages();
//当前页面路径
@ -194,21 +203,24 @@
this.openPath = this.path_arr[userType]
console.log(
'跳转',
this.thisPath,
userType,
this.path_arr[userType]
)
if(this.thisPath != this.openPath){
console.log('打印1')
//跳转tabBar首页-页面
uni.setStorageSync('tabBerIndex', 0)
uni.navigateTo({
url: this.openPath
})
return
}else{
//页面正确的情况下
//页面正确的情况下->执行学生页面初始化
this.init()
}
console.log(123123123123,this.thisPath,userType,this.path_arr[userType])
},
async getMemberIndex(){
@ -269,15 +281,20 @@
},
//获取学员信息
member_init() {
memberApi.member().then(res => {
if(res.code == 1){
this.member_info = res.data
}else{
this.member_info = []
}
async member_init() {
let res = await apiRoute.xy_memberInfo({})
if(res.code != 1){
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
this.member_info = res.data
console.log('xxxx',this.member_info)
},
//跳转页面-作业详情
details() {
uni.navigateTo({
url: '/pages/student/index/work_details'

59
pages/student/login/login.vue

@ -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>

Loading…
Cancel
Save