import Taro from '@tarojs/taro'
export default function navTo(url: string, isLogin = false) {
if (isLogin) {
if (!Taro.getStorageSync('access_token') || !Taro.getStorageSync('UserId')) {
Taro.showToast({
title: '请先登录',
icon: 'none',
duration: 500
});
return false;
}
}
Taro.navigateTo({
url: url
})
}
// 转base64
export function fileToBase64(filePath) {
return new Promise((resolve) => {
let fileManager = Taro.getFileSystemManager();
fileManager.readFile({
filePath,
encoding: 'base64',
success: (e: any) => {
resolve(`data:image/jpg;base64,${e.data}`);
}
});
});
};
/**
* 转义微信富文本图片样式
* @param htmlText
*/
export function wxParse(htmlText) {
// Replace
tags with max-width, height and margin styles to remove spacing
htmlText = htmlText.replace(/\![]()