Browse Source

政策法规

master
赵鹏 1 month ago
parent
commit
d6f8f6e430
  1. 37
      api/policy/index.js
  2. 4
      config.js
  3. 23
      pages.json
  4. 7
      pages/enterprise.vue
  5. 7
      pages/owner.vue
  6. 142
      sub/owner/policy-detail.vue
  7. 203
      sub/owner/policy.vue

37
api/policy/index.js

@ -0,0 +1,37 @@
import request from '@/utils/request'
// 处理富文本内容截取
export const formatPolicyContext = (context, maxLength = 100) => {
if (!context) return ''
// 移除HTML标签
const plainText = context.replace(/<[^>]+>/g, '')
return plainText.length > maxLength
? plainText.substring(0, maxLength) + '...'
: plainText
}
// 政策法规 API
export const PolicyApi = {
/**
* 查询政策法规分页
* @param {Object} params
*/
getPolicyPage: (params) => {
return request({
url: `/system/policy/page`,
method: 'GET',
params
})
},
// 查询政策法规详情
getPolicy: (id) => {
return request({ url: `/system/policy/get?id=` + id,method: 'GET' })
},
}

4
config.js

@ -1,8 +1,10 @@
// 应用全局配置
module.exports = {
baseUrl: 'https://hb.jzce.com',
baseUrl: 'http://188.188.3.166:48080',
//baseUrl: 'https://hb.jzce.com',
//baseUrl: 'http://188.188.3.232:48080',
baseApi: '/admin-api',
imgUrl: 'https://hb.jzce.com',
// 应用信息
appInfo: {
// 应用名称

23
pages.json

@ -76,7 +76,28 @@
"style": {
"navigationBarTitleText": "邀请企业"
}
}, {
},
{
"path": "owner/policy",
"style": {
"navigationBarTitleText": "政策法规",
"usingComponents": {
"van-search":"/wxcomponents/vant/search/index"
},
"componentPlaceholder": {
"u-modal": "view"
}
}
},
{
"path": "owner/policy-detail",
"style": {
"navigationBarTitleText": "政策法规",
"usingComponents": {},
"componentPlaceholder": {}
}
},
{
"path": "enterprise/edit",
"style": {
"navigationBarTitleText": "企业填报"

7
pages/enterprise.vue

@ -4,7 +4,7 @@
<van-search
:value="queryParams.enterprisesName"
placeholder="输入企业名称或类型查询"
@sreach="queryEnterprise"
@sreach="handleSearch"
@clear="resetQuery('enterpriseName')"
id="sreach"
/>
@ -227,6 +227,11 @@ export default {
this.queryParams[key] = v.detail
this.queryEnterprise()
},
handleSearch(e) {
this.queryParams.pageNum = 1 //
this.queryParams.name = e.detail //
this.getPolicyList()
},
queryEnterprise() {
this.queryParams.pageNo = 1
this.load = 'loadmore'

7
pages/owner.vue

@ -84,7 +84,7 @@
></u--image>
<text class="wd-font-800">政策法规</text>
</view>
<view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px">
<view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px" @click="btnPolicy">
<u-count-to
:startVal="30"
:endVal="500"
@ -147,6 +147,11 @@ export default {
this.init()
},
methods: {
btnPolicy() {
uni.navigateTo({
url: '/sub/owner/policy'
})
},
init() {
getUserProfile().then(res => {
this.user = res.data

142
sub/owner/policy-detail.vue

@ -0,0 +1,142 @@
<template>
<view class="policy-detail">
<!-- 详情内容区 -->
<view class="content-wrap">
<view class="policy-title">{{ policyDetail.name }}</view>
<view class="policy-time">生效时间{{ policyDetail.effectiveDate }}</view>
<!-- 富文本内容 -->
<view class="policy-content">
<rich-text :nodes="policyDetail.context"></rich-text>
</view>
</view>
</view>
</template>
<script>
import { PolicyApi } from '@/api/policy/index.js'
export default {
data() {
return {
id: '', // ID
policyDetail: {
name: '',
createTime: '',
context: ''
}
}
},
onLoad(options) {
if (options.id) {
this.id = options.id
this.getPolicyDetail()
}
},
methods: {
//
async getPolicyDetail() {
try {
const res = await PolicyApi.getPolicy(this.id)
if (res.code === 0) {
this.policyDetail = {
...res.data,
effectiveDate: this.formatTime(res.data.effectiveDate),
//
context: this.formatRichText(res.data.context)
}
}
} catch (error) {
uni.showToast({
title: '获取详情失败',
icon: 'none'
})
}
},
//
formatTime(time) {
if (!time) return ''
const date = new Date(time)
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
},
//
formatRichText(html) {
if (!html) return ''
//
return html.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block;"')
},
//
handleBack() {
uni.navigateBack()
}
}
}
</script>
<style lang="scss">
.policy-detail {
min-height: 100vh;
background: #fff;
.nav-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 88rpx;
background: #fff;
display: flex;
align-items: center;
padding: 0 30rpx;
border-bottom: 1rpx solid #eee;
z-index: 100;
.back-btn {
font-size: 28rpx;
color: #333;
}
.title {
flex: 1;
text-align: center;
font-size: 32rpx;
font-weight: bold;
padding-right: 60rpx;
}
}
.content-wrap {
padding: 30rpx 30rpx 30rpx;
.policy-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
}
.policy-time {
font-size: 24rpx;
color: #999;
margin-bottom: 40rpx;
}
.policy-content {
font-size: 28rpx;
line-height: 1.8;
color: #333;
:deep(img) {
max-width: 100%;
height: auto;
}
:deep(p) {
margin-bottom: 20rpx;
}
}
}
}
</style>

203
sub/owner/policy.vue

@ -0,0 +1,203 @@
<template>
<!-- 政策法规列表页面容器 -->
<view class="policy-container">
<!-- 搜索框区域 -->
<view class="search-box">
<van-search
:value="abc"
placeholder="输入关键字查询"
@search="handleSearch"
id="sreach"
@clear="handleClear"
/>
</view>
<!-- 政策法规列表区域 -->
<!-- 修改列表项部分 -->
<view class="policy-list">
<view
class="policy-item"
v-for="item in policyList"
:key="item.id"
@click="handlePolicyClick(item)"
>
<view class="item-left">
<image :src="itemImgUrl" class="policy-icon"></image>
</view>
<view class="item-right">
<view class="policy-title">{{ item.title }}</view>
<view class="policy-time">生效时间: {{ item.effectiveDate }}</view>
</view>
</view>
</view>
<!-- 加载更多状态组件 -->
<uni-load-more :status="loadMoreStatus" />
</view>
</template>
<script>
import { PolicyApi, formatPolicyContext } from '@/api/policy/index.js'
import { formatDate } from '@/utils/ruoyi.js'
import config from '@/config'
export default {
data() {
return {
searchValue: '', //
abc: '',
policyList: [], //
pageNum: 1, //
pageSize: 10, //
total: 0, //
loadMoreStatus: 'more' ,// more- loading- noMore-
itemImgUrl: config.imgUrl + '/miniohb/c103c92335bdd30d33ff8a062c219ead0626bf0a1898536bd7590285ca11c9db.png'
}
},
//
onShow() {
console.log(this.itemImgUrl)
this.getPolicyList()
},
//
onReachBottom() {
if (this.policyList.length < this.total) {
this.pageNum++
this.getPolicyList()
}
},
methods: {
//
async getPolicyList() {
try {
console.log('PolicyApi',this.searchValue)
this.loadMoreStatus = 'loading'
const res = await PolicyApi.getPolicyPage({
pageNum: this.pageNum,
pageSize: this.pageSize,
name: this.searchValue //
})
if (res.code === 0 && res.data.total > 0) {
//
const formattedData = res.data.list.map(item => ({
...item,
title: item.name.length > 15 ? item.name.slice(0, 15) + '...' : item.name,
effectiveDate: formatDate(item.effectiveDate,'YYYY年MM月DD日')
}))
//
if (this.pageNum === 1) {
this.policyList = formattedData
} else {
this.policyList = [...this.policyList, ...formattedData]
}
this.total = res.total
//
this.loadMoreStatus = this.policyList.length >= this.total ? 'noMore' : 'more'
}
} catch (error) {
console.error(error)
this.loadMoreStatus = 'more'
uni.showToast({
title: '获取列表失败',
icon: 'none'
})
}
},
//
handleSearch(e) {
this.pageNum = 1 //
this.searchValue = e.detail //
this.getPolicyList()
},
//
handleClear() {
this.pageNum = 1 //
this.searchValue = '' //
this.getPolicyList()
},
//
handlePolicyClick(item) {
uni.navigateTo({
url: `/sub/owner/policy-detail?id=${item.id}`
})
}
}
}
</script>
<style lang="scss">
.policy-container {
background: var(--LightMode-Secondary-Secondary, #F9F9F9);
min-height: 100vh;
.search-box {
padding: 20rpx;
background: #fff;
}
.policy-list {
display: flex;
flex-direction: column;
align-items: flex-start;
background: var(--LightMode-Secondary-Secondary, #F9F9F9);
.policy-item {
display: flex;
padding: var(--Number-12px, 12px);
align-items: center;
gap: var(--Number-12px, 12px);
align-self: stretch;
border-radius: var(--Number-8px, 8px);
border-bottom: 1px solid var(--LightMode-Grey-Grey-100, #F9F9F9);
background: var(--LightMode-Light-Light, #FFF);
margin-top: 12px;
margin-left: 12px;
margin-right: 12px;
margin-bottom: 0px;
.item-left {
margin-right: 20rpx;
border-radius: 100px;
background: var(--LightMode-Grey-Grey-100, #F9F9F9);
display: flex;
padding: 8px;
justify-content: center;
align-items: center;
gap: 8px;
.policy-icon {
display: flex;
width: 20px;
height: 20px;
justify-content: center;
align-items: center;
aspect-ratio: 1/1;
}
}
.item-right {
flex: 1;
.policy-title {
font-size: 28rpx;
color: #333;
margin-bottom: 10rpx;
}
.policy-time {
font-size: 24rpx;
color: #999;
}
}
}
}
}
</style>
Loading…
Cancel
Save