modilehome.js 3.6 KB
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5
/**
 * 徐立
 * 2019年9月20日
 * 主页接口
 */
6
import { uaaRequest } from '../utils/request';
徐立's avatar
徐立 committed
7
const myCollect = {
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
	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 }) {
			const response = yield call(uaaRequest, '/UnifiedThemeApi/getList', {
				...payload,
			});
			if (response == null) {
				yield put({ type: 'nom' });
				return;
			}
			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;
			}
			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 };
		},
	},
徐立's avatar
徐立 committed
169 170
};
export default myCollect;