| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- 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;
|