This commit is contained in:
沈鸿 2025-06-23 17:13:54 +08:00
commit a2f27394ea
4 changed files with 85 additions and 23 deletions

View File

@ -0,0 +1,19 @@
import request from '@/utils/axios';
// 农事服务
// 获取农事政策分类查询数据
export function informationList(params = {}) {
return request('contentManage/information/informationPage', {
method: 'GET',
params,
});
}
// 获取农资分类查询数据
export function informationDetail(id, params = {}) {
return request(`contentManage/information/informationInfo/${id}`, {
method: 'GET',
params,
});
}

View File

@ -6,12 +6,12 @@
<el-card shadow="hover" style="border-radius: 16px">
<h2 style="text-align: left">农业政策</h2>
<div v-for="(item, index) in tableData" :key="index" class="card-item">
<div style="width: 49%"><img :src="getAssetsFile(item.imgPath)" alt="" width="100%" /></div>
<div style="width: 49%; background-color: white"><img :src="item.coverUrl" alt="" width="100%" style="height: 250px" /></div>
<div style="width: 49%; display: flex; flex-direction: column; justify-content: space-between">
<div>
<div style="font-size: 20px; font-weight: bold">{{ item.title }}</div>
<div style="font-size: 14px; margin-top: 20px">
{{ item.desc }}
{{ item.content }}
</div>
</div>
<div>
@ -29,10 +29,11 @@
</template>
<script setup>
import { ref } from 'vue';
import { ref, onMounted } from 'vue';
import common from '../components/common.vue';
import { getAssetsFile } from '@/utils/index.js';
import { useRouter } from 'vue-router';
import { informationList } from '@/apis/farmingService.js';
const router = useRouter();
/* --------------- data --------------- */
@ -59,10 +60,43 @@ const tableData = ref([
},
]);
const pagination = ref({
total: 0,
page: 1,
size: 10,
});
// #endregion
/* --------------- methods --------------- */
// #region
onMounted(() => {
queryList();
});
const extractText = (htmlText, maxChars = 80) => {
// HTML
const cleanText = htmlText.replace(/<[^>]+>/g, '');
//
const trimmedText = cleanText.replace(/\s+/g, ' ').trim();
// 20
return trimmedText.substring(0, maxChars);
};
const queryList = () => {
informationList({ current: pagination.value.page, size: pagination.value.size }).then((res) => {
if (res.code === 200) {
tableData.value = res.data.records;
for (let i in res.data.records) {
tableData.value[i].content = extractText(res.data.records[i].content);
if (tableData.value[i].content.length > 80) {
tableData.value[i].content += '...';
}
}
}
});
};
const goDetail = (id) => {
router.push('/sub-operation-service/farmService/consult/policy/detail?id=' + id);
};

File diff suppressed because one or more lines are too long

View File

@ -145,10 +145,6 @@ const mockData = ref([
content:
'适用对象:农户。<p>授信额度单户贷款最高1000万元。</p><p>贷款期限最长10年。</p><p>担保方式:信用、保证、抵押、质押。</p><p>利率:以各地实际利率为准。</p>',
},
{
title: '三、办理渠道',
content: '邮储银行各大开办信贷业务的网点。客户服务热线95580。',
},
],
},
]);