| | |
| | | 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; |
| | | } |