load.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var app = getApp();
  2. Page({
  3. data: {
  4. logo: '',
  5. name: '',
  6. spid: 0,
  7. url: app.globalData.url,
  8. },
  9. onLoad: function (options) {
  10. var that = this;
  11. that.getEnterLogo();
  12. app.setBarColor();
  13. if (options.scene) that.data.spid = options.scene;
  14. },
  15. getEnterLogo: function () {
  16. var that = this;
  17. wx.request({
  18. url: app.globalData.url + '/routine/login/get_enter_logo',
  19. method: 'post',
  20. dataType  : 'json',
  21. success: function (res) {
  22. that.setData({
  23. logo: res.data.data.site_logo,
  24. name: res.data.data.site_name
  25. })
  26. }
  27. })
  28. },
  29. //获取用户信息并且授权
  30. getUserInfo: function(e){
  31. var userInfo = e.detail.userInfo;
  32. userInfo.spid = this.data.spid;
  33. wx.login({
  34. success: function (res) {
  35. if (res.code) {
  36. userInfo.code = res.code;
  37. wx.request({
  38. url: app.globalData.url + '/routine/login/index',
  39. method: 'post',
  40. dataType  : 'json',
  41. data: {
  42. info: userInfo
  43. },
  44. success: function (res) {
  45. app.globalData.uid = res.data.data.uid;
  46. if (app.globalData.openPages != '' && app.globalData.openPages != undefined) {//跳转到指定页面
  47. wx.navigateTo({
  48. url: app.globalData.openPages
  49. })
  50. } else {//跳转到首页
  51. wx.reLaunch({
  52. url: '/pages/index/index'
  53. })
  54. }
  55. }
  56. })
  57. } else {
  58. console.log('登录失败!' + res.errMsg)
  59. }
  60. }
  61. })
  62. },
  63. })