| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302 |
- <template>
- <view class="dashboard-container">
- <!-- 顶部 TopBar -->
- <view class="top-bar">
- <text class="greeting">农事有序,心里有数</text>
- <text class="top-sub-guide">从今天的田间环境开始</text>
- </view>
- <!-- 田间环境/天气区域 (降级为扁平状态块) -->
- <view class="environmental-status-block" @click="showWeatherDetail">
- <view class="status-main">
- <view class="main-info">
- <text class="main-text">{{ weatherData.infos.temperature }}° · {{ weatherData.infos.weather }}</text>
- <text class="fixed-subtitle">田间环境概览</text>
- </view>
- <view class="refresh-btn" :class="{ 'rotating': isLoadingWeather }" @click.stop="handleRefresh">
- <u-icon name="reload" :color="isLoadingWeather ? '#999' : '#3BB44A'" size="20"></u-icon>
- </view>
- </view>
- <view class="metrics-row">
- <view class="metric-item">
- <text class="label">湿度</text>
- <text class="value">{{ weatherData.infos.humidity }}%</text>
- </view>
- <view class="metric-item">
- <text class="label">风力</text>
- <text class="value">{{ weatherData.infos.wind_power_v2 }}</text>
- </view>
- <view class="metric-item">
- <text class="label">气压</text>
- <text class="value">{{ weatherData.infos.air_pressure }} hPa</text>
- </view>
- </view>
-
- <view class="update-time" v-if="weatherData.update_time">
- <text>更新时间:{{ weatherData.update_time }}</text>
- </view>
- </view>
- <!-- AI 主卡 -->
- <view class="card ai-card">
- <view class="ai-header">
- <view class="ai-pill">AI 农小禹</view>
- <text class="ai-subtitle">今天安排从这里开始</text>
- </view>
- <view class="ai-body">
- <text class="ai-title">{{ aiQuestion.title }}</text>
- <text class="ai-desc">问问 AI 农小禹,给你具体建议</text>
- </view>
- <view class="ai-footer">
- <view class="ai-cta">
- <u-button
- type="primary"
- color="#2F7D32"
- shape="round"
- :custom-style="{
- height: '60rpx',
- width: 'auto',
- minWidth: '200rpx',
- borderRadius: '30rpx',
- padding: '0 32rpx',
- fontSize: '28rpx',
- fontWeight: '600',
- margin: '0'
- }"
- @click="goToAI"
- >
- 立即提问
- <u-icon name="arrow-right" color="white" size="16" style="margin-left: 8rpx;"></u-icon>
- </u-button>
- </view>
- </view>
- <!-- 玻璃感噪点纹理 -->
- <view class="ai-texture"></view>
- </view>
- <!-- 农资精选 -->
- <view class="card">
- <view class="card-header">
- <view class="title-section">
- <view class="title-line"></view>
- <text class="card-title">农资精选</text>
- </view>
- <view class="more-btn" @click="goToMall">
- <text>去农资</text>
- <u-icon name="arrow-right" color="#3BB44A" size="14"></u-icon>
- </view>
- </view>
- <view class="products-grid">
- <view
- class="product-card"
- v-for="(product, index) in products"
- :key="index"
- @click="showProductDetail(product)"
- >
- <image
- :src="product.image"
- mode="aspectFill"
- class="product-image"
- lazy-load
- ></image>
- <view class="product-info">
- <text class="product-title">{{ product.title }}</text>
- <text class="product-desc">{{ product.desc }}</text>
- <view class="price-row">
- <text class="price">¥{{ product.price }}</text>
- <text class="unit">/{{ product.unit }}</text>
- </view>
- <u-button
- type="primary"
- color="linear-gradient(135deg, #3BB44A, #66CC6A)"
- size="mini"
- shape="round"
- >
- 了解更多
- </u-button>
- </view>
- </view>
- </view>
- </view>
- <!-- 农技推荐 -->
- <view class="card">
- <view class="card-header">
- <view class="title-section">
- <view class="title-line"></view>
- <text class="card-title">农技推荐</text>
- </view>
- <view class="more-btn" @click="goToKnowledge">
- <text>更多</text>
- <u-icon name="arrow-right" color="#3BB44A" size="14"></u-icon>
- </view>
- </view>
- <view class="articles-list">
- <view
- class="article-card"
- v-for="(article, index) in articles"
- :key="index"
- @click="showArticleDetail(article)"
- >
- <view class="article-image-wrapper">
- <image
- :src="article.image"
- mode="aspectFill"
- class="article-image"
- lazy-load
- ></image>
- <view class="article-tag">文章</view>
- </view>
- <view class="article-info">
- <text class="article-title">{{ article.title }}</text>
- <text class="article-source">{{ article.source }}</text>
- <view class="article-stats">
- <u-icon name="eye" color="#999" size="12"></u-icon>
- <text class="read-count">{{ article.readCount }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 天气详情弹窗 -->
- <!-- <u-popup
- :show="showWeatherPopup"
- mode="bottom"
- round="20"
- @close="showWeatherPopup = false"
- >
- <view class="popup-content">
- <view class="popup-header">
- <text class="popup-title">今日农事详情</text>
- <u-icon name="close" color="#999" size="20" @click="showWeatherPopup = false"></u-icon>
- </view>
- <view class="weather-detail">
- <view class="detail-item">
- <text class="detail-label">天气状况</text>
- <text class="detail-value">{{ weatherData.weatherText }}</text>
- </view>
- <view class="detail-item">
- <text class="detail-label">当前温度</text>
- <text class="detail-value">{{ weatherData.tempNow }}°C</text>
- </view>
- <view class="detail-item">
- <text class="detail-label">湿度</text>
- <text class="detail-value">{{ weatherData.humidity }}%</text>
- </view>
- <view class="detail-item">
- <text class="detail-label">风力</text>
- <text class="detail-value">{{ weatherData.windScale }}级</text>
- </view>
- <view class="detail-item">
- <text class="detail-label">降水量</text>
- <text class="detail-value">{{ weatherData.precipMm }}mm</text>
- </view>
- <view class="advice-detail">
- <text class="advice-label">今日建议:</text>
- <text class="advice-content">{{ weatherData.adviceText }}</text>
- </view>
- </view>
- <u-button
- type="primary"
- color="linear-gradient(135deg, #3BB44A, #66CC6A)"
- shape="round"
- @click="askAIAboutWeather"
- >
- 去问 AI
- </u-button>
- </view>
- </u-popup> -->
- <!-- 文章详情弹窗 -->
- <u-popup
- :show="showArticlePopup"
- mode="bottom"
- round="20"
- @close="showArticlePopup = false"
- >
- <view class="popup-content">
- <view class="popup-header">
- <text class="popup-title">文章详情</text>
- <u-icon name="close" color="#999" size="20" @click="showArticlePopup = false"></u-icon>
- </view>
- <view class="article-detail" v-if="currentArticle">
- <text class="article-detail-title">{{ currentArticle.title }}</text>
- <text class="article-detail-time">{{ currentArticle.time }}</text>
- <view class="article-detail-content">
- <text class="content-paragraph">{{ currentArticle.content }}</text>
- <text class="content-subtitle">主要要点:</text>
- <view class="content-list">
- <text class="list-item" v-for="(item, index) in currentArticle.points" :key="index">
- • {{ item }}
- </text>
- </view>
- </view>
- </view>
- <u-button
- type="primary"
- color="linear-gradient(135deg, #3BB44A, #66CC6A)"
- shape="round"
- @click="askAIAboutArticle"
- >
- 去问 AI
- </u-button>
- </view>
- </u-popup>
- </view>
- </template>
- <script setup>
- import { ref, reactive, onMounted } from 'vue'
- import { getWeatherInfo, getLocation } from '@/api/services/weather.js'
- import { getMallList } from '@/api/services/mall.js'
- import { getTopArticles } from '@/api/services/knowledge.js'
- // 天气数据
- const weatherData = reactive({
- infos: {
- weather: "加载中...",
- temperature: "--",
- humidity: "--",
- wind_power_v2: "--",
- air_pressure: "--"
- },
- update_time: "" // 更新时间
- })
- // 加载状态
- const isLoadingWeather = ref(false)
- const aiQuestions = [
- {
- title: '叶片发黄该从哪查?',
- recommend: '最近阴雨天多,管理要点?'
- },
- {
- title: '水稻分蘖期怎么管理?',
- recommend: '如何提高分蘖成穗率?'
- },
- {
- title: '玉米倒伏了怎么办?',
- recommend: '预防玉米倒伏的措施?'
- }
- ]
- const aiQuestion = ref(aiQuestions[0])
- // 商品列表数据
- const products = ref([])
- // 文章列表数据
- const articles = ref([])
- // 弹窗控制
- const showWeatherPopup = ref(false)
- const showArticlePopup = ref(false)
- const currentArticle = ref(null)
- // 方法
- const showTip = () => {
- uni.showToast({
- title: '建议先看今日农事,再去问 AI',
- icon: 'none',
- duration: 2000
- })
- }
- const showWeatherDetail = () => {
- showWeatherPopup.value = true
- }
- const showArticleDetail = (article) => {
- if (!article.id) {
- uni.showToast({
- title: '文章信息不完整',
- icon: 'none',
- duration: 2000
- })
- return;
- }
-
- // 跳转到农技详情页
- uni.navigateTo({
- url: `/pages/knowledge/detail?id=${article.id}`
- })
- }
- const showProductDetail = (product) => {
- if (!product.id) {
- uni.showToast({
- title: '商品信息不完整',
- icon: 'none',
- duration: 2000
- })
- return;
- }
-
- // 跳转到农资详情页
- uni.navigateTo({
- url: `/pages/service/mall-detail?id=${product.id}`
- })
- }
- const goToAI = () => {
- uni.switchTab({
- url: '/pages/knowledge/ai-chat/index'
- });
- }
- const goToMall = () => {
- uni.switchTab({
- url: '/pages/service/mall'
- })
- }
- const goToKnowledge = () => {
- uni.switchTab({
- url: '/pages/knowledge/index'
- })
- }
- const askAIAboutWeather = () => {
- showWeatherPopup.value = false
- uni.navigateTo({
- url: '/pages/knowledge/ai-chat/index?question=' + encodeURIComponent('今日天气适宜哪些农事活动?')
- })
- }
- const askAIAboutArticle = () => {
- showArticlePopup.value = false
- if (currentArticle.value) {
- uni.navigateTo({
- url: '/pages/knowledge/ai-chat/index?question=' + encodeURIComponent('关于' + currentArticle.value.title + '有什么建议?')
- })
- }
- }
- const handleRefresh = () => {
- if (isLoadingWeather.value) {
- uni.showToast({
- title: '正在刷新中...',
- icon: 'none',
- duration: 1500
- });
- return;
- }
- fetchWeatherData(true);
- }
- /**
- * 获取实时天气数据
- */
- const fetchWeatherData = async (showToast = false) => {
- if (isLoadingWeather.value) {
- return;
- }
-
- // 如果是手动刷新,显示提示
- if (showToast) {
- uni.showToast({
- title: '正在刷新天气...',
- icon: 'loading',
- duration: 2000
- });
- }
-
- isLoadingWeather.value = true;
-
- try {
- // 1. 获取当前位置
- const location = await getLocation();
- console.log('获取到位置信息:', location);
-
- // 2. 根据位置查询天气
- const weatherResult = await getWeatherInfo({
- latitude: location.latitude,
- longitude: location.longitude,
- type: 'now', // 查询实时天气
- added_fields: 'air' // 附加空气质量信息
- });
-
- console.log('天气查询结果:', weatherResult);
-
- // 3. 更新天气数据
- if (weatherResult && weatherResult.result && weatherResult.result.realtime) {
- const realtime = weatherResult.result.realtime;
- const infos = realtime[0].infos || {};
-
- weatherData.infos = {
- weather: infos.weather || '未知',
- temperature: infos.temperature !== undefined ? infos.temperature : '--',
- humidity: infos.humidity !== undefined ? infos.humidity : '--',
- wind_power_v2: infos.wind_power_v2 || '--',
- air_pressure: infos.air_pressure !== undefined ? infos.air_pressure : '--'
- };
-
- // 更新时间
- weatherData.update_time = realtime.update_time || '';
-
- console.log('天气数据更新成功:', weatherData);
-
- // 刷新成功提示
- if (showToast) {
- uni.showToast({
- title: '刷新成功',
- icon: 'success',
- duration: 1500
- });
- }
- }
- } catch (error) {
- console.error('获取天气失败:', error);
- uni.showToast({
- title: `${error}`,
- icon: 'none',
- duration: 2000
- })
- // 错误处理
- let errorMsg = '获取天气失败';
- if (error.errMsg) {
- if (error.errMsg.includes('auth deny')) {
- errorMsg = '定位权限被拒绝,请在设置中开启定位权限';
- } else if (error.errMsg.includes('timeout')) {
- errorMsg = '定位超时,请检查网络连接';
- }
- } else if (error.message) {
- errorMsg = error.message;
- }
-
- uni.showToast({
- title: errorMsg,
- icon: 'none',
- duration: 2000
- });
-
- // 设置默认值
- weatherData.infos = {
- weather: "暂无数据",
- temperature: "--",
- humidity: "--",
- wind_power_v2: "--",
- air_pressure: "--"
- };
- } finally {
- isLoadingWeather.value = false;
- }
- }
- /**
- * 获取第一张图片地址
- * @param {string} swiperImages - 图片地址字符串,可能包含多个用逗号分隔的地址
- * @returns {string} - 返回第一张图片地址
- */
- const getFirstImage = (swiperImages) => {
- if (!swiperImages) {
- return '/static/images/products/agriculture-tools.jpg';
- }
-
- // 如果包含逗号,说明有多张图片,取第一张
- if (swiperImages.includes(',')) {
- return swiperImages.split(',')[0].trim();
- }
-
- // 否则直接返回
- return swiperImages;
- }
- /**
- * 格式化阅读量显示
- * @param {number} count - 阅读量数字
- * @returns {string} - 格式化后的阅读量(如:1.2k)
- */
- const formatReadCount = (count) => {
- if (!count || count === 0) return '0';
- if (count >= 1000) {
- return (count / 1000).toFixed(1) + 'k';
- }
- return count.toString();
- }
- /**
- * 获取推荐商品列表
- */
- const fetchRecommendedProducts = async () => {
- try {
- const result = await getMallList({
- isRecommended: 1, // 查询推荐商品
- pageNum: 1,
- pageSize: 4 // 只获取4个推荐商品
- });
-
- console.log('推荐商品查询结果:', result);
-
- if (result.data && result.data.rows && result.data.rows.length > 0) {
- // 映射后端数据到前端展示格式
- products.value = result.data.rows.map(item => ({
- id: item.id,
- title: item.name || item.title || '商品名称',
- desc: item.description || item.desc || '暂无描述',
- price: item.price || '0',
- unit: item.unit || '件',
- image: getFirstImage(item.swiperImages)
- }));
-
- console.log('推荐商品数据更新成功:', products.value);
- } else {
- // 如果没有推荐商品,使用默认数据
- console.log('暂无推荐商品,使用默认数据');
- products.value = [
- {
- title: '优质玉米种子',
- desc: '高产抗病品种',
- price: '68',
- unit: '袋',
- image: '/static/images/products/corn-seeds-new.jpg'
- },
- {
- title: '有机肥料',
- desc: '纯天然环保',
- price: '128',
- unit: '袋',
- image: '/static/images/products/organic-fertilizer-new.jpg'
- },
- {
- title: '杀虫剂',
- desc: '广谱高效',
- price: '45',
- unit: '瓶',
- image: '/static/images/products/insecticide.jpg'
- },
- {
- title: '农用地膜',
- desc: '保湿保温',
- price: '89',
- unit: '卷',
- image: '/static/images/products/plastic-film.jpg'
- }
- ];
- }
- } catch (error) {
- console.error('获取推荐商品失败:', error);
- // 失败时使用默认数据
- products.value = [
- {
- title: '优质玉米种子',
- desc: '高产抗病品种',
- price: '68',
- unit: '袋',
- image: '/static/images/products/corn-seeds-new.jpg'
- },
- {
- title: '有机肥料',
- desc: '纯天然环保',
- price: '128',
- unit: '袋',
- image: '/static/images/products/organic-fertilizer-new.jpg'
- },
- {
- title: '杀虫剂',
- desc: '广谱高效',
- price: '45',
- unit: '瓶',
- image: '/static/images/products/insecticide.jpg'
- },
- {
- title: '农用地膜',
- desc: '保湿保温',
- price: '89',
- unit: '卷',
- image: '/static/images/products/plastic-film.jpg'
- }
- ];
- }
- }
- /**
- * 获取热门文章列表(根据阅读量)
- */
- const fetchTopArticles = async () => {
- try {
- const result = await getTopArticles();
-
- console.log('热门文章查询结果:', result);
-
- if (result.data && result.data.length > 0) {
- // 映射后端数据到前端展示格式
- articles.value = result.data.slice(0, 4).map(item => ({
- id: item.id,
- title: item.title || '文章标题',
- source: item.category || item.source || '农技知识',
- readCount: formatReadCount(item.viewCount || item.readCount || 0),
- image: getFirstImage(item.imageUrl) || '/static/images/rice-farming/rice-field1.jpg',
- time: item.createTime || item.publishTime || '',
- content: item.content || item.summary || '暂无内容',
- points: [] // 后端如果有要点字段可以映射
- }));
-
- console.log('热门文章数据更新成功:', articles.value);
- } else {
- // 如果没有热门文章,使用默认数据
- console.log('暂无热门文章,使用默认数据');
- articles.value = [
- {
- title: '春季水稻种植技术要点',
- source: '农技知识',
- readCount: '1.2k',
- image: '/static/images/rice-farming/rice-field1.jpg',
- time: '2024-03-15',
- content: '春季是水稻种植的关键时期,需要掌握以下技术要点。',
- points: []
- },
- {
- title: '玉米病虫害防治指南',
- source: '植保技术',
- readCount: '856',
- image: '/static/images/rice-farming/rice-field2.jpg',
- time: '2024-03-14',
- content: '玉米病虫害防治是确保产量的重要环节。',
- points: []
- },
- {
- title: '现代农业机械化作业规范',
- source: '农机管理',
- readCount: '2.1k',
- image: '/static/images/rice-farming/rice-field3.jpg',
- time: '2024-03-13',
- content: '提升农业机械化作业水平是现代农业发展的必然要求。',
- points: []
- },
- {
- title: '土壤肥力提升与改良方案',
- source: '土肥管理',
- readCount: '1.5k',
- image: '/static/images/rice-farming/rice-field4.jpg',
- time: '2024-03-12',
- content: '健康的土壤是丰收的基础。',
- points: []
- }
- ];
- }
- } catch (error) {
- console.error('获取热门文章失败:', error);
- // 失败时使用默认数据
- articles.value = [
- {
- title: '春季水稻种植技术要点',
- source: '农技知识',
- readCount: '1.2k',
- image: '/static/images/rice-farming/rice-field1.jpg',
- time: '2024-03-15',
- content: '春季是水稻种植的关键时期,需要掌握以下技术要点。',
- points: []
- },
- {
- title: '玉米病虫害防治指南',
- source: '植保技术',
- readCount: '856',
- image: '/static/images/rice-farming/rice-field2.jpg',
- time: '2024-03-14',
- content: '玉米病虫害防治是确保产量的重要环节。',
- points: []
- },
- {
- title: '现代农业机械化作业规范',
- source: '农机管理',
- readCount: '2.1k',
- image: '/static/images/rice-farming/rice-field3.jpg',
- time: '2024-03-13',
- content: '提升农业机械化作业水平是现代农业发展的必然要求。',
- points: []
- },
- {
- title: '土壤肥力提升与改良方案',
- source: '土肥管理',
- readCount: '1.5k',
- image: '/static/images/rice-farming/rice-field4.jpg',
- time: '2024-03-12',
- content: '健康的土壤是丰收的基础。',
- points: []
- }
- ];
- }
- }
- // 页面加载时获取天气、推荐商品和热门文章
- onMounted(() => {
- fetchWeatherData();
- fetchRecommendedProducts();
- fetchTopArticles();
- })
- </script>
- <style lang="scss" scoped>
- .dashboard-container {
- padding: 24rpx;
- background-color: #F6FDF9;
- min-height: 100vh;
- }
- // 顶部 TopBar
- .top-bar {
- display: flex;
- flex-direction: column;
- justify-content: flex-start;
- align-items: flex-start;
- margin-bottom: 12rpx;
- padding: 0 8rpx;
- .greeting {
- font-size: 32rpx;
- font-weight: 600;
- color: #1A3026;
- letter-spacing: 1rpx;
- line-height: 1.4;
- }
- .top-sub-guide {
- font-size: 24rpx;
- color: rgba(0, 0, 0, 0.45);
- margin-top: 4rpx;
- }
- }
- // Card 基础样式(复用旧首页)
- .card {
- background: white;
- border-radius: 20rpx;
- box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.04), 0 1rpx 4rpx rgba(0, 0, 0, 0.02);
- margin-bottom: 24rpx;
- overflow: hidden;
- .card-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 24rpx 28rpx;
- border-bottom: 1px solid rgba(0, 0, 0, 0.03);
- .title-section {
- display: flex;
- align-items: center;
- .title-line {
- width: 4rpx;
- height: 28rpx;
- border-radius: 0;
- background: linear-gradient(180deg, #3BB44A, #66CC6A);
- margin-right: 16rpx;
- }
- .card-title {
- font-size: 28rpx;
- font-weight: 600;
- color: #2C3E50;
- }
- }
- .tag {
- background: linear-gradient(135deg, #3BB44A, #66CC6A);
- color: white;
- font-size: 22rpx;
- padding: 6rpx 16rpx;
- border-radius: 16rpx;
- }
- .more-btn {
- display: flex;
- align-items: center;
- color: #3BB44A;
- font-size: 24rpx;
- text {
- margin-right: 6rpx;
- }
- }
- }
- }
- // 田间环境状态块 (降级为扁平化背景块)
- .environmental-status-block {
- position: relative;
- padding: 24rpx 28rpx;
- background: linear-gradient(135deg, #FFFFFF 0%, #F4FAF7 100%);
- border: 1rpx solid rgba(59, 180, 74, 0.08);
- border-radius: 24rpx;
- margin-bottom: 24rpx;
- overflow: hidden;
- .status-main {
- display: flex;
- justify-content: space-between;
- // align-items: flex-end;
- margin-bottom: 20rpx;
- .main-info {
- display: flex;
- flex-direction: column;
- .main-text {
- font-size: 48rpx;
- font-weight: 800;
- color: #1A3026;
- line-height: 1;
- }
- .fixed-subtitle {
- font-size: 24rpx;
- color: #7A9086;
- margin-top: 8rpx;
- }
- }
-
- .refresh-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 60rpx;
- height: 60rpx;
- border-radius: 50%;
- background: rgba(59, 180, 74, 0.08);
- transition: all 0.3s ease;
-
- &:active {
- background: rgba(59, 180, 74, 0.15);
- transform: scale(0.95);
- }
-
- &.rotating {
- animation: rotate 1s linear infinite;
- }
- }
- }
-
- @keyframes rotate {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
- }
- .metrics-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-top: 16rpx;
- border-top: 1rpx solid rgba(0, 0, 0, 0.03);
- .metric-item {
- flex: 1;
- display: flex;
- align-items: center;
- gap: 8rpx;
- .label {
- font-size: 22rpx;
- color: #8EAC9D;
- }
- .value {
- font-size: 24rpx;
- font-weight: 600;
- color: #2D4035;
- }
- }
- }
-
- .update-time {
- margin-top: 12rpx;
- text-align: right;
-
- text {
- font-size: 20rpx;
- color: #999;
- }
- }
- }
- // AI 主卡
- .ai-card {
- position: relative;
- background: linear-gradient(135deg, rgba(59, 180, 74, 0.18), rgba(102, 204, 106, 0.10));
- border: 1rpx solid rgba(59, 180, 74, 0.08);
- border-radius: 20rpx;
- box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.04), 0 1rpx 4rpx rgba(0, 0, 0, 0.02);
- margin-bottom: 24rpx;
- overflow: hidden;
- transition: transform 0.2s ease, box-shadow 0.2s ease;
- &:active {
- transform: scale(0.99);
- box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
- }
- // 多层背景光斑效果 (底层氛围)
- &::before {
- content: '';
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background:
- radial-gradient(circle at 85% 25%, rgba(59, 180, 74, 0.22), transparent 60%),
- radial-gradient(circle at 20% 80%, rgba(76, 175, 80, 0.14), transparent 55%);
- pointer-events: none;
- z-index: 1;
- }
- // 抽象 AI 设计母题层 (右侧增强设计感)
- &::after {
- content: '';
- position: absolute;
- top: -20%;
- right: -10%;
- width: 80%;
- height: 140%;
- background:
- radial-gradient(circle at 75% 35%, rgba(59, 180, 74, 0.06) 0%, transparent 45%),
- radial-gradient(circle at 85% 65%, rgba(76, 175, 80, 0.04) 0%, transparent 40%),
- radial-gradient(circle at 60% 85%, rgba(59, 180, 74, 0.03) 0%, transparent 50%);
- filter: blur(30rpx);
- pointer-events: none;
- z-index: 2;
- }
- .ai-texture {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: repeating-linear-gradient(
- 45deg,
- transparent,
- transparent 2rpx,
- rgba(255, 255, 255, 0.03) 2rpx,
- rgba(255, 255, 255, 0.03) 4rpx
- );
- pointer-events: none;
- z-index: 2;
- opacity: 0.5;
- }
- .ai-header {
- position: relative;
- z-index: 3;
- display: flex;
- flex-direction: row;
- align-items: center;
- padding: 32rpx 28rpx 16rpx;
- .ai-pill {
- background: #FFFFFF;
- color: #3BB44A;
- font-size: 24rpx;
- font-weight: 600;
- padding: 8rpx 24rpx;
- border-radius: 40rpx;
- margin-right: 20rpx;
- margin-bottom: 0;
- }
- .ai-subtitle {
- font-size: 28rpx;
- color: #5C6A70;
- font-weight: 500;
- }
- }
- .ai-body {
- position: relative;
- z-index: 3;
- padding: 12rpx 28rpx 20rpx;
- .ai-title {
- font-size: 40rpx;
- font-weight: 700;
- color: #2C3E50;
- line-height: 1.3;
- margin-bottom: 12rpx;
- display: block;
- }
- .ai-desc {
- font-size: 26rpx;
- color: rgba(44, 62, 80, 0.6);
- line-height: 1.4;
- display: block;
- }
- }
- .ai-footer {
- position: relative;
- z-index: 3;
- display: flex;
- justify-content: flex-start;
- padding: 16rpx 28rpx 24rpx;
- .ai-cta {
- display: flex;
- align-items: center;
- }
- }
- }
- // 农资精选
- .products-grid {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 16rpx;
- padding: 16rpx;
- .product-card {
- background: white;
- border-radius: 16rpx;
- overflow: hidden;
- box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
- border: 1px solid rgba(0, 0, 0, 0.02);
- .product-image {
- width: 100%;
- height: 160rpx;
- background: #f5f5f5;
- }
- .product-info {
- padding: 16rpx;
- .product-title {
- font-size: 26rpx;
- font-weight: 600;
- color: #2C3E50;
- margin-bottom: 6rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .product-desc {
- font-size: 22rpx;
- color: #8C9396;
- margin-bottom: 12rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .price-row {
- display: flex;
- align-items: baseline;
- margin-bottom: 12rpx;
- .price {
- font-size: 32rpx;
- font-weight: 700;
- color: #3BB44A;
- }
- .unit {
- font-size: 22rpx;
- color: #8C9396;
- margin-left: 4rpx;
- }
- }
- }
- }
- }
- // 农技推荐
- .articles-list {
- padding: 16rpx;
- .article-card {
- display: flex;
- background: white;
- border-radius: 16rpx;
- overflow: hidden;
- box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
- border: 1px solid rgba(0, 0, 0, 0.02);
- margin-bottom: 16rpx;
- .article-image-wrapper {
- position: relative;
- width: 200rpx;
- height: 140rpx;
- flex-shrink: 0;
- .article-image {
- width: 100%;
- height: 100%;
- background: #f5f5f5;
- }
- .article-tag {
- position: absolute;
- top: 8rpx;
- left: 8rpx;
- background: #2196F3;
- color: white;
- font-size: 20rpx;
- padding: 4rpx 8rpx;
- border-radius: 6rpx;
- }
- }
- .article-info {
- flex: 1;
- padding: 16rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .article-title {
- font-size: 26rpx;
- font-weight: 600;
- color: #2C3E50;
- margin-bottom: 6rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .article-source {
- font-size: 22rpx;
- color: #8C9396;
- margin-bottom: 8rpx;
- }
- .article-stats {
- display: flex;
- align-items: center;
- .read-count {
- font-size: 22rpx;
- color: #999;
- margin-left: 6rpx;
- }
- }
- }
- }
- }
- // 弹窗样式
- .popup-content {
- padding: 32rpx;
- max-height: 80vh;
- overflow-y: auto;
- .popup-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 24rpx;
- .popup-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #2C3E50;
- }
- }
- .weather-detail {
- margin-bottom: 32rpx;
- .detail-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 16rpx 0;
- border-bottom: 1px solid rgba(0, 0, 0, 0.03);
- .detail-label {
- font-size: 26rpx;
- color: #8C9396;
- }
- .detail-value {
- font-size: 26rpx;
- font-weight: 600;
- color: #2C3E50;
- }
- }
- .advice-detail {
- margin-top: 24rpx;
- padding: 20rpx;
- background: rgba(59, 180, 74, 0.05);
- border-radius: 16rpx;
- .advice-label {
- font-size: 26rpx;
- font-weight: 600;
- color: #2C3E50;
- margin-bottom: 8rpx;
- }
- .advice-content {
- font-size: 26rpx;
- color: #2C3E50;
- line-height: 1.4;
- }
- }
- }
- .article-detail {
- margin-bottom: 32rpx;
- .article-detail-title {
- font-size: 32rpx;
- font-weight: 700;
- color: #2C3E50;
- margin-bottom: 12rpx;
- }
- .article-detail-time {
- font-size: 22rpx;
- color: #8C9396;
- margin-bottom: 24rpx;
- }
- .article-detail-content {
- .content-paragraph {
- font-size: 26rpx;
- color: #2C3E50;
- line-height: 1.6;
- margin-bottom: 20rpx;
- }
- .content-subtitle {
- font-size: 28rpx;
- font-weight: 600;
- color: #2C3E50;
- margin-bottom: 12rpx;
- }
- .content-list {
- .list-item {
- font-size: 26rpx;
- color: #2C3E50;
- line-height: 1.5;
- margin-bottom: 8rpx;
- }
- }
- }
- }
- }
- // 旋转动画
- @keyframes rotate {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
- }
- </style>
|