|
|
|
|
@ -3,7 +3,9 @@
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
import { lang } from 'moment';
|
|
|
|
|
import {
|
|
|
|
|
lang
|
|
|
|
|
} from 'moment';
|
|
|
|
|
|
|
|
|
|
const base64ToFile = (dataurl, filename = 'file') => {
|
|
|
|
|
let arr = dataurl.split(',')
|
|
|
|
|
@ -65,8 +67,8 @@ const isMobile = (phoneNumber) => {
|
|
|
|
|
}
|
|
|
|
|
// 分享
|
|
|
|
|
const shareInfo = {
|
|
|
|
|
title:"蟹太太",
|
|
|
|
|
imageUrl:"/static/share.jpg"
|
|
|
|
|
title: "蟹太太",
|
|
|
|
|
imageUrl: "/static/share.jpg"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算距离
|
|
|
|
|
@ -93,7 +95,7 @@ const getDistance = (la1, lo1, la2, lo2) => { // 当前的纬度,当前的经
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打开导航
|
|
|
|
|
const toMapAPP = (lat,lng,name) => {
|
|
|
|
|
const toMapAPP = (lat, lng, name) => {
|
|
|
|
|
let that = this
|
|
|
|
|
const lat1 = parseFloat(lat)
|
|
|
|
|
const lng1 = parseFloat(lng)
|
|
|
|
|
@ -165,15 +167,49 @@ const toMapAPP = (lat,lng,name) => {
|
|
|
|
|
}
|
|
|
|
|
// 检查是否空对象
|
|
|
|
|
const isEmptyObject = (obj) => {
|
|
|
|
|
// 检查传入参数是否为一个对象
|
|
|
|
|
if (typeof obj !== 'object' || obj === null) {
|
|
|
|
|
throw new Error('Input must be an object');
|
|
|
|
|
}
|
|
|
|
|
// 检查传入参数是否为一个对象
|
|
|
|
|
if (typeof obj !== 'object' || obj === null) {
|
|
|
|
|
throw new Error('Input must be an object');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 使用Object.keys()方法获取对象的属性键数组,并检查其长度是否为0
|
|
|
|
|
return Object.keys(obj).length === 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const parseAddress = (address) => {
|
|
|
|
|
// 正则表达式匹配省市区和直辖市
|
|
|
|
|
// 直辖市
|
|
|
|
|
const regex = /^(.*?省|.*?市|.*?自治区|.*?特别行政区)(.*?市|.*?自治州|.*?盟|.*?县|.*?区|.*?旗)?/;
|
|
|
|
|
// 省市区
|
|
|
|
|
const regex1 = /^(.*?省|.*?市|.*?自治区|.*?特别行政区)(.*?市|.*?自治州|.*?盟)(.*?区|.*?县|.*?市|.*?旗)/;
|
|
|
|
|
|
|
|
|
|
// 使用Object.keys()方法获取对象的属性键数组,并检查其长度是否为0
|
|
|
|
|
return Object.keys(obj).length === 0;
|
|
|
|
|
|
|
|
|
|
// 初始化返回数组
|
|
|
|
|
let regionArray = [];
|
|
|
|
|
let match = null
|
|
|
|
|
// 检查是否是直辖市
|
|
|
|
|
const directCities = ['北京市', '天津市', '上海市', '重庆市'];
|
|
|
|
|
if(directCities.some(city => address.includes(city))){
|
|
|
|
|
match = address.match(regex);
|
|
|
|
|
}else{
|
|
|
|
|
match = address.match(regex1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log("address",address,match)
|
|
|
|
|
if (match) {
|
|
|
|
|
if (directCities.includes(match[1])) {
|
|
|
|
|
// 直辖市没有省这一级,直接将市名和区名放入数组
|
|
|
|
|
regionArray = [match[1], '市辖区', match[2]];
|
|
|
|
|
} else {
|
|
|
|
|
// 非直辖市,包含省市区
|
|
|
|
|
regionArray = [match[1], match[2], match[3]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return regionArray;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export {
|
|
|
|
|
base64ToFile,
|
|
|
|
|
toast,
|
|
|
|
|
@ -185,5 +221,6 @@ export {
|
|
|
|
|
getDistance,
|
|
|
|
|
toMapAPP,
|
|
|
|
|
shareInfo,
|
|
|
|
|
isEmptyObject
|
|
|
|
|
isEmptyObject,
|
|
|
|
|
parseAddress
|
|
|
|
|
}
|