1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import {
- userLogin
- } from '~/api/user'
- import {
- createStoreBindings
- } from 'mobx-miniprogram-bindings'
- import {
- store
- } from '~/store/index'
- let storeBindings
- App({
- onLaunch() {
- this.checkIsIos()
- this.getNavbarInfo()
- },
- async onShow(options) {
- let shareUid = options.query.uid
- this.login(shareUid)
- },
- login(shareUid) {
- this.storeBindings = createStoreBindings(this, {
- store,
- actions: ['setUser']
- })
- wx.login({
- success: async (res) => {
- if (res.code) {
-
- let data = {
- code: res.code,
- shareUid
- }
- let userRes = await userLogin(data)
- this.setUser(userRes.data)
- wx.setStorageSync('uid', userRes.data.uid)
- wx.setStorageSync('user', userRes.data)
- this.globalData.userInfo = userRes.data
- if (getApp().callBack) {
- getApp().callBack(userRes);
- }
- }
- }
- })
- },
- checkIsIos: function () {
- wx.getSystemInfo({
- success: (res) => {
- if (res.system.search('iOS') != -1) {
- this.globalData.isIOS = true
- }
- }
- })
- },
- getNavbarInfo() {
-
- const systemInfo = wx.getSystemInfoSync();
-
- const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
-
- this.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
- this.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
- this.globalData.menuTop = menuButtonInfo.top;
- this.globalData.menuHeight = menuButtonInfo.height;
- },
- globalData: {
- userInfo: null,
- isIOS: false,
- navBarHeight: 0,
- menuRight: 0,
- menuTop: 0,
- menuHeight: 0,
- }
- })
|