util.js 843 B

1234567891011121314151617181920212223242526272829303132333435
  1. const app = getApp();
  2. var filters = {
  3. getSessionKey: function () {
  4. wx.checkSession({
  5. success: (res) => {
  6. console.log(res.errMsg);
  7. app.globalData.publicUrl = res.errMsg;
  8. return res.errMsg;
  9. },
  10. fail() {
  11. wx.login({
  12. success(res) {
  13. console.log(res);
  14. var code = res.code
  15. wx.request({
  16. url: app.globalData.publicUrl + '/wx/user/wx7e7a46e129d6cd0f/login',
  17. method: "get",
  18. data: {
  19. code
  20. },
  21. success: function (res) {
  22. console.log(res.data.openid);
  23. that.setData(res.data);
  24. return res.data
  25. }
  26. })
  27. }
  28. })
  29. }
  30. })
  31. }
  32. }
  33. module.exports = {
  34. getSessionKey: filters.getSessionKey
  35. }