flat: init
This commit is contained in:
61
unpackage/dist/dev/mp-weixin/common/globalFunction.js
vendored
Normal file
61
unpackage/dist/dev/mp-weixin/common/globalFunction.js
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
const common_vendor = require("./vendor.js");
|
||||
const stores_useUserStore = require("../stores/useUserStore.js");
|
||||
const msg = (title, duration = 1500, mask = false, icon = "none", image) => {
|
||||
if (Boolean(title) === false) {
|
||||
return;
|
||||
}
|
||||
common_vendor.index.showToast({
|
||||
title,
|
||||
duration,
|
||||
mask,
|
||||
icon,
|
||||
image
|
||||
});
|
||||
};
|
||||
const prePage = () => {
|
||||
let pages = getCurrentPages();
|
||||
let prePage2 = pages[pages.length - 2];
|
||||
return prePage2.$vm;
|
||||
};
|
||||
const navTo = function(url, needLogin) {
|
||||
if (needLogin && stores_useUserStore.useUserStore().hasLogin) {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
});
|
||||
return;
|
||||
}
|
||||
common_vendor.index.navigateTo({
|
||||
url
|
||||
});
|
||||
};
|
||||
function getdeviceInfo() {
|
||||
const globalData = {
|
||||
statusBarHeight: 0,
|
||||
// 状态导航栏高度
|
||||
topHeight: 0,
|
||||
// 距离顶部高度
|
||||
navHeight: 0,
|
||||
// 总体高度
|
||||
windowHeight: 0,
|
||||
// 可使用窗口高度
|
||||
tabBarHight: 0
|
||||
//底部导航栏高度
|
||||
};
|
||||
let systemInfo = common_vendor.index.getSystemInfoSync();
|
||||
globalData.windowHeight = systemInfo.screenHeight;
|
||||
globalData.tabBarHight = systemInfo.screenHeight - systemInfo.safeArea.bottom;
|
||||
globalData.statusBarHeight = systemInfo.statusBarHeight;
|
||||
return {
|
||||
...globalData
|
||||
};
|
||||
}
|
||||
const globalFunction = {
|
||||
"$api": {
|
||||
msg,
|
||||
prePage
|
||||
},
|
||||
navTo,
|
||||
getdeviceInfo
|
||||
};
|
||||
exports.globalFunction = globalFunction;
|
Reference in New Issue
Block a user