提交 0fb18627 作者: 廖在望

feat: 功能修改

上级 083562c2
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,7 +3,7 @@ import { otherHttp } from '/@/utils/http/axios' ...@@ -3,7 +3,7 @@ import { otherHttp } from '/@/utils/http/axios'
enum Api { enum Api {
cascaderHn = '/region/cascader/hn', // 获取湖南省内 市/区县/乡镇级联数据 cascaderHn = '/region/cascader/hn', // 获取湖南省内 市/区县/乡镇级联数据
queryByType = '/banner/queryByType', // 获取开屏页背景图片 queryByType = '/banner/queryByType', // 获取开屏页背景图片
} }
/** /**
...@@ -23,8 +23,8 @@ export function getQueryByType(params = {}) { ...@@ -23,8 +23,8 @@ export function getQueryByType(params = {}) {
return otherHttp.get({ return otherHttp.get({
url: Api.queryByType, url: Api.queryByType,
params, params,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
} },
}) })
} }
\ No newline at end of file
...@@ -7,10 +7,9 @@ enum Api { ...@@ -7,10 +7,9 @@ enum Api {
serviceStatsList = '/online/cgform/api/getData/491863dde351404da63a1a6e8c699c4c', // 服务展示窗 serviceStatsList = '/online/cgform/api/getData/491863dde351404da63a1a6e8c699c4c', // 服务展示窗
agricultureClassList = '/online/cgform/api/getData/311c300e05694ba69a063d04c8572e9e', // 农技课堂 agricultureClassList = '/online/cgform/api/getData/311c300e05694ba69a063d04c8572e9e', // 农技课堂
warning = '/warningInfo/list', warning = '/warningInfo/list',
postConsultRecordAdd = '/server/consultRecord/add', // 添加咨询信息 postConsultRecordAdd = '/server/consultRecord/add', // 添加咨询信息
getNewsList = '/news/list', // 分页列表查询 getNewsList = '/news/list', // 分页列表查询
} }
/** /**
...@@ -20,7 +19,7 @@ enum Api { ...@@ -20,7 +19,7 @@ enum Api {
export function postConsultRecordAdd(params = {}) { export function postConsultRecordAdd(params = {}) {
return otherHttp.post({ return otherHttp.post({
url: Api.postConsultRecordAdd, url: Api.postConsultRecordAdd,
params params,
}) })
} }
......
...@@ -29,7 +29,7 @@ export function addViewCount(params) { ...@@ -29,7 +29,7 @@ export function addViewCount(params) {
url: Api.viewCount, url: Api.viewCount,
params, params,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded',
} },
}) })
} }
...@@ -7,14 +7,14 @@ enum Api { ...@@ -7,14 +7,14 @@ enum Api {
employmentDetails = '/employment/queryById', // 查看用工详情 employmentDetails = '/employment/queryById', // 查看用工详情
employmentEdit = '/employment/app/edit', // 编辑用工 employmentEdit = '/employment/app/edit', // 编辑用工
employmentRegister = '/employment/app/register', // 报名用工 employmentRegister = '/employment/app/register', // 报名用工
queryConditions = '/sys/region/queryConditions', // 组合条件查询市——村 queryConditions = '/sys/region/queryConditions', // 组合条件查询市——村
gitListByCodeDict = '/sys/dictItem/listByCode', // 查询字典 gitListByCodeDict = '/sys/dictItem/listByCode', // 查询字典
queryByCategoryAndCode = '/sys/labelCategory/queryByCategoryAndCode', // 查询字典 queryByCategoryAndCode = '/sys/labelCategory/queryByCategoryAndCode', // 查询字典
postLaborAdd = '/server/labor/add', // 新增 postLaborAdd = '/server/labor/add', // 新增
getLaborAppList = '/server/labor/appList', // APP用工列表查询 getLaborAppList = '/server/labor/appList', // APP用工列表查询
getLaborAppDetail = '/server/labor/appDetail', // APP用工详情查询 getLaborAppDetail = '/server/labor/appDetail', // APP用工详情查询
getLaborAppDel = '/server/labor/delete', // APP用工通过id删除 getLaborAppDel = '/server/labor/delete', // APP用工通过id删除
} }
/** /**
* 删除设备 * 删除设备
...@@ -24,10 +24,10 @@ enum Api { ...@@ -24,10 +24,10 @@ enum Api {
export function getLaborAppDel(params = {}) { export function getLaborAppDel(params = {}) {
return otherHttp.delete({ return otherHttp.delete({
url: Api.getLaborAppDel, url: Api.getLaborAppDel,
params, params,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
} },
}) })
} }
...@@ -78,9 +78,9 @@ export function queryByCategoryAndCode(params = {}) { ...@@ -78,9 +78,9 @@ export function queryByCategoryAndCode(params = {}) {
return otherHttp.get({ return otherHttp.get({
url: Api.queryByCategoryAndCode, url: Api.queryByCategoryAndCode,
params, params,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
}, },
}) })
} }
...@@ -92,9 +92,9 @@ export function gitListByCodeDict(params = {}) { ...@@ -92,9 +92,9 @@ export function gitListByCodeDict(params = {}) {
return otherHttp.get({ return otherHttp.get({
url: Api.gitListByCodeDict, url: Api.gitListByCodeDict,
params, params,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
}, },
}) })
} }
......
...@@ -29,7 +29,7 @@ export function addViewCount(params) { ...@@ -29,7 +29,7 @@ export function addViewCount(params) {
url: Api.viewCount, url: Api.viewCount,
params, params,
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded',
} },
}) })
} }
...@@ -161,9 +161,9 @@ export function farmsAdd(params = {}) { ...@@ -161,9 +161,9 @@ export function farmsAdd(params = {}) {
}) })
} }
/** /**
* @param params * @param params
* @description: 编辑农场 * @description: 编辑农场
* @returns * @returns
*/ */
export function farmsEdit(params = {}) { export function farmsEdit(params = {}) {
return otherHttp.post({ return otherHttp.post({
......
...@@ -8,10 +8,9 @@ enum Api { ...@@ -8,10 +8,9 @@ enum Api {
farmMachineAddFarm = '/farmMachine/machineWork/app/addFarm', // 发布农活服务 farmMachineAddFarm = '/farmMachine/machineWork/app/addFarm', // 发布农活服务
farmMachineEdit = '/farmMachine/machineWork/edit', // 编辑农机服务 farmMachineEdit = '/farmMachine/machineWork/edit', // 编辑农机服务
farmMachineRegister = '/farmMachine/machineWork/app/register', // 参与服务 farmMachineRegister = '/farmMachine/machineWork/app/register', // 参与服务
postMachineryAdd = '/server/machinery/add', // 农机商品管理-添加 postMachineryAdd = '/server/machinery/add', // 农机商品管理-添加
postMachineryQueryById = '/server/machinery/listByEnterpriseId', // 按企业ID查询未删除农机 postMachineryQueryById = '/server/machinery/listByEnterpriseId', // 按企业ID查询未删除农机
} }
/** /**
* @param params 请求参数 * @param params 请求参数
...@@ -107,4 +106,4 @@ export function farmMachineRegister(params = {}) { ...@@ -107,4 +106,4 @@ export function farmMachineRegister(params = {}) {
url: Api.farmMachineRegister, url: Api.farmMachineRegister,
params, params,
}) })
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ import { otherHttp } from '/@/utils/http/axios' ...@@ -2,11 +2,11 @@ import { otherHttp } from '/@/utils/http/axios'
enum Api { enum Api {
goodsList = '/trade/goods/list', // 农资列表 goodsList = '/trade/goods/list', // 农资列表
getEnterpriseList = '/server/enterprise/list', // 可信农资列表 getEnterpriseList = '/server/enterprise/list', // 可信农资列表
postEnterpriseAdd = '/server/enterprise/add', // 入驻申请 postEnterpriseAdd = '/server/enterprise/add', // 入驻申请
getEnterpriseDetail= '/server/enterprise/detail', // 企业详情 getEnterpriseDetail = '/server/enterprise/detail', // 企业详情
postGoodsAdd = '/trade/goods/add', // 农资商品管理-添加 postGoodsAdd = '/trade/goods/add', // 农资商品管理-添加
getGoodsQueryById = '/trade/goods/listByEnterpriseId', // 农资商品管理-通过id查询 getGoodsQueryById = '/trade/goods/listByEnterpriseId', // 农资商品管理-通过id查询
} }
/** /**
* @param params 请求参数 * @param params 请求参数
...@@ -81,4 +81,4 @@ export function getEnterpriseList(params = {}) { ...@@ -81,4 +81,4 @@ export function getEnterpriseList(params = {}) {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
}, },
}) })
} }
\ No newline at end of file
...@@ -17,12 +17,15 @@ enum Api { ...@@ -17,12 +17,15 @@ enum Api {
* @description: 查询登录用户信息 * @description: 查询登录用户信息
*/ */
export function getUserInfo(params = {}) { export function getUserInfo(params = {}) {
return otherHttp.get({ return otherHttp.get(
url: Api.getUserInfo, {
data: params, url: Api.getUserInfo,
}, { data: params,
errorMessageMode: null },
}) {
errorMessageMode: null,
},
)
} }
/** /**
...@@ -43,7 +46,7 @@ export function sysLogin(params = {}) { ...@@ -43,7 +46,7 @@ export function sysLogin(params = {}) {
export function phoneLogin(params = {}) { export function phoneLogin(params = {}) {
return otherHttp.post({ return otherHttp.post({
url: Api.phoneLogin, url: Api.phoneLogin,
data: params data: params,
}) })
} }
...@@ -54,7 +57,7 @@ export function phoneLogin(params = {}) { ...@@ -54,7 +57,7 @@ export function phoneLogin(params = {}) {
export function sysSms(params = {}) { export function sysSms(params = {}) {
return otherHttp.post({ return otherHttp.post({
url: Api.sms, url: Api.sms,
data: params data: params,
}) })
} }
......
<script setup lang="ts">
interface Props {
show?: boolean
title?: string
content?: string
cancelText?: string
confirmText?: string
}
const props = withDefaults(defineProps<Props>(), {
show: false,
title: '提示',
content: '',
cancelText: '取消',
confirmText: '确认',
})
const emit = defineEmits<{
(e: 'update:show', value: boolean): void
(e: 'cancel'): void
(e: 'confirm'): void
}>()
function handleCancel() {
emit('update:show', false)
emit('cancel')
}
function handleConfirm() {
emit('update:show', false)
emit('confirm')
}
</script>
<template> <template>
<view v-if="show" class="confirm-dialog-overlay" @click="handleCancel"> <view v-if="show" class="confirm-dialog-overlay" @click="handleCancel">
<view class="confirm-dialog-container" @click.stop> <view class="confirm-dialog-container" @click.stop>
...@@ -5,13 +39,13 @@ ...@@ -5,13 +39,13 @@
<view class="close-btn" @click="handleCancel"> <view class="close-btn" @click="handleCancel">
<text class="close-icon"></text> <text class="close-icon"></text>
</view> </view>
<!-- 标题 --> <!-- 标题 -->
<view class="dialog-title">{{ title }}</view> <view class="dialog-title">{{ title }}</view>
<!-- 内容 --> <!-- 内容 -->
<view class="dialog-content">{{ content }}</view> <view class="dialog-content">{{ content }}</view>
<!-- 按钮组 --> <!-- 按钮组 -->
<view class="dialog-buttons"> <view class="dialog-buttons">
<view class="cancel-btn" @click="handleCancel"> <view class="cancel-btn" @click="handleCancel">
...@@ -25,141 +59,107 @@ ...@@ -25,141 +59,107 @@
</view> </view>
</template> </template>
<script setup lang="ts">
interface Props {
show?: boolean
title?: string
content?: string
cancelText?: string
confirmText?: string
}
const props = withDefaults(defineProps<Props>(), {
show: false,
title: '提示',
content: '',
cancelText: '取消',
confirmText: '确认',
})
const emit = defineEmits<{
(e: 'update:show', value: boolean): void
(e: 'cancel'): void
(e: 'confirm'): void
}>()
function handleCancel() {
emit('update:show', false)
emit('cancel')
}
function handleConfirm() {
emit('update:show', false)
emit('confirm')
}
</script>
<style lang="scss" scoped> <style lang="scss" scoped>
.confirm-dialog-overlay { .confirm-dialog-overlay {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 99999; z-index: 99999;
} }
.confirm-dialog-container { .confirm-dialog-container {
position: relative; position: relative;
width: 600rpx; width: 600rpx;
background: linear-gradient(180deg, #E8F5E9 0%, #FFFFFF 30%); background: linear-gradient(180deg, #e8f5e9 0%, #ffffff 30%);
border-radius: 32rpx; border-radius: 32rpx;
padding: 60rpx 48rpx 48rpx; padding: 60rpx 48rpx 48rpx;
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1); box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
} }
.close-btn { .close-btn {
position: absolute; position: absolute;
top: 24rpx; top: 24rpx;
right: 24rpx; right: 24rpx;
width: 48rpx; width: 48rpx;
height: 48rpx; height: 48rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
cursor: pointer; cursor: pointer;
} }
.close-icon { .close-icon {
font-size: 36rpx; font-size: 36rpx;
color: #999999; color: #999999;
font-weight: 300; font-weight: 300;
} }
.dialog-title { .dialog-title {
font-size: 36rpx; font-size: 36rpx;
font-weight: 600; font-weight: 600;
color: #333333; color: #333333;
text-align: center; text-align: center;
margin-bottom: 32rpx; margin-bottom: 32rpx;
} }
.dialog-content { .dialog-content {
font-size: 28rpx; font-size: 28rpx;
color: #666666; color: #666666;
text-align: center; text-align: center;
line-height: 40rpx; line-height: 40rpx;
margin-bottom: 48rpx; margin-bottom: 48rpx;
} }
.dialog-buttons { .dialog-buttons {
display: flex; display: flex;
gap: 24rpx; gap: 24rpx;
} }
.cancel-btn, .cancel-btn,
.confirm-btn { .confirm-btn {
flex: 1; flex: 1;
height: 80rpx; height: 80rpx;
border-radius: 40rpx; border-radius: 40rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
cursor: pointer; cursor: pointer;
} }
.cancel-btn { .cancel-btn {
background-color: #FFFFFF; background-color: #ffffff;
border: 2rpx solid #5DB66F; border: 2rpx solid #5db66f;
} }
.cancel-text { .cancel-text {
font-size: 28rpx; font-size: 28rpx;
color: #5DB66F; color: #5db66f;
font-weight: 500; font-weight: 500;
} }
.confirm-btn { .confirm-btn {
background: linear-gradient(135deg, #5DB66F 0%, #4CAF50 100%); background: linear-gradient(135deg, #5db66f 0%, #4caf50 100%);
box-shadow: 0 4rpx 12rpx rgba(93, 182, 111, 0.3); box-shadow: 0 4rpx 12rpx rgba(93, 182, 111, 0.3);
} }
.confirm-text { .confirm-text {
font-size: 28rpx; font-size: 28rpx;
color: #FFFFFF; color: #ffffff;
font-weight: 500; font-weight: 500;
} }
.cancel-btn:active { .cancel-btn:active {
opacity: 0.8; opacity: 0.8;
} }
.confirm-btn:active { .confirm-btn:active {
opacity: 0.9; opacity: 0.9;
transform: scale(0.98); transform: scale(0.98);
} }
</style> </style>
<script setup lang="ts">
interface Props {
show?: boolean
title?: string
content?: string
cancelText?: string
confirmText?: string
}
const props = withDefaults(defineProps<Props>(), {
show: false,
title: '提示',
content: '',
cancelText: '取消',
confirmText: '确认',
})
const emit = defineEmits<{
(e: 'update:show', value: boolean): void
(e: 'cancel'): void
(e: 'confirm'): void
}>()
function handleCancel() {
emit('update:show', false)
emit('cancel')
}
function handleConfirm() {
emit('confirm')
}
</script>
<template> <template>
<view v-if="show" class="confirm-dialog-overlay" @click="handleCancel"> <view v-if="show" class="confirm-dialog-overlay" @click="handleCancel">
<view class="confirm-dialog-container" @click.stop> <view class="confirm-dialog-container" @click.stop>
<view class="confirm-dialog-content"> <view class="confirm-dialog-content">
<image class="apply_success_icon" src="/static/images/comm/apply_success_icon.png" /> <image class="apply_success_icon" src="/static/images/comm/apply_success_icon.png" />
</view> </view>
<!-- 标题 --> <!-- 标题 -->
<view class="dialog-title">{{ title }}</view> <view class="dialog-title">{{ title }}</view>
<!-- 内容 --> <!-- 内容 -->
<view class="dialog-content">{{ content }}</view> <view class="dialog-content">{{ content }}</view>
<!-- 按钮组 --> <!-- 按钮组 -->
<view class="dialog-buttons"> <view class="dialog-buttons">
<!-- <view class="cancel-btn" @click="handleCancel"> <!-- <view class="cancel-btn" @click="handleCancel">
...@@ -24,159 +57,126 @@ ...@@ -24,159 +57,126 @@
</view> </view>
</template> </template>
<script setup lang="ts">
interface Props {
show?: boolean
title?: string
content?: string
cancelText?: string
confirmText?: string
}
const props = withDefaults(defineProps<Props>(), {
show: false,
title: '提示',
content: '',
cancelText: '取消',
confirmText: '确认',
})
const emit = defineEmits<{
(e: 'update:show', value: boolean): void
(e: 'cancel'): void
(e: 'confirm'): void
}>()
function handleCancel() {
emit('update:show', false)
emit('cancel')
}
function handleConfirm() {
emit('confirm')
}
</script>
<style lang="scss" scoped> <style lang="scss" scoped>
.confirm-dialog-overlay { .confirm-dialog-overlay {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 9999; z-index: 9999;
} }
.confirm-dialog-container { .confirm-dialog-container {
position: relative; position: relative;
width: 600rpx; width: 600rpx;
background: #FFFFFF; background: #ffffff;
border-radius: 32rpx; border-radius: 32rpx;
box-sizing: border-box; box-sizing: border-box;
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1); box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
padding-bottom: 28rpx; padding-bottom: 28rpx;
} }
.confirm-dialog-content{ .confirm-dialog-content {
width: 600rpx; width: 600rpx;
height: 240rpx; height: 240rpx;
border-radius: 32rpx; border-radius: 32rpx;
opacity: 1; opacity: 1;
background: linear-gradient(0deg, rgba(93, 182, 111, 0) 0%, rgba(93, 182, 111, 0.25) 100%); background: linear-gradient(0deg, rgba(93, 182, 111, 0) 0%, rgba(93, 182, 111, 0.25) 100%);
position: relative; position: relative;
display: flex; display: flex;
justify-content: center; justify-content: center;
.apply_success_icon{ .apply_success_icon {
width: 240rpx; width: 240rpx;
height: 162rpx; height: 162rpx;
margin-top: 54rpx; margin-top: 54rpx;
} }
} }
.close-btn { .close-btn {
position: absolute; position: absolute;
top: 24rpx; top: 24rpx;
right: 24rpx; right: 24rpx;
width: 48rpx; width: 48rpx;
height: 48rpx; height: 48rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
cursor: pointer; cursor: pointer;
} }
.close-icon { .close-icon {
font-size: 36rpx; font-size: 36rpx;
color: #999999; color: #999999;
font-weight: 300; font-weight: 300;
} }
.dialog-title { .dialog-title {
margin-top: -32rpx; margin-top: -32rpx;
font-size: 36rpx; font-size: 36rpx;
font-weight: 600; font-weight: 600;
color: #333333; color: #333333;
text-align: center; text-align: center;
margin-bottom: 32rpx; margin-bottom: 32rpx;
} }
.dialog-content { .dialog-content {
font-size: 28rpx; font-size: 28rpx;
color: #666666; color: #666666;
text-align: center; text-align: center;
line-height: 40rpx; line-height: 40rpx;
margin-bottom: 48rpx; margin-bottom: 48rpx;
} }
.dialog-buttons { .dialog-buttons {
display: flex; display: flex;
gap: 24rpx; gap: 24rpx;
padding-left: 30rpx; padding-left: 30rpx;
padding-right: 30rpx; padding-right: 30rpx;
} }
.cancel-btn, .cancel-btn,
.confirm-btn { .confirm-btn {
flex: 1; flex: 1;
height: 80rpx; height: 80rpx;
border-radius: 40rpx; border-radius: 40rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
cursor: pointer; cursor: pointer;
} }
.cancel-btn { .cancel-btn {
background-color: #FFFFFF; background-color: #ffffff;
border: 2rpx solid #5DB66F; border: 2rpx solid #5db66f;
} }
.cancel-text { .cancel-text {
font-size: 28rpx; font-size: 28rpx;
color: #5DB66F; color: #5db66f;
font-weight: 500; font-weight: 500;
} }
.confirm-btn { .confirm-btn {
background: linear-gradient(135deg, #5DB66F 0%, #4CAF50 100%); background: linear-gradient(135deg, #5db66f 0%, #4caf50 100%);
box-shadow: 0 4rpx 12rpx rgba(93, 182, 111, 0.3); box-shadow: 0 4rpx 12rpx rgba(93, 182, 111, 0.3);
} }
.confirm-text { .confirm-text {
font-size: 28rpx; font-size: 28rpx;
color: #FFFFFF; color: #ffffff;
font-weight: 500; font-weight: 500;
} }
.cancel-btn:active { .cancel-btn:active {
opacity: 0.8; opacity: 0.8;
} }
.confirm-btn:active { .confirm-btn:active {
opacity: 0.9; opacity: 0.9;
transform: scale(0.98); transform: scale(0.98);
} }
</style> </style>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
// 将函数转换为字符串,在视图层重新构建 // 将函数转换为字符串,在视图层重新构建
option.tooltip.formatter = option.tooltip.formatter.toString() option.tooltip.formatter = option.tooltip.formatter.toString()
} }
this.option = { this.option = {
id: this.id, id: this.id,
...option, ...option,
......
<template>
<iframe :onload="onloadCode" style="width: 100%; height: 100%; border: 1px solid #fff; background: #000"></iframe>
</template>
<script> <script>
export default { export default {
props: { props: {
...@@ -16,4 +13,9 @@ ...@@ -16,4 +13,9 @@
}, },
} }
</script> </script>
<template>
<iframe :onload="onloadCode" style="width: 100%; height: 100%; border: 1px solid #fff; background: #000"></iframe>
</template>
<style lang="scss"></style> <style lang="scss"></style>
...@@ -80,8 +80,14 @@ export function useMapbox<T extends MapboxInstance, P extends MapboxConfig>( ...@@ -80,8 +80,14 @@ export function useMapbox<T extends MapboxInstance, P extends MapboxConfig>(
getInstance()?.setLayoutProperty(layerId, name, value), getInstance()?.setLayoutProperty(layerId, name, value),
setFilter: (layerId: string, filter: any[]) => getInstance()?.setFilter(layerId, filter), setFilter: (layerId: string, filter: any[]) => getInstance()?.setFilter(layerId, filter),
flyTo: (options: mapboxgl.FlyToOptions) => getInstance()?.flyTo(options), flyTo: (options: mapboxgl.FlyToOptions) => getInstance()?.flyTo(options),
addMarker: (id: string, lnglat: [number, number], popup?: string, popupDefaultOpen?: boolean, imageUrl?: string, iconSize?: [number, number]) => addMarker: (
getInstance()?.addMarker(id, lnglat, popup, popupDefaultOpen, imageUrl, iconSize), id: string,
lnglat: [number, number],
popup?: string,
popupDefaultOpen?: boolean,
imageUrl?: string,
iconSize?: [number, number],
) => getInstance()?.addMarker(id, lnglat, popup, popupDefaultOpen, imageUrl, iconSize),
removeMarker: (id: string) => getInstance()?.removeMarker(id), removeMarker: (id: string) => getInstance()?.removeMarker(id),
removePopup: () => getInstance()?.removePopup(), removePopup: () => getInstance()?.removePopup(),
loadImage: (url: string, callback: (error: Error | null, image: HTMLImageElement) => void) => loadImage: (url: string, callback: (error: Error | null, image: HTMLImageElement) => void) =>
...@@ -194,14 +200,14 @@ export function flyTo( ...@@ -194,14 +200,14 @@ export function flyTo(
zoom, zoom,
essential: true, essential: true,
} }
// 如果提供了时长,使用 duration 参数 // 如果提供了时长,使用 duration 参数
if (duration !== undefined) { if (duration !== undefined) {
flyOptions.duration = duration * 1000 // 转换为毫秒 flyOptions.duration = duration * 1000 // 转换为毫秒
} else { } else {
flyOptions.speed = 0.2 flyOptions.speed = 0.2
} }
map.flyTo(flyOptions) map.flyTo(flyOptions)
} }
......
...@@ -16,7 +16,7 @@ export const tk = 'aa0ccd36f2dbb86dbb16cbf63f0034a6' ...@@ -16,7 +16,7 @@ export const tk = 'aa0ccd36f2dbb86dbb16cbf63f0034a6'
const host = 'https://foxgis.app.yiring.com' const host = 'https://foxgis.app.yiring.com'
// 构建天地图图层地址 // 构建天地图图层地址
export function buildTdtTileUrl(id: string,layer:string) { export function buildTdtTileUrl(id: string, layer: string) {
return `http://t0.tianditu.gov.cn/${id}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${layer}&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${tk}` return `http://t0.tianditu.gov.cn/${id}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${layer}&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${tk}`
return `${host}/api/tdt/cache/${id}/{z}/{y}/{x}/${tk}?v=2022` return `${host}/api/tdt/cache/${id}/{z}/{y}/{x}/${tk}?v=2022`
} }
...@@ -41,13 +41,13 @@ export const defaultStyle: mapboxgl.Style = { ...@@ -41,13 +41,13 @@ export const defaultStyle: mapboxgl.Style = {
sources: { sources: {
'wms-vec_w-source': { 'wms-vec_w-source': {
type: 'raster', type: 'raster',
tiles: [buildTdtTileUrl('vec_w','vec')], tiles: [buildTdtTileUrl('vec_w', 'vec')],
tileSize: 256, tileSize: 256,
maxzoom: 18, maxzoom: 18,
}, },
'wms-cva_w-source': { 'wms-cva_w-source': {
type: 'raster', type: 'raster',
tiles: [buildTdtTileUrl('cva_w','cva')], tiles: [buildTdtTileUrl('cva_w', 'cva')],
tileSize: 256, tileSize: 256,
maxzoom: 18, maxzoom: 18,
}, },
...@@ -59,7 +59,7 @@ export const defaultStyle: mapboxgl.Style = { ...@@ -59,7 +59,7 @@ export const defaultStyle: mapboxgl.Style = {
// }, // },
'wms-img_w-source': { 'wms-img_w-source': {
type: 'raster', type: 'raster',
tiles: [buildTdtTileUrl('img_w','img')], tiles: [buildTdtTileUrl('img_w', 'img')],
tileSize: 256, tileSize: 256,
maxzoom: 18, maxzoom: 18,
}, },
...@@ -405,11 +405,11 @@ export interface MapControlOptions { ...@@ -405,11 +405,11 @@ export interface MapControlOptions {
} }
// 图层控制 // 图层控制
layer?: layer?:
| boolean | boolean
| { | {
tk: string tk: string
layers: LayerOption[] layers: LayerOption[]
} }
// 重置控件 // 重置控件
reset?: boolean | mapboxgl.FlyToOptions reset?: boolean | mapboxgl.FlyToOptions
// 全屏控件 // 全屏控件
...@@ -554,17 +554,17 @@ export function toPointGeoJSON( ...@@ -554,17 +554,17 @@ export function toPointGeoJSON(
features: !data features: !data
? [] ? []
: data.map((item) => { : data.map((item) => {
return { return {
type: 'Feature', type: 'Feature',
properties: { properties: {
...item, ...item,
}, },
geometry: { geometry: {
type: 'Point', type: 'Point',
coordinates: [item.lon, item.lat], coordinates: [item.lon, item.lat],
}, },
} }
}), }),
} }
} }
...@@ -850,7 +850,14 @@ export interface MapboxInstance { ...@@ -850,7 +850,14 @@ export interface MapboxInstance {
* @param iconSize 图标大小 [width, height] * @param iconSize 图标大小 [width, height]
* @link https://docs.mapbox.com/mapbox-gl-js/api/markers/#marker * @link https://docs.mapbox.com/mapbox-gl-js/api/markers/#marker
*/ */
addMarker(id: string, lngLat: number[], popup?: string, popupDefaultOpen?: boolean, imageUrl?: string, iconSize?: [number, number]): void addMarker(
id: string,
lngLat: number[],
popup?: string,
popupDefaultOpen?: boolean,
imageUrl?: string,
iconSize?: [number, number],
): void
/** /**
* 移除 Marker * 移除 Marker
* @param id Marker ID * @param id Marker ID
...@@ -986,8 +993,9 @@ export const HandlerUtil = { ...@@ -986,8 +993,9 @@ export const HandlerUtil = {
popup: HandlerUtil.createDefaultPopupHtml( popup: HandlerUtil.createDefaultPopupHtml(
station, station,
{ {
'{key}': `${(additional?.valueName ? station[additional.valueName] : station.value) || '-' '{key}': `${
}{suffix}`, (additional?.valueName ? station[additional.valueName] : station.value) || '-'
}{suffix}`,
...map, ...map,
}, },
isStation, isStation,
...@@ -1008,7 +1016,8 @@ export const HandlerUtil = { ...@@ -1008,7 +1016,8 @@ export const HandlerUtil = {
if (isPlainObject(station) && isStation) { if (isPlainObject(station) && isStation) {
htmls.push( htmls.push(
`<div class="popup-row"><span class="popup-title">地点:</span>${station.city || ''} ${station.cnty || '' `<div class="popup-row"><span class="popup-title">地点:</span>${station.city || ''} ${
station.cnty || ''
} ${station.town || ''}</div>`, } ${station.town || ''}</div>`,
) )
htmls.push(`<div class="popup-row"><span class="popup-title">发生时间:</span>${station.occurTime}</div>`) htmls.push(`<div class="popup-row"><span class="popup-title">发生时间:</span>${station.occurTime}</div>`)
...@@ -1024,7 +1033,8 @@ export const HandlerUtil = { ...@@ -1024,7 +1033,8 @@ export const HandlerUtil = {
for (const key in map) { for (const key in map) {
const len = String(key === '{key}' ? station.key : key).length const len = String(key === '{key}' ? station.key : key).length
htmls.push( htmls.push(
`<div class="popup-row"><span class="popup-title" style="min-width: ${len + 1}em">${key}: </span>${wrap ? '</br>' : '' `<div class="popup-row"><span class="popup-title" style="min-width: ${len + 1}em">${key}: </span>${
wrap ? '</br>' : ''
} ${map[key] || '-'}</div>`, } ${map[key] || '-'}</div>`,
) )
} }
...@@ -1039,7 +1049,8 @@ export const HandlerUtil = { ...@@ -1039,7 +1049,8 @@ export const HandlerUtil = {
if (isPlainObject(station) && isStation) { if (isPlainObject(station) && isStation) {
htmls.push(`<div class="popup-row"><span class="popup-title">站号:</span>${station.stationCode}</div>`) htmls.push(`<div class="popup-row"><span class="popup-title">站号:</span>${station.stationCode}</div>`)
htmls.push( htmls.push(
`<div class="popup-row"><span class="popup-title">站名:</span>${station.city || ''} ${station.cnty || '' `<div class="popup-row"><span class="popup-title">站名:</span>${station.city || ''} ${
station.cnty || ''
} ${station.stationName || ''}</div>`, } ${station.stationName || ''}</div>`,
) )
} }
...@@ -1068,7 +1079,8 @@ export const HandlerUtil = { ...@@ -1068,7 +1079,8 @@ export const HandlerUtil = {
const len = String(key === '{key}' ? station.key : key).length const len = String(key === '{key}' ? station.key : key).length
if (key !== '{key}') { if (key !== '{key}') {
htmls.push( htmls.push(
`<div class="popup-row"><span class="popup-title" style="min-width: ${len + 1}em">${key} </span>${wrap ? '</br>' : '' `<div class="popup-row"><span class="popup-title" style="min-width: ${len + 1}em">${key} </span>${
wrap ? '</br>' : ''
} ${map[key] || '-'}</div>`, } ${map[key] || '-'}</div>`,
) )
} }
......
<template>
</template>
<script> <script>
export default { export default {}
}
</script> </script>
<style> <template></template>
</style> <style></style>
<script setup lang="ts"> <script setup lang="ts">
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'
import { getCurrentDateTime } from '@/utils/date' import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore();
const consultRecord = reactive({ const userStore = useUserStore()
id: "", const consultRecord = reactive({
mobile: '',// 咨询人号码 id: '',
consultTime:"" ,// 咨询时间 mobile: '', // 咨询人号码
bizType:5, // 业务类型(1代理记账,2农资,3农机,4金融) consultTime: '', // 咨询时间
enterpriseId:"2004840258270433254", // 意向企业 bizType: 5, // 业务类型(1代理记账,2农资,3农机,4金融)
feedbackRemark:"" // 反馈备注 enterpriseId: '2004840258270433254', // 意向企业
}) feedbackRemark: '', // 反馈备注
const pageData = reactive({ })
showLogoutDialog: false, const pageData = reactive({
allpyMessageTitle:"", showLogoutDialog: false,
applyMessageText:"", allpyMessageTitle: '',
}) applyMessageText: '',
onShow(() => { })
const { id, realname, phone } = userStore.getUserInfo; onShow(() => {
consultRecord.id = id; const { id, realname, phone } = userStore.getUserInfo
consultRecord.mobile = phone; consultRecord.id = id
consultRecord.feedbackRemark = realname; consultRecord.mobile = phone
}) consultRecord.feedbackRemark = realname
})
// 洽谈合作 // 洽谈合作
function onCooperationClick() { function onCooperationClick() {
// Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示') // Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示')
consultRecord.consultTime = getCurrentDateTime(); consultRecord.consultTime = getCurrentDateTime()
HomeAPI.postConsultRecordAdd(consultRecord).then((res) => { HomeAPI.postConsultRecordAdd(consultRecord).then((res) => {
pageData.allpyMessageTitle = "申请成功"; pageData.allpyMessageTitle = '申请成功'
pageData.applyMessageText = "平台已收到申请,将尽快与您取得联系!"; pageData.applyMessageText = '平台已收到申请,将尽快与您取得联系!'
pageData.showLogoutDialog = true; pageData.showLogoutDialog = true
}) })
} }
</script> </script>
...@@ -105,13 +106,13 @@ ...@@ -105,13 +106,13 @@
</view> </view>
</view> </view>
</view> </view>
<successfulDialog <successfulDialog
v-model:show="pageData.showLogoutDialog" v-model:show="pageData.showLogoutDialog"
:title="pageData.allpyMessageTitle" :title="pageData.allpyMessageTitle"
:content="pageData.applyMessageText" :content="pageData.applyMessageText"
confirmText="我知道了" confirmText="我知道了"
@confirm="pageData.showLogoutDialog = false" @confirm="pageData.showLogoutDialog = false"
/> />
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -188,8 +188,10 @@ ...@@ -188,8 +188,10 @@
pageData.search.pageNo = 1 pageData.search.pageNo = 1
pageData.purchaseDemands = [] pageData.purchaseDemands = []
pageData.supplyInfos = [] pageData.supplyInfos = []
if (pageData.currentTransactionTab === 1) getPurchaseList() if (pageData.currentTransactionTab === 1)
if (pageData.currentTransactionTab === 2) getSupplyList() getPurchaseList()
if (pageData.currentTransactionTab === 2)
getSupplyList()
} }
// 采购/供应标签点击事件 // 采购/供应标签点击事件
...@@ -199,8 +201,10 @@ ...@@ -199,8 +201,10 @@
pageData.search.pageNo = 1 pageData.search.pageNo = 1
pageData.purchaseDemands = [] pageData.purchaseDemands = []
pageData.supplyInfos = [] pageData.supplyInfos = []
if (pageData.currentTransactionTab === 1) getPurchaseList() if (pageData.currentTransactionTab === 1)
if (pageData.currentTransactionTab === 2) getSupplyList() getPurchaseList()
if (pageData.currentTransactionTab === 2)
getSupplyList()
} }
// 新需求提醒点击事件 // 新需求提醒点击事件
...@@ -234,7 +238,7 @@ ...@@ -234,7 +238,7 @@
// 发布需求 // 发布需求
function handlePublish() { function handlePublish() {
if (pageData.currentTransactionTab === 1) { if (pageData.currentTransactionTab === 1) {
Navigate.to('/pages/chanxiao/supplyXuQiu') Navigate.to('/pages/chanxiao/supplyXuQiu')
return return
} }
if (pageData.currentTransactionTab === 2) { if (pageData.currentTransactionTab === 2) {
...@@ -245,12 +249,14 @@ ...@@ -245,12 +249,14 @@
onReachBottom(() => { onReachBottom(() => {
console.log('触底了') console.log('触底了')
if (pageData.currentTransactionTab === 1) { if (pageData.currentTransactionTab === 1) {
if (pageData.total <= pageData.purchaseDemands.length) return if (pageData.total <= pageData.purchaseDemands.length)
return
pageData.search.pageNo++ pageData.search.pageNo++
getPurchaseList() getPurchaseList()
} }
if (pageData.currentTransactionTab === 2) { if (pageData.currentTransactionTab === 2) {
if (pageData.total <= pageData.supplyInfos.length) return if (pageData.total <= pageData.supplyInfos.length)
return
pageData.search.pageNo++ pageData.search.pageNo++
getSupplyList() getSupplyList()
} }
......
<script setup lang="ts"> <script setup lang="ts">
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'
import { getCurrentDateTime } from '@/utils/date' import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore();
const consultRecord = reactive({ const userStore = useUserStore()
id: "", const consultRecord = reactive({
mobile: '',// 咨询人号码 id: '',
consultTime:"" ,// 咨询时间 mobile: '', // 咨询人号码
bizType:5, // 业务类型(1代理记账,2农资,3农机,4金融) consultTime: '', // 咨询时间
enterpriseId:"2004840258270488953", // 意向企业 bizType: 5, // 业务类型(1代理记账,2农资,3农机,4金融)
feedbackRemark:"" // 反馈备注 enterpriseId: '2004840258270488953', // 意向企业
}) feedbackRemark: '', // 反馈备注
const pageData = reactive({ })
showLogoutDialog: false, const pageData = reactive({
allpyMessageTitle:"", showLogoutDialog: false,
applyMessageText:"", allpyMessageTitle: '',
}) applyMessageText: '',
onShow(() => { })
const { id, realname, phone } = userStore.getUserInfo; onShow(() => {
consultRecord.id = id; const { id, realname, phone } = userStore.getUserInfo
consultRecord.mobile = phone; consultRecord.id = id
consultRecord.feedbackRemark = realname; consultRecord.mobile = phone
}) consultRecord.feedbackRemark = realname
})
// 洽谈合作 // 洽谈合作
function onCooperationClick() { function onCooperationClick() {
// Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示') // Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示')
consultRecord.consultTime = getCurrentDateTime(); consultRecord.consultTime = getCurrentDateTime()
HomeAPI.postConsultRecordAdd(consultRecord).then((res) => { HomeAPI.postConsultRecordAdd(consultRecord).then((res) => {
pageData.allpyMessageTitle = "申请成功"; pageData.allpyMessageTitle = '申请成功'
pageData.applyMessageText = "平台已收到申请,将尽快与您取得联系!"; pageData.applyMessageText = '平台已收到申请,将尽快与您取得联系!'
pageData.showLogoutDialog = true; pageData.showLogoutDialog = true
}) })
} }
</script> </script>
...@@ -123,13 +124,13 @@ ...@@ -123,13 +124,13 @@
</view> </view>
</view> </view>
</view> </view>
<successfulDialog <successfulDialog
v-model:show="pageData.showLogoutDialog" v-model:show="pageData.showLogoutDialog"
:title="pageData.allpyMessageTitle" :title="pageData.allpyMessageTitle"
:content="pageData.applyMessageText" :content="pageData.applyMessageText"
confirmText="我知道了" confirmText="我知道了"
@confirm="pageData.showLogoutDialog = false" @confirm="pageData.showLogoutDialog = false"
/> />
</view> </view>
</template> </template>
......
<script setup lang="ts"> <script setup lang="ts">
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'
import { getCurrentDateTime } from '@/utils/date' import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore();
const consultRecord = reactive({ const userStore = useUserStore()
id: "", const consultRecord = reactive({
mobile: '',// 咨询人号码 id: '',
consultTime:"" ,// 咨询时间 mobile: '', // 咨询人号码
bizType:5, // 业务类型(1代理记账,2农资,3农机,4金融) consultTime: '', // 咨询时间
enterpriseId:"2004840258270471548", // 意向企业 bizType: 5, // 业务类型(1代理记账,2农资,3农机,4金融)
feedbackRemark:"" // 反馈备注 enterpriseId: '2004840258270471548', // 意向企业
}) feedbackRemark: '', // 反馈备注
const pageData = reactive({ })
showLogoutDialog: false, const pageData = reactive({
allpyMessageTitle:"", showLogoutDialog: false,
applyMessageText:"", allpyMessageTitle: '',
}) applyMessageText: '',
onShow(() => { })
const { id, realname, phone } = userStore.getUserInfo; onShow(() => {
consultRecord.id = id; const { id, realname, phone } = userStore.getUserInfo
consultRecord.mobile = phone; consultRecord.id = id
consultRecord.feedbackRemark = realname; consultRecord.mobile = phone
}) consultRecord.feedbackRemark = realname
})
// 洽谈合作 // 洽谈合作
function onCooperationClick() { function onCooperationClick() {
// Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示') // Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示')
consultRecord.consultTime = getCurrentDateTime(); consultRecord.consultTime = getCurrentDateTime()
HomeAPI.postConsultRecordAdd(consultRecord).then((res) => { HomeAPI.postConsultRecordAdd(consultRecord).then((res) => {
pageData.allpyMessageTitle = "申请成功"; pageData.allpyMessageTitle = '申请成功'
pageData.applyMessageText = "平台已收到申请,将尽快与您取得联系!"; pageData.applyMessageText = '平台已收到申请,将尽快与您取得联系!'
pageData.showLogoutDialog = true; pageData.showLogoutDialog = true
}) })
} }
</script> </script>
...@@ -147,13 +148,13 @@ ...@@ -147,13 +148,13 @@
</view> </view>
</view> </view>
</view> </view>
<successfulDialog <successfulDialog
v-model:show="pageData.showLogoutDialog" v-model:show="pageData.showLogoutDialog"
:title="pageData.allpyMessageTitle" :title="pageData.allpyMessageTitle"
:content="pageData.applyMessageText" :content="pageData.applyMessageText"
confirmText="我知道了" confirmText="我知道了"
@confirm="pageData.showLogoutDialog = false" @confirm="pageData.showLogoutDialog = false"
/> />
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
} }
function getCurrentAddressInfo() { function getCurrentAddressInfo() {
if (!uni.getStorageSync('location')) if (!uni.getStorageSync('location'))
return return
const { lon, lat } = uni.getStorageSync('location') const { lon, lat } = uni.getStorageSync('location')
...@@ -291,8 +291,10 @@ return ...@@ -291,8 +291,10 @@ return
<view class="price-range"> <view class="price-range">
<input :disabled="!isSave" type="number" class="price-input" v-model="form.priceStart" placeholder="最低价" :min="0" maxlength="6" /> <input :disabled="!isSave" type="number" class="price-input" v-model="form.priceStart" placeholder="最低价" :min="0" maxlength="6" />
<text class="price-separator"></text> <text class="price-separator"></text>
<input :disabled="!isSave" type="number" class="price-input" v-model="form.priceEnd" placeholder="最高价" :min="0" maxlength="6" > <input :disabled="!isSave" type="number" class="price-input" v-model="form.priceEnd" placeholder="最高价" :min="0" maxlength="6" />
<view slot="suffix" class="unit-slot" style="font-size: 28rpx;"></view> <template #suffix>
<view class="unit-slot" style="font-size: 28rpx;"></view>
</template>
</input> </input>
</view> </view>
</view> </view>
...@@ -321,8 +323,8 @@ return ...@@ -321,8 +323,8 @@ return
</view> </view>
</view> </view>
<view class="mb-1 flex justify-start" style="font-size: 28rpx;"> <view class="mb-1 flex justify-start" style="font-size: 28rpx;">
<span style="color: red;margin-left: 10rpx;">*&nbsp;</span> <span style="color: red;margin-left: 10rpx;">*&nbsp;</span>
<span>图片</span> <span>图片</span>
</view> </view>
<uni-file-picker :readonly="!isSave" :value="form.imageObj" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete" style="margin-left:35rpx"/> <uni-file-picker :readonly="!isSave" :value="form.imageObj" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete" style="margin-left:35rpx"/>
</view> </view>
......
<script setup lang="ts"> <script setup lang="ts">
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'
import { getCurrentDateTime } from '@/utils/date' import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore();
const consultRecord = reactive({ const userStore = useUserStore()
id: "", const consultRecord = reactive({
mobile: '',// 咨询人号码 id: '',
consultTime:"" ,// 咨询时间 mobile: '', // 咨询人号码
bizType:5, // 业务类型(1代理记账,2农资,3农机,4金融) consultTime: '', // 咨询时间
enterpriseId:"2004840258270471581", // 意向企业 bizType: 5, // 业务类型(1代理记账,2农资,3农机,4金融)
feedbackRemark:"" // 反馈备注 enterpriseId: '2004840258270471581', // 意向企业
}) feedbackRemark: '', // 反馈备注
const pageData = reactive({ })
showLogoutDialog: false, const pageData = reactive({
allpyMessageTitle:"", showLogoutDialog: false,
applyMessageText:"", allpyMessageTitle: '',
}) applyMessageText: '',
onShow(() => { })
const { id, realname, phone } = userStore.getUserInfo; onShow(() => {
consultRecord.id = id; const { id, realname, phone } = userStore.getUserInfo
consultRecord.mobile = phone; consultRecord.id = id
consultRecord.feedbackRemark = realname; consultRecord.mobile = phone
}) consultRecord.feedbackRemark = realname
})
// 洽谈合作 // 洽谈合作
function onCooperationClick() { function onCooperationClick() {
// Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示') // Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示')
consultRecord.consultTime = getCurrentDateTime(); consultRecord.consultTime = getCurrentDateTime()
HomeAPI.postConsultRecordAdd(consultRecord).then((res) => { HomeAPI.postConsultRecordAdd(consultRecord).then((res) => {
pageData.allpyMessageTitle = "申请成功"; pageData.allpyMessageTitle = '申请成功'
pageData.applyMessageText = "平台已收到申请,将尽快与您取得联系!"; pageData.applyMessageText = '平台已收到申请,将尽快与您取得联系!'
pageData.showLogoutDialog = true; pageData.showLogoutDialog = true
}) })
} }
</script> </script>
...@@ -107,13 +108,13 @@ ...@@ -107,13 +108,13 @@
</view> </view>
</view> </view>
</view> </view>
<successfulDialog <successfulDialog
v-model:show="pageData.showLogoutDialog" v-model:show="pageData.showLogoutDialog"
:title="pageData.allpyMessageTitle" :title="pageData.allpyMessageTitle"
:content="pageData.applyMessageText" :content="pageData.applyMessageText"
confirmText="我知道了" confirmText="我知道了"
@confirm="pageData.showLogoutDialog = false" @confirm="pageData.showLogoutDialog = false"
/> />
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -12,24 +12,24 @@ ...@@ -12,24 +12,24 @@
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
const isSave = ref(false) const isSave = ref(false)
const pageText = ref('采购') const pageText = ref('采购')
onLoad((option) => { onLoad((option) => {
// 获取数据详情 // 获取数据详情
if (option.id) { if (option.id) {
isSave.value = false isSave.value = false
getDetails(option.id) getDetails(option.id)
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '采购需求', title: '采购需求',
}) })
pageText.value = '采购' pageText.value = '采购'
} else { } else {
isSave.value = true isSave.value = true
// 获取当前位置 // 获取当前位置
getCurrentAddressInfo() getCurrentAddressInfo()
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '发布供应需求', title: '发布供应需求',
}) })
pageText.value = '供应' pageText.value = '供应'
} }
}) })
...@@ -150,7 +150,8 @@ ...@@ -150,7 +150,8 @@
} }
function getCurrentAddressInfo() { function getCurrentAddressInfo() {
if (!uni.getStorageSync('location')) return if (!uni.getStorageSync('location'))
return
const { lon, lat } = uni.getStorageSync('location') const { lon, lat } = uni.getStorageSync('location')
UserInfoAPI.location({ UserInfoAPI.location({
...@@ -416,7 +417,7 @@ ...@@ -416,7 +417,7 @@
<!-- 供应时间 --> <!-- 供应时间 -->
<view class="form-section" style="padding: 0 30rpx"> <view class="form-section" style="padding: 0 30rpx">
<view class="form-item flex align-center"> <view class="form-item flex align-center">
<text class="label" style="font-size: 28rpx">{{pageText}}时间</text> <text class="label" style="font-size: 28rpx">{{ pageText }}时间</text>
<view class="time-range"> <view class="time-range">
<view <view
class="time-input" class="time-input"
......
<script setup lang="ts"> <script setup lang="ts">
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'
import { getCurrentDateTime } from '@/utils/date' import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore();
const consultRecord = reactive({ const userStore = useUserStore()
id: "", const consultRecord = reactive({
mobile: '',// 咨询人号码 id: '',
consultTime:"" ,// 咨询时间 mobile: '', // 咨询人号码
bizType:5, // 业务类型(1代理记账,2农资,3农机,4金融) consultTime: '', // 咨询时间
enterpriseId:"2004840258270437514", // 意向企业 bizType: 5, // 业务类型(1代理记账,2农资,3农机,4金融)
feedbackRemark:"" // 反馈备注 enterpriseId: '2004840258270437514', // 意向企业
}) feedbackRemark: '', // 反馈备注
const pageData = reactive({ })
showLogoutDialog: false, const pageData = reactive({
allpyMessageTitle:"", showLogoutDialog: false,
applyMessageText:"", allpyMessageTitle: '',
}) applyMessageText: '',
onShow(() => { })
const { id, realname, phone } = userStore.getUserInfo; onShow(() => {
consultRecord.id = id; const { id, realname, phone } = userStore.getUserInfo
consultRecord.mobile = phone; consultRecord.id = id
consultRecord.feedbackRemark = realname; consultRecord.mobile = phone
}) consultRecord.feedbackRemark = realname
})
// 洽谈合作 // 洽谈合作
function onCooperationClick() { function onCooperationClick() {
// Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示') // Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示')
consultRecord.consultTime = getCurrentDateTime(); consultRecord.consultTime = getCurrentDateTime()
HomeAPI.postConsultRecordAdd(consultRecord).then((res) => { HomeAPI.postConsultRecordAdd(consultRecord).then((res) => {
pageData.allpyMessageTitle = "申请成功"; pageData.allpyMessageTitle = '申请成功'
pageData.applyMessageText = "平台已收到申请,将尽快与您取得联系!"; pageData.applyMessageText = '平台已收到申请,将尽快与您取得联系!'
pageData.showLogoutDialog = true; pageData.showLogoutDialog = true
}) })
} }
</script> </script>
...@@ -104,7 +105,10 @@ ...@@ -104,7 +105,10 @@
src="/static/images/codefun/ca51ef39a15d5c8414c9a427b3c4434b.png" src="/static/images/codefun/ca51ef39a15d5c8414c9a427b3c4434b.png"
/> />
</view> </view>
<view class="codefun-flex-row codefun-justify-between codefun-relative group_6" @click="onCooperationClick"> <view
class="codefun-flex-row codefun-justify-between codefun-relative group_6"
@click="onCooperationClick"
>
<image class="image_8" src="/static/images/codefun/979b55187f885f1b302dd29760bb516b.png" /> <image class="image_8" src="/static/images/codefun/979b55187f885f1b302dd29760bb516b.png" />
<image class="image_8" src="/static/images/codefun/ecb55b953a8e07a17301bcd12aec591f.png" /> <image class="image_8" src="/static/images/codefun/ecb55b953a8e07a17301bcd12aec591f.png" />
<view class="codefun-flex-row codefun-justify-center codefun-items-center section_6 pos"> <view class="codefun-flex-row codefun-justify-center codefun-items-center section_6 pos">
...@@ -116,13 +120,13 @@ ...@@ -116,13 +120,13 @@
</view> </view>
</view> </view>
</view> </view>
<successfulDialog <successfulDialog
v-model:show="pageData.showLogoutDialog" v-model:show="pageData.showLogoutDialog"
:title="pageData.allpyMessageTitle" :title="pageData.allpyMessageTitle"
:content="pageData.applyMessageText" :content="pageData.applyMessageText"
confirmText="我知道了" confirmText="我知道了"
@confirm="pageData.showLogoutDialog = false" @confirm="pageData.showLogoutDialog = false"
/> />
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
......
<script setup lang="ts"> <script setup lang="ts">
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'
import { getCurrentDateTime } from '@/utils/date' import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore();
const consultRecord = reactive({ const userStore = useUserStore()
id: "", const consultRecord = reactive({
mobile: '',// 咨询人号码 id: '',
consultTime:"" ,// 咨询时间 mobile: '', // 咨询人号码
bizType:5, // 业务类型(1代理记账,2农资,3农机,4金融) consultTime: '', // 咨询时间
enterpriseId:"2004840258270474551", // 意向企业 bizType: 5, // 业务类型(1代理记账,2农资,3农机,4金融)
feedbackRemark:"" // 反馈备注 enterpriseId: '2004840258270474551', // 意向企业
}) feedbackRemark: '', // 反馈备注
const pageData = reactive({ })
showLogoutDialog: false, const pageData = reactive({
allpyMessageTitle:"", showLogoutDialog: false,
applyMessageText:"", allpyMessageTitle: '',
}) applyMessageText: '',
onShow(() => { })
const { id, realname, phone } = userStore.getUserInfo; onShow(() => {
consultRecord.id = id; const { id, realname, phone } = userStore.getUserInfo
consultRecord.mobile = phone; consultRecord.id = id
consultRecord.feedbackRemark = realname; consultRecord.mobile = phone
}) consultRecord.feedbackRemark = realname
})
// 洽谈合作 // 洽谈合作
function onCooperationClick() { function onCooperationClick() {
// Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示') // Message.alert('洽谈合作功能暂不可用,敬请期待~', '温馨提示')
consultRecord.consultTime = getCurrentDateTime(); consultRecord.consultTime = getCurrentDateTime()
HomeAPI.postConsultRecordAdd(consultRecord).then((res) => { HomeAPI.postConsultRecordAdd(consultRecord).then((res) => {
pageData.allpyMessageTitle = "申请成功"; pageData.allpyMessageTitle = '申请成功'
pageData.applyMessageText = "平台已收到申请,将尽快与您取得联系!"; pageData.applyMessageText = '平台已收到申请,将尽快与您取得联系!'
pageData.showLogoutDialog = true; pageData.showLogoutDialog = true
}) })
} }
</script> </script>
<template> <template>
<view class="codefun-flex-col page"> <view class="codefun-flex-col page">
<view class="codefun-flex-col section"> <view class="codefun-flex-col section">
...@@ -113,13 +115,13 @@ ...@@ -113,13 +115,13 @@
</view> </view>
</view> </view>
</view> </view>
<successfulDialog <successfulDialog
v-model:show="pageData.showLogoutDialog" v-model:show="pageData.showLogoutDialog"
:title="pageData.allpyMessageTitle" :title="pageData.allpyMessageTitle"
:content="pageData.applyMessageText" :content="pageData.applyMessageText"
confirmText="我知道了" confirmText="我知道了"
@confirm="pageData.showLogoutDialog = false" @confirm="pageData.showLogoutDialog = false"
/> />
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue' import { computed, reactive, ref, watch } from 'vue'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import * as NongchangAPI from '@/api/model/nongchang' import * as NongchangAPI from '@/api/model/nongchang'
// 定义Props // 定义Props
interface Props { interface Props {
show: boolean show: boolean
editData?: any editData?: any
farmId: any farmId: any
farmBaseId: any farmBaseId: any
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
show: false, show: false,
editData: null, editData: null,
farmId: 0, farmId: 0,
farmBaseId: 0, farmBaseId: 0,
}) })
// 定义Emits // 定义Emits
const emit = defineEmits<{ const emit = defineEmits<{
'update:show': [value: boolean] 'update:show': [value: boolean]
submit: [data: any] submit: [data: any]
close: [] close: []
}>() }>()
// 表单引用 // 表单引用
const formRef = ref() const formRef = ref()
const loading = ref(false) const loading = ref(false)
const showDeviceTypePicker = ref(false) const showDeviceTypePicker = ref(false)
// 字典存储 // 字典存储
const dictStore = useDictStore() const dictStore = useDictStore()
// 表单数据 // 表单数据
const formData = reactive({ const formData = reactive({
deviceName: '', deviceName: '',
deviceType: '', deviceType: '',
deviceTypeText: '', deviceTypeText: '',
deviceIdentifier: '', deviceIdentifier: '',
}) })
// 设备类型选项 - 使用字典数据 // 设备类型选项 - 使用字典数据
const deviceTypeOptions = computed(() => { const deviceTypeOptions = computed(() => {
return ( return (
dictStore.getDictList.deviceType?.map((item: any) => ({ dictStore.getDictList.deviceType?.map((item: any) => ({
value: item.value, value: item.value,
text: item.text, text: item.text,
})) || [] })) || []
) )
}) })
// 设备类型选择器数据 (不再需要,因为fui-picker使用options属性) // 设备类型选择器数据 (不再需要,因为fui-picker使用options属性)
// 计算属性 // 计算属性
const dialogTitle = computed(() => { const dialogTitle = computed(() => {
return props.editData ? '编辑设备' : '添加设备' return props.editData ? '编辑设备' : '添加设备'
}) })
const submitButtonText = computed(() => { const submitButtonText = computed(() => {
return props.editData ? '保存' : '确认' return props.editData ? '保存' : '确认'
}) })
// 表单验证规则 // 表单验证规则
const rules = { const rules = {
deviceName: [ deviceName: [
{ required: true, message: '请输入设备名称', trigger: 'blur' }, { required: true, message: '请输入设备名称', trigger: 'blur' },
{ min: 2, max: 50, message: '设备名称长度在2-50个字符之间', trigger: 'blur' }, { min: 2, max: 50, message: '设备名称长度在2-50个字符之间', trigger: 'blur' },
], ],
deviceType: [{ required: true, message: '请选择设备类型', type: 'number', trigger: 'change' }], deviceType: [{ required: true, message: '请选择设备类型', type: 'number', trigger: 'change' }],
deviceIdentifier: [ deviceIdentifier: [
{ required: true, message: '请输入设备唯一标识', trigger: 'blur' }, { required: true, message: '请输入设备唯一标识', trigger: 'blur' },
{ min: 6, max: 100, message: '设备标识长度在6-100个字符之间', trigger: 'blur' }, { min: 6, max: 100, message: '设备标识长度在6-100个字符之间', trigger: 'blur' },
{ {
validator: (rule: any, value: any, callback: any) => { validator: (rule: any, value: any, callback: any) => {
if (!/^[a-zA-Z0-9\-_:]+$/.test(value)) { if (!/^[a-zA-Z0-9\-_:]+$/.test(value)) {
callback(new Error('设备标识只能包含字母、数字、下划线、中划线和冒号')) callback(new Error('设备标识只能包含字母、数字、下划线、中划线和冒号'))
} else { } else {
callback() callback()
} }
},
trigger: 'blur',
}, },
trigger: 'blur', ],
},
],
}
// 监听显示状态
watch(
() => props.show,
(newVal) => {
if (newVal && props.editData) {
// 编辑模式,填充数据
resetFormData()
loadEditData()
} else if (newVal) {
// 添加模式,重置表单
resetFormData()
}
},
)
// 重置表单数据
function resetFormData() {
formData.deviceName = ''
formData.deviceType = ''
formData.deviceTypeText = ''
formData.deviceIdentifier = ''
// 清除验证状态
if (formRef.value) {
formRef.value.resetFields()
} }
}
// 加载编辑数据 // 监听显示状态
function loadEditData() { watch(
if (!props.editData) return () => props.show,
(newVal) => {
if (newVal && props.editData) {
// 编辑模式,填充数据
resetFormData()
loadEditData()
} else if (newVal) {
// 添加模式,重置表单
resetFormData()
}
},
)
// 重置表单数据
function resetFormData() {
formData.deviceName = ''
formData.deviceType = ''
formData.deviceTypeText = ''
formData.deviceIdentifier = ''
formData.deviceName = props.editData.deviceName || '' // 清除验证状态
formData.deviceType = props.editData.deviceType || '' if (formRef.value) {
formData.deviceIdentifier = props.editData.deviceIdentifier || '' formRef.value.resetFields()
}
}
// 设置设备类型文本 // 加载编辑数据
if (props.editData.deviceType) { function loadEditData() {
const typeOption = deviceTypeOptions.value.find((item) => item.value === props.editData.deviceType) if (!props.editData)
if (typeOption) { return
formData.deviceTypeText = typeOption.text
formData.deviceName = props.editData.deviceName || ''
formData.deviceType = props.editData.deviceType || ''
formData.deviceIdentifier = props.editData.deviceIdentifier || ''
// 设置设备类型文本
if (props.editData.deviceType) {
const typeOption = deviceTypeOptions.value.find((item) => item.value === props.editData.deviceType)
if (typeOption) {
formData.deviceTypeText = typeOption.text
} else {
// 如果字典中没有找到对应的文本,使用原始数据中的文本
formData.deviceTypeText = props.editData.deviceType_dictText || ''
}
} else { } else {
// 如果字典中没有找到对应的文本,使用原始数据中的文本 formData.deviceTypeText = ''
formData.deviceTypeText = props.editData.deviceType_dictText || ''
} }
} else {
formData.deviceTypeText = ''
} }
}
// 设备类型选择确认
function handleDeviceTypeConfirm(e: any) {
formData.deviceType = e.value
formData.deviceTypeText = e.text
showDeviceTypePicker.value = false
}
// 提交表单
async function handleSubmit() {
try {
console.log(formData)
// 先进行表单验证
const valid = await formRef.value.validate()
if (!valid) {
return
}
loading.value = true // 设备类型选择确认
function handleDeviceTypeConfirm(e: any) {
formData.deviceType = e.value
formData.deviceTypeText = e.text
showDeviceTypePicker.value = false
}
// 准备提交数据 // 提交表单
const submitData = { async function handleSubmit() {
...formData, try {
farmId: props.farmId, console.log(formData)
farmBaseId: props.farmBaseId, // 先进行表单验证
} const valid = await formRef.value.validate()
if (!valid) {
return
}
loading.value = true
// 准备提交数据
const submitData = {
...formData,
farmId: props.farmId,
farmBaseId: props.farmBaseId,
}
// 根据 editData 判断是新增还是修改
let result
if (props.editData && props.editData.id) {
// 编辑设备,需要传递设备ID
result = await NongchangAPI.editDevice({
...submitData,
id: props.editData.id,
})
console.log('修改设备数据:', submitData)
} else {
// 新增设备
result = await NongchangAPI.addDevice(submitData)
console.log('新增设备数据:', submitData)
}
// 根据 editData 判断是新增还是修改 uni.showToast({ title: '操作成功', icon: 'success' })
let result emit('update:show', false)
if (props.editData && props.editData.id) { emit('submitSuccess')
// 编辑设备,需要传递设备ID emit('close')
result = await NongchangAPI.editDevice({ } catch (error) {
...submitData, console.log('提交失败:', error)
id: props.editData.id, uni.showToast({
title: '操作失败',
icon: 'none',
duration: 2000,
}) })
console.log('修改设备数据:', submitData) } finally {
} else { loading.value = false
// 新增设备
result = await NongchangAPI.addDevice(submitData)
console.log('新增设备数据:', submitData)
} }
}
uni.showToast({ title: '操作成功', icon: 'success' }) // 关闭弹窗
function handleClose() {
emit('update:show', false) emit('update:show', false)
emit('submitSuccess')
emit('close') emit('close')
} catch (error) {
console.log('提交失败:', error)
uni.showToast({
title: '操作失败',
icon: 'none',
duration: 2000,
})
} finally {
loading.value = false
} }
}
// 暴露方法给父组件
// 关闭弹窗 defineExpose({
function handleClose() { resetFormData,
emit('update:show', false) setLoading: (value: boolean) => {
emit('close') loading.value = value
} },
})
// 暴露方法给父组件
defineExpose({
resetFormData,
setLoading: (value: boolean) => {
loading.value = value
},
})
</script> </script>
<template> <template>
...@@ -269,143 +270,143 @@ defineExpose({ ...@@ -269,143 +270,143 @@ defineExpose({
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.dialog-content { .dialog-content {
padding: 10rpx 30rpx; padding: 10rpx 30rpx;
width: 90%; width: 90%;
max-height: 80vh; max-height: 80vh;
overflow-y: auto; overflow-y: auto;
} }
.section-title { .section-title {
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
color: #333; color: #333;
margin: 20rpx 0 30rpx 0; margin: 20rpx 0 30rpx 0;
padding-left: 20rpx; padding-left: 20rpx;
border-left: 6rpx solid #5db66f; border-left: 6rpx solid #5db66f;
}
.dialog-buttons {
display: flex;
gap: 20rpx;
margin-top: 40rpx;
.submit-btn {
flex: 1;
::v-deep .u-button {
background-color: #5db66f;
border-color: #5db66f;
}
} }
.cancel-btn { .dialog-buttons {
flex: 1; display: flex;
gap: 20rpx;
margin-top: 40rpx;
.submit-btn {
flex: 1;
::v-deep .u-button { ::v-deep .u-button {
background-color: #fff; background-color: #5db66f;
color: #666; border-color: #5db66f;
border: 2rpx solid #dcdfe6; }
} }
}
}
// uview-plus 表单样式调整 .cancel-btn {
::v-deep .u-form-item { flex: 1;
margin-bottom: 40rpx;
.u-form-item__body { ::v-deep .u-button {
padding: 0; background-color: #fff;
align-items: flex-start; color: #666;
border: 2rpx solid #dcdfe6;
}
}
} }
.u-form-item__body__left__content__label { // uview-plus 表单样式调整
font-size: 28rpx; ::v-deep .u-form-item {
color: #333; margin-bottom: 40rpx;
font-weight: 500;
width: 180rpx;
flex-shrink: 0;
text-align: right;
padding-right: 20rpx;
line-height: 80rpx;
}
.u-form-item__body__right { .u-form-item__body {
flex: 1; padding: 0;
min-width: 0; align-items: flex-start;
} }
}
.address-display { .u-form-item__body__left__content__label {
display: flex; font-size: 28rpx;
justify-content: space-between; color: #333;
align-items: center; font-weight: 500;
padding: 12rpx 18rpx; width: 180rpx;
background-color: transparent; flex-shrink: 0;
border-bottom: 2rpx solid #e4e7ed; text-align: right;
border-radius: 0; padding-right: 20rpx;
cursor: pointer; line-height: 80rpx;
width: 100%; }
text { .u-form-item__body__right {
flex: 1; flex: 1;
font-size: 28rpx; min-width: 0;
color: #333; }
} }
.address-display {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12rpx 18rpx;
background-color: transparent;
border-bottom: 2rpx solid #e4e7ed;
border-radius: 0;
cursor: pointer;
width: 100%;
text {
flex: 1;
font-size: 28rpx;
color: #333;
}
.placeholder-text { .placeholder-text {
color: #c0c4cc; color: #c0c4cc;
}
} }
}
::v-deep .u-form-item__body__left__content__required { ::v-deep .u-form-item__body__left__content__required {
position: static; position: static;
padding-right: 10rpx; padding-right: 10rpx;
} }
// 输入框样式优化 // 输入框样式优化
::v-deep .u-input { ::v-deep .u-input {
.u-input__content { .u-input__content {
padding: 0; padding: 0;
.u-input__content__field-wrapper { .u-input__content__field-wrapper {
border: none; border: none;
border-radius: 0; border-radius: 0;
.u-input__content__field-wrapper__field { .u-input__content__field-wrapper__field {
font-size: 28rpx; font-size: 28rpx;
height: auto; height: auto;
} }
.u-input__content__field-wrapper__placeholder { .u-input__content__field-wrapper__placeholder {
color: #c0c4cc; color: #c0c4cc;
font-size: 28rpx; font-size: 28rpx;
}
} }
}
&.u-input--focus { &.u-input--focus {
.u-input__content__field-wrapper { .u-input__content__field-wrapper {
border-bottom-color: #5db66f; border-bottom-color: #5db66f;
}
} }
} }
} }
}
// 模态框样式调整 // 模态框样式调整
::v-deep .u-modal { ::v-deep .u-modal {
.u-modal__content { .u-modal__content {
border-radius: 20rpx; border-radius: 20rpx;
padding: 20rpx 0rpx; padding: 20rpx 0rpx;
} }
.u-modal__header { .u-modal__header {
border-bottom: 2rpx solid #f0f0f0; border-bottom: 2rpx solid #f0f0f0;
padding: 30rpx; padding: 30rpx;
.u-modal__header__title { .u-modal__header__title {
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
color: #333; color: #333;
}
} }
} }
}
</style> </style>
<script setup> <script setup>
import { reactive, ref, computed } from 'vue' import { computed, reactive, ref } from 'vue'
import { onLoad, onNavigationBarButtonTap } from '@dcloudio/uni-app' import { onLoad, onNavigationBarButtonTap } from '@dcloudio/uni-app'
import SaveDialog from './components/save-dialog.vue' import SaveDialog from './components/save-dialog.vue'
import * as NongchangAPI from '@/api/model/nongchang' import * as NongchangAPI from '@/api/model/nongchang'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import { merge } from 'lodash-es'
const dictStore = useDictStore()
const dictStore = useDictStore() const deviceType = ref('') // 设备类型参数
const deviceType = ref('') // 设备类型参数 const pageData = reactive({
const pageData = reactive({ param: {
param: { deviceName: '',
deviceName: '', deviceType: '', // 添加设备类型筛选
deviceType: '', // 添加设备类型筛选 farmBaseId: '', // 基地id
farmBaseId: '', //基地id },
}, list: [],
list: [], selectedCategory: 'all',
selectedCategory: 'all', selectedDevice: {},
selectedDevice: {}, })
})
// 摄像头设备的分类标签
// 摄像头设备的分类标签 const cameraCategories = computed(() => {
const cameraCategories = computed(() => { const dictList =
const dictList = dictStore.getDictList.deviceType?.map((item) => ({
dictStore.getDictList.deviceType?.map((item) => ({ id: item.value,
id: item.value, name: item.text,
name: item.text, })) || []
})) || [] return [{ id: 'all', name: '全部' }, ...dictList]
return [{ id: 'all', name: '全部' }, ...dictList] })
})
onLoad((options) => {
onLoad((options) => { // 获取设备类型参数
// 获取设备类型参数 if (options.deviceType) {
if (options.deviceType) { deviceType.value = options.deviceType
deviceType.value = options.deviceType pageData.selectedCategory = options.deviceType
pageData.selectedCategory = options.deviceType pageData.param.deviceType = options.deviceType
pageData.param.deviceType = options.deviceType pageData.param.farmBaseId = options.farmBaseId
pageData.param.farmBaseId = options.farmBaseId }
getList()
})
// 判断是否为摄像头设备
const isCameraDevice = computed(() => {
return deviceType.value == '1'
})
// 获取设备列表
function getList() {
const formData = {
deviceName: pageData.param.deviceName,
deviceType: pageData.param.deviceType,
farmBaseId: pageData.param.farmBaseId,
}
NongchangAPI.queryByType(formData)
.then((res) => {
pageData.list = res.result || []
if (res.result.length > 0)
handleDeviceClick(res.result[0])
})
.catch(() => {
pageData.list = []
})
}
function handleSearch() {
// 搜索时重新获取列表
getList()
}
const showDialog = ref(false)
const currentEditData = ref(null)
onNavigationBarButtonTap((_) => {
showAddDialog()
})
function showAddDialog() {
currentEditData.value = null
showDialog.value = true
}
function handleSubmitSuccess() {
// 提交成功后刷新列表
getList()
}
function handleDialogClose() {
// 弹窗关闭后的处理逻辑
}
// 获取状态样式类
function getStatusClass(status) {
if (status === '已连接')
return 'status-connected'
if (status === '未连接')
return 'status-disconnected'
return 'status-unknown'
} }
getList()
}) // 分类标签点击
// 判断是否为摄像头设备 function handleCategoryClick(category) {
const isCameraDevice = computed(() => { pageData.selectedCategory = category.id
return deviceType.value == '1' if (category.id === 'all') {
}) pageData.param.deviceType = ''
} else {
// 获取设备列表 pageData.param.deviceType = category.id
function getList() { }
const formData = { getList()
deviceName: pageData.param.deviceName,
deviceType: pageData.param.deviceType,
farmBaseId: pageData.param.farmBaseId,
} }
NongchangAPI.queryByType(formData) // 设备卡片点击
.then((res) => { function handleDeviceClick(device) {
pageData.list = res.result || [] pageData.selectedDevice = device
if (res.result.length > 0) handleDeviceClick(res.result[0]) deviceType.value = device.deviceType
})
.catch(() => {
pageData.list = []
})
}
function handleSearch() {
// 搜索时重新获取列表
getList()
}
const showDialog = ref(false)
const currentEditData = ref(null)
onNavigationBarButtonTap((_) => {
showAddDialog()
})
function showAddDialog() {
currentEditData.value = null
showDialog.value = true
}
function handleSubmitSuccess() {
// 提交成功后刷新列表
getList()
}
function handleDialogClose() {
// 弹窗关闭后的处理逻辑
}
// 获取状态样式类
function getStatusClass(status) {
if (status === '已连接') return 'status-connected'
if (status === '未连接') return 'status-disconnected'
return 'status-unknown'
}
// 分类标签点击
function handleCategoryClick(category) {
pageData.selectedCategory = category.id
if (category.id === 'all') {
pageData.param.deviceType = ''
} else {
pageData.param.deviceType = category.id
} }
getList()
}
// 设备卡片点击
function handleDeviceClick(device) {
pageData.selectedDevice = device
deviceType.value = device.deviceType
}
</script> </script>
<template> <template>
...@@ -138,14 +140,14 @@ function handleDeviceClick(device) { ...@@ -138,14 +140,14 @@ function handleDeviceClick(device) {
<view class="device-badges"> <view class="device-badges">
<!-- <text class="badge badge-green" v-if="pageData.selectedDevice.isOnline == 1">在线</text> <!-- <text class="badge badge-green" v-if="pageData.selectedDevice.isOnline == 1">在线</text>
<text class="badge badge-gray" v-else>离线</text> --> <text class="badge badge-gray" v-else>离线</text> -->
<view class="online-status online-green"> <view class="online-status online-green">
<view class="status-point"></view> <view class="status-point" />
<text>在线</text> <text>在线</text>
</view> </view>
<view class="online-status"> <view class="online-status">
<view class="status-point"></view> <view class="status-point" />
<text>离线</text> <text>离线</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
...@@ -183,13 +185,13 @@ function handleDeviceClick(device) { ...@@ -183,13 +185,13 @@ function handleDeviceClick(device) {
class="codefun-ml-8" class="codefun-ml-8"
@confirm="handleSearch" @confirm="handleSearch"
/> --> /> -->
<u-input <u-input
v-model="pageData.param.deviceName" v-model="pageData.param.deviceName"
placeholder="请输入搜索内容" placeholder="请输入搜索内容"
border="none" border="none"
class="codefun-ml-8" class="codefun-ml-8"
@confirm="handleSearch" @confirm="handleSearch"
/> />
</view> </view>
<!-- 分类标签 --> <!-- 分类标签 -->
...@@ -251,852 +253,852 @@ function handleDeviceClick(device) { ...@@ -251,852 +253,852 @@ function handleDeviceClick(device) {
</template> </template>
<style lang="scss"> <style lang="scss">
body { body {
background-color: #e6f5e8; background-color: #e6f5e8;
} }
.mt-5 {
margin-top: 10rpx;
}
.mt-11 {
margin-top: 22rpx;
}
.ml-5 {
margin-left: 10rpx;
}
.ml-13 {
margin-left: 26rpx;
}
.ml-9 {
margin-left: 18rpx;
}
.page {
background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
height: 100%;
.section {
padding: 32rpx 24rpx 32rpx 36rpx;
background-color: #5db66f;
mix-blend-mode: NOTTHROUGH;
.image { .mt-5 {
border-radius: 64rpx; margin-top: 10rpx;
width: 108rpx; }
height: 42rpx;
}
.group { .mt-11 {
margin-right: 4rpx; margin-top: 22rpx;
}
.image_2 { .ml-5 {
mix-blend-mode: NOTTHROUGH; margin-left: 10rpx;
width: 34rpx; }
height: 22rpx;
}
.image_3 { .ml-13 {
mix-blend-mode: NOTTHROUGH; margin-left: 26rpx;
width: 30rpx; }
height: 22rpx;
}
.image_4 { .ml-9 {
width: 48rpx; margin-left: 18rpx;
height: 22rpx; }
}
}
.group_2 { .page {
padding-left: 6rpx; background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
height: 100%;
.section {
padding: 32rpx 24rpx 32rpx 36rpx;
background-color: #5db66f;
mix-blend-mode: NOTTHROUGH;
.image_5 { .image {
mix-blend-mode: NOTTHROUGH; border-radius: 64rpx;
width: 14rpx; width: 108rpx;
height: 26rpx; height: 42rpx;
} }
.pos { .group {
position: absolute; margin-right: 4rpx;
left: 6rpx;
top: 50%;
transform: translateY(-50%);
}
.text { .image_2 {
color: #ffffffe6; mix-blend-mode: NOTTHROUGH;
line-height: 29.6rpx; width: 34rpx;
} height: 22rpx;
}
.pos_2 { .image_3 {
position: absolute; mix-blend-mode: NOTTHROUGH;
right: 0; width: 30rpx;
top: 50%; height: 22rpx;
transform: translateY(-50%); }
.text_2 { .image_4 {
line-height: 25.78rpx; width: 48rpx;
height: 22rpx;
} }
} }
}
}
.group_3 { .group_2 {
padding: 28rpx 24rpx 58rpx; padding-left: 6rpx;
.section_2 { .image_5 {
padding: 16rpx 20rpx; mix-blend-mode: NOTTHROUGH;
background-color: #ffffff; width: 14rpx;
border-radius: 1998rpx; height: 26rpx;
mix-blend-mode: NOTTHROUGH; }
.pos {
position: absolute;
left: 6rpx;
top: 50%;
transform: translateY(-50%);
}
.text {
color: #ffffffe6;
line-height: 29.6rpx;
}
.text_3 { .pos_2 {
color: #cccccc; position: absolute;
line-height: 26.02rpx; right: 0;
top: 50%;
transform: translateY(-50%);
.text_2 {
line-height: 25.78rpx;
}
}
} }
} }
.section_3 { .group_3 {
padding: 0 24rpx; padding: 28rpx 24rpx 58rpx;
background-color: #ffffff;
border-radius: 18.46rpx;
mix-blend-mode: NOTTHROUGH;
.group_4 { .section_2 {
padding: 42rpx 4rpx 30rpx 22rpx; padding: 16rpx 20rpx;
border-bottom: solid 2rpx #eeeeee; background-color: #ffffff;
border-radius: 1998rpx;
mix-blend-mode: NOTTHROUGH;
.image_7 { .text_3 {
width: 100rpx; color: #cccccc;
height: 86rpx; line-height: 26.02rpx;
} }
}
.group_7 { .section_3 {
margin-left: 32rpx; padding: 0 24rpx;
background-color: #ffffff;
border-radius: 18.46rpx;
mix-blend-mode: NOTTHROUGH;
.text_5 { .group_4 {
color: #5db66f; padding: 42rpx 4rpx 30rpx 22rpx;
font-size: 40rpx; border-bottom: solid 2rpx #eeeeee;
font-family: SourceHanSansCN;
line-height: 40rpx;
}
.text_7 { .image_7 {
line-height: 22.18rpx; width: 100rpx;
height: 86rpx;
} }
}
.text_4 { .group_7 {
color: #333333; margin-left: 32rpx;
line-height: 40rpx;
}
.group_5 { .text_5 {
width: 219.94rpx; color: #5db66f;
font-size: 40rpx;
font-family: SourceHanSansCN;
line-height: 40rpx;
}
.group_6 { .text_7 {
overflow: hidden; line-height: 22.18rpx;
}
}
.text-wrapper_2 { .text_4 {
padding: 8rpx 0 4rpx; color: #333333;
line-height: 40rpx;
}
.group_5 {
width: 219.94rpx;
.group_6 {
overflow: hidden; overflow: hidden;
width: 60rpx;
height: 40rpx; .text-wrapper_2 {
padding: 8rpx 0 4rpx;
overflow: hidden;
width: 60rpx;
height: 40rpx;
}
} }
}
.group_8 { .group_8 {
padding-top: 16rpx; padding-top: 16rpx;
.text-wrapper_3 {
padding: 8rpx 0 4rpx;
overflow: hidden;
width: 60rpx;
height: 40rpx;
.text_8 {
color: #ff9800;
}
}
}
.text-wrapper_3 { .text-wrapper {
padding: 8rpx 0 4rpx; padding: 8rpx 0 4rpx;
overflow: hidden; overflow: hidden;
width: 60rpx; width: 112rpx;
height: 40rpx; height: 40rpx;
.text_8 { .text_6 {
color: #ff9800; line-height: 25.74rpx;
} }
} }
} }
}
.text-wrapper { .group_9 {
padding: 8rpx 0 4rpx; padding: 12rpx 4rpx;
overflow: hidden;
width: 112rpx;
height: 40rpx;
.text_6 { .image_8 {
line-height: 25.74rpx; margin: 4rpx 0;
} width: 40rpx;
height: 40rpx;
} }
}
}
.group_9 { .text-wrapper_4 {
padding: 12rpx 4rpx; padding: 12rpx 0;
overflow: hidden;
.image_8 { width: 168rpx;
margin: 4rpx 0; height: 48rpx;
width: 40rpx; }
height: 40rpx;
}
.text-wrapper_4 { .image_9 {
padding: 12rpx 0; margin-right: 12rpx;
overflow: hidden; width: 16rpx;
width: 168rpx; height: 26rpx;
height: 48rpx; }
} }
.image_9 { .font_5 {
margin-right: 12rpx; font-size: 28rpx;
width: 16rpx; font-family: SourceHanSansCN;
height: 26rpx; line-height: 25.76rpx;
color: #5db66f;
} }
} }
.font_5 { .font_3 {
font-size: 28rpx; font-size: 28rpx;
font-family: SourceHanSansCN; font-family: SourceHanSansCN;
line-height: 25.76rpx; line-height: 25.76rpx;
color: #5db66f; color: #1f2937;
} }
}
.font_3 {
font-size: 28rpx;
font-family: SourceHanSansCN;
line-height: 25.76rpx;
color: #1f2937;
}
.section_4 {
padding-left: 6rpx;
padding-bottom: 26rpx;
background-color: #ffffff;
border-radius: 26.28rpx;
mix-blend-mode: NOTTHROUGH;
.list { .section_4 {
margin-left: 18rpx; padding-left: 6rpx;
margin-right: 24rpx; padding-bottom: 26rpx;
background-color: #ffffff;
.list-item { border-radius: 26.28rpx;
padding: 24rpx 0; mix-blend-mode: NOTTHROUGH;
border-bottom: solid 2rpx #eeeeee;
.section_5 { .list {
padding: 12rpx 0 116rpx; margin-left: 18rpx;
background-image: url('/static/images/codefun/4be80e2618f3c4b4aa1ce64fd9063abf.png'); margin-right: 24rpx;
background-size: 100% 100%;
background-repeat: no-repeat; .list-item {
width: 160rpx; padding: 24rpx 0;
height: 160rpx; border-bottom: solid 2rpx #eeeeee;
.text-wrapper_5 { .section_5 {
padding: 8rpx 0; padding: 12rpx 0 116rpx;
background-image: linear-gradient(90deg, #43cf7c 0%, #5db66f 100%); background-image: url('/static/images/codefun/4be80e2618f3c4b4aa1ce64fd9063abf.png');
border-radius: 0rpx 8rpx 8rpx 0rpx; background-size: 100% 100%;
mix-blend-mode: NOTTHROUGH; background-repeat: no-repeat;
width: 84rpx; width: 160rpx;
height: 160rpx;
.font_6 {
font-size: 20rpx; .text-wrapper_5 {
font-family: SourceHanSansCN; padding: 8rpx 0;
line-height: 18.38rpx; background-image: linear-gradient(90deg, #43cf7c 0%, #5db66f 100%);
color: #ffffff; border-radius: 0rpx 8rpx 8rpx 0rpx;
mix-blend-mode: NOTTHROUGH;
width: 84rpx;
.font_6 {
font-size: 20rpx;
font-family: SourceHanSansCN;
line-height: 18.38rpx;
color: #ffffff;
}
} }
} }
}
.group_10 { .group_10 {
margin-right: 40rpx; margin-right: 40rpx;
.text_9 { .text_9 {
line-height: 22.34rpx; line-height: 22.34rpx;
} }
.text_10 { .text_10 {
line-height: 22.22rpx; line-height: 22.22rpx;
} }
.group_11 { .group_11 {
padding-left: 64rpx; padding-left: 64rpx;
.image_10 { .image_10 {
width: 28rpx; width: 28rpx;
height: 28rpx; height: 28rpx;
} }
.text-wrapper_6 { .text-wrapper_6 {
padding-top: 8rpx; padding-top: 8rpx;
overflow: hidden; overflow: hidden;
width: 48rpx; width: 48rpx;
height: 32rpx; height: 32rpx;
.text_11 { .text_11 {
line-height: 22.12rpx; line-height: 22.12rpx;
}
} }
}
.font_8 { .font_8 {
font-size: 24rpx; font-size: 24rpx;
font-family: SourceHanSansCN; font-family: SourceHanSansCN;
line-height: 22.28rpx; line-height: 22.28rpx;
color: #f44336; color: #f44336;
}
} }
} }
} }
} }
}
.group_14 { .group_14 {
margin: 18rpx 24rpx 0; margin: 18rpx 24rpx 0;
.text_14 { .text_14 {
line-height: 26.12rpx; line-height: 26.12rpx;
} }
.text-wrapper_8 { .text-wrapper_8 {
padding: 4rpx 0; padding: 4rpx 0;
overflow: hidden; overflow: hidden;
width: 48rpx; width: 48rpx;
height: 32rpx; height: 32rpx;
.text_15 { .text_15 {
line-height: 22.2rpx; line-height: 22.2rpx;
}
} }
} }
}
.font_7 { .font_7 {
font-size: 24rpx; font-size: 24rpx;
font-family: SourceHanSansCN; font-family: SourceHanSansCN;
line-height: 22.28rpx; line-height: 22.28rpx;
color: #5db66f; color: #5db66f;
} }
.group_15 { .group_15 {
margin-left: 24rpx; margin-left: 24rpx;
margin-top: 28rpx; margin-top: 28rpx;
width: 528.18rpx; width: 528.18rpx;
.text_16 { .text_16 {
line-height: 25.12rpx; line-height: 25.12rpx;
} }
.text_17 { .text_17 {
line-height: 26.26rpx; line-height: 26.26rpx;
}
} }
}
.group_16 { .group_16 {
margin-left: 24rpx; margin-left: 24rpx;
margin-top: 28rpx; margin-top: 28rpx;
width: 216.94rpx; width: 216.94rpx;
.text_18 { .text_18 {
line-height: 25.82rpx; line-height: 25.82rpx;
}
.text_19 {
line-height: 25.34rpx;
}
} }
.text_19 { .font_9 {
line-height: 25.34rpx; font-size: 28rpx;
font-family: SourceHanSansCN;
line-height: 25.76rpx;
color: #6b7280;
} }
}
.font_9 { .group_17 {
font-size: 28rpx; margin-left: 24rpx;
font-family: SourceHanSansCN; margin-top: 28rpx;
line-height: 25.76rpx;
color: #6b7280;
}
.group_17 { .text_20 {
margin-left: 24rpx; line-height: 26.16rpx;
margin-top: 28rpx; }
.text_20 { .text_21 {
line-height: 26.16rpx; line-height: 22.66rpx;
}
} }
.text_21 { .divider {
line-height: 22.66rpx; margin: 28rpx 18rpx 0 24rpx;
background-color: #f3f4f6;
height: 2rpx;
} }
}
.divider { .text_22 {
margin: 28rpx 18rpx 0 24rpx; margin-left: 24rpx;
background-color: #f3f4f6; margin-top: 32rpx;
height: 2rpx; line-height: 26.12rpx;
} }
.text_22 { .group_18 {
margin-left: 24rpx; margin-left: 24rpx;
margin-top: 32rpx; margin-top: 32rpx;
line-height: 26.12rpx;
}
.group_18 { .text_23 {
margin-left: 24rpx; line-height: 26.06rpx;
margin-top: 32rpx; }
.text_23 { .text_24 {
line-height: 26.06rpx; line-height: 22.66rpx;
}
} }
.text_24 { .font_10 {
line-height: 22.66rpx; font-size: 28rpx;
font-family: SourceHanSansCN;
line-height: 22.28rpx;
color: #1f2937;
} }
}
.font_10 { .group_19 {
font-size: 28rpx; margin-left: 24rpx;
font-family: SourceHanSansCN; margin-top: 28rpx;
line-height: 22.28rpx;
color: #1f2937;
}
.group_19 { .text_25 {
margin-left: 24rpx; line-height: 25.9rpx;
margin-top: 28rpx; }
.text_25 { .text_26 {
line-height: 25.9rpx; line-height: 25.78rpx;
}
} }
.text_26 { .group_20 {
line-height: 25.78rpx; margin-left: 24rpx;
} margin-top: 32rpx;
}
.group_20 { .text_27 {
margin-left: 24rpx; line-height: 25.96rpx;
margin-top: 32rpx; }
.text_27 { .text_28 {
line-height: 25.96rpx; line-height: 25.88rpx;
}
} }
.text_28 { .divider_2 {
line-height: 25.88rpx; margin-top: 28rpx;
background-color: #f3f4f6;
width: 716rpx;
height: 2rpx;
}
.text-wrapper_9 {
margin-left: 24rpx;
margin-top: 32rpx;
padding: 24rpx 0;
background-color: #5db66f;
border-radius: 400rpx;
mix-blend-mode: NOTTHROUGH;
.text_29 {
line-height: 25.9rpx;
}
} }
} }
.divider_2 { .font_4 {
margin-top: 28rpx; font-size: 24rpx;
background-color: #f3f4f6; font-family: SourceHanSansCN;
width: 716rpx; line-height: 22.28rpx;
height: 2rpx; color: #555555;
} }
}
.text-wrapper_9 { .image_6 {
margin-left: 24rpx; width: 32rpx;
margin-top: 32rpx; height: 32rpx;
padding: 24rpx 0; }
background-color: #5db66f;
border-radius: 400rpx;
mix-blend-mode: NOTTHROUGH;
.text_29 { .font {
line-height: 25.9rpx; font-size: 32rpx;
} font-family: SourceHanSansCN;
} line-height: 29.88rpx;
color: #333333;
} }
.font_4 { .font_2 {
font-size: 24rpx; font-size: 28rpx;
font-family: SourceHanSansCN; font-family: SourceHanSansCN;
line-height: 22.28rpx; line-height: 25.76rpx;
color: #555555; color: #ffffff;
} }
} }
.image_6 { /* 设备列表样式 */
width: 32rpx; .device-list {
height: 32rpx; margin-top: 20rpx;
} }
.font { .device-item {
font-size: 32rpx; background-color: #ffffff;
font-family: SourceHanSansCN; border-radius: 16rpx;
line-height: 29.88rpx; padding: 24rpx;
color: #333333; display: flex;
// justify-content: space-between;
align-items: center;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
}
::v-deep .uni-swipe {
border-radius: 16rpx;
margin-bottom: 20rpx;
}
.device-info {
flex: 1;
} }
.font_2 { .device-name {
font-size: 28rpx; font-size: 28rpx;
font-family: SourceHanSansCN; font-weight: 400;
line-height: 25.76rpx; letter-spacing: 0px;
color: #ffffff; text-align: center;
} }
}
.device-details {
/* 设备列表样式 */ display: flex;
.device-list { flex-direction: column;
margin-top: 20rpx; gap: 6rpx;
} margin-bottom: 8rpx;
}
.device-item {
background-color: #ffffff; .device-type,
border-radius: 16rpx; .device-identifier {
padding: 24rpx; font-size: 24rpx;
display: flex; color: #666666;
// justify-content: space-between; }
align-items: center;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1); .device-status-time {
} display: flex;
flex-direction: column;
::v-deep .uni-swipe { align-items: flex-end;
border-radius: 16rpx; gap: 6rpx;
margin-bottom: 20rpx; min-width: 180rpx;
} }
.device-info { .device-status {
flex: 1; font-size: 24rpx;
}
.device-name {
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0px;
text-align: center;
}
.device-details {
display: flex;
flex-direction: column;
gap: 6rpx;
margin-bottom: 8rpx;
}
.device-type,
.device-identifier {
font-size: 24rpx;
color: #666666;
}
.device-status-time {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 6rpx;
min-width: 180rpx;
}
.device-status {
font-size: 24rpx;
font-weight: bold;
}
.device-time {
font-size: 22rpx;
color: #999999;
}
.device-actions {
display: flex;
flex-direction: column;
gap: 12rpx;
}
.status-connected {
color: #5db66f !important;
font-weight: bold;
}
.status-disconnected {
color: #f44336 !important;
font-weight: bold;
}
.status-unknown {
color: #ff9800 !important;
font-weight: bold;
}
.empty-state {
text-align: center;
padding: 100rpx 0;
color: #999999;
font-size: 28rpx;
}
/* 分类标签样式 */
.category-tabs {
display: flex;
gap: 16rpx;
padding: 24rpx 0;
overflow-x: auto;
white-space: nowrap;
}
.category-tab {
padding: 12rpx 32rpx;
background-color: #ffffff;
border-radius: 40rpx;
font-size: 28rpx;
color: #333333;
cursor: pointer;
flex-shrink: 0;
border: 2rpx solid transparent;
transition: all 0.3s;
&.active {
background-color: #5db66f;
color: #ffffff;
font-weight: bold; font-weight: bold;
} }
}
.device-time {
/* 摄像头设备样式 */ font-size: 22rpx;
/* 顶部视频占位区域 */ color: #999999;
.video-placeholder-top {
position: relative;
width: 100%;
height: 400rpx;
//background-image: url('/static/images/device/video-bg.jpg');
background-size: cover;
background-position: center;
flex-shrink: 0;
}
.video-overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 20rpx 24rpx;
background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.video-info {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.video-location {
color: #ffffff;
font-size: 32rpx;
font-weight: bold;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.3);
}
.video-time {
color: #ffffff;
font-size: 24rpx;
opacity: 0.9;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.3);
}
.fullscreen-icon {
width: 48rpx;
height: 48rpx;
opacity: 0.9;
}
/* 设备信息卡片样式 */
.device-info-card {
margin: 24rpx 24rpx 0rpx 24rpx;
padding: 32rpx 24rpx;
background-color: #ffffff;
border-radius: 16rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
}
.device-header {
display: flex;
align-items: center;
gap: 20rpx;
margin-bottom: 24rpx;
}
.device-icon {
width: 80rpx;
height: 80rpx;
background-color: #e8f5e9;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.icon-img {
width: 48rpx;
height: 48rpx;
}
.device-title-group {
display: flex;
align-items: center;
}
.device-title {
font-size: 32rpx;
font-weight: bold;
color: #333333;
margin-bottom: 12rpx;
}
.device-badges {
display: flex;
align-items: center;
margin-left: 16rpx;
.online-status{
width: 84rpx;
height: 36rpx;
opacity: 1;
border-radius: 4rpx;
background: rgba(159, 174, 181, 0.1);
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0px;
color: #9FAEB5;
text-align: center;
margin-right: 30rpx;
display: flex;
align-items: center;
justify-content: center;
.status-point{
width: 12rpx;
height: 12rpx;
background: #9FAEB5;
border-radius: 12rpx;
margin-right: 8rpx;
}
}
.online-green{
color: #43CF7C;
.status-point{
background: #43CF7C;
}
}
}
.badge {
padding: 6rpx 16rpx;
border-radius: 20rpx;
font-size: 24rpx;
}
.badge-green {
background-color: #5db66f;
color: #ffffff;
}
.badge-gray {
background-color: #e0e0e0;
color: #666666;
}
.device-stats {
display: flex;
justify-content: space-between;
margin-bottom: 16rpx;
padding-right: 26rpx;
&:last-child {
margin-bottom: 0;
} }
}
.device-actions {
.stat-item { display: flex;
flex: 1; flex-direction: column;
display: flex; gap: 12rpx;
align-items: center;
}
.stat-label {
font-size: 24rpx;
color: #999999;
}
.stat-value {
font-size: 24rpx;
color: #666666;
}
.device-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20rpx;
margin-top: 20rpx;
}
.device-card {
background-color: #ffffff;
border-radius: 16rpx;
padding: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
cursor: pointer;
transition: all 0.3s;
border: 2rpx solid transparent;
&.selected {
border-color: #5db66f;
box-shadow: 0 4rpx 12rpx rgba(93, 182, 111, 0.3);
background: #5DB66F;
color: #FFFFFF !important;
} }
}
.device-card-header { .status-connected {
display: flex; color: #5db66f !important;
flex-direction: column; font-weight: bold;
gap: 8rpx; }
margin-bottom: 16rpx;
border-bottom: 2rpx solid #f0f0f0;
padding-bottom: 16rpx;
.device-name { .status-disconnected {
font-size: 28rpx; color: #f44336 !important;
font-weight: bold; font-weight: bold;
color: #333333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
} }
.device-status { .status-unknown {
font-size: 22rpx; color: #ff9800 !important;
font-weight: bold; font-weight: bold;
} }
}
.device-card-body { .empty-state {
display: flex; text-align: center;
flex-direction: column; padding: 100rpx 0;
gap: 12rpx; color: #999999;
font-size: 28rpx;
}
.device-detail { /* 分类标签样式 */
font-size: 22rpx; .category-tabs {
display: flex;
gap: 16rpx;
padding: 24rpx 0;
overflow-x: auto;
white-space: nowrap;
}
.category-tab {
padding: 12rpx 32rpx;
background-color: #ffffff;
border-radius: 40rpx;
font-size: 28rpx;
color: #333333;
cursor: pointer;
flex-shrink: 0;
border: 2rpx solid transparent;
transition: all 0.3s;
&.active {
background-color: #5db66f;
color: #ffffff;
font-weight: bold;
}
}
/* 摄像头设备样式 */
/* 顶部视频占位区域 */
.video-placeholder-top {
position: relative;
width: 100%;
height: 400rpx;
//background-image: url('/static/images/device/video-bg.jpg');
background-size: cover;
background-position: center;
flex-shrink: 0;
}
.video-overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 20rpx 24rpx;
background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.video-info {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4rpx; gap: 8rpx;
}
.video-location {
color: #ffffff;
font-size: 32rpx;
font-weight: bold;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.3);
}
.video-time {
color: #ffffff;
font-size: 24rpx;
opacity: 0.9;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.3);
}
.fullscreen-icon {
width: 48rpx;
height: 48rpx;
opacity: 0.9;
}
/* 设备信息卡片样式 */
.device-info-card {
margin: 24rpx 24rpx 0rpx 24rpx;
padding: 32rpx 24rpx;
background-color: #ffffff;
border-radius: 16rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
}
.device-header {
display: flex;
align-items: center;
gap: 20rpx;
margin-bottom: 24rpx;
}
.device-icon {
width: 80rpx;
height: 80rpx;
background-color: #e8f5e9;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.icon-img {
width: 48rpx;
height: 48rpx;
}
.device-title-group {
display: flex;
align-items: center;
}
.device-title {
font-size: 32rpx;
font-weight: bold;
color: #333333;
margin-bottom: 12rpx;
}
.detail-label { .device-badges {
color: #999999; display: flex;
align-items: center;
margin-left: 16rpx;
.online-status {
width: 84rpx;
height: 36rpx;
opacity: 1;
border-radius: 4rpx;
background: rgba(159, 174, 181, 0.1);
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0px;
color: #9faeb5;
text-align: center;
margin-right: 30rpx;
display: flex;
align-items: center;
justify-content: center;
.status-point {
width: 12rpx;
height: 12rpx;
background: #9faeb5;
border-radius: 12rpx;
margin-right: 8rpx;
}
}
.online-green {
color: #43cf7c;
.status-point {
background: #43cf7c;
}
} }
}
.detail-value { .badge {
color: #666666; padding: 6rpx 16rpx;
border-radius: 20rpx;
font-size: 24rpx;
}
.badge-green {
background-color: #5db66f;
color: #ffffff;
}
.badge-gray {
background-color: #e0e0e0;
color: #666666;
}
.device-stats {
display: flex;
justify-content: space-between;
margin-bottom: 16rpx;
padding-right: 26rpx;
&:last-child {
margin-bottom: 0;
}
}
.stat-item {
flex: 1;
display: flex;
align-items: center;
}
.stat-label {
font-size: 24rpx;
color: #999999;
}
.stat-value {
font-size: 24rpx;
color: #666666;
}
.device-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20rpx;
margin-top: 20rpx;
}
.device-card {
background-color: #ffffff;
border-radius: 16rpx;
padding: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
cursor: pointer;
transition: all 0.3s;
border: 2rpx solid transparent;
&.selected {
border-color: #5db66f;
box-shadow: 0 4rpx 12rpx rgba(93, 182, 111, 0.3);
background: #5db66f;
color: #ffffff !important;
}
}
.device-card-header {
display: flex;
flex-direction: column;
gap: 8rpx;
margin-bottom: 16rpx;
border-bottom: 2rpx solid #f0f0f0;
padding-bottom: 16rpx;
.device-name {
font-size: 28rpx;
font-weight: bold;
color: #333333;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.device-status {
font-size: 22rpx;
font-weight: bold;
}
}
.device-card-body {
display: flex;
flex-direction: column;
gap: 12rpx;
.device-detail {
font-size: 22rpx;
display: flex;
flex-direction: column;
gap: 4rpx;
.detail-label {
color: #999999;
}
.detail-value {
color: #666666;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
} }
}
</style> </style>
<script setup lang="ts"> <script setup lang="ts">
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'
import { getCurrentDateTime } from '@/utils/date' import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore();
const consultRecord = reactive({ const userStore = useUserStore()
id: '', const consultRecord = reactive({
mobile: '',// 咨询人号码 id: '',
consultTime:"" ,// 咨询时间 mobile: '', // 咨询人号码
bizType:1, // 业务类型(1代理记账,2农资,3农机,4金融) consultTime: '', // 咨询时间
enterpriseId:1324324324, // 意向企业 bizType: 1, // 业务类型(1代理记账,2农资,3农机,4金融)
feedbackRemark:"" // 反馈备注 enterpriseId: 1324324324, // 意向企业
}) feedbackRemark: '', // 反馈备注
const pageData = reactive({ })
showLogoutDialog: false, const pageData = reactive({
}) showLogoutDialog: false,
onShow(() => { })
const { id, realname, phone } = userStore.getUserInfo; onShow(() => {
consultRecord.id = id; const { id, realname, phone } = userStore.getUserInfo
consultRecord.mobile = phone; consultRecord.id = id
consultRecord.feedbackRemark = realname; consultRecord.mobile = phone
}) consultRecord.feedbackRemark = realname
})
// 立即申请 // 立即申请
function onApplyClick() { function onApplyClick() {
consultRecord.consultTime = getCurrentDateTime(); consultRecord.consultTime = getCurrentDateTime()
HomeAPI.postConsultRecordAdd(consultRecord).then((res) => { HomeAPI.postConsultRecordAdd(consultRecord).then((res) => {
pageData.showLogoutDialog = true; pageData.showLogoutDialog = true
}) })
} }
// 提交申请 // 提交申请
function handleConfirmLogout(){ function handleConfirmLogout() {
pageData.showLogoutDialog = false; pageData.showLogoutDialog = false
} }
// 查看大图 // 查看大图
function onViewImage(imageUrl) { function onViewImage(imageUrl) {
uni.previewImage({ uni.previewImage({
urls: [imageUrl] urls: [imageUrl],
}) })
} }
</script> </script>
...@@ -222,14 +223,14 @@ ...@@ -222,14 +223,14 @@
<text class="font_8 text_32">立即申请</text> <text class="font_8 text_32">立即申请</text>
</view> </view>
</view> </view>
<successfulDialog <successfulDialog
v-model:show="pageData.showLogoutDialog" v-model:show="pageData.showLogoutDialog"
title="申请成功" title="申请成功"
content="平台已收到申请,将尽快与您取得联系!" content="平台已收到申请,将尽快与您取得联系!"
confirmText="我知道了" confirmText="我知道了"
@confirm="handleConfirmLogout" @confirm="handleConfirmLogout"
/> />
</view> </view>
</template> </template>
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
import * as NongzhiAPI from '@/api/model/nongzhi' import * as NongzhiAPI from '@/api/model/nongzhi'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore();
const userStore = useUserStore()
// 下拉刷新 // 下拉刷新
onPullDownRefresh(() => { onPullDownRefresh(() => {
getGoodsList() getGoodsList()
...@@ -227,25 +228,33 @@ ...@@ -227,25 +228,33 @@
// 查询服务列表 // 查询服务列表
function getServiceItems() { function getServiceItems() {
// '灵活用工','农机租赁','惠农金融','助农保险' // '灵活用工','农机租赁','惠农金融','助农保险'
const testLimitContent = ['1983075690694692866','1983077495298183170','1983077763284848642','1983077932298522625','1985038053803876354','1985038211056721921','1985038680680357889']; const testLimitContent = [
'1983075690694692866',
'1983077495298183170',
'1983077763284848642',
'1983077932298522625',
'1985038053803876354',
'1985038211056721921',
'1985038680680357889',
]
HomeAPI.zoneList({ HomeAPI.zoneList({
pageNo: 1, pageNo: 1,
pageSize: 5, pageSize: 5,
status: 1, status: 1,
type: 3, type: 3,
}).then((res) => { }).then((res) => {
const { records } = res; const { records } = res
if(userStore.isAuditMode){ if (userStore.isAuditMode) {
let arrData = []; const arrData = []
for(let i = 0; i < records.length; i++){ for (let i = 0; i < records.length; i++) {
if(!testLimitContent.includes(records[i].id)){ if (!testLimitContent.includes(records[i].id)) {
arrData.push(records[i]); arrData.push(records[i])
} }
} }
pageData.menuItems = arrData; pageData.menuItems = arrData
}else{ } else {
pageData.menuItems = [...records] pageData.menuItems = [...records]
} }
}) })
} }
...@@ -302,11 +311,11 @@ ...@@ -302,11 +311,11 @@
// 跳转到灵活用工界面 // 跳转到灵活用工界面
Navigate.to('/pages/linghuoyonggong/linghuoyonggong') Navigate.to('/pages/linghuoyonggong/linghuoyonggong')
} }
// 查看更多农资交易 // 查看更多农资交易
function onViewMoreKexinnongzi() { function onViewMoreKexinnongzi() {
Navigate.to('/pages/kexinnongzi/kexinnongzi') Navigate.to('/pages/kexinnongzi/kexinnongzi')
} }
// 助农金融产品点击事件 // 助农金融产品点击事件
function onFinancialProductClick(product: any) { function onFinancialProductClick(product: any) {
...@@ -403,7 +412,10 @@ ...@@ -403,7 +412,10 @@
</view> </view>
</view> </view>
</view> </view>
<view v-if="!userStore.isAuditMode" class="codefun-flex-row codefun-justify-between codefun-items-baseline codefun-mt-24"> <view
v-if="!userStore.isAuditMode"
class="codefun-flex-row codefun-justify-between codefun-items-baseline codefun-mt-24"
>
<text class="font_5 text_8">灵活用工</text> <text class="font_5 text_8">灵活用工</text>
<text class="font_6 text_9" @click="onViewMoreFlexibleEmployment">更多</text> <text class="font_6 text_9" @click="onViewMoreFlexibleEmployment">更多</text>
</view> </view>
...@@ -485,14 +497,12 @@ ...@@ -485,14 +497,12 @@
</view> </view>
</view> </view>
<view class="codefun-flex-col codefun-mt-24"> <view class="codefun-flex-col codefun-mt-24">
<view <view class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch">
class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch" <text class="font_5">农资交易</text>
> <text class="text-28 font-extralight color-#5DB66F" @click="onViewMoreKexinnongzi">
<text class="font_5">农资交易</text> 更多<fui-icon name="right" size="30" color="#5DB66F" />
<text class="text-28 font-extralight color-#5DB66F" @click="onViewMoreKexinnongzi"> </text>
更多<fui-icon name="right" size="30" color="#5DB66F" /> </view>
</text>
</view>
<view class="codefun-flex-col codefun-self-stretch section_6 codefun-mt-16"> <view class="codefun-flex-col codefun-self-stretch section_6 codefun-mt-16">
<view class="grid"> <view class="grid">
<view <view
...@@ -521,7 +531,10 @@ ...@@ -521,7 +531,10 @@
>{{ product.name }}</text >{{ product.name }}</text
> >
<text class="codefun-self-start font_1 text_27 codefun-mt-10" style="font-size: 32rpx" <text class="codefun-self-start font_1 text_27 codefun-mt-10" style="font-size: 32rpx"
>¥{{ product.minSellPrice }}<text v-if="product.unit" style="font-size: 24rpx;color:#999999;">/{{ product.unit }}</text></text >¥{{ product.minSellPrice
}}<text v-if="product.unit" style="font-size: 24rpx; color: #999999"
>/{{ product.unit }}</text
></text
> >
</view> </view>
</view> </view>
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive, toRefs } from 'vue' import { reactive } from 'vue'
import { onShow } from '@dcloudio/uni-app' import { onShow } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as NongchangAPI from '@/api/model/nongchang' import * as NongchangAPI from '@/api/model/nongchang'
import { areaTree } from '@/utils/areaData' import { areaTree } from '@/utils/areaData'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import { useFarmStore } from '@/store/modules/farm' import { useFarmStore } from '@/store/modules/farm'
const dictStore = useDictStore() const dictStore = useDictStore()
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
const farmStore = useFarmStore() const farmStore = useFarmStore()
onLoad((pageOptions) => { onLoad((pageOptions) => {
// 页面加载时的初始化操作 // 页面加载时的初始化操作
const farmInfo = farmStore.getFarm const farmInfo = farmStore.getFarm
if (farmInfo) { if (farmInfo) {
pageData.form.farmId = farmInfo.id pageData.form.farmId = farmInfo.id
} }
pageData.form.farmId = pageOptions.farmId pageData.form.farmId = pageOptions.farmId
}) })
onShow(() => { onShow(() => {
// 数据字典赋值 // 数据字典赋值
initDict() initDict()
pageData.form.userId = userStore.getUserInfo.id pageData.form.userId = userStore.getUserInfo.id
}) })
const pageData = reactive({ const pageData = reactive({
loading: false, loading: false,
show: { show: {
growCrops: false, growCrops: false,
},
options: {
address: [],
mainProducts: [],
growCrops: [],
},
form: {
id: '',
userId: '',
farmId: '',
baseName: '',
scale: '',
managerName: '',
contactPhone: '',
growCrops: '',
growCropsText: '',
},
rules: [
{
name: 'baseName',
rule: ['required'],
msg: ['请输入基地名称'],
},
{
name: 'scale',
rule: ['required'],
msg: ['请输入面积'],
},
{
name: 'managerName',
rule: ['required'],
msg: ['请输入负责人'],
}, },
{ options: {
name: 'contactPhone', address: [],
rule: ['required'], mainProducts: [],
msg: ['请输入联系电话'], growCrops: [],
}, },
{ form: {
name: 'growCrops', id: '',
rule: ['required'], userId: '',
msg: ['请选择种植作物'], farmId: '',
baseName: '',
scale: '',
managerName: '',
contactPhone: '',
growCrops: '',
growCropsText: '',
}, },
], rules: [
}) {
name: 'baseName',
function initDict() { rule: ['required'],
pageData.options.address = areaTree msg: ['请输入基地名称'],
pageData.options.growCrops = dictStore.getDictList.crops_type.map((item) => { },
return { {
value: item.value, name: 'scale',
text: item.text, rule: ['required'],
} msg: ['请输入面积'],
},
{
name: 'managerName',
rule: ['required'],
msg: ['请输入负责人'],
},
{
name: 'contactPhone',
rule: ['required'],
msg: ['请输入联系电话'],
},
{
name: 'growCrops',
rule: ['required'],
msg: ['请选择种植作物'],
},
],
}) })
}
function handleChangeGrowCrops(e) {
pageData.form.growCrops = e.value
pageData.form.growCropsText = e.text
pageData.show.growCrops = false
}
const toastRef = ref()
const formRef = ref() function initDict() {
function submit() { pageData.options.address = areaTree
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => { pageData.options.growCrops = dictStore.getDictList.crops_type.map((item) => {
if (res.isPassed) { return {
pageData.loading = true value: item.value,
// 根据是否有ID决定调用编辑还是新增接口 text: item.text,
const apiCall = pageData.form.id ? NongchangAPI.editFarmbase : NongchangAPI.addFarmbase }
apiCall(pageData.form) })
.then(() => { }
toastRef.value.show({ function handleChangeGrowCrops(e) {
type: 'success', pageData.form.growCrops = e.value
text: '添加基地成功', pageData.form.growCropsText = e.text
pageData.show.growCrops = false
}
const toastRef = ref()
const formRef = ref()
function submit() {
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => {
if (res.isPassed) {
pageData.loading = true
// 根据是否有ID决定调用编辑还是新增接口
const apiCall = pageData.form.id ? NongchangAPI.editFarmbase : NongchangAPI.addFarmbase
apiCall(pageData.form)
.then(() => {
toastRef.value.show({
type: 'success',
text: '添加基地成功',
})
setTimeout(() => {
uni.navigateBack()
}, 800)
// uni.switchTab({
// url: '/pages/mine/index',
// })
}) })
setTimeout(() => { .finally(() => {
uni.navigateBack() pageData.loading = false
}, 800) })
// uni.switchTab({ }
// url: '/pages/mine/index', })
// }) }
})
.finally(() => {
pageData.loading = false
})
}
})
}
</script> </script>
<template> <template>
...@@ -209,152 +209,152 @@ function submit() { ...@@ -209,152 +209,152 @@ function submit() {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.page { .page {
background: #e8f5e9; background: #e8f5e9;
min-height: 100vh; min-height: 100vh;
} }
.page-container { .page-container {
padding: 28rpx; padding: 28rpx;
} }
.form-card { .form-card {
background-color: #ffffff; background-color: #ffffff;
border-radius: 20rpx; border-radius: 20rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
padding: 0; padding: 0;
overflow: hidden; overflow: hidden;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
} }
.upload-title { .upload-title {
padding: 28rpx; padding: 28rpx;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
font-weight: 400; font-weight: 400;
} }
.upload-content { .upload-content {
padding: 0 32rpx 32rpx; padding: 0 32rpx 32rpx;
} }
.submit-btn-box { .submit-btn-box {
padding: 32rpx 0; padding: 32rpx 0;
} }
:deep(.fui-button) { :deep(.fui-button) {
border-color: #ff9800 !important; border-color: #ff9800 !important;
background: #ff9800 !important; background: #ff9800 !important;
} }
:deep(.fui-input__wrap), :deep(.fui-input__wrap),
:deep(.fui-textarea__wrap) { :deep(.fui-textarea__wrap) {
padding: 28rpx 32rpx; padding: 28rpx 32rpx;
// border-bottom: 1px solid #e5e5e5; // border-bottom: 1px solid #e5e5e5;
} }
:deep(.fui-input__label), :deep(.fui-input__label),
:deep(.fui-textarea__label) { :deep(.fui-textarea__label) {
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
min-width: 160rpx; min-width: 160rpx;
font-weight: 400; font-weight: 400;
} }
:deep(.fui-input__self), :deep(.fui-input__self),
:deep(.fui-textarea__self) { :deep(.fui-textarea__self) {
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
} }
:deep(.fui-input__placeholder), :deep(.fui-input__placeholder),
:deep(.fui-textarea__placeholder) { :deep(.fui-textarea__placeholder) {
color: #d0d0d0; color: #d0d0d0;
font-size: 28rpx; font-size: 28rpx;
} }
.form-card :deep(.fui-input__wrap:last-child), .form-card :deep(.fui-input__wrap:last-child),
.form-card :deep(.fui-textarea__wrap:last-child) { .form-card :deep(.fui-textarea__wrap:last-child) {
border-bottom: none; border-bottom: none;
} }
::v-deep .uni-input-placeholder { ::v-deep .uni-input-placeholder {
font-size: 28rpx !important; font-size: 28rpx !important;
color: #999999 !important; color: #999999 !important;
} }
:deep(.uni-textarea-placeholder) { :deep(.uni-textarea-placeholder) {
font-size: 28rpx !important; font-size: 28rpx !important;
color: #999999 !important; color: #999999 !important;
} }
:deep(.fui-button) { :deep(.fui-button) {
width: 690rpx; width: 690rpx;
border-color: #5db66f !important; border-color: #5db66f !important;
background: #5db66f !important; background: #5db66f !important;
} }
// 移除fui-form的默认样式 // 移除fui-form的默认样式
:deep(.fui-form) { :deep(.fui-form) {
background: transparent; background: transparent;
} }
:deep(.fui-form__item) { :deep(.fui-form__item) {
background: transparent; background: transparent;
border: none; border: none;
margin-bottom: 0; margin-bottom: 0;
padding: 0; padding: 0;
} }
:deep(.fui-input__border-bottom) { :deep(.fui-input__border-bottom) {
right: 32rpx !important; right: 32rpx !important;
} }
.form-item-block { .form-item-block {
padding: 24rpx 12rpx; padding: 24rpx 12rpx;
// border-bottom: 1px solid #e5e5e5; // border-bottom: 1px solid #e5e5e5;
&:last-child { &:last-child {
border-bottom: none; border-bottom: none;
}
} }
}
.form-item-label { .form-item-label {
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
font-weight: 400; font-weight: 400;
margin-bottom: 20rpx; margin-bottom: 20rpx;
&.required::before { &.required::before {
content: '*'; content: '*';
color: #ff4d4f; color: #ff4d4f;
margin-right: 8rpx; margin-right: 8rpx;
}
} }
}
.block-textarea { .block-textarea {
width: 100%; width: 100%;
padding: 0rpx 12rpx !important; padding: 0rpx 12rpx !important;
} }
.block-upload { .block-upload {
width: 100%; width: 100%;
padding: 0 20rpx; padding: 0 20rpx;
:deep(.uni-file-picker__container) { :deep(.uni-file-picker__container) {
background-color: #fff !important; background-color: #fff !important;
border: unset !important; border: unset !important;
border-radius: 16rpx; border-radius: 16rpx;
min-height: 200rpx; min-height: 200rpx;
display: flex; display: flex;
justify-content: left !important; justify-content: left !important;
}
} }
} .select-text {
.select-text { font-size: 28rpx;
font-size: 28rpx; color: #333333;
color: #333333; padding: 0 20rpx;
padding: 0 20rpx; &.placeholder {
&.placeholder { color: #999999;
color: #999999; }
} }
}
.fui-input-wrapper { .fui-input-wrapper {
cursor: pointer; cursor: pointer;
} }
</style> </style>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
}) })
}) })
function getList() { function getList() {
if (!paging.value) if (!paging.value)
return return
NongchangAPI.getFarmbaseList(pageData.param) NongchangAPI.getFarmbaseList(pageData.param)
.then((res) => { .then((res) => {
......
<script setup lang="ts"> <script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import Navigate from '@/utils/page/navigate' import { reactive, ref } from 'vue'
import { reactive, ref } from 'vue' import { useUserStore } from '@/store/modules/user'
import { useUserStore } from '@/store/modules/user' import { useGlobSetting } from '/@/hooks/setting'
import { useGlobSetting } from '/@/hooks/setting' import * as NongzhiAPI from '@/api/model/nongzhi'
import * as NongzhiAPI from '@/api/model/nongzhi' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import ConfirmDialog from '@/components/ConfirmDialog/index.vue'
import ConfirmDialog from '@/components/ConfirmDialog/index.vue'
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
let enterpriseId = null; let enterpriseId = null
onLoad((options) => { onLoad((options) => {
let param = JSON.parse(decodeURIComponent(options.param)); const param = JSON.parse(decodeURIComponent(options.param))
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: param.name title: param.name,
}); })
enterpriseId = param.id; enterpriseId = param.id
getDetailData(enterpriseId); getDetailData(enterpriseId)
queryByCategoryAndCode(0,null); queryByCategoryAndCode(0, null)
queryByCategory(); queryByCategory()
getGoodsQueryById(); getGoodsQueryById()
}) })
const toastRef = ref() const toastRef = ref()
const unitPopupRef = ref(null); const unitPopupRef = ref(null)
const uploadRef = ref() const uploadRef = ref()
const bgColorData = ["#EEFAEB","#EFF1FF","#FFF3F1","#E8F7F7","#FFF3E7","#FAF8EA"]; const bgColorData = ['#EEFAEB', '#EFF1FF', '#FFF3F1', '#E8F7F7', '#FFF3E7', '#FAF8EA']
const pageData = reactive({ const pageData = reactive({
data:null, data: null,
enterpriseCers:[], enterpriseCers: [],
isPopupShow:false, isPopupShow: false,
unitPopup:false, unitPopup: false,
unitOptions:[], unitOptions: [],
unitVal:[], unitVal: [],
productImageArr:[], productImageArr: [],
categoryPopup:false, categoryPopup: false,
categoryOptions:[], categoryOptions: [],
categoryText:[], categoryText: [],
categoryVal:[], categoryVal: [],
enterpriseProduct:[], enterpriseProduct: [],
contactName:"", contactName: '',
showConfirmDialog:false, showConfirmDialog: false,
rules: [ rules: [
{ {
name: 'name', name: 'name',
rule: ['required'], rule: ['required'],
msg: ['请输入商品名称'], msg: ['请输入商品名称'],
}, },
/* { /* {
name: "mobile", name: "mobile",
rule: ["required", "isMobile"], rule: ["required", "isMobile"],
msg: ["请输入联系电话", "请输入正确的联系电话"] msg: ["请输入联系电话", "请输入正确的联系电话"]
}, */ }, */
{ {
name: 'category', name: 'category',
rule: ['required'], rule: ['required'],
msg: ['请选择商品分类'], msg: ['请选择商品分类'],
},{ },
{
name: 'minSellPrice', name: 'minSellPrice',
rule: ['required'], rule: ['required'],
msg: ['请输入最小销售价'], msg: ['请输入最小销售价'],
},{ },
{
name: 'maxSellPrice', name: 'maxSellPrice',
rule: ['required'], rule: ['required'],
msg: ['请输入最大销售价'], msg: ['请输入最大销售价'],
}, },
{ {
name: 'unit', name: 'unit',
rule: ['required'], rule: ['required'],
msg: ['请选择单位'], msg: ['请选择单位'],
}, },
{ {
name: 'image', name: 'image',
rule: ['required'], rule: ['required'],
msg: ['请选择商品图片'], msg: ['请选择商品图片'],
}, },
] ],
}) })
let productInfo = reactive({ const productInfo = reactive({
id:"", id: '',
name:"",// 商品名称 name: '', // 商品名称
// mobile:"", // 联系方式 // mobile:"", // 联系方式
category:"", // 分类 category: '', // 分类
minSellPrice:"", // 最小销售价 minSellPrice: '', // 最小销售价
maxSellPrice: "", // 最大销售价 maxSellPrice: '', // 最大销售价
unit: "", // 单位 unit: '', // 单位
unitCode:"", // 单位编码 unitCode: '', // 单位编码
enterpriseId:"", // 企业ID enterpriseId: '', // 企业ID
image:"" image: '',
}) })
function getGoodsQueryById(){ function getGoodsQueryById() {
NongzhiAPI.getGoodsQueryById({enterpriseId:enterpriseId}).then((res) => { NongzhiAPI.getGoodsQueryById({ enterpriseId }).then((res) => {
pageData.enterpriseProduct = res; pageData.enterpriseProduct = res
}) })
} }
// 文件上传 // 文件上传
function handleUpload(file) { function handleUpload(file) {
const tempFilePaths = file.tempFilePaths; const tempFilePaths = file.tempFilePaths
// 处理每张选中的图片 // 处理每张选中的图片
for(let i = 0; i < tempFilePaths.length; i++){ for (let i = 0; i < tempFilePaths.length; i++) {
uni.uploadFile({ uni.uploadFile({
url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: tempFilePaths[i], filePath: tempFilePaths[i],
name: 'file', name: 'file',
formData: { formData: {
biz: 'temp', biz: 'temp',
}, },
header: { header: {
'X-Access-Token': userStore.getToken, 'X-Access-Token': userStore.getToken,
}, },
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
const data = JSON.parse(res.data) const data = JSON.parse(res.data)
if (data.code === 200 || data.code === 0) { if (data.code === 200 || data.code === 0) {
toastRef.value.show({ toastRef.value.show({
type: 'success', type: 'success',
text: '上传成功', text: '上传成功',
}) })
pageData.productImageArr[0] = data.message // 保存返回的图片信息 pageData.productImageArr[0] = data.message // 保存返回的图片信息
} }
} }
}, },
fail: (err) => { fail: (err) => {
toastRef.value.show({ toastRef.value.show({
type: 'error', type: 'error',
text: '上传失败', text: '上传失败',
}) })
uploadRef.value.clearFiles() uploadRef.value.clearFiles()
pageData.productImageArr[0] = null pageData.productImageArr[0] = null
},
}, })
}) }
} }
} // 文件删除
// 文件删除 function handleDelete(file, type) {
function handleDelete(file,type) { uploadRef.value.clearFiles()
uploadRef.value.clearFiles() pageData.productImageArr[0] = null
pageData.productImageArr[0] = null }
} function changeCategory(e) {
function changeCategory(e){ productInfo.category = e.value
productInfo.category = e.value; pageData.categoryPopup = false
pageData.categoryPopup = false; }
} function selectCompleteUnit(e) {
function selectCompleteUnit(e){ productInfo.unit = e.text[e.text.length - 1]
productInfo.unit = e.text[e.text.length-1]; pageData.unitPopup = false
pageData.unitPopup = false; }
} function changeUnit(e) {
function changeUnit(e){ const val = e.value
let val = e.value; queryByCategoryAndCode(val, e)
queryByCategoryAndCode(val,e); }
} function handleSelectCategory() {
function handleSelectCategory(){ pageData.categoryPopup = true
pageData.categoryPopup = true; }
} function handleSelectUnit() {
function handleSelectUnit(){ pageData.unitPopup = true
pageData.unitPopup = true; }
} // 查询商品分类
// 查询商品分类 function queryByCategory() {
function queryByCategory(){ LinghuoyonggongAPI.gitListByCodeDict({ code: 'category' }).then((res) => {
LinghuoyonggongAPI.gitListByCodeDict({ code : 'category'}).then(res=>{ pageData.categoryOptions = res
pageData.categoryOptions = res; const textArr = []
let textArr = []; for (let i = 0; i < res.length; i++) {
for(let i = 0; i < res.length; i++){ textArr.push(res[i].itemText)
textArr.push(res[i].itemText); }
} pageData.categoryText = textArr
pageData.categoryText = textArr; })
}) }
} // 查询单位字典
// 查询单位字典 function queryByCategoryAndCode(code, e) {
function queryByCategoryAndCode(code,e){ LinghuoyonggongAPI.queryByCategoryAndCode({ category: 2, code }).then((res) => {
LinghuoyonggongAPI.queryByCategoryAndCode({ category : 2,code : code}).then(res=>{ if (res.length) {
if(res.length){ const dataArr = []
let dataArr = []; for (let i = 0; i < res.length; i++) {
for(let i = 0; i < res.length; i++){ const obj = { text: '', value: '' }
let obj = {text:"",value:""}; obj.text = res[i].name
obj.text = res[i].name; obj.value = res[i].code
obj.value = res[i].code; dataArr.push(obj)
dataArr.push(obj); }
} if (!pageData.unitOptions.length) {
if(!pageData.unitOptions.length){ pageData.unitOptions = dataArr
pageData.unitOptions = dataArr; } else {
}else{ unitPopupRef.value.setRequestData(dataArr, e.layer)
unitPopupRef.value.setRequestData(dataArr, e.layer); }
} } else {
}else{ unitPopupRef.value.end()
unitPopupRef.value.end(); }
} })
}) }
}
// 发布
// 发布 const formRef = ref()
const formRef = ref() function addData() {
function addData(){ productInfo.image = pageData.productImageArr[0]
productInfo.image = pageData.productImageArr[0]; formRef.value.validator(productInfo, pageData.rules, true).then((res) => {
formRef.value.validator(productInfo, pageData.rules, true).then((res) => { if (res.isPassed) {
if (res.isPassed) { NongzhiAPI.postGoodsAdd(productInfo).then((res) => {
NongzhiAPI.postGoodsAdd(productInfo).then((res) => { toastRef.value.show({
toastRef.value.show({ type: 'success',
type: 'success', text: '发布成功',
text: '发布成功', })
}) pageData.isPopupShow = false
pageData.isPopupShow = false; setTimeout(() => {
setTimeout(()=>{ getGoodsQueryById()
getGoodsQueryById(); }, 500)
},500) })
}) }
} })
}) }
function getDetailData(id) {
} NongzhiAPI.getEnterpriseDetail({ id }).then((res) => {
function getDetailData(id){ pageData.enterpriseCers = res.enterpriseCers.split(',')
NongzhiAPI.getEnterpriseDetail({ id }).then((res) => { pageData.data = res
pageData.enterpriseCers = res.enterpriseCers.split(","); pageData.contactName =
pageData.data = res; res.contactPerson.substring(0, 1) + Array.from({ length: res.contactPerson.length }).join('*')
pageData.contactName = res.contactPerson.substring(0,1) + new Array(res.contactPerson.length).join('*'); productInfo.unitCode = res.enterpriseCode
productInfo.unitCode = res.enterpriseCode; productInfo.enterpriseId = res.id
productInfo.enterpriseId = res.id; })
}) }
} function getBgColor(index: any) {
function getBgColor(index:any){ if (index < 6) {
if(index < 6){ return bgColorData[index]
return bgColorData[index]; } else {
}else{ return bgColorData[Math.floor(Math.random() * 5)]
return bgColorData[Math.floor(Math.random() * 5)]; }
} }
} function handlePublish() {
function handlePublish() { productInfo.id = ''
productInfo.id = ""; productInfo.name = ''
productInfo.name = ""; // productInfo.mobile = "";
// productInfo.mobile = ""; productInfo.category = ''
productInfo.category = ""; productInfo.minSellPrice = ''
productInfo.minSellPrice = ""; productInfo.maxSellPrice = ''
productInfo.maxSellPrice = ""; productInfo.unit = ''
productInfo.unit = ""; productInfo.image = ''
productInfo.image = ""; pageData.productImageArr = []
pageData.productImageArr = []; pageData.isPopupShow = true
pageData.isPopupShow = true; }
} function makePhoneCall() {
function makePhoneCall(){ uni.makePhoneCall({
uni.makePhoneCall({ phoneNumber: pageData.data.contactMobile,
phoneNumber: pageData.data.contactMobile })
}); }
}
</script> </script>
<template> <template>
<view class="w-full bg-#E6F5E8 detail_page"> <view class="w-full bg-#E6F5E8 detail_page">
<view class="module_width top_content"> <view class="module_width top_content">
<view class="enterprise_logo_view"><image class="enterprise_logo" mode="heightFix" :src="pageData.data.enterpriseLogoUrl" /></view> <view class="enterprise_logo_view"
<view class="enterprise_business">主营:{{pageData.data.businessScope}}</view> ><image class="enterprise_logo" mode="heightFix" :src="pageData.data.enterpriseLogoUrl"
<view class="enterprise_description">{{pageData.data.profile}}</view> /></view>
</view> <view class="enterprise_business">主营:{{ pageData.data.businessScope }}</view>
<view class="module_width middle_content"> <view class="enterprise_description">{{ pageData.data.profile }}</view>
<view class="module_title">资质证书</view> </view>
<view class="module_separate"></view> <view class="module_width middle_content">
<view class="module_qualification"> <view class="module_title">资质证书</view>
<view class="qualification_item" :style="`height:126rpx;background:${getBgColor(index)}`" v-for="(item,index) in pageData.enterpriseCers" :key="index"> <view class="module_separate" />
<image class="enterprise_logo" mode="heightFix" :src="item" /> <view class="module_qualification">
<!-- <view class="qualification_name ellipsis">{{item}}</view> --> <view
</view> class="qualification_item"
</view> :style="`height:126rpx;background:${getBgColor(index)}`"
</view> v-for="(item, index) in pageData.enterpriseCers"
<view class="module_width footer_content"> :key="index"
<view class="module_title">主营产品</view> >
<view class="module_separate"></view> <image class="enterprise_logo" mode="heightFix" :src="item" />
<view class="module_business"> <!-- <view class="qualification_name ellipsis">{{item}}</view> -->
<view class="business_item" v-for="item in pageData.enterpriseProduct" :key="item.id"> </view>
<image class="business_img" mode="heightFix" :src="item.image" /> </view>
<view class="qualification_name ellipsis">{{item.name}}</view> </view>
<view class="qualification_price ellipsis">¥{{item.minSellPrice}}<text> ~ </text> {{item.maxSellPrice}}<text class="qualification_text">/{{item.unit}}</text></view> <view class="module_width footer_content">
</view> <view class="module_title">主营产品</view>
</view> <view class="module_separate" />
</view> <view class="module_business">
<view class="business_item" v-for="item in pageData.enterpriseProduct" :key="item.id">
<view class="make-phone-view"> <image class="business_img" mode="heightFix" :src="item.image" />
<fui-button text="我要购买" bold radius="96rpx" @click="pageData.showConfirmDialog=true;" height="80rpx"/> <view class="qualification_name ellipsis">{{ item.name }}</view>
</view> <view class="qualification_price ellipsis"
>¥{{ item.minSellPrice }}<text> ~ </text> {{ item.maxSellPrice
</view> }}<text class="qualification_text">/{{ item.unit }}</text></view
<!-- 确认对话框 --> >
<ConfirmDialog </view>
v-model:show="pageData.showConfirmDialog" </view>
title="温馨提示" </view>
:content="`你将与${pageData.contactName}进行电话沟通,若继续,请点击确认按钮!`"
cancelText="取消" <view class="make-phone-view">
confirmText="确认" <fui-button text="我要购买" bold radius="96rpx" @click="pageData.showConfirmDialog = true" height="80rpx" />
@confirm="makePhoneCall" </view>
/> </view>
<!-- 确认对话框 -->
<fui-fab position="right" distance="10" bottom="240" width="120" @click="handlePublish"> <ConfirmDialog
<view class="text-white text-center"> v-model:show="pageData.showConfirmDialog"
<view class="fab-icon" /> title="温馨提示"
<view style="font-size: 24rpx">发布产品</view> :content="`你将与${pageData.contactName}进行电话沟通,若继续,请点击确认按钮!`"
</view> cancelText="取消"
</fui-fab> confirmText="确认"
@confirm="makePhoneCall"
<fui-bottom-popup :show="pageData.isPopupShow" @close="pageData.isPopupShow = false"> />
<view class="fui-custom__wrap yr_person_popup">
<view class="popup_top"> <fui-fab position="right" distance="10" bottom="240" width="120" @click="handlePublish">
<uni-icons type="left" size="24" color="#333333" @click="pageData.isPopupShow = false"></uni-icons> <view class="text-white text-center">
<view class="add_person_text" style="font-size:36rpx;">产品信息</view> <view class="fab-icon" />
<view class="del_person_btn"></view> <view style="font-size: 24rpx">发布产品</view>
</view> </view>
<view class="popup_content"> </fui-fab>
<fui-form label-weight="auto" ref="formRef" top="10">
<fui-input required label="商品名称" placeholder="请输入商品名称" v-model="productInfo.name" label-width="212" size="28"></fui-input> <fui-bottom-popup :show="pageData.isPopupShow" @close="pageData.isPopupShow = false">
<view class="fui-custom__wrap yr_person_popup">
<fui-input @click="handleSelectCategory" required label="商品分类" placeholder="请选择商品分类" disabled :value="productInfo.category" label-width="212" size="28"></fui-input> <view class="popup_top">
<uni-icons type="left" size="24" color="#333333" @click="pageData.isPopupShow = false" />
<view class="add_person_text" style="font-size: 36rpx">产品信息</view>
<view class="del_person_btn" />
</view>
<view class="popup_content">
<fui-form label-weight="auto" ref="formRef" top="10">
<fui-input
required
label="商品名称"
placeholder="请输入商品名称"
v-model="productInfo.name"
label-width="212"
size="28"
/>
<!-- <fui-input required maxlength="11" label="联系电话" placeholder="请输入联系电话" v-model="productInfo.mobile" label-width="212" size="28"></fui-input> --> <fui-input
<fui-form-item asterisk label="价格(元)" label-width="212" size="28"> @click="handleSelectCategory"
<fui-input type="number" v-model="productInfo.minSellPrice" style="width: 120rpx !important" :borderBottom="false" :padding="[0]" placeholder="最低价" size="28"></fui-input> required
<template v-slot:right> label="商品分类"
<view style="color: #CCCCCC;margin-right: 40rpx;"></view> placeholder="请选择商品分类"
<fui-input v-model="productInfo.maxSellPrice" type="number" style="width: 120rpx !important;" :borderBottom="false" :padding="[0]" placeholder="最高价" size="28"></fui-input> disabled
<fui-text v-if="productInfo.unit==''" size="28" text="单位" color="#cccccc" @click="handleSelectUnit()"></fui-text> :value="productInfo.category"
<fui-text v-else :text="productInfo.unit" size="28" @click="handleSelectUnit()"></fui-text> label-width="212"
</template> size="28"
</fui-form-item> />
<fui-form-item asterisk label="商品图片" :bottomBorder="false"> <!-- <fui-input required maxlength="11" label="联系电话" placeholder="请输入联系电话" v-model="productInfo.mobile" label-width="212" size="28"></fui-input> -->
<template v-slot:vertical> <fui-form-item asterisk label="价格(元)" label-width="212" size="28">
<uni-file-picker :value="pageData.productImageArr" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete"/> <fui-input
</template> type="number"
</fui-form-item> v-model="productInfo.minSellPrice"
</fui-form> style="width: 120rpx !important"
</view> :borderBottom="false"
<fui-button style="margin-top:36rpx;" text="保存" bold radius="96rpx" @click="addData" height="80rpx"/> :padding="[0]"
</view> placeholder="最低价"
</fui-bottom-popup> size="28"
/>
<fui-bottom-popup :show="pageData.unitPopup"> <template #right>
<view class="fui-scroll__wrap"> <view style="color: #cccccc; margin-right: 40rpx"></view>
<view class="fui-title">请选择</view> <fui-input
<fui-cascader ref="unitPopupRef" :value="pageData.unitVal" stepLoading @change="changeUnit" @complete="selectCompleteUnit" :options="pageData.unitOptions"></fui-cascader> v-model="productInfo.maxSellPrice"
<view class="fui-icon__close" @tap.stop="pageData.unitPopup=false"> type="number"
<fui-icon name="close" :size="48"></fui-icon> style="width: 120rpx !important"
</view> :borderBottom="false"
</view> :padding="[0]"
</fui-bottom-popup> placeholder="最高价"
size="28"
<fui-picker :options="pageData.categoryText" layer="1" :show="pageData.categoryPopup" @change="changeCategory" @cancel="pageData.categoryPopup = false" zIndex="9999"></fui-picker> />
<fui-text
v-if="productInfo.unit == ''"
<fui-toast ref="toastRef" /> size="28"
text="单位"
color="#cccccc"
@click="handleSelectUnit()"
/>
<fui-text v-else :text="productInfo.unit" size="28" @click="handleSelectUnit()" />
</template>
</fui-form-item>
<fui-form-item asterisk label="商品图片" :bottomBorder="false">
<template #vertical>
<uni-file-picker
:value="pageData.productImageArr"
ref="uploadRef"
limit="1"
:auto-upload="false"
@select="handleUpload"
@delete="handleDelete"
/>
</template>
</fui-form-item>
</fui-form>
</view>
<fui-button style="margin-top: 36rpx" text="保存" bold radius="96rpx" @click="addData" height="80rpx" />
</view>
</fui-bottom-popup>
<fui-bottom-popup :show="pageData.unitPopup">
<view class="fui-scroll__wrap">
<view class="fui-title">请选择</view>
<fui-cascader
ref="unitPopupRef"
:value="pageData.unitVal"
stepLoading
@change="changeUnit"
@complete="selectCompleteUnit"
:options="pageData.unitOptions"
/>
<view class="fui-icon__close" @tap.stop="pageData.unitPopup = false">
<fui-icon name="close" :size="48" />
</view>
</view>
</fui-bottom-popup>
<fui-picker
:options="pageData.categoryText"
layer="1"
:show="pageData.categoryPopup"
@change="changeCategory"
@cancel="pageData.categoryPopup = false"
zIndex="9999"
/>
<fui-toast ref="toastRef" />
</template> </template>
<style lang="less" scoped> <style lang="less" scoped>
.detail_page{ .detail_page {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: center; justify-content: center;
align-items: flex-start; align-items: flex-start;
align-content: flex-start; align-content: flex-start;
padding-bottom: 40rpx; padding-bottom: 40rpx;
min-height: calc(100vh - 88rpx); min-height: calc(100vh - 88rpx);
.module_width{ .module_width {
width: 690rpx; width: 690rpx;
margin-top: 24rpx; margin-top: 24rpx;
background: #FFFFFF; background: #ffffff;
border-radius: 20rpx; border-radius: 20rpx;
padding:28rpx; padding: 28rpx;
box-sizing: border-box; box-sizing: border-box;
} }
.ellipsis{ .ellipsis {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.top_content{ .top_content {
.enterprise_logo_view{ .enterprise_logo_view {
width: 630rpx; width: 630rpx;
display:flex; display: flex;
align-items: flex-start; align-items: flex-start;
.enterprise_logo{ .enterprise_logo {
height: 80rpx; height: 80rpx;
} }
} }
.enterprise_business{ .enterprise_business {
width: 636rpx; width: 636rpx;
padding:8rpx 20rpx; padding: 8rpx 20rpx;
border-radius: 8rpx; border-radius: 8rpx;
background: linear-gradient(233.81deg, rgba(92, 181, 110, 1) 0%, rgba(100, 214, 62, 1) 100%); background: linear-gradient(233.81deg, rgba(92, 181, 110, 1) 0%, rgba(100, 214, 62, 1) 100%);
font-size: 24rpx; font-size: 24rpx;
font-weight: 500; font-weight: 500;
line-height: 40rpx; line-height: 40rpx;
color: #FFFFFF; color: #ffffff;
margin-top: 32rpx; margin-top: 32rpx;
} }
.enterprise_description{ .enterprise_description {
margin-top: 20rpx; margin-top: 20rpx;
font-size: 24rpx; font-size: 24rpx;
font-weight: 400; font-weight: 400;
letter-spacing: 0px; letter-spacing: 0px;
line-height: 40rpx; line-height: 40rpx;
color: #333333; color: #333333;
text-align: justify; text-align: justify;
vertical-align: middle; vertical-align: middle;
text-indent: 2em; text-indent: 2em;
} }
} }
.middle_content{ .middle_content {
}
} .module_title {
.module_title{ font-size: 32rpx;
font-size: 32rpx; font-weight: 500;
font-weight: 500; line-height: 40rpx;
line-height: 40rpx; color: #333333;
color: #333333; text-align: justify;
text-align: justify; vertical-align: middle;
vertical-align: middle; }
} .module_separate {
.module_separate{ margin-top: 20rpx;
margin-top: 20rpx; width: 128rpx;
width: 128rpx; height: 6rpx;
height: 6rpx; opacity: 1;
opacity: 1; background: linear-gradient(233.81deg, #5cb56e 0%, #64d63e 100%);
background: linear-gradient(233.81deg, #5CB56E 0%, #64D63E 100%); }
} .module_qualification {
.module_qualification{ margin-top: 6rpx;
margin-top: 6rpx; display: flex;
display: flex; flex-wrap: wrap;
flex-wrap: wrap; align-items: flex-start;
align-items: flex-start; align-content: flex-start;
align-content: flex-start; .qualification_item {
.qualification_item{ width: 198rpx;
width: 198rpx; height: 166rpx;
height: 166rpx; margin-left: 20rpx;
margin-left: 20rpx; margin-top: 26rpx;
margin-top: 26rpx; border-radius: 8rpx;
border-radius: 8rpx; padding-top: 8rpx;
padding-top: 8rpx; box-sizing: border-box;
box-sizing: border-box; display: flex;
display: flex; flex-wrap: wrap;
flex-wrap: wrap; justify-content: center;
justify-content: center; .enterprise_logo {
.enterprise_logo{ height: 114rpx;
height: 114rpx; max-width: 160rpx;
max-width: 160rpx; }
} .qualification_name {
.qualification_name{ height: 40rpx;
height: 40rpx; line-height: 40rpx;
line-height: 40rpx; font-size: 20rpx;
font-size: 20rpx; color: #333333;
color: #333333; max-width: 160rpx;
max-width: 160rpx; }
} }
} .qualification_item:nth-child(3n + 1) {
.qualification_item:nth-child(3n+1){ margin-left: 0rpx;
margin-left: 0rpx; }
} }
}
.footer_content {
.footer_content{ margin-bottom: 100rpx;
margin-bottom: 100rpx; }
} .module_business {
.module_business{ display: flex;
display: flex; flex-wrap: wrap;
flex-wrap: wrap; align-items: flex-start;
align-items: flex-start; align-content: flex-start;
align-content: flex-start; justify-content: space-between;
justify-content: space-between; .business_item {
.business_item{ width: 310rpx;
width: 310rpx; height: 292rpx;
height: 292rpx; margin-top: 24rpx;
margin-top: 24rpx; border-radius: 16rpx;
border-radius: 16rpx; box-sizing: border-box;
box-sizing: border-box; display: flex;
display: flex; justify-content: center;
justify-content: center; align-items: center;
align-items: center; flex-direction: column;
flex-direction: column; background: #f9fafb;
background: #F9FAFB; .business_img {
.business_img{ width: 310rpx;
width: 310rpx; height: 180rpx;
height: 180rpx; opacity: 1;
opacity: 1; border-radius: 16rpx 16rpx 0rpx 0rpx;
border-radius: 16rpx 16rpx 0rpx 0rpx; }
} .qualification_name {
.qualification_name{ height: 48rpx;
height: 48rpx; line-height: 48rpx;
line-height: 48rpx; font-size: 32rpx;
font-size: 32rpx; color: #000000;
color: #000000; max-width: 280rpx;
max-width: 280rpx; margin-top: 6rpx;
margin-top: 6rpx; }
} .qualification_price {
.qualification_price{ height: 48rpx;
height: 48rpx; width: 280rpx;
width: 280rpx; opacity: 1;
opacity: 1; font-size: 32rpx;
font-size: 32rpx; font-weight: 400;
font-weight: 400; letter-spacing: 0px;
letter-spacing: 0px; line-height: 48rpx;
line-height: 48rpx; text-align: center;
text-align: center; color: #5db66f;
color: #5DB66F; .qualification_text {
.qualification_text{ font-size: 12px;
font-size: 12px; }
} }
} }
} .business_item:nth-child(odd) {
.business_item:nth-child(odd){ margin-left: 0rpx;
margin-left: 0rpx; }
} }
} }
} ::v-deep .fui-fab__btn-main {
::v-deep .fui-fab__btn-main { background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important;
background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important; box-shadow: 0px 1px 8px #5db66f;
box-shadow: 0px 1px 8px #5db66f; }
}
.fui-scroll__wrap { .fui-scroll__wrap {
padding-top: 30rpx; padding-top: 30rpx;
position: relative; position: relative;
} }
.fui-title { .fui-title {
font-size: 30rpx; font-size: 30rpx;
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
padding-bottom: 24rpx; padding-bottom: 24rpx;
} }
.fui-icon__close { .fui-icon__close {
position: absolute; position: absolute;
top: 24rpx; top: 24rpx;
right: 24rpx; right: 24rpx;
} }
.make-phone-view{ .make-phone-view {
width: 690rpx; width: 690rpx;
height: 80rpx; height: 80rpx;
position: fixed; position: fixed;
left: 30rpx; left: 30rpx;
bottom: 20rpx; bottom: 20rpx;
} }
</style> </style>
<script setup lang="ts"> <script setup lang="ts">
import { onLoad, onPullDownRefresh, onShow } from '@dcloudio/uni-app' import { onPullDownRefresh, onShow } from '@dcloudio/uni-app'
import Navigate from '@/utils/page/navigate' import { reactive } from 'vue'
import { reactive, ref } from 'vue' import Navigate from '@/utils/page/navigate'
import * as NongzhiAPI from '@/api/model/nongzhi' import * as NongzhiAPI from '@/api/model/nongzhi'
onPullDownRefresh(() => {
resetData() onPullDownRefresh(() => {
getList(pageData.params) resetData()
}) getList(pageData.params)
})
onShow(() => {
resetData() onShow(() => {
getList(pageData.params) resetData()
}) getList(pageData.params)
})
onNavigationBarButtonTap(() => {
Navigate.to('/pages/kexinnongzi/shenqingruzhu') onNavigationBarButtonTap(() => {
}) Navigate.to('/pages/kexinnongzi/shenqingruzhu')
})
const pageData = reactive({ const pageData = reactive({
params: { params: {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
bizCategory:2, bizCategory: 2,
reviewStatus:1 reviewStatus: 1,
}, // 分页参数 }, // 分页参数
hasMore: true, // 是否还有更多数据 hasMore: true, // 是否还有更多数据
loading: false, // 是否正在加载 loading: false, // 是否正在加载
dataList:[] dataList: [],
}) })
async function getList(params) { async function getList(params) {
if (pageData.loading) return if (pageData.loading)
return
pageData.loading = true pageData.loading = true
await NongzhiAPI.getEnterpriseList(params).then((res) => { await NongzhiAPI.getEnterpriseList(params).then((res) => {
if (res.records.length > 0) { if (res.records.length > 0) {
...@@ -48,10 +50,9 @@ ...@@ -48,10 +50,9 @@
pageData.loading = false pageData.loading = false
} }
function toDetail(item) { function toDetail(item) {
let param = encodeURIComponent(JSON.stringify({id:item.id,name:item.enterpriseName})); const param = encodeURIComponent(JSON.stringify({ id: item.id, name: item.enterpriseName }))
Navigate.to(`/pages/kexinnongzi/detail?param=${param}`) Navigate.to(`/pages/kexinnongzi/detail?param=${param}`)
} }
function resetData() { function resetData() {
...@@ -71,25 +72,24 @@ ...@@ -71,25 +72,24 @@
@scrolltolower="getList(pageData.params)" @scrolltolower="getList(pageData.params)"
:show-scrollbar="false" :show-scrollbar="false"
> >
<view class="top_img"> <view class="top_img">
<image class="agr_sup_img" src="/static/images/comm/agr_sup_img.png" /> <image class="agr_sup_img" src="/static/images/comm/agr_sup_img.png" />
</view> </view>
<view class="page_content"> <view class="page_content">
<view class="item_list" v-for="item in pageData.dataList" :key="item.id"> <view class="item_list" v-for="item in pageData.dataList" :key="item.id">
<view class="item_left"> <view class="item_left">
<image class="enterprise_logo" mode="aspectFit" :src="item.enterpriseLogoUrl" /> <image class="enterprise_logo" mode="aspectFit" :src="item.enterpriseLogoUrl" />
</view> </view>
<view class="item_right"> <view class="item_right">
<view class="item_name ellipsis">{{item.enterpriseName}}</view> <view class="item_name ellipsis">{{ item.enterpriseName }}</view>
<view class="item_description ellipsis">{{item.businessScope}}</view> <view class="item_description ellipsis">{{ item.businessScope }}</view>
<view class="item_details"> <view class="item_details">
<view class="detail_btn" @click="toDetail(item)">查看详情</view> <view class="detail_btn" @click="toDetail(item)">查看详情</view>
</view> </view>
</view> </view>
</view> </view>
</view>
</view>
<!-- 加载状态 --> <!-- 加载状态 -->
<view class="loading-status"> <view class="loading-status">
<text v-if="pageData.loading">加载中...</text> <text v-if="pageData.loading">加载中...</text>
...@@ -101,79 +101,78 @@ ...@@ -101,79 +101,78 @@
</template> </template>
<style lang="less" scoped> <style lang="less" scoped>
.yr_page_view{ .yr_page_view {
padding: 28rpx; padding: 28rpx;
.top_img,.agr_sup_img{ .top_img,
height: 280rpx; .agr_sup_img {
width: 690rpx; height: 280rpx;
} width: 690rpx;
.top_img{ }
margin-bottom: 24rpx; .top_img {
} margin-bottom: 24rpx;
.page_content{ }
border-radius: 16rpx; .page_content {
background: #FFFFFF; border-radius: 16rpx;
} background: #ffffff;
.ellipsis{ }
width: 200px; .ellipsis {
white-space: nowrap; width: 200px;
overflow: hidden; white-space: nowrap;
text-overflow: ellipsis; overflow: hidden;
} text-overflow: ellipsis;
}
.item_list{ .item_list {
display: flex; display: flex;
align-items:flex-start; align-items: flex-start;
justify-content: space-between; justify-content: space-between;
padding-left: 24rpx; padding-left: 24rpx;
padding-right: 30rpx; padding-right: 30rpx;
padding-bottom: 24rpx; padding-bottom: 24rpx;
padding-top: 24rpx; padding-top: 24rpx;
border-bottom: 2rpx solid #EEEEEE; border-bottom: 2rpx solid #eeeeee;
.item_left,.enterprise_logo{ .item_left,
width: 192rpx; .enterprise_logo {
max-height: 160rpx; width: 192rpx;
} max-height: 160rpx;
.item_right{ }
width: 436rpx; .item_right {
.item_name{ width: 436rpx;
font-size: 32rpx; .item_name {
font-weight: 500; font-size: 32rpx;
color: #333333; font-weight: 500;
} color: #333333;
.item_description{ }
font-size: 24rpx; .item_description {
font-weight: 400; font-size: 24rpx;
color: #999999; font-weight: 400;
margin-top: 16rpx; color: #999999;
margin-bottom: 12rpx; margin-top: 16rpx;
} margin-bottom: 12rpx;
.item_details{ }
display: flex; .item_details {
justify-content: flex-end; display: flex;
} justify-content: flex-end;
.detail_btn{ }
border-radius: 100rpx; .detail_btn {
background: #5DB66F; border-radius: 100rpx;
display: flex; background: #5db66f;
justify-content: center; display: flex;
align-items: center; justify-content: center;
padding: 20rpx; align-items: center;
width: 136rpx; padding: 20rpx;
height: 48rpx; width: 136rpx;
font-size: 24rpx; height: 48rpx;
font-weight: 400; font-size: 24rpx;
color: #FFFFFF; font-weight: 400;
} color: #ffffff;
} }
} }
.item_list:last-child{ }
border-bottom: none; .item_list:last-child {
} border-bottom: none;
}
}
}
.loading-status { .loading-status {
text-align: center; text-align: center;
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive, toRefs,ref } from 'vue' import { reactive, ref, toRefs } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import * as UserInfoAPI from '@/api/model/userInfo' import * as NongzhiAPI from '@/api/model/nongzhi'
import * as NongzhiAPI from '@/api/model/nongzhi'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore() const dictStore = useDictStore()
...@@ -14,15 +13,14 @@ ...@@ -14,15 +13,14 @@
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
onLoad((option) => { onLoad((option) => {
// 获取数据详情 // 获取数据详情
getProvince(0,null); getProvince(0, null)
}) })
// 勾选协议校验
//勾选协议校验 function checkAgree(agree) {
function checkAgree(agree) { return agree
return agree }
} const areaPopupRef = ref(null)
const areaPopupRef = ref(null);
const pageData = reactive({ const pageData = reactive({
loading: false, loading: false,
show: { show: {
...@@ -34,215 +32,222 @@ ...@@ -34,215 +32,222 @@
}, },
options: { options: {
area: [], area: [],
areaVal:[], areaVal: [],
urgentdegree: [], urgentdegree: [],
type: [], type: [],
}, },
cersImageIndex:0, cersImageIndex: 0,
cersImageArr:[], cersImageArr: [],
enterpriseLogoArr:[], enterpriseLogoArr: [],
selectAreaVal:[], selectAreaVal: [],
form: { form: {
id: '', id: '',
enterpriseName:"",// 企业名称 enterpriseName: '', // 企业名称
enterpriseCode:"",// 企业编码 enterpriseCode: '', // 企业编码
businessScope:"", // 企业经营范围 businessScope: '', // 企业经营范围
contactPerson:"", // 联系人 contactPerson: '', // 联系人
contactMobile:"", // 联系人手机号 contactMobile: '', // 联系人手机号
profile:"", // 企业简介 profile: '', // 企业简介
provinceName:"", // 省 provinceName: '', // 省
cityName:"", // 市 cityName: '', // 市
districtName:"", // 区县 districtName: '', // 区县
townName:"", // 乡镇 townName: '', // 乡镇
provinceCode:"", // 省 provinceCode: '', // 省
cityCode:"", // 市 cityCode: '', // 市
districtCode:"", // 区县 districtCode: '', // 区县
townCode:"", // 乡镇 townCode: '', // 乡镇
addr: '', // 详细地址
addr:"", // 详细地址 lon: '', // 经度
lon:"", // 经度 lat: '', // 纬度
lat:'', // 纬度 bizCategory: 2, // 业务分类【1:代理记账、2:农资、3:农机、4:金融】
bizCategory: 2, // 业务分类【1:代理记账、2:农资、3:农机、4:金融】 enterpriseLogoUrl: null, // 企业logo url
enterpriseLogoUrl:null, // 企业logo url enterpriseCers: null, // 企业资质url
enterpriseCers:null, // 企业资质url
areaText: '',
agree: false,
areaText: '',
agree:false,
}, },
position: [], position: [],
rules: [ rules: [
{ {
name: 'enterpriseName', name: 'enterpriseName',
rule: ['required'], rule: ['required'],
msg: ['请输入公司名称'], msg: ['请输入公司名称'],
}, { },
{
name: 'enterpriseCode', name: 'enterpriseCode',
rule: ['required'], rule: ['required'],
msg: ['请输入企业编码'], msg: ['请输入企业编码'],
}, { },
{
name: 'businessScope', name: 'businessScope',
rule: ['required'], rule: ['required'],
msg: ['请输入经营业务'], msg: ['请输入经营业务'],
},{ },
{
name: 'profile', name: 'profile',
rule: ['required'], rule: ['required'],
msg: ['请输入平台介绍'], msg: ['请输入平台介绍'],
},{ },
{
name: 'areaText', name: 'areaText',
rule: ['required'], rule: ['required'],
msg: ['请选择地区'], msg: ['请选择地区'],
},{ },
{
name: 'addr', name: 'addr',
rule: ['required'], rule: ['required'],
msg: ['请输入详细地址'], msg: ['请输入详细地址'],
},{ },
{
name: 'contactPerson', name: 'contactPerson',
rule: ['required'], rule: ['required'],
msg: ['请输入联系人'], msg: ['请输入联系人'],
},{ },
name: "contactMobile", {
rule: ["required", "isMobile"], name: 'contactMobile',
msg: ["请输入联系电话", "请输入正确的联系电话"] rule: ['required', 'isMobile'],
},{ msg: ['请输入联系电话', '请输入正确的联系电话'],
},
{
name: 'enterpriseLogoUrl', name: 'enterpriseLogoUrl',
rule: ['required'], rule: ['required'],
msg: ['请上传公司logo'], msg: ['请上传公司logo'],
},{ },
{
name: 'enterpriseCers', name: 'enterpriseCers',
rule: ['required'], rule: ['required'],
msg: ['请上传公司资质证件'], msg: ['请上传公司资质证件'],
},{ },
name: "agree", {
validator: [{ name: 'agree',
msg: "请勾选并同意《入驻协议》与《服务条款》", validator: [
method: checkAgree {
}] msg: '请勾选并同意《入驻协议》与《服务条款》',
} method: checkAgree,
},
],
},
], ],
}) })
function agreeChange(e) { function agreeChange(e) {
pageData.form.agree = e.checked; pageData.form.agree = e.checked
} }
// 选择地区完成 // 选择地区完成
function selectCompleteArea(e){ function selectCompleteArea(e) {
let areaAttr = ['province','city','district','town']; const areaAttr = ['province', 'city', 'district', 'town']
let text = e.text; const text = e.text
let value = e.value; const value = e.value
let formData = pageData.form; const formData = pageData.form
for(let i = 0; i < text.length;i++){ for (let i = 0; i < text.length; i++) {
formData[areaAttr[i]+'Name'] = text[i]; formData[`${areaAttr[i]}Name`] = text[i]
formData[areaAttr[i]+'Code'] = value[i]; formData[`${areaAttr[i]}Code`] = value[i]
} }
pageData.form.areaText= text.join(''); pageData.form.areaText = text.join('')
pageData.show.area = false; pageData.show.area = false
} }
// 在选择地区 // 在选择地区
function changeArea(e){ function changeArea(e) {
let val = e.value; const val = e.value
getProvince(val,e); getProvince(val, e)
} }
// 获取下一级地区 // 获取下一级地区
function getProvince(code,e) { function getProvince(code, e) {
LinghuoyonggongAPI.queryConditions({ parentCode : code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: code }).then((res) => {
if(res.length){ if (res.length) {
let dataArr = []; const dataArr = []
for(let i = 0; i < res.length; i++){ for (let i = 0; i < res.length; i++) {
let obj = {text:"",value:""}; const obj = { text: '', value: '' }
obj.text = res[i].name; obj.text = res[i].name
obj.value = res[i].code; obj.value = res[i].code
dataArr.push(obj); dataArr.push(obj)
} }
if(!pageData.options.area.length){ if (!pageData.options.area.length) {
pageData.options.area = dataArr; pageData.options.area = dataArr
}else{ } else {
areaPopupRef.value.setRequestData(dataArr, e.layer); areaPopupRef.value.setRequestData(dataArr, e.layer)
} }
}else{ } else {
areaPopupRef.value.end(); areaPopupRef.value.end()
} }
}) })
} }
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
const toastRef = ref() const toastRef = ref()
const uploadLogoRef = ref() const uploadLogoRef = ref()
const uploadCersRef = ref() const uploadCersRef = ref()
// 文件上传 // 文件上传
function handleUpload(file,type) { function handleUpload(file, type) {
const tempFilePaths = file.tempFilePaths; const tempFilePaths = file.tempFilePaths
// 处理每张选中的图片 // 处理每张选中的图片
for(let i = 0; i < tempFilePaths.length; i++){ for (let i = 0; i < tempFilePaths.length; i++) {
uni.uploadFile({ uni.uploadFile({
url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: tempFilePaths[i], filePath: tempFilePaths[i],
name: 'file', name: 'file',
formData: { formData: {
biz: 'temp', biz: 'temp',
}, },
header: { header: {
'X-Access-Token': userStore.getToken, 'X-Access-Token': userStore.getToken,
}, },
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
const data = JSON.parse(res.data) const data = JSON.parse(res.data)
if (data.code === 200 || data.code === 0) { if (data.code === 200 || data.code === 0) {
toastRef.value.show({ toastRef.value.show({
type: 'success', type: 'success',
text: '上传成功', text: '上传成功',
}) })
if(type == 'logo'){ if (type == 'logo') {
pageData.enterpriseLogoArr[0] = data.message // 保存返回的图片信息 pageData.enterpriseLogoArr[0] = data.message // 保存返回的图片信息
}else{ } else {
pageData.cersImageIndex++; pageData.cersImageIndex++
pageData.cersImageArr.push(data.message); pageData.cersImageArr.push(data.message)
} }
}
} }
} },
}, fail: (err) => {
fail: (err) => { toastRef.value.show({
toastRef.value.show({ type: 'error',
type: 'error', text: '上传失败',
text: '上传失败', })
}) if (type == 'logo') {
if(type == 'logo'){ uploadLogoRef.value.clearFiles()
uploadLogoRef.value.clearFiles() pageData.enterpriseLogoArr[0] = null
pageData.enterpriseLogoArr[0] = null } else {
}else{ uploadCersRef.value.clearFiles(pageData.cersImageIndex)
uploadCersRef.value.clearFiles(pageData.cersImageIndex) pageData.form.enterpriseCers = null
pageData.form.enterpriseCers = null }
} },
})
}, }
})
}
} }
// 文件删除 // 文件删除
function handleDelete(file,type) { function handleDelete(file, type) {
if(type="logo"){ if ((type = 'logo')) {
uploadLogoRef.value.clearFiles() uploadLogoRef.value.clearFiles()
pageData.enterpriseLogoArr[0] = null pageData.enterpriseLogoArr[0] = null
}else{ } else {
const num = pageData.cersImageArr.findIndex(v => v.url === file.tempFilePath); const num = pageData.cersImageArr.findIndex((v) => v.url === file.tempFilePath)
pageData.cersImageArr.splice(num, 1); pageData.cersImageArr.splice(num, 1)
} }
} }
const formRef = ref() const formRef = ref()
function submit() { function submit() {
const { lon, lat } = uni.getStorageSync('location') const { lon, lat } = uni.getStorageSync('location')
pageData.position = [lon, lat]; pageData.position = [lon, lat]
pageData.form.enterpriseLogoUrl = pageData.enterpriseLogoArr.join(''); pageData.form.enterpriseLogoUrl = pageData.enterpriseLogoArr.join('')
pageData.form.enterpriseCers = pageData.cersImageArr.join(','); pageData.form.enterpriseCers = pageData.cersImageArr.join(',')
if (pageData.position.length == 0) { if (pageData.position.length == 0) {
toastRef.value.show({ toastRef.value.show({
type: 'error', type: 'error',
...@@ -259,17 +264,17 @@ ...@@ -259,17 +264,17 @@
type: 'success', type: 'success',
text: '发布成功', text: '发布成功',
}) })
setTimeout(()=>{ setTimeout(() => {
uni.navigateBack({ uni.navigateBack({
delta: 1 // 返回的页面数 delta: 1, // 返回的页面数
}) })
},1000) }, 1000)
}) })
} }
}) })
} }
function getCurrentDate(){ function getCurrentDate() {
const date = new Date() const date = new Date()
const year = date.getFullYear() const year = date.getFullYear()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
...@@ -283,42 +288,129 @@ ...@@ -283,42 +288,129 @@
<view class="formBox"> <view class="formBox">
<fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false"> <fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false">
<view class="mt20"> <view class="mt20">
<fui-input required label="公司名称" placeholder="请输入公司名称" v-model="form.enterpriseName" labelSize="28" label-width="180" size="28"/> <fui-input
<fui-input required label="企业编码" placeholder="请输入企业编码" v-model="form.enterpriseCode" labelSize="28" label-width="180" size="28"/> required
<fui-input required label="经营业务" placeholder="请输入经营业务" v-model="form.businessScope" labelSize="28" label-width="180" size="28"/> label="公司名称"
<fui-form-item asterisk label="平台介绍" :bottomBorder="false" prop="descr" error-align="left"> placeholder="请输入公司名称"
<template v-slot:vertical> v-model="form.enterpriseName"
<fui-textarea isCounter maxlength="-1" :padding="['0','32rpx','32rpx']" :border-bottom="false" :border-top="false" size="28" labelSize="28"
placeholder="请输入平台介绍..." v-model="form.profile"></fui-textarea> label-width="180"
</template> size="28"
</fui-form-item> />
<fui-input
required
label="企业编码"
placeholder="请输入企业编码"
v-model="form.enterpriseCode"
labelSize="28"
label-width="180"
size="28"
/>
<fui-input
required
label="经营业务"
placeholder="请输入经营业务"
v-model="form.businessScope"
labelSize="28"
label-width="180"
size="28"
/>
<fui-form-item asterisk label="平台介绍" :bottomBorder="false" prop="descr" error-align="left">
<template #vertical>
<fui-textarea
isCounter
maxlength="-1"
:padding="['0', '32rpx', '32rpx']"
:border-bottom="false"
:border-top="false"
size="28"
placeholder="请输入平台介绍..."
v-model="form.profile"
/>
</template>
</fui-form-item>
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" size="28" disabled/> <fui-input
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.addr" labelSize="28" label-width="180" size="28"/> required
<fui-input required label="联系人" placeholder="请输入联系人" v-model="form.contactPerson" labelSize="28" label-width="180" size="28"/> label="地区"
<fui-input type="tel" required label="联系电话" placeholder="请输入联系电话" v-model="form.contactMobile" labelSize="28" label-width="180" size="28"></fui-input> placeholder="请选择地区"
</view> 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
type="tel"
required
label="联系电话"
placeholder="请输入联系电话"
v-model="form.contactMobile"
labelSize="28"
label-width="180"
size="28"
/>
</view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size: 28rpx"
><span style="color: red">*&nbsp;</span> 公司logo
</view>
<uni-file-picker
:value="pageData.enterpriseLogoArr"
ref="uploadLogoRef"
limit="1"
:auto-upload="false"
@select="handleUpload($event, 'logo')"
@delete="handleDelete($event, 'logo')"
/>
</view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size: 28rpx;"><span style="color: red;">*&nbsp;</span> 公司logo </view> <view class="mb-1 flex justify-start" style="font-size: 28rpx"
<uni-file-picker :value="pageData.enterpriseLogoArr" ref="uploadLogoRef" limit="1" :auto-upload="false" @select="handleUpload($event,'logo')" @delete="handleDelete($event,'logo')"/> ><span style="color: red">*&nbsp;</span> 公司资质证件
</view>
<view class="mb-1 flex justify-start" style="font-size: 24rpx; color: #cccccc"
>前6张资质证件将展示在详情页,拖拽图片可自定义排序。</view
>
<uni-file-picker
limit="9"
:value="pageData.cersImageArr"
ref="uploadCersRef"
:auto-upload="false"
@select="handleUpload($event, 'cers')"
@delete="handleDelete($event, 'cers')"
/>
</view>
<view class="fui-clause--cell fui-clause--wrap">
<fui-label>
<view class="fui-clause--cell">
<fui-checkbox :scaleRatio="0.8" @change="agreeChange" />
<text class="fui-clause--text">我已阅读并同意</text>
</view>
</fui-label>
<fui-text class="fui-color__link">《入驻协议》</fui-text>
<text></text>
<fui-text class="fui-color__link">《服务条款》</fui-text>
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size: 28rpx;"><span style="color: red;">*&nbsp;</span> 公司资质证件 </view>
<view class="mb-1 flex justify-start" style="font-size: 24rpx;color: #CCCCCC;">前6张资质证件将展示在详情页,拖拽图片可自定义排序。</view>
<uni-file-picker limit="9" :value="pageData.cersImageArr" ref="uploadCersRef" :auto-upload="false" @select="handleUpload($event,'cers')" @delete="handleDelete($event,'cers')"/>
</view>
<view class="fui-clause--cell fui-clause--wrap">
<fui-label>
<view class="fui-clause--cell">
<fui-checkbox :scaleRatio="0.8" @change="agreeChange"></fui-checkbox>
<text class="fui-clause--text">我已阅读并同意</text>
</view>
</fui-label>
<fui-text class="fui-color__link">《入驻协议》</fui-text>
<text></text>
<fui-text class="fui-color__link">《服务条款》</fui-text>
</view>
<view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx"> <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> </view>
...@@ -331,18 +423,24 @@ ...@@ -331,18 +423,24 @@
<fui-picker :show="show.type" :layer="1" :linkage="true" :options="options.type" @change="handleChangetype" @cancel="show.type = false" /> <fui-picker :show="show.type" :layer="1" :linkage="true" :options="options.type" @change="handleChangetype" @cancel="show.type = false" />
<fui-picker :show="show.urgentdegree" :layer="1" :linkage="true" :options="options.urgentdegree" @change="handleChangeUrgentdegree" @cancel="show.urgentdegree = false"/> <fui-picker :show="show.urgentdegree" :layer="1" :linkage="true" :options="options.urgentdegree" @change="handleChangeUrgentdegree" @cancel="show.urgentdegree = false"/>
--><!-- <fui-picker :show="show.area" :options="options.area" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.area = false" /> --> --><!-- <fui-picker :show="show.area" :options="options.area" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.area = false" /> -->
<!-- 地区的选择 --> <!-- 地区的选择 -->
<fui-bottom-popup :show="show.area"> <fui-bottom-popup :show="show.area">
<view class="fui-scroll__wrap"> <view class="fui-scroll__wrap">
<view class="fui-title">请选择</view> <view class="fui-title">请选择</view>
<fui-cascader ref="areaPopupRef" :value="pageData.options.areaVal" stepLoading @change="changeArea" @complete="selectCompleteArea" :options="pageData.options.area"></fui-cascader> <fui-cascader
<view class="fui-icon__close" @tap.stop="pageData.show.area=false"> ref="areaPopupRef"
<fui-icon name="close" :size="48"></fui-icon> :value="pageData.options.areaVal"
</view> stepLoading
</view> @change="changeArea"
</fui-bottom-popup> @complete="selectCompleteArea"
:options="pageData.options.area"
/>
<view class="fui-icon__close" @tap.stop="pageData.show.area = false">
<fui-icon name="close" :size="48" />
</view>
</view>
</fui-bottom-popup>
<fui-toast ref="toastRef" /> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
...@@ -522,51 +620,49 @@ ...@@ -522,51 +620,49 @@
color: #333; color: #333;
font-size: 28rpx; font-size: 28rpx;
} }
.fui-clause--cell {
display: flex;
.fui-clause--cell { align-items: center;
display: flex; justify-content: center;
align-items: center; font-size: 24rpx;
justify-content: center; color: #999999;
font-size: 24rpx; }
color:#999999; .fui-clause--wrap {
} width: 100%;
.fui-clause--wrap { margin-top: 64rpx;
width: 100%; }
margin-top: 64rpx; .fui-clause--text {
} padding-left: 16rpx;
.fui-clause--text { /* #ifdef H5 */
padding-left: 16rpx; cursor: pointer;
/* #ifdef H5 */ /* #endif */
cursor: pointer; }
/* #endif */ .fui-color__link {
} color: #5fb771;
.fui-color__link { /* #ifdef H5 */
color: #5FB771; cursor: pointer;
/* #ifdef H5 */ /* #endif */
cursor: pointer; }
/* #endif */
} .fui-color__link:active {
opacity: 0.5;
.fui-color__link:active { }
opacity: .5; .fui-scroll__wrap {
} padding-top: 30rpx;
.fui-scroll__wrap { position: relative;
padding-top: 30rpx; }
position: relative;
} .fui-title {
font-size: 30rpx;
.fui-title { font-weight: bold;
font-size: 30rpx; text-align: center;
font-weight: bold; padding-bottom: 24rpx;
text-align: center; }
padding-bottom: 24rpx;
} .fui-icon__close {
position: absolute;
.fui-icon__close { top: 24rpx;
position: absolute; right: 24rpx;
top: 24rpx; }
right: 24rpx;
}
</style> </style>
...@@ -15,24 +15,25 @@ ...@@ -15,24 +15,25 @@
const videoList = ref([]) const videoList = ref([])
function getVideoList(params) { function getVideoList(params) {
if (model.loading) return if (model.loading)
return
model.loading = true model.loading = true
videoApi.getList(params).then((res) => { videoApi.getList(params).then((res) => {
if (res.records.length > 0) { if (res.records.length > 0) {
const { records } = res; const { records } = res
let scale:any = 0; let scale: any = 0
for(let i = 0; i < records.length;i++){ for (let i = 0; i < records.length; i++) {
if(records[i].width){ if (records[i].width) {
scale = (340 / records[i].width).toFixed(1); scale = (340 / records[i].width).toFixed(1)
records[i].videoWidth = 340; records[i].videoWidth = 340
records[i].videoHeight = Math.floor(records[i].height * scale); records[i].videoHeight = Math.floor(records[i].height * scale)
}else{ } else {
records[i].videoWidth = 0; records[i].videoWidth = 0
records[i].videoHeight = 0; records[i].videoHeight = 0
} }
} }
if (model.params.pageNo === 1) { if (model.params.pageNo === 1) {
videoList.value = records videoList.value = records
} else { } else {
...@@ -118,9 +119,9 @@ ...@@ -118,9 +119,9 @@
v-for="(item, index) in videoList" v-for="(item, index) in videoList"
:key="index" :key="index"
:src="item.thumbnailPath" :src="item.thumbnailPath"
:imgWidth="item.videoWidth" :imgWidth="item.videoWidth"
:imgHeight="item.videoHeight" :imgHeight="item.videoHeight"
:videoDuration="item.totalTime" :videoDuration="item.totalTime"
@click="toPlay(item.id)" @click="toPlay(item.id)"
> >
<view class="flex flex-col justify-between pl-2 pr-2 pb-2"> <view class="flex flex-col justify-between pl-2 pr-2 pb-2">
......
...@@ -73,8 +73,25 @@ ...@@ -73,8 +73,25 @@
</view> </view>
<view class="text-left"> <view class="text-left">
<fui-form ref="formRef"> <fui-form ref="formRef">
<fui-input marginTop="30" size="28" placeholder="请填写姓名" v-model="pageData.form.reservedname" required maxlength="16" placeholderStyle="margin-left: 10rpx"/> <fui-input
<fui-input marginTop="30" size="28" placeholder="请填写预留手机" v-model="pageData.form.reservedmobile" required type="number" maxlength="11" placeholderStyle="margin-left: 10rpx"/> marginTop="30"
size="28"
placeholder="请填写姓名"
v-model="pageData.form.reservedname"
required
maxlength="16"
placeholderStyle="margin-left: 10rpx"
/>
<fui-input
marginTop="30"
size="28"
placeholder="请填写预留手机"
v-model="pageData.form.reservedmobile"
required
type="number"
maxlength="11"
placeholderStyle="margin-left: 10rpx"
/>
<view style="margin-top: 30rpx"> <view style="margin-top: 30rpx">
<fui-button text="提交" bold radius="96rpx" @click="submit" /> <fui-button text="提交" bold radius="96rpx" @click="submit" />
</view> </view>
......
<!-- 农场详情 --> <!-- 农场详情 -->
<script setup lang="ts"> <script setup lang="ts">
import RegisterDialog from './register-dialog.vue' import * as turf from '@turf/turf'
import * as turf from '@turf/turf' import RegisterDialog from './register-dialog.vue'
import type { Page } from './config' import type { Page } from './config'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import { import { flyTo, useMapbox } from '@/components/Map/Mapbox/hook'
addDefaultGeoJSONSource, import { getText } from '@/utils/dict/area'
addDefaultSplotLayer, import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
addDefaultSymbolLayer,
useMapbox, // 页面参数
flyTo, const page = reactive<Page>({
} from '@/components/Map/Mapbox/hook' id: 'example-mapbox',
import { getText } from '@/utils/dict/area' init: false,
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' requests: 0,
latest: null,
// 页面参数 query: {},
const page = reactive<Page>({ })
id: 'example-mapbox',
init: false, const model = reactive({
requests: 0, id: '',
latest: null, name: '',
query: {}, lonlat: `${uni.getStorageSync('location').lon},${uni.getStorageSync('location').lat}`,
}) address: '',
description: '',
const model = reactive({ // 地块、位置信息 GeoJSON
id: '', plots: [],
name: '', // 设备信息
lonlat: `${uni.getStorageSync('location').lon},${uni.getStorageSync('location').lat}`, devices: [],
address: '',
description: '', employmentId: null,
// 地块、位置信息 GeoJSON showConfirmDialog: false,
plots: [], contactName: '',
// 设备信息 contactMobile: '',
devices: [],
// 分类标签
employmentId:null, categoryTabs: [
showConfirmDialog:false, { id: null, name: '全部' },
contactName:"", { id: 1, name: '种植' },
contactMobile:"", { id: 2, name: '养殖' },
{ id: 3, name: '采摘' },
// 分类标签 { id: 4, name: '其他' },
categoryTabs: [ ],
{ id: null, name: '全部' }, search: {
{ id: 1, name: '种植' }, pageNo: 1,
{ id: 2, name: '养殖' }, pageSize: 10,
{ id: 3, name: '采摘' }, publishstatu: 1,
{ id: 4, name: '其他' }, type: null,
], createBy: '',
search: { },
pageNo: 1, employmentList: [],
pageSize: 10, loading: false,
publishstatu: 1, total: 0,
type: null, requestDebounce: null,
createBy: '', // 用户当前位置
}, userLocation: {
employmentList: [], longitude: uni.getStorageSync('location').lon,
loading: false, latitude: uni.getStorageSync('location').lat,
total: 0, },
requestDebounce: null, // 选中的用工信息
// 用户当前位置 selectedEmployment: null,
userLocation: { showEmploymentPopup: false,
longitude: uni.getStorageSync('location').lon, searchText: '',
latitude: uni.getStorageSync('location').lat, // 标记点击事件是否已绑定
}, clickEventBound: false,
// 选中的用工信息 // 用于区分是哪个模块进的
selectedEmployment: null, currentEmploymentId: 1,
showEmploymentPopup: false, })
searchText: '',
// 标记点击事件是否已绑定 onLoad((options) => {
clickEventBound: false, model.id = options.id
// 用于区分是哪个模块进的 model.currentEmploymentId = options.currentEmploymentId
currentEmploymentId:1, model.name = decodeURIComponent(options.name)
}) model.search.pageNo = 1
model.search.publishstatu = 1
onLoad((options) => { model.search.createBy = ''
model.id = options.id; model.employmentList = []
model.currentEmploymentId = options.currentEmploymentId; getEmploymentList()
model.name = decodeURIComponent(options.name) })
model.search.pageNo = 1
model.search.publishstatu = 1 // 地图组件
model.search.createBy = '' const center: [number, number] = [uni.getStorageSync('location').lon, uni.getStorageSync('location').lat]
model.employmentList = [] const registerDialogRef = ref()
getEmploymentList() const [registerMap, map] = useMapbox({
}) style: { center, zoom: 10 },
onLoaded: (data) => {
// 地图组件 // 渲染用户当前位置
const center: [number, number] = [uni.getStorageSync('location').lon, uni.getStorageSync('location').lat] renderUserLocation()
const registerDialogRef = ref() },
const [registerMap, map] = useMapbox({ onSourceRequestHandle: () => {
style: { center, zoom: 10 }, page.requests--
onLoaded: (data) => { if (page.requests === 0) {
// 渲染用户当前位置 Message.hideLoading()
renderUserLocation() }
}, },
onSourceRequestHandle: () => { onSourceRequestErrorHandle: () => {
page.requests--
if (page.requests === 0) {
Message.hideLoading() Message.hideLoading()
} },
}, onMapEvent: (event) => {
onSourceRequestErrorHandle: () => { // 处理来自 renderjs 层的自定义事件
Message.hideLoading() if (event.type === 'custom' && event.name === 'navigateToDetail') {
}, console.log('接收到导航事件,id:', event)
onMapEvent: (event) => { // Navigate.to(`/pages/linghuoyonggong/detail/index?id=${event.data}`)
// 处理来自 renderjs 层的自定义事件 if (model.currentEmploymentId == 2) {
if (event.type === 'custom' && event.name === 'navigateToDetail') { model.employmentId = event.data
console.log('接收到导航事件,id:', event) getLaborAppDetail()
// Navigate.to(`/pages/linghuoyonggong/detail/index?id=${event.data}`) } else {
if(model.currentEmploymentId == 2){ registerDialogRef.value.open({ id: event.data })
model.employmentId = event.data; }
getLaborAppDetail(); }
}else{ },
registerDialogRef.value.open({ id: event.data }) })
} async function getLaborAppDetail() {
} await LinghuoyonggongAPI.getLaborAppDetail({ id: model.employmentId }).then((res) => {
model.contactMobile = res.contactMobile
model.contactName =
res.contactName.substring(0, 1) + Array.from({ length: res.contactName.length }).join('*')
model.showConfirmDialog = true
})
}
function makePhoneCall() {
uni.makePhoneCall({
phoneNumber: model.contactMobile,
})
} }
})
async function getLaborAppDetail() { // 创建弹框HTML内容
await LinghuoyonggongAPI.getLaborAppDetail({ id: model.employmentId }).then((res) => { function createPopupHTML(employment) {
model.contactMobile = res.contactMobile; if (!employment)
model.contactName = res.contactName.substring(0,1) + new Array(res.contactName.length).join('*'); return ''
model.showConfirmDialog = true;
}) if (model.currentEmploymentId == 2) {
} return `
function makePhoneCall(){
uni.makePhoneCall({
phoneNumber: model.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="width: 220px;background:#FFFFFF;padding: 12px;display: flex;flex-direction: column;">
<div style="display: flex;justify-content: space-between;line-height: 20px;"> <div style="display: flex;justify-content: space-between;line-height: 20px;">
<div style="font-size: 16px;color: #333333;">${employment.villageName}</div> <div style="font-size: 16px;color: #333333;">${employment.villageName}</div>
...@@ -149,7 +145,7 @@ function createPopupHTML(employment) { ...@@ -149,7 +145,7 @@ function createPopupHTML(employment) {
</div> </div>
<div style="color: #999999;margin-top: 4px;line-height: 18px;font-size: 12px;display: flex;align-items: center;"> <div style="color: #999999;margin-top: 4px;line-height: 18px;font-size: 12px;display: flex;align-items: center;">
<image style="width:11px;height:13px;margin-right:7px;" src="./static/images/linghuoyonggong/skill.png" /> <image style="width:11px;height:13px;margin-right:7px;" src="./static/images/linghuoyonggong/skill.png" />
<div>技能:${employment.skills.length ? employment.skills.join("、") : '未填写'}</div> <div>技能:${employment.skills.length ? employment.skills.join('、') : '未填写'}</div>
</div> </div>
<div style="color: #999999;margin-top: 4px;line-height: 18px;font-size: 12px;display: flex;align-items: center;"> <div style="color: #999999;margin-top: 4px;line-height: 18px;font-size: 12px;display: flex;align-items: center;">
<image style="width:11px;height:13px;margin-right:7px;" src="./static/images/linghuoyonggong/address.png" /> <image style="width:11px;height:13px;margin-right:7px;" src="./static/images/linghuoyonggong/address.png" />
...@@ -157,11 +153,11 @@ function createPopupHTML(employment) { ...@@ -157,11 +153,11 @@ function createPopupHTML(employment) {
</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> <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> </div>
`; `
}else{ } else {
const distance = getDistanceText(employment) const distance = getDistanceText(employment)
const stars = getStarsHTML(employment) const stars = getStarsHTML(employment)
return ` return `
<div style=" <div style="
max-width: 280px; max-width: 280px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
...@@ -205,8 +201,8 @@ function createPopupHTML(employment) { ...@@ -205,8 +201,8 @@ function createPopupHTML(employment) {
<div style="display: flex; gap: 12px; font-size: 13px; color: #666666; margin-bottom: 8px;"> <div style="display: flex; gap: 12px; font-size: 13px; color: #666666; margin-bottom: 8px;">
<span>⏱ 时长${ <span>⏱ 时长${
employment.daysDiff || getDaysDiff(employment.starttime, employment.estimatedendtime) employment.daysDiff || getDaysDiff(employment.starttime, employment.estimatedendtime)
}天</span> }天</span>
<span>👥 需${employment.workers || 0}人</span> <span>👥 需${employment.workers || 0}人</span>
<span>💰 ${employment.price || 0}元/天</span> <span>💰 ${employment.price || 0}元/天</span>
</div> </div>
...@@ -235,324 +231,324 @@ function createPopupHTML(employment) { ...@@ -235,324 +231,324 @@ function createPopupHTML(employment) {
</div> </div>
</div> </div>
` `
} }
}
// 渲染用户位置
function renderUserLocation() {
const markerId = `my-local`
// 修复 App 端图片路径问题
const imageUrl = '/static/images/local-map.png'
let finalImageUrl = imageUrl
// #ifdef APP-PLUS
// 在 App 端使用绝对路径
finalImageUrl = `./static/images/local-map.png`
// #endif
const iconSize: [number, number] = [40, 40] // 图标大小
// 使用 addMarker 添加到地图,带上 popup 和自定义图标
map.addMarker(
markerId,
[model.userLocation.longitude, model.userLocation.latitude],
'',
false, // 不默认打开
finalImageUrl, // 自定义图标图片URL
iconSize, // 图标大小
)
}
// 渲染用工标记
function renderEmploymentMarkers() {
if (!map) {
console.warn('地图未初始化')
return
} }
console.log('渲染用工标记数量:', model.employmentList.length) // 渲染用户位置
console.log('用工数据:', model.employmentList) function renderUserLocation() {
const markerId = `my-local`
let longitude = null,latitude = null; // 修复 App 端图片路径问题
// 使用 Marker 方式渲染带自定义图标的标记 const imageUrl = '/static/images/local-map.png'
model.employmentList.forEach((item) => { let finalImageUrl = imageUrl
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 // #ifdef APP-PLUS
// 处理 App 端图片路径 // 在 App 端使用绝对路径
if (imageUrl.startsWith('/static/')) { finalImageUrl = `./static/images/local-map.png`
imageUrl = `.${imageUrl}` // #endif
}
// #endif
// 使用 addMarker 添加到地图,带上 popup 和自定义图标 const iconSize: [number, number] = [40, 40] // 图标大小
map.addMarker(
markerId, // 使用 addMarker 添加到地图,带上 popup 和自定义图标
[longitude, latitude], map.addMarker(
createPopupHTML(item), markerId,
false, // 不默认打开 [model.userLocation.longitude, model.userLocation.latitude],
imageUrl, // 自定义图标图片URL '',
iconSize, // 图标大小 false, // 不默认打开
) finalImageUrl, // 自定义图标图片URL
iconSize, // 图标大小
)
}
// 渲染用工标记
function renderEmploymentMarkers() {
if (!map) {
console.warn('地图未初始化')
return
} }
})
// 绑定点击事件标记 console.log('渲染用工标记数量:', model.employmentList.length)
if (!model.clickEventBound) { console.log('用工数据:', model.employmentList)
console.log('标记点击事件已绑定')
model.clickEventBound = true let longitude = null
let latitude = null
// 使用 Marker 方式渲染带自定义图标的标记
model.employmentList.forEach((item) => {
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
// 处理 App 端图片路径
if (imageUrl.startsWith('/static/')) {
imageUrl = `.${imageUrl}`
}
// #endif
// 使用 addMarker 添加到地图,带上 popup 和自定义图标
map.addMarker(
markerId,
[longitude, latitude],
createPopupHTML(item),
false, // 不默认打开
imageUrl, // 自定义图标图片URL
iconSize, // 图标大小
)
}
})
// 绑定点击事件标记
if (!model.clickEventBound) {
console.log('标记点击事件已绑定')
model.clickEventBound = true
}
} }
} // 分类标签点击事件
// 分类标签点击事件 function onCategoryTabClick(tab: any) {
function onCategoryTabClick(tab: any) { model.search.type = tab.id
model.search.type = tab.id model.search.pageNo = 1
model.search.pageNo = 1 model.employmentList = []
model.employmentList = [] getEmploymentList()
getEmploymentList() // 在这里添加具体的分类标签点击逻辑
// 在这里添加具体的分类标签点击逻辑
}
async function getEmploymentList() {
// 如果正在加载或没有更多数据,直接返回
if (model.loading || (model.total > 0 && model.employmentList.length >= model.total)) {
return
} }
model.loading = true
try { async function getEmploymentList() {
if(model.currentEmploymentId == 2){ // 如果正在加载或没有更多数据,直接返回
await LinghuoyonggongAPI.getLaborAppList(model.search).then(async (res) => { if (model.loading || (model.total > 0 && model.employmentList.length >= model.total)) {
const { records, total } = res return
// 批量处理数据,避免多次DOM操作 }
const processedRecords = records.map((item) => { model.loading = true
// 缓存区域处理结果 try {
item.area = getText(item.area, ' / ') if (model.currentEmploymentId == 2) {
await LinghuoyonggongAPI.getLaborAppList(model.search).then(async (res) => {
// 计算天数并缓存结果 const { records, total } = res
if (item.starttime && item.estimatedendtime) { // 批量处理数据,避免多次DOM操作
item.daysDiff = getDaysDiff(item.starttime, item.estimatedendtime) const processedRecords = records.map((item) => {
} // 缓存区域处理结果
item.area = getText(item.area, ' / ')
return item
}) // 计算天数并缓存结果
if (item.starttime && item.estimatedendtime) {
// 一次性更新数据,避免多次响应式更新 item.daysDiff = getDaysDiff(item.starttime, item.estimatedendtime)
if (model.search.pageNo === 1) { }
model.employmentList = processedRecords
} else { return item
// 避免重复数据加载 })
const existingIds = new Set(model.employmentList.map((item) => item.id))
const newRecords = processedRecords.filter((item) => !existingIds.has(item.id)) // 一次性更新数据,避免多次响应式更新
model.employmentList = [...model.employmentList, ...newRecords] if (model.search.pageNo === 1) {
} model.employmentList = processedRecords
} else {
model.total = total // 避免重复数据加载
// 数据加载完成后渲染地图标记 const existingIds = new Set(model.employmentList.map((item) => item.id))
setTimeout(()=>{ const newRecords = processedRecords.filter((item) => !existingIds.has(item.id))
renderEmploymentMarkers(); model.employmentList = [...model.employmentList, ...newRecords]
},600) }
/* nextTick(() => {
model.total = total
// 数据加载完成后渲染地图标记
setTimeout(() => {
renderEmploymentMarkers()
}, 600)
/* nextTick(() => {
renderEmploymentMarkers() renderEmploymentMarkers()
}) */ }) */
}) })
}else{ } else {
await LinghuoyonggongAPI.employmentList(model.search).then(async (res) => { await LinghuoyonggongAPI.employmentList(model.search).then(async (res) => {
const { records, total } = res const { records, total } = res
// 批量处理数据,避免多次DOM操作 // 批量处理数据,避免多次DOM操作
const processedRecords = records.map((item) => { const processedRecords = records.map((item) => {
// 缓存区域处理结果 // 缓存区域处理结果
item.area = getText(item.area, ' / ') item.area = getText(item.area, ' / ')
// 计算天数并缓存结果 // 计算天数并缓存结果
if (item.starttime && item.estimatedendtime) { if (item.starttime && item.estimatedendtime) {
item.daysDiff = getDaysDiff(item.starttime, item.estimatedendtime) item.daysDiff = getDaysDiff(item.starttime, item.estimatedendtime)
} }
return item return item
}) })
// 一次性更新数据,避免多次响应式更新 // 一次性更新数据,避免多次响应式更新
if (model.search.pageNo === 1) { if (model.search.pageNo === 1) {
model.employmentList = processedRecords model.employmentList = processedRecords
} else { } else {
// 避免重复数据加载 // 避免重复数据加载
const existingIds = new Set(model.employmentList.map((item) => item.id)) const existingIds = new Set(model.employmentList.map((item) => item.id))
const newRecords = processedRecords.filter((item) => !existingIds.has(item.id)) const newRecords = processedRecords.filter((item) => !existingIds.has(item.id))
model.employmentList = [...model.employmentList, ...newRecords] model.employmentList = [...model.employmentList, ...newRecords]
} }
model.total = total model.total = total
// 数据加载完成后渲染地图标记 // 数据加载完成后渲染地图标记
setTimeout(()=>{ setTimeout(() => {
renderEmploymentMarkers(); renderEmploymentMarkers()
},600) }, 600)
/* nextTick(() => { /* nextTick(() => {
renderEmploymentMarkers() renderEmploymentMarkers()
}) */ }) */
}) })
} }
} catch (error) { } catch (error) {
console.error('获取用工列表失败:', error) console.error('获取用工列表失败:', error)
// 这里可以添加用户友好的错误提示 // 这里可以添加用户友好的错误提示
// uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' }) // uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
} finally { } finally {
model.loading = false model.loading = false
model.requestDebounce = null model.requestDebounce = null
}
} }
}
// 获取时间差
function getDaysDiff(date1: Date | number | string, date2: Date | number | string): number {
// 将输入转换为Date对象
const d1 = new Date(date1)
const d2 = new Date(date2)
// 检查日期是否有效 // 获取时间差
if (Number.isNaN(d1.getTime()) || Number.isNaN(d2.getTime())) { function getDaysDiff(date1: Date | number | string, date2: Date | number | string): number {
throw new TypeError('无效的日期格式') // 将输入转换为Date对象
} const d1 = new Date(date1)
const d2 = new Date(date2)
// 设置时间部分为00:00:00,只比较日期部分 // 检查日期是否有效
d1.setHours(0, 0, 0, 0) if (Number.isNaN(d1.getTime()) || Number.isNaN(d2.getTime())) {
d2.setHours(0, 0, 0, 0) throw new TypeError('无效的日期格式')
}
// 计算两个日期之间的毫秒差 // 设置时间部分为00:00:00,只比较日期部分
const diffTime = Math.abs(d2.getTime() - d1.getTime()) d1.setHours(0, 0, 0, 0)
d2.setHours(0, 0, 0, 0)
// 转换为天数 // 计算两个日期之间的毫秒差
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) const diffTime = Math.abs(d2.getTime() - d1.getTime())
return diffDays // 转换为天数
} const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
// 回到当前位置 return diffDays
function backToUserLocation() { }
if (map && model.userLocation.longitude && model.userLocation.latitude) {
flyTo(map, [model.userLocation.longitude, model.userLocation.latitude], 15, 0.5)
uni.showToast({
title: '已回到当前位置',
icon: 'none',
duration: 1500,
})
} else {
// 重新获取用户位置
uni.getLocation({
type: 'wgs84',
success: (res) => {
if (res.longitude !== 0 && res.latitude !== 0) {
model.userLocation.longitude = res.longitude
model.userLocation.latitude = res.latitude
// 更新缓存位置
uni.setStorageSync('location', {
lon: res.longitude,
lat: res.latitude,
})
// 飞到用户位置
flyTo(map, [res.longitude, res.latitude], 15, 0.5)
// 回到当前位置
function backToUserLocation() {
if (map && model.userLocation.longitude && model.userLocation.latitude) {
flyTo(map, [model.userLocation.longitude, model.userLocation.latitude], 15, 0.5)
uni.showToast({
title: '已回到当前位置',
icon: 'none',
duration: 1500,
})
} else {
// 重新获取用户位置
uni.getLocation({
type: 'wgs84',
success: (res) => {
if (res.longitude !== 0 && res.latitude !== 0) {
model.userLocation.longitude = res.longitude
model.userLocation.latitude = res.latitude
// 更新缓存位置
uni.setStorageSync('location', {
lon: res.longitude,
lat: res.latitude,
})
// 飞到用户位置
flyTo(map, [res.longitude, res.latitude], 15, 0.5)
uni.showToast({
title: '已获取并回到当前位置',
icon: 'none',
duration: 1500,
})
}
},
fail: (err) => {
console.error('获取位置失败:', err)
uni.showToast({ uni.showToast({
title: '已获取并回到当前位置', title: '获取位置失败,请检查定位权限',
icon: 'none', icon: 'none',
duration: 1500, duration: 2000,
}) })
} },
}, })
fail: (err) => { }
console.error('获取位置失败:', err)
uni.showToast({
title: '获取位置失败,请检查定位权限',
icon: 'none',
duration: 2000,
})
},
})
} }
}
// 关闭弹框
// 关闭弹框 function closeEmploymentPopup() {
function closeEmploymentPopup() { model.showEmploymentPopup = false
model.showEmploymentPopup = false model.selectedEmployment = null
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]) function getDistanceText2(item) {
const to = turf.point([employment.longitude, employment.latitude]) if (!item || !item.lon || !model.userLocation.longitude) {
const distance = turf.distance(from, to, { units: 'kilometers' }) 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) { if (distance < 1) {
return `${Math.round(distance * 1000)}m` return `${Math.round(distance * 1000)}m`
}
return `${distance.toFixed(1)}km`
} }
return `${distance.toFixed(1)}km` // 计算距离显示
} function getDistanceText(employment) {
if (!employment || !employment.longitude || !employment.latitude) {
// 生成星级HTML return '未知'
function getStarsHTML(employment) { }
// 获取紧急程度,默认为0 // 使用turf计算距离
const urgentdegree = Number(employment.urgentdegree) || 0 const from = turf.point([model.userLocation.longitude, model.userLocation.latitude])
// 确保评级在0-5之间 const to = turf.point([employment.longitude, employment.latitude])
const rating = Math.max(0, Math.min(5, urgentdegree)) const distance = turf.distance(from, to, { units: 'kilometers' })
let html = '' if (distance < 1) {
for (let i = 1; i <= 5; i++) { return `${Math.round(distance * 1000)}m`
if (i <= rating) {
html += '<span style="color: #FF9800; font-size: 16px;">★</span>'
} else {
html += '<span style="color: #E0E0E0; font-size: 16px;">★</span>'
} }
return `${distance.toFixed(1)}km`
} }
return { // 生成星级HTML
html, function getStarsHTML(employment) {
rating // 获取紧急程度,默认为0
const urgentdegree = Number(employment.urgentdegree) || 0
// 确保评级在0-5之间
const rating = Math.max(0, Math.min(5, urgentdegree))
let html = ''
for (let i = 1; i <= 5; i++) {
if (i <= rating) {
html += '<span style="color: #FF9800; font-size: 16px;">★</span>'
} else {
html += '<span style="color: #E0E0E0; font-size: 16px;">★</span>'
}
}
return {
html,
rating,
}
} }
} // 发布用工
// 发布用工 function handlePublish() {
function handlePublish() { if (model.currentEmploymentId == 2) {
if(model.currentEmploymentId == 2){ Navigate.to('/pages/linghuoyonggong/publishEmployment')
Navigate.to('/pages/linghuoyonggong/publishEmployment') } else {
}else{ Navigate.to('/pages/linghuoyonggong/form')
Navigate.to('/pages/linghuoyonggong/form') }
}
}
onNavigationBarButtonTap((e) => {
console.log(e)
if (e.index === 0) {
Navigate.to('/pages/linghuoyonggong/linghuoyonggong')
} }
}) onNavigationBarButtonTap((e) => {
console.log(e)
if (e.index === 0) {
Navigate.to('/pages/linghuoyonggong/linghuoyonggong')
}
})
</script> </script>
<template> <template>
...@@ -596,7 +592,7 @@ onNavigationBarButtonTap((e) => { ...@@ -596,7 +592,7 @@ onNavigationBarButtonTap((e) => {
<!-- 回到当前位置按钮 --> <!-- 回到当前位置按钮 -->
<view class="location-control" @click="backToUserLocation"> <view class="location-control" @click="backToUserLocation">
<view class="location-button"> <view class="location-button">
<image src="/static/images/toLocal.png" style="width: 58rpx; height: 58rpx"></image> <image src="/static/images/toLocal.png" style="width: 58rpx; height: 58rpx" />
<!-- <fui-icon name="location" color="#5DB66F" :size="36" /> --> <!-- <fui-icon name="location" color="#5DB66F" :size="36" /> -->
</view> </view>
</view> </view>
...@@ -608,123 +604,123 @@ onNavigationBarButtonTap((e) => { ...@@ -608,123 +604,123 @@ onNavigationBarButtonTap((e) => {
</view> </view>
</fui-fab> </fui-fab>
<RegisterDialog ref="registerDialogRef" /> <RegisterDialog ref="registerDialogRef" />
<!-- 确认对话框 --> <!-- 确认对话框 -->
<ConfirmDialog <ConfirmDialog
v-model:show="model.showConfirmDialog" v-model:show="model.showConfirmDialog"
title="温馨提示" title="温馨提示"
:content="`你将与${model.contactName}进行电话沟通,若继续,请点击确认按钮!`" :content="`你将与${model.contactName}进行电话沟通,若继续,请点击确认按钮!`"
cancelText="取消" cancelText="取消"
confirmText="确认" confirmText="确认"
@confirm="makePhoneCall" @confirm="makePhoneCall"
/> />
</view> </view>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
// //
.page { .page {
min-height: 100vh; min-height: 100vh;
background: #e6f5e8;
.map-box {
// #ifdef APP-PLUS
position: relative;
top: 0;
// #endif
// #ifdef H5
position: relative;
top: 0;
// #endif
width: 690rpx;
left: 30rpx;
border-radius: 20rpx;
background: #e6f5e8; background: #e6f5e8;
}
.group_2 { .map-box {
.text-wrapper { // #ifdef APP-PLUS
flex: 1 1 120rpx; position: relative;
background-color: #5db66f; top: 0;
border-radius: 19998rpx; // #endif
line-height: 60rpx; // #ifdef H5
height: 60rpx; position: relative;
top: 0;
.text_2 { // #endif
color: #ffffff; width: 690rpx;
} left: 30rpx;
border-radius: 20rpx;
background: #e6f5e8;
} }
.text-wrapper_2 { .group_2 {
flex: 1 1 120rpx; .text-wrapper {
line-height: 60rpx; flex: 1 1 120rpx;
background-color: #ffffff; background-color: #5db66f;
border-radius: 19998rpx; border-radius: 19998rpx;
height: 60rpx; line-height: 60rpx;
height: 60rpx;
.text_3 { .text_2 {
line-height: 25.88rpx; color: #ffffff;
}
} }
.text_4 { .text-wrapper_2 {
line-height: 26.16rpx; flex: 1 1 120rpx;
} line-height: 60rpx;
background-color: #ffffff;
border-radius: 19998rpx;
height: 60rpx;
.text_5 { .text_3 {
line-height: 25.96rpx; line-height: 25.88rpx;
} }
.text_6 { .text_4 {
line-height: 25.68rpx; line-height: 26.16rpx;
}
.text_5 {
line-height: 25.96rpx;
}
.text_6 {
line-height: 25.68rpx;
}
} }
} }
}
// 回到当前位置控制按钮样式 // 回到当前位置控制按钮样式
.location-control { .location-control {
position: absolute; position: absolute;
bottom: 100rpx; bottom: 100rpx;
right: 10rpx; right: 10rpx;
z-index: 1000; z-index: 1000;
.location-button { .location-button {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
// width: 80rpx; // width: 80rpx;
// height: 80rpx; // height: 80rpx;
background: rgba(255, 255, 255, 0.95); background: rgba(255, 255, 255, 0.95);
border-radius: 50%; border-radius: 50%;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.15); box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.15);
backdrop-filter: blur(10rpx); backdrop-filter: blur(10rpx);
// border: 2rpx solid #5db66f; // border: 2rpx solid #5db66f;
transition: all 0.3s ease; transition: all 0.3s ease;
&:active { &:active {
transform: scale(0.95); transform: scale(0.95);
background: linear-gradient(135deg, #5db66f 0%, #4caf50 100%); background: linear-gradient(135deg, #5db66f 0%, #4caf50 100%);
:deep(.fui-icon) { :deep(.fui-icon) {
color: #ffffff !important; color: #ffffff !important;
}
} }
}
&:hover { &:hover {
transform: scale(1.05); transform: scale(1.05);
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.2); box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.2);
}
} }
} }
} }
} ::v-deep .mapboxgl-popup {
::v-deep .mapboxgl-popup { max-width: 568rpx !important;
max-width: 568rpx !important; }
} ::v-deep .fui-fab__btn-main {
::v-deep .fui-fab__btn-main { background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important;
background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important; box-shadow: 0px 1px 8px #5db66f;
box-shadow: 0px 1px 8px #5db66f; }
} ::v-deep .mapboxgl-popup a {
::v-deep .mapboxgl-popup a { outline: none !important;
outline: none !important; -webkit-tap-highlight-color: transparent !important;
-webkit-tap-highlight-color: transparent !important; -webkit-touch-callout: none !important;
-webkit-touch-callout: none !important; }
}
</style> </style>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, toRefs } from 'vue' import { reactive } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { getCalculateAge } from '@/utils/date' import { getCalculateAge } from '@/utils/date'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'; import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import ConfirmDialog from '@/components/ConfirmDialog/index.vue' import ConfirmDialog from '@/components/ConfirmDialog/index.vue'
const pageData = reactive({ const pageData = reactive({
loading: false, loading: false,
workersParam:[], workersParam: [],
contactMobile:"", contactMobile: '',
contactName:"", contactName: '',
showConfirmDialog:false, showConfirmDialog: false,
}) })
// 字典值 // 字典值
const DictData = reactive({ const DictData = reactive({
sexArr:[],// 性别 sexArr: [], // 性别
educationArr:[]// 学历 educationArr: [], // 学历
}) })
onLoad((options) => { onLoad((options) => {
let param = JSON.parse(decodeURIComponent(options.param)); const param = JSON.parse(decodeURIComponent(options.param))
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: param.villageName title: param.villageName,
}); })
getLaborAppDetail(param.id); getLaborAppDetail(param.id)
}) })
async function getLaborAppDetail(id: string) { async function getLaborAppDetail(id: string) {
await LinghuoyonggongAPI.gitListByCodeDict({ code : 'sex'}).then(res=>{ await LinghuoyonggongAPI.gitListByCodeDict({ code: 'sex' }).then((res) => {
DictData.sexArr = res; DictData.sexArr = res
}) })
await LinghuoyonggongAPI.gitListByCodeDict({ code : 'education'}).then(res=>{ await LinghuoyonggongAPI.gitListByCodeDict({ code: 'education' }).then((res) => {
DictData.educationArr = res; DictData.educationArr = res
}) })
await LinghuoyonggongAPI.getLaborAppDetail({ id }).then((res) => { await LinghuoyonggongAPI.getLaborAppDetail({ id }).then((res) => {
pageData.workersParam = res.workers; pageData.workersParam = res.workers
pageData.contactMobile = res.contactMobile; pageData.contactMobile = res.contactMobile
pageData.contactName = res.contactName.substring(0,1) + new Array(res.contactName.length).join('*'); pageData.contactName =
}) res.contactName.substring(0, 1) + Array.from({ length: res.contactName.length }).join('*')
} })
// 返回字典中的中文值 }
function returnDictZhVel(type:any,val:any){ // 返回字典中的中文值
let valText = ""; function returnDictZhVel(type: any, val: any) {
if(type == 'gender'){ let valText = ''
let arr = DictData.sexArr; if (type == 'gender') {
for(let i = 0; i < arr.length;i++){ const arr = DictData.sexArr
if(val == parseInt(arr[i].itemValue)){ for (let i = 0; i < arr.length; i++) {
valText = arr[i].itemText; if (val == Number.parseInt(arr[i].itemValue)) {
break; valText = arr[i].itemText
} break
} }
} }
if(type == 'edu'){ }
let arr = DictData.educationArr; if (type == 'edu') {
for(let i = 0; i < arr.length;i++){ const arr = DictData.educationArr
if(val == parseInt(arr[i].itemValue)){ for (let i = 0; i < arr.length; i++) {
valText = arr[i].itemText; if (val == Number.parseInt(arr[i].itemValue)) {
break; valText = arr[i].itemText
} break
} }
} }
return valText; }
} return valText
function makePhoneCall(){ }
uni.makePhoneCall({ function makePhoneCall() {
phoneNumber: pageData.contactMobile uni.makePhoneCall({
}); phoneNumber: pageData.contactMobile,
} })
}
</script> </script>
<template> <template>
<view class="details_page"> <view class="details_page">
<view class="details-content"> <view class="details-content">
<view v-if="!pageData.workersParam || pageData.workersParam.length == 0" style="height: 700rpx"> <view v-if="!pageData.workersParam || pageData.workersParam.length == 0" style="height: 700rpx">
<fui-empty marginTop="100" src="/static/images/no-data.png" title="暂无数据" /> <fui-empty marginTop="100" src="/static/images/no-data.png" title="暂无数据" />
</view> </view>
<view class="yr-person-item" v-for="(item,index) in pageData.workersParam" :key="index"> <view class="yr-person-item" v-for="(item, index) in pageData.workersParam" :key="index">
<view class="yr-person-info"> <view class="yr-person-info">
<view class="person_name_attr">{{item.name}}<text class="person_attr">{{item.attr}}</text></view> <view class="person_name_attr"
<view class="person-info">{{getCalculateAge(item.birthday)}}{{ returnDictZhVel('gender',item.gender) }}{{ returnDictZhVel('edu',item.edu)}}</view> >{{ item.name }}<text class="person_attr">{{ item.attr }}</text></view
<view class="person-info text_overflow_ellipsis">技能:{{item.skill}}</view> >
</view> <view class="person-info"
</view> >{{ getCalculateAge(item.birthday) }}{{ returnDictZhVel('gender', item.gender) }}{{
</view> returnDictZhVel('edu', item.edu)
<view v-if="pageData.workersParam.length" class="make-phone-view"> }}</view
<fui-button text="电话沟通" bold radius="96rpx" @click="pageData.showConfirmDialog = true" height="80rpx"/> >
</view> <view class="person-info text_overflow_ellipsis">技能:{{ item.skill }}</view>
<!-- 确认对话框 --> </view>
<ConfirmDialog </view>
v-model:show="pageData.showConfirmDialog" </view>
title="温馨提示" <view v-if="pageData.workersParam.length" class="make-phone-view">
:content="`你将与${pageData.contactName}进行电话沟通,若继续,请点击确认按钮!`" <fui-button text="电话沟通" bold radius="96rpx" @click="pageData.showConfirmDialog = true" height="80rpx" />
cancelText="取消" </view>
confirmText="确认" <!-- 确认对话框 -->
@confirm="makePhoneCall" <ConfirmDialog
/> v-model:show="pageData.showConfirmDialog"
title="温馨提示"
:content="`你将与${pageData.contactName}进行电话沟通,若继续,请点击确认按钮!`"
cancelText="取消"
confirmText="确认"
@confirm="makePhoneCall"
/>
</view> </view>
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.details_page{ .details_page {
background: rgba(230, 245, 232, 1); background: rgba(230, 245, 232, 1);
min-height: 100vh; min-height: 100vh;
width: 750rpx; width: 750rpx;
padding-top: 24rpx; padding-top: 24rpx;
position: relative; position: relative;
.details-content{ .details-content {
width: 694rpx; width: 694rpx;
background-color: #FFFFFF; background-color: #ffffff;
margin-left: 28rpx; margin-left: 28rpx;
border-radius: 12rpx; border-radius: 12rpx;
padding: 24rpx; padding: 24rpx;
.yr-person-item{ .yr-person-item {
border-bottom: 2rpx solid #EEEEEE; border-bottom: 2rpx solid #eeeeee;
margin-bottom: 24rpx; margin-bottom: 24rpx;
.yr-person-info{ .yr-person-info {
.person_name_attr{ .person_name_attr {
font-size: 28rpx; font-size: 28rpx;
font-weight: 500; font-weight: 500;
color: #333333; color: #333333;
.person_attr{ .person_attr {
font-size: 24rpx; font-size: 24rpx;
font-weight: 400; font-weight: 400;
color: #5DB66F; color: #5db66f;
margin-left: 12rpx; margin-left: 12rpx;
} }
} }
.person-info{ .person-info {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
vertical-align: middle; vertical-align: middle;
margin-bottom: 24rpx; margin-bottom: 24rpx;
margin-top: 24rpx; margin-top: 24rpx;
} }
} }
} }
.yr-person-item:last-child{ .yr-person-item:last-child {
border-bottom: none; border-bottom: none;
} }
} }
.make-phone-view{ .make-phone-view {
width: 690rpx; width: 690rpx;
height: 80rpx; height: 80rpx;
position: fixed; position: fixed;
left: 30rpx; left: 30rpx;
bottom: 62rpx; bottom: 62rpx;
} }
} }
</style> </style>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import * as UserInfoAPI from '@/api/model/userInfo' import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData' import { getCodeByText } from '@/utils/areaData'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import { getDictData, getText } from '@/utils/dict/area' import { getDictData, getText } from '@/utils/dict/area'
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
picture: null, picture: null,
pictureObj: null, pictureObj: null,
longitude: '', longitude: '',
latitude: '' latitude: '',
}, },
position: [], position: [],
rules: [ rules: [
...@@ -70,43 +70,53 @@ ...@@ -70,43 +70,53 @@
name: 'type', name: 'type',
rule: ['required'], rule: ['required'],
msg: ['请选择用工类型'], msg: ['请选择用工类型'],
},{ },
{
name: 'name', name: 'name',
rule: ['required'], rule: ['required'],
msg: ['请输入标题'], msg: ['请输入标题'],
}, { },
{
name: 'workers', name: 'workers',
rule: ['required'], rule: ['required'],
msg: ['请输入工人数量'], msg: ['请输入工人数量'],
}, { },
{
name: 'price', name: 'price',
rule: ['required'], rule: ['required'],
msg: ['请输入用工单价'], msg: ['请输入用工单价'],
}, { },
{
name: 'starttime', name: 'starttime',
rule: ['required'], rule: ['required'],
msg: ['请选择开始时间'], msg: ['请选择开始时间'],
}, { },
{
name: 'estimatedendtime', name: 'estimatedendtime',
rule: ['required'], rule: ['required'],
msg: ['请选择预计结束时间'], msg: ['请选择预计结束时间'],
}, { },
{
name: 'content', name: 'content',
rule: ['required'], rule: ['required'],
msg: ['请输入工作内容'], msg: ['请输入工作内容'],
}, { },
{
name: 'area', name: 'area',
rule: ['required'], rule: ['required'],
msg: ['请选择地区'], msg: ['请选择地区'],
}, { },
{
name: 'address', name: 'address',
rule: ['required'], rule: ['required'],
msg: ['请输入详细地址'], msg: ['请输入详细地址'],
}, { },
{
name: 'urgentdegree', name: 'urgentdegree',
rule: ['required'], rule: ['required'],
msg: ['请选择紧急程度'], msg: ['请选择紧急程度'],
}, { },
{
name: 'picture', name: 'picture',
rule: ['required'], rule: ['required'],
msg: ['请上传图片'], msg: ['请上传图片'],
...@@ -133,8 +143,8 @@ ...@@ -133,8 +143,8 @@
} }
function getCurrentAddressInfo() { function getCurrentAddressInfo() {
if (!uni.getStorageSync('location')) if (!uni.getStorageSync('location'))
return return
const { lon, lat } = uni.getStorageSync('location') const { lon, lat } = uni.getStorageSync('location')
pageData.position = [lon, lat] pageData.position = [lon, lat]
...@@ -276,7 +286,7 @@ ...@@ -276,7 +286,7 @@
}) })
} }
function getCurrentDate(){ function getCurrentDate() {
const date = new Date() const date = new Date()
const year = date.getFullYear() const year = date.getFullYear()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
...@@ -290,15 +300,60 @@ ...@@ -290,15 +300,60 @@
<view class="formBox"> <view class="formBox">
<fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false"> <fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false">
<view class="mt20"> <view class="mt20">
<fui-input disabled required label="用工类型" placeholder="请选择用工类型" v-model="form.typeText" labelSize="28" size="28" label-width="180" @click="show.type = true" /> <fui-input
<fui-input required label="标题" placeholder="请输入标题" v-model="form.name" labelSize="28" label-width="180" maxlength="16" size="28"/> disabled
required
label="用工类型"
placeholder="请选择用工类型"
v-model="form.typeText"
labelSize="28"
size="28"
label-width="180"
@click="show.type = true"
/>
<fui-input
required
label="标题"
placeholder="请输入标题"
v-model="form.name"
labelSize="28"
label-width="180"
maxlength="16"
size="28"
/>
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input required type="number" :min="0" label="工人数量" placeholder="请输入工人数量" v-model="form.workers" labelSize="28" label-width="180" maxlength="4" size="28"> <fui-input
<view slot="suffix" class="unit-slot"></view> required
type="number"
:min="0"
label="工人数量"
placeholder="请输入工人数量"
v-model="form.workers"
labelSize="28"
label-width="180"
maxlength="4"
size="28"
>
<template #suffix>
<view class="unit-slot"></view>
</template>
</fui-input> </fui-input>
<fui-input required type="number" label="用工单价" :min="0" placeholder="请输入用工单价" v-model="form.price" labelSize="28" label-width="180" maxlength="6" size="28"> <fui-input
<view slot="suffix" class="unit-slot">元/人</view> required
type="number"
label="用工单价"
:min="0"
placeholder="请输入用工单价"
v-model="form.price"
labelSize="28"
label-width="180"
maxlength="6"
size="28"
>
<template #suffix>
<view class="unit-slot">元/人</view>
</template>
</fui-input> </fui-input>
<!-- 时间范围 --> <!-- 时间范围 -->
<view class="form-section" style="padding: 0 30rpx"> <view class="form-section" style="padding: 0 30rpx">
...@@ -319,16 +374,62 @@ ...@@ -319,16 +374,62 @@
</view> </view>
</view> </view>
</view> </view>
<fui-input required label="工作内容" placeholder="请输入工作内容" v-model="form.content" labelSize="28" label-width="180" maxlength="32" size="28" /> <fui-input
required
label="工作内容"
placeholder="请输入工作内容"
v-model="form.content"
labelSize="28"
label-width="180"
maxlength="32"
size="28"
/>
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input disabled required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" size="28"/> <fui-input
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.address" labelSize="28" label-width="180" size="28"/> disabled
<fui-input disabled required label="紧急程度" placeholder="请选择紧急程度" v-model="form.urgentdegreeText" labelSize="28" label-width="180" size="28" @click="show.urgentdegree = true" /> 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.address"
labelSize="28"
label-width="180"
size="28"
/>
<fui-input
disabled
required
label="紧急程度"
placeholder="请选择紧急程度"
v-model="form.urgentdegreeText"
labelSize="28"
label-width="180"
size="28"
@click="show.urgentdegree = true"
/>
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size: 28rpx;"><span style="color: red;">*&nbsp;</span> 图片 </view> <view class="mb-1 flex justify-start" style="font-size: 28rpx"
<uni-file-picker :value="form.pictureObj" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete"/> ><span style="color: red">*&nbsp;</span> 图片
</view>
<uni-file-picker
:value="form.pictureObj"
ref="uploadRef"
limit="1"
:auto-upload="false"
@select="handleUpload"
@delete="handleDelete"
/>
</view> </view>
<view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx"> <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" />
...@@ -337,11 +438,44 @@ ...@@ -337,11 +438,44 @@
</view> </view>
</view> </view>
<fui-date-picker :show="show.time1" type="3" @change="handleChangeTime1" :min-date="getCurrentDate()" @cancel="show.time1 = false" /> <fui-date-picker
<fui-date-picker :show="show.time2" type="3" @change="handleChangeTime2" :min-date="getCurrentDate()" @cancel="show.time2 = false" /> :show="show.time1"
<fui-picker :show="show.type" :layer="1" :linkage="true" :options="options.type" @change="handleChangetype" @cancel="show.type = false" /> type="3"
<fui-picker :show="show.urgentdegree" :layer="1" :linkage="true" :options="options.urgentdegree" @change="handleChangeUrgentdegree" @cancel="show.urgentdegree = false"/> @change="handleChangeTime1"
<fui-picker :show="show.area" :options="options.area" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.area = false" /> :min-date="getCurrentDate()"
@cancel="show.time1 = false"
/>
<fui-date-picker
:show="show.time2"
type="3"
@change="handleChangeTime2"
:min-date="getCurrentDate()"
@cancel="show.time2 = false"
/>
<fui-picker
:show="show.type"
:layer="1"
:linkage="true"
:options="options.type"
@change="handleChangetype"
@cancel="show.type = false"
/>
<fui-picker
:show="show.urgentdegree"
:layer="1"
:linkage="true"
:options="options.urgentdegree"
@change="handleChangeUrgentdegree"
@cancel="show.urgentdegree = false"
/>
<fui-picker
:show="show.area"
:options="options.area"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="show.area = false"
/>
<fui-toast ref="toastRef" /> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue' import { reactive } from 'vue'
import { onLoad, onReachBottom, onShow } from '@dcloudio/uni-app' import { onLoad, onShow } from '@dcloudio/uni-app'
import * as turf from '@turf/turf'
import RegisterDialog from './components/register-dialog.vue' import RegisterDialog from './components/register-dialog.vue'
import ConfirmDialog from '@/components/ConfirmDialog/index.vue' import ConfirmDialog from '@/components/ConfirmDialog/index.vue'
import { getTextByCode } from '@/utils/areaData'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import { getText } from '@/utils/dict/area' import { getText } from '@/utils/dict/area'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import * as turf from '@turf/turf'
const userStore = useUserStore() const userStore = useUserStore()
onLoad((option) => { onLoad((option) => {
pageData.currentEmploymentId = Number(option.type) || 2; pageData.currentEmploymentId = Number(option.type) || 2
}) })
onShow(() => { onShow(() => {
getUserLocation(); getUserLocation()
resetGetEmploymentList(); resetGetEmploymentList()
}) })
// 页面数据 // 页面数据
const pageData = reactive({ const pageData = reactive({
loading: false, loading: false,
requestDebounce:null, requestDebounce: null,
searchValue:"", searchValue: '',
search: { search: {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
publishstatu: 1, publishstatu: 1,
type: null, type: null,
createBy: '', createBy: '',
keyword:"" keyword: '',
}, },
hasMore:'more', hasMore: 'more',
// 用工类型标签 // 用工类型标签
employmentTabs: [ employmentTabs: [
{ id: 2, name: '找人干活(找人)' }, { id: 2, name: '找人干活(找人)' },
{ id: 1, name: '出工赚钱(找事)' }, { id: 1, name: '出工赚钱(找事)' },
], ],
currentEmploymentId: 2, currentEmploymentId: 2,
...@@ -44,20 +43,23 @@ ...@@ -44,20 +43,23 @@
// 用工列表 // 用工列表
employmentList: [], employmentList: [],
total: 0, total: 0,
dataTotal: 0, dataTotal: 0,
longitude:null, longitude: null,
latitude:null, latitude: null,
swipeActionButtons: [{ swipeActionButtons: [
text: '编辑', {
background: '#465CFF' text: '编辑',
}, { background: '#465CFF',
text: '删除', },
background: '#FF2B2B' {
}], text: '删除',
isShowConfirmDialog:false, background: '#FF2B2B',
dialogContent:"确认要删除吗", },
delLaborId:null ],
isShowConfirmDialog: false,
dialogContent: '确认要删除吗',
delLaborId: null,
}) })
// 缓存已处理的区域数据,避免重复计算 // 缓存已处理的区域数据,避免重复计算
...@@ -68,30 +70,32 @@ ...@@ -68,30 +70,32 @@
maxRetries: 2, maxRetries: 2,
retryDelay: 1000, retryDelay: 1000,
} }
function handleConfirmDialog(){ function handleConfirmDialog() {
pageData.loading = true; pageData.loading = true
LinghuoyonggongAPI.getLaborAppDel({ LinghuoyonggongAPI.getLaborAppDel({
id: pageData.delLaborId, id: pageData.delLaborId,
}).then((res) => { })
resetGetEmploymentList(); .then((res) => {
}).finally(()=>{ resetGetEmploymentList()
setTimeout(()=>{ })
pageData.loading = false; .finally(() => {
},200) setTimeout(() => {
}) pageData.loading = false
} }, 200)
// 左滑点击 })
function swipeActionOnClick(e,item){ }
pageData.delLaborId = item.id; // 左滑点击
if(e.item.text == '删除'){ function swipeActionOnClick(e, item) {
pageData.dialogContent = `确认要删除【${item.villageName}】吗`; pageData.delLaborId = item.id
setTimeout(()=>{ if (e.item.text == '删除') {
pageData.isShowConfirmDialog = true; pageData.dialogContent = `确认要删除【${item.villageName}】吗`
},100) setTimeout(() => {
}else{ pageData.isShowConfirmDialog = true
Navigate.to('/pages/linghuoyonggong/publishEmployment?id='+item.id); }, 100)
} } else {
} Navigate.to(`/pages/linghuoyonggong/publishEmployment?id=${item.id}`)
}
}
// 带重试机制的API调用 // 带重试机制的API调用
async function fetchWithRetry(apiCall, maxRetries = requestConfig.maxRetries) { async function fetchWithRetry(apiCall, maxRetries = requestConfig.maxRetries) {
const startTime = Date.now() const startTime = Date.now()
...@@ -127,23 +131,23 @@ ...@@ -127,23 +131,23 @@
function getEmploymentList() { function getEmploymentList() {
// 如果正在加载或没有更多数据,直接返回 // 如果正在加载或没有更多数据,直接返回
if (pageData.loading || pageData.hasMore == 'noMore') { if (pageData.loading || pageData.hasMore == 'noMore') {
return; return
} }
pageData.loading = true; pageData.loading = true
// 添加请求防抖,避免快速连续请求 // 添加请求防抖,避免快速连续请求
if (pageData.requestDebounce) { if (pageData.requestDebounce) {
clearTimeout(pageData.requestDebounce) clearTimeout(pageData.requestDebounce)
} }
pageData.requestDebounce = setTimeout(async () => { pageData.requestDebounce = setTimeout(async () => {
try { try {
let res = null; let res = null
if(pageData.currentEmploymentId == 2){ if (pageData.currentEmploymentId == 2) {
res = await fetchWithRetry(() => LinghuoyonggongAPI.getLaborAppList(pageData.search)) res = await fetchWithRetry(() => LinghuoyonggongAPI.getLaborAppList(pageData.search))
}else{ } else {
res = await fetchWithRetry(() => LinghuoyonggongAPI.employmentList(pageData.search)) res = await fetchWithRetry(() => LinghuoyonggongAPI.employmentList(pageData.search))
} }
const { records, total } = res; const { records, total } = res
// 批量处理数据,避免多次DOM操作 // 批量处理数据,避免多次DOM操作
const processedRecords = records.map((item) => { const processedRecords = records.map((item) => {
// 缓存区域处理结果 // 缓存区域处理结果
...@@ -154,21 +158,20 @@ ...@@ -154,21 +158,20 @@
} }
return item return item
}) })
pageData.dataTotal += processedRecords.length; pageData.dataTotal += processedRecords.length
// 一次性更新数据,避免多次响应式更新 // 一次性更新数据,避免多次响应式更新
if (pageData.search.pageNo === 1) { if (pageData.search.pageNo === 1) {
pageData.employmentList = processedRecords; pageData.employmentList = processedRecords
} else { } else {
// 避免重复数据加载 感觉有坑 // 避免重复数据加载 感觉有坑
/* const existingIds = new Set(pageData.employmentList.map((item) => item.id)) /* const existingIds = new Set(pageData.employmentList.map((item) => item.id))
const newRecords = processedRecords.filter((item) => !existingIds.has(item.id)) */ const newRecords = processedRecords.filter((item) => !existingIds.has(item.id)) */
pageData.employmentList = [...pageData.employmentList, ...processedRecords] pageData.employmentList = [...pageData.employmentList, ...processedRecords]
} }
pageData.total = total; pageData.total = total
if (pageData.dataTotal >= total) { if (pageData.dataTotal >= total) {
pageData.hasMore = 'noMore' pageData.hasMore = 'noMore'
} }
} catch (error) { } catch (error) {
console.error('获取用工列表失败:', error) console.error('获取用工列表失败:', error)
// 这里可以添加用户友好的错误提示 // 这里可以添加用户友好的错误提示
...@@ -202,11 +205,11 @@ ...@@ -202,11 +205,11 @@
} }
// 发布用工 // 发布用工
function handlePublish() { function handlePublish() {
if(pageData.currentEmploymentId === 2){ if (pageData.currentEmploymentId === 2) {
Navigate.to('/pages/linghuoyonggong/publishEmployment') Navigate.to('/pages/linghuoyonggong/publishEmployment')
}else{ } else {
Navigate.to('/pages/linghuoyonggong/form') Navigate.to('/pages/linghuoyonggong/form')
} }
} }
// 获取时间差 // 获取时间差
function getDaysDiff(date1: Date | number | string, date2: Date | number | string): number { function getDaysDiff(date1: Date | number | string, date2: Date | number | string): number {
...@@ -231,42 +234,42 @@ ...@@ -231,42 +234,42 @@
return diffDays return diffDays
} }
function onSearch(res:any){ function onSearch(res: any) {
pageData.employmentList = []; pageData.employmentList = []
pageData.search.pageNo = 1; pageData.search.pageNo = 1
pageData.dataTotal = 0; pageData.dataTotal = 0
pageData.hasMore = 'more'; pageData.hasMore = 'more'
if (pageData.currentEmploymentId === 1) { if (pageData.currentEmploymentId === 1) {
pageData.search.publishstatu = 1 pageData.search.publishstatu = 1
pageData.search.createBy = res.value pageData.search.createBy = res.value
} }
if (pageData.currentEmploymentId === 2) { if (pageData.currentEmploymentId === 2) {
pageData.search.keyword = res.value; pageData.search.keyword = res.value
} }
getEmploymentList() getEmploymentList()
} }
// 取消搜索了 // 取消搜索了
function onSearchCancel(){ function onSearchCancel() {
resetGetEmploymentList(); resetGetEmploymentList()
} }
function resetGetEmploymentList(){ function resetGetEmploymentList() {
pageData.employmentList = [] pageData.employmentList = []
pageData.searchValue = ""; pageData.searchValue = ''
pageData.search.pageNo = 1; pageData.search.pageNo = 1
pageData.dataTotal = 0; pageData.dataTotal = 0
pageData.hasMore = 'more'; pageData.hasMore = 'more'
if (pageData.currentEmploymentId === 1) { if (pageData.currentEmploymentId === 1) {
pageData.search.publishstatu = 1 pageData.search.publishstatu = 1
pageData.search.createBy = '' pageData.search.createBy = ''
} }
pageData.search.keyword = ""; pageData.search.keyword = ''
getEmploymentList() getEmploymentList()
} }
function loadMoreData(){ function loadMoreData() {
pageData.search.pageNo++ pageData.search.pageNo++
getEmploymentList() getEmploymentList()
} }
/* onReachBottom(() => { /* onReachBottom(() => {
console.log('触底了') console.log('触底了')
if (pageData.total <= pageData.employmentList.length) { if (pageData.total <= pageData.employmentList.length) {
return return
...@@ -276,54 +279,54 @@ ...@@ -276,54 +279,54 @@
}) */ }) */
onNavigationBarButtonTap(() => { onNavigationBarButtonTap(() => {
Navigate.to('/pages/linghuoyonggong/components/yonggongmap?currentEmploymentId='+pageData.currentEmploymentId); Navigate.to(`/pages/linghuoyonggong/components/yonggongmap?currentEmploymentId=${pageData.currentEmploymentId}`)
}) })
// 查看找人干活详情 // 查看找人干活详情
function onDetailsClick(item: any) { function onDetailsClick(item: any) {
let param = encodeURIComponent(JSON.stringify({id:item.id,villageName:item.villageName})); const param = encodeURIComponent(JSON.stringify({ id: item.id, villageName: item.villageName }))
Navigate.to('/pages/linghuoyonggong/details?param='+param); Navigate.to(`/pages/linghuoyonggong/details?param=${param}`)
} }
// 获取用户位置 // 获取用户位置
function getUserLocation(){ function getUserLocation() {
uni.getLocation({ uni.getLocation({
type: 'wgs84', type: 'wgs84',
success: (res) => { success: (res) => {
if (res.longitude !== 0 && res.latitude !== 0) { if (res.longitude !== 0 && res.latitude !== 0) {
pageData.longitude = res.longitude pageData.longitude = res.longitude
pageData.latitude = res.latitude pageData.latitude = res.latitude
} }
}, },
fail: (err) => { fail: (err) => {
console.error('获取位置失败:', err) console.error('获取位置失败:', err)
uni.showToast({ uni.showToast({
title: '获取位置失败,请检查定位权限', title: '获取位置失败,请检查定位权限',
icon: 'none', icon: 'none',
duration: 2000, duration: 2000,
}) })
}, },
}) })
} }
// 计算距离显示 // 计算距离显示
function getDistanceText(item) { function getDistanceText(item) {
if (!item || !item.lon || !pageData.longitude) { if (!item || !item.lon || !pageData.longitude) {
return '未知' return '未知'
} }
// 使用turf计算距离 // 使用turf计算距离
const from = turf.point([pageData.longitude, pageData.latitude]) const from = turf.point([pageData.longitude, pageData.latitude])
const to = turf.point([item.lon, item.lat]) const to = turf.point([item.lon, item.lat])
const distance = turf.distance(from, to, { units: 'kilometers' }) const distance = turf.distance(from, to, { units: 'kilometers' })
if (distance < 1) { if (distance < 1) {
return `${Math.round(distance * 1000)}m`; return `${Math.round(distance * 1000)}m`
} }
return `${distance.toFixed(1)}km`; return `${distance.toFixed(1)}km`
} }
</script> </script>
<template> <template>
<view class="page"> <view class="page">
<scroll-view scroll-y="true" style="height: 100%;" class="codefun-flex-col" @scrolltolower="loadMoreData"> <scroll-view scroll-y="true" style="height: 100%" class="codefun-flex-col" @scrolltolower="loadMoreData">
<!-- <view class="codefun-mt-14 codefun-flex-row group_2 gap-2"> <!-- <view class="codefun-mt-14 codefun-flex-row group_2 gap-2">
<view <view
v-for="tab in pageData.categoryTabs" v-for="tab in pageData.categoryTabs"
...@@ -339,9 +342,18 @@ ...@@ -339,9 +342,18 @@
</view> --> </view> -->
<view class="codefun-mt-14 codefun-flex-col group_3"> <view class="codefun-mt-14 codefun-flex-col group_3">
<view class="top-search-view"> <view class="top-search-view">
<uni-search-bar radius="100" v-model="pageData.searchValue" placeholder="请输入搜索内容" clearButton="auto" cancelButton="none" @confirm="onSearch" @cancel="onSearchCancel" @clear="onSearchCancel"/> <uni-search-bar
</view> radius="100"
v-model="pageData.searchValue"
placeholder="请输入搜索内容"
clearButton="auto"
cancelButton="none"
@confirm="onSearch"
@cancel="onSearchCancel"
@clear="onSearchCancel"
/>
</view>
<view class="codefun-flex-row section_2"> <view class="codefun-flex-row section_2">
<view <view
v-for="tab in pageData.employmentTabs" v-for="tab in pageData.employmentTabs"
...@@ -360,97 +372,136 @@ ...@@ -360,97 +372,136 @@
<fui-empty marginTop="100" src="/static/images/no-data.png" title="暂无数据" /> <fui-empty marginTop="100" src="/static/images/no-data.png" title="暂无数据" />
</view> </view>
<template v-else> <template v-else>
<template v-if="pageData.currentEmploymentId == 1"> <template v-if="pageData.currentEmploymentId == 1">
<view <view
class="codefun-flex-col list-item" class="codefun-flex-col list-item"
v-for="item in pageData.employmentList" v-for="item in pageData.employmentList"
:key="item.id" :key="item.id"
@click="onEmploymentItemClick(item)" @click="onEmploymentItemClick(item)"
> >
<view class="codefun-flex-row"> <view class="codefun-flex-row">
<image class="image_7" :src="item.picture" lazy-load /> <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>
<view> <view>
<image <image
class="codefun-self-start image_8" class="codefun-self-start image_8"
src="/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png" src="/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png"
/> />
<text class="codefun-self-start font_3 text_9">{{ item.area }}</text> <text class="codefun-self-start font_3 text_9">{{ item.area }}</text>
</view> </view>
</view> </view>
<view <view
class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch mt-11" class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch mt-11"
> >
<view class="flex codefun-items-center gap-1"> <view class="flex codefun-items-center gap-1">
<image class="image_9" src="/static/images/time.svg" /> <image class="image_9" src="/static/images/time.svg" />
<text class="font_4" <text class="font_4"
>预计{{ >预计{{
item.daysDiff || getDaysDiff(item.starttime, item.estimatedendtime) item.daysDiff ||
}}</text getDaysDiff(item.starttime, item.estimatedendtime)
> }}</text
</view> >
<view class="flex codefun-items-center gap-1"> </view>
<image class="image_9" src="/static/images/person.svg" /> <view class="flex codefun-items-center gap-1">
<text class="font_4">需要{{ item.workers }}</text> <image class="image_9" src="/static/images/person.svg" />
</view> <text class="font_4">需要{{ item.workers }}</text>
<view class="flex codefun-items-center gap-1"> </view>
<image class="image_9" src="/static/images/money.svg" /> <view class="flex codefun-items-center gap-1">
<text class="font_4 text_10">{{ item.price }}</text> <image class="image_9" src="/static/images/money.svg" />
</view> <text class="font_4 text_10">{{ item.price }}</text>
</view> </view>
</view> </view>
</view> </view>
<view class="codefun-mt-8 codefun-flex-row codefun-justify-between codefun-items-center"> </view>
<view class="flex-center"> <view
<fui-rate :score="item.urgentdegree" :size="36" /> class="codefun-mt-8 codefun-flex-row codefun-justify-between codefun-items-center"
<text class="font_5 ml-1">{{ item.urgentdegree }}</text> >
</view> <view class="flex-center">
<view <fui-rate :score="item.urgentdegree" :size="36" />
v-if="pageData.currentEmploymentId !== 2" <text class="font_5 ml-1">{{ item.urgentdegree }}</text>
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4" </view>
@click.stop="onQuoteClick(item)" <view
> v-if="pageData.currentEmploymentId !== 2"
<text class="font_6 text_12">我想去</text> class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4"
</view> @click.stop="onQuoteClick(item)"
</view> >
</view> <text class="font_6 text_12">我想去</text>
</template> </view>
<template v-else> </view>
<fui-swipeaction-group> </view>
<fui-swipe-action class="yr-list-swipe" v-for="item in pageData.employmentList" :key="item.id" :buttons="pageData.swipeActionButtons" @click="swipeActionOnClick($event,item)"> </template>
<fui-list-cell class="yr-list-cell" :padding="['0rpx','0rpx']" :highlight="false"> <template v-else>
<view class="work_list_view"> <fui-swipeaction-group>
<view class="d-flex j-sb"> <fui-swipe-action
<view class="left-width village_number_view"> class="yr-list-swipe"
<view class="village_view text_overflow_ellipsis">{{ item.villageName }}</view> v-for="item in pageData.employmentList"
<view class="d-flex align-center"><image class="avatar_icon" src="/static/images/linghuoyonggong/avatar.png" /><text class="text-color">待工人数{{item.workers}}</text></view> :key="item.id"
</view> :buttons="pageData.swipeActionButtons"
<view class="d-flex align-center justify-center right-width village_distance"> @click="swipeActionOnClick($event, item)"
<image class="distance_icon" src="/static/images/linghuoyonggong/distance.png" /> >
<text class="distance_val text-color">{{getDistanceText(item)}}</text> <fui-list-cell class="yr-list-cell" :padding="['0rpx', '0rpx']" :highlight="false">
</view> <view class="work_list_view">
</view> <view class="d-flex j-sb">
<view class="d-flex j-sb skill_details_view" style="padding-bottom: 0px;"> <view class="left-width village_number_view">
<view class="left-width d-flex j-sb align-center"> <view class="village_view text_overflow_ellipsis">{{
<image class="skill_icon" src="/static/images/linghuoyonggong/skill.png" /> item.villageName
<view class="skill_view text_overflow_ellipsis">技能:{{item.skills.length ? item.skills.join("、") : '未填写'}}</view> }}</view>
</view> <view class="d-flex align-center"
</view> ><image
<view class="d-flex j-sb skill_details_view"> class="avatar_icon"
<view class="left-width d-flex j-sb align-center"> src="/static/images/linghuoyonggong/avatar.png"
<image class="skill_icon" src="/static/images/linghuoyonggong/address.png" /> /><text class="text-color"
<view class="skill_view text_overflow_ellipsis">地址:{{item.villageFullName}}</view> >待工人数{{ item.workers }}</text
</view> ></view
<view class="right-width see_details_btn" @click="onDetailsClick(item)">查看详情</view> >
</view> </view>
</view> <view
</fui-list-cell> class="d-flex align-center justify-center right-width village_distance"
</fui-swipe-action> >
</fui-swipeaction-group> <image
</template> class="distance_icon"
<!-- <template v-else> 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" 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>
</fui-list-cell>
</fui-swipe-action>
</fui-swipeaction-group>
</template>
<!-- <template v-else>
<view class="work_list_view" v-for="item in pageData.employmentList" :key="item.id"> <view class="work_list_view" v-for="item in pageData.employmentList" :key="item.id">
<view class="d-flex j-sb"> <view class="d-flex j-sb">
<view class="left-width village_number_view"> <view class="left-width village_number_view">
...@@ -477,21 +528,21 @@ ...@@ -477,21 +528,21 @@
</view> </view>
</view> </view>
</template> --> </template> -->
</template> </template>
</view> </view>
</view> </view>
<view v-if="pageData.hasMore == 'noMore'" class="no-more">没有更多数据了</view> <view v-if="pageData.hasMore == 'noMore'" class="no-more">没有更多数据了</view>
</scroll-view> </scroll-view>
</view> </view>
<!-- 确认对话框 --> <!-- 确认对话框 -->
<ConfirmDialog <ConfirmDialog
v-model:show="pageData.isShowConfirmDialog" v-model:show="pageData.isShowConfirmDialog"
title="删除提醒" title="删除提醒"
:content="pageData.dialogContent" :content="pageData.dialogContent"
cancelText="取消" cancelText="取消"
confirmText="确认" confirmText="确认"
@confirm="handleConfirmDialog" @confirm="handleConfirmDialog"
/> />
<fui-fab position="right" distance="10" bottom="240" width="96" @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">
<view class="fab-icon" /> <view class="fab-icon" />
...@@ -529,10 +580,9 @@ ...@@ -529,10 +580,9 @@
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
height: calc(100vh - 88rpx); height: calc(100vh - 88rpx);
.top-search-view{ .top-search-view {
height: 64rpx; height: 64rpx;
}
}
.section { .section {
padding: 26rpx 28rpx 26rpx 36rpx; padding: 26rpx 28rpx 26rpx 36rpx;
background-color: #5db66f; background-color: #5db66f;
...@@ -622,13 +672,13 @@ ...@@ -622,13 +672,13 @@
.group_3 { .group_3 {
padding: 0 28rpx; padding: 0 28rpx;
// height: 685rpx; // height: 685rpx;
.top-search-view{ .top-search-view {
.uni-searchbar{ .uni-searchbar {
padding: 0rpx !important; padding: 0rpx !important;
} }
} }
.section_2 { .section_2 {
margin-top: 48rpx; margin-top: 48rpx;
padding-bottom: 8rpx; padding-bottom: 8rpx;
background-color: #ffffff66; background-color: #ffffff66;
border-radius: 32rpx; border-radius: 32rpx;
...@@ -755,91 +805,98 @@ ...@@ -755,91 +805,98 @@
background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important; background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important;
box-shadow: 0px 1px 8px #5db66f; box-shadow: 0px 1px 8px #5db66f;
} }
/* .yr-list-swipe{ /* .yr-list-swipe{
width: 680rpx; width: 680rpx;
.yr-list-cell{ .yr-list-cell{
width: 680rpx; width: 680rpx;
} }
} */ } */
.work_list_view{ .work_list_view {
// border-bottom: 2rpx solid #EEEEEE; // border-bottom: 2rpx solid #EEEEEE;
width: 100%; width: 100%;
padding-top: 24rpx; padding-top: 24rpx;
.text-color{color: #5DB66F;font-size: 24rpx;} .text-color {
.d-flex{display: flex;} color: #5db66f;
.j-sb{justify-content:space-between;} font-size: 24rpx;
.text_overflow_ellipsis{ }
white-space: nowrap; .d-flex {
overflow: hidden; display: flex;
text-overflow: ellipsis; }
} .j-sb {
.left-width{ justify-content: space-between;
width:440rpx; }
} .text_overflow_ellipsis {
.right-width{ white-space: nowrap;
width:140rpx; overflow: hidden;
} text-overflow: ellipsis;
.village_number_view{ }
.village_view{ .left-width {
height: 40rpx; width: 440rpx;
line-height: 40rpx; }
margin-bottom: 12rpx; .right-width {
font-size: 32rpx; width: 140rpx;
color: #333333; }
} .village_number_view {
.avatar_icon{ .village_view {
width: 24rpx; height: 40rpx;
height: 24rpx; line-height: 40rpx;
margin-right: 10rpx; margin-bottom: 12rpx;
} font-size: 32rpx;
} color: #333333;
.village_distance{ }
height: 26rpx; .avatar_icon {
margin-top: 16rpx; width: 24rpx;
.distance_icon{ height: 24rpx;
width: 24rpx; margin-right: 10rpx;
height: 28rpx; }
} }
.distance_val{ .village_distance {
margin-left: 6rpx; height: 26rpx;
} margin-top: 16rpx;
} .distance_icon {
width: 24rpx;
.skill_details_view{ height: 28rpx;
margin-top: 10rpx; }
padding-bottom: 24rpx; .distance_val {
.skill_icon{ margin-left: 6rpx;
width: 24rpx; }
height: 26rpx; }
}
.skill_view{ .skill_details_view {
width:440rpx; margin-top: 10rpx;
font-size: 24rpx; padding-bottom: 24rpx;
height: 40rpx; .skill_icon {
line-height: 40rpx; width: 24rpx;
color: #999999; height: 26rpx;
margin-left: 10rpx; }
} .skill_view {
.see_details_btn{ width: 440rpx;
height: 48rpx; font-size: 24rpx;
border-radius: 200rpx; height: 40rpx;
background: #5DB66F; line-height: 40rpx;
display: flex; color: #999999;
justify-content: center; margin-left: 10rpx;
align-items: center; }
padding: 20rpx; .see_details_btn {
font-size: 24rpx; height: 48rpx;
color: #FFFFFF; border-radius: 200rpx;
} background: #5db66f;
} display: flex;
} justify-content: center;
.no-more{ align-items: center;
padding-top: 40rpx; padding: 20rpx;
padding-bottom: 60rpx; font-size: 24rpx;
width: 750rpx; color: #ffffff;
text-align: center; }
font-size: 28rpx; }
color:#999999; }
} .no-more {
padding-top: 40rpx;
padding-bottom: 60rpx;
width: 750rpx;
text-align: center;
font-size: 28rpx;
color: #999999;
}
</style> </style>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, toRefs, ref, computed } from 'vue' import { reactive, ref, toRefs } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad, onShow } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import { getCalculateAge } from '@/utils/date' import { getCalculateAge } from '@/utils/date'
import * as UserInfoAPI from '@/api/model/userInfo' import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData' import { getCodeByText } from '@/utils/areaData'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import { getDictData, getText } from '@/utils/dict/area' import { getDictData } from '@/utils/dict/area'
const dictStore = useDictStore() const dictStore = useDictStore()
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
let pageType= 'add'; let pageType = 'add'
onLoad((option) => { onLoad((option) => {
// 获取数据详情 // 获取数据详情
if (option && option.id) { if (option && option.id) {
pageType = 'edit'; pageType = 'edit'
uni.setNavigationBarTitle({title: '编辑'}); uni.setNavigationBarTitle({ title: '编辑' })
getDetails(option.id) getDetails(option.id)
} else { } else {
// 获取当前位置 // 获取当前位置
getCurrentAddressInfo() getCurrentAddressInfo()
} }
getProvince(); getProvince()
// 获取字典值 // 获取字典值
getDictVal(); getDictVal()
}) })
onShow(() => { onShow(() => {
// 数据字典赋值 // 数据字典赋值
initDict() initDict()
}) })
const VerificationInfo1 = { const VerificationInfo1 = {
addr:'请选择村', addr: '请选择村',
contactName:'请输入联系人', contactName: '请输入联系人',
contactMobile:'请输入联系电话' contactMobile: '请输入联系电话',
} }
const VerificationInfo2 = { const VerificationInfo2 = {
name:'请输入姓名', name: '请输入姓名',
mobile:'请输入手机号', mobile: '请输入手机号',
genderZh:'请选择性别', genderZh: '请选择性别',
birthday:'请选择出生日期', birthday: '请选择出生日期',
eduZh:"请选择学历", eduZh: '请选择学历',
attr:"请选择人员属性", attr: '请选择人员属性',
skill:"请选择人员技能" skill: '请选择人员技能',
} }
const skillPopupRef = ref(null); const skillPopupRef = ref(null)
let tempWorkersParam = reactive({ const tempWorkersParam = reactive({
id:null, id: null,
laborId:null, //用工信息ID laborId: null, // 用工信息ID
name:"",// 工人姓名 name: '', // 工人姓名
mobile:"",// 手机号 mobile: '', // 手机号
gender:null,// 性别 gender: null, // 性别
genderZh:"", genderZh: '',
birthday:"", // 出生日期 birthday: '', // 出生日期
edu:null,// 学历 edu: null, // 学历
eduZh:"", eduZh: '',
attr:"",// 人员属性 attr: '', // 人员属性
skill:"", // 人员技能 skill: '', // 人员技能
}) })
let startDate = getDate('start'); let startDate = getDate('start')
const endDate = getDate('end'); const endDate = getDate('end')
// 字典值 // 字典值
const DictData = reactive({ const DictData = reactive({
sexArr:[],// 性别 sexArr: [], // 性别
educationArr:[],// 学历 educationArr: [], // 学历
socialattributesArr:[],// 人员属性 socialattributesArr: [], // 人员属性
dictValArr:[],// 过渡 dictValArr: [], // 过渡
dictType:"", dictType: '',
isSkillPopupShow:false, isSkillPopupShow: false,
skillValue:[], skillValue: [],
skillOptionsVal:[], skillOptionsVal: [],
})
})
const pageData = reactive({ const pageData = reactive({
province: [], //省数组 province: [], // 省数组
city: [], //市数组 city: [], // 市数组
district: [], //区数组 district: [], // 区数组
street: [], //街道数组 street: [], // 街道数组
mulSelect: [], //四级联动显示数组,该数组的值为[[province],[city],[district],[street]] mulSelect: [], // 四级联动显示数组,该数组的值为[[province],[city],[district],[street]]
provinceId: 0, //省的id provinceId: 0, // 省的id
cityId: 0, //市的id cityId: 0, // 市的id
districtId: 0,//区的id districtId: 0, // 区的id
isActive:false, isActive: false,
address:'', address: '',
birthdayPickerIsShow:false, birthdayPickerIsShow: false,
laborParam:{ laborParam: {
id:null, id: null,
lon:"", // 经度 lon: '', // 经度
lat:"", // 纬度 lat: '', // 纬度
contactName:"", // 联系人姓名 contactName: '', // 联系人姓名
contactMobile:"", // 联系人电话 contactMobile: '', // 联系人电话
provinceName:"湖南省", // 所属省名称 provinceName: '湖南省', // 所属省名称
provinceCode:"43", // 所属省编码 provinceCode: '43', // 所属省编码
cityName:"", // 所属市名称 cityName: '', // 所属市名称
cityCode:"", // 所属市编码 cityCode: '', // 所属市编码
districtName:"", // 所属区县名称 districtName: '', // 所属区县名称
districtCode:"", // 所属区县编码 districtCode: '', // 所属区县编码
townName:"", // 所属乡镇名称 townName: '', // 所属乡镇名称
townCode:"", // 所属乡镇编码 townCode: '', // 所属乡镇编码
villageName:"", // 村名称 villageName: '', // 村名称
villageCode:"", // 村编码 villageCode: '', // 村编码
addr:"", addr: '',
}, },
workersParam:[], workersParam: [],
actionType:'add', actionType: 'add',
editWorkersIndex:0, editWorkersIndex: 0,
loading: false, loading: false,
isPersonPopupShow:false, isPersonPopupShow: false,
datePickerShow:false, datePickerShow: false,
attrPickerShow:false, attrPickerShow: false,
show: { show: {
time1: false, time1: false,
time2: false, time2: false,
area: false, area: false,
...@@ -153,7 +151,7 @@ ...@@ -153,7 +151,7 @@
picture: null, picture: null,
pictureObj: null, pictureObj: null,
longitude: '', longitude: '',
latitude: '' latitude: '',
}, },
position: [], position: [],
rules: [ rules: [
...@@ -161,370 +159,379 @@ ...@@ -161,370 +159,379 @@
name: 'type', name: 'type',
rule: ['required'], rule: ['required'],
msg: ['请选择用工类型'], msg: ['请选择用工类型'],
},{ },
{
name: 'name', name: 'name',
rule: ['required'], rule: ['required'],
msg: ['请输入标题'], msg: ['请输入标题'],
}, { },
{
name: 'workers', name: 'workers',
rule: ['required'], rule: ['required'],
msg: ['请输入工人数量'], msg: ['请输入工人数量'],
}, { },
{
name: 'price', name: 'price',
rule: ['required'], rule: ['required'],
msg: ['请输入用工单价'], msg: ['请输入用工单价'],
}, { },
{
name: 'starttime', name: 'starttime',
rule: ['required'], rule: ['required'],
msg: ['请选择开始时间'], msg: ['请选择开始时间'],
}, { },
{
name: 'estimatedendtime', name: 'estimatedendtime',
rule: ['required'], rule: ['required'],
msg: ['请选择预计结束时间'], msg: ['请选择预计结束时间'],
}, { },
{
name: 'content', name: 'content',
rule: ['required'], rule: ['required'],
msg: ['请输入工作内容'], msg: ['请输入工作内容'],
}, { },
{
name: 'area', name: 'area',
rule: ['required'], rule: ['required'],
msg: ['请选择地区'], msg: ['请选择地区'],
}, { },
{
name: 'address', name: 'address',
rule: ['required'], rule: ['required'],
msg: ['请输入详细地址'], msg: ['请输入详细地址'],
}, { },
{
name: 'urgentdegree', name: 'urgentdegree',
rule: ['required'], rule: ['required'],
msg: ['请选择紧急程度'], msg: ['请选择紧急程度'],
}, { },
{
name: 'picture', name: 'picture',
rule: ['required'], rule: ['required'],
msg: ['请上传图片'], msg: ['请上传图片'],
}, },
], ],
}) })
// 获取字典值 // 获取字典值
function getDictVal(){ function getDictVal() {
LinghuoyonggongAPI.gitListByCodeDict({ code : 'sex'}).then(res=>{ LinghuoyonggongAPI.gitListByCodeDict({ code: 'sex' }).then((res) => {
DictData.sexArr = res; DictData.sexArr = res
}) })
LinghuoyonggongAPI.gitListByCodeDict({ code : 'education'}).then(res=>{ LinghuoyonggongAPI.gitListByCodeDict({ code: 'education' }).then((res) => {
DictData.educationArr = res; DictData.educationArr = res
}) })
LinghuoyonggongAPI.gitListByCodeDict({ code : 'socialattributes'}).then(res=>{ LinghuoyonggongAPI.gitListByCodeDict({ code: 'socialattributes' }).then((res) => {
DictData.socialattributesArr = res; DictData.socialattributesArr = res
}) })
queryByCategoryAndCode(0,null); queryByCategoryAndCode(0, null)
}
} function queryByCategoryAndCode(code, e) {
function queryByCategoryAndCode(code,e){ LinghuoyonggongAPI.queryByCategoryAndCode({ category: 1, code }).then((res) => {
LinghuoyonggongAPI.queryByCategoryAndCode({ category : 1,code : code}).then(res=>{ if (res.length) {
if(res.length){ const dataArr = []
let dataArr = []; for (let i = 0; i < res.length; i++) {
for(let i = 0; i < res.length; i++){ const obj = { text: '', value: '' }
let obj = {text:"",value:""}; obj.text = res[i].name
obj.text = res[i].name; obj.value = res[i].code
obj.value = res[i].code; dataArr.push(obj)
dataArr.push(obj); }
} if (!DictData.skillOptionsVal.length) {
if(!DictData.skillOptionsVal.length){ DictData.skillOptionsVal = dataArr
DictData.skillOptionsVal = dataArr; } else {
}else{ skillPopupRef.value.setRequestData(dataArr, e.layer)
skillPopupRef.value.setRequestData(dataArr, e.layer); }
} } else {
}else{ skillPopupRef.value.end()
skillPopupRef.value.end(); }
} })
}) }
} // 选择技能完成
// 选择技能完成 function selectCompleteSkill(e) {
function selectCompleteSkill(e){ // tempWorkersParam.skill = e.text.join('');
// tempWorkersParam.skill = e.text.join(''); const valText = e.text[e.text.length - 1]
let valText = e.text[e.text.length-1]; if (tempWorkersParam.skill.length) {
if(tempWorkersParam.skill.length){ const skillArray = tempWorkersParam.skill.split('、')
let skillArray = tempWorkersParam.skill.split("、"); if (skillArray.length < 3) {
if(skillArray.length < 3){ tempWorkersParam.skill = `${tempWorkersParam.skill}${valText}`
tempWorkersParam.skill = tempWorkersParam.skill+'、'+valText; } else {
}else{ toastRef.value.show({
toastRef.value.show({ type: 'error',
type: 'error', text: '最多只能选择3项技能!',
text: '最多只能选择3项技能!', })
}) }
} } else {
}else{ tempWorkersParam.skill = valText
tempWorkersParam.skill = valText; }
} DictData.isSkillPopupShow = false
DictData.isSkillPopupShow = false; }
} // 技能值发生了改变
// 技能值发生了改变 function changeSkill(e) {
function changeSkill(e){ const val = e.value
let val = e.value; queryByCategoryAndCode(val, e)
queryByCategoryAndCode(val,e); }
} // 学历和属性的选择
// 学历和属性的选择 function attrChange(e) {
function attrChange(e) { if (DictData.dictType == 'education') {
if(DictData.dictType == 'education'){ const educationArr = DictData.educationArr
let educationArr = DictData.educationArr; tempWorkersParam.eduZh = e.value
tempWorkersParam.eduZh = e.value; for (let i = 0; i < educationArr.length; i++) {
for(let i = 0; i < educationArr.length; i++){ if (e.value == educationArr[i].itemText) {
if(e.value == educationArr[i].itemText){ tempWorkersParam.edu = Number.parseInt(educationArr[i].itemValue)
tempWorkersParam.edu = parseInt(educationArr[i].itemValue); break
break; }
} }
} }
} if (DictData.dictType == 'socialattributes') {
if(DictData.dictType == 'socialattributes'){ tempWorkersParam.attr = e.value
tempWorkersParam.attr = e.value; }
} pageData.attrPickerShow = false
pageData.attrPickerShow = false; }
}
// 出生日期的选择
// 出生日期的选择 function dateBirthChange(e) {
function dateBirthChange(e) { tempWorkersParam.birthday = e.result
tempWorkersParam.birthday = e.result; pageData.datePickerShow = false
pageData.datePickerShow = false; }
} function getDate(type) {
function getDate(type) { const date = new Date()
const date = new Date(); let year = date.getFullYear()
let year = date.getFullYear(); let month: any = date.getMonth() + 1
let month:any = date.getMonth() + 1; let day: any = date.getDate()
let day:any = date.getDate(); if (type === 'start') {
if (type === 'start') { year = year - 18
year = year - 18; } else if (type === 'end') {
} else if (type === 'end') { year = year + 10
year = year + 10; }
} month = month > 9 ? month : `0${month}`
month = month > 9 ? month : '0' + month; day = day > 9 ? day : `0${day}`
day = day > 9 ? day : '0' + day; return `${year}-${month}-${day}`
return `${year}-${month}-${day}`; }
} // 删除人员
// 删除人员 function delPersonData(name) {
function delPersonData(name){ Message.confirm(`你真的要删除【${name}】吗?`, '温馨提示').then(async (confirm) => {
Message.confirm('你真的要删除【'+name+'】吗?', '温馨提示').then(async (confirm) => { if (confirm) {
if(confirm){ pageData.workersParam.splice(pageData.editWorkersIndex, 1)
pageData.workersParam.splice(pageData.editWorkersIndex, 1); pageData.isPersonPopupShow = false
pageData.isPersonPopupShow = false }
} })
}) }
} // 添加人员
// 添加人员 function addPersonData() {
function addPersonData(){ tempWorkersParam.gender = Number.parseInt(tempWorkersParam.genderZh)
tempWorkersParam.gender = parseInt(tempWorkersParam.genderZh); const entries = Object.entries(VerificationInfo2)
let entries = Object.entries(VerificationInfo2); for (const [key, value] of entries) {
for (let [key, value] of entries) { if (tempWorkersParam[key].trim().length === 0) {
if(tempWorkersParam[key].trim().length === 0){ toastRef.value.show({
toastRef.value.show({ type: 'error',
type: 'error', text: value,
text: value, })
}) return
return; }
} }
} if (pageData.actionType == 'edit') {
if(pageData.actionType == 'edit'){ const editObj = pageData.workersParam[pageData.editWorkersIndex]
let editObj = pageData.workersParam[pageData.editWorkersIndex]; Object.keys(tempWorkersParam).forEach((item) => {
Object.keys(tempWorkersParam).forEach((item) => { editObj[item] = tempWorkersParam[item]
editObj[item] = tempWorkersParam[item]; })
}); } else {
}else{ pageData.workersParam.push(JSON.parse(JSON.stringify(tempWorkersParam)))
pageData.workersParam.push(JSON.parse(JSON.stringify(tempWorkersParam))); }
} pageData.isPersonPopupShow = false
pageData.isPersonPopupShow = false; }
} // 返回字典中的中文值
// 返回字典中的中文值 function returnDictZhVel(type: any, val: any) {
function returnDictZhVel(type:any,val:any){ let valText = ''
let valText = ""; if (type == 'gender') {
if(type == 'gender'){ const arr = DictData.sexArr
let arr = DictData.sexArr; for (let i = 0; i < arr.length; i++) {
for(let i = 0; i < arr.length;i++){ if (val == Number.parseInt(arr[i].itemValue)) {
if(val == parseInt(arr[i].itemValue)){ valText = arr[i].itemText
valText = arr[i].itemText; break
break; }
} }
} }
} if (type == 'edu') {
if(type == 'edu'){ const arr = DictData.educationArr
let arr = DictData.educationArr; for (let i = 0; i < arr.length; i++) {
for(let i = 0; i < arr.length;i++){ if (val == Number.parseInt(arr[i].itemValue)) {
if(val == parseInt(arr[i].itemValue)){ valText = arr[i].itemText
valText = arr[i].itemText; break
break; }
} }
} }
} return valText
return valText; }
}
// 选择出生日期
// 选择出生日期 function onPickerTap(e) {
function onPickerTap(e) { let dataVal = null
let dataVal = null,itemTextArr = []; const itemTextArr = []
DictData.dictType = e; DictData.dictType = e
if(DictData.dictType == 'education'){ if (DictData.dictType == 'education') {
dataVal = DictData.educationArr; dataVal = DictData.educationArr
for(let i = 0; i < dataVal.length; i++){ for (let i = 0; i < dataVal.length; i++) {
itemTextArr.push(dataVal[i].itemText); itemTextArr.push(dataVal[i].itemText)
} }
} }
if(DictData.dictType == 'socialattributes'){ if (DictData.dictType == 'socialattributes') {
dataVal = DictData.socialattributesArr; dataVal = DictData.socialattributesArr
for(let i = 0; i < dataVal.length; i++){ for (let i = 0; i < dataVal.length; i++) {
itemTextArr.push(dataVal[i].itemText); itemTextArr.push(dataVal[i].itemText)
} }
} }
DictData.dictValArr = itemTextArr; DictData.dictValArr = itemTextArr
pageData.attrPickerShow = true pageData.attrPickerShow = true
} }
// 打开添加人员弹出框 // 打开添加人员弹出框
function openAddPersonPopup(){ function openAddPersonPopup() {
tempWorkersParam.id=null; tempWorkersParam.id = null
tempWorkersParam.laborId=null; tempWorkersParam.laborId = null
tempWorkersParam.name=""; tempWorkersParam.name = ''
tempWorkersParam.mobile=""; tempWorkersParam.mobile = ''
tempWorkersParam.gender=""; tempWorkersParam.gender = ''
tempWorkersParam.genderZh=""; tempWorkersParam.genderZh = ''
tempWorkersParam.birthday=""; tempWorkersParam.birthday = ''
tempWorkersParam.edu=""; tempWorkersParam.edu = ''
tempWorkersParam.eduZh=""; tempWorkersParam.eduZh = ''
tempWorkersParam.attr=""; tempWorkersParam.attr = ''
tempWorkersParam.skill=""; tempWorkersParam.skill = ''
pageData.actionType = "add"; pageData.actionType = 'add'
pageData.isPersonPopupShow = true; pageData.isPersonPopupShow = true
} }
// 编辑找人干活待业人员 // 编辑找人干活待业人员
function editPersonPopup(index){ function editPersonPopup(index) {
let workersParamObj = pageData.workersParam[index]; const workersParamObj = pageData.workersParam[index]
workersParamObj.eduZh = returnDictZhVel('edu',workersParamObj.edu); workersParamObj.eduZh = returnDictZhVel('edu', workersParamObj.edu)
if(pageType == 'edit'){ if (pageType == 'edit') {
workersParamObj.genderZh = workersParamObj.gender+''; workersParamObj.genderZh = `${workersParamObj.gender}`
startDate = workersParamObj.birthday; startDate = workersParamObj.birthday
} }
// workersParamObj.skill.split("、"); // workersParamObj.skill.split("、");
Object.keys(workersParamObj).forEach((item) => { Object.keys(workersParamObj).forEach((item) => {
tempWorkersParam[item] = workersParamObj[item]; tempWorkersParam[item] = workersParamObj[item]
}); })
pageData.actionType = "edit"; pageData.actionType = 'edit'
pageData.editWorkersIndex = index; pageData.editWorkersIndex = index
pageData.isPersonPopupShow = true; pageData.isPersonPopupShow = true
} }
function colChange(e) { function colChange(e) {
switch (e.detail.column){ switch (e.detail.column) {
case 0://选择市 case 0: // 选择市
pageData.provinceId = pageData.mulSelect[0][e.detail.value].code; pageData.provinceId = pageData.mulSelect[0][e.detail.value].code
// 获取对应的 区县 // 获取对应的 区县
LinghuoyonggongAPI.queryConditions({ parentCode : pageData.provinceId}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: pageData.provinceId }).then((res) => {
pageData.city = res; pageData.city = res
pageData.mulSelect[1]= pageData.city; pageData.mulSelect[1] = pageData.city
// 获取对应的乡镇 // 获取对应的乡镇
LinghuoyonggongAPI.queryConditions({ parentCode : pageData.city[0].code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: pageData.city[0].code }).then((res) => {
pageData.district = res; pageData.district = res
pageData.mulSelect[2]= pageData.district; pageData.mulSelect[2] = pageData.district
// 获取对应的村 // 获取对应的村
LinghuoyonggongAPI.queryConditions({ parentCode : pageData.district[0].code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: pageData.district[0].code }).then((res) => {
pageData.street = res; pageData.street = res
if(res.length){ if (res.length) {
pageData.mulSelect[3]= pageData.street; pageData.mulSelect[3] = pageData.street
} }
}) })
}) })
}) })
break; break
case 1://选择区县 case 1: // 选择区县
pageData.cityId=pageData.mulSelect[1][e.detail.value].code; pageData.cityId = pageData.mulSelect[1][e.detail.value].code
// 获取对应的乡镇 // 获取对应的乡镇
LinghuoyonggongAPI.queryConditions({ parentCode :pageData.cityId}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: pageData.cityId }).then((res) => {
pageData.district = res; pageData.district = res
pageData.mulSelect[2]=pageData.district; pageData.mulSelect[2] = pageData.district
// 获取对应的村 // 获取对应的村
LinghuoyonggongAPI.queryConditions({ parentCode :pageData.district[0].code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: pageData.district[0].code }).then((res) => {
if(res.length){ if (res.length) {
pageData.street = res; pageData.street = res
pageData.mulSelect[3]=pageData.street; pageData.mulSelect[3] = pageData.street
} }
}) })
}) })
break; break
case 2://选择镇 case 2: // 选择镇
pageData.districtId=pageData.mulSelect[2][e.detail.value].code; pageData.districtId = pageData.mulSelect[2][e.detail.value].code
LinghuoyonggongAPI.queryConditions({ parentCode :pageData.districtId}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: pageData.districtId }).then((res) => {
if(res.length){ if (res.length) {
pageData.street = res; pageData.street = res
pageData.mulSelect[3]=pageData.street; pageData.mulSelect[3] = pageData.street
} }
}); })
break; break
default: default:
break; break
} }
} }
function getProvince() { function getProvince() {
LinghuoyonggongAPI.queryConditions({ parentCode : 43 }).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: 43 }).then((res) => {
pageData.province = []; pageData.province = []
pageData.province = res; pageData.province = res
pageData.mulSelect.push(pageData.province); pageData.mulSelect.push(pageData.province)
let code = pageData.province[0].code; const code = pageData.province[0].code
LinghuoyonggongAPI.queryConditions({ parentCode : code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: code }).then((res) => {
pageData.city = res; pageData.city = res
pageData.mulSelect.push(pageData.city); pageData.mulSelect.push(pageData.city)
let code = pageData.city[0].code; const code = pageData.city[0].code
LinghuoyonggongAPI.queryConditions({ parentCode : code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: code }).then((res) => {
pageData.district = res; pageData.district = res
pageData.mulSelect.push(pageData.district); pageData.mulSelect.push(pageData.district)
let code = pageData.district[0].code; const code = pageData.district[0].code
LinghuoyonggongAPI.queryConditions({ parentCode : code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: code }).then((res) => {
pageData.street = res; pageData.street = res
if(res.length){ if (res.length) {
pageData.mulSelect.push(pageData.street); pageData.mulSelect.push(pageData.street)
} }
}) })
}) })
}) })
}) })
} }
function pickerChange(e) { function pickerChange(e) {
for(var i=0;i<e.detail.value.length;i++){ for (let i = 0; i < e.detail.value.length; i++) {
if(e.detail.value[i]===null){ if (e.detail.value[i] === null) {
e.detail.value[i]=0; e.detail.value[i] = 0
} }
} }
let s_province = pageData.mulSelect[0][e.detail.value[0]]; const s_province = pageData.mulSelect[0][e.detail.value[0]]
let s_city = pageData.mulSelect[1][e.detail.value[1]||0]; const s_city = pageData.mulSelect[1][e.detail.value[1] || 0]
let s_district = pageData.mulSelect[2][e.detail.value[2]||0]; const s_district = pageData.mulSelect[2][e.detail.value[2] || 0]
let s_street = null; let s_street = null
if(e.detail.value.length == 4){ if (e.detail.value.length == 4) {
s_street = pageData.mulSelect[3][e.detail.value[3]||0]; 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.cityName = s_province.name
pageData.laborParam.districtName = s_city.name; pageData.laborParam.districtName = s_city.name
pageData.laborParam.townName = s_district.name; pageData.laborParam.townName = s_district.name
pageData.laborParam.villageName = s_street.name; pageData.laborParam.villageName = s_street.name
pageData.laborParam.cityCode = s_province.code; pageData.laborParam.cityCode = s_province.code
pageData.laborParam.districtCode = s_city.code; pageData.laborParam.districtCode = s_city.code
pageData.laborParam.townCode = s_district.code; pageData.laborParam.townCode = s_district.code
pageData.laborParam.villageCode = s_street.code; pageData.laborParam.villageCode = s_street.code
}else{ } 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.cityName = s_province.name
pageData.laborParam.districtName = s_city.name; pageData.laborParam.districtName = s_city.name
pageData.laborParam.townName = s_district.name; pageData.laborParam.townName = s_district.name
pageData.laborParam.cityCode = s_province.code; pageData.laborParam.cityCode = s_province.code
pageData.laborParam.districtCode = s_city.code; pageData.laborParam.districtCode = s_city.code
pageData.laborParam.townCode = s_district.code; pageData.laborParam.townCode = s_district.code
} }
pageData.isActive=true; pageData.isActive = true
} }
/* ****************************************************** */ /* ****************************************************** */
const { show, options, form } = toRefs(pageData)
const { show, options, form } = toRefs(pageData);
async function initDict() { async function initDict() {
pageData.options.area = await getDictData(); pageData.options.area = await getDictData()
pageData.options.urgentdegree = dictStore.getDictList.employment_urgent.map((item) => { pageData.options.urgentdegree = dictStore.getDictList.employment_urgent.map((item) => {
return { return {
value: item.value, value: item.value,
...@@ -540,8 +547,8 @@ ...@@ -540,8 +547,8 @@
} }
function getCurrentAddressInfo() { function getCurrentAddressInfo() {
if (!uni.getStorageSync('location')) if (!uni.getStorageSync('location'))
return return
const { lon, lat } = uni.getStorageSync('location') const { lon, lat } = uni.getStorageSync('location')
pageData.position = [lon, lat] pageData.position = [lon, lat]
...@@ -561,11 +568,11 @@ ...@@ -561,11 +568,11 @@
pageData.loading = true pageData.loading = true
LinghuoyonggongAPI.getLaborAppDetail({ id }) LinghuoyonggongAPI.getLaborAppDetail({ id })
.then((res) => { .then((res) => {
pageData.laborParam.addr = res.villageName; pageData.laborParam.addr = res.villageName
pageData.laborParam.contactName = res.contactName; pageData.laborParam.contactName = res.contactName
pageData.laborParam.contactMobile = res.contactMobile; pageData.laborParam.contactMobile = res.contactMobile
pageData.workersParam = res.workers; pageData.workersParam = res.workers
pageData.isActive = true; pageData.isActive = true
}) })
.finally(() => { .finally(() => {
pageData.loading = false pageData.loading = false
...@@ -677,52 +684,52 @@ ...@@ -677,52 +684,52 @@
} }
}) })
} }
// 发布灵活用工 // 发布灵活用工
function submitLaborAdd(){ function submitLaborAdd() {
let laborParam = pageData.laborParam; const laborParam = pageData.laborParam
if (pageData.position.length == 0) { if (pageData.position.length == 0) {
toastRef.value.show({ toastRef.value.show({
type: 'error', type: 'error',
text: '无法获取位置', text: '无法获取位置',
}) })
return return
} }
laborParam.lon = pageData.position[0]; laborParam.lon = pageData.position[0]
laborParam.lat = pageData.position[1]; laborParam.lat = pageData.position[1]
let entries = Object.entries(VerificationInfo1); const entries = Object.entries(VerificationInfo1)
for (let [key, value] of entries) { for (const [key, value] of entries) {
if(laborParam[key].trim().length === 0){ if (laborParam[key].trim().length === 0) {
toastRef.value.show({ toastRef.value.show({
type: 'error', type: 'error',
text: value, text: value,
}) })
return; return
} }
} }
if(!pageData.workersParam.length){ if (!pageData.workersParam.length) {
toastRef.value.show({ toastRef.value.show({
type: 'error', type: 'error',
text: '请选择待业人员', text: '请选择待业人员',
}) })
return; return
} }
let formData = { const formData = {
laborParam:laborParam, laborParam,
workersParam:pageData.workersParam workersParam: pageData.workersParam,
} }
LinghuoyonggongAPI.postLaborAdd(formData).then((res) => { LinghuoyonggongAPI.postLaborAdd(formData).then((res) => {
toastRef.value.show({ toastRef.value.show({
type: 'success', type: 'success',
text: '发布成功', text: '发布成功',
}) })
setTimeout(()=>{ setTimeout(() => {
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1,
}); })
},1000) }, 1000)
}) })
} }
function getCurrentDate(){ function getCurrentDate() {
const date = new Date() const date = new Date()
const year = date.getFullYear() const year = date.getFullYear()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
...@@ -734,140 +741,264 @@ ...@@ -734,140 +741,264 @@
<template> <template>
<view class="page"> <view class="page">
<view class="bg_white formBox"> <view class="bg_white formBox">
<view class="form_view"> <view class="form_view">
<view class="yr-form"> <view class="yr-form">
<view class="yr-form-item"> <view class="yr-form-item">
<view class="yr-form-title"><text class="required-mark">*</text>村名称</view> <view class="yr-form-title"><text class="required-mark">*</text>村名称</view>
<picker class="yr-form-input" indicator-class="yr-form-village" mode="multiSelector" :range="pageData.mulSelect" :range-key="'name'" @change="pickerChange" @columnchange="colChange"> <picker
<view class="yr-input-placeholder" v-if="!pageData.isActive">请选择</view> class="yr-form-input"
<view v-else class="yr-input-style">{{pageData.laborParam.addr}}</view> indicator-class="yr-form-village"
</picker> mode="multiSelector"
</view> :range="pageData.mulSelect"
<view class="yr-form-item"> range-key="name"
<view class="yr-form-title"><text class="required-mark">*</text>联系人</view> @change="pickerChange"
<input class="yr-form-input" v-model="pageData.laborParam.contactName" name="input" placeholder="请填写联系人姓名" /> @columnchange="colChange"
</view> >
<view class="yr-form-item border-bottom-none"> <view class="yr-input-placeholder" v-if="!pageData.isActive">请选择</view>
<view class="yr-form-title"><text class="required-mark">*</text>联系电话</view> <view v-else class="yr-input-style">{{ pageData.laborParam.addr }}</view>
<input class="yr-form-input" v-model="pageData.laborParam.contactMobile" type="tel" :maxlength="11" placeholder="请填写联系电话" /> </picker>
</view> </view>
</view> <view class="yr-form-item">
</view> <view class="yr-form-title"><text class="required-mark">*</text>联系人</view>
<input
class="yr-form-input"
v-model="pageData.laborParam.contactName"
name="input"
placeholder="请填写联系人姓名"
/>
</view>
<view class="yr-form-item border-bottom-none">
<view class="yr-form-title"><text class="required-mark">*</text>联系电话</view>
<input
class="yr-form-input"
v-model="pageData.laborParam.contactMobile"
type="tel"
:maxlength="11"
placeholder="请填写联系电话"
/>
</view>
</view>
</view>
</view>
<!-- 待业人员 -->
<view class="bg_white formBox unemployed_person">
<view class="form_view">
<view class="yr-form">
<view class="yr-form-item border-bottom-none">
<view class="yr-form-title"><text class="required-mark">*</text>待业人员</view>
<view class="yr_add_btn" @click="openAddPersonPopup()">
<image class="add_person_icon" src="/static/images/linghuoyonggong/add_person.png" />
<view class="add_person_text">添加人员</view>
</view>
</view>
<view class="yr-person-item" v-for="(item, index) in pageData.workersParam" :key="index">
<view class="yr-person-info">
<view class="person_name_attr"
>{{ item.name }}<text class="person_attr">{{ item.attr }}</text></view
>
<view class="person-info"
>{{ getCalculateAge(item.birthday) }}{{ returnDictZhVel('gender', item.gender) }}{{
returnDictZhVel('edu', item.edu)
}}</view
>
<view class="person-info text_overflow_ellipsis">技能:{{ item.skill }}</view>
</view>
<view class="edit_person" @click="editPersonPopup(index)">
<image class="edit_person_icon" src="/static/images/linghuoyonggong/edit_person.png" />
</view>
</view>
</view>
</view>
</view>
<view class="yr-submit-btn">
<view class="submit-btn-view">
<fui-button text="发布" bold radius="96rpx" @click="submitLaborAdd" height="80rpx" />
</view>
</view> </view>
<!-- 待业人员 -->
<view class="bg_white formBox unemployed_person">
<view class="form_view">
<view class="yr-form">
<view class="yr-form-item border-bottom-none">
<view class="yr-form-title"><text class="required-mark">*</text>待业人员</view>
<view class="yr_add_btn" @click="openAddPersonPopup()">
<image class="add_person_icon" src="/static/images/linghuoyonggong/add_person.png" />
<view class="add_person_text">添加人员</view>
</view>
</view>
<view class="yr-person-item" v-for="(item,index) in pageData.workersParam" :key="index">
<view class="yr-person-info">
<view class="person_name_attr">{{item.name}}<text class="person_attr">{{item.attr}}</text></view>
<view class="person-info">{{getCalculateAge(item.birthday)}}{{ returnDictZhVel('gender',item.gender) }}{{ returnDictZhVel('edu',item.edu)}}</view>
<view class="person-info text_overflow_ellipsis">技能:{{item.skill}}</view>
</view>
<view class="edit_person" @click="editPersonPopup(index)">
<image class="edit_person_icon" src="/static/images/linghuoyonggong/edit_person.png" />
</view>
</view>
</view>
</view>
</view>
<view class="yr-submit-btn">
<view class="submit-btn-view">
<fui-button text="发布" bold radius="96rpx" @click="submitLaborAdd" height="80rpx"/>
</view>
</view>
</view> </view>
<fui-date-picker :show="show.time1" type="3" @change="handleChangeTime1" :min-date="getCurrentDate()" @cancel="show.time1 = false" /> <fui-date-picker
<fui-date-picker :show="show.time2" type="3" @change="handleChangeTime2" :min-date="getCurrentDate()" @cancel="show.time2 = false" /> :show="show.time1"
<fui-picker :show="show.type" :layer="1" :linkage="true" :options="options.type" @change="handleChangetype" @cancel="show.type = false" /> type="3"
<fui-picker :show="show.urgentdegree" :layer="1" :linkage="true" :options="options.urgentdegree" @change="handleChangeUrgentdegree" @cancel="show.urgentdegree = false"/> @change="handleChangeTime1"
<fui-picker :show="show.area" :options="options.area" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.area = false" /> :min-date="getCurrentDate()"
<fui-toast ref="toastRef" /> @cancel="show.time1 = false"
/>
<fui-date-picker
:show="show.time2"
type="3"
@change="handleChangeTime2"
:min-date="getCurrentDate()"
@cancel="show.time2 = false"
/>
<fui-picker
:show="show.type"
:layer="1"
:linkage="true"
:options="options.type"
@change="handleChangetype"
@cancel="show.type = false"
/>
<fui-picker
:show="show.urgentdegree"
:layer="1"
:linkage="true"
:options="options.urgentdegree"
@change="handleChangeUrgentdegree"
@cancel="show.urgentdegree = false"
/>
<fui-picker
:show="show.area"
:options="options.area"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="show.area = false"
/>
<fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
<!-- 普通弹窗 --> <!-- 普通弹窗 -->
<fui-bottom-popup :show="pageData.isPersonPopupShow" @close="pageData.isPersonPopupShow = false"> <fui-bottom-popup :show="pageData.isPersonPopupShow" @close="pageData.isPersonPopupShow = false">
<view class="fui-custom__wrap yr_person_popup"> <view class="fui-custom__wrap yr_person_popup">
<view class="popup_top"> <view class="popup_top">
<uni-icons type="left" size="24" color="#333333" @click="pageData.isPersonPopupShow = false"></uni-icons> <uni-icons type="left" size="24" color="#333333" @click="pageData.isPersonPopupShow = false" />
<view class="add_person_text">{{pageData.actionType == 'edit'?'编辑':'添加'}}人员</view> <view class="add_person_text">{{ pageData.actionType == 'edit' ? '编辑' : '添加' }}人员</view>
<view class="del_person_btn" v-if="pageData.actionType == 'edit'" @click="delPersonData(tempWorkersParam.name)">删除</view> <view
<view class="del_person_btn" v-else></view> class="del_person_btn"
</view> v-if="pageData.actionType == 'edit'"
<view class="popup_content"> @click="delPersonData(tempWorkersParam.name)"
<fui-form error-position="1" ref="form" top="0" :model="tempWorkersParam" :show="false"> >删除</view
<fui-form-item label="姓名"> >
<fui-input :borderBottom="false" v-model="tempWorkersParam.name" :padding="[0]" placeholder="请输入姓名"></fui-input> <view class="del_person_btn" v-else />
</fui-form-item> </view>
<fui-form-item label="手机号"> <view class="popup_content">
<fui-input type="tel" :borderBottom="false" v-model="tempWorkersParam.mobile" :padding="[0]" placeholder="请输入手机号"></fui-input> <fui-form error-position="1" ref="form" top="0" :model="tempWorkersParam" :show="false">
</fui-form-item> <fui-form-item label="姓名">
<fui-form-item label="性别"> <fui-input
<fui-radio-group v-model="tempWorkersParam.genderZh"> :borderBottom="false"
<fui-label inline v-for="item in DictData.sexArr" :key="item.id"> v-model="tempWorkersParam.name"
<fui-radio :value="item.itemValue"></fui-radio> :padding="[0]"
<fui-text :size="28" :text="item.itemText" :padding="['0','30rpx','0','16rpx']"></fui-text> placeholder="请输入姓名"
</fui-label> />
</fui-radio-group> </fui-form-item>
</fui-form-item> <fui-form-item label="手机号">
<fui-form-item label="出生日期" highlight> <fui-input
<fui-input :borderBottom="false" @click="pageData.datePickerShow = true" v-model="tempWorkersParam.birthday" :padding="[0]" :disabled="true" placeholder="请选择出生日期" type="tel"
backgroundColor="transparent"></fui-input> :borderBottom="false"
<!-- <picker class="publish_empl_picker" mode="date" :value="startDate" :end="endDate" @change="dateBirthChange"> v-model="tempWorkersParam.mobile"
:padding="[0]"
placeholder="请输入手机号"
/>
</fui-form-item>
<fui-form-item label="性别">
<fui-radio-group v-model="tempWorkersParam.genderZh">
<fui-label inline v-for="item in DictData.sexArr" :key="item.id">
<fui-radio :value="item.itemValue" />
<fui-text :size="28" :text="item.itemText" :padding="['0', '30rpx', '0', '16rpx']" />
</fui-label>
</fui-radio-group>
</fui-form-item>
<fui-form-item label="出生日期" highlight>
<fui-input
:borderBottom="false"
@click="pageData.datePickerShow = true"
v-model="tempWorkersParam.birthday"
:padding="[0]"
:disabled="true"
placeholder="请选择出生日期"
backgroundColor="transparent"
/>
<!-- <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="请选择出生日期" <fui-input :borderBottom="false" v-model="tempWorkersParam.birthday" :padding="[0]" :disabled="true" placeholder="请选择出生日期"
backgroundColor="transparent"></fui-input> backgroundColor="transparent"></fui-input>
</picker> --> </picker> -->
</fui-form-item> </fui-form-item>
<fui-form-item label="学历" highlight @click="onPickerTap('education')"> <fui-form-item label="学历" highlight @click="onPickerTap('education')">
<fui-input v-model="tempWorkersParam.eduZh" :borderBottom="false" :padding="[0]" placeholder="请选择学历" :disabled="true" <fui-input
backgroundColor="transparent"></fui-input> v-model="tempWorkersParam.eduZh"
</fui-form-item> :borderBottom="false"
<fui-form-item label="人员属性" highlight @click="onPickerTap('socialattributes')"> :padding="[0]"
<fui-input v-model="tempWorkersParam.attr" :borderBottom="false" :padding="[0]" placeholder="请选择人员属性" :disabled="true" placeholder="请选择学历"
backgroundColor="transparent"></fui-input> :disabled="true"
</fui-form-item> backgroundColor="transparent"
<fui-form-item label="人员技能" highlight @click="DictData.isSkillPopupShow = true"> />
<fui-input v-model="tempWorkersParam.skill" :borderBottom="false" :padding="[0]" placeholder="请选择人员技能" :disabled="true" </fui-form-item>
backgroundColor="transparent"></fui-input> <fui-form-item label="人员属性" highlight @click="onPickerTap('socialattributes')">
</fui-form-item> <fui-input
</fui-form> v-model="tempWorkersParam.attr"
</view> :borderBottom="false"
<fui-button text="保存" bold radius="96rpx" @click="addPersonData" height="80rpx"/> :padding="[0]"
</view> placeholder="请选择人员属性"
</fui-bottom-popup> :disabled="true"
backgroundColor="transparent"
/>
<!-- <picker mode="date" :value="currentDate" :start="startDate" :end="endDate" @change="dateBirthChange"></picker> --> </fui-form-item>
<fui-picker :show="pageData.attrPickerShow" :zIndex="9999" layer="1" :options="DictData.dictValArr" :linkage="false" @change="attrChange" @cancel="pageData.attrPickerShow = false"></fui-picker> <fui-form-item label="人员技能" highlight @click="DictData.isSkillPopupShow = true">
<!-- 人员技能 --> <fui-input
<fui-bottom-popup :show="DictData.isSkillPopupShow"> v-model="tempWorkersParam.skill"
<view class="fui-scroll__wrap"> :borderBottom="false"
<view class="fui-title">请选择技能</view> :padding="[0]"
<fui-cascader ref="skillPopupRef" :value="DictData.skillValue" textSize="32" size="32" stepLoading @change="changeSkill" @complete="selectCompleteSkill" :options="DictData.skillOptionsVal"></fui-cascader> placeholder="请选择人员技能"
<view class="fui-icon__close" @tap.stop="DictData.isSkillPopupShow=false"> :disabled="true"
<fui-icon name="close" :size="48"></fui-icon> backgroundColor="transparent"
</view> />
</view> </fui-form-item>
</fui-bottom-popup> </fui-form>
<fui-date-picker :isShow="true" :zIndex="9999" :show="pageData.datePickerShow" type="3" :range="false" minDate="1940-01-01" :valueEnd="getCurrentDate()" :value="startDate" :maxDate="getCurrentDate()" @change="dateBirthChange" @cancel="pageData.datePickerShow=false"></fui-date-picker> </view>
<fui-button text="保存" bold radius="96rpx" @click="addPersonData" height="80rpx" />
<!-- <fui-date-picker :show="pageData.birthdayPickerIsShow" :type="type" :range="range" :value="value" :valueEnd="valueEnd" @change="change" </view>
</fui-bottom-popup>
<!-- <picker mode="date" :value="currentDate" :start="startDate" :end="endDate" @change="dateBirthChange"></picker> -->
<fui-picker
:show="pageData.attrPickerShow"
:zIndex="9999"
layer="1"
:options="DictData.dictValArr"
:linkage="false"
@change="attrChange"
@cancel="pageData.attrPickerShow = false"
/>
<!-- 人员技能 -->
<fui-bottom-popup :show="DictData.isSkillPopupShow">
<view class="fui-scroll__wrap">
<view class="fui-title">请选择技能</view>
<fui-cascader
ref="skillPopupRef"
:value="DictData.skillValue"
textSize="32"
size="32"
stepLoading
@change="changeSkill"
@complete="selectCompleteSkill"
:options="DictData.skillOptionsVal"
/>
<view class="fui-icon__close" @tap.stop="DictData.isSkillPopupShow = false">
<fui-icon name="close" :size="48" />
</view>
</view>
</fui-bottom-popup>
<fui-date-picker
:isShow="true"
:zIndex="9999"
:show="pageData.datePickerShow"
type="3"
:range="false"
minDate="1940-01-01"
:valueEnd="getCurrentDate()"
:value="startDate"
:maxDate="getCurrentDate()"
@change="dateBirthChange"
@cancel="pageData.datePickerShow = false"
/>
<!-- <fui-date-picker :show="pageData.birthdayPickerIsShow" :type="type" :range="range" :value="value" :valueEnd="valueEnd" @change="change"
@cancel="cancel"> @cancel="cancel">
</fui-date-picker> --> </fui-date-picker> -->
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -885,132 +1016,131 @@ ...@@ -885,132 +1016,131 @@
padding: 20rpx; padding: 20rpx;
border-radius: 10rpx; border-radius: 10rpx;
} }
.bg_white{ .bg_white {
background-color: #FFFFFF; background-color: #ffffff;
} }
.required-mark{ .required-mark {
color:#FF5733; color: #ff5733;
font-size: 28rpx; font-size: 28rpx;
margin-right: 4rpx; margin-right: 4rpx;
} }
.text_overflow_ellipsis{ .text_overflow_ellipsis {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.formBox { .formBox {
width: 690rpx; width: 690rpx;
margin: 30rpx auto; margin: 30rpx auto;
border-radius: 16rpx; border-radius: 16rpx;
display: flex; display: flex;
justify-content: center; justify-content: center;
flex-wrap: wrap; flex-wrap: wrap;
.form_view{ .form_view {
display: flex; display: flex;
justify-content: center; justify-content: center;
.yr-form{ .yr-form {
width: 642rpx; width: 642rpx;
} }
.border-bottom-none{ .border-bottom-none {
border-bottom: none !important; border-bottom: none !important;
} }
.yr-form-item{ .yr-form-item {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-content: center; align-content: center;
padding-top: 36rpx; padding-top: 36rpx;
padding-bottom: 36rpx; padding-bottom: 36rpx;
border-bottom: 2rpx solid #EEEEEE; border-bottom: 2rpx solid #eeeeee;
.yr-form-title{ .yr-form-title {
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
width: 132rpx; width: 132rpx;
} }
.yr-form-input{ .yr-form-input {
width: 480rpx; width: 480rpx;
} }
.yr-input-placeholder { .yr-input-placeholder {
font-size: 28rpx !important; font-size: 28rpx !important;
color: #999999 !important; color: #999999 !important;
} }
.yr-input-style{ .yr-input-style {
font-size: 30rpx; font-size: 30rpx;
color:#181818; color: #181818;
} }
} }
} }
.unemployed_person{ .unemployed_person {
margin-top: 24rpx; margin-top: 24rpx;
} }
.yr_add_btn{ .yr_add_btn {
display: flex; display: flex;
align-items: center; align-items: center;
.add_person_icon{ .add_person_icon {
width: 32rpx; width: 32rpx;
height: 32rpx; height: 32rpx;
} }
.add_person_text{ .add_person_text {
color: #5DB66F; color: #5db66f;
font-size: 28rpx; font-size: 28rpx;
margin-left: 20rpx; margin-left: 20rpx;
} }
} }
.yr-person-item{ .yr-person-item {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
border-bottom: 2rpx solid #EEEEEE; border-bottom: 2rpx solid #eeeeee;
margin-top: 28rpx; margin-top: 28rpx;
.yr-person-info{ .yr-person-info {
.person_name_attr{ .person_name_attr {
font-size: 28rpx; font-size: 28rpx;
font-weight: 500; font-weight: 500;
color: #333333; color: #333333;
.person_attr{ .person_attr {
font-size: 24rpx; font-size: 24rpx;
font-weight: 400; font-weight: 400;
color: #5DB66F; color: #5db66f;
margin-left: 12rpx; margin-left: 12rpx;
} }
} }
.person-info{ .person-info {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
vertical-align: middle; vertical-align: middle;
margin-bottom: 24rpx; margin-bottom: 24rpx;
margin-top: 24rpx; margin-top: 24rpx;
width: 512rpx; width: 512rpx;
} }
} }
.edit_person{ .edit_person {
width: 68rpx; width: 68rpx;
height: 88rpx; height: 88rpx;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
} }
.edit_person_icon{ .edit_person_icon {
width: 32rpx; width: 32rpx;
height: 28rpx; height: 28rpx;
} }
} }
.yr-person-item:last-child{ .yr-person-item:last-child {
border-bottom: none; border-bottom: none;
} }
}
.yr-submit-btn {
display: flex;
justify-content: center;
margin-top: 40rpx;
.submit-btn-view {
width: 690rpx;
}
} }
.yr-submit-btn{
display: flex;
justify-content: center;
margin-top: 40rpx;
.submit-btn-view{
width: 690rpx;
}
}
.form-section { .form-section {
// border-bottom: 1rpx solid #f5f5f5; // border-bottom: 1rpx solid #f5f5f5;
...@@ -1166,22 +1296,22 @@ ...@@ -1166,22 +1296,22 @@
color: #333; color: #333;
font-size: 28rpx; font-size: 28rpx;
} }
.fui-scroll__wrap { .fui-scroll__wrap {
padding-top: 30rpx; padding-top: 30rpx;
position: relative; position: relative;
} }
.fui-title { .fui-title {
font-size: 30rpx; font-size: 30rpx;
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
padding-bottom: 24rpx; padding-bottom: 24rpx;
} }
.fui-icon__close { .fui-icon__close {
position: absolute; position: absolute;
top: 24rpx; top: 24rpx;
right: 24rpx; right: 24rpx;
} }
</style> </style>
...@@ -56,16 +56,16 @@ ...@@ -56,16 +56,16 @@
}, },
], ],
rules: [ rules: [
{ {
name: 'username', name: 'username',
rule: ['required'], rule: ['required'],
msg: ['请输入账号'], msg: ['请输入账号'],
}, },
{ {
name: 'password', name: 'password',
rule: ['required'], rule: ['required'],
msg: ['请输入密码'], msg: ['请输入密码'],
}, },
/* { /* {
name: 'username', name: 'username',
rule: ['required'], rule: ['required'],
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
], ],
data: { data: {
username: '', username: '',
password:'', password: '',
// code: '', // code: '',
read: false, read: false,
deviceId: '', deviceId: '',
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
if (isDevMode()) { if (isDevMode()) {
model.form.data.username = '' model.form.data.username = ''
// model.form.data.code = '' // model.form.data.code = ''
model.form.data.password = '' model.form.data.password = ''
model.form.data.read = false model.form.data.read = false
} }
...@@ -118,14 +118,14 @@ ...@@ -118,14 +118,14 @@
mobile: model.form.data.username, mobile: model.form.data.username,
captcha: model.form.data.code, captcha: model.form.data.code,
} */ } */
const params = { const params = {
username: model.form.data.username, username: model.form.data.username,
password: model.form.data.password, password: model.form.data.password,
} }
// 短信登录 // 短信登录
model.loading = true model.loading = true
// API.phoneLogin(params) // API.phoneLogin(params)
API.sysLogin(params) API.sysLogin(params)
.then(async (body) => { .then(async (body) => {
console.log('body', body) console.log('body', body)
if (body) { if (body) {
...@@ -236,48 +236,47 @@ ...@@ -236,48 +236,47 @@
<fui-form class="form" ref="form" top="0" :padding="['0rpx', '0rpx']" background="#e46962"> <fui-form class="form" ref="form" top="0" :padding="['0rpx', '0rpx']" background="#e46962">
<view class="login_content"> <view class="login_content">
<view class="login-input-area"> <view class="login-input-area">
<view class="user_phone"> <view class="user_phone">
<image class="user_phone_img" src="/static/images/register/user.png" /> <image class="user_phone_img" src="/static/images/register/user.png" />
<view class="user_text_view"><text class="view_text">账号</text></view> <view class="user_text_view"><text class="view_text">账号</text></view>
</view> </view>
<view class="input-bottom-border"> <view class="input-bottom-border">
<fui-input <fui-input
height="94rpx" height="94rpx"
:padding="['0rpx', '0rpx', '0rpx', '12rpx']" :padding="['0rpx', '0rpx', '0rpx', '12rpx']"
class="input" class="input"
autocomplete="off" autocomplete="off"
:required="false" :required="false"
clearable clearable
trim trim
placeholder="请输入账号" placeholder="请输入账号"
v-model="model.form.data.username" v-model="model.form.data.username"
name="mobile" name="mobile"
backgroundColor="transparent" backgroundColor="transparent"
borderColor="transparent" borderColor="transparent"
maxlength="11" maxlength="11"
/> />
</view> </view>
<view class="user_phone mt50"> <view class="user_phone mt50">
<image class="user_phone_img" src="/static/images/register/pwd.png" /> <image class="user_phone_img" src="/static/images/register/pwd.png" />
<view class="user_text_view"><text class="view_text">密码</text></view> <view class="user_text_view"><text class="view_text">密码</text></view>
</view> </view>
<view class="input-bottom-border"> <view class="input-bottom-border">
<fui-input <fui-input
height="94rpx" height="94rpx"
:padding="['0rpx', '0rpx', '0rpx', '12rpx']" :padding="['0rpx', '0rpx', '0rpx', '12rpx']"
class="input" class="input"
password password
clearable clearable
trim trim
placeholder="请输入密码" placeholder="请输入密码"
v-model="model.form.data.password" v-model="model.form.data.password"
backgroundColor="transparent" backgroundColor="transparent"
borderColor="transparent" borderColor="transparent"
> />
</fui-input> </view>
</view> </view>
</view>
<!-- <view class="login-input-area"> <!-- <view class="login-input-area">
<view class="user_phone"> <view class="user_phone">
<image class="user_phone_img" src="/static/images/register/user.png" /> <image class="user_phone_img" src="/static/images/register/user.png" />
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import * as NewsApi from '@/api/model/news'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import * as NewsApi from '@/api/model/news'
interface News { interface News {
id: number id: number
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
const navigateName = ref(['热点新闻', '农业政策']) const navigateName = ref(['热点新闻', '农业政策'])
async function getNewsList(params) { async function getNewsList(params) {
if (model.loading) return if (model.loading)
return
model.loading = true model.loading = true
NewsApi.getList(params).then((res) => { NewsApi.getList(params).then((res) => {
if (res.records.length > 0) { if (res.records.length > 0) {
...@@ -129,7 +130,7 @@ ...@@ -129,7 +130,7 @@
<image class="mt-0.5 mr-1 w-30 h-26" src="/static/images/news/views.png" /> <image class="mt-0.5 mr-1 w-30 h-26" src="/static/images/news/views.png" />
<view class="flex-center text-24 lh-24rpx">{{ news.viewCount }}</view> <view class="flex-center text-24 lh-24rpx">{{ news.viewCount }}</view>
</view> </view>
<view v-show="!news.posterUrl" class="w-4%"></view> <view v-show="!news.posterUrl" class="w-4%" />
</view> </view>
</view> </view>
<view v-show="news.posterUrl" class="w-30% h-130"> <view v-show="news.posterUrl" class="w-30% h-130">
......
<script setup lang="ts"> <script setup lang="ts">
import dayjs from 'dayjs' import dayjs from 'dayjs'
import * as WeatherAPI from '@/api/model/weather' import * as WeatherAPI from '@/api/model/weather'
import { Echarts, useEcharts } from '@/components/Echarts' import { Echarts, useEcharts } from '@/components/Echarts'
import { getDayLabelValue, getWeatherIcon } from '@/utils/weather' import { getDayLabelValue, getWeatherIcon } from '@/utils/weather'
// 逐 7 天预报图表 // 逐 7 天预报图表
const [register7Forecast, Forecast7Chart] = useEcharts() const [register7Forecast, Forecast7Chart] = useEcharts()
const model = reactive({ const model = reactive({
days: 15, days: 15,
updateTime: '-', updateTime: '-',
})
onLoad(async () => {
const location = uni.getStorageSync('location')
const forecasts = await WeatherAPI.forecast(`${location.lon},${location.lat}`, model.days).then((res) => {
model.updateTime = dayjs(res.data.updateTime).format('YYYY-MM-DD HH:mm')
return res.data.daily
}) })
console.log('forecasts', forecasts)
// 逐 7 天预报数据 onLoad(async () => {
const _7DayForecastData = forecasts.map((item, index) => { const location = uni.getStorageSync('location')
return { const forecasts = await WeatherAPI.forecast(`${location.lon},${location.lat}`, model.days).then((res) => {
minTem: item.tempMin, model.updateTime = dayjs(res.data.updateTime).format('YYYY-MM-DD HH:mm')
maxTem: item.tempMax, return res.data.daily
textDay: item.textDay, })
textNight: item.textNight, console.log('forecasts', forecasts)
dayWeather: item.iconDay,
nightWeather: item.iconNight,
fxDate: item.fxDate,
...getDayLabelValue(index),
}
})
const _7DayForecastMaxTemValue = Math.max(..._7DayForecastData.map((item) => Number(item.maxTem)))
// 设置逐 7 天预报图表参数 // 逐 7 天预报数据
Forecast7Chart.setOption({ const _7DayForecastData = forecasts.map((item, index) => {
tooltip: { return {
show: true, minTem: item.tempMin,
trigger: 'axis', maxTem: item.tempMax,
axisPointer: { textDay: item.textDay,
type: 'shadow', textNight: item.textNight,
}, dayWeather: item.iconDay,
formatter: (params) => { nightWeather: item.iconNight,
// 过滤掉星期标签、日期标签和天气图标 fxDate: item.fxDate,
const filteredParams = params.filter(param => { ...getDayLabelValue(index),
return param.seriesName !== '星期标签' &&
param.seriesName !== '日期标签' &&
param.seriesName !== '天气图标';
});
if (filteredParams.length === 0) return '';
let result = '';
filteredParams.forEach(param => {
// 只显示有意义的数值信息
if (param.seriesName === '最高温度' || param.seriesName === '最低温度') {
result += `${param.seriesName}: ${param.value}°<br/>`;
}
});
return result;
} }
}, })
grid: { const _7DayForecastMaxTemValue = Math.max(..._7DayForecastData.map((item) => Number(item.maxTem)))
top: '5%',
bottom: '10%', // 设置逐 7 天预报图表参数
left: '0', Forecast7Chart.setOption({
right: '3%', tooltip: {
}, show: true,
xAxis: { trigger: 'axis',
type: 'category', axisPointer: {
data: _7DayForecastData.map((item) => item.textNight), type: 'shadow',
axisLine: { },
show: false, formatter: (params) => {
}, // 过滤掉星期标签、日期标签和天气图标
axisTick: { const filteredParams = params.filter((param) => {
show: false, return (
}, param.seriesName !== '星期标签' &&
axisLabel: { param.seriesName !== '日期标签' &&
show: true, // 隐藏x轴标签 param.seriesName !== '天气图标'
interval: 0, )
color: '#999', })
fontSize: 11, if (filteredParams.length === 0) return ''
},
}, let result = ''
yAxis: { filteredParams.forEach((param) => {
type: 'value', // 只显示有意义的数值信息
splitLine: { if (param.seriesName === '最高温度' || param.seriesName === '最低温度') {
show: false, result += `${param.seriesName}: ${param.value}°<br/>`
}, }
axisLabel: { })
show: false, return result
}, },
},
series: [
// 顶部星期标签(今天、明天、周X)- 第一行
{
name: '星期标签',
type: 'scatter',
data: _7DayForecastData.map((item, index) => {
return {
value: [index, Number(_7DayForecastMaxTemValue) + 13],
symbolSize: 0,
label: {
show: true,
position: 'top',
formatter: item.label,
fontSize: 14,
color: '#333333',
fontWeight: 'bold',
},
}
}),
}, },
// 顶部日期标签(09/10)- 第二行 grid: {
{ top: '5%',
name: '日期标签', bottom: '10%',
type: 'scatter', left: '0',
data: _7DayForecastData.map((item, index) => { right: '3%',
return {
value: [index, Number(_7DayForecastMaxTemValue) + 10],
symbolSize: 0,
label: {
show: true,
position: 'top',
formatter: `${item.value}`,
fontSize: 12,
color: '#666666',
},
}
}),
}, },
{ xAxis: {
name: '日期标签', type: 'category',
type: 'scatter', data: _7DayForecastData.map((item) => item.textNight),
data: _7DayForecastData.map((item, index) => { axisLine: {
return { show: false,
value: [index, Number(_7DayForecastMaxTemValue) + 7], },
symbolSize: 0, axisTick: {
label: { show: false,
show: true, },
position: 'top', axisLabel: {
formatter: `${item.textDay}`, show: true, // 隐藏x轴标签
fontSize: 12, interval: 0,
color: '#666666', color: '#999',
}, fontSize: 11,
} },
}),
}, },
// 天气图标 - 第三行 yAxis: {
{ type: 'value',
name: '天气图标', splitLine: {
type: 'scatter', show: false,
data: _7DayForecastData.map((item, index) => { },
return { axisLabel: {
value: [index, Number(_7DayForecastMaxTemValue) + 5], show: false,
symbol: `image://${getWeatherIcon(String(item.dayWeather))}`, },
symbolSize: [28, 28],
}
}),
}, },
series: [
// 最高温度线 // 顶部星期标签(今天、明天、周X)- 第一行
{ {
name: '最高温度', name: '星期标签',
type: 'line', type: 'scatter',
data: _7DayForecastData.map((item) => item.maxTem), data: _7DayForecastData.map((item, index) => {
smooth: true, return {
color: '#F79D80', value: [index, Number(_7DayForecastMaxTemValue) + 13],
symbolSize: 6, symbolSize: 0,
label: { label: {
show: true, show: true,
position: 'top', position: 'top',
formatter: '{c}°', formatter: item.label,
fontSize: 14,
color: '#333333',
fontWeight: 'bold',
},
}
}),
},
// 顶部日期标签(09/10)- 第二行
{
name: '日期标签',
type: 'scatter',
data: _7DayForecastData.map((item, index) => {
return {
value: [index, Number(_7DayForecastMaxTemValue) + 10],
symbolSize: 0,
label: {
show: true,
position: 'top',
formatter: `${item.value}`,
fontSize: 12,
color: '#666666',
},
}
}),
},
{
name: '日期标签',
type: 'scatter',
data: _7DayForecastData.map((item, index) => {
return {
value: [index, Number(_7DayForecastMaxTemValue) + 7],
symbolSize: 0,
label: {
show: true,
position: 'top',
formatter: `${item.textDay}`,
fontSize: 12,
color: '#666666',
},
}
}),
},
// 天气图标 - 第三行
{
name: '天气图标',
type: 'scatter',
data: _7DayForecastData.map((item, index) => {
return {
value: [index, Number(_7DayForecastMaxTemValue) + 5],
symbol: `image://${getWeatherIcon(String(item.dayWeather))}`,
symbolSize: [28, 28],
}
}),
},
// 最高温度线
{
name: '最高温度',
type: 'line',
data: _7DayForecastData.map((item) => item.maxTem),
smooth: true,
color: '#F79D80', color: '#F79D80',
fontSize: 11, symbolSize: 6,
label: {
show: true,
position: 'top',
formatter: '{c}°',
color: '#F79D80',
fontSize: 11,
},
}, },
}, // 最低温度线
// 最低温度线 {
{ name: '最低温度',
name: '最低温度', type: 'line',
type: 'line', data: _7DayForecastData.map((item) => item.minTem),
data: _7DayForecastData.map((item) => item.minTem), smooth: true,
smooth: true,
color: '#52C41A',
symbolSize: 6,
label: {
show: true,
position: 'bottom',
formatter: '{c}°',
color: '#52C41A', color: '#52C41A',
fontSize: 11, symbolSize: 6,
label: {
show: true,
position: 'bottom',
formatter: '{c}°',
color: '#52C41A',
fontSize: 11,
},
}, },
}, ],
], })
}) })
})
</script> </script>
<template> <template>
...@@ -213,5 +215,5 @@ onLoad(async () => { ...@@ -213,5 +215,5 @@ onLoad(async () => {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
// //
</style> </style>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, toRefs } from 'vue'
import { onShow } from '@dcloudio/uni-app' import { onShow } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
...@@ -23,7 +22,13 @@ onLoad((pageOptions) => { ...@@ -23,7 +22,13 @@ onLoad((pageOptions) => {
pageData.form[key] = res[key] pageData.form[key] = res[key]
} }
}) })
pageData.form.provinceText = res.provinceName + '/' + res.cityName + '/' + res.districtName // 回显省市区名称
if (res.provinceName && res.cityName && res.districtName) {
pageData.form.provinceName = res.provinceName
pageData.form.cityName = res.cityName
pageData.form.districtName = res.districtName
pageData.form.provinceText = res.provinceName + '/' + res.cityName + '/' + res.districtName
}
// 编辑模式下,如果已有示例图片,需要设置到上传组件中 // 编辑模式下,如果已有示例图片,需要设置到上传组件中
if (res.coverImage) { if (res.coverImage) {
...@@ -99,6 +104,7 @@ const pageData = reactive({ ...@@ -99,6 +104,7 @@ const pageData = reactive({
districtName: '', districtName: '',
addressDetail: '', addressDetail: '',
coverImage: '', coverImage: '',
slogan: '',
}, },
rules: [ rules: [
{ {
...@@ -139,7 +145,17 @@ const pageData = reactive({ ...@@ -139,7 +145,17 @@ const pageData = reactive({
{ {
name: 'provinceName', name: 'provinceName',
rule: ['required'], rule: ['required'],
msg: ['请选择归属省份'], msg: ['请填写省市区信息!'],
},
{
name: 'cityName',
rule: ['required'],
msg: ['请填写省市区信息!'],
},
{
name: 'districtName',
rule: ['required'],
msg: ['请填写省市区信息!'],
}, },
{ {
name: 'addressDetail', name: 'addressDetail',
...@@ -231,15 +247,43 @@ function submit() { ...@@ -231,15 +247,43 @@ function submit() {
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => { formRef.value.validator(pageData.form, pageData.rules, true).then((res) => {
if (res.isPassed) { if (res.isPassed) {
pageData.loading = true pageData.loading = true
// 提交前处理:通过对provinceText值按/分隔,分别赋值给provinceName、cityName和districtName
if (pageData.form.provinceText) {
const addressParts = pageData.form.provinceText.split('/')
if (addressParts.length >= 3) {
pageData.form.provinceName = addressParts[0]
pageData.form.cityName = addressParts[1]
pageData.form.districtName = addressParts[2]
}
}
const apiCall = pageData.form.id ? NongchangAPI.farmsEdit : NongchangAPI.farmsAdd const apiCall = pageData.form.id ? NongchangAPI.farmsEdit : NongchangAPI.farmsAdd
apiCall(pageData.form) apiCall(pageData.form)
.then(() => { .then((res) => {
toastRef.value.show({ toastRef.value.show({
type: 'success', type: 'success',
text: pageData.form.id ? '保存修改成功' : '添加农场成功', text: pageData.form.id ? '保存修改成功' : '添加农场成功',
}) })
// 获取农场ID:编辑时使用当前ID,新增时从返回值获取(假设返回的是ID或包含ID的对象)
// 根据后端接口惯例,如果返回的是ID字符串直接使用,如果是对象则取id字段
// 暂时假设res为ID或者不影响跳转,优先使用pageData.form.id,如果是新增则尝试从res获取
// 如果res不是id,则需要确认接口返回值结构。通常新增接口返回ID比较合理。
// 鉴于不确定接口返回值,这里先假设编辑时id已知,新增时尝试从res获取,如果获取不到则回退到列表页
const targetId = pageData.form.id || (typeof res === 'string' ? res : res?.id);
setTimeout(() => { setTimeout(() => {
uni.navigateBack() if (targetId) {
// 跳转到农场详情页,注意路径需要是绝对路径
uni.redirectTo({
url: `/pages/nongchang/detail/index?id=${targetId}`
})
} else {
// 如果没有ID,回退上一页
uni.navigateBack()
}
}, 500); }, 500);
}) })
.finally(() => { .finally(() => {
...@@ -326,6 +370,19 @@ function submit() { ...@@ -326,6 +370,19 @@ function submit() {
class="block-textarea" class="block-textarea"
/> />
</view> </view>
<!-- 农场标语 -->
<view class="form-item-block">
<view class="form-item-label">农场标语</view>
<fui-textarea
height="100rpx"
size="28"
:borderTop="false"
:borderBottom="false"
placeholder="请输入农场标语"
v-model="pageData.form.slogan"
class="block-textarea"
/>
</view>
</view> </view>
<!-- 第二组表单 --> <!-- 第二组表单 -->
...@@ -333,14 +390,14 @@ function submit() { ...@@ -333,14 +390,14 @@ function submit() {
<fui-form-item <fui-form-item
required required
asterisk asterisk
label="归属省份" label="归属地区"
labelSize="28" labelSize="28"
:labelWeight="400" :labelWeight="400"
labelWidth="auto" labelWidth="auto"
> >
<view class="time-input" @click="pageData.show.address = true"> <view class="time-input" @click="pageData.show.address = true">
<text class="select-text" :class="{ placeholder: !pageData.form.provinceText }"> <text class="select-text" :class="{ placeholder: !pageData.form.provinceText }">
{{ pageData.form.provinceText || '请选择归属省份' }} {{ pageData.form.provinceText || '请选择归属地区' }}
</text> </text>
</view> </view>
</fui-form-item> </fui-form-item>
...@@ -351,8 +408,8 @@ function submit() { ...@@ -351,8 +408,8 @@ function submit() {
labelWidth="auto" labelWidth="auto"
labelSize="28" labelSize="28"
:labelWeight="400" :labelWeight="400"
label="归属省份" label="归属地区"
placeholder="请选择归属省份" placeholder="请选择归属地区"
:value="pageData.form.provinceText" :value="pageData.form.provinceText"
/> />
</view> --> </view> -->
......
<!-- 农场详情 --> <!-- 农场详情 -->
<script setup lang="ts"> <script setup lang="ts">
import * as turf from '@turf/turf' import * as turf from '@turf/turf'
import type { Page } from './config' import dayjs from 'dayjs'
import PlayWidget from './components/PlayWidget.vue' import SaveDialog from '../../device/components/save-dialog.vue'
import SaveDialog from '../../device/components/save-dialog.vue' import type { Page } from './config'
import Navigate from '@/utils/page/navigate' import PlayWidget from './components/PlayWidget.vue'
import { import Navigate from '@/utils/page/navigate'
addDefaultGeoJSONSource, import {
addDefaultSplotLayer, addDefaultGeoJSONSource,
addDefaultSymbolLayer, addDefaultSplotLayer,
useMapbox, addDefaultSymbolLayer,
} from '@/components/Map/Mapbox/hook' useMapbox,
import type { ToolBoxButtonHandleEvent } from '@/components/Map/Widgets/ToolBox' } from '@/components/Map/Mapbox/hook'
import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox' import type { ToolBoxButtonHandleEvent } from '@/components/Map/Widgets/ToolBox'
import * as NongchangAPI from '@/api/model/nongchang' import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox'
import * as farmbaseApi from '@/api/model/farmbase' import * as NongchangAPI from '@/api/model/nongchang'
import navigate from '@/utils/page/navigate' import * as farmbaseApi from '@/api/model/farmbase'
import dayjs from 'dayjs'
// 页面参数
// 页面参数 const page = reactive<Page>({
const page = reactive<Page>({ id: 'example-mapbox',
id: 'example-mapbox', init: false,
init: false, requests: 0,
requests: 0, latest: null,
latest: null, query: {},
query: {}, })
}) const showDialog = ref(false)
const showDialog = ref(false) onShow(() => {
onShow(() => { getFarmbaseInfoList()
getFarmbaseInfoList()
})
const model = reactive({
id: '',
name: '',
lonlat: '',
address: '',
description: '',
// 地块、位置信息 GeoJSON
plots: [],
// 设备信息
devices: [],
// 天气信息
weather: {
live: {
tem: '12°',
phenomena: '',
wind: '',
humidity: '',
},
forecast: [
{
phenomena: '',
date: '',
maxTem: '',
minTem: '',
},
],
},
// 预报日期
forecasts: [],
clicked: 0,
farmbaseInfo: {},
farmbaseInfoList: [],
deviceTypeCount: [],
})
onLoad(()=>{
var today = dayjs();
for (var i = 0; i < 5; i++) {
var futureDate = today.add(i, 'day');
model.forecasts.push(futureDate.format('DD')+'日');
}
})
async function getFarmbaseInfoList() {
farmbaseApi
.list({
farmId: model.id,
})
.then((res) => {
const { records } = res
model.farmbaseInfoList = records
if (records.length > 0) {
getFarmbaseInfoById(records[0].id)
}
})
}
async function getFarmbaseInfoById(id) {
farmbaseApi.getFarmbaseInfoById({ id }).then((res) => {
model.farmbaseInfo = res
getDeviceTypeCount()
}) })
}
async function getDeviceTypeCount() { const model = reactive({
farmbaseApi.getDeviceTypeCount({ farmId: model.id, farmBaseId: model.farmbaseInfo?.id }).then((res) => { id: '',
model.deviceTypeCount = res name: '',
lonlat: '',
address: '',
description: '',
// 地块、位置信息 GeoJSON
plots: [],
// 设备信息
devices: [],
// 天气信息
weather: {
live: {
tem: '12°',
phenomena: '',
wind: '',
humidity: '',
},
forecast: [
{
phenomena: '',
date: '',
maxTem: '',
minTem: '',
},
],
},
// 预报日期
forecasts: [],
clicked: 0,
farmbaseInfo: {},
farmbaseInfoList: [],
deviceTypeCount: [],
}) })
} onLoad(() => {
const today = dayjs()
// 地图组件 for (let i = 0; i < 5; i++) {
const [registerMap, map] = useMapbox({ const futureDate = today.add(i, 'day')
style: { zoom: 15, isImg: true }, model.forecasts.push(`${futureDate.format('DD')}日`)
onLoaded: async (data) => {
console.log('✨✨✨ Map Loaded', data)
// 查询农场数据
const res = await NongchangAPI.farmsList()
console.log('农场列表', res.records)
// 获取第一个农场信息
const item = res.records?.[0]
model.id = item.id
model.name = item.farmName
model.description = item.description
if (item.longitude && item.latitude) {
model.lonlat = `${item.longitude},${item.latitude}`
} else {
// 模拟位置数据
model.lonlat = '111.024108, 29.554847'
Message.toast('未设置农场坐标位置,已使用模拟位置数据')
} }
})
async function getFarmbaseInfoList() {
farmbaseApi
.list({
farmId: model.id,
})
.then((res) => {
const { records } = res
model.farmbaseInfoList = records
if (records.length > 0) {
getFarmbaseInfoById(records[0].id)
}
})
}
// 设置页面标题 async function getFarmbaseInfoById(id) {
uni.setNavigationBarTitle({ farmbaseApi.getFarmbaseInfoById({ id }).then((res) => {
title: item.farmName, model.farmbaseInfo = res
getDeviceTypeCount()
}) })
// 设置地图中心点 }
map.flyTo({
center: model.lonlat.split(',').map(Number) as [number, number], async function getDeviceTypeCount() {
duration: 0, farmbaseApi.getDeviceTypeCount({ farmId: model.id, farmBaseId: model.farmbaseInfo?.id }).then((res) => {
model.deviceTypeCount = res
}) })
}
// 渲染地块数据
model.plots = [ // 地图组件
turf.polygon( const [registerMap, map] = useMapbox({
[ style: { zoom: 15, isImg: true },
onLoaded: async (data) => {
console.log('✨✨✨ Map Loaded', data)
// 查询农场数据
const res = await NongchangAPI.farmsList()
console.log('农场列表', res.records)
// 获取第一个农场信息
const item = res.records?.[0]
model.id = item.id
model.name = item.farmName
model.description = item.description
if (item.longitude && item.latitude) {
model.lonlat = `${item.longitude},${item.latitude}`
} else {
// 模拟位置数据
model.lonlat = '111.024108, 29.554847'
Message.toast('未设置农场坐标位置,已使用模拟位置数据')
}
// 设置页面标题
uni.setNavigationBarTitle({
title: item.farmName,
})
// 设置地图中心点
map.flyTo({
center: model.lonlat.split(',').map(Number) as [number, number],
duration: 0,
})
// 渲染地块数据
model.plots = [
turf.polygon(
[ [
[111.0235, 29.5562], [
[111.0255, 29.5562], [111.0235, 29.5562],
[111.0255, 29.5558], [111.0255, 29.5562],
[111.0235, 29.5558], [111.0255, 29.5558],
[111.0235, 29.5562], [111.0235, 29.5558],
[111.0235, 29.5562],
],
], ],
], {
{ color: 'yellow',
color: 'yellow', name: '基地 A',
name: '基地 A', popup: `{{name}}`,
popup: `{{name}}`, },
}, ),
), turf.polygon(
turf.polygon(
[
[ [
[111.0225, 29.5565], [
[111.0238, 29.5568], [111.0225, 29.5565],
[111.023, 29.5555], [111.0238, 29.5568],
[111.022, 29.5558], [111.023, 29.5555],
[111.0225, 29.5565], [111.022, 29.5558],
[111.0225, 29.5565],
],
], ],
], {
{ color: 'red',
color: 'red', name: '基地 B',
name: '基地 B', popup: `{{name}}`,
popup: `{{name}}`, },
}, ),
), turf.polygon(
turf.polygon(
[
[ [
[111.0258, 29.555], [
[111.0262, 29.5542], [111.0258, 29.555],
[111.0252, 29.554], [111.0262, 29.5542],
[111.0258, 29.555], [111.0252, 29.554],
[111.0258, 29.555],
],
], ],
], {
{ color: 'blue',
color: 'blue', name: '基地 C',
name: '基地 C', popup: `{{name}}`,
},
),
]
addDefaultGeoJSONSource(map, `${page.id}-plot`, model.plots)
addDefaultSplotLayer(map, `${page.id}-plot`, {
paint: {
'fill-opacity': 0.2,
'fill-outline-color': ['get', 'color'],
},
})
map.addLayer({
type: 'line',
id: `${page.id}-plot-line`,
source: `${page.id}-plot`,
layout: {
'line-join': 'round',
'line-cap': 'round',
},
paint: {
'line-color': ['get', 'color'],
'line-width': 2,
},
})
// 渲染设备数据
model.devices = [
turf.point([111.024108, 29.554847], {
name: '设备1',
description: '设备1描述',
icon: 'GD',
popup: `{{name}}`,
}),
turf.point([111.023139, 29.55539], {
name: '设备2',
description: '设备2描述',
icon: 'JCD',
popup: `{{name}}`, popup: `{{name}}`,
}),
turf.point([111.024989, 29.555435], {
name: '设备3',
description: '设备3描述',
icon: 'BZ',
popup: `{{name}}`,
}),
]
addDefaultGeoJSONSource(map, `${page.id}-symbol`, model.devices)
addDefaultSymbolLayer(map, `${page.id}-symbol`, {
layout: {
'text-field': '',
'icon-image': ['get', 'icon'],
'icon-size': 1,
}, },
), })
]
addDefaultGeoJSONSource(map, `${page.id}-plot`, model.plots)
addDefaultSplotLayer(map, `${page.id}-plot`, {
paint: {
'fill-opacity': 0.2,
'fill-outline-color': ['get', 'color'],
},
})
map.addLayer({
type: 'line',
id: `${page.id}-plot-line`,
source: `${page.id}-plot`,
layout: {
'line-join': 'round',
'line-cap': 'round',
},
paint: {
'line-color': ['get', 'color'],
'line-width': 2,
},
})
// 渲染设备数据 // 查询农场信息
model.devices = [ getFarmbaseInfoList()
turf.point([111.024108, 29.554847], { },
name: '设备1', onSourceRequestHandle: () => {
description: '设备1描述', page.requests--
icon: 'GD', if (page.requests === 0) {
popup: `{{name}}`, Message.hideLoading()
}), }
turf.point([111.023139, 29.55539], { },
name: '设备2', onSourceRequestErrorHandle: () => {
description: '设备2描述',
icon: 'JCD',
popup: `{{name}}`,
}),
turf.point([111.024989, 29.555435], {
name: '设备3',
description: '设备3描述',
icon: 'BZ',
popup: `{{name}}`,
}),
]
addDefaultGeoJSONSource(map, `${page.id}-symbol`, model.devices)
addDefaultSymbolLayer(map, `${page.id}-symbol`, {
layout: {
'text-field': '',
'icon-image': ['get', 'icon'],
'icon-size': 1,
},
})
// 查询农场信息
getFarmbaseInfoList()
},
onSourceRequestHandle: () => {
page.requests--
if (page.requests === 0) {
Message.hideLoading() Message.hideLoading()
} },
}, })
onSourceRequestErrorHandle: () => {
Message.hideLoading()
},
})
/* const mapAddImage = new Image(); /* const mapAddImage = new Image();
mapAddImage.src = '/static/images/test/mapLayer.png'; mapAddImage.src = '/static/images/test/mapLayer.png';
// 添加自定义图像图层 // 添加自定义图像图层
map.on('load','custom-image',()=>{ map.on('load','custom-image',()=>{
console.log("进到自定义的地图里了") console.log("进到自定义的地图里了")
// 添加图片资源 // 添加图片资源
map.addImage('custom-image', mapAddImage, { pixelRatio: 2 }); // 确保路径正确且图片可访问 map.addImage('custom-image', mapAddImage, { pixelRatio: 2 }); // 确保路径正确且图片可访问
// 添加图层到地图上,并指定位置和大小 // 添加图层到地图上,并指定位置和大小
map.addLayer({ map.addLayer({
id: 'custom-image-layer', // 图层的唯一ID id: 'custom-image-layer', // 图层的唯一ID
...@@ -271,123 +270,123 @@ map.on('load','custom-image',()=>{ ...@@ -271,123 +270,123 @@ map.on('load','custom-image',()=>{
} }
}); });
}) */ }) */
// 左侧工具栏小部件 // 左侧工具栏小部件
const [registerToolBoxWidget] = useToolBoxWidget({ const [registerToolBoxWidget] = useToolBoxWidget({
show: true, show: true,
expand: true, expand: true,
showExpandButton: false, showExpandButton: false,
top: 10, top: 10,
tools: [ tools: [
{ {
key: 'action', key: 'action',
align: 'top', align: 'top',
buttons: [ buttons: [
{ {
name: '设备', name: '设备',
color: '#75c849', color: '#75c849',
icon: '/static/images/codefun/device.active.png', icon: '/static/images/codefun/device.active.png',
type: 'toggle', type: 'toggle',
handle: (e: ToolBoxButtonHandleEvent) => { handle: (e: ToolBoxButtonHandleEvent) => {
// 切换显示设备数据地图渲染 // 切换显示设备数据地图渲染
const active = e.button.icon === '/static/images/codefun/device.active.png' const active = e.button.icon === '/static/images/codefun/device.active.png'
if (active) { if (active) {
e.button.color = '#666666' e.button.color = '#666666'
e.button.icon = '/static/images/codefun/device.png' e.button.icon = '/static/images/codefun/device.png'
map.setLayoutProperty(`${page.id}-symbol`, 'visibility', 'none') map.setLayoutProperty(`${page.id}-symbol`, 'visibility', 'none')
} else { } else {
e.button.color = '#75c849' e.button.color = '#75c849'
e.button.icon = '/static/images/codefun/device.active.png' e.button.icon = '/static/images/codefun/device.active.png'
map.setLayoutProperty(`${page.id}-symbol`, 'visibility', 'visible') map.setLayoutProperty(`${page.id}-symbol`, 'visibility', 'visible')
} }
},
}, },
}, ],
], },
}, {
{ key: 'action',
key: 'action', align: 'top',
align: 'top', buttons: [
buttons: [ {
{ name: '降雨',
name: '降雨', icon: '/static/images/codefun/rain.png',
icon: '/static/images/codefun/rain.png', type: 'button',
type: 'button', handle: () => {
handle: () => { Message.toast('暂无降雨数据')
Message.toast('暂无降雨数据') },
}, },
}, {
{ name: '温度',
name: '温度', icon: '/static/images/codefun/temp.png',
icon: '/static/images/codefun/temp.png', type: 'button',
type: 'button', handle: () => {
handle: () => { Message.toast('暂无温度数据')
Message.toast('暂无温度数据') },
}, },
}, {
{ name: '强对流',
name: '强对流', icon: '/static/images/codefun/severe.png',
icon: '/static/images/codefun/severe.png', type: 'button',
type: 'button', handle: () => {
handle: () => { Message.toast('暂无强对流数据')
Message.toast('暂无强对流数据') },
}, },
}, {
{ name: '大风',
name: '大风', icon: '/static/images/codefun/wind.png',
icon: '/static/images/codefun/wind.png', type: 'button',
type: 'button', handle: () => {
handle: () => { Message.toast('暂无大风数据')
Message.toast('暂无大风数据') },
}, },
}, {
{ name: '其他',
name: '其他', icon: '/static/images/codefun/other.png',
icon: '/static/images/codefun/other.png', type: 'button',
type: 'button', handle: () => {
handle: () => { Message.alert('敬请期待~', '温馨提醒')
Message.alert('敬请期待~', '温馨提醒') },
}, },
}, ],
], },
}, ],
],
})
// 自定义导航栏回调函数
function onBackClick() {
uni.navigateBack({
delta: 1,
}) })
}
// 自定义导航栏回调函数
function onTitleIconClick() { function onBackClick() {
Navigate.to(`/pages/nongchang/create-nongchang-form?id=${model.id}`) uni.navigateBack({
} delta: 1,
})
function onAddBaseClick() { }
// 点击添加基地按钮的回调函数
Navigate.to(`/pages/jidiguanli/add?farmId=${model.id}`) function onTitleIconClick() {
} Navigate.to(`/pages/nongchang/create-nongchang-form?id=${model.id}`)
function makePhoneCall(contactPhone){ }
uni.makePhoneCall({
phoneNumber: contactPhone, function onAddBaseClick() {
success: function () { // 点击添加基地按钮的回调函数
console.log('拨打电话成功!');
},
fail: function () {
console.log('拨打电话失败!');
}
});
}
// 保留原有的导航栏按钮点击回调(如果有需要的话)
onNavigationBarButtonTap((e) => {
console.log(e)
if (e.index === 0) {
Navigate.to(`/pages/jidiguanli/add?farmId=${model.id}`) Navigate.to(`/pages/jidiguanli/add?farmId=${model.id}`)
} }
}) function makePhoneCall(contactPhone) {
const toDevice = (device)=>{ uni.makePhoneCall({
Navigate.to(`/pages/device/device?deviceType=${device.deviceType}&farmBaseId=`+model.farmbaseInfo?.id) phoneNumber: contactPhone,
} success() {
console.log('拨打电话成功!')
},
fail() {
console.log('拨打电话失败!')
},
})
}
// 保留原有的导航栏按钮点击回调(如果有需要的话)
onNavigationBarButtonTap((e) => {
console.log(e)
if (e.index === 0) {
Navigate.to(`/pages/jidiguanli/add?farmId=${model.id}`)
}
})
function toDevice(device) {
Navigate.to(`/pages/device/device?deviceType=${device.deviceType}&farmBaseId=${model.farmbaseInfo?.id}`)
}
</script> </script>
<template> <template>
...@@ -396,7 +395,7 @@ const toDevice = (device)=>{ ...@@ -396,7 +395,7 @@ const toDevice = (device)=>{
<view class="custom-navbar"> <view class="custom-navbar">
<view class="navbar-content"> <view class="navbar-content">
<view class="navbar-left" @click="onBackClick"> <view class="navbar-left" @click="onBackClick">
<fui-icon name="arrowleft" color="#FFF" size="44"></fui-icon> <fui-icon name="arrowleft" color="#FFF" size="44" />
</view> </view>
<view class="navbar-center"> <view class="navbar-center">
<text class="navbar-title">{{ model.name || '农场' }}</text> <text class="navbar-title">{{ model.name || '农场' }}</text>
...@@ -411,7 +410,7 @@ const toDevice = (device)=>{ ...@@ -411,7 +410,7 @@ const toDevice = (device)=>{
</view> </view>
<!-- 为自定义导航栏预留空间 --> <!-- 为自定义导航栏预留空间 -->
<view class="navbar-placeholder"></view> <view class="navbar-placeholder" />
<!-- 地图组件 --> <!-- 地图组件 -->
<!-- <view class="h-730 overflow-hidden map-box"> --> <!-- <view class="h-730 overflow-hidden map-box"> -->
...@@ -437,29 +436,27 @@ const toDevice = (device)=>{ ...@@ -437,29 +436,27 @@ const toDevice = (device)=>{
</view> </view>
</view> </view>
</view> </view>
<view class="card !top-854"> <view class="card !top-854">
<view class="box-1"> <view class="box-1">
<view class="relative w-full flex flex-row"> <view class="relative w-full flex flex-row">
<view class="box-1-left" <view class="box-1-left"><image class="image_1" src="/static/images/nongchang/play.png" /></view>
><image class="image_1" src="/static/images/nongchang/play.png" <view class="box-1-right">
/></view> <view class="box-1-right-top">
<view class="box-1-right"> <view class="text_1">预报</view>
<view class="box-1-right-top"> </view>
<view class="text_1">预报</view> <view class="box-1-right-bottom"
</view> ><text
<view class="box-1-right-bottom" v-for="(forecast, index) in model.forecasts"
><text :class="model.clicked === index ? 'active' : ''"
v-for="(forecast, index) in model.forecasts" :key="index"
:class="model.clicked === index ? 'active' : ''" >{{ forecast }}</text
:key="index" ></view
>{{ forecast }}</text >
></view </view>
> </view>
</view> </view>
</view> </view>
</view>
</view>
<view class="card !top-954"> <view class="card !top-954">
<view class="w-full absolute"> <view class="w-full absolute">
<view style="background: #e6f5e8"> <view style="background: #e6f5e8">
...@@ -496,18 +493,18 @@ const toDevice = (device)=>{ ...@@ -496,18 +493,18 @@ const toDevice = (device)=>{
<view class="box-2-right"> <view class="box-2-right">
<view class="box-2-right-item"> <view class="box-2-right-item">
<text class="box-2-right-text1">15°-19°</text> <text class="box-2-right-text1">15°-19°</text>
<view class="weather-view"> <view class="weather-view">
<image class="weather-icon" src="/static/images/test/yin.png" /> <image class="weather-icon" src="/static/images/test/yin.png" />
<text class="box-2-right-text2">今天 阴</text> <text class="box-2-right-text2">今天 阴</text>
</view> </view>
</view> </view>
<view class="box-2-right-interval" /> <view class="box-2-right-interval" />
<view class="box-2-right-item"> <view class="box-2-right-item">
<text class="box-2-right-text1">17°-21°</text> <text class="box-2-right-text1">17°-21°</text>
<view class="weather-view"> <view class="weather-view">
<image class="weather-icon" src="/static/images/test/cloudy.png" /> <image class="weather-icon" src="/static/images/test/cloudy.png" />
<text class="box-2-right-text2">明天 多云</text> <text class="box-2-right-text2">明天 多云</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
...@@ -534,7 +531,9 @@ const toDevice = (device)=>{ ...@@ -534,7 +531,9 @@ const toDevice = (device)=>{
<view class="box-3-info-item justify-between"> <view class="box-3-info-item justify-between">
<view class="box-3-info-item-text-box"> <view class="box-3-info-item-text-box">
<text class="box-3-info-item-text1">种植: </text> <text class="box-3-info-item-text1">种植: </text>
<text class="box-3-info-item-text2">{{model.farmbaseInfo.growCrops_dictText}}</text> <text class="box-3-info-item-text2">{{
model.farmbaseInfo.growCrops_dictText
}}</text>
</view> </view>
<view class="box-3-info-item-text-box"> <view class="box-3-info-item-text-box">
<text class="box-3-info-item-text1">预计产量: </text> <text class="box-3-info-item-text1">预计产量: </text>
...@@ -548,7 +547,11 @@ const toDevice = (device)=>{ ...@@ -548,7 +547,11 @@ const toDevice = (device)=>{
</view> </view>
<view class="box-3-info-item-text-box"> <view class="box-3-info-item-text-box">
<text class="box-3-info-item-text1">联系电话: </text> <text class="box-3-info-item-text1">联系电话: </text>
<text class="box-3-info-item-text2 box-contact-phone" @click="makePhoneCall(model.farmbaseInfo.contactPhone)">{{ model.farmbaseInfo.contactPhone }}</text> <text
class="box-3-info-item-text2 box-contact-phone"
@click="makePhoneCall(model.farmbaseInfo.contactPhone)"
>{{ model.farmbaseInfo.contactPhone }}</text
>
</view> </view>
</view> </view>
</view> </view>
...@@ -585,442 +588,442 @@ const toDevice = (device)=>{ ...@@ -585,442 +588,442 @@ const toDevice = (device)=>{
:show="showDialog" :show="showDialog"
:farmId="model.id" :farmId="model.id"
:farmBaseId="model.farmbaseInfo?.id" :farmBaseId="model.farmbaseInfo?.id"
@submitSuccess="getDeviceTypeCount" @submit-success="getDeviceTypeCount"
@close="showDialog = false" @close="showDialog = false"
/> />
</view> </view>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
// //
page { page {
background-color: #e6f5e8; background-color: #e6f5e8;
} }
.page { .page {
position: relative; position: relative;
min-height: 100vh; min-height: 100vh;
background-color: #e6f5e8; background-color: #e6f5e8;
// 自定义导航栏样式 // 自定义导航栏样式
.custom-navbar { .custom-navbar {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
z-index: 999; z-index: 999;
background-color: #5db66f; background-color: #5db66f;
padding-top: var(--status-bar-height, 44rpx); padding-top: var(--status-bar-height, 44rpx);
.navbar-content { .navbar-content {
height: 88rpx; height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20rpx;
.navbar-left {
flex: 1;
display: flex; display: flex;
justify-content: flex-start; align-items: center;
justify-content: space-between;
padding: 0 20rpx;
.back-icon { .navbar-left {
width: 60rpx; flex: 1;
height: 60rpx;
display: flex; display: flex;
align-items: center; justify-content: flex-start;
justify-content: center;
color: #fff;
font-size: 36rpx;
font-weight: bold;
border-radius: 50%;
background-color: rgba(255, 255, 255, 0.2);
&:active {
background-color: rgba(255, 255, 255, 0.3);
transform: scale(0.95);
}
}
}
.navbar-center { .back-icon {
flex: 1; width: 60rpx;
display: flex; height: 60rpx;
align-items: center; display: flex;
justify-content: center; align-items: center;
position: relative; justify-content: center;
color: #fff;
.navbar-title { font-size: 36rpx;
color: #fff; font-weight: bold;
font-size: 32rpx; border-radius: 50%;
font-weight: 600; background-color: rgba(255, 255, 255, 0.2);
// margin-right: 10rpx;
&:active {
background-color: rgba(255, 255, 255, 0.3);
transform: scale(0.95);
}
}
} }
.navbar-icon { .navbar-center {
flex: 1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
// margin-left: 8rpx; position: relative;
// padding: 8rpx;
border-radius: 50%;
// background-color: rgba(255, 255, 255, 0.2);
transition: all 0.3s ease;
.title-icon {
width: 32rpx;
height: 32rpx;
}
&:active { .navbar-title {
background-color: rgba(255, 255, 255, 0.3); color: #fff;
transform: scale(0.9); font-size: 32rpx;
font-weight: 600;
// margin-right: 10rpx;
} }
&:hover { .navbar-icon {
background-color: rgba(255, 255, 255, 0.25); display: flex;
align-items: center;
justify-content: center;
// margin-left: 8rpx;
// padding: 8rpx;
border-radius: 50%;
// background-color: rgba(255, 255, 255, 0.2);
transition: all 0.3s ease;
.title-icon {
width: 32rpx;
height: 32rpx;
}
&:active {
background-color: rgba(255, 255, 255, 0.3);
transform: scale(0.9);
}
&:hover {
background-color: rgba(255, 255, 255, 0.25);
}
} }
} }
}
.navbar-right { .navbar-right {
flex: 1; flex: 1;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
.add-base-btn { .add-base-btn {
color: #fff; color: #fff;
font-size: 26rpx; font-size: 26rpx;
padding: 12rpx 20rpx; padding: 12rpx 20rpx;
transition: all 0.3s ease; transition: all 0.3s ease;
&:active { &:active {
background-color: rgba(255, 255, 255, 0.3); background-color: rgba(255, 255, 255, 0.3);
transform: scale(0.95); transform: scale(0.95);
} }
&:hover { &:hover {
background-color: rgba(255, 255, 255, 0.25); background-color: rgba(255, 255, 255, 0.25);
}
} }
} }
} }
} }
}
// 导航栏占位空间 // 导航栏占位空间
.navbar-placeholder { .navbar-placeholder {
height: calc(88rpx + var(--status-bar-height, 44rpx)); height: calc(88rpx + var(--status-bar-height, 44rpx));
} }
.map-box { .map-box {
// #ifdef APP-PLUS // #ifdef APP-PLUS
position: relative; position: relative;
top: 0; top: 0;
// #endif // #endif
// #ifdef H5 // #ifdef H5
position: relative; position: relative;
top: 0; top: 0;
// #endif // #endif
} }
.card { .card {
width: 100%; width: 100%;
position: absolute; position: absolute;
font-weight: 400; font-weight: 400;
font-family: '思源黑体'; font-family: '思源黑体';
.box-1 { .box-1 {
width: 95%; width: 95%;
height: 80rpx; height: 80rpx;
background-color: #fff; background-color: #fff;
margin: 20rpx; margin: 20rpx;
border-radius: 18rpx; border-radius: 18rpx;
display: flex;
flex-direction: row;
// margin-top:-500rpx;
.box-1-left {
width: 50rpx;
height: 100%;
margin-left: 20rpx;
display: flex; display: flex;
align-items: center; flex-direction: row;
// margin-top:-500rpx;
.image_1 { .box-1-left {
width: 50rpx; width: 50rpx;
height: 50rpx; height: 100%;
} margin-left: 20rpx;
}
.box-1-right {
width: calc(100% - 80rpx);
height: 100%;
margin-left: 20rpx;
display: flex;
flex-direction: column;
.box-1-right-top {
// height: 50%;
// background-image: url('/static/images/nongchang/yubaobeijing.png');
padding-left: 184rpx;
.text_1 {
font-size: 25rpx;
color: #5db66f;
text-align: center;
background: linear-gradient(180deg, rgba(93, 182, 111, 0.3) 0%, rgba(93, 182, 111, 0) 100%);
background-size: 100% 100%;
background-repeat: no-repeat;
border-top-right-radius: 16rpx;
}
}
.box-1-right-bottom {
// height: 50%;
display: flex; display: flex;
flex-direction: row; align-items: center;
justify-content: space-around;
color: #999999;
font-size: 24rpx;
.active { .image_1 {
color: #cccccc; width: 50rpx;
height: 50rpx;
} }
} }
}
}
.box-2 {
width: 95%;
height: 150rpx;
margin: 20rpx;
display: flex;
flex-direction: row;
.box-2-left {
width: 35%;
display: flex;
flex-direction: column;
justify-content: space-around;
padding: 10rpx;
margin-right: 20rpx;
background-color: #fff;
border-radius: 18rpx;
line-height: 100%;
.box-2-left-top { .box-1-right {
width: calc(100% - 80rpx);
height: 100%;
margin-left: 20rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: column;
justify-content: space-around;
.box-2-left-top-text1 {
font-size: 50rpx;
font-weight: bold;
color: #333333;
}
.box-2-left-top-text2 { .box-1-right-top {
font-size: 32rpx; // height: 50%;
color: #555555; // background-image: url('/static/images/nongchang/yubaobeijing.png');
padding-left: 184rpx;
.text_1 {
font-size: 25rpx;
color: #5db66f;
text-align: center;
background: linear-gradient(180deg, rgba(93, 182, 111, 0.3) 0%, rgba(93, 182, 111, 0) 100%);
background-size: 100% 100%;
background-repeat: no-repeat;
border-top-right-radius: 16rpx;
}
} }
}
.box-2-left-bottom { .box-1-right-bottom {
display: flex; // height: 50%;
flex-direction: row; display: flex;
justify-content: space-around; flex-direction: row;
line-height: 100%; justify-content: space-around;
.box-2-left-bottom-text1 { color: #999999;
font-size: 24rpx; font-size: 24rpx;
color: #555555;
.active {
color: #cccccc;
}
} }
} }
} }
.box-2-right { .box-2 {
width: 62%; width: 95%;
height: 150rpx;
margin: 20rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-around;
margin-right: 20rpx;
background-color: #fff;
border-radius: 18rpx;
line-height: 100%;
.box-2-right-item { .box-2-left {
width: 50%; width: 35%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-around; justify-content: space-around;
text-align: center; padding: 10rpx;
.box-2-right-text1 { margin-right: 20rpx;
font-size: 42rpx; background-color: #fff;
font-weight: bold; border-radius: 18rpx;
color: #333333; line-height: 100%;
}
.weather-view{ .box-2-left-top {
display: flex; display: flex;
align-items: center; flex-direction: row;
justify-content: center; justify-content: space-around;
} .box-2-left-top-text1 {
.weather-icon{ font-size: 50rpx;
height: 40rpx; font-weight: bold;
width: 54rpx; color: #333333;
margin-right: 8rpx; }
}
.box-2-right-text2 { .box-2-left-top-text2 {
font-size: 24rpx; font-size: 32rpx;
color: #555555; color: #555555;
}
} }
}
.box-2-right-interval { .box-2-left-bottom {
width: 1px; display: flex;
height: 80%; flex-direction: row;
margin: auto; justify-content: space-around;
background-color: #eeeeee; line-height: 100%;
.box-2-left-bottom-text1 {
font-size: 24rpx;
color: #555555;
}
}
} }
}
}
.box-3 { .box-2-right {
width: 95%; width: 62%;
height: 280rpx; display: flex;
margin: 20rpx; flex-direction: row;
padding: 0 20rpx; justify-content: space-around;
background-color: #fff;
border-radius: 18rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
.box-3-tags {
width: 100%;
height: 70rpx;
display: flex;
flex-direction: row;
font-size: 28rpx;
.box-3-tags-item {
width: 31%;
height: 100%;
margin-right: 20rpx; margin-right: 20rpx;
text-align: center; background-color: #fff;
line-height: 70rpx; border-radius: 18rpx;
border-radius: 48rpx; line-height: 100%;
background-color: rgba($color: #5db66f, $alpha: 0.1);
color: #5db66f; .box-2-right-item {
font-weight: 300; width: 50%;
} display: flex;
flex-direction: column;
justify-content: space-around;
text-align: center;
.box-2-right-text1 {
font-size: 42rpx;
font-weight: bold;
color: #333333;
}
.weather-view {
display: flex;
align-items: center;
justify-content: center;
}
.weather-icon {
height: 40rpx;
width: 54rpx;
margin-right: 8rpx;
}
.box-2-right-text2 {
font-size: 24rpx;
color: #555555;
}
}
.box-3-tags-item-active { .box-2-right-interval {
background-color: #5db66f !important; width: 1px;
color: #fff !important; height: 80%;
margin: auto;
background-color: #eeeeee;
}
} }
} }
.box-3-info { .box-3 {
width: 100%; width: 95%;
height: calc(100% - 120rpx); height: 280rpx;
margin: 20rpx;
padding: 0 20rpx;
background-color: #fff;
border-radius: 18rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-around; justify-content: space-around;
.box-3-info-item { .box-3-tags {
width: 100%;
height: 70rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
font-size: 28rpx;
.box-3-info-item-text-box { .box-3-tags-item {
width: 50%; width: 31%;
.box-3-info-item-text1 { height: 100%;
font-size: 28rpx; margin-right: 20rpx;
color: #999999; text-align: center;
margin-right: 10rpx; line-height: 70rpx;
} border-radius: 48rpx;
background-color: rgba($color: #5db66f, $alpha: 0.1);
color: #5db66f;
font-weight: 300;
}
.box-3-info-item-text2 { .box-3-tags-item-active {
font-size: 28rpx; background-color: #5db66f !important;
color: #333333; color: #fff !important;
}
.box-contact-phone{
color: #2A82E4;
text-decoration: underline;
}
} }
} }
}
}
.box-4 {
width: 95%;
margin: 30rpx 20rpx 0 20rpx;
border-radius: 18rpx;
.box-4-title { .box-3-info {
width: 100%; width: 100%;
height: 50rpx; height: calc(100% - 120rpx);
display: flex; display: flex;
flex-direction: row; flex-direction: column;
justify-content: space-between; justify-content: space-around;
.box-4-title-text1 {
font-size: 30rpx;
color: #333333;
font-weight: bold;
}
.box-4-title-text2 { .box-3-info-item {
font-size: 28rpx; display: flex;
color: #5db66f; flex-direction: row;
.box-3-info-item-text-box {
width: 50%;
.box-3-info-item-text1 {
font-size: 28rpx;
color: #999999;
margin-right: 10rpx;
}
.box-3-info-item-text2 {
font-size: 28rpx;
color: #333333;
}
.box-contact-phone {
color: #2a82e4;
text-decoration: underline;
}
}
}
} }
} }
.box-4-device { .box-4 {
width: 100%; width: 95%;
//height: calc(100% - 50rpx); margin: 30rpx 20rpx 0 20rpx;
margin-top: 10rpx; border-radius: 18rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.box-4-device-item { .box-4-title {
width: 49%; width: 100%;
// height: 48%; height: 50rpx;
height: 136rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
border-radius: 24rpx; justify-content: space-between;
background-color: #fff;
margin-bottom: 10rpx;
.box-4-item-icon { .box-4-title-text1 {
width: 80rpx; font-size: 30rpx;
height: 100%; color: #333333;
margin: 0 25rpx; font-weight: bold;
display: flex; }
align-items: center;
.box-4-item-icon-image { .box-4-title-text2 {
width: 100%; font-size: 28rpx;
height: 80rpx; color: #5db66f;
}
} }
}
.box-4-item-content { .box-4-device {
width: 100%; width: 100%;
height: 100%; //height: calc(100% - 50rpx);
display: flex; margin-top: 10rpx;
justify-content: center; display: flex;
flex-direction: column; flex-wrap: wrap;
justify-content: space-between;
.box-4-item-text1 { .box-4-device-item {
font-size: 30rpx; width: 49%;
color: #333333; // height: 48%;
height: 136rpx;
display: flex;
flex-direction: row;
border-radius: 24rpx;
background-color: #fff;
margin-bottom: 10rpx;
.box-4-item-icon {
width: 80rpx;
height: 100%;
margin: 0 25rpx;
display: flex;
align-items: center;
.box-4-item-icon-image {
width: 100%;
height: 80rpx;
}
} }
.box-4-item-text2 { .box-4-item-content {
font-size: 26rpx; width: 100%;
color: #5db66f; height: 100%;
display: flex;
justify-content: center;
flex-direction: column;
.box-4-item-text1 {
font-size: 30rpx;
color: #333333;
}
.box-4-item-text2 {
font-size: 26rpx;
color: #5db66f;
}
} }
} }
} }
} }
} }
} }
}
</style> </style>
<script setup lang="ts">
import { computed, reactive, ref } from 'vue'
import dayjs from 'dayjs'
const nowText = ref('')
function tick() {
nowText.value = dayjs().format('YYYY年MM月DD日 dddd HH:mm:ss')
}
tick()
setInterval(tick, 1000)
const pageData = reactive({
banner: {
image: '/static/images/codefun/farm.jpg',
name: '西区茶油基地',
},
search: '',
categories: [
{ id: 'all', name: '全部' },
{ id: 'irrigation', name: '灌溉系统' },
{ id: 'soil', name: '土壤监测' },
{ id: 'camera', name: '摄像监控' },
{ id: 'weather', name: '气象站' },
],
currentCategory: 'all',
areas: [
{ id: 1, name: '北区灌溉系统', type: 'irrigation' },
{ id: 2, name: '南区灌溉系统', type: 'irrigation' },
{ id: 3, name: '西区灌溉系统', type: 'irrigation' },
{ id: 4, name: '东区灌溉系统', type: 'irrigation' },
{ id: 5, name: '南区土壤监测', type: 'soil' },
{ id: 6, name: '北区土壤监测', type: 'soil' },
{ id: 7, name: '北区土壤监测', type: 'soil' },
{ id: 8, name: '西区摄像监控', type: 'camera' },
{ id: 9, name: '东区摄像监控', type: 'camera' },
{ id: 10, name: '南区摄像监控', type: 'camera' },
{ id: 11, name: '北区摄像监控', type: 'camera' },
{ id: 12, name: '东区摄像监控', type: 'camera' },
{ id: 13, name: '北区气象站', type: 'weather' },
{ id: 14, name: '南区气象站', type: 'weather' },
{ id: 15, name: '西区气象站', type: 'weather' },
],
})
const filteredAreas = computed(() => {
const kw = pageData.search.trim()
return pageData.areas.filter((a) => {
const byCat = pageData.currentCategory === 'all' || a.type === pageData.currentCategory
const byKw = !kw || a.name.includes(kw)
return byCat && byKw
})
})
function selectCategory(id: string) {
pageData.currentCategory = id
}
function onSearchConfirm() {}
function openArea(item: any) {
uni.navigateTo({ url: `/pages/device/device?area=${encodeURIComponent(item.name)}` })
}
</script>
<template>
<view class="page">
<view class="banner">
<image class="banner-img" :src="pageData.banner.image" mode="aspectFill" />
<view class="banner-time">{{ nowText }}</view>
<view class="banner-label">
<text class="label-text">{{ pageData.banner.name }}</text>
<fui-icon name="share" :size="36" color="#fff" />
</view>
</view>
<view class="section">
<fui-search-bar
v-model="pageData.search"
:height="72"
:radius="80"
placeholder="请输入搜索内容"
inputBackground="#fff"
:cancel="false"
@search="onSearchConfirm"
/>
<scroll-view class="chip-row" scroll-x show-scrollbar="false">
<view class="chip-wrap">
<fui-tag
v-for="c in pageData.categories"
:key="c.id"
:text="c.name"
:theme="pageData.currentCategory === c.id ? 'dark' : 'light'"
type="success"
:padding="['16rpx', '32rpx']"
:radius="40"
:marginRight="16"
@click="selectCategory(c.id)"
/>
</view>
</scroll-view>
<view class="grid-box">
<fui-grid :columns="3" :showBorder="false" :square="false">
<fui-grid-item
v-for="(item, idx) in filteredAreas"
:key="item.id"
:index="idx"
backgroundColor="#FFFFFF"
@click="() => openArea(item)"
>
<view class="card" :class="{ active: item.name.includes('西区摄像监控') }">
<text class="card-text">{{ item.name }}</text>
</view>
</fui-grid-item>
</fui-grid>
</view>
</view>
</view>
</template>
<style lang="scss" scoped>
.page {
background: #e6f5e8;
min-height: 100vh;
}
.banner {
position: relative;
margin: 24rpx;
border-radius: 16rpx;
overflow: hidden;
height: 280rpx;
}
.banner-img {
width: 100%;
height: 100%;
}
.banner-time {
position: absolute;
left: 24rpx;
top: 20rpx;
color: #fff;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
font-size: 24rpx;
}
.banner-label {
position: absolute;
right: 16rpx;
bottom: 16rpx;
display: flex;
align-items: center;
gap: 12rpx;
}
.label-text {
color: #fff;
font-size: 28rpx;
}
.section {
padding: 24rpx;
}
.chip-row {
width: 100%;
}
.chip-wrap {
display: flex;
flex-direction: row;
gap: 16rpx;
}
.grid-box {
margin-top: 24rpx;
}
.card {
height: 120rpx;
margin: 12rpx;
border-radius: 16rpx;
border: 1rpx solid #eaeef1;
display: flex;
align-items: center;
justify-content: center;
background: #fff;
}
.card.active {
background: #5db66f;
color: #fff;
border-color: #5db66f;
}
.card-text {
font-size: 28rpx;
color: #2a2a2a;
}
</style>
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -33,23 +33,28 @@ ...@@ -33,23 +33,28 @@
name: 'phone', name: 'phone',
rule: ['required'], rule: ['required'],
msg: ['请填写手机号码'], msg: ['请填写手机号码'],
}, { },
{
name: 'scope', name: 'scope',
rule: ['required'], rule: ['required'],
msg: ['请选择作业区域'], msg: ['请选择作业区域'],
}, { },
{
name: 'startTime', name: 'startTime',
rule: ['required'], rule: ['required'],
msg: ['请选择开始时间'], msg: ['请选择开始时间'],
}, { },
{
name: 'endTime', name: 'endTime',
rule: ['required'], rule: ['required'],
msg: ['请选择结束时间'], msg: ['请选择结束时间'],
}, { },
{
name: 'address', name: 'address',
rule: ['required'], rule: ['required'],
msg: ['请填写详细地址'], msg: ['请填写详细地址'],
}, { },
{
name: 'demand', name: 'demand',
rule: ['required'], rule: ['required'],
msg: ['请填写需求'], msg: ['请填写需求'],
...@@ -135,11 +140,53 @@ ...@@ -135,11 +140,53 @@
</view> </view>
<view class="text-left"> <view class="text-left">
<fui-form ref="formRef"> <fui-form ref="formRef">
<fui-input marginTop="30" size="24" type="number" maxlength="11" placeholder="请填写手机号码" v-model="pageData.form.phone" required placeholderStyle="margin-left: 10rpx;"/> <fui-input
<fui-input marginTop="30" size="24" disabled @click="pageData.areaShow.address = true" placeholder="请选择作业区域" v-model="pageData.scopeText" required placeholderStyle="margin-left: 10rpx;"/> marginTop="30"
<fui-input marginTop="30" size="24" placeholder="请填写详细地址" v-model="pageData.form.address" required placeholderStyle="margin-left: 10rpx;"/> size="24"
<fui-input marginTop="30" size="24" placeholder="请选择作业时间" v-model="pageData.form.time" @click="dict.show.time = true" required placeholderStyle="margin-left: 10rpx;"/> type="number"
<fui-textarea v-model="pageData.form.demand" :marginTop="30" size="24" placeholder="简要说明作业要求" flexStart required placeholderStyle="margin-left: 10rpx;" height="100rpx" /> maxlength="11"
placeholder="请填写手机号码"
v-model="pageData.form.phone"
required
placeholderStyle="margin-left: 10rpx;"
/>
<fui-input
marginTop="30"
size="24"
disabled
@click="pageData.areaShow.address = true"
placeholder="请选择作业区域"
v-model="pageData.scopeText"
required
placeholderStyle="margin-left: 10rpx;"
/>
<fui-input
marginTop="30"
size="24"
placeholder="请填写详细地址"
v-model="pageData.form.address"
required
placeholderStyle="margin-left: 10rpx;"
/>
<fui-input
marginTop="30"
size="24"
placeholder="请选择作业时间"
v-model="pageData.form.time"
@click="dict.show.time = true"
required
placeholderStyle="margin-left: 10rpx;"
/>
<fui-textarea
v-model="pageData.form.demand"
:marginTop="30"
size="24"
placeholder="简要说明作业要求"
flexStart
required
placeholderStyle="margin-left: 10rpx;"
height="100rpx"
/>
<view style="margin-top: 30rpx"> <view style="margin-top: 30rpx">
<fui-button type="warning" text="提交" bold radius="96rpx" @click="submit" /> <fui-button type="warning" text="提交" bold radius="96rpx" @click="submit" />
</view> </view>
......
<script setup lang="ts"> <script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import Navigate from '@/utils/page/navigate'
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as NongzhiAPI from '@/api/model/nongzhi' import * as NongzhiAPI from '@/api/model/nongzhi'
import * as NongjifuwuAPI from '@/api/model/nongjifuwu' import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
let enterpriseId = null; let enterpriseId = null;
onLoad((options) => { onLoad((options) => {
let param = JSON.parse(decodeURIComponent(options.param)); const param = JSON.parse(decodeURIComponent(options.param));
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: param.name title: param.name
}); });
enterpriseId = param.id; enterpriseId = param.id;
getDetailData(enterpriseId); getDetailData(enterpriseId);
getProvince(0,null); getProvince(0, null);
postMachineryQueryById(); postMachineryQueryById();
}) })
const toastRef = ref() const toastRef = ref()
const unitPopupRef = ref(null); const unitPopupRef = ref(null);
const uploadRef = ref() const uploadRef = ref()
const bgColorData = ["#EEFAEB","#EFF1FF","#FFF3F1","#E8F7F7","#FFF3E7","#FAF8EA"]; const bgColorData = ["#EEFAEB", "#EFF1FF", "#FFF3F1", "#E8F7F7", "#FFF3E7", "#FAF8EA"];
const pageData = reactive({ const pageData = reactive({
data:null, data: null,
enterpriseCers:[], enterpriseCers: [],
isPopupShow:false, isPopupShow: false,
unitPopup:false, unitPopup: false,
unitOptions:[], unitOptions: [],
unitVal:[], unitVal: [],
productImageArr:[], productImageArr: [],
categoryPopup:false, categoryPopup: false,
categoryOptions:[], categoryOptions: [],
categoryText:[], categoryText: [],
categoryVal:[], categoryVal: [],
enterpriseProduct:[], enterpriseProduct: [],
contactName:"", contactName: "",
showConfirmDialog:false, showConfirmDialog: false,
rules: [ rules: [
{ {
name: 'name', name: 'name',
rule: ['required'], rule: ['required'],
msg: ['请输入农机名称'], msg: ['请输入农机名称'],
},{ }, {
name: "mobile", name: "mobile",
rule: ["required", "isMobile"], rule: ["required", "isMobile"],
msg: ["请输入联系电话", "请输入正确的联系电话"] msg: ["请输入联系电话", "请输入正确的联系电话"]
},{ }, {
name: 'areaText', name: 'areaText',
rule: ['required'], rule: ['required'],
msg: ['请选择服务区域'], msg: ['请选择服务区域'],
},{ }, {
name: 'minPrice', name: 'minPrice',
rule: ['required'], rule: ['required'],
msg: ['请输入最低价'], msg: ['请输入最低价'],
},{ }, {
name: 'maxPrice', name: 'maxPrice',
rule: ['required'], rule: ['required'],
msg: ['请输入最高价'], msg: ['请输入最高价'],
...@@ -73,28 +73,28 @@ ...@@ -73,28 +73,28 @@
}, },
] ]
}) })
let productInfo = reactive({ const productInfo = reactive({
id:"", id: "",
name:"",// 商品名称 name: "", // 商品名称
mobile:"", // 联系方式 mobile: "", // 联系方式
province:"", // 省 province: "", // 省
city:"", // 市 city: "", // 市
districts:"", // 区县 districts: "", // 区县
minPrice:"", // 最小销售价 minPrice: "", // 最小销售价
maxPrice: "", // 最大销售价 maxPrice: "", // 最大销售价
image:"", // 农机图片 image: "", // 农机图片
enterpriseId:"", // 企业ID enterpriseId: "", // 企业ID
areaText:'', areaText: '',
}) })
function handleSelectArea(){ function handleSelectArea() {
pageData.unitPopup = true; pageData.unitPopup = true;
} }
function postMachineryQueryById(){ function postMachineryQueryById() {
NongjifuwuAPI.postMachineryQueryById({enterpriseId:enterpriseId}).then((res) => { NongjifuwuAPI.postMachineryQueryById({ enterpriseId }).then((res) => {
pageData.enterpriseProduct = res; pageData.enterpriseProduct = res;
console.log(res); console.log(res);
}) })
} }
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
function handleUpload(file) { function handleUpload(file) {
const tempFilePaths = file.tempFilePaths; const tempFilePaths = file.tempFilePaths;
// 处理每张选中的图片 // 处理每张选中的图片
for(let i = 0; i < tempFilePaths.length; i++){ for (let i = 0; i < tempFilePaths.length; i++) {
uni.uploadFile({ uni.uploadFile({
url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: tempFilePaths[i], filePath: tempFilePaths[i],
...@@ -137,55 +137,55 @@ ...@@ -137,55 +137,55 @@
} }
} }
// 文件删除 // 文件删除
function handleDelete(file,type) { function handleDelete(file, type) {
uploadRef.value.clearFiles() uploadRef.value.clearFiles()
pageData.productImageArr[0] = null pageData.productImageArr[0] = null
} }
function selectCompleteUnit(e){ function selectCompleteUnit(e) {
const text = e.text; const text = e.text;
const areaAttr = ['province','city','districts']; const areaAttr = ['province', 'city', 'districts'];
for(let i = 0; i < text.length;i++){ for (let i = 0; i < text.length; i++) {
productInfo[areaAttr[i]] = text[i]; productInfo[areaAttr[i]] = text[i];
} }
productInfo.areaText = text.join(''); productInfo.areaText = text.join('');
pageData.unitPopup = false; pageData.unitPopup = false;
} }
function changeUnit(e){ function changeUnit(e) {
let val = e.value; const val = e.value;
getProvince(val,e); getProvince(val, e);
} }
function handleSelectUnit(){ function handleSelectUnit() {
pageData.unitPopup = true; pageData.unitPopup = true;
} }
// 获取下一级地区 // 获取下一级地区
function getProvince(code,e) { function getProvince(code, e) {
if(e && e.layer >=2){ if (e && e.layer >= 2) {
unitPopupRef.value.end(); unitPopupRef.value.end();
return; return;
} }
LinghuoyonggongAPI.queryConditions({ parentCode : code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: code }).then(res => {
if(res.length){ if (res.length) {
let dataArr = []; const dataArr = [];
for(let i = 0; i < res.length; i++){ for (let i = 0; i < res.length; i++) {
let obj = {text:"",value:""}; const obj = { text: "", value: "" };
obj.text = res[i].name; obj.text = res[i].name;
obj.value = res[i].code; obj.value = res[i].code;
dataArr.push(obj); dataArr.push(obj);
} }
if(!pageData.unitOptions.length){ if (!pageData.unitOptions.length) {
pageData.unitOptions = dataArr; pageData.unitOptions = dataArr;
}else{ } else {
unitPopupRef.value.setRequestData(dataArr, e.layer); unitPopupRef.value.setRequestData(dataArr, e.layer);
} }
}else{ } else {
unitPopupRef.value.end(); unitPopupRef.value.end();
} }
}) })
} }
// 发布 // 发布
const formRef = ref() const formRef = ref()
function addData(){ function addData() {
productInfo.image = pageData.productImageArr[0]; productInfo.image = pageData.productImageArr[0];
formRef.value.validator(productInfo, pageData.rules, true).then((res) => { formRef.value.validator(productInfo, pageData.rules, true).then((res) => {
if (res.isPassed) { if (res.isPassed) {
...@@ -195,26 +195,25 @@ ...@@ -195,26 +195,25 @@
text: '发布成功', text: '发布成功',
}) })
pageData.isPopupShow = false; pageData.isPopupShow = false;
setTimeout(()=>{ setTimeout(() => {
postMachineryQueryById(); postMachineryQueryById();
},500) }, 500)
}) })
} }
}) })
} }
function getDetailData(id){ function getDetailData(id) {
NongzhiAPI.getEnterpriseDetail({ id }).then((res) => { NongzhiAPI.getEnterpriseDetail({ id }).then((res) => {
pageData.enterpriseCers = res.enterpriseCers.split(","); pageData.enterpriseCers = res.enterpriseCers.split(",");
pageData.data = res; pageData.data = res;
pageData.contactName = res.contactPerson.substring(0,1) + new Array(res.contactPerson.length).join('*'); pageData.contactName = res.contactPerson.substring(0, 1) + Array.from({ length: res.contactPerson.length }).join('*');
productInfo.enterpriseId = res.id; productInfo.enterpriseId = res.id;
}) })
} }
function getBgColor(index:any){ function getBgColor(index: any) {
if(index < 6){ if (index < 6) {
return bgColorData[index]; return bgColorData[index];
}else{ } else {
return bgColorData[Math.floor(Math.random() * 5)]; return bgColorData[Math.floor(Math.random() * 5)];
} }
} }
...@@ -232,12 +231,13 @@ ...@@ -232,12 +231,13 @@
pageData.productImageArr = []; pageData.productImageArr = [];
pageData.isPopupShow = true; pageData.isPopupShow = true;
} }
function makePhoneCall(){ function makePhoneCall() {
uni.makePhoneCall({ uni.makePhoneCall({
phoneNumber: pageData.data.contactMobile phoneNumber: pageData.data.contactMobile
}); });
} }
</script> </script>
<template> <template>
<view class="w-full h-95vh bg-#E6F5E8 detail_page"> <view class="w-full h-95vh bg-#E6F5E8 detail_page">
<view class="module_width top_content" v-if="pageData.data"> <view class="module_width top_content" v-if="pageData.data">
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</view> </view>
<view class="module_width middle_content"> <view class="module_width middle_content">
<view class="module_title">资质证书</view> <view class="module_title">资质证书</view>
<view class="module_separate"></view> <view class="module_separate"/>
<view class="module_qualification"> <view class="module_qualification">
<view class="qualification_item" :style="`background:${getBgColor(index)}`" v-for="(item,index) in pageData.enterpriseCers" :key="index"> <view class="qualification_item" :style="`background:${getBgColor(index)}`" v-for="(item,index) in pageData.enterpriseCers" :key="index">
<image class="enterprise_logo" mode="heightFix" :src="item" /> <image class="enterprise_logo" mode="heightFix" :src="item" />
...@@ -258,8 +258,8 @@ ...@@ -258,8 +258,8 @@
</view> </view>
<view class="module_width footer_content"> <view class="module_width footer_content">
<view class="module_title">主营农机</view> <view class="module_title">主营农机</view>
<view class="module_separate"></view> <view class="module_separate"/>
<view class="business_item" v-for="item in pageData.enterpriseProduct" :key="item.id"> <view class="business_item" v-for="item in pageData.enterpriseProduct" :key="item.id">
<image class="business_img" :src="item.image" /> <image class="business_img" :src="item.image" />
<view class="yr-right"> <view class="yr-right">
...@@ -271,11 +271,11 @@ ...@@ -271,11 +271,11 @@
</view> </view>
</view> </view>
</view> </view>
<view class="make-phone-view"> <view class="make-phone-view">
<fui-button text="我要租赁" bold radius="96rpx" @click="pageData.showConfirmDialog=true;" height="80rpx"/> <fui-button text="我要租赁" bold radius="96rpx" @click="pageData.showConfirmDialog=true;" height="80rpx"/>
</view> </view>
</view> </view>
<!-- 确认对话框 --> <!-- 确认对话框 -->
<ConfirmDialog <ConfirmDialog
...@@ -286,37 +286,37 @@ ...@@ -286,37 +286,37 @@
confirmText="确认" confirmText="确认"
@confirm="makePhoneCall" @confirm="makePhoneCall"
/> />
<fui-fab position="right" distance="10" bottom="240" width="120" @click="handlePublish"> <fui-fab position="right" distance="10" bottom="240" width="120" @click="handlePublish">
<view class="text-white text-center"> <view class="text-white text-center">
<view class="fab-icon" /> <view class="fab-icon" />
<view style="font-size: 24rpx">发布产品</view> <view style="font-size: 24rpx">发布产品</view>
</view> </view>
</fui-fab> </fui-fab>
<fui-bottom-popup :show="pageData.isPopupShow" @close="pageData.isPopupShow = false"> <fui-bottom-popup :show="pageData.isPopupShow" @close="pageData.isPopupShow = false">
<view class="fui-custom__wrap yr_person_popup"> <view class="fui-custom__wrap yr_person_popup">
<view class="popup_top"> <view class="popup_top">
<uni-icons type="left" size="24" color="#333333" @click="pageData.isPopupShow = false"></uni-icons> <uni-icons type="left" size="24" color="#333333" @click="pageData.isPopupShow = false"/>
<view class="add_person_text">农机信息</view> <view class="add_person_text">农机信息</view>
<view class="del_person_btn"></view> <view class="del_person_btn"/>
</view> </view>
<view class="popup_content"> <view class="popup_content">
<fui-form label-weight="auto" ref="formRef" top="0"> <fui-form label-weight="auto" ref="formRef" top="0">
<fui-input required label="农机名称" borderTop placeholder="请输入农机名称" v-model="productInfo.name" label-width="220" size="28"></fui-input> <fui-input required label="农机名称" borderTop placeholder="请输入农机名称" v-model="productInfo.name" label-width="220" size="28"/>
<fui-input required maxlength="11" label="联系电话" placeholder="请输入联系方式" v-model="productInfo.mobile" label-width="220" size="28"></fui-input> <fui-input required maxlength="11" label="联系电话" placeholder="请输入联系方式" v-model="productInfo.mobile" label-width="220" size="28"/>
<fui-input @click="handleSelectArea" required label="服务区域" placeholder="请选择服务区域" disabled :value="productInfo.areaText" label-width="220" size="28"></fui-input> <fui-input @click="handleSelectArea" required label="服务区域" placeholder="请选择服务区域" disabled :value="productInfo.areaText" label-width="220" size="28"/>
<fui-form-item asterisk label="价格(元/亩)" labelSize="28" label-width="220" size="28"> <fui-form-item asterisk label="价格(元/亩)" labelSize="28" label-width="220" size="28">
<fui-input v-model="productInfo.minPrice" :borderBottom="false" :padding="[0]" placeholder="最低价"></fui-input> <fui-input v-model="productInfo.minPrice" :borderBottom="false" :padding="[0]" placeholder="最低价"/>
<template v-slot:right> <template #right>
<view style="color: #CCCCCC;margin-right: 40rpx;"></view> <view style="color: #CCCCCC;margin-right: 40rpx;"></view>
<fui-input v-model="productInfo.maxPrice" :borderBottom="false" :padding="[0]" placeholder="最高价"></fui-input> <fui-input v-model="productInfo.maxPrice" :borderBottom="false" :padding="[0]" placeholder="最高价"/>
</template> </template>
</fui-form-item> </fui-form-item>
<fui-form-item asterisk label="商品图片" :bottomBorder="false"> <fui-form-item asterisk label="商品图片" :bottomBorder="false">
<template v-slot:vertical> <template #vertical>
<uni-file-picker :value="pageData.productImageArr" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete"/> <uni-file-picker :value="pageData.productImageArr" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete"/>
</template> </template>
</fui-form-item> </fui-form-item>
...@@ -325,18 +325,17 @@ ...@@ -325,18 +325,17 @@
<fui-button text="保存" bold radius="96rpx" @click="addData" height="80rpx"/> <fui-button text="保存" bold radius="96rpx" @click="addData" height="80rpx"/>
</view> </view>
</fui-bottom-popup> </fui-bottom-popup>
<fui-bottom-popup :show="pageData.unitPopup"> <fui-bottom-popup :show="pageData.unitPopup">
<view class="fui-scroll__wrap"> <view class="fui-scroll__wrap">
<view class="fui-title">请选择</view> <view class="fui-title">请选择</view>
<fui-cascader ref="unitPopupRef" :value="pageData.unitVal" stepLoading @change="changeUnit" @complete="selectCompleteUnit" :options="pageData.unitOptions"></fui-cascader> <fui-cascader ref="unitPopupRef" :value="pageData.unitVal" stepLoading @change="changeUnit" @complete="selectCompleteUnit" :options="pageData.unitOptions"/>
<view class="fui-icon__close" @tap.stop="pageData.unitPopup=false"> <view class="fui-icon__close" @tap.stop="pageData.unitPopup=false">
<fui-icon name="close" :size="48"></fui-icon> <fui-icon name="close" :size="48"/>
</view> </view>
</view> </view>
</fui-bottom-popup> </fui-bottom-popup>
<fui-toast ref="toastRef" /> <fui-toast ref="toastRef" />
</template> </template>
...@@ -400,7 +399,7 @@ ...@@ -400,7 +399,7 @@
} }
} }
.middle_content{ .middle_content{
} }
.module_title{ .module_title{
font-size: 32rpx; font-size: 32rpx;
...@@ -450,9 +449,7 @@ ...@@ -450,9 +449,7 @@
margin-left: 0rpx; margin-left: 0rpx;
} }
} }
.business_item{ .business_item{
border-bottom: 1px solid #EEEEEE; border-bottom: 1px solid #EEEEEE;
margin-top: 24rpx; margin-top: 24rpx;
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive, toRefs } from 'vue' import { reactive, toRefs } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { getDictData, getText } from '@/utils/dict/area'
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
onLoad((option) => { onLoad((option) => {
...@@ -18,13 +17,13 @@ ...@@ -18,13 +17,13 @@
} else { } else {
pageData.title = '新增农活作业' pageData.title = '新增农活作业'
} }
getProvince(43,null); getProvince(43, null)
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: pageData.title, title: pageData.title,
}) })
}) })
/* onShow(() => { /* onShow(() => {
// 数据字典赋值 // 数据字典赋值
initDict() initDict()
}) */ }) */
...@@ -37,10 +36,10 @@ ...@@ -37,10 +36,10 @@
time2: false, time2: false,
address: false, address: false,
}, },
options: [], options: [],
optionsVal:[], optionsVal: [],
optionsValText:"", optionsValText: '',
form: { form: {
id: '', id: '',
name: '', name: '',
...@@ -94,51 +93,52 @@ ...@@ -94,51 +93,52 @@
}) })
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
const areaPopupRef = ref(null); const areaPopupRef = ref(null)
// 选择地区完成 // 选择地区完成
function selectCompleteArea(e){ function selectCompleteArea(e) {
let text = e.text; const text = e.text
let value = e.value; const value = e.value
let areaText = "",areaVal=""; let areaText = ''
for(let i = 0; i < (text.length-1);i++){ let areaVal = ''
areaText += text[i]+'/'; for (let i = 0; i < text.length - 1; i++) {
areaVal += value[i]+','; areaText += `${text[i]}/`
} areaVal += `${value[i]},`
pageData.form.scope = areaVal.slice(0, -1);; // code }
pageData.optionsValText = areaText.slice(0, -1);; pageData.form.scope = areaVal.slice(0, -1) // code
pageData.show.address = false; pageData.optionsValText = areaText.slice(0, -1)
} pageData.show.address = false
// 在选择地区 }
function changeArea(e){ // 在选择地区
let val = e.value; function changeArea(e) {
getProvince(val,e); const val = e.value
} getProvince(val, e)
// 获取下一级地区 }
function getProvince(code,e) { // 获取下一级地区
LinghuoyonggongAPI.queryConditions({ parentCode : code}).then(res=>{ function getProvince(code, e) {
if(res.length){ LinghuoyonggongAPI.queryConditions({ parentCode: code }).then((res) => {
let dataArr = []; if (res.length) {
for(let i = 0; i < res.length; i++){ const dataArr = []
let obj = {text:"",value:""}; for (let i = 0; i < res.length; i++) {
obj.text = res[i].name; const obj = { text: '', value: '' }
obj.value = res[i].code; obj.text = res[i].name
dataArr.push(obj); obj.value = res[i].code
} dataArr.push(obj)
if(!pageData.options.length){ }
pageData.options = dataArr; if (!pageData.options.length) {
}else{ pageData.options = dataArr
console.log("e.layer= "+ e.layer); } else {
areaPopupRef.value.setRequestData(dataArr, e.layer); console.log(`e.layer= ${e.layer}`)
if(e.layer >= 2){ areaPopupRef.value.setRequestData(dataArr, e.layer)
areaPopupRef.value.end(); if (e.layer >= 2) {
} areaPopupRef.value.end()
} }
}else{ }
areaPopupRef.value.end(); } else {
} areaPopupRef.value.end()
}) }
} })
}
function getDetails(id) { function getDetails(id) {
pageData.loading = true pageData.loading = true
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
}) })
} }
function getCurrentDate(){ function getCurrentDate() {
const date = new Date() const date = new Date()
const year = date.getFullYear() const year = date.getFullYear()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
...@@ -255,7 +255,15 @@ ...@@ -255,7 +255,15 @@
<view class="formBox"> <view class="formBox">
<fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false"> <fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false">
<view class="mt20"> <view class="mt20">
<fui-input required label="服务名称" placeholder="请输入服务名称" v-model="form.name" labelSize="28" label-width="180" maxlength="16" /> <fui-input
required
label="服务名称"
placeholder="请输入服务名称"
v-model="form.name"
labelSize="28"
label-width="180"
maxlength="16"
/>
<view class="form-item required flex align-center" style="padding: 20rpx 10rpx"> <view class="form-item required flex align-center" style="padding: 20rpx 10rpx">
<text class="label">服务范围</text> <text class="label">服务范围</text>
<view class="time-input" @click="show.address = true"> <view class="time-input" @click="show.address = true">
...@@ -264,11 +272,37 @@ ...@@ -264,11 +272,37 @@
</text> </text>
</view> </view>
</view> </view>
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.address" labelSize="28" label-width="180" size="28"/> <fui-input
<fui-input required type="number" label="联系方式" placeholder="请填写联系方式" v-model="form.phone" labelSize="28" label-width="180" :maxlength="11" /> required
label="详细地址"
placeholder="请输入详细地址"
v-model="form.address"
labelSize="28"
label-width="180"
size="28"
/>
<fui-input
required
type="number"
label="联系方式"
placeholder="请填写联系方式"
v-model="form.phone"
labelSize="28"
label-width="180"
:maxlength="11"
/>
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-textarea flexStart required label="作业需求" placeholder="请输入作业需求" v-model="form.demand" labelSize="28" label-width="180" placeholder-style="font-size: 28rpx;"/> <fui-textarea
flexStart
required
label="作业需求"
placeholder="请输入作业需求"
v-model="form.demand"
labelSize="28"
label-width="180"
placeholder-style="font-size: 28rpx;"
/>
<!-- 作业时间 --> <!-- 作业时间 -->
<view class="form-section" style="padding: 0 10rpx"> <view class="form-section" style="padding: 0 10rpx">
<view class="form-item flex align-center"> <view class="form-item flex align-center">
...@@ -291,31 +325,57 @@ ...@@ -291,31 +325,57 @@
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size:28rpx;"><span class="text-red">*&nbsp;</span> 图片 </view> <view class="mb-1 flex justify-start" style="font-size: 28rpx"
<uni-file-picker :value="form.pictureObj" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete" /> ><span class="text-red">*&nbsp;</span> 图片
</view>
<uni-file-picker
:value="form.pictureObj"
ref="uploadRef"
limit="1"
:auto-upload="false"
@select="handleUpload"
@delete="handleDelete"
/>
</view> </view>
<view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx"> <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> </view>
</fui-form> </fui-form>
<fui-date-picker :show="show.time1" type="3" @change="handleChangeTime1" @cancel="show.time1 = false" :minDate="getCurrentDate()" /> <fui-date-picker
<fui-date-picker :show="show.time2" type="3" @change="handleChangeTime2" @cancel="show.time2 = false" :minDate="getCurrentDate()" /> :show="show.time1"
type="3"
@change="handleChangeTime1"
@cancel="show.time1 = false"
:minDate="getCurrentDate()"
/>
<fui-date-picker
:show="show.time2"
type="3"
@change="handleChangeTime2"
@cancel="show.time2 = false"
:minDate="getCurrentDate()"
/>
<fui-toast ref="toastRef" /> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
<!-- <fui-picker :show="show.address" :options="options.address" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.address = false" /> <!-- <fui-picker :show="show.address" :options="options.address" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.address = false" />
--> -->
<fui-bottom-popup :show="pageData.show.address"> <fui-bottom-popup :show="pageData.show.address">
<view class="fui-scroll__wrap yr-select-area"> <view class="fui-scroll__wrap yr-select-area">
<view class="fui-title">请选择</view> <view class="fui-title">请选择</view>
<fui-cascader ref="areaPopupRef" :value="pageData.optionsVal" stepLoading @change="changeArea" @complete="selectCompleteArea" :options="pageData.options"></fui-cascader> <fui-cascader
<view class="fui-icon__close" @tap.stop="pageData.show.address = false"> ref="areaPopupRef"
<fui-icon name="close" :size="48"></fui-icon> :value="pageData.optionsVal"
</view> stepLoading
</view> @change="changeArea"
</fui-bottom-popup> @complete="selectCompleteArea"
:options="pageData.options"
/>
<view class="fui-icon__close" @tap.stop="pageData.show.address = false">
<fui-icon name="close" :size="48" />
</view>
</view>
</fui-bottom-popup>
</view> </view>
</view> </view>
</template> </template>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { getDictData, getText } from '@/utils/dict/area' import { getDictData, getText } from '@/utils/dict/area'
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
onLoad((option) => { onLoad((option) => {
...@@ -222,14 +222,17 @@ ...@@ -222,14 +222,17 @@
label-width="180" label-width="180"
maxlength="6" maxlength="6"
> >
<view slot="suffix" class="unit-slot">元/亩</view> <template #suffix>
<!-- <slot name="right" style="font-size:28rpx;"></slot> --> <view class="unit-slot">元/亩</view>
</fui-input> </template>
<!-- <slot name="right" style="font-size:28rpx;"></slot> -->
</fui-input>
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size:28rpx;"><span class="text-red">*&nbsp;</span> 图片 </view> <view class="mb-1 flex justify-start" style="font-size: 28rpx"
><span class="text-red">*&nbsp;</span> 图片
</view>
<uni-file-picker <uni-file-picker
:value="form.pictureObj" :value="form.pictureObj"
:max-size="1024" :max-size="1024"
......
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import { onLoad, onReachBottom, onShow } from '@dcloudio/uni-app' import { onLoad, onReachBottom, onShow } from '@dcloudio/uni-app'
import ApplyDialog from './components/apply-dialog.vue' import ApplyDialog from './components/apply-dialog.vue'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import * as NongjifuwuAPI from '@/api/model/nongjifuwu' import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
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 { s } from 'vite/dist/node/types.d-aGj9QkWt'
import { getDictData, getText } from '@/utils/dict/area' import { getDictData, getText } from '@/utils/dict/area'
onLoad((option) => { onLoad((option) => {
pageData.search.serviceType = Number(option.type) || 1; pageData.search.serviceType = Number(option.type) || 1
getProvince(43,null); getProvince(43, null)
}) })
onShow(() => { onShow(() => {
...@@ -29,8 +28,8 @@ ...@@ -29,8 +28,8 @@
address: false, address: false,
}, },
options: [], options: [],
optionsVal:[], optionsVal: [],
optionsValText:"", optionsValText: '',
// 分类标签 // 分类标签
categoryTabs: [ categoryTabs: [
{ id: 1, name: '找农机' }, { id: 1, name: '找农机' },
...@@ -41,108 +40,108 @@ ...@@ -41,108 +40,108 @@
pageSize: 10, pageSize: 10,
serviceType: 1, serviceType: 1,
scope: null, scope: null,
bizCategory:3, bizCategory: 3,
reviewStatus:1 reviewStatus: 1,
}, },
farmMachineList: [], farmMachineList: [],
total: 0, total: 0,
}) })
const areaPopupRef = ref(null); const areaPopupRef = ref(null)
// 选择地区完成 // 选择地区完成
function selectCompleteArea(e){ function selectCompleteArea(e) {
let text = e.text; const text = e.text
let value = e.value; const value = e.value
let areaText = "",areaVal=""; let areaText = ''
for(let i = 0; i < (text.length-1);i++){ let areaVal = ''
areaText += text[i]+'/'; for (let i = 0; i < text.length - 1; i++) {
areaVal += value[i]+','; areaText += `${text[i]}/`
} areaVal += `${value[i]},`
pageData.search.scope = areaVal.slice(0, -1);; // code }
pageData.optionsValText= areaText.slice(0, -1);; pageData.search.scope = areaVal.slice(0, -1) // code
pageData.show.address = false; pageData.optionsValText = areaText.slice(0, -1)
// 触发搜索 pageData.show.address = false
search(); // 触发搜索
} search()
// 在选择地区 }
function changeArea(e){ // 在选择地区
let val = e.value; function changeArea(e) {
getProvince(val,e); const val = e.value
} getProvince(val, e)
// 获取下一级地区 }
function getProvince(code,e) { // 获取下一级地区
LinghuoyonggongAPI.queryConditions({ parentCode : code}).then(res=>{ function getProvince(code, e) {
if(res.length){ LinghuoyonggongAPI.queryConditions({ parentCode: code }).then((res) => {
let dataArr = []; if (res.length) {
for(let i = 0; i < res.length; i++){ const dataArr = []
let obj = {text:"",value:""}; for (let i = 0; i < res.length; i++) {
obj.text = res[i].name; const obj = { text: '', value: '' }
obj.value = res[i].code; obj.text = res[i].name
dataArr.push(obj); obj.value = res[i].code
} dataArr.push(obj)
if(!pageData.options.length){ }
pageData.options = dataArr; if (!pageData.options.length) {
}else{ pageData.options = dataArr
console.log("e.layer= "+ e.layer); } else {
areaPopupRef.value.setRequestData(dataArr, e.layer); console.log(`e.layer= ${e.layer}`)
if(e.layer >= 2){ areaPopupRef.value.setRequestData(dataArr, e.layer)
areaPopupRef.value.end(); if (e.layer >= 2) {
} areaPopupRef.value.end()
} }
}else{ }
areaPopupRef.value.end(); } else {
} areaPopupRef.value.end()
}) }
} })
}
function getFarmMachineList() { function getFarmMachineList() {
pageData.loading = true pageData.loading = true
if(pageData.search.serviceType == 1){ if (pageData.search.serviceType == 1) {
NongzhiAPI.getEnterpriseList(pageData.search) NongzhiAPI.getEnterpriseList(pageData.search)
.then((res) => { .then((res) => {
const { records, total } = res const { records, total } = res
pageData.farmMachineList = [...pageData.farmMachineList, ...records] pageData.farmMachineList = [...pageData.farmMachineList, ...records]
pageData.total = total; pageData.total = total
}) })
.finally(() => { .finally(() => {
pageData.loading = false pageData.loading = false
}) })
}else{ } else {
NongjifuwuAPI.farmMachineList(pageData.search) NongjifuwuAPI.farmMachineList(pageData.search)
.then((res) => { .then((res) => {
const { records, total } = res const { records, total } = res
pageData.farmMachineList = [...pageData.farmMachineList, ...records] pageData.farmMachineList = [...pageData.farmMachineList, ...records]
pageData.total = total pageData.total = total
}) })
.finally(() => { .finally(() => {
pageData.loading = false pageData.loading = false
}) })
} }
} }
function search() { function search() {
pageData.loading = true pageData.loading = true
if(pageData.search.serviceType == 1){ if (pageData.search.serviceType == 1) {
NongzhiAPI.getEnterpriseList(pageData.search) NongzhiAPI.getEnterpriseList(pageData.search)
.then((res) => { .then((res) => {
const { records, total } = res const { records, total } = res
pageData.farmMachineList = records pageData.farmMachineList = records
pageData.total = total pageData.total = total
}) })
.finally(() => { .finally(() => {
pageData.loading = false pageData.loading = false
}) })
}else{ } else {
NongjifuwuAPI.farmMachineList(pageData.search) NongjifuwuAPI.farmMachineList(pageData.search)
.then((res) => { .then((res) => {
const { records, total } = res const { records, total } = res
pageData.farmMachineList = records pageData.farmMachineList = records
pageData.total = total pageData.total = total
}) })
.finally(() => { .finally(() => {
pageData.loading = false pageData.loading = false
}) })
} }
} }
async function getCascader() { async function getCascader() {
...@@ -151,40 +150,40 @@ ...@@ -151,40 +150,40 @@
// 分类标签点击事件 // 分类标签点击事件
function onCategoryTabClick(tab: any) { function onCategoryTabClick(tab: any) {
pageData.search.serviceType = tab.id; pageData.search.serviceType = tab.id
// 在这里添加具体的分类标签点击逻辑 // 在这里添加具体的分类标签点击逻辑
pageData.search.pageNo = 1 pageData.search.pageNo = 1
pageData.farmMachineList = []; pageData.farmMachineList = []
getFarmMachineList() getFarmMachineList()
let pages = getCurrentPages(); const pages = getCurrentPages()
let page = pages[pages.length - 1]; const page = pages[pages.length - 1]
if(pageData.search.serviceType == 1){ if (pageData.search.serviceType == 1) {
// #ifdef H5 // #ifdef H5
document.querySelector('.uni-page-head-ft .uni-page-head-btn .uni-btn-icon').innerHTML = '申请入驻'; document.querySelector('.uni-page-head-ft .uni-page-head-btn .uni-btn-icon').innerHTML = '申请入驻'
// #endif // #endif
// #ifdef APP-PLUS // #ifdef APP-PLUS
var currentVebview = page.$getAppWebview(); var currentVebview = page.$getAppWebview()
var tn = currentVebview.getStyle().titleNView; var tn = currentVebview.getStyle().titleNView
tn.buttons[0].text = '申请入驻'; // \ue... 字体图标 tn.buttons[0].text = '申请入驻' // \ue... 字体图标
// tn.buttons[0].fontSrc = "/static/font/iconfont.ttf" // tn.buttons[0].fontSrc = "/static/font/iconfont.ttf"
currentVebview.setStyle({ currentVebview.setStyle({
titleNView: tn titleNView: tn,
}) })
// #endif // #endif
}else{ } else {
// #ifdef H5 // #ifdef H5
document.querySelector('.uni-page-head-ft .uni-page-head-btn .uni-btn-icon').innerHTML = ''; document.querySelector('.uni-page-head-ft .uni-page-head-btn .uni-btn-icon').innerHTML = ''
// #endif // #endif
// #ifdef APP-PLUS // #ifdef APP-PLUS
var currentVebview = page.$getAppWebview(); var currentVebview = page.$getAppWebview()
var tn = currentVebview.getStyle().titleNView; var tn = currentVebview.getStyle().titleNView
tn.buttons[0].text = ''; tn.buttons[0].text = ''
currentVebview.setStyle({ currentVebview.setStyle({
titleNView: tn titleNView: tn,
}) })
// #endif // #endif
} }
} }
function handlePublish() { function handlePublish() {
...@@ -217,23 +216,23 @@ ...@@ -217,23 +216,23 @@
// 触发搜索 // 触发搜索
search() search()
} }
function toDetail(item) { function toDetail(item) {
let param = encodeURIComponent(JSON.stringify({id:item.id,name:item.enterpriseName})); const param = encodeURIComponent(JSON.stringify({ id: item.id, name: item.enterpriseName }))
Navigate.to(`/pages/nongjifuwu/detail?param=${param}`) Navigate.to(`/pages/nongjifuwu/detail?param=${param}`)
} }
onNavigationBarButtonTap((e) => { onNavigationBarButtonTap((e) => {
/* pageData.search.scope = null /* pageData.search.scope = null
search() */ search() */
if(pageData.search.serviceType == 1){ if (pageData.search.serviceType == 1) {
Navigate.to('/pages/nongjifuwu/shenqingruzhu') Navigate.to('/pages/nongjifuwu/shenqingruzhu')
} }
}) })
onReachBottom(() => { onReachBottom(() => {
if (pageData.total <= pageData.farmMachineList.length) return if (pageData.total <= pageData.farmMachineList.length)
return
pageData.search.pageNo++ pageData.search.pageNo++
getFarmMachineList() getFarmMachineList()
}) })
...@@ -273,69 +272,77 @@ ...@@ -273,69 +272,77 @@
<fui-empty marginTop="100" src="/static/images/no-data.png" title="暂无数据" /> <fui-empty marginTop="100" src="/static/images/no-data.png" title="暂无数据" />
</view> </view>
<view class="codefun-flex-col codefun-relative section_4"> <view class="codefun-flex-col codefun-relative section_4">
<template v-if="pageData.search.serviceType == 1"> <template v-if="pageData.search.serviceType == 1">
<view class="yr-item" v-for="item in pageData.farmMachineList" :key="item.id"> <view class="yr-item" v-for="item in pageData.farmMachineList" :key="item.id">
<view class="item_top"> <view class="item_top">
<image class="enterprise_logo" mode="aspectFit" :src="item.enterpriseLogoUrl" /> <image class="enterprise_logo" mode="aspectFit" :src="item.enterpriseLogoUrl" />
<view class="item_right"> <view class="item_right">
<view class="text-ellipsis yr-item-name">{{item.enterpriseName}}</view> <view class="text-ellipsis yr-item-name">{{ item.enterpriseName }}</view>
<view class="text-ellipsis yr-item-product">公司主营: {{item.businessScope}}</view> <view class="text-ellipsis yr-item-product">公司主营: {{ item.businessScope }}</view>
</view> </view>
</view> </view>
<view class="yr-item-info"> <view class="yr-item-info">
<view class="text-ellipsis yr-item-address"> <view class="text-ellipsis yr-item-address">
<image class="address_icon" src="/static/images/linghuoyonggong/address.png" /> <image class="address_icon" src="/static/images/linghuoyonggong/address.png" />
<text>{{item.provinceName}}{{item.cityName}}{{item.districtName}}{{item.townName}}</text> <text
</view> >{{ item.provinceName }}{{ item.cityName }}{{ item.districtName
<view class="yr-item-detail" @click="toDetail(item)">查看详情</view> }}{{ item.townName }}</text
</view> >
</view> </view>
</template> <view class="yr-item-detail" @click="toDetail(item)">查看详情</view>
<template v-else> </view>
<view class="codefun-flex-row group_6" v-for="item in pageData.farmMachineList" :key="item.id"> </view>
<image </template>
class="codefun-shrink-0 codefun-self-center image_8" <template v-else>
:src="item.picture" <view class="codefun-flex-row group_6" v-for="item in pageData.farmMachineList" :key="item.id">
@click="handleDetails(item)" <image
/> class="codefun-shrink-0 codefun-self-center image_8"
<view style="width: 70%"> :src="item.picture"
<view @click="handleDetails(item)"
class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-self-center" />
@click="handleDetails(item)" <view style="width: 70%">
> <view
<text class="font text_6">{{ item.name }}</text> class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-self-center"
<text class="font_3 text_7 ellipsis" style="width: 100%; margin: 26rpx 0" @click="handleDetails(item)"
>服务范围:{{ getText(item.scope, ' / ') }}</text >
> <text class="font text_6">{{ item.name }}</text>
</view> <text class="font_3 text_7 ellipsis" style="width: 100%; margin: 26rpx 0"
<view class="flex justify-between" style="width: 100%"> >服务范围:{{ getText(item.scope, ' / ') }}</text
<view class="group_5" @click="handleDetails(item)"> >
<text class="font_6">¥</text> </view>
<text class="font_4 text_8">{{ item.price }}</text> <view class="flex justify-between" style="width: 100%">
<text class="font_7">/亩</text> <view class="group_5" @click="handleDetails(item)">
</view> <text class="font_6">¥</text>
<view <text class="font_4 text_8">{{ item.price }}</text>
class="codefun-flex-col codefun-justify-start codefun-items-center codefun-shrink-0 codefun-self-start text-wrapper_2" <text class="font_7">/亩</text>
@click="handleApply(item)" </view>
> <view
<text class="font_5">去预约</text> class="codefun-flex-col codefun-justify-start codefun-items-center codefun-shrink-0 codefun-self-start text-wrapper_2"
</view> @click="handleApply(item)"
</view> >
</view> <text class="font_5">去预约</text>
</view> </view>
</template> </view>
</view>
</view>
</template>
</view> </view>
</view> </view>
</view> </view>
<fui-fab v-show="pageData.search.serviceType != 1" position="right" distance="10" bottom="240" width="96" @click="handlePublish"> <fui-fab
v-show="pageData.search.serviceType != 1"
position="right"
distance="10"
bottom="240"
width="96"
@click="handlePublish"
>
<view class="text-white text-center"> <view class="text-white text-center">
<view class="fab-icon" /> <view class="fab-icon" />
<view style="font-size: 24rpx">发布</view> <view style="font-size: 24rpx">发布</view>
</view> </view>
</fui-fab> </fui-fab>
<!-- <fui-picker <!-- <fui-picker
:show="pageData.show.address" :show="pageData.show.address"
:options="pageData.options" :options="pageData.options"
...@@ -344,16 +351,22 @@ ...@@ -344,16 +351,22 @@
@change="handleChangeAddress" @change="handleChangeAddress"
@cancel="pageData.show.address = false" @cancel="pageData.show.address = false"
/> --> /> -->
<fui-bottom-popup :show="pageData.show.address"> <fui-bottom-popup :show="pageData.show.address">
<view class="fui-scroll__wrap yr-select-area"> <view class="fui-scroll__wrap yr-select-area">
<view class="fui-title">请选择</view> <view class="fui-title">请选择</view>
<fui-cascader ref="areaPopupRef" :value="pageData.optionsVal" stepLoading @change="changeArea" @complete="selectCompleteArea" :options="pageData.options"></fui-cascader> <fui-cascader
<view class="fui-icon__close" @tap.stop="pageData.show.address = false"> ref="areaPopupRef"
<fui-icon name="close" :size="48"></fui-icon> :value="pageData.optionsVal"
</view> stepLoading
</view> @change="changeArea"
</fui-bottom-popup> @complete="selectCompleteArea"
:options="pageData.options"
/>
<view class="fui-icon__close" @tap.stop="pageData.show.address = false">
<fui-icon name="close" :size="48" />
</view>
</view>
</fui-bottom-popup>
<ApplyDialog ref="applyDialogRef" /> <ApplyDialog ref="applyDialogRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
...@@ -361,86 +374,86 @@ ...@@ -361,86 +374,86 @@
<style scoped lang="scss"> <style scoped lang="scss">
.page { .page {
box-sizing: border-box; box-sizing: border-box;
padding-bottom: 12rpx; padding-bottom: 12rpx;
background-color: #e6f5e8; background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH; mix-blend-mode: NOTTHROUGH;
width: 100%; width: 100%;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
min-height: calc(100vh - 88rpx); min-height: calc(100vh - 88rpx);
.text-ellipsis { .text-ellipsis {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.yr-item{ .yr-item {
margin-top: 24rpx; margin-top: 24rpx;
border-bottom: 2rpx solid #EEEEEE; border-bottom: 2rpx solid #eeeeee;
padding-left: 8rpx; padding-left: 8rpx;
padding-bottom: 20rpx; padding-bottom: 20rpx;
.item_top{ .item_top {
display: flex; display: flex;
align-items:flex-start; align-items: flex-start;
justify-content: space-between; justify-content: space-between;
} }
.enterprise_logo{ .enterprise_logo {
width: 160rpx; width: 160rpx;
max-height: 120rpx; max-height: 120rpx;
} }
.yr-item-name{ .yr-item-name {
width: 480rpx; width: 480rpx;
height: 40rpx; height: 40rpx;
font-size: 32rpx; font-size: 32rpx;
line-height: 40rpx; line-height: 40rpx;
font-weight: 500; font-weight: 500;
color: #333333; color: #333333;
} }
.yr-item-product{ .yr-item-product {
margin-top: 12rpx; margin-top: 12rpx;
width: 480rpx; width: 480rpx;
height: 32rpx; height: 32rpx;
font-size: 24rpx; font-size: 24rpx;
line-height: 32rpx; line-height: 32rpx;
font-weight: 500; font-weight: 500;
color: #555555; color: #555555;
} }
.yr-item-info{ .yr-item-info {
margin-top: 18rpx; margin-top: 18rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
.yr-item-address{ .yr-item-address {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
width: 480rpx; width: 480rpx;
display: flex; display: flex;
align-items: center; align-items: center;
.address_icon{ .address_icon {
width: 24rpx; width: 24rpx;
height: 26rpx; height: 26rpx;
margin-right: 8rpx; margin-right: 8rpx;
} }
} }
.yr-item-detail{ .yr-item-detail {
width: 136rpx; width: 136rpx;
height: 48rpx; height: 48rpx;
border-radius: 200rpx; border-radius: 200rpx;
background: #5DB66F; background: #5db66f;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
padding: 20rpx; padding: 20rpx;
color: #FFFFFF; color: #ffffff;
font-size: 24rpx; font-size: 24rpx;
font-weight: 400; font-weight: 400;
} }
} }
} }
.yr-item:last-child{ .yr-item:last-child {
border-bottom:none border-bottom: none;
} }
.section { .section {
padding: 24rpx 24rpx 24rpx 32rpx; padding: 24rpx 24rpx 24rpx 32rpx;
background-color: #5db66f; background-color: #5db66f;
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive, toRefs,ref } from 'vue' import { reactive, ref, toRefs } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import * as UserInfoAPI from '@/api/model/userInfo' import * as NongzhiAPI from '@/api/model/nongzhi'
import * as NongzhiAPI from '@/api/model/nongzhi'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore() const dictStore = useDictStore()
...@@ -14,15 +13,14 @@ ...@@ -14,15 +13,14 @@
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
onLoad((option) => { onLoad((option) => {
// 获取数据详情 // 获取数据详情
getProvince(0,null); getProvince(0, null)
}) })
// 勾选协议校验
//勾选协议校验 function checkAgree(agree) {
function checkAgree(agree) { return agree
return agree }
} const areaPopupRef = ref(null)
const areaPopupRef = ref(null);
const pageData = reactive({ const pageData = reactive({
loading: false, loading: false,
show: { show: {
...@@ -34,215 +32,222 @@ ...@@ -34,215 +32,222 @@
}, },
options: { options: {
area: [], area: [],
areaVal:[], areaVal: [],
urgentdegree: [], urgentdegree: [],
type: [], type: [],
}, },
cersImageIndex:0, cersImageIndex: 0,
cersImageArr:[], cersImageArr: [],
enterpriseLogoArr:[], enterpriseLogoArr: [],
selectAreaVal:[], selectAreaVal: [],
form: { form: {
id: '', id: '',
enterpriseName:"",// 企业名称 enterpriseName: '', // 企业名称
enterpriseCode:"",// 企业编码 enterpriseCode: '', // 企业编码
businessScope:"", // 企业经营范围 businessScope: '', // 企业经营范围
contactPerson:"", // 联系人 contactPerson: '', // 联系人
contactMobile:"", // 联系人手机号 contactMobile: '', // 联系人手机号
profile:"", // 企业简介 profile: '', // 企业简介
provinceName:"", // 省 provinceName: '', // 省
cityName:"", // 市 cityName: '', // 市
districtName:"", // 区县 districtName: '', // 区县
townName:"", // 乡镇 townName: '', // 乡镇
provinceCode:"", // 省 provinceCode: '', // 省
cityCode:"", // 市 cityCode: '', // 市
districtCode:"", // 区县 districtCode: '', // 区县
townCode:"", // 乡镇 townCode: '', // 乡镇
addr: '', // 详细地址
addr:"", // 详细地址 lon: '', // 经度
lon:"", // 经度 lat: '', // 纬度
lat:'', // 纬度 bizCategory: 3, // 业务分类【1:代理记账、2:农资、3:农机、4:金融】
bizCategory: 3, // 业务分类【1:代理记账、2:农资、3:农机、4:金融】 enterpriseLogoUrl: null, // 企业logo url
enterpriseLogoUrl:null, // 企业logo url enterpriseCers: null, // 企业资质url
enterpriseCers:null, // 企业资质url
areaText: '',
agree: false,
areaText: '',
agree:false,
}, },
position: [], position: [],
rules: [ rules: [
{ {
name: 'enterpriseName', name: 'enterpriseName',
rule: ['required'], rule: ['required'],
msg: ['请输入公司名称'], msg: ['请输入公司名称'],
}, { },
{
name: 'enterpriseCode', name: 'enterpriseCode',
rule: ['required'], rule: ['required'],
msg: ['请输入企业编码'], msg: ['请输入企业编码'],
}, { },
{
name: 'businessScope', name: 'businessScope',
rule: ['required'], rule: ['required'],
msg: ['请输入经营业务'], msg: ['请输入经营业务'],
},{ },
{
name: 'profile', name: 'profile',
rule: ['required'], rule: ['required'],
msg: ['请输入平台介绍'], msg: ['请输入平台介绍'],
},{ },
{
name: 'areaText', name: 'areaText',
rule: ['required'], rule: ['required'],
msg: ['请选择地区'], msg: ['请选择地区'],
},{ },
{
name: 'addr', name: 'addr',
rule: ['required'], rule: ['required'],
msg: ['请输入详细地址'], msg: ['请输入详细地址'],
},{ },
{
name: 'contactPerson', name: 'contactPerson',
rule: ['required'], rule: ['required'],
msg: ['请输入联系人'], msg: ['请输入联系人'],
},{ },
name: "contactMobile", {
rule: ["required", "isMobile"], name: 'contactMobile',
msg: ["请输入联系电话", "请输入正确的联系电话"] rule: ['required', 'isMobile'],
},{ msg: ['请输入联系电话', '请输入正确的联系电话'],
},
{
name: 'enterpriseLogoUrl', name: 'enterpriseLogoUrl',
rule: ['required'], rule: ['required'],
msg: ['请上传公司logo'], msg: ['请上传公司logo'],
},{ },
{
name: 'enterpriseCers', name: 'enterpriseCers',
rule: ['required'], rule: ['required'],
msg: ['请上传公司资质证件'], msg: ['请上传公司资质证件'],
},{ },
name: "agree", {
validator: [{ name: 'agree',
msg: "请勾选并同意《入驻协议》与《服务条款》", validator: [
method: checkAgree {
}] msg: '请勾选并同意《入驻协议》与《服务条款》',
} method: checkAgree,
},
],
},
], ],
}) })
function agreeChange(e) { function agreeChange(e) {
pageData.form.agree = e.checked; pageData.form.agree = e.checked
} }
// 选择地区完成 // 选择地区完成
function selectCompleteArea(e){ function selectCompleteArea(e) {
let areaAttr = ['province','city','district','town']; const areaAttr = ['province', 'city', 'district', 'town']
let text = e.text; const text = e.text
let value = e.value; const value = e.value
let formData = pageData.form; const formData = pageData.form
for(let i = 0; i < text.length;i++){ for (let i = 0; i < text.length; i++) {
formData[areaAttr[i]+'Name'] = text[i]; formData[`${areaAttr[i]}Name`] = text[i]
formData[areaAttr[i]+'Code'] = value[i]; formData[`${areaAttr[i]}Code`] = value[i]
} }
pageData.form.areaText= text.join(''); pageData.form.areaText = text.join('')
pageData.show.area = false; pageData.show.area = false
} }
// 在选择地区 // 在选择地区
function changeArea(e){ function changeArea(e) {
let val = e.value; const val = e.value
getProvince(val,e); getProvince(val, e)
} }
// 获取下一级地区 // 获取下一级地区
function getProvince(code,e) { function getProvince(code, e) {
LinghuoyonggongAPI.queryConditions({ parentCode : code}).then(res=>{ LinghuoyonggongAPI.queryConditions({ parentCode: code }).then((res) => {
if(res.length){ if (res.length) {
let dataArr = []; const dataArr = []
for(let i = 0; i < res.length; i++){ for (let i = 0; i < res.length; i++) {
let obj = {text:"",value:""}; const obj = { text: '', value: '' }
obj.text = res[i].name; obj.text = res[i].name
obj.value = res[i].code; obj.value = res[i].code
dataArr.push(obj); dataArr.push(obj)
} }
if(!pageData.options.area.length){ if (!pageData.options.area.length) {
pageData.options.area = dataArr; pageData.options.area = dataArr
}else{ } else {
areaPopupRef.value.setRequestData(dataArr, e.layer); areaPopupRef.value.setRequestData(dataArr, e.layer)
} }
}else{ } else {
areaPopupRef.value.end(); areaPopupRef.value.end()
} }
}) })
} }
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
const toastRef = ref() const toastRef = ref()
const uploadLogoRef = ref() const uploadLogoRef = ref()
const uploadCersRef = ref() const uploadCersRef = ref()
// 文件上传 // 文件上传
function handleUpload(file,type) { function handleUpload(file, type) {
const tempFilePaths = file.tempFilePaths; const tempFilePaths = file.tempFilePaths
// 处理每张选中的图片 // 处理每张选中的图片
for(let i = 0; i < tempFilePaths.length; i++){ for (let i = 0; i < tempFilePaths.length; i++) {
uni.uploadFile({ uni.uploadFile({
url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: tempFilePaths[i], filePath: tempFilePaths[i],
name: 'file', name: 'file',
formData: { formData: {
biz: 'temp', biz: 'temp',
}, },
header: { header: {
'X-Access-Token': userStore.getToken, 'X-Access-Token': userStore.getToken,
}, },
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
const data = JSON.parse(res.data) const data = JSON.parse(res.data)
if (data.code === 200 || data.code === 0) { if (data.code === 200 || data.code === 0) {
toastRef.value.show({ toastRef.value.show({
type: 'success', type: 'success',
text: '上传成功', text: '上传成功',
}) })
if(type == 'logo'){ if (type == 'logo') {
pageData.enterpriseLogoArr[0] = data.message // 保存返回的图片信息 pageData.enterpriseLogoArr[0] = data.message // 保存返回的图片信息
}else{ } else {
pageData.cersImageIndex++; pageData.cersImageIndex++
pageData.cersImageArr.push(data.message); pageData.cersImageArr.push(data.message)
} }
}
} }
} },
}, fail: (err) => {
fail: (err) => { toastRef.value.show({
toastRef.value.show({ type: 'error',
type: 'error', text: '上传失败',
text: '上传失败', })
}) if (type == 'logo') {
if(type == 'logo'){ uploadLogoRef.value.clearFiles()
uploadLogoRef.value.clearFiles() pageData.enterpriseLogoArr[0] = null
pageData.enterpriseLogoArr[0] = null } else {
}else{ uploadCersRef.value.clearFiles(pageData.cersImageIndex)
uploadCersRef.value.clearFiles(pageData.cersImageIndex) pageData.form.enterpriseCers = null
pageData.form.enterpriseCers = null }
} },
})
}, }
})
}
} }
// 文件删除 // 文件删除
function handleDelete(file,type) { function handleDelete(file, type) {
if(type="logo"){ if ((type = 'logo')) {
uploadLogoRef.value.clearFiles() uploadLogoRef.value.clearFiles()
pageData.enterpriseLogoArr[0] = null pageData.enterpriseLogoArr[0] = null
}else{ } else {
const num = pageData.cersImageArr.findIndex(v => v.url === file.tempFilePath); const num = pageData.cersImageArr.findIndex((v) => v.url === file.tempFilePath)
pageData.cersImageArr.splice(num, 1); pageData.cersImageArr.splice(num, 1)
} }
} }
const formRef = ref() const formRef = ref()
function submit() { function submit() {
const { lon, lat } = uni.getStorageSync('location') const { lon, lat } = uni.getStorageSync('location')
pageData.position = [lon, lat]; pageData.position = [lon, lat]
pageData.form.enterpriseLogoUrl = pageData.enterpriseLogoArr.join(''); pageData.form.enterpriseLogoUrl = pageData.enterpriseLogoArr.join('')
pageData.form.enterpriseCers = pageData.cersImageArr.join(','); pageData.form.enterpriseCers = pageData.cersImageArr.join(',')
if (pageData.position.length == 0) { if (pageData.position.length == 0) {
toastRef.value.show({ toastRef.value.show({
type: 'error', type: 'error',
...@@ -259,17 +264,17 @@ ...@@ -259,17 +264,17 @@
type: 'success', type: 'success',
text: '发布成功', text: '发布成功',
}) })
setTimeout(()=>{ setTimeout(() => {
uni.navigateBack({ uni.navigateBack({
delta: 1 // 返回的页面数 delta: 1, // 返回的页面数
}) })
},1000) }, 1000)
}) })
} }
}) })
} }
function getCurrentDate(){ function getCurrentDate() {
const date = new Date() const date = new Date()
const year = date.getFullYear() const year = date.getFullYear()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
...@@ -283,42 +288,129 @@ ...@@ -283,42 +288,129 @@
<view class="formBox"> <view class="formBox">
<fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false"> <fui-form ref="formRef" label-weight="auto" top="60" :disabled="form.id ? true : false">
<view class="mt20"> <view class="mt20">
<fui-input required label="公司名称" placeholder="请输入公司名称" v-model="form.enterpriseName" labelSize="28" label-width="180" size="28"/> <fui-input
<fui-input required label="企业编码" placeholder="请输入企业编码" v-model="form.enterpriseCode" labelSize="28" label-width="180" size="28"/> required
<fui-input required label="经营业务" placeholder="请输入经营业务" v-model="form.businessScope" labelSize="28" label-width="180" size="28"/> label="公司名称"
<fui-form-item asterisk label="平台介绍" :bottomBorder="false" prop="descr" error-align="left"> placeholder="请输入公司名称"
<template v-slot:vertical> v-model="form.enterpriseName"
<fui-textarea isCounter maxlength="-1" :padding="['0','32rpx','32rpx']" :border-bottom="false" :border-top="false" size="28" labelSize="28"
placeholder="请输入平台介绍..." v-model="form.profile"></fui-textarea> label-width="180"
</template> size="28"
</fui-form-item> />
<fui-input
required
label="企业编码"
placeholder="请输入企业编码"
v-model="form.enterpriseCode"
labelSize="28"
label-width="180"
size="28"
/>
<fui-input
required
label="经营业务"
placeholder="请输入经营业务"
v-model="form.businessScope"
labelSize="28"
label-width="180"
size="28"
/>
<fui-form-item asterisk label="平台介绍" :bottomBorder="false" prop="descr" error-align="left">
<template #vertical>
<fui-textarea
isCounter
maxlength="-1"
:padding="['0', '32rpx', '32rpx']"
:border-bottom="false"
:border-top="false"
size="28"
placeholder="请输入平台介绍..."
v-model="form.profile"
/>
</template>
</fui-form-item>
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input required label="地区" placeholder="请选择地区" v-model="form.areaText" labelSize="28" label-width="180" @click="show.area = true" size="28" disabled/> <fui-input
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.addr" labelSize="28" label-width="180" size="28"/> required
<fui-input required label="联系人" placeholder="请输入联系人" v-model="form.contactPerson" labelSize="28" label-width="180" size="28"/> label="地区"
<fui-input type="tel" required label="联系电话" placeholder="请输入联系电话" v-model="form.contactMobile" labelSize="28" label-width="180" size="28"></fui-input> placeholder="请选择地区"
</view> 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
type="tel"
required
label="联系电话"
placeholder="请输入联系电话"
v-model="form.contactMobile"
labelSize="28"
label-width="180"
size="28"
/>
</view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size: 28rpx"
><span style="color: red">*&nbsp;</span> 公司logo
</view>
<uni-file-picker
:value="pageData.enterpriseLogoArr"
ref="uploadLogoRef"
limit="1"
:auto-upload="false"
@select="handleUpload($event, 'logo')"
@delete="handleDelete($event, 'logo')"
/>
</view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size: 28rpx;"><span style="color: red;">*&nbsp;</span> 公司logo </view> <view class="mb-1 flex justify-start" style="font-size: 28rpx"
<uni-file-picker :value="pageData.enterpriseLogoArr" ref="uploadLogoRef" limit="1" :auto-upload="false" @select="handleUpload($event,'logo')" @delete="handleDelete($event,'logo')"/> ><span style="color: red">*&nbsp;</span> 公司资质证件
</view>
<view class="mb-1 flex justify-start" style="font-size: 24rpx; color: #cccccc"
>前6张资质证件将展示在详情页,拖拽图片可自定义排序。</view
>
<uni-file-picker
limit="9"
:value="pageData.cersImageArr"
ref="uploadCersRef"
:auto-upload="false"
@select="handleUpload($event, 'cers')"
@delete="handleDelete($event, 'cers')"
/>
</view>
<view class="fui-clause--cell fui-clause--wrap">
<fui-label>
<view class="fui-clause--cell">
<fui-checkbox :scaleRatio="0.8" @change="agreeChange" />
<text class="fui-clause--text">我已阅读并同意</text>
</view>
</fui-label>
<fui-text class="fui-color__link">《入驻协议》</fui-text>
<text></text>
<fui-text class="fui-color__link">《服务条款》</fui-text>
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem">
<view class="mb-1 flex justify-start" style="font-size: 28rpx;"><span style="color: red;">*&nbsp;</span> 公司资质证件 </view>
<view class="mb-1 flex justify-start" style="font-size: 24rpx;color: #CCCCCC;">前6张资质证件将展示在详情页,拖拽图片可自定义排序。</view>
<uni-file-picker limit="9" :value="pageData.cersImageArr" ref="uploadCersRef" :auto-upload="false" @select="handleUpload($event,'cers')" @delete="handleDelete($event,'cers')"/>
</view>
<view class="fui-clause--cell fui-clause--wrap">
<fui-label>
<view class="fui-clause--cell">
<fui-checkbox :scaleRatio="0.8" @change="agreeChange"></fui-checkbox>
<text class="fui-clause--text">我已阅读并同意</text>
</view>
</fui-label>
<fui-text class="fui-color__link">《入驻协议》</fui-text>
<text></text>
<fui-text class="fui-color__link">《服务条款》</fui-text>
</view>
<view class="fui-btn__box" v-if="!form.id" style="margin-top: 30rpx"> <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> </view>
...@@ -331,18 +423,24 @@ ...@@ -331,18 +423,24 @@
<fui-picker :show="show.type" :layer="1" :linkage="true" :options="options.type" @change="handleChangetype" @cancel="show.type = false" /> <fui-picker :show="show.type" :layer="1" :linkage="true" :options="options.type" @change="handleChangetype" @cancel="show.type = false" />
<fui-picker :show="show.urgentdegree" :layer="1" :linkage="true" :options="options.urgentdegree" @change="handleChangeUrgentdegree" @cancel="show.urgentdegree = false"/> <fui-picker :show="show.urgentdegree" :layer="1" :linkage="true" :options="options.urgentdegree" @change="handleChangeUrgentdegree" @cancel="show.urgentdegree = false"/>
--><!-- <fui-picker :show="show.area" :options="options.area" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.area = false" /> --> --><!-- <fui-picker :show="show.area" :options="options.area" :linkage="true" :layer="3" @change="handleChangeAddress" @cancel="show.area = false" /> -->
<!-- 地区的选择 --> <!-- 地区的选择 -->
<fui-bottom-popup :show="show.area"> <fui-bottom-popup :show="show.area">
<view class="fui-scroll__wrap"> <view class="fui-scroll__wrap">
<view class="fui-title">请选择</view> <view class="fui-title">请选择</view>
<fui-cascader ref="areaPopupRef" :value="pageData.options.areaVal" stepLoading @change="changeArea" @complete="selectCompleteArea" :options="pageData.options.area"></fui-cascader> <fui-cascader
<view class="fui-icon__close" @tap.stop="pageData.show.area=false"> ref="areaPopupRef"
<fui-icon name="close" :size="48"></fui-icon> :value="pageData.options.areaVal"
</view> stepLoading
</view> @change="changeArea"
</fui-bottom-popup> @complete="selectCompleteArea"
:options="pageData.options.area"
/>
<view class="fui-icon__close" @tap.stop="pageData.show.area = false">
<fui-icon name="close" :size="48" />
</view>
</view>
</fui-bottom-popup>
<fui-toast ref="toastRef" /> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" /> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
...@@ -522,51 +620,49 @@ ...@@ -522,51 +620,49 @@
color: #333; color: #333;
font-size: 28rpx; font-size: 28rpx;
} }
.fui-clause--cell {
display: flex;
.fui-clause--cell { align-items: center;
display: flex; justify-content: center;
align-items: center; font-size: 24rpx;
justify-content: center; color: #999999;
font-size: 24rpx; }
color:#999999; .fui-clause--wrap {
} width: 100%;
.fui-clause--wrap { margin-top: 64rpx;
width: 100%; }
margin-top: 64rpx; .fui-clause--text {
} padding-left: 16rpx;
.fui-clause--text { /* #ifdef H5 */
padding-left: 16rpx; cursor: pointer;
/* #ifdef H5 */ /* #endif */
cursor: pointer; }
/* #endif */ .fui-color__link {
} color: #5fb771;
.fui-color__link { /* #ifdef H5 */
color: #5FB771; cursor: pointer;
/* #ifdef H5 */ /* #endif */
cursor: pointer; }
/* #endif */
} .fui-color__link:active {
opacity: 0.5;
.fui-color__link:active { }
opacity: .5; .fui-scroll__wrap {
} padding-top: 30rpx;
.fui-scroll__wrap { position: relative;
padding-top: 30rpx; }
position: relative;
} .fui-title {
font-size: 30rpx;
.fui-title { font-weight: bold;
font-size: 30rpx; text-align: center;
font-weight: bold; padding-bottom: 24rpx;
text-align: center; }
padding-bottom: 24rpx;
} .fui-icon__close {
position: absolute;
.fui-icon__close { top: 24rpx;
position: absolute; right: 24rpx;
top: 24rpx; }
right: 24rpx;
}
</style> </style>
<!-- src/pages/zhunongjinrong/zhunongjinrong.vue --> <!-- src/pages/zhunongjinrong/zhunongjinrong.vue -->
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import dayjs from 'dayjs'
import { getCurrentDateTime } from '@/utils/date' import * as NewsApi from '@/api/model/news'
import * as NewsApi from '@/api/model/news'
import dayjs from 'dayjs' const currentTab = ref('redian')
let currentTab = ref('redian'); const pageData = reactive({
const pageData = reactive({ params: {
params: { pageNo: 1,
pageNo: 1, pageSize: 10,
pageSize: 10, category: 1,
category:1, /* news:{
/* news:{
category:1 category:1
} */ } */
}, // 分页参数 }, // 分页参数
hasMore: true, // 是否还有更多数据 hasMore: true, // 是否还有更多数据
loading: false, // 是否正在加载 loading: false, // 是否正在加载
dataList:[] dataList: [],
}) })
onLoad((options) => { onLoad((options) => {
if(options && options.category==1){ if (options && options.category == 1) {
pageData.params.category = options.category; pageData.params.category = options.category
currentTab.value = 'redian'; currentTab.value = 'redian'
}else{ } else {
pageData.params.category = 2; pageData.params.category = 2
currentTab.value = 'nongye'; currentTab.value = 'nongye'
} }
}) })
onShow(() => { onShow(() => {
getListData(); getListData()
}) })
async function getListData() { async function getListData() {
if (pageData.loading) return if (pageData.loading)
pageData.loading = true return
pageData.loading = true
await NewsApi.getList(pageData.params).then((res) => { await NewsApi.getList(pageData.params).then((res) => {
if (res.records.length > 0) { if (res.records.length > 0) {
const { records } = res const { records } = res
if (pageData.params.pageNo === 1) { if (pageData.params.pageNo === 1) {
pageData.dataList = records pageData.dataList = records
} else { } else {
pageData.dataList = [...pageData.dataList, ...records] pageData.dataList = [...pageData.dataList, ...records]
} }
pageData.hasMore = records.length === pageData.params.pageSize pageData.hasMore = records.length === pageData.params.pageSize
pageData.params.pageNo++ pageData.params.pageNo++
} else { } else {
pageData.hasMore = false pageData.hasMore = false
} }
})
pageData.loading = false
}
function toNewsDetail(news) {
uni.navigateTo({
url: `/pages/news/detail?id=${news.id}`,
}) })
pageData.loading = false
} }
function toNewsDetail(news) { function switchTab(type) {
uni.navigateTo({ pageData.dataList = []
url: `/pages/news/detail?id=${news.id}`, pageData.hasMore = true
}) pageData.params.pageNo = 1
} currentTab.value = type
function switchTab(type){ if (type == 'redian') {
pageData.dataList = []; pageData.params.category = 1
pageData.hasMore = true; getListData()
pageData.params.pageNo = 1; }
currentTab.value = type; if (type == 'nongye') {
if(type == 'redian'){ pageData.params.category = 2
pageData.params.category = 1; getListData()
getListData(); }
} if (type == 'butie') {
if(type == 'nongye'){ pageData.params.category = 3
pageData.params.category = 2; pageData.dataList = []
getListData(); }
} }
if(type == 'butie'){
pageData.params.category = 3;
pageData.dataList = [];
}
}
</script> </script>
<template> <template>
<view class="nongyezhengce-page"> <view class="nongyezhengce-page">
<view class="nongyezhengce-content"> <view class="nongyezhengce-content">
<scroll-view class="page-content" scroll-y @scrolltolower="getListData()" :show-scrollbar="false" > <scroll-view class="page-content" scroll-y @scrolltolower="getListData()" :show-scrollbar="false">
<view class="top-tab"> <view class="top-tab">
<view class="tab-btn" :class="currentTab == 'redian' ? 'tab-active' : ''" @click="switchTab('redian')"> <view
<image class="tab-icon" mode="heightFix" :src="`/static/images/home/${currentTab == 'redian' ?'redian_active':'redian_icon'}.png`" /> class="tab-btn"
<text class="tab-text">热点新闻</text> :class="currentTab == 'redian' ? 'tab-active' : ''"
</view> @click="switchTab('redian')"
<view class="tab-btn" :class="currentTab == 'nongye' ? 'tab-active' : ''" @click="switchTab('nongye')"> >
<image class="tab-icon" mode="heightFix" :src="`/static/images/home/${currentTab == 'nongye' ?'nongye_active':'nongye_icon'}.png`" /> <image
<text class="tab-text">农业政策</text> class="tab-icon"
</view> mode="heightFix"
<view class="tab-btn" :class="currentTab == 'butie' ? 'tab-active' : ''" @click="switchTab('butie')"> :src="`/static/images/home/${currentTab == 'redian' ? 'redian_active' : 'redian_icon'}.png`"
<image class="tab-icon" mode="heightFix" :src="`/static/images/home/${currentTab == 'butie' ?'butie_active':'butie_icon'}.png`" /> />
<text class="tab-text">购置补贴</text> <text class="tab-text">热点新闻</text>
</view> </view>
</view> <view
<view class="list-content"> class="tab-btn"
<view v-if="!pageData.dataList || pageData.dataList.length == 0" style="height: 700rpx"> :class="currentTab == 'nongye' ? 'tab-active' : ''"
<fui-empty marginTop="100" src="/static/images/no-data.png" title="暂无数据" /> @click="switchTab('nongye')"
</view> >
<view class="content-item" v-for="item in pageData.dataList" :key="item.id" @click="toNewsDetail(item)"> <image
<view class="item-content">{{item.title}}</view> class="tab-icon"
<view class="item-info"> mode="heightFix"
<view class="item-time">{{ dayjs(item.publishDate).format('YYYY-MM-DD') }}</view> :src="`/static/images/home/${currentTab == 'nongye' ? 'nongye_active' : 'nongye_icon'}.png`"
<view class="item-views"><image class="views-icon" mode="widthFix" src="/static/images/home/views_icon.png" /><text>{{item.viewCount}}</text></view> />
</view> <text class="tab-text">农业政策</text>
</view> </view>
</view> <view
</scroll-view> class="tab-btn"
</view> :class="currentTab == 'butie' ? 'tab-active' : ''"
<view class="loading-status"> @click="switchTab('butie')"
<text v-if="pageData.loading">加载中...</text> >
<text v-else-if="!pageData.hasMore">没有更多数据了</text> <image
<text v-else>上拉加载更多</text> class="tab-icon"
</view> mode="heightFix"
</view> :src="`/static/images/home/${currentTab == 'butie' ? 'butie_active' : 'butie_icon'}.png`"
/>
<text class="tab-text">购置补贴</text>
</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">
<view class="item-time">{{ dayjs(item.publishDate).format('YYYY-MM-DD') }}</view>
<view class="item-views"
><image
class="views-icon"
mode="widthFix"
src="/static/images/home/views_icon.png"
/><text>{{ item.viewCount }}</text></view
>
</view>
</view>
</view>
</scroll-view>
</view>
<view class="loading-status">
<text v-if="pageData.loading">加载中...</text>
<text v-else-if="!pageData.hasMore">没有更多数据了</text>
<text v-else>上拉加载更多</text>
</view>
</view>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.nongyezhengce-page{ .nongyezhengce-page {
background-color: #e6f5e8; background-color: #e6f5e8;
overflow-y: auto; overflow-y: auto;
} }
.nongyezhengce-content{ .nongyezhengce-content {
width: 100vw; width: 100vw;
height: calc(100vh - 88rpx); height: calc(100vh - 88rpx);
display: flex; display: flex;
justify-content: center; justify-content: center;
.page-content{ .page-content {
width: 690rpx; width: 690rpx;
padding-top: 24rpx; padding-top: 24rpx;
padding-bottom: 24rpx; padding-bottom: 24rpx;
.top-tab{ .top-tab {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.tab-btn{ .tab-btn {
width: 220rpx; width: 220rpx;
height: 72rpx; height: 72rpx;
border-radius: 9999px; border-radius: 9999px;
background: #FFFFFF; background: #ffffff;
color: #333333; color: #333333;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.tab-icon{ .tab-icon {
height: 36rpx; height: 36rpx;
margin-right: 8rpx; margin-right: 8rpx;
} }
.tab-text{ .tab-text {
font-size: 28rpx; font-size: 28rpx;
} }
} }
.tab-active{ .tab-active {
background: #5DB66F; background: #5db66f;
color: #FFFFFF; color: #ffffff;
} }
} }
.list-content{ .list-content {
margin-top: 4rpx; margin-top: 4rpx;
} }
.content-item{ .content-item {
width: 690rpx; width: 690rpx;
border-radius: 8rpx; border-radius: 8rpx;
background: #FFFFFF; background: #ffffff;
padding:20rpx; padding: 20rpx;
margin-top: 20rpx; margin-top: 20rpx;
.item-content{ .item-content {
font-size: 28rpx; font-size: 28rpx;
line-height: 40rpx; line-height: 40rpx;
text-align: justify; text-align: justify;
color: #333333; color: #333333;
} }
.item-info{ .item-info {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-top: 20rpx; margin-top: 20rpx;
color: #666666; color: #666666;
font-size: 24rpx; font-size: 24rpx;
line-height: 40rpx; line-height: 40rpx;
font-weight: 400; font-weight: 400;
.views-icon{ .views-icon {
width: 28rpx; width: 28rpx;
margin-right: 8rpx; margin-right: 8rpx;
} }
} }
} }
} }
} }
.loading-status { .loading-status {
background-color: #e6f5e8; background-color: #e6f5e8;
text-align: center; text-align: center;
padding: 20rpx; padding: 20rpx;
color: #999; color: #999;
font-size: 28rpx; font-size: 28rpx;
} }
</style> </style>
...@@ -115,8 +115,7 @@ ...@@ -115,8 +115,7 @@
// 加载编辑数据 // 加载编辑数据
function loadEditData() { function loadEditData() {
if (!props.editData) if (!props.editData) return
return
formData.fileName = props.editData.fileName || '' formData.fileName = props.editData.fileName || ''
formData.fileType = props.editData.fileType || '' formData.fileType = props.editData.fileType || ''
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
}) })
function getList() { function getList() {
if (!paging.value) return if (!paging.value)
return
// API留空,使用模拟数据 - 根据图片内容调整 // API留空,使用模拟数据 - 根据图片内容调整
API.getResourceList(pageData.param).then((res) => { API.getResourceList(pageData.param).then((res) => {
paging.value.complete(res.records) paging.value.complete(res.records)
...@@ -50,8 +51,7 @@ ...@@ -50,8 +51,7 @@
// 格式化时间显示 // 格式化时间显示
function formatTime(time) { function formatTime(time) {
if (!time) if (!time) return ''
return ''
// 如果是完整的时间字符串,可以格式化为图片中的样式 // 如果是完整的时间字符串,可以格式化为图片中的样式
return time.includes(' ') ? time : `${time} 14:00` return time.includes(' ') ? time : `${time} 14:00`
} }
...@@ -75,8 +75,7 @@ return '' ...@@ -75,8 +75,7 @@ return ''
// 格式化文件大小 // 格式化文件大小
function formatFileSize(bytes) { function formatFileSize(bytes) {
if (!bytes) if (!bytes) return '125kb'
return '125kb'
const k = 1024 const k = 1024
const sizes = ['B', 'KB', 'MB', 'GB'] const sizes = ['B', 'KB', 'MB', 'GB']
const i = Math.floor(Math.log(bytes) / Math.log(k)) const i = Math.floor(Math.log(bytes) / Math.log(k))
......
<template>
<view class="webview-container">
<web-view :src="url"></web-view>
</view>
</template>
<script> <script>
export default { export default {
data() { data() {
return { return {
url: '' url: '',
} }
}, },
onLoad(options) { onLoad(options) {
if (options.url) { if (options.url) {
this.url = decodeURIComponent(options.url) this.url = decodeURIComponent(options.url)
} else { } else {
uni.showToast({ uni.showToast({
title: '网址不存在', title: '网址不存在',
icon: 'none' icon: 'none',
}) })
uni.navigateBack() uni.navigateBack()
}
},
} }
} </script>
}
</script> <template>
\ No newline at end of file <view class="webview-container">
<web-view :src="url" />
</view>
</template>
...@@ -239,7 +239,8 @@ ...@@ -239,7 +239,8 @@
function onAddClick(feature: any) { function onAddClick(feature: any) {
console.log('点击功能模块:', feature) console.log('点击功能模块:', feature)
if (feature.id === 2) showAddDialog() if (feature.id === 2)
showAddDialog()
} }
// 常用资源点击事件 // 常用资源点击事件
function onResourceClick(resource: any) { function onResourceClick(resource: any) {
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
} }
const policyInfoTitle = computed(() => { const policyInfoTitle = computed(() => {
return (pageData.buttons.filter((btn) => btn.active)?.[0]?.name || '惠农贷款') + '政策' return `${pageData.buttons.filter((btn) => btn.active)?.[0]?.name || '惠农贷款'}政策`
}) })
</script> </script>
......
<!-- src/pages/zhunongjinrong/zhunongjinrong.vue --> <!-- src/pages/zhunongjinrong/zhunongjinrong.vue -->
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'; import successfulDialog from '@/components/ConfirmDialog/successfulDialog.vue'
import { getCurrentDateTime } from '@/utils/date' import { getCurrentDateTime } from '@/utils/date'
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
onShow(() => {
const { id, realname, phone } = userStore.getUserInfo; onShow(() => {
consultRecord.id = id; const { id, realname, phone } = userStore.getUserInfo
consultRecord.mobile = phone; consultRecord.id = id
consultRecord.feedbackRemark = realname; consultRecord.mobile = phone
}) consultRecord.feedbackRemark = realname
})
// 定义银行类型 // 定义银行类型
type BankKey = 'nongye' | 'youzheng' | 'nongshang' type BankKey = 'nongye' | 'youzheng' | 'nongshang'
...@@ -167,33 +168,33 @@ ...@@ -167,33 +168,33 @@
currentBank.value = bank currentBank.value = bank
} }
const userStore = useUserStore(); const userStore = useUserStore()
const consultRecord = reactive({ const consultRecord = reactive({
id: "", id: '',
mobile: '',// 咨询人号码 mobile: '', // 咨询人号码
consultTime:"" ,// 咨询时间 consultTime: '', // 咨询时间
bizType:4, // 业务类型(1代理记账,2农资,3农机,4金融) bizType: 4, // 业务类型(1代理记账,2农资,3农机,4金融)
enterpriseId:1324324324, // 意向企业 enterpriseId: 1324324324, // 意向企业
feedbackRemark:"" // 反馈备注 feedbackRemark: '', // 反馈备注
}) })
const pageData = reactive({ const pageData = reactive({
showLogoutDialog: false, showLogoutDialog: false,
allpyMessageTitle:"", allpyMessageTitle: '',
applyMessageText:"", applyMessageText: '',
}) })
// 立即申请 // 立即申请
function onApplyClick() { function onApplyClick() {
consultRecord.consultTime = getCurrentDateTime(); consultRecord.consultTime = getCurrentDateTime()
HomeAPI.postConsultRecordAdd(consultRecord).then((res) => { HomeAPI.postConsultRecordAdd(consultRecord).then((res) => {
pageData.allpyMessageTitle = "申请成功"; pageData.allpyMessageTitle = '申请成功'
pageData.applyMessageText = "平台已收到申请,将尽快与您取得联系!"; pageData.applyMessageText = '平台已收到申请,将尽快与您取得联系!'
pageData.showLogoutDialog = true; pageData.showLogoutDialog = true
}) })
} }
// 提交申请 // 提交申请
function handleConfirmLogout(){ function handleConfirmLogout() {
pageData.showLogoutDialog = false; pageData.showLogoutDialog = false
} }
</script> </script>
...@@ -287,7 +288,7 @@ ...@@ -287,7 +288,7 @@
v-if="bankInfo[currentBank].processType === 'simple'" v-if="bankInfo[currentBank].processType === 'simple'"
class="codefun-flex-col codefun-justify-start codefun-items-start codefun-self-stretch text-wrapper" class="codefun-flex-col codefun-justify-start codefun-items-start codefun-self-stretch text-wrapper"
> >
<text class=" font_6 text_13 fontsize_28">线下咨询,已实际办理流程为准。</text> <text class="font_6 text_13 fontsize_28">线下咨询,已实际办理流程为准。</text>
</view> </view>
<view v-else class="codefun-flex-col codefun-self-stretch section_8"> <view v-else class="codefun-flex-col codefun-self-stretch section_8">
<view <view
...@@ -302,7 +303,7 @@ ...@@ -302,7 +303,7 @@
> >
<text class="font_8">{{ step.number }}</text> <text class="font_8">{{ step.number }}</text>
</view> </view>
<text class="font_9 text_15 ml-11 ">{{ step.title }}</text> <text class="font_9 text_15 ml-11">{{ step.title }}</text>
</view> </view>
<view v-if="step.desc" class="codefun-flex-row group_5"> <view v-if="step.desc" class="codefun-flex-row group_5">
<view class="codefun-self-center section_9" /> <view class="codefun-self-center section_9" />
...@@ -359,13 +360,13 @@ ...@@ -359,13 +360,13 @@
<text class="font_2 text_20">立即申请</text> <text class="font_2 text_20">立即申请</text>
</view> </view>
</view> </view>
<successfulDialog <successfulDialog
v-model:show="pageData.showLogoutDialog" v-model:show="pageData.showLogoutDialog"
:title="pageData.allpyMessageTitle" :title="pageData.allpyMessageTitle"
:content="pageData.applyMessageText" :content="pageData.applyMessageText"
confirmText="我知道了" confirmText="我知道了"
@confirm="handleConfirmLogout" @confirm="handleConfirmLogout"
/> />
</view> </view>
</template> </template>
......
...@@ -37,17 +37,17 @@ export function formatDate(date: Date | number | string): string { ...@@ -37,17 +37,17 @@ export function formatDate(date: Date | number | string): string {
*/ */
export function getCalculateAge(birthDate: Date | string): number { export function getCalculateAge(birthDate: Date | string): number {
// 解析出生日期字符串为Date对象 // 解析出生日期字符串为Date对象
const birthDateObj = new Date(birthDate); const birthDateObj = new Date(birthDate)
// 获取当前日期 // 获取当前日期
const currentDate = new Date(); const currentDate = new Date()
// 计算两个日期之间的年份差异 // 计算两个日期之间的年份差异
let age = currentDate.getFullYear() - birthDateObj.getFullYear(); let age = currentDate.getFullYear() - birthDateObj.getFullYear()
// 检查是否还没到生日,如果是,则年龄减1 // 检查是否还没到生日,如果是,则年龄减1
const m = currentDate.getMonth() - birthDateObj.getMonth(); const m = currentDate.getMonth() - birthDateObj.getMonth()
if (m < 0 || (m === 0 && currentDate.getDate() < birthDateObj.getDate())) { if (m < 0 || (m === 0 && currentDate.getDate() < birthDateObj.getDate())) {
age--; age--
} }
return age; return age
} }
/** /**
...@@ -62,12 +62,12 @@ export function getCurrentDateTime(): string { ...@@ -62,12 +62,12 @@ export function getCurrentDateTime(): string {
const month = String(now.getMonth() + 1).padStart(2, '0') const month = String(now.getMonth() + 1).padStart(2, '0')
// 获取日期,确保两位数格式 // 获取日期,确保两位数格式
const day = String(now.getDate()).padStart(2, '0'); const day = String(now.getDate()).padStart(2, '0')
const hour = String(now.getHours()).padStart(2, '0'); const hour = String(now.getHours()).padStart(2, '0')
const minute = String(now.getMinutes()).padStart(2, '0'); const minute = String(now.getMinutes()).padStart(2, '0')
const second = String(now.getSeconds()).padStart(2, '0'); const second = String(now.getSeconds()).padStart(2, '0')
// 返回格式化后的日期字符串 // 返回格式化后的日期字符串
return `${year}-${month}-${day} ${hour}:${minute}:${second}` return `${year}-${month}-${day} ${hour}:${minute}:${second}`
} }
\ No newline at end of file
import { cascaderHn } from '/@/api/model/dict' import { cascaderHn } from '/@/api/model/dict'
const storageKey = 'app_dict_data_area_cascaderHn'; const storageKey = 'app_dict_data_area_cascaderHn'
let areaOptions = []; let areaOptions = []
export const getDictData = async () => { export async function getDictData() {
// 先从本地加载数据 // 先从本地加载数据
let dictData = getLocalDict(); let dictData = getLocalDict()
if (!dictData) { if (!dictData) {
// 如果本地没有数据,则从接口获取 // 如果本地没有数据,则从接口获取
const res = await cascaderHn(); const res = await cascaderHn()
const data = JSON.stringify(res[0].children).replace(/label/g, 'text'); const data = JSON.stringify(res[0].children).replace(/label/g, 'text')
uni.setStorageSync(storageKey, data); uni.setStorageSync(storageKey, data)
dictData = JSON.parse(data); dictData = JSON.parse(data)
} }
areaOptions = dictData; areaOptions = dictData
return dictData; return dictData
} }
/** /**
* 获取本地数据 * 获取本地数据
*/ */
export const getLocalDict = () => { export function getLocalDict() {
const data = uni.getStorageSync(storageKey); const data = uni.getStorageSync(storageKey)
if (data) { if (data) {
return data ? JSON.parse(data) : null; return data ? JSON.parse(data) : null
} }
return null; return null
} }
/** /**
* 刷新数据 * 刷新数据
*/ */
export const refreshDictData = () => { export function refreshDictData() {
// 删除本地数据 // 删除本地数据
uni.removeStorageSync(storageKey); uni.removeStorageSync(storageKey)
// 重新获取数据 // 重新获取数据
getDictData(); getDictData()
} }
export const getText = (scope: string, spliced: string) => { export function getText(scope: string, spliced: string) {
if (!scope || !areaOptions || areaOptions.length === 0) { if (!scope || !areaOptions || areaOptions.length === 0) {
return '' return ''
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论