function calcContentHeight(chaliang) {
	let contentHeight = 0
	uni.getSystemInfo({
		success(res) {
			contentHeight = res.windowHeight - 40 - chaliang
		}
	})
	return contentHeight
}
function SystemInfo() {//获取屏幕宽高
	let SystemInfo = {}
	uni.getSystemInfo({
		success(res) {
			SystemInfo.windowWidth = res.windowWidth
			SystemInfo.windowHeight = res.windowHeight
		}
	})
	return SystemInfo
}
function getRect(selector) {//获取元素的信息
	return new Promise((resolve) => {
		let view = uni.createSelectorQuery().select(selector);
		view.fields({
			size: true,
			rect: true,
			scrollOffset: true
		}, (res) => {
			resolve(res);
		}).exec();
	})
}
function getretailer() {//判断是否是分销商
	let isdistributor = false
	let mall_UserInfo = uni.getStorageSync("b2b_user");
	if (mall_UserInfo && mall_UserInfo.token) {
		isdistributor = true
	}
	return isdistributor
}
// #ifdef MP-ALIPAY
// 引入消息模板方法   
const { requestSubscribeMessage } = requirePlugin("subscribeMsg");
//支付宝小程序订阅消息
function SubscribeMsgAli(cb) {
	let idsArr = uni.getStorageSync("basedata")?.mall?.alimessage ?? [];
	let ids = [];
	if (idsArr.length > 0) {
		idsArr.map((e) => {
			ids.push(e.MessageId);
		});
	}
	if (ids.length === 0) {
		my.showToast({
			type: 'fail',
			content: '请传入模板id',
			duration: 3000,
		});
		cb();
		return;
	}
	console.log('ids', ids);
	requestSubscribeMessage({ // 触发消息订阅弹框
		entityIds: ids, // 模板消息id，
		callback(res) {
			console.log('订阅回调', res);
			if (res.success) {
				uni.showToast({
					title: "订阅成功",
					duration: 1000,
				});
				cb();
			} else {
				switch (res.errorCode) {
					case 11: {
						my.call('toast', {
							content: '用户取消订阅',
						});
						break;
					}
					default: {
						my.call('toast', {
							content: `ErrorCode: ${res.errorCode}, ErrorMsg: ${res.errorMessage}`,
						});
						break;
					}
				}
				cb();
			}
		}
	})
}
// #endif

export default {
	calcContentHeight,
	SystemInfo,
	getRect,
	getretailer,
	// #ifdef MP-ALIPAY
	SubscribeMsgAli
	// #endif
}