• 小程序 openid 的原始请求和网络请求


    // 登录
    wx.login({
    success: res => {
    var code = res.code; //返回code
    // console.log(code)
    // 小程序appid
    // wxd751fc845c90fbd8
    // 3df95e167161ab74e09ea54eda471c96

    var appId = 'wx2bd115231a8d3eb4';
    // 小程序密钥
    var secret = '4318963731f224658258d1c3cc851052';
    wx.request({
    url: 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appId + '&secret=' + secret + '&js_code=' + code + '&grant_type=authorization_code',
    data: {},
    header: {
    'content-type': 'json'
    },
    success: function (res) {
    // console.log(res)
    var openid = res.data.openid
    console.log(openid)
    that.globalData.userId = openid;
    // wx.request({
    // url: 'https://www.didu86.com/Cloth-manager-web/queryUsers',
    // data: {
    // openid: openid,
    // },
    // success: function (res) {
    // var result = res.data;
    // // console.log(result)
    // if (result.length != 0) {
    // wx.setStorageSync('user', result[0]);
    // } else {
    // }

    // }
    // })

    }
    })
    }
    });
     
     
     
     
    // 展示本地存储能力
    wx.login({
    success: res => {
    var that = this
    if (res.code) {
    console.log(res.code)
    var code1 = res.code;
    wx.request({
    url: 'http://192.168.1.15:8080/getOpenid',
    data: { code1: code1 },
    success: function (res) {
    console.log(res)
    // var openid = res.data
    // console.log(openid)
    // that.globalData.userId = openid

    // wx.request({
    // url: 'https://www.didu86.com/Cloth-manager-web/queryUsers', //仅为示例,并非真实的接口地址
    // data: {
    // openid: openid,
    // },
    // success: function (res) {
    // var result = res.data;
    // // console.log(result)
    // if (result.length != 0) {
    // wx.setStorageSync('user', result[0]);
    // } else {
    // }

    // }
    // })
    }
    })
    }
    }
    });
  • 相关阅读:
    Elasticsearch 分词
    Elasticsearch:文档乐观锁控制 if_seq_no与if_primary_term
    调用javaAPI访问hive
    sqoop笔记
    hive学习
    添加用户到sudo组
    HTTP协议用的TCP但是只建立单向连接
    Hadoop基本操作
    Hadoop原理介绍
    sed用法
  • 原文地址:https://www.cnblogs.com/dianzan/p/8124058.html
Copyright © 2020-2023  润新知