From 9d901b4215323c97a00a068cd962f5c9c04dadfa Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期四, 04 九月 2025 10:15:09 +0800
Subject: [PATCH] 前端
---
h5/utils/utils.js | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/h5/utils/utils.js b/h5/utils/utils.js
index 770fa4b..3562b9e 100644
--- a/h5/utils/utils.js
+++ b/h5/utils/utils.js
@@ -4,3 +4,46 @@
export const runcation = (date) => {
return date.substring(0, 16)
}
+
+// 杩斿洖璺濈
+export function distance(lat1, lng1, lat2, lng2) {
+ var that = this;
+ let rad1 = lat1 * Math.PI / 180.0;
+ let rad2 = lat2 * Math.PI / 180.0;
+ let a = rad1 - rad2;
+ let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
+ let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) *
+ Math.cos(
+ rad2) * Math.pow(
+ Math.sin(b / 2), 2)));
+ s = s * 6378.137 * 1000;
+
+ s = (Math.round(s * 10000) / 10000).toFixed(2);
+ console.log(s)
+ // s = s.toString();
+ // s = s.substring(0, s.indexOf('.') + 2);
+
+ return s
+}
+
+// 鐧诲綍
+export function userLogin() {
+ let that = this;
+ let promise = new Promise((resolve, reject) => {
+ uni.login({
+ provider: 'weixin',
+ success: async function(loginRes) {
+ let { code } = loginRes;
+ let res = await that.$u.api.wxLogin({ code })
+ if (res.code === 200) {
+ resolve(res);
+ // that.$store.commit('setToken', res.data.token)
+ // that.$store.commit('setUserInfo', res.data.userResponse)
+ } else {
+ reject(err)
+ }
+ }
+ });
+ })
+ return promise;
+}
\ No newline at end of file
--
Gitblit v1.9.3