login.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {loginByUserInfo, loginFn} from './../../utils/login'
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  7. navUrl: '',
  8. code: '',
  9. login_img: "/image/4Dage/login-bg.svg",
  10. login_logo: "/assets/images/login-logo.svg"
  11. },
  12. onLoad: function(options) {
  13. wx.login({
  14. success: (res) => {
  15. if (res.code) {
  16. this.setData({
  17. code: res.code
  18. })
  19. }
  20. }
  21. });
  22. },
  23. onReady: function() {
  24. // 页面渲染完成
  25. },
  26. onShow: function() {
  27. // 页面显示
  28. },
  29. onHide: function() {
  30. // 页面隐藏
  31. },
  32. onUnload: function() {
  33. // 页面关闭
  34. },
  35. bindgetphonenumber(e) {
  36. loginFn(e, this.data.code).then(() => {
  37. wx.navigateBack()
  38. })
  39. },
  40. bindgetuserinfo (e) {
  41. wx.showLoading({
  42. title: '登录中',
  43. })
  44. loginByUserInfo(e.detail, this.data.code).then(() => {
  45. wx.hideLoading({
  46. complete: (res) => {
  47. wx.navigateBack()
  48. },
  49. })
  50. })
  51. }
  52. })