Commit 13c5c1be authored by spc's avatar spc

fixed

parent 2ec95e00
...@@ -7,13 +7,20 @@ ...@@ -7,13 +7,20 @@
</view> </view>
<!-- 商品信息区域 --> <!-- 商品信息区域 -->
<view class="product-info" v-if="currentProduct" @tap="openSpecModal"> <view class="product-info" v-if="currentProduct">
<view class="product-name">{{ currentProduct.name }}</view> <view class="product-name">{{ currentProduct.name }}</view>
<view class="product-stock">库存 {{ currentProduct.stock || 0 }}</view> <view class="product-stock">库存 {{ currentProduct.stock || 0 }}</view>
<view class="product-price">{{ currentProduct.price || '0' }}积分</view> <view class="product-price">{{ currentProduct.price || '0' }}积分</view>
<view class="exchange-hint">点击选择规格</view> <view class="exchange-hint">点击选择规格</view>
</view> </view>
<!-- 兑换按钮 -->
<view class="exchange-section" v-if="currentProduct">
<view class="exchange-btn" @tap="handleExchange">
<text class="exchange-btn-text">{{ getExchangeButtonText() }}</text>
</view>
</view>
<!-- 固定底部按钮区域 --> <!-- 固定底部按钮区域 -->
<view class="fixed-bottom"> <view class="fixed-bottom">
<view class="button-group"> <view class="button-group">
...@@ -78,12 +85,18 @@ ...@@ -78,12 +85,18 @@
<script setup> <script setup>
import { ref, onMounted, computed, getCurrentInstance } from 'vue' import { ref, onMounted, computed, getCurrentInstance } from 'vue'
import { getProductById, getProductImagesById, getShareImageById, getShareTextById, shareBtn, rightsBtn } from '@/utils/constant.js' import { getProductById, getProductImagesById, getShareImageById, getShareTextById, shareBtn, rightsBtn } from '@/utils/constant.js'
import { useUserStore } from '@/stores/user'
import { jump, JumpType } from '@/utils'
// 响应式数据 // 响应式数据
const productId = ref('') const productId = ref('')
const currentProduct = ref(null) const currentProduct = ref(null)
const isLoading = ref(true) const isLoading = ref(true)
// 用户状态
const userStore = ref(null)
const isLoggedIn = ref(false)
// 规格选择相关数据 // 规格选择相关数据
const showSpecModal = ref(false) const showSpecModal = ref(false)
const selectedNetContent = ref('') const selectedNetContent = ref('')
...@@ -96,7 +109,10 @@ const productImages = computed(() => { ...@@ -96,7 +109,10 @@ const productImages = computed(() => {
}) })
// 页面加载时获取商品ID和产品信息 // 页面加载时获取商品ID和产品信息
onMounted(() => { onMounted(async () => {
// 初始化用户状态
await initUserStatus()
// 获取页面参数 // 获取页面参数
const pages = getCurrentPages() const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] const currentPage = pages[pages.length - 1]
...@@ -110,7 +126,6 @@ onMounted(() => { ...@@ -110,7 +126,6 @@ onMounted(() => {
if (productId.value) { if (productId.value) {
loadProductInfo() loadProductInfo()
} }
}) })
// 加载产品信息 // 加载产品信息
...@@ -122,7 +137,63 @@ const loadProductInfo = () => { ...@@ -122,7 +137,63 @@ const loadProductInfo = () => {
} else { } else {
console.warn('未找到对应的产品信息:', productId.value) console.warn('未找到对应的产品信息:', productId.value)
} }
}
// 初始化用户状态
const initUserStatus = async () => {
// 获取用户store实例
userStore.value = useUserStore()
// 加载会员信息
await userStore.value.loadMemberInfo()
// 检查用户状态
checkLoginStatus()
}
// 检查登录状态
const checkLoginStatus = () => {
if (!userStore.value) {
isLoggedIn.value = false
return
}
// 检查用户信息是否存在且有效
const userInfo = userStore.value.userInfo
const memberId = userInfo?.memberId
// 如果memberId为"not_login"或不存在,则未登录
if (!memberId || memberId === "not_login") {
isLoggedIn.value = false
} else {
isLoggedIn.value = true
}
console.log('登录状态检查:', {
userInfo,
memberId,
isLoggedIn: isLoggedIn.value
})
}
// 获取兑换按钮文本
const getExchangeButtonText = () => {
return isLoggedIn.value ? '马上兑换' : '马上兑换'
}
// 处理兑换按钮点击
const handleExchange = () => {
if (!isLoggedIn.value) {
// 未登录,跳转到登录注册页面
jump({
type: JumpType.INNER,
url: "/pages/activity/register",
})
return
}
// 已登录,显示规格选择弹窗
openSpecModal()
} }
// 图片加载成功 // 图片加载成功
...@@ -330,6 +401,28 @@ export default { ...@@ -330,6 +401,28 @@ export default {
text-align: center; text-align: center;
} }
/* 兑换按钮样式 */
.exchange-section {
padding: 0 30rpx;
margin-bottom: 20rpx;
}
.exchange-btn {
width: 100%;
height: 88rpx;
background-color: #D3A458;
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
}
.exchange-btn-text {
font-size: 32rpx;
color: #ffffff;
font-weight: 500;
}
/* 规格选择弹窗样式 */ /* 规格选择弹窗样式 */
.spec-modal-overlay { .spec-modal-overlay {
position: fixed; position: fixed;
......
<template> <template>
<view class="address-list-container"> <view class="address-list-container">
<view class="address-list"> <view class="address-list">
<view v-if="addressList.length > 0"> <view v-if="addressList.length > 0">
<block v-for="(address, index) in addressList" :key="index"> <block v-for="(address, index) in addressList" :key="index">
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
</view> </view>
<text class="address-detail">{{ address.address }}</text> <text class="address-detail">{{ address.address }}</text>
<view class="address-footer"> <view class="address-footer">
<text class="default-tag" :class="{ 'active': address.isDefault, 'inactive': !address.isDefault }">默认</text> <text class="default-tag"
:class="{ 'active': address.isDefault, 'inactive': !address.isDefault }">默认</text>
<view class="action-buttons"> <view class="action-buttons">
<view class="edit-btn" @tap="editAddress(address.id)">编辑</view> <view class="edit-btn" @tap="editAddress(address.id)">编辑</view>
<view class="delete-btn" @tap="confirmDelete(index)">删除</view> <view class="delete-btn" @tap="confirmDelete(index)">删除</view>
...@@ -69,9 +70,9 @@ export default { ...@@ -69,9 +70,9 @@ export default {
try { try {
const response = await getAddressList(); const response = await getAddressList();
console.log('地址列表接口返回:', response); console.log('地址列表接口返回:', response);
if (response.ok && response.success && response.data) { if (response.ok && response.success && response.data) {
// 处理API返回的地址数据 // 处理API返回的地址数据,并倒序排列
this.addressList = response.data.map(address => ({ this.addressList = response.data.map(address => ({
id: address.id, id: address.id,
name: address.name, name: address.name,
...@@ -87,9 +88,9 @@ export default { ...@@ -87,9 +88,9 @@ export default {
isDefault: address.current, isDefault: address.current,
// 构建完整地址字符串 // 构建完整地址字符串
address: this.buildFullAddress(address) address: this.buildFullAddress(address)
})); })).reverse(); // 倒序排列,最新的地址在前面
console.log('处理后的地址列表:', this.addressList); console.log('处理后的地址列表(倒序):', this.addressList);
} else { } else {
uni.showToast({ uni.showToast({
title: response.msg || '获取地址列表失败', title: response.msg || '获取地址列表失败',
...@@ -128,6 +129,16 @@ export default { ...@@ -128,6 +129,16 @@ export default {
// 添加地址 // 添加地址
addAddress() { addAddress() {
// 检查地址数量限制
if (this.addressList.length >= 20) {
uni.showToast({
title: '地址添加已经达到上限啦~',
icon: 'none',
duration: 2000
});
return;
}
uni.navigateTo({ uni.navigateTo({
url: '/v3/addressList/addressEdit' url: '/v3/addressList/addressEdit'
}); });
...@@ -152,7 +163,7 @@ export default { ...@@ -152,7 +163,7 @@ export default {
try { try {
const response = await deleteAddress({ id: address.id }); const response = await deleteAddress({ id: address.id });
console.log('删除地址接口返回:', response); console.log('删除地址接口返回:', response);
if (response.ok && response.success) { if (response.ok && response.success) {
this.addressList.splice(this.currentDeleteIndex, 1); this.addressList.splice(this.currentDeleteIndex, 1);
uni.showToast({ uni.showToast({
......
...@@ -193,7 +193,7 @@ export default { ...@@ -193,7 +193,7 @@ export default {
if (!this.cfgStatus.isRegister) { if (!this.cfgStatus.isRegister) {
return false; return false;
} }
// 只有goodsState为1时才可兑换 // 只有goodsState为1时才可兑换
return this.goodsData.goodsState === 1; return this.goodsData.goodsState === 1;
}, },
...@@ -204,7 +204,7 @@ export default { ...@@ -204,7 +204,7 @@ export default {
if (!this.cfgStatus.isRegister) { if (!this.cfgStatus.isRegister) {
return 'notLoggedIn'; return 'notLoggedIn';
} }
// 只有goodsState为1时才可兑换 // 只有goodsState为1时才可兑换
if (this.goodsData.goodsState === 1) { if (this.goodsData.goodsState === 1) {
return 'canExchange'; return 'canExchange';
...@@ -263,10 +263,10 @@ export default { ...@@ -263,10 +263,10 @@ export default {
async initUserStatus() { async initUserStatus() {
// 获取用户store实例 // 获取用户store实例
this.userStore = useUserStore(); this.userStore = useUserStore();
// 加载会员信息 // 加载会员信息
await this.userStore.loadMemberInfo(); await this.userStore.loadMemberInfo();
// 检查用户状态 // 检查用户状态
this.checkUserStatus(); this.checkUserStatus();
}, },
...@@ -277,11 +277,11 @@ export default { ...@@ -277,11 +277,11 @@ export default {
this.cfgStatus.isRegister = false; this.cfgStatus.isRegister = false;
return; return;
} }
// 检查用户信息是否存在且有效 // 检查用户信息是否存在且有效
const userInfo = this.userStore.userInfo; const userInfo = this.userStore.userInfo;
const memberId = userInfo?.memberId; const memberId = userInfo?.memberId;
// 如果memberId为"not_login"或不存在,则未登录 // 如果memberId为"not_login"或不存在,则未登录
if (!memberId || memberId === "not_login") { if (!memberId || memberId === "not_login") {
this.cfgStatus.isRegister = false; this.cfgStatus.isRegister = false;
...@@ -292,7 +292,7 @@ export default { ...@@ -292,7 +292,7 @@ export default {
const babyInfo = this.userStore.babyInfo; const babyInfo = this.userStore.babyInfo;
this.cfgStatus.showDetail = babyInfo?.babyStage ? [1, 2].includes(babyInfo.babyStage) : false; this.cfgStatus.showDetail = babyInfo?.babyStage ? [1, 2].includes(babyInfo.babyStage) : false;
} }
console.log('用户状态检查:', { console.log('用户状态检查:', {
userInfo, userInfo,
memberId, memberId,
...@@ -465,11 +465,6 @@ export default { ...@@ -465,11 +465,6 @@ export default {
// 获取按钮文本 // 获取按钮文本
getButtonText() { getButtonText() {
// 未登录状态
if (!this.cfgStatus.isRegister) {
return '请先登录';
}
// 优先使用API返回的按钮文本 // 优先使用API返回的按钮文本
return this.goodsData.buttonText || '立即兑换'; return this.goodsData.buttonText || '立即兑换';
}, },
...@@ -496,7 +491,7 @@ export default { ...@@ -496,7 +491,7 @@ export default {
// 显示状态提示信息 // 显示状态提示信息
showStatusMessage() { showStatusMessage() {
let message = ''; let message = '';
// 未登录状态 // 未登录状态
if (!this.cfgStatus.isRegister) { if (!this.cfgStatus.isRegister) {
message = '请先登录后再进行兑换'; message = '请先登录后再进行兑换';
...@@ -505,7 +500,7 @@ export default { ...@@ -505,7 +500,7 @@ export default {
} else { } else {
message = this.goodsData.buttonText || '无法兑换该商品'; message = this.goodsData.buttonText || '无法兑换该商品';
} }
uni.showToast({ uni.showToast({
title: message, title: message,
icon: 'none', icon: 'none',
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<view class="product-details"> <view class="product-details">
<view class="product-name-row"> <view class="product-name-row">
<text class="product-name">{{ order.productName }}</text> <text class="product-name">{{ order.productName }}</text>
<text class="product-points">{{ order.points }}积分</text> <text class="product-points">{{ order.points }}{{ order.creditsTypeName }}</text>
</view> </view>
<text class="product-description">{{ order.description }}</text> <text class="product-description">{{ order.description }}</text>
...@@ -96,6 +96,7 @@ export default { ...@@ -96,6 +96,7 @@ export default {
productName: '商品名称—实物', productName: '商品名称—实物',
description: '商品描述文案占位', description: '商品描述文案占位',
points: 200, points: 200,
creditsTypeName: '积分',
exchangeTime: '2025.09.10 23:23:23', exchangeTime: '2025.09.10 23:23:23',
productImage: '' productImage: ''
}, },
...@@ -106,6 +107,7 @@ export default { ...@@ -106,6 +107,7 @@ export default {
productName: '商品名称—实物', productName: '商品名称—实物',
description: '商品描述文案占位', description: '商品描述文案占位',
points: 300, points: 300,
creditsTypeName: '积分',
exchangeTime: '2025.09.10 23:23:23', exchangeTime: '2025.09.10 23:23:23',
countdown: '23:59:59', countdown: '23:59:59',
productImage: '' productImage: ''
...@@ -117,6 +119,7 @@ export default { ...@@ -117,6 +119,7 @@ export default {
productName: '商品名称—实物', productName: '商品名称—实物',
description: '商品描述文案占位', description: '商品描述文案占位',
points: 150, points: 150,
creditsTypeName: '积分',
exchangeTime: '2025.09.10 23:23:23', exchangeTime: '2025.09.10 23:23:23',
productImage: '' productImage: ''
}, },
...@@ -127,6 +130,7 @@ export default { ...@@ -127,6 +130,7 @@ export default {
productName: '商品名称—卡券', productName: '商品名称—卡券',
description: '商品描述文案占位', description: '商品描述文案占位',
points: 100, points: 100,
creditsTypeName: '积分',
exchangeTime: '2025.09.10 23:23:23', exchangeTime: '2025.09.10 23:23:23',
validUntil: '2025.09.10 23:23:23', validUntil: '2025.09.10 23:23:23',
productImage: '' productImage: ''
...@@ -207,6 +211,7 @@ export default { ...@@ -207,6 +211,7 @@ export default {
productName: item.bizDesc || '', productName: item.bizDesc || '',
description: item.bizDesc || '', description: item.bizDesc || '',
points: item.credits || 0, points: item.credits || 0,
creditsTypeName: item.creditsTypeName || '积分',
exchangeTime: this.formatTime(item.createTime), exchangeTime: this.formatTime(item.createTime),
productImage: item.bizIcon || '', productImage: item.bizIcon || '',
countdown: this.calculateCountdown(item.expireTime), countdown: this.calculateCountdown(item.expireTime),
...@@ -220,9 +225,10 @@ export default { ...@@ -220,9 +225,10 @@ export default {
'1': 'pending_payment', // 待付款 '1': 'pending_payment', // 待付款
'2': 'pending_shipment', // 待发货 '2': 'pending_shipment', // 待发货
'3': 'completed', // 已完成 '3': 'completed', // 已完成
'4': 'cancelled' // 已取消 '4': 'cancelled', // 已取消
'99': 'completed' // 特殊状态,按已完成处理
}; };
return statusMap[flowState] || 'completed'; return statusMap[flowState.toString()] || 'completed';
}, },
// 映射业务类型到商品类型 // 映射业务类型到商品类型
...@@ -359,6 +365,7 @@ export default { ...@@ -359,6 +365,7 @@ export default {
.order-card { .order-card {
background-color: #ffffff; background-color: #ffffff;
border-radius: 16rpx; border-radius: 16rpx;
border: 1rpx solid #EFEFEF;
padding: 30rpx; padding: 30rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05); box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
} }
...@@ -369,25 +376,28 @@ export default { ...@@ -369,25 +376,28 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-bottom: 20rpx; margin-bottom: 20rpx;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #EFEFEF;
} }
.order-number { .order-number {
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #b9b9b9;
font-weight: 500; font-weight: 500;
} }
.order-status { .order-status {
font-size: 28rpx; font-size: 28rpx;
color: #b9b9b9;
font-weight: 500; font-weight: 500;
} }
.status-pending_shipment { .status-pending_shipment {
color: #333333; color: #b9b9b9;
} }
.status-pending_payment { .status-pending_payment {
color: #FF6B35; color: #D3A458;
} }
.status-completed { .status-completed {
...@@ -440,7 +450,7 @@ export default { ...@@ -440,7 +450,7 @@ export default {
.product-points { .product-points {
font-size: 28rpx; font-size: 28rpx;
color: #FF6B35; color: #D3A458;
font-weight: 500; font-weight: 500;
} }
...@@ -476,24 +486,24 @@ export default { ...@@ -476,24 +486,24 @@ export default {
.countdown-text { .countdown-text {
font-size: 26rpx; font-size: 26rpx;
color: #FF6B35; color: #D3A458;
font-weight: 500; font-weight: 500;
} }
.pay-btn, .pay-btn,
.action-btn { .action-btn {
background-color: #FFE9C5; background-color: #D3A458;
border-radius: 8rpx; border-radius: 50rpx;
padding: 16rpx 32rpx; width: 132rpx;
min-width: 120rpx; height: 52rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.btn-text { .btn-text {
font-size: 28rpx; font-size: 24rpx;
color: #333333; color: #ffffff;
font-weight: 500; font-weight: 500;
} }
......
...@@ -57,8 +57,9 @@ export default { ...@@ -57,8 +57,9 @@ export default {
// 支付结果数据 - 可根据实际需要修改 // 支付结果数据 - 可根据实际需要修改
resultData: { resultData: {
isSuccess: true, // true: 成功, false: 失败 isSuccess: true, // true: 成功, false: 失败
pointsValue: '12000', pointsValue: '',
failureReason: '失败原因:XXXXXXXX' failureReason: '',
orderId: '' // 订单ID,用于跳转订单详情
} }
} }
}, },
...@@ -98,15 +99,39 @@ export default { ...@@ -98,15 +99,39 @@ export default {
return this.isSuccess ? '查看订单' : '返回首页'; return this.isSuccess ? '查看订单' : '返回首页';
} }
}, },
onLoad(options) {
// 处理页面参数
if (options.isSuccess !== undefined) {
this.resultData.isSuccess = options.isSuccess === 'true';
}
if (options.pointsValue) {
this.resultData.pointsValue = options.pointsValue;
}
if (options.failureReason) {
this.resultData.failureReason = decodeURIComponent(options.failureReason);
}
if (options.orderId) {
this.resultData.orderId = options.orderId;
}
console.log('支付结果页面参数:', options);
console.log('支付结果数据:', this.resultData);
},
methods: { methods: {
// 处理操作按钮点击 // 处理操作按钮点击
handleAction() { handleAction() {
if (this.isSuccess) { if (this.isSuccess) {
// 查看订单 // 查看订单 - 跳转到订单详情页面
uni.showToast({ if (this.resultData.orderId) {
title: '查看订单', uni.navigateTo({
icon: 'none' url: `/v3/orderDetail/orderDetail?orderId=${this.resultData.orderId}`
}); });
} else {
// 如果没有订单ID,跳转到订单列表页面
uni.navigateTo({
url: '/v3/orderList/orderList'
});
}
} else { } else {
// 返回首页 // 返回首页
uni.reLaunch({ uni.reLaunch({
...@@ -116,10 +141,11 @@ export default { ...@@ -116,10 +141,11 @@ export default {
}, },
// 设置支付结果 - 供外部调用 // 设置支付结果 - 供外部调用
setPaymentResult(isSuccess, pointsValue = '', failureReason = '') { setPaymentResult(isSuccess, pointsValue = '', failureReason = '', orderId = '') {
this.resultData.isSuccess = isSuccess; this.resultData.isSuccess = isSuccess;
this.resultData.pointsValue = pointsValue; this.resultData.pointsValue = pointsValue;
this.resultData.failureReason = failureReason; this.resultData.failureReason = failureReason;
this.resultData.orderId = orderId;
} }
} }
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<image class="banner_cover" :src="$baseUrl + 'my/cover_white.png'" mode="aspectFill" /> <image class="banner_cover" :src="$baseUrl + 'my/cover_white.png'" mode="aspectFill" />
</view> </view>
<view v-if="!cfgStatus.isRegister" class="phone-button" @click="clickRegisterShield" /> <view v-if="!cfgStatus.isRegister" class="bg-container" @click="clickRegisterShield" />
<!-- 用户信息区域 --> <!-- 用户信息区域 -->
<view class="user-info" :style="{ 'min-height': cfgStatus.showDetail ? '343rpx' : '180rpx' }"> <view class="user-info" :style="{ 'min-height': cfgStatus.showDetail ? '343rpx' : '180rpx' }">
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
<text class="menu-title">我的优惠券</text> <text class="menu-title">我的优惠券</text>
<text class="menu-arrow"></text> <text class="menu-arrow"></text>
</view> </view>
<view class="menu-item" @click="navigateTo('/v3/more/index')" :data-log="{ <view class="menu-item" @click="navigateToWithLogin('/v3/more/index')" :data-log="{
xcxClick: '我的页面点击', xcxClick: '我的页面点击',
pageName: '我的页面', pageName: '我的页面',
buttonName: '更多' buttonName: '更多'
......
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