提交 e266b465 作者: 15973817745_JPN

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

......@@ -180,3 +180,39 @@ page {
.fui-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 @@
</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">
<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 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 style="font-size: 24rpx">发布供应</view>
<view class="fab-icon"></view>
<view style="font-size: 24rpx">发布</view>
</view>
</fui-fab>
......@@ -827,4 +827,9 @@
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>
......@@ -77,7 +77,13 @@
<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.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="mr-3" style="color: #ccc">|</view>
<view></view>
......
......@@ -3,6 +3,7 @@
import { onPullDownRefresh, onLoad } from '@dcloudio/uni-app'
import * as NongzhiAPI from '@/api/model/nongzhi'
import Navigate from '@/utils/page/navigate'
import { url } from 'inspector'
// 下拉刷新
onPullDownRefresh(() => {
......@@ -47,6 +48,7 @@
title: '季节性用工',
description: '三农区域灵活用工服务',
actionText: '去发布',
url: '/pages/nongjifuwu/farm-form',
},
{
id: 2,
......@@ -54,14 +56,15 @@
title: '农机手调度',
description: '专业人员作业安排',
actionText: '去预约',
url: '/pages/nongjifuwu/nongjifuwu',
},
{
id: 3,
image: '/static/images/codefun/06319419d17b7630c1d5bc415bcd26ef.png',
title: '作业质量评价',
description: '农机定位精度≤50米',
actionText: '去评价',
},
// {
// id: 3,
// image: '/static/images/codefun/06319419d17b7630c1d5bc415bcd26ef.png',
// title: '作业质量评价',
// description: '农机定位精度≤50米',
// actionText: '去评价',
// },
],
// 助农金融产品
......@@ -347,7 +350,12 @@
</view>
<view class="codefun-flex-col group_8">
<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">
<image class="image_8" :src="service.image" />
......@@ -367,7 +375,7 @@
<text class="font_8" :class="`text_${9 + service.id}`">{{ service.actionText }}</text>
</view>
</view>
</view>
</navigator>
</view>
<view class="codefun-flex-col codefun-mt-24">
<view class="codefun-flex-row codefun-justify-between codefun-items-center group_11">
......@@ -503,7 +511,7 @@
class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch group_14"
>
<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 class="codefun-flex-col codefun-self-stretch section_14">
<view class="codefun-flex-row">
......
......@@ -113,23 +113,107 @@
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() {
// 如果正在加载或没有更多数据,直接返回
if (pageData.loading || (pageData.total > 0 && pageData.employmentList.length >= pageData.total)) {
return
}
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
console.log('records', records)
records.map((item) => {
item.area = item.area.split(',')
item.area = getTextByCode(item.area[0]) + ' ' + getTextByCode(item.area[1])
// 批量处理数据,避免多次DOM操作
const processedRecords = records.map((item) => {
// 缓存区域处理结果
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
})
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
})
.finally(() => {
} catch (error) {
console.error('获取用工列表失败:', error)
// 这里可以添加用户友好的错误提示
// uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
} finally {
pageData.loading = false
})
pageData.requestDebounce = null
}
}, 150)
}
// 分类标签点击事件
......@@ -251,7 +335,7 @@
@click="onEmploymentItemClick(item)"
>
<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-row codefun-justify-between codefun-items-center">
<text class="codefun-self-start font">{{ item.name }}</text>
......@@ -269,7 +353,9 @@
<view class="flex codefun-items-center gap-1">
<image class="image_9" src="/src/static/images/time.svg" />
<text class="font_4"
>预计{{ getDaysDiff(item.starttime, item.estimatedendtime) }}</text
>预计{{
item.daysDiff || getDaysDiff(item.starttime, item.estimatedendtime)
}}</text
>
</view>
<view class="flex codefun-items-center gap-1">
......@@ -304,10 +390,11 @@
<!-- <image class="codefun-self-end image_7 image_12 mt-269" :src="pageData.bottomImage" /> -->
</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">
<image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image>
<view style="font-size: 24rpx">发布用工</view>
<!-- <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>
</fui-fab>
<register-dialog ref="registerDialogRef"></register-dialog>
......@@ -315,6 +402,9 @@
</template>
<style scoped lang="scss">
body {
background-color: #e6f5e8;
}
.mt-19 {
margin-top: 38rpx;
}
......@@ -331,7 +421,7 @@
margin-top: 538rpx;
}
.page {
padding-bottom: 128rpx;
// padding-bottom: 128rpx;
background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH;
width: 100%;
......@@ -544,9 +634,14 @@
.image_7 {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
}
.image_12 {
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>
......@@ -126,7 +126,7 @@
:src="item.picture"
@click="handleDetails(item)"
/>
<view style="width: 75%">
<view style="width: 70%">
<view
class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-self-center"
@click="handleDetails(item)"
......@@ -270,12 +270,10 @@
</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">
<image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image>
<view style="font-size: 24rpx"
>发布{{ pageData.categoryTabs.find((item) => item.id === pageData.search.serviceType)?.name }}</view
>
<view class="fab-icon"></view>
<view style="font-size: 24rpx">发布</view>
</view>
</fui-fab>
......@@ -462,6 +460,8 @@
.image_8 {
width: 160rpx;
height: 160rpx;
border-radius: 10rpx;
margin-right: 20rpx;
}
.font_6 {
font-size: 24rpx;
......@@ -641,4 +641,9 @@
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>
......@@ -54,8 +54,17 @@ export const convertToTree = (): AreaNode[] => {
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 => {
// 根据编号获取文本
export function getTextByCode(code) {
// 遍历省份
for (const provinceCode in areaList.province_list) {
if (provinceCode === code) {
return areaList.province_list[provinceCode]
}
// 遍历城市
for (const cityCode in areaList.city_list) {
if (cityCode === code) {
return areaList.city_list[cityCode]
}
// 遍历区县
for (const countyCode in areaList.county_list) {
if (countyCode === code) {
return areaList.county_list[countyCode]
}
}
}
// 直接查询,避免多层嵌套循环
if (areaList.province_list[code]) {
return areaList.province_list[code]
}
if (areaList.city_list[code]) {
return areaList.city_list[code]
}
if (areaList.county_list[code]) {
return areaList.county_list[code]
}
return null
}
// 根据文本获取编号
export function getCodeByText(text) {
// 遍历省份
for (const provinceCode in areaList.province_list) {
if (areaList.province_list[provinceCode] === text) {
return provinceCode
}
}
// 遍历城市
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
}
// 使用Object.entries和find方法优化性能
const findCode = (obj: Record<string, string>) => {
const entry = Object.entries(obj).find(([_, value]) => value === text)
return entry ? entry[0] : null
}
return null
return findCode(areaList.province_list)
|| findCode(areaList.city_list)
|| findCode(areaList.county_list)
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论