<script> import Vue from 'vue'; import store from '@/store'; export default Vue.extend({ mpType: 'app', onLaunch(options) { const option = options || {}; // 获取用户来源 // console.log('软件启动,输出转来的参数:', option); // console.log('场景值------------------:', option.scene); let loginQueryInfo = option ? option.query : {}; loginQueryInfo = loginQueryInfo || {}; // console.log('loginQueryInfo onShow===>', loginQueryInfo); const scene = decodeURIComponent(loginQueryInfo.scene); // console.log('decodeURIComponent scense====>', scene); let fromInfo = {}; if(scene.length > 0 ) { const getQueryString = { uid: undefined, sid: undefined, pid: undefined }; const strB = scene.split('&'); for(let i = 0; i < strB.length; i += 1) { getQueryString[strB[i].split('=')[0]] = unescape(strB[i].split('=')[1]); } fromInfo = { loginQueryInfo, fromuid: getQueryString.uid, fromsid: getQueryString.sid, frompid: getQueryString.pid, scene: option.scene, } store.dispatch('user/setFrom', fromInfo); // console.log('loginQueryInfo.hasOwnProperty=====111===>', getQueryString); } else { // console.log('loginQueryInfo.hasOwnProperty====22222====>', loginQueryInfo); if (loginQueryInfo.hasOwnProperty('sid') == false) { loginQueryInfo.sid = 0; } if (loginQueryInfo.hasOwnProperty('pid') == false) { loginQueryInfo.pid = 0; } if (loginQueryInfo.hasOwnProperty('uid') == false) { loginQueryInfo.uid = 0; } fromInfo = { loginQueryInfo, fromuid: loginQueryInfo.uid, fromsid: loginQueryInfo.sid, frompid: loginQueryInfo.pid, scene: option.scene, } store.dispatch('user/setFrom', fromInfo) } // 登陆 const openId = uni.getStorageSync('openid') || ""; if(openId.length <= 10) { uni.clearStorageSync() store.dispatch("user/login", fromInfo); } else { store.dispatch("user/getUserInfo", fromInfo); } }, onShow() { // console.log('App Show') }, onHide() { // console.log('App Hide') }, methods: { } }); </script> <style> /*每个页面公共css */ </style>