提交 c44bd1b9 作者: 王定

feat: 优化一些存在的问题

上级 ba786372
......@@ -300,7 +300,6 @@
"buttons": [
{
"text": "申请入驻",
"fontSrc": "/static/uni.ttf",
"color": "#fff",
"fontSize": "28rpx",
"width": "auto"
......@@ -695,12 +694,10 @@
"titleNView": {
"buttons": [
{
"text": "\uE674 申请入驻",
"fontSrc": "/static/fonts/tihuan.ttf",
"text": "申请入驻",
"color": "#fff",
"fontSize": "26rpx",
"width": "auto",
"icon": "map"
"width": "auto"
}
]
}
......
......@@ -483,7 +483,7 @@
<view
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_3"
>
<text class="font_13">{{ product.labels_dictText.split(',')[0] }}</text>
<text v-if="product.labels_dictText" class="font_13">{{ product.labels_dictText.split(',')[0] }}</text>
</view>
</view>
<text
......
......@@ -6,6 +6,7 @@
import { useGlobSetting } from '/@/hooks/setting'
import * as NongzhiAPI from '@/api/model/nongzhi'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import ConfirmDialog from '@/components/ConfirmDialog/index.vue'
const userStore = useUserStore()
const globSetting = useGlobSetting()
let enterpriseId = null;
......@@ -41,6 +42,8 @@
categoryVal:[],
enterpriseProduct:[],
contactName:"",
showConfirmDialog:false,
rules: [
{
......@@ -212,6 +215,7 @@
NongzhiAPI.getEnterpriseDetail({ id }).then((res) => {
pageData.enterpriseCers = res.enterpriseCers.split(",");
pageData.data = res;
pageData.contactName = res.contactPerson.substring(0,1) + new Array(res.contactPerson.length).join('*');
productInfo.unitCode = res.enterpriseCode;
productInfo.enterpriseId = res.id;
})
......@@ -237,7 +241,7 @@
}
function makePhoneCall(){
uni.makePhoneCall({
phoneNumber: pageData.data.createBy
phoneNumber: pageData.data.contactMobile
});
}
</script>
......@@ -271,10 +275,20 @@
</view>
<view class="make-phone-view">
<fui-button text="我要购买" bold radius="96rpx" @click="makePhoneCall()" height="80rpx"/>
<fui-button text="我要购买" bold radius="96rpx" @click="pageData.showConfirmDialog=true;" height="80rpx"/>
</view>
</view>
<!-- 确认对话框 -->
<ConfirmDialog
v-model:show="pageData.showConfirmDialog"
title="温馨提示"
:content="`你将与${pageData.contactName}进行电话沟通,若继续,请点击确认按钮!`"
cancelText="取消"
confirmText="确认"
@confirm="makePhoneCall"
/>
<fui-fab position="right" distance="10" bottom="240" width="120" @click="handlePublish">
<view class="text-white text-center">
<view class="fab-icon" />
......
......@@ -20,9 +20,7 @@
params: {
pageNo: 1,
pageSize: 10,
enterprise:{
bizCategory:2
}
}, // 分页参数
hasMore: true, // 是否还有更多数据
loading: false, // 是否正在加载
......
......@@ -239,6 +239,8 @@
}
const formRef = ref()
function submit() {
const { lon, lat } = uni.getStorageSync('location')
pageData.position = [lon, lat];
pageData.form.enterpriseLogoUrl = pageData.enterpriseLogoArr.join('');
pageData.form.enterpriseCers = pageData.cersImageArr.join(',');
if (pageData.position.length == 0) {
......@@ -292,7 +294,7 @@
</fui-form-item>
</view>
<view class="mt20">
<fui-input required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" size="28"/>
<fui-input required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" size="28" disabled/>
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.addr" labelSize="28" label-width="180" size="28"/>
<fui-input required label="联系人" placeholder="请输入联系人" v-model="form.contactPerson" labelSize="28" label-width="180" size="28"/>
<fui-input required label="联系电话" placeholder="请输入联系电话" v-model="form.contactMobile" labelSize="28" label-width="180" size="28"></fui-input>
......@@ -318,7 +320,7 @@
<fui-text class="fui-color__link">《服务条款》</fui-text>
</view>
<view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx">
<fui-button text="立即申请" bold radius="96rpx" @click="submit" />
<fui-button text="提交申请" bold radius="96rpx" @click="submit" />
</view>
</fui-form>
</view>
......
......@@ -70,7 +70,6 @@ const model = reactive({
onLoad((options) => {
model.id = options.id;
model.currentEmploymentId = options.currentEmploymentId;
console.log("model.currentEmploymentId= "+model.currentEmploymentId)
model.name = decodeURIComponent(options.name)
model.search.pageNo = 1
model.search.publishstatu = 1
......@@ -83,7 +82,7 @@ onLoad((options) => {
const center: [number, number] = [uni.getStorageSync('location').lon, uni.getStorageSync('location').lat]
const registerDialogRef = ref()
const [registerMap, map] = useMapbox({
style: { center, zoom: 12 },
style: { center, zoom: 10 },
onLoaded: (data) => {
// 渲染用户当前位置
renderUserLocation()
......@@ -101,19 +100,51 @@ const [registerMap, map] = useMapbox({
// 处理来自 renderjs 层的自定义事件
if (event.type === 'custom' && event.name === 'navigateToDetail') {
console.log('接收到导航事件,id:', event)
registerDialogRef.value.open({ id: event.data })
// Navigate.to(`/pages/linghuoyonggong/detail/index?id=${event.data}`)
if(model.currentEmploymentId == 2){
getLaborAppDetail(event.data);
}else{
registerDialogRef.value.open({ id: event.data })
}
}
}
},
})
async function getLaborAppDetail(id) {
await LinghuoyonggongAPI.getLaborAppDetail({ id }).then((res) => {
uni.makePhoneCall({
phoneNumber: res.contactMobile
});
})
}
// 创建弹框HTML内容
function createPopupHTML(employment) {
if (!employment) return ''
if(model.currentEmploymentId == 2){
return `
<div style="width: 220px;background:#FFFFFF;padding: 12px;display: flex;flex-direction: column;">
<div style="display: flex;justify-content: space-between;line-height: 20px;">
<div style="font-size: 16px;color: #333333;">${employment.villageName}</div>
<div style="color: #5DB66F;font-size: 12px;display: flex;align-items: center;">
<image style="width:11px;height:13px;margin-right:7px;" src="./static/images/linghuoyonggong/distance.png" />
<div>${getDistanceText2(employment)}</div>
</div>
</div>
<div style="color: #5DB66F;margin-top: 6px;line-height: 20px;font-size: 12px;display: flex;align-items: center;">
<image style="width:12px;height:12px;margin-right:7px;" src="./static/images/linghuoyonggong/avatar.png" />
<div>待工人数${employment.workers}名</div>
</div>
<div style="color: #999999;margin-top: 4px;line-height: 20px;font-size: 12px;display: flex;align-items: center;">
<image style="width:11px;height:13px;margin-right:7px;" src="./static/images/linghuoyonggong/skill.png" />
<div>技能:${employment.skills.length ? employment.skills.join("、") : '未填写'}</div>
</div>
<a href="#" onclick="window.navigateToDetail('${employment.id}'); return false;" style="margin-top:8px;background: #5DB66F;text-decoration: none;border-radius: 200px;padding: 10px;text-align: center;color: #FFFFFF;font-size: 12px;display: flex;justify-content: center;align-items: center;">电话沟通</a>
</div>
`;
}else{
const distance = getDistanceText(employment)
const stars = getStarsHTML(employment)
console.log('employment', employment)
return `
<div style="
max-width: 280px;
......@@ -188,6 +219,8 @@ function createPopupHTML(employment) {
</div>
</div>
`
}
}
// 渲染用户位置
......@@ -225,11 +258,20 @@ function renderEmploymentMarkers() {
console.log('渲染用工标记数量:', model.employmentList.length)
console.log('用工数据:', model.employmentList)
let longitude = null,latitude = null;
// 使用 Marker 方式渲染带自定义图标的标记
model.employmentList.forEach((item) => {
if (item.longitude && item.latitude) {
if(model.currentEmploymentId == 2){
longitude = item.lon;
latitude = item.lat;
}else{
longitude = item.longitude;
latitude = item.latitude;
}
if (longitude && latitude) {
const markerId = `employment-marker-${item.id}`
let imageUrl = item.picture || '/static/images/linghuoyonggong/default-icon.png'
// let imageUrl = '/static/images/linghuoyonggong/default-icon.png'
const iconSize: [number, number] = [40, 40] // 图标大小
// #ifdef APP-PLUS
......@@ -242,7 +284,7 @@ function renderEmploymentMarkers() {
// 使用 addMarker 添加到地图,带上 popup 和自定义图标
map.addMarker(
markerId,
[item.longitude, item.latitude],
[longitude, latitude],
createPopupHTML(item),
false, // 不默认打开
imageUrl, // 自定义图标图片URL
......@@ -273,7 +315,8 @@ function getEmploymentList() {
}
model.loading = true
try {
LinghuoyonggongAPI.employmentList(model.search).then(async (res) => {
if(model.currentEmploymentId == 2){
LinghuoyonggongAPI.getLaborAppList(model.search).then(async (res) => {
const { records, total } = res
// 批量处理数据,避免多次DOM操作
const processedRecords = records.map((item) => {
......@@ -299,12 +342,44 @@ function getEmploymentList() {
}
model.total = total
// 数据加载完成后渲染地图标记
nextTick(() => {
renderEmploymentMarkers()
})
})
}else{
LinghuoyonggongAPI.employmentList(model.search).then(async (res) => {
const { records, total } = res
// 批量处理数据,避免多次DOM操作
const processedRecords = records.map((item) => {
// 缓存区域处理结果
item.area = getText(item.area, ' / ')
// 计算天数并缓存结果
if (item.starttime && item.estimatedendtime) {
item.daysDiff = getDaysDiff(item.starttime, item.estimatedendtime)
}
return item
})
// 一次性更新数据,避免多次响应式更新
if (model.search.pageNo === 1) {
model.employmentList = processedRecords
} else {
// 避免重复数据加载
const existingIds = new Set(model.employmentList.map((item) => item.id))
const newRecords = processedRecords.filter((item) => !existingIds.has(item.id))
model.employmentList = [...model.employmentList, ...newRecords]
}
model.total = total
// 数据加载完成后渲染地图标记
nextTick(() => {
renderEmploymentMarkers()
})
})
}
} catch (error) {
console.error('获取用工列表失败:', error)
// 这里可以添加用户友好的错误提示
......@@ -390,13 +465,26 @@ function closeEmploymentPopup() {
model.showEmploymentPopup = false
model.selectedEmployment = null
}
// 计算距离显示
function getDistanceText2(item) {
if (!item || !item.lon || !model.userLocation.longitude) {
return '未知'
}
// 使用turf计算距离
const from = turf.point([model.userLocation.longitude, model.userLocation.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`;
}
// 计算距离显示
function getDistanceText(employment) {
if (!employment || !employment.longitude || !employment.latitude) {
return '未知'
}
// 使用turf计算距离
const from = turf.point([model.userLocation.longitude, model.userLocation.latitude])
const to = turf.point([employment.longitude, employment.latitude])
......
......@@ -3,10 +3,14 @@
import { onLoad, onShow } from '@dcloudio/uni-app'
import { getCalculateAge } from '@/utils/date'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong';
import ConfirmDialog from '@/components/ConfirmDialog/index.vue'
const pageData = reactive({
loading: false,
workersParam:[],
contactMobile:""
contactMobile:"",
contactName:"",
showConfirmDialog:false,
})
// 字典值
const DictData = reactive({
......@@ -30,6 +34,7 @@
await LinghuoyonggongAPI.getLaborAppDetail({ id }).then((res) => {
pageData.workersParam = res.workers;
pageData.contactMobile = res.contactMobile;
pageData.contactName = res.contactName.substring(0,1) + new Array(res.contactName.length).join('*');
})
}
// 返回字典中的中文值
......@@ -76,10 +81,18 @@
</view>
</view>
</view>
<view v-if="!pageData.workersParam" class="make-phone-view">
<fui-button text="电话沟通" bold radius="96rpx" @click="makePhoneCall()" height="80rpx"/>
<view v-if="pageData.workersParam.length" class="make-phone-view">
<fui-button text="电话沟通" bold radius="96rpx" @click="pageData.showConfirmDialog = true" height="80rpx"/>
</view>
<!-- 确认对话框 -->
<ConfirmDialog
v-model:show="pageData.showConfirmDialog"
title="温馨提示"
:content="`你将与${pageData.contactName}进行电话沟通,若继续,请点击确认按钮!`"
cancelText="取消"
confirmText="确认"
@confirm="makePhoneCall"
/>
</view>
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template>
......
......@@ -387,21 +387,26 @@
<view class="d-flex j-sb">
<view class="left-width village_number_view">
<view class="village_view text_overflow_ellipsis">{{ item.villageName }}</view>
<view class="d-flex align-center"><image class="avatar_icon" src="/static/images/linghuoyonggong/avatar.png" /><text class="text-color">待工人{{item.workers}}</text></view>
<view class="d-flex align-center"><image class="avatar_icon" src="/static/images/linghuoyonggong/avatar.png" /><text class="text-color">待工人{{item.workers}}</text></view>
</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">{{getDistanceText(item)}}</text>
</view>
</view>
<view class="d-flex j-sb skill_details_view">
<view class="d-flex j-sb skill_details_view" style="padding-bottom: 0px;">
<view class="left-width d-flex j-sb align-center">
<image class="skill_icon" src="/static/images/linghuoyonggong/skill.png" />
<view class="skill_view text_overflow_ellipsis">技能:{{item.skills.length ? item.skills.join("、") : '未填写'}}</view>
</view>
</view>
<view class="d-flex j-sb skill_details_view">
<view class="left-width d-flex j-sb align-center">
<image class="skill_icon" src="/static/images/linghuoyonggong/address.png" />
<view class="skill_view text_overflow_ellipsis">地址:{{item.villageFullName}}</view>
</view>
<view class="right-width see_details_btn" @click="onDetailsClick(item)">查看详情</view>
</view>
</view>
</template>
</template>
......@@ -726,7 +731,7 @@
height: 26rpx;
}
.skill_view{
width:416rpx;
width:440rpx;
font-size: 24rpx;
height: 40rpx;
line-height: 40rpx;
......
......@@ -41,6 +41,8 @@
categoryVal:[],
enterpriseProduct:[],
contactName:"",
showConfirmDialog:false,
rules: [
{
......@@ -204,6 +206,7 @@
NongzhiAPI.getEnterpriseDetail({ id }).then((res) => {
pageData.enterpriseCers = res.enterpriseCers.split(",");
pageData.data = res;
pageData.contactName = res.contactPerson.substring(0,1) + new Array(res.contactPerson.length).join('*');
productInfo.enterpriseId = res.id;
})
}
......@@ -230,7 +233,7 @@
}
function makePhoneCall(){
uni.makePhoneCall({
phoneNumber: pageData.data.createBy
phoneNumber: pageData.data.contactMobile
});
}
</script>
......@@ -269,10 +272,20 @@
</view>
<view class="make-phone-view">
<fui-button text="我要租赁" bold radius="96rpx" @click="makePhoneCall()" height="80rpx"/>
<fui-button text="我要租赁" bold radius="96rpx" @click="pageData.showConfirmDialog=true;" height="80rpx"/>
</view>
</view>
<!-- 确认对话框 -->
<ConfirmDialog
v-model:show="pageData.showConfirmDialog"
title="温馨提示"
:content="`你将与${pageData.contactName}进行电话沟通,若继续,请点击确认按钮!`"
cancelText="取消"
confirmText="确认"
@confirm="makePhoneCall"
/>
<fui-fab position="right" distance="10" bottom="240" width="120" @click="handlePublish">
<view class="text-white text-center">
<view class="fab-icon" />
......
......@@ -38,9 +38,7 @@
pageSize: 10,
serviceType: 1,
scope: null,
enterprise:{
bizCategory:3
}
},
farmMachineList: [],
total: 0,
......
......@@ -239,6 +239,8 @@
}
const formRef = ref()
function submit() {
const { lon, lat } = uni.getStorageSync('location')
pageData.position = [lon, lat];
pageData.form.enterpriseLogoUrl = pageData.enterpriseLogoArr.join('');
pageData.form.enterpriseCers = pageData.cersImageArr.join(',');
if (pageData.position.length == 0) {
......@@ -292,7 +294,7 @@
</fui-form-item>
</view>
<view class="mt20">
<fui-input required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" size="28"/>
<fui-input required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" size="28" disabled/>
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.addr" labelSize="28" label-width="180" size="28"/>
<fui-input required label="联系人" placeholder="请输入联系人" v-model="form.contactPerson" labelSize="28" label-width="180" size="28"/>
<fui-input required label="联系电话" placeholder="请输入联系电话" v-model="form.contactMobile" labelSize="28" label-width="180" size="28"></fui-input>
......@@ -318,7 +320,7 @@
<fui-text class="fui-color__link">《服务条款》</fui-text>
</view>
<view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx">
<fui-button text="立即申请" bold radius="96rpx" @click="submit" />
<fui-button text="提交申请" bold radius="96rpx" @click="submit" />
</view>
</fui-form>
</view>
......
......@@ -18,6 +18,15 @@
loading: false, // 是否正在加载
dataList:[]
})
onLoad((options) => {
if(options && options.category){
pageData.params.news.category = options.category;
currentTab.value = 'redian';
}else{
pageData.params.news.category = 2;
currentTab.value = 'nongye';
}
})
onShow(() => {
getListData();
})
......
......@@ -442,7 +442,7 @@ function onClickWarning(item) {
}
function toNewsList() {
uni.navigateTo({
url: '/pages/news/index',
url: '/pages/nongyezhengce/nongyezhengce?category=1',
})
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论