一体机的登录修复
This commit is contained in:
@@ -256,6 +256,7 @@ import dictLabel from '@/components/dict-Label/dict-Label.vue';
|
|||||||
import RadarMap from './component/radarMap.vue';
|
import RadarMap from './component/radarMap.vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import useUserStore from '@/stores/useUserStore';
|
import useUserStore from '@/stores/useUserStore';
|
||||||
|
import { checkLoginAndNavigate } from '@/utils/loginHelper';
|
||||||
const { userInfo } = storeToRefs(useUserStore());
|
const { userInfo } = storeToRefs(useUserStore());
|
||||||
// 与首页一致的用户类型获取:优先store,兜底缓存
|
// 与首页一致的用户类型获取:优先store,兜底缓存
|
||||||
const currentUserType = computed(() => {
|
const currentUserType = computed(() => {
|
||||||
@@ -445,9 +446,7 @@ function getCompetivetuveness(encryptJobId) {
|
|||||||
|
|
||||||
// 申请岗位
|
// 申请岗位
|
||||||
function jobApply() {
|
function jobApply() {
|
||||||
const tokenValue = uni.getStorageSync('token') || '';
|
if (!checkLoginAndNavigate({ content: '投递简历请先登录' })) {
|
||||||
if (!tokenValue) {
|
|
||||||
$api.msg('请您先登录');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 显示确认弹窗
|
// 显示确认弹窗
|
||||||
@@ -502,6 +501,9 @@ function cancelApply() {
|
|||||||
|
|
||||||
// 取消/收藏岗位
|
// 取消/收藏岗位
|
||||||
function jobCollection() {
|
function jobCollection() {
|
||||||
|
if (!checkLoginAndNavigate({ content: '收藏请先登录' })) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const encryptJobId = jobIdRef.value;
|
const encryptJobId = jobIdRef.value;
|
||||||
if (jobInfo.value.isCollection) {
|
if (jobInfo.value.isCollection) {
|
||||||
$api.createRequest(`/app/job/collection/${encryptJobId}`, {}, 'DELETE').then((resData) => {
|
$api.createRequest(`/app/job/collection/${encryptJobId}`, {}, 'DELETE').then((resData) => {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
<!-- <view class="h5-action-btn press-button" @click="handleH5SalaryClick">
|
<!-- <view class="h5-action-btn press-button" @click="handleH5SalaryClick">
|
||||||
<view class="btn-text">薪酬信息</view>
|
<view class="btn-text">薪酬信息</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
<view class="h5-action-btn press-button" @click="handelGoResumeGuide()">
|
<view class="h5-action-btn press-button" @click="handleServiceClick('resume-creation')">
|
||||||
<view class="btn-text">简历指导</view>
|
<view class="btn-text">简历指导</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -937,18 +937,8 @@ const handleLoginSuccess = () => {
|
|||||||
// onLoad 函数已移至下方,包含筛选参数处理
|
// onLoad 函数已移至下方,包含筛选参数处理
|
||||||
|
|
||||||
// 处理附近工作点击
|
// 处理附近工作点击
|
||||||
const handleNearbyClick = (options ) => {
|
const handleNearbyClick = () => {
|
||||||
// #ifdef MP-WEIXIN
|
navTo('/packageA/pages/nearby/nearby');
|
||||||
if (checkLogin()) {
|
|
||||||
navTo('/packageA/pages/nearby/nearby');
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
// #ifdef H5
|
|
||||||
const token = options.token || uni.getStorageSync('zkr-token');
|
|
||||||
if (token) {
|
|
||||||
navTo('/packageA/pages/nearby/nearby');
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
};
|
};
|
||||||
const handleNoticeClick = () =>{
|
const handleNoticeClick = () =>{
|
||||||
if (checkLogin()) {
|
if (checkLogin()) {
|
||||||
@@ -976,20 +966,12 @@ function handleInstitutionClick(type){
|
|||||||
}
|
}
|
||||||
// 处理服务功能点击
|
// 处理服务功能点击
|
||||||
const handleServiceClick = (serviceType) => {
|
const handleServiceClick = (serviceType) => {
|
||||||
if (checkLogin()) {
|
const noLoginRequired = ['resume-creation'];
|
||||||
|
if (noLoginRequired.includes(serviceType) || checkLogin()) {
|
||||||
navToService(serviceType);
|
navToService(serviceType);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// H5的简历指导跳转
|
|
||||||
const handelGoResumeGuide = () => {
|
|
||||||
const token = uni.getStorageSync('zkr-token');
|
|
||||||
// myToken.value = token;
|
|
||||||
if (token) {
|
|
||||||
// navTo()
|
|
||||||
navTo('/pages/resume-guide/resume-guide');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// 处理直播按钮点击
|
// 处理直播按钮点击
|
||||||
const handleLiveClick = () => {
|
const handleLiveClick = () => {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
import useUserStore from '@/stores/useUserStore';
|
import useUserStore from '@/stores/useUserStore';
|
||||||
|
|
||||||
|
/** 一体机 H5 首页地址 */
|
||||||
|
export const MACHINE_HOME_URL = 'https://www.xjksly.cn/mechine-single-vue/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查当前平台类型
|
* 检查当前平台类型
|
||||||
* @returns {string} 平台类型:'mp-weixin' | 'h5' | 'app'
|
* @returns {string} 平台类型:'mp-weixin' | 'h5' | 'app'
|
||||||
@@ -88,21 +91,64 @@ export function navigateToLoginPage(options = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查用户是否已登录
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function isUserLoggedIn() {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const tokenValue = uni.getStorageSync('token') || '';
|
||||||
|
return !!(tokenValue && userStore.hasLogin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* H5 一体机端:弹窗提示登录,点击确定跳转一体机首页
|
||||||
|
* @param {Object} options
|
||||||
|
* @param {string} options.content 提示文案
|
||||||
|
* @returns {Promise<boolean>} 用户是否点击确定
|
||||||
|
*/
|
||||||
|
export function promptH5MachineLogin(options = {}) {
|
||||||
|
const { content = '您还未登录,请先登录' } = options;
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content,
|
||||||
|
showCancel: true,
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmText: '确定',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
// #ifdef H5
|
||||||
|
window.location.href = MACHINE_HOME_URL;
|
||||||
|
// #endif
|
||||||
|
resolve(true);
|
||||||
|
} else {
|
||||||
|
resolve(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: () => resolve(false),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查登录状态,如果未登录则跳转到对应登录页面
|
* 检查登录状态,如果未登录则跳转到对应登录页面
|
||||||
* @param {Object} options 选项
|
* @param {Object} options 选项
|
||||||
* @param {string} options.redirectUrl 登录成功后跳转的URL
|
* @param {string} options.redirectUrl 登录成功后跳转的URL
|
||||||
* @param {string} options.loginType 登录类型
|
* @param {string} options.loginType 登录类型
|
||||||
|
* @param {string} options.content H5 一体机端登录提示文案
|
||||||
* @returns {boolean} 是否已登录
|
* @returns {boolean} 是否已登录
|
||||||
*/
|
*/
|
||||||
export function checkLoginAndNavigate(options = {}) {
|
export function checkLoginAndNavigate(options = {}) {
|
||||||
const userStore = useUserStore();
|
if (isUserLoggedIn()) {
|
||||||
|
|
||||||
if (userStore.hasLogin) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 未登录,跳转到对应登录页面
|
if (getPlatformType() === 'h5') {
|
||||||
|
promptH5MachineLogin(options);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
navigateToLoginPage(options);
|
navigateToLoginPage(options);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -202,6 +248,9 @@ export default {
|
|||||||
getPlatformType,
|
getPlatformType,
|
||||||
navigateToLoginPage,
|
navigateToLoginPage,
|
||||||
checkLoginAndNavigate,
|
checkLoginAndNavigate,
|
||||||
|
isUserLoggedIn,
|
||||||
|
promptH5MachineLogin,
|
||||||
|
MACHINE_HOME_URL,
|
||||||
parseIdCardLoginParams,
|
parseIdCardLoginParams,
|
||||||
decodeIdCardBase64,
|
decodeIdCardBase64,
|
||||||
refreshWxLoginCode,
|
refreshWxLoginCode,
|
||||||
|
|||||||
Reference in New Issue
Block a user