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

113 lines
2.8 KiB
JavaScript

"use strict";
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
const common_vendor = require("../../common/vendor.js");
const sheep_platform_provider_wechat_index = require("./provider/wechat/index.js");
const sheep_platform_provider_apple_index = require("./provider/apple/index.js");
const sheep_platform_share = require("./share.js");
const sheep_platform_pay = require("./pay.js");
const device = common_vendor.index.getSystemInfoSync();
const os = device.platform;
let name = "";
let provider = "";
let platform = "";
let isWechatInstalled = true;
name = "WechatMiniProgram";
platform = "miniProgram";
provider = "wechat";
if (common_vendor.isEmpty(name)) {
common_vendor.index.showToast({
title: "暂不支持该平台",
icon: "none"
});
}
const load = () => {
if (provider === "wechat") {
sheep_platform_provider_wechat_index.wechat.load();
}
};
const useProvider = (_provider = "") => {
if (_provider === "")
_provider = provider;
if (_provider === "wechat")
return sheep_platform_provider_wechat_index.wechat;
if (_provider === "apple")
return sheep_platform_provider_apple_index.apple;
};
const pay = (payment, orderType, orderSN) => {
return new sheep_platform_pay.SheepPay(payment, orderType, orderSN);
};
const checkUpdate = (silence = false) => {
useProvider().checkUpdate(silence);
};
function checkNetwork() {
return __async(this, null, function* () {
const networkStatus = yield common_vendor.index.getNetworkType();
if (networkStatus.networkType == "none") {
return Promise.resolve(false);
}
return Promise.resolve(true);
});
}
const getCapsule = () => {
let capsule2 = common_vendor.index.getMenuButtonBoundingClientRect();
if (!capsule2) {
capsule2 = {
bottom: 56,
height: 32,
left: 278,
right: 365,
top: 24,
width: 87
};
}
return capsule2;
};
const capsule = getCapsule();
const getNavBar = () => {
return device.statusBarHeight + 44;
};
const navbar = getNavBar();
function getLandingPage() {
let page = "";
return page;
}
const landingPage = getLandingPage();
const _platform = {
name,
device,
os,
provider,
platform,
useProvider,
checkUpdate,
checkNetwork,
pay,
share: sheep_platform_share.$share,
load,
capsule,
navbar,
landingPage,
isWechatInstalled
};
exports._platform = _platform;
//# sourceMappingURL=index.js.map