commit
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckLogin;
|
|||||||
import com.budwk.app.base.constant.RedisConstant;
|
import com.budwk.app.base.constant.RedisConstant;
|
||||||
import com.budwk.app.base.exception.BaseException;
|
import com.budwk.app.base.exception.BaseException;
|
||||||
import com.budwk.app.base.result.Result;
|
import com.budwk.app.base.result.Result;
|
||||||
|
import com.budwk.app.client.auth.models.Client_user;
|
||||||
import com.budwk.app.client.auth.service.ClientAuthService;
|
import com.budwk.app.client.auth.service.ClientAuthService;
|
||||||
import com.budwk.app.client.auth.vo.ClientLoginBody;
|
import com.budwk.app.client.auth.vo.ClientLoginBody;
|
||||||
import com.budwk.app.sys.services.SysMsgService;
|
import com.budwk.app.sys.services.SysMsgService;
|
||||||
@@ -86,6 +87,15 @@ public class ClientAuthController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@At("/info")
|
||||||
|
@Ok("json")
|
||||||
|
@SaCheckLogin(type = StpClientUtil.TYPE)
|
||||||
|
public Result info() {
|
||||||
|
Client_user user = dao.fetch(Client_user.class, StpClientUtil.STP.getLoginIdAsLong());
|
||||||
|
return Result.success(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录
|
* 退出登录
|
||||||
*/
|
*/
|
||||||
|
|||||||
+13
-1
@@ -69,10 +69,20 @@ public class ClientGroupController {
|
|||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询自己在那个团队
|
||||||
|
* @param activityId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@At("/info/?")
|
@At("/info/?")
|
||||||
@SaCheckLogin(type = StpClientUtil.TYPE)
|
@SaCheckLogin(type = StpClientUtil.TYPE)
|
||||||
public Result info(Long activityId) {
|
public Result info(Long activityId) {
|
||||||
Sql sql = Sqls.create("select * from act_group where activityId=@activityId").setParam("activityId", activityId);
|
ActGroupUser groupUser = dao.fetch(ActGroupUser.class, Cnd.where(ActGroupUser::getUserId, "=", StpClientUtil.STP.getLoginIdAsLong())
|
||||||
|
.and(ActGroupUser::getActivityId, "=", activityId));
|
||||||
|
if(Lang.isEmpty(groupUser)){
|
||||||
|
return Result.error("您还没加入任何团队");
|
||||||
|
}
|
||||||
|
Sql sql = Sqls.create("select * from act_group where id=@id").setParam("id", groupUser.getGroupId());
|
||||||
sql.setCallback(Sqls.callback.map());
|
sql.setCallback(Sqls.callback.map());
|
||||||
NutMap map = (NutMap) dao.execute(sql).getResult();
|
NutMap map = (NutMap) dao.execute(sql).getResult();
|
||||||
Sql sqlGroupUser = Sqls.create("""
|
Sql sqlGroupUser = Sqls.create("""
|
||||||
@@ -85,6 +95,8 @@ public class ClientGroupController {
|
|||||||
`act_group_user` t1
|
`act_group_user` t1
|
||||||
LEFT JOIN act_user t2 ON t1.userId = t2.userId
|
LEFT JOIN act_user t2 ON t1.userId = t2.userId
|
||||||
WHERE t1.groupId=@groupId
|
WHERE t1.groupId=@groupId
|
||||||
|
ORDER BY
|
||||||
|
t1.isLeader DESC
|
||||||
""").setParam("groupId", map.getString("id"));
|
""").setParam("groupId", map.getString("id"));
|
||||||
List<NutMap> groupUsers = clientActivityService.listMap(sqlGroupUser);
|
List<NutMap> groupUsers = clientActivityService.listMap(sqlGroupUser);
|
||||||
map.put("groupUsers", groupUsers);
|
map.put("groupUsers", groupUsers);
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
<script>
|
<script>
|
||||||
import { setupRouterInterceptor, getDefaultWhiteList } from './utils/routerInterceptor'
|
import {setupRouterInterceptor, getDefaultWhiteList} from './utils/routerInterceptor'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
globalData: {
|
||||||
|
user: null
|
||||||
|
},
|
||||||
onLaunch: function () {
|
onLaunch: function () {
|
||||||
console.log('App Launch')
|
console.log('App Launch')
|
||||||
|
|
||||||
@@ -46,7 +49,7 @@ html, body {
|
|||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
uni-page-body{
|
uni-page-body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="page-container">
|
<view class="page-container">
|
||||||
<view v-if="actList&&actList?.length>0">
|
<view v-if="team">
|
||||||
<t-sticky>
|
<t-sticky>
|
||||||
<t-dropdown-menu class="top-dropdown-menu">
|
<t-dropdown-menu class="top-dropdown-menu">
|
||||||
<t-dropdown-item :options="actOptions" :value="pageForm.actId" @change="actChange"/>
|
<t-dropdown-item :options="actOptions" :value="pageForm.actId" @change="actChange"/>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<div class="team-basic-info">
|
<div class="team-basic-info">
|
||||||
<div class="team-name">{{ team.groupName }}</div>
|
<div class="team-name">{{ team.groupName }}</div>
|
||||||
<div class="team-meta">创建于 {{moment(team.createdAt).format("YYYY-MM-DD HH:mm")}}</div>
|
<div class="team-meta">创建于 {{ moment(team.createdAt).format("YYYY-MM-DD HH:mm") }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -41,9 +41,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 项目报名按钮 -->
|
<!-- 项目报名按钮 -->
|
||||||
<div class="action-section" v-if="team.isSelfLeader">
|
<div class="action-section" >
|
||||||
<t-button block theme="danger" size="large" class="register-btn" @click="goToEventRegistration">
|
<t-button block theme="danger" size="large" class="register-btn" @click="goToEventRegistration">
|
||||||
参与项目报名
|
{{ team.isSelfLeader ? '参与项目报名' : '查看项目报名' }}
|
||||||
</t-button>
|
</t-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -103,9 +103,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</view>
|
</view>
|
||||||
<view v-else>暂无团队</view>
|
<view v-else style="background-color: #FFFFFF">
|
||||||
</view>
|
<view >
|
||||||
|
<t-result>
|
||||||
|
<template #image>
|
||||||
|
<t-image src="https://tdesign.gtimg.com/mobile/demos/result1.png" class="external-class-image" />
|
||||||
|
</template>
|
||||||
|
<template #title>
|
||||||
|
<div>暂无团队</div>
|
||||||
|
</template>
|
||||||
|
</t-result>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<t-dialog
|
<t-dialog
|
||||||
v-model:visible="leaderConfirmVisible"
|
v-model:visible="leaderConfirmVisible"
|
||||||
title="申请成为队长"
|
title="申请成为队长"
|
||||||
@@ -126,8 +137,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</t-dialog>
|
</t-dialog>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -155,21 +164,7 @@ const pageForm = reactive({
|
|||||||
|
|
||||||
const teamId = ''
|
const teamId = ''
|
||||||
|
|
||||||
let team = ref({
|
let team = ref(null);
|
||||||
id: teamId,
|
|
||||||
name: 'xx队',
|
|
||||||
logoUrl: null,
|
|
||||||
createdDate: '2023-10-15',
|
|
||||||
eventId: '',
|
|
||||||
eventName: '',
|
|
||||||
memberCount: 12,
|
|
||||||
rank: 5,
|
|
||||||
score: 256,
|
|
||||||
description: 'xxxxxxxxxxxxxxxxxxx',
|
|
||||||
|
|
||||||
// 团队成员
|
|
||||||
groupUsers: []
|
|
||||||
});
|
|
||||||
// 申请成为队长弹框提示
|
// 申请成为队长弹框提示
|
||||||
const leaderConfirmVisible = ref(false)
|
const leaderConfirmVisible = ref(false)
|
||||||
|
|
||||||
@@ -190,6 +185,7 @@ const onLeaderConfirm = async () => {
|
|||||||
pageForm.groupId = team.value.id
|
pageForm.groupId = team.value.id
|
||||||
const {code, msg} = await useRequest().post('/client/group/apply-leader/' + team.value.id);
|
const {code, msg} = await useRequest().post('/client/group/apply-leader/' + team.value.id);
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
|
await getTeamInfo();
|
||||||
Toast({message: '申请成功', theme: 'success'});
|
Toast({message: '申请成功', theme: 'success'});
|
||||||
leaderConfirmVisible.value = false
|
leaderConfirmVisible.value = false
|
||||||
} else {
|
} else {
|
||||||
@@ -205,13 +201,14 @@ const goToEventRegistration = () => {
|
|||||||
uni.navigateTo({url: '/pages/activity/team-form/index?id=' + pageForm.actId})
|
uni.navigateTo({url: '/pages/activity/team-form/index?id=' + pageForm.actId})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 根据活动查询队伍信息
|
// 根据活动查询队伍信息
|
||||||
const getTeamInfo = async () => {
|
const getTeamInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const {code, msg, data} = await useRequest().post('/client/group/info/' + pageForm.actId);
|
const {code, msg, data} = await useRequest().post('/client/group/info/' + pageForm.actId);
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
team.value = data
|
team.value = data
|
||||||
|
console.log(team.value.groupUsers.find(t=>t.userId===uni.getStorageSync('userId')))
|
||||||
|
console.log()
|
||||||
} else {
|
} else {
|
||||||
Toast({message: msg, theme: 'error'});
|
Toast({message: msg, theme: 'error'});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {Dialog} from "tdesign-mobile-vue";
|
import {Dialog} from "tdesign-mobile-vue";
|
||||||
|
import {useRequest} from "@/utils/request";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由拦截器配置
|
* 路由拦截器配置
|
||||||
@@ -41,44 +42,61 @@ function addNavigationInterceptors(whiteList) {
|
|||||||
* @param {Array} whiteList - 白名单页面列表
|
* @param {Array} whiteList - 白名单页面列表
|
||||||
* @returns {Object|boolean} - 继续导航或阻止导航
|
* @returns {Object|boolean} - 继续导航或阻止导航
|
||||||
*/
|
*/
|
||||||
function routeInterceptor(args, whiteList) {
|
async function routeInterceptor(args, whiteList) {
|
||||||
// 获取目标路径
|
// 获取目标路径
|
||||||
const token = uni.getStorageSync('token')
|
const token = uni.getStorageSync('token')
|
||||||
const targetUrl = args.url
|
const targetUrl = args.url
|
||||||
|
|
||||||
// 检查目标路径是否在白名单中
|
|
||||||
const isInWhiteList = whiteList.some(path => {
|
let isInWhiteList = targetUrl === '/'
|
||||||
return targetUrl.startsWith(path) || targetUrl === path
|
|
||||||
})
|
if (!isInWhiteList) {
|
||||||
|
// 检查目标路径是否在白名单中
|
||||||
|
isInWhiteList = whiteList.some(path => {
|
||||||
|
return targetUrl.startsWith(path) || targetUrl === path
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
console.log('路由拦截检查:', {url: targetUrl, isInWhiteList, hasToken: !!token})
|
console.log('路由拦截检查:', {url: targetUrl, isInWhiteList, hasToken: !!token})
|
||||||
|
|
||||||
// 如果不在白名单且未登录,则跳转到登录页
|
// 如果不在白名单且未登录,则跳转到登录页
|
||||||
if (!isInWhiteList && !token) {
|
if (!isInWhiteList) {
|
||||||
console.log('拦截导航,跳转到登录页')
|
if (token) {
|
||||||
|
// 获取用户信息
|
||||||
// 保存用户尝试访问的页面,以便登录后跳回
|
const {user} = getApp().globalData
|
||||||
try {
|
if (user == null) {
|
||||||
uni.setStorageSync('REDIRECT_URL', targetUrl)
|
const {code, data, msg} = await useRequest().get('/client/auth/info')
|
||||||
} catch (e) {
|
if (code === 0) {
|
||||||
}
|
getApp().globalData.user = data
|
||||||
|
return args
|
||||||
Dialog.confirm({
|
}
|
||||||
title: '提示',
|
|
||||||
content: '您尚未登录,是否前往登录页面?',
|
|
||||||
cancelBtn: '取消',
|
|
||||||
confirmBtn: '确认',
|
|
||||||
onConfirm: () => {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/login/index'
|
|
||||||
})
|
|
||||||
},
|
|
||||||
onCancel: () => {
|
|
||||||
console.log('取消登录')
|
|
||||||
}
|
}
|
||||||
})
|
return args
|
||||||
// 阻止原导航
|
} else {
|
||||||
return false
|
console.log('拦截导航,跳转到登录页')
|
||||||
|
|
||||||
|
// 保存用户尝试访问的页面,以便登录后跳回
|
||||||
|
try {
|
||||||
|
uni.setStorageSync('REDIRECT_URL', targetUrl)
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Dialog.confirm({
|
||||||
|
title: '提示',
|
||||||
|
content: '您尚未登录,是否前往登录页面?',
|
||||||
|
cancelBtn: '取消',
|
||||||
|
confirmBtn: '确认',
|
||||||
|
onConfirm: () => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/login/index'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onCancel: () => {
|
||||||
|
console.log('取消登录')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 阻止原导航
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 继续原导航
|
// 继续原导航
|
||||||
return args
|
return args
|
||||||
@@ -90,9 +108,7 @@ function routeInterceptor(args, whiteList) {
|
|||||||
*/
|
*/
|
||||||
export const getDefaultWhiteList = () => {
|
export const getDefaultWhiteList = () => {
|
||||||
return [
|
return [
|
||||||
'/',
|
|
||||||
'/pages/index/index',
|
'/pages/index/index',
|
||||||
'/pages/login/index',
|
'/pages/login/index'
|
||||||
'/pages/profile/index'
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user