app.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {
  2. GetQueryString
  3. } from 'utils/util'
  4. import {
  5. getOpenidNoLogin
  6. } from '~/utils/httpUtilNoLogin';
  7. // const Towxml = require('/towxml/main');
  8. App({
  9. watch(method) {
  10. let obj = this.globalData
  11. // 这里监听 openId
  12. Object.defineProperty(obj, "openId", {
  13. configurable: true,
  14. enumerable: true,
  15. set: function(value) {
  16. console.log('zzeweqweqw', value);
  17. method(value) // 触发页面回调函数
  18. }
  19. })
  20. },
  21. async onLaunch(options) {
  22. // 判断设备是否为 iPhone X
  23. this.checkIsIPhoneX()
  24. options.referrerInfo.extraData && (this.globalData.upgradeHide = options.referrerInfo.extraData.upgrade)
  25. },
  26. async onShow(options) {
  27. let shareUid = options.query.uid
  28. getOpenidNoLogin((res) => {
  29. if (getApp().callBack) {
  30. getApp().callBack(res);
  31. }
  32. }, () => {}, shareUid);
  33. },
  34. globalData: {
  35. isIPX: false, // 当前设备是否为 iPhone X
  36. isIOS: false, // 判断设备是否为苹果
  37. userInfo: null,
  38. statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
  39. userGrade: '二年级',
  40. upgradeHide: true,
  41. openId: null
  42. },
  43. checkIsIPhoneX: function() {
  44. const self = this
  45. wx.getSystemInfo({
  46. success: function(res) {
  47. // 根据 model 进行判断
  48. if (res.model.search('iPhone X') != -1) {
  49. self.globalData.isIPX = true
  50. }
  51. if (res.system.search('iOS') != -1) {
  52. self.globalData.isIOS = true
  53. }
  54. }
  55. })
  56. },
  57. // towxml: new Towxml()
  58. })