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
/**
* 徐立
* 2019年9月20日
* 主页接口
*/
import { uaaRequest } from '../utils/request';
import prepareShow from "@/webPublic/one_stop_public/Table/prepareShow";
import { queryApiVersion } from '@/webPublic/one_stop_public/utils/queryConfig';
const myCollect = {
namespace: 'modileHome',
state: {
home: {},
affair: {},
},
effects: {
// 为主页我的服务的数据请求函数
*getMyHome({ payload, callback }, { call, put }) {
const response = yield call(uaaRequest, '/UnifiedAppApi/getCurrentList', {
...payload,
});
if (response == null) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'initHome',
payload: response,
});
if (callback) {
callback(response);
}
},
// 为主页所有服务的数据请求函数
*getHome({ payload, callback }, { call, put }) {
let response = yield call(uaaRequest, '/UnifiedThemeApi/getList', {
...payload,
});
if (response == null) {
yield put({ type: 'nom' });
return;
}
if(queryApiVersion() === '2.0' && response.info){
response = response.info;
}
yield put({
type: 'initHome',
payload: response,
});
if (callback) {
callback(response);
}
},
/**
* 添加当前事务到我的服务
* @param {ids} 服务ids
*/
*addMyHome({ payload, callback }, { call, put }) {
const response = yield call(uaaRequest, '/UnifiedAppApi/addApp', {
...payload,
});
if (response == null) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'initHome',
payload: response,
});
if (callback) {
callback(response);
}
},
/**
* 移除当前用户我的服务
* @param {ids} 服务ids
*/
*removeMyHome({ payload, callback }, { call, put }) {
const response = yield call(uaaRequest, '/UnifiedAppApi/removeApp', {
...payload,
});
if (response == null) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'initHome',
payload: response,
});
if (callback) {
callback(response);
}
},
/**
* 根据id查询应用详情指南
* @param {id} 服务ids
*/
*getDetail({ payload, callback }, { call, put }) {
const response = yield call(uaaRequest, '/UnifiedAppApi/getDetail', {
...payload,
});
yield put({
type: 'initAffair',
payload: response,
});
if (response == null) {
yield put({ type: 'nom' });
return;
}
yield call(prepareShow, response); // prepareShow( // 执行templateWillMount公式
if (callback) {
callback(response);
}
},
/**
* 获取系统指南
* @param {configKey} 系统指南 homeHelp
*/
*getConfigDetail({ payload, callback }, { call, put }) {
const response = yield call(uaaRequest, '/ConfigApi/getDetail', {
...payload,
});
if (response == null) {
yield put({ type: 'nom' });
return;
}
if (callback) {
callback(response);
}
},
/**
* 获取我的收藏系统分页
* @param {pageNo} 页码
* @param {pageSize} 每页数量
*/
*getPagesCollect({ payload, callback }, { call, put }) {
const response = yield call(uaaRequest, '/UnifiedAppApi/getCurrentPage', {
...payload,
});
if (response == null) {
yield put({ type: 'nom' });
return;
}
if (callback) {
callback(response);
}
},
*getCodeDetail({ payload, callback }, { call, put }) {
const response = yield call(uaaRequest, '/UnifiedServicePatternApi/getDetail', {
...payload,
});
yield put({
type: 'initAffair',
payload: response,
});
if (response == null) {
yield put({ type: 'nom' });
return;
}
if (callback) {
callback(response);
}
},
},
reducers: {
initHome(state, action) {
return { ...state, home: action.payload };
},
initAffair(state, action) {
return { ...state, affair: action.payload };
},
nom(state, action) {
return { ...state };
},
},
};
export default myCollect;