build(custom): 修正提交规范

This commit is contained in:
2023-11-09 19:49:24 +08:00
parent 76d57cea37
commit 29c1d4280f
105 changed files with 29374 additions and 18618 deletions

View File

@@ -2,22 +2,29 @@ import { showToast, navigateBack } from "@tarojs/taro";
// 经纬度计算距离
export function calculateDistance(
la1: number,
lo1: number,
la2: number,
lo2: number
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'
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";
}
// 将角度转换为弧度
function toRadians(degrees: number): number {
return (degrees * Math.PI) / 180;
return (degrees * Math.PI) / 180;
}

File diff suppressed because one or more lines are too long

View File

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