|
@@ -2,54 +2,21 @@
|
|
|
import {GetQueryString} from 'utils/util'
|
|
|
App({
|
|
|
onLaunch: function (options) {
|
|
|
-
|
|
|
-
|
|
|
- // 展示本地存储能力
|
|
|
- var logs = wx.getStorageSync('logs') || []
|
|
|
- logs.unshift(Date.now())
|
|
|
- wx.setStorageSync('logs', logs)
|
|
|
-
|
|
|
- // 登录
|
|
|
- wx.login({
|
|
|
- success: res => {
|
|
|
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
|
- }
|
|
|
- })
|
|
|
- // 获取用户信息
|
|
|
- wx.getSetting({
|
|
|
- success: res => {
|
|
|
- if (res.authSetting['scope.userInfo']) {
|
|
|
- // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
|
|
- wx.getUserInfo({
|
|
|
- success: res => {
|
|
|
- // 可以将 res 发送给后台解码出 unionId
|
|
|
- this.globalData.userInfo = res.userInfo
|
|
|
-
|
|
|
- // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
- // 所以此处加入 callback 以防止这种情况
|
|
|
- if (this.userInfoReadyCallback) {
|
|
|
- this.userInfoReadyCallback(res)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ // 判断设备是否为 iPhone X
|
|
|
+ this.checkIsIPhoneX()
|
|
|
+ },
|
|
|
+ globalData: {
|
|
|
+ isIPX: false, // 当前设备是否为 iPhone X
|
|
|
+ },
|
|
|
+ checkIsIPhoneX: function() {
|
|
|
+ const self = this
|
|
|
+ wx.getSystemInfo({
|
|
|
+ success: function (res) {
|
|
|
+ // 根据 model 进行判断
|
|
|
+ if (res.model.search('iPhone X') != -1) {
|
|
|
+ self.globalData.isIPX = true
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- },
|
|
|
- // onShow: function(options){
|
|
|
- // console.log(options)
|
|
|
- // const type = GetQueryString(decodeURIComponent(options.query.scene), "type");
|
|
|
- // const sceneId = GetQueryString(decodeURIComponent(options.query.scene), "id");
|
|
|
- // console.log(type, sceneId)
|
|
|
- // switch (type) {
|
|
|
- // case "works":
|
|
|
- // wx.navigateTo({
|
|
|
- // url: `../social/works/works?id=${sceneId}&title="测试"`
|
|
|
- // })
|
|
|
- // break
|
|
|
- // };
|
|
|
- // },
|
|
|
- globalData: {
|
|
|
- userInfo: null
|
|
|
}
|
|
|
})
|