首页,我的 写扫码点餐之前提交1.0.0

This commit is contained in:
wwz
2025-02-13 16:49:13 +08:00
parent 6cea5aeb42
commit f2513ef13a
48 changed files with 7757 additions and 514 deletions

View File

@@ -1,45 +1,50 @@
import { defineStore } from 'pinia';
import {
defineStore
} from 'pinia';
import {
ref
} from 'vue';
export const useNavbarStore = defineStore('navbar', {
state: () => ({
showBack: true,
rightText: '',
showSearch: false,
title: '',
isTransparent: false,
height: 0,
hasPlaceholder: true,
state: () => ({
showBack: true,
rightText: '',
showSearch: false,
title: '',
isTransparent: false,
height: 0,
hasPlaceholder: true,
scrollTop: 0 //滚动高度
}),
actions: {
updateNavbarConfig(config) {
Object.assign(this, config);
},
initNavbarHeight() {
uni.getSystemInfo({
success: (res) => {
const statusBarHeight = res.statusBarHeight;
let navBarHeight;
}),
actions: {
updateNavbarConfig(config) {
Object.assign(this, config);
},
initNavbarHeight() {
uni.getSystemInfo({
success: (res) => {
const statusBarHeight = res.statusBarHeight;
let navBarHeight;
// 微信小程序的特殊处理
if (res.platform === 'weapp') {
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
const topGap = menuButtonInfo.top - statusBarHeight;
const bottomGap = statusBarHeight + menuButtonInfo.height + topGap * 2 - (menuButtonInfo.top + menuButtonInfo.height);
navBarHeight = menuButtonInfo.height + topGap + bottomGap;
} else if (uni.getSystemInfoSync().platform === 'ios') {
navBarHeight = 44;
} else {
navBarHeight = 48;
}
// 微信小程序的特殊处理
if (res.platform === 'weapp') {
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
const topGap = menuButtonInfo.top - statusBarHeight;
const bottomGap = statusBarHeight + menuButtonInfo.height + topGap * 2 - (
menuButtonInfo.top + menuButtonInfo.height);
navBarHeight = menuButtonInfo.height + topGap + bottomGap;
} else if (uni.getSystemInfoSync().platform === 'ios') {
navBarHeight = 44;
} else {
navBarHeight = 48;
}
this.height = statusBarHeight + navBarHeight;
},
fail: (err) => {
console.error('获取系统信息失败:', err);
this.height = 64; // 失败时设置一个默认高度
}
});
}
}
this.height = statusBarHeight + navBarHeight;
},
fail: (err) => {
console.error('获取系统信息失败:', err);
this.height = 64; // 失败时设置一个默认高度
}
});
}
}
});

88
stores/share.js Normal file
View File

@@ -0,0 +1,88 @@
import {
defineStore
} from 'pinia';
import {
ref
} from 'vue';
import {
APIcustomlogin
} from '@/common/api/api.js'
export const Storelogin = defineStore('login', {
state: () => ({
token: '',
miniAppOpenId: '',
userInfo: ''
}),
actions: {
actionslogin() {
return new Promise((resolve, reject) => {
// #ifdef MP-WEIXIN
uni.login({
provider: 'weixin',
success: (data) => {
// 微信小程序环境
uni.getUserInfo({
provider: 'weixin',
success: async (infoRes) => {
let res = await APIcustomlogin({
code: data.code, //临时登录凭证
rawData: infoRes.rawData,
source: 'wechat'
})
if (res.code == 0) {
this.token = res.data.token
this.miniAppOpenId = res.data.userInfo
.miniAppOpenId
this.userInfo = res.data.userInfo
uni.cache.set('token', res.data.token);
uni.cache.set('miniAppOpenId', res.data
.userInfo
.miniAppOpenId)
uni.cache.set('userInfo', res.data
.userInfo);
}
resolve(true);
},
fail: (err) => {
reject(false);
}
});
}
});
// #endif
// #ifdef MP-ALIPAY
my.getAuthCode({
scopes: 'auth_base',
success: async (data) => {
console.log(data)
// 支付宝小程序环境
// my.getAuthUserInfo({
// success: async (infoRes) => {
let res = await APIcustomlogin({
code: data.authCode, //临时登录凭证
// rawData: JSON.stringify(infoRes),
source: 'alipay'
})
if (res.code == 0) {
this.token = res.data.token
this.miniAppOpenId = res.data.userInfo.miniAppOpenId
this.userInfo = res.data.userInfo
uni.cache.set('token', res.data.token);
uni.cache.set('miniAppOpenId', res.data.userInfo
.miniAppOpenId)
uni.cache.set('userInfo', res.data.userInfo);
resolve(true);
}
},
fail: (err) => {
reject(false);
}
});
}
});
// #endif
}).catch((e) => {});
}
}
});