acdr-ui/dist/dev/mp-weixin/sheep/platform/index.js.map

1 line
5.3 KiB
Plaintext
Raw Normal View History

2024-09-19 07:20:14 +08:00
{"version":3,"file":"index.js","sources":["../../../../../src/sheep/platform/index.js"],"sourcesContent":["/**\r\n * Shopro 第三方平台功能聚合\r\n * @version 1.0.3\r\n * @author lidongtony\r\n * @param {String} name - 厂商+平台名称\r\n * @param {String} provider - 厂商\r\n * @param {String} platform - 平台名称\r\n * @param {String} os - 系统型号\r\n * @param {Object} device - 设备信息\r\n */\r\n\r\nimport { isEmpty } from 'lodash-es'\r\n// #ifdef H5\r\nimport { isWxBrowser } from '@/sheep/helper/utils'\r\n// #endif\r\nimport wechat from './provider/wechat/index.js'\r\nimport apple from './provider/apple'\r\nimport share from './share'\r\nimport Pay from './pay'\r\n\r\nconst device = uni.getSystemInfoSync()\r\n\r\nconst os = device.platform\r\n\r\nlet name = ''\r\nlet provider = ''\r\nlet platform = ''\r\nlet isWechatInstalled = true\r\n\r\n// #ifdef H5\r\nif (isWxBrowser()) {\r\n name = 'WechatOfficialAccount'\r\n provider = 'wechat'\r\n platform = 'officialAccount'\r\n} else {\r\n name = 'H5'\r\n platform = 'h5'\r\n}\r\n// #endif\r\n\r\n// #ifdef APP-PLUS\r\nname = 'App'\r\nplatform = 'openPlatform'\r\n// 检查微信客户端是否安装否则AppleStore会因此拒绝上架\r\nif (os === 'ios') {\r\n isWechatInstalled = plus.ios.import('WXApi').isWXAppInstalled()\r\n}\r\n// #endif\r\n\r\n// #ifdef MP-WEIXIN\r\nname = 'WechatMiniProgram'\r\nplatform = 'miniProgram'\r\nprovider = 'wechat'\r\n// #endif\r\n\r\nif (isEmpty(name)) {\r\n uni.showToast({\r\n title: '暂不支持该平台',\r\n icon: 'none',\r\n })\r\n}\r\n\r\n// 加载当前平台前置行为\r\nconst load = () => {\r\n if (provider === 'wechat') {\r\n wechat.load()\r\n }\r\n}\r\n\r\n// 使用厂商独占sdk name = 'wechat' | 'alipay' | 'apple'\r\nconst useProvider = (_provider = '') => {\r\n if (_provider === '') _provider = provider\r\n if (_provider === 'wechat') return wechat\r\n if (_provider === 'apple') return apple\r\n}\r\n\r\n// 支付服务转发\r\nconst pay = (payment, orderType, orderSN) => {\r\n return new Pay(payment, orderType, orderSN)\r\n}\r\n\r\n/**\r\n * 检查更新 (只检查小程序和App)\r\n * @param {Boolean} silence - 静默检查\r\n */\r\nconst checkUpdate = (silence = false) => {\r\n let canUpdate\r\n // #ifdef MP-WEIXIN\r\n useProvider().checkUpdate(silence)\r\n // #endif\r\n\r\n // #ifdef APP-PLUS\r\n // TODO: 热更新\r\n // #endif\r\n}\r\n\r\n/**\r\n * 检查网络\r\n * @param {Boolean} silence - 静默检查\r\n */\r\nasync function checkNetwork() {\r\n const networkStatus = await uni.getNetworkType()\r\n if (networkStatus.networkType == 'none') {\r\n return Promise.resolve(false)\r\n }\r\n return Promise.resolve(true)\r\n}\r\n\r\n// 获取小程序胶囊信息\r\nconst getCapsule = () => {\r\n // #ifdef MP\r\n let capsule = uni.getMenuButtonBoundingClientRect()\r\n if (!capsule) {\r\n capsule = {\r\n bottom: 56,\r\n height: 32,\r\n left: 278,\r\n right: 365,\r\n top: 24,\r\n width: 87,\r\n }\r\n }\r\n return capsule\r\n // #endif\r\n\r\n // #ifndef MP\r\n return {\r\n bottom: 56,\r\n height: 32,\r\n left: 278,\r\n right: 365,\r\n top: 24,\r\n width: 87,\r\n }\r\n // #endif\r\n}\r\n\r\nconst capsule = getCapsule()\r\n\r\n// 标题栏高度\r\nconst getNavBar = () => {\r\n return device.statusBarHeight + 44\r\n}\r\nconst navbar = getNavBar()\r\n\r\nfunction getLandingPage() {\r\n let page = ''\r\n // #ifdef H5\r\n page = location.href.split('?')[0]\r\n // #endif\r\n return page\r\n}\r\n\r\n// 设置ios+公众号网页落地页 解决微信sdk签名问题\r\nconst landingPage = getLandingPage()\r\n\r\nconst _platform = {\r\n name,\r\n device,\r\n os,\r\n provider,\r\n platform,\r\n useProvider,\r\n checkUpdate,\r\n checkNetwork,\r\n pay,\r\n share,\r\n load,\r\n capsule,\r\n navbar,\r\n landingPage,\r\n isWechatInstalled,\r\n}\r\n\r\nexport default _platform\r\n"],"names":["uni","isEmpty","wechat","apple","Pay","capsule","share"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA