location.js 473 B

1234567891011121314151617181920
  1. import { defineStore } from "pinia";
  2. export const useLocationStore = defineStore('location', () => {
  3. const locationPlugin = uni.requireNativePlugin('Location')
  4. const getLocationInfo = () => {
  5. return new Promise(async (resolve, reject) => {
  6. locationPlugin.getLocationInfo((res) => {
  7. if (res.success) {
  8. resolve(res)
  9. } else {
  10. reject(res.msg)
  11. }
  12. })
  13. })
  14. }
  15. return { getLocationInfo }
  16. })