export default {
    /**
     * 获取平台用户信息
     */
    platformInfo() {
        return new Promise((resolve, reject) => {
            // 获取用户信息
            uni.getUserProfile({
                provider: 'weixin',
                desc: "获取用户信息",
                success: function (info) {
                    console.log(info);
                    uni.login({
                        provider: "weixin",
                        success: (result) => {
                            resolve({
                                code: result.code,
                                userInfo: {
                                    avatarUrl: info.userInfo.avatarUrl,
                                    city: info.userInfo.city,
                                    country: info.userInfo.country,
                                    gender: info.userInfo.gender,
                                    language: info.userInfo.language,
                                    nickName: info.userInfo.nickName,
                                    province: info.userInfo.province
                                }
                                // encryptedData: info.encryptedData,
                                // iv: info.iv,
                            });
                        },
                        fail: e => {
                            reject(e);
                        },
                    });
                },
                fail: e => {
                    reject(e);
                },
            });
        });
    },
    register() {
        this.platformInfo().then(platfromUser => {
            console.log(platfromUser);
        }).catch(e => { });
    },
    login() {
        uni.navigateTo({
            url: '/pages/auth/login'
        });
    },
    getInfo() {
        return new Promise((resolve, reject) => {
            resolve({
                id: 123,
                name: '李四'
            });
        });
    }
}
