fix:修复bug
This commit is contained in:
Vendored
+2
-2
@@ -4,7 +4,7 @@ NODE_ENV=development
|
||||
VITE_DELETE_CONSOLE=false
|
||||
|
||||
#本地环境
|
||||
VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api
|
||||
#VITE_SERVER_BASEURL=http://192.168.5.36:8080
|
||||
#VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api
|
||||
VITE_SERVER_BASEURL=http://192.168.5.58:8080
|
||||
#VITE_SERVER_BASEURL=http://192.168.0.148:8888
|
||||
#VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai
|
||||
@@ -320,6 +320,7 @@
|
||||
"input-placeholder": "Email Address/Phone",
|
||||
"prompt": {
|
||||
"confirm-email-verify": "The email address was inconsistent twice",
|
||||
"confirm-password-verify": "The passwords do not match",
|
||||
"email-address-verify": "Please enter the correct email address",
|
||||
"first-name": "Please enter a name",
|
||||
"last-name": "Please enter your last name",
|
||||
@@ -342,6 +343,7 @@
|
||||
},
|
||||
"sign-up": {
|
||||
"confirm-email": "Confirm email",
|
||||
"confirm-password": "Confirm password",
|
||||
"first-name": "First name",
|
||||
"last-name": "Last name",
|
||||
"password": "Password",
|
||||
|
||||
@@ -320,6 +320,7 @@
|
||||
"input-placeholder": "邮箱地址/手机号",
|
||||
"prompt": {
|
||||
"confirm-email-verify": "两次邮箱不一致",
|
||||
"confirm-password-verify": "两次密码不一致",
|
||||
"email-address-verify": "请输入正确的邮箱地址",
|
||||
"first-name": "请输入名字",
|
||||
"last-name": "请输入姓氏",
|
||||
@@ -342,6 +343,7 @@
|
||||
},
|
||||
"sign-up": {
|
||||
"confirm-email": "确认邮箱",
|
||||
"confirm-password": "确认密码",
|
||||
"first-name": "名",
|
||||
"last-name": "姓",
|
||||
"password": "密码",
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
"name" : "CHEFLINK delivery",
|
||||
"appid" : "__UNI__06509BE",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.26",
|
||||
"versionCode" : 126,
|
||||
"versionName" : "1.0.28",
|
||||
"versionCode" : 128,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
|
||||
@@ -70,6 +70,22 @@ const handleSubmit = R.when(checkForm, debounce(Config.debounceLongTime, submit,
|
||||
|
||||
|
||||
function navigateTo(url: string) {
|
||||
// 从“密码页”去注册时,尽量复用上一页输入的邮箱/手机号
|
||||
if (url.includes('/pages-login/pages/sign-up/index')) {
|
||||
const type = logicStore.loginForm.type
|
||||
logicStore.resetRegisterForm()
|
||||
if (type === 'email' && logicStore.loginForm.email) {
|
||||
logicStore.registerForm.type = 'email'
|
||||
logicStore.registerForm.email = logicStore.loginForm.email
|
||||
logicStore.registerForm.confirmEmail = logicStore.loginForm.email
|
||||
} else if (type === 'phone' && logicStore.loginForm.phone) {
|
||||
logicStore.registerForm.type = 'phone'
|
||||
logicStore.registerForm.phone = logicStore.loginForm.phone
|
||||
logicStore.registerForm.areaCode = logicStore.loginForm.areaCode
|
||||
}
|
||||
uni.navigateTo({url});
|
||||
return
|
||||
}
|
||||
logicStore.resetRegisterForm()
|
||||
uni.navigateTo({url});
|
||||
}
|
||||
|
||||
@@ -20,21 +20,38 @@ const columns = ref<string[]>(Config.phoneCodeList);
|
||||
|
||||
const isAgreed = ref(false)
|
||||
|
||||
const EmailRegisterSchema = z.object({
|
||||
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')}),
|
||||
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')}),
|
||||
loginPwd: 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, {
|
||||
path: ['confirmEmail'],
|
||||
message: t('pages-login.index.prompt.confirm-email-verify')
|
||||
})
|
||||
.refine((data) => data.loginPwd === data.confirmLoginPwd, {
|
||||
path: ['confirmLoginPwd'],
|
||||
message: t('pages-login.index.prompt.confirm-password-verify')
|
||||
})
|
||||
|
||||
const FormSchema = z.object({
|
||||
const PhoneRegisterSchema = z.object({
|
||||
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')}),
|
||||
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')}),
|
||||
email: z.string().email({message: t('pages-login.index.prompt.email-address-verify')}),
|
||||
confirmEmail: z.string().email({message: t('pages-login.index.prompt.email-address-verify')}),
|
||||
}).refine((data) => data.email === data.confirmEmail, {
|
||||
path: ['confirmEmail'],
|
||||
message: t('pages-login.index.prompt.confirm-email-verify')
|
||||
confirmLoginPwd: z.string().min(1, {message: t('pages-login.index.prompt.password')}),
|
||||
}).refine((data) => data.loginPwd === data.confirmLoginPwd, {
|
||||
path: ['confirmLoginPwd'],
|
||||
message: t('pages-login.index.prompt.confirm-password-verify')
|
||||
})
|
||||
|
||||
function checkForm(): boolean {
|
||||
const validateFormField = FormSchema.safeParse(logicStore.registerForm)
|
||||
const type = logicStore.registerForm.type
|
||||
const schema = type === 'phone' ? PhoneRegisterSchema : EmailRegisterSchema
|
||||
const validateFormField = schema.safeParse(logicStore.registerForm)
|
||||
if (!validateFormField.success) {
|
||||
const fieldErrorMessage = validateFormField.error.flatten().fieldErrors
|
||||
const errorMessage: string | undefined = R.path([0, 0], R.values(fieldErrorMessage))
|
||||
@@ -63,15 +80,21 @@ const btnLoading = ref(false)
|
||||
function codeSubmit() {
|
||||
btnLoading.value = true
|
||||
// console.log(data)
|
||||
const {
|
||||
confirmEmail,
|
||||
confirmLoginPwd,
|
||||
...rest
|
||||
} = logicStore.registerForm as any
|
||||
appUserRegisterPost({
|
||||
body: {
|
||||
...logicStore.registerForm,
|
||||
phone: logicStore.registerForm.phone,
|
||||
...rest,
|
||||
// 后端接收“确认密码”字段名为 newPwd
|
||||
newPwd: confirmLoginPwd,
|
||||
areaCode: areaCode.value,
|
||||
// captcha: data.code,
|
||||
// uuid: data.uuid,
|
||||
userPort: Config.userPort, // 登录端口2 商户端
|
||||
}
|
||||
} as any
|
||||
}).then((res) => {
|
||||
userStore.token = res.data.token;
|
||||
logicStore.reset()
|
||||
@@ -120,12 +143,17 @@ function navigateTo(url: string) {
|
||||
const emailIsReadonly = ref(false)
|
||||
const phoneIsReadonly = ref(false)
|
||||
onMounted(() => {
|
||||
const {email, type} = logicStore.registerForm
|
||||
const {email, confirmEmail, phone, type} = logicStore.registerForm
|
||||
if (type === 'phone') {
|
||||
// phoneIsReadonly.value = true
|
||||
phoneIsReadonly.value = !!phone
|
||||
emailIsReadonly.value = false
|
||||
}
|
||||
if (type === 'email') {
|
||||
// emailIsReadonly.value = true
|
||||
emailIsReadonly.value = !!(email || confirmEmail)
|
||||
phoneIsReadonly.value = false
|
||||
if (!logicStore.registerForm.email && logicStore.registerForm.confirmEmail) {
|
||||
logicStore.registerForm.email = logicStore.registerForm.confirmEmail
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -139,7 +167,7 @@ onMounted(() => {
|
||||
</view>
|
||||
<view class="">
|
||||
<!-- 邮箱 -->
|
||||
<view class="">
|
||||
<view v-if="logicStore.registerForm.type !== 'phone'" class="">
|
||||
<view class="text-32rpx leading-32rpx text-#14181B mb-24rpx">{{ t("common.email") }}</view>
|
||||
<view class="border-color px-30rpx flex items-center bg-#EFEFEF">
|
||||
<wd-input
|
||||
@@ -158,7 +186,7 @@ onMounted(() => {
|
||||
</view>
|
||||
</view>
|
||||
<!-- Confirm email -->
|
||||
<view class="mt-36rpx">
|
||||
<view v-if="logicStore.registerForm.type !== 'phone'" class="mt-36rpx">
|
||||
<view class="text-32rpx leading-32rpx text-#14181B mb-24rpx">{{
|
||||
t("pages-login.sign-up.confirm-email")
|
||||
}}
|
||||
@@ -198,6 +226,25 @@ onMounted(() => {
|
||||
</wd-input>
|
||||
</view>
|
||||
</view>
|
||||
<!-- Confirm password -->
|
||||
<view class="mt-36rpx ">
|
||||
<view class="text-32rpx leading-32rpx text-#14181B mb-24rpx">{{ t("pages-login.sign-up.confirm-password") }}</view>
|
||||
<view class="border-color px-30rpx flex items-center bg-#EFEFEF">
|
||||
<wd-input
|
||||
v-model.trim="logicStore.registerForm.confirmLoginPwd"
|
||||
:cursorSpacing="20"
|
||||
:focus-when-clear="false"
|
||||
:maxlength="20"
|
||||
:placeholder="t('common.enterPassword')"
|
||||
clearable
|
||||
custom-class="flex-1 !bg-transparent"
|
||||
no-border
|
||||
placeholderClass="!text-#999 !text-32rpx"
|
||||
showPassword
|
||||
>
|
||||
</wd-input>
|
||||
</view>
|
||||
</view>
|
||||
<!-- First name -->
|
||||
<view class="mt-36rpx ">
|
||||
<view class="text-32rpx leading-32rpx text-#14181B mb-24rpx">{{ t("pages-login.sign-up.first-name") }}</view>
|
||||
@@ -235,7 +282,7 @@ onMounted(() => {
|
||||
</view>
|
||||
</view>
|
||||
<!-- Phone number -->
|
||||
<view class="mt-36rpx ">
|
||||
<view v-if="logicStore.registerForm.type !== 'email'" class="mt-36rpx ">
|
||||
<view class="text-32rpx leading-32rpx text-#14181B mb-24rpx">{{
|
||||
t("pages-login.sign-up.phone-number")
|
||||
}}
|
||||
|
||||
@@ -13,9 +13,10 @@ export const useLogicStore = defineStore('login-logic', () => {
|
||||
email: '',
|
||||
confirmEmail: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
surname: '',
|
||||
phone: '',
|
||||
loginPwd: '',
|
||||
confirmLoginPwd: '',
|
||||
areaCode: defaultAreaCode.value,
|
||||
captcha: "",
|
||||
})
|
||||
@@ -81,6 +82,7 @@ export const useLogicStore = defineStore('login-logic', () => {
|
||||
surname: '',
|
||||
phone: '',
|
||||
loginPwd: '',
|
||||
confirmLoginPwd: '',
|
||||
areaCode: defaultAreaCode.value,
|
||||
captcha: "",
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ function handleClickSegmented(index: number) {
|
||||
deliveryMethod.value = index
|
||||
// 重置配送类型为预约配送
|
||||
deliveryTimeType.value = 2
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ function selectedTipChange(item: any) {
|
||||
if(item.value === selectedTipIndex.value) return
|
||||
diyTipValue.value = ''
|
||||
selectedTipIndex.value = item.value
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
|
||||
// 批量订单:选择某个店铺的小费
|
||||
@@ -213,7 +213,7 @@ function selectedTipChangeForMerchant(merchantId: string, item: any) {
|
||||
if(item.value === merchantTipIndexMap.value[merchantId]) return
|
||||
merchantDiyTipValueMap.value[merchantId] = ''
|
||||
merchantTipIndexMap.value[merchantId] = item.value
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
|
||||
// 单个订单的自定义小费确认(金额,单位:美元)
|
||||
@@ -227,7 +227,7 @@ function handleConfirmTip() {
|
||||
if (selectedTipIndex.value !== 0) {
|
||||
selectedTipIndex.value = 0
|
||||
}
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
|
||||
// 批量订单:确认某个店铺的自定义小费(金额,单位:美元)
|
||||
@@ -240,7 +240,7 @@ function handleConfirmTipForMerchant(merchantId: string) {
|
||||
if (merchantTipIndexMap.value[merchantId] !== 0) {
|
||||
merchantTipIndexMap.value[merchantId] = 0
|
||||
}
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
|
||||
// 是否选择了配送周卡
|
||||
@@ -249,7 +249,7 @@ const isWeeklyDelivery = ref(false);
|
||||
const toggleWeeklyDelivery = (value: boolean) => {
|
||||
if(value === isWeeklyDelivery.value) return
|
||||
isWeeklyDelivery.value = value;
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
};
|
||||
|
||||
// 价格明细
|
||||
@@ -297,50 +297,67 @@ const formData = ref<CreateOrderCartBo>({
|
||||
})
|
||||
// 是否需要餐具
|
||||
const needTableware = ref(false)
|
||||
onLoad((options: any)=> {
|
||||
|
||||
async function safeAwait<T>(label: string, task: () => Promise<T>): Promise<T | undefined> {
|
||||
try {
|
||||
return await task()
|
||||
} catch (e) {
|
||||
console.error(`[checkout] ${label} failed`, e)
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
onLoad(async (options: any)=> {
|
||||
loading.value = true
|
||||
|
||||
// 判断是批量下单还是普通下单
|
||||
if(options.type == 'batch' && options.cartIds) {
|
||||
// 批量下单模式
|
||||
orderType.value = 'batch'
|
||||
batchCartIds.value = options.cartIds.split(',')
|
||||
console.log("下单类型",options.type);
|
||||
try {
|
||||
// 判断是批量下单还是普通下单
|
||||
if(options.type == 'batch' && options.cartIds) {
|
||||
// 批量下单模式
|
||||
orderType.value = 'batch'
|
||||
batchCartIds.value = options.cartIds.split(',')
|
||||
console.log("下单类型",options.type);
|
||||
|
||||
// 默认取用户信息中的手机号作为收货手机号
|
||||
formData.value.phone = userStore.userInfo.phone || ''
|
||||
contact.value.areaCode = userStore.userInfo.areaCode || ''
|
||||
// 获取用户地址列表
|
||||
getAddressList()
|
||||
// 查询批量购物车详情
|
||||
getBatchCartInfo()
|
||||
// 查询用户默认信用卡
|
||||
appUserCardSelectDefault()
|
||||
} else if(options.storeId) {
|
||||
// 普通下单模式
|
||||
orderType.value = 'normal'
|
||||
storeId.value = options.storeId as string
|
||||
formData.value.orderRemark = options.orderRemark as string
|
||||
// 默认取用户信息中的手机号作为收货手机号
|
||||
formData.value.phone = userStore.userInfo.phone || ''
|
||||
contact.value.areaCode = userStore.userInfo.areaCode || ''
|
||||
|
||||
needTableware.value = options.needTableware === 'true'
|
||||
// 严格按顺序执行
|
||||
await safeAwait('getAddressList', getAddressList)
|
||||
await safeAwait('getBatchCartInfo', getBatchCartInfo)
|
||||
await safeAwait('appUserCardSelectDefault', appUserCardSelectDefault)
|
||||
} else if(options.storeId) {
|
||||
// 普通下单模式
|
||||
orderType.value = 'normal'
|
||||
storeId.value = options.storeId as string
|
||||
formData.value.orderRemark = options.orderRemark as string
|
||||
|
||||
// 默认取用户信息中的手机号作为收货手机号
|
||||
formData.value.phone = userStore.userInfo.phone || ''
|
||||
contact.value.areaCode = userStore.userInfo.areaCode || ''
|
||||
// 获取用户地址列表
|
||||
getAddressList()
|
||||
// 查询当前店铺购物车详情
|
||||
getCartInfo()
|
||||
// 获取商家详情信息
|
||||
getStoreDetail()
|
||||
// 查询用户默认信用卡
|
||||
appUserCardSelectDefault()
|
||||
needTableware.value = options.needTableware === 'true'
|
||||
|
||||
// 默认取用户信息中的手机号作为收货手机号
|
||||
formData.value.phone = userStore.userInfo.phone || ''
|
||||
contact.value.areaCode = userStore.userInfo.areaCode || ''
|
||||
|
||||
// 严格按顺序执行
|
||||
await safeAwait('getAddressList', getAddressList)
|
||||
await safeAwait('getCartInfo', getCartInfo)
|
||||
await safeAwait('getStoreDetail', getStoreDetail)
|
||||
await safeAwait('appUserCardSelectDefault', appUserCardSelectDefault)
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
onShow(()=> {
|
||||
// 刷新购物车列表
|
||||
getAddressList()
|
||||
onShow(async ()=> {
|
||||
// 刷新地址,并在必要时重新计算价格
|
||||
await safeAwait('getAddressList', getAddressList)
|
||||
const hasCart =
|
||||
orderType.value === 'batch'
|
||||
? (batchCartIds.value?.length || 0) > 0
|
||||
: (cartDataList.value?.length || 0) > 0
|
||||
if (hasCart) {
|
||||
await safeAwait('appMerchantOrderCalculatePriceCart', appMerchantOrderCalculatePriceCart)
|
||||
}
|
||||
})
|
||||
|
||||
// 页面加载状态
|
||||
@@ -360,24 +377,21 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
const cartDataList = ref<MerchantCartVo[]>([])
|
||||
function getCartInfo() {
|
||||
appMerchantCartListByMerchantIdPost({
|
||||
async function getCartInfo() {
|
||||
const res: any = await appMerchantCartListByMerchantIdPost({
|
||||
params: {
|
||||
merchantId: storeId.value,
|
||||
}
|
||||
}).then((res: any)=> {
|
||||
console.log('购物车列表', res)
|
||||
cartDataList.value = res.data
|
||||
|
||||
// 购物车有菜品,查询菜品会员折扣价
|
||||
if(cartDataList.value.length > 0) {
|
||||
appMerchantCartCalculateSavings()
|
||||
// 查询购物车下单价格
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
}).finally(()=> {
|
||||
loading.value = false
|
||||
})
|
||||
|
||||
console.log('购物车列表', res)
|
||||
cartDataList.value = res.data
|
||||
|
||||
// 购物车有菜品,查询菜品会员折扣价 + 计算价格(严格串行)
|
||||
if(cartDataList.value.length > 0) {
|
||||
await appMerchantCartCalculateSavings()
|
||||
await appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
}
|
||||
|
||||
// 批量下单:查询购物车详情
|
||||
@@ -430,30 +444,26 @@ async function getBatchCartInfo() {
|
||||
cartDataList.value = results.filter(item => item !== null);
|
||||
console.log('批量模式-最终购物车数据', cartDataList.value);
|
||||
|
||||
// 查询菜品会员折扣价
|
||||
// 批量模式:查询菜品会员折扣价 + 计算价格(严格串行)
|
||||
if(cartIds.length > 0) {
|
||||
appMerchantCartCalculateSavings()
|
||||
// 注意:价格计算会在地址加载完成后自动调用
|
||||
// 这里不需要立即调用 appMerchantOrderCalculatePriceCart()
|
||||
await appMerchantCartCalculateSavings()
|
||||
await appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取批量购物车详情失败', error)
|
||||
cartDataList.value = [];
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 查询菜品会员折扣价
|
||||
const cartSavingsData = ref({})
|
||||
function appMerchantCartCalculateSavings() {
|
||||
async function appMerchantCartCalculateSavings() {
|
||||
const cartIds = orderType.value == 'batch' ? batchCartIds.value : cartDataList.value.map(item => item.id)
|
||||
appMerchantCartCalculateSavingsPost({
|
||||
const res: any = await appMerchantCartCalculateSavingsPost({
|
||||
body: cartIds
|
||||
}).then(res=> {
|
||||
console.log('菜品会员折扣价', res)
|
||||
cartSavingsData.value = res.data
|
||||
})
|
||||
console.log('菜品会员折扣价', res)
|
||||
cartSavingsData.value = res.data
|
||||
}
|
||||
|
||||
// 获取商家详情信息
|
||||
@@ -470,58 +480,56 @@ const storeIsSelfPickup = computed(()=> {
|
||||
const storeDetail = ref<MerchantVo>({})
|
||||
// 用户距离商家的距离信息
|
||||
const storeDistance = ref(null)
|
||||
function getStoreDetail() {
|
||||
appMerchantDetailMerchantIdGet({
|
||||
async function getStoreDetail() {
|
||||
const res: any = await appMerchantDetailMerchantIdGet({
|
||||
params: {
|
||||
merchantId: storeId.value,
|
||||
}
|
||||
}).then((res: any) => {
|
||||
console.log('商家详情', res)
|
||||
storeDetail.value = res.data as MerchantVo
|
||||
|
||||
// 配送时间(是否支持配送)
|
||||
if(+storeDetail.value.deliveryService === 1) {
|
||||
// 配送时间
|
||||
deliveryMinutes.value = res.data.deliveryTime || 0
|
||||
}
|
||||
if(+storeDetail.value.selfPickup === 1) {
|
||||
// 自提时间
|
||||
selfPickupMinutes.value = res.data.pickupTime
|
||||
}
|
||||
// 商户的经纬度存在,并且用户的经纬度也存在
|
||||
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)
|
||||
console.log('距离商家距离', distance)
|
||||
storeDistance.value = distance
|
||||
}
|
||||
|
||||
// 判断配送和自取的开通状态
|
||||
const hasDelivery = +storeDetail.value.deliveryService === 1
|
||||
const hasPickup = +storeDetail.value.selfPickup === 1
|
||||
|
||||
if (!hasDelivery && !hasPickup) {
|
||||
// 两个都没开通,不显示切换组件
|
||||
showDeliverySwitch.value = false
|
||||
} else if (!hasDelivery && hasPickup) {
|
||||
// 只开通自取,默认选中自取
|
||||
deliveryMethod.value = 1
|
||||
showDeliverySwitch.value = true
|
||||
} else if (hasDelivery && !hasPickup) {
|
||||
// 只开通配送,默认选中配送
|
||||
deliveryMethod.value = 0
|
||||
showDeliverySwitch.value = true
|
||||
} else {
|
||||
// 两个都开通,默认选中配送
|
||||
deliveryMethod.value = 0
|
||||
showDeliverySwitch.value = true
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('获取商家详情失败:', error);
|
||||
})
|
||||
|
||||
console.log('商家详情', res)
|
||||
storeDetail.value = res.data as MerchantVo
|
||||
|
||||
// 配送时间(是否支持配送)
|
||||
if(+storeDetail.value.deliveryService === 1) {
|
||||
// 配送时间
|
||||
deliveryMinutes.value = res.data.deliveryTime || 0
|
||||
}
|
||||
if(+storeDetail.value.selfPickup === 1) {
|
||||
// 自提时间
|
||||
selfPickupMinutes.value = res.data.pickupTime
|
||||
}
|
||||
// 商户的经纬度存在,并且用户的经纬度也存在
|
||||
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)
|
||||
console.log('距离商家距离', distance)
|
||||
storeDistance.value = distance
|
||||
}
|
||||
|
||||
// 判断配送和自取的开通状态
|
||||
const hasDelivery = +storeDetail.value.deliveryService === 1
|
||||
const hasPickup = +storeDetail.value.selfPickup === 1
|
||||
|
||||
if (!hasDelivery && !hasPickup) {
|
||||
// 两个都没开通,不显示切换组件
|
||||
showDeliverySwitch.value = false
|
||||
} else if (!hasDelivery && hasPickup) {
|
||||
// 只开通自取,默认选中自取
|
||||
deliveryMethod.value = 1
|
||||
showDeliverySwitch.value = true
|
||||
} else if (hasDelivery && !hasPickup) {
|
||||
// 只开通配送,默认选中配送
|
||||
deliveryMethod.value = 0
|
||||
showDeliverySwitch.value = true
|
||||
} else {
|
||||
// 两个都开通,默认选中配送
|
||||
deliveryMethod.value = 0
|
||||
showDeliverySwitch.value = true
|
||||
}
|
||||
}
|
||||
|
||||
const priceData = ref({})
|
||||
function appMerchantOrderCalculatePriceCart() {
|
||||
async function appMerchantOrderCalculatePriceCart() {
|
||||
// 优先使用新选择的地址id
|
||||
const targetAddressId = selectedAddressId.value || currentAddressId.value
|
||||
// if(!targetAddressId) return
|
||||
@@ -561,7 +569,7 @@ function appMerchantOrderCalculatePriceCart() {
|
||||
}
|
||||
})
|
||||
|
||||
appMerchantOrderCalculatePriceCartBatchPost({
|
||||
const res: any = await appMerchantOrderCalculatePriceCartBatchPost({
|
||||
body: {
|
||||
addressId: targetAddressId,
|
||||
cartIds: cartIds,
|
||||
@@ -571,10 +579,9 @@ function appMerchantOrderCalculatePriceCart() {
|
||||
phone: formData.value.phone,
|
||||
areaCode: contact.value.areaCode,
|
||||
}
|
||||
}).then(res=> {
|
||||
console.log('批量购物车下单价格', res)
|
||||
priceData.value = res.data
|
||||
})
|
||||
console.log('批量购物车下单价格', res)
|
||||
priceData.value = res.data
|
||||
} else {
|
||||
// 普通模式使用单店铺计算价格接口
|
||||
// 计算小费金额(美元)
|
||||
@@ -588,7 +595,7 @@ function appMerchantOrderCalculatePriceCart() {
|
||||
}
|
||||
}
|
||||
|
||||
appMerchantOrderCalculatePriceCartPost({
|
||||
const res: any = await appMerchantOrderCalculatePriceCartPost({
|
||||
body: {
|
||||
addressId: targetAddressId,
|
||||
cartIds: cartIds,
|
||||
@@ -599,10 +606,9 @@ function appMerchantOrderCalculatePriceCart() {
|
||||
phone: formData.value.phone,
|
||||
areaCode: contact.value.areaCode,
|
||||
}
|
||||
}).then(res=> {
|
||||
console.log('购物车下单价格', res)
|
||||
priceData.value = res.data
|
||||
})
|
||||
console.log('购物车下单价格', res)
|
||||
priceData.value = res.data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,36 +626,30 @@ const addressInfo = computed(()=> {
|
||||
return addressesList.value.find(item => String(item.id) === String(targetId)) || {};
|
||||
});
|
||||
|
||||
function getAddressList() {
|
||||
appUserAddressListPost({
|
||||
async function getAddressList() {
|
||||
const res: any = await appUserAddressListPost({
|
||||
params: {
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('获取用户地址列表', res)
|
||||
addressesList.value = res.rows
|
||||
if(addressesList.value.length > 0) {
|
||||
currentAddressId.value = addressesList.value[0].id
|
||||
|
||||
let data = addressesList.value[0]
|
||||
|
||||
// 回显送达偏好(deliveryType: 1-亲自送达 2-放门口)
|
||||
if(+data.deliveryType === 1) {
|
||||
visitMethod.value.label = t('components.visit.leaveItToMePersonally')
|
||||
visitMethod.value.value = 0
|
||||
}
|
||||
if(+data.deliveryType === 2) {
|
||||
visitMethod.value.label = t('components.visit.putItAtTheDoor')
|
||||
visitMethod.value.value = 1
|
||||
}
|
||||
|
||||
// 如果是批量模式,地址加载完成后重新计算价格
|
||||
if(orderType.value === 'batch') {
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log('获取用户地址列表', res)
|
||||
addressesList.value = res.rows
|
||||
if(addressesList.value.length > 0) {
|
||||
currentAddressId.value = addressesList.value[0].id
|
||||
|
||||
let data = addressesList.value[0]
|
||||
|
||||
// 回显送达偏好(deliveryType: 1-亲自送达 2-放门口)
|
||||
if(+data.deliveryType === 1) {
|
||||
visitMethod.value.label = t('components.visit.leaveItToMePersonally')
|
||||
visitMethod.value.value = 0
|
||||
}
|
||||
if(+data.deliveryType === 2) {
|
||||
visitMethod.value.label = t('components.visit.putItAtTheDoor')
|
||||
visitMethod.value.value = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function chooseAddress() {
|
||||
@@ -675,17 +675,18 @@ function chooseAddress() {
|
||||
}
|
||||
|
||||
// 重新计算价格
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function appUserCardSelectDefault() {
|
||||
appUserCardSelectDefaultPost({}).then(res=> {
|
||||
return appUserCardSelectDefaultPost({}).then((res: any)=> {
|
||||
console.log('查询用户默认信用卡', res)
|
||||
payMethodOptions.value.cardId = res.data?.cardId || ''
|
||||
payMethodOptions.value.cardNumber = res.data?.cardNumber || ''
|
||||
return res
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1078,7 +1079,7 @@ function navigateToCoupon(merchantId?: string) {
|
||||
couponInfo.value = data
|
||||
}
|
||||
// 重新计算价格
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
},
|
||||
},
|
||||
@@ -1093,7 +1094,7 @@ function handleClose(merchantId?: string) {
|
||||
couponInfo.value = null
|
||||
}
|
||||
// 重新计算价格
|
||||
appMerchantOrderCalculatePriceCart()
|
||||
void appMerchantOrderCalculatePriceCart()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ function getStoreDetail() {
|
||||
<view class="flex items-center gap-12rpx">
|
||||
<text class="current-price">US${{ dishDetailData?.discountPrice }}</text>
|
||||
<text class="original-price">US${{ dishDetailData?.originalPrice }}</text>
|
||||
<view class="member-price-tag center">
|
||||
<view v-if="Number(dishDetailData?.memberPrice) > 0" class="member-price-tag center">
|
||||
<text class="member-price-text">{{ t('pages-store.store.members') }}: ${{ dishDetailData?.memberPrice }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -695,7 +695,10 @@ function handleShare() {
|
||||
</view>
|
||||
<view class="flex-center-sb mt-12rpx">
|
||||
<text class="text-26rpx lh-30rpx text-#333 font-500">US${{ item.discountPrice }}</text>
|
||||
<view class="member-price-tag text-[#FBE3C3] font-500 text-28rpx lh-28rpx center pl-6rpx break-all">
|
||||
<view
|
||||
v-if="Number(item.memberPrice) > 0"
|
||||
class="member-price-tag text-[#FBE3C3] font-500 text-28rpx lh-28rpx center pl-6rpx break-all"
|
||||
>
|
||||
<text class="!text-24rpx">{{ t('pages-store.store.members') }}: </text>
|
||||
${{ item.memberPrice }}
|
||||
</view>
|
||||
|
||||
@@ -311,7 +311,7 @@ function navigateTo(url: string) {
|
||||
|
||||
<!-- 会员价标签 -->
|
||||
<view
|
||||
v-if="item.merchantDishVo.memberPrice"
|
||||
v-if="Number(item.merchantDishVo.memberPrice) > 0"
|
||||
class="member-price-tag ml-10rpx center pl-16rpx pr-6rpx pb-2rpx"
|
||||
>
|
||||
<text class="text-[#FBE3C3] text-20rpx"
|
||||
|
||||
@@ -138,7 +138,12 @@ defineExpose({
|
||||
</view>
|
||||
<view class="flex-center-sb">
|
||||
<text class="text-30rpx lh-30rpx text-#333 font-500">US${{ item.merchantDishVo.discountPrice }}</text>
|
||||
<view class="member-price-tag text-[#FBE3C3] text-18rpx center pl-6rpx">{{ t('pages-store.store.members') }}: ${{ item.merchantDishVo.memberPrice }}</view>
|
||||
<view
|
||||
v-if="Number(item.merchantDishVo.memberPrice) > 0"
|
||||
class="member-price-tag text-[#FBE3C3] text-18rpx center pl-6rpx"
|
||||
>
|
||||
{{ t('pages-store.store.members') }}: ${{ item.merchantDishVo.memberPrice }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-center-sb mt-12rpx">
|
||||
<view class="text-28rpx text-#999">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import {thumbnailImg} from "@/utils/utils";
|
||||
const props = defineProps<{
|
||||
list: object[];
|
||||
list: any[];
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -16,11 +16,13 @@ function handleClickFood(item: any) {
|
||||
<scroll-view scroll-x="true">
|
||||
<view class="flex">
|
||||
<view class="w-30rpx shrink-0"></view>
|
||||
<template v-for="(item, index) in list">
|
||||
<template v-for="(item, index) in list" :key="item?.id ?? index">
|
||||
<view @click="handleClickFood(item)" :class="[index === 0 ? '' : 'ml-28rpx']">
|
||||
<image :src="thumbnailImg(item?.shopImages?.split(',')[0])" class="w-448rpx h-252rpx rounded-24rpx mb-20rpx bg-common" mode="aspectFill"></image>
|
||||
<text class="text-30rpx lh-30rpx text-#333 font-500 line-clamp-1">{{ item?.merchantName }}</text>
|
||||
<view v-if="+item.deliveryService === 1" class="text-#CE7138 text-24rpx lh-24rpx mt-12rpx">${{ item.deliveryFee }} {{ t('pages.home.deliveryFee') }}</view>
|
||||
<view v-if="+item.deliveryService === 1" class="text-#CE7138 text-24rpx lh-24rpx mt-12rpx">
|
||||
{{ t('pages-store.store.tips5') }} ${{ item.deliveryFee }}{{ t('pages-store.store.start') }}
|
||||
</view>
|
||||
<view class="text-24rpx lh-24rpx flex items-center mt-12rpx">
|
||||
<text class="text-#333 font-500">{{ item.rating }}</text>
|
||||
<image src="@img/chef/124.png" class="w-24rpx h-24rpx mx-4rpx mt-2rpx"></image>
|
||||
|
||||
@@ -384,7 +384,10 @@ const debouncedEmit = debounce(1300, (isCollected: boolean, id: string, type: Co
|
||||
</view>
|
||||
<view class="flex-center-sb mt-12rpx">
|
||||
<text class="text-32rpx lh-30rpx text-#333 font-500">US${{ item?.discountPrice }}</text>
|
||||
<view class="member-price-tag text-[#FBE3C3] font-500 text-30rpx lh-30rpx center pl-6rpx break-all">
|
||||
<view
|
||||
v-if="Number(item?.memberPrice) > 0"
|
||||
class="member-price-tag text-[#FBE3C3] font-500 text-30rpx lh-30rpx center pl-6rpx break-all"
|
||||
>
|
||||
<text>{{ t('pages-store.store.members') }}: </text>
|
||||
${{ item?.memberPrice }}
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user