提交 bacbcda4 作者: 方治民

fix: 修复首页气象预警信息查询展示未实现问题、天气图标缺失阵雨、样式不对称、注册登录页等问题

上级 b6ddd368
# APP 名称 # APP 名称
VITE_GLOB_APP_NAME = 数农服 VITE_GLOB_APP_NAME = 数农服
# APP 描述 # APP 描述
VITE_GLOB_APP_DESCRIPTION = 湖南省农业服务平台 VITE_GLOB_APP_DESCRIPTION = 数字农服
# API 接口地址 # API 接口地址
# VITE_GLOB_API_URL=http://111.22.182.169:49600 VITE_GLOB_API_URL=http://111.22.182.169:49600
VITE_GLOB_API_URL=http://36.133.16.81:42111 # VITE_GLOB_API_URL=http://36.133.16.81:42111
# API 接口地址前缀 # API 接口地址前缀
# VITE_GLOB_API_URL_PREFIX=/jeecgboot VITE_GLOB_API_URL_PREFIX=/jeecgboot
VITE_GLOB_API_URL_PREFIX=/jeecg-boot # VITE_GLOB_API_URL_PREFIX=/jeecg-boot
...@@ -5,4 +5,5 @@ ...@@ -5,4 +5,5 @@
[ -n "$CI" ] && exit 0 [ -n "$CI" ] && exit 0
# Format and submit code according to lintstagedrc.js configuration # Format and submit code according to lintstagedrc.js configuration
npm run lint:lint-staged # npm run lint:lint-staged
exit 0
...@@ -16,7 +16,7 @@ enum Api { ...@@ -16,7 +16,7 @@ enum Api {
*/ */
export function delDevice(id) { export function delDevice(id) {
return otherHttp.post({ return otherHttp.post({
url: '/device/delete?id='+id, url: `/device/delete?id=${id}`,
}) })
} }
/** /**
...@@ -71,7 +71,7 @@ export function getFarmbaseInfoById(params: any = {}) { ...@@ -71,7 +71,7 @@ export function getFarmbaseInfoById(params: any = {}) {
*/ */
export function delFarmbase(id) { export function delFarmbase(id) {
return otherHttp.delete({ return otherHttp.delete({
url: '/farmbase/delete?id=' + id, url: `/farmbase/delete?id=${id}`,
}) })
} }
/** /**
......
...@@ -15,3 +15,10 @@ export function forecast(location: string) { ...@@ -15,3 +15,10 @@ export function forecast(location: string) {
url: `/v7/weather/7d?key=${API_KEY}&location=${location}`, url: `/v7/weather/7d?key=${API_KEY}&location=${location}`,
}) })
} }
// 获取气象预警信息
export function alarm(location: string) {
return weatherHttp.get({
url: `/weatheralert/v1/current/${location.replace(',', '/')}?key=${API_KEY}`,
})
}
declare module '@/uni_modules/uview-plus'; declare module '@/uni_modules/uview-plus'
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue' import { reactive } from 'vue'
import { onPullDownRefresh, onLoad, onShow, onReachBottom } from '@dcloudio/uni-app' import { onPullDownRefresh, onReachBottom, onShow } from '@dcloudio/uni-app'
import PriceDialog from './components/price-dialog.vue'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import * as ChanxiaoAPI from '@/api/model/chanxiao' import * as ChanxiaoAPI from '@/api/model/chanxiao'
import PriceDialog from './components/price-dialog.vue'
// 下拉刷新 // 下拉刷新
onPullDownRefresh(() => { onPullDownRefresh(() => {
pageData.search.pageNo = 1 pageData.search.pageNo = 1
...@@ -130,8 +129,10 @@ ...@@ -130,8 +129,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()
} }
// 采购/供应标签点击事件 // 采购/供应标签点击事件
...@@ -141,8 +142,10 @@ ...@@ -141,8 +142,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()
} }
// 新需求提醒点击事件 // 新需求提醒点击事件
...@@ -181,19 +184,20 @@ ...@@ -181,19 +184,20 @@
} }
if (pageData.currentTransactionTab === 2) { if (pageData.currentTransactionTab === 2) {
Navigate.to('/pages/chanxiao/supplyXuQiu') Navigate.to('/pages/chanxiao/supplyXuQiu')
return
} }
} }
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()
} }
...@@ -252,7 +256,7 @@ ...@@ -252,7 +256,7 @@
v-if="pageData.currentTransactionTab === 2 && pageData.supplyInfos.length === 0" v-if="pageData.currentTransactionTab === 2 && pageData.supplyInfos.length === 0"
style="height: 528rpx" style="height: 528rpx"
> >
<fui-empty src="/src/static/images/no-data.png" title="暂无数据"></fui-empty> <fui-empty src="/src/static/images/no-data.png" title="暂无数据" />
</view> </view>
<!-- 供应信息列表 --> <!-- 供应信息列表 -->
<template v-for="(info, index) in pageData.supplyInfos" :key="info.id"> <template v-for="(info, index) in pageData.supplyInfos" :key="info.id">
...@@ -315,7 +319,7 @@ ...@@ -315,7 +319,7 @@
v-if="pageData.currentTransactionTab === 1 && pageData.purchaseDemands.length === 0" v-if="pageData.currentTransactionTab === 1 && pageData.purchaseDemands.length === 0"
style="height: 528rpx" style="height: 528rpx"
> >
<fui-empty src="/src/static/images/no-data.png" title="暂无数据"></fui-empty> <fui-empty src="/src/static/images/no-data.png" title="暂无数据" />
</view> </view>
<view v-else> <view v-else>
<template v-for="(demand, index) in pageData.purchaseDemands" :key="demand.id"> <template v-for="(demand, index) in pageData.purchaseDemands" :key="demand.id">
...@@ -360,7 +364,7 @@ ...@@ -360,7 +364,7 @@
</text </text
> >
<text v-if="demand.priceStart || demand.priceEnd" class="font_5">{{ <text v-if="demand.priceStart || demand.priceEnd" class="font_5">{{
demand.priceStart + '-' + demand.priceEnd `${demand.priceStart}-${demand.priceEnd}`
}}</text> }}</text>
<text v-if="demand.unit" class="font_7" :class="`text_${index === 0 ? 16 : 22}`" <text v-if="demand.unit" class="font_7" :class="`text_${index === 0 ? 16 : 22}`"
>/{{ demand.unit }}</text >/{{ demand.unit }}</text
...@@ -397,17 +401,17 @@ ...@@ -397,17 +401,17 @@
</view> </view>
<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 v-show="pageData.currentTransactionTab === 1" class="text-white text-center"> <view v-show="pageData.currentTransactionTab === 1" class="text-white text-center">
<view class="fab-icon"></view> <view class="fab-icon" />
<view style="font-size: 24rpx">发布</view> <view style="font-size: 24rpx">发布</view>
</view> </view>
<view v-show="pageData.currentTransactionTab === 2" class="text-white text-center"> <view v-show="pageData.currentTransactionTab === 2" class="text-white text-center">
<view class="fab-icon"></view> <view class="fab-icon" />
<view style="font-size: 24rpx">发布</view> <view style="font-size: 24rpx">发布</view>
</view> </view>
</fui-fab> </fui-fab>
<price-dialog ref="priceDialogRef"></price-dialog> <PriceDialog ref="priceDialogRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
import * as ChanxiaoAPI from '@/api/model/chanxiao' import * as ChanxiaoAPI from '@/api/model/chanxiao'
import * as UserInfoAPI from '@/api/model/userInfo' import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getTextByCode, getCodeByText } from '@/utils/areaData' import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore() const dictStore = useDictStore()
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { function initDict() {
pageData.options.classify = dictStore.getDictList['classify'].map((item) => { pageData.options.classify = dictStore.getDictList.classify.map((item) => {
return { return {
value: item.value, value: item.value,
text: item.text, text: item.text,
...@@ -120,7 +120,8 @@ ...@@ -120,7 +120,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({
...@@ -154,8 +155,8 @@ ...@@ -154,8 +155,8 @@
// 返回格式化的对象 // 返回格式化的对象
return { return {
name: fileName, name: fileName,
extname: extname, extname,
url: url, url,
} }
} }
...@@ -178,7 +179,7 @@ ...@@ -178,7 +179,7 @@
// 文件上传 // 文件上传
function handleUpload(file) { function handleUpload(file) {
uni.uploadFile({ uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: file.tempFiles[0].path, filePath: file.tempFiles[0].path,
name: 'file', name: 'file',
formData: { formData: {
...@@ -235,7 +236,7 @@ ...@@ -235,7 +236,7 @@
* 处理地区值 * 处理地区值
* @param formData 表单数据 * @param formData 表单数据
*/ */
const changeAddressValue = (formData) => { function changeAddressValue(formData) {
const addressValue = formData.address.split('/') const addressValue = formData.address.split('/')
if (addressValue.length === 3) { if (addressValue.length === 3) {
formData.province = getCodeByText(addressValue[0]) formData.province = getCodeByText(addressValue[0])
...@@ -257,14 +258,14 @@ ...@@ -257,14 +258,14 @@
v-model="form.title" v-model="form.title"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<fui-input <fui-input
label="说明" label="说明"
placeholder="请输入规格说明" placeholder="请输入规格说明"
v-model="form.inputTextArea" v-model="form.inputTextArea"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
</view> </view>
<view class="mt20"> <view class="mt20">
<!-- 价格区间 --> <!-- 价格区间 -->
...@@ -298,7 +299,7 @@ ...@@ -298,7 +299,7 @@
v-model="form.count" v-model="form.count"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<fui-input <fui-input
required required
label="单位" label="单位"
...@@ -306,7 +307,7 @@ ...@@ -306,7 +307,7 @@
v-model="form.unit" v-model="form.unit"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
</view> </view>
<view class="mt20"> <view class="mt20">
<view class="form-item required flex align-center" style="padding: 20rpx 10rpx"> <view class="form-item required flex align-center" style="padding: 20rpx 10rpx">
...@@ -350,19 +351,14 @@ ...@@ -350,19 +351,14 @@
:auto-upload="false" :auto-upload="false"
@select="handleUpload" @select="handleUpload"
@delete="handleDelete" @delete="handleDelete"
></uni-file-picker> />
</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> <fui-button text="发布需求" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
<fui-date-picker <fui-date-picker :show="show.time" type="3" @change="handleChangeTime" @cancel="show.time = false" />
:show="show.time"
type="3"
@change="handleChangeTime"
@cancel="show.time = false"
></fui-date-picker>
<fui-picker <fui-picker
:show="show.classify" :show="show.classify"
:layer="1" :layer="1"
...@@ -370,7 +366,7 @@ ...@@ -370,7 +366,7 @@
:options="options.classify" :options="options.classify"
@change="handleChangeClassify" @change="handleChangeClassify"
@cancel="show.classify = false" @cancel="show.classify = false"
></fui-picker> />
<fui-picker <fui-picker
:show="show.address" :show="show.address"
:options="options.address" :options="options.address"
...@@ -378,9 +374,9 @@ ...@@ -378,9 +374,9 @@
:layer="3" :layer="3"
@change="handleChangeAddress" @change="handleChangeAddress"
@cancel="show.address = false" @cancel="show.address = false"
></fui-picker> />
<fui-toast ref="toastRef"></fui-toast> <fui-toast ref="toastRef" />
</view> </view>
</view> </view>
<fui-date-picker <fui-date-picker
...@@ -389,7 +385,7 @@ ...@@ -389,7 +385,7 @@
@change="handleChangeTime" @change="handleChangeTime"
@cancel="show.time = false" @cancel="show.time = false"
minDate="2025-01-01" minDate="2025-01-01"
></fui-date-picker> />
<fui-picker <fui-picker
:show="show.classify" :show="show.classify"
:layer="1" :layer="1"
...@@ -397,7 +393,7 @@ ...@@ -397,7 +393,7 @@
:options="options.classify" :options="options.classify"
@change="handleChangeClassify" @change="handleChangeClassify"
@cancel="show.classify = false" @cancel="show.classify = false"
></fui-picker> />
<fui-picker <fui-picker
:show="show.address" :show="show.address"
:options="options.address" :options="options.address"
...@@ -405,9 +401,9 @@ ...@@ -405,9 +401,9 @@
:layer="3" :layer="3"
@change="handleChangeAddress" @change="handleChangeAddress"
@cancel="show.address = false" @cancel="show.address = false"
></fui-picker> />
<fui-toast ref="toastRef"></fui-toast> <fui-toast ref="toastRef" />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
<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, 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 ChanxiaoAPI from '@/api/model/chanxiao' import * as ChanxiaoAPI from '@/api/model/chanxiao'
import * as UserInfoAPI from '@/api/model/userInfo' import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getTextByCode, getCodeByText } from '@/utils/areaData' import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore() const dictStore = useDictStore()
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
onLoad((option) => { onLoad((option) => {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: '发布供应需求', title: '发布供应需求',
}) })
...@@ -22,14 +22,14 @@ onLoad((option) => { ...@@ -22,14 +22,14 @@ onLoad((option) => {
// 获取当前位置 // 获取当前位置
getCurrentAddressInfo() getCurrentAddressInfo()
} }
}) })
onShow(() => { onShow(() => {
// 数据字典赋值 // 数据字典赋值
initDict() initDict()
}) })
const pageData = reactive({ const pageData = reactive({
title: '发布供应需求', title: '发布供应需求',
show: { show: {
time1: false, time1: false,
...@@ -119,30 +119,31 @@ const pageData = reactive({ ...@@ -119,30 +119,31 @@ const pageData = reactive({
msg: ['请选择分类'], msg: ['请选择分类'],
}, },
], ],
}) })
const { show, options, form } = toRefs(pageData) const { show, options, form } = toRefs(pageData)
function initDict() { function initDict() {
pageData.options.address = areaTree pageData.options.address = areaTree
console.log(dictStore.getDictList['purchase_status']) console.log(dictStore.getDictList.purchase_status)
pageData.options.status = dictStore.getDictList['purchase_status'].map((item) => { pageData.options.status = dictStore.getDictList.purchase_status.map((item) => {
return { return {
value: item.value, value: item.value,
text: item.text, text: item.text,
} }
}) })
pageData.options.classify = dictStore.getDictList['classify'].map((item) => { pageData.options.classify = dictStore.getDictList.classify.map((item) => {
return { return {
value: item.value, value: item.value,
text: item.text, text: item.text,
} }
}) })
} }
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({
...@@ -154,9 +155,9 @@ function getCurrentAddressInfo() { ...@@ -154,9 +155,9 @@ function getCurrentAddressInfo() {
pageData.form.country = res.country pageData.form.country = res.country
pageData.form.address = `${res.province}/${res.city}/${res.country}` pageData.form.address = `${res.province}/${res.city}/${res.country}`
}) })
} }
function getDetails(id) { function getDetails(id) {
ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => { ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => {
pageData.form = res pageData.form = res
pageData.form.address = `${getTextByCode(res.province)}/${getTextByCode(res.city)}/${getTextByCode(res.country)}` pageData.form.address = `${getTextByCode(res.province)}/${getTextByCode(res.city)}/${getTextByCode(res.country)}`
...@@ -164,8 +165,8 @@ function getDetails(id) { ...@@ -164,8 +165,8 @@ function getDetails(id) {
pageData.form.classifyText = pageData.options.classify.find((item) => item.value == res.classify).text pageData.form.classifyText = pageData.options.classify.find((item) => item.value == res.classify).text
pageData.form.imageObj = pageData.form.image && parseUrlInfo(pageData.form.image) pageData.form.imageObj = pageData.form.image && parseUrlInfo(pageData.form.image)
}) })
} }
function parseUrlInfo(url) { function parseUrlInfo(url) {
// 从URL中提取文件名 // 从URL中提取文件名
const pathParts = url.split('/') const pathParts = url.split('/')
const fileName = pathParts[pathParts.length - 1] const fileName = pathParts[pathParts.length - 1]
...@@ -177,40 +178,40 @@ function parseUrlInfo(url) { ...@@ -177,40 +178,40 @@ function parseUrlInfo(url) {
// 返回格式化的对象 // 返回格式化的对象
return { return {
name: fileName, name: fileName,
extname: extname, extname,
url: url, url,
}
} }
}
function handleChangeTime1(e) { function handleChangeTime1(e) {
pageData.form.supplyStartDate = e.result pageData.form.supplyStartDate = e.result
pageData.show.time1 = false pageData.show.time1 = false
} }
function handleChangeTime2(e) { function handleChangeTime2(e) {
pageData.form.supplyEndDate = e.result pageData.form.supplyEndDate = e.result
pageData.show.time2 = false pageData.show.time2 = false
} }
function handleChangeClassify(e) { function handleChangeClassify(e) {
pageData.form.classify = e.value pageData.form.classify = e.value
pageData.form.classifyText = e.text pageData.form.classifyText = e.text
pageData.show.classify = false pageData.show.classify = false
} }
function handleChangeAddress(e) { function handleChangeAddress(e) {
pageData.form.address = e.text.join('/') pageData.form.address = e.text.join('/')
pageData.show.address = false pageData.show.address = false
} }
function handleChangeStatus(e) { function handleChangeStatus(e) {
pageData.form.status = e.value pageData.form.status = e.value
pageData.form.statusText = e.text pageData.form.statusText = e.text
pageData.show.status = false pageData.show.status = false
} }
const toastRef = ref() const toastRef = ref()
const uploadRef = ref() const uploadRef = ref()
// 文件上传 // 文件上传
function handleUpload(file) { function handleUpload(file) {
uni.uploadFile({ uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: file.tempFiles[0].path, filePath: file.tempFiles[0].path,
name: 'file', name: 'file',
formData: { formData: {
...@@ -240,14 +241,14 @@ function handleUpload(file) { ...@@ -240,14 +241,14 @@ function handleUpload(file) {
pageData.form.image = null pageData.form.image = null
}, },
}) })
} }
// 文件删除 // 文件删除
function handleDelete(file) { function handleDelete(file) {
uploadRef.value.clearFiles() uploadRef.value.clearFiles()
pageData.form.image = null pageData.form.image = null
} }
const formRef = ref() const formRef = ref()
function submit() { 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) {
changeAddressValue(pageData.form) changeAddressValue(pageData.form)
...@@ -262,19 +263,19 @@ function submit() { ...@@ -262,19 +263,19 @@ function submit() {
}) })
} }
}) })
} }
/** /**
* 处理地区值 * 处理地区值
* @param formData 表单数据 * @param formData 表单数据
*/ */
const changeAddressValue = (formData) => { function changeAddressValue(formData) {
const addressValue = formData.address.split('/') const addressValue = formData.address.split('/')
if (addressValue.length === 3) { if (addressValue.length === 3) {
formData.province = getCodeByText(addressValue[0]) formData.province = getCodeByText(addressValue[0])
formData.city = getCodeByText(addressValue[1]) formData.city = getCodeByText(addressValue[1])
formData.country = getCodeByText(addressValue[2]) formData.country = getCodeByText(addressValue[2])
} }
} }
</script> </script>
<template> <template>
...@@ -282,20 +283,43 @@ const changeAddressValue = (formData) => { ...@@ -282,20 +283,43 @@ const changeAddressValue = (formData) => {
<view class="formBox"> <view class="formBox">
<fui-form ref="formRef" label-weight="auto" top="60"> <fui-form ref="formRef" label-weight="auto" top="60">
<view class="mt20"> <view class="mt20">
<fui-input required label="供应标题" placeholder="请输入供应标题" v-model="form.title" <fui-input
labelSize="28" label-width="180"></fui-input> required
<fui-input label="规格说明" placeholder="请输入规格说明" v-model="form.productSpecs" label="供应标题"
labelSize="28" label-width="180"></fui-input> placeholder="请输入供应标题"
v-model="form.title"
labelSize="28"
label-width="180"
/>
<fui-input
label="规格说明"
placeholder="请输入规格说明"
v-model="form.productSpecs"
labelSize="28"
label-width="180"
/>
</view> </view>
<view class="mt20"> <view class="mt20">
<!-- 价格区间 --> <!-- 价格区间 -->
<view class="form-section" style="padding: 0 10rpx;"> <view class="form-section" style="padding: 0 10rpx">
<view class="form-item required flex align-center"> <view class="form-item required flex align-center">
<text class="label">价格区间</text> <text class="label">价格区间</text>
<view class="price-range"> <view class="price-range">
<input type="number" class="price-input" v-model="form.minPrice" placeholder="最低价" :min="0" /> <input
type="number"
class="price-input"
v-model="form.minPrice"
placeholder="最低价"
:min="0"
/>
<text class="price-separator">-</text> <text class="price-separator">-</text>
<input type="number" class="price-input" v-model="form.maxPrice" placeholder="最高价" :min="0"/> <input
type="number"
class="price-input"
v-model="form.maxPrice"
placeholder="最高价"
:min="0"
/>
</view> </view>
</view> </view>
</view> </view>
...@@ -303,30 +327,60 @@ const changeAddressValue = (formData) => { ...@@ -303,30 +327,60 @@ const changeAddressValue = (formData) => {
labelSize="28" label-width="180"></fui-input> labelSize="28" label-width="180"></fui-input>
<fui-input required label="最高价" placeholder="请输入最高价" v-model="form.maxPrice" <fui-input required label="最高价" placeholder="请输入最高价" v-model="form.maxPrice"
labelSize="28" label-width="180"></fui-input> --> labelSize="28" label-width="180"></fui-input> -->
<fui-input required label="计量单位" placeholder="请输入计量单位" v-model="form.unit" <fui-input
labelSize="28" label-width="180" ></fui-input> required
<fui-input required label="币种" placeholder="请输入币种" v-model="form.currency" label="计量单位"
labelSize="28" label-width="180"></fui-input> placeholder="请输入计量单位"
<fui-input type="number" required label="供应数量" placeholder="请输入供应数量" v-model="form.supplyQuantity" v-model="form.unit"
labelSize="28" label-width="180"></fui-input> labelSize="28"
<fui-input type="number" required label="最小起订量" placeholder="请输入最小起订量" v-model="form.minOrderQuantity" label-width="180"
labelSize="28" label-width="180"></fui-input> />
<fui-input
required
label="币种"
placeholder="请输入币种"
v-model="form.currency"
labelSize="28"
label-width="180"
/>
<fui-input
type="number"
required
label="供应数量"
placeholder="请输入供应数量"
v-model="form.supplyQuantity"
labelSize="28"
label-width="180"
/>
<fui-input
type="number"
required
label="最小起订量"
placeholder="请输入最小起订量"
v-model="form.minOrderQuantity"
labelSize="28"
label-width="180"
/>
</view> </view>
<view class="mt20"> <view class="mt20">
<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="select-input" @click="show.address = true"> <view class="select-input" @click="show.address = true">
<text class="time-text" :class="{ placeholder: !form.address }"> <text class="time-text" :class="{ placeholder: !form.address }">
{{ form.address || '请选择省/市/区县' }} {{ form.address || '请选择省/市/区县' }}
</text> </text>
</view> </view>
</view> </view>
<fui-input label="详细地址" placeholder="请输入详细地址" v-model="form.detailedAddress" <fui-input
labelSize="28" label-width="180"></fui-input> label="详细地址"
placeholder="请输入详细地址"
v-model="form.detailedAddress"
labelSize="28"
label-width="180"
/>
<!-- 供应时间 --> <!-- 供应时间 -->
<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">供应时间</text> <text class="label">供应时间</text>
<view class="time-range"> <view class="time-range">
...@@ -348,7 +402,7 @@ const changeAddressValue = (formData) => { ...@@ -348,7 +402,7 @@ const changeAddressValue = (formData) => {
@click="show.time1 = true" labelSize="28" label-width="180"></fui-input> @click="show.time1 = true" labelSize="28" label-width="180"></fui-input>
<fui-input label="供应结束时间" placeholder="请选择供应结束时间" v-model="form.supplyEndDate" <fui-input label="供应结束时间" placeholder="请选择供应结束时间" v-model="form.supplyEndDate"
@click="show.time2 = true" labelSize="28" label-width="180"></fui-input> --> @click="show.time2 = true" labelSize="28" label-width="180"></fui-input> -->
<view class="form-section" style="padding: 0 10rpx;"> <view class="form-section" style="padding: 0 10rpx">
<view class="form-item required flex align-center"> <view class="form-item required flex align-center">
<text class="label">分类</text> <text class="label">分类</text>
<view class="time-input" @click="show.classify = true"> <view class="time-input" @click="show.classify = true">
...@@ -358,7 +412,7 @@ const changeAddressValue = (formData) => { ...@@ -358,7 +412,7 @@ const changeAddressValue = (formData) => {
</view> </view>
</view> </view>
</view> </view>
<view class="form-section" style="padding: 0 10rpx;"> <view class="form-section" style="padding: 0 10rpx">
<view class="form-item required flex align-center"> <view class="form-item required flex align-center">
<text class="label">状态</text> <text class="label">状态</text>
<view class="time-input" @click="show.status = true"> <view class="time-input" @click="show.status = true">
...@@ -368,49 +422,80 @@ const changeAddressValue = (formData) => { ...@@ -368,49 +422,80 @@ const changeAddressValue = (formData) => {
</view> </view>
</view> </view>
</view> </view>
</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"> 示例图片 </view> <view class="mb-1 flex justify-start"> 示例图片 </view>
<uni-file-picker :value="form.imageObj" ref="uploadRef" limit="1" :auto-upload="false" <uni-file-picker
@select="handleUpload" @delete="handleDelete"></uni-file-picker> :value="form.imageObj"
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> <fui-button text="发布需求" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
<fui-date-picker :show="show.time1" type="3" @change="handleChangeTime1" <fui-date-picker
@cancel="show.time1 = false" minDate="2025-01-01"></fui-date-picker> :show="show.time1"
<fui-date-picker :show="show.time2" type="3" @change="handleChangeTime2" type="3"
@cancel="show.time2 = false" minDate="2025-01-01"></fui-date-picker> @change="handleChangeTime1"
<fui-picker :show="show.status" :layer="1" :linkage="true" :options="options.status" @cancel="show.time1 = false"
@change="handleChangeStatus" @cancel="show.status = false"></fui-picker> minDate="2025-01-01"
<fui-picker :show="show.classify" :layer="1" :linkage="true" :options="options.classify" />
@change="handleChangeClassify" @cancel="show.classify = false"></fui-picker> <fui-date-picker
<fui-picker :show="show.address" :options="options.address" :linkage="true" :layer="3" :show="show.time2"
@change="handleChangeAddress" @cancel="show.address = false"></fui-picker> type="3"
@change="handleChangeTime2"
<fui-toast ref="toastRef"></fui-toast> @cancel="show.time2 = false"
minDate="2025-01-01"
/>
<fui-picker
:show="show.status"
:layer="1"
:linkage="true"
:options="options.status"
@change="handleChangeStatus"
@cancel="show.status = false"
/>
<fui-picker
:show="show.classify"
:layer="1"
:linkage="true"
:options="options.classify"
@change="handleChangeClassify"
@cancel="show.classify = false"
/>
<fui-picker
:show="show.address"
:options="options.address"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="show.address = false"
/>
<fui-toast ref="toastRef" />
</view> </view>
</view> </view>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
body { body {
background-color: #E6F5E8; background-color: #e6f5e8;
} }
.page { .page {
background-color: #E6F5E8; background-color: #e6f5e8;
width: 750rpx; width: 750rpx;
overflow-x: hidden; overflow-x: hidden;
.mt20 { .mt20 {
margin-top: 30rpx; margin-top: 30rpx;
background: #FFF; background: #fff;
padding: 20rpx; padding: 20rpx;
border-radius: 10rpx; border-radius: 10rpx;
} }
...@@ -451,10 +536,6 @@ body { ...@@ -451,10 +536,6 @@ body {
.select-input { .select-input {
position: relative; position: relative;
}
}
.form-row { .form-row {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
...@@ -606,7 +687,7 @@ body { ...@@ -606,7 +687,7 @@ body {
.submit-btn { .submit-btn {
width: 100%; width: 100%;
height: 88rpx; height: 88rpx;
background: #5DB66F; background: #5db66f;
border-radius: 44rpx; border-radius: 44rpx;
color: #ffffff; color: #ffffff;
font-size: 32rpx; font-size: 32rpx;
...@@ -618,28 +699,27 @@ body { ...@@ -618,28 +699,27 @@ body {
opacity: 0.9; opacity: 0.9;
} }
} }
}
} ::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(.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;
} }
</style> </style>
<template>
<u-modal :show="show" :title="dialogTitle" :showConfirmButton="false" :showCancelButton="false" @close="handleClose"
:closeOnClickOverlay="false">
<view class="dialog-content">
<u-form :model="formData" :rules="rules" ref="formRef" label-width="180rpx">
<!-- 设备基本信息 -->
<view class="section-title">设备基本信息</view>
<u-form-item label="设备名称" prop="deviceName" required>
<u-input v-model="formData.deviceName" placeholder="请输入设备名称" border="bottom" />
</u-form-item>
<u-form-item label="设备类型" prop="deviceType" required>
<view class="address-display" @click="showDeviceTypePicker = true">
<text :class="{ 'placeholder-text': !formData.deviceTypeText }">
{{ formData.deviceTypeText || '请选择设备类型' }}
</text>
</view>
<!-- <u-input v-model="formData.deviceTypeText" placeholder="请选择设备类型" border="bottom"
@click="showDeviceTypePicker = true" /> -->
</u-form-item>
<u-form-item label="设备标识" prop="deviceIdentifier" required>
<u-input v-model="formData.deviceIdentifier" placeholder="序列号/MAC地址等" border="bottom" />
</u-form-item>
<!-- 操作按钮 -->
<view class="dialog-buttons">
<u-button type="primary" @click="handleSubmit" :loading="loading" size="normal" class="submit-btn"
color="var(--fui-color-success)">
{{ submitButtonText }}
</u-button>
<u-button @click="handleClose" size="normal" class="cancel-btn">取消</u-button>
</view>
</u-form>
<!-- 设备类型选择器 -->
<fui-picker :show="showDeviceTypePicker" :options="deviceTypeOptions" :layer="1" :linkage="true"
@change="handleDeviceTypeConfirm" @cancel="showDeviceTypePicker = false"></fui-picker>
</view>
</u-modal>
</template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, watch, computed } 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
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
show: false, show: false,
editData: null editData: null,
}) })
// 定义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 dictStore.getDictList['deviceType']?.map((item: any) => ({ return (
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' },
...@@ -119,13 +76,15 @@ const rules = { ...@@ -119,13 +76,15 @@ const rules = {
callback() callback()
} }
}, },
trigger: 'blur' trigger: 'blur',
},
],
} }
]
}
// 监听显示状态 // 监听显示状态
watch(() => props.show, (newVal) => { watch(
() => props.show,
(newVal) => {
if (newVal && props.editData) { if (newVal && props.editData) {
// 编辑模式,填充数据 // 编辑模式,填充数据
resetFormData() resetFormData()
...@@ -134,10 +93,11 @@ watch(() => props.show, (newVal) => { ...@@ -134,10 +93,11 @@ watch(() => props.show, (newVal) => {
// 添加模式,重置表单 // 添加模式,重置表单
resetFormData() resetFormData()
} }
}) },
)
// 重置表单数据 // 重置表单数据
const resetFormData = () => { function resetFormData() {
formData.deviceName = '' formData.deviceName = ''
formData.deviceType = '' formData.deviceType = ''
formData.deviceTypeText = '' formData.deviceTypeText = ''
...@@ -147,11 +107,12 @@ const resetFormData = () => { ...@@ -147,11 +107,12 @@ const resetFormData = () => {
if (formRef.value) { if (formRef.value) {
formRef.value.resetFields() formRef.value.resetFields()
} }
} }
// 加载编辑数据 // 加载编辑数据
const loadEditData = () => { function loadEditData() {
if (!props.editData) return if (!props.editData)
return
formData.deviceName = props.editData.deviceName || '' formData.deviceName = props.editData.deviceName || ''
formData.deviceType = props.editData.deviceType || '' formData.deviceType = props.editData.deviceType || ''
...@@ -159,7 +120,7 @@ const loadEditData = () => { ...@@ -159,7 +120,7 @@ const loadEditData = () => {
// 设置设备类型文本 // 设置设备类型文本
if (props.editData.deviceType) { if (props.editData.deviceType) {
const typeOption = deviceTypeOptions.value.find(item => item.value === props.editData.deviceType) const typeOption = deviceTypeOptions.value.find((item) => item.value === props.editData.deviceType)
if (typeOption) { if (typeOption) {
formData.deviceTypeText = typeOption.text formData.deviceTypeText = typeOption.text
} else { } else {
...@@ -169,17 +130,17 @@ const loadEditData = () => { ...@@ -169,17 +130,17 @@ const loadEditData = () => {
} else { } else {
formData.deviceTypeText = '' formData.deviceTypeText = ''
} }
} }
// 设备类型选择确认 // 设备类型选择确认
const handleDeviceTypeConfirm = (e: any) => { function handleDeviceTypeConfirm(e: any) {
formData.deviceType = e.value formData.deviceType = e.value
formData.deviceTypeText = e.text formData.deviceTypeText = e.text
showDeviceTypePicker.value = false showDeviceTypePicker.value = false
} }
// 提交表单 // 提交表单
const handleSubmit = async () => { async function handleSubmit() {
try { try {
console.log(formData) console.log(formData)
// 先进行表单验证 // 先进行表单验证
...@@ -192,7 +153,7 @@ const handleSubmit = async () => { ...@@ -192,7 +153,7 @@ const handleSubmit = async () => {
// 准备提交数据 // 准备提交数据
const submitData = { const submitData = {
...formData ...formData,
} }
// 根据 editData 判断是新增还是修改 // 根据 editData 判断是新增还是修改
...@@ -201,7 +162,7 @@ const handleSubmit = async () => { ...@@ -201,7 +162,7 @@ const handleSubmit = async () => {
// 编辑设备,需要传递设备ID // 编辑设备,需要传递设备ID
result = await NongchangAPI.editDevice({ result = await NongchangAPI.editDevice({
...submitData, ...submitData,
id: props.editData.id id: props.editData.id,
}) })
console.log('修改设备数据:', submitData) console.log('修改设备数据:', submitData)
} else { } else {
...@@ -213,52 +174,112 @@ const handleSubmit = async () => { ...@@ -213,52 +174,112 @@ const handleSubmit = async () => {
uni.showToast({ title: '操作成功', icon: 'success' }) uni.showToast({ title: '操作成功', icon: 'success' })
emit('update:show', false) emit('update:show', false)
emit('submitSuccess') emit('submitSuccess')
} catch (error) { } catch (error) {
console.log('提交失败:', error) console.log('提交失败:', error)
uni.showToast({ uni.showToast({
title: '操作失败', title: '操作失败',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000,
}) })
} finally { } finally {
loading.value = false loading.value = false
} }
} }
// 关闭弹窗 // 关闭弹窗
const handleClose = () => { function handleClose() {
emit('update:show', false) emit('update:show', false)
emit('close') emit('close')
} }
// 暴露方法给父组件 // 暴露方法给父组件
defineExpose({ defineExpose({
resetFormData, resetFormData,
setLoading: (value: boolean) => { setLoading: (value: boolean) => {
loading.value = value loading.value = value
} },
}) })
</script> </script>
<template>
<u-modal
:show="show"
:title="dialogTitle"
:showConfirmButton="false"
:showCancelButton="false"
@close="handleClose"
:closeOnClickOverlay="false"
>
<view class="dialog-content">
<u-form :model="formData" :rules="rules" ref="formRef" label-width="180rpx">
<!-- 设备基本信息 -->
<view class="section-title">设备基本信息</view>
<u-form-item label="设备名称" prop="deviceName" required>
<u-input v-model="formData.deviceName" placeholder="请输入设备名称" border="bottom" />
</u-form-item>
<u-form-item label="设备类型" prop="deviceType" required>
<view class="address-display" @click="showDeviceTypePicker = true">
<text :class="{ 'placeholder-text': !formData.deviceTypeText }">
{{ formData.deviceTypeText || '请选择设备类型' }}
</text>
</view>
<!-- <u-input v-model="formData.deviceTypeText" placeholder="请选择设备类型" border="bottom"
@click="showDeviceTypePicker = true" /> -->
</u-form-item>
<u-form-item label="设备标识" prop="deviceIdentifier" required>
<u-input v-model="formData.deviceIdentifier" placeholder="序列号/MAC地址等" border="bottom" />
</u-form-item>
<!-- 操作按钮 -->
<view class="dialog-buttons">
<u-button
type="primary"
@click="handleSubmit"
:loading="loading"
size="normal"
class="submit-btn"
color="var(--fui-color-success)"
>
{{ submitButtonText }}
</u-button>
<u-button @click="handleClose" size="normal" class="cancel-btn">取消</u-button>
</view>
</u-form>
<!-- 设备类型选择器 -->
<fui-picker
:show="showDeviceTypePicker"
:options="deviceTypeOptions"
:layer="1"
:linkage="true"
@change="handleDeviceTypeConfirm"
@cancel="showDeviceTypePicker = false"
/>
</view>
</u-modal>
</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 { .dialog-buttons {
display: flex; display: flex;
gap: 20rpx; gap: 20rpx;
margin-top: 40rpx; margin-top: 40rpx;
...@@ -267,8 +288,8 @@ defineExpose({ ...@@ -267,8 +288,8 @@ defineExpose({
flex: 1; flex: 1;
::v-deep .u-button { ::v-deep .u-button {
background-color: #5DB66F; background-color: #5db66f;
border-color: #5DB66F; border-color: #5db66f;
} }
} }
...@@ -281,10 +302,10 @@ defineExpose({ ...@@ -281,10 +302,10 @@ defineExpose({
border: 2rpx solid #dcdfe6; border: 2rpx solid #dcdfe6;
} }
} }
} }
// uview-plus 表单样式调整 // uview-plus 表单样式调整
::v-deep .u-form-item { ::v-deep .u-form-item {
margin-bottom: 40rpx; margin-bottom: 40rpx;
.u-form-item__body { .u-form-item__body {
...@@ -307,8 +328,8 @@ defineExpose({ ...@@ -307,8 +328,8 @@ defineExpose({
flex: 1; flex: 1;
min-width: 0; min-width: 0;
} }
} }
.address-display { .address-display {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
...@@ -328,15 +349,15 @@ defineExpose({ ...@@ -328,15 +349,15 @@ defineExpose({
.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;
...@@ -357,14 +378,14 @@ defineExpose({ ...@@ -357,14 +378,14 @@ defineExpose({
&.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;
...@@ -380,5 +401,5 @@ defineExpose({ ...@@ -380,5 +401,5 @@ defineExpose({
color: #333; color: #333;
} }
} }
} }
</style> </style>
<template>
<view class="codefun-flex-col page">
<z-paging ref="paging" v-model="pageData.list" @query="queryList">
<view class="codefun-flex-col group_3">
<view class="codefun-flex-row codefun-items-center section_2">
<image class="image_6" src="/static/images/codefun/6c5c5a3c082b8c60a307d3a7caee623c.png" />
<u-input v-model="pageData.param.deviceName" placeholder="请输入设备名称搜索" border="none"
class="codefun-ml-8" @confirm="handleSearch" />
</view>
<!-- 设备列表 -->
<view class="device-list">
<uni-swipe-action>
<uni-swipe-action-item v-for="(item, index) in pageData.list" :key="index" :right-options="swipeOptions"
@click="(e) => handleSwipeAction(e, item)">
<view class="device-item">
<view class="device-info">
<view class="device-name">{{ item.deviceName }}</view>
<view class="device-details">
<text class="device-type">类型: {{ item.deviceType_dictText || '未知' }}</text>
<text class="device-identifier">标识: {{ item.deviceIdentifier }}</text>
</view>
</view>
<view class="device-status-time">
<text class="device-status" :class="getStatusClass(item.connectStatus)">
{{ item.connectStatus_dictText || '未知' }}
</text>
<view style="opacity: 0;">1</view>
<view class="device-time">添加日期: {{ item.createTime }}</view>
</view>
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="pageData.list.length === 0">
<text>暂无设备数据</text>
</view>
</view>
</z-paging>
<!-- 弹窗组件 -->
<save-dialog :show="showDialog" :editData="currentEditData" @update:show="showDialog = $event"
@submitSuccess="handleSubmitSuccess" @close="handleDialogClose" />
</view>
</template>
<script setup> <script setup>
import { nextTick, reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import { onLoad, onNavigationBarButtonTap, onShow } from '@dcloudio/uni-app' import { onNavigationBarButtonTap } from '@dcloudio/uni-app'
import * as NongchangAPI from '@/api/model/nongchang' import SaveDialog from './components/save-dialog.vue'
import SaveDialog from './components/save-dialog.vue' import * as NongchangAPI from '@/api/model/nongchang'
const isOnePage = ref(true) const isOnePage = ref(true)
const paging = ref(null) const paging = ref(null)
const pageData = reactive({ const pageData = reactive({
param: { param: {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
deviceName: '', deviceName: '',
}, },
list: [], list: [],
}) })
// 滑动操作选项 // 滑动操作选项
const swipeOptions = [ const swipeOptions = [
{ {
text: '编辑', text: '编辑',
style: { style: {
backgroundColor: 'var(--fui-color-primary)' backgroundColor: 'var(--fui-color-primary)',
} },
}, },
{ {
text: '删除', text: '删除',
style: { style: {
backgroundColor: 'var(--fui-color-danger)' backgroundColor: 'var(--fui-color-danger)',
} },
} },
] ]
function getList() { function getList() {
if (!paging.value) return if (!paging.value) return
NongchangAPI.getDeviceList(pageData.param) NongchangAPI.getDeviceList(pageData.param)
.then((res) => { .then((res) => {
...@@ -88,81 +40,82 @@ function getList() { ...@@ -88,81 +40,82 @@ function getList() {
.catch(() => { .catch(() => {
paging.value.complete(false) paging.value.complete(false)
}) })
} }
function queryList(pageNo, pageSize) { function queryList(pageNo, pageSize) {
pageData.param.pageNo = pageNo pageData.param.pageNo = pageNo
pageData.param.pageSize = pageSize pageData.param.pageSize = pageSize
getList() getList()
} }
function handleSearch() { function handleSearch() {
// 重置页码为1,重新搜索 // 重置页码为1,重新搜索
pageData.param.pageNo = 1 pageData.param.pageNo = 1
if (paging.value) { if (paging.value) {
paging.value.reload() paging.value.reload()
} }
} }
const showDialog = ref(false) const showDialog = ref(false)
const currentEditData = ref(null) const currentEditData = ref(null)
onNavigationBarButtonTap((_) => { onNavigationBarButtonTap((_) => {
showAddDialog() showAddDialog()
}) })
const showAddDialog = () => { function showAddDialog() {
currentEditData.value = null currentEditData.value = null
showDialog.value = true showDialog.value = true
} }
const showEditDialog = (device) => { function showEditDialog(device) {
currentEditData.value = device currentEditData.value = device
showDialog.value = true showDialog.value = true
} }
const handleSubmitSuccess = () => { function handleSubmitSuccess() {
// 提交成功后刷新列表 // 提交成功后刷新列表
handleSearch() handleSearch()
} }
const handleDialogClose = () => { function handleDialogClose() {
// 弹窗关闭后的处理逻辑 // 弹窗关闭后的处理逻辑
} }
// 删除设备 // 删除设备
const handleDelete = async (id) => { async function handleDelete(id) {
try { try {
await uni.showModal({ await uni.showModal({
title: '确认删除', title: '确认删除',
content: '确定要删除这个设备吗?', content: '确定要删除这个设备吗?',
success: async (res) => { success: async (res) => {
if (res.confirm) { if (res.confirm) {
await NongchangAPI.delDevice( id ) await NongchangAPI.delDevice(id)
uni.showToast({ title: '删除成功', icon: 'success' }) uni.showToast({ title: '删除成功', icon: 'success' })
handleSearch() handleSearch()
} }
} },
}) })
} catch (error) { } catch (error) {
uni.showToast({ title: '删除失败', icon: 'none' }) uni.showToast({ title: '删除失败', icon: 'none' })
} }
} }
// 获取状态样式类 // 获取状态样式类
const getStatusClass = (status) => { function getStatusClass(status) {
if (status === '已连接') return 'status-connected' if (status === '已连接')
if (status === '未连接') return 'status-disconnected' return 'status-connected'
if (status === '未连接')
return 'status-disconnected'
return 'status-unknown' return 'status-unknown'
} }
// 处理滑动打开事件 // 处理滑动打开事件
const handleSwipeOpen = (index) => { function handleSwipeOpen(index) {
// 关闭其他已打开的滑动单元格,确保同时只有一个处于打开状态 // 关闭其他已打开的滑动单元格,确保同时只有一个处于打开状态
pageData.list.forEach((item, i) => { pageData.list.forEach((item, i) => {
item.isShow = i === index item.isShow = i === index
}) })
} }
// 处理滑动操作 // 处理滑动操作
const handleSwipeAction = (e, device) => { function handleSwipeAction(e, device) {
const index = e.index const index = e.index
const position = e.position const position = e.position
if (position === 'right') { if (position === 'right') {
...@@ -174,35 +127,96 @@ const handleSwipeAction = (e, device) => { ...@@ -174,35 +127,96 @@ const handleSwipeAction = (e, device) => {
handleDelete(device.id) handleDelete(device.id)
} }
} }
} }
</script> </script>
<template>
<view class="codefun-flex-col page">
<z-paging ref="paging" v-model="pageData.list" @query="queryList">
<view class="codefun-flex-col group_3">
<view class="codefun-flex-row codefun-items-center section_2">
<image class="image_6" src="/static/images/codefun/6c5c5a3c082b8c60a307d3a7caee623c.png" />
<u-input
v-model="pageData.param.deviceName"
placeholder="请输入设备名称搜索"
border="none"
class="codefun-ml-8"
@confirm="handleSearch"
/>
</view>
<!-- 设备列表 -->
<view class="device-list">
<uni-swipe-action>
<uni-swipe-action-item
v-for="(item, index) in pageData.list"
:key="index"
:right-options="swipeOptions"
@click="(e) => handleSwipeAction(e, item)"
>
<view class="device-item">
<view class="device-info">
<view class="device-name">{{ item.deviceName }}</view>
<view class="device-details">
<text class="device-type">类型: {{ item.deviceType_dictText || '未知' }}</text>
<text class="device-identifier">标识: {{ item.deviceIdentifier }}</text>
</view>
</view>
<view class="device-status-time">
<text class="device-status" :class="getStatusClass(item.connectStatus)">
{{ item.connectStatus_dictText || '未知' }}
</text>
<view style="opacity: 0">1</view>
<view class="device-time">添加日期: {{ item.createTime }}</view>
</view>
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="pageData.list.length === 0">
<text>暂无设备数据</text>
</view>
</view>
</z-paging>
<!-- 弹窗组件 -->
<SaveDialog
:show="showDialog"
:editData="currentEditData"
@update:show="showDialog = $event"
@submit-success="handleSubmitSuccess"
@close="handleDialogClose"
/>
</view>
</template>
<style lang="scss"> <style lang="scss">
body { body {
background-color: #e6f5e8; background-color: #e6f5e8;
} }
.mt-5 { .mt-5 {
margin-top: 10rpx; margin-top: 10rpx;
} }
.mt-11 { .mt-11 {
margin-top: 22rpx; margin-top: 22rpx;
} }
.ml-5 { .ml-5 {
margin-left: 10rpx; margin-left: 10rpx;
} }
.ml-13 { .ml-13 {
margin-left: 26rpx; margin-left: 26rpx;
} }
.ml-9 { .ml-9 {
margin-left: 18rpx; margin-left: 18rpx;
} }
.page { .page {
background-color: #e6f5e8; background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH; mix-blend-mode: NOTTHROUGH;
width: 100%; width: 100%;
...@@ -665,14 +679,14 @@ body { ...@@ -665,14 +679,14 @@ body {
line-height: 25.76rpx; line-height: 25.76rpx;
color: #ffffff; color: #ffffff;
} }
} }
/* 设备列表样式 */ /* 设备列表样式 */
.device-list { .device-list {
margin-top: 20rpx; margin-top: 20rpx;
} }
.device-item { .device-item {
background-color: #ffffff; background-color: #ffffff;
border-radius: 16rpx; border-radius: 16rpx;
padding: 24rpx; padding: 24rpx;
...@@ -680,82 +694,82 @@ body { ...@@ -680,82 +694,82 @@ body {
// justify-content: space-between; // justify-content: space-between;
align-items: center; align-items: center;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1); box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
} }
::v-deep .uni-swipe { ::v-deep .uni-swipe {
border-radius: 16rpx; border-radius: 16rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.device-info { .device-info {
flex: 1; flex: 1;
} }
.device-name { .device-name {
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
color: #333333; color: #333333;
margin-bottom: 8rpx; margin-bottom: 8rpx;
border-left: 6rpx solid #5DB66F; border-left: 6rpx solid #5db66f;
padding-left: 6rpx; padding-left: 6rpx;
} }
.device-details { .device-details {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 6rpx; gap: 6rpx;
margin-bottom: 8rpx; margin-bottom: 8rpx;
} }
.device-type, .device-type,
.device-identifier { .device-identifier {
font-size: 24rpx; font-size: 24rpx;
color: #666666; color: #666666;
} }
.device-status-time { .device-status-time {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: flex-end; align-items: flex-end;
gap: 6rpx; gap: 6rpx;
min-width: 180rpx; min-width: 180rpx;
} }
.device-status { .device-status {
font-size: 24rpx; font-size: 24rpx;
font-weight: bold; font-weight: bold;
} }
.device-time { .device-time {
font-size: 22rpx; font-size: 22rpx;
color: #999999; color: #999999;
} }
.device-actions { .device-actions {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 12rpx; gap: 12rpx;
} }
.status-connected { .status-connected {
color: #5db66f !important; color: #5db66f !important;
font-weight: bold; font-weight: bold;
} }
.status-disconnected { .status-disconnected {
color: #f44336 !important; color: #f44336 !important;
font-weight: bold; font-weight: bold;
} }
.status-unknown { .status-unknown {
color: #ff9800 !important; color: #ff9800 !important;
font-weight: bold; font-weight: bold;
} }
.empty-state { .empty-state {
text-align: center; text-align: center;
padding: 100rpx 0; padding: 100rpx 0;
color: #999999; color: #999999;
font-size: 28rpx; font-size: 28rpx;
} }
</style> </style>
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue' import { reactive } from 'vue'
import { onPullDownRefresh, onLoad } from '@dcloudio/uni-app' import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
import * as NongzhiAPI from '@/api/model/nongzhi' import * as NongzhiAPI from '@/api/model/nongzhi'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
import { url } from 'inspector'
// 下拉刷新 // 下拉刷新
onPullDownRefresh(() => { onPullDownRefresh(() => {
...@@ -275,7 +274,7 @@ ...@@ -275,7 +274,7 @@
function onFarmMachineryServiceClick(service: any) { function onFarmMachineryServiceClick(service: any) {
console.log('点击农机服务:', service) console.log('点击农机服务:', service)
// 在这里添加具体的服务点击逻辑 // 在这里添加具体的服务点击逻辑
Navigate.to('/pages/nongjifuwu/nongjifuwu?type=' + service.id) Navigate.to(`/pages/nongjifuwu/nongjifuwu?type=${service.id}`)
} }
// 技能培训点击事件 // 技能培训点击事件
...@@ -474,7 +473,7 @@ ...@@ -474,7 +473,7 @@
> >
<view class="codefun-flex-row codefun-items-center codefun-self-stretch"> <view class="codefun-flex-row codefun-items-center codefun-self-stretch">
<image class="image_11" :src="service.image" /> <image class="image_11" :src="service.image" />
<text class="font_5" :class="`text_33 ml-7`">{{ service.title }}</text> <text class="font_5 text_33 ml-7">{{ service.title }}</text>
</view> </view>
<text <text
class="codefun-self-start font_10" class="codefun-self-start font_10"
......
<template>
<view class="container">
<u-form :model="formData" :rules="rules" ref="formRef" label-width="160rpx">
<!-- 基地基本信息 -->
<view class="section-title">基地基本信息</view>
<u-form-item label="基地名称" prop="baseName" required>
<u-input v-model="formData.baseName" placeholder="请输入基地名称" border="bottom" />
</u-form-item>
<u-form-item label="基地类型" prop="baseType" required class="clickable" @click="show.farmType = true">
<view class="address-display">
<text :class="{'placeholder-text': !formData.baseTypeText}">
{{ formData.baseTypeText || '请选择基地类型' }}
</text>
</view>
</u-form-item>
<u-form-item label="规模" prop="scale" required>
<u-input v-model="formData.scale" placeholder="请输入规模(亩)" border="bottom" type="number">
<template #suffix>
<text class="suffix-text"></text>
</template>
</u-input>
</u-form-item>
<!-- 地址信息 -->
<view class="section-title">地址信息</view>
<u-form-item label="省市区" prop="province" required class="clickable" @click="show.address = true">
<view class="address-display">
<text :class="{'placeholder-text': !formData.province}">
{{ formData.province || '请选择省市区' }}
</text>
</view>
</u-form-item>
<u-form-item label="详细地址" prop="detailedAddress" required>
<u-input v-model="formData.detailedAddress" placeholder="请输入详细地址" border="bottom" />
</u-form-item>
<!-- 负责人信息 -->
<view class="section-title">负责人信息</view>
<u-form-item label="负责人姓名" prop="managerName" required>
<u-input v-model="formData.managerName" placeholder="请输入负责人姓名" border="bottom" />
</u-form-item>
<u-form-item label="联系电话" prop="contactPhone" required>
<u-input v-model="formData.contactPhone" placeholder="请输入联系电话" border="bottom" type="number" />
</u-form-item>
<u-form-item label="身份证号" prop="idCard" required>
<u-input v-model="formData.idCard" placeholder="请输入身份证号" border="bottom" />
</u-form-item>
<!-- 经营信息 -->
<view class="section-title">经营信息</view>
<u-form-item label="种植作物" prop="plantedCrops" required>
<u-input v-model="formData.plantedCrops" placeholder="请输入种植作物,多个用逗号分隔" border="bottom" />
</u-form-item>
<u-form-item label="经营年限" prop="operationYears" required>
<u-input v-model="formData.operationYears" placeholder="请输入经营年限" border="bottom" type="number">
<template #suffix>
<text class="suffix-text"></text>
</template>
</u-input>
</u-form-item>
<!-- 基地图片 -->
<view class="section-title">认证材料</view>
<u-form-item label="基地图片" prop="baseImages">
<u-upload :fileList="formData.baseImages" @afterRead="(e) => afterRead(e, 'baseImages')"
@delete="(e) => deletePic(e, 'baseImages')" name="1" multiple :maxCount="5"
:previewFullImage="true"></u-upload>
</u-form-item>
<u-form-item label="身份证明" prop="identityProveUrl" required>
<div>
<u-upload :fileList="formData.identityProveUrl" @afterRead="(e) => afterRead(e, 'identityProveUrl')"
@delete="(e) => deletePic(e, 'identityProveUrl')" name="identityProveUrl" multiple :maxCount="2"
:previewFullImage="true"></u-upload>
<div><i>身份证/营业执照图片</i></div>
</div>
</u-form-item>
<u-form-item label="场地证明" prop="landProveUrl" required>
<div>
<u-upload :fileList="formData.landProveUrl" @afterRead="(e) => afterRead(e, 'landProveUrl')"
@delete="(e) => deletePic(e, 'landProveUrl')" name="landProveUrl" multiple :maxCount="2"
:previewFullImage="true"></u-upload>
<div><i>土地合同/场地照片</i></div>
</div>
</u-form-item>
<u-form-item label="生产证明" prop="productionProveUrl" required>
<div>
<u-upload :fileList="formData.productionProveUrl"
@afterRead="(e) => afterRead(e, 'productionProveUrl')"
@delete="(e) => deletePic(e, 'productionProveUrl')" name="productionProveUrl" multiple
:maxCount="2" :previewFullImage="true"></u-upload>
<div><i>现场作业照片/产品照片</i></div>
</div>
</u-form-item>
<u-form-item label="质量证书">
<div>
<u-upload :fileList="formData.qualityCertificateUrl"
@afterRead="(e) => afterRead(e, 'qualityCertificateUrl')"
@delete="(e) => deletePic(e, 'qualityCertificateUrl')" name="qualityCertificateUrl" multiple
:maxCount="2" :previewFullImage="true"></u-upload>
<div><i>质量认证证书</i></div>
</div>
</u-form-item>
<u-form-item label="其他材料">
<div>
<u-upload :fileList="formData.otherMaterialUrl" @afterRead="(e) => afterRead(e, 'otherMaterialUrl')"
@delete="(e) => deletePic(e, 'otherMaterialUrl')" name="otherMaterialUrl" multiple :maxCount="2"
:previewFullImage="true"></u-upload>
<div><i>其他补充材料</i></div>
</div>
</u-form-item>
<!-- 提交按钮 -->
<view class="submit-btn-container">
<u-button type="primary" @click="submitForm" :loading="loading">提交</u-button>
</view>
</u-form>
<fui-picker :show="show.address" :options="options.address" :linkage="true" :layer="3"
@change="handleChangeAddress" @cancel="show.address = false"></fui-picker>
<fui-picker :show="show.farmType" :layer="1" :linkage="true" :options="options.farmType"
@change="handleChangeFarmType" @cancel="show.farmType = false"></fui-picker>
</view>
</template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, computed } from 'vue' import { reactive, ref } from 'vue'
import { areaTree } from '@/utils/areaData' import { onLoad } from '@dcloudio/uni-app'
import { onLoad } from '@dcloudio/uni-app' import { areaTree } from '@/utils/areaData'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting' import { useGlobSetting } from '/@/hooks/setting'
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'
import { useFarmStore } from '@/store/modules/farm' import { useFarmStore } from '@/store/modules/farm'
const dictStore = useDictStore()
// 表单引用 const dictStore = useDictStore()
const formRef = ref() // 表单引用
const loading = ref(false) const formRef = ref()
const show = reactive({ const loading = ref(false)
const show = reactive({
address: false, address: false,
farmType: false, farmType: false,
}) })
const options = reactive({ const options = reactive({
address: areaTree, address: areaTree,
farmType: [] farmType: [],
}) })
// 表单数据 // 表单数据
const formData = reactive({ const formData = reactive({
farmId: '', farmId: '',
baseName: '', baseName: '',
baseType: '', baseType: '',
...@@ -174,22 +38,20 @@ const formData = reactive({ ...@@ -174,22 +38,20 @@ const formData = reactive({
plantedCrops: '', plantedCrops: '',
operationYears: '', operationYears: '',
baseImages: [], baseImages: [],
identityProveUrl: [],//身份证明(身份证/营业执照图片) identityProveUrl: [], // 身份证明(身份证/营业执照图片)
landProveUrl: [],//土地证明(土地证/国有土地使用证) landProveUrl: [], // 土地证明(土地证/国有土地使用证)
productionProveUrl: [],//生产证明(生产许可证/种养许可证) productionProveUrl: [], // 生产证明(生产许可证/种养许可证)
qualityCertificateUrl: [],//质量证明(质量认证证书) qualityCertificateUrl: [], // 质量证明(质量认证证书)
otherMaterialUrl: [],//其他证明(其他证明) otherMaterialUrl: [], // 其他证明(其他证明)
}) })
// 表单验证规则 // 表单验证规则
const rules = { const rules = {
baseName: [ baseName: [
{ 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' },
],
baseType: [
{ required: true, message: '请选择基地类型', trigger: 'change' }
], ],
baseType: [{ required: true, message: '请选择基地类型', trigger: 'change' }],
scale: [ scale: [
{ {
validator: (rule: any, value: any, callback: any) => { validator: (rule: any, value: any, callback: any) => {
...@@ -201,37 +63,40 @@ const rules = { ...@@ -201,37 +63,40 @@ const rules = {
callback() callback()
} }
}, },
trigger: ['blur', 'change'] trigger: ['blur', 'change'],
} },
], ],
province: [ province: [
{ {
required: true, message: '请获取地址信息', trigger: 'change', required: true,
message: '请获取地址信息',
trigger: 'change',
// validator: () => formData.provinceName && formData.cityName && formData.districtName // validator: () => formData.provinceName && formData.cityName && formData.districtName
} },
], ],
detailedAddress: [ detailedAddress: [
{ required: true, message: '请输入详细地址', trigger: 'blur' }, { required: true, message: '请输入详细地址', trigger: 'blur' },
{ min: 5, max: 200, message: '详细地址长度在5-200个字符之间', trigger: 'blur' } { min: 5, max: 200, message: '详细地址长度在5-200个字符之间', trigger: 'blur' },
], ],
managerName: [ managerName: [
{ required: true, message: '请输入负责人姓名', trigger: 'blur' }, { required: true, message: '请输入负责人姓名', trigger: 'blur' },
{ pattern: /^[\u4e00-\u9fa5]{2,10}$/, message: '姓名必须为2-10个汉字', trigger: 'blur' } { pattern: /^[\u4E00-\u9FA5]{2,10}$/, message: '姓名必须为2-10个汉字', trigger: 'blur' },
], ],
contactPhone: [ contactPhone: [
{ required: true, message: '请输入联系电话', trigger: 'blur' }, { required: true, message: '请输入联系电话', trigger: 'blur' },
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' } { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' },
], ],
idCard: [ idCard: [
{ required: true, message: '请输入身份证号', trigger: 'blur' }, { required: true, message: '请输入身份证号', trigger: 'blur' },
{ {
pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
message: '请输入正确的身份证号码', trigger: 'blur' message: '请输入正确的身份证号码',
} trigger: 'blur',
},
], ],
plantedCrops: [ plantedCrops: [
{ required: true, message: '请输入种植作物', trigger: 'blur' }, { required: true, message: '请输入种植作物', trigger: 'blur' },
{ min: 2, max: 100, message: '种植作物长度在2-100个字符之间', trigger: 'blur' } { min: 2, max: 100, message: '种植作物长度在2-100个字符之间', trigger: 'blur' },
], ],
operationYears: [ operationYears: [
{ {
...@@ -243,37 +108,31 @@ const rules = { ...@@ -243,37 +108,31 @@ const rules = {
} }
}, },
message: '经营年限必须为正整数', message: '经营年限必须为正整数',
trigger: ['blur', 'change'] trigger: ['blur', 'change'],
} },
],
identityProveUrl: [
{ required: true, message: '请上传身份证明', trigger: 'change', type: 'array' }
],
landProveUrl: [
{ required: true, message: '请上传场地证明', trigger: 'change', type: 'array' }
], ],
productionProveUrl: [ identityProveUrl: [{ required: true, message: '请上传身份证明', trigger: 'change', type: 'array' }],
{ required: true, message: '请上传生产证明', trigger: 'change', type: 'array' } landProveUrl: [{ required: true, message: '请上传场地证明', trigger: 'change', type: 'array' }],
] productionProveUrl: [{ required: true, message: '请上传生产证明', trigger: 'change', type: 'array' }],
} }
function handleChangeFarmType(e) { function handleChangeFarmType(e) {
formData.baseType = e.value formData.baseType = e.value
formData.baseTypeText = e.text formData.baseTypeText = e.text
show.farmType = false show.farmType = false
} }
function handleChangeAddress(e) { function handleChangeAddress(e) {
formData.province = e.result; formData.province = e.result
formData.provinceName = e.text[0]; formData.provinceName = e.text[0]
formData.cityName = e.text[1]; formData.cityName = e.text[1]
formData.districtName = e.text[2]; formData.districtName = e.text[2]
show.address = false show.address = false
} }
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
const toastRef = ref() const toastRef = ref()
// 文件上传 // 文件上传
function afterRead(event, key) { function afterRead(event, key) {
// 获取上传的文件列表 // 获取上传的文件列表
const files = event.file const files = event.file
...@@ -282,12 +141,12 @@ function afterRead(event, key) { ...@@ -282,12 +141,12 @@ function afterRead(event, key) {
// 记录成功上传的数量 // 记录成功上传的数量
let successCount = 0 let successCount = 0
let totalCount = files.length const totalCount = files.length
// 遍历所有文件进行上传 // 遍历所有文件进行上传
files.forEach((file) => { files.forEach((file) => {
uni.uploadFile({ uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: file.url, filePath: file.url,
name: 'file', name: 'file',
formData: { formData: {
...@@ -321,14 +180,14 @@ function afterRead(event, key) { ...@@ -321,14 +180,14 @@ function afterRead(event, key) {
}, },
}) })
}) })
} }
// 删除图片 // 删除图片
const deletePic = (event: any, key) => { function deletePic(event: any, key) {
formData[key].splice(event.index, 1) formData[key].splice(event.index, 1)
} }
// 提交表单 // 提交表单
const submitForm = async () => { async function submitForm() {
try { try {
// 先进行表单验证 // 先进行表单验证
const valid = await formRef.value.validate() const valid = await formRef.value.validate()
...@@ -348,12 +207,12 @@ const submitForm = async () => { ...@@ -348,12 +207,12 @@ const submitForm = async () => {
'landProveUrl', 'landProveUrl',
'productionProveUrl', 'productionProveUrl',
'qualityCertificateUrl', 'qualityCertificateUrl',
'otherMaterialUrl' 'otherMaterialUrl',
] ]
arrayFields.forEach(field => { arrayFields.forEach((field) => {
if (Array.isArray(submitData[field])) { if (Array.isArray(submitData[field])) {
submitData[field] = submitData[field].filter(item => item?.trim()).join(',') submitData[field] = submitData[field].filter((item) => item?.trim()).join(',')
} }
}) })
...@@ -366,59 +225,66 @@ const submitForm = async () => { ...@@ -366,59 +225,66 @@ const submitForm = async () => {
uni.showToast({ uni.showToast({
title: '提交成功', title: '提交成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500,
}) })
// 延迟返回上一页 // 延迟返回上一页
setTimeout(() => { setTimeout(() => {
uni.navigateBack() uni.navigateBack()
}, 1500) }, 1500)
} catch (error) { } catch (error) {
console.error('API调用失败:', error) console.error('API调用失败:', error)
uni.showToast({ uni.showToast({
title: error.message || '提交失败,请重试', title: error.message || '提交失败,请重试',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000,
}) })
} finally { } finally {
loading.value = false loading.value = false
} }
} catch (error) { } catch (error) {
console.log('表单验证失败:', error) console.log('表单验证失败:', error)
loading.value = false loading.value = false
uni.showToast({ uni.showToast({
title: '请完善表单信息', title: '请完善表单信息',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000,
}) })
} }
} }
const farmStore = useFarmStore() const farmStore = useFarmStore()
onLoad((pageOptions) => { onLoad((pageOptions) => {
// 页面加载时的初始化操作 // 页面加载时的初始化操作
const farmInfo = farmStore.getFarm const farmInfo = farmStore.getFarm
if (farmInfo) { if (farmInfo) {
formData.farmId = farmInfo.id formData.farmId = farmInfo.id
} }
// 修复:修改页面上定义的 options 对象中的 farmType // 修复:修改页面上定义的 options 对象中的 farmType
options.farmType = dictStore.getDictList['farm_type'].map((item) => { options.farmType = dictStore.getDictList.farm_type.map((item) => {
return { return {
value: item.value, value: item.value,
text: item.text, text: item.text,
} }
}) })
if (pageOptions.id) { if (pageOptions.id) {
NongchangAPI.getFarmbaseInfoById({ id: pageOptions.id }).then(res => { NongchangAPI.getFarmbaseInfoById({ id: pageOptions.id }).then((res) => {
if (res) { if (res) {
// 将 res 中的数据赋值到 formData 中,key 保持一致 // 将 res 中的数据赋值到 formData 中,key 保持一致
Object.keys(res).forEach(key => { Object.keys(res).forEach((key) => {
if (key in formData) { if (key in formData) {
// 如果是数组类型的字段且返回的是字符串,需要转换为数组 // 如果是数组类型的字段且返回的是字符串,需要转换为数组
if (['baseImages', 'identityProveUrl', 'landProveUrl', 'productionProveUrl', 'qualityCertificateUrl', 'otherMaterialUrl'].includes(key) && if (
typeof res[key] === 'string') { [
formData[key] = res[key].split(',').filter(item => item.trim() !== '') 'baseImages',
'identityProveUrl',
'landProveUrl',
'productionProveUrl',
'qualityCertificateUrl',
'otherMaterialUrl',
].includes(key) &&
typeof res[key] === 'string'
) {
formData[key] = res[key].split(',').filter((item) => item.trim() !== '')
} else { } else {
formData[key] = res[key] formData[key] = res[key]
} }
...@@ -447,26 +313,204 @@ onLoad((pageOptions) => { ...@@ -447,26 +313,204 @@ onLoad((pageOptions) => {
} }
}) })
} }
}) })
</script> </script>
<template>
<view class="container">
<u-form :model="formData" :rules="rules" ref="formRef" label-width="160rpx">
<!-- 基地基本信息 -->
<view class="section-title">基地基本信息</view>
<u-form-item label="基地名称" prop="baseName" required>
<u-input v-model="formData.baseName" placeholder="请输入基地名称" border="bottom" />
</u-form-item>
<u-form-item label="基地类型" prop="baseType" required class="clickable" @click="show.farmType = true">
<view class="address-display">
<text :class="{ 'placeholder-text': !formData.baseTypeText }">
{{ formData.baseTypeText || '请选择基地类型' }}
</text>
</view>
</u-form-item>
<u-form-item label="规模" prop="scale" required>
<u-input v-model="formData.scale" placeholder="请输入规模(亩)" border="bottom" type="number">
<template #suffix>
<text class="suffix-text"></text>
</template>
</u-input>
</u-form-item>
<!-- 地址信息 -->
<view class="section-title">地址信息</view>
<u-form-item label="省市区" prop="province" required class="clickable" @click="show.address = true">
<view class="address-display">
<text :class="{ 'placeholder-text': !formData.province }">
{{ formData.province || '请选择省市区' }}
</text>
</view>
</u-form-item>
<u-form-item label="详细地址" prop="detailedAddress" required>
<u-input v-model="formData.detailedAddress" placeholder="请输入详细地址" border="bottom" />
</u-form-item>
<!-- 负责人信息 -->
<view class="section-title">负责人信息</view>
<u-form-item label="负责人姓名" prop="managerName" required>
<u-input v-model="formData.managerName" placeholder="请输入负责人姓名" border="bottom" />
</u-form-item>
<u-form-item label="联系电话" prop="contactPhone" required>
<u-input v-model="formData.contactPhone" placeholder="请输入联系电话" border="bottom" type="number" />
</u-form-item>
<u-form-item label="身份证号" prop="idCard" required>
<u-input v-model="formData.idCard" placeholder="请输入身份证号" border="bottom" />
</u-form-item>
<!-- 经营信息 -->
<view class="section-title">经营信息</view>
<u-form-item label="种植作物" prop="plantedCrops" required>
<u-input v-model="formData.plantedCrops" placeholder="请输入种植作物,多个用逗号分隔" border="bottom" />
</u-form-item>
<u-form-item label="经营年限" prop="operationYears" required>
<u-input v-model="formData.operationYears" placeholder="请输入经营年限" border="bottom" type="number">
<template #suffix>
<text class="suffix-text"></text>
</template>
</u-input>
</u-form-item>
<!-- 基地图片 -->
<view class="section-title">认证材料</view>
<u-form-item label="基地图片" prop="baseImages">
<u-upload
:fileList="formData.baseImages"
@after-read="(e) => afterRead(e, 'baseImages')"
@delete="(e) => deletePic(e, 'baseImages')"
name="1"
multiple
:maxCount="5"
:previewFullImage="true"
/>
</u-form-item>
<u-form-item label="身份证明" prop="identityProveUrl" required>
<div>
<u-upload
:fileList="formData.identityProveUrl"
@after-read="(e) => afterRead(e, 'identityProveUrl')"
@delete="(e) => deletePic(e, 'identityProveUrl')"
name="identityProveUrl"
multiple
:maxCount="2"
:previewFullImage="true"
/>
<div><i>身份证/营业执照图片</i></div>
</div>
</u-form-item>
<u-form-item label="场地证明" prop="landProveUrl" required>
<div>
<u-upload
:fileList="formData.landProveUrl"
@after-read="(e) => afterRead(e, 'landProveUrl')"
@delete="(e) => deletePic(e, 'landProveUrl')"
name="landProveUrl"
multiple
:maxCount="2"
:previewFullImage="true"
/>
<div><i>土地合同/场地照片</i></div>
</div>
</u-form-item>
<u-form-item label="生产证明" prop="productionProveUrl" required>
<div>
<u-upload
:fileList="formData.productionProveUrl"
@after-read="(e) => afterRead(e, 'productionProveUrl')"
@delete="(e) => deletePic(e, 'productionProveUrl')"
name="productionProveUrl"
multiple
:maxCount="2"
:previewFullImage="true"
/>
<div><i>现场作业照片/产品照片</i></div>
</div>
</u-form-item>
<u-form-item label="质量证书">
<div>
<u-upload
:fileList="formData.qualityCertificateUrl"
@after-read="(e) => afterRead(e, 'qualityCertificateUrl')"
@delete="(e) => deletePic(e, 'qualityCertificateUrl')"
name="qualityCertificateUrl"
multiple
:maxCount="2"
:previewFullImage="true"
/>
<div><i>质量认证证书</i></div>
</div>
</u-form-item>
<u-form-item label="其他材料">
<div>
<u-upload
:fileList="formData.otherMaterialUrl"
@after-read="(e) => afterRead(e, 'otherMaterialUrl')"
@delete="(e) => deletePic(e, 'otherMaterialUrl')"
name="otherMaterialUrl"
multiple
:maxCount="2"
:previewFullImage="true"
/>
<div><i>其他补充材料</i></div>
</div>
</u-form-item>
<!-- 提交按钮 -->
<view class="submit-btn-container">
<u-button type="primary" @click="submitForm" :loading="loading">提交</u-button>
</view>
</u-form>
<fui-picker
:show="show.address"
:options="options.address"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="show.address = false"
/>
<fui-picker
:show="show.farmType"
:layer="1"
:linkage="true"
:options="options.farmType"
@change="handleChangeFarmType"
@cancel="show.farmType = false"
/>
</view>
</template>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
padding: 30rpx; padding: 30rpx;
background-color: #f8f9fa; background-color: #f8f9fa;
min-height: 100vh; min-height: 100vh;
} }
.section-title { .section-title {
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
color: #333; color: #333;
margin: 40rpx 0 20rpx 0; margin: 40rpx 0 20rpx 0;
padding-left: 20rpx; padding-left: 20rpx;
border-left: 6rpx solid #5DB66F; border-left: 6rpx solid #5db66f;
} }
.address-display { .address-display {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
...@@ -486,27 +530,27 @@ onLoad((pageOptions) => { ...@@ -486,27 +530,27 @@ onLoad((pageOptions) => {
.placeholder-text { .placeholder-text {
color: #c0c4cc; color: #c0c4cc;
} }
} }
.suffix-text { .suffix-text {
color: #909399; color: #909399;
margin-left: 10rpx; margin-left: 10rpx;
} }
.submit-btn-container { .submit-btn-container {
margin: 60rpx 0; margin: 60rpx 0;
::v-deep .u-button { ::v-deep .u-button {
height: 88rpx; height: 88rpx;
border-radius: 44rpx; border-radius: 44rpx;
font-size: 32rpx; font-size: 32rpx;
background-color: #5DB66F; background-color: #5db66f;
border-color: #5DB66F; border-color: #5db66f;
}
} }
}
// uview-plus 表单样式调整 // uview-plus 表单样式调整
::v-deep .u-form-item { ::v-deep .u-form-item {
margin-bottom: 40rpx; margin-bottom: 40rpx;
.u-form-item__body { .u-form-item__body {
...@@ -529,15 +573,15 @@ onLoad((pageOptions) => { ...@@ -529,15 +573,15 @@ onLoad((pageOptions) => {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
} }
} }
::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;
...@@ -561,23 +605,23 @@ onLoad((pageOptions) => { ...@@ -561,23 +605,23 @@ onLoad((pageOptions) => {
&.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-upload { ::v-deep .u-upload {
margin-top: 10rpx; margin-top: 10rpx;
.u-upload__wrap { .u-upload__wrap {
padding: 0; padding: 0;
} }
} }
// 选择器输入框样式 // 选择器输入框样式
::v-deep .u-input--readonly { ::v-deep .u-input--readonly {
.u-input__content__field-wrapper { .u-input__content__field-wrapper {
background-color: transparent; background-color: transparent;
...@@ -585,10 +629,10 @@ onLoad((pageOptions) => { ...@@ -585,10 +629,10 @@ onLoad((pageOptions) => {
color: #333; color: #333;
} }
} }
} }
// 表单项点击区域样式 // 表单项点击区域样式
::v-deep .u-form-item { ::v-deep .u-form-item {
&.clickable { &.clickable {
cursor: pointer; cursor: pointer;
...@@ -605,5 +649,5 @@ onLoad((pageOptions) => { ...@@ -605,5 +649,5 @@ onLoad((pageOptions) => {
} }
} }
} }
} }
</style> </style>
<script setup lang="ts"> <script setup lang="ts">
import { nextTick, reactive, ref } from 'vue' import { nextTick, reactive, ref } from 'vue'
import { onLoad, onNavigationBarButtonTap, onShow } from '@dcloudio/uni-app' import { onLoad, onNavigationBarButtonTap, onShow } from '@dcloudio/uni-app'
import * as NongchangAPI from '@/api/model/nongchang' import * as NongchangAPI from '@/api/model/nongchang'
const isOnePage = ref(true) const isOnePage = ref(true)
const paging = ref(null) const paging = ref(null)
const pageData = reactive({ const pageData = reactive({
param: { param: {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
...@@ -15,12 +15,12 @@ const pageData = reactive({ ...@@ -15,12 +15,12 @@ const pageData = reactive({
total: 0, // 基地总数 total: 0, // 基地总数
type_success_total: 0, // 已认证 type_success_total: 0, // 已认证
type_unverified_total: 0, // 未认证 type_unverified_total: 0, // 未认证
}) })
onNavigationBarButtonTap((e) => { onNavigationBarButtonTap((e) => {
console.log('onNavigationBarButtonTap', e) console.log('onNavigationBarButtonTap', e)
}) })
onLoad(() => { }) onLoad(() => {})
onShow(() => { onShow(() => {
nextTick(() => { nextTick(() => {
if (!isOnePage.value && paging.value) { if (!isOnePage.value && paging.value) {
paging.value.reload() paging.value.reload()
...@@ -28,9 +28,10 @@ onShow(() => { ...@@ -28,9 +28,10 @@ onShow(() => {
isOnePage.value = false isOnePage.value = false
}) })
}) })
function getList() { function getList() {
if (!paging.value) return if (!paging.value)
return
NongchangAPI.getFarmbaseList(pageData.param) NongchangAPI.getFarmbaseList(pageData.param)
.then((res) => { .then((res) => {
pageData.total = res.total pageData.total = res.total
...@@ -39,31 +40,31 @@ function getList() { ...@@ -39,31 +40,31 @@ function getList() {
.catch(() => { .catch(() => {
paging.value.complete(false) paging.value.complete(false)
}) })
} }
onNavigationBarButtonTap((_) => { onNavigationBarButtonTap((_) => {
uni.navigateTo({ uni.navigateTo({
url: './add', url: './add',
}) })
}) })
function queryList(pageNo, pageSize) { function queryList(pageNo, pageSize) {
pageData.param.pageNo = pageNo pageData.param.pageNo = pageNo
pageData.param.pageSize = pageSize pageData.param.pageSize = pageSize
getList() getList()
} }
function handleSearch() { function handleSearch() {
// 重置页码为1,重新搜索 // 重置页码为1,重新搜索
pageData.param.pageNo = 1 pageData.param.pageNo = 1
if (paging.value) { if (paging.value) {
paging.value.reload() paging.value.reload()
} }
} }
const goDetail = (id) => { function goDetail(id) {
uni.navigateTo({ uni.navigateTo({
url: './add?id=' + id, url: `./add?id=${id}`,
}) })
} }
function del(id) { function del(id) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定删除吗?', content: '确定删除吗?',
...@@ -81,7 +82,7 @@ function del(id) { ...@@ -81,7 +82,7 @@ function del(id) {
} }
}, },
}) })
} }
</script> </script>
<template> <template>
...@@ -90,16 +91,24 @@ function del(id) { ...@@ -90,16 +91,24 @@ function del(id) {
<view class="codefun-flex-col group_3"> <view class="codefun-flex-col group_3">
<view class="codefun-flex-row codefun-items-center section_2"> <view class="codefun-flex-row codefun-items-center section_2">
<image class="image_6" src="/static/images/codefun/6c5c5a3c082b8c60a307d3a7caee623c.png" /> <image class="image_6" src="/static/images/codefun/6c5c5a3c082b8c60a307d3a7caee623c.png" />
<u-input v-model="pageData.param.baseName" placeholder="请输入搜索内容" border="none" class="codefun-ml-8" <u-input
@confirm="handleSearch" /> v-model="pageData.param.baseName"
placeholder="请输入搜索内容"
border="none"
class="codefun-ml-8"
@confirm="handleSearch"
/>
</view> </view>
<view class="codefun-mt-12 codefun-flex-col section_3"> <view class="codefun-mt-12 codefun-flex-col section_3">
<view class="codefun-flex-row codefun-justify-between group_4"> <view class="codefun-flex-row codefun-justify-between group_4">
<view class="codefun-flex-row codefun-self-start"> <view class="codefun-flex-row codefun-self-start">
<image class="codefun-shrink-0 image_7" <image
src="/static/images/codefun/db26a8ae3f4d5f1e0a3f11d8fb5bc491.png" /> class="codefun-shrink-0 image_7"
src="/static/images/codefun/db26a8ae3f4d5f1e0a3f11d8fb5bc491.png"
/>
<view <view
class="codefun-flex-col codefun-items-start codefun-shrink-0 codefun-self-center group_7"> class="codefun-flex-col codefun-items-start codefun-shrink-0 codefun-self-center group_7"
>
<text class="text_5">{{ pageData.total }}</text> <text class="text_5">{{ pageData.total }}</text>
<text class="font_4 text_7 mt-5">总基地数</text> <text class="font_4 text_7 mt-5">总基地数</text>
</view> </view>
...@@ -107,26 +116,34 @@ function del(id) { ...@@ -107,26 +116,34 @@ function del(id) {
</view> </view>
<view class="codefun-flex-col codefun-self-center group_5"> <view class="codefun-flex-col codefun-self-center group_5">
<view class="codefun-flex-row codefun-items-center group_6"> <view class="codefun-flex-row codefun-items-center group_6">
<image class="image_6" <image
src="/static/images/codefun/118c884c539aaba710313f0682db00e1.png" /> class="image_6"
src="/static/images/codefun/118c884c539aaba710313f0682db00e1.png"
/>
<view <view
class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"> class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"
>
<text class="font_3 text_6">已认证:</text> <text class="font_3 text_6">已认证:</text>
</view> </view>
<view <view
class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_2"> class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_2"
>
<text class="font_5">{{ pageData.type_success_total }}</text> <text class="font_5">{{ pageData.type_success_total }}</text>
</view> </view>
</view> </view>
<view class="codefun-flex-row codefun-items-center group_8"> <view class="codefun-flex-row codefun-items-center group_8">
<image class="image_6" <image
src="/static/images/codefun/27ef797870c2085d1a14446c50cf53e0.png" /> class="image_6"
src="/static/images/codefun/27ef797870c2085d1a14446c50cf53e0.png"
/>
<view <view
class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"> class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"
>
<text class="font_3 text_6">待认证:</text> <text class="font_3 text_6">待认证:</text>
</view> </view>
<view <view
class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_3"> class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_3"
>
<text class="font_3 text_8">{{ pageData.type_unverified_total }}</text> <text class="font_3 text_8">{{ pageData.type_unverified_total }}</text>
</view> </view>
</view> </view>
...@@ -136,7 +153,8 @@ function del(id) { ...@@ -136,7 +153,8 @@ function del(id) {
<view class="codefun-flex-row"> <view class="codefun-flex-row">
<image class="image_8" src="/static/images/codefun/c24e87154a833caadfcb70fb24ae52dc.png" /> <image class="image_8" src="/static/images/codefun/c24e87154a833caadfcb70fb24ae52dc.png" />
<view <view
class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-start text-wrapper_4"> class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-start text-wrapper_4"
>
<text class="font_5">基地认证指南</text> <text class="font_5">基地认证指南</text>
</view> </view>
</view> </view>
...@@ -145,11 +163,15 @@ function del(id) { ...@@ -145,11 +163,15 @@ function del(id) {
</view> </view>
<view class="codefun-mt-12 codefun-flex-col section_4" v-if="pageData.list.length"> <view class="codefun-mt-12 codefun-flex-col section_4" v-if="pageData.list.length">
<view class="codefun-flex-col codefun-self-stretch list"> <view class="codefun-flex-col codefun-self-stretch list">
<view class="codefun-flex-row codefun-items-center list-item" <view
v-for="(item, index) in pageData.list" :key="index"> class="codefun-flex-row codefun-items-center list-item"
v-for="(item, index) in pageData.list"
:key="index"
>
<view class="codefun-flex-col codefun-justify-start codefun-items-start section_5"> <view class="codefun-flex-col codefun-justify-start codefun-items-start section_5">
<view <view
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_5"> class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_5"
>
<text class="font_6">{{ item.auditStatus_dictText }}</text> <text class="font_6">{{ item.auditStatus_dictText }}</text>
</view> </view>
</view> </view>
...@@ -162,18 +184,24 @@ function del(id) { ...@@ -162,18 +184,24 @@ function del(id) {
</view> </view>
</view> </view>
<view <view
class="codefun-mt-18 codefun-flex-row codefun-justify-between codefun-items-center group_11"> class="codefun-mt-18 codefun-flex-row codefun-justify-between codefun-items-center group_11"
>
<view class="codefun-flex-row" @click="goDetail(item.id)"> <view class="codefun-flex-row" @click="goDetail(item.id)">
<image class="image_10" <image
src="/static/images/codefun/3566724e23f8a91e60ae87c2744e4090.png" /> class="image_10"
src="/static/images/codefun/3566724e23f8a91e60ae87c2744e4090.png"
/>
<view <view
class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_6"> class="codefun-ml-4 codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_6"
>
<text class="font_7 text_11">详情</text> <text class="font_7 text_11">详情</text>
</view> </view>
</view> </view>
<view class="codefun-flex-row codefun-items-center" @click="del(item.id)"> <view class="codefun-flex-row codefun-items-center" @click="del(item.id)">
<image class="codefun-shrink-0 image_10" <image
src="/static/images/codefun/8630d19ebb6334e2028daa7d7b8b5983.png" /> class="codefun-shrink-0 image_10"
src="/static/images/codefun/8630d19ebb6334e2028daa7d7b8b5983.png"
/>
<text class="font_8 ml-5">删除</text> <text class="font_8 ml-5">删除</text>
</view> </view>
</view> </view>
...@@ -187,31 +215,31 @@ function del(id) { ...@@ -187,31 +215,31 @@ function del(id) {
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
body { body {
background-color: #e6f5e8; background-color: #e6f5e8;
} }
.mt-5 { .mt-5 {
margin-top: 10rpx; margin-top: 10rpx;
} }
.mt-11 { .mt-11 {
margin-top: 22rpx; margin-top: 22rpx;
} }
.ml-5 { .ml-5 {
margin-left: 10rpx; margin-left: 10rpx;
} }
.ml-13 { .ml-13 {
margin-left: 26rpx; margin-left: 26rpx;
} }
.ml-9 { .ml-9 {
margin-left: 18rpx; margin-left: 18rpx;
} }
.page { .page {
background-color: #e6f5e8; background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH; mix-blend-mode: NOTTHROUGH;
width: 100%; width: 100%;
...@@ -674,5 +702,5 @@ body { ...@@ -674,5 +702,5 @@ body {
line-height: 25.76rpx; line-height: 25.76rpx;
color: #ffffff; color: #ffffff;
} }
} }
</style> </style>
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { reactive } from 'vue' import { reactive } from 'vue'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong' import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const { getUserInfo } = useUserStore() const { getUserInfo } = useUserStore()
const pageData = reactive({ const pageData = reactive({
...@@ -62,33 +63,30 @@ ...@@ -62,33 +63,30 @@
close, close,
}) })
</script> </script>
<template> <template>
<fui-dialog title="" :buttons="[]" :show="pageData.show" maskClosable> <fui-dialog title="" :buttons="[]" :show="pageData.show" maskClosable>
<view class="title flex justify-center"> <view class="title flex justify-center">
<view class="flex-1">报名</view> <view class="flex-1">报名</view>
<fui-icon class="close flex-basis" name="close" size="46" color="#999999" @click="close"></fui-icon> <fui-icon class="close flex-basis" name="close" size="46" color="#999999" @click="close" />
</view> </view>
<view class="text-left"> <view class="text-left">
<fui-form ref="formRef"> <fui-form ref="formRef">
<fui-input <fui-input marginTop="30" size="28" placeholder="请填写预留姓名" v-model="pageData.form.reservedname" />
marginTop="30"
size="28"
placeholder="请填写预留姓名"
v-model="pageData.form.reservedname"
></fui-input>
<fui-input <fui-input
marginTop="30" marginTop="30"
size="28" size="28"
placeholder="请填写预留手机" placeholder="请填写预留手机"
v-model="pageData.form.reservedmobile" v-model="pageData.form.reservedmobile"
></fui-input> />
<view style="margin-top: 30rpx"> <view style="margin-top: 30rpx">
<fui-button text="确定" bold radius="96rpx" @click="submit"></fui-button> <fui-button text="确定" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
</view> </view>
</fui-dialog> </fui-dialog>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
:deep(.fui-dialog__body) { :deep(.fui-dialog__body) {
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%);
......
...@@ -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, getTextByCode, getCodeByText } from '@/utils/areaData' import { areaTree, getCodeByText, getTextByCode } from '@/utils/areaData'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore() const dictStore = useDictStore()
...@@ -124,15 +124,15 @@ ...@@ -124,15 +124,15 @@
function initDict() { function initDict() {
pageData.options.area = areaTree pageData.options.area = areaTree
console.log(dictStore.getDictList['purchase_status']) console.log(dictStore.getDictList.purchase_status)
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,
text: item.text, text: item.text,
} }
}) })
pageData.options.type = dictStore.getDictList['employment_type'].map((item) => { pageData.options.type = dictStore.getDictList.employment_type.map((item) => {
return { return {
value: item.value, value: item.value,
text: item.text, text: item.text,
...@@ -141,7 +141,8 @@ ...@@ -141,7 +141,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({
...@@ -152,8 +153,7 @@ ...@@ -152,8 +153,7 @@
pageData.form.city = res.city pageData.form.city = res.city
pageData.form.country = res.country pageData.form.country = res.country
pageData.form.areaText = `${res.province}/${res.city}/${res.country}` pageData.form.areaText = `${res.province}/${res.city}/${res.country}`
pageData.form.area = pageData.form.area = `${getCodeByText(res.province)},${getCodeByText(res.city)},${getCodeByText(res.country)}`
getCodeByText(res.province) + ',' + getCodeByText(res.city) + ',' + getCodeByText(res.country)
}) })
} }
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
.then((res) => { .then((res) => {
console.log(res) console.log(res)
pageData.form = res pageData.form = res
let areaCopy = pageData.form.area.split(',') const areaCopy = pageData.form.area.split(',')
pageData.form.areaText = `${getTextByCode(areaCopy[0])}/${getTextByCode(areaCopy[1])}/${getTextByCode(areaCopy[2])}` pageData.form.areaText = `${getTextByCode(areaCopy[0])}/${getTextByCode(areaCopy[1])}/${getTextByCode(areaCopy[2])}`
pageData.form.urgentdegreeText = pageData.options.urgentdegree.find( pageData.form.urgentdegreeText = pageData.options.urgentdegree.find(
(item) => item.value == pageData.form.urgentdegree, (item) => item.value == pageData.form.urgentdegree,
...@@ -188,8 +188,8 @@ ...@@ -188,8 +188,8 @@
// 返回格式化的对象 // 返回格式化的对象
return { return {
name: fileName, name: fileName,
extname: extname, extname,
url: url, url,
} }
} }
...@@ -221,7 +221,7 @@ ...@@ -221,7 +221,7 @@
// 文件上传 // 文件上传
function handleUpload(file) { function handleUpload(file) {
uni.uploadFile({ uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: file.tempFiles[0].path, filePath: file.tempFiles[0].path,
name: 'file', name: 'file',
formData: { formData: {
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
v-model="form.name" v-model="form.name"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<fui-input <fui-input
required required
label="工作内容" label="工作内容"
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
v-model="form.content" v-model="form.content"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input <fui-input
...@@ -307,7 +307,7 @@ ...@@ -307,7 +307,7 @@
v-model="form.workers" v-model="form.workers"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<fui-input <fui-input
required required
type="number" type="number"
...@@ -317,7 +317,7 @@ ...@@ -317,7 +317,7 @@
v-model="form.price" v-model="form.price"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<fui-input <fui-input
required required
label="类型" label="类型"
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
labelSize="28" labelSize="28"
label-width="180" label-width="180"
@click="show.type = true" @click="show.type = true"
></fui-input> />
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input <fui-input
...@@ -337,7 +337,7 @@ ...@@ -337,7 +337,7 @@
labelSize="28" labelSize="28"
label-width="180" label-width="180"
@click="show.area = true" @click="show.area = true"
></fui-input> />
<fui-input <fui-input
required required
label="详细地址" label="详细地址"
...@@ -345,7 +345,7 @@ ...@@ -345,7 +345,7 @@
v-model="form.address" v-model="form.address"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<fui-input <fui-input
required required
label="紧急程度" label="紧急程度"
...@@ -354,7 +354,7 @@ ...@@ -354,7 +354,7 @@
labelSize="28" labelSize="28"
label-width="180" label-width="180"
@click="show.urgentdegree = true" @click="show.urgentdegree = true"
></fui-input> />
<!-- 时间范围 --> <!-- 时间范围 -->
<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">
...@@ -384,27 +384,17 @@ ...@@ -384,27 +384,17 @@
:auto-upload="false" :auto-upload="false"
@select="handleUpload" @select="handleUpload"
@delete="handleDelete" @delete="handleDelete"
></uni-file-picker> />
</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> <fui-button text="发布用工" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
</view> </view>
</view> </view>
<fui-date-picker <fui-date-picker :show="show.time1" type="3" @change="handleChangeTime1" @cancel="show.time1 = false" />
:show="show.time1" <fui-date-picker :show="show.time2" type="3" @change="handleChangeTime2" @cancel="show.time2 = false" />
type="3"
@change="handleChangeTime1"
@cancel="show.time1 = false"
></fui-date-picker>
<fui-date-picker
:show="show.time2"
type="3"
@change="handleChangeTime2"
@cancel="show.time2 = false"
></fui-date-picker>
<fui-picker <fui-picker
:show="show.type" :show="show.type"
:layer="1" :layer="1"
...@@ -412,7 +402,7 @@ ...@@ -412,7 +402,7 @@
:options="options.type" :options="options.type"
@change="handleChangetype" @change="handleChangetype"
@cancel="show.type = false" @cancel="show.type = false"
></fui-picker> />
<fui-picker <fui-picker
:show="show.urgentdegree" :show="show.urgentdegree"
:layer="1" :layer="1"
...@@ -420,7 +410,7 @@ ...@@ -420,7 +410,7 @@
:options="options.urgentdegree" :options="options.urgentdegree"
@change="handleChangeUrgentdegree" @change="handleChangeUrgentdegree"
@cancel="show.urgentdegree = false" @cancel="show.urgentdegree = false"
></fui-picker> />
<fui-picker <fui-picker
:show="show.area" :show="show.area"
:options="options.area" :options="options.area"
...@@ -428,10 +418,10 @@ ...@@ -428,10 +418,10 @@
:layer="3" :layer="3"
@change="handleChangeAddress" @change="handleChangeAddress"
@cancel="show.area = false" @cancel="show.area = false"
></fui-picker> />
<fui-toast ref="toastRef"></fui-toast> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
<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 RegisterDialog from './components/register-dialog.vue' import RegisterDialog from './components/register-dialog.vue'
import { onPullDownRefresh, onLoad, onShow, onReachBottom } from '@dcloudio/uni-app' import { getTextByCode } from '@/utils/areaData'
import { areaTree, getTextByCode, getCodeByText } 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'
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
item.area = areaCache.get(cacheKey) item.area = areaCache.get(cacheKey)
} else { } else {
const areaCodes = item.area.split(',') const areaCodes = item.area.split(',')
const areaText = getTextByCode(areaCodes[0]) + ' ' + getTextByCode(areaCodes[1]) const areaText = `${getTextByCode(areaCodes[0])} ${getTextByCode(areaCodes[1])}`
areaCache.set(cacheKey, areaText) areaCache.set(cacheKey, areaText)
item.area = areaText item.area = areaText
} }
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
function onEmploymentItemClick(item: any) { function onEmploymentItemClick(item: any) {
console.log('点击用工项:', item) console.log('点击用工项:', item)
// 在这里添加具体的用工项点击逻辑 // 在这里添加具体的用工项点击逻辑
Navigate.to('/pages/linghuoyonggong/form?id=' + item.id) Navigate.to(`/pages/linghuoyonggong/form?id=${item.id}`)
} }
// "我想去"按钮点击事件 // "我想去"按钮点击事件
...@@ -270,7 +270,7 @@ ...@@ -270,7 +270,7 @@
// 检查日期是否有效 // 检查日期是否有效
if (isNaN(d1.getTime()) || isNaN(d2.getTime())) { if (isNaN(d1.getTime()) || isNaN(d2.getTime())) {
throw new Error('无效的日期格式') throw new TypeError('无效的日期格式')
} }
// 设置时间部分为00:00:00,只比较日期部分 // 设置时间部分为00:00:00,只比较日期部分
...@@ -287,7 +287,8 @@ ...@@ -287,7 +287,8 @@
} }
onReachBottom(() => { onReachBottom(() => {
console.log('触底了') console.log('触底了')
if (pageData.total <= pageData.employmentList.length) return if (pageData.total <= pageData.employmentList.length)
return
pageData.search.pageNo++ pageData.search.pageNo++
getEmploymentList() getEmploymentList()
}) })
...@@ -325,7 +326,7 @@ ...@@ -325,7 +326,7 @@
</view> </view>
<view class="codefun-flex-col codefun-relative list"> <view class="codefun-flex-col codefun-relative list">
<view v-if="!pageData.employmentList || pageData.employmentList.length == 0" style="height: 700rpx"> <view v-if="!pageData.employmentList || pageData.employmentList.length == 0" style="height: 700rpx">
<fui-empty marginTop="100" src="/src/static/images/no-data.png" title="暂无数据"></fui-empty> <fui-empty marginTop="100" src="/src/static/images/no-data.png" title="暂无数据" />
</view> </view>
<template v-else> <template v-else>
<view <view
...@@ -393,12 +394,12 @@ ...@@ -393,12 +394,12 @@
<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">
<!-- <image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image> --> <!-- <image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image> -->
<view class="fab-icon"></view> <view class="fab-icon" />
<view style="font-size: 24rpx">发布</view> <view style="font-size: 24rpx">发布</view>
</view> </view>
</fui-fab> </fui-fab>
<register-dialog ref="registerDialogRef"></register-dialog> <RegisterDialog ref="registerDialogRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
}) })
// 页面数据 // 页面数据
const defaultText = '湖南省农业服务平台' const defaultText = '数字农服'
const readConfirmShow = ref<boolean>(false) const readConfirmShow = ref<boolean>(false)
const form = ref() const form = ref()
const model = reactive({ const model = reactive({
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
:loading="model.loading" :loading="model.loading"
/> />
</view> </view>
<view class="flex-center p-32rpx box-border btn-register" @click="goRegister"> 立即注册 </view> <view class="flex-center p-32rpx box-border btn-register" @click="goRegister"> 还没有账号,立即注册 </view>
</fui-form> </fui-form>
<!-- </view> --> <!-- </view> -->
<fui-checkbox-group class="checkbox" name="checkbox"> <fui-checkbox-group class="checkbox" name="checkbox">
...@@ -464,6 +464,7 @@ ...@@ -464,6 +464,7 @@
:deep(.fui-input__border-bottom) { :deep(.fui-input__border-bottom) {
right: 32rpx !important; right: 32rpx !important;
} }
.btn-register { .btn-register {
color: cadetblue; color: cadetblue;
} }
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
// 注册参数 // 注册参数
const params = { const params = {
phone: model.form.data.phone, phone: model.form.data.phone,
password: model.form.data.password, password: model.form.data.password || '123@2025',
code: model.form.data.code, code: model.form.data.code,
} }
...@@ -179,6 +179,7 @@ ...@@ -179,6 +179,7 @@
<template> <template>
<view class="warp"> <view class="warp">
<!-- <image class="login-warp" src="/static/login/login_bg.png" /> --> <!-- <image class="login-warp" src="/static/login/login_bg.png" /> -->
<view class="register-form">
<view class="register-bg-wrap"> <view class="register-bg-wrap">
<!-- <image class="register-bg" src="/static/images/register/register.png" /> --> <!-- <image class="register-bg" src="/static/images/register/register.png" /> -->
<view class="logo-content-wrap"> <view class="logo-content-wrap">
...@@ -186,7 +187,6 @@ ...@@ -186,7 +187,6 @@
<view class="logo-text">数字农业服务平台</view> <view class="logo-text">数字农业服务平台</view>
</view> </view>
</view> </view>
<view class="register-form">
<fui-form class="form" ref="form" top="50" :padding="['0rpx', '32rpx']"> <fui-form class="form" ref="form" top="50" :padding="['0rpx', '32rpx']">
<view class="reigister-form-item"> <view class="reigister-form-item">
<image class="reigister-form-image" src="/static/images/register/user.png" /> <image class="reigister-form-image" src="/static/images/register/user.png" />
...@@ -207,13 +207,13 @@ ...@@ -207,13 +207,13 @@
maxlength="11" maxlength="11"
/> />
<view class="reigister-form-item"> <view class="reigister-form-item !hidden">
<image class="reigister-form-image" src="/static/images/register/pwd.png" /> <image class="reigister-form-image" src="/static/images/register/pwd.png" />
<text>密码</text> <text>密码</text>
</view> </view>
<fui-input <fui-input
height="100rpx" height="100rpx"
class="input" class="input !hidden"
password password
autocomplete="new-password" autocomplete="new-password"
code code
...@@ -321,30 +321,33 @@ ...@@ -321,30 +321,33 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background-image: url(/static/images/register/register.png); background-image: url('/static/images/register/register.png');
background-size: 100% 100%; background-size: 100% 100%;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
.logo-content-wrap { .logo-content-wrap {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: left; justify-content: left;
align-items: flex-start; align-items: flex-start;
width: 86%; width: 86%;
.logo-text-1 { .logo-text-1 {
font-size: 30rpx; font-size: 30rpx;
font-weight: 400; font-weight: 400;
letter-spacing: 0px; letter-spacing: 0;
margin-top: 4.25rem; margin-top: 4.25rem;
color: rgba(51, 51, 51, 0.7); color: rgb(51 51 51 / 70%);
vertical-align: middle; vertical-align: middle;
} }
.logo-text { .logo-text {
font-size: 40rpx; font-size: 40rpx;
font-weight: 500; font-weight: 500;
letter-spacing: 0px; letter-spacing: 0;
margin-top: 40rpx; margin-top: 40rpx;
color: rgba(51, 51, 51, 1); color: rgb(51 51 51 / 100%);
vertical-align: middle; vertical-align: middle;
} }
} }
...@@ -354,18 +357,19 @@ ...@@ -354,18 +357,19 @@
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 60vh; height: 60vh;
left: 0px; left: 0;
top: 450rpx; top: 0;
opacity: 1; opacity: 1;
border-radius: 14.03px 14.03px 0px 0px; border-radius: 14.03px 14.03px 0 0;
border: 1px solid #fff; border: 1px solid #fff;
background: linear-gradient( background: linear-gradient(
180deg, 180deg,
rgba(181, 238, 215, 1) 0%, rgb(181 238 215 / 100%) 0%,
rgba(181, 238, 215, 0.5) 30%, rgb(181 238 215 / 50%) 30%,
rgba(255, 255, 255, 0.8) 100% rgb(255 255 255 / 80%) 100%
); );
} }
.reigister-form-item { .reigister-form-item {
color: #000; color: #000;
display: flex; display: flex;
...@@ -373,10 +377,12 @@ ...@@ -373,10 +377,12 @@
justify-content: left; justify-content: left;
align-items: center; align-items: center;
margin: 10rpx; margin: 10rpx;
.reigister-form-image { .reigister-form-image {
width: 60rpx; width: 60rpx;
height: 60rpx; height: 60rpx;
} }
text { text {
font-size: 32rpx; font-size: 32rpx;
display: flex; display: flex;
...@@ -384,11 +390,11 @@ ...@@ -384,11 +390,11 @@
margin-left: 20rpx; margin-left: 20rpx;
} }
} }
.form { .form {
position: absolute;
top: 80rpx;
width: 100%; width: 100%;
z-index: 10; z-index: 10;
margin-top: 540rpx;
} }
.checkbox { .checkbox {
...@@ -421,6 +427,7 @@ ...@@ -421,6 +427,7 @@
:deep(.fui-input__border-bottom) { :deep(.fui-input__border-bottom) {
right: 32rpx !important; right: 32rpx !important;
} }
.btn-register { .btn-register {
color: cadetblue; color: cadetblue;
} }
......
<script setup lang="ts"> <script setup lang="ts">
import { useRuntime } from '@/hooks/app/useRuntime' import { useRuntime } from '@/hooks/app/useRuntime'
import { convertKB } from '@/utils' import { convertKB } from '@/utils'
import { calculateCacheSize, cleanCache } from '@/components/CacheImage/index' import { calculateCacheSize, cleanCache } from '@/components/CacheImage/index'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { useFarmStore } from '@/store/modules/farm' import { useFarmStore } from '@/store/modules/farm'
import { checkUpgrade } from '@/utils/upgrade' import { checkUpgrade } from '@/utils/upgrade'
import * as NongchangAPI from '@/api/model/nongchang' import * as NongchangAPI from '@/api/model/nongchang'
// import { Permissions, usePermissions } from '@/components/Permissions' // import { Permissions, usePermissions } from '@/components/Permissions'
// import { useUserPermissions } from '@/utils/auth' // import { useUserPermissions } from '@/utils/auth'
// const [registerPermissions, { request }] = usePermissions() // const [registerPermissions, { request }] = usePermissions()
const userStore = useUserStore() const userStore = useUserStore()
const farmStore = useFarmStore() const farmStore = useFarmStore()
const { app } = useRuntime() const { app } = useRuntime()
const version = computed(() => app.value.version) const version = computed(() => app.value.version)
onShow(() => { onShow(() => {
const { id, realname, phone, avatar } = userStore.getUserInfo const { id, realname, phone, avatar } = userStore.getUserInfo
model.id = id model.id = id
model.realname = realname model.realname = realname
...@@ -26,34 +26,34 @@ onShow(() => { ...@@ -26,34 +26,34 @@ onShow(() => {
if (avatar) { if (avatar) {
model.avatar = avatar model.avatar = avatar
} }
}) })
// 个人信息 // 个人信息
function navMsg() { function navMsg() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/mine/components/myMessage', url: '/pages/mine/components/myMessage',
}) })
} }
// 退出登录 // 退出登录
function logOut() { function logOut() {
Message.confirm('确认退出登录状态?', '温馨提示').then((confirm) => { Message.confirm('确认退出登录状态?', '温馨提示').then((confirm) => {
if (confirm) { if (confirm) {
loginOut() loginOut()
} }
}) })
} }
// 调用登出 // 调用登出
function loginOut() { function loginOut() {
model.loading = true model.loading = true
userStore.logout().finally(() => { userStore.logout().finally(() => {
model.loading = false model.loading = false
}) })
} }
/** /**
* 计算缓存 * 计算缓存
*/ */
function calculateCache() { function calculateCache() {
// 重新计算 // 重新计算
const cacheIamgeSizeTotal = calculateCacheSize() const cacheIamgeSizeTotal = calculateCacheSize()
const { size: currentStorageSize, unit: currentStorageSizeUnit } = convertKB(cacheIamgeSizeTotal / 1024) const { size: currentStorageSize, unit: currentStorageSizeUnit } = convertKB(cacheIamgeSizeTotal / 1024)
...@@ -61,9 +61,9 @@ function calculateCache() { ...@@ -61,9 +61,9 @@ function calculateCache() {
// 更新视图 // 更新视图
items.find((item) => item.title === '系统缓存清除').suffix = items.find((item) => item.title === '系统缓存清除').suffix =
Number(currentStorageSize) === 0 ? '' : `${currentStorageSize}${currentStorageSizeUnit}` Number(currentStorageSize) === 0 ? '' : `${currentStorageSize}${currentStorageSizeUnit}`
} }
const model = reactive({ const model = reactive({
id: '', id: '',
avatar: '/static/logo.png', avatar: '/static/logo.png',
realname: '', realname: '',
...@@ -73,16 +73,16 @@ const model = reactive({ ...@@ -73,16 +73,16 @@ const model = reactive({
state: '', state: '',
version: '', version: '',
loading: false, loading: false,
}) })
// 用户默认层级 // 用户默认层级
// const { isPermission } = useUserPermissions('user_default_zIndex_btn') // const { isPermission } = useUserPermissions('user_default_zIndex_btn')
// 用户应急管理 // 用户应急管理
// const { isPermission: emergencyPermission } = useUserPermissions('emergency_response_btn') // const { isPermission: emergencyPermission } = useUserPermissions('emergency_response_btn')
const pageData = reactive({ const pageData = reactive({
farmsListTotal: 0, farmsListTotal: 0,
}) })
const items = reactive<Recordable[]>([ const items = reactive<Recordable[]>([
{ {
title: '我的农场', title: '我的农场',
icon: 'nongchang2', icon: 'nongchang2',
...@@ -176,9 +176,9 @@ const items = reactive<Recordable[]>([ ...@@ -176,9 +176,9 @@ const items = reactive<Recordable[]>([
}) })
}, },
}, },
]) ])
function getFarmsList() { function getFarmsList() {
NongchangAPI.farmsList({ NongchangAPI.farmsList({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
...@@ -186,71 +186,116 @@ function getFarmsList() { ...@@ -186,71 +186,116 @@ function getFarmsList() {
console.log(res) console.log(res)
const { total } = res const { total } = res
pageData.farmsListTotal = total pageData.farmsListTotal = total
if(res.records.length){ if (res.records.length) {
farmStore.setFarmInfo(res.records[0]) farmStore.setFarmInfo(res.records[0])
} }
}) })
} }
onShow(() => { onShow(() => {
getFarmsList() getFarmsList()
// 计算缓存 // 计算缓存
calculateCache() calculateCache()
}) })
watch( watch(
() => version.value, () => version.value,
(value) => { (value) => {
if (value) { if (value) {
items.find((item) => item.title === '系统检查更新').suffix = `v${value}` items.find((item) => item.title === '系统检查更新').suffix = `v${value}`
} }
}, },
) )
</script> </script>
<template> <template>
<view class="main page-bg"> <view class="main page-bg">
<view class="w-full h-250 flex flex-row items-center avatar pt-44px pl-6"> <view class="w-full h-250 flex flex-row items-center avatar pt-44px pl-6">
<CacheImage :src="model.avatar" width="150" height="150" radius="999" background="transparent" <CacheImage
style="box-shadow: 0 0 10rpx #cdcdcd" @click="navMsg" /> :src="model.avatar"
width="150"
height="150"
radius="999"
background="transparent"
style="box-shadow: 0 0 10rpx #cdcdcd"
@click="navMsg"
/>
<view class="flex flex-col ml-50rpx"> <view class="flex flex-col ml-50rpx">
<text class="text-#fff" style="text-shadow: 0 0 10rpx #888">{{ model.realname }}</text> <text class="text-#fff" style="text-shadow: 0 0 10rpx #888">{{ model.realname }}</text>
<view class="max-w-400rpx mt-20rpx flex-center"> <view class="max-w-400rpx mt-20rpx flex-center">
<fui-overflow-hidden width="100%" size="24" color="#fff" <fui-overflow-hidden
:text="model.phone ? `${model.phone}` : '- -'" /> width="100%"
size="24"
color="#fff"
:text="model.phone ? `${model.phone}` : '- -'"
/>
</view> </view>
</view> </view>
</view> </view>
<view class="px-6 pt-6"> <view class="px-6 pt-6">
<fui-list class="rd-3 overflow-hidden shadow" :top-border="false"> <fui-list class="rd-3 overflow-hidden shadow" :top-border="false">
<fui-list-cell arrow v-for="(item, index) in items.slice(0, 2)" :key="index" :bottom-border="false" <fui-list-cell
:class="{ disabled: item.disabled }" v-show="item.show" @tap="item.handle(item)"> arrow
<CacheImage :src="`/static/images/mine/${item.icon}.png`" width="42" height="42" v-for="(item, index) in items.slice(0, 2)"
background="transparent" /> :key="index"
:bottom-border="false"
:class="{ disabled: item.disabled }"
v-show="item.show"
@tap="item.handle(item)"
>
<CacheImage
:src="`/static/images/mine/${item.icon}.png`"
width="42"
height="42"
background="transparent"
/>
<text class="ml-3.5 text-30 text-#67c17a font-bold">{{ item.title }}</text> <text class="ml-3.5 text-30 text-#67c17a font-bold">{{ item.title }}</text>
<text v-show="index === 0 && pageData.farmsListTotal === 0" class="text-red">({{ <text v-show="index === 0 && pageData.farmsListTotal === 0" class="text-red"
pageData.farmsListTotal || 0 }})</text> >({{ pageData.farmsListTotal || 0 }})</text
<view v-show="index === 0 && pageData.farmsListTotal === 0" class="text-red flex-1 text-right">去添加 >
<view v-show="index === 0 && pageData.farmsListTotal === 0" class="text-red flex-1 text-right"
>去添加
</view> </view>
</fui-list-cell> </fui-list-cell>
</fui-list> </fui-list>
<fui-list class="rd-3 overflow-hidden shadow !mt-20rpx" :top-border="false"> <fui-list class="rd-3 overflow-hidden shadow !mt-20rpx" :top-border="false">
<fui-list-cell arrow v-for="(item, index) in items.slice(2, 10)" :key="index" :bottom-border="false" <fui-list-cell
class="pos-relative" :class="{ disabled: item.disabled }" v-show="item.show" arrow
@tap="item.handle(item)"> v-for="(item, index) in items.slice(2, 10)"
<CacheImage :src="`/static/images/mine/${item.icon}.png`" width="42" height="42" :key="index"
background="transparent" /> :bottom-border="false"
class="pos-relative"
:class="{ disabled: item.disabled }"
v-show="item.show"
@tap="item.handle(item)"
>
<CacheImage
:src="`/static/images/mine/${item.icon}.png`"
width="42"
height="42"
background="transparent"
/>
<text class="ml-3.5 text-30 text-#333333 font-500">{{ item.title }}</text> <text class="ml-3.5 text-30 text-#333333 font-500">{{ item.title }}</text>
<text v-if="item.suffix" class="pos-absolute right-70" <text
:style="{ color: item.icon === 'call' ? '#1890FF' : '#999' }"> v-if="item.suffix"
class="pos-absolute right-70"
:style="{ color: item.icon === 'call' ? '#1890FF' : '#999' }"
>
{{ item.suffix }} {{ item.suffix }}
</text> </text>
</fui-list-cell> </fui-list-cell>
</fui-list> </fui-list>
</view> </view>
<view class="p-6 pt-5 pb-2"> <view class="p-6 pt-5 pb-2">
<fui-button class="shadow" background="#fff" radius="18rpx" color="#4da25b" @click="logOut" <fui-button
:disabled="model.loading" :loading="model.loading"> class="shadow"
background="#fff"
radius="18rpx"
color="#4da25b"
@click="logOut"
:disabled="model.loading"
:loading="model.loading"
>
退出登录 退出登录
</fui-button> </fui-button>
</view> </view>
...@@ -260,20 +305,20 @@ watch( ...@@ -260,20 +305,20 @@ watch(
</template> </template>
<style lang="less" scoped> <style lang="less" scoped>
.main { .main {
width: 100%; width: 100%;
height: 100%; height: 100%;
// #ifdef H5 // #ifdef H5
height: calc(100vh - 60px); height: calc(100vh - 60px);
// #endif // #endif
} }
.page-bg { .page-bg {
background: url('/static/images/codefun/7a5dc4ee864fe55da98b41c14ee3b931.png') no-repeat top center; background: url('/static/images/codefun/7a5dc4ee864fe55da98b41c14ee3b931.png') no-repeat top center;
background-size: 100%; background-size: 100%;
} }
.userInfo_box { .userInfo_box {
background: #fff; background: #fff;
padding: 32rpx 30rpx; padding: 32rpx 30rpx;
display: flex; display: flex;
...@@ -287,41 +332,41 @@ watch( ...@@ -287,41 +332,41 @@ watch(
flex-direction: column; flex-direction: column;
justify-content: space-around; justify-content: space-around;
} }
} }
.fui-color-border { .fui-color-border {
border-color: #fff; border-color: #fff;
} }
.me_action { .me_action {
margin-top: 20rpx; margin-top: 20rpx;
} }
.fui-list__item { .fui-list__item {
flex: 1; flex: 1;
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.fui-text__explain { .fui-text__explain {
font-size: 28rpx; font-size: 28rpx;
color: #7f7f7f; color: #7f7f7f;
flex-shrink: 0; flex-shrink: 0;
} }
.fui-list__img { .fui-list__img {
width: 48rpx; width: 48rpx;
height: 48rpx; height: 48rpx;
margin-right: 10rpx; margin-right: 10rpx;
} }
.action_text { .action_text {
font-size: 32rpx; font-size: 32rpx;
} }
.loginout { .loginout {
height: 104rpx; height: 104rpx;
background: #fff; background: #fff;
font-weight: 400; font-weight: 400;
...@@ -330,14 +375,14 @@ watch( ...@@ -330,14 +375,14 @@ watch(
text-align: center; text-align: center;
line-height: 104rpx; line-height: 104rpx;
margin-top: 20rpx; margin-top: 20rpx;
} }
.avatar { .avatar {
font-weight: bold; font-weight: bold;
color: #fff; color: #fff;
} }
.border-bottom { .border-bottom {
&.disabled { &.disabled {
pointer-events: none; pointer-events: none;
...@@ -345,5 +390,5 @@ watch( ...@@ -345,5 +390,5 @@ watch(
color: gray; color: gray;
} }
} }
} }
</style> </style>
<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 { 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'
...@@ -112,13 +112,13 @@ ...@@ -112,13 +112,13 @@
function initDict() { function initDict() {
pageData.options.address = areaTree pageData.options.address = areaTree
pageData.options.mainProducts = dictStore.getDictList['main_business'].map((item) => { pageData.options.mainProducts = dictStore.getDictList.main_business.map((item) => {
return { return {
value: item.value, value: item.value,
text: item.text, text: item.text,
} }
}) })
pageData.options.farmType = dictStore.getDictList['farm_type'].map((item) => { pageData.options.farmType = dictStore.getDictList.farm_type.map((item) => {
return { return {
value: item.value, value: item.value,
text: item.text, text: item.text,
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
function handleUpload(file) { function handleUpload(file) {
pageData.loading = true pageData.loading = true
uni.uploadFile({ uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: file.tempFiles[0].path, filePath: file.tempFiles[0].path,
name: 'file', name: 'file',
formData: { formData: {
...@@ -212,38 +212,21 @@ ...@@ -212,38 +212,21 @@
<template> <template>
<fui-form ref="formRef"> <fui-form ref="formRef">
<fui-input required label="农场名称" placeholder="请输入农场名称" v-model="form.farmName"></fui-input> <fui-input required label="农场名称" placeholder="请输入农场名称" v-model="form.farmName" />
<fui-input required label="农场标语" placeholder="请输入农场标语" v-model="form.title"></fui-input> <fui-input required label="农场标语" placeholder="请输入农场标语" v-model="form.title" />
<fui-input <fui-input
required required
label="农场类型" label="农场类型"
placeholder="请选择农场类型" placeholder="请选择农场类型"
v-model="form.farmTypeText" v-model="form.farmTypeText"
@click="show.farmType = true" @click="show.farmType = true"
></fui-input> />
<fui-input required label="联系人" placeholder="请输入联系人" v-model="form.contactPerson"></fui-input> <fui-input required label="联系人" placeholder="请输入联系人" v-model="form.contactPerson" />
<fui-input required label="联系电话" placeholder="请输入联系电话" v-model="form.contactPhone"></fui-input> <fui-input required label="联系电话" placeholder="请输入联系电话" v-model="form.contactPhone" />
<fui-textarea <fui-textarea required label="农场描述" placeholder="请输入农场描述" v-model="pageData.form.description" />
required <fui-input required label="地区" placeholder="请选择地区" v-model="form.address" @click="show.address = true" />
label="农场描述" <fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.addressDetail" />
placeholder="请输入农场描述" <fui-input required label="主营业务" borderTop placeholder="请输入主营业务" v-model="form.mainBusiness" />
v-model="pageData.form.description"
></fui-textarea>
<fui-input
required
label="地区"
placeholder="请选择地区"
v-model="form.address"
@click="show.address = true"
></fui-input>
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.addressDetail"></fui-input>
<fui-input
required
label="主营业务"
borderTop
placeholder="请输入主营业务"
v-model="form.mainBusiness"
></fui-input>
<fui-input <fui-input
required required
label="主要产品" label="主要产品"
...@@ -251,14 +234,8 @@ ...@@ -251,14 +234,8 @@
placeholder="请选择主要产品" placeholder="请选择主要产品"
v-model="form.mainProductsText" v-model="form.mainProductsText"
@click="show.mainProducts = true" @click="show.mainProducts = true"
></fui-input> />
<fui-input <fui-input required label="总面积(亩)" borderTop placeholder="请输入总面积" v-model="form.totalArea" />
required
label="总面积(亩)"
borderTop
placeholder="请输入总面积"
v-model="form.totalArea"
></fui-input>
<view class="bg-white" style="padding: 0.875rem 0.35rem"> <view class="bg-white" style="padding: 0.875rem 0.35rem">
<view class="mb-1 flex justify-start"> 封面图片 </view> <view class="mb-1 flex justify-start"> 封面图片 </view>
<uni-file-picker <uni-file-picker
...@@ -267,10 +244,10 @@ ...@@ -267,10 +244,10 @@
:auto-upload="false" :auto-upload="false"
@select="handleUpload" @select="handleUpload"
@delete="handleDelete" @delete="handleDelete"
></uni-file-picker> />
</view> </view>
<view class="fui-btn__box bg-white p-4"> <view class="fui-btn__box bg-white p-4">
<fui-button text="添加农场" bold radius="96rpx" @click="submit"></fui-button> <fui-button text="添加农场" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
...@@ -281,7 +258,7 @@ ...@@ -281,7 +258,7 @@
:options="options.farmType" :options="options.farmType"
@change="handleChangeFarmType" @change="handleChangeFarmType"
@cancel="show.farmType = false" @cancel="show.farmType = false"
></fui-picker> />
<fui-picker <fui-picker
:show="show.mainProducts" :show="show.mainProducts"
:layer="1" :layer="1"
...@@ -289,7 +266,7 @@ ...@@ -289,7 +266,7 @@
:options="options.mainProducts" :options="options.mainProducts"
@change="handleChangeMainProducts" @change="handleChangeMainProducts"
@cancel="show.mainProducts = false" @cancel="show.mainProducts = false"
></fui-picker> />
<fui-picker <fui-picker
:show="show.address" :show="show.address"
:options="options.address" :options="options.address"
...@@ -297,10 +274,10 @@ ...@@ -297,10 +274,10 @@
:layer="3" :layer="3"
@change="handleChangeAddress" @change="handleChangeAddress"
@cancel="show.address = false" @cancel="show.address = false"
></fui-picker> />
<fui-toast ref="toastRef"></fui-toast> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue' import { reactive } from 'vue'
import * as NongjifuwuAPI from '@/api/model/nongjifuwu' import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
import { getCurrentDate } from '@/utils/date'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
const { getUserInfo } = useUserStore() const { getUserInfo } = useUserStore()
const pageData = reactive({ const pageData = reactive({
...@@ -112,60 +112,36 @@ ...@@ -112,60 +112,36 @@
close, close,
}) })
</script> </script>
<template> <template>
<fui-dialog title="" :buttons="[]" :show="pageData.show" maskClosable> <fui-dialog title="" :buttons="[]" :show="pageData.show" maskClosable>
<view class="title flex justify-center"> <view class="title flex justify-center">
<view class="flex-1">我有需要</view> <view class="flex-1">我有需要</view>
<fui-icon class="close flex-basis" name="close" size="46" color="#999999" @click="close"></fui-icon> <fui-icon class="close flex-basis" name="close" size="46" color="#999999" @click="close" />
</view> </view>
<view class="text-left"> <view class="text-left">
<fui-form ref="formRef"> <fui-form ref="formRef">
<fui-input <fui-input marginTop="30" size="24" placeholder="请填写预留手机" v-model="pageData.form.phone" />
marginTop="30" <fui-input marginTop="30" size="24" placeholder="请填写作业地区" v-model="pageData.form.scope" />
size="24" <fui-input marginTop="30" size="24" placeholder="请填写作业详细地址" v-model="pageData.form.address" />
placeholder="请填写预留手机"
v-model="pageData.form.phone"
></fui-input>
<fui-input
marginTop="30"
size="24"
placeholder="请填写作业地区"
v-model="pageData.form.scope"
></fui-input>
<fui-input
marginTop="30"
size="24"
placeholder="请填写作业详细地址"
v-model="pageData.form.address"
></fui-input>
<fui-input <fui-input
marginTop="30" marginTop="30"
size="24" size="24"
placeholder="请选择作业时间" placeholder="请选择作业时间"
v-model="pageData.form.time" v-model="pageData.form.time"
@click="dict.show.time = true" @click="dict.show.time = true"
></fui-input> />
<fui-textarea <fui-textarea v-model="pageData.form.demand" :marginTop="30" size="24" placeholder="简要说明作业需求" />
v-model="pageData.form.demand"
:marginTop="30"
size="24"
placeholder="简要说明作业需求"
></fui-textarea>
<view style="margin-top: 30rpx"> <view style="margin-top: 30rpx">
<fui-button type="warning" text="确定" bold radius="96rpx" @click="submit"></fui-button> <fui-button type="warning" text="确定" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
</view> </view>
</fui-dialog> </fui-dialog>
<fui-date-picker <fui-date-picker :show="dict.show.time" type="3" range @change="handleTimeChange" @cancel="handleTimeCancel" />
:show="dict.show.time"
type="3"
range
@change="handleTimeChange"
@cancel="handleTimeCancel"
></fui-date-picker>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
:deep(.fui-dialog__body) { :deep(.fui-dialog__body) {
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%);
......
...@@ -124,8 +124,8 @@ ...@@ -124,8 +124,8 @@
// 返回格式化的对象 // 返回格式化的对象
return { return {
name: fileName, name: fileName,
extname: extname, extname,
url: url, url,
} }
} }
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
// 文件上传 // 文件上传
function handleUpload(file) { function handleUpload(file) {
uni.uploadFile({ uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: file.tempFiles[0].path, filePath: file.tempFiles[0].path,
name: 'file', name: 'file',
formData: { formData: {
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
v-model="form.name" v-model="form.name"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<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">
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
v-model="form.address" v-model="form.address"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<fui-input <fui-input
required required
label="联系方式" label="联系方式"
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
v-model="form.phone" v-model="form.phone"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
</view> </view>
<view class="mt20"> <view class="mt20">
<fui-input <fui-input
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
v-model="form.demand" v-model="form.demand"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<!-- 作业时间 --> <!-- 作业时间 -->
<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">
...@@ -286,10 +286,10 @@ ...@@ -286,10 +286,10 @@
:auto-upload="false" :auto-upload="false"
@select="handleUpload" @select="handleUpload"
@delete="handleDelete" @delete="handleDelete"
></uni-file-picker> />
</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> <fui-button text="发布作业" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
...@@ -299,17 +299,17 @@ ...@@ -299,17 +299,17 @@
@change="handleChangeTime1" @change="handleChangeTime1"
@cancel="show.time1 = false" @cancel="show.time1 = false"
minDate="2025-01-01" minDate="2025-01-01"
></fui-date-picker> />
<fui-date-picker <fui-date-picker
:show="show.time2" :show="show.time2"
type="3" type="3"
@change="handleChangeTime2" @change="handleChangeTime2"
@cancel="show.time2 = false" @cancel="show.time2 = false"
minDate="2025-01-01" minDate="2025-01-01"
></fui-date-picker> />
<fui-toast ref="toastRef"></fui-toast> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
<fui-picker <fui-picker
:show="show.address" :show="show.address"
:options="options.address" :options="options.address"
...@@ -317,7 +317,7 @@ ...@@ -317,7 +317,7 @@
:layer="3" :layer="3"
@change="handleChangeAddress" @change="handleChangeAddress"
@cancel="show.address = false" @cancel="show.address = false"
></fui-picker> />
</view> </view>
</view> </view>
</template> </template>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import * as nongjifuwu from '@/api/model/nongjifuwu' import * as nongjifuwu from '@/api/model/nongjifuwu'
import { useDictStore } from '@/store/modules/dict' import { useDictStore } from '@/store/modules/dict'
import { areaTree } from '@/utils/areaData' import { areaTree } from '@/utils/areaData'
const dictStore = useDictStore() const dictStore = useDictStore()
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
...@@ -111,8 +112,8 @@ ...@@ -111,8 +112,8 @@
// 返回格式化的对象 // 返回格式化的对象
return { return {
name: fileName, name: fileName,
extname: extname, extname,
url: url, url,
} }
} }
...@@ -121,7 +122,7 @@ ...@@ -121,7 +122,7 @@
// 文件上传 // 文件上传
function handleUpload(file) { function handleUpload(file) {
uni.uploadFile({ uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: file.tempFiles[0].path, filePath: file.tempFiles[0].path,
name: 'file', name: 'file',
formData: { formData: {
...@@ -178,6 +179,7 @@ ...@@ -178,6 +179,7 @@
pageData.show.address = false pageData.show.address = false
} }
</script> </script>
<template> <template>
<view class="page"> <view class="page">
<view class="formBox"> <view class="formBox">
...@@ -190,7 +192,7 @@ ...@@ -190,7 +192,7 @@
v-model="form.name" v-model="form.name"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<fui-input <fui-input
required required
label="联系方式" label="联系方式"
...@@ -198,7 +200,7 @@ ...@@ -198,7 +200,7 @@
v-model="form.phone" v-model="form.phone"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
<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">
...@@ -225,7 +227,7 @@ ...@@ -225,7 +227,7 @@
v-model="form.price" v-model="form.price"
labelSize="28" labelSize="28"
label-width="180" label-width="180"
></fui-input> />
</view> </view>
<view class="bg-white mt20" style="padding: 0.875rem 1rem"> <view class="bg-white mt20" style="padding: 0.875rem 1rem">
...@@ -238,16 +240,16 @@ ...@@ -238,16 +240,16 @@
:auto-upload="false" :auto-upload="false"
@select="handleUpload" @select="handleUpload"
@delete="handleDelete" @delete="handleDelete"
></uni-file-picker> />
</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> <fui-button text="发布作业" bold radius="96rpx" @click="submit" />
</view> </view>
</fui-form> </fui-form>
<fui-toast ref="toastRef"></fui-toast> <fui-toast ref="toastRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
<fui-picker <fui-picker
:show="show.address" :show="show.address"
:options="options.address" :options="options.address"
...@@ -255,7 +257,7 @@ ...@@ -255,7 +257,7 @@
:layer="3" :layer="3"
@change="handleChangeAddress" @change="handleChangeAddress"
@cancel="show.address = false" @cancel="show.address = false"
></fui-picker> />
</view> </view>
</view> </view>
</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 ApplyDialog from './components/apply-dialog.vue' import ApplyDialog from './components/apply-dialog.vue'
import { onPullDownRefresh, onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
import * as NongjifuwuAPI from '@/api/model/nongjifuwu' import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
import Navigate from '@/utils/page/navigate' import Navigate from '@/utils/page/navigate'
...@@ -80,7 +80,8 @@ ...@@ -80,7 +80,8 @@
onReachBottom(() => { onReachBottom(() => {
console.log('触底了') console.log('触底了')
if (pageData.total <= pageData.farmMachineList.length) return if (pageData.total <= pageData.farmMachineList.length)
return
pageData.search.pageNo++ pageData.search.pageNo++
getFarmMachineList() getFarmMachineList()
}) })
...@@ -117,7 +118,7 @@ ...@@ -117,7 +118,7 @@
class="codefun-flex-col codefun-relative section_4" class="codefun-flex-col codefun-relative section_4"
style="height: 700rpx" style="height: 700rpx"
> >
<fui-empty marginTop="100" src="/src/static/images/no-data.png" title="暂无数据"></fui-empty> <fui-empty marginTop="100" src="/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">
<view class="codefun-flex-row group_6" v-for="item in pageData.farmMachineList" :key="item.id"> <view class="codefun-flex-row group_6" v-for="item in pageData.farmMachineList" :key="item.id">
...@@ -272,13 +273,13 @@ ...@@ -272,13 +273,13 @@
</view> </view>
<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> <view class="fab-icon" />
<view style="font-size: 24rpx">发布</view> <view style="font-size: 24rpx">发布</view>
</view> </view>
</fui-fab> </fui-fab>
<ApplyDialog ref="applyDialogRef"></ApplyDialog> <ApplyDialog ref="applyDialogRef" />
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading> <fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)" />
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue' import { reactive } from 'vue'
import { onPullDownRefresh, onLoad, onShow, onReachBottom } from '@dcloudio/uni-app' import { onPullDownRefresh, onReachBottom, onShow } from '@dcloudio/uni-app'
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'
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
}) })
function initDict() { function initDict() {
pageData.categoryList1 = dictStore.getDictList['category'].map((item) => { pageData.categoryList1 = dictStore.getDictList.category.map((item) => {
return { return {
text: item.text, text: item.text,
value: item.value, value: item.value,
...@@ -181,7 +181,8 @@ ...@@ -181,7 +181,8 @@
} }
onReachBottom(() => { onReachBottom(() => {
if (pagedata.total <= pageData.products.length) return if (pagedata.total <= pageData.products.length)
return
pageData.search.pageNo++ pageData.search.pageNo++
getGoodsList() getGoodsList()
}) })
...@@ -215,7 +216,7 @@ ...@@ -215,7 +216,7 @@
<view class="fui-filter__item" @tap="filterTap1"> <view class="fui-filter__item" @tap="filterTap1">
<text>{{ pageData.range1 }}</text> <text>{{ pageData.range1 }}</text>
<view class="fui-filter__icon" :class="{ 'fui-icon__ani': pageData.rangeShow1 }"> <view class="fui-filter__icon" :class="{ 'fui-icon__ani': pageData.rangeShow1 }">
<fui-icon name="turningdown" :size="32"></fui-icon> <fui-icon name="turningdown" :size="32" />
</view> </view>
</view> </view>
</fui-dropdown-menu> </fui-dropdown-menu>
...@@ -232,14 +233,14 @@ ...@@ -232,14 +233,14 @@
<view class="fui-filter__item" @tap="filterTap2"> <view class="fui-filter__item" @tap="filterTap2">
<text>{{ pageData.range2 }}</text> <text>{{ pageData.range2 }}</text>
<view class="fui-filter__icon" :class="{ 'fui-icon__ani': pageData.rangeShow2 }"> <view class="fui-filter__icon" :class="{ 'fui-icon__ani': pageData.rangeShow2 }">
<fui-icon name="turningdown" :size="32"></fui-icon> <fui-icon name="turningdown" :size="32" />
</view> </view>
</view> </view>
</fui-dropdown-menu> </fui-dropdown-menu>
</view> </view>
<view class="codefun-mt-6 codefun-flex-col codefun-self-stretch"> <view class="codefun-mt-6 codefun-flex-col codefun-self-stretch">
<view v-if="!pageData.products || pageData.products.length == 0" style="height: 700rpx"> <view v-if="!pageData.products || pageData.products.length == 0" style="height: 700rpx">
<fui-empty marginTop="100" src="/src/static/images/no-data.png" title="暂无数据"></fui-empty> <fui-empty marginTop="100" src="/src/static/images/no-data.png" title="暂无数据" />
</view> </view>
<template v-else> <template v-else>
<view <view
......
<template>
<u-modal
:show="show"
:title="dialogTitle"
:showConfirmButton="false"
:showCancelButton="false"
@close="handleClose"
:closeOnClickOverlay="false"
>
<view class="dialog-content">
<u-form :model="formData" :rules="rules" ref="formRef" label-width="auto">
<!-- 资源基本信息 -->
<!-- <view class="section-title">资源基本信息</view> -->
<u-form-item label="" prop="fileName">
<u-input v-model="formData.fileName" placeholder="请输入文件名称" border="bottom" />
</u-form-item>
<!-- <u-form-item label="文件类型" prop="fileType" required>
<u-input v-model="formData.fileType" placeholder="请选择文件类型" border="bottom"
@click="showFileTypePicker = true" />
</u-form-item> -->
<u-form-item label="上传文件" prop="file" required>
<view class="file-upload">
<u-button v-if="!formData.file" @click="chooseFile" type="primary" class="ui-button">
<text class="font_10">选择文件</text>
</u-button>
<view v-else class="file-info">
<view class="file-name-container">
<text class="file-name">{{ formData.file.name }}</text>
<text class="remove-icon" @click="removeFile">×</text>
</view>
</view>
</view>
</u-form-item>
<!-- 操作按钮 -->
<view class="dialog-buttons">
<u-button
type="primary"
@click="handleSubmit"
:loading="loading"
size="normal"
class="submit-btn"
color="var(--fui-color-success)"
>
{{ submitButtonText }}
</u-button>
<u-button @click="handleClose" size="normal" class="cancel-btn">取消</u-button>
</view>
</u-form>
</view>
</u-modal>
</template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, watch, computed } from 'vue' import { computed, reactive, ref, watch } 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 WodeAPI from '@/api/model/wode' import * as WodeAPI from '@/api/model/wode'
const lemonjkFileSelect = uni.requireNativePlugin('lemonjk-FileSelect')
// 定义Props
interface Props {
show: boolean
editData?: any
}
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
show: false, show: false,
...@@ -79,6 +17,14 @@ ...@@ -79,6 +17,14 @@
submitSuccess: [] submitSuccess: []
}>() }>()
const lemonjkFileSelect = uni.requireNativePlugin('lemonjk-FileSelect')
// 定义Props
interface Props {
show: boolean
editData?: any
}
// 表单引用 // 表单引用
const formRef = ref() const formRef = ref()
const loading = ref(false) const loading = ref(false)
...@@ -155,7 +101,7 @@ ...@@ -155,7 +101,7 @@
) )
// 重置表单数据 // 重置表单数据
const resetFormData = () => { function resetFormData() {
formData.fileName = '' formData.fileName = ''
formData.fileType = '' formData.fileType = ''
formData.fileTypeText = '' formData.fileTypeText = ''
...@@ -168,8 +114,9 @@ ...@@ -168,8 +114,9 @@
} }
// 加载编辑数据 // 加载编辑数据
const loadEditData = () => { function loadEditData() {
if (!props.editData) return if (!props.editData)
return
formData.fileName = props.editData.fileName || '' formData.fileName = props.editData.fileName || ''
formData.fileType = props.editData.fileType || '' formData.fileType = props.editData.fileType || ''
...@@ -180,7 +127,7 @@ ...@@ -180,7 +127,7 @@
} }
const uplpoadFile = ref(null) const uplpoadFile = ref(null)
// 选择文件 // 选择文件
const chooseFile = () => { function chooseFile() {
// #ifdef H5 // #ifdef H5
uni.chooseFile({ uni.chooseFile({
count: 1, count: 1,
...@@ -219,7 +166,7 @@ ...@@ -219,7 +166,7 @@
// #ifndef H5 // #ifndef H5
lemonjkFileSelect.showNativePicker( lemonjkFileSelect.showNativePicker(
{ {
//各属性配置见下方【showPicker可配置参数说明】 // 各属性配置见下方【showPicker可配置参数说明】
pathScope: '/Download', pathScope: '/Download',
mimeType: '*/*', mimeType: '*/*',
utisType: ['public.data'], utisType: ['public.data'],
...@@ -243,7 +190,7 @@ ...@@ -243,7 +190,7 @@
} }
// 移除文件 // 移除文件
const removeFile = () => { function removeFile() {
formData.file = null formData.file = null
// 移除文件后触发验证 // 移除文件后触发验证
if (formRef.value) { if (formRef.value) {
...@@ -252,7 +199,7 @@ ...@@ -252,7 +199,7 @@
} }
// 根据文件扩展名获取文件类型 // 根据文件扩展名获取文件类型
const getFileTypeByExt = (ext) => { function getFileTypeByExt(ext) {
const map = { const map = {
doc: 'doc', doc: 'doc',
docx: 'doc', docx: 'doc',
...@@ -280,7 +227,7 @@ ...@@ -280,7 +227,7 @@
const userStore = useUserStore() const userStore = useUserStore()
const globSetting = useGlobSetting() const globSetting = useGlobSetting()
// 提交表单 // 提交表单
const handleSubmit = async () => { async function handleSubmit() {
try { try {
console.log(formData) console.log(formData)
// 先进行表单验证 // 先进行表单验证
...@@ -313,7 +260,7 @@ ...@@ -313,7 +260,7 @@
// API留空 // API留空
console.log('上传资源数据:', submitData) console.log('上传资源数据:', submitData)
uni.uploadFile({ uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: uplpoadFile.value, filePath: uplpoadFile.value,
name: 'file', name: 'file',
formData: { formData: {
...@@ -377,12 +324,67 @@ ...@@ -377,12 +324,67 @@
} }
// 关闭弹窗 // 关闭弹窗
const handleClose = () => { function handleClose() {
emit('update:show', false) emit('update:show', false)
emit('close') emit('close')
} }
</script> </script>
<template>
<u-modal
:show="show"
:title="dialogTitle"
:showConfirmButton="false"
:showCancelButton="false"
@close="handleClose"
:closeOnClickOverlay="false"
>
<view class="dialog-content">
<u-form :model="formData" :rules="rules" ref="formRef" label-width="auto">
<!-- 资源基本信息 -->
<!-- <view class="section-title">资源基本信息</view> -->
<u-form-item label="" prop="fileName">
<u-input v-model="formData.fileName" placeholder="请输入文件名称" border="bottom" />
</u-form-item>
<!-- <u-form-item label="文件类型" prop="fileType" required>
<u-input v-model="formData.fileType" placeholder="请选择文件类型" border="bottom"
@click="showFileTypePicker = true" />
</u-form-item> -->
<u-form-item label="上传文件" prop="file" required>
<view class="file-upload">
<u-button v-if="!formData.file" @click="chooseFile" type="primary" class="ui-button">
<text class="font_10">选择文件</text>
</u-button>
<view v-else class="file-info">
<view class="file-name-container">
<text class="file-name">{{ formData.file.name }}</text>
<text class="remove-icon" @click="removeFile">×</text>
</view>
</view>
</view>
</u-form-item>
<!-- 操作按钮 -->
<view class="dialog-buttons">
<u-button
type="primary"
@click="handleSubmit"
:loading="loading"
size="normal"
class="submit-btn"
color="var(--fui-color-success)"
>
{{ submitButtonText }}
</u-button>
<u-button @click="handleClose" size="normal" class="cancel-btn">取消</u-button>
</view>
</u-form>
</view>
</u-modal>
</template>
<style lang="scss" scoped> <style lang="scss" scoped>
.dialog-content { .dialog-content {
padding: 10rpx 30rpx; padding: 10rpx 30rpx;
......
<template>
<view class="codefun-flex-col page">
<z-paging ref="paging" v-model="pageData.list" @query="queryList">
<view class="codefun-flex-col group_3">
<view class="codefun-flex-row codefun-items-center section_2">
<image class="image_6" src="/static/images/codefun/6c5c5a3c082b8c60a307d3a7caee623c.png" />
<u-input
v-model="pageData.param.fileName"
placeholder="请输入文件名称搜索"
border="none"
class="codefun-ml-8"
@confirm="handleSearch"
/>
</view>
<!-- 资源列表 - 根据图片样式修改 -->
<view class="resource-list">
<view v-for="(item, index) in pageData.list" :key="index" class="resource-item">
<view class="resource-content">
<view class="resource-main">
<view class="resource-name">{{ item.fileName }}</view>
<view class="resource-meta">
<text class="resource-size">{{ item.fileSize }}</text>
<text class="separator">|</text>
<text class="download-count">已下载{{ item.downloadCount || 0 }}</text>
<text class="separator">|</text>
<text class="upload-time">{{ formatTime(item.createTime) }}</text>
</view>
</view>
<view
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4"
@click.stop="handleDownload(item)"
>
<text class="font_10">下载</text>
</view>
<!-- <view class="download-section">
<view class="download-btn" @click="handleDownload(item)">
<text class="btn-text">下载</text>
</view>
</view> -->
</view>
</view>
</view>
<!-- 空状态 -->
<!-- <view class="empty-state" v-if="pageData.list.length === 0">
<image class="empty-icon" src="/static/images/empty.png" mode="aspectFit"></image>
<text class="empty-text">暂无资源</text>
</view> -->
</view>
</z-paging>
<!-- 弹窗组件 -->
<save-dialog
:show="showDialog"
:editData="currentEditData"
@update:show="showDialog = $event"
@submitSuccess="handleSubmitSuccess"
/>
</view>
</template>
<script setup> <script setup>
import { nextTick, reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import { onLoad, onNavigationBarButtonTap, onShow } from '@dcloudio/uni-app' import { onNavigationBarButtonTap } from '@dcloudio/uni-app'
import * as API from '@/api/model/wode'
import SaveDialog from './components/save-dialog.vue' import SaveDialog from './components/save-dialog.vue'
import * as API from '@/api/model/wode'
const isOnePage = ref(true) const isOnePage = ref(true)
const paging = ref(null) const paging = ref(null)
...@@ -104,19 +43,20 @@ ...@@ -104,19 +43,20 @@
showAddDialog() showAddDialog()
}) })
const showAddDialog = () => { function showAddDialog() {
currentEditData.value = null currentEditData.value = null
showDialog.value = true showDialog.value = true
} }
// 格式化时间显示 // 格式化时间显示
const formatTime = (time) => { function formatTime(time) {
if (!time) return '' if (!time)
return ''
// 如果是完整的时间字符串,可以格式化为图片中的样式 // 如果是完整的时间字符串,可以格式化为图片中的样式
return time.includes(' ') ? time : `${time} 14:00` return time.includes(' ') ? time : `${time} 14:00`
} }
// 下载资源 // 下载资源
const handleDownload = async (resource) => { async function handleDownload(resource) {
await API.downloadResource({ id: resource.id }) await API.downloadResource({ id: resource.id })
// 更新下载次数 // 更新下载次数
const index = pageData.list.findIndex((item) => item.id === resource.id) const index = pageData.list.findIndex((item) => item.id === resource.id)
...@@ -134,21 +74,83 @@ ...@@ -134,21 +74,83 @@
} }
// 格式化文件大小 // 格式化文件大小
const formatFileSize = (bytes) => { function formatFileSize(bytes) {
if (!bytes) return '125kb' if (!bytes)
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))
return parseFloat((bytes / Math.pow(k, i)).toFixed(0)) + sizes[i].toLowerCase() return Number.parseFloat((bytes / k ** i).toFixed(0)) + sizes[i].toLowerCase()
} }
const handleSubmitSuccess = () => { function handleSubmitSuccess() {
showDialog.value = false showDialog.value = false
// 重新加载数据 // 重新加载数据
handleSearch() handleSearch()
} }
</script> </script>
<template>
<view class="codefun-flex-col page">
<z-paging ref="paging" v-model="pageData.list" @query="queryList">
<view class="codefun-flex-col group_3">
<view class="codefun-flex-row codefun-items-center section_2">
<image class="image_6" src="/static/images/codefun/6c5c5a3c082b8c60a307d3a7caee623c.png" />
<u-input
v-model="pageData.param.fileName"
placeholder="请输入文件名称搜索"
border="none"
class="codefun-ml-8"
@confirm="handleSearch"
/>
</view>
<!-- 资源列表 - 根据图片样式修改 -->
<view class="resource-list">
<view v-for="(item, index) in pageData.list" :key="index" class="resource-item">
<view class="resource-content">
<view class="resource-main">
<view class="resource-name">{{ item.fileName }}</view>
<view class="resource-meta">
<text class="resource-size">{{ item.fileSize }}</text>
<text class="separator">|</text>
<text class="download-count">已下载{{ item.downloadCount || 0 }}</text>
<text class="separator">|</text>
<text class="upload-time">{{ formatTime(item.createTime) }}</text>
</view>
</view>
<view
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4"
@click.stop="handleDownload(item)"
>
<text class="font_10">下载</text>
</view>
<!-- <view class="download-section">
<view class="download-btn" @click="handleDownload(item)">
<text class="btn-text">下载</text>
</view>
</view> -->
</view>
</view>
</view>
<!-- 空状态 -->
<!-- <view class="empty-state" v-if="pageData.list.length === 0">
<image class="empty-icon" src="/static/images/empty.png" mode="aspectFit"></image>
<text class="empty-text">暂无资源</text>
</view> -->
</view>
</z-paging>
<!-- 弹窗组件 -->
<SaveDialog
:show="showDialog"
:editData="currentEditData"
@update:show="showDialog = $event"
@submit-success="handleSubmitSuccess"
/>
</view>
</template>
<style lang="scss"> <style lang="scss">
body { body {
background: #e6f5e8; background: #e6f5e8;
......
...@@ -184,6 +184,15 @@ ...@@ -184,6 +184,15 @@
} }
}) })
}) })
WeatherAPI.alarm(`${pageData.weather.lat},${pageData.weather.lon}`).then((res) => {
console.log('WeatherAPI.alarm', res)
// pageData.weather.warning = res.data.alerts?.[0]?.description || ''
// TODO: 测试数据
pageData.weather.warning =
'雨花区气象台24日11时19分继续发布大风蓝色预警信号:预计未来24小时内临桂将出现6级(或阵风7级)以上大风,请做好防范。'
})
} }
// 页面数据 // 页面数据
...@@ -375,13 +384,13 @@ ...@@ -375,13 +384,13 @@
} }
// 农产品关注点击事件 // 农产品关注点击事件
function onProductFollowClick(product: any) { function _onProductFollowClick(product: any) {
console.log('点击关注农产品:', product) console.log('点击关注农产品:', product)
// 在这里添加具体的关注逻辑 // 在这里添加具体的关注逻辑
} }
// 查看更多农技课堂 // 查看更多农技课堂
function onViewMoreClass() { function _onViewMoreClass() {
console.log('查看全部农技课堂') console.log('查看全部农技课堂')
// 在这里添加具体的查看逻辑 // 在这里添加具体的查看逻辑
} }
...@@ -389,7 +398,7 @@ ...@@ -389,7 +398,7 @@
// 轮播视频切换的时候触发 // 轮播视频切换的时候触发
function handleChangeVideo(e: any) { function handleChangeVideo(e: any) {
const currentIndex = e.detail.current const currentIndex = e.detail.current
const prevIndex = pageData.current const _prevIndex = pageData.current
pageData.current = currentIndex pageData.current = currentIndex
pageData.agricultureClass.title = pageData.agricultureClass.videoList[currentIndex]?.title pageData.agricultureClass.title = pageData.agricultureClass.videoList[currentIndex]?.title
...@@ -458,7 +467,7 @@ ...@@ -458,7 +467,7 @@
<view class="codefun-flex-col codefun-relative group_3"> <view class="codefun-flex-col codefun-relative group_3">
<view class="codefun-flex-col"> <view class="codefun-flex-col">
<view class="codefun-flex-col codefun-self-stretch group_4"> <view class="codefun-flex-col codefun-self-stretch group_4">
<view class="codefun-flex-col section_3"> <view class="codefun-flex-col section_3" :class="{ '!pb-6': !pageData.weather.warning }">
<view class="codefun-flex-row codefun-justify-between" style="align-items: center"> <view class="codefun-flex-row codefun-justify-between" style="align-items: center">
<view <view
class="codefun-flex-row codefun-items-center codefun-relative codefun-overflow-hidden" class="codefun-flex-row codefun-items-center codefun-relative codefun-overflow-hidden"
...@@ -474,7 +483,7 @@ ...@@ -474,7 +483,7 @@
style="width: 400rpx" style="width: 400rpx"
> >
<up-notice-bar <up-notice-bar
v-if="pageData.weather.detailedLocation != '获取中'" v-if="pageData.weather.detailedLocation !== '获取中'"
icon="" icon=""
bgColor="#FFFFFF00" bgColor="#FFFFFF00"
color="#5db66f" color="#5db66f"
...@@ -559,7 +568,18 @@ ...@@ -559,7 +568,18 @@
</view> </view>
</view> </view>
</view> </view>
<view class="codefun-flex-row section_4" v-if="pageData.weather.warning"> <view class="my-2" v-if="pageData.weather.warning">
<fui-notice-bar
:content="pageData.weather.warning"
scrollable
:padding="['0', '32rpx']"
>
<view class="fui-icon__box">
<fui-icon name="notice" :size="36" color="#FF2B2B" />
</view>
</fui-notice-bar>
</view>
<!-- <view class="codefun-flex-row section_4" v-if="pageData.weather.warning">
<image <image
class="codefun-shrink-0 image_10" class="codefun-shrink-0 image_10"
src="/static/images/codefun/344155285176a7ac7ccd670a2a1daf19.png" src="/static/images/codefun/344155285176a7ac7ccd670a2a1daf19.png"
...@@ -569,7 +589,7 @@ ...@@ -569,7 +589,7 @@
> >
<text class="text_12">{{ pageData.weather.warning }}</text> <text class="text_12">{{ pageData.weather.warning }}</text>
</view> </view>
</view> </view> -->
</view> </view>
<view class="codefun-flex-col codefun-relative section_5"> <view class="codefun-flex-col codefun-relative section_5">
<view class="codefun-flex-row"> <view class="codefun-flex-row">
...@@ -884,7 +904,7 @@ ...@@ -884,7 +904,7 @@
.section_3 { .section_3 {
width: 694rpx; width: 694rpx;
// margin-right: 28rpx; // margin-right: 28rpx;
padding: 20rpx 28rpx 58rpx; padding: 28rpx;
background-image: linear-gradient(180deg, #dcfce7 0%, #f8fef9 100%); background-image: linear-gradient(180deg, #dcfce7 0%, #f8fef9 100%);
border-radius: 16rpx; border-radius: 16rpx;
mix-blend-mode: NOTTHROUGH; mix-blend-mode: NOTTHROUGH;
...@@ -1184,7 +1204,7 @@ ...@@ -1184,7 +1204,7 @@
border-radius: 16rpx; border-radius: 16rpx;
mix-blend-mode: NOTTHROUGH; mix-blend-mode: NOTTHROUGH;
width: 32rpx; width: 32rpx;
height: 32rpx; height: 40rpx;
} }
.codefun-mr-4 { .codefun-mr-4 {
margin-right: 10rpx; margin-right: 10rpx;
......
<script setup lang="ts"> <script setup lang="ts">
import { reactive } from 'vue' import { reactive } from 'vue'
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app' import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
import * as WodeAPI from '@/api/model/wode' import SaveDialog from '../device/components/save-dialog.vue'
import * as NongchangAPI from '@/api/model/nongchang' import * as WodeAPI from '@/api/model/wode'
import SaveDialog from '../device/components/save-dialog.vue' import * as NongchangAPI from '@/api/model/nongchang'
// 下拉刷新
onPullDownRefresh(() => { // 下拉刷新
onPullDownRefresh(() => {
setTimeout(function () { setTimeout(function () {
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
uni.showToast({ uni.showToast({
title: '刷新成功', title: '刷新成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500,
}) })
}, 1000) }, 1000)
}) })
onLoad(() => { onLoad(() => {
getBizCommonFileList() getBizCommonFileList()
getFarmsList() getFarmsList()
}) })
// 页面数据 // 页面数据
const pageData = reactive({ const pageData = reactive({
// 用户信息 // 用户信息
userInfo: { userInfo: {
avatar: '/static/images/codefun/8653455b786fbf94ae1c3946f11e7d40.png', avatar: '/static/images/codefun/8653455b786fbf94ae1c3946f11e7d40.png',
...@@ -63,7 +64,7 @@ const pageData = reactive({ ...@@ -63,7 +64,7 @@ const pageData = reactive({
status: '离线可用', status: '离线可用',
statusClass: 'text_14', statusClass: 'text_14',
arrowIcon: '/static/images/codefun/f29a8c39eb37da965d0a764a567a1c77.png', arrowIcon: '/static/images/codefun/f29a8c39eb37da965d0a764a567a1c77.png',
url: '/pages/resource/resource' url: '/pages/resource/resource',
}, },
{ {
id: 2, id: 2,
...@@ -74,7 +75,7 @@ const pageData = reactive({ ...@@ -74,7 +75,7 @@ const pageData = reactive({
actionText: '添加设备', actionText: '添加设备',
arrowIcon: '/static/images/codefun/f29a8c39eb37da965d0a764a567a1c77.png', arrowIcon: '/static/images/codefun/f29a8c39eb37da965d0a764a567a1c77.png',
addIcon: '/static/images/codefun/2ff61f748e26b18760ca166aa8cfa15a.png', addIcon: '/static/images/codefun/2ff61f748e26b18760ca166aa8cfa15a.png',
url: '/pages/device/device' url: '/pages/device/device',
}, },
], ],
...@@ -171,9 +172,9 @@ const pageData = reactive({ ...@@ -171,9 +172,9 @@ const pageData = reactive({
}, },
], ],
}, },
}) })
function getBizCommonFileList() { function getBizCommonFileList() {
WodeAPI.bizCommonFileList({ WodeAPI.bizCommonFileList({
pageNo: 1, pageNo: 1,
pageSize: 4, pageSize: 4,
...@@ -181,13 +182,13 @@ function getBizCommonFileList() { ...@@ -181,13 +182,13 @@ function getBizCommonFileList() {
const { records } = res const { records } = res
pageData.commonResources.resources = records pageData.commonResources.resources = records
}) })
} }
function getFarmBaseList(id) { function getFarmBaseList(id) {
NongchangAPI.getFarmBaseList({ id }).then((res) => { NongchangAPI.getFarmBaseList({ id }).then((res) => {
pageData.statistics[0].value = res.length pageData.statistics[0].value = res.length
}) })
} }
function getFarmsList() { function getFarmsList() {
NongchangAPI.farmsList({ NongchangAPI.farmsList({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
...@@ -204,51 +205,50 @@ function getFarmsList() { ...@@ -204,51 +205,50 @@ function getFarmsList() {
getFarmBaseList(pageData.userInfo.ncId) getFarmBaseList(pageData.userInfo.ncId)
}) })
} }
// 用户信息设置点击事件 // 用户信息设置点击事件
function onSettingsClick() { function onSettingsClick() {
console.log('点击设置') console.log('点击设置')
// 在这里添加具体的设置点击逻辑 // 在这里添加具体的设置点击逻辑
} }
// 消息中心点击事件 // 消息中心点击事件
function onMessageCenterClick() { function onMessageCenterClick() {
console.log('点击消息中心') console.log('点击消息中心')
// 在这里添加具体的消息中心点击逻辑 // 在这里添加具体的消息中心点击逻辑
} }
// 功能模块点击事件 // 功能模块点击事件
function onFeatureClick(feature: any) { function onFeatureClick(feature: any) {
console.log('点击功能模块:', feature) console.log('点击功能模块:', feature)
// 在这里添加具体的功能模块点击逻辑 // 在这里添加具体的功能模块点击逻辑
uni.navigateTo({ uni.navigateTo({
url: feature.url, url: feature.url,
}) })
} }
const showDialog = ref(false) const showDialog = ref(false)
const currentEditData = ref(null) const currentEditData = ref(null)
onNavigationBarButtonTap((_) => { onNavigationBarButtonTap((_) => {
showAddDialog() showAddDialog()
}) })
const showAddDialog = () => { function showAddDialog() {
currentEditData.value = null currentEditData.value = null
showDialog.value = true showDialog.value = true
} }
const 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) {
console.log('点击资源:', resource) console.log('点击资源:', resource)
// 在这里添加具体的资源点击逻辑 // 在这里添加具体的资源点击逻辑
} }
// 资源下载点击事件 // 资源下载点击事件
async function onDownloadClick(e, resource: any) { async function onDownloadClick(e, resource: any) {
// 阻止事件冒泡 // 阻止事件冒泡
e?.stopPropagation() e?.stopPropagation()
...@@ -260,39 +260,37 @@ async function onDownloadClick(e, resource: any) { ...@@ -260,39 +260,37 @@ async function onDownloadClick(e, resource: any) {
if (!result.success) { if (!result.success) {
console.error('下载失败:', result.error) console.error('下载失败:', result.error)
} }
} }
// 查看所有资源 // 查看所有资源
function onViewAllResources() { function onViewAllResources() {
console.log('查看所有资源') console.log('查看所有资源')
// 在这里添加具体的查看所有资源逻辑 // 在这里添加具体的查看所有资源逻辑
} }
// 我的设备标题点击事件 // 我的设备标题点击事件
function onMyDevicesTitleClick() { function onMyDevicesTitleClick() {
console.log('点击我的设备标题') console.log('点击我的设备标题')
// 在这里添加具体的设备标题点击逻辑 // 在这里添加具体的设备标题点击逻辑
} }
// 设备点击事件 // 设备点击事件
function onDeviceClick(device: any) { function onDeviceClick(device: any) {
console.log('点击设备:', device) console.log('点击设备:', device)
// 在这里添加具体的设备点击逻辑 // 在这里添加具体的设备点击逻辑
} }
// 客服点击事件 // 客服点击事件
function onServiceClick(service: any) { function onServiceClick(service: any) {
console.log('点击客服:', service) console.log('点击客服:', service)
// 在这里添加具体的客服点击逻辑 // 在这里添加具体的客服点击逻辑
} }
// 帮助点击事件 // 帮助点击事件
function onHelpClick(help: any) { function onHelpClick(help: any) {
console.log('点击帮助:', help) console.log('点击帮助:', help)
// 在这里添加具体的帮助点击逻辑 // 在这里添加具体的帮助点击逻辑
} }
</script> </script>
<template> <template>
...@@ -306,13 +304,18 @@ function onHelpClick(help: any) { ...@@ -306,13 +304,18 @@ function onHelpClick(help: any) {
<view class="codefun-flex-row codefun-items-center codefun-self-stretch"> <view class="codefun-flex-row codefun-items-center codefun-self-stretch">
<text class="font_2 text_2">{{ pageData.userInfo.farmName }}</text> <text class="font_2 text_2">{{ pageData.userInfo.farmName }}</text>
<view <view
class="codefun-flex-row codefun-items-center codefun-shrink-0 section_2 codefun-ml-6"> class="codefun-flex-row codefun-items-center codefun-shrink-0 section_2 codefun-ml-6"
<image v-show="pageData.userInfo.certification.icon" >
<image
v-show="pageData.userInfo.certification.icon"
class="codefun-shrink-0 image_7 mr-1" class="codefun-shrink-0 image_7 mr-1"
:src="pageData.userInfo.certification.icon" /> :src="pageData.userInfo.certification.icon"
<text class="font_3 text_3" />
:style="{ color: pageData.userInfo.certification.icon ? '' : '#fbc428' }">{{ <text
pageData.userInfo.certification.text }}</text> class="font_3 text_3"
:style="{ color: pageData.userInfo.certification.icon ? '' : '#fbc428' }"
>{{ pageData.userInfo.certification.text }}</text
>
</view> </view>
</view> </view>
<text class="codefun-self-start font_1 codefun-mt-10">{{ <text class="codefun-self-start font_1 codefun-mt-10">{{
...@@ -324,9 +327,15 @@ function onHelpClick(help: any) { ...@@ -324,9 +327,15 @@ function onHelpClick(help: any) {
</view> </view>
<view class="codefun-flex-col codefun-justify-start section_3"> <view class="codefun-flex-col codefun-justify-start section_3">
<view class="codefun-flex-row"> <view class="codefun-flex-row">
<navigator v-for="stat in pageData.statistics" :url="stat.url" :key="stat.id" <navigator
class="codefun-flex-col codefun-items-center group_6 equal-division-item" hover-class="none" v-for="stat in pageData.statistics"
:render-link="false" :class="{ 'codefun-ml-32': stat.id > 1 }"> :url="stat.url"
:key="stat.id"
class="codefun-flex-col codefun-items-center group_6 equal-division-item"
hover-class="none"
:render-link="false"
:class="{ 'codefun-ml-32': stat.id > 1 }"
>
<text class="font_4">{{ stat.value }}</text> <text class="font_4">{{ stat.value }}</text>
<text class="font_5 codefun-mt-16">{{ stat.label }}</text> <text class="font_5 codefun-mt-16">{{ stat.label }}</text>
</navigator> </navigator>
...@@ -336,14 +345,17 @@ function onHelpClick(help: any) { ...@@ -336,14 +345,17 @@ function onHelpClick(help: any) {
<view class="codefun-flex-col codefun-relative group_7"> <view class="codefun-flex-col codefun-relative group_7">
<view class="codefun-flex-col"> <view class="codefun-flex-col">
<!-- 消息中心 --> <!-- 消息中心 -->
<view class="codefun-flex-row codefun-justify-between codefun-items-center section_12" <view
@click="onMessageCenterClick"> class="codefun-flex-row codefun-justify-between codefun-items-center section_12"
@click="onMessageCenterClick"
>
<view class="codefun-flex-row group_8"> <view class="codefun-flex-row group_8">
<image class="image_10" :src="pageData.messageCenter.icon" /> <image class="image_10" :src="pageData.messageCenter.icon" />
<view class="codefun-flex-col group_9 codefun-ml-12"> <view class="codefun-flex-col group_9 codefun-ml-12">
<text class="codefun-self-start font">{{ pageData.messageCenter.title }}</text> <text class="codefun-self-start font">{{ pageData.messageCenter.title }}</text>
<view <view
class="codefun-flex-col codefun-justify-start codefun-items-start codefun-self-stretch text-wrapper_2 codefun-mt-4"> class="codefun-flex-col codefun-justify-start codefun-items-start codefun-self-stretch text-wrapper_2 codefun-mt-4"
>
<text class="font_7">{{ pageData.messageCenter.description }}</text> <text class="font_7">{{ pageData.messageCenter.description }}</text>
</view> </view>
</view> </view>
...@@ -357,9 +369,13 @@ function onHelpClick(help: any) { ...@@ -357,9 +369,13 @@ function onHelpClick(help: any) {
</view> </view>
<!-- 资源/设备 --> <!-- 资源/设备 -->
<view class="codefun-flex-row equal-division codefun-mt-12"> <view class="codefun-flex-row equal-division codefun-mt-12">
<view v-for="(feature, index) in pageData.features" :key="feature.id" <view
class="codefun-flex-col section_5 section_11" :class="{ 'codefun-ml-12': index > 0 }" v-for="(feature, index) in pageData.features"
@click="onFeatureClick(feature)"> :key="feature.id"
class="codefun-flex-col section_5 section_11"
:class="{ 'codefun-ml-12': index > 0 }"
@click="onFeatureClick(feature)"
>
<view class="codefun-flex-row codefun-self-stretch"> <view class="codefun-flex-row codefun-self-stretch">
<view class="codefun-flex-row codefun-items-center codefun-flex-1"> <view class="codefun-flex-row codefun-items-center codefun-flex-1">
<image class="codefun-shrink-0 image_10" :src="feature.icon" /> <image class="codefun-shrink-0 image_10" :src="feature.icon" />
...@@ -368,20 +384,28 @@ function onHelpClick(help: any) { ...@@ -368,20 +384,28 @@ function onHelpClick(help: any) {
<text class="font_8 codefun-mt-8">{{ feature.count }}</text> <text class="font_8 codefun-mt-8">{{ feature.count }}</text>
</view> </view>
</view> </view>
<image class="codefun-shrink-0 codefun-self-start image_11" :class="{ <image
class="codefun-shrink-0 codefun-self-start image_11"
:class="{
image_12: feature.id === 1, image_12: feature.id === 1,
image_13: feature.id === 2, image_13: feature.id === 2,
'codefun-ml-8': feature.id === 1, 'codefun-ml-8': feature.id === 1,
}" :src="feature.arrowIcon" /> }"
:src="feature.arrowIcon"
/>
</view> </view>
<text class="codefun-self-stretch font_7 codefun-mt-10">{{ feature.description }}</text> <text class="codefun-self-stretch font_7 codefun-mt-10">{{ feature.description }}</text>
<view v-if="feature.status" <view
class="codefun-flex-col codefun-justify-start codefun-items-center codefun-self-start view mt-2"> v-if="feature.status"
class="codefun-flex-col codefun-justify-start codefun-items-center codefun-self-start view mt-2"
>
<text class="font_6" :class="feature.statusClass">{{ feature.status }}</text> <text class="font_6" :class="feature.statusClass">{{ feature.status }}</text>
</view> </view>
<view v-if="feature.actionText && feature.addIcon" <view
v-if="feature.actionText && feature.addIcon"
class="codefun-flex-row codefun-justify-evenly codefun-items-center codefun-self-start view_2 mt-2" class="codefun-flex-row codefun-justify-evenly codefun-items-center codefun-self-start view_2 mt-2"
@click.stop="onAddClick(feature)"> @click.stop="onAddClick(feature)"
>
<image class="image_14" :src="feature.addIcon" /> <image class="image_14" :src="feature.addIcon" />
<text class="font_3">{{ feature.actionText }}</text> <text class="font_3">{{ feature.actionText }}</text>
</view> </view>
...@@ -399,8 +423,10 @@ function onHelpClick(help: any) { ...@@ -399,8 +423,10 @@ function onHelpClick(help: any) {
<view class="codefun-flex-col list"> <view class="codefun-flex-col list">
<view <view
class="codefun-flex-row codefun-justify-between codefun-items-center list-item codefun-mt-24" class="codefun-flex-row codefun-justify-between codefun-items-center list-item codefun-mt-24"
v-for="resource in pageData.commonResources.resources" :key="resource.id" v-for="resource in pageData.commonResources.resources"
@click="onResourceClick(resource)"> :key="resource.id"
@click="onResourceClick(resource)"
>
<view class="codefun-flex-row"> <view class="codefun-flex-row">
<image class="image_15" :src="pageData.commonResources.icon[resource.fileType]?.icon" /> <image class="image_15" :src="pageData.commonResources.icon[resource.fileType]?.icon" />
<view class="codefun-flex-col codefun-items-start group_14 codefun-ml-12"> <view class="codefun-flex-col codefun-items-start group_14 codefun-ml-12">
...@@ -408,8 +434,10 @@ function onHelpClick(help: any) { ...@@ -408,8 +434,10 @@ function onHelpClick(help: any) {
<text class="font_6 codefun-mt-12">{{ resource.fileSize }}</text> <text class="font_6 codefun-mt-12">{{ resource.fileSize }}</text>
</view> </view>
</view> </view>
<view class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4" <view
@click.stop="(e) => onDownloadClick(e, resource)"> class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4"
@click.stop="(e) => onDownloadClick(e, resource)"
>
<text class="font_10">下载</text> <text class="font_10">下载</text>
</view> </view>
</view> </view>
...@@ -424,9 +452,13 @@ function onHelpClick(help: any) { ...@@ -424,9 +452,13 @@ function onHelpClick(help: any) {
</view> </view>
<view class="codefun-flex-col codefun-mt-16"> <view class="codefun-flex-col codefun-mt-16">
<view class="codefun-flex-col section_12"> <view class="codefun-flex-col section_12">
<view class="codefun-flex-row codefun-justify-between codefun-items-center" <view
v-for="(device, index) in pageData.myDevices.devices" :key="device.id" class="codefun-flex-row codefun-justify-between codefun-items-center"
:class="{ 'codefun-mt-16': index > 0 }" @click="onDeviceClick(device)"> v-for="(device, index) in pageData.myDevices.devices"
:key="device.id"
:class="{ 'codefun-mt-16': index > 0 }"
@click="onDeviceClick(device)"
>
<view class="codefun-flex-row codefun-items-center"> <view class="codefun-flex-row codefun-items-center">
<image class="image_17" :src="device.image" /> <image class="image_17" :src="device.image" />
<view class="codefun-flex-col codefun-items-start codefun-ml-8"> <view class="codefun-flex-col codefun-items-start codefun-ml-8">
...@@ -436,17 +468,23 @@ function onHelpClick(help: any) { ...@@ -436,17 +468,23 @@ function onHelpClick(help: any) {
</view> </view>
<view class="codefun-flex-row codefun-items-center"> <view class="codefun-flex-row codefun-items-center">
<image class="codefun-shrink-0 image_18" :src="device.statusIcon" /> <image class="codefun-shrink-0 image_18" :src="device.statusIcon" />
<text class="font_6" :class="device.statusClass || ''" <text
:style="{ color: device.status === '正常' ? '#13e000' : '#999999' }"> class="font_6"
:class="device.statusClass || ''"
:style="{ color: device.status === '正常' ? '#13e000' : '#999999' }"
>
{{ device.status }} {{ device.status }}
</text> </text>
</view> </view>
</view> </view>
</view> </view>
<view class="codefun-flex-col section_9 codefun-mt-12"> <view class="codefun-flex-col section_9 codefun-mt-12">
<view class="codefun-flex-row codefun-justify-between codefun-items-center" <view
v-for="service in pageData.support.services" :key="service.id" class="codefun-flex-row codefun-justify-between codefun-items-center"
@click="onServiceClick(service)"> v-for="service in pageData.support.services"
:key="service.id"
@click="onServiceClick(service)"
>
<view class="codefun-flex-row codefun-items-center"> <view class="codefun-flex-row codefun-items-center">
<image class="codefun-shrink-0 image_19" :src="service.icon" /> <image class="codefun-shrink-0 image_19" :src="service.icon" />
<text class="font_13 codefun-ml-8">{{ service.title }}</text> <text class="font_13 codefun-ml-8">{{ service.title }}</text>
...@@ -454,9 +492,13 @@ function onHelpClick(help: any) { ...@@ -454,9 +492,13 @@ function onHelpClick(help: any) {
<image class="image_20" :src="service.arrowIcon" /> <image class="image_20" :src="service.arrowIcon" />
</view> </view>
<view class="codefun-flex-col codefun-mt-20"> <view class="codefun-flex-col codefun-mt-20">
<view class="codefun-flex-row codefun-justify-between codefun-items-center" <view
v-for="help in pageData.support.helps" :key="help.id" class="codefun-flex-row codefun-justify-between codefun-items-center"
:class="{ 'codefun-mt-20': help.id > 1 }" @click="onHelpClick(help)"> v-for="help in pageData.support.helps"
:key="help.id"
:class="{ 'codefun-mt-20': help.id > 1 }"
@click="onHelpClick(help)"
>
<view class="codefun-flex-row codefun-items-center"> <view class="codefun-flex-row codefun-items-center">
<image class="codefun-shrink-0 image_21" :src="help.icon" /> <image class="codefun-shrink-0 image_21" :src="help.icon" />
<text class="font_13 codefun-ml-8">{{ help.title }}</text> <text class="font_13 codefun-ml-8">{{ help.title }}</text>
...@@ -470,12 +512,12 @@ function onHelpClick(help: any) { ...@@ -470,12 +512,12 @@ function onHelpClick(help: any) {
</view> </view>
</view> </view>
<!-- 弹窗组件 --> <!-- 弹窗组件 -->
<save-dialog :show="showDialog" :editData="currentEditData" @update:show="showDialog = $event" /> <SaveDialog :show="showDialog" :editData="currentEditData" @update:show="showDialog = $event" />
</view> </view>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.page { .page {
background-color: #e6f5e8; background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH; mix-blend-mode: NOTTHROUGH;
width: 100%; width: 100%;
...@@ -900,5 +942,5 @@ function onHelpClick(help: any) { ...@@ -900,5 +942,5 @@ function onHelpClick(help: any) {
width: 32rpx; width: 32rpx;
height: 32rpx; height: 32rpx;
} }
} }
</style> </style>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" width="64px" height="64.00px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M402.432 307.968m-286.5152 0a286.5152 286.5152 0 1 0 573.0304 0 286.5152 286.5152 0 1 0-573.0304 0Z" fill="#9FDFFF" /><path d="M731.648 498.5856m-253.0816 0a253.0816 253.0816 0 1 0 506.1632 0 253.0816 253.0816 0 1 0-506.1632 0Z" fill="#78CCFF" /><path d="M268.4416 522.4448m-229.2224 0a229.2224 229.2224 0 1 0 458.4448 0 229.2224 229.2224 0 1 0-458.4448 0Z" fill="#78CCFF" /><path d="M266.0864 522.4448h463.2064v229.2224H266.0864z" fill="#78CCFF" /><path d="M543.6416 260.864l-187.9552 293.888 189.7472 27.648L450.56 803.84l281.088-289.8944-213.8624-32.3584z" fill="#FFB612" /><path d="M297.6256 904.9088c0 37.8368-27.2896 68.4544-60.928 68.4544s-60.928-30.6688-60.928-68.4544c0-37.8368 60.928-112.7424 60.928-112.7424s60.928 74.9056 60.928 112.7424zM664.6784 904.9088c0 37.8368-27.2896 68.4544-60.928 68.4544s-60.928-30.6688-60.928-68.4544c0-37.8368 60.928-112.7424 60.928-112.7424s60.928 74.9056 60.928 112.7424z" fill="#78CCFF" /><path d="M481.1264 904.9088c0 37.8368-27.2896 68.4544-60.928 68.4544s-60.928-30.6688-60.928-68.4544c0-37.8368 60.928-112.7424 60.928-112.7424s60.928 74.9056 60.928 112.7424zM848.2304 904.9088c0 37.8368-27.2896 68.4544-60.928 68.4544s-60.928-30.6688-60.928-68.4544c0-37.8368 60.928-112.7424 60.928-112.7424s60.928 74.9056 60.928 112.7424z" fill="#9FDFFF" /></svg>
\ No newline at end of file
...@@ -11,7 +11,7 @@ interface AreaNode { ...@@ -11,7 +11,7 @@ interface AreaNode {
* 将areaList转换为树形结构(省市县三级联动) * 将areaList转换为树形结构(省市县三级联动)
* @returns 树形结构的地区数据 * @returns 树形结构的地区数据
*/ */
export const convertToTree = (): AreaNode[] => { export function convertToTree(): AreaNode[] {
const { province_list, city_list, county_list } = areaList const { province_list, city_list, county_list } = areaList
const tree: AreaNode[] = [] const tree: AreaNode[] = []
...@@ -56,7 +56,7 @@ export const convertToTree = (): AreaNode[] => { ...@@ -56,7 +56,7 @@ export const convertToTree = (): AreaNode[] => {
// 导出树形结构数据(懒加载) // 导出树形结构数据(懒加载)
let areaTreeCache: AreaNode[] | null = null let areaTreeCache: AreaNode[] | null = null
export const getAreaTree = (): AreaNode[] => { export function getAreaTree(): AreaNode[] {
if (!areaTreeCache) { if (!areaTreeCache) {
areaTreeCache = convertToTree() areaTreeCache = convertToTree()
} }
...@@ -71,18 +71,18 @@ export const areaTree = getAreaTree() ...@@ -71,18 +71,18 @@ export const areaTree = getAreaTree()
* @param code 地区代码 * @param code 地区代码
* @returns 完整的地区名称 * @returns 完整的地区名称
*/ */
export const getFullAreaName = (code: string): string => { export function getFullAreaName(code: string): string {
const { province_list, city_list, county_list } = areaList const { province_list, city_list, county_list } = areaList
let name = '' let name = ''
if (county_list[code]) { if (county_list[code]) {
// 如果是区县代码,获取完整的省市县名称 // 如果是区县代码,获取完整的省市县名称
const cityCode = code.substring(0, 4) + '00' const cityCode = `${code.substring(0, 4)}00`
const provinceCode = code.substring(0, 2) + '0000' const provinceCode = `${code.substring(0, 2)}0000`
name = `${province_list[provinceCode]}${city_list[cityCode]}${county_list[code]}` name = `${province_list[provinceCode]}${city_list[cityCode]}${county_list[code]}`
} else if (city_list[code]) { } else if (city_list[code]) {
// 如果是城市代码,获取完整的省市名称 // 如果是城市代码,获取完整的省市名称
const provinceCode = code.substring(0, 2) + '0000' const provinceCode = `${code.substring(0, 2)}0000`
name = `${province_list[provinceCode]}${city_list[code]}` name = `${province_list[provinceCode]}${city_list[code]}`
} else if (province_list[code]) { } else if (province_list[code]) {
// 如果是省份代码,直接返回省份名称 // 如果是省份代码,直接返回省份名称
...@@ -115,7 +115,5 @@ export function getCodeByText(text) { ...@@ -115,7 +115,5 @@ export function getCodeByText(text) {
return entry ? entry[0] : null return entry ? entry[0] : null
} }
return findCode(areaList.province_list) return findCode(areaList.province_list) || findCode(areaList.city_list) || findCode(areaList.county_list)
|| findCode(areaList.city_list)
|| findCode(areaList.county_list)
} }
...@@ -6,11 +6,11 @@ export default { ...@@ -6,11 +6,11 @@ export default {
/** /**
* 服务协议地址 * 服务协议地址
*/ */
services: 'https://app.yiring.com/agri/app/agreement.html', services: 'https://app.yiring.com/agri/services.html',
/** /**
* 隐私政策地址 * 隐私政策地址
*/ */
privacy: 'https://app.yiring.com/agri/app/guide.html', privacy: 'https://app.yiring.com/agri/privacy.html',
/** /**
* 从内部打开指定页面 * 从内部打开指定页面
......
...@@ -206,7 +206,7 @@ export function downloadFile(options: DownloadOptions): Promise<DownloadResult> ...@@ -206,7 +206,7 @@ export function downloadFile(options: DownloadOptions): Promise<DownloadResult>
/* #endif */ /* #endif */
// 其他平台使用原生下载 // 其他平台使用原生下载
/* #ifndef H5*/ /* #ifndef H5 */
return downloadFileForNative(options) return downloadFileForNative(options)
/* #endif */ /* #endif */
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论