App.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import "@/uni_modules/uview-ui/index.scss";
  4. </style>
  5. <script>
  6. import config from './config'
  7. import store from '@/store'
  8. import { getToken } from '@/utils/auth'
  9. export default {
  10. onLaunch: function(option) {
  11. uni.removeStorageSync("device_sn")
  12. uni.removeStorageSync("sessionId")
  13. uni.removeStorageSync("title")
  14. uni.removeStorageSync("channel")
  15. console.log('option>onLaunch>>>>'+JSON.stringify( option.query))
  16. if( option.query.sn!=''&&option.query.sn!=null){
  17. uni.setStorageSync("device_sn",option.query.sn)
  18. }else{
  19. // uni.showModal({
  20. // title: '提示',
  21. // content: '设备码获取失败请重新扫码',
  22. // showCancel:false,
  23. // success: function (res) {
  24. // if (res.confirm) {
  25. // console.log('用户点击确定');
  26. // } else if (res.cancel) {
  27. // console.log('用户点击取消');
  28. // }
  29. // }
  30. // });
  31. // return;
  32. }
  33. //Object.keys(option.query).includes('sessionId') &&
  34. if( option.query.sessionId!=''&&option.query.sessionId!=null){
  35. uni.setStorageSync("sessionId",option.query.sessionId)
  36. }else{
  37. // uni.showModal({
  38. // title: '提示',
  39. // content: '小程序加载失败请重新扫码',
  40. // showCancel:false,
  41. // success: function (res) {
  42. // if (res.confirm) {
  43. // console.log('用户点击确定');
  44. // } else if (res.cancel) {
  45. // console.log('用户点击取消');
  46. // }
  47. // }
  48. // });
  49. // return;
  50. }
  51. this.initApp()
  52. },
  53. onShow(option) {
  54. // 热启动时获取参数
  55. console.log('option>onShow>>>>'+JSON.stringify( option))
  56. uni.removeStorageSync("device_sn")
  57. uni.removeStorageSync("sessionId")
  58. uni.removeStorageSync("title")
  59. uni.removeStorageSync("channel")
  60. console.log('option>onLaunch>>>>'+JSON.stringify( option.query))
  61. if( option.query.sn!=''&&option.query.sn!=null){
  62. uni.setStorageSync("device_sn",option.query.sn)
  63. }else{
  64. uni.setStorageSync("device_sn",'')
  65. }
  66. if( option.query.channel!=''&&option.query.channel!=null){
  67. uni.setStorageSync("channel",option.query.channel)
  68. }else{
  69. uni.setStorageSync("channel",'')
  70. }
  71. //Object.keys(option.query).includes('sessionId') &&
  72. if( option.query.sessionId!=''&&option.query.sessionId!=null){
  73. uni.setStorageSync("sessionId",option.query.sessionId)
  74. }else{
  75. uni.setStorageSync("sessionId",'')
  76. }
  77. if( option.query.title!=''&&option.query.title!=null){
  78. uni.setStorageSync("title",option.query.title)
  79. }else{
  80. uni.setStorageSync("title",'')
  81. }
  82. },
  83. methods: {
  84. // 初始化应用
  85. initApp() {
  86. // 初始化应用配置
  87. this.initConfig()
  88. // 检查用户登录状态
  89. //#ifdef H5
  90. this.checkLogin()
  91. //#endif
  92. },
  93. initConfig() {
  94. this.globalData.config = config
  95. },
  96. checkLogin() {
  97. // if (!getToken()) {
  98. // this.$tab.reLaunch('/pages/login')
  99. // }
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss">
  105. </style>