This commit is contained in:
2023-10-08 22:53:13 +08:00
parent b883b02fb9
commit e36d60d015
83 changed files with 18303 additions and 9590 deletions

View File

@@ -1,26 +1,20 @@
import { showToast, navigateBack } from "@tarojs/taro";
// 经纬度计算距离
export function calculateDistance(
lat1: number,
lon1: number,
lat2: number,
lon2: number
): string {
const R = 6371; // 地球平均半径(单位:千米)
const dLat = toRadians(lat2 - lat1);
const dLon = toRadians(lon2 - lon1);
const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(toRadians(lat1)) *
Math.cos(toRadians(lat2)) *
Math.sin(dLon / 2) *
Math.sin(dLon / 2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
const distance = R * c;
return distance.toFixed(2);
la1: number,
lo1: number,
la2: number,
lo2: number
): any {
var radLat1 = la1 * Math.PI / 180.0;
var radLat2 = la2 * Math.PI / 180.0;
var a = radLat1 - radLat2;
var b = lo1 * Math.PI / 180.0 - lo2 * Math.PI / 180.0;
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * 6378.137;
s = Math.round(s * 10000) / 10000;
return s.toFixed(2) + 'km'
}
// 将角度转换为弧度

18
src/utils/js_sdk/u-charts.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,6 @@
import Taro from "@tarojs/taro";
import Taro from '@tarojs/taro'
export const BASE_URL =
process.env.NODE_ENV === "development"
? "http://192.168.2.3:9000/app"
: "https://www.wanzhuanyongcheng.cn/app";
export const BASE_URL = process.env.TARO_APP_API
interface Res<T> {
code: number;
@@ -11,47 +8,47 @@ interface Res<T> {
msg: string;
}
type Method = "GET" | "POST" | "PUT" | "DELETE";
type Method = 'GET' | 'POST' | 'PUT' | 'DELETE';
const request = (
url: string,
data: object = {},
method: Method = "GET"
method: Method = 'GET'
): Promise<Res<any>> => {
return new Promise((resolve, reject) => {
Taro.showLoading({
title: "加载中...",
mask: true,
});
// Taro.showLoading({
// title: '加载中...',
// mask: true
// })
Taro.request({
url: BASE_URL + url,
data: data,
method: method,
header: {
"content-type": "application/json",
token: Taro.getStorageSync("token"),
'content-type': 'application/json',
token: Taro.getStorageSync('token') || ''
},
success: ({ data }) => {
Taro.hideLoading();
success: ({data}) => {
// Taro.hideLoading()
if (data.code !== 200) {
Taro.showToast({
title: data.msg,
icon: "none",
});
reject(data);
return;
icon: 'none'
})
reject(data)
return
}
resolve(data);
resolve(data)
},
fail: () => {
Taro.showToast({
title: "服务器异常",
icon: "none",
});
reject({ code: 1, msg: "服务器异常" });
},
});
});
};
title: '服务器异常',
icon: 'none'
})
reject({code: 1, msg: '服务器异常'})
}
})
})
}
export default request;
export default request