• 小程序获取用户的信息


     <!--获取用户的信息-->
    wx.getSetting({
          success(res) {
            if (!res.authSetting['scope.userInfo']) {
              wx.authorize({
                scope: 'scope.userInfo',
                success(res) {
                   
                }
              })
            }
          }
        })
     <!--把数据返回给后台并获取open_id-->
        wx.login({
          success: function (res) {
            // 获取openID;
           var openId = res.code;
            
            var that = this;
              wx.getUserInfo({
                withCredentials: true,
                success: function (res) {
                  var send_data = md5.hexMD5({ act: 'get_user_info_or_log', headimgurl: res.userInfo.avatarUrl, open_id: openId, nickName:res.userInfo.nickName});
                  wx.request({
                    //后台接口地址
                    url: "https://xcx.baidu.com",
                    data: send_data,
                    method: 'POST',
                    header: {
                      'content-type': 'application/x-www-form-urlencoded'
                    },
                    success: function (res) {
                      wx.setStorageSync('user_id', res.data.user_id);
                    }
                  })
                },
              })
            },
    <!--把user_id储存在本地-->
           user_id:function(){
                // 获取本地的user_id
                   var user_id = wx.getStorageSync('user_id');
                   console.log(user_id);
    },

    })

      

  • 相关阅读:
    SpringBoot创建定时任务
    SpringBoot 多环境配置
    SpringBoot中使用log4j日志
    SpringBoot项目结构介绍
    SpringBoot快速入门
    Zookeeper Zkclient客户端
    Zookeeper java api
    学习微信小程序及知识占及v-if与v-show差别

    1像素
  • 原文地址:https://www.cnblogs.com/liujun1128/p/7932445.html
Copyright © 2020-2023  润新知