修复bug

This commit is contained in:
2026-04-02 11:10:23 +08:00
parent dabf7a3ec8
commit 657933fe16
4 changed files with 395 additions and 375 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ NODE_ENV=development
VITE_DELETE_CONSOLE=false VITE_DELETE_CONSOLE=false
#本地环境 #本地环境
VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api #VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api
#VITE_SERVER_BASEURL=http://192.168.5.200:8080 VITE_SERVER_BASEURL=http://192.168.5.23:8080
#VITE_SERVER_BASEURL=http://192.168.0.148:8888 #VITE_SERVER_BASEURL=http://192.168.0.148:8888
#VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai #VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai
+2 -2
View File
@@ -2,8 +2,8 @@
"name" : "CHEFLINK delivery", "name" : "CHEFLINK delivery",
"appid" : "__UNI__06509BE", "appid" : "__UNI__06509BE",
"description" : "", "description" : "",
"versionName" : "1.0.29", "versionName" : "2.0.1",
"versionCode" : 129, "versionCode" : 201,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {
+75 -61
View File
@@ -1,33 +1,33 @@
<script lang="ts" setup> <script lang="ts" setup>
import * as R from 'ramda' import * as R from 'ramda'
import {z} from "zod"; import {z} from "zod";
import {useLogicStore} from "@/pages-login/store/module/logic"; import {useLogicStore} from "@/pages-login/store/module/logic";
import {Agreement} from "@/constant/enums"; import {Agreement} from "@/constant/enums";
import {debounce} from "throttle-debounce"; import {debounce} from "throttle-debounce";
import Config from "@/config"; import Config from "@/config";
import VerificationCode from "../../components/verification-code.vue"; import VerificationCode from "../../components/verification-code.vue";
import {appUserRegisterPost} from "@/service"; import {appUserRegisterPost} from "@/service";
import {useConfigStore, useUserStore} from "@/store"; import {useConfigStore, useUserStore} from "@/store";
const {t} = useI18n() const {t} = useI18n()
const userStore = useUserStore(); const userStore = useUserStore();
const configStore = useConfigStore() const configStore = useConfigStore()
const logicStore = useLogicStore() const logicStore = useLogicStore()
const areaCode = ref<string>(logicStore.registerForm.areaCode || '+1'); const areaCode = ref<string>(logicStore.registerForm.areaCode || '+1');
const columns = ref<string[]>(Config.phoneCodeList); const columns = ref<string[]>(Config.phoneCodeList);
const isAgreed = ref(false) const isAgreed = ref(false)
const EmailRegisterSchema = z.object({ const EmailRegisterSchema = z.object({
firstName: z.string().min(1, {message: t('pages-login.index.prompt.first-name')}), firstName: z.string().min(1, {message: t('pages-login.index.prompt.first-name')}),
surname: z.string().min(1, {message: t('pages-login.index.prompt.last-name')}), surname: z.string().min(1, {message: t('pages-login.index.prompt.last-name')}),
email: z.string().min(1, {message: t('pages-login.index.prompt.email-address-verify')}).email({message: t('pages-login.index.prompt.email-address-verify')}), email: z.string().min(1, {message: t('pages-login.index.prompt.email-address-verify')}).email({message: t('pages-login.index.prompt.email-address-verify')}),
confirmEmail: z.string().min(1, {message: t('pages-login.index.prompt.email-address-verify')}).email({message: t('pages-login.index.prompt.email-address-verify')}), confirmEmail: z.string().min(1, {message: t('pages-login.index.prompt.email-address-verify')}).email({message: t('pages-login.index.prompt.email-address-verify')}),
loginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}), loginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}),
confirmLoginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}), confirmLoginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}),
}) })
.refine((data) => data.email === data.confirmEmail, { .refine((data) => data.email === data.confirmEmail, {
path: ['confirmEmail'], path: ['confirmEmail'],
message: t('pages-login.index.prompt.confirm-email-verify') message: t('pages-login.index.prompt.confirm-email-verify')
@@ -37,18 +37,18 @@ const EmailRegisterSchema = z.object({
message: t('pages-login.index.prompt.confirm-password-verify') message: t('pages-login.index.prompt.confirm-password-verify')
}) })
const PhoneRegisterSchema = z.object({ const PhoneRegisterSchema = z.object({
firstName: z.string().min(1, {message: t('pages-login.index.prompt.first-name')}), firstName: z.string().min(1, {message: t('pages-login.index.prompt.first-name')}),
surname: z.string().min(1, {message: t('pages-login.index.prompt.last-name')}), surname: z.string().min(1, {message: t('pages-login.index.prompt.last-name')}),
phone: z.string().min(1, {message: t('pages-login.index.prompt.phone-number')}).regex(/^\d{6,11}$/, {message: t('pages-login.index.prompt.phone-number-verify')}), phone: z.string().min(1, {message: t('pages-login.index.prompt.phone-number')}).regex(/^\d{6,11}$/, {message: t('pages-login.index.prompt.phone-number-verify')}),
loginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}), loginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}),
confirmLoginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}), confirmLoginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}),
}).refine((data) => data.loginPwd === data.confirmLoginPwd, { }).refine((data) => data.loginPwd === data.confirmLoginPwd, {
path: ['confirmLoginPwd'], path: ['confirmLoginPwd'],
message: t('pages-login.index.prompt.confirm-password-verify') message: t('pages-login.index.prompt.confirm-password-verify')
}) })
function checkForm(): boolean { function checkForm(): boolean {
const type = logicStore.registerForm.type const type = logicStore.registerForm.type
const schema = type === 'phone' ? PhoneRegisterSchema : EmailRegisterSchema const schema = type === 'phone' ? PhoneRegisterSchema : EmailRegisterSchema
const validateFormField = schema.safeParse(logicStore.registerForm) const validateFormField = schema.safeParse(logicStore.registerForm)
@@ -67,17 +67,17 @@ function checkForm(): boolean {
}) })
} }
return validateFormField.success && isAgreed.value return validateFormField.success && isAgreed.value
} }
const verificationCodeRef = ref() const verificationCodeRef = ref()
const submit = () => { const submit = () => {
// verificationCodeRef.value.onOpen() // verificationCodeRef.value.onOpen()
codeSubmit() codeSubmit()
} }
// 验证码提交 // 验证码提交
const btnLoading = ref(false) const btnLoading = ref(false)
function codeSubmit() { function codeSubmit() {
btnLoading.value = true btnLoading.value = true
// console.log(data) // console.log(data)
const { const {
@@ -85,8 +85,7 @@ function codeSubmit() {
confirmLoginPwd, confirmLoginPwd,
...rest ...rest
} = logicStore.registerForm as any } = logicStore.registerForm as any
appUserRegisterPost({ const requestBody: Record<string, any> = {
body: {
...rest, ...rest,
// 后端接收“确认密码”字段名为 newPwd // 后端接收“确认密码”字段名为 newPwd
newPwd: confirmLoginPwd, newPwd: confirmLoginPwd,
@@ -94,7 +93,21 @@ function codeSubmit() {
// captcha: data.code, // captcha: data.code,
// uuid: data.uuid, // uuid: data.uuid,
userPort: Config.userPort, // 登录端口2 商户端 userPort: Config.userPort, // 登录端口2 商户端
} as any }
if (requestBody.email == null || requestBody.email === '') {
delete requestBody.email
}
const phoneVal = requestBody.phone
if (
phoneVal == null ||
phoneVal === '' ||
(typeof phoneVal === 'string' && phoneVal.trim() === '')
) {
delete requestBody.phone
delete requestBody.areaCode
}
appUserRegisterPost({
body: requestBody as any
}).then((res) => { }).then((res) => {
userStore.token = res.data.token; userStore.token = res.data.token;
logicStore.reset() logicStore.reset()
@@ -128,21 +141,21 @@ function codeSubmit() {
}).finally(() => { }).finally(() => {
btnLoading.value = false btnLoading.value = false
}) })
} }
// 提交 // 提交
const handleSubmit = R.when(checkForm, debounce(Config.debounceLongTime, submit, { const handleSubmit = R.when(checkForm, debounce(Config.debounceLongTime, submit, {
atBegin: true atBegin: true
})) }))
function navigateTo(url: string) { function navigateTo(url: string) {
uni.navigateTo({url}); uni.navigateTo({url});
} }
const emailIsReadonly = ref(false) const emailIsReadonly = ref(false)
const phoneIsReadonly = ref(false) const phoneIsReadonly = ref(false)
onMounted(() => { onMounted(() => {
const {email, confirmEmail, phone, type} = logicStore.registerForm const {email, confirmEmail, phone, type} = logicStore.registerForm
if (type === 'phone') { if (type === 'phone') {
phoneIsReadonly.value = !!phone phoneIsReadonly.value = !!phone
@@ -155,10 +168,10 @@ onMounted(() => {
logicStore.registerForm.email = logicStore.registerForm.confirmEmail logicStore.registerForm.email = logicStore.registerForm.confirmEmail
} }
} }
}) })
</script> </script>
<template> <template>
<view> <view>
<navbar/> <navbar/>
<view class="pt-60rpx px-27rpx pb-80rpx"> <view class="pt-60rpx px-27rpx pb-80rpx">
@@ -337,40 +350,41 @@ onMounted(() => {
<verification-code ref="verificationCodeRef" @submit="codeSubmit"/> <verification-code ref="verificationCodeRef" @submit="codeSubmit"/>
</view> </view>
</template> </template>
<style lang="scss"> <style lang="scss">
page { page {
background-color: #fff; background-color: #fff;
} }
.border-color { .border-color {
height: 98rpx; height: 98rpx;
border-radius: 16rpx; border-radius: 16rpx;
border: 2rpx solid #D4D4D4; border: 2rpx solid #D4D4D4;
} }
:deep(.wd-input__clear) { :deep(.wd-input__clear) {
background-color: transparent !important; background-color: transparent !important;
} }
:deep(.wd-input__icon) { :deep(.wd-input__icon) {
background-color: transparent !important; background-color: transparent !important;
} }
:deep(.wd-picker__cell) { :deep(.wd-picker__cell) {
background-color: transparent !important; background-color: transparent !important;
.wd-picker__value { .wd-picker__value {
margin-right: 8rpx !important; margin-right: 8rpx !important;
} }
} }
:deep(.wd-picker-view-column__item) { :deep(.wd-picker-view-column__item) {
line-height: 94rpx !important; line-height: 94rpx !important;
} }
:deep(.uni-picker-view-indicator) { :deep(.uni-picker-view-indicator) {
height: 94rpx !important; height: 94rpx !important;
} }
</style> </style>
+20 -14
View File
@@ -165,6 +165,20 @@ function getStoreDetail() {
] ]
} }
// 用详情中的首屏菜品初始化列表,并让下一次触底从第 2 页开始,避免仍请求第 1 页导致与详情数据重复
const firstRecords = res.data?.dishPage?.records
if (firstRecords && firstRecords.length > 0) {
dishListByQuery.value = [...firstRecords]
const gotFullPage = firstRecords.length >= pageSize.value
hasMore.value = gotFullPage
pageNum.value = gotFullPage ? 2 : 1
} else if (tabs.value.length > 0) {
dishListByQuery.value = []
hasMore.value = true
pageNum.value = 1
nextTick(() => loadDishList(false))
}
// 商户的经纬度存在,并且用户的经纬度也存在 // 商户的经纬度存在,并且用户的经纬度也存在
if(res.data.latitude && res.data.longitude && userStore.userLocation.latitude && userStore.userLocation.longitude) { if(res.data.latitude && res.data.longitude && userStore.userLocation.latitude && userStore.userLocation.longitude) {
let distance = getDistanceInMiles(res.data.latitude, res.data.longitude, userStore.userLocation.latitude, userStore.userLocation.longitude) let distance = getDistanceInMiles(res.data.latitude, res.data.longitude, userStore.userLocation.latitude, userStore.userLocation.longitude)
@@ -309,15 +323,8 @@ const hasMore = ref(true);
const isLoadingMore = ref(false); const isLoadingMore = ref(false);
const dishListByQuery = ref<any[]>([]); const dishListByQuery = ref<any[]>([]);
// 计算当前显示的商品列表 // 计算当前显示的商品列表(统一走 dishListByQuery,避免「全部」首屏用详情、加载更多再拼第 1 页造成重复)
const currentDishList = computed(() => { const currentDishList = computed(() => dishListByQuery.value || [])
if(tabs.value[activeTab.value].key==''&&pageNum.value===1){
return storeDetail.value?.dishPage?.records
}
console.log(tabs.value[activeTab.value].key=='');
// 使用 dishListByQuery 作为数据源
return dishListByQuery.value || []
})
// 加载菜品列表 // 加载菜品列表
async function loadDishList(isLoadMore = false) { async function loadDishList(isLoadMore = false) {
@@ -352,11 +359,10 @@ async function loadDishList(isLoadMore = false) {
if (res.data && res.data.rows) { if (res.data && res.data.rows) {
if (isLoadMore) { if (isLoadMore) {
// 加载更多,追加数据 // 加载更多:按 id 去重,防止接口分页重叠或重复请求时的重复项
dishListByQuery.value = [ const existingIds = new Set(dishListByQuery.value.map((r: any) => r.id))
...dishListByQuery.value, const nextRows = res.data.rows.filter((r: any) => r != null && !existingIds.has(r.id))
...res.data.rows dishListByQuery.value = [...dishListByQuery.value, ...nextRows]
];
} else { } else {
// 首次加载或刷新 // 首次加载或刷新
dishListByQuery.value = res.data.rows; dishListByQuery.value = res.data.rows;