Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
2ec95e00
Commit
2ec95e00
authored
Oct 24, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
parent
c2c297e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
7 deletions
+89
-7
goods.js
api/goods.js
+2
-2
goodDetail.vue
v3/goodDetail/goodDetail.vue
+86
-4
My.vue
views/My.vue
+1
-1
No files found.
api/goods.js
View file @
2ec95e00
...
@@ -30,7 +30,7 @@ export const fetchGoodsDetail = (data) => api.get('/c/goods/detail', data);
...
@@ -30,7 +30,7 @@ export const fetchGoodsDetail = (data) => api.get('/c/goods/detail', data);
* @returns {Promise} API响应
* @returns {Promise} API响应
* @description 计算商品价格和优惠信息,在下单前调用
* @description 计算商品价格和优惠信息,在下单前调用
*/
*/
export
const
fetchGoodsPrice
=
(
data
)
=>
api
.
ge
t
(
'/c/goods/price'
,
data
);
export
const
fetchGoodsPrice
=
(
data
)
=>
api
.
pos
t
(
'/c/goods/price'
,
data
);
/**
/**
* 下单
* 下单
...
@@ -48,7 +48,7 @@ export const fetchGoodsPrice = (data) => api.get('/c/goods/price', data);
...
@@ -48,7 +48,7 @@ export const fetchGoodsPrice = (data) => api.get('/c/goods/price', data);
* @returns {Promise} API响应
* @returns {Promise} API响应
* @description 创建订单,在价格计算后调用
* @description 创建订单,在价格计算后调用
*/
*/
export
const
fetchTradeCredits
=
(
data
)
=>
api
.
ge
t
(
'/c/trade/credits'
,
data
);
export
const
fetchTradeCredits
=
(
data
)
=>
api
.
pos
t
(
'/c/trade/credits'
,
data
);
...
...
v3/goodDetail/goodDetail.vue
View file @
2ec95e00
...
@@ -121,6 +121,8 @@
...
@@ -121,6 +121,8 @@
<
script
>
<
script
>
import
{
fetchGoodsDetail
,
fetchGoodsPrice
,
fetchTradeCredits
}
from
'@/api/goods.js'
;
import
{
fetchGoodsDetail
,
fetchGoodsPrice
,
fetchTradeCredits
}
from
'@/api/goods.js'
;
import
{
useUserStore
}
from
'@/stores/user'
;
import
{
jump
,
JumpType
}
from
'../../utils'
;
export
default
{
export
default
{
data
()
{
data
()
{
...
@@ -175,23 +177,39 @@ export default {
...
@@ -175,23 +177,39 @@ export default {
// 订单相关
// 订单相关
orderParams
:
{},
// 订单参数
orderParams
:
{},
// 订单参数
priceData
:
null
,
// 价格计算结果
priceData
:
null
,
// 价格计算结果
orderResult
:
null
// 下单结果
orderResult
:
null
,
// 下单结果
// 用户状态
userStore
:
null
,
// 用户store实例
cfgStatus
:
{
isRegister
:
true
,
// 登录状态
showDetail
:
false
// 是否显示详情
}
}
}
},
},
computed
:
{
computed
:
{
// 是否可以兑换
// 是否可以兑换
canExchange
()
{
canExchange
()
{
// 首先检查登录状态
if
(
!
this
.
cfgStatus
.
isRegister
)
{
return
false
;
}
// 只有goodsState为1时才可兑换
// 只有goodsState为1时才可兑换
return
this
.
goodsData
.
goodsState
===
1
;
return
this
.
goodsData
.
goodsState
===
1
;
},
},
// 兑换状态
// 兑换状态
exchangeStatus
()
{
exchangeStatus
()
{
// 未登录状态
if
(
!
this
.
cfgStatus
.
isRegister
)
{
return
'notLoggedIn'
;
}
// 只有goodsState为1时才可兑换
// 只有goodsState为1时才可兑换
if
(
this
.
goodsData
.
goodsState
===
1
)
{
if
(
this
.
goodsData
.
goodsState
===
1
)
{
return
'canExchange'
;
return
'canExchange'
;
}
}
// 其他状态都不可兑换
// 其他状态都不可兑换
return
'disabled'
;
return
'disabled'
;
}
}
...
@@ -199,6 +217,9 @@ export default {
...
@@ -199,6 +217,9 @@ export default {
onLoad
(
options
)
{
onLoad
(
options
)
{
console
.
log
(
'页面参数:'
,
options
);
console
.
log
(
'页面参数:'
,
options
);
// 初始化用户状态
this
.
initUserStatus
();
// 构建API请求参数
// 构建API请求参数
const
apiParams
=
{
const
apiParams
=
{
gid
:
options
.
gid
||
options
.
id
||
options
.
goodsId
||
''
,
// 商品ID (必须)
gid
:
options
.
gid
||
options
.
id
||
options
.
goodsId
||
''
,
// 商品ID (必须)
...
@@ -228,12 +249,57 @@ export default {
...
@@ -228,12 +249,57 @@ export default {
},
1500
);
},
1500
);
}
}
},
},
onShow
()
{
// 每次页面显示时重新检查用户状态
this
.
checkUserStatus
();
},
methods
:
{
methods
:
{
// 返回上一页
// 返回上一页
navigateBack
()
{
navigateBack
()
{
uni
.
navigateBack
();
uni
.
navigateBack
();
},
},
// 初始化用户状态
async
initUserStatus
()
{
// 获取用户store实例
this
.
userStore
=
useUserStore
();
// 加载会员信息
await
this
.
userStore
.
loadMemberInfo
();
// 检查用户状态
this
.
checkUserStatus
();
},
// 检查用户状态
checkUserStatus
()
{
if
(
!
this
.
userStore
)
{
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
;
this
.
cfgStatus
.
showDetail
=
false
;
}
else
{
this
.
cfgStatus
.
isRegister
=
true
;
// 根据宝宝阶段决定是否显示详情
const
babyInfo
=
this
.
userStore
.
babyInfo
;
this
.
cfgStatus
.
showDetail
=
babyInfo
?.
babyStage
?
[
1
,
2
].
includes
(
babyInfo
.
babyStage
)
:
false
;
}
console
.
log
(
'用户状态检查:'
,
{
userInfo
,
memberId
,
cfgStatus
:
this
.
cfgStatus
});
},
// 获取商品详情
// 获取商品详情
async
fetchGoodsDetail
(
params
)
{
async
fetchGoodsDetail
(
params
)
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
...
@@ -399,12 +465,25 @@ export default {
...
@@ -399,12 +465,25 @@ export default {
// 获取按钮文本
// 获取按钮文本
getButtonText
()
{
getButtonText
()
{
// 未登录状态
if
(
!
this
.
cfgStatus
.
isRegister
)
{
return
'请先登录'
;
}
// 优先使用API返回的按钮文本
// 优先使用API返回的按钮文本
return
this
.
goodsData
.
buttonText
||
'立即兑换'
;
return
this
.
goodsData
.
buttonText
||
'立即兑换'
;
},
},
// 处理兑换
// 处理兑换
handleExchange
()
{
handleExchange
()
{
if
(
!
this
.
cfgStatus
.
isRegister
)
{
// 未登录,跳转到登录注册页面
jump
({
type
:
JumpType
.
INNER
,
url
:
"/pages/activity/register"
,
});
return
;
}
if
(
!
this
.
canExchange
)
{
if
(
!
this
.
canExchange
)
{
this
.
showStatusMessage
();
this
.
showStatusMessage
();
return
;
return
;
...
@@ -418,12 +497,15 @@ export default {
...
@@ -418,12 +497,15 @@ export default {
showStatusMessage
()
{
showStatusMessage
()
{
let
message
=
''
;
let
message
=
''
;
if
(
this
.
goodsData
.
goodsState
===
1
)
{
// 未登录状态
if
(
!
this
.
cfgStatus
.
isRegister
)
{
message
=
'请先登录后再进行兑换'
;
}
else
if
(
this
.
goodsData
.
goodsState
===
1
)
{
message
=
'可以兑换'
;
message
=
'可以兑换'
;
}
else
{
}
else
{
message
=
this
.
goodsData
.
buttonText
||
'无法兑换该商品'
;
message
=
this
.
goodsData
.
buttonText
||
'无法兑换该商品'
;
}
}
uni
.
showToast
({
uni
.
showToast
({
title
:
message
,
title
:
message
,
icon
:
'none'
,
icon
:
'none'
,
...
...
views/My.vue
View file @
2ec95e00
...
@@ -390,7 +390,7 @@ const navigateToWithLogin = (url) => {
...
@@ -390,7 +390,7 @@ const navigateToWithLogin = (url) => {
console
.
warn
(
'navigateToWithLogin'
,
url
);
console
.
warn
(
'navigateToWithLogin'
,
url
);
console
.
warn
(
'cfgStatus.value.isRegister'
,
cfgStatus
.
value
.
isRegister
);
console
.
warn
(
'cfgStatus.value.isRegister'
,
cfgStatus
.
value
.
isRegister
);
// 检查登录状态
// 检查登录状态
if
(
cfgStatus
.
value
.
isRegister
)
{
if
(
!
cfgStatus
.
value
.
isRegister
)
{
// 未登录,跳转到登录注册页面
// 未登录,跳转到登录注册页面
jump
({
jump
({
type
:
JumpType
.
INNER
,
type
:
JumpType
.
INNER
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment