flat: 优化
This commit is contained in:
@@ -165,7 +165,7 @@ function serchforIt(defaultId) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$api.createRequest('/app/common/jobTitle/treeselect', {}, 'GET').then((resData) => {
|
const LoadCache = (resData) => {
|
||||||
if (userInfo.value.jobTitleId) {
|
if (userInfo.value.jobTitleId) {
|
||||||
const ids = userInfo.value.jobTitleId.split(',').map((id) => Number(id));
|
const ids = userInfo.value.jobTitleId.split(',').map((id) => Number(id));
|
||||||
count.value = ids.length;
|
count.value = ids.length;
|
||||||
@@ -174,7 +174,8 @@ function serchforIt(defaultId) {
|
|||||||
state.jobTitleId = userInfo.value.jobTitleId;
|
state.jobTitleId = userInfo.value.jobTitleId;
|
||||||
state.stations = resData.data;
|
state.stations = resData.data;
|
||||||
state.visible = true;
|
state.visible = true;
|
||||||
});
|
};
|
||||||
|
$api.createRequestWithCache('/app/common/jobTitle/treeselect', {}, 'GET', false, LoadCache).then(LoadCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ function getJobList(type = 'add') {
|
|||||||
current: pageState.page,
|
current: pageState.page,
|
||||||
pageSize: pageState.pageSize,
|
pageSize: pageState.pageSize,
|
||||||
};
|
};
|
||||||
$api.createRequest('/app/user/apply/job', params).then((resData) => {
|
const LoadCache = (resData) => {
|
||||||
const { rows, total } = resData;
|
const { rows, total } = resData;
|
||||||
if (type === 'add') {
|
if (type === 'add') {
|
||||||
const str = pageState.pageSize * (pageState.page - 1);
|
const str = pageState.pageSize * (pageState.page - 1);
|
||||||
@@ -66,8 +66,9 @@ function getJobList(type = 'add') {
|
|||||||
// pageState.list = resData.rows;
|
// pageState.list = resData.rows;
|
||||||
pageState.total = resData.total;
|
pageState.total = resData.total;
|
||||||
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
|
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
|
||||||
console.log(pageState.list);
|
};
|
||||||
});
|
|
||||||
|
$api.createRequestWithCache('/app/user/apply/job', params, 'GET', false, {}, LoadCache).then(LoadCache);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -176,12 +176,13 @@ function complete(values) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getTree() {
|
function getTree() {
|
||||||
$api.createRequest('/app/common/jobTitle/treeselect', {}, 'GET').then((resData) => {
|
const LoadCache = (resData) => {
|
||||||
if (resData.code === 200) {
|
if (resData.code === 200) {
|
||||||
dataSource.value = flattenTree(resData.data);
|
dataSource.value = flattenTree(resData.data);
|
||||||
treeDataList.value = resData.data;
|
treeDataList.value = resData.data;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
$api.createRequestWithCache('/app/common/jobTitle/treeselect', {}, 'GET', false, LoadCache).then(LoadCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flattenTree(treeData, parentPath = '') {
|
function flattenTree(treeData, parentPath = '') {
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ function getJobList(type = 'add') {
|
|||||||
current: pageState.page,
|
current: pageState.page,
|
||||||
pageSize: pageState.pageSize,
|
pageSize: pageState.pageSize,
|
||||||
};
|
};
|
||||||
$api.createRequest('/app/user/collection/job', params).then((resData) => {
|
const LoadCache = (resData) => {
|
||||||
|
console.log(resData);
|
||||||
const { rows, total } = resData;
|
const { rows, total } = resData;
|
||||||
if (type === 'add') {
|
if (type === 'add') {
|
||||||
const str = pageState.pageSize * (pageState.page - 1);
|
const str = pageState.pageSize * (pageState.page - 1);
|
||||||
@@ -191,7 +192,8 @@ function getJobList(type = 'add') {
|
|||||||
// pageState.list = resData.rows;
|
// pageState.list = resData.rows;
|
||||||
pageState.total = resData.total;
|
pageState.total = resData.total;
|
||||||
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
|
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
|
||||||
});
|
};
|
||||||
|
$api.createRequestWithCache('/app/user/collection/job', params, 'GET', false, {}, LoadCache).then(LoadCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCompanyList(type = 'add') {
|
function getCompanyList(type = 'add') {
|
||||||
@@ -206,7 +208,7 @@ function getCompanyList(type = 'add') {
|
|||||||
current: pageCompanyState.page,
|
current: pageCompanyState.page,
|
||||||
pageSize: pageCompanyState.pageSize,
|
pageSize: pageCompanyState.pageSize,
|
||||||
};
|
};
|
||||||
$api.createRequest('/app/user/collection/company', params).then((resData) => {
|
const LoadCache = (resData) => {
|
||||||
const { rows, total } = resData;
|
const { rows, total } = resData;
|
||||||
if (type === 'add') {
|
if (type === 'add') {
|
||||||
const str = pageCompanyState.pageSize * (pageCompanyState.page - 1);
|
const str = pageCompanyState.pageSize * (pageCompanyState.page - 1);
|
||||||
@@ -219,7 +221,8 @@ function getCompanyList(type = 'add') {
|
|||||||
// pageCompanyState.list = resData.rows;
|
// pageCompanyState.list = resData.rows;
|
||||||
pageCompanyState.total = resData.total;
|
pageCompanyState.total = resData.total;
|
||||||
pageCompanyState.maxPage = Math.ceil(pageCompanyState.total / pageCompanyState.pageSize);
|
pageCompanyState.maxPage = Math.ceil(pageCompanyState.total / pageCompanyState.pageSize);
|
||||||
});
|
};
|
||||||
|
$api.createRequestWithCache('/app/user/collection/company', params, 'GET', false, {}, LoadCache).then(LoadCache);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ onLoad((options) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function getJobFairInfo(id, name) {
|
function getJobFairInfo(id, name) {
|
||||||
$api.createRequest(`/app/internal/jobFairThirdPart/${id}`).then((resData) => {
|
$api.createRequest(`/app/internal/jobFairThirdPart/${id}`, {}, 'GET', true).then((resData) => {
|
||||||
fairInfo.value = resData.data;
|
fairInfo.value = resData.data;
|
||||||
hasAppointment();
|
hasAppointment();
|
||||||
});
|
});
|
||||||
@@ -152,21 +152,24 @@ function getCompanyList(type = 'add') {
|
|||||||
current: pageState.current,
|
current: pageState.current,
|
||||||
pageSize: pageState.pageSize,
|
pageSize: pageState.pageSize,
|
||||||
};
|
};
|
||||||
$api.createRequest(`/app/internal/companyThirdPart/?zphID=${jobFairId}&zphmc=${jobFairName}`, params).then(
|
$api.createRequest(
|
||||||
(resData) => {
|
`/app/internal/companyThirdPart/?zphID=${jobFairId}&zphmc=${jobFairName}`,
|
||||||
const { rows, total } = resData;
|
params,
|
||||||
if (type === 'add') {
|
'GET',
|
||||||
const str = pageState.pageSize * (pageState.current - 1);
|
true
|
||||||
const end = pageState.list.length;
|
).then((resData) => {
|
||||||
const reslist = rows;
|
const { rows, total } = resData;
|
||||||
pageState.list.splice(str, end, ...reslist);
|
if (type === 'add') {
|
||||||
} else {
|
const str = pageState.pageSize * (pageState.current - 1);
|
||||||
pageState.list = rows;
|
const end = pageState.list.length;
|
||||||
}
|
const reslist = rows;
|
||||||
pageState.total = resData.total;
|
pageState.list.splice(str, end, ...reslist);
|
||||||
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
|
} else {
|
||||||
|
pageState.list = rows;
|
||||||
}
|
}
|
||||||
);
|
pageState.total = resData.total;
|
||||||
|
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasAppointment = () => {
|
const hasAppointment = () => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<image src="@/static/icon/collect2.png" v-else @click="jobCollection"></image>
|
<image src="@/static/icon/collect2.png" v-else @click="jobCollection"></image>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 根据 dataType 显示不同内容 -->
|
<!-- 根据 dataType 显示不同内容 -->
|
||||||
<view class="content" v-show="!isEmptyObject(jobInfo)">
|
<view class="content" v-show="!isEmptyObject(jobInfo)">
|
||||||
<!-- 顶部信息区域 -->
|
<!-- 顶部信息区域 -->
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
:is-month="true"
|
:is-month="true"
|
||||||
></Salary-Expectation>
|
></Salary-Expectation>
|
||||||
</view>
|
</view>
|
||||||
<view class="top-salary" v-else>
|
<view class="top-salary" v-else>
|
||||||
<Salary-Expectation
|
<Salary-Expectation
|
||||||
:max-salary="jobInfo.maxSalary"
|
:max-salary="jobInfo.maxSalary"
|
||||||
:min-salary="jobInfo.minSalary"
|
:min-salary="jobInfo.minSalary"
|
||||||
@@ -35,17 +35,17 @@
|
|||||||
<view class="info-img"><image src="/static/icon/post12.png"></image></view>
|
<view class="info-img"><image src="/static/icon/post12.png"></image></view>
|
||||||
<!-- 第三方数据展示 -->
|
<!-- 第三方数据展示 -->
|
||||||
<view class="info-text" v-if="dataType === 2">
|
<view class="info-text" v-if="dataType === 2">
|
||||||
{{jobInfo.xlyq == '不限' ? '学历不限' : jobInfo.xlyq}}
|
{{ jobInfo.xlyq == '不限' ? '学历不限' : jobInfo.xlyq }}
|
||||||
</view>
|
</view>
|
||||||
<!-- 原数据展示 -->
|
<!-- 原数据展示 -->
|
||||||
<view class="info-text" v-else>
|
<view class="info-text" v-else>
|
||||||
<dict-Label dictType="experience" :value="jobInfo.experience"></dict-Label>
|
<dict-Label dictType="experience" :value="jobInfo.experience"></dict-Label>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="info-img mar_le20"><image src="/static/icon/post13.png"></image></view>
|
<view class="info-img mar_le20"><image src="/static/icon/post13.png"></image></view>
|
||||||
<!-- 第三方数据展示 -->
|
<!-- 第三方数据展示 -->
|
||||||
<view class="info-text" v-if="dataType === 2">
|
<view class="info-text" v-if="dataType === 2">
|
||||||
{{jobInfo.gwgzjy == '不限' ? '经验不限' : jobInfo.gwgzjy}}
|
{{ jobInfo.gwgzjy == '不限' ? '经验不限' : jobInfo.gwgzjy }}
|
||||||
</view>
|
</view>
|
||||||
<!-- 原数据展示 -->
|
<!-- 原数据展示 -->
|
||||||
<view class="info-text" v-else>
|
<view class="info-text" v-else>
|
||||||
@@ -83,12 +83,7 @@
|
|||||||
<view class="content-card">
|
<view class="content-card">
|
||||||
<view class="card-title">
|
<view class="card-title">
|
||||||
<text class="title">公司信息</text>
|
<text class="title">公司信息</text>
|
||||||
<text
|
<text class="btntext button-click" @click="handleCompanyDetail">单位详情</text>
|
||||||
class="btntext button-click"
|
|
||||||
@click="handleCompanyDetail"
|
|
||||||
>
|
|
||||||
单位详情
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="company-info">
|
<view class="company-info">
|
||||||
<view class="companyinfo-left">
|
<view class="companyinfo-left">
|
||||||
@@ -103,12 +98,12 @@
|
|||||||
:value="jobInfo.company?.industry"
|
:value="jobInfo.company?.industry"
|
||||||
></dict-tree-Label>
|
></dict-tree-Label>
|
||||||
<span v-if="dataType !== 2 && jobInfo.company?.industry"> </span>
|
<span v-if="dataType !== 2 && jobInfo.company?.industry"> </span>
|
||||||
<dict-Label
|
<dict-Label
|
||||||
v-if="dataType !== 2"
|
v-if="dataType !== 2"
|
||||||
dictType="scale"
|
dictType="scale"
|
||||||
:value="jobInfo.company?.scale"
|
:value="jobInfo.company?.scale"
|
||||||
></dict-Label>
|
></dict-Label>
|
||||||
<span v-if="dataType === 2">{{jobInfo.qyxz}}</span>
|
<span v-if="dataType === 2">{{ jobInfo.qyxz }}</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="row2">
|
<view class="row2">
|
||||||
<text>在招</text>
|
<text>在招</text>
|
||||||
@@ -156,19 +151,24 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view style="height: 24px"></view>
|
<view style="height: 24px"></view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<view class="footer">
|
<view class="footer">
|
||||||
<view v-if="dataType==2" class="btn-wq button-click" :class="{'btn-des' : jobInfo.isApply}" @click="jobApply">
|
<view
|
||||||
<span v-if="jobInfo.isApply"> 已投递 </span>
|
v-if="dataType == 2"
|
||||||
<span v-if="!jobInfo.isApply"> 立即投递</span>
|
class="btn-wq button-click"
|
||||||
|
:class="{ 'btn-des': jobInfo.isApply }"
|
||||||
|
@click="jobApply"
|
||||||
|
>
|
||||||
|
<span v-if="jobInfo.isApply">已投递</span>
|
||||||
|
<span v-if="!jobInfo.isApply">立即投递</span>
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="btn-wq button-click" @click="jobApply">
|
<view v-else class="btn-wq button-click" @click="jobApply">
|
||||||
<span v-if="jobInfo.isApply"> 立即前往</span>
|
<span v-if="jobInfo.isApply">立即前往</span>
|
||||||
<span v-if="!jobInfo.isApply">立即投递 </span>
|
<span v-if="!jobInfo.isApply">立即投递</span>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -232,12 +232,12 @@ function getDetail(jobId) {
|
|||||||
if (dataType.value === 2) {
|
if (dataType.value === 2) {
|
||||||
// 第三方数据接口
|
// 第三方数据接口
|
||||||
return new Promise((reslove, reject) => {
|
return new Promise((reslove, reject) => {
|
||||||
$api.createRequest(`/app/internal/jobThirdPart/${jobId}`).then((resData) => {
|
$api.createRequest(`/app/internal/jobThirdPart/${jobId}`, {}, 'GET', true).then((resData) => {
|
||||||
const { gsID, gsmc, zphID } = resData.data;
|
const { gsID, gsmc, zphID } = resData.data;
|
||||||
jobInfo.value = resData.data;
|
jobInfo.value = resData.data;
|
||||||
reslove(resData.data);
|
reslove(resData.data);
|
||||||
getCompanyIsAJobs(gsID, gsmc, zphID);
|
getCompanyIsAJobs(gsID, gsmc, zphID);
|
||||||
|
|
||||||
if (resData.data.latitude && resData.data.longitude) {
|
if (resData.data.latitude && resData.data.longitude) {
|
||||||
initMapCovers(resData.data.latitude, resData.data.longitude, resData.data.gsmc);
|
initMapCovers(resData.data.latitude, resData.data.longitude, resData.data.gsmc);
|
||||||
}
|
}
|
||||||
@@ -245,12 +245,12 @@ function getDetail(jobId) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 原数据接口
|
// 原数据接口
|
||||||
$api.createRequest(`/app/job/${jobId}`).then((resData) => {
|
$api.createRequest(`/app/job/${jobId}`, {}, 'GET', true).then((resData) => {
|
||||||
const { latitude, longitude, companyName, companyId } = resData.data;
|
const { latitude, longitude, companyName, companyId } = resData.data;
|
||||||
jobInfo.value = resData.data;
|
jobInfo.value = resData.data;
|
||||||
getCompanyIsAJobs(companyId);
|
getCompanyIsAJobs(companyId);
|
||||||
getCompetivetuveness(jobId);
|
getCompetivetuveness(jobId);
|
||||||
|
|
||||||
if (latitude && longitude) {
|
if (latitude && longitude) {
|
||||||
initMapCovers(latitude, longitude, companyName);
|
initMapCovers(latitude, longitude, companyName);
|
||||||
}
|
}
|
||||||
@@ -315,12 +315,12 @@ function jobApply() {
|
|||||||
if (dataType.value === 2) {
|
if (dataType.value === 2) {
|
||||||
// 第三方数据申请逻辑
|
// 第三方数据申请逻辑
|
||||||
const params = {
|
const params = {
|
||||||
jobid:jobInfo.value.id,
|
jobid: jobInfo.value.id,
|
||||||
jobname:jobInfo.value.gwmc
|
jobname: jobInfo.value.gwmc,
|
||||||
}
|
};
|
||||||
if (jobInfo.value.isApply) {
|
if (jobInfo.value.isApply) {
|
||||||
$api.msg('已经投递过该岗位了~');
|
$api.msg('已经投递过该岗位了~');
|
||||||
return ;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$api.createRequest(`/app/internal/sendResume`, params, 'POST').then((resData) => {
|
$api.createRequest(`/app/internal/sendResume`, params, 'POST').then((resData) => {
|
||||||
$api.msg('投递成功');
|
$api.msg('投递成功');
|
||||||
@@ -380,7 +380,9 @@ function jobCollection() {
|
|||||||
// 处理公司详情跳转
|
// 处理公司详情跳转
|
||||||
function handleCompanyDetail() {
|
function handleCompanyDetail() {
|
||||||
if (dataType.value === 2) {
|
if (dataType.value === 2) {
|
||||||
navTo(`/packageA/pages/UnitDetails/UnitDetails?companyId=${jobInfo.value.gsID}&companyName=${jobInfo.value.gsmc}&zphId=${jobInfo.value.zphID}&dataType=2`);
|
navTo(
|
||||||
|
`/packageA/pages/UnitDetails/UnitDetails?companyId=${jobInfo.value.gsID}&companyName=${jobInfo.value.gsmc}&zphId=${jobInfo.value.zphID}&dataType=2`
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
navTo(`/packageA/pages/UnitDetails/UnitDetails?companyId=${jobInfo.value.company.companyId}`);
|
navTo(`/packageA/pages/UnitDetails/UnitDetails?companyId=${jobInfo.value.company.companyId}`);
|
||||||
}
|
}
|
||||||
@@ -660,4 +662,4 @@ for i in 0..100
|
|||||||
box-shadow: 0rpx -4rpx 24rpx 0rpx rgba(11,44,112,0.12);
|
box-shadow: 0rpx -4rpx 24rpx 0rpx rgba(11,44,112,0.12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ function getList(type = 'add', loading = true) {
|
|||||||
pageSize: pageState.pageSize,
|
pageSize: pageState.pageSize,
|
||||||
type: ranItem.value.value,
|
type: ranItem.value.value,
|
||||||
};
|
};
|
||||||
$api.createRequest('/app/user/collection/fair', params).then((resData) => {
|
const LoadCache = (resData) => {
|
||||||
const { rows, total } = resData;
|
const { rows, total } = resData;
|
||||||
if (type === 'add') {
|
if (type === 'add') {
|
||||||
const str = pageState.pageSize * (pageState.page - 1);
|
const str = pageState.pageSize * (pageState.page - 1);
|
||||||
@@ -140,7 +140,8 @@ function getList(type = 'add', loading = true) {
|
|||||||
// pageState.list = resData.rows;
|
// pageState.list = resData.rows;
|
||||||
pageState.total = resData.total;
|
pageState.total = resData.total;
|
||||||
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
|
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
|
||||||
});
|
};
|
||||||
|
$api.createRequestWithCache('/app/user/collection/fair', params, 'GET', false, {}, LoadCache).then(LoadCache);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ function getFair(type = 'add') {
|
|||||||
if (currentDay.value?.fullDate) {
|
if (currentDay.value?.fullDate) {
|
||||||
params.zphjbsj = currentDay.value.fullDate.replace(/-/g, '');
|
params.zphjbsj = currentDay.value.fullDate.replace(/-/g, '');
|
||||||
}
|
}
|
||||||
$api.createRequest('/app/internal/jobFairThirdPart', params).then((resData) => {
|
$api.createRequest('/app/internal/jobFairThirdPart', params, 'GET', true).then((resData) => {
|
||||||
const { rows, total } = resData;
|
const { rows, total } = resData;
|
||||||
if (type === 'add') {
|
if (type === 'add') {
|
||||||
// const str = pageState.pageSize * (pageState.page - 1);
|
// const str = pageState.pageSize * (pageState.page - 1);
|
||||||
|
|||||||
@@ -241,9 +241,10 @@ function nextStep() {
|
|||||||
|
|
||||||
// 获取职位
|
// 获取职位
|
||||||
function getTreeselect() {
|
function getTreeselect() {
|
||||||
$api.createRequest('/app/common/jobTitle/treeselect', {}, 'GET').then((resData) => {
|
const LoadCache = (resData) => {
|
||||||
state.station = resData.data;
|
state.station = resData.data;
|
||||||
});
|
};
|
||||||
|
$api.createRequestWithCache('/app/common/jobTitle/treeselect', {}, 'GET', false, LoadCache).then(LoadCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginbackdoor() {
|
function loginbackdoor() {
|
||||||
|
|||||||
@@ -381,14 +381,17 @@ defineExpose({ loadData, handleFilterConfirm });
|
|||||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||||
.nearby-list
|
.nearby-list
|
||||||
border-top: 2rpx solid #EBEBEB;
|
border-top: 2rpx solid #EBEBEB;
|
||||||
height: calc(100% - 140rpx)
|
min-height: calc(100% - 140rpx)
|
||||||
background: #f4f4f4
|
background: #f4f4f4
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
.one-cards{
|
.one-cards{
|
||||||
height: 100%
|
height: 100%
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 0 20rpx 20rpx 20rpx;
|
padding: 0 20rpx 20rpx 20rpx;
|
||||||
background: #f4f4f4
|
background: #f4f4f4
|
||||||
|
flex: 1
|
||||||
}
|
}
|
||||||
.nav-filter
|
.nav-filter
|
||||||
padding: 16rpx 28rpx 0 28rpx
|
padding: 16rpx 28rpx 0 28rpx
|
||||||
|
|||||||
@@ -370,14 +370,17 @@ defineExpose({ loadData, handleFilterConfirm });
|
|||||||
background: #e8e8e8;
|
background: #e8e8e8;
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
.nearby-list
|
.nearby-list
|
||||||
height: calc(100% - 384rpx)
|
min-height: calc(100% - 384rpx)
|
||||||
background: #f4f4f4
|
background: #f4f4f4
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
.one-cards{
|
.one-cards{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 0 20rpx 20rpx 20rpx;
|
padding: 0 20rpx 20rpx 20rpx;
|
||||||
background: #f4f4f4
|
background: #f4f4f4
|
||||||
height: 100%
|
height: 100%
|
||||||
|
flex: 1
|
||||||
}
|
}
|
||||||
.nav-filter
|
.nav-filter
|
||||||
padding: 16rpx 28rpx 0 28rpx
|
padding: 16rpx 28rpx 0 28rpx
|
||||||
|
|||||||
@@ -483,14 +483,17 @@ defineExpose({ loadData, handleFilterConfirm });
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
.nearby-list
|
.nearby-list
|
||||||
border-top: 2rpx solid #EBEBEB;
|
border-top: 2rpx solid #EBEBEB;
|
||||||
height: calc(100% - 222rpx)
|
min-height: calc(100% - 222rpx)
|
||||||
background: #f4f4f4
|
background: #f4f4f4
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
.one-cards{
|
.one-cards{
|
||||||
height: 100%
|
height: 100%
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 0 20rpx 20rpx 20rpx;
|
padding: 0 20rpx 20rpx 20rpx;
|
||||||
background: #f4f4f4
|
background: #f4f4f4
|
||||||
|
flex: 1
|
||||||
}
|
}
|
||||||
.nav-filter
|
.nav-filter
|
||||||
padding: 16rpx 28rpx 0 28rpx
|
padding: 16rpx 28rpx 0 28rpx
|
||||||
|
|||||||
@@ -285,14 +285,17 @@ defineExpose({ loadData, handleFilterConfirm });
|
|||||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||||
.nearby-list
|
.nearby-list
|
||||||
border-top: 2rpx solid #EBEBEB;
|
border-top: 2rpx solid #EBEBEB;
|
||||||
height: calc(100% - 252rpx)
|
min-height: calc(100% - 252rpx)
|
||||||
background: #f4f4f4
|
background: #f4f4f4
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
.one-cards{
|
.one-cards{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 0 20rpx 20rpx 20rpx;
|
padding: 0 20rpx 20rpx 20rpx;
|
||||||
background: #f4f4f4
|
background: #f4f4f4
|
||||||
height: 100%
|
height: 100%
|
||||||
|
flex: 1
|
||||||
}
|
}
|
||||||
.nav-filter
|
.nav-filter
|
||||||
padding: 16rpx 28rpx 0 28rpx
|
padding: 16rpx 28rpx 0 28rpx
|
||||||
|
|||||||
@@ -12,27 +12,25 @@ import {
|
|||||||
$api,
|
$api,
|
||||||
} from '../common/globalFunction';
|
} from '../common/globalFunction';
|
||||||
|
|
||||||
// 控制消息
|
// 常量定义:消息在 TabBar 的索引位置
|
||||||
|
const TABBAR_INDEX = 3;
|
||||||
|
|
||||||
export const useReadMsg = defineStore('readMsg', () => {
|
export const useReadMsg = defineStore('readMsg', () => {
|
||||||
const msgList = ref([])
|
const msgList = ref([])
|
||||||
|
// 用于自定义 Tabbar 组件的渲染
|
||||||
const badges = ref([{
|
const badges = ref([{
|
||||||
count: 0
|
count: 0
|
||||||
},
|
}, {
|
||||||
{
|
count: 0
|
||||||
count: 0
|
}, {
|
||||||
},
|
count: 0
|
||||||
{
|
}, {
|
||||||
count: 0
|
count: 0
|
||||||
},
|
}, {
|
||||||
{
|
count: 0
|
||||||
count: 0
|
}])
|
||||||
},
|
|
||||||
{
|
|
||||||
count: 0
|
|
||||||
},
|
|
||||||
])
|
|
||||||
|
|
||||||
// 计算总未读数量,基于 notReadCount 字段
|
// 计算总未读数量
|
||||||
const unreadCount = computed(() =>
|
const unreadCount = computed(() =>
|
||||||
msgList.value.reduce((sum, msg) => sum + (msg.notReadCount || 0), 0)
|
msgList.value.reduce((sum, msg) => sum + (msg.notReadCount || 0), 0)
|
||||||
)
|
)
|
||||||
@@ -42,40 +40,49 @@ export const useReadMsg = defineStore('readMsg', () => {
|
|||||||
msgList.value.filter(msg => msg.notReadCount > 0)
|
msgList.value.filter(msg => msg.notReadCount > 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function updateBadgeEffect() {
|
||||||
// 设置 TabBar 角标
|
|
||||||
function updateTabBarBadge() {
|
|
||||||
const count = unreadCount.value
|
const count = unreadCount.value
|
||||||
const index = 3
|
// 处理显示文本:超过99显示99+
|
||||||
const countVal = count > 99 ? '99+' : String(count)
|
const countStr = count > 99 ? '99+' : String(count)
|
||||||
if (count === 0) {
|
|
||||||
uni.removeTabBarBadge({
|
// 1. 更新内部状态 (用于自定义 UI)
|
||||||
index
|
if (badges.value[TABBAR_INDEX]) {
|
||||||
}) // 替换为你消息页面的 TabBar index
|
badges.value[TABBAR_INDEX].count = count === 0 ? 0 : countStr
|
||||||
badges.value[index] = {
|
}
|
||||||
count: 0
|
|
||||||
|
// 2. 更新系统原生 TabBar
|
||||||
|
// 加 try-catch 防止在非 Tabbar 页面或加栽未完成时报错
|
||||||
|
try {
|
||||||
|
if (count > 0) {
|
||||||
|
uni.setTabBarBadge({
|
||||||
|
index: TABBAR_INDEX,
|
||||||
|
text: countStr
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.removeTabBarBadge({
|
||||||
|
index: TABBAR_INDEX
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} catch (e) {
|
||||||
badges.value[index] = {
|
console.warn('TabBar Badge 更新失败(可能当前非TabBar页面):', e)
|
||||||
count: countVal
|
|
||||||
}
|
|
||||||
uni.setTabBarBadge({
|
|
||||||
index,
|
|
||||||
text: countVal
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(unreadCount, () => {
|
||||||
|
updateBadgeEffect()
|
||||||
|
console.log('value', unreadCount.value)
|
||||||
|
}, {
|
||||||
|
immediate: true
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// 拉取消息列表
|
// 拉取消息列表
|
||||||
async function fetchMessages() {
|
async function fetchMessages() {
|
||||||
try {
|
try {
|
||||||
$api.createRequest('/app/notice/info', {
|
const res = await $api.createRequest('/app/notice/info', {
|
||||||
isRead: 1
|
isRead: 1
|
||||||
}, "GET").then((res) => {
|
}, "GET")
|
||||||
msgList.value = res.data || []
|
msgList.value = res.data || []
|
||||||
updateTabBarBadge()
|
|
||||||
})
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('获取消息失败:', err)
|
console.error('获取消息失败:', err)
|
||||||
}
|
}
|
||||||
@@ -83,17 +90,23 @@ export const useReadMsg = defineStore('readMsg', () => {
|
|||||||
|
|
||||||
// 设置为已读
|
// 设置为已读
|
||||||
async function markAsRead(item, index) {
|
async function markAsRead(item, index) {
|
||||||
const msg = msgList.value[index]
|
const targetMsg = msgList.value[index]
|
||||||
if (!msg || msg.isRead === 1) return
|
if (!targetMsg) return
|
||||||
|
|
||||||
|
// 如果已经是已读,直接返回,避免无效请求
|
||||||
|
// 假设服务端逻辑是:isRead=1 表示已读 (注意检查你的字段定义)
|
||||||
|
// 你的原代码判断是 if (msg.isRead === 1) return,如果是这样,下面请求成功应该设为 1
|
||||||
|
// 但通常未读是0,已读是1。这里维持你原有的逻辑,假设服务端把 notReadCount 清零
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let params = {
|
let params = {
|
||||||
id: msg.noticeId
|
id: targetMsg.noticeId
|
||||||
}
|
}
|
||||||
$api.createRequest('/app/notice/read?id=' + msg.noticeId, params, "POST").then((res) => {
|
await $api.createRequest('/app/notice/read?id=' + targetMsg.noticeId, params, "POST")
|
||||||
msgList.value[index].isRead = 1
|
|
||||||
updateTabBarBadge()
|
// 更新本地数据
|
||||||
})
|
msgList.value[index].notReadCount = 0
|
||||||
|
msgList.value[index].isRead = 1 // 标记已读状态
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('设置消息已读失败:', err)
|
console.error('设置消息已读失败:', err)
|
||||||
}
|
}
|
||||||
@@ -106,8 +119,8 @@ export const useReadMsg = defineStore('readMsg', () => {
|
|||||||
unreadCount,
|
unreadCount,
|
||||||
fetchMessages,
|
fetchMessages,
|
||||||
markAsRead,
|
markAsRead,
|
||||||
updateTabBarBadge
|
updateTabBarBadge: updateBadgeEffect
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
unistorage: true,
|
unistorage: true, // 开启持久化
|
||||||
})
|
})
|
||||||
@@ -26,6 +26,10 @@ const needToEncrypt = [
|
|||||||
*/
|
*/
|
||||||
export async function createRequestWithCache(url, data = {}, method = 'GET', loading = false, headers = {},
|
export async function createRequestWithCache(url, data = {}, method = 'GET', loading = false, headers = {},
|
||||||
onCacheLoad = null) {
|
onCacheLoad = null) {
|
||||||
|
// 是分页接口的话, 只缓存第一页的数据
|
||||||
|
if (data.current && data.current > 1) {
|
||||||
|
return createRequest(url, data, method, loading, headers);
|
||||||
|
}
|
||||||
const cacheKey = `${method.toUpperCase()}:${url}:${JSON.stringify(data)}`;
|
const cacheKey = `${method.toUpperCase()}:${url}:${JSON.stringify(data)}`;
|
||||||
|
|
||||||
baseDB.getDB().then(async (dbHelper) => {
|
baseDB.getDB().then(async (dbHelper) => {
|
||||||
@@ -77,13 +81,16 @@ export function createRequest(url, data = {}, method = 'GET', loading = false, h
|
|||||||
mask: true
|
mask: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let Authorization = ''
|
let header = {
|
||||||
if (useUserStore().token) {
|
...headers
|
||||||
Authorization = `${useUserStore().token}`
|
};
|
||||||
}
|
const userStore = useUserStore();
|
||||||
|
const token = userStore.token;
|
||||||
|
|
||||||
const header = headers || {};
|
if (token) {
|
||||||
header["Authorization"] = encodeURIComponent(Authorization);
|
// 确保 Authorization 不会被覆盖,且进行编码
|
||||||
|
header["Authorization"] = encodeURIComponent(token);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// 检查当前请求是否需要加密
|
// 检查当前请求是否需要加密
|
||||||
|
|||||||
Reference in New Issue
Block a user