// 登录功能
function login() {
    return new Promise((resolve, reject) => {
        wx.login({
            success: (res) => {
                if (res.code) {
                    // 登录成功，获取到用户的code
                    resolve(res.code);
                } else {
                    reject(res.errMsg);
                }
            },
            fail: (error) => {
                reject(error);
            }
        });
    });
}

// 获取用户信息
function getUserInfo() {
    return new Promise((resolve, reject) => {
        wx.getUserInfo({
            success: (res) => {
                resolve(res.userInfo);
            },
            fail: (error) => {
                reject(error);
            }
        });
    });
}
// 获取用户授权
function getAuthSetting() {
    return new Promise((resolve, reject) => {
        wx.getSetting({
            success: (res) => {
                resolve(res.authSetting);
            },
            fail: (error) => {
                reject(error);
            }
        });
    });
}

// 获取用户信息
function getAllUserInfo() {
    return new Promise((resolve, reject) => {

        wx.cloud.init({
            env: 'yourEnvID'
        });

        const db = wx.cloud.database();
        const userInfo = db.collection('userInfo');
    });
}




module.exports = {
    login,
    getUserInfo,
    getAuthSetting
};


