mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-08-06 19:07:23 +08:00
- 将多个组件转换为 `<script setup>` 语法,提升可读性和性能 - 优化状态管理和事件处理逻辑,简化代码结构 - 更新样式和布局以适应新组件结构 - 添加新功能和修复已知问题,提升用户体验
79 lines
2.1 KiB
Vue
79 lines
2.1 KiB
Vue
<template>
|
|
<view class="address">
|
|
|
|
<u-empty class="empty" v-if="storeAddressList.length == 0" text="暂无自提地址" mode="address"></u-empty>
|
|
<view class="list" v-else>
|
|
<view class="item c-content" v-for="(item, index) in storeAddressList" :key="index">
|
|
<view class="basic" @click="selectAddressData(item)">
|
|
<text>{{ item.addressName }}</text>
|
|
<text>{{ item.mobile }}</text>
|
|
<view>
|
|
<div class="region">
|
|
<span>{{ item.address }}</span>
|
|
</div>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view style="height: 100px"></view>
|
|
</view>
|
|
<u-action-sheet :list="removeList" :tips="tips" v-model:show="showAction" @click="deleteAddressMessage"></u-action-sheet>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app'
|
|
import { useStore } from '@/store'
|
|
import * as API_Trade from '@/api/trade'
|
|
import * as API_Store from '@/api/store.js'
|
|
|
|
const store = useStore()
|
|
|
|
const storeAddressList = ref<any[]>([])
|
|
const showAction = ref(false)
|
|
const removeList = [{ text: '确定' }]
|
|
const tips = { text: '确定要删除该收货人信息吗?' }
|
|
const removeId = ref('')
|
|
const routerVal = ref<Record<string, string>>({})
|
|
const params = { pageNumber: 1, pageSize: 1000 }
|
|
|
|
onPullDownRefresh(() => {
|
|
storeAddressList.value = []
|
|
getAddressList()
|
|
})
|
|
|
|
onLoad((val) => {
|
|
routerVal.value = val || {}
|
|
})
|
|
|
|
onShow(() => {
|
|
storeAddressList.value = []
|
|
getAddressList()
|
|
})
|
|
|
|
function hideLoadingIfNeeded() {
|
|
if (store.state.isShowToast) uni.hideLoading()
|
|
}
|
|
|
|
async function selectAddressData(val: any) {
|
|
await API_Trade.setStoreAddressId(val.id, routerVal.value.way)
|
|
uni.navigateBack({ delta: 1 })
|
|
}
|
|
|
|
function getAddressList() {
|
|
uni.showLoading()
|
|
API_Store.getStoreAddress(routerVal.value.storeId, params).then((res) => {
|
|
storeAddressList.value = res.data.result.records
|
|
hideLoadingIfNeeded()
|
|
})
|
|
}
|
|
|
|
function deleteAddressMessage() {
|
|
// 保留 action-sheet 回调占位,当前页面无删除入口
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import "./address.scss";
|
|
</style>
|