123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- // component/auth/auth.js
- Component({
- /**
- * 页面的初始数据
- */
- data: {
- show: false,
- canIUse: wx.canIUse('button.open-type.getUserInfo')
- },
-
- attached() {
- this.callback = () => {
- this.setData({show: !getApp().globalData.loginProps.isLogin})
- let pages = getCurrentPages()
- let currPage = pages[pages.length - 1].route
- if (currPage === 'pages/discover/discover') {
- this.setData({bottom: '50px'})
- } else {
- this.setData({bottom: 0})
- }
- }
- this.callback()
- getApp().addLoginListener(this.callback)
- },
- detached() {
- getApp().removeLoginListener(this.callback)
- },
- methods: {
- quitHandle: function() {
- getApp().setLoginProps(true)
- },
- getCode: function() {
- return new Promise(r => {
- wx.login({
- success: function(res) {
- if (res.code) {
- r(res.code)
- }
- }
- });
- })
- },
- authLogin() {
- this.triggerEvent('login')
- },
- bindGetUserInfo: async function(e) {
- console.log(e)
- },
- }
- })
|