You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.6 KiB
JavaScript

2 months ago
let data = {
/*
*/
store () {
return {
appid: 'wxa7b4864efbcff191', //
cdnBaseImg: "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/dailibaoming/", // 图片公共前缀路径
// #ifdef MP-WEIXIN
version: uni.getAccountInfoSync().miniProgram.version || "1.0.0",
mapKey: 'LHQBZ-MLTEG-BO4QK-QJ2TH-NLGZJ-7GFAS',
// #endif
// #ifdef H5 || APP-PLUS || MP-TOUTIAO || MP-KUAISHOU
version: "1.0.0"
// #endif
}
},
/*
*/
shareFun (
path = "/pages/home/index",
image = "",
title = ''
) {
console.log(uni.getStorageSync('miniApp-info'));
let appInfo = uni.getStorageSync('miniApp-info')
let params = {
path: path + `?userId=${uni.getStorageSync("apply-userinfo") ? uni.getStorageSync("apply-userinfo").user.id : ''}`,
imageUrl: appInfo.sharePoster || "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/share.jpeg", // image ? image :
title: appInfo.slogan || ' '
};
return params;
},
/**
* 获取头部nav高度
*/
getNavInfo () {
if (uni.getSystemInfoSync()) {
var { statusBarHeight, platform, windowHeight } = uni.getSystemInfoSync();
}
// #ifdef APP-PLUS || H5 || MP-TOUTIAO || MP-KUAISHOU
var { top, height } = this.getMobileInfo;
// #endif
// #ifdef MP-WEIXIN
if (uni.getMenuButtonBoundingClientRect()) {
var { top, height } = uni.getMenuButtonBoundingClientRect();
}
// #endif
let info = {}
info.statusBarHeight = statusBarHeight;
info.menuButtonHeight = height ? height : 32;
info.windowHeight = windowHeight;
if (top && top !== 0 && height && height !== 0) {
const navigationBarHeight = (top - statusBarHeight) * 2 + height;
// 导航栏高度
info.navigationBarHeight = navigationBarHeight;
} else {
info.navigationBarHeight = platform === "android" ? 48 : 40;
}
return info
},
/*
判断是否登录未登录强制跳转至登录页
*/
isLogin () {
let that = this;
if (!uni.getStorageSync("apply-token")) {
uni.reLaunch({
url: '/root/login/index?path=' + that.getPath().path + '&level=' + that.getPath().level
});
return false;
} else {
return true;
}
},
/* path
*/
getPath () {
const pages = getCurrentPages();
if (pages.length > 0) {
let _path = pages[pages.length - 1].route;
return {
path: _path,
level: _path.slice(0, 4)
}
} else {
return {
path: '',
level: ''
};
}
},
}
export default data;