Files
ks-app-employment-service/pages/index/index.vue

154 lines
4.0 KiB
Vue
Raw Normal View History

2024-11-08 11:55:23 +08:00
<template>
2025-06-20 22:03:24 +08:00
<view class="app-custom-root">
<view class="app-container">
<!-- 主体内容区域 -->
<view class="container-main">
<swiper class="swiper" :current="state.current" @change="changeSwiperType">
<swiper-item class="swiper-item" v-for="(_, index) in 2" :key="index">
<!-- #ifndef MP-WEIXIN -->
<component :is="components[index]" :ref="(el) => handelComponentsRef(el, index)" />
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<IndexOne v-show="currentIndex === 0" :ref="(el) => handelComponentsRef(el, index)" />
<IndexTwo v-show="currentIndex === 1" :ref="(el) => handelComponentsRef(el, index)" />
<!-- #endif -->
</swiper-item>
</swiper>
2024-11-18 16:33:37 +08:00
</view>
</view>
</view>
2024-11-08 11:55:23 +08:00
</template>
<script setup>
2025-06-20 22:03:24 +08:00
import { reactive, inject, watch, ref, onMounted } from 'vue';
2024-11-08 11:55:23 +08:00
import { onLoad, onShow } from '@dcloudio/uni-app';
2025-06-20 22:03:24 +08:00
import IndexOne from './components/index-one.vue';
import IndexTwo from './components/index-two.vue';
const loadedMap = reactive([false, false]);
const swiperRefs = [ref(null), ref(null)];
const components = [IndexOne, IndexTwo];
2025-03-28 15:19:42 +08:00
import { storeToRefs } from 'pinia';
2025-06-20 22:03:24 +08:00
import { useReadMsg } from '@/stores/useReadMsg';
const { unreadCount } = storeToRefs(useReadMsg());
2025-05-13 11:10:38 +08:00
2025-06-20 22:03:24 +08:00
onShow(() => {
// 获取消息列表
useReadMsg().fetchMessages();
2024-11-08 11:55:23 +08:00
});
2025-06-20 22:03:24 +08:00
const state = reactive({
current: 0,
all: [{}],
2024-11-08 11:55:23 +08:00
});
2025-03-28 15:19:42 +08:00
2025-06-20 22:03:24 +08:00
onMounted(() => {
handleTabChange(state.current);
2024-11-08 11:55:23 +08:00
});
2025-06-20 22:03:24 +08:00
const handelComponentsRef = (el, index) => {
if (el) {
swiperRefs[index].value = el;
2025-05-13 11:10:38 +08:00
}
2025-06-20 22:03:24 +08:00
};
// 查看消息类型
function changeSwiperType(e) {
const index = e.detail.current;
state.current = index;
handleTabChange(index);
2025-03-28 15:19:42 +08:00
}
2025-06-20 22:03:24 +08:00
function changeType(index) {
state.current = index;
handleTabChange(index);
2025-03-28 15:19:42 +08:00
}
2025-06-20 22:03:24 +08:00
function handleTabChange(index) {
if (!loadedMap[index]) {
swiperRefs[index].value?.loadData();
loadedMap[index] = true;
2025-05-13 11:10:38 +08:00
}
2025-03-28 15:19:42 +08:00
}
2025-06-20 22:03:24 +08:00
// 查看消息类型
function changeSwiperMsgType(e) {
const currented = e.detail.current;
state.current = currented;
2025-03-28 15:19:42 +08:00
}
2025-06-20 22:03:24 +08:00
</script>
2025-03-28 15:19:42 +08:00
2025-06-20 22:03:24 +08:00
<style lang="stylus" scoped>
.app-custom-root {
position: fixed;
z-index: 10;
width: 100vw;
height: calc(100% - var(--window-bottom));
overflow: hidden;
2025-03-28 15:19:42 +08:00
}
2025-06-20 22:03:24 +08:00
.app-container {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
.container-header {
height: calc(88rpx - 14rpx);
text-align: center;
line-height: calc(88rpx - 14rpx);
font-size: 32rpx;
display: flex;
flex-direction: row;
align-items: center;
padding: 16rpx 44rpx 36rpx 44rpx;
background: url('@/static/icon/msgTopbg.png') 0 0 no-repeat;
background-size: 100% 100%;
.header-title {
color: #000000;
font-weight: bold;
2025-03-28 15:19:42 +08:00
}
2025-06-20 22:03:24 +08:00
.header-btnLf {
display: flex;
justify-content: flex-start;
align-items: center;
width: calc(60rpx * 3);
font-weight: 500;
font-size: 40rpx;
color: #696969;
margin-right: 44rpx;
position: relative;
.btns-wd{
position: absolute
top: 2rpx;
right: 2rpx
width: 16rpx;
height: 16rpx;
background: #F73636;
border-radius: 50%;
border: 4rpx solid #EEEEFF;
}
2025-03-28 15:19:42 +08:00
}
2025-06-20 22:03:24 +08:00
.active {
font-weight: 600;
font-size: 40rpx;
color: #000000;
2025-03-28 15:19:42 +08:00
}
}
}
2025-06-20 22:03:24 +08:00
.container-main {
flex: 1;
overflow: hidden;
background-color: #f4f4f4;
2025-03-28 15:19:42 +08:00
}
2025-06-20 22:03:24 +08:00
.main-scroll {
2025-03-28 15:19:42 +08:00
width: 100%
2025-06-20 22:03:24 +08:00
height: 100%;
2025-05-13 11:10:38 +08:00
}
2025-06-20 22:03:24 +08:00
.scrollmain{
padding: 28rpx
}
.swiper
height: 100%;
width: 100%
.list
width: 100%
display: flex;
flex-direction: column;
2025-05-16 09:28:44 +08:00
</style>