This commit is contained in:
jeremygan2021
2026-02-12 16:31:05 +08:00
parent 70c8608110
commit 1919ab2227
14 changed files with 1090 additions and 4 deletions

View File

@@ -31,3 +31,37 @@ export const distributorWithdraw = (amount: number) => request({ url: '/distribu
// User
export const updateUserInfo = (data: any) => request({ url: '/wechat/update/', method: 'POST', data })
export const wechatLogin = (code: string) => request({ url: '/wechat/login/', method: 'POST', data: { code } })
// Forum / Community
export const getTopics = (params: any) => request({ url: '/community/topics/', data: params })
export const getTopicDetail = (id: number) => request({ url: `/community/topics/${id}/` })
export const createTopic = (data: any) => request({ url: '/community/topics/', method: 'POST', data })
export const updateTopic = (id: number, data: any) => request({ url: `/community/topics/${id}/`, method: 'PATCH', data })
export const getReplies = (params: any) => request({ url: '/community/replies/', data: params })
export const createReply = (data: any) => request({ url: '/community/replies/', method: 'POST', data })
export const getStarUsers = () => request({ url: '/users/stars/' })
export const getAnnouncements = () => request({ url: '/community/announcements/' })
// Upload Media for Forum
export const uploadMedia = (filePath: string, type: 'image' | 'video') => {
const BASE_URL = process.env.TARO_APP_API_URL || 'https://market.quant-speed.com/api'
return Taro.uploadFile({
url: `${BASE_URL}/community/media/`,
filePath,
name: 'file',
formData: {
media_type: type
},
header: {
'Authorization': `Bearer ${Taro.getStorageSync('token')}`
}
}).then(res => {
if (res.statusCode >= 200 && res.statusCode < 300) {
return JSON.parse(res.data)
}
throw new Error('Upload failed')
})
}
import Taro from '@tarojs/taro'