diff --git a/pages-user/address/submit.vue b/pages-user/address/submit.vue
index 4b471a1..e170116 100644
--- a/pages-user/address/submit.vue
+++ b/pages-user/address/submit.vue
@@ -5,6 +5,36 @@
好友正在为您申请奖品发货,请填写您的准确收货地址
+
+
+ 选择已保存的地址
+
+
+
+
+
+ {{ addr.province }} {{ addr.city }} {{ addr.district }} {{ addr.address }}
+
+
+
+ ✓
+
+
+
+
+ 或填写新地址
+
+
+
收货人
@@ -32,7 +62,7 @@
-
+
* 请确保信息准确,提交后无法修改
* 您已登录,提交后该奖品将转移至您的账户下
@@ -45,10 +75,13 @@
import { ref, reactive, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { request } from '@/utils/request'
+import { listAddresses } from '@/api/appUser'
const token = ref('')
const loading = ref(false)
const isLoggedIn = ref(!!uni.getStorageSync('token'))
+const addressList = ref([])
+const selectedAddressIndex = ref(-1)
const form = reactive({
name: '',
@@ -62,16 +95,52 @@ const form = reactive({
onLoad((options) => {
if (options.token) {
token.value = options.token
+ // 如果已登录,加载用户的地址列表
+ if (isLoggedIn.value) {
+ loadAddressList()
+ }
} else {
uni.showToast({ title: '参数错误', icon: 'none' })
}
})
+// 加载用户地址列表
+async function loadAddressList() {
+ if (!isLoggedIn.value) return
+
+ try {
+ const userId = uni.getStorageSync('user_id')
+ if (!userId) return
+
+ const res = await listAddresses(userId)
+ addressList.value = res.list || res.data || res || []
+ } catch (e) {
+ console.error('获取地址列表失败:', e)
+ addressList.value = []
+ }
+}
+
+// 选择地址
+function selectAddress(index) {
+ selectedAddressIndex.value = index
+ const addr = addressList.value[index]
+ if (addr) {
+ form.name = addr.name || ''
+ form.mobile = addr.mobile || ''
+ form.province = addr.province || ''
+ form.city = addr.city || ''
+ form.district = addr.district || ''
+ form.address = addr.address || ''
+ }
+}
+
function onRegionChange(e) {
const [p, c, d] = e.detail.value
form.province = p
form.city = c
form.district = d
+ // 用户手动修改地区时,清除地址选择状态
+ selectedAddressIndex.value = -1
}
async function onSubmit() {
@@ -127,14 +196,14 @@ async function onSubmit() {
padding: 40rpx;
margin-bottom: 30rpx;
animation: fadeInDown 0.5s ease-out;
-
+
.title {
font-size: 36rpx;
font-weight: 700;
color: $text-main;
margin-bottom: 16rpx;
}
-
+
.desc {
font-size: 26rpx;
color: $text-sub;
@@ -142,17 +211,125 @@ async function onSubmit() {
}
}
+/* 地址列表部分 */
+.address-list-section {
+ margin-bottom: 30rpx;
+ animation: fadeInUp 0.5s ease-out 0.1s backwards;
+}
+
+.section-title {
+ font-size: 28rpx;
+ color: $text-main;
+ font-weight: 600;
+ margin-bottom: 20rpx;
+ padding: 0 10rpx;
+}
+
+.address-list {
+ display: flex;
+ flex-direction: column;
+ gap: 16rpx;
+ margin-bottom: 30rpx;
+}
+
+.address-card {
+ background: #fff;
+ border-radius: $radius-lg;
+ padding: 24rpx;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ box-shadow: $shadow-sm;
+ border: 2rpx solid transparent;
+ transition: all 0.3s;
+
+ &.selected {
+ border-color: $brand-primary;
+ background: rgba($brand-primary, 0.03);
+ }
+
+ &:active {
+ transform: scale(0.98);
+ }
+}
+
+.address-info {
+ flex: 1;
+ margin-right: 20rpx;
+}
+
+.address-header {
+ display: flex;
+ align-items: center;
+ gap: 20rpx;
+ margin-bottom: 12rpx;
+
+ .name {
+ font-size: 30rpx;
+ font-weight: 600;
+ color: $text-main;
+ }
+
+ .mobile {
+ font-size: 26rpx;
+ color: $text-sub;
+ }
+}
+
+.address-detail {
+ font-size: 26rpx;
+ color: $text-secondary;
+ line-height: 1.5;
+}
+
+.address-check {
+ width: 44rpx;
+ height: 44rpx;
+ border-radius: 50%;
+ background: $brand-primary;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+
+ .check-icon {
+ color: #fff;
+ font-size: 28rpx;
+ font-weight: bold;
+ }
+}
+
+.divider {
+ display: flex;
+ align-items: center;
+ margin: 30rpx 0;
+
+ &::before,
+ &::after {
+ content: '';
+ flex: 1;
+ height: 1rpx;
+ background: rgba(0, 0, 0, 0.1);
+ }
+
+ .divider-text {
+ padding: 0 20rpx;
+ font-size: 24rpx;
+ color: $text-tertiary;
+ }
+}
+
.form {
padding: 20rpx 40rpx;
- animation: fadeInUp 0.5s ease-out 0.1s backwards;
+ animation: fadeInUp 0.5s ease-out 0.2s backwards;
}
.form-item {
padding: 30rpx 0;
border-bottom: 1rpx solid rgba(0,0,0,0.05);
-
+
&:last-child { border-bottom: none; }
-
+
.label {
display: block;
font-size: 28rpx;
@@ -160,18 +337,18 @@ async function onSubmit() {
margin-bottom: 20rpx;
font-weight: 600;
}
-
+
.input, .textarea {
width: 100%;
font-size: 28rpx;
color: $text-main;
}
-
+
.textarea {
height: 160rpx;
padding: 0;
}
-
+
.picker-placeholder { color: $text-tertiary; }
}
@@ -191,7 +368,7 @@ async function onSubmit() {
align-items: center;
justify-content: center;
box-shadow: $shadow-warm;
-
+
&:active { transform: scale(0.98); opacity: 0.9; }
}
diff --git a/pages/shop/index.vue b/pages/shop/index.vue
index 6495e29..2beb8a2 100644
--- a/pages/shop/index.vue
+++ b/pages/shop/index.vue
@@ -204,7 +204,6 @@ function normalizeItems(list, kind) {
function switchTab(id) {
if (currentTab.value === id) return
currentTab.value = id
- loading.value = true
items.value = []
allItems.value = []
page.value = 1