App.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <script>
  2. import {hasUpdate} from '@/utils/common.js'
  3. export default {
  4. onLaunch: function(options) {
  5. if(options.query.thirdCode){
  6. this.$store.commit('setThirdCode',options.query.thirdCode)
  7. }
  8. this.$store.dispatch('getUserInfo')
  9. this.$store.dispatch('getTabBar')
  10. const ENV=uni.getAccountInfoSync().miniProgram
  11. console.log('当前版本',ENV);
  12. uni.getSystemInfo({
  13. success: function (res) {
  14. console.log('宽度:',res.windowWidth);
  15. console.log('设备:',res.platform);
  16. if (res.windowWidth > 750||['windows','mac'].includes(res.platform)) {
  17. const params=options.query//此处的query就是在pc分享钩子函数中拼接的参数
  18. let paramsStr=`xcxPath=${decodeURIComponent(options.path)}`
  19. for(const key in params){
  20. paramsStr=`${paramsStr}&${key}=${params[key]}`
  21. }
  22. console.log('进入pc');
  23. uni.reLaunch({
  24. url: `/pages/pc?${paramsStr}&platform_source=xcx`,
  25. });
  26. }
  27. },
  28. fail:function(res){
  29. }
  30. })
  31. // 用户通过分享看看有没有code
  32. if (options.query && options.query.InviteShareCode) {
  33. console.log('进来了没有?');
  34. this.$store.commit("getInviteShareCode", options.query.InviteShareCode);
  35. }
  36. // 开启ios静音也行播放语音
  37. wx.setInnerAudioOption({
  38. obeyMuteSwitch:false
  39. })
  40. //设置在小程序内屏幕常亮(防止录音等操作自动息屏会停止录音)
  41. wx.setKeepScreenOn({
  42. keepScreenOn: true,
  43. fail(res){
  44. console.log('设置屏幕常亮失败:',res);
  45. }
  46. })
  47. if(ENV.envVersion!=='release'){
  48. // 打开调试
  49. wx.setEnableDebug({
  50. enableDebug: true
  51. })
  52. }
  53. },
  54. onShow: function(options) {
  55. console.log('App Show')
  56. hasUpdate()
  57. },
  58. onHide: function() {
  59. console.log('App Hide')
  60. }
  61. }
  62. </script>
  63. <style lang='scss'>
  64. @import "/wxcomponents/vant/common/index.wxss";
  65. /* 页面公共样式 */
  66. @import "./style/common.scss";
  67. </style>