提交 50ba3d74 作者: 方治民
......@@ -6,6 +6,7 @@ enum Api {
productMarketList = '/online/cgform/api/getData/5b71e11020d44366b2d130e200c7a640', // 热门产地行情
serviceStatsList = '/online/cgform/api/getData/491863dde351404da63a1a6e8c699c4c', // 服务展示窗
agricultureClassList = '/online/cgform/api/getData/311c300e05694ba69a063d04c8572e9e', // 农技课堂
warning = '/warningInfo/list'
}
/**
......@@ -65,3 +66,14 @@ export function agricultureClassList(params = {}) {
params,
})
}
/**
* @param params 请求参数
* @returns 获取预警数据
*/
export function warning(params = {}) {
return otherHttp.get({
url: Api.warning,
params,
})
}
......@@ -8,6 +8,7 @@ enum Api {
farmMachineAddFarm = '/farmMachine/machineWork/app/addFarm', // 发布农活服务
farmMachineEdit = '/farmMachine/machineWork/edit', // 编辑农机服务
farmMachineRegister = '/farmMachine/machineWork/app/register', // 参与服务
cascaderHn = '/region/cascader/hn',
}
/**
......@@ -80,3 +81,13 @@ export function farmMachineRegister(params = {}) {
params,
})
}
/**
* 查询湖南省 市/区县/乡镇
* @returns 市/区县/乡镇
*/
export function cascaderHn() {
return otherHttp.get({
url: Api.cascaderHn,
})
}
\ No newline at end of file
......@@ -295,6 +295,16 @@
}
},
{
"path": "pages/webview/webview",
"style": {
"navigationBarTitleText": "常用工具",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2"
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "Basic APP"
......
......@@ -347,6 +347,9 @@
function onClickTool(tool: any) {
console.log('点击常用工具:', tool)
// 在这里添加具体的常用工具点击逻辑
uni.navigateTo({
url: `/pages/webview/webview?url=${encodeURIComponent(tool.addr)}`,
})
}
// 轮播视频切换的时候触发
......
<script setup lang="ts">
import { reactive } from 'vue'
import { reactive, ref } from 'vue'
import { onLoad, onReachBottom, onShow } from '@dcloudio/uni-app'
import ApplyDialog from './components/apply-dialog.vue'
......@@ -14,8 +14,10 @@
pageData.search.pageNo = 1
pageData.farmMachineList = []
getFarmMachineList()
getCascader()
})
const options = ref([])
const pageData = reactive({
loading: false,
// 分类标签
......@@ -45,6 +47,12 @@
})
}
function getCascader() {
NongjifuwuAPI.cascaderHn().then((res) => {
options.value = res[0].children;
})
}
// 分类标签点击事件
function onCategoryTabClick(tab: any) {
console.log('点击分类标签:', tab)
......@@ -78,10 +86,41 @@
applyDialogRef.value.open(item)
}
function getScope(scope: any) {
if (!scope || !options.value || options.value.length === 0) {
return []
}
const values = scope.split(',')
const labels = []
// 递归查找label
const findLabel = (nodes, value) => {
for (const node of nodes) {
if (node.value === value) {
return node.label
}
if (node.children && node.children.length > 0) {
const found = findLabel(node.children, value)
if (found) {
return found
}
}
}
return null // 如果没找到,返回原始value
}
for (const value of values) {
const label = findLabel(options.value, value.trim())
labels.push(label)
}
return labels.join(' / ')
}
onReachBottom(() => {
console.log('触底了')
if (pageData.total <= pageData.farmMachineList.length)
return
if (pageData.total <= pageData.farmMachineList.length) return
pageData.search.pageNo++
getFarmMachineList()
})
......@@ -134,7 +173,7 @@ return
>
<text class="font text_6">{{ item.name }}</text>
<text class="font_3 text_7 ellipsis" style="width: 100%; margin: 26rpx 0"
>服务范围:{{ item.scope }}</text
>服务范围:{{ getScope(item.scope) }}</text
>
</view>
<view class="flex justify-between" style="width: 100%">
......
......@@ -251,6 +251,9 @@ return
>
<view
class="codefun-flex-col codefun-justify-start codefun-items-start codefun-self-center section_3"
:style="{
'background-image': `url(${product.image})`,
}"
>
<view
v-if="product.labels_dictText.split(',').length > 0"
......@@ -418,7 +421,6 @@ return
border-bottom: solid 2rpx #eeeeee;
.section_3 {
padding: 12rpx 0 116rpx;
background-image: url('/static/images/codefun/00db5a56fec86b1852516ae34b6d443a.png');
background-size: 100% 100%;
background-repeat: no-repeat;
width: 160rpx;
......
......@@ -129,7 +129,6 @@
// 查询金刚区数据
getServiceItems()
getMenuItems()
// 查询天气信息
getWarningInfo()
// 查询热门产地行情
......@@ -138,6 +137,8 @@
getServiceStatsList()
// 农技课堂
getAgricultureClassList()
// 预警信息
getWarning()
})
// 下拉刷新
......@@ -184,15 +185,6 @@
}
})
})
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级)以上大风,请做好防范。'
})
}
// 页面数据
......@@ -228,14 +220,7 @@
serviceItems: [],
// 新闻资讯
newsItems: [
{
id: 1,
type: '最新预警',
title: '积极防范持续高温对农作物的影响',
date: dayjs().format('YYYY-MM-DD'),
},
],
newsItems: [],
// 农产品行情
productMarket: {
......@@ -307,7 +292,7 @@
function getServiceItems() {
HomeAPI.zoneList({
pageNo: 1,
pageSize: 4,
pageSize: 8,
status: 1,
type: 1,
}).then((res) => {
......@@ -316,18 +301,6 @@
pageData.serviceItems = records
})
}
function getMenuItems() {
HomeAPI.zoneList({
pageNo: 1,
pageSize: 4,
status: 1,
type: 2,
}).then((res) => {
const { records } = res
pageData.menuItems = []
pageData.menuItems = records
})
}
function getWarningInfo() {
if (!pageData.weather.lon || !pageData.weather.lat) {
return
......@@ -377,6 +350,13 @@
})
}
function getWarning() {
HomeAPI.warning().then((res) => {
const { records } = res
pageData.newsItems = records
})
}
// 菜单点击事件
function onMenuItemClick(item: any) {
console.log('点击菜单项:', item)
......@@ -384,13 +364,13 @@
}
// 农产品关注点击事件
function _onProductFollowClick(product: any) {
function onProductFollowClick(product: any) {
console.log('点击关注农产品:', product)
// 在这里添加具体的关注逻辑
}
// 查看更多农技课堂
function _onViewMoreClass() {
function onViewMoreClass() {
console.log('查看全部农技课堂')
// 在这里添加具体的查看逻辑
}
......@@ -495,7 +475,7 @@
<view class="codefun-flex-col codefun-relative group_3">
<view class="codefun-flex-col">
<view class="codefun-flex-col codefun-self-stretch group_4">
<view class="codefun-flex-col section_3" :class="{ '!pb-6': !pageData.weather.warning }">
<view class="codefun-flex-col section_3">
<view class="codefun-flex-row codefun-justify-between" style="align-items: center">
<view
class="codefun-flex-row codefun-items-center codefun-relative codefun-overflow-hidden"
......@@ -511,7 +491,7 @@
style="width: 400rpx"
>
<up-notice-bar
v-if="pageData.weather.detailedLocation !== '获取中'"
v-if="pageData.weather.detailedLocation != '获取中'"
icon=""
bgColor="#FFFFFF00"
color="#5db66f"
......@@ -617,13 +597,13 @@
>
<text class="text_12">{{ pageData.weather.warning }}</text>
</view>
</view>
</view> -->
</view>
<view class="codefun-flex-col codefun-relative section_5">
<view class="codefun-flex-row">
<view class="codefun-flex-row section_5">
<view
v-show="item.status"
v-for="item in pageData.menuItems"
v-for="item in pageData.serviceItems"
:key="item.id"
class="codefun-flex-col codefun-items-center group_10"
@click="onMenuItemClick(item)"
......@@ -632,36 +612,46 @@
<text class="font_2 mt-11">{{ item.name }}</text>
</view>
</view>
<view class="codefun-flex-row codefun-mt-20">
<view
v-show="item.status"
v-for="item in pageData.serviceItems"
<swiper
:autoplay="true"
:interval="5000"
:duration="500"
:circular="true"
:vertical="true"
:indicator-dots="false"
class="codefun-flex-row codefun-justify-between codefun-items-center section_6 warn-scroll"
>
<swiper-item
id="scroll-view-content"
v-for="item of pageData.newsItems"
:key="item.id"
class="codefun-flex-col codefun-items-center group_10"
@click="onMenuItemClick(item)"
class="codefun-flex-col"
>
<image class="image_11" :src="item.icon_url" />
<text class="font_2 mt-11">{{ item.name }}</text>
</view>
</view>
</view>
<view class="codefun-flex-row codefun-justify-between codefun-items-center section_6">
<view class="codefun-flex-col">
<view class="codefun-flex-row codefun-items-baseline" style="align-items: center">
<view class="font_5 text_17">{{ pageData.newsItems[0].type }}</view>
<view class="font_5 text_17">最新预警</view>
<view
class="codefun-flex-row"
style="flex-flow: column; justify-content: space-around; height: 90rpx"
style="
flex-flow: column;
justify-content: space-around;
height: 90rpx;
width: calc(100% - 110rpx);
"
>
<view class="font_2 text_18 ml-11">{{ pageData.newsItems[0].title }}</view>
<text class="text-26 text_20 text_21 ml-11">{{
pageData.newsItems[0].date
}}</text>
</view>
</view>
<view
class="font_2 text_18 ml-11"
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
>{{ item.title }}</view
>
<text class="text-26 text_20 text_21 ml-11">{{ item.warningDate }}</text>
</view>
<image class="image_13" src="/static/images/codefun/64d85a99ca3de5fab9ce0e8dc71aa791.png" />
<image
class="warn-image"
src="/static/images/codefun/64d85a99ca3de5fab9ce0e8dc71aa791.png"
/>
</view>
</swiper-item>
</swiper>
</view>
<view class="codefun-self-end section_7" />
</view>
......@@ -711,7 +701,7 @@
text_26: !product.isUp,
}"
>
{{ `${product.isUp ? '' : '-'}${product.percent}%` }}
{{ `${product.percent}%` }}
</text>
</view>
<!-- <view
......@@ -939,7 +929,7 @@
.section_3 {
width: 694rpx;
// margin-right: 28rpx;
padding: 28rpx;
padding: 20rpx 28rpx 58rpx;
background-image: linear-gradient(180deg, #dcfce7 0%, #f8fef9 100%);
border-radius: 16rpx;
mix-blend-mode: NOTTHROUGH;
......@@ -1116,12 +1106,12 @@
}
.section_5 {
flex-wrap: wrap;
margin-right: 28rpx;
margin-top: -34rpx;
padding: 30rpx 0 40.76rpx;
padding: 30rpx 0 30rpx;
background-color: #ffffff;
border-radius: 16rpx;
mix-blend-mode: NOTTHROUGH;
.image_11 {
border-radius: 88rpx;
......@@ -1130,6 +1120,7 @@
}
.group_10 {
margin-bottom: 15rpx;
flex: 1 1 173.5rpx;
.text_50 {
......@@ -1235,11 +1226,22 @@
line-height: 17.18rpx;
}
}
.warn-scroll {
width: 655rpx;
height: 90rpx;
.warn-image {
border-radius: 16rpx;
mix-blend-mode: NOTTHROUGH;
width: 32rpx;
height: 32rpx;
}
}
.image_13 {
border-radius: 16rpx;
mix-blend-mode: NOTTHROUGH;
width: 32rpx;
height: 40rpx;
height: 32rpx;
}
.codefun-mr-4 {
margin-right: 10rpx;
......
<template>
<view class="webview-container">
<web-view :src="url"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
url: ''
}
},
onLoad(options) {
if (options.url) {
this.url = decodeURIComponent(options.url)
} else {
uni.showToast({
title: '网址不存在',
icon: 'none'
})
uni.navigateBack()
}
}
}
</script>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论