app.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. App({
  2. /**
  3. * 当小程序初始化完成时,会触发 onLaunch(全局只触发一次)
  4. */
  5. onLaunch: function () {
  6. // wx.checkSession({
  7. // success: function () {
  8. // console.debug("already login");
  9. // try {
  10. // var userToken = wx.getStorageSync('user_token');
  11. // if (userToken == null || userToken == undefined || userToken == "") {
  12. // wx.removeStorageSync("user_token");
  13. // wx.removeStorageSync("openid");
  14. // that.login();
  15. // }
  16. // } catch (e) {
  17. // console.log(e);
  18. // }
  19. // },
  20. // fail: function () {
  21. // console.log("go login");
  22. // wx.removeStorageSync("user_token");
  23. // wx.removeStorageSync("openid");
  24. // that.login();
  25. // }
  26. // })
  27. },
  28. // login: function () {
  29. // var that = this;
  30. // wx.login({
  31. // success: function (res) {
  32. // console.debug("wx.login" + res);
  33. // if (res.code) {
  34. // // that.loginToTaishan(res.code);
  35. // } else {
  36. // console.log('登录失败!' + res.errMsg)
  37. // }
  38. // },
  39. // fail: function (res) {
  40. // console.log('fail' + res.errMsg)
  41. // }
  42. // })
  43. // },
  44. /**
  45. * 登录泰山系统
  46. * @param {*} code
  47. */
  48. // loginToTaishan: function (code) {
  49. // wx.request({
  50. // url: this.globalData.cloudBase + "/Wx/Login/code=" + code,
  51. // method: 'GET',
  52. // header: {
  53. // "Content-Type": "json"
  54. // },
  55. // success: function (res) {
  56. // console.debug("login " + res.data);
  57. // if (res.data.code === "0") {
  58. // try {
  59. // wx.setStorageSync('openid', res.data.openid);
  60. // if (res.data.reg === "1") {
  61. // wx.setStorageSync('headIcon', res.data.headIcon);
  62. // wx.setStorageSync('nick', res.data.nick);
  63. // wx.setStorageSync('user_token', res.data.userToken);
  64. // } else {
  65. // console.log("user check fail ");
  66. // }
  67. // } catch (e) {
  68. // console.log(e);
  69. // }
  70. // } else {
  71. // console.log("login to taishan fail " + res);
  72. // }
  73. // },
  74. // fail: function (res) {
  75. // console.log("fail" + res);
  76. // }
  77. // })
  78. // },
  79. globalData: {
  80. defaultCity: '',
  81. defaultCounty: '',
  82. weatherData: '',
  83. g_isPlayingMusic: false,
  84. g_currentMusicPostId: null,
  85. //doubanBase: "https://api.douban.com",
  86. heWeatherBase: "https://free-api.heweather.com",
  87. //juhetoutiaoBase: "https://v.juhe.cn/toutiao/index",
  88. cloudBase: "https://wx.dahengsi.com",
  89. tencentMapKey: "4HYBZ-EB23D-SLC42-HQ5R3-LP3LQ-OZFU5",
  90. heWeatherKey: "4a817b4338e04cc59bdb92da7771411e",
  91. //juhetoutiaoKey: "a9f703a0200d68926f707f3f13629078",
  92. marketIndex: 0,
  93. imageBase: "https://wx.dahengsi.com",
  94. bluetoothErrCode: {
  95. ok: 0,
  96. //已连接
  97. alreadyConnect: -1,
  98. //未初始化蓝牙适配器
  99. notInit: 10000,
  100. //当前蓝牙适配器不可用
  101. notAvailable: 10001,
  102. //没有找到指定设备
  103. noDevice: 10002,
  104. //连接失败
  105. connectionFail: 10003,
  106. //没有找到指定服务
  107. noService: 10004,
  108. //没有找到指定特征
  109. noCharacteristic: 10005,
  110. //当前连接已断开
  111. noConnection: 10006,
  112. //当前特征不支持此操作
  113. propertyNotSupport: 10007,
  114. //其余所有系统上报的异常
  115. systemErro: 10008,
  116. //Android 系统特有,系统版本低于 4.3 不支持 BLE
  117. systemNotSupport: 10009,
  118. //连接超时
  119. operateTimeOut: 10012,
  120. //连接 deviceId 为空或者是格式不正确
  121. invalidData: 10013
  122. }
  123. }
  124. })