Commit ee263c3a authored by spc's avatar spc

foixed

parent ac3c2070
...@@ -76,21 +76,35 @@ export default { ...@@ -76,21 +76,35 @@ export default {
type: String, type: String,
default: '25|25|25|25' default: '25|25|25|25'
}, },
fallResult: {
type: String,
default: ''
},
optionDistribution: { optionDistribution: {
type: Array, type: Array,
default: () => [ default: () => [
{ label: '能吃', percentage: '30%', color: '#B27C1E' }, { label: '能吃', percentage: '25%', color: '#B27C1E' },
{ label: '少吃', percentage: '23%', color: '#B27C1E' }, { label: '少吃', percentage: '25%', color: '#B27C1E' },
{ label: '慎吃', percentage: '17%', color: '#B27C1E' }, { label: '慎吃', percentage: '25%', color: '#B27C1E' },
{ label: '禁吃', percentage: '30%', color: '#B27C1E' } { label: '禁吃', percentage: '25%', color: '#B27C1E' }
] ]
} }
}, },
computed: { computed: {
// 根据allResult字符串生成显示用的选项分布数据 // 根据fallResult或allResult字符串生成显示用的选项分布数据
displayOptionDistribution() { displayOptionDistribution() {
// 如果有allResult属性且格式正确,使用它来生成分布数据 // 优先使用fallResult(后端返回的实际数据)
if (this.allResult && this.allResult.trim() !== '' && this.allResult.includes('|')) { if (this.fallResult && this.fallResult.trim() !== '' && this.fallResult.includes('|')) {
const percentages = this.fallResult.split('|');
const labels = ['能吃', '少吃', '慎吃', '禁吃'];
return percentages.map((percent, index) => ({
label: labels[index] || '',
percentage: `${percent}%`
}));
}
// 如果没有fallResult,再使用allResult
else if (this.allResult && this.allResult.trim() !== '' && this.allResult.includes('|')) {
const percentages = this.allResult.split('|'); const percentages = this.allResult.split('|');
const labels = ['能吃', '少吃', '慎吃', '禁吃']; const labels = ['能吃', '少吃', '慎吃', '禁吃'];
......
...@@ -372,25 +372,25 @@ ...@@ -372,25 +372,25 @@
{ {
"path": "goodDetail/goodDetail", "path": "goodDetail/goodDetail",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": "商品详情"
} }
}, },
{ {
"path": "settlementCenter/settlementCenter", "path": "settlementCenter/settlementCenter",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": "结算中心"
} }
}, },
{ {
"path": "orderDetail/orderDetail", "path": "orderDetail/orderDetail",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": "订单详情"
} }
}, },
{ {
"path": "payResultPage/payResultPage", "path": "payResultPage/payResultPage",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": "支付结果"
} }
}, },
{ {
...@@ -400,10 +400,9 @@ ...@@ -400,10 +400,9 @@
} }
}, },
{ {
"path" : "orderList/orderList", "path": "orderList/orderList",
"style" : "style": {
{ "navigationBarTitleText": "我的订单"
"navigationBarTitleText" : "我的订单"
} }
} }
] ]
......
...@@ -105,39 +105,40 @@ import { getAddressDetail, saveAddress, updateAddress, deleteAddress, getAddress ...@@ -105,39 +105,40 @@ import { getAddressDetail, saveAddress, updateAddress, deleteAddress, getAddress
export default { export default {
data() { data() {
return { return {
isEditMode: false, isEditMode: false,
addressId: '', addressId: '',
isLoading: false, isLoading: false,
phoneError: false, isSubmitting: false, // 用于防连点
formData: { phoneError: false,
name: '', formData: {
phone: '', name: '',
region: '', phone: '',
province: '', region: '',
city: '', province: '',
district: '', city: '',
detailAddress: '', district: '',
houseNumber: '', detailAddress: '',
isDefault: false, houseNumber: '',
email: '', isDefault: false,
postalCode: '' email: '',
}, postalCode: ''
showPicker: false, },
pickerValue: [0, 0, 0, 0], showPicker: false,
provinces: [], pickerValue: [0, 0, 0, 0],
cities: [], provinces: [],
districts: [], cities: [],
streets: [], districts: [],
selectedProvince: null, streets: [],
selectedCity: null, selectedProvince: null,
selectedDistrict: null, selectedCity: null,
selectedStreet: null, selectedDistrict: null,
isLoadingRegions: false, selectedStreet: null,
currentLevel: 0, // 当前选择的级别 0:省份 1:城市 2:区县 3:街道 isLoadingRegions: false,
currentLevelData: [] // 当前级别显示的数据 currentLevel: 0, // 当前选择的级别 0:省份 1:城市 2:区县 3:街道
} currentLevelData: [] // 当前级别显示的数据
}, }
},
computed: { computed: {
canSave() { canSave() {
// 除默认按钮外,所有必填项都必须填写且格式正确 // 除默认按钮外,所有必填项都必须填写且格式正确
...@@ -668,6 +669,9 @@ export default { ...@@ -668,6 +669,9 @@ export default {
// 设置为默认地址 // 设置为默认地址
async setAsDefault() { async setAsDefault() {
// 防连点检查
if (this.isSubmitting) return;
this.isSubmitting = true;
try { try {
// 先获取当前地址列表,检查是否已有默认地址 // 先获取当前地址列表,检查是否已有默认地址
const response = await getAddressList(); const response = await getAddressList();
...@@ -694,6 +698,8 @@ export default { ...@@ -694,6 +698,8 @@ export default {
title: '设置失败,请重试', title: '设置失败,请重试',
icon: 'none' icon: 'none'
}); });
} finally {
this.isSubmitting = false;
} }
}, },
...@@ -724,6 +730,8 @@ export default { ...@@ -724,6 +730,8 @@ export default {
// 处理保存操作 // 处理保存操作
handleSave() { handleSave() {
// 防连点检查
if (this.isSubmitting) return;
if (!this.validateForm()) return; if (!this.validateForm()) return;
// 构建完整地址 // 构建完整地址
...@@ -742,6 +750,9 @@ export default { ...@@ -742,6 +750,9 @@ export default {
// 保存地址(新增) // 保存地址(新增)
async saveAddress(addressInfo) { async saveAddress(addressInfo) {
// 防连点检查
if (this.isSubmitting) return;
this.isSubmitting = true;
this.isLoading = true; this.isLoading = true;
try { try {
// 如果要设为默认地址,先处理其他默认地址 // 如果要设为默认地址,先处理其他默认地址
...@@ -790,11 +801,15 @@ export default { ...@@ -790,11 +801,15 @@ export default {
}); });
} finally { } finally {
this.isLoading = false; this.isLoading = false;
this.isSubmitting = false;
} }
}, },
// 更新地址(编辑) // 更新地址(编辑)
async updateAddress(addressInfo) { async updateAddress(addressInfo) {
// 防连点检查
if (this.isSubmitting) return;
this.isSubmitting = true;
this.isLoading = true; this.isLoading = true;
try { try {
// 如果要设为默认地址,先处理其他默认地址 // 如果要设为默认地址,先处理其他默认地址
...@@ -844,6 +859,7 @@ export default { ...@@ -844,6 +859,7 @@ export default {
}); });
} finally { } finally {
this.isLoading = false; this.isLoading = false;
this.isSubmitting = false;
} }
}, },
...@@ -867,6 +883,8 @@ export default { ...@@ -867,6 +883,8 @@ export default {
// 删除地址 // 删除地址
deleteAddress() { deleteAddress() {
// 防连点检查
if (this.isSubmitting) return;
uni.showModal({ uni.showModal({
title: '确认删除', title: '确认删除',
content: '确定要删除这个地址吗?', content: '确定要删除这个地址吗?',
...@@ -874,6 +892,7 @@ export default { ...@@ -874,6 +892,7 @@ export default {
cancelText: '取消', cancelText: '取消',
success: async (res) => { success: async (res) => {
if (res.confirm) { if (res.confirm) {
this.isSubmitting = true;
this.isLoading = true; this.isLoading = true;
try { try {
const response = await deleteAddress({ id: this.addressId }); const response = await deleteAddress({ id: this.addressId });
...@@ -903,6 +922,7 @@ export default { ...@@ -903,6 +922,7 @@ export default {
}); });
} finally { } finally {
this.isLoading = false; this.isLoading = false;
this.isSubmitting = false;
} }
} }
} }
...@@ -916,6 +936,9 @@ export default { ...@@ -916,6 +936,9 @@ export default {
// 微信导入功能 // 微信导入功能
importFromWechat() { importFromWechat() {
// 防连点检查
if (this.isSubmitting) return;
this.isSubmitting = true;
wx.chooseAddress({ wx.chooseAddress({
success: (res) => { success: (res) => {
console.log('微信地址导入成功:', res); console.log('微信地址导入成功:', res);
...@@ -936,6 +959,9 @@ export default { ...@@ -936,6 +959,9 @@ export default {
area: res.countyName area: res.countyName
}); });
// 导入后验证手机号格式
this.validatePhone();
uni.showToast({ uni.showToast({
title: '地址导入成功', title: '地址导入成功',
icon: 'success' icon: 'success'
...@@ -952,12 +978,11 @@ export default { ...@@ -952,12 +978,11 @@ export default {
showCancel: false, showCancel: false,
confirmText: '我知道了' confirmText: '我知道了'
}); });
} else {
uni.showToast({
title: '导入失败,请重试',
icon: 'none'
});
} }
},
complete: () => {
// 无论成功失败,都重置防连点状态
this.isSubmitting = false;
} }
}); });
} }
......
...@@ -51,7 +51,8 @@ export default { ...@@ -51,7 +51,8 @@ export default {
addressList: [], addressList: [],
showDeleteConfirm: false, showDeleteConfirm: false,
currentDeleteIndex: -1, currentDeleteIndex: -1,
isLoading: false isLoading: false,
isSubmitting: false // 用于防连点
}; };
}, },
onLoad() { onLoad() {
...@@ -122,13 +123,23 @@ export default { ...@@ -122,13 +123,23 @@ export default {
// 编辑地址 // 编辑地址
editAddress(id) { editAddress(id) {
// 防连点检查
if (this.isSubmitting) return;
this.isSubmitting = true;
uni.navigateTo({ uni.navigateTo({
url: `/v3/addressList/addressEdit?id=${id}` url: `/v3/addressList/addressEdit?id=${id}`,
complete: () => {
// 页面跳转完成后重置防连点状态
this.isSubmitting = false;
}
}); });
}, },
// 添加地址 // 添加地址
addAddress() { addAddress() {
// 防连点检查
if (this.isSubmitting) return;
// 检查地址数量限制 // 检查地址数量限制
if (this.addressList.length >= 20) { if (this.addressList.length >= 20) {
uni.showToast({ uni.showToast({
...@@ -139,13 +150,20 @@ export default { ...@@ -139,13 +150,20 @@ export default {
return; return;
} }
this.isSubmitting = true;
uni.navigateTo({ uni.navigateTo({
url: '/v3/addressList/addressEdit' url: '/v3/addressList/addressEdit',
complete: () => {
// 页面跳转完成后重置防连点状态
this.isSubmitting = false;
}
}); });
}, },
// 确认删除 // 确认删除
confirmDelete(index) { confirmDelete(index) {
// 防连点检查
if (this.isSubmitting) return;
this.currentDeleteIndex = index; this.currentDeleteIndex = index;
this.showDeleteConfirm = true; this.showDeleteConfirm = true;
}, },
...@@ -158,34 +176,40 @@ export default { ...@@ -158,34 +176,40 @@ export default {
// 删除地址 // 删除地址
async deleteAddress() { async deleteAddress() {
if (this.currentDeleteIndex >= 0) { // 防连点检查
const address = this.addressList[this.currentDeleteIndex]; if (this.isSubmitting || this.currentDeleteIndex < 0) return;
try { this.isSubmitting = true;
const response = await deleteAddress({ id: address.id }); this.isLoading = true;
console.log('删除地址接口返回:', response);
const address = this.addressList[this.currentDeleteIndex];
if (response.ok && response.success) { try {
this.addressList.splice(this.currentDeleteIndex, 1); const response = await deleteAddress({ id: address.id });
uni.showToast({ console.log('删除地址接口返回:', response);
title: '删除成功',
icon: 'success' if (response.ok && response.success) {
}); this.addressList.splice(this.currentDeleteIndex, 1);
} else {
uni.showToast({
title: response.msg || '删除失败',
icon: 'none'
});
}
} catch (error) {
console.error('删除地址失败:', error);
uni.showToast({ uni.showToast({
title: '网络错误,请重试', title: '删除成功',
icon: 'success'
});
} else {
uni.showToast({
title: response.msg || '删除失败',
icon: 'none' icon: 'none'
}); });
} }
} catch (error) {
console.error('删除地址失败:', error);
uni.showToast({
title: '网络错误,请重试',
icon: 'none'
});
} finally {
this.showDeleteConfirm = false;
this.currentDeleteIndex = -1;
this.isLoading = false;
this.isSubmitting = false;
} }
this.showDeleteConfirm = false;
this.currentDeleteIndex = -1;
}, },
// 截断姓名显示 // 截断姓名显示
......
...@@ -25,16 +25,19 @@ ...@@ -25,16 +25,19 @@
<text class="exchange-count">已兑换{{ formatCount(goodsData.saleCount) }}</text> <text class="exchange-count">已兑换{{ formatCount(goodsData.saleCount) }}</text>
</view> </view>
<!-- 会员标签 --> <!-- 标签容器 -->
<view class="member-tags" v-if="goodsData.vipLimit && goodsData.vipLimit.length > 0"> <view class="tags-container">
<text class="member-level" v-for="(level, index) in goodsData.vipLimit" :key="index">{{ level <!-- 会员标签 -->
}}</text> <view class="member-tags" v-if="goodsData.vipLimit && goodsData.vipLimit.length > 0">
</view> <text class="member-level" v-for="(level, index) in goodsData.vipLimit" :key="index">{{ level
}}</text>
<!-- 购买限制 --> </view>
<view class="purchase-limit-section" v-if="goodsData.userBuyLimitCount">
<text class="purchase-limit">每人限{{ goodsData.userBuyLimitCount }}</text> <!-- 购买限制 -->
</view> <view class="purchase-limit-section" v-if="goodsData.userBuyLimitCount">
<text class="purchase-limit">每人限{{ goodsData.userBuyLimitCount }}</text>
</view>
</view>
<!-- 优惠券名称 --> <!-- 优惠券名称 -->
<view class="coupon-title-section"> <view class="coupon-title-section">
...@@ -81,7 +84,7 @@ ...@@ -81,7 +84,7 @@
</view> </view>
<!-- 净含量选择 --> <!-- 净含量选择 -->
<view class="spec-section"> <view class="spec-section" v-if="specOptions && specOptions.length > 0">
<text class="spec-label">净含量</text> <text class="spec-label">净含量</text>
<view class="spec-options"> <view class="spec-options">
<view class="spec-option" :class="{ active: selectedSpec === spec.value }" <view class="spec-option" :class="{ active: selectedSpec === spec.value }"
...@@ -153,6 +156,7 @@ export default { ...@@ -153,6 +156,7 @@ export default {
vipLimit: [], // 会员限制数组 vipLimit: [], // 会员限制数组
limit: '', limit: '',
goodsLimit: false, // 商品购买限制 goodsLimit: false, // 商品购买限制
userBuyLimitCount: 0, // 用户购买限制数量
name: '', name: '',
couponName: '', couponName: '',
expireDate: '', expireDate: '',
...@@ -372,6 +376,7 @@ export default { ...@@ -372,6 +376,7 @@ export default {
vipLimit: data.vipLimit || [], // 会员限制数组 vipLimit: data.vipLimit || [], // 会员限制数组
limit: data.groupCount ? data.groupCount.toString() : '1', limit: data.groupCount ? data.groupCount.toString() : '1',
goodsLimit: data.goodsLimit || false, // 商品购买限制 goodsLimit: data.goodsLimit || false, // 商品购买限制
userBuyLimitCount: data.userBuyLimitCount || 0, // 用户购买限制数量
name: data.goodsName || data.name || '', name: data.goodsName || data.name || '',
couponName: data.goodsName || data.name || '', couponName: data.goodsName || data.name || '',
expireDate: data.expireTime && data.expireTime.length > 0 ? data.expireTime[0] : '', expireDate: data.expireTime && data.expireTime.length > 0 ? data.expireTime[0] : '',
...@@ -447,6 +452,7 @@ export default { ...@@ -447,6 +452,7 @@ export default {
vipLimit: data.vipLimit || [], // 会员限制数组 vipLimit: data.vipLimit || [], // 会员限制数组
limit: data.groupCount ? data.groupCount.toString() : '1', limit: data.groupCount ? data.groupCount.toString() : '1',
goodsLimit: data.goodsLimit || false, // 商品购买限制 goodsLimit: data.goodsLimit || false, // 商品购买限制
userBuyLimitCount: data.userBuyLimitCount || 0, // 用户购买限制数量
name: data.goodsName || data.name || '', name: data.goodsName || data.name || '',
couponName: data.goodsName || data.name || '', couponName: data.goodsName || data.name || '',
expireDate: data.expireTime && data.expireTime.length > 0 ? data.expireTime[0] : '', expireDate: data.expireTime && data.expireTime.length > 0 ? data.expireTime[0] : '',
...@@ -1254,11 +1260,21 @@ export default { ...@@ -1254,11 +1260,21 @@ export default {
color: #999; color: #999;
} }
/* 标签容器 - 包含会员标签和购买限制 */
.tags-container {
display: flex;
gap: 20rpx;
margin-bottom: 20rpx;
flex-wrap: nowrap;
align-items: center;
}
/* 会员标签 */ /* 会员标签 */
.member-tags { .member-tags {
display: flex; display: flex;
gap: 20rpx; gap: 20rpx;
margin-bottom: 20rpx; flex-wrap: nowrap;
margin-bottom: 0;
} }
.member-level { .member-level {
...@@ -1267,11 +1283,13 @@ export default { ...@@ -1267,11 +1283,13 @@ export default {
background-color: #FCF2E2; background-color: #FCF2E2;
padding: 8rpx 16rpx; padding: 8rpx 16rpx;
border-radius: 20rpx; border-radius: 20rpx;
white-space: nowrap;
} }
/* 购买限制区域 */ /* 购买限制区域 */
.purchase-limit-section { .purchase-limit-section {
margin-bottom: 20rpx; margin-bottom: 0;
display: flex;
} }
.purchase-limit { .purchase-limit {
...@@ -1280,6 +1298,7 @@ export default { ...@@ -1280,6 +1298,7 @@ export default {
background-color: #FCF2E2; background-color: #FCF2E2;
padding: 8rpx 16rpx; padding: 8rpx 16rpx;
border-radius: 20rpx; border-radius: 20rpx;
white-space: nowrap;
} }
/* 优惠券标题 */ /* 优惠券标题 */
......
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
<view class="product-image"> <view class="product-image">
<image v-if="goodsInfo.image" class="product-img" :src="goodsInfo.image" mode="aspectFill"> <image v-if="goodsInfo.image" class="product-img" :src="goodsInfo.image" mode="aspectFill">
</image> </image>
<text v-else class="image-placeholder">商品图片</text> <image v-else class="product-img" :src="$baseUrl + 'homepage/Q3Res/defaultProductImage.png'"
mode="aspectFill"></image>
</view> </view>
<view class="product-info"> <view class="product-info">
<text class="product-name">{{ goodsInfo.name }}</text> <text class="product-name">{{ goodsInfo.name }}</text>
...@@ -203,11 +204,11 @@ export default { ...@@ -203,11 +204,11 @@ export default {
// 设置商品信息 // 设置商品信息
this.goodsInfo = { this.goodsInfo = {
name: options.goodsName || '', name: options.goodsName ? decodeURIComponent(options.goodsName) : '',
spec: options.goodsSpec || options.spec || '', spec: options.goodsSpec || options.spec || '',
points: parseInt(options.points ? decodeURIComponent(options.points) : options.points) || 0, points: parseInt(options.points ? decodeURIComponent(options.points) : options.points) || 0,
quantity: parseInt(options.buy_num) || 1, quantity: parseInt(options.buy_num) || 1,
image: options.goodsImage || '', image: options.goodsImage ? decodeURIComponent(options.goodsImage) : '',
creditsTypeName: options.creditsTypeName ? decodeURIComponent(options.creditsTypeName) : '积分' creditsTypeName: options.creditsTypeName ? decodeURIComponent(options.creditsTypeName) : '积分'
}; };
...@@ -327,7 +328,7 @@ export default { ...@@ -327,7 +328,7 @@ export default {
} }
// 显示确认兑换弹窗 // 显示确认兑换弹窗
this.showConfirmModal(); this.showExchangeConfirmModal();
} catch (error) { } catch (error) {
console.error('提交订单失败:', error); console.error('提交订单失败:', error);
uni.showToast({ uni.showToast({
...@@ -338,7 +339,7 @@ export default { ...@@ -338,7 +339,7 @@ export default {
}, },
// 显示确认兑换弹窗 // 显示确认兑换弹窗
showConfirmModal() { showExchangeConfirmModal() {
this.showConfirmModal = true; this.showConfirmModal = true;
}, },
...@@ -824,7 +825,7 @@ export default { ...@@ -824,7 +825,7 @@ export default {
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1); box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: flex-end;
} }
.total-info { .total-info {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment