提交 e70e0280 作者: 宇宙超人

Merge branch 'main' of https://gitee.com/mrf/agri-app

<script setup lang="ts">
// import { PUSH_CLIENT_KEY } from '/@/enums/cacheEnum'
import { useUserStore } from '@/store/modules/user'
import * as API from '/@/api/model/userInfo'
const userStore = useUserStore()
onShow(async () => {})
// 页面数据
......
......@@ -5,7 +5,9 @@
import * as HomeAPI from '@/api/model/home'
import * as NongChangAPI from '@/api/model/nongchang'
import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore()
onShow(() => {
// 获取金刚区菜单数据
getZoomList()
......@@ -17,6 +19,7 @@
getCommonToolsList()
// 农技课堂
getAgricultureClassList()
pageData.userInfo = userStore.getUserInfo
})
// 下拉刷新
......@@ -214,6 +217,10 @@
videoList: [],
},
current: 0,
// 信用分
userInfo: {
creditScore: 0,
},
})
function getZoomList() {
......@@ -270,7 +277,10 @@
// 菜单点击事件
function onMenuItemClick(item: any) {
console.log('点击菜单项:', item)
// 在这里添加具体的菜单点击逻辑
// 在这里添加具体的菜单点击逻辑+
uni.reLaunch({
url: item.jump_target,
})
}
// 农业模型点击事件
......@@ -308,6 +318,9 @@
function onDeviceManagementClick() {
console.log('设备管理')
// 在这里添加具体的设备管理逻辑
uni.navigateTo({
url: '/pages/device/device',
})
}
// 灵活用工
function onViewMoreFlexibleEmployment(type) {
......@@ -338,9 +351,41 @@
// 轮播视频切换的时候触发
function handleChangeVideo(e: any) {
// console.log('切换视频', e.detail.current)
pageData.current = e.detail.current
pageData.agricultureClass.title = pageData.agricultureClass.videoList[pageData.current]?.title
const currentIndex = e.detail.current
const prevIndex = pageData.current
pageData.current = currentIndex
pageData.agricultureClass.title = pageData.agricultureClass.videoList[currentIndex]?.title
// 延迟处理视频切换,避免卡顿
setTimeout(() => {
// 停止所有其他视频的播放(只暂停,不重置位置)
pageData.agricultureClass.videoList.forEach((_, index) => {
if (index !== currentIndex) {
try {
const videoContext = uni.createVideoContext(`video${index}`)
videoContext.pause()
// 不重置到开头,保留播放位置
} catch (error) {
console.log('停止视频失败:', error)
}
} else {
// 当前视频:尝试播放
try {
const videoContext = uni.createVideoContext(`video${index}`)
// 自动播放当前视频
videoContext.play()
} catch (error) {
console.log('播放视频失败:', error)
}
}
})
}, 100)
}
// 处理swiper过渡动画
function handleTransition(e: any) {
// 过渡期间可以做一些优化处理
console.log('swiper过渡中...')
}
// 获取视频时长
......@@ -352,11 +397,20 @@
function handleVideoPlay(currentIndex) {
pageData.agricultureClass.videoList.forEach((_, index) => {
if (index !== currentIndex) {
try {
const videoContext = uni.createVideoContext(`video${index}`)
videoContext.pause()
} catch (error) {
console.log('停止视频失败:', error)
}
}
})
}
// 视频暂停事件处理
function handleVideoPause(currentIndex) {
console.log(`视频${currentIndex}暂停`)
}
</script>
<template>
......@@ -643,7 +697,7 @@
>
<image class="image_15" :src="pageData.creditCenter.image" />
<view class="codefun-flex-col codefun-items-start group_29">
<text class="text_62">{{ pageData.creditCenter.score }}</text>
<text class="text_62">{{ pageData.userInfo.creditScore }}</text>
<text class="font_5 text_63 mt-13">{{ pageData.creditCenter.rating }}</text>
<text class="font_10 text_64 mt-13">{{ pageData.creditCenter.tips }}</text>
<view
......@@ -676,10 +730,14 @@
class="fui-banner__wrap"
circular
:indicator-dots="false"
autoplay
:interval="4000"
:duration="150"
:autoplay="false"
:interval="8000"
:duration="300"
:disable-touch="false"
:touch-angle="45"
:threshold="50"
@change="handleChangeVideo"
@transition="handleTransition"
>
<swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index">
<video
......@@ -688,8 +746,17 @@
:poster="video.cover_image"
:controls="false"
style="width: 654rpx; height: 358rpx"
:autoplay="false"
:muted="false"
:loop="false"
:show-play-btn="true"
:show-center-play-btn="true"
:enable-progress-gesture="false"
:show-progress="false"
object-fit="contain"
@loadedmetadata="handleMetadataLoaded"
@play="handleVideoPlay(index)"
@pause="handleVideoPause(index)"
></video>
</swiper-item>
</swiper>
......@@ -1496,7 +1563,7 @@
.equal-division_6 {
position: relative;
margin-top: -16rpx;
margin-top: -5rpx;
.section_13 {
flex: 1 1 201.34rpx;
......
......@@ -47,18 +47,9 @@
UserAPI.location({ lat: cachedLocation.lat, lon: cachedLocation.lon })
.then((res) => {
console.log('UserAPI.location', res)
pageData.weather.detailedLocation =
res.province +
'-' +
res.city +
'-' +
res.country +
'-' +
res.road +
'-' +
res.town +
'-' +
res.address
pageData.weather.detailedLocation = `${res.province}-${res.city}-${res.country}-${
res.road
}-${res.town}-${res.address}`
})
.catch(() => {
// 地址获取失败时使用默认显示
......@@ -92,18 +83,9 @@
UserAPI.location({ lat: res.latitude, lon: res.longitude })
.then((res) => {
console.log('UserAPI.location', res)
pageData.weather.detailedLocation =
res.province +
'-' +
res.city +
'-' +
res.country +
'-' +
res.road +
'-' +
res.town +
'-' +
res.address
pageData.weather.detailedLocation = `${res.province}-${res.city}-${res.country}-${
res.road
}-${res.town}-${res.address}`
})
.catch(() => {
// 地址获取失败时使用默认显示
......@@ -406,9 +388,46 @@
// 轮播视频切换的时候触发
function handleChangeVideo(e: any) {
// console.log('切换视频', e.detail.current)
pageData.current = e.detail.current
pageData.agricultureClass.title = pageData.agricultureClass.videoList[pageData.current]?.title
const currentIndex = e.detail.current
const prevIndex = pageData.current
pageData.current = currentIndex
pageData.agricultureClass.title = pageData.agricultureClass.videoList[currentIndex]?.title
// 延迟处理视频切换,避免卡顿
setTimeout(() => {
// 停止所有其他视频的播放(只暂停,不重置位置)
pageData.agricultureClass.videoList.forEach((_, index) => {
if (index !== currentIndex) {
try {
const videoContext = uni.createVideoContext(`video${index}`)
videoContext.pause()
// 不重置到开头,保留播放位置
} catch (error) {
console.log('停止视频失败:', error)
}
} else {
// 当前视频:尝试播放
try {
const videoContext = uni.createVideoContext(`video${index}`)
// 自动播放当前视频
videoContext.play()
} catch (error) {
console.log('播放视频失败:', error)
}
}
})
}, 100)
}
// 处理swiper过渡动画
function handleTransition(e: any) {
// 过渡期间可以做一些优化处理
console.log('swiper过渡中...')
}
// 视频暂停事件处理
function handleVideoPause(currentIndex) {
console.log(`视频${currentIndex}暂停`)
}
// 获取视频时长
......@@ -464,7 +483,7 @@
scrollable
:speed="50"
style="width: 100%; height: auto"
></up-notice-bar>
/>
<view v-else class="text_3">{{ pageData.weather.detailedLocation }}</view>
</view>
<!-- <image
......@@ -700,10 +719,14 @@
class="fui-banner__wrap"
circular
:indicator-dots="false"
autoplay
:interval="4000"
:duration="150"
:autoplay="false"
:interval="8000"
:duration="300"
:disable-touch="false"
:touch-angle="45"
:threshold="50"
@change="handleChangeVideo"
@transition="handleTransition"
>
<swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index">
<video
......@@ -712,8 +735,17 @@
:poster="video.cover_image"
:controls="false"
style="width: 654rpx; height: 358rpx"
:autoplay="false"
:muted="false"
:loop="false"
:show-play-btn="true"
:show-center-play-btn="true"
:enable-progress-gesture="false"
:show-progress="false"
object-fit="contain"
@loadedmetadata="handleMetadataLoaded"
@play="handleVideoPlay(index)"
@pause="handleVideoPause(index)"
></video>
</swiper-item>
</swiper>
......
......@@ -11,7 +11,7 @@ const PROXY_LIST: [[string, string]?] = [
// [`http://192.168.0.100:18100`, `https://oss.beta.app.yiring.com`],
// 开发环境(预览)
[`http://192.168.0.156:18100`, `http://111.22.182.169:49091`],
[`http://192.168.0.156:18100`, `http://36.133.16.81:42112`],
]
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论