index.vue
3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
<view class="configuation-page">
<view class="configuation-header">
<view class="header-gap"></view>
<view class="search-top">
<view class="search-main">
<u--input @change="inputChanged" prefixIcon="search" :placeholder="$t('homePage.pleaseVisualBoard')" border="surround"
shape="circle"></u--input>
</view>
</view>
<header-org @openOrg="openOrg" :total="total" :title="$t('homePage.bulletionBoard')" :imageSrc="imageSrc"></header-org>
</view>
<view style="height:128rpx"></view>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<!-- 自带分页组件 -->
<mescroll-body height="80%" ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback"
@up="upCallback">
<view class="configuation-container">
<view class="configuation-item">
<view @click="openConfigDetail(item)" v-for="(item, index) in list" :key="index" class="item">
<image class="image" :src="item.icon || defaultConfigImage"></image>
<text class="name">{{ item.name }}</text>
</view>
</view>
</view>
<!-- <mescroll-empty v-if="!list.length" /> -->
</mescroll-body>
<!-- 自带分页组件 -->
<view style="height: 60rpx;"></view>
</view>
</template>
<script>
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
import api from '@/api/index.js'
import headerOrg from '@/components/common/header-org.vue'
import {
useNavigateTo
} from '@/plugins/utils.js'
export default {
mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
components:{
headerOrg
},
data() {
return {
defaultConfigImage: '../../../../static/test.png',
imageSrc:'/static/visual-board.png',
page: {
num: 0,
size: 10
},
downOption: {
auto: true //是否在初始化后,自动执行downCallback; 默认true
},
upOption: {
auto: false // 不自动加载
},
list: [],
total:0,
ordId:''
};
},
onLoad() {
// 隐藏原生的tabbar
uni.hideTabBar();
uni.setStorageSync('getConfiguration', {
isConfiguration: false
});
},
onShow(){
uni.setNavigationBarTitle({
title:this.$t('menu.viewBoard')
})
if (this.ordId) {
this.loadData(1,null, this.ordId);
}
},
onHide() {
this.ordId = '';
},
onUnload() {
uni.setStorageSync('getConfiguration', {
isConfiguration: false
});
uni.removeStorageSync('getConfiguration');
},
methods: {
inputChanged(e) {
this.page.num = 1;
this.loadData(1, e);
},
openConfigDetail(e) {
uni.navigateTo({
url: 'detail?id=' + e.id
});
},
/*下拉刷新的回调 */
downCallback() {
//联网加载数据
this.page.num = 1;
this.loadData(1);
},
/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
upCallback() {
//联网加载数据
this.page.num += 1;
this.loadData(this.page.num);
},
async loadData(pageNo, name,organizationId) {
let httpData = {
page: pageNo,
pageSize: 10,
name,
organizationId,
platform: 'phone'
};
const res = await api.homeApi.getVisualBoardApi({
params: httpData,
custom: {
load: false
}
})
if (res) {
uni.stopPullDownRefresh();
this.mescroll.endBySize(res.items.length, res.total);
this.total = res.total;
if(!res.items.length && res.total==0){
this.mescroll.showEmpty()
}else{
this.mescroll.removeEmpty()
}
if (pageNo == 1) {
this.list = res.items;
} else {
this.list = this.list.concat(res.items);
}
}
},
openOrg() {
useNavigateTo('/pages/organization/organization')
}
}
};
</script>
<style lang="scss" scoped>
@import '../../static/configuration.scss';
</style>