/* 用户授权相关 */

// 获取微信code(用户登录)
export function wxLogin() {
    return new Promise((resolve, reject) => {
        uni.login({
            provider: 'weixin',
            success(res) {
                console.log(res.code)
                resolve(res.code)
            },
            fail() {
                reject()
            }
        })
    })
}

export function authorize(scope, callback) {
    uni.authorize({
        scope: `scope.${scope}`,
        success() {
            console.log(1)
            callback()
        },
        fail(err) {
            console.log(err)
        }
    })
}


// 获取用户微信信息
export function getUserProfile() {
    return new Promise((resolve, reject) => {
        uni.getUserProfile({
            desc: '获取头像、昵称', 
            success(res) {
                resolve(res.userInfo)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}
