...
|
...
|
@@ -2,60 +2,112 @@ |
2
|
2
|
<view class="status-page">
|
3
|
3
|
<f-navbar navbarType="2" @leftClick="leftClick">
|
4
|
4
|
<view class="u-flex search-top" slot="left">
|
5
|
|
- <view class="search-main"><u--input prefixIcon="search" placeholder="请输入组态名称" border="surround" shape="circle"></u--input></view>
|
|
5
|
+ <view class="search-main"><u--input @change="inputChanged" prefixIcon="search" placeholder="请输入组态名称" border="surround" shape="circle"></u--input></view>
|
6
|
6
|
</view>
|
7
|
7
|
</f-navbar>
|
8
|
8
|
<!-- 公共组件-每个页面必须引入 -->
|
9
|
9
|
<public-module></public-module>
|
10
|
|
- <view class="status-container">
|
11
|
|
- <view @click="openStatusDetail(item.id)" v-for="(item, index) in list" :key="index" class="status-item u-flex">
|
12
|
|
- <view class="item-image"><image class="image" :src="item.icon"></image></view>
|
13
|
|
- <view class="item-text">
|
14
|
|
- <text class="text">{{ item.name }}</text>
|
|
10
|
+ <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
|
|
11
|
+ <view class="status-container">
|
|
12
|
+ <view @click="openConfigDetail(item.id)" v-for="(item, index) in list" :key="index" class="status-item u-flex">
|
|
13
|
+ <view style="cursor: pointer;" class="item-image"><image class="image" :src="item.icon || defaultConfigImage"></image></view>
|
|
14
|
+ <view class="item-text">
|
|
15
|
+ <text class="text">{{ item.name }}</text>
|
|
16
|
+ </view>
|
15
|
17
|
</view>
|
16
|
18
|
</view>
|
17
|
|
- </view>
|
18
|
|
- <f-tabbar></f-tabbar>
|
|
19
|
+ </mescroll-body>
|
19
|
20
|
</view>
|
20
|
21
|
</template>
|
21
|
22
|
|
22
|
23
|
<script>
|
23
|
|
-import fTabbar from '@/components/module/f-tabbar/f-tabbar';
|
24
|
24
|
import fNavbar from '@/components/module/f-navbar/f-navbar';
|
|
25
|
+import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
|
25
|
26
|
|
26
|
27
|
export default {
|
27
|
28
|
components: {
|
28
|
|
- fTabbar,
|
29
|
29
|
fNavbar
|
30
|
30
|
},
|
|
31
|
+ mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
|
31
|
32
|
data() {
|
32
|
33
|
return {
|
33
|
|
- list: [
|
34
|
|
- {
|
35
|
|
- id: 1,
|
36
|
|
- name: '智慧办公室1',
|
37
|
|
- icon: '../../../static/test.png'
|
38
|
|
- },
|
39
|
|
- {
|
40
|
|
- id: 2,
|
41
|
|
- name: '智慧办公室2',
|
42
|
|
- icon: '../../../static/test.png'
|
43
|
|
- }
|
44
|
|
- ]
|
|
34
|
+ page: {
|
|
35
|
+ num: 0,
|
|
36
|
+ size: 10
|
|
37
|
+ },
|
|
38
|
+ downOption: {
|
|
39
|
+ auto: true //是否在初始化后,自动执行downCallback; 默认true
|
|
40
|
+ },
|
|
41
|
+ upOption: {
|
|
42
|
+ auto: false // 不自动加载
|
|
43
|
+ },
|
|
44
|
+ defaultConfigImage: '../../../static/test.png',
|
|
45
|
+ list: []
|
45
|
46
|
};
|
46
|
47
|
},
|
47
|
48
|
onLoad() {
|
48
|
49
|
// 隐藏原生的tabbar
|
49
|
50
|
uni.hideTabBar();
|
|
51
|
+ uni.setStorageSync('getConfiguration', {
|
|
52
|
+ isConfiguration: false
|
|
53
|
+ });
|
|
54
|
+ },
|
|
55
|
+ onUnload() {
|
|
56
|
+ uni.setStorageSync('getConfiguration', {
|
|
57
|
+ isConfiguration: false
|
|
58
|
+ });
|
|
59
|
+ uni.removeStorageSync('getConfiguration');
|
50
|
60
|
},
|
51
|
61
|
methods: {
|
|
62
|
+ inputChanged(e) {
|
|
63
|
+ this.page.num = 1;
|
|
64
|
+ this.loadData(1, e);
|
|
65
|
+ },
|
52
|
66
|
leftClick() {
|
53
|
67
|
return false;
|
54
|
68
|
},
|
55
|
|
- openStatusDetail(e) {
|
|
69
|
+ onBackPress() {
|
|
70
|
+ console.log('返回');
|
|
71
|
+ return true; // 阻止返回 不阻止就不写或者用uni.navigateBack({ delta: 1 })返回
|
|
72
|
+ },
|
|
73
|
+ openConfigDetail(e) {
|
56
|
74
|
uni.navigateTo({
|
57
|
|
- url: 'configurationDetail'
|
|
75
|
+ url: 'configurationDetail?configId=' + e
|
58
|
76
|
});
|
|
77
|
+ },
|
|
78
|
+ /*下拉刷新的回调 */
|
|
79
|
+ downCallback() {
|
|
80
|
+ //联网加载数据
|
|
81
|
+ this.page.num = 1;
|
|
82
|
+ this.loadData(1);
|
|
83
|
+ },
|
|
84
|
+ /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
|
|
85
|
+ upCallback() {
|
|
86
|
+ //联网加载数据
|
|
87
|
+ this.page.num += 1;
|
|
88
|
+ this.loadData(this.page.num);
|
|
89
|
+ },
|
|
90
|
+ loadData(pageNo, T) {
|
|
91
|
+ let httpData = {
|
|
92
|
+ page: pageNo,
|
|
93
|
+ pageSize: 10,
|
|
94
|
+ name: T
|
|
95
|
+ };
|
|
96
|
+ uni.$u.http
|
|
97
|
+ .get('/yt/configuration/center', { params: httpData, custom: { load: false } })
|
|
98
|
+ .then(res => {
|
|
99
|
+ uni.stopPullDownRefresh();
|
|
100
|
+ this.mescroll.endByPage(res.items.length, res.total);
|
|
101
|
+ if (pageNo == 1) {
|
|
102
|
+ this.list = res.items;
|
|
103
|
+ } else {
|
|
104
|
+ this.list = this.list.concat(res.items);
|
|
105
|
+ }
|
|
106
|
+ })
|
|
107
|
+ .catch(e => {
|
|
108
|
+ //联网失败, 结束加载
|
|
109
|
+ this.mescroll.endErr();
|
|
110
|
+ });
|
59
|
111
|
}
|
60
|
112
|
}
|
61
|
113
|
};
|
...
|
...
|
|