This commit is contained in:
那些花儿
2025-09-11 14:48:34 +08:00
parent 204deed9d6
commit e931e5d85d
6 changed files with 107 additions and 21 deletions
@@ -99,6 +99,9 @@ layout("/layouts/platform.html"){
show-overflow-tooltip
v-for="column in tableColumns"
></el-table-column>
<el-table-column label="收货地址" prop="receiveAddress" v-if="provideMode===3"></el-table-column>
<el-table-column align="center" fixed="right" header-align="center" label="操作" width="100px">
<template slot-scope="{row}">
<el-button size="mini" type="primary" @click="proxySelect(row)">代选</el-button>
@@ -152,6 +155,9 @@ layout("/layouts/platform.html"){
return this.projectOptions.find((item) => item.id === this.pageForm.projectId).options
}
return []
},
provideMode() {
return this.projectOptions.find((item) => item.id === this.pageForm.projectId).provideMode
}
},
methods: {
@@ -74,11 +74,7 @@ layout("/layouts/platform_h5.html"){
}, 500)
},
back() {
if (this.projectId) {
this.$pjaxReplace("/platform/h5/welfare/userChoose/index?id=" + this.projectId)
} else {
this.$pjaxReplace("/platform/h5/home")
}
this.historyBack()
},
onEdit(row) {
this.title = "编辑地址"
@@ -56,6 +56,10 @@ const selectView = {
<div class="info-row__label">联系电话</div>
<div class="info-row__value">{{ mergedSelections[0]?.mobile || '暂无' }}</div>
</div>
<div class="info-row">
<div class="info-row__label">收货地址</div>
<div class="info-row__value">{{ mergedSelections[0]?.receiveAddress || '暂无' }}</div>
</div>
</div>
</div>
@@ -73,7 +77,7 @@ const selectView = {
:key="item.id"
@click="showOptionDetail(item)">
<div class="selection-item__image">
<img :src="item.imgUrl || '/static/images/default-welfare.png'"
<img :src="item.imgUrl"
alt="福利图片"
@error="handleImageError">
</div>
@@ -678,18 +678,17 @@ layout("/layouts/platform_h5.html"){
maxlength="11"
required
></van-field>
<!--
收货地址字段预留位置
<!--收货地址-->
<van-field
v-if="projectInfo.needAddress"
v-model="formData.address"
v-if="projectInfo.provideMode == 3"
v-model="formData.receiveAddress"
label="收货地址"
placeholder="请输入收货地址"
type="textarea"
rows="2"
placeholder="请选择收货地址"
readonly
is-link
@click="showAddressSheet = true"
required
></van-field>
-->
></van-field>
</div>
<!-- 选择内容 -->
@@ -733,6 +732,35 @@ layout("/layouts/platform_h5.html"){
<div class="welfare-detail-content" v-html="selectedOption.description"></div>
</div>
</van-popup>
<!-- 收货地址选择弹窗 -->
<van-action-sheet v-model="showAddressSheet" title="选择收货地址" :round="true">
<div style="padding: 16px 0 0">
<div
v-for="address in addressOptions"
:key="address.id"
class="address-item"
@click="selectAddress(address)"
style="padding: 12px 16px; border-bottom: 1px solid #f0f0f0; cursor: pointer"
>
<div style="display: flex; justify-content: space-between; align-items: flex-start">
<div style="flex: 1">
<div style="font-size: 16px; font-weight: 500; color: #323233; margin-bottom: 4px">
{{ address.userName }} {{ address.tel }}
</div>
<div style="font-size: 14px; color: #646566; line-height: 1.4">
{{ address.province }}{{ address.city }}{{ address.county }}{{ address.addressDetail }}
</div>
</div>
<van-tag v-if="address.isDefault" type="primary" size="mini" style="margin-left: 8px">默认</van-tag>
</div>
</div>
<div v-if="addressOptions.length === 0" style="text-align: center; padding: 40px 16px; color: #969799">暂无收货地址</div>
</div>
<div style="padding: 16px; border-top: 1px solid #f0f0f0; background: #fafafa">
<van-button type="info" block round @click="goToAddressManage">收货地址管理</van-button>
</div>
</van-action-sheet>
</div>
</div>
@@ -757,8 +785,12 @@ layout("/layouts/platform_h5.html"){
formData: {
userSign: "", // 用户签名
mobile: "", // 手机号码
address: "" // 收货地址(预留)
}
address: "" // 收货地址
},
addressOptions: [],
showAddressSheet: false, // 收货地址选择弹窗
selectedAddressText: "" // 选中的收货地址显示文本
}
},
@@ -815,6 +847,11 @@ layout("/layouts/platform_h5.html"){
if (res.code === 0) {
this.projectInfo = res.data
// 获取收货地址
if (this.projectInfo.provideMode === 3) {
this.getAddress()
}
// 初始化选项的selectNum为0
if (this.projectInfo.options) {
this.projectInfo.options.forEach((option) => {
@@ -846,10 +883,16 @@ layout("/layouts/platform_h5.html"){
}
} else if (this.$store.user && this.$store.user.mobile) {
// 如果没有选择过,使用store中的默认手机号
debugger
this.formData.mobile = this.$store.user.mobile
}
// 地址回显
if (this.projectInfo.provideMode === 3) {
if (this.userSelection && this.userSelection[0].receiveAddress) {
this.formData.receiveAddress = this.userSelection[0].receiveAddress
}
}
// 设置已选择的选项
if (this.projectInfo.options && this.userSelection.length > 0) {
// 单选模式
@@ -898,6 +941,12 @@ layout("/layouts/platform_h5.html"){
return
}
// 如果需要邮寄
if (this.projectInfo.provideMode === 3 && !this.formData.receiveAddress) {
this.$toast.fail("请填写邮寄地址")
return
}
if (this.isSubmitting) return
this.isSubmitting = true
@@ -937,10 +986,10 @@ layout("/layouts/platform_h5.html"){
})
}
// 未来可扩展添加收货地址
if (this.formData.address) {
// 收货地址
if (this.projectInfo.provideMode === 3 && this.formData.receiveAddress) {
selections.forEach((selection) => {
selection.address = this.formData.address
selection.receiveAddress = this.formData.receiveAddress
})
}
@@ -1082,6 +1131,18 @@ layout("/layouts/platform_h5.html"){
}
},
// 选择收货地址
selectAddress(address) {
this.formData.receiveAddress =
address.userName + " " + address.tel + " " + address.province + address.city + address.county + address.addressDetail
this.showAddressSheet = false
},
// 跳转到地址管理页面
goToAddressManage() {
this.$pjaxReplace("/platform/h5/welfare/address/list")
},
// 切换选项选中状态
toggleOption(option) {
if (this.projectInfo.isCheckBox === "radio") {
@@ -1120,6 +1181,14 @@ layout("/layouts/platform_h5.html"){
}
}
}
},
// 获取收货地址
async getAddress() {
const resp = await this.$axios.post("/platform/welfare/addressManage/selectUserAddress")
if (resp.code === 0) {
this.addressOptions = resp.data
}
}
},