load.js 1.8 KB

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