App.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <script>
  2. import {hasUpdate} from '@/utils/common.js'
  3. export default {
  4. onLaunch: function(options) {
  5. this.$store.dispatch('getUserInfo')
  6. this.$store.dispatch('getTabBar')
  7. },
  8. onShow: function(options) {
  9. console.log('App Show:',options)
  10. hasUpdate()
  11. uni.getSystemInfo({
  12. success: function (res) {
  13. if (res.windowWidth > 700) {
  14. const params=options.query//此处的query就是在pc分享钩子函数中拼接的参数
  15. let paramsStr=`xcxPath=${decodeURIComponent(options.path)}`
  16. for(const key in params){
  17. paramsStr=`${paramsStr}&${key}=${params[key]}`
  18. }
  19. console.log('进入pc');
  20. uni.reLaunch({
  21. url: `/pages/pc?${paramsStr}`,
  22. });
  23. }
  24. },
  25. fail:function(res){
  26. }
  27. })
  28. const env=uni.getAccountInfoSync().miniProgram
  29. if(env.envVersion!=='release'){
  30. // 打开调试
  31. wx.setEnableDebug({
  32. enableDebug: true
  33. })
  34. }
  35. },
  36. onHide: function() {
  37. console.log('App Hide')
  38. }
  39. }
  40. </script>
  41. <style lang='scss'>
  42. @import "/wxcomponents/vant/common/index.wxss";
  43. /* 页面公共样式 */
  44. @import "./style/common.scss";
  45. </style>