提交 b644e698 作者: 15973817745_JPN

修改

上级 4fd308f1
<script setup lang="ts"> <script setup lang="ts">
// import { PUSH_CLIENT_KEY } from '/@/enums/cacheEnum' // import { PUSH_CLIENT_KEY } from '/@/enums/cacheEnum'
import { useUserStore } from '@/store/modules/user'
import * as API from '/@/api/model/userInfo' import * as API from '/@/api/model/userInfo'
const userStore = useUserStore()
onShow(async () => {}) onShow(async () => {})
// 页面数据 // 页面数据
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
import * as HomeAPI from '@/api/model/home' import * as HomeAPI from '@/api/model/home'
import * as NongChangAPI from '@/api/model/nongchang' import * as NongChangAPI from '@/api/model/nongchang'
import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore()
onShow(() => { onShow(() => {
// 获取金刚区菜单数据 // 获取金刚区菜单数据
getZoomList() getZoomList()
...@@ -17,6 +19,7 @@ ...@@ -17,6 +19,7 @@
getCommonToolsList() getCommonToolsList()
// 农技课堂 // 农技课堂
getAgricultureClassList() getAgricultureClassList()
pageData.userInfo = userStore.getUserInfo
}) })
// 下拉刷新 // 下拉刷新
...@@ -214,6 +217,10 @@ ...@@ -214,6 +217,10 @@
videoList: [], videoList: [],
}, },
current: 0, current: 0,
// 信用分
userInfo: {
creditScore: 0,
},
}) })
function getZoomList() { function getZoomList() {
...@@ -270,7 +277,10 @@ ...@@ -270,7 +277,10 @@
// 菜单点击事件 // 菜单点击事件
function onMenuItemClick(item: any) { function onMenuItemClick(item: any) {
console.log('点击菜单项:', item) console.log('点击菜单项:', item)
// 在这里添加具体的菜单点击逻辑 // 在这里添加具体的菜单点击逻辑+
uni.reLaunch({
url: item.jump_target,
})
} }
// 农业模型点击事件 // 农业模型点击事件
...@@ -308,6 +318,9 @@ ...@@ -308,6 +318,9 @@
function onDeviceManagementClick() { function onDeviceManagementClick() {
console.log('设备管理') console.log('设备管理')
// 在这里添加具体的设备管理逻辑 // 在这里添加具体的设备管理逻辑
uni.navigateTo({
url: '/pages/device/device',
})
} }
// 灵活用工 // 灵活用工
function onViewMoreFlexibleEmployment(type) { function onViewMoreFlexibleEmployment(type) {
...@@ -338,9 +351,41 @@ ...@@ -338,9 +351,41 @@
// 轮播视频切换的时候触发 // 轮播视频切换的时候触发
function handleChangeVideo(e: any) { function handleChangeVideo(e: any) {
// console.log('切换视频', e.detail.current) const currentIndex = e.detail.current
pageData.current = e.detail.current const prevIndex = pageData.current
pageData.agricultureClass.title = pageData.agricultureClass.videoList[pageData.current]?.title 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 @@ ...@@ -352,11 +397,20 @@
function handleVideoPlay(currentIndex) { function handleVideoPlay(currentIndex) {
pageData.agricultureClass.videoList.forEach((_, index) => { pageData.agricultureClass.videoList.forEach((_, index) => {
if (index !== currentIndex) { if (index !== currentIndex) {
try {
const videoContext = uni.createVideoContext(`video${index}`) const videoContext = uni.createVideoContext(`video${index}`)
videoContext.pause() videoContext.pause()
} catch (error) {
console.log('停止视频失败:', error)
}
} }
}) })
} }
// 视频暂停事件处理
function handleVideoPause(currentIndex) {
console.log(`视频${currentIndex}暂停`)
}
</script> </script>
<template> <template>
...@@ -643,7 +697,7 @@ ...@@ -643,7 +697,7 @@
> >
<image class="image_15" :src="pageData.creditCenter.image" /> <image class="image_15" :src="pageData.creditCenter.image" />
<view class="codefun-flex-col codefun-items-start group_29"> <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_5 text_63 mt-13">{{ pageData.creditCenter.rating }}</text>
<text class="font_10 text_64 mt-13">{{ pageData.creditCenter.tips }}</text> <text class="font_10 text_64 mt-13">{{ pageData.creditCenter.tips }}</text>
<view <view
...@@ -676,10 +730,14 @@ ...@@ -676,10 +730,14 @@
class="fui-banner__wrap" class="fui-banner__wrap"
circular circular
:indicator-dots="false" :indicator-dots="false"
autoplay :autoplay="false"
:interval="4000" :interval="8000"
:duration="150" :duration="300"
:disable-touch="false"
:touch-angle="45"
:threshold="50"
@change="handleChangeVideo" @change="handleChangeVideo"
@transition="handleTransition"
> >
<swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index"> <swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index">
<video <video
...@@ -688,8 +746,17 @@ ...@@ -688,8 +746,17 @@
:poster="video.cover_image" :poster="video.cover_image"
:controls="false" :controls="false"
style="width: 654rpx; height: 358rpx" 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" @loadedmetadata="handleMetadataLoaded"
@play="handleVideoPlay(index)" @play="handleVideoPlay(index)"
@pause="handleVideoPause(index)"
></video> ></video>
</swiper-item> </swiper-item>
</swiper> </swiper>
...@@ -1496,7 +1563,7 @@ ...@@ -1496,7 +1563,7 @@
.equal-division_6 { .equal-division_6 {
position: relative; position: relative;
margin-top: -16rpx; margin-top: -5rpx;
.section_13 { .section_13 {
flex: 1 1 201.34rpx; flex: 1 1 201.34rpx;
......
...@@ -47,18 +47,9 @@ ...@@ -47,18 +47,9 @@
UserAPI.location({ lat: cachedLocation.lat, lon: cachedLocation.lon }) UserAPI.location({ lat: cachedLocation.lat, lon: cachedLocation.lon })
.then((res) => { .then((res) => {
console.log('UserAPI.location', res) console.log('UserAPI.location', res)
pageData.weather.detailedLocation = pageData.weather.detailedLocation = `${res.province}-${res.city}-${res.country}-${
res.province + res.road
'-' + }-${res.town}-${res.address}`
res.city +
'-' +
res.country +
'-' +
res.road +
'-' +
res.town +
'-' +
res.address
}) })
.catch(() => { .catch(() => {
// 地址获取失败时使用默认显示 // 地址获取失败时使用默认显示
...@@ -92,18 +83,9 @@ ...@@ -92,18 +83,9 @@
UserAPI.location({ lat: res.latitude, lon: res.longitude }) UserAPI.location({ lat: res.latitude, lon: res.longitude })
.then((res) => { .then((res) => {
console.log('UserAPI.location', res) console.log('UserAPI.location', res)
pageData.weather.detailedLocation = pageData.weather.detailedLocation = `${res.province}-${res.city}-${res.country}-${
res.province + res.road
'-' + }-${res.town}-${res.address}`
res.city +
'-' +
res.country +
'-' +
res.road +
'-' +
res.town +
'-' +
res.address
}) })
.catch(() => { .catch(() => {
// 地址获取失败时使用默认显示 // 地址获取失败时使用默认显示
...@@ -406,9 +388,46 @@ ...@@ -406,9 +388,46 @@
// 轮播视频切换的时候触发 // 轮播视频切换的时候触发
function handleChangeVideo(e: any) { function handleChangeVideo(e: any) {
// console.log('切换视频', e.detail.current) const currentIndex = e.detail.current
pageData.current = e.detail.current const prevIndex = pageData.current
pageData.agricultureClass.title = pageData.agricultureClass.videoList[pageData.current]?.title 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 @@ ...@@ -464,7 +483,7 @@
scrollable scrollable
:speed="50" :speed="50"
style="width: 100%; height: auto" style="width: 100%; height: auto"
></up-notice-bar> />
<view v-else class="text_3">{{ pageData.weather.detailedLocation }}</view> <view v-else class="text_3">{{ pageData.weather.detailedLocation }}</view>
</view> </view>
<!-- <image <!-- <image
...@@ -700,10 +719,14 @@ ...@@ -700,10 +719,14 @@
class="fui-banner__wrap" class="fui-banner__wrap"
circular circular
:indicator-dots="false" :indicator-dots="false"
autoplay :autoplay="false"
:interval="4000" :interval="8000"
:duration="150" :duration="300"
:disable-touch="false"
:touch-angle="45"
:threshold="50"
@change="handleChangeVideo" @change="handleChangeVideo"
@transition="handleTransition"
> >
<swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index"> <swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index">
<video <video
...@@ -712,8 +735,17 @@ ...@@ -712,8 +735,17 @@
:poster="video.cover_image" :poster="video.cover_image"
:controls="false" :controls="false"
style="width: 654rpx; height: 358rpx" 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" @loadedmetadata="handleMetadataLoaded"
@play="handleVideoPlay(index)" @play="handleVideoPlay(index)"
@pause="handleVideoPause(index)"
></video> ></video>
</swiper-item> </swiper-item>
</swiper> </swiper>
......
...@@ -11,7 +11,7 @@ const PROXY_LIST: [[string, string]?] = [ ...@@ -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.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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论