App.vue 970 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. },
  29. onHide: function() {
  30. console.log('App Hide')
  31. }
  32. }
  33. </script>
  34. <style lang='scss'>
  35. @import "/wxcomponents/vant/common/index.wxss";
  36. /* 页面公共样式 */
  37. @import "./style/common.scss";
  38. </style>