企业收藏功能开发
This commit is contained in:
@@ -1,16 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<AppLayout title="" :use-scroll-view="false">
|
<AppLayout title="单位详情" :use-scroll-view="false">
|
||||||
<template #headerleft>
|
<template #headerleft>
|
||||||
<view class="btnback">
|
<view class="btnback">
|
||||||
<image src="@/static/icon/back.png" @click="navBack"></image>
|
<image src="@/static/icon/back.png" @click="navBack"></image>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<template #headerright>
|
|
||||||
<view class="btn mar_ri10">
|
|
||||||
<image src="@/static/icon/collect3.png" v-if="!companyInfo?.isCollection"></image>
|
|
||||||
<image src="@/static/icon/collect2.png" v-else></image>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<view class="content-top">
|
<view class="content-top">
|
||||||
<view class="companyinfo-left">
|
<view class="companyinfo-left">
|
||||||
@@ -22,6 +17,10 @@
|
|||||||
{{ getScaleLabel(companyInfo?.scale) }}
|
{{ getScaleLabel(companyInfo?.scale) }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="companyinfo-collect" @click="toggleCollection">
|
||||||
|
<image src="@/static/icon/collect3.png" v-if="!companyInfo?.isCollection"></image>
|
||||||
|
<image src="@/static/icon/collect2.png" v-else></image>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="conetent-info" :class="{ expanded: isExpanded }">
|
<view class="conetent-info" :class="{ expanded: isExpanded }">
|
||||||
<view class="info-title">公司介绍</view>
|
<view class="info-title">公司介绍</view>
|
||||||
@@ -372,6 +371,37 @@
|
|||||||
navTo(`/packageA/pages/post/post?jobId=${encodeURIComponent(jobId)}`);
|
navTo(`/packageA/pages/post/post?jobId=${encodeURIComponent(jobId)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 收藏和取消收藏企业
|
||||||
|
function toggleCollection() {
|
||||||
|
const companyId = companyInfo.value.id || companyInfo.value.companyId;
|
||||||
|
if (!companyId) {
|
||||||
|
$api.msg('获取公司信息失败,无法操作');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isCollection = companyInfo.value.isCollection;
|
||||||
|
const method = isCollection ? 'DELETE' : 'POST';
|
||||||
|
const apiUrl = `/app/company/collection/${companyId}`;
|
||||||
|
|
||||||
|
uni.showLoading({
|
||||||
|
title: '操作中'
|
||||||
|
});
|
||||||
|
|
||||||
|
$api.createRequest(apiUrl, {}, method).then((resData) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
if (resData && resData.code === 200) {
|
||||||
|
companyInfo.value.isCollection = !isCollection;
|
||||||
|
$api.msg(isCollection ? '取消收藏成功' : '收藏成功');
|
||||||
|
} else {
|
||||||
|
$api.msg((resData && resData.msg) || (isCollection ? '取消收藏失败' : '收藏失败'));
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
uni.hideLoading();
|
||||||
|
console.error('API error when toggling collection:', error);
|
||||||
|
$api.msg('网络请求失败,请检查网络连接');
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="stylus" scoped>
|
<style lang="stylus" scoped>
|
||||||
@@ -404,6 +434,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
.companyinfo-left {
|
.companyinfo-left {
|
||||||
width: 96rpx;
|
width: 96rpx;
|
||||||
@@ -412,6 +443,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.companyinfo-right {
|
.companyinfo-right {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
.row1 {
|
.row1 {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
@@ -425,6 +458,17 @@
|
|||||||
line-height: 45rpx;
|
line-height: 45rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.companyinfo-collect {
|
||||||
|
width: 52rpx;
|
||||||
|
height: 52rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
|
||||||
|
image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.conetent-info {
|
.conetent-info {
|
||||||
|
|||||||
Reference in New Issue
Block a user