Commit 13c5c1be authored by spc's avatar spc

fixed

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