Files
ys-app/src/pages/home/home.vue

501 lines
14 KiB
Vue
Raw Normal View History

2025-07-22 11:21:01 +08:00
<template>
<view class="con-body">
<view class="con-bg">
<!-- 下拉刷新 -->
<mescroll-uni ref="mescrollRef" @init="mescrollInit"
:down="downOption" @down="downCallback"
:fixed="false" class="scroll-h" :style="{ paddingTop: navBarPaddingTop + 'px' }"
>
<!-- #ifdef H5 -->
<view style="height:50rpx"></view>
<!-- #endif -->
2025-08-04 16:19:03 +08:00
<!-- 搜索 @confirm="handleSearch" -->
2025-07-22 11:21:01 +08:00
<view class="search search-sao" >
<uni-search-bar class="custom-search" radius="28"
placeholder="请输入您想查询的内容或服务"
clearButton="auto" cancelButton="none"
bgColor="#6FA2F8" textColor="#ffffff"
2025-08-04 16:19:03 +08:00
@focus="handleFocus"
2025-07-22 11:21:01 +08:00
/>
<uni-icons custom-prefix="iconfont" color="#ffffff" type="icon-phonesaoyisao" size="20"></uni-icons>
</view>
<!-- 待办内容 -->
<view class="backlog-bg">
<view class="backlog-b-item">
<view class="font-number">{{ backBlogObj.count1 }}</view>
<view class="font-title">待办</view>
</view>
<view class="backlog-b-item">
<view class="font-number">{{ backBlogObj.count2 }}</view>
<view class="font-title">待审查</view>
</view>
<view class="backlog-b-item">
<view class="font-number">{{ backBlogObj.count3 }}</view>
<view class="font-title">待巡检</view>
</view>
<view class="backlog-b-item">
<view class="font-number">{{ backBlogObj.count4 }}</view>
<view class="font-title">待发货</view>
</view>
</view>
<!-- 跑马灯滚动 -->
<view class="notice-bg">
<img :src="'static/images/icon-notice@2x.png'" class="notice-icon" />
<view class="notice-list">
<!-- :interval="4000" -->
<swiper class="swiper-con"
:vertical="true"
:autoplay="true"
:duration="500"
:circular="true"
:disable-touch="true"
:display-multiple-items="1"
>
<swiper-item v-for="(item, index) in extendedList" :key="index" >
<view class="swiper-item">
{{ item }}
</view>
</swiper-item>
</swiper>
</view>
</view>
<!-- 日程提醒 -->
<view class="white-bg mar-top" v-if="stepList.length>0">
<view class="w-b-title">日程提醒
<view class="yellow-bg">
<i :class="{iconfont:true,'icon-phoneshizhong':true}"></i>
<view class="text-black">{{ weekStr }}</view>
</view>
</view>
<view class="section-line">
<customSteps :steps="stepList" :modelValue="stepList"></customSteps>
</view>
</view>
<!-- 销售任务完成情况 -->
<view class="white-bg mar-top">
<view class="w-b-title">销售任务完成情况
<view class="yellow-bg">
<picker @change="bindPickerChange" :value="activeIndex" :range="salesList" @click="clickPicker" @cancel="bindPickerCancel">
<view class="uni-input">{{salesList[activeIndex]}}</view>
</picker>
<i :class="{iconfont:true,'icon-down':salesFlag,'icon-up':!salesFlag}" class="picker-icon"></i>
</view>
</view>
<view class="progress-bg">
<progress :percent="percentNum" stroke-width="10" activeColor="#41E1B1" backgroundColor="#F0F0F0" />
<view class="percent" :style="{left:percentNum+'%'}">
<view class="percent-num">{{ percentNum }}%</view>
<i class="iconfont icon-down"></i>
</view>
<view class="percent-con">
<view class="p-first">
<view>实际销售额</view>
<view class="font-money">{{totalSales}}</view>
</view>
<view class="p-last">
<view>目标销售额</view>
<view class="font-money">{{ targetSales }}</view>
</view>
</view>
</view>
</view>
<!-- 常用服务 -->
2025-08-13 18:15:04 +08:00
<view class="white-bg" v-if="commonServiceList.length>0">
2025-07-22 11:21:01 +08:00
<view class="w-b-title">常用服务</view>
<view class="logo-list">
2025-08-14 14:01:54 +08:00
<view v-for="(item,index) in commonServiceList" class="l-l-item" :key="index" @click="handleJump(item.bizUrl)">
<img :src="'static/images/business/'+item.icon+'.png'" />
<text class="font-gray">{{ item.bizName }}</text>
2025-07-22 11:21:01 +08:00
</view>
<!-- <view class="l-l-item" @click="handleAddCommonSercice">
<img :src="'static/images/business/icon-add.png'">
<text class="font-gray">添加</text>
</view> -->
</view>
</view>
<!-- 新闻公告 -->
<view class="white-bg">
<view class="w-b-title">新闻公告
<text>更多新闻</text>
</view>
<view class="news-list">
<view v-for="(item,index) in newsList" class="news-item" :key="index">
<view class="n-i-title">{{ item.name }}
<view class="n-i-date">{{ formatDateStr(item.date) }}</view>
</view>
<img :src="item.imgSrc" v-if="item.imgSrc" />
</view>
</view>
</view>
<!-- 底部加高度来避免tabbar遮挡 -->
<view class="bottom-height"></view>
</mescroll-uni>
</view>
</view>
</template>
<script setup>
2025-08-01 18:12:36 +08:00
import { ref,onMounted,computed } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
2025-07-22 11:21:01 +08:00
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
import customSteps from '@/components/customSteps.vue'
import { getNavBarPaddingTop} from '@/utils/system.js'
2025-08-13 18:15:04 +08:00
// ,swiperList,stepData,salesTask,commonServices,newsQueryList
import { messageNotifyCount,messageFlowCount,getUserFavorite} from '@/api/home.js';
2025-07-22 11:21:01 +08:00
import { getWeekStr,formatTimestamp } from '@/utils/datetime.js'
import { formatMoney } from '@/utils/formatter.js'
2025-08-13 18:15:04 +08:00
import {showLoading,hideLoading} from '@/utils/message.js'
2025-07-22 11:21:01 +08:00
2025-08-14 20:26:26 +08:00
2025-08-01 18:12:36 +08:00
onLoad(async(opt) => {
uni.setStorageSync('page_cache',true);
2025-08-13 18:15:04 +08:00
// initLoad();
2025-08-01 18:12:36 +08:00
})
2025-08-13 09:22:58 +08:00
// 初始化调用方法
const initLoad =()=>{
2025-08-13 18:15:04 +08:00
try {
showLoading("加载中...")
getBackBlogCount();
getSwiperList();
getStepData();
getSalesTask();
getCommonServices();
getNewsList();
hideLoading();
} catch (error) {
hideLoading();
}
2025-08-13 09:22:58 +08:00
}
2025-07-22 11:21:01 +08:00
// 下拉刷新
const mescrollRef = ref(null);
const mescrollInit = (mescroll) => {
mescrollRef.value = mescroll;
};
const downOption = ref({
auto: true,
textInOffset: '下拉刷新',
textOutOffset: '释放更新',
textLoading: '刷新中...'
});
// 下拉刷新
const downCallback = async (mescroll) => {
try {
2025-08-13 09:22:58 +08:00
// setTimeout(async ()=>{
// // mescroll.resetUpScroll();
// },500);
initLoad();
2025-07-22 11:21:01 +08:00
} catch (error) {
mescroll.endErr();
} finally {
setTimeout(async ()=>{
mescroll.endSuccess();
},500);
}
}
// 获取导航栏高度用于内容区域padding
const navBarPaddingTop = ref(0);
onMounted(() => {
navBarPaddingTop.value = getNavBarPaddingTop()*2;
})
2025-08-04 16:19:03 +08:00
// 获取input 焦点跳转
let handleFocus=()=>{
uni.navigateTo({url:'/pages/search/search?type=1'})
}
2025-07-22 11:21:01 +08:00
// 查询搜索跳转
let handleSearch = ()=>{
}
2025-08-13 18:15:04 +08:00
let backBlogObj = ref({
count1:0,
count2:0,
count3:0,
count4: 0
})
2025-07-22 11:21:01 +08:00
// 获取待办数据
2025-08-13 18:15:04 +08:00
const getBackBlogCount = async () =>{
let res = await messageNotifyCount();
let res2 = await messageFlowCount();
backBlogObj.value.count1= res.todoCount || 0//消息待阅
backBlogObj.value.count2= res2.todoCount || 0//审核待办
// tabar 增加消息数量
try {
if(backBlogObj.value.count1>0){
wx.setTabBarBadge({
index: 2, // TabBar的索引从0开始计数
text: res.todoCount+'' // 徽章的文本
});
}
} catch (error) {
console.error('设置TabBar Badge失败:', error);
}
2025-07-22 11:21:01 +08:00
}
2025-08-13 09:22:58 +08:00
2025-07-22 11:21:01 +08:00
// 跑马灯处理
let extendedList = ref([]);// ;
const getSwiperList = async () => {
2025-08-13 09:22:58 +08:00
// extendedList.value = await swiperList();
extendedList.value = ["祝贺“友晟夏季封装外壳发布会”圆满成功","祝贺“友晟科技发布会”圆满成功","祝贺“友晟夏季封装外壳发布会”圆满成功"]
2025-07-22 11:21:01 +08:00
}
2025-08-13 09:22:58 +08:00
2025-07-22 11:21:01 +08:00
// 日程提醒
let weekStr = ref(null) //'2025-09-19 星期三'
let stepList = ref([]);
const getStepData = async ()=>{
2025-08-13 09:22:58 +08:00
// let res = await stepData({});
let res={
date:new Date().getTime(),
list:[
{ id:1,desc: '2025秋季产品发布前期准备会在科研楼0317会议室召开。', title: '13:30 — 15:30',beginTime:'13:30',endTime:'15:30'},
{ id:2,desc: '生产间安全巡检。', title: '16:30 — 18:00',beginTime:'16:30',endTime:'18:00'},
]
}
2025-07-22 11:21:01 +08:00
weekStr.value = getWeekStr(res.date);
stepList.value = res.list;
}
2025-08-13 09:22:58 +08:00
2025-07-22 11:21:01 +08:00
// 销售任务完成情况
let salesList = ref([]);
let salesFlag = ref(true);
let activeIndex = ref(0);
const bindPickerChange = (e)=>{
// console.log('picker发送选择改变携带值为', e.detail.value)
activeIndex.value = e.detail.value;
salesFlag.value = true;
}
const bindPickerCancel= (e)=>{
salesFlag.value = true;
}
const clickPicker= (e)=>{
salesFlag.value = false;
}
let percentNum = ref(0);
let totalSales = ref(0)
let targetSales = ref(0)
const getSalesTask = async ()=>{
2025-08-13 09:22:58 +08:00
// let res = await salesTask({});
let res = {
salesList:['2025-3季度', '2025-2季度', '2025-1季度'],
percentNum:82,
totalSales:62075000,
targetSales:75000000
}
2025-07-22 11:21:01 +08:00
salesList.value = res.salesList;
percentNum.value = res.percentNum;
totalSales.value = formatMoney(res.totalSales);
targetSales.value = formatMoney(res.targetSales);
}
2025-08-13 09:22:58 +08:00
2025-07-22 11:21:01 +08:00
// 常用服务
let commonServiceList = ref([])
const getCommonServices = async ()=>{
2025-08-14 14:01:54 +08:00
let data = await getUserFavorite({});
commonServiceList.value = data || []
}
// 跳转
let handleJump=(url)=>{
if(url){
uni.navigateTo({ url })
}
2025-07-22 11:21:01 +08:00
}
2025-08-13 09:22:58 +08:00
2025-07-22 11:21:01 +08:00
// 添加常用服务
const handleAddCommonSercice = ()=>{
}
// 新闻公告
let newsList = ref([])
const getNewsList = async()=>{
2025-08-13 09:22:58 +08:00
// let res = await newsQueryList({});
let res = {
list:[
{id:1,date:'2025-06-29',name:'友晟亮相2025慕尼黑上海电子展',imgSrc:'https://img2.baidu.com/it/u=363858033,1221485415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1067'},
{id:2,date:'2025-06-26',name:'孜孜不倦,谱写公司发展新篇章',imgSrc:'https://img0.baidu.com/it/u=2830423559,3962669886&fm=253&app=138&f=JPEG?w=570&h=760'},
{id:3,date:'2025-03-29 08:10:00',name:'质量管理体系提升助力实现质的飞跃',imgSrc:''},
],
}
2025-07-22 11:21:01 +08:00
newsList.value = res.list;
}
2025-08-13 09:22:58 +08:00
2025-07-22 11:21:01 +08:00
const formatDateStr =(times)=>{
return formatTimestamp(times)
}
</script>
<style scope>
.scroll-h{
/* #ifdef APP-PLUS */
height:calc(100vh - 30px) !important;
/* #endif */
/* #ifndef APP-PLUS */
height: calc(100vh - 30px) !important;
/* #endif */
}
:deep(.mescroll-upwarp){
display:none
}
.search-sao{
display: flex;
padding-top:10rpx;
}
.search-sao .custom-search{
width:612rpx;
}
.search-sao :deep(.custom-search.uni-searchbar){
padding-bottom: 15rpx !important;
}
.search-sao .icon-phonesaoyisao{
margin:15rpx 30rpx 10rpx auto;
}
.backlog-bg{
background:url('@/static/images/bg-main@2x.png') no-repeat;
background-size:730rpx 205rpx;
/* width:730rpx; */
width:690rpx;
height:205rpx;
margin:0 auto;
display: flex;
padding:0 20rpx;
}
.backlog-b-item{
width:25%;
color:#579FF9;
border-right:1px solid #EAEAEA;
height:100rpx;
margin-top:40rpx;
}
.backlog-b-item .font-number{
font-size: 60rpx;
font-weight: bold;
text-align: center;
}
.backlog-b-item .font-title{
font-size:28rpx;
text-align: center;
}
.notice-bg{
background:url('@/static/images/bg-notice@2x.png') no-repeat;
background-size:750rpx 90rpx;
width:690rpx;
height: 90rpx;
margin-top:10rpx;
padding:0 30rpx;
display: flex;
align-items: center;
}
.notice-bg .notice-icon{
width:46rpx;
height:40rpx;
}
.notice-list{
width:100%;
position: relative;
height: 90rpx;
overflow: hidden;
}
.notice-list .swiper-con{
width:640rpx;
}
.notice-list .swiper-con .swiper-item {
height: 90rpx;
line-height: 90rpx;
padding: 0 20rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color:#fff;
font-size:30rpx;
}
.progress-bg{
position: relative;
width:528rpx;
margin:120rpx auto 0;
}
.progress-bg :deep(.uni-progress .uni-progress-bar){
border-radius: 5px;
}
.progress-bg :deep(.uni-progress .uni-progress-inner-bar){
border-radius: 5px 0 0 5px;
}
.progress-bg .percent{
position: absolute;
top:0;
color:#FF687A;
font-size:60rpx;
font-weight: bold;
}
.progress-bg .percent .icon-down{
position: absolute;
bottom:0rpx;
left:-20rpx;
color:#FF687A;
font-size:40rpx;
}
.progress-bg .percent .percent-num{
position: absolute;
left:-60rpx;
bottom:30rpx;
}
.progress-bg .percent-con{
display: flex;
width:528rpx;
color:#333;
font-size:28rpx;
margin:20rpx 0 10rpx;
}
.progress-bg .percent-con .p-last{
margin-left: auto;
text-align: right;
}
.progress-bg .percent-con .font-money{
font-weight: bold;
margin-top:10rpx;
}
.white-bg .logo-list{
gap:50rpx;
padding:0 20rpx;
/* margin-bottom: -50rpx; */
}
.white-bg .logo-list .l-l-item{
width:160rpx;
margin-bottom:0rpx;
}
.white-bg .logo-list .l-l-item img{
width:110rpx;
height:110rpx;
}
</style>