提交 130f1eff 作者: 王定

feat: 完成农业政策接口对接

上级 61cf84cb
......@@ -14,20 +14,6 @@ enum Api {
}
/**
* @param params 请求参数
* @description: 分页列表查询热门新闻管理
*/
export function getNewsList(params = {}) {
return otherHttp.get({
url: Api.getNewsList,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
/**
* @param params 添加
* @description: 添加咨询信息
*/
......
......@@ -7,14 +7,16 @@
import Navigate from '@/utils/page/navigate'
import { getText } from '@/utils/dict/area'
import { useUserStore } from '@/store/modules/user'
import * as turf from '@turf/turf'
const userStore = useUserStore()
onLoad((option) => {
pageData.currentEmploymentId = Number(option.type) || 2
pageData.currentEmploymentId = Number(option.type) || 2;
})
onShow(() => {
resetGetEmploymentList()
getUserLocation();
resetGetEmploymentList();
})
// 页面数据
......@@ -42,6 +44,8 @@
employmentList: [],
total: 0,
dataTotal: 0,
longitude:null,
latitude:null,
})
// 缓存已处理的区域数据,避免重复计算
......@@ -52,7 +56,7 @@
maxRetries: 2,
retryDelay: 1000,
}
// 带重试机制的API调用
async function fetchWithRetry(apiCall, maxRetries = requestConfig.maxRetries) {
const startTime = Date.now()
......@@ -237,7 +241,7 @@
}) */
onNavigationBarButtonTap(() => {
Navigate.to('/pages/linghuoyonggong/components/yonggongmap')
Navigate.to('/pages/linghuoyonggong/components/yonggongmap?currentEmploymentId='+pageData.currentEmploymentId);
})
// 查看找人干活详情
......@@ -245,7 +249,41 @@
let param = encodeURIComponent(JSON.stringify({id:item.id,villageName:item.villageName}));
Navigate.to('/pages/linghuoyonggong/details?param='+param);
}
// 获取用户位置
function getUserLocation(){
uni.getLocation({
type: 'wgs84',
success: (res) => {
if (res.longitude !== 0 && res.latitude !== 0) {
pageData.longitude = res.longitude
pageData.latitude = res.latitude
}
},
fail: (err) => {
console.error('获取位置失败:', err)
uni.showToast({
title: '获取位置失败,请检查定位权限',
icon: 'none',
duration: 2000,
})
},
})
}
// 计算距离显示
function getDistanceText(item) {
if (!item || !item.lon || !pageData.longitude) {
return '未知'
}
// 使用turf计算距离
const from = turf.point([pageData.longitude, pageData.latitude])
const to = turf.point([item.lon, item.lat])
const distance = turf.distance(from, to, { units: 'kilometers' })
if (distance < 1) {
return `${Math.round(distance * 1000)}m`;
}
return `${distance.toFixed(1)}km`;
}
</script>
<template>
......@@ -353,7 +391,7 @@
</view>
<view class="d-flex align-center justify-center right-width village_distance">
<image class="distance_icon" src="/static/images/linghuoyonggong/distance.png" />
<text class="distance_val text-color">2km</text>
<text class="distance_val text-color">{{getDistanceText(item)}}</text>
</view>
</view>
<view class="d-flex j-sb skill_details_view">
......
......@@ -92,11 +92,23 @@
laborParam:{
id:null,
lon:"", // 经度
lat:"", // 纬度
contactName:"", // 联系人姓名
contactMobile:"", // 联系人电话
provinceName:"湖南省", // 所属省名称
provinceCode:"43", // 所属省编码
cityName:"", // 所属市名称
cityCode:"", // 所属市编码
districtName:"", // 所属区县名称
districtCode:"", // 所属区县编码
townName:"", // 所属乡镇名称
townCode:"", // 所属乡镇编码
villageName:"", // 村名称
villageCode:"", // 村编码
addr:"",
lon:29,
lat:110,
contactName:"",
contactMobile:"",
},
workersParam:[],
actionType:'add',
......@@ -262,7 +274,6 @@
}
if(DictData.dictType == 'socialattributes'){
tempWorkersParam.attr = e.value;
console.log("tempWorkersParam.attr= "+tempWorkersParam.attr);
}
pageData.attrPickerShow = false;
}
......@@ -476,9 +487,25 @@
let s_street = null;
if(e.detail.value.length == 4){
s_street = pageData.mulSelect[3][e.detail.value[3]||0];
pageData.laborParam.addr=s_province.name+s_city.name+s_district.name+s_street.name;
pageData.laborParam.addr = s_province.name+s_city.name+s_district.name+s_street.name;
pageData.laborParam.cityName = s_province.name;
pageData.laborParam.districtName = s_city.name;
pageData.laborParam.townName = s_district.name;
pageData.laborParam.villageName = s_street.name;
pageData.laborParam.cityCode = s_province.code;
pageData.laborParam.districtCode = s_city.code;
pageData.laborParam.townCode = s_district.code;
pageData.laborParam.villageCode = s_street.code;
}else{
pageData.laborParam.addr=s_province.name+s_city.name+s_district.name;
pageData.laborParam.addr = s_province.name+s_city.name+s_district.name;
pageData.laborParam.cityName = s_province.name;
pageData.laborParam.districtName = s_city.name;
pageData.laborParam.townName = s_district.name;
pageData.laborParam.cityCode = s_province.code;
pageData.laborParam.districtCode = s_city.code;
pageData.laborParam.townCode = s_district.code;
}
pageData.isActive=true;
}
......@@ -489,8 +516,6 @@
const { show, options, form } = toRefs(pageData);
async function initDict() {
pageData.options.area = await getDictData();
console.log("pageData.options.area =");
console.log(pageData.options.area);
pageData.options.urgentdegree = dictStore.getDictList.employment_urgent.map((item) => {
return {
value: item.value,
......@@ -792,7 +817,7 @@
</fui-radio-group>
</fui-form-item>
<fui-form-item label="出生日期" highlight>
<picker class="publish_empl_picker" mode="date" :value="startDate" :start="startDate" :end="endDate" @change="dateBirthChange">
<picker class="publish_empl_picker" mode="date" :value="startDate" :end="endDate" @change="dateBirthChange">
<fui-input :borderBottom="false" v-model="tempWorkersParam.birthday" :padding="[0]" :disabled="true" placeholder="请选择出生日期"
backgroundColor="transparent"></fui-input>
</picker>
......
......@@ -3,7 +3,7 @@
import { reactive, ref } from 'vue'
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue';
import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home'
import * as NewsApi from '@/api/model/news'
import dayjs from 'dayjs'
let currentTab = ref('redian');
const pageData = reactive({
......@@ -11,7 +11,7 @@
pageNo: 1,
pageSize: 10,
news:{
source:2
category:1
}
}, // 分页参数
hasMore: true, // 是否还有更多数据
......@@ -24,7 +24,7 @@
async function getListData() {
if (pageData.loading) return
pageData.loading = true
await HomeAPI.getNewsList(pageData.params).then((res) => {
await NewsApi.getList(pageData.params).then((res) => {
if (res.records.length > 0) {
const { records } = res
if (pageData.params.pageNo === 1) {
......@@ -49,17 +49,19 @@
pageData.dataList = [];
pageData.hasMore = true;
pageData.params.pageNo = 1;
currentTab.value = type;
if(type == 'redian'){
pageData.params.news.source = 2;
pageData.params.news.category = 1;
getListData();
}
if(type == 'nongye'){
pageData.params.news.source = 3;
pageData.params.news.category = 2;
getListData();
}
if(type == 'butie'){
pageData.params.news.source = 2;
pageData.params.news.category = 3;
pageData.dataList = [];
}
currentTab.value = type;
getListData();
}
</script>
......@@ -82,6 +84,9 @@
</view>
</view>
<view class="list-content">
<view v-if="!pageData.dataList || pageData.dataList.length == 0" style="height: 700rpx">
<fui-empty marginTop="100" src="/static/images/no-data.png" title="暂无数据" />
</view>
<view class="content-item" v-for="item in pageData.dataList" :key="item.id" @click="toNewsDetail(item)">
<view class="item-content">{{item.title}}</view>
<view class="item-info">
......
......@@ -298,9 +298,6 @@ function getServiceItems() {
type: 1,
}).then((res) => {
const { records } = res
console.log("菜单数据");
console.log(records);
records[0].jump_target = "/pages/nongyezhengce/nongyezhengce";
pageData.serviceItems = []
pageData.serviceItems = records
})
......@@ -480,21 +477,11 @@ onHide(() => {
<!-- <text class="text" style="font-family: alimamashuheiti">湖南省</text> -->
</view>
<!-- ai助手 -->
<!-- <FuiMovableView top="650" right="-12" zIndex="99999">
<FuiMovableView direction="vertical" top="650" right="-12" zIndex="99999">
<view class="h-80rpx flex items-center" @click="openAITools">
<image class="w-117rpx h-118rpx" src="/static/images/codefun/ai.png" alt="" />
</view>
</FuiMovableView> -->
<view class="top-movable-area">
<movable-area class="movable-area">
<movable-view class="movable-view" direction="vertical" y="650rpx">
<view class="ai_icon" @click="openAITools">
<image class="ai_icon" src="/static/images/codefun/ai.png" alt="" />
</view>
</movable-view>
</movable-area>
</view>
</FuiMovableView>
<view class="codefun-flex-col codefun-relative group_3">
<view class="codefun-flex-col">
<view class="codefun-flex-col codefun-self-stretch group_4">
......@@ -1627,22 +1614,5 @@ onHide(() => {
text-overflow: ellipsis;
/* 可选,部分浏览器不生效 */
}
.top-movable-area{
height: 100vh;
width: 122rpx;
position: fixed;
top: 0rpx;
right:0rpx;
z-index: 9999;
overflow: hidden;
.movable-area{
height: 100vh;
width: 122rpx;
.movable-view,.ai_icon{
width: 120rpx;
height: 120rpx;
}
}
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论