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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
| /**
| 导航栏
| **/
| (function (vc) {
| var vm = new Vue({
| el: '#nav',
| data: {
| nav: {
| moreNoticeUrl: '/flow/noticeFlow',
| notices: [],
| total: 0
| },
| logo: '',
| userName: "",
| navCommunityInfo: {
| _currentCommunity: {},
| communityInfos: []
| }
| },
| mounted: function () {
| this._initSysInfo();
| this.getNavCommunity();
| this.getNavData();
| //this.getUserInfo();
| },
| methods: {
| _initSysInfo: function () {
| var sysInfo = vc.getData("_sysInfo");
| if (sysInfo == null) {
| this.logo = "HC";
| return;
| }
| this.logo = sysInfo.logo;
| },
| getNavData: function () {
|
| var param = {
| params: {
| page: 1,
| row: 3,
| communityId: vc.getCurrentCommunity().communityId
| }
|
| };
|
| //发送get请求
| vc.http.get('nav',
| 'getNavData',
| param,
| function (json) {
| var _noticeObj = JSON.parse(json);
| vm.nav.notices = _noticeObj.msgs;
| vm.nav.total = _noticeObj.total;
| }, function () {
| console.log('请求失败处理');
| }
| );
|
| },
| logout: function () {
| var param = {
| msg: 123
| };
| //发送get请求
| vc.http.post('nav',
| 'logout',
| JSON.stringify(param),
| {
| emulateJSON: true
| },
| function (json, res) {
| if (res.status == 200) {
| vc.jumpToPage("/flow/login");
| return;
| }
| }, function () {
| console.log('请求失败处理');
| }
| );
| },
| getUserInfo: function () {
| // var _userInfo = vc.getData("_userInfo");
| // //浏览器缓存中能获取到
| // if(_userInfo != null && _userInfo != undefined){
| // vm.userName = _userInfo.name;
| // return ;
| // }
| //获取用户名
| var param = {
| msg: '123',
| };
|
| //发送get请求
| vc.http.get('nav',
| 'getUserInfo',
| param,
| function (json, res) {
| if (res.status == 200) {
| var tmpUserInfo = JSON.parse(json);
| console.log(vm, tmpUserInfo);
| vm.userName = tmpUserInfo.name;
| // vc.saveData("_userInfo",tmpUserInfo);
| }
| }, function () {
| console.log('请求失败处理');
| }
| );
| },
| getNavCommunity: function () {
| var _tmpCurrentCommunity = vc.getCurrentCommunity();
| //浏览器缓存中能获取到
| if (_tmpCurrentCommunity != null && _tmpCurrentCommunity != undefined) {
| this.navCommunityInfo._currentCommunity = _tmpCurrentCommunity;
| this.navCommunityInfo.communityInfos = vc.getCommunitys();
|
| return;
| }
|
| //说明缓存中没有数据
| //发送get请求
| /**
| [{community:"123123",name:"测试1小区"},{community:"223123",name:"测试2小区"}]
| **/
| var param = {
| params:{
| _uid:'123mlkdinkldldijdhuudjdjkkd'
| }
| };
| vc.http.get('nav',
| 'getCommunitys',
| param,
| function (json, res) {
| if (res.status == 200) {
| vm.navCommunityInfo.communityInfos = JSON.parse(json);
|
| if (vm.navCommunityInfo.communityInfos == null || vm.navCommunityInfo.communityInfos.length == 0) {
| vm.navCommunityInfo._currentCommunity = {
| name: "还没有入驻小区"
| };
| return;
| }
|
| vm.navCommunityInfo._currentCommunity = vm.navCommunityInfo.communityInfos[0];
| vc.setCurrentCommunity(vm.navCommunityInfo._currentCommunity);
| vc.setCommunitys(vm.navCommunityInfo.communityInfos);
|
| //对首页做特殊处理,因为首页在加载数据时还没有小区信息 会报错
| if (vm.navCommunityInfo.communityInfos != null && vm.navCommunityInfo.communityInfos.length > 0) {
| vc.emit("indexContext", "_queryIndexContextData", {});
| vc.emit("indexArrears", "_listArrearsData", {});
| }
|
| }
| }, function () {
| console.log('请求失败处理');
| }
| );
|
| },
| changeCommunity: function (_community) {
| vc.setCurrentCommunity(_community);
| vm.navCommunityInfo._currentCommunity = _community;
| //中心加载当前页
| location.reload();
| },
| _noticeDetail: function (_msg) {
| //console.log(_notice.noticeId);
| //vc.jumpToPage("/flow/noticeDetailFlow?noticeId="+_notice.noticeId);
|
| //标记为消息已读
| vc.http.post('nav',
| 'readMsg',
| JSON.stringify(_msg),
| function (json, res) {
| if (res.status == 200) {
| vc.jumpToPage(_msg.url);
| }
| }, function () {
| console.log('请求失败处理');
| }
| );
| }
| }
| });
|
| vm.getUserInfo();
|
| })(window.vc);
|
|