提交 8a00c42a 编写于 作者: fxy060608's avatar fxy060608

feat(app): add referrerInfo

上级 bf33a6c7
......@@ -245,7 +245,8 @@ const third = [
'preloadPage',
'unPreloadPage',
'loadSubPackage',
'sendHostEvent'
'sendHostEvent',
'navigateToMiniProgram'
]
const ad = [
......
......@@ -256,7 +256,8 @@ var serviceContext = (function () {
'preloadPage',
'unPreloadPage',
'loadSubPackage',
'sendHostEvent'
'sendHostEvent',
'navigateToMiniProgram'
];
const ad = [
......@@ -1702,13 +1703,17 @@ var serviceContext = (function () {
"uni.chooseLocation.cancel": "取消"
};
const messages = {
const messages = {};
{
Object.assign(messages, {
en,
es,
fr,
'zh-Hans': zhHans,
'zh-Hant': zhHant
};
});
}
let locale;
......@@ -5802,7 +5807,7 @@ var serviceContext = (function () {
animationDuration: 200,
uniNView: {
path: `${(typeof process === 'object' && process.env && process.env.VUE_APP_TEMPLATE_PATH) || ''}/${url}.js`,
defaultFontSize: plus_.screen.resolutionWidth / 20,
defaultFontSize: 16,
viewport: plus_.screen.resolutionWidth
}
};
......@@ -9225,7 +9230,7 @@ var serviceContext = (function () {
});
}
function onWebviewPopGesture (webview) {
function onWebviewPopGesture(webview) {
let popStartStatusBarStyle;
webview.addEventListener('popGesture', e => {
if (e.type === 'start') {
......@@ -9242,16 +9247,49 @@ var serviceContext = (function () {
const pages = getCurrentPages();
const page = pages[pages.length - 1];
page && page.$remove();
setStatusBarStyle();
if (page && isDirectPage(page)) {
reLaunchEntryPage();
} else {
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateBack'
});
}
}
});
}
/**
* 是否处于直达页面
* @param page
* @returns
*/
function isDirectPage(page) {
return (
__uniConfig.realEntryPagePath &&
page.$page.route === __uniConfig.entryPagePath
)
}
/**
* 重新启动到首页
*/
function reLaunchEntryPage() {
__uniConfig.entryPagePath = __uniConfig.realEntryPagePath;
delete __uniConfig.realEntryPagePath;
uni.reLaunch({
url: addLeadingSlash(__uniConfig.entryPagePath),
});
}
function hasLeadingSlash(str) {
return str.indexOf('/') === 0
}
function addLeadingSlash(str) {
return hasLeadingSlash(str) ? str : '/' + str
}
let preloadWebview;
let id$1 = 2;
......@@ -9753,6 +9791,64 @@ var serviceContext = (function () {
return pageVm
}
const extend = Object.assign;
function createLaunchOptions () {
return {
path: '',
query: {},
scene: 1001,
referrerInfo: {
appId: '',
extraData: {}
}
}
}
const enterOptions = createLaunchOptions();
const launchOptions = createLaunchOptions();
function initLaunchOptions ({
path,
query,
referrerInfo
}) {
extend(launchOptions, {
path,
query: query ? parseQuery(query) : {},
referrerInfo: referrerInfo || {}
});
extend(enterOptions, launchOptions);
return launchOptions
}
function parseRedirectInfo () {
const weexPlus = weex.requireModule('plus');
if (weexPlus.getRedirectInfo) {
const {
path,
query,
extraData,
userAction,
fromAppid
} =
weexPlus.getRedirectInfo() || {};
const referrerInfo = {
appId: fromAppid,
extraData: {}
};
if (extraData) {
referrerInfo.extraData = extraData;
}
return {
path: path || '',
query: query ? '?' + query : '',
referrerInfo,
userAction
}
}
}
let isInitEntryPage = false;
function initEntryPage () {
......@@ -9767,9 +9863,16 @@ var serviceContext = (function () {
const weexPlus = weex.requireModule('plus');
if (weexPlus.getRedirectInfo) {
const info = weexPlus.getRedirectInfo() || {};
entryPagePath = info.path;
entryPageQuery = info.query ? ('?' + info.query) : '';
const {
path,
query,
referrerInfo
} = parseRedirectInfo();
if (path) {
entryPagePath = path;
entryPageQuery = query;
}
__uniConfig.referrerInfo = referrerInfo;
} else {
const argsJsonStr = plus.runtime.arguments;
if (!argsJsonStr) {
......@@ -21993,11 +22096,11 @@ var serviceContext = (function () {
}
function initAppLaunch (appVm) {
const args = {
const args = initLaunchOptions({
path: __uniConfig.entryPagePath,
query: {},
scene: 1001
};
query: __uniConfig.entryPageQuery,
referrerInfo: __uniConfig.referrerInfo
});
callAppHook(appVm, 'onLaunch', args);
callAppHook(appVm, 'onShow', args);
......
......@@ -45,6 +45,10 @@ import {
backbuttonListener
} from './backbutton'
import {
initLaunchOptions
} from './utils'
let appCtx
const defaultApp = {
......@@ -143,11 +147,11 @@ function onPlusMessage (e) {
}
function initAppLaunch (appVm) {
const args = {
const args = initLaunchOptions({
path: __uniConfig.entryPagePath,
query: {},
scene: 1001
}
query: __uniConfig.entryPageQuery,
referrerInfo: __uniConfig.referrerInfo
})
callAppHook(appVm, 'onLaunch', args)
callAppHook(appVm, 'onShow', args)
......
import {
parseRedirectInfo
} from './utils'
function parseRoutes (config) {
__uniRoutes.length = 0
/* eslint-disable no-mixed-operators */
......@@ -51,9 +55,16 @@ export function initEntryPage () {
const weexPlus = weex.requireModule('plus')
if (weexPlus.getRedirectInfo) {
const info = weexPlus.getRedirectInfo() || {}
entryPagePath = info.path
entryPageQuery = info.query ? ('?' + info.query) : ''
const {
path,
query,
referrerInfo
} = parseRedirectInfo()
if (path) {
entryPagePath = path
entryPageQuery = query
}
__uniConfig.referrerInfo = referrerInfo
} else {
const argsJsonStr = plus.runtime.arguments
if (!argsJsonStr) {
......
import {
parseQuery
} from 'uni-shared'
const extend = Object.assign
function createLaunchOptions () {
return {
path: '',
query: {},
scene: 1001,
referrerInfo: {
appId: '',
extraData: {}
}
}
}
const enterOptions = createLaunchOptions()
const launchOptions = createLaunchOptions()
export function getLaunchOptions () {
return launchOptions
}
export function getEnterOptions () {
return enterOptions
}
export function initEnterOptions ({
path,
query,
referrerInfo
}) {
extend(enterOptions, {
path,
query: query ? parseQuery(query) : {},
referrerInfo: referrerInfo || {}
})
}
export function initLaunchOptions ({
path,
query,
referrerInfo
}) {
extend(launchOptions, {
path,
query: query ? parseQuery(query) : {},
referrerInfo: referrerInfo || {}
})
extend(enterOptions, launchOptions)
return launchOptions
}
export function parseRedirectInfo () {
const weexPlus = weex.requireModule('plus')
if (weexPlus.getRedirectInfo) {
const {
path,
query,
extraData,
userAction,
fromAppid
} =
weexPlus.getRedirectInfo() || {}
const referrerInfo = {
appId: fromAppid,
extraData: {}
}
if (extraData) {
referrerInfo.extraData = extraData
}
return {
path: path || '',
query: query ? '?' + query : '',
referrerInfo,
userAction
}
}
}
......@@ -19,12 +19,44 @@ export function onWebviewPopGesture (webview) {
const pages = getCurrentPages()
const page = pages[pages.length - 1]
page && page.$remove()
setStatusBarStyle()
if (page && isDirectPage(page)) {
reLaunchEntryPage()
} else {
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateBack'
})
}
}
})
}
/**
* 是否处于直达页面
* @param page
* @returns
*/
function isDirectPage (page) {
return (
__uniConfig.realEntryPagePath &&
page.$page.route === __uniConfig.entryPagePath
)
}
/**
* 重新启动到首页
*/
function reLaunchEntryPage () {
__uniConfig.entryPagePath = __uniConfig.realEntryPagePath
delete __uniConfig.realEntryPagePath
uni.reLaunch({
url: addLeadingSlash(__uniConfig.entryPagePath)
})
}
function hasLeadingSlash (str) {
return str.indexOf('/') === 0
}
function addLeadingSlash (str) {
return hasLeadingSlash(str) ? str : '/' + str
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册