登录角色的区分和二维码跳转的修改
This commit is contained in:
parent
2630c7fef0
commit
431f24418a
|
|
@ -418,7 +418,7 @@ public class TeacherServiceImpl implements ITeacherService {
|
|||
* @return 小程序页面路径
|
||||
*/
|
||||
private String buildMiniProgramPagePath() {
|
||||
return "pages/pre_registration/pre_registration";
|
||||
return "pages/index/index";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -179,35 +179,44 @@ public class EnrollmentService {
|
|||
* <p>- 本周招生数量
|
||||
* <p>- 本月招生数量
|
||||
* 招生数量定义:student_status = 0 或 1 的学生数量
|
||||
*
|
||||
* @param teacherId 招生老师 ID(为空则统计所有老师)
|
||||
*/
|
||||
public Map<String, Object> buildEnrollmentStats() {
|
||||
public Map<String, Object> buildEnrollmentStats(Integer teacherId) {
|
||||
Map<String, Object> stats = new LinkedHashMap<>();
|
||||
|
||||
// 当前时间
|
||||
Date now = new Date();
|
||||
stats.put("time", new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now));
|
||||
|
||||
// 总招生数量(所有时间)
|
||||
long totalCount = studentInfoMapper.selectCount(
|
||||
// 构建查询条件
|
||||
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<StudentInfo> queryWrapper =
|
||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<StudentInfo>()
|
||||
.in("student_status", 0, 1)
|
||||
.isNull("delete_time")
|
||||
);
|
||||
.isNull("delete_time");
|
||||
|
||||
// 如果指定了老师 ID,则只统计该老师的数据
|
||||
if (teacherId != null) {
|
||||
queryWrapper.eq("recruitment_teacher_id", teacherId);
|
||||
}
|
||||
|
||||
// 总招生数量(所有时间)
|
||||
long totalCount = studentInfoMapper.selectCount(queryWrapper);
|
||||
|
||||
// 今日、本周、本月时间范围
|
||||
LocalDate today = LocalDate.now();
|
||||
Date todayStart = toDate(today.atStartOfDay());
|
||||
Date tomorrowStart = toDate(today.plusDays(1).atStartOfDay());
|
||||
|
||||
LocalDate weekStartDate = today.minusDays(6); // 最近7天
|
||||
LocalDate weekStartDate = today.minusDays(6); // 最近 7 天
|
||||
Date weekStart = toDate(weekStartDate.atStartOfDay());
|
||||
|
||||
LocalDate monthStartDate = today.minusDays(29); // 最近30天
|
||||
LocalDate monthStartDate = today.minusDays(29); // 最近 30 天
|
||||
Date monthStart = toDate(monthStartDate.atStartOfDay());
|
||||
|
||||
long todayCount = countEnrollmentInRange(todayStart, tomorrowStart);
|
||||
long weekCount = countEnrollmentInRange(weekStart, tomorrowStart);
|
||||
long monthCount = countEnrollmentInRange(monthStart, tomorrowStart);
|
||||
long todayCount = countEnrollmentInRange(teacherId, todayStart, tomorrowStart);
|
||||
long weekCount = countEnrollmentInRange(teacherId, weekStart, tomorrowStart);
|
||||
long monthCount = countEnrollmentInRange(teacherId, monthStart, tomorrowStart);
|
||||
|
||||
stats.put("total_enroll_count", totalCount);
|
||||
stats.put("today_enroll_count", todayCount);
|
||||
|
|
@ -340,16 +349,26 @@ public class EnrollmentService {
|
|||
|
||||
/**
|
||||
* 计算时间区间内的招生数量(按 pre_registration_time 筛选)
|
||||
*
|
||||
* @param teacherId 招生老师 ID(为空则统计所有老师)
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
private long countEnrollmentInRange(Date startTime, Date endTime) {
|
||||
return studentInfoMapper.selectCount(
|
||||
private long countEnrollmentInRange(Integer teacherId, Date startTime, Date endTime) {
|
||||
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<StudentInfo> queryWrapper =
|
||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<StudentInfo>()
|
||||
.in("student_status", 0, 1)
|
||||
.isNull("delete_time")
|
||||
.isNotNull("pre_registration_time")
|
||||
.ge("pre_registration_time", startTime)
|
||||
.lt("pre_registration_time", endTime)
|
||||
);
|
||||
.lt("pre_registration_time", endTime);
|
||||
|
||||
// 如果指定了老师 ID,则只统计该老师的数据
|
||||
if (teacherId != null) {
|
||||
queryWrapper.eq("recruitment_teacher_id", teacherId);
|
||||
}
|
||||
|
||||
return studentInfoMapper.selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
public Map<String, Object> getAliyunUrl() {
|
||||
|
|
|
|||
|
|
@ -56,8 +56,12 @@ public class EnrollmentController {
|
|||
|
||||
@PostMapping("/enrollmentStatistical")
|
||||
@ApiOperation(value = "招生统计数据")
|
||||
public AjaxResult<Map<String, Object>> buildEnrollmentStatistical() {
|
||||
return AjaxResult.success(enrollmentService.buildEnrollmentStats());
|
||||
public AjaxResult<Map<String, Object>> buildEnrollmentStatistical(@RequestBody(required = false) Map<String, Object> params) {
|
||||
Integer teacherId = null;
|
||||
if (params != null && params.get("teacherId") != null) {
|
||||
teacherId = Integer.parseInt(params.get("teacherId").toString());
|
||||
}
|
||||
return AjaxResult.success(enrollmentService.buildEnrollmentStats(teacherId));
|
||||
}
|
||||
|
||||
@GetMapping("/enrollmentTrend")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson2.JSONArray;
|
|||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.common.entity.Teacher;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.entity.user.UserAuth;
|
||||
import com.mdd.common.entity.user.UserSession;
|
||||
|
|
@ -16,6 +17,7 @@ import com.mdd.common.exception.OperateException;
|
|||
import com.mdd.common.mapper.user.UserAuthMapper;
|
||||
import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.mapper.user.UserSessionMapper;
|
||||
import com.mdd.common.mapper.TeacherMapper;
|
||||
import com.mdd.common.plugin.notice.NoticeCheck;
|
||||
import com.mdd.common.plugin.wechat.WxMnpDriver;
|
||||
import com.mdd.common.service.RegisterService;
|
||||
|
|
@ -56,6 +58,8 @@ public class LoginServiceImpl implements ILoginService {
|
|||
UserAuthMapper userAuthMapper;
|
||||
@Resource
|
||||
UserSessionMapper userSessionMapper;
|
||||
@Resource
|
||||
TeacherMapper teacherMapper;
|
||||
|
||||
/**
|
||||
* 注册账号
|
||||
|
|
@ -458,6 +462,25 @@ public class LoginServiceImpl implements ILoginService {
|
|||
vo.setIsNew(isNew);
|
||||
vo.setMobile(mobile);
|
||||
|
||||
User currentUser = userMapper.selectOne(new QueryWrapper<User>()
|
||||
.select("id,account")
|
||||
.eq("id", userId)
|
||||
.isNull("delete_time")
|
||||
.last("limit 1"));
|
||||
if (currentUser != null && StringUtils.isNotEmpty(currentUser.getAccount())) {
|
||||
Teacher teacher = teacherMapper.selectOne(new QueryWrapper<Teacher>()
|
||||
.eq("teacher_code", currentUser.getAccount())
|
||||
.isNull("delete_time")
|
||||
.last("limit 1"));
|
||||
if (teacher != null) {
|
||||
vo.setUserType(1);
|
||||
} else {
|
||||
vo.setUserType(0);
|
||||
}
|
||||
} else {
|
||||
vo.setUserType(0);
|
||||
}
|
||||
|
||||
//保存登录信息到session
|
||||
userSessionMapper.delete(new QueryWrapper<UserSession>().eq("user_id", userId).eq("terminal", terminal));
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
|||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.entity.Teacher;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.entity.user.UserAuth;
|
||||
import com.mdd.common.enums.ClientEnum;
|
||||
|
|
@ -15,6 +16,7 @@ import com.mdd.common.enums.UserEnum;
|
|||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.user.UserAuthMapper;
|
||||
import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.mapper.TeacherMapper;
|
||||
import com.mdd.common.plugin.notice.NoticeCheck;
|
||||
import com.mdd.common.plugin.wechat.WxMnpDriver;
|
||||
import com.mdd.common.util.*;
|
||||
|
|
@ -46,6 +48,9 @@ public class UserServiceImpl implements IUserService {
|
|||
@Resource
|
||||
UserAuthMapper userAuthMapper;
|
||||
|
||||
@Resource
|
||||
TeacherMapper teacherMapper;
|
||||
|
||||
/**
|
||||
* 个人中心
|
||||
*
|
||||
|
|
@ -83,6 +88,17 @@ public class UserServiceImpl implements IUserService {
|
|||
vo.setHasPassword(StringUtils.isNotBlank(user.getPassword()));
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(user.getCreateTime()));
|
||||
vo.setSex(UserEnum.getSexDesc(user.getSex()));
|
||||
|
||||
if (StringUtils.isNotEmpty(user.getAccount())) {
|
||||
Teacher teacher = teacherMapper.selectOne(new QueryWrapper<Teacher>()
|
||||
.eq("teacher_code", user.getAccount())
|
||||
.isNull("delete_time")
|
||||
.last("limit 1"));
|
||||
vo.setUserType(teacher != null ? 1 : 0);
|
||||
} else {
|
||||
vo.setUserType(0);
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,4 +27,7 @@ public class LoginTokenVo implements Serializable {
|
|||
@ApiModelProperty(value = "是否为新用户")
|
||||
private Integer isNew;
|
||||
|
||||
@ApiModelProperty(value = "用户类型: 0=学生, 1=招生老师")
|
||||
private Integer userType;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,5 +51,7 @@ public class UserCenterVo implements Serializable {
|
|||
@ApiModelProperty("是否绑定微信")
|
||||
private Boolean isAuth;
|
||||
|
||||
@ApiModelProperty(value = "用户类型: 0=学生, 1=招生老师")
|
||||
private Integer userType;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,9 +70,13 @@ export function getRecruitmentList(data: any) {
|
|||
}
|
||||
|
||||
// 获取招生统计数据(总招生人数、本日、本周、本月)
|
||||
export function getEnrollmentStatistical() {
|
||||
export function getEnrollmentStatistical(teacherId?: number) {
|
||||
const data: any = {}
|
||||
if (teacherId !== undefined && teacherId !== null) {
|
||||
data.teacherId = teacherId
|
||||
}
|
||||
return request.post(
|
||||
{ url: 'frontapi/enrollment/enrollmentStatistical' },
|
||||
{ url: 'frontapi/enrollment/enrollmentStatistical', data },
|
||||
{ urlPrefix: '' }
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<template>
|
||||
<u-tabbar
|
||||
v-if="showTabbar"
|
||||
v-model="current"
|
||||
v-bind="tabbarStyle"
|
||||
:list="tabbarList"
|
||||
|
|
@ -10,42 +9,44 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { navigateTo } from '@/utils/util'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
const current = ref()
|
||||
const appStore = useAppStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const allTabs = [
|
||||
{
|
||||
iconPath: '/static/yubaoming/home_icon.png',
|
||||
selectedIconPath: '/static/yubaoming/home_icon_active.png',
|
||||
text: '首页',
|
||||
pagePath: '/pages/index/index'
|
||||
},
|
||||
{
|
||||
iconPath: '/static/yubaoming/my_icon.png',
|
||||
selectedIconPath: '/static/yubaoming/my_icon_active.png',
|
||||
text: '我的',
|
||||
pagePath: '/pages/user/user',
|
||||
teacherOnly: true
|
||||
}
|
||||
]
|
||||
|
||||
const tabbarList = computed(() => {
|
||||
return appStore.getTabbarConfig
|
||||
?.filter((item: any) => item.is_show == 1)
|
||||
.map((item: any) => {
|
||||
return {
|
||||
iconPath: item.unselected,
|
||||
selectedIconPath: item.selected,
|
||||
text: item.name,
|
||||
link: item.link,
|
||||
pagePath: item.link.path
|
||||
}
|
||||
})
|
||||
})
|
||||
const showTabbar = computed(() => {
|
||||
const currentPages = getCurrentPages()
|
||||
const currentPage = currentPages[currentPages.length - 1]
|
||||
const current = tabbarList.value.findIndex((item: any) => {
|
||||
return item.pagePath === '/' + currentPage.route
|
||||
return allTabs.filter((item) => {
|
||||
if (item.teacherOnly && !userStore.isTeacher) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
return current >= 0
|
||||
})
|
||||
|
||||
const tabbarStyle = computed(() => ({
|
||||
activeColor: appStore.getStyleConfig.selected_color,
|
||||
inactiveColor: appStore.getStyleConfig.default_color
|
||||
activeColor: '#2979ff',
|
||||
inactiveColor: '#999999'
|
||||
}))
|
||||
|
||||
const nativeTabbar = ['/pages/index/index', '/pages/user/user']
|
||||
const handleChange = (index: number) => {
|
||||
const selectTab = tabbarList.value[index]
|
||||
const navigateType = nativeTabbar.includes(selectTab.link.path) ? 'switchTab' : 'reLaunch'
|
||||
navigateTo(selectTab.link, navigateType)
|
||||
uni.reLaunch({ url: selectTab.pagePath })
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import { isDevMode } from '@/utils/env'
|
||||
|
||||
// 微信小程序特殊处理:确保编译后也能正确获取 baseUrl
|
||||
// 优先级:环境变量 > 默认开发地址
|
||||
const envBaseUrl = import.meta.env.VITE_APP_BASE_URL || ''
|
||||
|
||||
let baseUrl = `${envBaseUrl}/`
|
||||
|
||||
/*
|
||||
* 微信小程序在`VITE_APP_BASE_URL`存在或`dev`模式下
|
||||
* 使用`VITE_APP_BASE_URL`的值
|
||||
* 其他情况使用`[baseUrl]`,方便服务端替换
|
||||
*/
|
||||
|
||||
//#ifdef MP-WEIXIN
|
||||
baseUrl = isDevMode() || envBaseUrl ? baseUrl : '[baseUrl]'
|
||||
// 微信小程序:如果环境变量为空,使用默认开发地址
|
||||
let baseUrl = envBaseUrl ? `${envBaseUrl}/` : 'http://192.168.123.123:8084/'
|
||||
//#endif
|
||||
|
||||
//#ifndef MP-WEIXIN
|
||||
let baseUrl = `${envBaseUrl}/`
|
||||
//#endif
|
||||
|
||||
const config = {
|
||||
|
|
|
|||
|
|
@ -87,23 +87,6 @@
|
|||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
"tabBar": {
|
||||
"iconWidth": "20px",
|
||||
"list": [
|
||||
{
|
||||
"iconPath": "static/images/tabbar/home.png",
|
||||
"selectedIconPath": "static/yubaoming/home_icon_active.png",
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"iconPath": "static/images/tabbar/user.png",
|
||||
"selectedIconPath": "static/yubaoming/my_icon_active.png",
|
||||
"pagePath": "pages/user/user",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
},
|
||||
"easycom": {
|
||||
"custom": {
|
||||
"router-navigate": "uniapp-router-next/components/router-navigate/router-navigate.vue",
|
||||
|
|
|
|||
|
|
@ -13,8 +13,10 @@
|
|||
class="school-logo"
|
||||
/>
|
||||
<view class="welcome-text">
|
||||
<view class="title">您好,招生老师</view>
|
||||
<view class="subtitle">祝您招生顺利,业绩长虹!</view>
|
||||
<view class="title" v-if="isTeacher">您好,招生老师</view>
|
||||
<view class="title" v-else>欢迎来到预报名系统</view>
|
||||
<view class="subtitle" v-if="isTeacher">祝您招生顺利,业绩长虹!</view>
|
||||
<view class="subtitle" v-else>请选择下方功能开始操作</view>
|
||||
</view>
|
||||
<image
|
||||
:src="homeImageSrc"
|
||||
|
|
@ -23,7 +25,7 @@
|
|||
/>
|
||||
|
||||
<!-- 快捷操作标题 -->
|
||||
<view class="section-title" v-if="isLogin">
|
||||
<view class="section-title" v-if="isLogin && isTeacher">
|
||||
<view class="title-icon"></view>
|
||||
<text>快捷操作</text>
|
||||
</view>
|
||||
|
|
@ -31,8 +33,8 @@
|
|||
|
||||
<!-- 主要内容区域 -->
|
||||
<view class="main-content">
|
||||
<!-- 快捷操作入口 -->
|
||||
<view class="quick-actions" v-if="isLogin">
|
||||
<!-- 招生老师:快捷操作入口 -->
|
||||
<view class="quick-actions" v-if="isLogin && isTeacher">
|
||||
<view class="action-item" @click="goToPreRegistration">
|
||||
<view class="action-icon blue">
|
||||
<u-icon name="edit-pen" size="40" color="#FFFFFF"></u-icon>
|
||||
|
|
@ -59,6 +61,22 @@
|
|||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 学生:功能入口 -->
|
||||
<view class="quick-actions" v-if="isLogin && !isTeacher">
|
||||
<view class="action-item" @click="goToPreRegistration">
|
||||
<view class="action-icon blue">
|
||||
<u-icon name="edit-pen" size="40" color="#FFFFFF"></u-icon>
|
||||
</view>
|
||||
<text class="action-text">预报名</text>
|
||||
</view>
|
||||
<view class="action-item" @click="goToPayment">
|
||||
<view class="action-icon orange">
|
||||
<u-icon name="rmb-circle" size="40" color="#FFFFFF"></u-icon>
|
||||
</view>
|
||||
<text class="action-text">缴费</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 未登录提示 -->
|
||||
<view class="login-tip" v-if="!isLogin">
|
||||
<view class="tip-icon">🔒</view>
|
||||
|
|
@ -101,12 +119,13 @@
|
|||
<!-- 微信小程序隐私弹窗 -->
|
||||
<MpPrivacyPopup></MpPrivacyPopup>
|
||||
<!-- #endif -->
|
||||
<tabbar />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getIndex } from '@/api/shop'
|
||||
import { getEnrollmentStatistical } from '@/api/app'
|
||||
import { getEnrollmentStatistical, getTeacherInfo } from '@/api/app'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
|
|
@ -121,7 +140,7 @@ import MpPrivacyPopup from './component/mp-privacy-popup.vue'
|
|||
|
||||
const appStore = useAppStore()
|
||||
const userStore = useUserStore()
|
||||
const { isLogin, userInfo } = storeToRefs(userStore)
|
||||
const { isLogin, userInfo, isTeacher } = storeToRefs(userStore)
|
||||
|
||||
const state = reactive<{
|
||||
pages: any[]
|
||||
|
|
@ -164,16 +183,42 @@ const getStats = async () => {
|
|||
if (!isLogin.value) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await getEnrollmentStatistical()
|
||||
// 接口直接返回数据对象,没有 code 包装
|
||||
if (res && res.total_enroll_count !== undefined) {
|
||||
stats.value = {
|
||||
total: res.total_enroll_count,
|
||||
today: res.today_enroll_count,
|
||||
week: res.week_enroll_count
|
||||
// 先获取教师信息,获取 teacherId
|
||||
let teacherId: number | undefined = undefined
|
||||
|
||||
// 尝试从 userInfo 中获取
|
||||
if (userInfo.value?.teacherId) {
|
||||
teacherId = userInfo.value.teacherId
|
||||
} else {
|
||||
// 如果 userInfo 中没有,调用 getTeacherInfo 获取
|
||||
try {
|
||||
const teacherRes = await getTeacherInfo({ id: userInfo.value.id })
|
||||
if (teacherRes && teacherRes.code === 1 && teacherRes.data) {
|
||||
teacherId = teacherRes.data.teacherId
|
||||
// 更新 userInfo
|
||||
userInfo.value.teacherId = teacherId
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取教师信息失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
if (teacherId) {
|
||||
console.log('首页获取招生统计,teacherId:', teacherId)
|
||||
const res = await getEnrollmentStatistical(teacherId)
|
||||
// 接口直接返回数据对象,没有 code 包装
|
||||
if (res && res.total_enroll_count !== undefined) {
|
||||
stats.value = {
|
||||
total: res.total_enroll_count,
|
||||
today: res.today_enroll_count,
|
||||
week: res.week_enroll_count
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('未找到 teacherId,跳过获取招生统计')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取招生统计失败:', error)
|
||||
}
|
||||
|
|
@ -192,7 +237,7 @@ const goToMyRecruitment = () => {
|
|||
}
|
||||
|
||||
const goToUser = () => {
|
||||
uni.switchTab({
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/user'
|
||||
})
|
||||
}
|
||||
|
|
@ -220,7 +265,7 @@ const initImageSources = async () => {
|
|||
}
|
||||
|
||||
const shareQrcode = () => {
|
||||
uni.switchTab({
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/user'
|
||||
})
|
||||
setTimeout(() => {
|
||||
|
|
@ -228,14 +273,39 @@ const shareQrcode = () => {
|
|||
}, 300)
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
onLoad((options: any) => {
|
||||
initImageSources()
|
||||
getData()
|
||||
|
||||
if (options.scene) {
|
||||
const invitationCode = decodeURIComponent(options.scene)
|
||||
if (isLogin.value) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/pre_registration/pre_registration?invitationCode=${invitationCode}`
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/login/login?invitationCode=${invitationCode}`
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
onShow(async () => {
|
||||
// 等待一下确保登录状态已确定
|
||||
// 等待登录状态确定
|
||||
await new Promise(resolve => setTimeout(resolve, 100))
|
||||
|
||||
// 如果没有登录,跳过
|
||||
if (!isLogin.value) {
|
||||
return
|
||||
}
|
||||
|
||||
// 如果 userInfo 中没有用户信息,先调用 getUser 获取用户信息
|
||||
if (!userInfo.value?.id) {
|
||||
await userStore.getUser()
|
||||
}
|
||||
|
||||
// 获取招生统计(getStats 内部会处理获取 teacherId)
|
||||
getStats()
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -376,13 +376,26 @@ const loginHandle = async (data: any) => {
|
|||
uni.hideLoading()
|
||||
return
|
||||
}
|
||||
userStore.login(data.token)
|
||||
console.log('登录返回数据:', data)
|
||||
console.log('登录返回userType:', data.user_type)
|
||||
userStore.login(data.token, data.user_type)
|
||||
console.log('登录后token:', userStore.token)
|
||||
console.log('登录后userType:', userStore.userType)
|
||||
console.log('登录后isTeacher:', userStore.isTeacher)
|
||||
await userStore.getUser()
|
||||
console.log('获取用户信息后userInfo:', userStore.userInfo)
|
||||
console.log('获取用户信息后userType:', userStore.userType)
|
||||
console.log('获取用户信息后isTeacher:', userStore.isTeacher)
|
||||
console.log('登录状态:', userStore.isLogin)
|
||||
uni.$u.toast('登录成功')
|
||||
uni.hideLoading()
|
||||
const invitationCode = cache.get('INVITATION_CODE')
|
||||
if (invitationCode) {
|
||||
cache.remove('INVITATION_CODE')
|
||||
router.reLaunch(`/pages/pre_registration/pre_registration?invitationCode=${invitationCode}`)
|
||||
cache.remove(BACK_URL)
|
||||
return
|
||||
}
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
const prevPage = pages[pages.length - 2]
|
||||
|
|
@ -393,16 +406,12 @@ const loginHandle = async (data: any) => {
|
|||
onLoad && onLoad(options)
|
||||
} else if (cache.get(BACK_URL)) {
|
||||
try {
|
||||
router.switchTab(cache.get(BACK_URL))
|
||||
router.reLaunch(cache.get(BACK_URL))
|
||||
} catch (error) {
|
||||
router.redirectTo(cache.get(BACK_URL))
|
||||
}
|
||||
} else {
|
||||
// try {
|
||||
// router.reLaunch('/pages/index/index')
|
||||
// } catch (error) {
|
||||
router.switchTab('/pages/index/index')
|
||||
//}
|
||||
router.reLaunch('/pages/index/index')
|
||||
}
|
||||
cache.remove(BACK_URL)
|
||||
}
|
||||
|
|
@ -496,7 +505,10 @@ const removeWxQuery = () => {
|
|||
}
|
||||
}
|
||||
|
||||
onLoad(async () => {
|
||||
onLoad(async (pageOptions: any) => {
|
||||
if (pageOptions.invitationCode) {
|
||||
cache.set('INVITATION_CODE', pageOptions.invitationCode)
|
||||
}
|
||||
//#ifdef H5
|
||||
const options = wechatOa.getAuthData()
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
<view class="td td-name">{{ item.name }}</view>
|
||||
<view class="td td-gender">{{ item.gender === 1 ? '男' : item.gender === 2 ? '女' : '-' }}</view>
|
||||
<view class="td td-score">{{ item.highSchoolScore || '-' }}</view>
|
||||
<view class="td td-major">{{ item.majorName || '-' }}</view>
|
||||
<view class="td td-major">{{ item.major_name || '-' }}</view>
|
||||
<view class="td td-status">
|
||||
<text :class="item.studentStatus === 1 ? 'status-enrolled' : 'status-pre'">
|
||||
{{ item.studentStatus === 1 ? '已报名' : '预报名' }}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,5 @@
|
|||
<template>
|
||||
<view class="payment">
|
||||
<u-navbar
|
||||
title="缴费"
|
||||
:border-bottom="false"
|
||||
back-icon-color="#333"
|
||||
title-color="#333"
|
||||
:background="{ background: '#FFFFFF' }"
|
||||
/>
|
||||
|
||||
<view class="payment-content">
|
||||
<!-- 缴费金额输入 -->
|
||||
<view class="amount-section">
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@
|
|||
class="dropdown-option"
|
||||
@click="selectMajor(index)"
|
||||
>
|
||||
{{ item.majorName }}
|
||||
{{ item.major_name }}
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
|
@ -233,11 +233,30 @@ const submitBtnStyle = {
|
|||
}
|
||||
|
||||
const getTeacherData = async (teacherId: string) => {
|
||||
console.log('=== getTeacherData 被调用 ===')
|
||||
console.log('teacherId:', teacherId)
|
||||
try {
|
||||
console.log('开始调用 getTeacherInfo...')
|
||||
const res = await getTeacherInfo({ teacherId: Number(teacherId) })
|
||||
console.log('getTeacherInfo 返回:', res)
|
||||
if (res.code === 1 && res.data) {
|
||||
formData.teacher = res.data.teacherName
|
||||
formData.recruitmentTeacherId = res.data.teacherId
|
||||
formData.teacher = res.data.teacher_name
|
||||
formData.recruitmentTeacherId = res.data.teacher_id
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取老师信息失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const getTeacherDataByInvitationCode = async (invitationCode: string) => {
|
||||
console.log('=== getTeacherDataByInvitationCode 被调用 ===')
|
||||
console.log('invitationCode:', invitationCode)
|
||||
try {
|
||||
const res = await getTeacherInfo({ invitationCode: invitationCode })
|
||||
console.log('getTeacherInfo 返回:', res)
|
||||
if (res.code === 1 && res.data) {
|
||||
formData.teacher = res.data.teacher_name
|
||||
formData.recruitmentTeacherId = res.data.teacher_id
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取老师信息失败:', error)
|
||||
|
|
@ -258,7 +277,7 @@ const getMajors = async () => {
|
|||
|
||||
const onMajorChange = (e: any) => {
|
||||
console.log('选择了专业:', e)
|
||||
formData.major = majorList.value[e.detail.value].majorName
|
||||
formData.major = majorList.value[e.detail.value].major_name
|
||||
majorIndex.value = e.detail.value
|
||||
}
|
||||
|
||||
|
|
@ -275,7 +294,7 @@ const clearMajor = () => {
|
|||
|
||||
const selectMajor = (index: number) => {
|
||||
console.log('选择了专业索引:', index)
|
||||
formData.major = majorList.value[index].majorName
|
||||
formData.major = majorList.value[index].major_name
|
||||
formData.majorId = majorList.value[index].id
|
||||
majorIndex.value = index
|
||||
showDropdown.value = false
|
||||
|
|
@ -441,8 +460,13 @@ onMounted(() => {
|
|||
})
|
||||
|
||||
onLoad((options: any) => {
|
||||
console.log('=== 预报名页面 onLoad ===')
|
||||
console.log('options:', options)
|
||||
|
||||
if (options.teacherId) {
|
||||
getTeacherData(options.teacherId)
|
||||
} else if (options.invitationCode) {
|
||||
getTeacherDataByInvitationCode(options.invitationCode)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
<tabbar />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -305,11 +306,12 @@ const getQrcode = async (teacherId?: number) => {
|
|||
console.log('=== getQrcode 执行结束 ===')
|
||||
}
|
||||
|
||||
const getStats = async () => {
|
||||
const getStats = async (teacherId?: number) => {
|
||||
console.log('=== getStats 开始执行 ===')
|
||||
console.log('传入的 teacherId:', teacherId)
|
||||
try {
|
||||
console.log('正在调用 getEnrollmentStatistical...')
|
||||
const res = await getEnrollmentStatistical()
|
||||
console.log('正在调用 getEnrollmentStatistical, teacherId:', teacherId)
|
||||
const res = await getEnrollmentStatistical(teacherId)
|
||||
console.log('接口返回结果:', res)
|
||||
// 接口直接返回数据对象,没有 code 包装
|
||||
if (res && res.total_enroll_count !== undefined) {
|
||||
|
|
@ -437,7 +439,7 @@ const logout = () => {
|
|||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
userStore.logout()
|
||||
uni.switchTab({
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
uni.$u.toast('已退出登录')
|
||||
|
|
@ -495,9 +497,9 @@ onShow(async () => {
|
|||
|
||||
console.log('开始调用 getQrcode 和 getStats, teacherIdForQrcode:', teacherIdForQrcode)
|
||||
console.log('userInfo 中的 teacherId:', userInfo.value?.teacherId)
|
||||
// 使用本地变量传递teacherId,避免响应式延迟问题
|
||||
// 使用本地变量传递 teacherId,避免响应式延迟问题
|
||||
await getQrcode(teacherIdForQrcode)
|
||||
await getStats()
|
||||
await getStats(teacherIdForQrcode)
|
||||
} else {
|
||||
console.log('条件不满足,跳过数据获取')
|
||||
console.log('isLogin:', isLogin.value)
|
||||
|
|
|
|||
|
|
@ -8,16 +8,19 @@ interface UserSate {
|
|||
userInfo: Record<string, any>
|
||||
token: string | null
|
||||
temToken: string | null
|
||||
userType: number
|
||||
}
|
||||
export const useUserStore = defineStore({
|
||||
id: 'userStore',
|
||||
state: (): UserSate => ({
|
||||
userInfo: {},
|
||||
token: cache.get(TOKEN_KEY) || null,
|
||||
temToken: null
|
||||
temToken: null,
|
||||
userType: 0
|
||||
}),
|
||||
getters: {
|
||||
isLogin: (state) => !!state.token
|
||||
isLogin: (state) => !!state.token,
|
||||
isTeacher: (state) => state.userType === 1
|
||||
},
|
||||
actions: {
|
||||
async getUser() {
|
||||
|
|
@ -32,14 +35,20 @@ export const useUserStore = defineStore({
|
|||
try {
|
||||
const data = await getUserCenter()
|
||||
this.userInfo = data
|
||||
if (data.user_type !== undefined && data.user_type !== null) {
|
||||
this.userType = data.user_type
|
||||
}
|
||||
resetSession()
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
}
|
||||
},
|
||||
login(token: string) {
|
||||
login(token: string, userType?: number) {
|
||||
console.log('保存token:', token)
|
||||
this.token = token
|
||||
if (userType !== undefined && userType !== null) {
|
||||
this.userType = userType
|
||||
}
|
||||
cache.set(TOKEN_KEY, token)
|
||||
console.log('保存后从cache读取token:', cache.get(TOKEN_KEY))
|
||||
resetSession()
|
||||
|
|
@ -47,6 +56,7 @@ export const useUserStore = defineStore({
|
|||
logout() {
|
||||
this.token = ''
|
||||
this.userInfo = {}
|
||||
this.userType = 0
|
||||
cache.remove(TOKEN_KEY)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,54 +6,5 @@
|
|||
import { getTabBarIconPath } from './configUtils'
|
||||
import { ensureStorageConfig } from './configUtils'
|
||||
|
||||
/**
|
||||
* 动态设置tabbar图标
|
||||
* @param index tabbar索引
|
||||
* @param iconType 图标类型
|
||||
* @param isActive 是否为选中状态
|
||||
*/
|
||||
export function setTabBarIcon(index: number, iconType: 'home' | 'user', isActive: boolean = false) {
|
||||
try {
|
||||
// 获取阿里云图标路径
|
||||
const iconPath = getTabBarIconPath(iconType, isActive)
|
||||
|
||||
// 设置tabbar图标
|
||||
if (isActive) {
|
||||
uni.setTabBarItem({
|
||||
index,
|
||||
selectedIconPath: iconPath
|
||||
})
|
||||
} else {
|
||||
uni.setTabBarItem({
|
||||
index,
|
||||
iconPath
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`设置tabbar图标失败:`, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新所有tabbar图标
|
||||
*/
|
||||
export function updateAllTabBarIcons() {
|
||||
// 更新首页tabbar图标 (索引0)
|
||||
setTabBarIcon(0, 'home', false)
|
||||
setTabBarIcon(0, 'home', true)
|
||||
|
||||
// 更新个人中心tabbar图标 (索引1)
|
||||
setTabBarIcon(1, 'user', false)
|
||||
setTabBarIcon(1, 'user', true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化tabbar图标
|
||||
*/
|
||||
export function initTabBarIcons() {
|
||||
// 延迟执行,确保配置已加载
|
||||
setTimeout(async () => {
|
||||
await ensureStorageConfig()
|
||||
updateAllTabBarIcons()
|
||||
}, 1000)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ export function navigateTo(
|
|||
|
||||
const url = link?.query ? `${link.path}?${objectToQuery(link?.query)}` : link.path
|
||||
|
||||
;(navigateType == 'switchTab' || link.canTab) && uni.switchTab({ url })
|
||||
navigateType == 'navigateTo' && uni.navigateTo({ url })
|
||||
navigateType == 'reLaunch' && uni.reLaunch({ url })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import uni from '@dcloudio/vite-plugin-uni'
|
||||
import tailwindcss from 'tailwindcss'
|
||||
import autoprefixer from 'autoprefixer'
|
||||
|
|
@ -24,26 +24,19 @@ if (!weappTailwindcssDisabled) {
|
|||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [uni(), uniRouter(), weappTailwindcssDisabled ? undefined : vwt()],
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: postcssPlugin
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 8991,
|
||||
proxy: {
|
||||
'/frontapi': {
|
||||
target: 'http://192.168.123.91:8084',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/frontapi/, '/frontapi')
|
||||
},
|
||||
'/adminapi': {
|
||||
target: 'http://192.168.123.91:8084',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/adminapi/, '/adminapi')
|
||||
export default defineConfig(({ mode }) => {
|
||||
// 加载环境变量,支持 .env, .env.local, .env.development, .env.production
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
|
||||
return {
|
||||
plugins: [uni(), uniRouter(), weappTailwindcssDisabled ? undefined : vwt()],
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: postcssPlugin
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 8991
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue