From 358c040c069504a7d87603cb144cbd7e7be12ff8 Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 17 Nov 2022 16:52:33 +0800 Subject: [PATCH] chore: build --- packages/uni-app-plus/dist/index.v3.js | 7798 +++++++++-------- packages/uni-app-plus/dist/view.umd.min.js | 2 +- packages/uni-h5/dist/index.dark.css | 2 +- packages/uni-h5/dist/index.umd.min.js | 2 +- packages/uni-quickapp-native/dist/vue.dev.js | 2 +- packages/uni-quickapp-native/dist/vue.prod.js | 2 +- 6 files changed, 3923 insertions(+), 3885 deletions(-) diff --git a/packages/uni-app-plus/dist/index.v3.js b/packages/uni-app-plus/dist/index.v3.js index 982035f2e..5007f1737 100644 --- a/packages/uni-app-plus/dist/index.v3.js +++ b/packages/uni-app-plus/dist/index.v3.js @@ -3161,7 +3161,7 @@ var serviceContext = (function () { }, cancelColor: { type: String, - default: '#000000' + default: '#000' }, confirmText: { type: String, @@ -3249,7 +3249,7 @@ var serviceContext = (function () { }, itemColor: { type: String, - default: '#000000' + default: '#000' }, visible: { type: Boolean, @@ -6269,4414 +6269,4436 @@ var serviceContext = (function () { } } - const ON_THEME_CHANGE$1 = 'api.onThemeChange'; - - function onThemeChange (callback = () => { }) { - UniServiceJSBridge.on(ON_THEME_CHANGE$1, callback); - } - - function offThemeChange (callback = () => { }) { - UniServiceJSBridge.off(ON_THEME_CHANGE$1, callback); - } - - function parseTheme (pageStyle) { - let parsedStyle = {}; - if (__uniConfig.darkmode) { - let theme = 'light'; - const systemInfo = weexGetSystemInfoSync(); - if (systemInfo) { - theme = systemInfo.hostTheme || systemInfo.osTheme; - } - parsedStyle = normallizeStyles(pageStyle, __uniConfig.themeConfig, theme); - } - return __uniConfig.darkmode ? parsedStyle : pageStyle - } - - function useTabBarThemeChange (tabBar, options) { - if (__uniConfig.darkmode) { - const fn = () => { - const { - list = [], color, selectedColor, - backgroundColor, borderStyle - } = parseTheme(options); - const tabbarStyle = { - color, - selectedColor, - backgroundColor, - borderStyle - }; - - tabBar && tabBar.setTabBarStyle(tabbarStyle); - tabBar && tabBar.setTabBarItems({ - list: list.map((item) => ({ - iconPath: item.iconPath, - selectedIconPath: item.selectedIconPath, - visible: item.visible - })) - }); - // TODO 暂未实现 - // tabBar && tabBar.setAnimationAlphaBGColor(parseTheme((__uniConfig.window || {}).backgroundColor, false)) - }; - - fn(); - - onThemeChange(fn); - } - } - - function useWebviewThemeChange (webview, getWebviewStyle) { - if (__uniConfig.darkmode) { - const fn = () => { - const { - animationAlphaBGColor, background, - backgroundColorBottom, backgroundColorTop, - titleNView: { backgroundColor, titleColor } = {} - } = getWebviewStyle(); - webview && webview.setStyle({ - animationAlphaBGColor, - background, - backgroundColorBottom, - backgroundColorTop, - titleNView: { - backgroundColor, - titleColor - } - }); - }; - onThemeChange(fn); - webview.addEventListener('close', () => offThemeChange(fn)); - } - } - - const TABBAR_HEIGHT = 50; - let config; - - /** - * tabbar显示状态 - */ - let visible = true; - - let tabBar; - - function setTabBarItems (style) { - tabBar && tabBar.setTabBarItems(style); + function createButtonOnClick (index) { + return function onClick (btn) { + const pages = getCurrentPages(); + if (!pages.length) { + return + } + btn.index = index; + const page = pages[pages.length - 1]; + page.$vm && + page.$vm.__call_hook && + page.$vm.__call_hook('onNavigationBarButtonTap', btn); + } } - /** - * 设置角标 - * @param {string} type - * @param {number} index - * @param {string} text - */ - function setTabBarBadge$1 (type, index, text) { - if (!tabBar) { - return - } - if (type === 'none') { - tabBar.hideTabBarRedDot({ - index - }); - tabBar.removeTabBarBadge({ - index - }); - } else if (type === 'text') { - tabBar.setTabBarBadge({ - index, - text - }); - } else if (type === 'redDot') { - tabBar.showTabBarRedDot({ - index - }); + function parseTitleNViewButtons (titleNView) { + const buttons = titleNView.buttons; + if (!Array.isArray(buttons)) { + return titleNView } + buttons.forEach((btn, index) => { + btn.onclick = createButtonOnClick(index); + }); + return titleNView } - /** - * 动态设置 tabBar 某一项的内容 - */ - function setTabBarItem$1 (index, text, iconPath, selectedIconPath, visible, iconfont) { - const item = { - index - }; - if (text !== undefined) { - item.text = text; - } - if (iconPath) { - item.iconPath = getRealPath$1(iconPath); - } - if (selectedIconPath) { - item.selectedIconPath = getRealPath$1(selectedIconPath); - } - if (iconfont !== undefined) { - item.iconfont = iconfont; + + function parseTitleNView (id, routeOptions) { + const windowOptions = routeOptions.window; + const titleNView = windowOptions.titleNView; + routeOptions.meta.statusBarStyle = + windowOptions.navigationBarTextStyle === 'black' ? 'dark' : 'light'; + if ( + // 无头 + titleNView === false || + titleNView === 'false' || + (windowOptions.navigationStyle === 'custom' && + !isPlainObject(titleNView)) || + (windowOptions.transparentTitle === 'always' && !isPlainObject(titleNView)) + ) { + return false } - if (visible !== undefined) { - item.visible = config.list[index].visible = visible; - delete item.index; - const tabbarItems = config.list.map(item => ({ visible: item.visible })); - tabbarItems[index] = item; + const titleImage = windowOptions.titleImage || ''; + const transparentTitle = windowOptions.transparentTitle || 'none'; + const titleNViewTypeList = { + none: 'default', + auto: 'transparent', + always: 'float' + }; - setTabBarItems({ list: tabbarItems }); - } else { - tabBar && tabBar.setTabBarItem(item); + const navigationBarBackgroundColor = + windowOptions.navigationBarBackgroundColor; + const ret = { + autoBackButton: !routeOptions.meta.isQuit, + titleText: + titleImage === '' ? windowOptions.navigationBarTitleText || '' : '', + titleColor: + windowOptions.navigationBarTextStyle === 'black' ? '#000000' : '#ffffff', + type: titleNViewTypeList[transparentTitle], + backgroundColor: + /^#[a-z0-9]{6}$/i.test(navigationBarBackgroundColor) || + navigationBarBackgroundColor === 'transparent' + ? navigationBarBackgroundColor + : '#f7f7f7', + tags: + titleImage === '' + ? [] + : [ + { + tag: 'img', + src: titleImage, + position: { + left: 'auto', + top: 'auto', + width: 'auto', + height: '26px' + } + } + ] + }; + + if (isPlainObject(titleNView)) { + return initTitleNViewI18n( + id, + Object.assign(ret, parseTitleNViewButtons(titleNView)) + ) } - } - /** - * 动态设置 tabBar 的整体样式 - * @param {Object} style 样式 - */ - function setTabBarStyle$1 (style) { - tabBar && tabBar.setTabBarStyle(style); - } - /** - * 隐藏 tabBar - * @param {boolean} animation 是否需要动画效果 - */ - function hideTabBar$1 (animation) { - visible = false; - tabBar && tabBar.hideTabBar({ - animation - }); - } - /** - * 显示 tabBar - * @param {boolean} animation 是否需要动画效果 - */ - function showTabBar$1 (animation) { - visible = true; - tabBar && tabBar.showTabBar({ - animation - }); + return initTitleNViewI18n(id, ret) } - const maskClickCallback = []; - - var tabBar$1 = { - id: '0', - init (options, clickCallback) { - if (options && options.list.length) { - config = options; - } - try { - tabBar = requireNativePlugin('uni-tabview'); - } catch (error) { - console.log(`uni.requireNativePlugin("uni-tabview") error ${error}`); - } - tabBar.onMaskClick(() => { - maskClickCallback.forEach((callback) => { - callback(); + function initTitleNViewI18n (id, titleNView) { + const i18nResult = initNavigationBarI18n(titleNView); + if (!i18nResult) { + return titleNView + } + const [titleTextI18n, searchInputPlaceholderI18n] = i18nResult; + if (titleTextI18n || searchInputPlaceholderI18n) { + uni.onLocaleChange(() => { + const webview = plus.webview.getWebviewById(id + ''); + if (!webview) { + return + } + const newTitleNView = {}; + if (titleTextI18n) { + newTitleNView.titleText = titleNView.titleText; + } + if (searchInputPlaceholderI18n) { + newTitleNView.searchInput = { + placeholder: titleNView.searchInput.placeholder + }; + } + if (process.env.NODE_ENV !== 'production') { + console.log('[uni-app] updateWebview', webview.id, newTitleNView); + } + webview.setStyle({ + titleNView: newTitleNView }); }); - tabBar && tabBar.onClick(({ index }) => { - clickCallback(config.list[index], index); - }); - tabBar && tabBar.onMidButtonClick(() => { - publish('onTabBarMidButtonTap', {}); - }); + } + return titleNView + } + + function parsePullToRefresh (routeOptions) { + const windowOptions = routeOptions.window; - useTabBarThemeChange(tabBar, options); - }, - indexOf (page) { - const config = this.config; - const itemLength = config && config.list && config.list.length; - if (itemLength) { - for (let i = 0; i < itemLength; i++) { - if ( - config.list[i].pagePath === page || - config.list[i].pagePath === `${page}.html` - ) { - return i + if (windowOptions.enablePullDownRefresh || (windowOptions.pullToRefresh && windowOptions.pullToRefresh.support)) { + const pullToRefreshStyles = Object.create(null); + // 初始化默认值 + if (plus.os.name === 'Android') { + Object.assign(pullToRefreshStyles, { + support: true, + style: 'circle' + }); + } else { + Object.assign(pullToRefreshStyles, { + support: true, + style: 'default', + height: '50px', + range: '200px', + contentdown: { + caption: '' + }, + contentover: { + caption: '' + }, + contentrefresh: { + caption: '' } - } - } - return -1 - }, - switchTab (page) { - const index = this.indexOf(page); - if (index >= 0) { - tabBar && tabBar.switchSelect({ - index }); - return true } - return false - }, - setTabBarBadge: setTabBarBadge$1, - setTabBarItem: setTabBarItem$1, - setTabBarStyle: setTabBarStyle$1, - hideTabBar: hideTabBar$1, - showTabBar: showTabBar$1, - append (webview) { - tabBar && tabBar.append({ - id: webview.id - }, ({ code }) => { - if (code !== 0) { - // console.log('tab append error') - setTimeout(() => { - this.append(webview); - }, 20); - } - }); - }, - get config () { - return config || __uniConfig.tabBar - }, - get visible () { - return visible - }, - get height () { - const config = this.config; - return (config && config.height ? parseFloat(config.height) : TABBAR_HEIGHT) + plus.navigator.getSafeAreaInsets().deviceBottom - }, - // tabBar是否遮挡内容区域 - get cover () { - const config = this.config; - const array = ['extralight', 'light', 'dark']; - return config && array.indexOf(config.blurEffect) >= 0 - }, - setStyle ({ mask }) { - tabBar.setMask({ - color: mask - }); - }, - addEventListener (name, callback) { - maskClickCallback.push(callback); - }, - removeEventListener (name, callback) { - const callbackIndex = maskClickCallback.indexOf(callback); - maskClickCallback.splice(callbackIndex, 1); + + if (windowOptions.backgroundTextStyle) { + pullToRefreshStyles.color = windowOptions.backgroundTextStyle; + pullToRefreshStyles.snowColor = windowOptions.backgroundTextStyle; + } + + Object.assign(pullToRefreshStyles, windowOptions.pullToRefresh || {}); + + return pullToRefreshStyles } - }; - - function getStatusbarHeight () { - // 横屏时 iOS 获取的状态栏高度错误,进行纠正 - return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === 'iOS' ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0 } - function getWindowInfo () { - const ios = plus.os.name.toLowerCase() === 'ios'; + const REGEX_UPX = /(\d+(\.\d+)?)[r|u]px/g; - const { - screenWidth, - screenHeight - } = getScreenInfo(); - const statusBarHeight = getStatusbarHeight(); + function transformCSS (css) { + return css.replace(REGEX_UPX, (a, b) => { + return uni.upx2px(parseInt(b) || 0) + 'px' + }) + } - let safeAreaInsets; - const titleNView = { - height: 0, - cover: false - }; - const webview = getLastWebview(); - if (webview) { - let style = webview.getStyle(); - style = style && style.titleNView; - if (style && style.type && style.type !== 'none') { - titleNView.height = style.type === 'transparent' ? 0 : (statusBarHeight + NAVBAR_HEIGHT); - titleNView.cover = style.type === 'transparent' || style.type === 'float'; + function parseStyleUnit (styles) { + let newStyles = {}; + const stylesStr = JSON.stringify(styles); + if (~stylesStr.indexOf('upx') || ~stylesStr.indexOf('rpx')) { + try { + newStyles = JSON.parse(transformCSS(stylesStr)); + } catch (e) { + newStyles = styles; + console.error(e); } - safeAreaInsets = webview.getSafeAreaInsets(); } else { - safeAreaInsets = plus.navigator.getSafeAreaInsets(); - } - const tabBarView = { - height: 0, - cover: false - }; - if (isTabBarPage()) { - tabBarView.height = tabBar$1.visible ? tabBar$1.height : 0; - tabBarView.cover = tabBar$1.cover; - } - const windowTop = titleNView.cover ? titleNView.height : 0; - const windowBottom = tabBarView.cover ? tabBarView.height : 0; - let windowHeight = screenHeight - titleNView.height - tabBarView.height; - let windowHeightReal = screenHeight - (titleNView.cover ? 0 : titleNView.height) - (tabBarView.cover ? 0 : tabBarView.height); - const windowWidth = screenWidth; - if ((!tabBarView.height || tabBarView.cover) && !safeAreaInsets.bottom && safeAreaInsets.deviceBottom) { - windowHeight -= safeAreaInsets.deviceBottom; - windowHeightReal -= safeAreaInsets.deviceBottom; + newStyles = JSON.parse(stylesStr); } - safeAreaInsets = ios ? safeAreaInsets : { - left: 0, - right: 0, - top: titleNView.height && !titleNView.cover ? 0 : statusBarHeight, - bottom: 0 - }; - const safeArea = { - left: safeAreaInsets.left, - right: windowWidth - safeAreaInsets.right, - top: safeAreaInsets.top, - bottom: windowHeightReal - safeAreaInsets.bottom, - width: windowWidth - safeAreaInsets.left - safeAreaInsets.right, - height: windowHeightReal - safeAreaInsets.top - safeAreaInsets.bottom - }; - return { - pixelRatio: plus.screen.scale, - screenWidth, - screenHeight, - windowWidth, - windowHeight, - statusBarHeight, - safeArea, - safeAreaInsets: { - top: safeAreaInsets.top, - right: safeAreaInsets.right, - bottom: safeAreaInsets.bottom, - left: safeAreaInsets.left - }, - windowTop, - windowBottom, - screenTop: screenHeight - windowHeight - } + return newStyles } - let systemInfo = {}; - let _initSystemInfo = true; + const WEBVIEW_STYLE_BLACKLIST = [ + 'navigationBarBackgroundColor', + 'navigationBarTextStyle', + 'navigationBarTitleText', + 'navigationBarShadow', + 'navigationStyle', + 'disableScroll', + 'backgroundColor', + 'backgroundTextStyle', + 'enablePullDownRefresh', + 'onReachBottomDistance', + 'usingComponents', + // 需要解析的 + 'titleNView', + 'pullToRefresh' + ]; - function weexGetSystemInfoSync () { - if (!_initSystemInfo) return - const { getSystemInfoSync } = weex.requireModule('plus'); - systemInfo = getSystemInfoSync(); - if (typeof systemInfo === 'string') { - try { - systemInfo = JSON.parse(systemInfo); - } catch (error) { } - } - return systemInfo - } - - function getDeviceInfo () { - weexGetSystemInfoSync(); - const { - deviceBrand = '', deviceModel, osName, - osVersion, deviceOrientation, deviceType, - deviceId - } = systemInfo; - - const brand = deviceBrand.toLowerCase(); - const _osName = osName.toLowerCase(); + function parseWebviewStyle (id, path, _routeOptions = {}) { + const webviewStyle = { + bounce: 'vertical' + }; - return { - brand, - deviceBrand: brand, - deviceModel, - devicePixelRatio: plus.screen.scale, - deviceId, - deviceOrientation, - deviceType, - model: deviceModel, - platform: _osName, - system: `${_osName === 'ios' ? 'iOS' : 'Android'} ${osVersion}` - } - } + // 合并 + _routeOptions.window = parseStyleUnit( + Object.assign( + JSON.parse(JSON.stringify(__uniConfig.window || {})), + _routeOptions.window || {} + ) + ); - function getAppBaseInfo () { - weexGetSystemInfoSync(); - const { - hostPackageName, hostName, osLanguage, - hostVersion, hostLanguage, hostTheme, - appId, appName, appVersion, appVersionCode, - appWgtVersion, osTheme - } = systemInfo; + Object.keys(_routeOptions.window).forEach(name => { + if (WEBVIEW_STYLE_BLACKLIST.indexOf(name) === -1) { + webviewStyle[name] = _routeOptions.window[name]; + } + }); - const appLanguage = uni - ? uni.getLocale - ? uni.getLocale() - : hostLanguage - : hostLanguage; + const routeOptions = parseTheme(_routeOptions); - return { - appId, - appName, - appVersion, - appVersionCode, - appWgtVersion, - appLanguage, - enableDebug: false, - hostSDKVersion: undefined, - hostPackageName, - hostName, - hostVersion, - hostLanguage, - hostTheme, - hostFontSizeSetting: undefined, - language: osLanguage, - SDKVersion: '', - theme: hostTheme || osTheme, - version: plus.runtime.innerVersion + const backgroundColor = routeOptions.window.backgroundColor; + if ( + /^#[a-z0-9]{6}$/i.test(backgroundColor) || + backgroundColor === 'transparent' + ) { + if (!webviewStyle.background) { + webviewStyle.background = backgroundColor; + } + if (!webviewStyle.backgroundColorTop) { + webviewStyle.backgroundColorTop = backgroundColor; + } + if (!webviewStyle.backgroundColorBottom) { + webviewStyle.backgroundColorBottom = backgroundColor; + } + if (!webviewStyle.animationAlphaBGColor) { + webviewStyle.animationAlphaBGColor = backgroundColor; + } + if (typeof webviewStyle.webviewBGTransparent === 'undefined') { + webviewStyle.webviewBGTransparent = true; + } } - } - function getSystemInfoSync () { - return callApiSync(getSystemInfo, Object.create(null), 'getSystemInfo', 'getSystemInfoSync') - } + const titleNView = parseTitleNView(id, routeOptions); + if (titleNView) { + if ( + id === 1 && + __uniConfig.realEntryPagePath && + !routeOptions.meta.isQuit // 可能是tabBar + ) { + titleNView.autoBackButton = true; + } + webviewStyle.titleNView = titleNView; + } - function getSystemInfo () { - _initSystemInfo = true; - weexGetSystemInfoSync(); - _initSystemInfo = false; - const windowInfo = getWindowInfo(); - const deviceInfo = getDeviceInfo(); - const appBaseInfo = getAppBaseInfo(); - _initSystemInfo = true; + const pullToRefresh = parsePullToRefresh(routeOptions); + if (pullToRefresh) { + if (pullToRefresh.style === 'circle') { + webviewStyle.bounce = 'none'; + } + webviewStyle.pullToRefresh = pullToRefresh; + } - const extraData = { - errMsg: 'getSystemInfo:ok', - fontSizeSetting: appBaseInfo.hostFontSizeSetting, - osName: systemInfo.osName.toLowerCase() - }; + // 不支持 hide + if (webviewStyle.popGesture === 'hide') { + delete webviewStyle.popGesture; + } - if (systemInfo.hostName) { - extraData.hostSDKVersion = systemInfo.uniRuntimeVersion; + if (routeOptions.meta.isQuit) { + // 退出 + webviewStyle.popGesture = plus.os.name === 'iOS' ? 'appback' : 'none'; } - const _systemInfo = Object.assign( - {}, - systemInfo, - windowInfo, - deviceInfo, - appBaseInfo, - extraData - ); + // TODO 下拉刷新 - delete _systemInfo.screenTop; - delete _systemInfo.enableDebug; - if (!__uniConfig.darkmode) { - delete _systemInfo.theme; + if (path && routeOptions.meta.isNVue) { + webviewStyle.uniNView = { + path, + defaultFontSize: __uniConfig.defaultFontSize, + viewport: __uniConfig.viewport + }; } - return sortObject(_systemInfo) + _routeOptions.meta = routeOptions.meta; + return webviewStyle } - function vibrateLong () { - plus.device.vibrate(400); - return { - errMsg: 'vibrateLong:ok' - } - } - function vibrateShort () { - plus.device.vibrate(15); - return { - errMsg: 'vibrateShort:ok' - } + function backbuttonListener () { + uni.navigateBack({ + from: 'backbutton' + }); } - function getSystemSetting () { - const { getSystemSetting } = weex.requireModule('plus'); - let systemSetting = getSystemSetting(); - try { - if (typeof systemSetting === 'string') { systemSetting = JSON.parse(systemSetting); } - } catch (error) { } - - return systemSetting + function getStatusbarHeight () { + // 横屏时 iOS 获取的状态栏高度错误,进行纠正 + return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === 'iOS' ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0 } - function getAppAuthorizeSetting () { - const { getAppAuthorizeSetting } = weex.requireModule('plus'); - let appAuthorizeSetting = getAppAuthorizeSetting(); - try { - if (typeof appAuthorizeSetting === 'string') { appAuthorizeSetting = JSON.parse(appAuthorizeSetting); } - } catch (error) { } - - for (const key in appAuthorizeSetting) { - if (Object.hasOwnProperty.call(appAuthorizeSetting, key)) { - const value = appAuthorizeSetting[key]; - if (value === 'undefined') appAuthorizeSetting[key] = undefined; - } + function initPopupSubNVue (subNVueWebview, style, maskWebview) { + if (!maskWebview.popupSubNVueWebviews) { + maskWebview.popupSubNVueWebviews = {}; } - return appAuthorizeSetting - } + maskWebview.popupSubNVueWebviews[subNVueWebview.id] = subNVueWebview; - function openAppAuthorizeSetting (options, callbackId) { - const { openAppAuthorizeSetting } = weex.requireModule('plus'); - openAppAuthorizeSetting(ret => { - if (ret.type === 'success') { - invoke$1(callbackId, { - errMsg: 'getClipboardData:ok' - }); - } else { - invoke$1(callbackId, { - errMsg: 'getClipboardData:fail' - }); + if (process.env.NODE_ENV !== 'production') { + console.log( + `UNIAPP[webview][${maskWebview.id}]:add.popupSubNVueWebview[${subNVueWebview.id}]` + ); + } + + const hideSubNVue = function () { + maskWebview.setStyle({ + mask: 'none' + }); + subNVueWebview.hide('auto'); + }; + maskWebview.addEventListener('maskClick', hideSubNVue); + let isRemoved = false; // 增加个 remove 标记,防止出错 + subNVueWebview.addEventListener('show', () => { + if (!isRemoved) { + plus.key.removeEventListener('backbutton', backbuttonListener); + plus.key.addEventListener('backbutton', hideSubNVue); + isRemoved = true; + } + }); + subNVueWebview.addEventListener('hide', () => { + if (isRemoved) { + plus.key.removeEventListener('backbutton', hideSubNVue); + plus.key.addEventListener('backbutton', backbuttonListener); + isRemoved = false; + } + }); + subNVueWebview.addEventListener('close', () => { + delete maskWebview.popupSubNVueWebviews[subNVueWebview.id]; + if (isRemoved) { + plus.key.removeEventListener('backbutton', hideSubNVue); + plus.key.addEventListener('backbutton', backbuttonListener); + isRemoved = false; } }); } - const SAVED_DIR = 'uniapp_save'; - const SAVE_PATH = `_doc/${SAVED_DIR}`; - - function getSavedFileDir (success, fail) { - fail = fail || function () { }; - plus.io.requestFileSystem(plus.io.PRIVATE_DOC, fs => { // 请求_doc fs - fs.root.getDirectory(SAVED_DIR, { // 获取文件保存目录对象 - create: true - }, success, fail); - }, fail); - } + function initNormalSubNVue (subNVueWebview, style, webview) { + webview.append(subNVueWebview); + } + + function initSubNVue (subNVue, routeOptions, webview) { + if (!subNVue.path) { + return + } + const style = subNVue.style || {}; + const isNavigationBar = subNVue.type === 'navigationBar'; + const isPopup = subNVue.type === 'popup'; + + delete style.type; + + if (isPopup && !subNVue.id) { + console.warn('subNVue[' + subNVue.path + '] is missing id'); + } + // TODO lazyload + + style.uniNView = { + path: subNVue.path.replace('.nvue', '.js'), + defaultFontSize: __uniConfig.defaultFontSize, + viewport: __uniConfig.viewport + }; + + const extras = { + __uniapp_host: routeOptions.path, + __uniapp_origin: style.uniNView.path.split('?')[0].replace('.js', ''), + __uniapp_origin_id: webview.id, + __uniapp_origin_type: webview.__uniapp_type + }; + + let maskWebview; + + if (isNavigationBar) { + style.position = 'dock'; + style.dock = 'top'; + style.top = 0; + style.width = '100%'; + style.height = NAVBAR_HEIGHT + getStatusbarHeight(); + delete style.left; + delete style.right; + delete style.bottom; + delete style.margin; + } else if (isPopup) { + style.position = 'absolute'; + if (isTabBarPage(routeOptions.path)) { + maskWebview = tabBar$1; + } else { + maskWebview = webview; + } + extras.__uniapp_mask = style.mask || 'rgba(0,0,0,0.5)'; + extras.__uniapp_mask_id = maskWebview.id; + } + + if (process.env.NODE_ENV !== 'production') { + console.log( + `UNIAPP[webview][${webview.id}]:create[${subNVue.id}]:${JSON.stringify(style)}` + ); + } + delete style.mask; + const subNVueWebview = plus.webview.create('', subNVue.id, style, extras); + + if (isPopup) { + initPopupSubNVue(subNVueWebview, style, maskWebview); + } else { + initNormalSubNVue(subNVueWebview, style, webview); + } + } + + function initSubNVues (routeOptions, webview) { + const subNVues = routeOptions.window.subNVues; + if (!subNVues || !subNVues.length) { + return + } + subNVues.forEach(subNVue => { + initSubNVue(subNVue, routeOptions, webview); + }); + } + + function onWebviewClose (webview) { + webview.popupSubNVueWebviews && webview.addEventListener('close', () => { + Object.keys(webview.popupSubNVueWebviews).forEach(id => { + if (process.env.NODE_ENV !== 'production') { + console.log( + `UNIAPP[webview][${webview.id}]:popupSubNVueWebview[${id}].close` + ); + } + webview.popupSubNVueWebviews[id].close('none'); + }); + }); + } + + function onWebviewResize (webview) { + const onResize = function ({ + width, + height + }) { + const landscape = Math.abs(plus.navigator.getOrientation()) === 90; + const res = { + deviceOrientation: landscape ? 'landscape' : 'portrait', + size: { + windowWidth: Math.ceil(width), + windowHeight: Math.ceil(height) + } + }; + publish('onViewDidResize', res); // API + UniServiceJSBridge.emit('onResize', res, parseInt(webview.id)); // Page lifecycle + }; + webview.addEventListener('resize', debounce(onResize, 50)); + } + + const VD_SYNC_VERSION = 2; - let index = 0; - function saveFile$1 ({ - tempFilePath - } = {}, callbackId) { - const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile'); - const fileName = `${Date.now()}${index++}${getExtName(tempFilePath)}`; + const PAGE_CREATE = 2; + const MOUNTED_DATA = 4; + const UPDATED_DATA = 6; + const PAGE_CREATED = 10; - plus.io.resolveLocalFileSystemURL(tempFilePath, entry => { // 读取临时文件 FileEntry - getSavedFileDir(dir => { - entry.copyTo(dir, fileName, () => { // 复制临时文件 FileEntry,为了避免把相册里的文件删除,使用 copy,微信中是要删除临时文件的 - const savedFilePath = SAVE_PATH + '/' + fileName; - invoke$1(callbackId, { - errMsg: 'saveFile:ok', - savedFilePath - }); - }, errorCallback); - }, errorCallback); - }, errorCallback); - } + const UI_EVENT = 20; - function getSavedFileList (options, callbackId) { - const errorCallback = warpPlusErrorCallback(callbackId, 'getSavedFileList'); + const VD_SYNC = 'vdSync'; - getSavedFileDir(entry => { - var reader = entry.createReader(); + const WEBVIEW_READY = 'webviewReady'; + const VD_SYNC_CALLBACK = 'vdSyncCallback'; + const INVOKE_API = 'invokeApi'; + const WEB_INVOKE_APPSERVICE$1 = 'WEB_INVOKE_APPSERVICE'; + const WEBVIEW_INSERTED = 'webviewInserted'; + const WEBVIEW_REMOVED = 'webviewRemoved'; + const WEBVIEW_ID_PREFIX = 'webviewId'; + + function onWebviewRecovery (webview, routeOptions) { + const { + subscribe, + unsubscribe + } = UniServiceJSBridge; - var fileList = []; - reader.readEntries(entries => { - if (entries && entries.length) { - entries.forEach(entry => { - entry.getMetadata(meta => { - fileList.push({ - filePath: plus.io.convertAbsoluteFileSystem(entry.fullPath), - createTime: meta.modificationTime.getTime(), - size: meta.size - }); - if (fileList.length === entries.length) { - invoke$1(callbackId, { - errMsg: 'getSavedFileList:ok', - fileList - }); - } - }, errorCallback, false); - }); + const id = webview.id; + const onWebviewRecoveryReady = function (data, pageId) { + if (id !== pageId) { + return + } + unsubscribe(WEBVIEW_READY, onWebviewRecoveryReady); + if (process.env.NODE_ENV !== 'production') { + console.log(`UNIAPP[webview][${id}]:onWebviewRecoveryReady ready`); + } + // 恢复目标页面 + pageId = parseInt(pageId); + const page = getCurrentPages(true).find(page => page.$page.id === pageId); + if (!page) { + return console.error(`Page[${pageId}] not found`) + } + page.$vm._$vd.restore(); + }; + + webview.addEventListener('recovery', e => { + if (process.env.NODE_ENV !== 'production') { + console.log(`UNIAPP[webview][${this.id}].recovery.reload:` + JSON.stringify({ + path: routeOptions.path, + webviewId: id + })); + } + subscribe(WEBVIEW_READY, onWebviewRecoveryReady); + }); + } + + function onWebviewPopGesture (webview) { + let popStartStatusBarStyle; + webview.addEventListener('popGesture', e => { + if (e.type === 'start') { + // 设置下一个页面的 statusBarStyle + const pages = getCurrentPages(); + const page = pages[pages.length - 2]; + popStartStatusBarStyle = lastStatusBarStyle; + const statusBarStyle = page && page.$page.meta.statusBarStyle; + statusBarStyle && setStatusBarStyle(statusBarStyle); + } else if (e.type === 'end' && !e.result) { + // 拖拽未完成,设置为当前状态栏前景色 + setStatusBarStyle(popStartStatusBarStyle); + } else if (e.type === 'end' && e.result) { + const pages = getCurrentPages(); + const len = pages.length; + const page = pages[pages.length - 1]; + page && page.$remove(); + setStatusBarStyle(); + // 仅当存在一个页面,且是直达页面时,才 reLaunch 首页 + if (page && len === 1 && isDirectPage(page)) { + reLaunchEntryPage(); } else { - invoke$1(callbackId, { - errMsg: 'getSavedFileList:ok', - fileList + UniServiceJSBridge.emit('onAppRoute', { + type: 'navigateBack' }); } - }, errorCallback); - }, errorCallback); - } - - const getFileInfo$1 = warpPlusMethod('io', 'getFileInfo'); - - function getSavedFileInfo$1 ({ - filePath - } = {}, callbackId) { - const errorCallback = warpPlusErrorCallback(callbackId, 'getSavedFileInfo'); - - plus.io.resolveLocalFileSystemURL(filePath, entry => { - entry.getMetadata(meta => { - invoke$1(callbackId, { - createTime: meta.modificationTime.getTime(), - size: meta.size, - errMsg: 'getSavedFileInfo:ok' - }); - }, errorCallback, false); - }, errorCallback); + } + }); } - function removeSavedFile$1 ({ - filePath - } = {}, callbackId) { - const errorCallback = warpPlusErrorCallback(callbackId, 'removeSavedFile'); + /** + * 是否处于直达页面 + * @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) + }); + } - plus.io.resolveLocalFileSystemURL(filePath, entry => { - entry.remove(() => { - invoke$1(callbackId, { - errMsg: 'removeSavedFile:ok' - }); - }, errorCallback); - }, errorCallback); - } - - function openDocument$1 ({ - filePath, - fileType - } = {}, callbackId) { - const successCallback = warpPlusSuccessCallback(callbackId, 'saveFile'); - const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile'); + function hasLeadingSlash (str) { + return str.indexOf('/') === 0 + } - plus.runtime.openDocument(getRealPath$1(filePath), undefined, successCallback, errorCallback); + function addLeadingSlash (str) { + return hasLeadingSlash(str) ? str : '/' + str } - const CHOOSE_LOCATION_PATH = '_www/__uniappchooselocation.html'; + let preloadWebview; - const MESSAGE_TYPE$1 = 'chooseLocation'; + let id$1 = 2; - function chooseLocation$1 (params, callbackId) { - const statusBarStyle = plus.navigator.getStatusBarStyle(); - const webview = plus.webview.create( - CHOOSE_LOCATION_PATH, - MAP_ID, { - titleNView: { - autoBackButton: true, - backgroundColor: '#000000', - titleColor: '#ffffff', - titleText: '选择位置', - titleSize: '17px', - buttons: [{ - float: 'right', - text: '完成', - fontSize: '17px', - width: '60px', - onclick: function () { - webview.evalJS('__chooseLocationConfirm__()'); - } - }] - }, - popGesture: 'close', - scrollIndicator: 'none' - }, { - __uniapp_type: 'map', - __uniapp_statusbar_style: statusBarStyle, - 'uni-app': 'none' - } - ); - if (statusBarStyle === 'dark') { - plus.navigator.setStatusBarStyle('light'); - webview.addEventListener('popGesture', ({ - type, - result - }) => { - if (type === 'start') { - plus.navigator.setStatusBarStyle('dark'); - } else if (type === 'end' && !result) { - plus.navigator.setStatusBarStyle('light'); - } - }); + const WEBVIEW_LISTENERS = { + pullToRefresh: 'onPullDownRefresh', + titleNViewSearchInputChanged: 'onNavigationBarSearchInputChanged', + titleNViewSearchInputConfirmed: 'onNavigationBarSearchInputConfirmed', + titleNViewSearchInputClicked: 'onNavigationBarSearchInputClicked', + titleNViewSearchInputFocusChanged: 'onNavigationBarSearchInputFocusChanged' + }; + + function setPreloadWebview (webview) { + preloadWebview = webview; + } + + function noop$1 (str) { + return str + } + + function getUniPageUrl (path, query) { + const queryString = query ? stringifyQuery(query, noop$1) : ''; + return { + path: path.substr(1), + query: queryString ? queryString.substr(1) : queryString } - let index = 0; - const onShow = function () { - index++; - if (index === 2) { - webview.evalJS(`__chooseLocation__(${JSON.stringify(params)})`); + } + + function getDebugRefresh (path, query, routeOptions) { + const queryString = query ? stringifyQuery(query, noop$1) : ''; + return { + isTab: routeOptions.meta.isTabBar, + arguments: JSON.stringify({ + path: path.substr(1), + query: queryString ? queryString.substr(1) : queryString + }) + } + } + + function createWebview (path, routeOptions, query, extras = {}) { + if (routeOptions.meta.isNVue) { + const getWebviewStyle = () => parseWebviewStyle( + webviewId, + path, + routeOptions + ); + const webviewId = id$1++; + const webviewStyle = getWebviewStyle(); + webviewStyle.uniPageUrl = getUniPageUrl(path, query); + if (process.env.NODE_ENV !== 'production') { + console.log('[uni-app] createWebview', webviewId, path, webviewStyle); } - }; - webview.addEventListener('loaded', onShow); - webview.show('slide-in-bottom', ANI_DURATION, onShow); + // android 需要使用 + webviewStyle.isTab = !!routeOptions.meta.isTabBar; + const webview = plus.webview.create('', String(webviewId), webviewStyle, Object.assign({ + nvue: true + }, extras)); - let result; + useWebviewThemeChange(webview, getWebviewStyle); - webview.addEventListener('close', () => { - if (result) { - invoke$1(callbackId, { - name: result.poiname, - address: result.poiaddress, - latitude: result.latlng.lat, - longitude: result.latlng.lng, - errMsg: 'chooseLocation:ok' - }); + return webview + } + if (id$1 === 2) { // 如果首页非 nvue,则直接返回 Launch Webview + return plus.webview.getLaunchWebview() + } + const webview = preloadWebview; + return webview + } + + function initWebview (webview, routeOptions, path, query) { + // 首页或非 nvue 页面 + if (webview.id === '1' || !routeOptions.meta.isNVue) { + const getWebviewStyle = () => parseWebviewStyle( + parseInt(webview.id), + '', + routeOptions + ); + const webviewStyle = getWebviewStyle(); + + webviewStyle.uniPageUrl = getUniPageUrl(path, query); + + if (!routeOptions.meta.isNVue) { + webviewStyle.debugRefresh = getDebugRefresh(path, query, routeOptions); } else { - consumePlusMessage(MESSAGE_TYPE$1); - invoke$1(callbackId, { - errMsg: 'chooseLocation:fail cancel' - }); + // android 需要使用 + webviewStyle.isTab = !!routeOptions.meta.isTabBar; + } + if (process.env.NODE_ENV !== 'production') { + console.log('[uni-app] updateWebview', webviewStyle); } + + useWebviewThemeChange(webview, getWebviewStyle); + + webview.setStyle(webviewStyle); + } + + const { + on, + emit + } = UniServiceJSBridge; + + initSubNVues(routeOptions, webview); + + Object.keys(WEBVIEW_LISTENERS).forEach(name => { + webview.addEventListener(name, (e) => { + emit(WEBVIEW_LISTENERS[name], e, parseInt(webview.id)); + }); }); - registerPlusMessage(MESSAGE_TYPE$1, function (res) { - if (res && 'latlng' in res) { - result = res; + onWebviewClose(webview); + onWebviewResize(webview); + + if (plus.os.name === 'iOS') { + !webview.nvue && onWebviewRecovery(webview, routeOptions); + onWebviewPopGesture(webview); + } + + on(webview.id + '.startPullDownRefresh', () => { + webview.beginPullToRefresh(); + }); + + on(webview.id + '.stopPullDownRefresh', () => { + webview.endPullToRefresh(); + }); + + return webview + } + + function createPreloadWebview () { + if (!preloadWebview || preloadWebview.__uniapp_route) { // 不存在,或已被使用 + preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(id$1++), { contentAdjust: false }); + if (process.env.NODE_ENV !== 'production') { + console.log(`[uni-app] preloadWebview[${preloadWebview.id}]`); } - }, false); + } + return preloadWebview + } + + const webviewReadyCallbacks = {}; + + function registerWebviewReady (pageId, callback) { + (webviewReadyCallbacks[pageId] || (webviewReadyCallbacks[pageId] = [])).push(callback); + } + + function consumeWebviewReady (pageId) { + const callbacks = webviewReadyCallbacks[pageId]; + Array.isArray(callbacks) && callbacks.forEach(callback => callback()); + delete webviewReadyCallbacks[pageId]; } - var webview$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - chooseLocation: chooseLocation$1 - }); - - function getStatusBarStyle$2 () { - let style = plus.navigator.getStatusBarStyle(); - if (style === 'UIStatusBarStyleBlackTranslucent' || style === 'UIStatusBarStyleBlackOpaque' || style === 'null') { - style = 'light'; - } else if (style === 'UIStatusBarStyleDefault') { - style = 'dark'; - } - return style - } - - function chooseLocation$2 (options, callbackId) { - const statusBarStyle = getStatusBarStyle$2(); - const isDark = statusBarStyle !== 'light'; - - let result; - const page = showPage({ - url: '__uniappchooselocation', - data: Object.assign({}, options, { - locale: getLocale() - }), - style: { - animationType: options.animationType || 'slide-in-bottom', - titleNView: false, - popGesture: 'close', - scrollIndicator: 'none' - }, - onMessage ({ - event, - detail - }) { - if (event === 'selected') { - result = detail; - result.errMsg = 'chooseLocation:ok'; - } - }, - onClose () { - if (isDark) { - plus.navigator.setStatusBarStyle('dark'); - } - - invoke$1(callbackId, result || { - errMsg: 'chooseLocation:fail cancel' - }); - } - }); - - if (isDark) { - plus.navigator.setStatusBarStyle('light'); - page.webview.addEventListener('popGesture', ({ - type, - result - }) => { - if (type === 'start') { - plus.navigator.setStatusBarStyle('dark'); - } else if (type === 'end' && !result) { - plus.navigator.setStatusBarStyle('light'); - } - }); - } - } - - var weex$2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - chooseLocation: chooseLocation$2 - }); - - function chooseLocation$3 (...array) { - const api = __uniConfig.nvueCompiler !== 'weex' ? weex$2 : webview$1; - return api.chooseLocation(...array) - } - - function getLocationSuccess (type, position, callbackId) { - const coords = position.coords; - if (type !== position.coordsType) { - if (process.env.NODE_ENV !== 'production') { - console.log( - `UNIAPP[location]:before[${position.coordsType}][lng:${ - coords.longitude - },lat:${coords.latitude}]` - ); + let todoNavigator = false; + + function setTodoNavigator (path, callback, msg) { + todoNavigator = { + path: path, + nvue: __uniRoutes.find(route => route.path === path).meta.isNVue, + navigate: callback + }; + if (process.env.NODE_ENV !== 'production') { + console.log(`todoNavigator:${todoNavigator.path} ${msg}`); + } + } + + function navigate (path, callback, isAppLaunch) { + { + if (isAppLaunch && __uniConfig.splashscreen && __uniConfig.splashscreen.autoclose && (!__uniConfig.splashscreen.alwaysShowBeforeRender)) { + plus.navigator.closeSplashscreen(); } - let coordArray; - if (type === 'wgs84') { - coordArray = gcj02towgs84(coords.longitude, coords.latitude); - } else if (type === 'gcj02') { - coordArray = wgs84togcj02(coords.longitude, coords.latitude); + if (!isAppLaunch && todoNavigator) { + return console.error(`Waiting to navigate to: ${todoNavigator.path}, do not operate continuously: ${path}.`) } - if (coordArray) { - coords.longitude = coordArray[0]; - coords.latitude = coordArray[1]; - if (process.env.NODE_ENV !== 'production') { - console.log( - `UNIAPP[location]:after[${type}][lng:${coords.longitude},lat:${ - coords.latitude - }]` - ); + if (__uniConfig.renderer === 'native') { // 纯原生无需wait逻辑 + // 如果是首页还未初始化,需要等一等,其他无需等待 + if (getCurrentPages().length === 0) { + return setTodoNavigator(path, callback, 'waitForReady') } + return callback() + } + // 未创建 preloadWebview 或 preloadWebview 已被使用 + const waitPreloadWebview = !preloadWebview || (preloadWebview && preloadWebview.__uniapp_route); + // 已创建未 loaded + const waitPreloadWebviewReady = preloadWebview && !preloadWebview.loaded; + + if (waitPreloadWebview || waitPreloadWebviewReady) { + setTodoNavigator(path, callback, waitPreloadWebview ? 'waitForCreate' : 'waitForReady'); + } else { + callback(); + } + if (waitPreloadWebviewReady) { + registerWebviewReady(preloadWebview.id, todoNavigate); } } + } - invoke$1(callbackId, { - type, - altitude: coords.altitude || 0, - latitude: coords.latitude, - longitude: coords.longitude, - speed: coords.speed, - accuracy: coords.accuracy, - address: position.address, - errMsg: 'getLocation:ok' - }); + function todoNavigate () { + if (!todoNavigator) { + return + } + const { + navigate + } = todoNavigator; + if (process.env.NODE_ENV !== 'production') { + console.log(`todoNavigate:${todoNavigator.path}`); + } + todoNavigator = false; + return navigate() } - function getLocation$1 ({ - type = 'wgs84', - geocode = false, - altitude = false, - isHighAccuracy = false, - highAccuracyExpireTime - } = {}, callbackId) { - const errorCallback = warpPlusErrorCallback(callbackId, 'getLocation'); - plus.geolocation.getCurrentPosition( - position => { - getLocationSuccess(type, position, callbackId); - }, - e => { - // 坐标地址解析失败 - if (e.code === 1501) { - getLocationSuccess(type, e, callbackId); + function navigateFinish () { + { + if (__uniConfig.renderer === 'native') { + if (!todoNavigator) { return } - errorCallback(e); - }, { - geocode: geocode, - enableHighAccuracy: isHighAccuracy || altitude, - timeout: highAccuracyExpireTime, - coordsType: type + if (todoNavigator.nvue) { + return todoNavigate() + } + return } - ); + // 创建预加载 + const preloadWebview = createPreloadWebview(); + if (process.env.NODE_ENV !== 'production') { + console.log(`navigateFinish.preloadWebview:${preloadWebview.id}`); + } + if (!todoNavigator) { + return + } + if (todoNavigator.nvue) { + return todoNavigate() + } + preloadWebview.loaded + ? todoNavigator.navigate() + : registerWebviewReady(preloadWebview.id, todoNavigate); + } } - const OPEN_LOCATION_PATH = '_www/__uniappopenlocation.html'; + const pageFactory = Object.create(null); - function openLocation$1 (params) { - const statusBarStyle = plus.navigator.getStatusBarStyle(); - const webview = plus.webview.create( - OPEN_LOCATION_PATH, - MAP_ID, { - titleNView: { - autoBackButton: true, - titleColor: '#ffffff', - titleText: '', - titleSize: '17px', - type: 'transparent' - }, - popGesture: 'close', - scrollIndicator: 'none' - }, { - __uniapp_type: 'map', - __uniapp_statusbar_style: statusBarStyle, - 'uni-app': 'none' - } - ); - if (statusBarStyle === 'light') { - plus.navigator.setStatusBarStyle('dark'); - webview.addEventListener('popGesture', ({ - type, - result - }) => { - if (type === 'start') { - plus.navigator.setStatusBarStyle('light'); - } else if (type === 'end' && !result) { - plus.navigator.setStatusBarStyle('dark'); - } - }); - } - webview.show(ANI_SHOW, ANI_DURATION, () => { - webview.evalJS(`__openLocation__(${JSON.stringify(params)})`); - }); + function definePage (name, createPageVueComponent) { + pageFactory[name] = createPageVueComponent; + } - return { - errMsg: 'openLocation:ok' + const getPageVueComponent = cached(function (pagePath) { + return pageFactory[pagePath]() + }); + + function createPage (pagePath, pageId, pageQuery, pageInstance) { + if (!pageFactory[pagePath]) { + console.error(`${pagePath} not found`); } - } - - var webview$2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - openLocation: openLocation$1 - }); - - function openLocation$2 (data, callbackId) { - showPage({ - url: '__uniappopenlocation', - data: Object.assign({}, data, { - locale: getLocale() - }), - style: { - titleNView: { - type: 'transparent' - }, - popGesture: 'close', - backButtonAutoControl: 'close' - }, - onClose () { - invoke$1(callbackId, { - errMsg: 'openLocation:fail cancel' - }); - } + const startTime = Date.now(); + const pageVm = new (getPageVueComponent(pagePath))({ + mpType: 'page', + pageId, + pagePath, + pageQuery, + pageInstance }); - return { - errMsg: 'openLocation:ok' + if (process.env.NODE_ENV !== 'production') { + console.log(`new ${pagePath}[${pageId}]:time(${Date.now() - startTime})`); } + return pageVm } - var weex$3 = /*#__PURE__*/Object.freeze({ - __proto__: null, - openLocation: openLocation$2 - }); - - function openLocation$3 (...array) { - const api = __uniConfig.nvueCompiler !== 'weex' ? weex$3 : webview$2; - return api.openLocation(...array) - } - - let successCallbackIds = []; - let errorCallbackIds = []; - let started = false; - let watchId = 0; - - function startLocationUpdate ({ type = 'gcj02' }, callbackId) { - watchId = watchId || plus.geolocation.watchPosition( - res => { - started = true; - successCallbackIds.forEach(callbackId => { - invoke$1(callbackId, res.coords); - }); - }, - error => { - if (!started) { - invoke$1(callbackId, { errMsg: `startLocationUpdate:fail ${error.message}` }); - started = true; - } - errorCallbackIds.forEach(callbackId => { - invoke$1(callbackId, { - errMsg: `onLocationChange:fail ${error.message}` - }); - }); - }, - { - coordsType: type - } - ); - setTimeout(() => { - invoke$1(callbackId, { - errMsg: 'startLocationUpdate:ok' - }); - }, 100); - } - - function stopLocationUpdate () { - if (watchId !== 0) { - plus.geolocation.clearWatch(watchId); - started = false; - watchId = 0; - } - return {} - } - - function onLocationChange (callbackId) { - successCallbackIds.push(callbackId); - } - - function offLocationChange (callbackId) { - if (callbackId) { - const index = successCallbackIds.indexOf(callbackId); - if (index >= 0) { - successCallbackIds.splice(index, 1); - } - } else { - successCallbackIds = []; - } - } - - function onLocationChangeError (callbackId) { - errorCallbackIds.push(callbackId); - } - - function offLocationChangeError (callbackId) { - if (callbackId) { - const index = errorCallbackIds.indexOf(callbackId); - if (index >= 0) { - errorCallbackIds.splice(index, 1); - } - } else { - errorCallbackIds = []; - } - } - - const RECORD_TIME = 60 * 60 * 1000; - - let recorder; - let recordTimeout; + const loadedSubPackages = []; - function startRecord (args, callbackId) { - recorder && recorder.stop(); - recorder = plus.audio.getRecorder(); - recorder.record({ - filename: '_doc/audio/', - format: 'aac' - }, (res) => { - invoke$1(callbackId, { - errMsg: 'startRecord:ok', - tempFilePath: res - }); - }, (res) => { - invoke$1(callbackId, { - errMsg: 'startRecord:fail' - }); - }); - recordTimeout = setTimeout(() => { - recorder.stop(); - recorder = false; - }, RECORD_TIME); + /** + * 指定路由 ready 后,检查是否触发分包预加载 + * @param {Object} route + */ + function preloadSubPackages (route) { + if (!__uniConfig.preloadRule) { + return + } + const options = __uniConfig.preloadRule[route]; + if (!options || !Array.isArray(options.packages)) { + return + } + const packages = options.packages.filter(root => loadedSubPackages.indexOf(root) === -1); + if (!packages.length) { + return + } + loadSubPackages(options.packages); + // 暂不需要网络下载 + // const network = options.network || 'wifi' + // if (network === 'wifi') { + // uni.getNetworkType({ + // success (res) { + // if (process.env.NODE_ENV !== 'production') { + // console.log('UNIAPP[preloadRule]:' + res.networkType + ':' + JSON.stringify(options)) + // } + // if (res.networkType === 'wifi') { + // loadSubPackages(options.packages) + // } + // } + // }) + // } else { + // if (process.env.NODE_ENV !== 'production') { + // console.log('UNIAPP[preloadRule]:' + JSON.stringify(options)) + // } + // loadSubPackages(options.packages) + // } } - function stopRecord () { - if (recorder) { - recordTimeout && clearTimeout(recordTimeout); - recorder.stop(); - return { - errMsg: 'stopRecord:ok' + function loadPage (route, callback) { + let isInSubPackage = false; + const subPackages = __uniConfig.subPackages; + if (Array.isArray(subPackages)) { + const subPackage = subPackages.find(subPackage => route.indexOf(subPackage.root) === 0); + if (subPackage) { + isInSubPackage = true; + loadSubPackage$1(subPackage.root, callback); } } - return { - errMsg: 'stopRecord:fail' + if (!isInSubPackage) { + callback(); } } - let player; - let playerFilePath; - let playerStatus; - - function playVoice ({ - filePath - } = {}, callbackId) { - if (player && playerFilePath === filePath && playerStatus === 'pause') { // 如果是当前音频被暂停,则继续播放 - playerStatus = 'play'; - player.play((res) => { - player = false; - playerFilePath = false; - playerStatus = false; - invoke$1(callbackId, { - errMsg: 'playVoice:ok' - }); - }); - return { - errMsg: 'playVoice:ok' - } - } - if (player) { // 如果存在音频播放,则停止 - player.stop(); + function loadSubPackage$1 (root, callback) { + if (loadedSubPackages.indexOf(root) !== -1) { + return callback() } - playerFilePath = filePath; - playerStatus = 'play'; - player = plus.audio.createPlayer(getRealPath$1(filePath)); - // 播放操作成功回调 - player.play((res) => { - player = false; - playerFilePath = false; - playerStatus = false; - invoke$1(callbackId, { - errMsg: 'playVoice:ok' - }); + loadSubPackages([root], () => { + callback(); }); } - function pauseVoice () { - if (player && playerStatus === 'play') { - player.pause(); - playerStatus = 'pause'; - } - return { - errMsg: 'pauseVoice:ok' - } + const SUB_FILENAME = 'app-sub-service.js'; + + function evaluateScriptFiles (files, callback) { + __uniConfig.onServiceReady(() => { + weex.requireModule('plus').evalJSFiles(files, callback); + }); } - function stopVoice () { - if (player) { - player.stop(); - player = false; - playerFilePath = false; - playerStatus = false; - } - return { - errMsg: 'stopVoice:ok' + function loadSubPackages (packages, callback) { + if (process.env.NODE_ENV !== 'production') { + console.log('UNIAPP[loadSubPackages]:' + JSON.stringify(packages)); } + const startTime = Date.now(); + evaluateScriptFiles(packages.map(root => { + loadedSubPackages.push(root); + return root + '/' + SUB_FILENAME + }), res => { + if (process.env.NODE_ENV !== 'production') { + console.log('UNIAPP[loadSubPackages]:耗时(' + (Date.now() - startTime) + ')'); + } + callback && callback(true); + }); } - /** - * 获取文件信息 - * @param {string} filePath 文件路径 - * @returns {Promise} 文件信息Promise - */ - function getFileInfo$2 (filePath) { - return new Promise((resolve, reject) => { - plus.io.resolveLocalFileSystemURL(filePath, function (entry) { - entry.getMetadata(resolve, reject, false); - }, reject); - }) + const extend = Object.assign; + + function createLaunchOptions () { + return { + path: '', + query: {}, + scene: 1001, + referrerInfo: { + appId: '', + extraData: {} + } + } } - function chooseImage$1 ({ - count, - sizeType, - sourceType, - crop - } = {}, callbackId) { - const errorCallback = warpPlusErrorCallback(callbackId, 'chooseImage', 'cancel'); + const enterOptions = createLaunchOptions(); + const launchOptions = createLaunchOptions(); - function successCallback (paths) { - const tempFiles = []; - const tempFilePaths = []; - Promise.all(paths.map((path) => getFileInfo$2(path))) - .then((filesInfo) => { - filesInfo.forEach((file, index) => { - const path = paths[index]; - tempFilePaths.push(path); - tempFiles.push({ path, size: file.size }); - }); + function getLaunchOptions () { + return launchOptions + } - invoke$1(callbackId, { - errMsg: 'chooseImage:ok', - tempFilePaths, - tempFiles - }); - }) - .catch(errorCallback); - } + function getEnterOptions () { + return enterOptions + } - function openCamera () { - const camera = plus.camera.getCamera(); - camera.captureImage(path => successCallback([path]), - errorCallback, { - filename: TEMP_PATH + '/camera/', - resolution: 'high', - crop, - sizeType - }); - } + function initEnterOptions ({ + path, + query, + referrerInfo + }) { + extend(enterOptions, { + path, + query: query ? parseQuery(query) : {}, + referrerInfo: referrerInfo || {} + }); + } - function openAlbum () { - plus.gallery.pick(({ files }) => successCallback(files), errorCallback, { - maximum: count, - multiple: true, - system: false, - filename: TEMP_PATH + '/gallery/', - permissionAlert: true, - crop, - sizeType - }); - } + function initLaunchOptions ({ + path, + query, + referrerInfo + }) { + extend(launchOptions, { + path, + query: query ? parseQuery(query) : {}, + referrerInfo: referrerInfo || {}, + channel: plus.runtime.channel, + launcher: plus.runtime.launcher + }); + extend(enterOptions, launchOptions); + return launchOptions + } - if (sourceType.length === 1) { - if (sourceType.includes('album')) { - openAlbum(); - return - } else if (sourceType.includes('camera')) { - openCamera(); - return + 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; } - } - plus.nativeUI.actionSheet({ - cancel: t('uni.chooseImage.cancel'), - buttons: [{ - title: t('uni.chooseImage.sourceType.camera') - }, { - title: t('uni.chooseImage.sourceType.album') - }] - }, (e) => { - switch (e.index) { - case 1: - openCamera(); - break - case 2: - openAlbum(); - break - default: - errorCallback(); - break + return { + path: path || '', + query: query ? '?' + query : '', + referrerInfo, + userAction } - }); + } } - function chooseVideo$1 ({ - sourceType, - compressed, - maxDuration, - camera - } = {}, callbackId) { - const errorCallback = warpPlusErrorCallback(callbackId, 'chooseVideo', 'cancel'); + let isInitEntryPage = false; - function successCallback (tempFilePath = '') { - plus.io.getVideoInfo({ - filePath: tempFilePath, - success (videoInfo) { - const result = { - errMsg: 'chooseVideo:ok', - tempFilePath: tempFilePath - }; - result.size = videoInfo.size; - result.duration = videoInfo.duration; - result.width = videoInfo.width; - result.height = videoInfo.height; - invoke$1(callbackId, result); - }, - fail: errorCallback - }); + function initEntryPage () { + if (isInitEntryPage) { + return } + isInitEntryPage = true; - function openAlbum () { - plus.gallery.pick(({ files }) => successCallback(files[0]), errorCallback, { - filter: 'video', - system: false, - // 不启用 multiple 时 system 无效 - multiple: true, - maximum: 1, - filename: TEMP_PATH + '/gallery/', - permissionAlert: true, - videoCompress: compressed - }); - } + let entryPagePath; + let entryPageQuery; - function openCamera () { - const plusCamera = plus.camera.getCamera(); - plusCamera.startVideoCapture(successCallback, errorCallback, { - index: camera === 'front' ? 2 : 1, - videoMaximumDuration: maxDuration, - filename: TEMP_PATH + '/camera/', - videoCompress: compressed - }); - } + const weexPlus = weex.requireModule('plus'); - if (sourceType.length === 1) { - if (sourceType.includes('album')) { - openAlbum(); - return - } else if (sourceType.includes('camera')) { - openCamera(); + if (weexPlus.getRedirectInfo) { + const { + path, + query, + referrerInfo + } = parseRedirectInfo(); + if (path) { + entryPagePath = path; + entryPageQuery = query; + } + __uniConfig.referrerInfo = referrerInfo; + } else { + const argsJsonStr = plus.runtime.arguments; + if (!argsJsonStr) { return } + try { + const args = JSON.parse(argsJsonStr); + entryPagePath = args.path || args.pathName; + entryPageQuery = args.query ? ('?' + args.query) : ''; + } catch (e) {} } - plus.nativeUI.actionSheet({ - cancel: t('uni.chooseVideo.cancel'), - buttons: [{ - title: t('uni.chooseVideo.sourceType.camera') - }, { - title: t('uni.chooseVideo.sourceType.album') - }] - }, e => { - switch (e.index) { - case 1: - openCamera(); - break - case 2: - openAlbum(); - break - default: - errorCallback(); - break + + if (!entryPagePath || entryPagePath === __uniConfig.entryPagePath) { + if (entryPageQuery) { + __uniConfig.entryPageQuery = entryPageQuery; } - }); - } - - function compressImage$1 (options, callbackId) { - const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; - const errorCallback = warpPlusErrorCallback(callbackId, 'compressImage'); - plus.zip.compressImage(Object.assign({}, options, { - dst - }), () => { - invoke$1(callbackId, { - errMsg: 'compressImage:ok', - tempFilePath: dst - }); - }, errorCallback); - } - - function compressVideo$1 (options, callbackId) { - const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; - const successCallback = warpPlusSuccessCallback(callbackId, 'compressVideo'); - const errorCallback = warpPlusErrorCallback(callbackId, 'compressVideo'); - plus.zip.compressVideo(Object.assign({}, options, { - filename - }), successCallback, errorCallback); - } - - const getImageInfo$1 = warpPlusMethod('io', 'getImageInfo', options => { - options.savePath = options.filename = TEMP_PATH + '/download/'; - return options - }); - - const getVideoInfo$1 = warpPlusMethod('io', 'getVideoInfo', options => { - options.filePath = options.src; - return options - }, data => { - return { - orientation: data.orientation, - type: data.type, - duration: data.duration, - size: data.size / 1024, - height: data.height, - width: data.width, - fps: data.fps || 30, - bitrate: data.bitrate + return } - }); - - function previewImagePlus ({ - current = 0, - background = '#000000', - indicator = 'number', - loop = false, - urls, - longPressActions - } = {}) { - urls = urls.map(url => getRealPath$1(url)); - const index = Number(current); - if (isNaN(index)) { - current = urls.indexOf(getRealPath$1(current)); - current = current < 0 ? 0 : current; - } else { - current = index; + const entryRoute = '/' + entryPagePath; + const routeOptions = __uniRoutes.find(route => route.path === entryRoute); + if (!routeOptions) { + console.error(`[uni-app] ${entryPagePath} not found...`); + return } - plus.nativeUI.previewImage(urls, { - current, - background, - indicator, - loop, - onLongPress: function (res) { - let itemList = []; - let itemColor = ''; - let title = ''; - const hasLongPressActions = longPressActions && longPressActions.callbackId; - if (!hasLongPressActions) { - itemList = [t('uni.previewImage.button.save')]; - itemColor = '#000000'; - title = ''; - } else { - itemList = longPressActions.itemList ? longPressActions.itemList : []; - itemColor = longPressActions.itemColor ? longPressActions.itemColor : '#000000'; - title = longPressActions.title ? longPressActions.title : ''; - } - - const options = { - buttons: itemList.map(item => ({ - title: item, - color: itemColor - })), - cancel: t('uni.previewImage.cancel') - }; - if (title) { - options.title = title; - } - plus.nativeUI.actionSheet(options, (e) => { - if (e.index > 0) { - if (hasLongPressActions) { - publish(longPressActions.callbackId, { - errMsg: 'showActionSheet:ok', - tapIndex: e.index - 1, - index: res.index - }); - return - } - plus.gallery.save(res.url, function (GallerySaveEvent) { - plus.nativeUI.toast(t('uni.previewImage.save.success')); - }, function () { - plus.nativeUI.toast(t('uni.previewImage.save.fail')); - }); - } else if (hasLongPressActions) { - publish(longPressActions.callbackId, { - errMsg: 'showActionSheet:fail cancel' - }); - } - }); - } - }); - return { - errMsg: 'previewImage:ok' + if (!routeOptions.meta.isTabBar) { + __uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath; } - } - function closePreviewImagePlus () { - try { - plus.nativeUI.closePreviewImage(); - return { - errMsg: 'closePreviewImagePlus:ok' - } - } catch (error) { - return { - errMsg: 'closePreviewImagePlus:fail' - } + __uniConfig.entryPagePath = entryPagePath; + __uniConfig.entryPageQuery = entryPageQuery; + + if (process.env.NODE_ENV !== 'production') { + console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`); } } - let recorder$1; - let recordTimeout$1; + const pages = []; - const publishRecorderStateChange = (state, res = {}) => { - publish('onRecorderStateChange', Object.assign({ - state - }, res)); - }; + function getCurrentPages$1 (returnAll) { + return returnAll ? pages.slice(0) : pages.filter(page => { + return !page.$page.meta.isTabBar || page.$page.meta.visible + }) + } - const Recorder = { - start ({ - duration = 60000, - sampleRate, - numberOfChannels, - encodeBitRate, - format = 'mp3', - frameSize, - audioSource = 'auto' - }, callbackId) { - if (recorder$1) { - return publishRecorderStateChange('start') - } - recorder$1 = plus.audio.getRecorder(); - recorder$1.record({ - format, - samplerate: sampleRate, - filename: TEMP_PATH + '/recorder/' - }, res => publishRecorderStateChange('stop', { - tempFilePath: res - }), err => publishRecorderStateChange('error', { - errMsg: err.message - })); - recordTimeout$1 = setTimeout(() => { - Recorder.stop(); - }, duration); - publishRecorderStateChange('start'); - }, - stop () { - if (recorder$1) { - recorder$1.stop(); - recorder$1 = false; - recordTimeout$1 && clearTimeout(recordTimeout$1); - } - }, - pause () { - if (recorder$1) { - publishRecorderStateChange('error', { - errMsg: 'Unsupported operation: pause' - }); + const preloadWebviews = {}; + + function removePreloadWebview (webview) { + const url = Object.keys(preloadWebviews).find(url => preloadWebviews[url].id === webview.id); + if (url) { + if (process.env.NODE_ENV !== 'production') { + console.log(`[uni-app] removePreloadWebview(${webview.id})`); } - }, - resume () { - if (recorder$1) { - publishRecorderStateChange('error', { - errMsg: 'Unsupported operation: resume' - }); + delete preloadWebviews[url]; + } + } + + function closePreloadWebview ({ + url + }) { + const webview = preloadWebviews[url]; + if (webview) { + if (webview.__page__) { + if (!getCurrentPages$1(true).find(page => page === webview.__page__)) { + // 未使用 + webview.close('none'); + } else { // 被使用 + webview.__preload__ = false; + } + } else { // 未使用 + webview.close('none'); } + delete preloadWebviews[url]; } - }; + return webview + } - function operateRecorder ({ - operationType, - ...args - }, callbackId) { - Recorder[operationType](args); - return { - errMsg: 'operateRecorder:ok' + function preloadWebview$1 ({ + url, + path, + query + }) { + if (!preloadWebviews[url]) { + const routeOptions = JSON.parse(JSON.stringify(__uniRoutes.find(route => route.path === path))); + preloadWebviews[url] = createWebview(path, routeOptions, query, { + __preload__: true, + __query__: JSON.stringify(query) + }); } - } - - function saveImageToPhotosAlbum$1 ({ - filePath - } = {}, callbackId) { - const successCallback = warpPlusSuccessCallback(callbackId, 'saveImageToPhotosAlbum'); - const errorCallback = warpPlusErrorCallback(callbackId, 'saveImageToPhotosAlbum'); - plus.gallery.save(getRealPath$1(filePath), successCallback, errorCallback); - } - - function saveVideoToPhotosAlbum ({ - filePath - } = {}, callbackId) { - plus.gallery.save(getRealPath$1(filePath), e => { - invoke$1(callbackId, { - errMsg: 'saveVideoToPhotosAlbum:ok' - }); - }, e => { - invoke$1(callbackId, { - errMsg: 'saveVideoToPhotosAlbum:fail' - }); - }); - } - - let downloadTaskId = 0; - const downloadTasks = {}; - - const publishStateChange = (res) => { - publish('onDownloadTaskStateChange', res); - }; + return preloadWebviews[url] + } - const createDownloadTaskById = function (downloadTaskId, { + /** + * 首页需要主动registerPage,二级页面路由跳转时registerPage + */ + function registerPage ({ url, - header, - timeout - } = {}) { - timeout = (timeout || (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000) / 1000; - const downloader = plus.downloader.createDownload(url, { - timeout, - filename: TEMP_PATH + '/download/', - // 需要与其它平台上的表现保持一致,不走重试的逻辑。 - retry: 0, - retryInterval: 0 - }, (download, statusCode) => { - if (statusCode) { - publishStateChange({ - downloadTaskId, - state: 'success', - tempFilePath: download.filename, - statusCode - }); - } else { - publishStateChange({ - downloadTaskId, - state: 'fail', - statusCode - }); - } - }); - for (const name in header) { - if (hasOwn(header, name)) { - downloader.setRequestHeader(name, header[name]); - } - } - downloader.addEventListener('statechanged', (download, status) => { - if (download.downloadedSize && download.totalSize) { - publishStateChange({ - downloadTaskId, - state: 'progressUpdate', - progress: parseInt(download.downloadedSize / download.totalSize * 100), - totalBytesWritten: download.downloadedSize, - totalBytesExpectedToWrite: download.totalSize - }); - } - }); - downloadTasks[downloadTaskId] = downloader; - downloader.start(); - return { - downloadTaskId, - errMsg: 'createDownloadTask:ok' - } - }; + path, + query, + openType, + webview, + eventChannel + }) { + // fast 模式,nvue 首页时,初始化下 entry page + webview && initEntryPage(); - function operateDownloadTask ({ - downloadTaskId, - operationType - } = {}) { - const downloadTask = downloadTasks[downloadTaskId]; - if (downloadTask && operationType === 'abort') { - delete downloadTasks[downloadTaskId]; - downloadTask.abort(); - publishStateChange({ - downloadTaskId, - state: 'fail', - errMsg: 'abort' - }); - return { - errMsg: 'operateDownloadTask:ok' + if (preloadWebviews[url]) { + webview = preloadWebviews[url]; + if (webview.__page__) { + // 该预载页面已处于显示状态,不再使用该预加载页面,直接新开 + if (getCurrentPages$1(true).find(page => page === webview.__page__)) { + if (process.env.NODE_ENV !== 'production') { + console.log(`[uni-app] preloadWebview(${path},${webview.id}) already in use`); + } + webview = null; + } else { + if (eventChannel) { + webview.__page__.eventChannel = eventChannel; + } + pages.push(webview.__page__); + if (process.env.NODE_ENV !== 'production') { + console.log(`[uni-app] reuse preloadWebview(${path},${webview.id})`); + } + return webview + } } } - return { - errMsg: 'operateDownloadTask:fail' - } - } + const routeOptions = JSON.parse(JSON.stringify(__uniRoutes.find(route => route.path === path))); - function createDownloadTask (args) { - return createDownloadTaskById(++downloadTaskId, args) - } - - let requestTaskId = 0; - const requestTasks = {}; + if ( + openType === 'reLaunch' || + ( + !__uniConfig.realEntryPagePath && + getCurrentPages$1().length === 0 // redirectTo + ) + ) { + routeOptions.meta.isQuit = true; + } else if (!routeOptions.meta.isTabBar) { + routeOptions.meta.isQuit = false; + } - const publishStateChange$1 = res => { - publish('onRequestTaskStateChange', res); - delete requestTasks[requestTaskId]; - }; + if (!webview) { + webview = createWebview(path, routeOptions, query); + } else { + webview = plus.webview.getWebviewById(webview.id); + webview.nvue = routeOptions.meta.isNVue; + } - const cookiesParse = header => { - let cookiesStr = header['Set-Cookie'] || header['set-cookie']; - let cookiesArr = []; - if (!cookiesStr) { - return [] + if (routeOptions.meta.isTabBar) { + routeOptions.meta.visible = true; } - if (cookiesStr[0] === '[' && cookiesStr[cookiesStr.length - 1] === ']') { - cookiesStr = cookiesStr.slice(1, -1); + + if (routeOptions.meta.isTabBar) { + tabBar$1.append(webview); } - const handleCookiesArr = cookiesStr.split(';'); - for (let i = 0; i < handleCookiesArr.length; i++) { - if (handleCookiesArr[i].indexOf('Expires=') !== -1 || handleCookiesArr[i].indexOf('expires=') !== -1) { - cookiesArr.push(handleCookiesArr[i].replace(',', '')); - } else { - cookiesArr.push(handleCookiesArr[i]); - } + + if (process.env.NODE_ENV !== 'production') { + console.log(`[uni-app] registerPage(${path},${webview.id})`); } - cookiesArr = cookiesArr.join(';').split(','); - return cookiesArr - }; + const isLaunchNVuePage = webview.id === '1' && webview.nvue; - function createRequestTaskById (requestTaskId, { - url, - data, - header, - method = 'GET', - responseType, - sslVerify = true, - firstIpv4 = false, - tls, - timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000 - } = {}) { - const stream = requireNativePlugin('stream'); - const headers = {}; + initWebview(webview, routeOptions, path, query); - let abortTimeout; - let aborted; - let hasContentType = false; - for (const name in header) { - if (!hasContentType && name.toLowerCase() === 'content-type') { - hasContentType = true; - headers['Content-Type'] = header[name]; - // TODO 需要重构 - if (method !== 'GET' && header[name].indexOf('application/x-www-form-urlencoded') === 0 && typeof data !== - 'string' && !(data instanceof ArrayBuffer)) { - const bodyArray = []; - for (const key in data) { - if (hasOwn(data, key)) { - bodyArray.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); - } + const route = path.slice(1); + + webview.__uniapp_route = route; + + const pageInstance = { + route, + options: Object.assign({}, query || {}), + $getAppWebview () { + // 重要,不能直接返回 webview 对象,因为 plus 可能会被二次替换,返回的 webview 对象内部的 plus 不正确 + // 导致 webview.getStyle 等逻辑出错(旧的 webview 内部 plus 被释放) + return plus.webview.getWebviewById(webview.id) + }, + eventChannel, + $page: { + id: parseInt(webview.id), + meta: routeOptions.meta, + path, + route, + fullPath: url, + openType + }, + $remove () { + const index = pages.findIndex(page => page === this); + if (index !== -1) { + if (!webview.nvue) { + this.$vm.$destroy(); + } + pages.splice(index, 1); + if (process.env.NODE_ENV !== 'production') { + console.log('[uni-app] removePage(' + path + ')[' + webview.id + ']'); } - data = bodyArray.join('&'); } - } else { - headers[name] = header[name]; + }, + // 兼容小程序框架 + selectComponent (selector) { + return this.$vm.selectComponent(selector) + }, + selectAllComponents (selector) { + return this.$vm.selectAllComponents(selector) } - } + }; - if (!hasContentType && method === 'POST') { - headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - } + pages.push(pageInstance); - if (timeout) { - abortTimeout = setTimeout(() => { - aborted = true; - publishStateChange$1({ - requestTaskId, - state: 'fail', - statusCode: 0, - errMsg: 'timeout' - }); - }, (timeout + 200)); // TODO +200 发消息到原生层有时间开销,以后考虑由原生层回调超时 + if (webview.__preload__) { + webview.__page__ = pageInstance; } - const options = { - method, - url: url.trim(), - // weex 官方文档有误,headers 类型实际 object,用 string 类型会无响应 - headers, - type: responseType === 'arraybuffer' ? 'base64' : 'text', - // weex 官方文档未说明实际支持 timeout,单位:ms - timeout: timeout || 6e5, - // 配置和weex模块内相反 - sslVerify: !sslVerify, - firstIpv4: firstIpv4, - tls - }; - let withArrayBuffer; - if (method !== 'GET') { - if (toString.call(data) === '[object ArrayBuffer]') { - withArrayBuffer = true; - } else { - options.body = typeof data === 'string' ? data : JSON.stringify(data); + + // 首页是 nvue 时,在 registerPage 时,执行路由堆栈 + if (isLaunchNVuePage) { + if ( + __uniConfig.splashscreen && + __uniConfig.splashscreen.autoclose && + !__uniConfig.splashscreen.alwaysShowBeforeRender + ) { + plus.navigator.closeSplashscreen(); } + __uniConfig.onReady(function () { + navigateFinish(); + }); } - const callback = ({ - ok, - status, - data, - headers, - errorMsg - }) => { - if (aborted) { - return - } - if (abortTimeout) { - clearTimeout(abortTimeout); - } - const statusCode = status; - if (statusCode > 0) { - publishStateChange$1({ - requestTaskId, - state: 'success', - data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer$2(data) : data, - statusCode, - header: headers, - cookies: cookiesParse(headers) - }); - } else { - let errMsg = 'abort statusCode:' + statusCode; - if (errorMsg) { - errMsg = errMsg + ' ' + errorMsg; - } - publishStateChange$1({ - requestTaskId, - state: 'fail', - statusCode, - errMsg - }); - } - }; - try { - if (withArrayBuffer) { - stream.fetchWithArrayBuffer({ - '@type': 'binary', - base64: arrayBufferToBase64$2(data) - }, options, callback); - } else { - stream.fetch(options, callback); - } - requestTasks[requestTaskId] = { - abort () { - aborted = true; - if (abortTimeout) { - clearTimeout(abortTimeout); - } - publishStateChange$1({ - requestTaskId, - state: 'fail', - statusCode: 0, - errMsg: 'abort' + + { + if (!webview.nvue) { + const pageId = webview.id; + try { + loadPage(route, () => { + createPage(route, pageId, query, pageInstance).$mount(); }); + } catch (e) { + console.error(e); } - }; - } catch (e) { - return { - requestTaskId, - errMsg: 'createRequestTask:fail' - } - } - return { - requestTaskId, - errMsg: 'createRequestTask:ok' - } - } - - function createRequestTask (args) { - return createRequestTaskById(++requestTaskId, args) - } - - function operateRequestTask ({ - requestTaskId, - operationType - } = {}) { - const requestTask = requestTasks[requestTaskId]; - if (requestTask && operationType === 'abort') { - requestTask.abort(); - return { - errMsg: 'operateRequestTask:ok' } } - return { - errMsg: 'operateRequestTask:fail' - } - } - function configMTLS$1 ({ certificates }, callbackId) { - const stream = requireNativePlugin('stream'); - stream.configMTLS(certificates, ({ type, code, message }) => { - switch (type) { - case 'success': - invoke$1(callbackId, { - errMsg: 'configMTLS:ok', - code - }); - break - case 'fail': - invoke$1(callbackId, { - errMsg: 'configMTLS:fail ' + message, - code - }); - break - } - }); + return webview } - const socketTasks = {}; + const ON_THEME_CHANGE$1 = 'api.onThemeChange'; + + function onThemeChange (callback = () => { }) { + UniServiceJSBridge.on(ON_THEME_CHANGE$1, callback); + } + + function offThemeChange (callback = () => { }) { + UniServiceJSBridge.off(ON_THEME_CHANGE$1, callback); + } + + function getNavigatorStyle () { + return plus.navigator.getUIStyle() === 'dark' ? 'light' : 'dark' + } + + function changePagesNavigatorStyle () { + if (__uniConfig.darkmode) { + const theme = getNavigatorStyle(); + + setStatusBarStyle(theme); + + const pages = getCurrentPages$1(true); + pages.forEach((page) => { + page.$page.meta.statusBarStyle = theme; + }); + } + } + + function parseTheme (pageStyle) { + if (__uniConfig.darkmode) { + let parsedStyle = {}; + let theme = plus.navigator.getUIStyle(); + + const systemInfo = weexGetSystemInfoSync(); + // 小程序 SDK + if (systemInfo && systemInfo.hostTheme) { + theme = systemInfo.hostTheme; + } + + parsedStyle = normallizeStyles(pageStyle, __uniConfig.themeConfig, theme); + return parsedStyle + } + return pageStyle + } + + function useTabBarThemeChange (tabBar, options) { + if (__uniConfig.darkmode) { + const fn = () => { + const { + list = [], color, selectedColor, + backgroundColor, borderStyle + } = parseTheme(options); + const tabbarStyle = { + color, + selectedColor, + backgroundColor, + borderStyle + }; + + tabBar && tabBar.setTabBarStyle(tabbarStyle); + tabBar && tabBar.setTabBarItems({ + list: list.map((item) => ({ + iconPath: item.iconPath, + selectedIconPath: item.selectedIconPath, + visible: item.visible + })) + }); + // TODO 暂未实现 + // tabBar && tabBar.setAnimationAlphaBGColor(parseTheme((__uniConfig.window || {}).backgroundColor, false)) + }; + + fn(); + + onThemeChange(fn); + } + } + + function useWebviewThemeChange (webview, getWebviewStyle) { + if (__uniConfig.darkmode) { + const fn = () => { + const { + animationAlphaBGColor, background, + backgroundColorBottom, backgroundColorTop, + titleNView: { backgroundColor, titleColor } = {} + } = getWebviewStyle(); + webview && webview.setStyle({ + animationAlphaBGColor, + background, + backgroundColorBottom, + backgroundColorTop, + titleNView: { + backgroundColor, + titleColor + } + }); + }; + onThemeChange(fn); + webview.addEventListener('close', () => offThemeChange(fn)); + } + } + + const TABBAR_HEIGHT = 50; + let config; - const publishStateChange$2 = (res) => { - publish('onSocketTaskStateChange', res); - }; + /** + * tabbar显示状态 + */ + let visible = true; - let socket; - function getSocket () { - if (socket) { - return socket + let tabBar; + + function setTabBarItems (style) { + tabBar && tabBar.setTabBarItems(style); + } + + /** + * 设置角标 + * @param {string} type + * @param {number} index + * @param {string} text + */ + function setTabBarBadge$1 (type, index, text) { + if (!tabBar) { + return } - socket = requireNativePlugin('uni-webSocket'); - socket.onopen(function (e) { - publishStateChange$2({ - socketTaskId: e.id, - state: 'open' + if (type === 'none') { + tabBar.hideTabBarRedDot({ + index }); - }); - socket.onmessage(function (e) { - const data = e.data; - publishStateChange$2({ - socketTaskId: e.id, - state: 'message', - data: typeof data === 'object' ? base64ToArrayBuffer$2(data.base64) : data + tabBar.removeTabBarBadge({ + index }); - }); - socket.onerror(function (e) { - publishStateChange$2({ - socketTaskId: e.id, - state: 'error', - errMsg: e.data + } else if (type === 'text') { + tabBar.setTabBarBadge({ + index, + text }); - }); - socket.onclose(function (e) { - const socketTaskId = e.id; - delete socketTasks[socketTaskId]; - publishStateChange$2({ - socketTaskId, - state: 'close' + } else if (type === 'redDot') { + tabBar.showTabBarRedDot({ + index }); - }); - return socket - } - - const createSocketTaskById = function (socketTaskId, { - url, - data, - header, - method, - protocols - } = {}) { - const socket = getSocket(); - socket.WebSocket({ - id: socketTaskId, - url, - protocol: Array.isArray(protocols) ? protocols.join(',') : protocols, - header - }); - socketTasks[socketTaskId] = socket; - return { - socketTaskId, - errMsg: 'createSocketTask:ok' } - }; - - function createSocketTask (args) { - return createSocketTaskById(String(Date.now()), args) } - - function operateSocketTask (args) { - const { - operationType, - code, - reason, - data, - socketTaskId - } = unpack(args); - const socket = socketTasks[socketTaskId]; - if (!socket) { - return { - errMsg: 'operateSocketTask:fail' - } + /** + * 动态设置 tabBar 某一项的内容 + */ + function setTabBarItem$1 (index, text, iconPath, selectedIconPath, visible, iconfont) { + const item = { + index + }; + if (text !== undefined) { + item.text = text; } - switch (operationType) { - case 'send': - if (data) { - socket.send({ - id: socketTaskId, - data: typeof data === 'object' ? { - '@type': 'binary', - base64: arrayBufferToBase64$2(data) - } : data - }); - } - return { - errMsg: 'operateSocketTask:ok' - } - case 'close': - socket.close({ - id: socketTaskId, - code, - reason - }); - delete socketTasks[socketTaskId]; - return { - errMsg: 'operateSocketTask:ok' - } + if (iconPath) { + item.iconPath = getRealPath$1(iconPath); } - return { - errMsg: 'operateSocketTask:fail' + if (selectedIconPath) { + item.selectedIconPath = getRealPath$1(selectedIconPath); } - } - - let uploadTaskId = 0; - const uploadTasks = {}; + if (iconfont !== undefined) { + item.iconfont = iconfont; + } + if (visible !== undefined) { + item.visible = config.list[index].visible = visible; + delete item.index; - const publishStateChange$3 = (res) => { - publish('onUploadTaskStateChange', res); - }; + const tabbarItems = config.list.map(item => ({ visible: item.visible })); + tabbarItems[index] = item; - const createUploadTaskById = function (uploadTaskId, { - url, - filePath, - name, - files, - header, - formData, - timeout = __uniConfig.networkTimeout.uploadFile ? __uniConfig.networkTimeout.uploadFile / 1000 : 120 - } = {}) { - const uploader = plus.uploader.createUpload(url, { - timeout, - // 需要与其它平台上的表现保持一致,不走重试的逻辑。 - retry: 0, - retryInterval: 0 - }, (upload, statusCode) => { - if (statusCode) { - publishStateChange$3({ - uploadTaskId, - state: 'success', - data: upload.responseText, - statusCode - }); - } else { - publishStateChange$3({ - uploadTaskId, - state: 'fail', - data: '', - statusCode - }); - } - delete uploadTasks[uploadTaskId]; + setTabBarItems({ list: tabbarItems }); + } else { + tabBar && tabBar.setTabBarItem(item); + } + } + /** + * 动态设置 tabBar 的整体样式 + * @param {Object} style 样式 + */ + function setTabBarStyle$1 (style) { + tabBar && tabBar.setTabBarStyle(style); + } + /** + * 隐藏 tabBar + * @param {boolean} animation 是否需要动画效果 + */ + function hideTabBar$1 (animation) { + visible = false; + tabBar && tabBar.hideTabBar({ + animation + }); + } + /** + * 显示 tabBar + * @param {boolean} animation 是否需要动画效果 + */ + function showTabBar$1 (animation) { + visible = true; + tabBar && tabBar.showTabBar({ + animation }); + } - for (const name in header) { - if (hasOwn(header, name)) { - uploader.setRequestHeader(name, String(header[name])); + const maskClickCallback = []; + + var tabBar$1 = { + id: '0', + init (options, clickCallback) { + if (options && options.list.length) { + config = options; } - } - for (const name in formData) { - if (hasOwn(formData, name)) { - uploader.addData(name, String(formData[name])); + try { + tabBar = requireNativePlugin('uni-tabview'); + } catch (error) { + console.log(`uni.requireNativePlugin("uni-tabview") error ${error}`); } - } - if (files && files.length) { - files.forEach(file => { - uploader.addFile(getRealPath$1(file.uri || file.filePath), { - key: file.name || 'file' + tabBar.onMaskClick(() => { + maskClickCallback.forEach((callback) => { + callback(); }); }); - } else { - uploader.addFile(getRealPath$1(filePath), { - key: name + tabBar && tabBar.onClick(({ index }) => { + clickCallback(config.list[index], index); }); - } - uploader.addEventListener('statechanged', (upload, status) => { - if (upload.uploadedSize && upload.totalSize) { - publishStateChange$3({ - uploadTaskId, - state: 'progressUpdate', - progress: parseInt(upload.uploadedSize / upload.totalSize * 100), - totalBytesSent: upload.uploadedSize, - totalBytesExpectedToSend: upload.totalSize - }); - } - }); - uploadTasks[uploadTaskId] = uploader; - uploader.start(); - return { - uploadTaskId, - errMsg: 'createUploadTask:ok' - } - }; - - function operateUploadTask ({ - uploadTaskId, - operationType - } = {}) { - const uploadTask = uploadTasks[uploadTaskId]; - if (uploadTask && operationType === 'abort') { - delete uploadTasks[uploadTaskId]; - uploadTask.abort(); - publishStateChange$3({ - uploadTaskId, - state: 'fail', - errMsg: 'abort' + tabBar && tabBar.onMidButtonClick(() => { + publish('onTabBarMidButtonTap', {}); }); - return { - errMsg: 'operateUploadTask:ok' - } - } - return { - errMsg: 'operateUploadTask:fail' - } - } - function createUploadTask (args) { - return createUploadTaskById(++uploadTaskId, args) - } - - const providers = { - oauth (callback) { - plus.oauth.getServices(services => { - const provider = []; - services.forEach(({ - id - }) => { - provider.push(id); - }); - callback(null, provider, services); - }, err => { - callback(err); - }); + useTabBarThemeChange(tabBar, options); }, - share (callback) { - plus.share.getServices(services => { - const provider = []; - services.forEach(({ - id - }) => { - provider.push(id); - }); - callback(null, provider, services); - }, err => { - callback(err); - }); + indexOf (page) { + const config = this.config; + const itemLength = config && config.list && config.list.length; + if (itemLength) { + for (let i = 0; i < itemLength; i++) { + if ( + config.list[i].pagePath === page || + config.list[i].pagePath === `${page}.html` + ) { + return i + } + } + } + return -1 }, - payment (callback) { - plus.payment.getChannels(services => { - const provider = []; - services.forEach(({ - id - }) => { - provider.push(id); + switchTab (page) { + const index = this.indexOf(page); + if (index >= 0) { + tabBar && tabBar.switchSelect({ + index }); - callback(null, provider, services); - }, err => { - callback(err); - }); - }, - push (callback) { - if (typeof weex !== 'undefined' || typeof plus !== 'undefined') { - const clientInfo = plus.push.getClientInfo(); - callback(null, [clientInfo.id], [clientInfo]); - } else { - callback(null, []); + return true } - } - }; - - function getProvider$1 ({ - service - }, callbackId) { - if (providers[service]) { - providers[service]((err, provider, providers) => { - if (err) { - invoke$1(callbackId, { - errMsg: 'getProvider:fail ' + err.message - }); - } else { - invoke$1(callbackId, { - errMsg: 'getProvider:ok', - service, - provider, - providers: providers.map((provider) => { - if (typeof provider.serviceReady === 'boolean') { - provider.isAppExist = provider.serviceReady; - } - if (typeof provider.nativeClient === 'boolean') { - provider.isAppExist = provider.nativeClient; - } - return provider - }) - }); + return false + }, + setTabBarBadge: setTabBarBadge$1, + setTabBarItem: setTabBarItem$1, + setTabBarStyle: setTabBarStyle$1, + hideTabBar: hideTabBar$1, + showTabBar: showTabBar$1, + append (webview) { + tabBar && tabBar.append({ + id: webview.id + }, ({ code }) => { + if (code !== 0) { + // console.log('tab append error') + setTimeout(() => { + this.append(webview); + }, 20); } }); - } else { - invoke$1(callbackId, { - errMsg: 'getProvider:fail service not found' + }, + get config () { + return config || __uniConfig.tabBar + }, + get visible () { + return visible + }, + get height () { + const config = this.config; + return (config && config.height ? parseFloat(config.height) : TABBAR_HEIGHT) + plus.navigator.getSafeAreaInsets().deviceBottom + }, + // tabBar是否遮挡内容区域 + get cover () { + const config = this.config; + const array = ['extralight', 'light', 'dark']; + return config && array.indexOf(config.blurEffect) >= 0 + }, + setStyle ({ mask }) { + tabBar.setMask({ + color: mask }); + }, + addEventListener (name, callback) { + maskClickCallback.push(callback); + }, + removeEventListener (name, callback) { + const callbackIndex = maskClickCallback.indexOf(callback); + maskClickCallback.splice(callbackIndex, 1); } + }; + + function getWindowInfo () { + const ios = plus.os.name.toLowerCase() === 'ios'; + + const { + screenWidth, + screenHeight + } = getScreenInfo(); + const statusBarHeight = getStatusbarHeight(); + + let safeAreaInsets; + const titleNView = { + height: 0, + cover: false + }; + const webview = getLastWebview(); + if (webview) { + let style = webview.getStyle(); + style = style && style.titleNView; + if (style && style.type && style.type !== 'none') { + titleNView.height = style.type === 'transparent' ? 0 : (statusBarHeight + NAVBAR_HEIGHT); + titleNView.cover = style.type === 'transparent' || style.type === 'float'; + } + safeAreaInsets = webview.getSafeAreaInsets(); + } else { + safeAreaInsets = plus.navigator.getSafeAreaInsets(); + } + const tabBarView = { + height: 0, + cover: false + }; + if (isTabBarPage()) { + tabBarView.height = tabBar$1.visible ? tabBar$1.height : 0; + tabBarView.cover = tabBar$1.cover; + } + const windowTop = titleNView.cover ? titleNView.height : 0; + const windowBottom = tabBarView.cover ? tabBarView.height : 0; + let windowHeight = screenHeight - titleNView.height - tabBarView.height; + let windowHeightReal = screenHeight - (titleNView.cover ? 0 : titleNView.height) - (tabBarView.cover ? 0 : tabBarView.height); + const windowWidth = screenWidth; + if ((!tabBarView.height || tabBarView.cover) && !safeAreaInsets.bottom && safeAreaInsets.deviceBottom) { + windowHeight -= safeAreaInsets.deviceBottom; + windowHeightReal -= safeAreaInsets.deviceBottom; + } + safeAreaInsets = ios ? safeAreaInsets : { + left: 0, + right: 0, + top: titleNView.height && !titleNView.cover ? 0 : statusBarHeight, + bottom: 0 + }; + const safeArea = { + left: safeAreaInsets.left, + right: windowWidth - safeAreaInsets.right, + top: safeAreaInsets.top, + bottom: windowHeightReal - safeAreaInsets.bottom, + width: windowWidth - safeAreaInsets.left - safeAreaInsets.right, + height: windowHeightReal - safeAreaInsets.top - safeAreaInsets.bottom + }; + + return { + pixelRatio: plus.screen.scale, + screenWidth, + screenHeight, + windowWidth, + windowHeight, + statusBarHeight, + safeArea, + safeAreaInsets: { + top: safeAreaInsets.top, + right: safeAreaInsets.right, + bottom: safeAreaInsets.bottom, + left: safeAreaInsets.left + }, + windowTop, + windowBottom, + screenTop: screenHeight - windowHeight + } } - let univerifyManager; + let systemInfo = {}; + let _initSystemInfo = true; - function getService (provider) { - return new Promise((resolve, reject) => { - plus.oauth.getServices(services => { - const service = services.find(({ id }) => id === provider); - service ? resolve(service) : reject(new Error('provider not find')); - }, reject); - }) + function weexGetSystemInfoSync () { + if (!_initSystemInfo) return + const { getSystemInfoSync } = weex.requireModule('plus'); + systemInfo = getSystemInfoSync(); + if (typeof systemInfo === 'string') { + try { + systemInfo = JSON.parse(systemInfo); + } catch (error) { } + } + return systemInfo } - /** - * 微信登录 - */ - function login (params, callbackId, plus = true) { - const provider = params.provider || 'weixin'; - const errorCallback = warpErrorCallback(callbackId, 'login', plus); - const isAppleLogin = provider === 'apple'; - const authOptions = isAppleLogin - ? { scope: 'email' } - : params.univerifyStyle - ? { univerifyStyle: univerifyButtonsClickHandling(params.univerifyStyle, errorCallback) } - : {}; - const _invoke = plus ? invoke$1 : callback.invoke; - - getService(provider).then(service => { - function login () { - if (params.onlyAuthorize && provider === 'weixin') { - service.authorize(({ code }) => { - _invoke(callbackId, { - code, - authResult: '', - errMsg: 'login:ok' - }); - }, errorCallback); - return - } - service.login(res => { - const authResult = res.target.authResult; - const appleInfo = res.target.appleInfo; - _invoke(callbackId, { - code: authResult.code, - authResult: authResult, - appleInfo, - errMsg: 'login:ok' - }); - }, errorCallback, authOptions); - } - // 先注销再登录 - // apple登录logout之后无法重新触发获取email,fullname;一键登录无logout - if (isAppleLogin || provider === 'univerify') { - login(); - } else { - service.logout(login, login); - } - }).catch(errorCallback); - } + function getDeviceInfo () { + weexGetSystemInfoSync(); + const { + deviceBrand = '', deviceModel, osName, + osVersion, deviceOrientation, deviceType, + deviceId + } = systemInfo; - function getUserInfo (params, callbackId) { - const provider = params.provider || 'weixin'; - const errorCallback = warpPlusErrorCallback(callbackId, 'operateWXData'); - getService(provider).then(loginService => { - loginService.getUserInfo(res => { - let userInfo; - if (provider === 'weixin') { - const wechatUserInfo = loginService.userInfo; - userInfo = { - openId: wechatUserInfo.openid, - nickName: wechatUserInfo.nickname, - gender: wechatUserInfo.sex, - city: wechatUserInfo.city, - province: wechatUserInfo.province, - country: wechatUserInfo.country, - avatarUrl: wechatUserInfo.headimgurl, - unionId: wechatUserInfo.unionid - }; - } else if (provider === 'apple') { - const appleInfo = loginService.appleInfo; - userInfo = { - openId: appleInfo.user, - fullName: appleInfo.fullName, - email: appleInfo.email, - authorizationCode: appleInfo.authorizationCode, - identityToken: appleInfo.identityToken, - realUserStatus: appleInfo.realUserStatus - }; - } else { - userInfo = loginService.userInfo; - userInfo.openId = userInfo.openId || userInfo.openid || loginService.authResult.openid; - userInfo.nickName = userInfo.nickName || userInfo.nickname; - userInfo.avatarUrl = userInfo.avatarUrl || userInfo.headimgurl; - } - const result = { - errMsg: 'operateWXData:ok' - }; - if (params.data && params.data.api_name === 'webapi_getuserinfo') { - result.data = { - data: JSON.stringify(userInfo), - rawData: '', - signature: '', - encryptedData: '', - iv: '' - }; - } else { - result.userInfo = userInfo; - } - invoke$1(callbackId, result); - }, errorCallback); - }).catch(() => { - invoke$1(callbackId, { - errMsg: 'operateWXData:fail 请先调用 uni.login' - }); - }); - } - /** - * 获取用户信息-兼容 - */ - function getUserProfile (params, callbackId) { - return getUserInfo(params, callbackId) - } + const brand = deviceBrand.toLowerCase(); + const _osName = osName.toLowerCase(); - /** - * 获取用户信息 - */ - function operateWXData (params, callbackId) { - switch (params.data.api_name) { - case 'webapi_getuserinfo': - getUserInfo(params, callbackId); - break - default: - return { - errMsg: 'operateWXData:fail' - } + return { + brand, + deviceBrand: brand, + deviceModel, + devicePixelRatio: plus.screen.scale, + deviceId, + deviceOrientation, + deviceType, + model: deviceModel, + platform: _osName, + system: `${_osName === 'ios' ? 'iOS' : 'Android'} ${osVersion}` } } - function preLogin$1 (params, callbackId, plus) { - const successCallback = warpSuccessCallback(callbackId, 'preLogin', plus); - const errorCallback = warpErrorCallback(callbackId, 'preLogin', plus); - getService(params.provider).then(service => service.preLogin(successCallback, errorCallback)).catch(errorCallback); - } + function getAppBaseInfo () { + weexGetSystemInfoSync(); + const { + hostPackageName, hostName, osLanguage, + hostVersion, hostLanguage, hostTheme, + appId, appName, appVersion, appVersionCode, + appWgtVersion + } = systemInfo; - function closeAuthView () { - return getService('univerify').then(service => service.closeAuthView()) - } + const appLanguage = uni + ? uni.getLocale + ? uni.getLocale() + : hostLanguage + : hostLanguage; - function getCheckBoxState (params, callbackId, plus) { - const successCallback = warpSuccessCallback(callbackId, 'getCheckBoxState', plus); - const errorCallback = warpErrorCallback(callbackId, 'getCheckBoxState', plus); - try { - getService('univerify').then(service => { - const state = service.getCheckBoxState(); - successCallback({ state }); - }); - } catch (error) { - errorCallback(error); + return { + appId, + appName, + appVersion, + appVersionCode, + appWgtVersion, + appLanguage, + enableDebug: false, + hostSDKVersion: undefined, + hostPackageName, + hostName, + hostVersion, + hostLanguage, + hostTheme, + hostFontSizeSetting: undefined, + language: osLanguage, + SDKVersion: '', + theme: plus.navigator.getUIStyle(), + version: plus.runtime.innerVersion } } - /** - * 一键登录自定义登陆按钮点击处理 - */ - function univerifyButtonsClickHandling (univerifyStyle, errorCallback) { - if (isPlainObject(univerifyStyle) && isPlainObject(univerifyStyle.buttons) && toRawType(univerifyStyle.buttons.list) === 'Array') { - univerifyStyle.buttons.list.forEach((button, index) => { - univerifyStyle.buttons.list[index].onclick = function () { - const res = { - code: '30008', - message: '用户点击了自定义按钮', - index, - provider: button.provider - }; - isPlainObject(univerifyManager) - ? univerifyManager._triggerUniverifyButtonsClick(res) - : closeAuthView().then(() => { - errorCallback(res); - }); - }; - }); - } - return univerifyStyle + function getSystemInfoSync () { + return callApiSync(getSystemInfo, Object.create(null), 'getSystemInfo', 'getSystemInfoSync') } - class UniverifyManager { - constructor () { - this.provider = 'univerify'; - this.eventName = 'api.univerifyButtonsClick'; - } - - close () { - closeAuthView(); - } + function getSystemInfo () { + _initSystemInfo = true; + weexGetSystemInfoSync(); + _initSystemInfo = false; + const windowInfo = getWindowInfo(); + const deviceInfo = getDeviceInfo(); + const appBaseInfo = getAppBaseInfo(); + _initSystemInfo = true; - login (options) { - this._warp((data, callbackId) => login(data, callbackId, false), options); - } + const extraData = { + errMsg: 'getSystemInfo:ok', + fontSizeSetting: appBaseInfo.hostFontSizeSetting, + osName: systemInfo.osName.toLowerCase() + }; - getCheckBoxState (options) { - this._warp((_, callbackId) => getCheckBoxState(_, callbackId, false), options); + if (systemInfo.hostName) { + extraData.hostSDKVersion = systemInfo.uniRuntimeVersion; } - preLogin (options) { - this._warp((data, callbackId) => preLogin$1(data, callbackId, false), options); - } - - onButtonsClick (callback) { - UniServiceJSBridge.on(this.eventName, callback); - } + const _systemInfo = Object.assign( + {}, + systemInfo, + windowInfo, + deviceInfo, + appBaseInfo, + extraData + ); - offButtonsClick (callback) { - UniServiceJSBridge.off(this.eventName, callback); + delete _systemInfo.screenTop; + delete _systemInfo.enableDebug; + if (!__uniConfig.darkmode) { + delete _systemInfo.theme; } - _triggerUniverifyButtonsClick (res) { - UniServiceJSBridge.emit(this.eventName, res); + return sortObject(_systemInfo) + } + + function vibrateLong () { + plus.device.vibrate(400); + return { + errMsg: 'vibrateLong:ok' } - - _warp (fn, options) { - return callback.warp(fn)(this._getOptions(options)) + } + function vibrateShort () { + plus.device.vibrate(15); + return { + errMsg: 'vibrateShort:ok' } + } + + function getSystemSetting () { + const { getSystemSetting } = weex.requireModule('plus'); + let systemSetting = getSystemSetting(); + try { + if (typeof systemSetting === 'string') { systemSetting = JSON.parse(systemSetting); } + } catch (error) { } + + return systemSetting + } + + function getAppAuthorizeSetting () { + const { getAppAuthorizeSetting } = weex.requireModule('plus'); + let appAuthorizeSetting = getAppAuthorizeSetting(); + try { + if (typeof appAuthorizeSetting === 'string') { appAuthorizeSetting = JSON.parse(appAuthorizeSetting); } + } catch (error) { } + + for (const key in appAuthorizeSetting) { + if (Object.hasOwnProperty.call(appAuthorizeSetting, key)) { + const value = appAuthorizeSetting[key]; + if (value === 'undefined') appAuthorizeSetting[key] = undefined; + } + } + + return appAuthorizeSetting + } + + function openAppAuthorizeSetting (options, callbackId) { + const { openAppAuthorizeSetting } = weex.requireModule('plus'); + openAppAuthorizeSetting(ret => { + if (ret.type === 'success') { + invoke$1(callbackId, { + errMsg: 'getClipboardData:ok' + }); + } else { + invoke$1(callbackId, { + errMsg: 'getClipboardData:fail' + }); + } + }); + } + + const SAVED_DIR = 'uniapp_save'; + const SAVE_PATH = `_doc/${SAVED_DIR}`; - _getOptions (options = {}) { - return Object.assign({}, options, { provider: this.provider }) - } + function getSavedFileDir (success, fail) { + fail = fail || function () { }; + plus.io.requestFileSystem(plus.io.PRIVATE_DOC, fs => { // 请求_doc fs + fs.root.getDirectory(SAVED_DIR, { // 获取文件保存目录对象 + create: true + }, success, fail); + }, fail); } - function getUniverifyManager () { - return univerifyManager || (univerifyManager = new UniverifyManager()) + let index = 0; + function saveFile$1 ({ + tempFilePath + } = {}, callbackId) { + const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile'); + const fileName = `${Date.now()}${index++}${getExtName(tempFilePath)}`; + + plus.io.resolveLocalFileSystemURL(tempFilePath, entry => { // 读取临时文件 FileEntry + getSavedFileDir(dir => { + entry.copyTo(dir, fileName, () => { // 复制临时文件 FileEntry,为了避免把相册里的文件删除,使用 copy,微信中是要删除临时文件的 + const savedFilePath = SAVE_PATH + '/' + fileName; + invoke$1(callbackId, { + errMsg: 'saveFile:ok', + savedFilePath + }); + }, errorCallback); + }, errorCallback); + }, errorCallback); } - function warpSuccessCallback (callbackId, name, plus = true) { - return plus - ? warpPlusSuccessCallback(callbackId, name) - : (options) => { - callback.invoke(callbackId, Object.assign({}, options, { - errMsg: `${name}:ok` - })); - } + function getSavedFileList (options, callbackId) { + const errorCallback = warpPlusErrorCallback(callbackId, 'getSavedFileList'); + + getSavedFileDir(entry => { + var reader = entry.createReader(); + + var fileList = []; + reader.readEntries(entries => { + if (entries && entries.length) { + entries.forEach(entry => { + entry.getMetadata(meta => { + fileList.push({ + filePath: plus.io.convertAbsoluteFileSystem(entry.fullPath), + createTime: meta.modificationTime.getTime(), + size: meta.size + }); + if (fileList.length === entries.length) { + invoke$1(callbackId, { + errMsg: 'getSavedFileList:ok', + fileList + }); + } + }, errorCallback, false); + }); + } else { + invoke$1(callbackId, { + errMsg: 'getSavedFileList:ok', + fileList + }); + } + }, errorCallback); + }, errorCallback); } - function warpErrorCallback (callbackId, name, plus = true) { - return plus - ? warpPlusErrorCallback(callbackId, name) - : (error) => { - const { code = 0, message: errorMessage } = error; - callback.invoke(callbackId, { - errMsg: `${name}:fail ${errorMessage || ''}`, - errCode: code, - code + const getFileInfo$1 = warpPlusMethod('io', 'getFileInfo'); + + function getSavedFileInfo$1 ({ + filePath + } = {}, callbackId) { + const errorCallback = warpPlusErrorCallback(callbackId, 'getSavedFileInfo'); + + plus.io.resolveLocalFileSystemURL(filePath, entry => { + entry.getMetadata(meta => { + invoke$1(callbackId, { + createTime: meta.modificationTime.getTime(), + size: meta.size, + errMsg: 'getSavedFileInfo:ok' }); - } - } - - function requestPayment (params, callbackId) { - const provider = params.provider; - const errorCallback = warpPlusErrorCallback(callbackId, 'requestPayment'); + }, errorCallback, false); + }, errorCallback); + } - plus.payment.getChannels(services => { - const service = services.find(({ - id - }) => id === provider); - if (!service) { + function removeSavedFile$1 ({ + filePath + } = {}, callbackId) { + const errorCallback = warpPlusErrorCallback(callbackId, 'removeSavedFile'); + + plus.io.resolveLocalFileSystemURL(filePath, entry => { + entry.remove(() => { invoke$1(callbackId, { - errMsg: 'requestPayment:fail service not found' + errMsg: 'removeSavedFile:ok' }); - } else { - plus.payment.request(service, params.orderInfo, res => { - res.errMsg = 'requestPayment:ok'; - invoke$1(callbackId, res); - }, errorCallback); - } + }, errorCallback); }, errorCallback); } - let onPushing; - - let isListening = false; - - let unsubscribe = false; + function openDocument$1 ({ + filePath, + fileType + } = {}, callbackId) { + const successCallback = warpPlusSuccessCallback(callbackId, 'saveFile'); + const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile'); - function subscribePush (params, callbackId) { - const clientInfo = plus.push.getClientInfo(); - if (clientInfo) { - if (!isListening) { - isListening = true; - plus.push.addEventListener('receive', msg => { - if (onPushing && !unsubscribe) { - publish('onPushMessage', { - messageId: msg.__UUID__, - data: msg.payload, - errMsg: 'onPush:ok' - }); - } - }); - } - unsubscribe = false; - clientInfo.errMsg = 'subscribePush:ok'; - return clientInfo - } else { - return { - errMsg: 'subscribePush:fail 请确保当前运行环境已包含 push 模块' - } - } - } + plus.runtime.openDocument(getRealPath$1(filePath), undefined, successCallback, errorCallback); + } + + const CHOOSE_LOCATION_PATH = '_www/__uniappchooselocation.html'; - function unsubscribePush (params) { - unsubscribe = true; - return { - errMsg: 'unsubscribePush:ok' - } - } + const MESSAGE_TYPE$1 = 'chooseLocation'; - function onPush () { - if (!isListening) { - return { - errMsg: 'onPush:fail 请先调用 uni.subscribePush' - } - } - if (plus.push.getClientInfo()) { - onPushing = true; - return { - errMsg: 'onPush:ok' + function chooseLocation$1 (params, callbackId) { + const statusBarStyle = plus.navigator.getStatusBarStyle(); + const webview = plus.webview.create( + CHOOSE_LOCATION_PATH, + MAP_ID, { + titleNView: { + autoBackButton: true, + backgroundColor: '#000000', + titleColor: '#ffffff', + titleText: '选择位置', + titleSize: '17px', + buttons: [{ + float: 'right', + text: '完成', + fontSize: '17px', + width: '60px', + onclick: function () { + webview.evalJS('__chooseLocationConfirm__()'); + } + }] + }, + popGesture: 'close', + scrollIndicator: 'none' + }, { + __uniapp_type: 'map', + __uniapp_statusbar_style: statusBarStyle, + 'uni-app': 'none' } + ); + if (statusBarStyle === 'dark') { + plus.navigator.setStatusBarStyle('light'); + webview.addEventListener('popGesture', ({ + type, + result + }) => { + if (type === 'start') { + plus.navigator.setStatusBarStyle('dark'); + } else if (type === 'end' && !result) { + plus.navigator.setStatusBarStyle('light'); + } + }); } - return { - errMsg: 'onPush:fail 请确保当前运行环境已包含 push 模块' - } - } + let index = 0; + const onShow = function () { + index++; + if (index === 2) { + webview.evalJS(`__chooseLocation__(${JSON.stringify(params)})`); + } + }; + webview.addEventListener('loaded', onShow); + webview.show('slide-in-bottom', ANI_DURATION, onShow); - function offPush (params) { - onPushing = false; - return { - errMsg: 'offPush:ok' - } - } + let result; - function createPushMessage (params, callbackId) { - const setting = getAppAuthorizeSetting(); - if (setting.notificationAuthorized !== 'authorized') { - return invoke$1(callbackId, { - errMsg: 'createPushMessage:fail notificationAuthorized: ' + setting.notificationAuthorized - }) - } - const options = Object.assign({}, params); - delete options.content; - delete options.payload; - plus.push.createMessage(params.content, params.payload, options); - invoke$1(callbackId, { - errMsg: 'createPushMessage:ok' + webview.addEventListener('close', () => { + if (result) { + invoke$1(callbackId, { + name: result.poiname, + address: result.poiaddress, + latitude: result.latlng.lat, + longitude: result.latlng.lng, + errMsg: 'chooseLocation:ok' + }); + } else { + consumePlusMessage(MESSAGE_TYPE$1); + invoke$1(callbackId, { + errMsg: 'chooseLocation:fail cancel' + }); + } }); + + registerPlusMessage(MESSAGE_TYPE$1, function (res) { + if (res && 'latlng' in res) { + result = res; + } + }, false); } - function requireNativePlugin$1 (name) { - return weex.requireModule(name) + var webview$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + chooseLocation: chooseLocation$1 + }); + + function getStatusBarStyle$2 () { + let style = plus.navigator.getStatusBarStyle(); + if (style === 'UIStatusBarStyleBlackTranslucent' || style === 'UIStatusBarStyleBlackOpaque' || style === 'null') { + style = 'light'; + } else if (style === 'UIStatusBarStyleDefault') { + style = 'dark'; + } + return style } - // 0:图文,1:纯文字,2:纯图片,3:音乐,4:视频,5:小程序 - const TYPES$1 = { - 0: { - name: 'web', - title: '图文' - }, - 1: { - name: 'text', - title: '纯文字' - }, - 2: { - name: 'image', - title: '纯图片' - }, - 3: { - name: 'music', - title: '音乐' - }, - 4: { - name: 'video', - title: '视频' - }, - 5: { - name: 'miniProgram', - title: '小程序' + function chooseLocation$2 (options, callbackId) { + const statusBarStyle = getStatusBarStyle$2(); + const isDark = statusBarStyle !== 'light'; + + let result; + const page = showPage({ + url: '__uniappchooselocation', + data: Object.assign({}, options, { + locale: getLocale() + }), + style: { + animationType: options.animationType || 'slide-in-bottom', + titleNView: false, + popGesture: 'close', + scrollIndicator: 'none' + }, + onMessage ({ + event, + detail + }) { + if (event === 'selected') { + result = detail; + result.errMsg = 'chooseLocation:ok'; + } + }, + onClose () { + if (isDark) { + plus.navigator.setStatusBarStyle('dark'); + } + + invoke$1(callbackId, result || { + errMsg: 'chooseLocation:fail cancel' + }); + } + }); + + if (isDark) { + plus.navigator.setStatusBarStyle('light'); + page.webview.addEventListener('popGesture', ({ + type, + result + }) => { + if (type === 'start') { + plus.navigator.setStatusBarStyle('dark'); + } else if (type === 'end' && !result) { + plus.navigator.setStatusBarStyle('light'); + } + }); + } + } + + var weex$2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + chooseLocation: chooseLocation$2 + }); + + function chooseLocation$3 (...array) { + const api = __uniConfig.nvueCompiler !== 'weex' ? weex$2 : webview$1; + return api.chooseLocation(...array) + } + + function getLocationSuccess (type, position, callbackId) { + const coords = position.coords; + if (type !== position.coordsType) { + if (process.env.NODE_ENV !== 'production') { + console.log( + `UNIAPP[location]:before[${position.coordsType}][lng:${ + coords.longitude + },lat:${coords.latitude}]` + ); + } + let coordArray; + if (type === 'wgs84') { + coordArray = gcj02towgs84(coords.longitude, coords.latitude); + } else if (type === 'gcj02') { + coordArray = wgs84togcj02(coords.longitude, coords.latitude); + } + if (coordArray) { + coords.longitude = coordArray[0]; + coords.latitude = coordArray[1]; + if (process.env.NODE_ENV !== 'production') { + console.log( + `UNIAPP[location]:after[${type}][lng:${coords.longitude},lat:${ + coords.latitude + }]` + ); + } + } } - }; - - const parseParams = (args, callbackId, method) => { - args.type = args.type || 0; - let { - provider, + invoke$1(callbackId, { type, - title, - summary: content, - href, - imageUrl, - mediaUrl: media, - scene, - miniProgram, - openCustomerServiceChat, - corpid, - customerUrl: url - } = args; - - if (typeof imageUrl === 'string' && imageUrl) { - imageUrl = getRealPath$1(imageUrl); - } + altitude: coords.altitude || 0, + latitude: coords.latitude, + longitude: coords.longitude, + speed: coords.speed, + accuracy: coords.accuracy, + address: position.address, + errMsg: 'getLocation:ok' + }); + } - const shareType = TYPES$1[type + '']; - if (shareType) { - const sendMsg = { - provider, - type: shareType.name, - title, - content, - href, - pictures: [imageUrl], - thumbs: [imageUrl], - media, - miniProgram, - extra: { - scene - }, - openCustomerServiceChat, - corpid, - url - }; - if (provider === 'weixin' && (type === 1 || type === 2)) { - delete sendMsg.thumbs; - } - return sendMsg - } - return '分享参数 type 不正确' - }; - - const sendShareMsg = function (service, params, callbackId, method = 'share') { - const errorCallback = warpPlusErrorCallback(callbackId, method); - const serviceMethod = params.openCustomerServiceChat ? 'openCustomerServiceChat' : 'send'; - try { - service[serviceMethod](params, () => { - invoke$1(callbackId, { - errMsg: method + ':ok' - }); - }, errorCallback); - } catch (error) { - errorCallback({ - message: `${params.provider} ${serviceMethod} 方法调用失败` - }); - } - }; - - function shareAppMessageDirectly ({ - title, - path, - imageUrl, - useDefaultSnapshot - }, callbackId) { - title = title || __uniConfig.appname; - const goShare = () => { - share({ - provider: 'weixin', - type: 0, - title, - imageUrl, - href: path, - scene: 'WXSceneSession' + function getLocation$1 ({ + type = 'wgs84', + geocode = false, + altitude = false, + isHighAccuracy = false, + highAccuracyExpireTime + } = {}, callbackId) { + const errorCallback = warpPlusErrorCallback(callbackId, 'getLocation'); + plus.geolocation.getCurrentPosition( + position => { + getLocationSuccess(type, position, callbackId); }, - callbackId, - 'shareAppMessageDirectly' - ); - }; - const errorCallback = warpPlusErrorCallback(callbackId, 'shareAppMessageDirectly'); - - if (useDefaultSnapshot) { - const pages = getCurrentPages(); - const webview = plus.webview.getWebviewById(pages[pages.length - 1].__wxWebviewId__ + ''); - if (webview) { - const bitmap = new plus.nativeObj.Bitmap(); - webview.draw(bitmap, () => { - const fileName = TEMP_PATH + '/share/snapshot.jpg'; - bitmap.save( - fileName, { - overwrite: true, - format: 'jpg' - }, () => { - imageUrl = fileName; - goShare(); - }, errorCallback); - }, errorCallback); - } else { - goShare(); - } - } else { - goShare(); - } - } - - function share (params, callbackId, method = 'share') { - params = parseParams(params); - const errorCallback = warpPlusErrorCallback(callbackId, method); - - if (typeof params === 'string') { - return invoke$1(callbackId, { - errMsg: method + ':fail ' + params - }) - } - const provider = params.provider; - plus.share.getServices(services => { - const service = services.find(({ - id - }) => id === provider); - if (!service) { - invoke$1(callbackId, { - errMsg: method + ':fail service not found' - }); - } else { - if (service.authenticated) { - sendShareMsg(service, params, callbackId); - } else { - service.authorize( - () => sendShareMsg(service, params, callbackId), - errorCallback - ); + e => { + // 坐标地址解析失败 + if (e.code === 1501) { + getLocationSuccess(type, e, callbackId); + return } + errorCallback(e); + }, { + geocode: geocode, + enableHighAccuracy: isHighAccuracy || altitude, + timeout: highAccuracyExpireTime, + coordsType: type } - }, errorCallback); - } - - function shareWithSystem (params, callbackId, method = 'shareWithSystem') { - let { - type, - imageUrl, - summary: content, - href - } = params; - type = type || 'text'; - const allowedTypes = ['text', 'image']; - const errorCallback = warpPlusErrorCallback(callbackId, method); + ); + } + + const OPEN_LOCATION_PATH = '_www/__uniappopenlocation.html'; - if (allowedTypes.indexOf(type) < 0) { - invoke$1(callbackId, { - errMsg: method + ':fail 分享参数 type 不正确' + function openLocation$1 (params) { + const statusBarStyle = plus.navigator.getStatusBarStyle(); + const webview = plus.webview.create( + OPEN_LOCATION_PATH, + MAP_ID, { + titleNView: { + autoBackButton: true, + titleColor: '#ffffff', + titleText: '', + titleSize: '17px', + type: 'transparent' + }, + popGesture: 'close', + scrollIndicator: 'none' + }, { + __uniapp_type: 'map', + __uniapp_statusbar_style: statusBarStyle, + 'uni-app': 'none' + } + ); + if (statusBarStyle === 'light') { + plus.navigator.setStatusBarStyle('dark'); + webview.addEventListener('popGesture', ({ + type, + result + }) => { + if (type === 'start') { + plus.navigator.setStatusBarStyle('light'); + } else if (type === 'end' && !result) { + plus.navigator.setStatusBarStyle('dark'); + } }); } - if (typeof imageUrl === 'string' && imageUrl) { - imageUrl = getRealPath$1(imageUrl); + webview.show(ANI_SHOW, ANI_DURATION, () => { + webview.evalJS(`__openLocation__(${JSON.stringify(params)})`); + }); + + return { + errMsg: 'openLocation:ok' } - plus.share.sendWithSystem({ - type, - pictures: imageUrl && [imageUrl], - content, - href - }, function (res) { - invoke$1(callbackId, { - errMsg: method + ':ok' - }); - }, errorCallback); } - function restoreGlobal ( - newWeex, - newPlus, - newSetTimeout, - newClearTimeout, - newSetInterval, - newClearInterval - ) { - // 确保部分全局变量 是 app-service 中的 - // 若首页 nvue 初始化比 app-service 快,导致框架处于该 nvue 环境下 - // plus 如果不用 app-service,资源路径会出问题 - // 若首页 nvue 被销毁,如 redirectTo 或 reLaunch,则这些全局功能会损坏 - if (plus !== newPlus) { - if (process.env.NODE_ENV !== 'production') { - console.log(`[restoreGlobal][${Date.now()}]`); + var webview$2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + openLocation: openLocation$1 + }); + + function openLocation$2 (data, callbackId) { + showPage({ + url: '__uniappopenlocation', + data: Object.assign({}, data, { + locale: getLocale() + }), + style: { + titleNView: { + type: 'transparent' + }, + popGesture: 'close', + backButtonAutoControl: 'close' + }, + onClose () { + invoke$1(callbackId, { + errMsg: 'openLocation:fail cancel' + }); } - weex = newWeex; - plus = newPlus; - restoreOldSetStatusBarStyle(plus.navigator.setStatusBarStyle); - plus.navigator.setStatusBarStyle = newSetStatusBarStyle; - /* eslint-disable no-global-assign */ - setTimeout = newSetTimeout; - clearTimeout = newClearTimeout; - setInterval = newSetInterval; - clearInterval = newClearInterval; + }); + return { + errMsg: 'openLocation:ok' } - __uniConfig.serviceReady = true; } - function requireGlobal () { - const list = [ - 'ArrayBuffer', - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Int16Array', - 'Uint16Array', - 'Int32Array', - 'Uint32Array', - 'Float32Array', - 'Float64Array', - 'BigInt64Array', - 'BigUint64Array' - ]; - const object = {}; - for (let i = 0; i < list.length; i++) { - const key = list[i]; - object[key] = global[key]; + var weex$3 = /*#__PURE__*/Object.freeze({ + __proto__: null, + openLocation: openLocation$2 + }); + + function openLocation$3 (...array) { + const api = __uniConfig.nvueCompiler !== 'weex' ? weex$3 : webview$2; + return api.openLocation(...array) + } + + let successCallbackIds = []; + let errorCallbackIds = []; + let started = false; + let watchId = 0; + + function startLocationUpdate ({ type = 'gcj02' }, callbackId) { + watchId = watchId || plus.geolocation.watchPosition( + res => { + started = true; + successCallbackIds.forEach(callbackId => { + invoke$1(callbackId, res.coords); + }); + }, + error => { + if (!started) { + invoke$1(callbackId, { errMsg: `startLocationUpdate:fail ${error.message}` }); + started = true; + } + errorCallbackIds.forEach(callbackId => { + invoke$1(callbackId, { + errMsg: `onLocationChange:fail ${error.message}` + }); + }); + }, + { + coordsType: type + } + ); + setTimeout(() => { + invoke$1(callbackId, { + errMsg: 'startLocationUpdate:ok' + }); + }, 100); + } + + function stopLocationUpdate () { + if (watchId !== 0) { + plus.geolocation.clearWatch(watchId); + started = false; + watchId = 0; } - return object + return {} } - function wrapper$1 (webview) { - webview.$processed = true; - - webview.postMessage = function (data) { - plus.webview.postMessageToUniNView({ - type: 'UniAppSubNVue', - data - }, webview.id); - }; - let callbacks = []; - webview.onMessage = function (callback) { - callbacks.push(callback); - }; - webview.$consumeMessage = function (e) { - callbacks.forEach(callback => callback(e)); - }; + function onLocationChange (callbackId) { + successCallbackIds.push(callbackId); + } + + function offLocationChange (callbackId) { + if (callbackId) { + const index = successCallbackIds.indexOf(callbackId); + if (index >= 0) { + successCallbackIds.splice(index, 1); + } + } else { + successCallbackIds = []; + } + } + + function onLocationChangeError (callbackId) { + errorCallbackIds.push(callbackId); + } + + function offLocationChangeError (callbackId) { + if (callbackId) { + const index = errorCallbackIds.indexOf(callbackId); + if (index >= 0) { + errorCallbackIds.splice(index, 1); + } + } else { + errorCallbackIds = []; + } + } + + const RECORD_TIME = 60 * 60 * 1000; - if (!webview.__uniapp_mask_id) { - return - } - const maskColor = webview.__uniapp_mask; - const maskWebview = webview.__uniapp_mask_id === '0' ? { - setStyle ({ - mask - }) { - requireNativePlugin$1('uni-tabview').setMask({ - color: mask - }); - } - } : plus.webview.getWebviewById(webview.__uniapp_mask_id); - const oldShow = webview.show; - const oldHide = webview.hide; - const oldClose = webview.close; + let recorder; + let recordTimeout; - const showMask = function () { - maskWebview.setStyle({ - mask: maskColor + function startRecord (args, callbackId) { + recorder && recorder.stop(); + recorder = plus.audio.getRecorder(); + recorder.record({ + filename: '_doc/audio/', + format: 'aac' + }, (res) => { + invoke$1(callbackId, { + errMsg: 'startRecord:ok', + tempFilePath: res }); - }; - const closeMask = function () { - maskWebview.setStyle({ - mask: 'none' + }, (res) => { + invoke$1(callbackId, { + errMsg: 'startRecord:fail' }); - }; - webview.show = function (...args) { - showMask(); - return oldShow.apply(webview, args) - }; - webview.hide = function (...args) { - closeMask(); - return oldHide.apply(webview, args) - }; - webview.close = function (...args) { - closeMask(); - callbacks = []; - return oldClose.apply(webview, args) - }; + }); + recordTimeout = setTimeout(() => { + recorder.stop(); + recorder = false; + }, RECORD_TIME); } - function getSubNVueById (id) { - const webview = plus.webview.getWebviewById(id); - if (webview === null || webview === undefined) { - throw new Error('Unable to find SubNVue, id=' + id) + function stopRecord () { + if (recorder) { + recordTimeout && clearTimeout(recordTimeout); + recorder.stop(); + return { + errMsg: 'stopRecord:ok' + } } - if (webview && !webview.$processed) { - wrapper$1(webview); + return { + errMsg: 'stopRecord:fail' } - const oldSetStyle = webview.setStyle; - var parentWebview = plus.webview.getWebviewById(webview.__uniapp_mask_id); - webview.setStyle = function (style) { - if (style && style.mask) { - parentWebview && parentWebview.setStyle({ - mask: style.mask - }); - delete style.mask; - } - oldSetStyle.call(this, style); - }; - return webview } - function getCurrentSubNVue () { - return getSubNVueById(plus.webview.currentWebview().id) - } - - const callbacks$3 = []; - // 不使用uni-core/service/platform中的onMethod,避免循环引用 - UniServiceJSBridge.on('api.uniMPNativeEvent', function (res) { - callbacks$3.forEach(callbackId => { - invoke$1(callbackId, res.event, res.data); - }); - }); + let player; + let playerFilePath; + let playerStatus; - function onHostEventReceive (callbackId) { - callbacks$3.push(callbackId); + function playVoice ({ + filePath + } = {}, callbackId) { + if (player && playerFilePath === filePath && playerStatus === 'pause') { // 如果是当前音频被暂停,则继续播放 + playerStatus = 'play'; + player.play((res) => { + player = false; + playerFilePath = false; + playerStatus = false; + invoke$1(callbackId, { + errMsg: 'playVoice:ok' + }); + }); + return { + errMsg: 'playVoice:ok' + } + } + if (player) { // 如果存在音频播放,则停止 + player.stop(); + } + playerFilePath = filePath; + playerStatus = 'play'; + player = plus.audio.createPlayer(getRealPath$1(filePath)); + // 播放操作成功回调 + player.play((res) => { + player = false; + playerFilePath = false; + playerStatus = false; + invoke$1(callbackId, { + errMsg: 'playVoice:ok' + }); + }); } - function onNativeEventReceive (callbackId) { - callbacks$3.push(callbackId); - } - - function sendNativeEvent (event, data, callback) { - // 实时获取weex module(weex可能会变化,比如首页nvue加速显示时) - return weex.requireModule('plus').sendNativeEvent(event, data, callback) - } - - const loadedSubPackages = []; - - /** - * 指定路由 ready 后,检查是否触发分包预加载 - * @param {Object} route - */ - function preloadSubPackages (route) { - if (!__uniConfig.preloadRule) { - return - } - const options = __uniConfig.preloadRule[route]; - if (!options || !Array.isArray(options.packages)) { - return + function pauseVoice () { + if (player && playerStatus === 'play') { + player.pause(); + playerStatus = 'pause'; } - const packages = options.packages.filter(root => loadedSubPackages.indexOf(root) === -1); - if (!packages.length) { - return + return { + errMsg: 'pauseVoice:ok' } - loadSubPackages(options.packages); - // 暂不需要网络下载 - // const network = options.network || 'wifi' - // if (network === 'wifi') { - // uni.getNetworkType({ - // success (res) { - // if (process.env.NODE_ENV !== 'production') { - // console.log('UNIAPP[preloadRule]:' + res.networkType + ':' + JSON.stringify(options)) - // } - // if (res.networkType === 'wifi') { - // loadSubPackages(options.packages) - // } - // } - // }) - // } else { - // if (process.env.NODE_ENV !== 'production') { - // console.log('UNIAPP[preloadRule]:' + JSON.stringify(options)) - // } - // loadSubPackages(options.packages) - // } } - function loadPage (route, callback) { - let isInSubPackage = false; - const subPackages = __uniConfig.subPackages; - if (Array.isArray(subPackages)) { - const subPackage = subPackages.find(subPackage => route.indexOf(subPackage.root) === 0); - if (subPackage) { - isInSubPackage = true; - loadSubPackage$1(subPackage.root, callback); - } + function stopVoice () { + if (player) { + player.stop(); + player = false; + playerFilePath = false; + playerStatus = false; } - if (!isInSubPackage) { - callback(); + return { + errMsg: 'stopVoice:ok' } + } + + /** + * 获取文件信息 + * @param {string} filePath 文件路径 + * @returns {Promise} 文件信息Promise + */ + function getFileInfo$2 (filePath) { + return new Promise((resolve, reject) => { + plus.io.resolveLocalFileSystemURL(filePath, function (entry) { + entry.getMetadata(resolve, reject, false); + }, reject); + }) } - function loadSubPackage$1 (root, callback) { - if (loadedSubPackages.indexOf(root) !== -1) { - return callback() - } - loadSubPackages([root], () => { - callback(); - }); - } + function chooseImage$1 ({ + count, + sizeType, + sourceType, + crop + } = {}, callbackId) { + const errorCallback = warpPlusErrorCallback(callbackId, 'chooseImage', 'cancel'); - const SUB_FILENAME = 'app-sub-service.js'; + function successCallback (paths) { + const tempFiles = []; + const tempFilePaths = []; + Promise.all(paths.map((path) => getFileInfo$2(path))) + .then((filesInfo) => { + filesInfo.forEach((file, index) => { + const path = paths[index]; + tempFilePaths.push(path); + tempFiles.push({ path, size: file.size }); + }); - function evaluateScriptFiles (files, callback) { - __uniConfig.onServiceReady(() => { - weex.requireModule('plus').evalJSFiles(files, callback); - }); - } + invoke$1(callbackId, { + errMsg: 'chooseImage:ok', + tempFilePaths, + tempFiles + }); + }) + .catch(errorCallback); + } - function loadSubPackages (packages, callback) { - if (process.env.NODE_ENV !== 'production') { - console.log('UNIAPP[loadSubPackages]:' + JSON.stringify(packages)); + function openCamera () { + const camera = plus.camera.getCamera(); + camera.captureImage(path => successCallback([path]), + errorCallback, { + filename: TEMP_PATH + '/camera/', + resolution: 'high', + crop, + sizeType + }); } - const startTime = Date.now(); - evaluateScriptFiles(packages.map(root => { - loadedSubPackages.push(root); - return root + '/' + SUB_FILENAME - }), res => { - if (process.env.NODE_ENV !== 'production') { - console.log('UNIAPP[loadSubPackages]:耗时(' + (Date.now() - startTime) + ')'); - } - callback && callback(true); - }); - } - - const SUB_FILENAME$1 = 'app-sub-service.js'; - function evaluateScriptFile (file, callback) { - __uniConfig.onServiceReady(() => { - weex.requireModule('plus').evalJSFiles([file], callback); - }); - } + function openAlbum () { + plus.gallery.pick(({ files }) => successCallback(files), errorCallback, { + maximum: count, + multiple: true, + system: false, + filename: TEMP_PATH + '/gallery/', + permissionAlert: true, + crop, + sizeType + }); + } - function loadSubPackage$2 ({ - root - }, callbackId) { - if (loadedSubPackages.indexOf(root) !== -1) { - return { - errMsg: 'loadSubPackage:ok' + if (sourceType.length === 1) { + if (sourceType.includes('album')) { + openAlbum(); + return + } else if (sourceType.includes('camera')) { + openCamera(); + return } } - loadedSubPackages.push(root); - if (process.env.NODE_ENV !== 'production') { - console.log('UNIAPP[loadSubPackage]:' + root); - } - const startTime = Date.now(); - evaluateScriptFile(root + '/' + SUB_FILENAME$1, res => { - if (process.env.NODE_ENV !== 'production') { - console.log('UNIAPP[loadSubPackage]:耗时(' + (Date.now() - startTime) + ')'); + plus.nativeUI.actionSheet({ + cancel: t('uni.chooseImage.cancel'), + buttons: [{ + title: t('uni.chooseImage.sourceType.camera') + }, { + title: t('uni.chooseImage.sourceType.album') + }] + }, (e) => { + switch (e.index) { + case 1: + openCamera(); + break + case 2: + openAlbum(); + break + default: + errorCallback(); + break } - invoke$1(callbackId, { - errMsg: 'loadSubPackage:ok' - }); }); } - const sendHostEvent = sendNativeEvent; - - function navigateToMiniProgram (data, callbackId) { - sendHostEvent( - 'navigateToUniMP', - data, - (res) => { - if (res.errMsg && res.errMsg.indexOf(':ok') === -1) { - return invoke$1(callbackId, { - errMsg: res.errMsg - }) - } - invoke$1(callbackId, { - errMsg: 'navigateToMiniProgram:ok' - }); - } - ); - } - - const extend = Object.assign; + function chooseVideo$1 ({ + sourceType, + compressed, + maxDuration, + camera + } = {}, callbackId) { + const errorCallback = warpPlusErrorCallback(callbackId, 'chooseVideo', 'cancel'); - function createLaunchOptions () { - return { - path: '', - query: {}, - scene: 1001, - referrerInfo: { - appId: '', - extraData: {} - } + function successCallback (tempFilePath = '') { + plus.io.getVideoInfo({ + filePath: tempFilePath, + success (videoInfo) { + const result = { + errMsg: 'chooseVideo:ok', + tempFilePath: tempFilePath + }; + result.size = videoInfo.size; + result.duration = videoInfo.duration; + result.width = videoInfo.width; + result.height = videoInfo.height; + invoke$1(callbackId, result); + }, + fail: errorCallback + }); } - } - - const enterOptions = createLaunchOptions(); - const launchOptions = createLaunchOptions(); - function getLaunchOptions () { - return launchOptions - } - - function getEnterOptions () { - return enterOptions - } - - function initEnterOptions ({ - path, - query, - referrerInfo - }) { - extend(enterOptions, { - path, - query: query ? parseQuery(query) : {}, - referrerInfo: referrerInfo || {} - }); - } + function openAlbum () { + plus.gallery.pick(({ files }) => successCallback(files[0]), errorCallback, { + filter: 'video', + system: false, + // 不启用 multiple 时 system 无效 + multiple: true, + maximum: 1, + filename: TEMP_PATH + '/gallery/', + permissionAlert: true, + videoCompress: compressed + }); + } - function initLaunchOptions ({ - path, - query, - referrerInfo - }) { - extend(launchOptions, { - path, - query: query ? parseQuery(query) : {}, - referrerInfo: referrerInfo || {}, - channel: plus.runtime.channel, - launcher: plus.runtime.launcher - }); - extend(enterOptions, launchOptions); - return launchOptions - } + function openCamera () { + const plusCamera = plus.camera.getCamera(); + plusCamera.startVideoCapture(successCallback, errorCallback, { + index: camera === 'front' ? 2 : 1, + videoMaximumDuration: maxDuration, + filename: TEMP_PATH + '/camera/', + videoCompress: compressed + }); + } - 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 + if (sourceType.length === 1) { + if (sourceType.includes('album')) { + openAlbum(); + return + } else if (sourceType.includes('camera')) { + openCamera(); + return } } + plus.nativeUI.actionSheet({ + cancel: t('uni.chooseVideo.cancel'), + buttons: [{ + title: t('uni.chooseVideo.sourceType.camera') + }, { + title: t('uni.chooseVideo.sourceType.album') + }] + }, e => { + switch (e.index) { + case 1: + openCamera(); + break + case 2: + openAlbum(); + break + default: + errorCallback(); + break + } + }); } - function getLaunchOptionsSync () { - return getLaunchOptions() + function compressImage$1 (options, callbackId) { + const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; + const errorCallback = warpPlusErrorCallback(callbackId, 'compressImage'); + plus.zip.compressImage(Object.assign({}, options, { + dst + }), () => { + invoke$1(callbackId, { + errMsg: 'compressImage:ok', + tempFilePath: dst + }); + }, errorCallback); } - function getEnterOptionsSync () { - return getEnterOptions() + + function compressVideo$1 (options, callbackId) { + const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; + const successCallback = warpPlusSuccessCallback(callbackId, 'compressVideo'); + const errorCallback = warpPlusErrorCallback(callbackId, 'compressVideo'); + plus.zip.compressVideo(Object.assign({}, options, { + filename + }), successCallback, errorCallback); } - const VD_SYNC_VERSION = 2; - - const PAGE_CREATE = 2; - const MOUNTED_DATA = 4; - const UPDATED_DATA = 6; - const PAGE_CREATED = 10; + const getImageInfo$1 = warpPlusMethod('io', 'getImageInfo', options => { + options.savePath = options.filename = TEMP_PATH + '/download/'; + return options + }); + + const getVideoInfo$1 = warpPlusMethod('io', 'getVideoInfo', options => { + options.filePath = options.src; + return options + }, data => { + return { + orientation: data.orientation, + type: data.type, + duration: data.duration, + size: data.size / 1024, + height: data.height, + width: data.width, + fps: data.fps || 30, + bitrate: data.bitrate + } + }); + + function previewImagePlus ({ + current = 0, + background = '#000000', + indicator = 'number', + loop = false, + urls, + longPressActions + } = {}) { + urls = urls.map(url => getRealPath$1(url)); - const UI_EVENT = 20; + const index = Number(current); + if (isNaN(index)) { + current = urls.indexOf(getRealPath$1(current)); + current = current < 0 ? 0 : current; + } else { + current = index; + } - const VD_SYNC = 'vdSync'; + plus.nativeUI.previewImage(urls, { + current, + background, + indicator, + loop, + onLongPress: function (res) { + let itemList = []; + let itemColor = ''; + let title = ''; + const hasLongPressActions = longPressActions && longPressActions.callbackId; + if (!hasLongPressActions) { + itemList = [t('uni.previewImage.button.save')]; + itemColor = '#000000'; + title = ''; + } else { + itemList = longPressActions.itemList ? longPressActions.itemList : []; + itemColor = longPressActions.itemColor ? longPressActions.itemColor : '#000000'; + title = longPressActions.title ? longPressActions.title : ''; + } - const WEBVIEW_READY = 'webviewReady'; - const VD_SYNC_CALLBACK = 'vdSyncCallback'; - const INVOKE_API = 'invokeApi'; - const WEB_INVOKE_APPSERVICE$1 = 'WEB_INVOKE_APPSERVICE'; - const WEBVIEW_INSERTED = 'webviewInserted'; - const WEBVIEW_REMOVED = 'webviewRemoved'; - const WEBVIEW_ID_PREFIX = 'webviewId'; - - function createButtonOnClick (index) { - return function onClick (btn) { - const pages = getCurrentPages(); - if (!pages.length) { - return + const options = { + buttons: itemList.map(item => ({ + title: item, + color: itemColor + })), + cancel: t('uni.previewImage.cancel') + }; + if (title) { + options.title = title; + } + plus.nativeUI.actionSheet(options, (e) => { + if (e.index > 0) { + if (hasLongPressActions) { + publish(longPressActions.callbackId, { + errMsg: 'showActionSheet:ok', + tapIndex: e.index - 1, + index: res.index + }); + return + } + plus.gallery.save(res.url, function (GallerySaveEvent) { + plus.nativeUI.toast(t('uni.previewImage.save.success')); + }, function () { + plus.nativeUI.toast(t('uni.previewImage.save.fail')); + }); + } else if (hasLongPressActions) { + publish(longPressActions.callbackId, { + errMsg: 'showActionSheet:fail cancel' + }); + } + }); } - btn.index = index; - const page = pages[pages.length - 1]; - page.$vm && - page.$vm.__call_hook && - page.$vm.__call_hook('onNavigationBarButtonTap', btn); + }); + return { + errMsg: 'previewImage:ok' } } - function parseTitleNViewButtons (titleNView) { - const buttons = titleNView.buttons; - if (!Array.isArray(buttons)) { - return titleNView + function closePreviewImagePlus () { + try { + plus.nativeUI.closePreviewImage(); + return { + errMsg: 'closePreviewImagePlus:ok' + } + } catch (error) { + return { + errMsg: 'closePreviewImagePlus:fail' + } } - buttons.forEach((btn, index) => { - btn.onclick = createButtonOnClick(index); - }); - return titleNView - } - - function parseTitleNView (id, routeOptions) { - const windowOptions = routeOptions.window; - const titleNView = windowOptions.titleNView; - routeOptions.meta.statusBarStyle = - windowOptions.navigationBarTextStyle === 'black' ? 'dark' : 'light'; - if ( - // 无头 - titleNView === false || - titleNView === 'false' || - (windowOptions.navigationStyle === 'custom' && - !isPlainObject(titleNView)) || - (windowOptions.transparentTitle === 'always' && !isPlainObject(titleNView)) - ) { - return false - } - - const titleImage = windowOptions.titleImage || ''; - const transparentTitle = windowOptions.transparentTitle || 'none'; - const titleNViewTypeList = { - none: 'default', - auto: 'transparent', - always: 'float' - }; - - const navigationBarBackgroundColor = - windowOptions.navigationBarBackgroundColor; - const ret = { - autoBackButton: !routeOptions.meta.isQuit, - titleText: - titleImage === '' ? windowOptions.navigationBarTitleText || '' : '', - titleColor: - windowOptions.navigationBarTextStyle === 'black' ? '#000000' : '#ffffff', - type: titleNViewTypeList[transparentTitle], - backgroundColor: - /^#[a-z0-9]{6}$/i.test(navigationBarBackgroundColor) || - navigationBarBackgroundColor === 'transparent' - ? navigationBarBackgroundColor - : '#f7f7f7', - tags: - titleImage === '' - ? [] - : [ - { - tag: 'img', - src: titleImage, - position: { - left: 'auto', - top: 'auto', - width: 'auto', - height: '26px' - } - } - ] - }; - - if (isPlainObject(titleNView)) { - return initTitleNViewI18n( - id, - Object.assign(ret, parseTitleNViewButtons(titleNView)) - ) - } - return initTitleNViewI18n(id, ret) - } - - function initTitleNViewI18n (id, titleNView) { - const i18nResult = initNavigationBarI18n(titleNView); - if (!i18nResult) { - return titleNView - } - const [titleTextI18n, searchInputPlaceholderI18n] = i18nResult; - if (titleTextI18n || searchInputPlaceholderI18n) { - uni.onLocaleChange(() => { - const webview = plus.webview.getWebviewById(id + ''); - if (!webview) { - return - } - const newTitleNView = {}; - if (titleTextI18n) { - newTitleNView.titleText = titleNView.titleText; - } - if (searchInputPlaceholderI18n) { - newTitleNView.searchInput = { - placeholder: titleNView.searchInput.placeholder - }; - } - if (process.env.NODE_ENV !== 'production') { - console.log('[uni-app] updateWebview', webview.id, newTitleNView); - } - webview.setStyle({ - titleNView: newTitleNView - }); - }); - } - return titleNView } - function parsePullToRefresh (routeOptions) { - const windowOptions = routeOptions.window; + let recorder$1; + let recordTimeout$1; - if (windowOptions.enablePullDownRefresh || (windowOptions.pullToRefresh && windowOptions.pullToRefresh.support)) { - const pullToRefreshStyles = Object.create(null); - // 初始化默认值 - if (plus.os.name === 'Android') { - Object.assign(pullToRefreshStyles, { - support: true, - style: 'circle' - }); - } else { - Object.assign(pullToRefreshStyles, { - support: true, - style: 'default', - height: '50px', - range: '200px', - contentdown: { - caption: '' - }, - contentover: { - caption: '' - }, - contentrefresh: { - caption: '' - } + const publishRecorderStateChange = (state, res = {}) => { + publish('onRecorderStateChange', Object.assign({ + state + }, res)); + }; + + const Recorder = { + start ({ + duration = 60000, + sampleRate, + numberOfChannels, + encodeBitRate, + format = 'mp3', + frameSize, + audioSource = 'auto' + }, callbackId) { + if (recorder$1) { + return publishRecorderStateChange('start') + } + recorder$1 = plus.audio.getRecorder(); + recorder$1.record({ + format, + samplerate: sampleRate, + filename: TEMP_PATH + '/recorder/' + }, res => publishRecorderStateChange('stop', { + tempFilePath: res + }), err => publishRecorderStateChange('error', { + errMsg: err.message + })); + recordTimeout$1 = setTimeout(() => { + Recorder.stop(); + }, duration); + publishRecorderStateChange('start'); + }, + stop () { + if (recorder$1) { + recorder$1.stop(); + recorder$1 = false; + recordTimeout$1 && clearTimeout(recordTimeout$1); + } + }, + pause () { + if (recorder$1) { + publishRecorderStateChange('error', { + errMsg: 'Unsupported operation: pause' }); } - - if (windowOptions.backgroundTextStyle) { - pullToRefreshStyles.color = windowOptions.backgroundTextStyle; - pullToRefreshStyles.snowColor = windowOptions.backgroundTextStyle; + }, + resume () { + if (recorder$1) { + publishRecorderStateChange('error', { + errMsg: 'Unsupported operation: resume' + }); } + } + }; - Object.assign(pullToRefreshStyles, windowOptions.pullToRefresh || {}); - - return pullToRefreshStyles + function operateRecorder ({ + operationType, + ...args + }, callbackId) { + Recorder[operationType](args); + return { + errMsg: 'operateRecorder:ok' } } - const REGEX_UPX = /(\d+(\.\d+)?)[r|u]px/g; - - function transformCSS (css) { - return css.replace(REGEX_UPX, (a, b) => { - return uni.upx2px(parseInt(b) || 0) + 'px' - }) + function saveImageToPhotosAlbum$1 ({ + filePath + } = {}, callbackId) { + const successCallback = warpPlusSuccessCallback(callbackId, 'saveImageToPhotosAlbum'); + const errorCallback = warpPlusErrorCallback(callbackId, 'saveImageToPhotosAlbum'); + plus.gallery.save(getRealPath$1(filePath), successCallback, errorCallback); } - function parseStyleUnit (styles) { - let newStyles = {}; - const stylesStr = JSON.stringify(styles); - if (~stylesStr.indexOf('upx') || ~stylesStr.indexOf('rpx')) { - try { - newStyles = JSON.parse(transformCSS(stylesStr)); - } catch (e) { - newStyles = styles; - console.error(e); - } - } else { - newStyles = JSON.parse(stylesStr); - } - - return newStyles + function saveVideoToPhotosAlbum ({ + filePath + } = {}, callbackId) { + plus.gallery.save(getRealPath$1(filePath), e => { + invoke$1(callbackId, { + errMsg: 'saveVideoToPhotosAlbum:ok' + }); + }, e => { + invoke$1(callbackId, { + errMsg: 'saveVideoToPhotosAlbum:fail' + }); + }); } - const WEBVIEW_STYLE_BLACKLIST = [ - 'navigationBarBackgroundColor', - 'navigationBarTextStyle', - 'navigationBarTitleText', - 'navigationBarShadow', - 'navigationStyle', - 'disableScroll', - 'backgroundColor', - 'backgroundTextStyle', - 'enablePullDownRefresh', - 'onReachBottomDistance', - 'usingComponents', - // 需要解析的 - 'titleNView', - 'pullToRefresh' - ]; - - function parseWebviewStyle (id, path, _routeOptions = {}) { - const webviewStyle = { - bounce: 'vertical' - }; + let downloadTaskId = 0; + const downloadTasks = {}; - // 合并 - _routeOptions.window = parseStyleUnit( - Object.assign( - JSON.parse(JSON.stringify(__uniConfig.window || {})), - _routeOptions.window || {} - ) - ); + const publishStateChange = (res) => { + publish('onDownloadTaskStateChange', res); + }; - Object.keys(_routeOptions.window).forEach(name => { - if (WEBVIEW_STYLE_BLACKLIST.indexOf(name) === -1) { - webviewStyle[name] = _routeOptions.window[name]; + const createDownloadTaskById = function (downloadTaskId, { + url, + header, + timeout + } = {}) { + timeout = (timeout || (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000) / 1000; + const downloader = plus.downloader.createDownload(url, { + timeout, + filename: TEMP_PATH + '/download/', + // 需要与其它平台上的表现保持一致,不走重试的逻辑。 + retry: 0, + retryInterval: 0 + }, (download, statusCode) => { + if (statusCode) { + publishStateChange({ + downloadTaskId, + state: 'success', + tempFilePath: download.filename, + statusCode + }); + } else { + publishStateChange({ + downloadTaskId, + state: 'fail', + statusCode + }); } }); - - const routeOptions = parseTheme(_routeOptions); - - const backgroundColor = routeOptions.window.backgroundColor; - if ( - /^#[a-z0-9]{6}$/i.test(backgroundColor) || - backgroundColor === 'transparent' - ) { - if (!webviewStyle.background) { - webviewStyle.background = backgroundColor; - } - if (!webviewStyle.backgroundColorTop) { - webviewStyle.backgroundColorTop = backgroundColor; - } - if (!webviewStyle.backgroundColorBottom) { - webviewStyle.backgroundColorBottom = backgroundColor; - } - if (!webviewStyle.animationAlphaBGColor) { - webviewStyle.animationAlphaBGColor = backgroundColor; + for (const name in header) { + if (hasOwn(header, name)) { + downloader.setRequestHeader(name, header[name]); } - if (typeof webviewStyle.webviewBGTransparent === 'undefined') { - webviewStyle.webviewBGTransparent = true; + } + downloader.addEventListener('statechanged', (download, status) => { + if (download.downloadedSize && download.totalSize) { + publishStateChange({ + downloadTaskId, + state: 'progressUpdate', + progress: parseInt(download.downloadedSize / download.totalSize * 100), + totalBytesWritten: download.downloadedSize, + totalBytesExpectedToWrite: download.totalSize + }); } + }); + downloadTasks[downloadTaskId] = downloader; + downloader.start(); + return { + downloadTaskId, + errMsg: 'createDownloadTask:ok' } + }; - const titleNView = parseTitleNView(id, routeOptions); - if (titleNView) { - if ( - id === 1 && - __uniConfig.realEntryPagePath && - !routeOptions.meta.isQuit // 可能是tabBar - ) { - titleNView.autoBackButton = true; + function operateDownloadTask ({ + downloadTaskId, + operationType + } = {}) { + const downloadTask = downloadTasks[downloadTaskId]; + if (downloadTask && operationType === 'abort') { + delete downloadTasks[downloadTaskId]; + downloadTask.abort(); + publishStateChange({ + downloadTaskId, + state: 'fail', + errMsg: 'abort' + }); + return { + errMsg: 'operateDownloadTask:ok' } - webviewStyle.titleNView = titleNView; } + return { + errMsg: 'operateDownloadTask:fail' + } + } - const pullToRefresh = parsePullToRefresh(routeOptions); - if (pullToRefresh) { - if (pullToRefresh.style === 'circle') { - webviewStyle.bounce = 'none'; + function createDownloadTask (args) { + return createDownloadTaskById(++downloadTaskId, args) + } + + let requestTaskId = 0; + const requestTasks = {}; + + const publishStateChange$1 = res => { + publish('onRequestTaskStateChange', res); + delete requestTasks[requestTaskId]; + }; + + const cookiesParse = header => { + let cookiesStr = header['Set-Cookie'] || header['set-cookie']; + let cookiesArr = []; + if (!cookiesStr) { + return [] + } + if (cookiesStr[0] === '[' && cookiesStr[cookiesStr.length - 1] === ']') { + cookiesStr = cookiesStr.slice(1, -1); + } + const handleCookiesArr = cookiesStr.split(';'); + for (let i = 0; i < handleCookiesArr.length; i++) { + if (handleCookiesArr[i].indexOf('Expires=') !== -1 || handleCookiesArr[i].indexOf('expires=') !== -1) { + cookiesArr.push(handleCookiesArr[i].replace(',', '')); + } else { + cookiesArr.push(handleCookiesArr[i]); } - webviewStyle.pullToRefresh = pullToRefresh; } + cookiesArr = cookiesArr.join(';').split(','); - // 不支持 hide - if (webviewStyle.popGesture === 'hide') { - delete webviewStyle.popGesture; - } + return cookiesArr + }; - if (routeOptions.meta.isQuit) { - // 退出 - webviewStyle.popGesture = plus.os.name === 'iOS' ? 'appback' : 'none'; - } + function createRequestTaskById (requestTaskId, { + url, + data, + header, + method = 'GET', + responseType, + sslVerify = true, + firstIpv4 = false, + tls, + timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000 + } = {}) { + const stream = requireNativePlugin('stream'); + const headers = {}; - // TODO 下拉刷新 + let abortTimeout; + let aborted; + let hasContentType = false; + for (const name in header) { + if (!hasContentType && name.toLowerCase() === 'content-type') { + hasContentType = true; + headers['Content-Type'] = header[name]; + // TODO 需要重构 + if (method !== 'GET' && header[name].indexOf('application/x-www-form-urlencoded') === 0 && typeof data !== + 'string' && !(data instanceof ArrayBuffer)) { + const bodyArray = []; + for (const key in data) { + if (hasOwn(data, key)) { + bodyArray.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); + } + } + data = bodyArray.join('&'); + } + } else { + headers[name] = header[name]; + } + } - if (path && routeOptions.meta.isNVue) { - webviewStyle.uniNView = { - path, - defaultFontSize: __uniConfig.defaultFontSize, - viewport: __uniConfig.viewport - }; + if (!hasContentType && method === 'POST') { + headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; } - return webviewStyle - } - - function backbuttonListener () { - uni.navigateBack({ - from: 'backbutton' - }); - } - - function initPopupSubNVue (subNVueWebview, style, maskWebview) { - if (!maskWebview.popupSubNVueWebviews) { - maskWebview.popupSubNVueWebviews = {}; - } - - maskWebview.popupSubNVueWebviews[subNVueWebview.id] = subNVueWebview; - - if (process.env.NODE_ENV !== 'production') { - console.log( - `UNIAPP[webview][${maskWebview.id}]:add.popupSubNVueWebview[${subNVueWebview.id}]` - ); - } - - const hideSubNVue = function () { - maskWebview.setStyle({ - mask: 'none' - }); - subNVueWebview.hide('auto'); - }; - maskWebview.addEventListener('maskClick', hideSubNVue); - let isRemoved = false; // 增加个 remove 标记,防止出错 - subNVueWebview.addEventListener('show', () => { - if (!isRemoved) { - plus.key.removeEventListener('backbutton', backbuttonListener); - plus.key.addEventListener('backbutton', hideSubNVue); - isRemoved = true; - } - }); - subNVueWebview.addEventListener('hide', () => { - if (isRemoved) { - plus.key.removeEventListener('backbutton', hideSubNVue); - plus.key.addEventListener('backbutton', backbuttonListener); - isRemoved = false; - } - }); - subNVueWebview.addEventListener('close', () => { - delete maskWebview.popupSubNVueWebviews[subNVueWebview.id]; - if (isRemoved) { - plus.key.removeEventListener('backbutton', hideSubNVue); - plus.key.addEventListener('backbutton', backbuttonListener); - isRemoved = false; - } - }); - } - - function initNormalSubNVue (subNVueWebview, style, webview) { - webview.append(subNVueWebview); - } - - function initSubNVue (subNVue, routeOptions, webview) { - if (!subNVue.path) { - return - } - const style = subNVue.style || {}; - const isNavigationBar = subNVue.type === 'navigationBar'; - const isPopup = subNVue.type === 'popup'; - - delete style.type; - - if (isPopup && !subNVue.id) { - console.warn('subNVue[' + subNVue.path + '] is missing id'); - } - // TODO lazyload - - style.uniNView = { - path: subNVue.path.replace('.nvue', '.js'), - defaultFontSize: __uniConfig.defaultFontSize, - viewport: __uniConfig.viewport - }; - - const extras = { - __uniapp_host: routeOptions.path, - __uniapp_origin: style.uniNView.path.split('?')[0].replace('.js', ''), - __uniapp_origin_id: webview.id, - __uniapp_origin_type: webview.__uniapp_type - }; - - let maskWebview; - - if (isNavigationBar) { - style.position = 'dock'; - style.dock = 'top'; - style.top = 0; - style.width = '100%'; - style.height = NAVBAR_HEIGHT + getStatusbarHeight(); - delete style.left; - delete style.right; - delete style.bottom; - delete style.margin; - } else if (isPopup) { - style.position = 'absolute'; - if (isTabBarPage(routeOptions.path)) { - maskWebview = tabBar$1; - } else { - maskWebview = webview; - } - extras.__uniapp_mask = style.mask || 'rgba(0,0,0,0.5)'; - extras.__uniapp_mask_id = maskWebview.id; - } - - if (process.env.NODE_ENV !== 'production') { - console.log( - `UNIAPP[webview][${webview.id}]:create[${subNVue.id}]:${JSON.stringify(style)}` - ); - } - delete style.mask; - const subNVueWebview = plus.webview.create('', subNVue.id, style, extras); - - if (isPopup) { - initPopupSubNVue(subNVueWebview, style, maskWebview); - } else { - initNormalSubNVue(subNVueWebview, style, webview); - } + if (timeout) { + abortTimeout = setTimeout(() => { + aborted = true; + publishStateChange$1({ + requestTaskId, + state: 'fail', + statusCode: 0, + errMsg: 'timeout' + }); + }, (timeout + 200)); // TODO +200 发消息到原生层有时间开销,以后考虑由原生层回调超时 + } + const options = { + method, + url: url.trim(), + // weex 官方文档有误,headers 类型实际 object,用 string 类型会无响应 + headers, + type: responseType === 'arraybuffer' ? 'base64' : 'text', + // weex 官方文档未说明实际支持 timeout,单位:ms + timeout: timeout || 6e5, + // 配置和weex模块内相反 + sslVerify: !sslVerify, + firstIpv4: firstIpv4, + tls + }; + let withArrayBuffer; + if (method !== 'GET') { + if (toString.call(data) === '[object ArrayBuffer]') { + withArrayBuffer = true; + } else { + options.body = typeof data === 'string' ? data : JSON.stringify(data); + } + } + const callback = ({ + ok, + status, + data, + headers, + errorMsg + }) => { + if (aborted) { + return + } + if (abortTimeout) { + clearTimeout(abortTimeout); + } + const statusCode = status; + if (statusCode > 0) { + publishStateChange$1({ + requestTaskId, + state: 'success', + data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer$2(data) : data, + statusCode, + header: headers, + cookies: cookiesParse(headers) + }); + } else { + let errMsg = 'abort statusCode:' + statusCode; + if (errorMsg) { + errMsg = errMsg + ' ' + errorMsg; + } + publishStateChange$1({ + requestTaskId, + state: 'fail', + statusCode, + errMsg + }); + } + }; + try { + if (withArrayBuffer) { + stream.fetchWithArrayBuffer({ + '@type': 'binary', + base64: arrayBufferToBase64$2(data) + }, options, callback); + } else { + stream.fetch(options, callback); + } + requestTasks[requestTaskId] = { + abort () { + aborted = true; + if (abortTimeout) { + clearTimeout(abortTimeout); + } + publishStateChange$1({ + requestTaskId, + state: 'fail', + statusCode: 0, + errMsg: 'abort' + }); + } + }; + } catch (e) { + return { + requestTaskId, + errMsg: 'createRequestTask:fail' + } + } + return { + requestTaskId, + errMsg: 'createRequestTask:ok' + } + } + + function createRequestTask (args) { + return createRequestTaskById(++requestTaskId, args) + } + + function operateRequestTask ({ + requestTaskId, + operationType + } = {}) { + const requestTask = requestTasks[requestTaskId]; + if (requestTask && operationType === 'abort') { + requestTask.abort(); + return { + errMsg: 'operateRequestTask:ok' + } + } + return { + errMsg: 'operateRequestTask:fail' + } + } + + function configMTLS$1 ({ certificates }, callbackId) { + const stream = requireNativePlugin('stream'); + stream.configMTLS(certificates, ({ type, code, message }) => { + switch (type) { + case 'success': + invoke$1(callbackId, { + errMsg: 'configMTLS:ok', + code + }); + break + case 'fail': + invoke$1(callbackId, { + errMsg: 'configMTLS:fail ' + message, + code + }); + break + } + }); } - function initSubNVues (routeOptions, webview) { - const subNVues = routeOptions.window.subNVues; - if (!subNVues || !subNVues.length) { - return - } - subNVues.forEach(subNVue => { - initSubNVue(subNVue, routeOptions, webview); - }); + const socketTasks = {}; + + const publishStateChange$2 = (res) => { + publish('onSocketTaskStateChange', res); + }; + + let socket; + function getSocket () { + if (socket) { + return socket + } + socket = requireNativePlugin('uni-webSocket'); + socket.onopen(function (e) { + publishStateChange$2({ + socketTaskId: e.id, + state: 'open' + }); + }); + socket.onmessage(function (e) { + const data = e.data; + publishStateChange$2({ + socketTaskId: e.id, + state: 'message', + data: typeof data === 'object' ? base64ToArrayBuffer$2(data.base64) : data + }); + }); + socket.onerror(function (e) { + publishStateChange$2({ + socketTaskId: e.id, + state: 'error', + errMsg: e.data + }); + }); + socket.onclose(function (e) { + const socketTaskId = e.id; + delete socketTasks[socketTaskId]; + publishStateChange$2({ + socketTaskId, + state: 'close' + }); + }); + return socket + } + + const createSocketTaskById = function (socketTaskId, { + url, + data, + header, + method, + protocols + } = {}) { + const socket = getSocket(); + socket.WebSocket({ + id: socketTaskId, + url, + protocol: Array.isArray(protocols) ? protocols.join(',') : protocols, + header + }); + socketTasks[socketTaskId] = socket; + return { + socketTaskId, + errMsg: 'createSocketTask:ok' + } + }; + + function createSocketTask (args) { + return createSocketTaskById(String(Date.now()), args) + } + + function operateSocketTask (args) { + const { + operationType, + code, + reason, + data, + socketTaskId + } = unpack(args); + const socket = socketTasks[socketTaskId]; + if (!socket) { + return { + errMsg: 'operateSocketTask:fail' + } + } + switch (operationType) { + case 'send': + if (data) { + socket.send({ + id: socketTaskId, + data: typeof data === 'object' ? { + '@type': 'binary', + base64: arrayBufferToBase64$2(data) + } : data + }); + } + return { + errMsg: 'operateSocketTask:ok' + } + case 'close': + socket.close({ + id: socketTaskId, + code, + reason + }); + delete socketTasks[socketTaskId]; + return { + errMsg: 'operateSocketTask:ok' + } + } + return { + errMsg: 'operateSocketTask:fail' + } } - function onWebviewClose (webview) { - webview.popupSubNVueWebviews && webview.addEventListener('close', () => { - Object.keys(webview.popupSubNVueWebviews).forEach(id => { - if (process.env.NODE_ENV !== 'production') { - console.log( - `UNIAPP[webview][${webview.id}]:popupSubNVueWebview[${id}].close` - ); - } - webview.popupSubNVueWebviews[id].close('none'); + let uploadTaskId = 0; + const uploadTasks = {}; + + const publishStateChange$3 = (res) => { + publish('onUploadTaskStateChange', res); + }; + + const createUploadTaskById = function (uploadTaskId, { + url, + filePath, + name, + files, + header, + formData, + timeout = __uniConfig.networkTimeout.uploadFile ? __uniConfig.networkTimeout.uploadFile / 1000 : 120 + } = {}) { + const uploader = plus.uploader.createUpload(url, { + timeout, + // 需要与其它平台上的表现保持一致,不走重试的逻辑。 + retry: 0, + retryInterval: 0 + }, (upload, statusCode) => { + if (statusCode) { + publishStateChange$3({ + uploadTaskId, + state: 'success', + data: upload.responseText, + statusCode + }); + } else { + publishStateChange$3({ + uploadTaskId, + state: 'fail', + data: '', + statusCode + }); + } + delete uploadTasks[uploadTaskId]; + }); + + for (const name in header) { + if (hasOwn(header, name)) { + uploader.setRequestHeader(name, String(header[name])); + } + } + for (const name in formData) { + if (hasOwn(formData, name)) { + uploader.addData(name, String(formData[name])); + } + } + if (files && files.length) { + files.forEach(file => { + uploader.addFile(getRealPath$1(file.uri || file.filePath), { + key: file.name || 'file' + }); + }); + } else { + uploader.addFile(getRealPath$1(filePath), { + key: name }); + } + uploader.addEventListener('statechanged', (upload, status) => { + if (upload.uploadedSize && upload.totalSize) { + publishStateChange$3({ + uploadTaskId, + state: 'progressUpdate', + progress: parseInt(upload.uploadedSize / upload.totalSize * 100), + totalBytesSent: upload.uploadedSize, + totalBytesExpectedToSend: upload.totalSize + }); + } }); + uploadTasks[uploadTaskId] = uploader; + uploader.start(); + return { + uploadTaskId, + errMsg: 'createUploadTask:ok' + } + }; + + function operateUploadTask ({ + uploadTaskId, + operationType + } = {}) { + const uploadTask = uploadTasks[uploadTaskId]; + if (uploadTask && operationType === 'abort') { + delete uploadTasks[uploadTaskId]; + uploadTask.abort(); + publishStateChange$3({ + uploadTaskId, + state: 'fail', + errMsg: 'abort' + }); + return { + errMsg: 'operateUploadTask:ok' + } + } + return { + errMsg: 'operateUploadTask:fail' + } + } + + function createUploadTask (args) { + return createUploadTaskById(++uploadTaskId, args) } - function onWebviewResize (webview) { - const onResize = function ({ - width, - height - }) { - const landscape = Math.abs(plus.navigator.getOrientation()) === 90; - const res = { - deviceOrientation: landscape ? 'landscape' : 'portrait', - size: { - windowWidth: Math.ceil(width), - windowHeight: Math.ceil(height) + const providers = { + oauth (callback) { + plus.oauth.getServices(services => { + const provider = []; + services.forEach(({ + id + }) => { + provider.push(id); + }); + callback(null, provider, services); + }, err => { + callback(err); + }); + }, + share (callback) { + plus.share.getServices(services => { + const provider = []; + services.forEach(({ + id + }) => { + provider.push(id); + }); + callback(null, provider, services); + }, err => { + callback(err); + }); + }, + payment (callback) { + plus.payment.getChannels(services => { + const provider = []; + services.forEach(({ + id + }) => { + provider.push(id); + }); + callback(null, provider, services); + }, err => { + callback(err); + }); + }, + push (callback) { + if (typeof weex !== 'undefined' || typeof plus !== 'undefined') { + const clientInfo = plus.push.getClientInfo(); + callback(null, [clientInfo.id], [clientInfo]); + } else { + callback(null, []); + } + } + }; + + function getProvider$1 ({ + service + }, callbackId) { + if (providers[service]) { + providers[service]((err, provider, providers) => { + if (err) { + invoke$1(callbackId, { + errMsg: 'getProvider:fail ' + err.message + }); + } else { + invoke$1(callbackId, { + errMsg: 'getProvider:ok', + service, + provider, + providers: providers.map((provider) => { + if (typeof provider.serviceReady === 'boolean') { + provider.isAppExist = provider.serviceReady; + } + if (typeof provider.nativeClient === 'boolean') { + provider.isAppExist = provider.nativeClient; + } + return provider + }) + }); } - }; - publish('onViewDidResize', res); // API - UniServiceJSBridge.emit('onResize', res, parseInt(webview.id)); // Page lifecycle - }; - webview.addEventListener('resize', debounce(onResize, 50)); + }); + } else { + invoke$1(callbackId, { + errMsg: 'getProvider:fail service not found' + }); + } } - function onWebviewRecovery (webview, routeOptions) { - const { - subscribe, - unsubscribe - } = UniServiceJSBridge; + let univerifyManager; - const id = webview.id; - const onWebviewRecoveryReady = function (data, pageId) { - if (id !== pageId) { - return - } - unsubscribe(WEBVIEW_READY, onWebviewRecoveryReady); - if (process.env.NODE_ENV !== 'production') { - console.log(`UNIAPP[webview][${id}]:onWebviewRecoveryReady ready`); + function getService (provider) { + return new Promise((resolve, reject) => { + plus.oauth.getServices(services => { + const service = services.find(({ id }) => id === provider); + service ? resolve(service) : reject(new Error('provider not find')); + }, reject); + }) + } + + /** + * 微信登录 + */ + function login (params, callbackId, plus = true) { + const provider = params.provider || 'weixin'; + const errorCallback = warpErrorCallback(callbackId, 'login', plus); + const isAppleLogin = provider === 'apple'; + const authOptions = isAppleLogin + ? { scope: 'email' } + : params.univerifyStyle + ? { univerifyStyle: univerifyButtonsClickHandling(params.univerifyStyle, errorCallback) } + : {}; + const _invoke = plus ? invoke$1 : callback.invoke; + + getService(provider).then(service => { + function login () { + if (params.onlyAuthorize && provider === 'weixin') { + service.authorize(({ code }) => { + _invoke(callbackId, { + code, + authResult: '', + errMsg: 'login:ok' + }); + }, errorCallback); + return + } + service.login(res => { + const authResult = res.target.authResult; + const appleInfo = res.target.appleInfo; + _invoke(callbackId, { + code: authResult.code, + authResult: authResult, + appleInfo, + errMsg: 'login:ok' + }); + }, errorCallback, authOptions); } - // 恢复目标页面 - pageId = parseInt(pageId); - const page = getCurrentPages(true).find(page => page.$page.id === pageId); - if (!page) { - return console.error(`Page[${pageId}] not found`) + // 先注销再登录 + // apple登录logout之后无法重新触发获取email,fullname;一键登录无logout + if (isAppleLogin || provider === 'univerify') { + login(); + } else { + service.logout(login, login); } - page.$vm._$vd.restore(); - }; + }).catch(errorCallback); + } - webview.addEventListener('recovery', e => { - if (process.env.NODE_ENV !== 'production') { - console.log(`UNIAPP[webview][${this.id}].recovery.reload:` + JSON.stringify({ - path: routeOptions.path, - webviewId: id - })); - } - subscribe(WEBVIEW_READY, onWebviewRecoveryReady); - }); - } - - function onWebviewPopGesture (webview) { - let popStartStatusBarStyle; - webview.addEventListener('popGesture', e => { - if (e.type === 'start') { - // 设置下一个页面的 statusBarStyle - const pages = getCurrentPages(); - const page = pages[pages.length - 2]; - popStartStatusBarStyle = lastStatusBarStyle; - const statusBarStyle = page && page.$page.meta.statusBarStyle; - statusBarStyle && setStatusBarStyle(statusBarStyle); - } else if (e.type === 'end' && !e.result) { - // 拖拽未完成,设置为当前状态栏前景色 - setStatusBarStyle(popStartStatusBarStyle); - } else if (e.type === 'end' && e.result) { - const pages = getCurrentPages(); - const len = pages.length; - const page = pages[pages.length - 1]; - page && page.$remove(); - setStatusBarStyle(); - // 仅当存在一个页面,且是直达页面时,才 reLaunch 首页 - if (page && len === 1 && isDirectPage(page)) { - reLaunchEntryPage(); + function getUserInfo (params, callbackId) { + const provider = params.provider || 'weixin'; + const errorCallback = warpPlusErrorCallback(callbackId, 'operateWXData'); + getService(provider).then(loginService => { + loginService.getUserInfo(res => { + let userInfo; + if (provider === 'weixin') { + const wechatUserInfo = loginService.userInfo; + userInfo = { + openId: wechatUserInfo.openid, + nickName: wechatUserInfo.nickname, + gender: wechatUserInfo.sex, + city: wechatUserInfo.city, + province: wechatUserInfo.province, + country: wechatUserInfo.country, + avatarUrl: wechatUserInfo.headimgurl, + unionId: wechatUserInfo.unionid + }; + } else if (provider === 'apple') { + const appleInfo = loginService.appleInfo; + userInfo = { + openId: appleInfo.user, + fullName: appleInfo.fullName, + email: appleInfo.email, + authorizationCode: appleInfo.authorizationCode, + identityToken: appleInfo.identityToken, + realUserStatus: appleInfo.realUserStatus + }; } else { - UniServiceJSBridge.emit('onAppRoute', { - type: 'navigateBack' - }); + userInfo = loginService.userInfo; + userInfo.openId = userInfo.openId || userInfo.openid || loginService.authResult.openid; + userInfo.nickName = userInfo.nickName || userInfo.nickname; + userInfo.avatarUrl = userInfo.avatarUrl || userInfo.headimgurl; } - } + const result = { + errMsg: 'operateWXData:ok' + }; + if (params.data && params.data.api_name === 'webapi_getuserinfo') { + result.data = { + data: JSON.stringify(userInfo), + rawData: '', + signature: '', + encryptedData: '', + iv: '' + }; + } else { + result.userInfo = userInfo; + } + invoke$1(callbackId, result); + }, errorCallback); + }).catch(() => { + invoke$1(callbackId, { + errMsg: 'operateWXData:fail 请先调用 uni.login' + }); }); } - /** - * 是否处于直达页面 - * @param page - * @returns + * 获取用户信息-兼容 */ - function isDirectPage (page) { - return ( - __uniConfig.realEntryPagePath && - page.$page.route === __uniConfig.entryPagePath - ) + function getUserProfile (params, callbackId) { + return getUserInfo(params, callbackId) } + /** - * 重新启动到首页 + * 获取用户信息 */ - 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; - - const WEBVIEW_LISTENERS = { - pullToRefresh: 'onPullDownRefresh', - titleNViewSearchInputChanged: 'onNavigationBarSearchInputChanged', - titleNViewSearchInputConfirmed: 'onNavigationBarSearchInputConfirmed', - titleNViewSearchInputClicked: 'onNavigationBarSearchInputClicked', - titleNViewSearchInputFocusChanged: 'onNavigationBarSearchInputFocusChanged' - }; - - function setPreloadWebview (webview) { - preloadWebview = webview; - } - - function noop$1 (str) { - return str - } - - function getUniPageUrl (path, query) { - const queryString = query ? stringifyQuery(query, noop$1) : ''; - return { - path: path.substr(1), - query: queryString ? queryString.substr(1) : queryString + function operateWXData (params, callbackId) { + switch (params.data.api_name) { + case 'webapi_getuserinfo': + getUserInfo(params, callbackId); + break + default: + return { + errMsg: 'operateWXData:fail' + } } } - function getDebugRefresh (path, query, routeOptions) { - const queryString = query ? stringifyQuery(query, noop$1) : ''; - return { - isTab: routeOptions.meta.isTabBar, - arguments: JSON.stringify({ - path: path.substr(1), - query: queryString ? queryString.substr(1) : queryString - }) - } + function preLogin$1 (params, callbackId, plus) { + const successCallback = warpSuccessCallback(callbackId, 'preLogin', plus); + const errorCallback = warpErrorCallback(callbackId, 'preLogin', plus); + getService(params.provider).then(service => service.preLogin(successCallback, errorCallback)).catch(errorCallback); } - function createWebview (path, routeOptions, query, extras = {}) { - if (routeOptions.meta.isNVue) { - const getWebviewStyle = () => parseWebviewStyle( - webviewId, - path, - routeOptions - ); - const webviewId = id$1++; - const webviewStyle = getWebviewStyle(); - webviewStyle.uniPageUrl = getUniPageUrl(path, query); - if (process.env.NODE_ENV !== 'production') { - console.log('[uni-app] createWebview', webviewId, path, webviewStyle); - } - // android 需要使用 - webviewStyle.isTab = !!routeOptions.meta.isTabBar; - const webview = plus.webview.create('', String(webviewId), webviewStyle, Object.assign({ - nvue: true - }, extras)); - - useWebviewThemeChange(webview, getWebviewStyle); - - return webview - } - if (id$1 === 2) { // 如果首页非 nvue,则直接返回 Launch Webview - return plus.webview.getLaunchWebview() - } - const webview = preloadWebview; - return webview + function closeAuthView () { + return getService('univerify').then(service => service.closeAuthView()) } - function initWebview (webview, routeOptions, path, query) { - // 首页或非 nvue 页面 - if (webview.id === '1' || !routeOptions.meta.isNVue) { - const getWebviewStyle = () => parseWebviewStyle( - parseInt(webview.id), - '', - routeOptions - ); - const webviewStyle = getWebviewStyle(); - - webviewStyle.uniPageUrl = getUniPageUrl(path, query); - - if (!routeOptions.meta.isNVue) { - webviewStyle.debugRefresh = getDebugRefresh(path, query, routeOptions); - } else { - // android 需要使用 - webviewStyle.isTab = !!routeOptions.meta.isTabBar; - } - if (process.env.NODE_ENV !== 'production') { - console.log('[uni-app] updateWebview', webviewStyle); - } - - useWebviewThemeChange(webview, getWebviewStyle); - - webview.setStyle(webviewStyle); - } - - const { - on, - emit - } = UniServiceJSBridge; - - initSubNVues(routeOptions, webview); - - Object.keys(WEBVIEW_LISTENERS).forEach(name => { - webview.addEventListener(name, (e) => { - emit(WEBVIEW_LISTENERS[name], e, parseInt(webview.id)); + function getCheckBoxState (params, callbackId, plus) { + const successCallback = warpSuccessCallback(callbackId, 'getCheckBoxState', plus); + const errorCallback = warpErrorCallback(callbackId, 'getCheckBoxState', plus); + try { + getService('univerify').then(service => { + const state = service.getCheckBoxState(); + successCallback({ state }); }); - }); - - onWebviewClose(webview); - onWebviewResize(webview); + } catch (error) { + errorCallback(error); + } + } - if (plus.os.name === 'iOS') { - !webview.nvue && onWebviewRecovery(webview, routeOptions); - onWebviewPopGesture(webview); + /** + * 一键登录自定义登陆按钮点击处理 + */ + function univerifyButtonsClickHandling (univerifyStyle, errorCallback) { + if (isPlainObject(univerifyStyle) && isPlainObject(univerifyStyle.buttons) && toRawType(univerifyStyle.buttons.list) === 'Array') { + univerifyStyle.buttons.list.forEach((button, index) => { + univerifyStyle.buttons.list[index].onclick = function () { + const res = { + code: '30008', + message: '用户点击了自定义按钮', + index, + provider: button.provider + }; + isPlainObject(univerifyManager) + ? univerifyManager._triggerUniverifyButtonsClick(res) + : closeAuthView().then(() => { + errorCallback(res); + }); + }; + }); } + return univerifyStyle + } - on(webview.id + '.startPullDownRefresh', () => { - webview.beginPullToRefresh(); - }); + class UniverifyManager { + constructor () { + this.provider = 'univerify'; + this.eventName = 'api.univerifyButtonsClick'; + } - on(webview.id + '.stopPullDownRefresh', () => { - webview.endPullToRefresh(); - }); + close () { + closeAuthView(); + } - return webview - } + login (options) { + this._warp((data, callbackId) => login(data, callbackId, false), options); + } - function createPreloadWebview () { - if (!preloadWebview || preloadWebview.__uniapp_route) { // 不存在,或已被使用 - preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(id$1++), { contentAdjust: false }); - if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] preloadWebview[${preloadWebview.id}]`); - } + getCheckBoxState (options) { + this._warp((_, callbackId) => getCheckBoxState(_, callbackId, false), options); } - return preloadWebview - } - const webviewReadyCallbacks = {}; + preLogin (options) { + this._warp((data, callbackId) => preLogin$1(data, callbackId, false), options); + } - function registerWebviewReady (pageId, callback) { - (webviewReadyCallbacks[pageId] || (webviewReadyCallbacks[pageId] = [])).push(callback); - } + onButtonsClick (callback) { + UniServiceJSBridge.on(this.eventName, callback); + } - function consumeWebviewReady (pageId) { - const callbacks = webviewReadyCallbacks[pageId]; - Array.isArray(callbacks) && callbacks.forEach(callback => callback()); - delete webviewReadyCallbacks[pageId]; - } - - let todoNavigator = false; + offButtonsClick (callback) { + UniServiceJSBridge.off(this.eventName, callback); + } - function setTodoNavigator (path, callback, msg) { - todoNavigator = { - path: path, - nvue: __uniRoutes.find(route => route.path === path).meta.isNVue, - navigate: callback - }; - if (process.env.NODE_ENV !== 'production') { - console.log(`todoNavigator:${todoNavigator.path} ${msg}`); + _triggerUniverifyButtonsClick (res) { + UniServiceJSBridge.emit(this.eventName, res); } - } - function navigate (path, callback, isAppLaunch) { - { - if (isAppLaunch && __uniConfig.splashscreen && __uniConfig.splashscreen.autoclose && (!__uniConfig.splashscreen.alwaysShowBeforeRender)) { - plus.navigator.closeSplashscreen(); - } - if (!isAppLaunch && todoNavigator) { - return console.error(`Waiting to navigate to: ${todoNavigator.path}, do not operate continuously: ${path}.`) - } - if (__uniConfig.renderer === 'native') { // 纯原生无需wait逻辑 - // 如果是首页还未初始化,需要等一等,其他无需等待 - if (getCurrentPages().length === 0) { - return setTodoNavigator(path, callback, 'waitForReady') - } - return callback() - } - // 未创建 preloadWebview 或 preloadWebview 已被使用 - const waitPreloadWebview = !preloadWebview || (preloadWebview && preloadWebview.__uniapp_route); - // 已创建未 loaded - const waitPreloadWebviewReady = preloadWebview && !preloadWebview.loaded; + _warp (fn, options) { + return callback.warp(fn)(this._getOptions(options)) + } - if (waitPreloadWebview || waitPreloadWebviewReady) { - setTodoNavigator(path, callback, waitPreloadWebview ? 'waitForCreate' : 'waitForReady'); - } else { - callback(); - } - if (waitPreloadWebviewReady) { - registerWebviewReady(preloadWebview.id, todoNavigate); - } + _getOptions (options = {}) { + return Object.assign({}, options, { provider: this.provider }) } } - function todoNavigate () { - if (!todoNavigator) { - return - } - const { - navigate - } = todoNavigator; - if (process.env.NODE_ENV !== 'production') { - console.log(`todoNavigate:${todoNavigator.path}`); - } - todoNavigator = false; - return navigate() + function getUniverifyManager () { + return univerifyManager || (univerifyManager = new UniverifyManager()) } - function navigateFinish () { - { - if (__uniConfig.renderer === 'native') { - if (!todoNavigator) { - return - } - if (todoNavigator.nvue) { - return todoNavigate() - } - return - } - // 创建预加载 - const preloadWebview = createPreloadWebview(); - if (process.env.NODE_ENV !== 'production') { - console.log(`navigateFinish.preloadWebview:${preloadWebview.id}`); - } - if (!todoNavigator) { - return + function warpSuccessCallback (callbackId, name, plus = true) { + return plus + ? warpPlusSuccessCallback(callbackId, name) + : (options) => { + callback.invoke(callbackId, Object.assign({}, options, { + errMsg: `${name}:ok` + })); } - if (todoNavigator.nvue) { - return todoNavigate() + } + + function warpErrorCallback (callbackId, name, plus = true) { + return plus + ? warpPlusErrorCallback(callbackId, name) + : (error) => { + const { code = 0, message: errorMessage } = error; + callback.invoke(callbackId, { + errMsg: `${name}:fail ${errorMessage || ''}`, + errCode: code, + code + }); } - preloadWebview.loaded - ? todoNavigator.navigate() - : registerWebviewReady(preloadWebview.id, todoNavigate); - } } - function closeWebview (webview, animationType, animationDuration) { - webview[webview.__preload__ ? 'hide' : 'close'](animationType, animationDuration); - } - - function showWebview (webview, animationType, animationDuration, showCallback, delay) { - if (typeof delay === 'undefined') { - delay = webview.nvue ? 0 : 100; - } - - if (typeof animationDuration === 'undefined') { - animationDuration = ANI_DURATION; - } else { - animationDuration = parseInt(animationDuration); - } + function requestPayment (params, callbackId) { + const provider = params.provider; + const errorCallback = warpPlusErrorCallback(callbackId, 'requestPayment'); - if (process.env.NODE_ENV !== 'production') { - console.log(`[show][${Date.now()}]`, delay); - } - const duration = animationDuration || ANI_DURATION; - setTimeout(() => { - const execShowCallback = function () { - if (execShowCallback._called) { - if (process.env.NODE_ENV !== 'production') { - console.log('execShowCallback.prevent'); - } - return - } - execShowCallback._called = true; - showCallback && showCallback(); - navigateFinish(); - }; - const timer = setTimeout(() => { - if (process.env.NODE_ENV !== 'production') { - console.log(`[show.callback.timer][${Date.now()}]`); - } - execShowCallback(); - }, duration + 150); - webview.show( - animationType || ANI_SHOW, - duration, - () => { - if (process.env.NODE_ENV !== 'production') { - console.log(`[show.callback][${Date.now()}]`); - } - if (!execShowCallback._called) { - clearTimeout(timer); - } - execShowCallback(); - } - ); - }, delay); + plus.payment.getChannels(services => { + const service = services.find(({ + id + }) => id === provider); + if (!service) { + invoke$1(callbackId, { + errMsg: 'requestPayment:fail service not found' + }); + } else { + plus.payment.request(service, params.orderInfo, res => { + res.errMsg = 'requestPayment:ok'; + invoke$1(callbackId, res); + }, errorCallback); + } + }, errorCallback); } - let firstBackTime = 0; + let onPushing; + + let isListening = false; + + let unsubscribe = false; - function quit () { - if (!firstBackTime) { - firstBackTime = Date.now(); - plus.nativeUI.toast(t('uni.app.quit')); - setTimeout(() => { - firstBackTime = null; - }, 2000); - } else if (Date.now() - firstBackTime < 2000) { - plus.runtime.quit(); + function subscribePush (params, callbackId) { + const clientInfo = plus.push.getClientInfo(); + if (clientInfo) { + if (!isListening) { + isListening = true; + plus.push.addEventListener('receive', msg => { + if (onPushing && !unsubscribe) { + publish('onPushMessage', { + messageId: msg.__UUID__, + data: msg.payload, + errMsg: 'onPush:ok' + }); + } + }); + } + unsubscribe = false; + clientInfo.errMsg = 'subscribePush:ok'; + return clientInfo + } else { + return { + errMsg: 'subscribePush:fail 请确保当前运行环境已包含 push 模块' + } } } - function backWebview (webview, callback) { - const children = webview.children(); - if (!children || !children.length) { // 有子 webview - return callback() + function unsubscribePush (params) { + unsubscribe = true; + return { + errMsg: 'unsubscribePush:ok' } + } - // 如果页面有subNvues,切使用了webview组件,则返回时子webview会取错,因此需要做id匹配 - const childWebview = children.find(webview => webview.id.indexOf(WEBVIEW_ID_PREFIX) === 0) || children[0]; - - childWebview.canBack(({ - canBack - }) => { - if (canBack) { - childWebview.back(); // webview 返回 - } else { - callback(); + function onPush () { + if (!isListening) { + return { + errMsg: 'onPush:fail 请先调用 uni.subscribePush' } - }); + } + if (plus.push.getClientInfo()) { + onPushing = true; + return { + errMsg: 'onPush:ok' + } + } + return { + errMsg: 'onPush:fail 请确保当前运行环境已包含 push 模块' + } } - function back (delta, animationType, animationDuration) { - const pages = getCurrentPages(); - const len = pages.length; - const currentPage = pages[len - 1]; + function offPush (params) { + onPushing = false; + return { + errMsg: 'offPush:ok' + } + } - if (delta > 1) { - // 中间页隐藏 - pages.slice(len - delta, len - 1).reverse().forEach(deltaPage => { - closeWebview(deltaPage.$getAppWebview(), 'none'); - }); + function createPushMessage (params, callbackId) { + const setting = getAppAuthorizeSetting(); + if (setting.notificationAuthorized !== 'authorized') { + return invoke$1(callbackId, { + errMsg: 'createPushMessage:fail notificationAuthorized: ' + setting.notificationAuthorized + }) + } + const options = Object.assign({}, params); + delete options.content; + delete options.payload; + plus.push.createMessage(params.content, params.payload, options); + invoke$1(callbackId, { + errMsg: 'createPushMessage:ok' + }); + } + + function requireNativePlugin$1 (name) { + return weex.requireModule(name) + } + + // 0:图文,1:纯文字,2:纯图片,3:音乐,4:视频,5:小程序 + const TYPES$1 = { + 0: { + name: 'web', + title: '图文' + }, + 1: { + name: 'text', + title: '纯文字' + }, + 2: { + name: 'image', + title: '纯图片' + }, + 3: { + name: 'music', + title: '音乐' + }, + 4: { + name: 'video', + title: '视频' + }, + 5: { + name: 'miniProgram', + title: '小程序' } + }; - const backPage = function (webview) { - if (animationType) { - closeWebview(webview, animationType, animationDuration || ANI_DURATION); - } else { - if (currentPage.$page.openType === 'redirect') { // 如果是 redirectTo 跳转的,需要制定 back 动画 - closeWebview(webview, ANI_CLOSE, ANI_DURATION); - } else { - closeWebview(webview, 'auto'); - } - } + const parseParams = (args, callbackId, method) => { + args.type = args.type || 0; - pages.slice(len - delta, len).forEach(page => page.$remove()); + let { + provider, + type, + title, + summary: content, + href, + imageUrl, + mediaUrl: media, + scene, + miniProgram, + openCustomerServiceChat, + corpid, + customerUrl: url + } = args; - setStatusBarStyle(); + if (typeof imageUrl === 'string' && imageUrl) { + imageUrl = getRealPath$1(imageUrl); + } - UniServiceJSBridge.emit('onAppRoute', { - type: 'navigateBack' - }); - }; + const shareType = TYPES$1[type + '']; + if (shareType) { + const sendMsg = { + provider, + type: shareType.name, + title, + content, + href, + pictures: [imageUrl], + thumbs: [imageUrl], + media, + miniProgram, + extra: { + scene + }, + openCustomerServiceChat, + corpid, + url + }; + if (provider === 'weixin' && (type === 1 || type === 2)) { + delete sendMsg.thumbs; + } + return sendMsg + } + return '分享参数 type 不正确' + }; - const webview = currentPage.$getAppWebview(); - if (!currentPage.__uniapp_webview) { - return backPage(webview) + const sendShareMsg = function (service, params, callbackId, method = 'share') { + const errorCallback = warpPlusErrorCallback(callbackId, method); + const serviceMethod = params.openCustomerServiceChat ? 'openCustomerServiceChat' : 'send'; + try { + service[serviceMethod](params, () => { + invoke$1(callbackId, { + errMsg: method + ':ok' + }); + }, errorCallback); + } catch (error) { + errorCallback({ + message: `${params.provider} ${serviceMethod} 方法调用失败` + }); } - backWebview(webview, () => { - backPage(webview); - }); - } + }; - function navigateBack$1 ({ - from = 'navigateBack', - delta, - animationType, - animationDuration - }) { - const pages = getCurrentPages(); + function shareAppMessageDirectly ({ + title, + path, + imageUrl, + useDefaultSnapshot + }, callbackId) { + title = title || __uniConfig.appname; + const goShare = () => { + share({ + provider: 'weixin', + type: 0, + title, + imageUrl, + href: path, + scene: 'WXSceneSession' + }, + callbackId, + 'shareAppMessageDirectly' + ); + }; + const errorCallback = warpPlusErrorCallback(callbackId, 'shareAppMessageDirectly'); + + if (useDefaultSnapshot) { + const pages = getCurrentPages(); + const webview = plus.webview.getWebviewById(pages[pages.length - 1].__wxWebviewId__ + ''); + if (webview) { + const bitmap = new plus.nativeObj.Bitmap(); + webview.draw(bitmap, () => { + const fileName = TEMP_PATH + '/share/snapshot.jpg'; + bitmap.save( + fileName, { + overwrite: true, + format: 'jpg' + }, () => { + imageUrl = fileName; + goShare(); + }, errorCallback); + }, errorCallback); + } else { + goShare(); + } + } else { + goShare(); + } + } - const currentPage = pages[pages.length - 1]; - if ( - currentPage.$vm && - currentPage.$vm.$options.onBackPress && - currentPage.$vm.__call_hook && - currentPage.$vm.__call_hook('onBackPress', { - from + function share (params, callbackId, method = 'share') { + params = parseParams(params); + const errorCallback = warpPlusErrorCallback(callbackId, method); + + if (typeof params === 'string') { + return invoke$1(callbackId, { + errMsg: method + ':fail ' + params }) - ) { - return } + const provider = params.provider; + plus.share.getServices(services => { + const service = services.find(({ + id + }) => id === provider); + if (!service) { + invoke$1(callbackId, { + errMsg: method + ':fail service not found' + }); + } else { + if (service.authenticated) { + sendShareMsg(service, params, callbackId); + } else { + service.authorize( + () => sendShareMsg(service, params, callbackId), + errorCallback + ); + } + } + }, errorCallback); + } - // 后退时,关闭 toast,loading - uni.hideToast(); - uni.hideLoading(); + function shareWithSystem (params, callbackId, method = 'shareWithSystem') { + let { + type, + imageUrl, + summary: content, + href + } = params; + type = type || 'text'; + const allowedTypes = ['text', 'image']; + const errorCallback = warpPlusErrorCallback(callbackId, method); - if (currentPage.$page.meta.isQuit) { - quit(); - } else if (currentPage.$page.id === 1 && __uniConfig.realEntryPagePath) { - // condition - __uniConfig.entryPagePath = __uniConfig.realEntryPagePath; - delete __uniConfig.realEntryPagePath; - uni.reLaunch({ - url: '/' + __uniConfig.entryPagePath + if (allowedTypes.indexOf(type) < 0) { + invoke$1(callbackId, { + errMsg: method + ':fail 分享参数 type 不正确' }); - } else { - back(delta, animationType, animationDuration); } - return { - errMsg: 'navigateBack:ok' + if (typeof imageUrl === 'string' && imageUrl) { + imageUrl = getRealPath$1(imageUrl); } + plus.share.sendWithSystem({ + type, + pictures: imageUrl && [imageUrl], + content, + href + }, function (res) { + invoke$1(callbackId, { + errMsg: method + ':ok' + }); + }, errorCallback); } - class EventChannel { - constructor (id, events) { - this.id = id; - this.listener = {}; - this.emitCache = {}; - if (events) { - Object.keys(events).forEach(name => { - this.on(name, events[name]); - }); + function restoreGlobal ( + newWeex, + newPlus, + newSetTimeout, + newClearTimeout, + newSetInterval, + newClearInterval + ) { + // 确保部分全局变量 是 app-service 中的 + // 若首页 nvue 初始化比 app-service 快,导致框架处于该 nvue 环境下 + // plus 如果不用 app-service,资源路径会出问题 + // 若首页 nvue 被销毁,如 redirectTo 或 reLaunch,则这些全局功能会损坏 + if (plus !== newPlus) { + if (process.env.NODE_ENV !== 'production') { + console.log(`[restoreGlobal][${Date.now()}]`); } + weex = newWeex; + plus = newPlus; + restoreOldSetStatusBarStyle(plus.navigator.setStatusBarStyle); + plus.navigator.setStatusBarStyle = newSetStatusBarStyle; + /* eslint-disable no-global-assign */ + setTimeout = newSetTimeout; + clearTimeout = newClearTimeout; + setInterval = newSetInterval; + clearInterval = newClearInterval; } + __uniConfig.serviceReady = true; + } + + function requireGlobal () { + const list = [ + 'ArrayBuffer', + 'Int8Array', + 'Uint8Array', + 'Uint8ClampedArray', + 'Int16Array', + 'Uint16Array', + 'Int32Array', + 'Uint32Array', + 'Float32Array', + 'Float64Array', + 'BigInt64Array', + 'BigUint64Array' + ]; + const object = {}; + for (let i = 0; i < list.length; i++) { + const key = list[i]; + object[key] = global[key]; + } + return object + } + + function wrapper$1 (webview) { + webview.$processed = true; - emit (eventName, ...args) { - const fns = this.listener[eventName]; - if (!fns) { - return (this.emitCache[eventName] || (this.emitCache[eventName] = [])).push(args) + webview.postMessage = function (data) { + plus.webview.postMessageToUniNView({ + type: 'UniAppSubNVue', + data + }, webview.id); + }; + let callbacks = []; + webview.onMessage = function (callback) { + callbacks.push(callback); + }; + webview.$consumeMessage = function (e) { + callbacks.forEach(callback => callback(e)); + }; + + if (!webview.__uniapp_mask_id) { + return + } + const maskColor = webview.__uniapp_mask; + const maskWebview = webview.__uniapp_mask_id === '0' ? { + setStyle ({ + mask + }) { + requireNativePlugin$1('uni-tabview').setMask({ + color: mask + }); } - fns.forEach(opt => { - opt.fn.apply(opt.fn, args); + } : plus.webview.getWebviewById(webview.__uniapp_mask_id); + const oldShow = webview.show; + const oldHide = webview.hide; + const oldClose = webview.close; + + const showMask = function () { + maskWebview.setStyle({ + mask: maskColor }); - this.listener[eventName] = fns.filter(opt => opt.type !== 'once'); - } + }; + const closeMask = function () { + maskWebview.setStyle({ + mask: 'none' + }); + }; + webview.show = function (...args) { + showMask(); + return oldShow.apply(webview, args) + }; + webview.hide = function (...args) { + closeMask(); + return oldHide.apply(webview, args) + }; + webview.close = function (...args) { + closeMask(); + callbacks = []; + return oldClose.apply(webview, args) + }; + } - on (eventName, fn) { - this._addListener(eventName, 'on', fn); - this._clearCache(eventName); + function getSubNVueById (id) { + const webview = plus.webview.getWebviewById(id); + if (webview === null || webview === undefined) { + throw new Error('Unable to find SubNVue, id=' + id) } - - once (eventName, fn) { - this._addListener(eventName, 'once', fn); - this._clearCache(eventName); + if (webview && !webview.$processed) { + wrapper$1(webview); } - - off (eventName, fn) { - const fns = this.listener[eventName]; - if (!fns) { - return - } - if (fn) { - for (let i = 0; i < fns.length;) { - if (fns[i].fn === fn) { - fns.splice(i, 1); - i--; - } - i++; - } - } else { - delete this.listener[eventName]; + const oldSetStyle = webview.setStyle; + var parentWebview = plus.webview.getWebviewById(webview.__uniapp_mask_id); + webview.setStyle = function (style) { + if (style && style.mask) { + parentWebview && parentWebview.setStyle({ + mask: style.mask + }); + delete style.mask; } - } + oldSetStyle.call(this, style); + }; + return webview + } + + function getCurrentSubNVue () { + return getSubNVueById(plus.webview.currentWebview().id) + } + + const callbacks$3 = []; + // 不使用uni-core/service/platform中的onMethod,避免循环引用 + UniServiceJSBridge.on('api.uniMPNativeEvent', function (res) { + callbacks$3.forEach(callbackId => { + invoke$1(callbackId, res.event, res.data); + }); + }); - _clearCache (eventName) { - const cacheArgs = this.emitCache[eventName]; - if (cacheArgs) { - for (; cacheArgs.length > 0;) { - this.emit.apply(this, [eventName].concat(cacheArgs.shift())); - } - } - } + function onHostEventReceive (callbackId) { + callbacks$3.push(callbackId); + } - _addListener (eventName, type, fn) { - (this.listener[eventName] || (this.listener[eventName] = [])).push({ - fn, - type - }); - } + function onNativeEventReceive (callbackId) { + callbacks$3.push(callbackId); } - let id$2 = 0; - - function initEventChannel (events, cache = true) { - id$2++; - const eventChannel = new EventChannel(id$2, events); - return eventChannel + function sendNativeEvent (event, data, callback) { + // 实时获取weex module(weex可能会变化,比如首页nvue加速显示时) + return weex.requireModule('plus').sendNativeEvent(event, data, callback) } - const pageFactory = Object.create(null); + const SUB_FILENAME$1 = 'app-sub-service.js'; - function definePage (name, createPageVueComponent) { - pageFactory[name] = createPageVueComponent; + function evaluateScriptFile (file, callback) { + __uniConfig.onServiceReady(() => { + weex.requireModule('plus').evalJSFiles([file], callback); + }); } - const getPageVueComponent = cached(function (pagePath) { - return pageFactory[pagePath]() - }); - - function createPage (pagePath, pageId, pageQuery, pageInstance) { - if (!pageFactory[pagePath]) { - console.error(`${pagePath} not found`); + function loadSubPackage$2 ({ + root + }, callbackId) { + if (loadedSubPackages.indexOf(root) !== -1) { + return { + errMsg: 'loadSubPackage:ok' + } } - const startTime = Date.now(); - const pageVm = new (getPageVueComponent(pagePath))({ - mpType: 'page', - pageId, - pagePath, - pageQuery, - pageInstance - }); + loadedSubPackages.push(root); if (process.env.NODE_ENV !== 'production') { - console.log(`new ${pagePath}[${pageId}]:time(${Date.now() - startTime})`); + console.log('UNIAPP[loadSubPackage]:' + root); } - return pageVm + const startTime = Date.now(); + evaluateScriptFile(root + '/' + SUB_FILENAME$1, res => { + if (process.env.NODE_ENV !== 'production') { + console.log('UNIAPP[loadSubPackage]:耗时(' + (Date.now() - startTime) + ')'); + } + invoke$1(callbackId, { + errMsg: 'loadSubPackage:ok' + }); + }); } - let isInitEntryPage = false; - - function initEntryPage () { - if (isInitEntryPage) { - return - } - isInitEntryPage = true; - - let entryPagePath; - let entryPageQuery; - - const weexPlus = weex.requireModule('plus'); - - if (weexPlus.getRedirectInfo) { - const { - path, - query, - referrerInfo - } = parseRedirectInfo(); - if (path) { - entryPagePath = path; - entryPageQuery = query; - } - __uniConfig.referrerInfo = referrerInfo; - } else { - const argsJsonStr = plus.runtime.arguments; - if (!argsJsonStr) { - return - } - try { - const args = JSON.parse(argsJsonStr); - entryPagePath = args.path || args.pathName; - entryPageQuery = args.query ? ('?' + args.query) : ''; - } catch (e) {} - } + const sendHostEvent = sendNativeEvent; - if (!entryPagePath || entryPagePath === __uniConfig.entryPagePath) { - if (entryPageQuery) { - __uniConfig.entryPageQuery = entryPageQuery; + function navigateToMiniProgram (data, callbackId) { + sendHostEvent( + 'navigateToUniMP', + data, + (res) => { + if (res.errMsg && res.errMsg.indexOf(':ok') === -1) { + return invoke$1(callbackId, { + errMsg: res.errMsg + }) + } + invoke$1(callbackId, { + errMsg: 'navigateToMiniProgram:ok' + }); } - return - } + ); + } + + function getLaunchOptionsSync () { + return getLaunchOptions() + } + function getEnterOptionsSync () { + return getEnterOptions() + } + + function closeWebview (webview, animationType, animationDuration) { + webview[webview.__preload__ ? 'hide' : 'close'](animationType, animationDuration); + } - const entryRoute = '/' + entryPagePath; - const routeOptions = __uniRoutes.find(route => route.path === entryRoute); - if (!routeOptions) { - console.error(`[uni-app] ${entryPagePath} not found...`); - return + function showWebview (webview, animationType, animationDuration, showCallback, delay) { + if (typeof delay === 'undefined') { + delay = webview.nvue ? 0 : 100; } - if (!routeOptions.meta.isTabBar) { - __uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath; + if (typeof animationDuration === 'undefined') { + animationDuration = ANI_DURATION; + } else { + animationDuration = parseInt(animationDuration); } - __uniConfig.entryPagePath = entryPagePath; - __uniConfig.entryPageQuery = entryPageQuery; - if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`); + console.log(`[show][${Date.now()}]`, delay); } + const duration = animationDuration || ANI_DURATION; + setTimeout(() => { + const execShowCallback = function () { + if (execShowCallback._called) { + if (process.env.NODE_ENV !== 'production') { + console.log('execShowCallback.prevent'); + } + return + } + execShowCallback._called = true; + showCallback && showCallback(); + navigateFinish(); + }; + const timer = setTimeout(() => { + if (process.env.NODE_ENV !== 'production') { + console.log(`[show.callback.timer][${Date.now()}]`); + } + execShowCallback(); + }, duration + 150); + webview.show( + animationType || ANI_SHOW, + duration, + () => { + if (process.env.NODE_ENV !== 'production') { + console.log(`[show.callback][${Date.now()}]`); + } + if (!execShowCallback._called) { + clearTimeout(timer); + } + execShowCallback(); + } + ); + }, delay); } - const pages = []; + let firstBackTime = 0; - function getCurrentPages$1 (returnAll) { - return returnAll ? pages.slice(0) : pages.filter(page => { - return !page.$page.meta.isTabBar || page.$page.meta.visible - }) + function quit () { + if (!firstBackTime) { + firstBackTime = Date.now(); + plus.nativeUI.toast(t('uni.app.quit')); + setTimeout(() => { + firstBackTime = null; + }, 2000); + } else if (Date.now() - firstBackTime < 2000) { + plus.runtime.quit(); + } } - const preloadWebviews = {}; + function backWebview (webview, callback) { + const children = webview.children(); + if (!children || !children.length) { // 有子 webview + return callback() + } - function removePreloadWebview (webview) { - const url = Object.keys(preloadWebviews).find(url => preloadWebviews[url].id === webview.id); - if (url) { - if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] removePreloadWebview(${webview.id})`); + // 如果页面有subNvues,切使用了webview组件,则返回时子webview会取错,因此需要做id匹配 + const childWebview = children.find(webview => webview.id.indexOf(WEBVIEW_ID_PREFIX) === 0) || children[0]; + + childWebview.canBack(({ + canBack + }) => { + if (canBack) { + childWebview.back(); // webview 返回 + } else { + callback(); } - delete preloadWebviews[url]; - } + }); } - function closePreloadWebview ({ - url - }) { - const webview = preloadWebviews[url]; - if (webview) { - if (webview.__page__) { - if (!getCurrentPages$1(true).find(page => page === webview.__page__)) { - // 未使用 - webview.close('none'); - } else { // 被使用 - webview.__preload__ = false; + function back (delta, animationType, animationDuration) { + const pages = getCurrentPages(); + const len = pages.length; + const currentPage = pages[len - 1]; + + if (delta > 1) { + // 中间页隐藏 + pages.slice(len - delta, len - 1).reverse().forEach(deltaPage => { + closeWebview(deltaPage.$getAppWebview(), 'none'); + }); + } + + const backPage = function (webview) { + if (animationType) { + closeWebview(webview, animationType, animationDuration || ANI_DURATION); + } else { + if (currentPage.$page.openType === 'redirect') { // 如果是 redirectTo 跳转的,需要制定 back 动画 + closeWebview(webview, ANI_CLOSE, ANI_DURATION); + } else { + closeWebview(webview, 'auto'); } - } else { // 未使用 - webview.close('none'); } - delete preloadWebviews[url]; - } - return webview - } - function preloadWebview$1 ({ - url, - path, - query - }) { - if (!preloadWebviews[url]) { - const routeOptions = JSON.parse(JSON.stringify(__uniRoutes.find(route => route.path === path))); - preloadWebviews[url] = createWebview(path, routeOptions, query, { - __preload__: true, - __query__: JSON.stringify(query) + pages.slice(len - delta, len).forEach(page => page.$remove()); + + setStatusBarStyle(); + + UniServiceJSBridge.emit('onAppRoute', { + type: 'navigateBack' }); + }; + + const webview = currentPage.$getAppWebview(); + if (!currentPage.__uniapp_webview) { + return backPage(webview) } - return preloadWebviews[url] + backWebview(webview, () => { + backPage(webview); + }); } - /** - * 首页需要主动registerPage,二级页面路由跳转时registerPage - */ - function registerPage ({ - url, - path, - query, - openType, - webview, - eventChannel + function navigateBack$1 ({ + from = 'navigateBack', + delta, + animationType, + animationDuration }) { - // fast 模式,nvue 首页时,初始化下 entry page - webview && initEntryPage(); - - if (preloadWebviews[url]) { - webview = preloadWebviews[url]; - if (webview.__page__) { - // 该预载页面已处于显示状态,不再使用该预加载页面,直接新开 - if (getCurrentPages$1(true).find(page => page === webview.__page__)) { - if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] preloadWebview(${path},${webview.id}) already in use`); - } - webview = null; - } else { - if (eventChannel) { - webview.__page__.eventChannel = eventChannel; - } - pages.push(webview.__page__); - if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] reuse preloadWebview(${path},${webview.id})`); - } - return webview - } - } - } - const routeOptions = JSON.parse(JSON.stringify(__uniRoutes.find(route => route.path === path))); + const pages = getCurrentPages(); + const currentPage = pages[pages.length - 1]; if ( - openType === 'reLaunch' || - ( - !__uniConfig.realEntryPagePath && - getCurrentPages$1().length === 0 // redirectTo - ) + currentPage.$vm && + currentPage.$vm.$options.onBackPress && + currentPage.$vm.__call_hook && + currentPage.$vm.__call_hook('onBackPress', { + from + }) ) { - routeOptions.meta.isQuit = true; - } else if (!routeOptions.meta.isTabBar) { - routeOptions.meta.isQuit = false; + return } - if (!webview) { - webview = createWebview(path, routeOptions, query); + // 后退时,关闭 toast,loading + uni.hideToast(); + uni.hideLoading(); + + if (currentPage.$page.meta.isQuit) { + quit(); + } else if (currentPage.$page.id === 1 && __uniConfig.realEntryPagePath) { + // condition + __uniConfig.entryPagePath = __uniConfig.realEntryPagePath; + delete __uniConfig.realEntryPagePath; + uni.reLaunch({ + url: '/' + __uniConfig.entryPagePath + }); } else { - webview = plus.webview.getWebviewById(webview.id); - webview.nvue = routeOptions.meta.isNVue; + back(delta, animationType, animationDuration); } - - if (routeOptions.meta.isTabBar) { - routeOptions.meta.visible = true; + return { + errMsg: 'navigateBack:ok' } - - if (routeOptions.meta.isTabBar) { - tabBar$1.append(webview); + } + + class EventChannel { + constructor (id, events) { + this.id = id; + this.listener = {}; + this.emitCache = {}; + if (events) { + Object.keys(events).forEach(name => { + this.on(name, events[name]); + }); + } } - if (process.env.NODE_ENV !== 'production') { - console.log(`[uni-app] registerPage(${path},${webview.id})`); + emit (eventName, ...args) { + const fns = this.listener[eventName]; + if (!fns) { + return (this.emitCache[eventName] || (this.emitCache[eventName] = [])).push(args) + } + fns.forEach(opt => { + opt.fn.apply(opt.fn, args); + }); + this.listener[eventName] = fns.filter(opt => opt.type !== 'once'); } - const isLaunchNVuePage = webview.id === '1' && webview.nvue; - - initWebview(webview, routeOptions, path, query); - - const route = path.slice(1); + on (eventName, fn) { + this._addListener(eventName, 'on', fn); + this._clearCache(eventName); + } - webview.__uniapp_route = route; + once (eventName, fn) { + this._addListener(eventName, 'once', fn); + this._clearCache(eventName); + } - const pageInstance = { - route, - options: Object.assign({}, query || {}), - $getAppWebview () { - // 重要,不能直接返回 webview 对象,因为 plus 可能会被二次替换,返回的 webview 对象内部的 plus 不正确 - // 导致 webview.getStyle 等逻辑出错(旧的 webview 内部 plus 被释放) - return plus.webview.getWebviewById(webview.id) - }, - eventChannel, - $page: { - id: parseInt(webview.id), - meta: routeOptions.meta, - path, - route, - fullPath: url, - openType - }, - $remove () { - const index = pages.findIndex(page => page === this); - if (index !== -1) { - if (!webview.nvue) { - this.$vm.$destroy(); - } - pages.splice(index, 1); - if (process.env.NODE_ENV !== 'production') { - console.log('[uni-app] removePage(' + path + ')[' + webview.id + ']'); + off (eventName, fn) { + const fns = this.listener[eventName]; + if (!fns) { + return + } + if (fn) { + for (let i = 0; i < fns.length;) { + if (fns[i].fn === fn) { + fns.splice(i, 1); + i--; } + i++; } - }, - // 兼容小程序框架 - selectComponent (selector) { - return this.$vm.selectComponent(selector) - }, - selectAllComponents (selector) { - return this.$vm.selectAllComponents(selector) + } else { + delete this.listener[eventName]; } - }; - - pages.push(pageInstance); - - if (webview.__preload__) { - webview.__page__ = pageInstance; } - // 首页是 nvue 时,在 registerPage 时,执行路由堆栈 - if (isLaunchNVuePage) { - if ( - __uniConfig.splashscreen && - __uniConfig.splashscreen.autoclose && - !__uniConfig.splashscreen.alwaysShowBeforeRender - ) { - plus.navigator.closeSplashscreen(); + _clearCache (eventName) { + const cacheArgs = this.emitCache[eventName]; + if (cacheArgs) { + for (; cacheArgs.length > 0;) { + this.emit.apply(this, [eventName].concat(cacheArgs.shift())); + } } - __uniConfig.onReady(function () { - navigateFinish(); - }); } - { - if (!webview.nvue) { - const pageId = webview.id; - try { - loadPage(route, () => { - createPage(route, pageId, query, pageInstance).$mount(); - }); - } catch (e) { - console.error(e); - } - } + _addListener (eventName, type, fn) { + (this.listener[eventName] || (this.listener[eventName] = [])).push({ + fn, + type + }); } + } + + let id$2 = 0; - return webview + function initEventChannel (events, cache = true) { + id$2++; + const eventChannel = new EventChannel(id$2, events); + return eventChannel } function _navigateTo ({ @@ -11445,7 +11467,7 @@ var serviceContext = (function () { confirmText, confirmColor, editable = false, - placeholderText = '' + placeholderText = '' } = {}, callbackId) { const buttons = showCancel ? [cancelText, confirmText] : [confirmText]; const tip = editable ? placeholderText : buttons; @@ -11472,12 +11494,27 @@ var serviceContext = (function () { } }, title, tip, buttons); } + + const ACTION_SHEET_THEME = { + light: { + itemColor: '#000000' + }, + dark: { + itemColor: 'rgba(255, 255, 255, 0.8)' + } + }; function showActionSheet$1 ({ itemList = [], - itemColor = '#000000', + itemColor, title = '', popover }, callbackId) { + // #000 by default in protocols + if (itemColor === '#000' && __uniConfig.darkmode) { + itemColor = + ACTION_SHEET_THEME[plus.navigator.getUIStyle()] + .itemColor; + } const options = { buttons: itemList.map(item => ({ title: item, @@ -22857,6 +22894,7 @@ var serviceContext = (function () { publish('onUIStyleChange', { style: event.uistyle }); + changePagesNavigatorStyle(); }); globalEvent.addEventListener('uniMPNativeEvent', function (event) { diff --git a/packages/uni-app-plus/dist/view.umd.min.js b/packages/uni-app-plus/dist/view.umd.min.js index b425fd843..3ed7f8320 100644 --- a/packages/uni-app-plus/dist/view.umd.min.js +++ b/packages/uni-app-plus/dist/view.umd.min.js @@ -1,4 +1,4 @@ -(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["uni"]=e():t["uni"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fae3")}({"0094":function(t,e,n){"use strict";n.r(e);var i=n("f2b3"),r=n("c4c5");function o(t,e,n){return o="undefined"!==typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=a(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(n):r.value}},o(t,e,n||t)}function a(t,e){while(!Object.prototype.hasOwnProperty.call(t,e))if(t=y(t),null===t)break;return t}function s(t){var e="function"===typeof Map?new Map:void 0;return s=function(t){if(null===t||!u(t))return t;if("function"!==typeof t)throw new TypeError("Super expression must either be null or a function");if("undefined"!==typeof e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return c(t,arguments,y(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)},s(t)}function c(t,e,n){return c=b()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var r=Function.bind.apply(t,i),o=new r;return n&&v(o,n.prototype),o},c.apply(null,arguments)}function u(t){return-1!==Function.toString.call(t).indexOf("[native code]")}function l(t){return l="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var n=0;n1)){this.getAttribute("hover-stop-propagation")&&(t._hoverPropagationStopped=!0),this._hoverTouch=!0;var n=50,i=Number(this.getAttribute("hover-start-time")||n);this._hoverStartTimer=setTimeout((function(){e.hovering=!0,e._hoverTouch||e._hoverReset()}),isNaN(i)?n:i)}}},{key:"_hoverTouchEnd",value:function(){this._hoverTouch=!1,this.hovering&&this._hoverReset()}},{key:"_hoverReset",value:function(){var t=this;requestAnimationFrame((function(){clearTimeout(t._hoverStayTimer);var e=400,n=Number(t.getAttribute("hover-stay-time")||e);t._hoverStayTimer=setTimeout((function(){t.hovering=!1}),isNaN(n)?e:n)}))}},{key:"_hoverTouchCancel",value:function(){this._hoverTouch=!1,this.hovering=!1,clearTimeout(this._hoverStartTimer)}},{key:"hovering",get:function(){return this._hovering},set:function(t){this._hovering=t;var e=this.getAttribute("hover-class").split(" ").filter(Boolean),n=this.classList;t?n.add.apply(n,e):n.remove.apply(n,e)}}]),n}(F);function et(t){return et="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},et(t)}function nt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function it(t,e){if("function"!==typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&rt(t,e)}function rt(t,e){return rt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},rt(t,e)}function ot(t){return function(){var e,n=ut(t);if(ct()){var i=ut(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return at(this,e)}}function at(t,e){return!e||"object"!==et(e)&&"function"!==typeof e?st(t):e}function st(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ct(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function ut(t){return ut=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ut(t)}var lt=function(t){it(n,t);var e=ot(n);function n(){return nt(this,n),e.apply(this,arguments)}return n}(tt);e["default"]={View:lt}},"00b2":function(t,e,n){},"01ab":function(t,e,n){},"02b5":function(t,e,n){"use strict";var i=n("8e72"),r=n.n(i);r.a},"02ed":function(t){t.exports=JSON.parse('{"uni.app.quit":"再按一次退出應用","uni.async.error":"連接服務器超時,點擊屏幕重試","uni.showActionSheet.cancel":"取消","uni.showToast.unpaired":"請注意 showToast 與 hideToast 必須配對使用","uni.showLoading.unpaired":"請注意 showLoading 與 hideLoading 必須配對使用","uni.showModal.cancel":"取消","uni.showModal.confirm":"確定","uni.chooseImage.cancel":"取消","uni.chooseImage.sourceType.album":"從相冊選擇","uni.chooseImage.sourceType.camera":"拍攝","uni.chooseVideo.cancel":"取消","uni.chooseVideo.sourceType.album":"從相冊選擇","uni.chooseVideo.sourceType.camera":"拍攝","uni.chooseFile.notUserActivation":"文件選擇器對話框只能在由用戶激活時顯示","uni.previewImage.cancel":"取消","uni.previewImage.button.save":"保存圖像","uni.previewImage.save.success":"保存圖像到相冊成功","uni.previewImage.save.fail":"保存圖像到相冊失敗","uni.setClipboardData.success":"內容已復制","uni.scanCode.title":"掃碼","uni.scanCode.album":"相冊","uni.scanCode.fail":"識別失敗","uni.scanCode.flash.on":"輕觸照亮","uni.scanCode.flash.off":"輕觸關閉","uni.startSoterAuthentication.authContent":"指紋識別中...","uni.picker.done":"完成","uni.picker.cancel":"取消","uni.video.danmu":"彈幕","uni.video.volume":"音量","uni.button.feedback.title":"問題反饋","uni.button.feedback.send":"發送","uni.chooseLocation.search":"搜索地點","uni.chooseLocation.cancel":"取消"}')},"03df":function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-web-view",t._g({},t.$listeners))},r=[],o=n("ed56"),a=o["a"],s=(n("2df3"),n("2877")),c=Object(s["a"])(a,i,r,!1,null,null,null);e["default"]=c.exports},"0516":function(t,e,n){"use strict";(function(t,i){n.d(e,"a",(function(){return f}));var r=n("f2b3"),o=n("a6b0"),a=n("33ed"),s=n("2522"),c=n("a20d"),u=!!r["l"]&&{passive:!1};function l(e){var n=e.statusbarHeight,i=e.windowTop,r=e.windowBottom;if(t.__WINDOW_TOP=i,t.__WINDOW_BOTTOM=r,uni.canIUse("css.var")){var o=document.documentElement.style;o.setProperty("--window-left","0px"),o.setProperty("--window-right","0px"),o.setProperty("--window-top",i+"px"),o.setProperty("--window-bottom",r+"px"),o.setProperty("--status-bar-height",n+"px")}}function h(t,e){var n=t.locale,i=t.statusbarHeight,r=t.windowTop,s=t.windowBottom,c=t.disableScroll,h=t.onPageScroll,d=t.onPageReachBottom,f=t.onReachBottomDistance;Object(o["c"])(n),l({statusbarHeight:i,windowTop:r,windowBottom:s}),c?document.addEventListener("touchmove",a["b"],u):(h||d)&&requestAnimationFrame((function(){document.addEventListener("scroll",Object(a["a"])(e,{enablePageScroll:h,enablePageReachBottom:d,onReachBottomDistance:f}))}))}function d(){i.publishHandler("webviewReady")}function f(t){t(c["m"],d),t(s["a"],h),t(c["f"],o["c"])}}).call(this,n("c8ba"),n("501c"))},"0741":function(t,e,n){"use strict";var i=n("3c79"),r=n.n(i);r.a},"07f4":function(t,e,n){"use strict";var i=n("be7f"),r=4,o=0,a=1,s=2;function c(t){var e=t.length;while(--e>=0)t[e]=0}var u=0,l=1,h=2,d=3,f=258,p=29,v=256,m=v+1+p,g=30,_=19,b=2*m+1,y=15,w=16,S=7,k=256,x=16,C=17,T=18,O=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],$=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],A=512,M=new Array(2*(m+2));c(M);var P=new Array(2*g);c(P);var j=new Array(A);c(j);var L=new Array(f-d+1);c(L);var N=new Array(p);c(N);var D,R,B,F=new Array(g);function z(t,e,n,i,r){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=t&&t.length}function V(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function H(t){return t<256?j[t]:j[256+(t>>>7)]}function Y(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function U(t,e,n){t.bi_valid>w-n?(t.bi_buf|=e<>w-t.bi_valid,t.bi_valid+=n-w):(t.bi_buf|=e<>>=1,n<<=1}while(--e>0);return n>>>1}function q(t){16===t.bi_valid?(Y(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}function Z(t,e){var n,i,r,o,a,s,c=e.dyn_tree,u=e.max_code,l=e.stat_desc.static_tree,h=e.stat_desc.has_stree,d=e.stat_desc.extra_bits,f=e.stat_desc.extra_base,p=e.stat_desc.max_length,v=0;for(o=0;o<=y;o++)t.bl_count[o]=0;for(c[2*t.heap[t.heap_max]+1]=0,n=t.heap_max+1;np&&(o=p,v++),c[2*i+1]=o,i>u||(t.bl_count[o]++,a=0,i>=f&&(a=d[i-f]),s=c[2*i],t.opt_len+=s*(o+a),h&&(t.static_len+=s*(l[2*i+1]+a)));if(0!==v){do{o=p-1;while(0===t.bl_count[o])o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[p]--,v-=2}while(v>0);for(o=p;0!==o;o--){i=t.bl_count[o];while(0!==i)r=t.heap[--n],r>u||(c[2*r+1]!==o&&(t.opt_len+=(o-c[2*r+1])*c[2*r],c[2*r+1]=o),i--)}}}function G(t,e,n){var i,r,o=new Array(y+1),a=0;for(i=1;i<=y;i++)o[i]=a=a+n[i-1]<<1;for(r=0;r<=e;r++){var s=t[2*r+1];0!==s&&(t[2*r]=X(o[s]++,s))}}function K(){var t,e,n,i,r,o=new Array(y+1);for(n=0,i=0;i>=7;i8?Y(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function tt(t,e,n,r){Q(t),r&&(Y(t,n),Y(t,~n)),i.arraySet(t.pending_buf,t.window,e,n,t.pending),t.pending+=n}function et(t,e,n,i){var r=2*e,o=2*n;return t[r]>1;n>=1;n--)nt(t,o,n);r=c;do{n=t.heap[1],t.heap[1]=t.heap[t.heap_len--],nt(t,o,1),i=t.heap[1],t.heap[--t.heap_max]=n,t.heap[--t.heap_max]=i,o[2*r]=o[2*n]+o[2*i],t.depth[r]=(t.depth[n]>=t.depth[i]?t.depth[n]:t.depth[i])+1,o[2*n+1]=o[2*i+1]=r,t.heap[1]=r++,nt(t,o,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],Z(t,e),G(o,u,t.bl_count)}function ot(t,e,n){var i,r,o=-1,a=e[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),e[2*(n+1)+1]=65535,i=0;i<=n;i++)r=a,a=e[2*(i+1)+1],++s=3;e--)if(0!==t.bl_tree[2*I[e]+1])break;return t.opt_len+=3*(e+1)+5+5+4,e}function ct(t,e,n,i){var r;for(U(t,e-257,5),U(t,n-1,5),U(t,i-4,4),r=0;r>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return o;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return a;for(e=32;e0?(t.strm.data_type===s&&(t.strm.data_type=ut(t)),rt(t,t.l_desc),rt(t,t.d_desc),c=st(t),o=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=o&&(o=a)):o=a=n+5,n+4<=o&&-1!==e?dt(t,e,n,i):t.strategy===r||a===o?(U(t,(l<<1)+(i?1:0),3),it(t,M,P)):(U(t,(h<<1)+(i?1:0),3),ct(t,t.l_desc.max_code+1,t.d_desc.max_code+1,c+1),it(t,t.dyn_ltree,t.dyn_dtree)),J(t),i&&Q(t)}function vt(t,e,n){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(L[n]+v+1)]++,t.dyn_dtree[2*H(e)]++),t.last_lit===t.lit_bufsize-1}e._tr_init=ht,e._tr_stored_block=dt,e._tr_flush_block=pt,e._tr_tally=vt,e._tr_align=ft},"0998":function(t,e,n){"use strict";var i=n("927d"),r=n.n(i);r.a},"0aa0":function(t,e,n){"use strict";var i=n("a53f");function r(t){var e;while(t){var n=getComputedStyle(t),i=n.transform||n.webkitTransform;e=(!i||"none"===i)&&e,e="fixed"===n.position||e,t=t.parentElement}return e}e["a"]={name:"Native",data:function(){return{position:{top:"0px",left:"0px",width:"0px",height:"0px",position:"static"},hidden:!1}},provide:function(){return{parentOnDraw:this._onDraw}},inject:{parentOnDraw:{default:null}},created:function(){this.isNative=!0,this.onCanInsertCallbacks=[],this.onDrawCallbacks=[]},mounted:function(){this._updatePosition(),this.onCanInsertCallbacks.forEach((function(t){return t()})),this.onCanInsertCallbacks=null,this.$on("uni-view-update",this._requestPositionUpdate)},methods:{_updatePosition:function(){var t=(this.$refs.container||this.$el).getBoundingClientRect();if(this.hidden=0===t.width||0===t.height,!this.hidden){var e=this.position;e.position=r(this.$el)?"absolute":"static";var n=["top","left","width","height"];n.forEach((function(n){var r=t[n];r="top"===n?r+("static"===e.position?document.documentElement.scrollTop||document.body.scrollTop||0:Object(i["a"])()):r,e[n]=r+"px"}))}},_requestPositionUpdate:function(){var t=this;this._positionUpdateRequest&&cancelAnimationFrame(this._positionUpdateRequest),this._positionUpdateRequest=requestAnimationFrame((function(){delete t._positionUpdateRequest,t._updatePosition()}))},_onParentReady:function(t){var e=this,n=function(n){t(n),e.onDrawCallbacks.forEach((function(t){return t(e.position)})),e.onDrawCallbacks=null};this._onSelfReady((function(){e.parentOnDraw?e.parentOnDraw(n):n({top:"0px",left:"0px",width:Number.MAX_SAFE_INTEGER+"px",height:Number.MAX_SAFE_INTEGER+"px",position:"static"})}))},_onSelfReady:function(t){this.onCanInsertCallbacks?this.onCanInsertCallbacks.push(t):t()},_onDraw:function(t){this.onDrawCallbacks?this.onDrawCallbacks.push(t):t(this.position)}}}},"0b86":function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));var i=n("f2b3");function r(t,e,n){if(!t.$parent)return"-1";var r=t.$vnode,o=r.context,a=r.data.attrs._i;return n&&Object(i["e"])(r.data,"key")&&(a=a+";"+r.data.key),o&&o!==e&&o._$id?o._$id+";"+e._$id+","+a:e._$id+","+a}},"0f55":function(t,e,n){"use strict";var i=n("2190"),r=n.n(i);r.a},1082:function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-image",t._g({},t.$listeners),[n("div",{ref:"content",style:t.style}),"widthFix"===t.mode||"heightFix"===t.mode?n("v-uni-resize-sensor",{ref:"sensor",on:{resize:function(e){return t._fixSize()}}}):t._e()],1)},r=[];function o(t){return o="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function a(t){return("undefined"===typeof navigator||o(navigator))&&"Google Inc."===navigator.vendor&&t>10&&(t=2*Math.round(t/2)),t}var s={name:"Image",props:{src:{type:String,default:""},mode:{type:String,default:"scaleToFill"},lazyLoad:{type:[Boolean,String],default:!1},draggable:{type:Boolean,default:!1}},data:function(){return{originalWidth:0,originalHeight:0,originalStyle:{width:"",height:""},contentPath:""}},computed:{ratio:function(){return this.originalWidth&&this.originalHeight?this.originalWidth/this.originalHeight:0},style:function(){var t="auto",e="",n="no-repeat";switch(this.mode){case"aspectFit":t="contain",e="center center";break;case"aspectFill":t="cover",e="center center";break;case"widthFix":case"heightFix":t="100% 100%";break;case"top":e="center top";break;case"bottom":e="center bottom";break;case"center":e="center center";break;case"left":e="left center";break;case"right":e="right center";break;case"top left":e="left top";break;case"top right":e="right top";break;case"bottom left":e="left bottom";break;case"bottom right":e="right bottom";break;default:t="100% 100%",e="0% 0%";break}return{"background-image":this.contentPath?'url("'.concat(this.contentPath,'")'):"none","background-position":e,"background-size":t,"background-repeat":n}}},watch:{src:function(t,e){this._loadImage()},mode:function(t,e){"widthFix"!==e&&"heightFix"!==e||this._resetSize(),"widthFix"!==t&&"heightFix"!==t||this._fixSize()},contentPath:function(t){!t&&this.__img&&(this.__img.remove(),delete this.__img)}},mounted:function(){this.originalStyle.width=this.$el.style.width||"",this.originalStyle.height=this.$el.style.height||"",this._loadImage()},beforeDestroy:function(){this._clearImage()},methods:{_fixSize:function(){if(this.ratio){var t=this.$el;if("widthFix"===this.mode){var e=t.offsetWidth;e&&(t.style.height=a(e/this.ratio)+"px")}else if("heightFix"===this.mode){var n=t.offsetHeight;n&&(t.style.width=a(n*this.ratio)+"px")}}window.dispatchEvent(new CustomEvent("updateview"))},_resetSize:function(){this.$el.style.width=this.originalStyle.width,this.$el.style.height=this.originalStyle.height},_resetData:function(){this.originalWidth=0,this.originalHeight=0,this.contentPath=""},_loadImage:function(){var t=this,e=this.$getRealPath(this.src);if(e){var n=this._img=this._img||new Image;n.onload=function(i){t._img=null;var r=t.originalWidth=n.width,o=t.originalHeight=n.height;t._fixSize(),t.contentPath=e,n.draggable=t.draggable,t.__img&&t.__img.remove(),t.__img=n,t.$el.appendChild(n),t.$trigger("load",i,{width:r,height:o})},n.onerror=function(e){t._img=null,t._resetData(),t.$trigger("error",e,{errMsg:"GET ".concat(t.src," 404 (Not Found)")})},n.src=e}else this._clearImage(),this._resetData()},_clearImage:function(){var t=this._img;t&&(t.onload=null,t.onerror=null,this._img=null)}}},c=s,u=(n("db18"),n("2877")),l=Object(u["a"])(c,i,r,!1,null,null,null);e["default"]=l.exports},1307:function(t,e,n){},"14db":function(t,e,n){"use strict";var i=n("c58b"),r=n.n(i);r.a},"17fd":function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.hoverClass&&"none"!==t.hoverClass?n("uni-navigator",t._g({class:[t.hovering?t.hoverClass:""],on:{touchstart:t._hoverTouchStart,touchend:t._hoverTouchEnd,touchcancel:t._hoverTouchCancel,mousedown:t._hoverMousedown,mouseup:t._hoverMouseup,click:t._onClick}},t.$listeners),[t._t("default")],2):n("uni-navigator",t._g({on:{click:t._onClick}},t.$listeners),[t._t("default")],2)},r=[],o=n("8af1"),a=["navigate","redirect","switchTab","reLaunch","navigateBack"],s=["slide-in-right","slide-in-left","slide-in-top","slide-in-bottom","fade-in","zoom-out","zoom-fade-out","pop-in","none"],c=["slide-out-right","slide-out-left","slide-out-top","slide-out-bottom","fade-out","zoom-in","zoom-fade-in","pop-out","none"],u={name:"Navigator",mixins:[o["c"]],props:{hoverClass:{type:String,default:"navigator-hover"},url:{type:String,default:""},openType:{type:String,default:"navigate",validator:function(t){return~a.indexOf(t)}},delta:{type:Number,default:1},hoverStartTime:{type:[Number,String],default:50},hoverStayTime:{type:[Number,String],default:600},exists:{type:String,default:""},animationType:{type:String,validator:function(t){return!t||~s.concat(c).indexOf(t)},default:""},animationDuration:{type:[String,Number],default:300}},methods:{_onClick:function(t){if("navigateBack"===this.openType||this.url){var e=parseInt(this.animationDuration);switch(this.openType){case"navigate":uni.navigateTo({url:this.url,animationType:this.animationType||"pop-in",animationDuration:e});break;case"redirect":uni.redirectTo({url:this.url,exists:this.exists});break;case"switchTab":uni.switchTab({url:this.url});break;case"reLaunch":uni.reLaunch({url:this.url});break;case"navigateBack":uni.navigateBack({delta:this.delta,animationType:this.animationType||"pop-out",animationDuration:e});break;default:break}}else console.error(" should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab")}}},l=u,h=(n("f7fd"),n("2877")),d=Object(h["a"])(l,i,r,!1,null,null,null);e["default"]=d.exports},"18fd":function(t,e,n){"use strict";n.d(e,"a",(function(){return d}));var i=/^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,r=/^<\/([-A-Za-z0-9_]+)[^>]*>/,o=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g,a=f("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"),s=f("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"),c=f("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),u=f("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),l=f("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),h=f("script,style");function d(t,e){var n,d,f,p=[],v=t;p.last=function(){return this[this.length-1]};while(t){if(d=!0,p.last()&&h[p.last()])t=t.replace(new RegExp("([\\s\\S]*?)]*>"),(function(t,n){return n=n.replace(/|/g,"$1$2"),e.chars&&e.chars(n),""})),_("",p.last());else if(0==t.indexOf("\x3c!--")?(n=t.indexOf("--\x3e"),n>=0&&(e.comment&&e.comment(t.substring(4,n)),t=t.substring(n+3),d=!1)):0==t.indexOf("=0;i--)if(p[i]==n)break}else var i=0;if(i>=0){for(var r=p.length-1;r>=i;r--)e.end&&e.end(p[r]);p.length=i}}_()}function f(t){for(var e={},n=t.split(","),i=0;i*{height: ").concat(t,"px;overflow: hidden;}"),document.head.appendChild(e)},_handleTrack:function(t){if(this._scroller)switch(t.detail.state){case"start":this._handleTouchStart(t),Object(s["a"])({disable:!0});break;case"move":this._handleTouchMove(t),t.stopPropagation();break;case"end":case"cancel":this._handleTouchEnd(t),Object(s["a"])({disable:!1})}},_handleTap:function(t){var e=t.clientY;if(!this._scroller.isScrolling()){var n=this.$el.getBoundingClientRect(),i=e-n.top-this.height/2,r=this.indicatorHeight/2;if(!(Math.abs(i)<=r)){var o=Math.ceil((Math.abs(i)-r)/this.indicatorHeight),a=i<0?-o:o,s=Math.min(this.current+a,this.length-1);this.current=s=Math.max(s,0),this._scroller.scrollTo(s*this.indicatorHeight)}}},_handleWheel:function(t){var e=this.deltaY+t.deltaY;if(Math.abs(e)>10){this.deltaY=0;var n=Math.min(this.current+(e<0?-1:1),this.length-1);this.current=n=Math.max(n,0),this._scroller.scrollTo(n*this.indicatorHeight)}else this.deltaY=e;t.preventDefault()},setCurrent:function(t){t!==this.current&&(this.current=t,this.inited&&this.update())},init:function(){var t=this;this.initScroller(this.$refs.content,{enableY:!0,enableX:!1,enableSnap:!0,itemSize:this.indicatorHeight,friction:new o["a"](1e-4),spring:new a["a"](2,90,20),onSnap:function(e){isNaN(e)||e===t.current||(t.current=e)}}),this.inited=!0},update:function(){var t=this;this.$nextTick((function(){var e=Math.min(t.current,t.length-1);e=Math.max(e,0),t._scroller.update(e*t.indicatorHeight,void 0,t.indicatorHeight)}))},_resize:function(t){var e=t.height;this.indicatorHeight=e}},render:function(t){return this.length=this.$slots.default&&this.$slots.default.length||0,t("uni-picker-view-column",{on:{on:this.$listeners}},[t("div",{ref:"main",staticClass:"uni-picker-view-group",on:{wheel:this._handleWheel,click:this._handleTap}},[t("div",{ref:"mask",staticClass:"uni-picker-view-mask",class:this.maskClass,style:"background-size: 100% ".concat(this.maskSize,"px;").concat(this.maskStyle)}),t("div",{ref:"indicator",staticClass:"uni-picker-view-indicator",class:this.indicatorClass,style:this.indicatorStyle},[t("v-uni-resize-sensor",{attrs:{initial:!0},on:{resize:this._resize}})]),t("div",{ref:"content",staticClass:"uni-picker-view-content",class:this.scope,style:"padding: ".concat(this.maskSize,"px 0;")},[this.$slots.default])])])}},d=h,f=(n("edfa"),n("2877")),p=Object(f["a"])(d,u,l,!1,null,null,null);e["default"]=p.exports},"1b6f":function(t,e,n){"use strict";(function(t){var i=n("f2b3");e["a"]={mounted:function(){var t=this;this._toggleListeners("subscribe",this.id),this.$watch("id",(function(e,n){t._toggleListeners("unsubscribe",n,!0),t._toggleListeners("subscribe",e,!0)}))},beforeDestroy:function(){this._toggleListeners("unsubscribe",this.id),this._contextId&&this._toggleListeners("unsubscribe",this._contextId)},methods:{_toggleListeners:function(e,n,r){r&&!n||Object(i["f"])(this._handleSubscribe)&&t[e](this.$page.id+"-"+this.$options.name.replace(/VUni([A-Z])/,"$1").toLowerCase()+"-"+n,this._handleSubscribe)},_getContextInfo:function(){var t="context-".concat(this._uid);return this._contextId||(this._toggleListeners("subscribe",t),this._contextId=t),{name:this.$options.name.replace(/VUni([A-Z])/,"$1").toLowerCase(),id:t,page:this.$page.id}}}}}).call(this,n("501c"))},"1c64":function(t,e,n){"use strict";var i=n("60ee"),r=n.n(i);r.a},"1c73":function(t,e,n){"use strict";(function(t){n.d(e,"b",(function(){return s})),n.d(e,"a",(function(){return c}));var i={},r={};function o(t){for(var e=[],n=["width","minWidth","maxWidth","height","minHeight","maxHeight","orientation"],i=0,r=n;i=0&&e.push("(".concat(a(o),": ").concat(Number(t[o]),"px)")),"orientation"===o&&t[o]&&e.push("(".concat(a(o),": ").concat(t[o],")"))}return e=e.join(" and "),e}function a(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function s(e){var n=e.reqId,a=e.options,s=i[n]=window.matchMedia(o(a)),c=r[n]=function(e){t.publishHandler("onRequestMediaQueryObserver",{reqId:n,res:e.matches})};c(s),s.addListener(c)}function c(e){var n=e.reqId,o=r[n],a=i[n];a&&(a.removeListener(o),delete i[n],t.publishHandler("onRequestMediaQueryObserver",{reqId:n,reqEnd:!0}))}}).call(this,n("501c"))},"1e88":function(t,e,n){"use strict";function i(){return{top:0,bottom:0,left:0,right:0}}n.d(e,"a",(function(){return i}))},"1efd":function(t,e,n){"use strict";n.r(e);var i=n("e571"),r=n("a34f"),o=n("d4b6"),a={methods:{$getRealPath:function(t){return t?Object(r["a"])(t):t},$trigger:function(t,e,n){this.$emit(t,o["b"].call(this,t,e,n,this.$el,this.$el))}}},s=n("9b52"),c=[n("5408"),n("1922")],u={};n("d16b");var l=n("0094");for(var h in u=l.default||l,u)customElements.define("uni-".concat(h.toLowerCase()),u[h]);c.forEach((function(t,e){t.keys().forEach((function(e){var n=t(e),r=n.default||n;r.mixins=r.mixins?[].concat(a,r.mixins):[a],r.functional||r.mixins.push(s["a"]),r.name="VUni"+r.name,r.isReserved=!0,i["a"].component(r.name,r)}))}))},"1f56":function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-video",t._g({},t.$listeners),[n("div",{ref:"container",staticClass:"uni-video-container"}),n("div",{staticClass:"uni-video-slot"},[t._t("default")],2)])},r=[],o=n("8af1"),a=n("0aa0");function s(t){return s="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function u(t){for(var e=1;e-1:t.valueSync},on:{change:[function(e){var n=t.valueSync,i=e.target,r=!!i.checked;if(Array.isArray(n)){var o=null,a=t._i(n,o);i.checked?a<0&&(t.valueSync=n.concat([o])):a>-1&&(t.valueSync=n.slice(0,a).concat(n.slice(a+1)))}else t.valueSync=r},function(t){t.stopPropagation()}],focus:t._onFocus,blur:t._onBlur,input:function(e){return e.stopPropagation(),t._onInput(e)},compositionstart:function(e){return e.stopPropagation(),t._onComposition(e)},compositionend:function(e){return e.stopPropagation(),t._onComposition(e)},compositionupdate:function(e){return e.stopPropagation(),t._onComposition(e)},keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:(e.stopPropagation(),t._onKeyup(e))}}}),t.disabled&&t.fixColor?n("input",{ref:"input",staticClass:"uni-input-input",attrs:{tabindex:"-1",readonly:t.disabled,type:t.inputType,maxlength:t.maxlength,step:t._step},domProps:{value:t.valueSync},on:{focus:function(t){return t.target.blur()}}}):t._e()])])},r=[],o=n("8af1"),a=n("f2b3"),s=["text","number","idcard","digit","password","tel"],c=["number","digit"],u=["off","one-time-code"],l={name:"Input",mixins:[o["b"]],props:{name:{type:String,default:""},type:{type:String,default:"text"},password:{type:[Boolean,String],default:!1},placeholder:{type:String,default:""},placeholderStyle:{type:String,default:""},placeholderClass:{type:String,default:"input-placeholder"},disabled:{type:[Boolean,String],default:!1},maxlength:{type:[Number,String],default:140},confirmType:{type:String,default:"done"},textContentType:{type:String,default:""},step:{type:String,default:"0.000000000000000001"}},data:function(){return{wrapperHeight:0,cachedValue:""}},computed:{inputType:function(){var t="";switch(this.type){case"text":"search"===this.confirmType&&(t="search");break;case"idcard":t="text";break;case"digit":t="number";break;default:t=~s.indexOf(this.type)?this.type:"text";break}return this.password?"password":t},_step:function(){return~c.indexOf(this.type)?this.step:""},autocomplete:function(){var t=u.indexOf(this.textContentType),e=u.indexOf(Object(a["i"])(this.textContentType)),n=-1!==t?t:-1!==e?e:0;return u[n]},inputmode:function(){switch(this.type){case"digit":return"decimal";default:return}}},watch:{maxlength:function(t){var e=this.valueSync.slice(0,parseInt(t,10));e!==this.valueSync&&(this.valueSync=e)},valueSync:function(t){"number"!==this.type||"-"===this.cachedValue&&""===t||(this.cachedValue=t)}},created:function(){this.$dispatch("Form","uni-form-group-update",{type:"add",vm:this})},mounted:function(){if("search"===this.confirmType){var t=document.createElement("form");t.action="",t.onsubmit=function(){return!1},t.className="uni-input-form",t.appendChild(this.$refs.input),this.$refs.wrapper.appendChild(t)}var e=this;while(e){var n=e.$options._scopeId;n&&this.$refs.placeholder.setAttribute(n,""),e=e.$parent}},beforeDestroy:function(){this.$dispatch("Form","uni-form-group-update",{type:"remove",vm:this})},methods:{_onKeyup:function(t){var e=t.target;this.$trigger("confirm",t,{value:e.value}),this.confirmHold||e.blur()},_onInput:function(t,e){var n=this,i=!1;if(!this.composing||!this.ignoreCompositionEvent){if("number"===this.inputType){var r=parseInt(this.maxlength,10);if(r>0&&t.target.value.length>r&&(this.cachedValue.length===r?(this.valueSync=this.cachedValue,i=!0):(t.target.value=t.target.value.slice(0,r),this.valueSync=t.target.value)),this.__clearCachedValue&&t.target.removeEventListener("blur",this.__clearCachedValue),t.target.validity&&!t.target.validity.valid){if(!this.cachedValue&&"-"===t.data||"-"===this.cachedValue[0]&&"deleteContentBackward"===t.inputType){this.cachedValue="-";var o=this.__clearCachedValue=function(){n.cachedValue=""};return void t.target.addEventListener("blur",o)}if(this.cachedValue)if(-1!==this.cachedValue.indexOf(".")){if("."!==t.data&&"deleteContentBackward"===t.inputType){var a=this.cachedValue.indexOf(".");return this.cachedValue=t.target.value=this.valueSync=this.cachedValue.slice(0,a),this.$triggerInput(t,{value:this.valueSync},e)}}else if("."===t.data)return this.cachedValue+=".",this.__clearCachedValue=function(){n.cachedValue=n.valueSync=t.target.value=n.cachedValue.slice(0,-1)},t.target.addEventListener("blur",this.__clearCachedValue),!1;return void(this.cachedValue=this.valueSync=t.target.value="-"===this.cachedValue?"":this.cachedValue)}this.cachedValue=this.valueSync}i||(this.ignoreCompositionEvent||(this.valueSync=this.$refs.input.value),this.$triggerInput(t,{value:this.valueSync},e))}},_onComposition:function(t){switch(t.type){case"compositionstart":this.composing=!0;break;case"compositionend":this.composing&&(this.composing=!1,this._onInput(t));break}!this.ignoreCompositionEvent&&this.$trigger(t.type,t,{data:t.data})},_resetFormData:function(){this.valueSync=""},_getFormData:function(){return this.name?{value:this.valueSync,key:this.name}:{}}}},h=l,d=(n("0f55"),n("2877")),f=Object(d["a"])(h,i,r,!1,null,null,null);e["default"]=f.exports},2522:function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var i="onPageCreate"},"25ce":function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-checkbox-group",t._g({},t.$listeners),[t._t("default")],2)},r=[],o=n("8af1"),a={name:"CheckboxGroup",mixins:[o["a"],o["e"]],props:{name:{type:String,default:""}},data:function(){return{checkboxList:[]}},listeners:{"@checkbox-change":"_changeHandler","@checkbox-group-update":"_checkboxGroupUpdateHandler"},created:function(){this.$dispatch("Form","uni-form-group-update",{type:"add",vm:this})},beforeDestroy:function(){this.$dispatch("Form","uni-form-group-update",{type:"remove",vm:this})},methods:{_changeHandler:function(t){var e=[];this.checkboxList.forEach((function(t){t.checkboxChecked&&e.push(t.value)})),this.$trigger("change",t,{value:e})},_checkboxGroupUpdateHandler:function(t){if("add"===t.type)this.checkboxList.push(t.vm);else{var e=this.checkboxList.indexOf(t.vm);this.checkboxList.splice(e,1)}},_getFormData:function(){var t={};if(""!==this.name){var e=[];this.checkboxList.forEach((function(t){t.checkboxChecked&&e.push(t.value)})),t.value=e,t.key=this.name}return t}}},s=a,c=(n("0998"),n("2877")),u=Object(c["a"])(s,i,r,!1,null,null,null);e["default"]=u.exports},"27ab":function(t,e,n){"use strict";n.r(e);var i=n("f2b3");function r(t){return c(t)||s(t)||a(t)||o()}function o(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(t,e){if(t){if("string"===typeof t)return u(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,e):void 0}}function s(t){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}function c(t){if(Array.isArray(t))return u(t)}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n=0)&&(this.valueSync.length=t.length,t.forEach((function(t,e){t!==n.valueSync[e]&&n.$set(n.valueSync,e,t)})))},valueSync:{deep:!0,handler:function(t,e){if(""===this.changeSource)this._valueChanged(t);else{this.changeSource="";var n=t.map((function(t){return t}));this.$emit("update:value",n),this.$trigger("change",{},{value:n})}}}},methods:{getItemIndex:function(t){return this.items.indexOf(t)},getItemValue:function(t){return this.valueSync[this.getItemIndex(t.$vnode)]||0},setItemValue:function(t,e){var n=this.getItemIndex(t.$vnode),i=this.valueSync[n];i!==e&&(this.changeSource="touch",this.$set(this.valueSync,n,e))},_valueChanged:function(t){this.items.forEach((function(e,n){e.componentInstance.setCurrent(t[n]||0)}))},_resize:function(t){var e=t.height;this.height=e}},render:function(t){var e=[];return this.$slots.default&&Object(i["d"])(this.$slots.default,t).forEach((function(t){t.componentOptions&&"v-uni-picker-view-column"===t.componentOptions.tag&&e.push(t)})),this.items=e,t("uni-picker-view",{on:this.$listeners},[t("v-uni-resize-sensor",{attrs:{initial:!0},on:{resize:this._resize}}),t("div",{ref:"wrapper",class:"uni-picker-view-wrapper"},e)])}},f=d,p=(n("6062"),n("2877")),v=Object(p["a"])(f,l,h,!1,null,null,null);e["default"]=v.exports},"27c2":function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-editor",t._g({staticClass:"ql-container",attrs:{id:t.id}},t.$listeners))},r=[],o=n("3e4d"),a=o["a"],s=(n("e298"),n("2877")),c=Object(s["a"])(a,i,r,!1,null,null,null);e["default"]=c.exports},"27ef":function(t,e,n){"use strict";var i=n("a250"),r=n.n(i);r.a},"286b":function(t,e,n){"use strict";(function(t){var i=n("8af1"),r=n("0aa0"),o=["getCenterLocation","moveToLocation","getRegion","getScale","$getAppMap"],a=["latitude","longitude","scale","markers","polyline","polygons","circles","controls","show-location"],s=function(t,e,n){n({coord:{latitude:e,longitude:t}})};function c(t){if(0!==t.indexOf("#"))return{color:t,opacity:1};var e=t.substr(7,2);return{color:t.substr(0,7),opacity:e?Number("0x"+e)/255:1}}e["a"]={name:"Map",mixins:[i["f"],r["a"]],props:{id:{type:String,default:""},latitude:{type:[Number,String],default:""},longitude:{type:[Number,String],default:""},scale:{type:[String,Number],default:16},markers:{type:Array,default:function(){return[]}},polyline:{type:Array,default:function(){return[]}},circles:{type:Array,default:function(){return[]}},polygons:{type:Array,default:function(){return[]}},controls:{type:Array,default:function(){return[]}}},data:function(){return{style:{top:"0px",left:"0px",width:"0px",height:"0px",position:"static"},hidden:!1}},computed:{attrs:function(){var t=this,e={};return a.forEach((function(n){var i=t.$props[n];i="src"===n?t.$getRealPath(i):i,e[n.replace(/[A-Z]/g,(function(t){return"-"+t.toLowerCase()}))]=i})),e},mapControls:function(){var t=this,e=this.controls.map((function(e){var n={position:"absolute"};return["top","left","width","height"].forEach((function(t){e.position[t]&&(n[t]=e.position[t]+"px")})),{id:e.id,iconPath:t.$getRealPath(e.iconPath),position:n}}));return e}},watch:{hidden:function(t){this.map&&this.map[t?"hide":"show"]()},scale:function(t){this.map&&this.map.setZoom(parseInt(t))},latitude:function(t){this.map&&this.map.setStyles({center:new plus.maps.Point(this.longitude,this.latitude)})},longitude:function(t){this.map&&this.map.setStyles({center:new plus.maps.Point(this.longitude,this.latitude)})},markers:function(t){this.map&&this._addMarkers(t,!0)},polyline:function(t){this.map&&this._addMapLines(t)},circles:function(t){this.map&&this._addMapCircles(t)},polygons:function(t){this.map&&this._addMapPolygons(t)}},mounted:function(){var t=this;this._onParentReady((function(){var e=Object.assign({},t.attrs,t.position);t.latitude&&t.longitude&&(e.center=new plus.maps.Point(t.longitude,t.latitude));var n=t.map=plus.maps.create(t.$page.id+"-map-"+(t.id||Date.now()),e);n.__markers__=[],n.__markers_map__={},n.__lines__=[],n.__circles__=[],n.__polygons__=[],n.setZoom(parseInt(t.scale)),plus.webview.currentWebview().append(n),t.hidden&&n.hide(),t.$watch("position",(function(){t.map&&t.map.setStyles(t.position)}),{deep:!0}),n.onclick=function(e){t.$trigger("click",{},e)},n.onstatuschanged=function(e){t.$trigger("regionchange",{},{})},t._addMarkers(t.markers),t._addMapLines(t.polyline),t._addMapCircles(t.circles),t._addMapPolygons(t.polygons)}))},beforeDestroy:function(){this.map&&this.map.close(),delete this.map},methods:{_handleSubscribe:function(t){var e=t.type,n=t.data,i=void 0===n?{}:n;o.includes(e)&&this.map&&this[e](i)},moveToLocation:function(t){var e=t.callbackId,n=t.longitude,i=t.latitude;this.map.setCenter(new plus.maps.Point(n||this.longitude,i||this.latitude)),this._publishHandler(e,{errMsg:"moveToLocation:ok"})},getCenterLocation:function(t){var e=this,n=t.callbackId;this.map.getCurrentCenter((function(t,i){e._publishHandler(n,{longitude:i.longitude,latitude:i.latitude,errMsg:"getCenterLocation:ok"})}))},getRegion:function(t){var e=t.callbackId,n=this.map.getBounds();this._publishHandler(e,{southwest:n.southwest,northeast:n.northeast||n.northease,errMsg:"getRegion:ok"})},getScale:function(t){var e=t.callbackId;this._publishHandler(e,{scale:this.map.getZoom(),errMsg:"getScale:ok"})},controlclick:function(t){this.$trigger("controltap",{},{controlId:t.id})},_publishHandler:function(e,n){t.publishHandler("onMapMethodCallback",{callbackId:e,data:n},this.$page.id)},_addMarker:function(t,e){var n=this,i=e.id,r=e.latitude,o=e.longitude,a=e.iconPath,c=e.callout,u=e.label;s(o,r,(function(e){var r=e.coord,o=r.latitude,s=r.longitude,l=new plus.maps.Marker(new plus.maps.Point(s,o));a&&l.setIcon(n.$getRealPath(a)),u&&u.content&&l.setLabel(u.content);var h=!1;c&&c.content&&(h=new plus.maps.Bubble(c.content)),h&&l.setBubble(h),(i||0===i)&&(l.onclick=function(t){n.$trigger("markertap",{},{markerId:i,latitude:o,longitude:s})},h&&(h.onclick=function(){n.$trigger("callouttap",{},{markerId:i})})),t.addOverlay(l),t.__markers__.push(l),t.__markers_map__[i+""]=l}))},_clearMarkers:function(){var t=this.map,e=t.__markers__;e.forEach((function(e){t.removeOverlay(e)})),t.__markers__=[],t.__markers_map__={}},_addMarkers:function(t,e){var n=this;e&&this._clearMarkers(),t.forEach((function(t){n._addMarker(n.map,t)}))},_translateMapMarker:function(t){t.autoRotate,t.callbackId;var e=t.destination,n=(t.duration,t.markerId),i=this.map.__markers_map__[n+""];i&&i.setPoint(new plus.maps.Point(e.longitude,e.latitude))},_addMapLines:function(t){var e=this.map;e.__lines__.length>0&&(e.__lines__.forEach((function(t){e.removeOverlay(t)})),e.__lines__=[]),t.forEach((function(t){var n=t.color,i=t.width,r=t.points.map((function(t){return new plus.maps.Point(t.longitude,t.latitude)})),o=new plus.maps.Polyline(r);if(n){var a=c(n);o.setStrokeColor(a.color),o.setStrokeOpacity(a.opacity)}i&&o.setLineWidth(i),e.addOverlay(o),e.__lines__.push(o)}))},_addMapCircles:function(t){var e=this.map;e.__circles__.length>0&&(e.__circles__.forEach((function(t){e.removeOverlay(t)})),e.__circles__=[]),t.forEach((function(t){var n=t.latitude,i=t.longitude,r=t.color,o=t.fillColor,a=t.radius,s=t.strokeWidth,u=new plus.maps.Circle(new plus.maps.Point(i,n),a);if(r){var l=c(r);u.setStrokeColor(l.color),u.setStrokeOpacity(l.opacity)}if(o){var h=c(o);u.setFillColor(h.color),u.setFillOpacity(h.opacity)}s&&u.setLineWidth(s),e.addOverlay(u),e.__circles__.push(u)}))},_addMapPolygons:function(t){var e=this.map,n=e.__polygons__;n.forEach((function(t){e.removeOverlay(t)})),n.length=0,t.forEach((function(t){var i=t.points,r=t.strokeWidth,o=t.strokeColor,a=t.fillColor,s=[];i&&i.forEach((function(t){var e=t.latitude,n=t.longitude;s.push(new plus.maps.Point(n,e))}));var u=new plus.maps.Polygon(s);if(o){var l=c(o);u.setStrokeColor(l.color),u.setStrokeOpacity(l.opacity)}if(a){var h=c(a);u.setFillColor(h.color),u.setFillOpacity(h.opacity)}r&&u.setLineWidth(r),e.addOverlay(u),n.push(u)}))}}}}).call(this,n("501c"))},2877:function(t,e,n){"use strict";function i(t,e,n,i,r,o,a,s){var c,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),a?(c=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=c):r&&(c=s?function(){r.call(this,this.$root.$options.shadowRoot)}:r),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var h=u.beforeCreate;u.beforeCreate=h?[].concat(h,c):[c]}return{exports:t,options:u}}n.d(e,"a",(function(){return i}))},"28e4":function(t,e,n){"use strict";function i(t){return new Promise((function(e,n){function i(){var i=new plus.nativeObj.Bitmap("bitmap_".concat(Date.now(),"_").concat(Math.random(),"}"));i.load(t,(function(){e(i.toBase64Data()),i.clear()}),(function(t){i.clear(),n(t)}))}plus.io.resolveLocalFileSystemURL(t,(function(t){t.file((function(t){var n=new plus.io.FileReader;n.onload=function(t){e(t.target.result)},n.onerror=i,n.readAsDataURL(t)}),i)}),i)}))}function r(t){return new Promise((function(e,n){0===t.indexOf("http://")||0===t.indexOf("https://")?plus.downloader.createDownload(t,{filename:"_doc/uniapp_temp/download/"},(function(t,i){200===i?e(t.filename):n(new Error("network fail"))})).start():e(t)}))}function o(t){return r(t).then((function(t){return window.webkit&&window.webkit.messageHandlers?i(t):plus.io.convertLocalFileSystemURL(t)}))}n.d(e,"a",(function(){return o}))},2937:function(t,e,n){},"2a0a":function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return s}));var i,r,o=n("f2b3");function a(){Object(o["j"])((function(){i||(i=plus.webview.currentWebview()),r||(r=(i.getStyle()||{}).pullToRefresh||{})}))}function s(t){var e=t.disable;r&&r.support&&i.setPullToRefresh(Object.assign({},r,{support:!e}))}},"2c45":function(t,e,n){},"2ceb":function(t,e,n){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},"2df3":function(t,e,n){"use strict";var i=n("b1a3"),r=n.n(i);r.a},"33b4":function(t,e,n){},"33ed":function(t,e,n){"use strict";(function(t){n.d(e,"b",(function(){return o})),n.d(e,"c",(function(){return a})),n.d(e,"a",(function(){return c}));var i,r=n("5bb5");function o(t){t.preventDefault()}function a(t){var e=t.scrollTop,n=t.selector,i=t.duration;if("undefined"===typeof e){var r=document.querySelector(n);if(r){var o=r.getBoundingClientRect(),a=o.top;o.height;e=a+window.pageYOffset}}var s=document.documentElement,c=s.clientHeight,u=s.scrollHeight;function l(t){if(t<=0)window.scrollTo(0,e);else{var n=e-window.scrollY;requestAnimationFrame((function(){window.scrollTo(0,window.scrollY+n/t*10),l(t-10)}))}}e=Math.min(e,u-c),0!==i?window.scrollY!==e&&l(i):s.scrollTop=document.body.scrollTop=e}var s=0;function c(e,n){var o=n.enablePageScroll,a=n.enablePageReachBottom,c=n.onReachBottomDistance,u=n.enableTransparentTitleNView,l=!1,h=!1,d=!0;function f(){var t=document.documentElement.scrollHeight,e=window.innerHeight,n=window.scrollY,i=n>0&&t>e&&n+e+c>=t,r=Math.abs(t-s)>c;return!i||h&&!r?(!i&&h&&(h=!1),!1):(s=t,h=!0,!0)}function p(){var n=getCurrentPages();if(n.length&&n[n.length-1].$page.id===e){var s=window.pageYOffset;o&&Object(r["a"])("onPageScroll",{scrollTop:s},e),u&&t.emit("onPageScroll",{scrollTop:s}),a&&d&&(c()||(i=setTimeout(c,300))),l=!1}function c(){if(f())return Object(r["a"])("onReachBottom",{},e),d=!1,setTimeout((function(){d=!0}),350),!0}}return function(){clearTimeout(i),l||requestAnimationFrame(p),l=!0}}}).call(this,n("501c"))},3878:function(t,e){var n,i;0===String(navigator.vendor).indexOf("Apple")&&document.documentElement.addEventListener("click",(function(t){var e=450,r=44;clearTimeout(i),n&&Math.abs(t.pageX-n.pageX)<=r&&Math.abs(t.pageY-n.pageY)<=r&&t.timeStamp-n.timeStamp<=e&&t.preventDefault(),n=t,i=setTimeout((function(){n=null}),e)}))},"39aa":function(t){t.exports=JSON.parse('{"uni.app.quit":"Press back button again to exit","uni.async.error":"The connection timed out, click the screen to try again.","uni.showActionSheet.cancel":"Cancel","uni.showToast.unpaired":"Please note showToast must be paired with hideToast","uni.showLoading.unpaired":"Please note showLoading must be paired with hideLoading","uni.showModal.cancel":"Cancel","uni.showModal.confirm":"OK","uni.chooseImage.cancel":"Cancel","uni.chooseImage.sourceType.album":"Album","uni.chooseImage.sourceType.camera":"Camera","uni.chooseVideo.cancel":"Cancel","uni.chooseVideo.sourceType.album":"Album","uni.chooseVideo.sourceType.camera":"Camera","uni.chooseFile.notUserActivation":"File chooser dialog can only be shown with a user activation","uni.previewImage.cancel":"Cancel","uni.previewImage.button.save":"Save Image","uni.previewImage.save.success":"Saved successfully","uni.previewImage.save.fail":"Save failed","uni.setClipboardData.success":"Content copied","uni.scanCode.title":"Scan code","uni.scanCode.album":"Album","uni.scanCode.fail":"Recognition failure","uni.scanCode.flash.on":"Tap to turn light on","uni.scanCode.flash.off":"Tap to turn light off","uni.startSoterAuthentication.authContent":"Fingerprint recognition","uni.picker.done":"Done","uni.picker.cancel":"Cancel","uni.video.danmu":"Danmu","uni.video.volume":"Volume","uni.button.feedback.title":"feedback","uni.button.feedback.send":"send","uni.chooseLocation.search":"Find Place","uni.chooseLocation.cancel":"Cancel"}')},"39ba":function(t,e,n){"use strict";n.r(e);var i,r,o=n("0aa0"),a=n("5077"),s={name:"CoverView",mixins:[o["a"],a["a"]],props:{},data:function(){return{coverType:"text",coverContent:""}},render:function(t){var e="",n=this.$slots.default||[],i=n.filter((function(t){return t.tag}));return i.length?e=i:(n.forEach((function(t){t.tag||(e+=t.text||"")})),this.coverContent=e),t("uni-cover-view",{on:{on:this.$listeners}},[t("div",{ref:"container",staticClass:"uni-cover-view"},[].concat(e))])}},c=s,u=(n("4ba9"),n("2877")),l=Object(u["a"])(c,i,r,!1,null,null,null);e["default"]=l.exports},"3c47":function(t,e,n){"use strict";(function(t){var i=n("8af1");e["a"]={name:"Label",mixins:[i["a"]],props:{for:{type:String,default:""}},computed:{pointer:function(){return this.for||this.$slots.default&&this.$slots.default.length}},methods:{_onClick:function(e){var n=/^uni-(checkbox|radio|switch)-/.test(e.target.className);n||(n=/^uni-(checkbox|radio|switch|button)$/i.test(e.target.tagName)),n||(this.for?t.emit("uni-label-click-"+this.$page.id+"-"+this.for,e,!0):this.$broadcast(["Checkbox","Radio","Switch","Button"],"uni-label-click",e,!0))}}}}).call(this,n("501c"))},"3c79":function(t,e,n){},"3e4d":function(t,e,n){"use strict";(function(t){var i=n("8af1"),r=n("18fd"),o=n("b253"),a=n("93ab");function s(t){return s="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function c(){return"ios"===plus.os.name.toLowerCase()}e["a"]={name:"Editor",mixins:[i["f"],i["a"],i["d"]],props:{id:{type:String,default:""},readOnly:{type:[Boolean,String],default:!1},placeholder:{type:String,default:""},showImgSize:{type:[Boolean,String],default:!1},showImgToolbar:{type:[Boolean,String],default:!1},showImgResize:{type:[Boolean,String],default:!1}},data:function(){return{quillReady:!1}},computed:{},watch:{readOnly:function(t){if(this.quillReady){var e=this.quill;e.enable(!t),t||e.blur()}},placeholder:function(t){this.quillReady&&this.setPlaceHolder(t)}},mounted:function(){var t=this,e=[];this.showImgSize&&e.push("DisplaySize"),this.showImgToolbar&&e.push("Toolbar"),this.showImgResize&&e.push("Resize");var n="./__uniappquill.js";Object(a["a"])(window.Quill,n,(function(){if(e.length){var n="./__uniappquillimageresize.js";Object(a["a"])(window.ImageResize,n,(function(){t.initQuill(e)}))}else t.initQuill(e)}))},methods:{_textChangeHandler:function(){this.$trigger("input",{},this.getContents())},_handleSubscribe:function(e){var n,i,r,o=this,a=e.type,c=e.data,u=c.options,l=c.callbackId,h=this.quill,d=window.Quill;if(this.quillReady){switch(a){case"format":var f=u.name,p=void 0===f?"":f,v=u.value,m=void 0!==v&&v;i=h.getSelection(!0);var g=h.getFormat(i)[p]||!1;if(["bold","italic","underline","strike","ins"].includes(p))m=!g;else if("direction"===p){m=("rtl"!==m||!g)&&m;var _=h.getFormat(i).align;"rtl"!==m||_?m||"right"!==_||h.format("align",!1,d.sources.USER):h.format("align","right",d.sources.USER)}else if("indent"===p){var b="rtl"===h.getFormat(i).direction;m="+1"===m,b&&(m=!m),m=m?"+1":"-1"}else"list"===p&&(m="check"===m?"unchecked":m,g="checked"===g?"unchecked":g),m=g&&g!==(m||!1)||!g&&m?m:!g;h.format(p,m,d.sources.USER);break;case"insertDivider":i=h.getSelection(!0),h.insertText(i.index,"\n",d.sources.USER),h.insertEmbed(i.index+1,"divider",!0,d.sources.USER),h.setSelection(i.index+2,d.sources.SILENT);break;case"insertImage":i=h.getSelection(!0);var y=u.src,w=void 0===y?"":y,S=u.alt,k=void 0===S?"":S,x=u.width,C=void 0===x?"":x,T=u.height,O=void 0===T?"":T,$=u.extClass,E=void 0===$?"":$,I=u.data,A=void 0===I?{}:I,M=this.$getRealPath(w);h.insertEmbed(i.index,"image",M,d.sources.SILENT);var P=!!/^(file|blob):/.test(M)&&M;h.formatText(i.index,1,"data-local",P,d.sources.SILENT),h.formatText(i.index,1,"alt",k,d.sources.SILENT),h.formatText(i.index,1,"width",C,d.sources.SILENT),h.formatText(i.index,1,"height",O,d.sources.SILENT),h.formatText(i.index,1,"class",E,d.sources.SILENT),h.formatText(i.index,1,"data-custom",Object.keys(A).map((function(t){return"".concat(t,"=").concat(A[t])})).join("&"),d.sources.SILENT),h.setSelection(i.index+1,d.sources.SILENT),h.scrollIntoView(),setTimeout((function(){o._textChangeHandler()}),1e3);break;case"insertText":i=h.getSelection(!0);var j=u.text,L=void 0===j?"":j;h.insertText(i.index,L,d.sources.USER),h.setSelection(i.index+L.length,0,d.sources.SILENT);break;case"setContents":var N=u.delta,D=u.html;"object"===s(N)?h.setContents(N,d.sources.SILENT):"string"===typeof D?h.setContents(this.html2delta(D),d.sources.SILENT):r="contents is missing";break;case"getContents":n=this.getContents();break;case"clear":h.setContents([]);break;case"removeFormat":i=h.getSelection(!0);var R=d.import("parchment");i.length?h.removeFormat(i,d.sources.USER):Object.keys(h.getFormat(i)).forEach((function(t){R.query(t,R.Scope.INLINE)&&h.format(t,!1)}));break;case"undo":h.history.undo();break;case"redo":h.history.redo();break;case"blur":h.blur();break;case"getSelectionText":i=h.selection.savedRange,n={text:""},i&&0!==i.length&&(n.text=h.getText(i.index,i.length));break;case"scrollIntoView":h.scrollIntoView();break;default:break}this.updateStatus(i)}else r="not ready";l&&t.publishHandler("onEditorMethodCallback",{callbackId:l,data:Object.assign({},n,{errMsg:"".concat(a,":").concat(r?"fail "+r:"ok")})},this.$page.id)},setPlaceHolder:function(t){var e="data-placeholder",n=this.quill.root;n.getAttribute(e)!==t&&n.setAttribute(e,t)},initQuill:function(t){var e=this,n=window.Quill;o["a"](n);var i={toolbar:!1,readOnly:this.readOnly,placeholder:this.placeholder,modules:{}};t.length&&(n.register("modules/ImageResize",window.ImageResize.default),i.modules.ImageResize={modules:t});var r=this.quill=new n(this.$el,i),a=r.root,s=["focus","blur","input"];s.forEach((function(t){a.addEventListener(t,(function(n){var i=e.getContents();if("input"===t){if(c()){var r=(i.html.match(/([\s\S]*)<\/span>/)||[])[1],o=r&&r.replace(/\s/g,"")?"":e.placeholder;e.setPlaceHolder(o)}n.stopPropagation()}else e.$trigger(t,n,i)}))})),r.on(n.events.TEXT_CHANGE,this._textChangeHandler),r.on(n.events.SELECTION_CHANGE,this.updateStatus.bind(this)),r.on(n.events.SCROLL_OPTIMIZE,(function(){var t=r.selection.getRange()[0];e.updateStatus(t)})),r.clipboard.addMatcher(Node.ELEMENT_NODE,(function(t,n){return e.skipMatcher||(n.ops=n.ops.filter((function(t){var e=t.insert;return"string"===typeof e})).map((function(t){var e=t.insert;return{insert:e}}))),n})),this.initKeyboard(a),this.quillReady=!0,this.$trigger("ready",event,{})},getContents:function(){var t=this.quill,e=t.root["inner"+"HTML"],n=t.getText(),i=t.getContents();return{html:e,text:n,delta:i}},html2delta:function(t){var e,n=["span","strong","b","ins","em","i","u","a","del","s","sub","sup","img","div","p","h1","h2","h3","h4","h5","h6","hr","ol","ul","li","br"],i="";Object(r["a"])(t,{start:function(t,r,o){if(n.includes(t)){e=!1;var a=r.map((function(t){var e=t.name,n=t.value;return"".concat(e,'="').concat(n,'"')})).join(" "),s="<".concat(t," ").concat(a," ").concat(o?"/":"",">");i+=s}else e=!o},end:function(t){e||(i+=""))},chars:function(t){e||(i+=t)}}),this.skipMatcher=!0;var o=this.quill.clipboard.convert(i);return this.skipMatcher=!1,o},updateStatus:function(t){var e=this,n=t?this.quill.getFormat(t):{},i=Object.keys(n);(i.length!==Object.keys(this.__status||{}).length||i.find((function(t){return n[t]!==e.__status[t]})))&&(this.__status=n,this.$trigger("statuschange",{},n))}}}}).call(this,n("501c"))},"3e5d":function(t,e,n){"use strict";(function(t){n.d(e,"b",(function(){return r})),n.d(e,"a",(function(){return T}));var i,r,o,a=n("e571"),s=n("a20d"),c=n("2522"),u=n("9d20"),l=n("9856"),h=n("2376");function d(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f(t,e){return _(t)||g(t,e)||v(t,e)||p()}function p(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(t,e){if(t){if("string"===typeof t)return m(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(t,e):void 0}}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n3?i-3:0),o=3;o0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var n=i.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==h)throw new Error(a[n]);if(e.header&&i.deflateSetHeader(this.strm,e.header),e.dictionary){var u;if(u="string"===typeof e.dictionary?o.string2buf(e.dictionary):"[object ArrayBuffer]"===c.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=i.deflateSetDictionary(this.strm,u),n!==h)throw new Error(a[n]);this._dict_set=!0}}function _(t,e){var n=new g(e);if(n.push(t,!0),n.err)throw n.msg||a[n.err];return n.result}function b(t,e){return e=e||{},e.raw=!0,_(t,e)}function y(t,e){return e=e||{},e.gzip=!0,_(t,e)}g.prototype.push=function(t,e){var n,a,s=this.strm,p=this.options.chunkSize;if(this.ended)return!1;a=e===~~e?e:!0===e?l:u,"string"===typeof t?s.input=o.string2buf(t):"[object ArrayBuffer]"===c.call(t)?s.input=new Uint8Array(t):s.input=t,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new r.Buf8(p),s.next_out=0,s.avail_out=p),n=i.deflate(s,a),n!==d&&n!==h)return this.onEnd(n),this.ended=!0,!1;0!==s.avail_out&&(0!==s.avail_in||a!==l&&a!==f)||("string"===this.options.to?this.onData(o.buf2binstring(r.shrinkBuf(s.output,s.next_out))):this.onData(r.shrinkBuf(s.output,s.next_out)))}while((s.avail_in>0||0===s.avail_out)&&n!==d);return a===l?(n=i.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===h):a!==f||(this.onEnd(h),s.avail_out=0,!0)},g.prototype.onData=function(t){this.chunks.push(t)},g.prototype.onEnd=function(t){t===h&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Deflate=g,e.deflate=_,e.deflateRaw=b,e.gzip=y},4617:function(t,e,n){"use strict";(function(t){function i(t,e){return c(t)||s(t,e)||o(t,e)||r()}function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(t,e){if(t){if("string"===typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n2&&void 0!==arguments[2]?arguments[2]:v;if(!e)return[t];var i=this._caches[t];return i||(i=b(t,n),this._caches[t]=i),y(i,e)}}]),t}(),g=/^(?:\d)+/,_=/^(?:\w)+/;function b(t,e){var n=i(e,2),r=n[0],o=n[1],a=[],s=0,c="";while(s-1?w:t.indexOf("-hant")>-1||E(t,["-tw","-hk","-mo","-cht"])?S:w;var n=I(t,[k,x,C]);return n||void 0}}var M=function(){function t(e){var n=e.locale,i=e.fallbackLocale,r=e.messages,o=e.watcher,a=e.formater;u(this,t),this.locale=k,this.fallbackLocale=k,this.message={},this.messages={},this.watchers=[],i&&(this.fallbackLocale=i),this.formater=a||$,this.messages=r||{},this.setLocale(n||k),o&&this.watchLocale(o)}return h(t,[{key:"setLocale",value:function(t){var e=this,n=this.locale;this.locale=A(t,this.messages)||this.fallbackLocale,this.messages[this.locale]||(this.messages[this.locale]={}),this.message=this.messages[this.locale],n!==this.locale&&this.watchers.forEach((function(t){t(e.locale,n)}))}},{key:"getLocale",value:function(){return this.locale}},{key:"watchLocale",value:function(t){var e=this,n=this.watchers.push(t)-1;return function(){e.watchers.splice(n,1)}}},{key:"add",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=this.messages[t];i?n?Object.assign(i,e):Object.keys(e).forEach((function(t){O(i,t)||(i[t]=e[t])})):this.messages[t]=e}},{key:"f",value:function(t,e,n){return this.formater.interpolate(t,e,n).join("")}},{key:"t",value:function(t,e,n){var i=this.message;return"string"===typeof e?(e=A(e,this.messages),e&&(i=this.messages[e])):n=e,O(i,t)?this.formater.interpolate(i[t],n).join(""):(console.warn("Cannot translate the value of keypath ".concat(t,". Use the value of keypath as default.")),t)}}]),t}();function P(t,e){t.$watchLocale?t.$watchLocale((function(t){e.setLocale(t)})):t.$watch((function(){return t.$locale}),(function(t){e.setLocale(t)}))}function j(){return"undefined"!==typeof uni&&uni.getLocale?uni.getLocale():"undefined"!==typeof t&&t.getLocale?t.getLocale():k}function L(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if("string"!==typeof t){var r=[e,t];t=r[0],e=r[1]}"string"!==typeof t&&(t=j()),"string"!==typeof n&&(n="undefined"!==typeof __uniConfig&&__uniConfig.fallbackLocale||k);var o=new M({locale:t,fallbackLocale:n,messages:e,watcher:i}),a=function(t,e){if("function"!==typeof getApp)a=function(t,e){return o.t(t,e)};else{var n=!1;a=function(t,e){var i=getApp().$vm;return i&&(i.$locale,n||(n=!0,P(i,o))),o.t(t,e)}}return a(t,e)};return{i18n:o,f:function(t,e,n){return o.f(t,e,n)},t:function(t,e){return a(t,e)},add:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return o.add(t,e,n)},watch:function(t){return o.watchLocale(t)},getLocale:function(){return o.getLocale()},setLocale:function(t){return o.setLocale(t)}}}function N(t,e){return t.indexOf(e[0])>-1}}).call(this,n("c8ba"))},"4ba9":function(t,e,n){"use strict";var i=n("8779"),r=n.n(i);r.a},"4da7":function(t,e,n){"use strict";n.r(e);var i,r,o={ensp:" ",emsp:" ",nbsp:" "},a={name:"Text",props:{selectable:{type:[Boolean,String],default:!1},space:{type:String,default:""},decode:{type:[Boolean,String],default:!1}},methods:{_decodeHtml:function(t){return this.space&&o[this.space]&&(t=t.replace(/ /g,o[this.space])),this.decode&&(t=t.replace(/ /g,o.nbsp).replace(/ /g,o.ensp).replace(/ /g,o.emsp).replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'")),t}},render:function(t){var e=this,n=[];return this.$slots.default&&this.$slots.default.forEach((function(i){if(i.text){var r=i.text.replace(/\\n/g,"\n"),o=r.split("\n");o.forEach((function(i,r){n.push(e._decodeHtml(i)),r!==o.length-1&&n.push(t("br"))}))}else i.componentOptions&&"v-uni-text"!==i.componentOptions.tag&&console.warn("Do not nest other components in the text component, as there may be display differences on different platforms."),n.push(i)})),t("uni-text",{on:this.$listeners,attrs:{selectable:!!this.selectable}},[t("span",{},n)])}},s=a,c=(n("c8ed"),n("2877")),u=Object(c["a"])(s,i,r,!1,null,null,null);e["default"]=u.exports},"4dc6":function(t,e,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},"4e0b":function(t,e,n){},"4f1c":function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-switch",t._g({attrs:{disabled:t.disabled},on:{click:t._onClick}},t.$listeners),[n("div",{staticClass:"uni-switch-wrapper"},[n("div",{directives:[{name:"show",rawName:"v-show",value:"switch"===t.type,expression:"type === 'switch'"}],staticClass:"uni-switch-input",class:[t.switchChecked?"uni-switch-input-checked":""],style:{backgroundColor:t.switchChecked?t.color:"#DFDFDF",borderColor:t.switchChecked?t.color:"#DFDFDF"}}),n("div",{directives:[{name:"show",rawName:"v-show",value:"checkbox"===t.type,expression:"type === 'checkbox'"}],staticClass:"uni-checkbox-input",class:[t.switchChecked?"uni-checkbox-input-checked":""],style:{color:t.color}})])])},r=[],o=n("8af1"),a={name:"Switch",mixins:[o["a"],o["e"]],props:{name:{type:String,default:""},checked:{type:[Boolean,String],default:!1},type:{type:String,default:"switch"},id:{type:String,default:""},disabled:{type:[Boolean,String],default:!1},color:{type:String,default:"#007aff"}},data:function(){return{switchChecked:this.checked}},watch:{checked:function(t){this.switchChecked=t}},created:function(){this.$dispatch("Form","uni-form-group-update",{type:"add",vm:this})},beforeDestroy:function(){this.$dispatch("Form","uni-form-group-update",{type:"remove",vm:this})},listeners:{"label-click":"_onClick","@label-click":"_onClick"},methods:{_onClick:function(t){this.disabled||(this.switchChecked=!this.switchChecked,this.$trigger("change",t,{value:this.switchChecked}))},_resetFormData:function(){this.switchChecked=!1},_getFormData:function(){var t={};return""!==this.name&&(t.value=this.switchChecked,t.key=this.name),t}}},s=a,c=(n("a5ec"),n("2877")),u=Object(c["a"])(s,i,r,!1,null,null,null);e["default"]=u.exports},"501c":function(t,e,n){"use strict";n.r(e),n.d(e,"on",(function(){return v})),n.d(e,"off",(function(){return m})),n.d(e,"once",(function(){return g})),n.d(e,"emit",(function(){return _})),n.d(e,"subscribe",(function(){return b})),n.d(e,"unsubscribe",(function(){return y})),n.d(e,"subscribeHandler",(function(){return w})),n.d(e,"publishHandler",(function(){return f["a"]}));var i=n("e571");function r(t){var e=t.pageStyle,n=t.rootFontSize,i=document.querySelector("uni-page-body")||document.body;i.setAttribute("style",e),n&&document.documentElement.style.fontSize!==n&&(document.documentElement.style.fontSize=n)}var o=n("6bdf"),a=n("5dc1"),s=n("1c73"),c={setPageMeta:r,requestComponentInfo:o["a"],requestComponentObserver:a["b"],destroyComponentObserver:a["a"],requestMediaQueryObserver:s["b"],destroyMediaQueryObserver:s["a"]},u=n("33ed"),l=n("7107"),h=n("0516");function d(t){Object.keys(c).forEach((function(e){t(e,c[e])})),t("pageScrollTo",u["c"]),t("loadFontFace",l["a"]),Object(h["a"])(t)}var f=n("5bb5"),p=new i["a"],v=p.$on.bind(p),m=p.$off.bind(p),g=p.$once.bind(p),_=p.$emit.bind(p);function b(t,e){return v("service."+t,e)}function y(t,e){return m("service."+t,e)}function w(t,e,n){_("service."+t,e,n)}d(b)},5077:function(t,e,n){"use strict";var i=["borderRadius","borderColor","borderWidth","backgroundColor"],r=["paddingTop","paddingRight","paddingBottom","paddingLeft","color","textAlign","lineHeight","fontSize","fontWeight","textOverflow","whiteSpace"],o=[],a={start:"left",end:"right"},s=0;e["a"]={name:"Cover",data:function(){return{style:{},parentPosition:{}}},computed:{viewPosition:function(){var t={};for(var e in this.position){var n=this.position[e],i=parseFloat(n),r=parseFloat(this.parentPosition[e]);if("top"===e||"left"===e)n=Math.max(i,r)+"px";else if("width"===e||"height"===e){var o="width"===e?"left":"top",a=parseFloat(this.parentPosition[o]),s=parseFloat(this.position[o]),c=Math.max(a-s,0),u=Math.max(s+i-(a+r),0);n=Math.max(i-c-u,0)+"px"}t[e]=n}return t},tags:function(){var t=this._getTagPosition(),e=this.style,n=[{tag:"rect",position:t,rectStyles:{color:e.backgroundColor,radius:e.borderRadius,borderColor:e.borderColor,borderWidth:e.borderWidth}}];if("image"===this.coverType)n.push({tag:"img",position:t,src:this.coverContent});else{var i=parseFloat(e.lineHeight)-parseFloat(e.fontSize),r=parseFloat(t.width)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight);r=r<0?0:r;var o=parseFloat(t.height)-parseFloat(e.paddingTop)-i/2-parseFloat(e.paddingBottom);o=o<0?0:o,n.push({tag:"font",position:{top:"".concat(parseFloat(t.top)+parseFloat(e.paddingTop)+i/2,"px"),left:"".concat(parseFloat(t.left)+parseFloat(e.paddingLeft),"px"),width:"".concat(r,"px"),height:"".concat(o,"px")},textStyles:{align:a[e.textAlign]||e.textAlign,color:e.color,decoration:"none",lineSpacing:"".concat(i,"px"),margin:"0px",overflow:e.textOverflow,size:e.fontSize,verticalAlign:"top",weight:e.fontWeight,whiteSpace:e.whiteSpace},text:this.coverContent})}return n}},created:function(){var t=this.$parent;while(!t.isNative&&t!==this.$root)t=t.$parent;this._nativeParent=t},mounted:function(){var t=this;this._onParentReady((function(e){t.parentPosition=t._nativeParent.position||e,t._updateStyle(),t._onCanInsert(),t.$watch("hidden",(function(e){t.cover&&t.cover[e?"hide":"show"]()})),t.$watch("viewPosition",(function(e){t.cover&&t.cover.setStyle(e)}),{deep:!0}),t.$watch("tags",(function(){var e=t.cover;e&&(e.reset(),e.draw(t.tags))}),{deep:!0}),t.$on("uni-view-update",t._requestStyleUpdate)}))},beforeDestroy:function(){this._nativeParent.isNative&&(this.cover&&this.cover.close(),delete this.cover)},methods:{_onCanInsert:function(){var t=this,e=this.cover=new plus.nativeObj.View("cover-".concat(Date.now(),"-").concat(s++),this.viewPosition,this.tags);plus.webview.currentWebview().append(e),this.hidden&&e.hide(),e.addEventListener("click",(function(){t.$trigger("click",{},{})}))},_getTagPosition:function(){var t={};for(var e in this.position){var n=this.position[e];"top"!==e&&"left"!==e||(n=Math.min(parseFloat(n)-parseFloat(this.parentPosition[e]),0)+"px"),t[e]=n}return t},_updateStyle:function(){var t=this,e=getComputedStyle(this.$el);i.concat(r,o).forEach((function(n){t.$set(t.style,n,e[n])}))},_requestStyleUpdate:function(){var t=this;this._styleUpdateRequest&&cancelAnimationFrame(this._styleUpdateRequest),this._styleUpdateRequest=requestAnimationFrame((function(){delete t._styleUpdateRequest,t._updateStyle()}))}}}},5129:function(t,e){t.exports=["uni-app","uni-layout","uni-content","uni-main","uni-top-window","uni-left-window","uni-right-window","uni-tabbar","uni-page","uni-page-head","uni-page-wrapper","uni-page-body","uni-page-refresh","uni-actionsheet","uni-modal","uni-toast","uni-resize-sensor","uni-shadow-root","uni-ad","uni-audio","uni-button","uni-camera","uni-canvas","uni-checkbox","uni-checkbox-group","uni-cover-image","uni-cover-view","uni-editor","uni-form","uni-functional-page-navigator","uni-icon","uni-image","uni-input","uni-label","uni-live-player","uni-live-pusher","uni-map","uni-movable-area","uni-movable-view","uni-navigator","uni-official-account","uni-open-data","uni-picker","uni-picker-view","uni-picker-view-column","uni-progress","uni-radio","uni-radio-group","uni-rich-text","uni-scroll-view","uni-slider","uni-swiper","uni-swiper-item","uni-switch","uni-text","uni-textarea","uni-video","uni-view","uni-web-view"]},"515d":function(t,e,n){},5363:function(t,e,n){"use strict";function i(t){this._drag=t,this._dragLog=Math.log(t),this._x=0,this._v=0,this._startTime=0}n.d(e,"a",(function(){return i})),i.prototype.set=function(t,e){this._x=t,this._v=e,this._startTime=(new Date).getTime()},i.prototype.setVelocityByEnd=function(t){this._v=(t-this._x)*this._dragLog/(Math.pow(this._drag,100)-1)},i.prototype.x=function(t){var e;return void 0===t&&(t=((new Date).getTime()-this._startTime)/1e3),e=t===this._dt&&this._powDragDt?this._powDragDt:this._powDragDt=Math.pow(this._drag,t),this._dt=t,this._x+this._v*e/this._dragLog-this._v/this._dragLog},i.prototype.dx=function(t){var e;return void 0===t&&(t=((new Date).getTime()-this._startTime)/1e3),e=t===this._dt&&this._powDragDt?this._powDragDt:this._powDragDt=Math.pow(this._drag,t),this._dt=t,this._v*e},i.prototype.done=function(){return Math.abs(this.dx())<3},i.prototype.reconfigure=function(t){var e=this.x(),n=this.dx();this._drag=t,this._dragLog=Math.log(t),this.set(e,n)},i.prototype.configuration=function(){var t=this;return[{label:"Friction",read:function(){return t._drag},write:function(e){t.reconfigure(e)},min:.001,max:.1,step:.001}]}},5408:function(t,e,n){var i={"./audio/index.vue":"6150","./button/index.vue":"d3bd","./canvas/index.vue":"bacd","./checkbox-group/index.vue":"25ce","./checkbox/index.vue":"7bb3","./editor/index.vue":"27c2","./form/index.vue":"b34d","./icon/index.vue":"9a8b","./image/index.vue":"1082","./input/index.vue":"250d","./label/index.vue":"70f4","./movable-area/index.vue":"c61c","./movable-view/index.vue":"8842","./navigator/index.vue":"17fd","./picker-view-column/index.vue":"1955","./picker-view/index.vue":"27ab","./progress/index.vue":"9b1f","./radio-group/index.vue":"d5ec","./radio/index.vue":"6491","./resize-sensor/index.vue":"3e8c","./rich-text/index.vue":"b705","./scroll-view/index.vue":"f1ef","./slider/index.vue":"9f96","./swiper-item/index.vue":"9213","./swiper/index.vue":"5513","./switch/index.vue":"4f1c","./text/index.vue":"4da7","./textarea/index.vue":"5768"};function r(t){var e=o(t);return n(e)}function o(t){if(!n.o(i,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return i[t]}r.keys=function(){return Object.keys(i)},r.resolve=o,t.exports=r,r.id="5408"},"54bc":function(t,e,n){},5513:function(t,e,n){"use strict";n.r(e);var i=n("ba15"),r=n("f2b3");var o,a,s={name:"Swiper",mixins:[i["a"]],props:{indicatorDots:{type:[Boolean,String],default:!1},vertical:{type:[Boolean,String],default:!1},autoplay:{type:[Boolean,String],default:!1},circular:{type:[Boolean,String],default:!1},interval:{type:[Number,String],default:5e3},duration:{type:[Number,String],default:500},current:{type:[Number,String],default:0},indicatorColor:{type:String,default:""},indicatorActiveColor:{type:String,default:""},previousMargin:{type:String,default:""},nextMargin:{type:String,default:""},currentItemId:{type:String,default:""},skipHiddenItemLayout:{type:[Boolean,String],default:!1},displayMultipleItems:{type:[Number,String],default:1},disableTouch:{type:[Boolean,String],default:!1},navigation:{type:[Boolean,String],default:!1},navigationColor:{type:String,default:"#fff"},navigationActiveColor:{type:String,default:"rgba(53, 53, 53, 0.6)"}},data:function(){return{currentSync:Math.round(this.current)||0,currentItemIdSync:this.currentItemId||"",userTracking:!1,currentChangeSource:"",items:[],isNavigationAuto:!1,hideNavigation:!1,prevDisabled:!1,nextDisabled:!1}},computed:{intervalNumber:function(){var t=Number(this.interval);return isNaN(t)?5e3:t},durationNumber:function(){var t=Number(this.duration);return isNaN(t)?500:t},displayMultipleItemsNumber:function(){var t=Math.round(this.displayMultipleItems);return isNaN(t)?1:t},slidesStyle:function(){var t={};return(this.nextMargin||this.previousMargin)&&(t=this.vertical?{left:0,right:0,top:this._upx2px(this.previousMargin),bottom:this._upx2px(this.nextMargin)}:{top:0,bottom:0,left:this._upx2px(this.previousMargin),right:this._upx2px(this.nextMargin)}),t},slideFrameStyle:function(){var t=Math.abs(100/this.displayMultipleItemsNumber)+"%";return{width:this.vertical?"100%":t,height:this.vertical?t:"100%"}},swiperEnabled:function(){return this.items.length>this.displayMultipleItemsNumber},circularEnabled:function(){return this.circular&&this.swiperEnabled}},watch:{vertical:function(){this._resetLayout()},circular:function(){this._resetLayout()},intervalNumber:function(t){this._timer&&(this._cancelSchedule(),this._scheduleAutoplay())},current:function(t){this._currentCheck()},currentSync:function(t,e){this._currentChanged(t,e),this.$emit("update:current",t),this._setNavigationState()},currentItemId:function(t){this._currentCheck()},currentItemIdSync:function(t){this.$emit("update:currentItemId",t)},displayMultipleItemsNumber:function(){this._resetLayout()},navigation:{immediate:!0,handler:function(t){this.isNavigationAuto="auto"===t,this.hideNavigation=!0!==t||this.isNavigationAuto,this._navigationSwiperAddMouseEvent()}},items:function(){this._setNavigationState()},swiperEnabled:function(t){t||(this.prevDisabled=!0,this.nextDisabled=!0,this.isNavigationAuto&&(this.hideNavigation=!0))}},created:function(){this._invalid=!0,this._viewportPosition=0,this._viewportMoveRatio=1,this._animating=null,this._requestedAnimation=!1,this._userDirectionChecked=!1,this._contentTrackViewport=0,this._contentTrackSpeed=0,this._contentTrackT=0},mounted:function(){var t=this;this._currentCheck(),this.touchtrack(this.$refs.slidesWrapper,"_handleContentTrack",!0),this._resetLayout(),this.$watch((function(){return t.autoplay&&!t.userTracking}),this._inintAutoplay),this._inintAutoplay(this.autoplay&&!this.userTracking),this.$watch("items.length",this._resetLayout),this._navigationSwiperAddMouseEvent()},beforeDestroy:function(){this._cancelSchedule(),cancelAnimationFrame(this._animationFrame)},methods:{_inintAutoplay:function(t){t?this._scheduleAutoplay():this._cancelSchedule()},_currentCheck:function(){var t=-1;if(this.currentItemId)for(var e=0,n=this.items;er/2?1:0)}var o=this.items[t];o&&this._itemReady(o,(function(){var t=n.currentItemIdSync=o.componentInstance.itemId||"";n.$trigger("change",{},{current:n.currentSync,currentItemId:t,source:i})}))},_scheduleAutoplay:function(){var t=this;function e(){t._timer=null,t.currentChangeSource="autoplay",t.circularEnabled?t.currentSync=t._normalizeCurrentValue(t.currentSync+1):t.currentSync=t.currentSync+t.displayMultipleItemsNumbere-this.displayMultipleItemsNumber)return e-this.displayMultipleItemsNumber;return n},_upx2px:function(t){return/\d+[ur]px$/i.test(t)&&t.replace(/\d+[ur]px$/i,(function(t){return"".concat(uni.upx2px(parseFloat(t)),"px")})),t||""},_resetLayout:function(){if(this._isMounted){this._cancelSchedule(),this._endViewportAnimation();for(var t=this.items,e=0;e0&&this._viewportMoveRatio<1||(this._viewportMoveRatio=1)}var r=this._viewportPosition;this._viewportPosition=-2;var o=this.currentSync;o>=0?(this._invalid=!1,this.userTracking?(this._updateViewport(r+o-this._contentTrackViewport),this._contentTrackViewport=o):(this._updateViewport(o),this.autoplay&&this._scheduleAutoplay())):(this._invalid=!0,this._updateViewport(-this.displayMultipleItemsNumber-1))}},_checkCircularLayout:function(t){if(!this._invalid)for(var e=this.items,n=e.length,i=t+this.displayMultipleItemsNumber,r=0;r=this.items.length&&(t-=this.items.length),t=this._transitionStart%1>.5||this._transitionStart<0?t-1:t,this.$trigger("transition",{},{dx:this.vertical?0:t*r.offsetWidth,dy:this.vertical?t*r.offsetHeight:0})},_animateFrameFuncProto:function(){var t=this;if(this._animating){var e=this._animating,n=e.toPos,i=e.acc,r=e.endTime,o=e.source,a=r-Date.now();if(a<=0){this._updateViewport(n),this._animating=null,this._requestedAnimation=!1,this._transitionStart=null;var s=this.items[this.currentSync];s&&this._itemReady(s,(function(){var e=s.componentInstance.itemId||"";t.$trigger("animationfinish",{},{current:t.currentSync,currentItemId:e,source:o})}))}else{var c=i*a*a/2,u=n+c;this._updateViewport(u),this._animationFrame=requestAnimationFrame(this._animateFrameFuncProto.bind(this))}}else this._requestedAnimation=!1},_animateViewport:function(t,e,n){this._cancelViewportAnimation();var i=this.durationNumber,r=this.items.length,o=this._viewportPosition;if(this.circularEnabled)if(n<0){for(;ot;)o-=r}else if(n>0){for(;o>t;)o-=r;for(;o+rt;)o-=r;o+r-tr)&&(i<0?i=-o(-i):i>r&&(i=r+o(i-r)),e._contentTrackSpeed=0),e._updateViewport(i)}var s=this._contentTrackT-n||1;this.vertical?a(-t.dy/this.$refs.slideFrame.offsetHeight,-t.ddy/s):a(-t.dx/this.$refs.slideFrame.offsetWidth,-t.ddx/s)},_handleTrackEnd:function(t){this.userTracking=!1;var e=this._contentTrackSpeed/Math.abs(this._contentTrackSpeed),n=0;!t&&Math.abs(this._contentTrackSpeed)>.2&&(n=.5*e);var i=this._normalizeCurrentValue(this._viewportPosition+n);t?this._updateViewport(this._contentTrackViewport):(this.currentChangeSource="touch",this.currentSync=i,this._animateViewport(i,"touch",0!==n?n:0===i&&this.circularEnabled&&this._viewportPosition>=1?1:0))},_handleContentTrack:function(t){if(!this.disableTouch&&this.items.length&&!this._invalid){if("start"===t.detail.state)return this.userTracking=!0,this._userDirectionChecked=!1,this._handleTrackStart();if("end"===t.detail.state)return this._handleTrackEnd(!1);if("cancel"===t.detail.state)return this._handleTrackEnd(!0);if(this.userTracking){if(!this._userDirectionChecked){this._userDirectionChecked=!0;var e=Math.abs(t.detail.dx),n=Math.abs(t.detail.dy);if((e>=n&&this.vertical||e<=n&&!this.vertical)&&(this.userTracking=!1),!this.userTracking)return void(this.autoplay&&this._scheduleAutoplay())}return this._handleTrackMove(t.detail),!1}}},_onSwiperDotClick:function(t){this._animateViewport(this.currentSync=t,this.currentChangeSource="click",this.circularEnabled?1:0)},_navigationClick:function(t,e,n){if(t.stopPropagation(),!n){var i=this.items.length,r=this.currentSync;switch(e){case"prev":r--,r<0&&this.circularEnabled&&(r=i-1);break;case"next":r++,r>=i&&this.circularEnabled&&(r=0);break}this._onSwiperDotClick(r)}},_navigationMouseMove:function(t){var e=this;clearTimeout(this.hideNavigationTimer);var n=t.clientX,i=t.clientY,r=this.$refs.slidesWrapper.getBoundingClientRect(),o=r.left,a=r.right,s=r.top,c=r.bottom,u=r.width,l=r.height,h=!1;h=this.vertical?!(i-s=t}},render:function(t){var e=this,n=[],i=[];this.$slots.default&&Object(r["d"])(this.$slots.default,t).forEach((function(t){t.componentOptions&&"v-uni-swiper-item"===t.componentOptions.tag&&i.push(t)}));for(var o=function(i,r){var o=e.currentSync;n.push(t("div",{on:{click:function(){return e._onSwiperDotClick(i)}},class:{"uni-swiper-dot":!0,"uni-swiper-dot-active":i=o||i-1&&t.indexOf("MSIE")>-1,n=t.indexOf("Edge")>-1&&!e,i=t.indexOf("Trident")>-1&&t.indexOf("rv:11.0")>-1;if(e){var r=new RegExp("MSIE (\\d+\\.\\d+);");r.test(t);var o=parseFloat(RegExp.$1);return o>6?o:6}return n?-1:i?11:-1}function b(){try{return window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}catch(t){return"light"}}var y=navigator.userAgent,w=/android/i.test(y),S=/iphone|ipad|ipod/i.test(y),k=y.match(/Windows NT ([\d|\d.\d]*)/i),x=/Macintosh|Mac/i.test(y),C=/Linux|X11/i.test(y),T=x&&navigator.maxTouchPoints>0;function O(){var t,e,n,i=navigator.language,r="phone";if(S){t="iOS";var o=y.match(/OS\s([\w_]+)\slike/);o&&(e=o[1].replace(/_/g,"."));var a=y.match(/\(([a-zA-Z]+);/);a&&(n=a[1])}else if(w){t="Android";var s=y.match(/Android[\s/]([\w\.]+)[;\s]/);s&&(e=s[1]);for(var c=y.match(/\((.+?)\)/),u=c?c[1].split(";"):y.split(" "),l=[/\bAndroid\b/i,/\bLinux\b/i,/\bU\b/i,/^\s?[a-z][a-z]$/i,/^\s?[a-z][a-z]-[a-z][a-z]$/i,/\bwv\b/i,/\/[\d\.,]+$/,/^\s?[\d\.,]+$/,/\bBrowser\b/i,/\bMobile\b/i],h=0;h0){n=d.split("Build")[0].trim();break}for(var f=void 0,p=0;p=13)&&document.activeElement.blur()};t.addEventListener("focus",(function(){e=!0,clearTimeout(i),document.addEventListener("click",h,!1),s=l,a&&n.$trigger("keyboardheightchange",{},{height:a,duration:0}),f(n),d(n)})),r&&t.addEventListener("click",(function(){!n.disabled&&e&&0===a&&d(n)})),r||(parseInt(o)<12&&t.addEventListener("touchstart",(function(){n.disabled||e||d(n)})),parseFloat(o)>=14.6&&!c&&Object(u["j"])((function(){var t=plus.webview.currentWebview();c=t.getStyle()||{}})));var v=function(){document.removeEventListener("click",h,!1),s=null,a&&n.$trigger("keyboardheightchange",{},{height:0,duration:0}),p(n),r&&(i=setTimeout((function(){d(n,!0)}),300)),n.isApple&&document.documentElement.scrollTo(document.documentElement.scrollLeft,document.documentElement.scrollTop)};t.addEventListener("blur",(function(){n.isApple&&t.blur(),e=!1,v()}))}}}},"5ab3":function(t,e,n){"use strict";var i=n("b2bb"),r=n.n(i);r.a},"5abe":function(t,e){(function(){"use strict";if("object"===typeof window)if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});else{var t=window.document,e=[];i.prototype.THROTTLE_TIMEOUT=100,i.prototype.POLL_INTERVAL=null,i.prototype.USE_MUTATION_OBSERVER=!0,i.prototype.observe=function(t){var e=this._observationTargets.some((function(e){return e.element==t}));if(!e){if(!t||1!=t.nodeType)throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),this._monitorIntersections(),this._checkForIntersections()}},i.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter((function(e){return e.element!=t})),this._observationTargets.length||(this._unmonitorIntersections(),this._unregisterInstance())},i.prototype.disconnect=function(){this._observationTargets=[],this._unmonitorIntersections(),this._unregisterInstance()},i.prototype.takeRecords=function(){var t=this._queuedEntries.slice();return this._queuedEntries=[],t},i.prototype._initThresholds=function(t){var e=t||[0];return Array.isArray(e)||(e=[e]),e.sort().filter((function(t,e,n){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new Error("threshold must be a number between 0 and 1 inclusively");return t!==n[e-1]}))},i.prototype._parseRootMargin=function(t){var e=t||"0px",n=e.split(/\s+/).map((function(t){var e=/^(-?\d*\.?\d+)(px|%)$/.exec(t);if(!e)throw new Error("rootMargin must be specified in pixels or percent");return{value:parseFloat(e[1]),unit:e[2]}}));return n[1]=n[1]||n[0],n[2]=n[2]||n[0],n[3]=n[3]||n[1],n},i.prototype._monitorIntersections=function(){this._monitoringIntersections||(this._monitoringIntersections=!0,this.POLL_INTERVAL?this._monitoringInterval=setInterval(this._checkForIntersections,this.POLL_INTERVAL):(a(window,"resize",this._checkForIntersections,!0),a(t,"scroll",this._checkForIntersections,!0),this.USE_MUTATION_OBSERVER&&"MutationObserver"in window&&(this._domObserver=new MutationObserver(this._checkForIntersections),this._domObserver.observe(t,{attributes:!0,childList:!0,characterData:!0,subtree:!0}))))},i.prototype._unmonitorIntersections=function(){this._monitoringIntersections&&(this._monitoringIntersections=!1,clearInterval(this._monitoringInterval),this._monitoringInterval=null,s(window,"resize",this._checkForIntersections,!0),s(t,"scroll",this._checkForIntersections,!0),this._domObserver&&(this._domObserver.disconnect(),this._domObserver=null))},i.prototype._checkForIntersections=function(){var t=this._rootIsInDom(),e=t?this._getRootRect():l();this._observationTargets.forEach((function(i){var o=i.element,a=u(o),s=this._rootContainsTarget(o),c=i.entry,l=t&&s&&this._computeTargetAndRootIntersection(o,e),h=i.entry=new n({time:r(),target:o,boundingClientRect:a,rootBounds:e,intersectionRect:l});c?t&&s?this._hasCrossedThreshold(c,h)&&this._queuedEntries.push(h):c&&c.isIntersecting&&this._queuedEntries.push(h):this._queuedEntries.push(h)}),this),this._queuedEntries.length&&this._callback(this.takeRecords(),this)},i.prototype._computeTargetAndRootIntersection=function(e,n){if("none"!=window.getComputedStyle(e).display){var i=u(e),r=i,o=d(e),a=!1;while(!a){var s=null,l=1==o.nodeType?window.getComputedStyle(o):{};if("none"==l.display)return;if(o==this.root||o==t?(a=!0,s=n):o!=t.body&&o!=t.documentElement&&"visible"!=l.overflow&&(s=u(o)),s&&(r=c(s,r),!r))break;o=d(o)}return r}},i.prototype._getRootRect=function(){var e;if(this.root)e=u(this.root);else{var n=t.documentElement,i=t.body;e={top:0,left:0,right:n.clientWidth||i.clientWidth,width:n.clientWidth||i.clientWidth,bottom:n.clientHeight||i.clientHeight,height:n.clientHeight||i.clientHeight}}return this._expandRectByRootMargin(e)},i.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map((function(e,n){return"px"==e.unit?e.value:e.value*(n%2?t.width:t.height)/100})),n={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};return n.width=n.right-n.left,n.height=n.bottom-n.top,n},i.prototype._hasCrossedThreshold=function(t,e){var n=t&&t.isIntersecting?t.intersectionRatio||0:-1,i=e.isIntersecting?e.intersectionRatio||0:-1;if(n!==i)for(var r=0;r=0&&s>=0&&{top:n,bottom:i,left:r,right:o,width:a,height:s}}function u(t){var e;try{e=t.getBoundingClientRect()}catch(n){}return e?(e.width&&e.height||(e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}),e):l()}function l(){return{top:0,bottom:0,left:0,right:0,width:0,height:0}}function h(t,e){var n=e;while(n){if(n==t)return!0;n=d(n)}return!1}function d(t){var e=t.parentNode;return e&&11==e.nodeType&&e.host?e.host:e&&e.assignedSlot?e.assignedSlot.parentNode:e}})()},"5bb5":function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var i=n("a20d"),r=n("f2b3");function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(r["j"])((function(){var n=plus.webview.currentWebview().id;plus.webview.postMessageToUniNView({type:"subscribeHandler",args:{type:t,data:e,pageId:n}},i["a"])}))}},"5cf8":function(t,e,n){"use strict";function i(t,e){for(var n=this.$children,r=n.length,o=arguments.length,a=new Array(o>2?o-2:0),s=2;s2?r-2:0),a=2;a2?n-2:0),o=2;o=1;M--)if(0!==z[M])break;if(P>M&&(P=M),0===M)return v[m++]=20971520,v[m++]=20971520,_.bits=1,0;for(A=1;A0&&(t===s||1!==M))return-1;for(V[1]=0,E=1;Eo||t===u&&D>a)return 1;for(;;){C=E-L,g[I]x?(T=H[Y+g[I]],O=B[F+g[I]]):(T=96,O=0),b=1<>L)+y]=C<<24|T<<16|O|0}while(0!==y);b=1<>=1;if(0!==b?(R&=b-1,R+=b):R=0,I++,0===--z[E]){if(E===M)break;E=e[n+g[I]]}if(E>P&&(R&S)!==w){0===L&&(L=P),k+=A,j=E-L,N=1<o||t===u&&D>a)return 1;w=R&S,v[w]=P<<24|j<<16|k-m|0}}return 0!==R&&(v[k+R]=E-L<<24|64<<16|0),_.bits=P,0}},"68f3":function(t,e,n){"use strict";(function(t){var i=n("8af1"),r=n("0aa0"),o=["adpid","data"];e["a"]={name:"Ad",mixins:[i["f"],r["a"]],props:{adpid:{type:[Number,String],default:""},data:{type:Object,default:null},dataCount:{type:Number,default:5},channel:{type:String,default:""}},data:function(){return{hidden:!1}},computed:{attrs:function(){var t=this,e={};return o.forEach((function(n){var i=t.$props[n];i="src"===n?t.$getRealPath(i):i,e[n.replace(/[A-Z]/g,(function(t){return"-"+t.toLowerCase()}))]=i})),e}},watch:{hidden:function(t){this.adView&&this.adView[t?"hide":"show"]()},adpid:function(t){t&&this._loadData(t)},data:function(t){t&&this._fillData(t)}},mounted:function(){var e=this;this._onParentReady((function(){e._adId="AdView-"+e._newGUID();var n=Object.assign({id:e._adId},e.position),i=e.adView=plus.ad.createAdView(n);i.interceptTouchEvent(!1),plus.webview.currentWebview().append(i),e.hidden&&i.hide(),e.$watch("attrs",(function(){e._request()}),{deep:!0}),e.$watch("position",(function(){e.adView&&e.adView.setStyle(e.position)}),{deep:!0}),i.setDislikeListener&&i.setDislikeListener((function(t){e.adView&&e.adView.close(),e.$refs.container.style.height="0px",e._updateView(),e.$trigger("close",{},t)})),i.setRenderingListener&&i.setRenderingListener((function(t){0===t.result?(e.$refs.container.style.height=t.height+"px",e._updateView()):e.$trigger("error",{},{errCode:t.result})})),i.setAdClickedListener((function(t){e.$trigger("adclicked",{},t)})),e._callbackId=e.$page.id+e._adId,t.subscribe(e._callbackId,e._handleAdData.bind(e)),e._request()}))},beforeDestroy:function(){this.adView&&this.adView.close(),delete this.adView},methods:{_handleAdData:function(t){var e=t.type,n=t.data,i=void 0===n?{}:n;switch(e){case"success":this._fillData(i);break;case"fail":this.$trigger("error",{},i);break}},_request:function(){this.adView&&(this.data?this._fillData(this.data):this.adpid&&this._loadData())},_loadData:function(e){var n={adpid:e||this.adpid,width:this.position.width,count:this.dataCount,ext:{channel:this.channel}};t.publishHandler("onAdMethodCallback",{callbackId:this._callbackId,data:n},this.$page.id)},_fillData:function(t){this.adView.renderingBind(t),this.$trigger("load",{},{})},_updateView:function(){window.dispatchEvent(new CustomEvent("updateview"))},_newGUID:function(){for(var t="",e="xxxxxxxx-xxxx",n=0;n=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0===(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var n=i.inflateInit2(this.strm,e.windowBits);if(n!==a.Z_OK)throw new Error(s[n]);if(this.header=new u,i.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"===typeof e.dictionary?e.dictionary=o.string2buf(e.dictionary):"[object ArrayBuffer]"===l.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=i.inflateSetDictionary(this.strm,e.dictionary),n!==a.Z_OK)))throw new Error(s[n])}function d(t,e){var n=new h(e);if(n.push(t,!0),n.err)throw n.msg||s[n.err];return n.result}function f(t,e){return e=e||{},e.raw=!0,d(t,e)}h.prototype.push=function(t,e){var n,s,c,u,h,d=this.strm,f=this.options.chunkSize,p=this.options.dictionary,v=!1;if(this.ended)return!1;s=e===~~e?e:!0===e?a.Z_FINISH:a.Z_NO_FLUSH,"string"===typeof t?d.input=o.binstring2buf(t):"[object ArrayBuffer]"===l.call(t)?d.input=new Uint8Array(t):d.input=t,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new r.Buf8(f),d.next_out=0,d.avail_out=f),n=i.inflate(d,a.Z_NO_FLUSH),n===a.Z_NEED_DICT&&p&&(n=i.inflateSetDictionary(this.strm,p)),n===a.Z_BUF_ERROR&&!0===v&&(n=a.Z_OK,v=!1),n!==a.Z_STREAM_END&&n!==a.Z_OK)return this.onEnd(n),this.ended=!0,!1;d.next_out&&(0!==d.avail_out&&n!==a.Z_STREAM_END&&(0!==d.avail_in||s!==a.Z_FINISH&&s!==a.Z_SYNC_FLUSH)||("string"===this.options.to?(c=o.utf8border(d.output,d.next_out),u=d.next_out-c,h=o.buf2string(d.output,c),d.next_out=u,d.avail_out=f-u,u&&r.arraySet(d.output,d.output,c,u,0),this.onData(h)):this.onData(r.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(v=!0)}while((d.avail_in>0||0===d.avail_out)&&n!==a.Z_STREAM_END);return n===a.Z_STREAM_END&&(s=a.Z_FINISH),s===a.Z_FINISH?(n=i.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===a.Z_OK):s!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),d.avail_out=0,!0)},h.prototype.onData=function(t){this.chunks.push(t)},h.prototype.onEnd=function(t){t===a.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Inflate=h,e.inflate=d,e.inflateRaw=f,e.ungzip=d},"72ad":function(t,e,n){},"72b3":function(t,e,n){"use strict";function i(t,e,n){return t>e-n&&t0){var u=(-n-Math.sqrt(o))/(2*i),l=(-n+Math.sqrt(o))/(2*i),h=(e-u*t)/(l-u),d=t-h;return{x:function(t){var e,n;return t===this._t&&(e=this._powER1T,n=this._powER2T),this._t=t,e||(e=this._powER1T=Math.pow(Math.E,u*t)),n||(n=this._powER2T=Math.pow(Math.E,l*t)),d*e+h*n},dx:function(t){var e,n;return t===this._t&&(e=this._powER1T,n=this._powER2T),this._t=t,e||(e=this._powER1T=Math.pow(Math.E,u*t)),n||(n=this._powER2T=Math.pow(Math.E,l*t)),d*u*e+h*l*n}}}var f=Math.sqrt(4*i*r-n*n)/(2*i),p=-n/2*i,v=t,m=(e-p*t)/f;return{x:function(t){return Math.pow(Math.E,p*t)*(v*Math.cos(f*t)+m*Math.sin(f*t))},dx:function(t){var e=Math.pow(Math.E,p*t),n=Math.cos(f*t),i=Math.sin(f*t);return e*(m*f*n-v*f*i)+p*e*(m*i+v*n)}}},o.prototype.x=function(t){return void 0===t&&(t=((new Date).getTime()-this._startTime)/1e3),this._solution?this._endPosition+this._solution.x(t):0},o.prototype.dx=function(t){return void 0===t&&(t=((new Date).getTime()-this._startTime)/1e3),this._solution?this._solution.dx(t):0},o.prototype.setEnd=function(t,e,n){if(n||(n=(new Date).getTime()),t!==this._endPosition||!r(e,.4)){e=e||0;var i=this._endPosition;this._solution&&(r(e,.4)&&(e=this._solution.dx((n-this._startTime)/1e3)),i=this._solution.x((n-this._startTime)/1e3),r(e,.4)&&(e=0),r(i,.4)&&(i=0),i+=this._endPosition),this._solution&&r(i-t,.4)&&r(e,.4)||(this._endPosition=t,this._solution=this._solve(i-this._endPosition,e),this._startTime=n)}},o.prototype.snap=function(t){this._startTime=(new Date).getTime(),this._endPosition=t,this._solution={x:function(){return 0},dx:function(){return 0}}},o.prototype.done=function(t){return t||(t=(new Date).getTime()),i(this.x(),this._endPosition,.4)&&r(this.dx(),.4)},o.prototype.reconfigure=function(t,e,n){this._m=t,this._k=e,this._c=n,this.done()||(this._solution=this._solve(this.x()-this._endPosition,this.dx()),this._startTime=(new Date).getTime())},o.prototype.springConstant=function(){return this._k},o.prototype.damping=function(){return this._c},o.prototype.configuration=function(){function t(t,e){t.reconfigure(1,e,t.damping())}function e(t,e){t.reconfigure(1,t.springConstant(),e)}return[{label:"Spring Constant",read:this.springConstant.bind(this),write:t.bind(this,this),min:100,max:1e3},{label:"Damping",read:this.damping.bind(this),write:e.bind(this,this),min:1,max:500}]}},7466:function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-map",t._g({},t.$listeners),[n("div",{ref:"container",staticClass:"uni-map-container"}),t._l(t.mapControls,(function(e,i){return n("v-uni-cover-image",{key:i,style:e.position,attrs:{src:e.iconPath,"auto-size":""},on:{click:function(n){return t.controlclick(e)}}})})),n("div",{staticClass:"uni-map-slot"},[t._t("default")],2)],2)},r=[],o=n("286b"),a=o["a"],s=(n("a252"),n("2877")),c=Object(s["a"])(a,i,r,!1,null,null,null);e["default"]=c.exports},7522:function(t,e,n){},"76a8":function(t,e,n){"use strict";var i=n("3fe7"),r=n.n(i);r.a},"7b27":function(t,e,n){"use strict";var i=n("be7f"),r=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(u){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(u){o=!1}for(var a=new i.Buf8(256),s=0;s<256;s++)a[s]=s>=252?6:s>=248?5:s>=240?4:s>=224?3:s>=192?2:1;function c(t,e){if(e<65534&&(t.subarray&&o||!t.subarray&&r))return String.fromCharCode.apply(null,i.shrinkBuf(t,e));for(var n="",a=0;a>>6,e[a++]=128|63&n):n<65536?(e[a++]=224|n>>>12,e[a++]=128|n>>>6&63,e[a++]=128|63&n):(e[a++]=240|n>>>18,e[a++]=128|n>>>12&63,e[a++]=128|n>>>6&63,e[a++]=128|63&n);return e},e.buf2binstring=function(t){return c(t,t.length)},e.binstring2buf=function(t){for(var e=new i.Buf8(t.length),n=0,r=e.length;n4)u[i++]=65533,n+=o-1;else{r&=2===o?31:3===o?15:7;while(o>1&&n1?u[i++]=65533:r<65536?u[i++]=r:(r-=65536,u[i++]=55296|r>>10&1023,u[i++]=56320|1023&r)}return c(u,i)},e.utf8border=function(t,e){var n;e=e||t.length,e>t.length&&(e=t.length),n=e-1;while(n>=0&&128===(192&t[n]))n--;return n<0||0===n?e:n+a[t[n]]>e?n:e}},"7bb3":function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-checkbox",t._g({attrs:{disabled:t.disabled},on:{click:t._onClick}},t.$listeners),[n("div",{staticClass:"uni-checkbox-wrapper"},[n("div",{staticClass:"uni-checkbox-input",class:{"uni-checkbox-input-checked":t.checkboxChecked,"uni-checkbox-input-disabled":t.disabled},style:{color:t.color}}),t._t("default")],2)])},r=[],o=n("8af1"),a={name:"Checkbox",mixins:[o["a"],o["e"]],props:{checked:{type:[Boolean,String],default:!1},id:{type:String,default:""},disabled:{type:[Boolean,String],default:!1},color:{type:String,default:"#007aff"},value:{type:String,default:""}},data:function(){return{checkboxChecked:this.checked,checkboxValue:this.value}},watch:{checked:function(t){this.checkboxChecked=t},value:function(t){this.checkboxValue=t}},listeners:{"label-click":"_onClick","@label-click":"_onClick"},created:function(){this.$dispatch("CheckboxGroup","uni-checkbox-group-update",{type:"add",vm:this}),this.$dispatch("Form","uni-form-group-update",{type:"add",vm:this})},beforeDestroy:function(){this.$dispatch("CheckboxGroup","uni-checkbox-group-update",{type:"remove",vm:this}),this.$dispatch("Form","uni-form-group-update",{type:"remove",vm:this})},methods:{_onClick:function(t){this.disabled||(this.checkboxChecked=!this.checkboxChecked,this.$dispatch("CheckboxGroup","uni-checkbox-change",t))},_resetFormData:function(){this.checkboxChecked=!1}}},s=a,c=(n("f53a"),n("2877")),u=Object(c["a"])(s,i,r,!1,null,null,null);e["default"]=u.exports},"7c2b":function(t,e,n){"use strict";var i=n("2c45"),r=n.n(i);r.a},"7d0f":function(t,e,n){"use strict";var i=n("5129"),r=n.n(i),o=n("85b6"),a=n("f2b3");function s(t){t.config.errorHandler=function(e,n,i){var r=Object(a["n"])(e);t.util.warn("Error in ".concat(i,': "').concat("Error"===r?e.toString():e,'"'),n);var s="function"===typeof getApp&&getApp();s&&Object(o["b"])(s.$options,"onError")?s.__call_hook("onError",e):console.error(e)};var e=t.config.isReservedTag;t.config.isReservedTag=function(t){return-1!==r.a.indexOf(t)||e(t)},t.config.ignoredElements=r.a;var n=t.config.getTagNamespace,i=["switch","image","text","view"];t.config.getTagNamespace=function(t){return!~i.indexOf(t)&&n(t)}}var c=n("8c15"),u=n("a34f"),l=n("3e5d");function h(t){Object.defineProperty(t.prototype,"$page",{get:function(){return getCurrentPages()[0].$page}}),t.prototype.$handleVModelEvent=function(t,e){l["b"].sendUIEvent(this._$id,t,{type:"input",target:{value:e}})},t.prototype.$handleViewEvent=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.stop&&t.stopPropagation(),e.prevent&&t.preventDefault();var n=this.$handleEvent(t),i=this._$id,r=t.$origCurrentTarget||t.currentTarget,o=(r===this.$el&&"page"!==this.$options.mpType?"r-":"")+n.options.nid;if("undefined"===typeof o)return console.error("[".concat(i,"] nid not found"));delete n._processed,delete n.mp,delete n.preventDefault,delete n.stopPropagation,delete n.options,delete n.$origCurrentTarget,l["b"].sendUIEvent(i,o,n)}}n("3878"),e["a"]={install:function(t,e){t.prototype._$getRealPath=u["a"],s(t),c["a"].install(t,e),Object(l["a"])(t),h(t)}}},"7df2":function(t,e,n){},"7e6a":function(t,e,n){"use strict";var i=n("515d"),r=n.n(i);r.a},"7eb1":function(t,e,n){"use strict";var i=30,r=12;t.exports=function(t,e){var n,o,a,s,c,u,l,h,d,f,p,v,m,g,_,b,y,w,S,k,x,C,T,O,$;n=t.state,o=t.next_in,O=t.input,a=o+(t.avail_in-5),s=t.next_out,$=t.output,c=s-(e-t.avail_out),u=s+(t.avail_out-257),l=n.dmax,h=n.wsize,d=n.whave,f=n.wnext,p=n.window,v=n.hold,m=n.bits,g=n.lencode,_=n.distcode,b=(1<>>24,v>>>=S,m-=S,S=w>>>16&255,0===S)$[s++]=65535&w;else{if(!(16&S)){if(0===(64&S)){w=g[(65535&w)+(v&(1<>>=S,m-=S),m<15&&(v+=O[o++]<>>24,v>>>=S,m-=S,S=w>>>16&255,!(16&S)){if(0===(64&S)){w=_[(65535&w)+(v&(1<l){t.msg="invalid distance too far back",n.mode=i;break t}if(v>>>=S,m-=S,S=s-c,x>S){if(S=x-S,S>d&&n.sane){t.msg="invalid distance too far back",n.mode=i;break t}if(C=0,T=p,0===f){if(C+=h-S,S2)$[s++]=T[C++],$[s++]=T[C++],$[s++]=T[C++],k-=3;k&&($[s++]=T[C++],k>1&&($[s++]=T[C++]))}else{C=s-x;do{$[s++]=$[C++],$[s++]=$[C++],$[s++]=$[C++],k-=3}while(k>2);k&&($[s++]=$[C++],k>1&&($[s++]=$[C++]))}break}}break}}while(o>3,o-=k,m-=k<<3,v&=(1<0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;return Array.isArray(t[e])&&t[e].length}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=JSON.parse(JSON.stringify(t));return e}function a(t){var e={},n=t.__vue__;function r(t,n){var r=t.$attrs;for(var o in r)if(o.startsWith("data-")){var a=Object(i["b"])(o.substr(5).toLowerCase()),s=r[o];e[a]=n?s:e[a]||s}}if(n){var a=n;while(a&&a.$el===t)r(a),a=a.$children[0];var s=n.$parent;while(s&&s.$el===t)r(s,!0),s=s.$parent}else e=Object.assign({},t.dataset,t.__uniDataset);return o(e)}},8779:function(t,e,n){},8842:function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("uni-movable-view",t._g({},t.$listeners),[n("v-uni-resize-sensor",{on:{resize:t.setParent}}),t._t("default")],2)},r=[],o=n("ba15");function a(t,e,n){return t>e-n&&tthis._t&&(t=this._t,this._lastDt=t);var e=this._x_v*t+.5*this._x_a*Math.pow(t,2)+this._x_s,n=this._y_v*t+.5*this._y_a*Math.pow(t,2)+this._y_s;return(this._x_a>0&&ethis._endPositionX)&&(e=this._endPositionX),(this._y_a>0&&nthis._endPositionY)&&(n=this._endPositionY),{x:e,y:n}},u.prototype.ds=function(t){return void 0===t&&(t=((new Date).getTime()-this._startTime)/1e3),t>this._t&&(t=this._t),{dx:this._x_v+this._x_a*t,dy:this._y_v+this._y_a*t}},u.prototype.delta=function(){return{x:-1.5*Math.pow(this._x_v,2)/this._x_a||0,y:-1.5*Math.pow(this._y_v,2)/this._y_a||0}},u.prototype.dt=function(){return-this._x_v/this._x_a},u.prototype.done=function(){var t=a(this.s().x,this._endPositionX)||a(this.s().y,this._endPositionY)||this._lastDt===this._t;return this._lastDt=null,t},u.prototype.setEnd=function(t,e){this._endPositionX=t,this._endPositionY=e},u.prototype.reconfigure=function(t,e){this._m=t,this._f=1e3*e},l.prototype._solve=function(t,e){var n=this._c,i=this._m,r=this._k,o=n*n-4*i*r;if(0===o){var a=-n/(2*i),s=t,c=e/(a*t);return{x:function(t){return(s+c*t)*Math.pow(Math.E,a*t)},dx:function(t){var e=Math.pow(Math.E,a*t);return a*(s+c*t)*e+c*e}}}if(o>0){var u=(-n-Math.sqrt(o))/(2*i),l=(-n+Math.sqrt(o))/(2*i),h=(e-u*t)/(l-u),d=t-h;return{x:function(t){var e,n;return t===this._t&&(e=this._powER1T,n=this._powER2T),this._t=t,e||(e=this._powER1T=Math.pow(Math.E,u*t)),n||(n=this._powER2T=Math.pow(Math.E,l*t)),d*e+h*n},dx:function(t){var e,n;return t===this._t&&(e=this._powER1T,n=this._powER2T),this._t=t,e||(e=this._powER1T=Math.pow(Math.E,u*t)),n||(n=this._powER2T=Math.pow(Math.E,l*t)),d*u*e+h*l*n}}}var f=Math.sqrt(4*i*r-n*n)/(2*i),p=-n/2*i,v=t,m=(e-p*t)/f;return{x:function(t){return Math.pow(Math.E,p*t)*(v*Math.cos(f*t)+m*Math.sin(f*t))},dx:function(t){var e=Math.pow(Math.E,p*t),n=Math.cos(f*t),i=Math.sin(f*t);return e*(m*f*n-v*f*i)+p*e*(m*i+v*n)}}},l.prototype.x=function(t){return void 0===t&&(t=((new Date).getTime()-this._startTime)/1e3),this._solution?this._endPosition+this._solution.x(t):0},l.prototype.dx=function(t){return void 0===t&&(t=((new Date).getTime()-this._startTime)/1e3),this._solution?this._solution.dx(t):0},l.prototype.setEnd=function(t,e,n){if(n||(n=(new Date).getTime()),t!==this._endPosition||!s(e,.1)){e=e||0;var i=this._endPosition;this._solution&&(s(e,.1)&&(e=this._solution.dx((n-this._startTime)/1e3)),i=this._solution.x((n-this._startTime)/1e3),s(e,.1)&&(e=0),s(i,.1)&&(i=0),i+=this._endPosition),this._solution&&s(i-t,.1)&&s(e,.1)||(this._endPosition=t,this._solution=this._solve(i-this._endPosition,e),this._startTime=n)}},l.prototype.snap=function(t){this._startTime=(new Date).getTime(),this._endPosition=t,this._solution={x:function(){return 0},dx:function(){return 0}}},l.prototype.done=function(t){return t||(t=(new Date).getTime()),a(this.x(),this._endPosition,.1)&&s(this.dx(),.1)},l.prototype.reconfigure=function(t,e,n){this._m=t,this._k=e,this._c=n,this.done()||(this._solution=this._solve(this.x()-this._endPosition,this.dx()),this._startTime=(new Date).getTime())},l.prototype.springConstant=function(){return this._k},l.prototype.damping=function(){return this._c},l.prototype.configuration=function(){function t(t,e){t.reconfigure(1,e,t.damping())}function e(t,e){t.reconfigure(1,t.springConstant(),e)}return[{label:"Spring Constant",read:this.springConstant.bind(this),write:t.bind(this,this),min:100,max:1e3},{label:"Damping",read:this.damping.bind(this),write:e.bind(this,this),min:1,max:500}]},h.prototype.setEnd=function(t,e,n,i){var r=(new Date).getTime();this._springX.setEnd(t,i,r),this._springY.setEnd(e,i,r),this._springScale.setEnd(n,i,r),this._startTime=r},h.prototype.x=function(){var t=((new Date).getTime()-this._startTime)/1e3;return{x:this._springX.x(t),y:this._springY.x(t),scale:this._springScale.x(t)}},h.prototype.done=function(){var t=(new Date).getTime();return this._springX.done(t)&&this._springY.done(t)&&this._springScale.done(t)},h.prototype.reconfigure=function(t,e,n){this._springX.reconfigure(t,e,n),this._springY.reconfigure(t,e,n),this._springScale.reconfigure(t,e,n)};var d=n("2a0a"),f=!1;function p(t){f||(f=!0,requestAnimationFrame((function(){t(),f=!1})))}function v(t,e){if(t===e)return 0;var n=t.offsetLeft;return t.offsetParent?n+=v(t.offsetParent,e):0}function m(t,e){if(t===e)return 0;var n=t.offsetTop;return t.offsetParent?n+=m(t.offsetParent,e):0}function g(t,e){return+((1e3*t-1e3*e)/1e3).toFixed(1)}function _(t,e,n){var i=function(t){t&&t.id&&cancelAnimationFrame(t.id),t&&(t.cancelled=!0)},r={id:0,cancelled:!1};function o(e,n,i,r){if(!e||!e.cancelled){i(n);var a=t.done();a||e.cancelled||(e.id=requestAnimationFrame(o.bind(null,e,n,i,r))),a&&r&&r(n)}}return o(r,t,e,n),{cancel:i.bind(null,r),model:t}}var b={name:"MovableView",mixins:[o["a"]],props:{direction:{type:String,default:"none"},inertia:{type:[Boolean,String],default:!1},outOfBounds:{type:[Boolean,String],default:!1},x:{type:[Number,String],default:0},y:{type:[Number,String],default:0},damping:{type:[Number,String],default:20},friction:{type:[Number,String],default:2},disabled:{type:[Boolean,String],default:!1},scale:{type:[Boolean,String],default:!1},scaleMin:{type:[Number,String],default:.5},scaleMax:{type:[Number,String],default:10},scaleValue:{type:[Number,String],default:1},animation:{type:[Boolean,String],default:!0}},data:function(){return{xSync:this._getPx(this.x),ySync:this._getPx(this.y),scaleValueSync:Number(this.scaleValue)||1,width:0,height:0,minX:0,minY:0,maxX:0,maxY:0}},computed:{dampingNumber:function(){var t=Number(this.damping);return isNaN(t)?20:t},frictionNumber:function(){var t=Number(this.friction);return isNaN(t)||t<=0?2:t},scaleMinNumber:function(){var t=Number(this.scaleMin);return isNaN(t)?.5:t},scaleMaxNumber:function(){var t=Number(this.scaleMax);return isNaN(t)?10:t},xMove:function(){return"all"===this.direction||"horizontal"===this.direction},yMove:function(){return"all"===this.direction||"vertical"===this.direction}},watch:{x:function(t){this.xSync=this._getPx(t)},xSync:function(t){this._setX(t)},y:function(t){this.ySync=this._getPx(t)},ySync:function(t){this._setY(t)},disabled:function(){this.__handleTouchStart()},scaleValue:function(t){this.scaleValueSync=Number(t)||0},scaleValueSync:function(t){this._setScaleValue(t)},scaleMinNumber:function(){this._setScaleMinOrMax()},scaleMaxNumber:function(){this._setScaleMinOrMax()}},created:function(){this._offset={x:0,y:0},this._scaleOffset={x:0,y:0},this._translateX=0,this._translateY=0,this._scale=1,this._oldScale=1,this._STD=new h(1,9*Math.pow(this.dampingNumber,2)/40,this.dampingNumber),this._friction=new u(1,this.frictionNumber),this._declineX=new c,this._declineY=new c,this.__touchInfo={historyX:[0,0],historyY:[0,0],historyT:[0,0]}},mounted:function(){this.touchtrack(this.$el,"_onTrack"),this.setParent(),this._friction.reconfigure(1,this.frictionNumber),this._STD.reconfigure(1,9*Math.pow(this.dampingNumber,2)/40,this.dampingNumber),this.$el.style.transformOrigin="center",Object(d["b"])()},methods:{_getPx:function(t){return/\d+[ur]px$/i.test(t)?uni.upx2px(parseFloat(t)):Number(t)||0},_setX:function(t){if(this.xMove){if(t+this._scaleOffset.x===this._translateX)return this._translateX;this._SFA&&this._SFA.cancel(),this._animationTo(t+this._scaleOffset.x,this.ySync+this._scaleOffset.y,this._scale)}return t},_setY:function(t){if(this.yMove){if(t+this._scaleOffset.y===this._translateY)return this._translateY;this._SFA&&this._SFA.cancel(),this._animationTo(this.xSync+this._scaleOffset.x,t+this._scaleOffset.y,this._scale)}return t},_setScaleMinOrMax:function(){if(!this.scale)return!1;this._updateScale(this._scale,!0),this._updateOldScale(this._scale)},_setScaleValue:function(t){return!!this.scale&&(t=this._adjustScale(t),this._updateScale(t,!0),this._updateOldScale(t),t)},__handleTouchStart:function(){this._isScaling||this.disabled||(Object(d["a"])({disable:!0}),this._FA&&this._FA.cancel(),this._SFA&&this._SFA.cancel(),this.__touchInfo.historyX=[0,0],this.__touchInfo.historyY=[0,0],this.__touchInfo.historyT=[0,0],this.xMove&&(this.__baseX=this._translateX),this.yMove&&(this.__baseY=this._translateY),this.$el.style.willChange="transform",this._checkCanMove=null,this._firstMoveDirection=null,this._isTouching=!0)},__handleTouchMove:function(t){var e=this;if(!this._isScaling&&!this.disabled&&this._isTouching){var n=this._translateX,i=this._translateY;if(null===this._firstMoveDirection&&(this._firstMoveDirection=Math.abs(t.detail.dx/t.detail.dy)>1?"htouchmove":"vtouchmove"),this.xMove&&(n=t.detail.dx+this.__baseX,this.__touchInfo.historyX.shift(),this.__touchInfo.historyX.push(n),this.yMove||null!==this._checkCanMove||(this._checkCanMove=Math.abs(t.detail.dx/t.detail.dy)<1)),this.yMove&&(i=t.detail.dy+this.__baseY,this.__touchInfo.historyY.shift(),this.__touchInfo.historyY.push(i),this.xMove||null!==this._checkCanMove||(this._checkCanMove=Math.abs(t.detail.dy/t.detail.dx)<1)),this.__touchInfo.historyT.shift(),this.__touchInfo.historyT.push(t.detail.timeStamp),!this._checkCanMove){t.preventDefault();var r="touch";nthis.maxX&&(this.outOfBounds?(r="touch-out-of-bounds",n=this.maxX+this._declineX.x(n-this.maxX)):n=this.maxX),ithis.maxY&&(this.outOfBounds?(r="touch-out-of-bounds",i=this.maxY+this._declineY.x(i-this.maxY)):i=this.maxY),p((function(){e._setTransform(n,i,e._scale,r)}))}}},__handleTouchEnd:function(){var t=this;if(!this._isScaling&&!this.disabled&&this._isTouching&&(Object(d["a"])({disable:!1}),this.$el.style.willChange="auto",this._isTouching=!1,!this._checkCanMove&&!this._revise("out-of-bounds")&&this.inertia)){var e=1e3*(this.__touchInfo.historyX[1]-this.__touchInfo.historyX[0])/(this.__touchInfo.historyT[1]-this.__touchInfo.historyT[0]),n=1e3*(this.__touchInfo.historyY[1]-this.__touchInfo.historyY[0])/(this.__touchInfo.historyT[1]-this.__touchInfo.historyT[0]);this._friction.setV(e,n),this._friction.setS(this._translateX,this._translateY);var i=this._friction.delta().x,r=this._friction.delta().y,o=i+this._translateX,a=r+this._translateY;othis.maxX&&(o=this.maxX,a=this._translateY+(this.maxX-this._translateX)*r/i),athis.maxY&&(a=this.maxY,o=this._translateX+(this.maxY-this._translateY)*i/r),this._friction.setEnd(o,a),this._FA=_(this._friction,(function(){var e=t._friction.s(),n=e.x,i=e.y;t._setTransform(n,i,t._scale,"friction")}),(function(){t._FA.cancel()}))}},_onTrack:function(t){switch(t.detail.state){case"start":this.__handleTouchStart();break;case"move":this.__handleTouchMove(t);break;case"end":this.__handleTouchEnd()}},_getLimitXY:function(t,e){var n=!1;return t>this.maxX?(t=this.maxX,n=!0):tthis.maxY?(e=this.maxY,n=!0):e3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0;null!==t&&"NaN"!==t.toString()&&"number"===typeof t||(t=this._translateX||0),null!==e&&"NaN"!==e.toString()&&"number"===typeof e||(e=this._translateY||0),t=Number(t.toFixed(1)),e=Number(e.toFixed(1)),n=Number(n.toFixed(1)),this._translateX===t&&this._translateY===e||r||this.$trigger("change",{},{x:g(t,this._scaleOffset.x),y:g(e,this._scaleOffset.y),source:i}),this.scale||(n=this._scale),n=this._adjustScale(n),n=+n.toFixed(3),o&&n!==this._scale&&this.$trigger("scale",{},{x:t,y:e,scale:n});var a="translateX("+t+"px) translateY("+e+"px) translateZ(0px) scale("+n+")";this.$el.style.transform=a,this.$el.style.webkitTransform=a,this._translateX=t,this._translateY=e,this._scale=n}}},y=b,w=(n("7c2b"),n("2877")),S=Object(w["a"])(y,i,r,!1,null,null,null);e["default"]=S.exports},8875:function(t,e,n){var i,r,o;(function(n,a){r=[],i=a,o="function"===typeof i?i.apply(e,r):i,void 0===o||(t.exports=o)})("undefined"!==typeof self&&self,(function(){function t(){if(document.currentScript)return document.currentScript;try{throw new Error}catch(h){var t,e,n,i=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,r=/@([^@]*):(\d+):(\d+)\s*$/gi,o=i.exec(h.stack)||r.exec(h.stack),a=o&&o[1]||!1,s=o&&o[2]||!1,c=document.location.href.replace(document.location.hash,""),u=document.getElementsByTagName("script");a===c&&(t=document.documentElement.outerHTML,e=new RegExp("(?:[^\\n]+?\\n){0,"+(s-2)+"}[^<]*