Merge remote-tracking branch 'origin/cyh666666/consumer'

This commit is contained in:
not-like-juvenile
2026-03-18 20:34:55 +08:00
2321 changed files with 130733 additions and 36674 deletions

View File

@@ -1,4 +1,4 @@
<!-- 地址管理页面 -->
<!-- 地址管理页面 -->
<template>
<view class="address-page">
<!-- 顶部栏 -->
@@ -131,7 +131,8 @@
</template>
<script setup lang="uts">
import { ref, onMounted } from 'vue'
import { ref, onMounted, onUnmounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import supa from '@/components/supadb/aksupainstance.uts'
type AddressType = {
@@ -150,7 +151,6 @@ type AddressType = {
const addressList = ref<Array<AddressType>>([])
const fromSelect = ref<boolean>(false)
const selectCallback = ref<any>(null)
const showNewAddressForm = ref<boolean>(false)
const newAddress = ref<any>({
recipient_name: '',
@@ -163,16 +163,14 @@ const newAddress = ref<any>({
})
const smartAddressInput = ref<string>('')
onLoad((options: any) => {
const optObj = (options instanceof UTSJSONObject) ? (options as UTSJSONObject) : (JSON.parse(JSON.stringify(options ?? {})) as UTSJSONObject)
const flag = optObj.getString('fromSelect') ?? ''
fromSelect.value = (flag == '1' || flag == 'true')
})
// 生命周期
onMounted(() => {
const eventChannel = uni.getEventChannel()
if (eventChannel) {
eventChannel.on('fromSelect', (data: any) => {
fromSelect.value = data.fromSelect || false
selectCallback.value = data.callback
})
}
loadAddresses()
// 监听地址更新事件从checkout页面或其他页面
@@ -222,7 +220,11 @@ const loadAddresses = async () => {
// 获取当前用户ID
const getCurrentUserId = (): string | null => {
const userStore = uni.getStorageSync('userInfo')
return userStore?.id || null
if (userStore instanceof UTSJSONObject) {
return userStore.getString('id')
}
const obj = JSON.parse(JSON.stringify(userStore ?? {})) as UTSJSONObject
return obj.getString('id')
}
// 获取完整地址
@@ -232,9 +234,11 @@ const getFullAddress = (address: AddressType): string => {
// 选择地址
const selectAddress = (address: AddressType) => {
if (fromSelect.value && selectCallback.value) {
// 返回选择的地址
selectCallback.value(address)
if (fromSelect.value) {
try {
uni.setStorageSync('selectedAddress', JSON.stringify(address))
} catch (e) {}
uni.$emit('addressSelected', address)
uni.navigateBack()
}
}
@@ -916,3 +920,4 @@ const cancelNewAddress = () => {
border: none;
}
</style>