import request from '@/utils/request'
import Storage from '@/utils/storage'
import md5 from 'js-md5'

/**
 * 登录
 * @param params
 * @returns {*}
 */
export function login(params) {
   /*  params.password = md5(params.password) */
    return request({
        url: 'admin/systems/admin-users/login',
        method: 'get',
        loading: false,
        needToken: false,
        params
    })
}

/**
 * 加盟商登录
 * @param params
 * @returns {*}
 */
export function loginByFranchise(params) {
/*     params.password = md5(params.password) */
    return request({
        url: `admin/shops/franchise/login`,
        method: 'get',
        loading: false,
        needToken: false,
        params
    })
}

/**
 * 退出账户
 * @returns {*}
 */
export function logout(uid) {
    return request({/* Storage.getItem('admin_uid') */
        url: `admin/systems/admin-users/logout?uid=${uid}`,
        method: 'post'
    })
}

/**
 * 获取用户角色权限
 * @param role_id
 * @returns {*}
 */
export function getUserRolesPermissions(role_id) {
    return request({
        url: `admin/systems/roles/${role_id}/checked`,
        method: 'get'
    })
}
