import http from '../util/http'
import store from '../store/store'
import * as types from '../store/mutations-types'
import upload from '../util/uniAppUpload.js'

// 上传
export const updateImg = (file) => {
	return upload('app-api/file/upload', file , {
		Authorization: 'Bearer ' + store.getters.userToken()
	}, {
		method: 'post',
		loading: true
	}).then((data) => {
		return data;
	})
}

// 字典数据查询
export const listSimpleDictDatas = (params) => {
	return http('/system/dict-data/list-all-simple', params, {
		method: 'GET',
	})
}

// 获得所有产品属性
export const getProductAttrList = (params) => {
  return http('/ecw/product-attr/list', params, {
		method: 'GET',
	})
}

// 获得所有产品属性
export const getUserProfile = () => {
  return http('/system/user/profile/get', {}, {
		method: 'GET',
	}).then(data => {
		store.commit(types.SET_USER_INFO, data)
  })
}
// 获得所有产品属性
export const getUserPermission = () => {
  return http('/system/get-permission-info', {}, {
    method: 'GET',
  })
}
export const getVesionData = (params) => {
	return http('/system/version/latestVersion', params, {
		method: 'GET',
	})
}
