小程序蓝牙通信例子
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
708 B

  1. // app.js
  2. import { globalData } from "./utils/global";
  3. const EventEmitter2 = require("./miniprogram_npm/eventemitter2/index").EventEmitter2;
  4. const emitter = new EventEmitter2();
  5. App({
  6. onLaunch() {
  7. // 展示本地存储能力
  8. const logs = wx.getStorageSync('logs') || []
  9. logs.unshift(Date.now())
  10. wx.setStorageSync('logs', logs)
  11. // 登录
  12. wx.login({
  13. success: res => {
  14. // 发送 res.code 到后台换取 openId, sessionKey, unionId
  15. }
  16. })
  17. },
  18. globalData: Object.assign(
  19. {
  20. ble: "",//全局蓝牙实例
  21. emitter: emitter, //全局订阅函数
  22. blueStatus: false,
  23. userInfo: null
  24. },
  25. globalData
  26. ),
  27. })