app.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {
  2. GetQueryString
  3. } from 'utils/util'
  4. import {
  5. userLogin
  6. } from '~/api/user'
  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. /* wx.login({
  23. success(res) {
  24. if (res.code) {
  25. console.log(res.code);
  26. // 获取openid
  27. userLogin({
  28. code: res.code,
  29. grade: null
  30. }).then(res => {
  31. console.log(res);
  32. })
  33. }
  34. }
  35. }) */
  36. // 判断设备是否为 iPhone X
  37. this.checkIsIPhoneX()
  38. options.referrerInfo.extraData && (this.globalData.upgradeHide = options.referrerInfo.extraData.upgrade)
  39. },
  40. globalData: {
  41. isIPX: false, // 当前设备是否为 iPhone X
  42. isIOS: false, // 判断设备是否为苹果
  43. userInfo: null,
  44. statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
  45. userGrade: '二年级',
  46. upgradeHide: true,
  47. openId: null
  48. },
  49. checkIsIPhoneX: function () {
  50. const self = this
  51. wx.getSystemInfo({
  52. success: function (res) {
  53. // 根据 model 进行判断
  54. if (res.model.search('iPhone X') != -1) {
  55. self.globalData.isIPX = true
  56. }
  57. if (res.system.search('iOS') != -1) {
  58. self.globalData.isIOS = true
  59. }
  60. }
  61. })
  62. },
  63. // towxml: new Towxml()
  64. })