import request from '@/utils/network/request';

/**
 * 登录接口
 * @param {Object} params
 */
export function login (params) {
	return request({
		url: '/api/user.ashx?act=studentlogin',
		method: 'GET',
		data: params
	})
}

/**
 * 登出接口
 */
export function logout () {
	return request({
		url: '',
		method: 'GET'
	})
}

export function getImgData(url) {
	return new Promise((resolve, reject) => {
		uni.request({
			url,
			method: 'GET',
			responseType: 'arraybuffer',
			success: (e) => {
				const imgData = uni.arrayBufferToBase64(e.data)
				const imgBase64 = 'data:image/png;base64,' + imgData
				// resolve(e.data)
				resolve(imgBase64)
			},
			fail: (error) => {
				console.log(error)
				reject(error)
			}
		})
	})
}
