communityApi.js
2.58 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
import { setCommunitys,setCurrentCommunity,getCurrentCommunity } from "@/utils/vc"
import request from '@/utils/request'
export function _loadCommunityInfo(_param) {
return new Promise((resolve, reject) => {
request({
url: '/community.listMyEnteredCommunitys',
method: 'get',
params: {
page: 1,
row: 3
}
}).then(response => {
const res = response.data
let _communityInfos = res.communitys;
if (_communityInfos && _communityInfos.length > 0) {
setCommunitys(_communityInfos);
let _currentCommunity = JSON.parse(window.localStorage.getItem('hc_currentCommunityInfo'));
if(_currentCommunity){
resolve(res)
return ;
}
setCurrentCommunity(_communityInfos[0]);
if (_param && _param.communityId) {
let _communityId = _param.communityId;
_communityInfos.forEach(_c => {
if (_c.communityId == _communityId) {
setCurrentCommunity(_c);
}
})
}
}
// 获取验证码成功
resolve(res)
}).catch(error => {
reject(error)
})
})
}
export function getDict(tableName,tableColumns) {
return new Promise((resolve, reject) => {
request({
url: '/callComponent/core/list',
method: 'get',
params: {
name: tableName,
type: tableColumns,
page:1,
row:500
}
}).then(response => {
const res = response.data
// 获取验证码成功
resolve(res)
}).catch(error => {
reject(error)
})
})
}
export function getCommunityId() {
return getCurrentCommunity().communityId
}
export function getCommunity() {
return getCurrentCommunity()
}
export function getCommunityName() {
return getCurrentCommunity().name
}
export function getMyEnteredCommunitys(_param) {
return new Promise((resolve, reject) => {
request({
url: '/community.listMyEnteredCommunitys',
method: 'get',
params: {
..._param
}
}).then(response => {
const res = response.data
// 获取验证码成功
resolve(res)
}).catch(error => {
reject(error)
})
})
}