import request from '../../../Utils/RequestUtils'; import Toast from '../../../flooks/Toast'; import MapModel from '../../Map/model'; const CategoryModel = (now) => ({ list: [], finish: false, page: 0, size: 20, sort: '', filter: '', tag: '', natureId: '', endAmount: '', categoryId: null, merchantNatureList: [], getData(chooseCategoryId) { if (chooseCategoryId != null) { now({ categoryId: chooseCategoryId }); } const { page, size, list, sort, filter, tag, natureId, endAmount, categoryId, } = now(); const { loading, warnning, clearLoading } = now(Toast); loading(); const { chooseInfo } = now(MapModel); const { location } = chooseInfo; const params = { latitude: location.lat, longitude: location.lng }; if (sort) { params.sort = sort; } if (filter) { params.filter = filter; } if (tag) { params.tag = tag; } if (natureId) { params.natureId = natureId; } if (endAmount) { params.startAmount = 0; params.endAmount = endAmount; } request .get('/settings/show', { params, }) .then((res) => { clearLoading(); now({ list: list.concat(res), finish: true, page: 0, loading: false, }); }) .catch((e) => { warnning(e.error); }); }, changeChooseMap(info) { console.log(info); }, changeSort(type) { now({ sort: type, page: 0, list: [], }); const { getData } = now(); getData(); }, getNature() { request.get('/merchantNature/all').then((res) => { now({ merchantNatureList: res.content, }); }); }, ChangeFiliter(filter, tag, natureId, endAmount) { now({ filter, tag, natureId, endAmount, page: 0, list: [], }); const { getData } = now(); getData(); }, clearFiliter() { now({ filter: '', tag: '', natureId: '', endAmount: '', page: 0, list: [], }); const { getData } = now(); getData(); }, }); export default CategoryModel;