import { get, post } from '../utils/request'; import { showMessage } from '../common/toast/toast' import { goToLogin } from '../utils/login' export const fetchInviteColList = (params: { limit: number; lastTime: number; activityId: string; }) => { return get('//www.lofter.com/spread/collectionShowAct/getInviteCollections', // return get('https://nei.hz.netease.com/api/apimock-v2/c6da9202198a943efec7f11c8a937f16/collectionShowAct/getInviteCollections', params ).then(res => { if (res.code === 200) { return res } else { showMessage({ text: res.msg }) return Promise.reject() } }) } export const fetchMyInviteColList = (params: { activityId: string; }) => { return get('//www.lofter.com/spread/collectionShowAct/getCurrentInviteCollections', params).then(res => { // return get('https://nei.hz.netease.com/api/apimock-v2/c6da9202198a943efec7f11c8a937f16/collectionShowAct/getCurrentInviteCollections').then(res => { if (res.code === 200) { return res } else if (res.code === 401) { return Promise.reject() } else { showMessage({ text: res.msg }) return Promise.reject() } }) } export const cancelInvite = (collectionShowId: number) => { // return post('https://nei.hz.netease.com/api/apimock-v2/c6da9202198a943efec7f11c8a937f16/collectionShowAct/cancelInvitation', { return post('//www.lofter.com/spread/collectionShowAct/cancelInvitation', { collectionShowId }).then(res => { if (res.code === 200) { showMessage({ text: '撤回成功' }) return res } else { showMessage({ text: res.msg }) return Promise.reject('CODE_ERROR') } }).catch((res) => { if (res !== 'CODE_ERROR') { showMessage({ text: '请求失败' }) } return Promise.reject() }) } export const fetchMyColList = (params: { activityId: string; }) => { return get('//www.lofter.com/spread/collectionShowAct/getUserCollections', params).then(res => { // return get('https://nei.hz.netease.com/api/apimock-v2/c6da9202198a943efec7f11c8a937f16/collectionShowAct/getUserCollections').then(res => { if (res.code === 200) { return res } else if (res.code === 401) { goToLogin() } else { showMessage({ text: res.msg }) return Promise.reject('CODE_ERROR') } }).catch((res) => { if (res !== 'CODE_ERROR') { showMessage({ text: '请求失败' }) } return Promise.reject() }) } export const addInvite = (collectionId: number, activityId: string) => { // return post('https://nei.hz.netease.com/api/apimock-v2/c6da9202198a943efec7f11c8a937f16/collectionShowAct/publishInvitation', { return post('//www.lofter.com/spread//collectionShowAct/publishInvitation', { collectionId, activityId }).then(res => { if (res.code === 200) { showMessage({ text: '发布成功' }) return res } else { showMessage({ text: res.msg }) return Promise.reject('CODE_ERROR') } }).catch((res) => { if (res !== 'CODE_ERROR') { showMessage({ text: '请求失败' }) } return Promise.reject() }) }