load.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. if (app.globalData.openPages != '' && app.globalData.openPages != undefined) {//跳转到指定页面
  45. wx.navigateTo({
  46. url: app.globalData.openPages
  47. })
  48. } else {//跳转到首页
  49. wx.reLaunch({
  50. url: '/pages/index/index'
  51. })
  52. }
  53. }
  54. })
  55. } else {
  56. console.log('登录失败!' + res.errMsg)
  57. }
  58. }
  59. })
  60. },
  61. })