From 712c080180b9e8511b4e1c26d707882a557b26c7 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 16 七月 2025 18:26:30 +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