import {
	get,
	post
} from '../utils/request.js'
import {
	useUserStore
} from '@/store/index.js';

// 测试
let data = {
	"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdW5zaGluZS5jZGJhb2xhbi5jb20iLCJhdWQiOiJzdW5zaGluZS5jZGJhb2xhbi5jb20iLCJpYXQiOjE3MTEzNTM2NTEsIm5iZiI6MTcxMTM1MzU5MSwiZXhwIjoxNzExMzc4ODUxLCJkYXRhIjp7ImlkIjoiMzQ2NTciLCJwaG9uZSI6ImRvdDFAcXEuY29tIn19.nw4_Aoez9jSA2krU_X760zkps4dEPO4DpItEQCM5u7s",
	"language": "zh_cn"
}
// export const apihost = 'https://loanvem.com'
// export const apihost = 'https://loanicom.com'
export const apihost = 'http://192.168.50.253:8000'

// 上传图片
export function uploadImage(url) {
	return new Promise((resolve, reject) => {
		const userStore = useUserStore()
		uni.uploadFile({
			url: apihost + '/api/upload/file',
			filePath: url,
			header: {
				'Authorization': userStore.token
			},
			name: 'file',
			formData: {
				'type': 0,
			},
			success: (res) => {
				const temp = JSON.parse(res.data)
				resolve({
					success: true,
					data: temp
				});
			}
		});
	})
}

export function fetchChatConfig() {
	return post('/api/user/activity-list', data)
}

export function signup(params = {}) {
	return post('/api/user/sign-up', params)
}

export function init(params = {}) {
	return post('/api/user/init', params)
}

export function about(params = {}) {
	return post('/api/user/about', params)
}

export function articledetail(params = {}) {
	return post('/api/article/detail', params)
}

export function signin(params = {}) {
	return post('/api/user/sign-in', params)
}

export function itemsearch(params = {}) {
	return post('/api/item/search', params)
}

export function itemlist(params = {}) {
	return post('/api/item/list', params)
}

export function itemdetail(params = {}) {
	return post('/api/item/detail', params)
}

export function userprofile(params = {}) {
	return post('/api/user/profile', params)
}

export function userorderlist(params = {}) {
	return post('/api/user/order-list', params)
}

export function userdetail(params = {}) {
	return post('/api/user/order-detail', params)
}

export function banklist(params = {}) {
	return post('/api/bank/list', params)
}

export function bankadd(params = {}) {
	return post('/api/bank/add', params)
}

export function bankdel(params = {}) {
	return post('/api/bank/del', params)
}
export function rechargetype(params = {}) {
	return post('/api/user/recharge-type', params)
}

export function recharge(params = {}) {
	return post('/api/user/recharge', params)
}

export function noticelist(params = {}) {
	return post('/api/user/notice-list', params)
}

export function noticeview(params = {}) {
	return post('/api/user/notice-view', params)
}

export function userfunds(params = {}) {
	return post('/api/user/funds', params)
}

export function fetchweather(params = {}) {
	return post('/api/user/weather', params)
}

export function sendsms(params = {}) {
	return post('/api/user/send-sms', params)
}

export function itembuy(params = {}) {
	return post('/api/item/apply', params)
}

export function orderlist(params = {}) {
	return post('/api/user/order-list', params)
}

export function upload(params = {}) {
	return post('/api/upload/file', params, {'content-type': "application/form-data"})
}

export function forgot(params = {}) {
	return post('/api/user/forgot-passwd', params)
}

export function cashpasswd(params = {}) {
	return post('/api/user/cash-passwd-reset', params)
}

export function updateprofile(params = {}) {
	return post('/api/user/profile-update', params)
}

export function team(params = {}) {
	return post('/api/user/team', params)
}

export function cashApply(params = {}) {
	return post('/api/cash/apply', params)
}
export function cashList(params = {}) {
	return post('/api/cash/list', params)
}


export function cashEmailList(params = {}) {
	return post('/api/cash/email_list', params)
}
export function cashEmailView(params = {}) {
	return post('/api/cash/email_view', params)
}