xcx/app.js

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

//app.js
App({
  onLaunch: function() {
    var that = this;
    //获取微信用户openid
    that.getOpendId(function(data) {
      if (data) {
        that.isLogin();
        console.log("getOpendId=" + JSON.stringify(data));
      }
    })
  },
  //获取微信openid
  getOpendId: function(callback) {
    var that = this;
    wx.login({
      success: res => {
        wx.request({
          url: that.globalData.apiUrl,
          data: {
            code: res.code,
            action: 'getXcxLogin'
          },
          header: {
            'content-type': 'application/json'
          },
          success: function(resOpendId) {
            that.globalData.openid = resOpendId.data.data.openid;
            callback(resOpendId.data.data.openid)
          }
        })
      }
    });
  },
  //获取用户信息接口
  getUserOpenId: function (callback) {
    var that = this;
    wx.request({
      url: getApp().globalData.apiUrl,
      data: {
        action: "getUserOpenId",
        openid: getApp().globalData.openid
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        // 拿到自己后台传过来的数据,自己作处理
        console.log(res.data);
        if (res.data.status == 0) {
          wx.redirectTo({
            url: '/pages/login/login'
          })
        } else {
          wx.setStorageSync('userInfo', res.data.data);
          wx.setStorageSync('userId', res.data.data.id);
          callback(res.data.data)
        }
      }
    });
后面还有 18 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。