consumerm模块完成度90%,完善消费者和商家端数据库表,商品、聊天、订单数据对接好了supabase,和商家端对接了聊天功能,安卓端编译通过了css样式,剩余几个页面在处理函数规范问题
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user