// pages/login/authorize-avatar-name/index.js Page({ /** * 页面的初始数据 */ data: { image: "https://cdn-we-retail.ym.tencent.com/miniapp/usercenter/icon-user-center-avatar@2x.png", }, login() { var that = this; // 基础库要在2.27.1以下才可以使用 wx.getUserProfile({ //获取用户信息。页面产生点击事件(例如 button 上 bindtap 的回调中)后才可调用,每次请求都会弹出授权窗口,用户同意后返回 userInfo,用于替换 wx.getUserInfo lang: 'zh_CN', desc: '用于在后台更好的识别您的身份', //声明获取用户个人信息后的用途 success(user) { //接口调用成功的回调函数 const data = { encryptedData: user.encryptedData, iv: user.iv, // signature: user.signature, // rawData: user.rawData, userInfo: user.userInfo, }; // app.request({ // url: `login`, // method: 'POST', // data: data, // success: async function (res) { // // wx.setStorageSync('userInfo', res); // app.put('userInfo', res, 86400); // const userInfo = app.get('userInfo'); // // 如果第一次登录就注册一个客户账号 // }, // }); }, fail() { wx.switchTab({ url: '/pages/home/home', }); }, }); }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })