TakeOutShop/store/counter.js

56 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineStore } from 'pinia';
import { computed,ref } from 'vue';
export const useCounterStore = defineStore('counter',()=>{
//定义数据state)
const openId = ref('');
const nikeName = ref('');
const key = ref('');
const phone = ref('');
const uid = ref('');
const statusHeight = ref(uni.getMenuButtonBoundingClientRect()['height']);
const headerHeight = ref(uni.getSystemInfoSync()['statusBarHeight']);
const statusBartop = ref(uni.getMenuButtonBoundingClientRect()['top']);
const ButtonWidth = ref(uni.getMenuButtonBoundingClientRect().width);
const ButtonHeight = ref(uni.getMenuButtonBoundingClientRect().height)
const storeName = ref('');
const storeId = ref('');
const token = ref(uni.getStorageSync('token') || '');
const latitude = ref('');
const longitude = ref('');
const locationName = ref('正在获取定位');
const locationShow = ref(false);
// 设置 Token
const setToken = (tokens,uids,phones,nikeNames) => {
token.value = tokens;
uid.value = uids;
phone.value = phones;
nikeName.value = nikeNames;
uni.setStorageSync('token', tokens);
};
// 清除 Token
const clearToken = () => {
token.value = '';
uni.removeStorageSync('token');
};
//以对象的形式return供组件调用
return{
storeId,
storeName,
nikeName,
key,
token,
setToken,
clearToken,
phone,
uid,
ButtonWidth,
ButtonHeight,
statusHeight,
headerHeight,
statusBartop,
latitude,
longitude,
locationName,
locationShow
}
})