提交 e266b465 作者: 15973817745_JPN

Merge branch 'main' of https://gitee.com/mrf/agri-app

...@@ -180,3 +180,39 @@ page { ...@@ -180,3 +180,39 @@ page {
.fui-relative { .fui-relative {
position: relative; position: relative;
} }
.fab-icon {
position: relative;
width: 40rpx;
height: 40rpx;
font-size: 0;
margin: auto;
}
.fab-icon::before,
.fab-icon::after {
content: '';
position: absolute;
border-radius: 20rpx;
background: linear-gradient(90deg, #ffffff 0%, #ffffff 100%);
}
.fab-icon::before {
/* 横线 */
top: 50%;
left: 25%;
right: 25%;
height: 4rpx;
transform: translateY(-50%);
}
.fab-icon::after {
/* 竖线 */
left: 50%;
top: 25%;
bottom: 25%;
width: 4rpx;
transform: translateX(-50%);
border-radius: 20rpx;
background: linear-gradient(90deg, #ffffff 0%, #ffffff 100%);
}
...@@ -395,14 +395,14 @@ ...@@ -395,14 +395,14 @@
</view> </view>
</view> </view>
</view> </view>
<fui-fab background="#5db66f" position="right" distance="10" bottom="240" width="120" @click="handlePublish"> <fui-fab position="right" distance="10" bottom="240" width="96" @click="handlePublish">
<view v-show="pageData.currentTransactionTab === 1" class="text-white text-center"> <view v-show="pageData.currentTransactionTab === 1" class="text-white text-center">
<image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image> <view class="fab-icon"></view>
<view style="font-size: 24rpx">发布需求</view> <view style="font-size: 24rpx">发布</view>
</view> </view>
<view v-show="pageData.currentTransactionTab === 2" class="text-white text-center"> <view v-show="pageData.currentTransactionTab === 2" class="text-white text-center">
<image src="/src/static/images/chanxiao/flower.svg" style="width: 50rpx" mode="widthFix"></image> <view class="fab-icon"></view>
<view style="font-size: 24rpx">发布供应</view> <view style="font-size: 24rpx">发布</view>
</view> </view>
</fui-fab> </fui-fab>
...@@ -827,4 +827,9 @@ ...@@ -827,4 +827,9 @@
border-top: solid 1rpx #e7e7e7; border-top: solid 1rpx #e7e7e7;
} }
} }
::v-deep .fui-fab__btn-main {
background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important;
box-shadow: 0px 1px 8px #5db66f;
}
</style> </style>
...@@ -77,7 +77,13 @@ ...@@ -77,7 +77,13 @@
<fui-form ref="formRef" top="180" color="#000"> <fui-form ref="formRef" top="180" color="#000">
<fui-input marginTop="30" size="28" placeholder="请填写联系人姓名" v-model="pageData.form.supplyName" /> <fui-input marginTop="30" size="28" placeholder="请填写联系人姓名" v-model="pageData.form.supplyName" />
<fui-input marginTop="30" size="28" placeholder="请填写联系电话" v-model="pageData.form.phone" /> <fui-input marginTop="30" size="28" placeholder="请填写联系电话" v-model="pageData.form.phone" />
<fui-input marginTop="30" size="28" placeholder="请填写价格" v-model="pageData.form.supplyPrice"> <fui-input
type="number"
marginTop="30"
size="28"
placeholder="请填写价格"
v-model="pageData.form.supplyPrice"
>
<view class="flex"> <view class="flex">
<view class="mr-3" style="color: #ccc">|</view> <view class="mr-3" style="color: #ccc">|</view>
<view></view> <view></view>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import { onPullDownRefresh, onLoad } from '@dcloudio/uni-app' import { onPullDownRefresh, onLoad } from '@dcloudio/uni-app'
import * as NongzhiAPI from '@/api/model/nongzhi' import * as NongzhiAPI from '@/api/model/nongzhi'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import { url } from 'inspector'
// 下拉刷新 // 下拉刷新
onPullDownRefresh(() => { onPullDownRefresh(() => {
...@@ -47,6 +48,7 @@ ...@@ -47,6 +48,7 @@
title: '季节性用工', title: '季节性用工',
description: '三农区域灵活用工服务', description: '三农区域灵活用工服务',
actionText: '去发布', actionText: '去发布',
url: '/pages/nongjifuwu/farm-form',
}, },
{ {
id: 2, id: 2,
...@@ -54,14 +56,15 @@ ...@@ -54,14 +56,15 @@
title: '农机手调度', title: '农机手调度',
description: '专业人员作业安排', description: '专业人员作业安排',
actionText: '去预约', actionText: '去预约',
url: '/pages/nongjifuwu/nongjifuwu',
}, },
{ // {
id: 3, // id: 3,
image: '/static/images/codefun/06319419d17b7630c1d5bc415bcd26ef.png', // image: '/static/images/codefun/06319419d17b7630c1d5bc415bcd26ef.png',
title: '作业质量评价', // title: '作业质量评价',
description: '农机定位精度≤50米', // description: '农机定位精度≤50米',
actionText: '去评价', // actionText: '去评价',
}, // },
], ],
// 助农金融产品 // 助农金融产品
...@@ -347,7 +350,12 @@ ...@@ -347,7 +350,12 @@
</view> </view>
<view class="codefun-flex-col group_8"> <view class="codefun-flex-col group_8">
<view class="codefun-flex-col section_4 flex gap-4"> <view class="codefun-flex-col section_4 flex gap-4">
<view v-for="service in pageData.flexibleEmploymentServices" :key="service.id"> <navigator
v-for="service in pageData.flexibleEmploymentServices"
:key="service.id"
:url="service.url"
hover-class="none"
>
<view class="codefun-flex-row codefun-justify-between codefun-items-center"> <view class="codefun-flex-row codefun-justify-between codefun-items-center">
<view class="codefun-flex-row"> <view class="codefun-flex-row">
<image class="image_8" :src="service.image" /> <image class="image_8" :src="service.image" />
...@@ -367,7 +375,7 @@ ...@@ -367,7 +375,7 @@
<text class="font_8" :class="`text_${9 + service.id}`">{{ service.actionText }}</text> <text class="font_8" :class="`text_${9 + service.id}`">{{ service.actionText }}</text>
</view> </view>
</view> </view>
</view> </navigator>
</view> </view>
<view class="codefun-flex-col codefun-mt-24"> <view class="codefun-flex-col codefun-mt-24">
<view class="codefun-flex-row codefun-justify-between codefun-items-center group_11"> <view class="codefun-flex-row codefun-justify-between codefun-items-center group_11">
...@@ -503,7 +511,7 @@ ...@@ -503,7 +511,7 @@
class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch group_14" class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch group_14"
> >
<text class="font_5">一站式解决农机问题</text> <text class="font_5">一站式解决农机问题</text>
<text class="font_6 text_37" @click="onViewAllMachineryCases">全部案例</text> <!-- <text class="font_6 text_37" @click="onViewAllMachineryCases">全部案例</text> -->
</view> </view>
<view class="codefun-flex-col codefun-self-stretch section_14"> <view class="codefun-flex-col codefun-self-stretch section_14">
<view class="codefun-flex-row"> <view class="codefun-flex-row">
......
...@@ -113,23 +113,107 @@ ...@@ -113,23 +113,107 @@
total: 0, total: 0,
}) })
// 缓存已处理的区域数据,避免重复计算
const areaCache = new Map()
// 请求重试配置
const requestConfig = {
maxRetries: 2,
retryDelay: 1000,
}
// 带重试机制的API调用
async function fetchWithRetry(apiCall, maxRetries = requestConfig.maxRetries) {
const startTime = Date.now()
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const result = await apiCall()
const endTime = Date.now()
// 记录API性能数据(仅在开发环境)
if (import.meta.env.DEV) {
console.log(`API请求成功,耗时: ${endTime - startTime}ms`)
}
return result
} catch (error) {
console.warn(`API请求失败 (尝试 ${attempt}/${maxRetries}):`, error)
if (attempt === maxRetries) {
const endTime = Date.now()
if (import.meta.env.DEV) {
console.error(`API请求最终失败,总耗时: ${endTime - startTime}ms`)
}
throw error
}
// 指数退避策略
await new Promise((resolve) => setTimeout(resolve, requestConfig.retryDelay * attempt))
}
}
}
function getEmploymentList() { function getEmploymentList() {
// 如果正在加载或没有更多数据,直接返回
if (pageData.loading || (pageData.total > 0 && pageData.employmentList.length >= pageData.total)) {
return
}
pageData.loading = true pageData.loading = true
LinghuoyonggongAPI.employmentList(pageData.search)
.then((res) => { // 添加请求防抖,避免快速连续请求
if (pageData.requestDebounce) {
clearTimeout(pageData.requestDebounce)
}
pageData.requestDebounce = setTimeout(async () => {
try {
const res = await fetchWithRetry(() => LinghuoyonggongAPI.employmentList(pageData.search))
const { records, total } = res const { records, total } = res
console.log('records', records)
records.map((item) => { // 批量处理数据,避免多次DOM操作
item.area = item.area.split(',') const processedRecords = records.map((item) => {
item.area = getTextByCode(item.area[0]) + ' ' + getTextByCode(item.area[1]) // 缓存区域处理结果
const cacheKey = item.area
if (areaCache.has(cacheKey)) {
item.area = areaCache.get(cacheKey)
} else {
const areaCodes = item.area.split(',')
const areaText = getTextByCode(areaCodes[0]) + ' ' + getTextByCode(areaCodes[1])
areaCache.set(cacheKey, areaText)
item.area = areaText
}
// 计算天数并缓存结果
if (item.starttime && item.estimatedendtime) {
item.daysDiff = getDaysDiff(item.starttime, item.estimatedendtime)
}
return item return item
}) })
pageData.employmentList = [...pageData.employmentList, ...records]
// 一次性更新数据,避免多次响应式更新
if (pageData.search.pageNo === 1) {
pageData.employmentList = processedRecords
} else {
// 避免重复数据加载
const existingIds = new Set(pageData.employmentList.map((item) => item.id))
const newRecords = processedRecords.filter((item) => !existingIds.has(item.id))
pageData.employmentList = [...pageData.employmentList, ...newRecords]
}
pageData.total = total pageData.total = total
}) } catch (error) {
.finally(() => { console.error('获取用工列表失败:', error)
// 这里可以添加用户友好的错误提示
// uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
} finally {
pageData.loading = false pageData.loading = false
}) pageData.requestDebounce = null
}
}, 150)
} }
// 分类标签点击事件 // 分类标签点击事件
...@@ -251,7 +335,7 @@ ...@@ -251,7 +335,7 @@
@click="onEmploymentItemClick(item)" @click="onEmploymentItemClick(item)"
> >
<view class="codefun-flex-row"> <view class="codefun-flex-row">
<image class="image_7" :src="item.picture" /> <image class="image_7" :src="item.picture" lazy-load />
<view class="codefun-flex-col codefun-flex-1 codefun-self-center group_4"> <view class="codefun-flex-col codefun-flex-1 codefun-self-center group_4">
<view class="codefun-flex-row codefun-justify-between codefun-items-center"> <view class="codefun-flex-row codefun-justify-between codefun-items-center">
<text class="codefun-self-start font">{{ item.name }}</text> <text class="codefun-self-start font">{{ item.name }}</text>
...@@ -269,7 +353,9 @@ ...@@ -269,7 +353,9 @@
<view class="flex codefun-items-center gap-1"> <view class="flex codefun-items-center gap-1">
<image class="image_9" src="/src/static/images/time.svg" /> <image class="image_9" src="/src/static/images/time.svg" />
<text class="font_4" <text class="font_4"
>预计{{ getDaysDiff(item.starttime, item.estimatedendtime) }}</text >预计{{
item.daysDiff || getDaysDiff(item.starttime, item.estimatedendtime)
}}</text
> >
</view> </view>
<view class="flex codefun-items-center gap-1"> <view class="flex codefun-items-center gap-1">
...@@ -304,10 +390,11 @@ ...@@ -304,10 +390,11 @@
<!-- <image class="codefun-self-end image_7 image_12 mt-269" :src="pageData.bottomImage" /> --> <!-- <image class="codefun-self-end image_7 image_12 mt-269" :src="pageData.bottomImage" /> -->
</view> </view>
<fui-fab background="#5db66f" position="right" distance="10" bottom="240" width="120" @click="handlePublish"> <fui-fab position="right" distance="10" bottom="240" width="96" @click="handlePublish">
<view class="text-white text-center"> <view class="text-white text-center">
<image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image> <!-- <image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image> -->
<view style="font-size: 24rpx">发布用工</view> <view class="fab-icon"></view>
<view style="font-size: 24rpx">发布</view>
</view> </view>
</fui-fab> </fui-fab>
<register-dialog ref="registerDialogRef"></register-dialog> <register-dialog ref="registerDialogRef"></register-dialog>
...@@ -315,6 +402,9 @@ ...@@ -315,6 +402,9 @@
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
body {
background-color: #e6f5e8;
}
.mt-19 { .mt-19 {
margin-top: 38rpx; margin-top: 38rpx;
} }
...@@ -331,7 +421,7 @@ ...@@ -331,7 +421,7 @@
margin-top: 538rpx; margin-top: 538rpx;
} }
.page { .page {
padding-bottom: 128rpx; // padding-bottom: 128rpx;
background-color: #e6f5e8; background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH; mix-blend-mode: NOTTHROUGH;
width: 100%; width: 100%;
...@@ -544,9 +634,14 @@ ...@@ -544,9 +634,14 @@
.image_7 { .image_7 {
width: 96rpx; width: 96rpx;
height: 96rpx; height: 96rpx;
border-radius: 50%;
} }
.image_12 { .image_12 {
margin-right: 58rpx; margin-right: 58rpx;
} }
} }
::v-deep .fui-fab__btn-main {
background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important;
box-shadow: 0px 1px 8px #5db66f;
}
</style> </style>
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
:src="item.picture" :src="item.picture"
@click="handleDetails(item)" @click="handleDetails(item)"
/> />
<view style="width: 75%"> <view style="width: 70%">
<view <view
class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-self-center" class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-self-center"
@click="handleDetails(item)" @click="handleDetails(item)"
...@@ -270,12 +270,10 @@ ...@@ -270,12 +270,10 @@
</view> --> </view> -->
</view> </view>
</view> </view>
<fui-fab background="#5db66f" position="right" distance="10" bottom="240" width="130" @click="handlePublish"> <fui-fab position="right" distance="10" bottom="240" width="96" @click="handlePublish">
<view class="text-white text-center"> <view class="text-white text-center">
<image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image> <view class="fab-icon"></view>
<view style="font-size: 24rpx" <view style="font-size: 24rpx">发布</view>
>发布{{ pageData.categoryTabs.find((item) => item.id === pageData.search.serviceType)?.name }}</view
>
</view> </view>
</fui-fab> </fui-fab>
...@@ -462,6 +460,8 @@ ...@@ -462,6 +460,8 @@
.image_8 { .image_8 {
width: 160rpx; width: 160rpx;
height: 160rpx; height: 160rpx;
border-radius: 10rpx;
margin-right: 20rpx;
} }
.font_6 { .font_6 {
font-size: 24rpx; font-size: 24rpx;
...@@ -641,4 +641,9 @@ ...@@ -641,4 +641,9 @@
color: #333333; color: #333333;
} }
} }
::v-deep .fui-fab__btn-main {
background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important;
box-shadow: 0px 1px 8px #5db66f;
}
</style> </style>
...@@ -54,8 +54,17 @@ export const convertToTree = (): AreaNode[] => { ...@@ -54,8 +54,17 @@ export const convertToTree = (): AreaNode[] => {
return tree return tree
} }
// 导出树形结构数据 // 导出树形结构数据(懒加载)
export const areaTree = convertToTree() let areaTreeCache: AreaNode[] | null = null
export const getAreaTree = (): AreaNode[] => {
if (!areaTreeCache) {
areaTreeCache = convertToTree()
}
return areaTreeCache
}
// 向后兼容的导出
export const areaTree = getAreaTree()
/** /**
* 根据地区代码获取完整的地区名称(如:广东省广州市天河区) * 根据地区代码获取完整的地区名称(如:广东省广州市天河区)
...@@ -85,46 +94,28 @@ export const getFullAreaName = (code: string): string => { ...@@ -85,46 +94,28 @@ export const getFullAreaName = (code: string): string => {
// 根据编号获取文本 // 根据编号获取文本
export function getTextByCode(code) { export function getTextByCode(code) {
// 遍历省份 // 直接查询,避免多层嵌套循环
for (const provinceCode in areaList.province_list) { if (areaList.province_list[code]) {
if (provinceCode === code) { return areaList.province_list[code]
return areaList.province_list[provinceCode] }
} if (areaList.city_list[code]) {
// 遍历城市 return areaList.city_list[code]
for (const cityCode in areaList.city_list) { }
if (cityCode === code) { if (areaList.county_list[code]) {
return areaList.city_list[cityCode] return areaList.county_list[code]
}
// 遍历区县
for (const countyCode in areaList.county_list) {
if (countyCode === code) {
return areaList.county_list[countyCode]
}
}
}
} }
return null return null
} }
// 根据文本获取编号 // 根据文本获取编号
export function getCodeByText(text) { export function getCodeByText(text) {
// 遍历省份 // 使用Object.entries和find方法优化性能
for (const provinceCode in areaList.province_list) { const findCode = (obj: Record<string, string>) => {
if (areaList.province_list[provinceCode] === text) { const entry = Object.entries(obj).find(([_, value]) => value === text)
return provinceCode return entry ? entry[0] : null
}
}
// 遍历城市
for (const cityCode in areaList.city_list) {
if (areaList.city_list[cityCode] === text) {
return cityCode
}
}
// 遍历区县
for (const countyCode in areaList.county_list) {
if (areaList.county_list[countyCode] === text) {
return countyCode
}
} }
return null
return findCode(areaList.province_list)
|| findCode(areaList.city_list)
|| findCode(areaList.county_list)
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论