acdr-ui/dist/dev/mp-weixin/utils/commUtils.js

96 lines
2.9 KiB
JavaScript

"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
const common_vendor = require("../common/vendor.js");
const sheep_index = require("../sheep/index.js");
const baseUrl = "http://47.99.70.12:28184/api";
const uploadUrl = "http://47.99.70.12:28184/api";
const ossUrl = "http://116.204.119.171:9000/linghe";
const toast = (message) => {
common_vendor.index.showToast({ title: message, icon: "none" });
};
const imgUrl = (img, isOss) => {
const placeholder = "https://via.placeholder.com/150";
const isLocation = img.startsWith("@/");
if (isLocation)
return img.replace("@", ossUrl);
if (!img)
return placeholder;
const isNetworkImage = img.startsWith("http://") || img.startsWith("https://");
return isNetworkImage ? img : `${uploadUrl + img}`;
};
const showModalAsync = (options) => {
return new Promise((resolve, reject) => {
common_vendor.index.showModal(__spreadProps(__spreadValues({}, options), {
success: (res) => {
if (res.confirm) {
resolve(res);
} else if (res.cancel) {
resolve(res);
}
},
fail: (err) => {
reject(err);
}
}));
});
};
const scanCodeAsync = () => {
return new Promise((resolve, reject) => {
common_vendor.index.scanCode({
onlyFromCamera: true,
// 是否只能从相机扫码
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
}
});
});
};
const toPath = (path) => {
if (path === "/") {
common_vendor.index.switchTab({ url: "/pages/index/index" });
return;
}
if (!path) {
common_vendor.index.switchTab({ url: "/pages/index/index" });
return;
}
const isWebUrl = path.startsWith("http://") || path.startsWith("https://");
if (isWebUrl) {
return;
}
const isMallPath = path.includes("/pages/mall") !== -1;
if (isMallPath) {
sheep_index.sheep.$router.go(path);
return;
}
common_vendor.index.navigateTo({ url: path });
};
exports.baseUrl = baseUrl;
exports.imgUrl = imgUrl;
exports.scanCodeAsync = scanCodeAsync;
exports.showModalAsync = showModalAsync;
exports.toPath = toPath;
exports.toast = toast;
//# sourceMappingURL=commUtils.js.map