App.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <script>
  2. import ws from '@/common/js/ws.js'
  3. export default {
  4. onLaunch: function() {
  5. console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
  6. console.log('App Launch')
  7. let that = this;
  8. let macAddress = that.api.getMacAddress()
  9. that.api.setSn(macAddress)
  10. // 获取设备信息
  11. // that.api.setSn("864629045684215,864629045684215")
  12. // plus.device.getInfo({
  13. // success:function(e){
  14. // console.log('getDeviceInfo success: '+JSON.stringify(e));
  15. // console.log('imei: '+e.imei);
  16. // that.api.setSn(e.imei)
  17. // // that.api.setSn("864629045684215,864629045684215")
  18. // // let sn = that.api.getSn();
  19. // // let url = that.api.wsHost() + sn;
  20. // // console.log('准备链接websocket:'+url);
  21. // // ws.connect(url, function(frame) {
  22. // // console.log('连接成功:' + frame);
  23. // // ws.subscribe('/topic/order/push', function(response) {
  24. // // console.log('收到消息:' + response.body);
  25. // // var json = JSON.parse(response.body);
  26. // // if (json.type == 'order_push' && json.sendType == 'all') {
  27. // // let orderId = json.data,
  28. // // dIds = json.msg;
  29. // // let user = that.api.getUser();
  30. // // if (user) {
  31. // // console.log(dIds);
  32. // // let userId = user.userId;
  33. // // console.log(userId);
  34. // // console.log(dIds.indexOf(',' + userId + ','));
  35. // // if (dIds.indexOf(',' + userId + ',') >= 0) {
  36. // // console.log("匹配到订单:" + orderId);
  37. // // uni.navigateTo({
  38. // // url: '/pages/order/accept?orderId=' + orderId
  39. // // })
  40. // // }
  41. // // }
  42. // // }
  43. // // })
  44. // // ws.subscribe('/topic/order/assign', function(response) {
  45. // // console.log('收到消息assign:' + response.body);
  46. // // var json = JSON.parse(response.body);
  47. // // if (json.type == 'order_assign' && json.sendType == 'all') {
  48. // // let orderId = json.data,
  49. // // dIds = json.msg;
  50. // // let user = that.api.getUser();
  51. // // if (user) {
  52. // // console.log(dIds);
  53. // // let userId = user.userId;
  54. // // console.log(userId);
  55. // // if (userId==dIds) {
  56. // // console.log("匹配到订单:" + orderId);
  57. // // let voice = uni.createInnerAudioContext()
  58. // // voice.src = that.api.mp3Url()
  59. // // // voice.src = 'http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=5&text=有新订单来了'
  60. // // voice.play()
  61. // // voice.onPlay(() => {
  62. // // console.log('开始播放');
  63. // // });
  64. // // voice.onEnded(() => {
  65. // // console.log('停止播放');
  66. // // voice.destroy();
  67. // // });
  68. // // voice.onError((res) => {
  69. // // console.log(res.errMsg);
  70. // // console.log(res.errCode);
  71. // // });
  72. // // uni.navigateTo({
  73. // // url: '/pages/accountInformation/information/information'
  74. // // })
  75. // // }
  76. // // }
  77. // // }
  78. // // })
  79. // // }, function(error) {
  80. // // console.log('连接失败:' + error);
  81. // // });
  82. // },
  83. // fail:function(e){
  84. // console.log('getDeviceInfo failed: '+JSON.stringify(e));
  85. // }
  86. // });
  87. },
  88. onShow: function() {
  89. console.log('App Show')
  90. },
  91. onHide: function() {
  92. console.log('App Hide')
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. /*每个页面公共css */
  98. @import '@/uni_modules/uni-scss/index.scss';
  99. /* #ifndef APP-NVUE */
  100. @import '@/static/customicons.css';
  101. // 设置整个项目的背景色
  102. page {
  103. background-color: #f5f5f5;
  104. }
  105. /* #endif */
  106. .example-info {
  107. font-size: 14px;
  108. color: #333;
  109. padding: 10px;
  110. }
  111. </style>