Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-professional-exam
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Culm
pica-professional-exam
提交
bf9f22fd
提交
bf9f22fd
编写于
10月 27, 2020
作者:
guangjun.yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优惠券选中逻辑
还有价格计算及商品详情接口没有使用新的接口
上级
4f95358e
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
381 行增加
和
255 行删除
+381
-255
goods-detail.vue
src/views/goods-detail.vue
+381
-255
未找到文件。
src/views/goods-detail.vue
浏览文件 @
bf9f22fd
...
...
@@ -3,22 +3,20 @@
<!-- 轮播 -->
<div
class=
"swiper-box"
>
<van-swipe
:show-indicators=
"false"
@
change=
"onSwiperChange"
>
<van-swipe-item
v-for=
"(item, index) in swiperList"
:key=
"index"
>
<img
class=
"img"
:src=
"item.goodsImgUrl"
alt=
""
/>
<van-swipe-item
v-for=
"(item, index) in swiperList"
:key=
"index"
>
<img
class=
"img"
:src=
"item.goodsImgUrl"
alt
/>
</van-swipe-item>
</van-swipe>
<div
class=
"indicator"
>
{{
swiperCurtIndex
+
1
}}
/
{{
swiperList
.
length
}}
</div>
<div
class=
"indicator"
>
{{
swiperCurtIndex
+
1
}}
/
{{
swiperList
.
length
}}
</div>
</div>
<!-- 商品信息 -->
<div
class=
"info-box border-line"
>
<p
class=
"title"
>
{{
goods
.
goodsName
}}
</p>
<div
class=
"price"
>
<div
class=
"money"
>
<span
class=
"yuan"
>
¥
{{
goods
.
salePrice
.
yuan
}}
</span><span
class=
"fen"
>
.
{{
goods
.
salePrice
.
fen
}}
</span><span
v-if=
"goods.hasDiscount"
class=
"del"
>
原价: ¥
{{
goods
.
costPriceText
}}
</span>
<span
class=
"yuan"
>
¥
{{
goods
.
salePrice
.
yuan
}}
</span>
<span
class=
"fen"
>
.
{{
goods
.
salePrice
.
fen
}}
</span>
<span
v-if=
"goods.hasDiscount"
class=
"del"
>
原价: ¥
{{
goods
.
costPriceText
}}
</span>
</div>
<div
class=
"bought"
>
{{
goods
.
saledNum
}}
购买
</div>
</div>
...
...
@@ -33,12 +31,10 @@
<div
class=
"plus"
@
click=
"onPlus"
></div>
</div>
</div>
<div
class=
"flex buy-way"
>
<div
class=
"name "
>
优惠券
</div>
<div
@
click=
"showCouponPopup"
class=
"coupon-select coupon-pc"
>
-¥
{{
yuan
(
currentCoupon
.
discountAmount
)
}}
</div>
<div
class=
"name"
>
优惠券
</div>
<div
@
click=
"showCouponPopup"
class=
"coupon-select coupon-pc"
>
{{
getCPText
()
}}
</div>
</div>
<div
class=
"flex buy-way"
>
...
...
@@ -56,9 +52,8 @@
:class=
"
{'tab-active': curtTabIdx === index}"
v-for="(tab, index) in tabs"
:key="index"
@click="tabToggle(index)">
{{
tab
.
name
}}
</div>
@click="tabToggle(index)"
>
{{
tab
.
name
}}
</div>
<div
class=
"tab-line"
:style=
"
{left: `${tabLeft}px`}">
</div>
</div>
<!-- 详情 -->
...
...
@@ -66,46 +61,58 @@
<!-- 底部购买 -->
<div
class=
"btn-box"
>
<div
class=
"money"
>
<p>
合计:
<span
class=
"yuan"
>
¥
{{
totalPrice
.
yuan
}}
</span><span
class=
"fen"
>
.
{{
totalPrice
.
fen
}}
</span><span
v-if=
"goods.hasDiscount"
class=
"del"
>
原价: ¥
{{
totalPrice
.
costPriceText
}}
</span></p>
<p>
合计:
<span
class=
"yuan"
>
¥
{{
totalPrice
.
yuan
}}
</span>
<span
class=
"fen"
>
.
{{
totalPrice
.
fen
}}
</span>
<span
v-if=
"goods.hasDiscount"
class=
"del"
>
原价: ¥
{{
totalPrice
.
costPriceText
}}
</span>
</p>
<!--
<p
v-if=
"totalPrice.savePrice"
class=
"coupon"
>
已使用优惠券,为您再优惠
{{
totalPrice
.
savePrice
}}
元
</p>
-->
</div>
<div
class=
"btn"
:class=
"[goods.isSale === 2 ? 'cannot-buy' : 'can-but']"
@
click=
"createOrder"
>
{{
goods
.
isSale
===
2
?
'商品已下架'
:
'确认支付'
}}
</div>
@
click=
"createOrder"
>
{{
goods
.
isSale
===
2
?
'商品已下架'
:
'确认支付'
}}
</div>
</div>
<Loading
v-show=
"showLoading"
/>
<!-- 优惠券弹框 -->
<CouponSelectList
v-if=
"isShowCoupon"
<CouponSelectList
v-if=
"isShowCoupon"
:showSelectCoupon=
"isShowCoupon"
@
cancle=
"closeCouponPopup"
@
confirm=
"setCurrentPopup"
>
</CouponSelectList>
@
confirm=
"setCurrentPopup"
>
</CouponSelectList>
<CourseDialog
content=
"微信授权"
subContent=
'
<p
style=
"font-size: 16px; font-weight: bold; text-align: center;"
>
云鹊医申请以下权限:
</p><p
style=
"font-size: 14px; color: #999; text-align: center; padding-bottom: 10px;"
>
获得你的公开信息(头像,昵称等)
</p>
'
subContent=
"
<p
style=
'font-size: 16px; font-weight: bold; text-align: center;'
>
云鹊医申请以下权限:
</p><p
style=
'font-size: 14px; color: #999; text-align: center; padding-bottom: 10px;'
>
获得你的公开信息(头像,昵称等)
</p>
"
cancleBtnText="取消"
confirmBtnText="允许"
needSubContent
:isShowDialog="isShowDialog"
@handlerAction="handlerAction"
>
</CourseDialog>
</div>
</
template
>
<
script
>
import
{
Swipe
,
SwipeItem
}
from
'vant'
;
import
{
Swipe
,
SwipeItem
}
from
"vant"
;
import
Loading
from
"@/components/common/common-loading"
;
import
CourseDialog
from
"@/components/course/course-dialog"
;
import
CouponSelectList
from
"@/components/coupon/coupon-select-list"
;
import
{
wxConfig
,
chooseWXPay
}
from
'@/utils/wxShare'
;
import
{
getAPPID
,
getTradeType
,
getWebPageUrl
,
isWeiXin
,
wxOauth
,
debounce
,
getHactiveUrl
}
from
'@/utils'
;
import
{
wxConfig
,
chooseWXPay
}
from
"@/utils/wxShare"
;
import
{
getAPPID
,
getTradeType
,
getWebPageUrl
,
isWeiXin
,
wxOauth
,
debounce
,
getHactiveUrl
}
from
"@/utils"
;
import
{
mapGetters
,
mapActions
}
from
"vuex"
;
import
{
convertToYuan
}
from
"@/utils"
;
const
isWechat
=
isWeiXin
();
...
...
@@ -124,7 +131,7 @@ export default {
token
:
""
,
isWeb
:
window
.
__isWeb
,
goods
:
{
salePrice
:
{}
,
salePrice
:
{}
},
// 商品信息
totalPrice
:
{},
// 底部价格
swiperList
:
[],
// 轮播图
...
...
@@ -136,11 +143,17 @@ export default {
showLoading
:
false
,
isShowDialog
:
false
,
isShowCoupon
:
false
,
//是否展示激活弹框,
courseUrl
:
""
,
}
courseUrl
:
""
}
;
},
computed
:
{
...
mapGetters
([
"userInfo"
,
"webUserInfo"
,
"currentCoupon"
,
"goodsInfo4Coupon"
,
"selectCouponList"
]),
...
mapGetters
([
"userInfo"
,
"webUserInfo"
,
"currentCoupon"
,
"goodsInfo4Coupon"
,
"selectCouponList"
]),
wxInfo
()
{
return
this
.
$store
.
state
.
user
.
wxInfo
;
},
...
...
@@ -150,14 +163,14 @@ export default {
tabLeft
()
{
const
num
=
this
.
curtTabIdx
+
0.25
+
15
/
115
;
return
this
.
tabW
*
num
;
}
,
}
},
watch
:
{
webUserInfo
:
{
handler
(
userInfo
)
{
console
.
log
(
'userInfo'
,
userInfo
);
if
(
userInfo
.
id
)
{
console
.
log
(
"userInfo"
,
userInfo
);
if
(
userInfo
.
id
)
{
this
.
getGoodsInfo
();
}
},
...
...
@@ -169,52 +182,56 @@ export default {
handler
(
goodsInfo
)
{
this
.
setSelectCouponList
(
this
.
selectCouponList
);
},
deep
:
true
deep
:
true
}
},
created
()
{
let
_this
=
this
;
console
.
log
(
'in goods detail new'
,
111111111
);
console
.
log
(
"in goods detail new"
,
111111111
);
let
href
=
location
.
href
;
this
.
shareUrl
=
href
;
this
.
projectId
=
this
.
$route
.
query
.
projectId
;
this
.
goodsId
=
this
.
$route
.
query
.
goodsId
||
74
;
this
.
courseUrl
=
this
.
$route
.
query
.
courseUrl
||
''
;
//
this
.
courseUrl
=
this
.
$route
.
query
.
courseUrl
||
""
;
//
if
(
href
.
indexOf
(
"singlemessage"
)
>=
0
||
href
.
indexOf
(
"wx_code"
)
>=
0
)
{
if
(
this
.
projectId
)
{
this
.
shareUrl
=
getWebPageUrl
(
`profexam/#/goods-detail?goodsId=
${
this
.
goodsId
}
&projectId=
${
this
.
projectId
}
`
);
if
(
this
.
projectId
)
{
this
.
shareUrl
=
getWebPageUrl
(
`profexam/#/goods-detail?goodsId=
${
this
.
goodsId
}
&projectId=
${
this
.
projectId
}
`
);
}
else
{
this
.
shareUrl
=
getWebPageUrl
(
`profexam/#/goods-detail?goodsId=
${
this
.
goodsId
}
`
);
this
.
shareUrl
=
getWebPageUrl
(
`profexam/#/goods-detail?goodsId=
${
this
.
goodsId
}
`
);
}
location
.
replace
(
this
.
shareUrl
);
}
localStorage
.
setItem
(
'returnUrl'
,
this
.
shareUrl
);
localStorage
.
setItem
(
"returnUrl"
,
this
.
shareUrl
);
window
.
__getUserInfo4GD
=
function
(
param
)
{
// appVersion 安卓 3.2.2 iOS
console
.
log
(
"__getUserInfo4GD"
,
param
);
_this
.
token
=
param
.
userToken
;
_this
.
setUserInfo
(
param
);
_this
.
get
CanUseCoupons
();
_this
.
get
GoodsInfo
();
};
window
.
__refresh
=
function
()
{
_this
.
getUserInfo
();
};
window
.
__WXpay
=
function
(
params
){
_this
.
paycallback
(
params
)
};
window
.
__WXpay
=
function
(
params
)
{
_this
.
paycallback
(
params
)
;
};
},
mounted
()
{
this
.
getTabW
();
console
.
log
(
'this.isWeb ... isWechat - 1'
,
this
.
isWeb
,
isWechat
);
if
(
this
.
isWeb
)
{
console
.
log
(
"this.isWeb ... isWechat - 1"
,
this
.
isWeb
,
isWechat
);
if
(
this
.
isWeb
)
{
const
{
token
,
info
}
=
this
.
$store
.
state
.
user
;
if
(
token
&&
!
info
.
id
)
{
this
.
$store
.
dispatch
(
'getUserInfo'
);
this
.
$store
.
dispatch
(
"getUserInfo"
);
return
;
}
// 从登陆页面过来时
...
...
@@ -227,42 +244,84 @@ export default {
this
.
curtGoodsNum
=
this
.
goodsNum
;
this
.
countTotalPrice
=
debounce
(
this
.
getTotalPrice
,
300
);
// 记录参数,授权登录返回时重新赋值,在main.js
sessionStorage
.
setItem
(
'goodsDetailParams'
,
JSON
.
stringify
(
this
.
$route
.
query
))
sessionStorage
.
setItem
(
"goodsDetailParams"
,
JSON
.
stringify
(
this
.
$route
.
query
)
);
},
methods
:
{
...
mapActions
([
"setUserInfo"
,
"setCurrentCoupon"
,
"setGoodsInfo4Coupon"
,
"setSelectCouponList"
]),
...
mapActions
([
"setUserInfo"
,
"setCurrentCoupon"
,
"setGoodsInfo4Coupon"
,
"setSelectCouponList"
]),
getCPText
()
{
// yuan(currentCoupon.discountAmount) -¥{{}}
// 如果没有选择优惠券
let
text
=
""
;
if
(
this
.
currentCoupon
.
couponId
)
{
text
=
"-¥"
+
this
.
yuan
(
this
.
currentCoupon
.
discountAmount
);
}
else
{
if
(
this
.
goodsInfo4Coupon
.
count
)
{
text
=
this
.
goodsInfo4Coupon
.
count
+
"张优惠券"
;
}
else
{
text
=
"无优惠券"
;
}
}
return
text
;
},
// 查询我的可用优惠券
getCanUseCoupons
()
{
this
.
GET
(
`trade/coupon/app/goodsCoupons`
,
{}).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
this
.
handlerCouponList
(
res
.
data
||
[]);
getCanUseCoupons
(
params
)
{
// TODO params有问题
const
{
goodsType
,
cardType
}
=
params
;
this
.
GET
(
`trade/coupon/app/goodsCoupons`
,
{
goodsType
,
cardType
}).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
this
.
handlerCouponList
(
res
.
data
||
[],
params
.
price
);
params
.
count
=
(
res
.
data
||
[]).
length
;
this
.
setGoodsInfo4Coupon
(
params
);
}
}
})
);
},
// 处理数据
handlerCouponList
(
couponList
)
{
if
(
!
couponList
.
length
)
return
[]
let
newList
=
[],
obj
=
{};
this
.
setCurrentCoupon
(
JSON
.
parse
(
JSON
.
stringify
(
couponList
[
0
])));
couponList
.
forEach
(
item
=>
{
handlerCouponList
(
couponList
,
goodsPrice
)
{
if
(
!
couponList
.
length
)
return
[];
let
newList
=
[],
obj
=
{},
firstCanCoupon
=
null
;
couponList
.
forEach
(
item
=>
{
// TODO 要根据商品价格及券适用类型来计算
item
.
disabled
=
this
.
isCanSelect
();
item
.
disabled
=
this
.
isCanSelect
(
item
,
goodsPrice
);
// item.disabled = !(item.couponStatus == 0 || item.couponStatus == 1);
// 是否已经选择
item
.
isChecked
=
false
;
console
.
log
(
'firstCanCoupon, item.disabled'
,
firstCanCoupon
,
item
.
disabled
);
if
(
!
firstCanCoupon
&&
!
item
.
disabled
)
{
console
.
log
(
'!firstCanCoupon'
);
item
.
isChecked
=
true
;
firstCanCoupon
=
item
;
}
newList
.
push
(
item
);
});
couponList
[
0
].
isChecked
=
true
;
this
.
setCurrentCoupon
(
firstCanCoupon
||
{})
;
this
.
setSelectCouponList
(
newList
);
return
newList
;
},
// 判断是否可用
isCanSelect
(){
return
false
;
isCanSelect
(
coupon
,
goodsPrice
)
{
console
.
log
(
"isCanSelect"
,
coupon
.
requiredTotalFee
,
goodsPrice
,
goodsPrice
>=
coupon
.
requiredTotalFee
);
return
goodsPrice
>=
coupon
.
requiredTotalFee
;
},
//获取用户信息
...
...
@@ -275,13 +334,19 @@ export default {
// 微信支付回调
paycallback
(
params
)
{
// 0成功 -1错误 -2 用户取消 -3 没有安装微信
let
url
=
getHactiveUrl
()
+
`/message_push/#/order?orderBack=1&id=
${
this
.
orderId
}
&courseUrl=
${
this
.
courseUrl
}
`
;
if
(
params
.
result
==
-
3
)
{
this
.
$toast
(
'您未安装微信,暂不能支付'
);
}
else
if
(
params
.
result
==
-
2
)
{
this
.
POST
(
`/trade/center/order/pay_cancelled`
,
{
orderId
:
this
.
orderId
}).
then
(
res
=>
{
this
.
jumpToOrder
(
url
);
}).
catch
((
err
)
=>
{})
let
url
=
getHactiveUrl
()
+
`/message_push/#/order?orderBack=1&id=
${
this
.
orderId
}
&courseUrl=
${
this
.
courseUrl
}
`
;
if
(
params
.
result
==
-
3
)
{
this
.
$toast
(
"您未安装微信,暂不能支付"
);
}
else
if
(
params
.
result
==
-
2
)
{
this
.
POST
(
`/trade/center/order/pay_cancelled`
,
{
orderId
:
this
.
orderId
})
.
then
(
res
=>
{
this
.
jumpToOrder
(
url
);
})
.
catch
(
err
=>
{});
}
else
{
this
.
jumpToOrder
(
url
);
}
...
...
@@ -295,27 +360,32 @@ export default {
value
:
pageUrl
,
type
:
4
,
seqNo
:
1
}
]
}
]
;
rocNative
.
dispatchEventByModuleCode
({
modeCode
:
"M300"
,
jsonString
:
paramList
});
},
// 关闭优惠券弹框
closeCouponPopup
()
{
this
.
isShowCoupon
=
false
;
},
// 显示优惠券弹框
showCouponPopup
()
{
this
.
isShowCoupon
=
true
;
},
// 设置当前选中的优惠券
setCurrentPopup
(
currentCoupon
)
{
console
.
log
(
'setCurrentPopup'
,
currentCoupon
);
console
.
log
(
"setCurrentPopup"
,
currentCoupon
);
this
.
setCurrentCoupon
(
currentCoupon
);
this
.
getCPText
();
this
.
isShowCoupon
=
false
;
// 要重新调用计算价格接口
// this.getTotalPrice(currentCoupon);
},
// tab切换
...
...
@@ -325,51 +395,59 @@ export default {
component_tag
:
`888#8880
${
index
+
4
}
`
});
},
// 获取商品信息
getGoodsInfo
()
{
this
.
GET
(
`trade/goods/goodInfo/
${
this
.
goodsId
}
`
,
{}).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
const
goods
=
res
.
data
;
const
tabs
=
[];
let
price
=
goods
.
couponPrice
||
goods
.
preferentialPrice
||
goods
.
costPrice
;
this
.
setGoodsInfo4Coupon
({
price
:
price
,
let
price
=
goods
.
couponPrice
||
goods
.
preferentialPrice
||
goods
.
costPrice
;
this
.
goods
=
goods
;
// 获取到商品后,再获取优惠券
this
.
getCanUseCoupons
({
goodsType
:
goods
.
goodsType
,
cardType
:
goods
.
cardType
,
price
:
price
,
count
:
0
});
// 获取到商品后,再获取优惠券
this
.
getCanUseCoupons
();
goods
.
salePrice
=
this
.
formatPrice
(
price
);
goods
.
costPriceText
=
(
goods
.
costPrice
/
100
).
toFixed
(
2
);
goods
.
hasDiscount
=
!!
(
goods
.
couponPrice
||
goods
.
preferentialPrice
);
let
savePrice
=
0
;
if
(
goods
.
couponPrice
)
{
if
(
goods
.
preferentialPrice
)
{
savePrice
=
((
goods
.
preferentialPrice
-
goods
.
couponPrice
)
/
100
).
toFixed
(
2
)
savePrice
=
(
(
goods
.
preferentialPrice
-
goods
.
couponPrice
)
/
100
).
toFixed
(
2
);
}
else
{
savePrice
=
((
goods
.
costPrice
-
goods
.
couponPrice
)
/
100
).
toFixed
(
2
)
savePrice
=
((
goods
.
costPrice
-
goods
.
couponPrice
)
/
100
).
toFixed
(
2
);
}
}
// if (goods.couponDTO) {
// goods.couponAmountText = (goods.couponDTO.discountAmount / 100).toFixed(2);
// }
if
(
goods
.
goodsDescWhere
)
{
tabs
.
push
({
name
:
'使用范围'
,
detail
:
goods
.
goodsDescWhere
})
tabs
.
push
({
name
:
"使用范围"
,
detail
:
goods
.
goodsDescWhere
});
}
if
(
goods
.
goodsDescHow
)
{
tabs
.
push
({
name
:
'如何使用'
,
detail
:
goods
.
goodsDescHow
})
tabs
.
push
({
name
:
"如何使用"
,
detail
:
goods
.
goodsDescHow
});
}
if
(
goods
.
goodsDescQaq
)
{
tabs
.
push
({
name
:
'常见问题'
,
detail
:
goods
.
goodsDescQaq
})
tabs
.
push
({
name
:
"常见问题"
,
detail
:
goods
.
goodsDescQaq
});
}
this
.
totalPrice
=
{
...
goods
.
salePrice
,
preferentialPrice
:
goods
.
preferentialPrice
,
costPrice
:
goods
.
costPrice
,
costPriceText
:
goods
.
costPriceText
,
savePrice
,
}
this
.
goods
=
goods
;
this
.
swiperList
=
res
.
data
&&
res
.
data
.
imgList
||
[];
savePrice
};
this
.
swiperList
=
(
res
.
data
&&
res
.
data
.
imgList
)
||
[];
this
.
tabs
=
tabs
;
this
.
getTabW
();
let
sharePrice
=
goods
.
preferentialPrice
||
goods
.
costPrice
;
...
...
@@ -393,29 +471,66 @@ export default {
}
else
{
this
.
$toast
(
res
.
message
);
}
})
})
;
},
// 多件商品的价格
getTotalPrice
()
{
// TODO,要多传优惠券id参数
getTotalPrice
(
coupon
)
{
const
num
=
this
.
curtGoodsNum
;
this
.
GET
(
`trade/goods/getPrice/
${
this
.
goodsId
}
/
${
num
}
`
,
{}).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
const
{
couponPrice
,
preferentialPrice
,
costPrice
,
savePrice
}
=
res
.
data
;
const
{
couponPrice
,
preferentialPrice
,
costPrice
,
savePrice
}
=
res
.
data
;
let
price
=
couponPrice
||
preferentialPrice
||
costPrice
;
this
.
totalPrice
=
{
...
this
.
formatPrice
(
price
),
preferentialPrice
,
costPrice
:
costPrice
,
costPriceText
:
(
costPrice
/
100
).
toFixed
(
2
),
savePrice
:
savePrice
?
(
savePrice
/
100
).
toFixed
(
2
)
:
0
,
}
savePrice
:
savePrice
?
(
savePrice
/
100
).
toFixed
(
2
)
:
0
}
;
this
.
goodsInfo4Coupon
.
price
=
price
;
this
.
setGoodsInfo4Coupon
(
this
.
goodsInfo4Coupon
);
this
.
goodsNum
=
num
;
}
else
if
(
res
.
code
===
"200006"
)
{
this
.
$store
.
dispatch
(
'logout'
)
this
.
$store
.
dispatch
(
"logout"
);
}
})
})
;
},
// 多件商品的价格
getTotalPriceOld
()
{
const
num
=
this
.
curtGoodsNum
;
this
.
GET
(
`trade/goods/getPrice/
${
this
.
goodsId
}
/
${
num
}
`
,
{}).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
const
{
couponPrice
,
preferentialPrice
,
costPrice
,
savePrice
}
=
res
.
data
;
let
price
=
couponPrice
||
preferentialPrice
||
costPrice
;
this
.
totalPrice
=
{
...
this
.
formatPrice
(
price
),
preferentialPrice
,
costPrice
:
costPrice
,
costPriceText
:
(
costPrice
/
100
).
toFixed
(
2
),
savePrice
:
savePrice
?
(
savePrice
/
100
).
toFixed
(
2
)
:
0
};
this
.
goodsInfo4Coupon
.
price
=
price
;
this
.
setGoodsInfo4Coupon
(
this
.
goodsInfo4Coupon
);
this
.
goodsNum
=
num
;
}
else
if
(
res
.
code
===
"200006"
)
{
this
.
$store
.
dispatch
(
"logout"
);
}
});
},
// 价格转成元、分
formatPrice
(
price
)
{
let
yuan
=
(
price
/
100
).
toFixed
(
0
);
...
...
@@ -424,7 +539,7 @@ export default {
return
{
yuan
,
fen
}
}
;
},
// 获取切换标签宽度
getTabW
()
{
...
...
@@ -432,9 +547,11 @@ export default {
return
;
}
this
.
$nextTick
(()
=>
{
const
{
width
}
=
this
.
$el
.
querySelector
(
'.tab-item'
).
getBoundingClientRect
();
const
{
width
}
=
this
.
$el
.
querySelector
(
".tab-item"
)
.
getBoundingClientRect
();
this
.
tabW
=
width
;
})
})
;
},
// 轮播切换
onSwiperChange
(
index
)
{
...
...
@@ -445,33 +562,33 @@ export default {
this
.
$sendBuriedData
({
component_tag
:
`888#88801`
});
this
.
commonCheckToken
(()
=>
{
});
this
.
commonCheckToken
(()
=>
{});
let
num
=
this
.
curtGoodsNum
;
if
(
this
.
goods
.
limitPurchase
&&
this
.
goods
.
limitPurchaseNum
&&
num
>=
this
.
goods
.
limitPurchaseNum
)
{
this
.
$toast
(
'已达最大限购数量'
)
if
(
this
.
goods
.
limitPurchase
&&
this
.
goods
.
limitPurchaseNum
&&
num
>=
this
.
goods
.
limitPurchaseNum
)
{
this
.
$toast
(
"已达最大限购数量"
);
return
;
}
if
(
this
.
goods
.
goodsStocks
&&
num
>=
this
.
goods
.
goodsStocks
)
{
this
.
$toast
(
'库存不足'
)
this
.
$toast
(
"库存不足"
);
return
;
}
this
.
curtGoodsNum
=
num
+
1
;
this
.
countTotalPrice
();
this
.
countTotalPrice
();
},
// 数量减
onReduce
()
{
this
.
$sendBuriedData
({
component_tag
:
`888#88802`
});
this
.
commonCheckToken
(()
=>
{
});
this
.
commonCheckToken
(()
=>
{});
let
num
=
this
.
curtGoodsNum
;
if
(
num
<=
1
)
{
this
.
$toast
(
'最少购买一张哦'
)
this
.
$toast
(
"最少购买一张哦"
);
return
;
}
this
.
curtGoodsNum
=
num
-
1
;
...
...
@@ -491,7 +608,7 @@ export default {
this
.
$sendBuriedData
({
component_tag
:
`888#88803`
});
this
.
commonCheckToken
(()
=>
{
// 微信内先去授权
if
(
isWechat
&&
!
this
.
wxInfo
.
openid
)
{
...
...
@@ -508,55 +625,58 @@ export default {
if
(
!
id
||
isSale
!==
1
)
{
return
;
}
// TODO 使用新的优惠券id
const
orderData
=
{
couponId
:
couponDTO
?
couponDTO
.
couponId
:
0
,
goodsId
:
id
,
goodsQuantity
:
this
.
goodsNum
,
orderSource
:
3
,
preferentialPrice
:
this
.
goods
.
preferentialPrice
,
price
:
this
.
goods
.
costPrice
,
}
console
.
log
(
'orderData...'
,
orderData
);
price
:
this
.
goods
.
costPrice
}
;
console
.
log
(
"orderData..."
,
orderData
);
this
.
showLoading
=
true
;
this
.
POST
(
'trade/center/order/createV2'
,
orderData
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
const
orderId
=
res
.
data
.
orderId
;
// if (isWechat) {
// this.goWxPayInner(orderId);
// } else {
// this.goWxPayOut(orderId);
// }
// 在站外,则调用站外支付
console
.
log
(
'this.isWeb ... isWechat - 2'
,
this
.
isWeb
,
isWechat
);
if
(
this
.
isWeb
)
{
console
.
log
(
'in web...'
);
if
(
isWechat
)
{
this
.
goWxPayInner
(
orderId
);
this
.
POST
(
"trade/center/order/createV2"
,
orderData
)
.
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
const
orderId
=
res
.
data
.
orderId
;
// if (isWechat) {
// this.goWxPayInner(orderId);
// } else {
// this.goWxPayOut(orderId);
// }
// 在站外,则调用站外支付
console
.
log
(
"this.isWeb ... isWechat - 2"
,
this
.
isWeb
,
isWechat
);
if
(
this
.
isWeb
)
{
console
.
log
(
"in web..."
);
if
(
isWechat
)
{
this
.
goWxPayInner
(
orderId
);
}
else
{
this
.
goWxPayOut
(
orderId
);
}
}
else
{
this
.
goWxPayOut
(
orderId
);
console
.
log
(
"not in web..."
);
rocNative
.
WXpay
({
__funcName
:
"__WXpay"
,
orderId
:
String
(
orderId
)
});
}
}
else
{
console
.
log
(
'not in web...'
);
rocNative
.
WXpay
({
'__funcName'
:
'__WXpay'
,
'orderId'
:
String
(
orderId
)
});
}
if
(
this
.
projectId
)
{
this
.
createRelation
(
this
.
projectId
,
orderId
);
if
(
this
.
projectId
)
{
this
.
createRelation
(
this
.
projectId
,
orderId
);
}
}
else
{
this
.
$toast
(
res
.
message
);
this
.
showLoading
=
false
;
if
(
res
.
code
===
"200006"
)
{
this
.
$store
.
dispatch
(
"logout"
);
}
}
}
else
{
this
.
$toast
(
res
.
message
);
}
)
.
catch
(()
=>
{
this
.
showLoading
=
false
;
if
(
res
.
code
===
"200006"
)
{
this
.
$store
.
dispatch
(
'logout'
)
}
}
}).
catch
(()
=>
{
this
.
showLoading
=
false
;
});
});
});
},
// 微信内支付
...
...
@@ -567,38 +687,40 @@ export default {
payChannel
:
1
,
tradeType
:
getTradeType
(),
userId
:
this
.
$store
.
state
.
user
.
info
.
id
}
this
.
POST
(
'trade/center/jsapi_prepay'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
&&
res
.
data
)
{
// console.log('______prepay_____', res.data);
const
that
=
this
;
const
payData
=
{
...
res
.
data
,
appid
:
res
.
data
.
appId
,
timestamp
:
res
.
data
.
timeStamp
,
success
:
function
()
{
let
query
=
{
orderId
};
if
(
that
.
projectId
)
{
query
.
projectId
=
that
.
projectId
}
that
.
$router
.
push
({
path
:
'/prezult'
,
query
});
},
fail
:
function
()
{
that
.
$toast
(
'支付失败,请重试~'
);
},
cancel
:
function
()
{
// that.$toast('支付取消~');
},
complete
:
function
()
{},
};
chooseWXPay
(
payData
);
}
else
{
this
.
$toast
(
res
.
message
);
}
this
.
showLoading
=
false
;
}).
catch
(()
=>
{
this
.
showLoading
=
false
;
})
};
this
.
POST
(
"trade/center/jsapi_prepay"
,
data
)
.
then
(
res
=>
{
if
(
res
.
code
==
"000000"
&&
res
.
data
)
{
// console.log('______prepay_____', res.data);
const
that
=
this
;
const
payData
=
{
...
res
.
data
,
appid
:
res
.
data
.
appId
,
timestamp
:
res
.
data
.
timeStamp
,
success
:
function
()
{
let
query
=
{
orderId
};
if
(
that
.
projectId
)
{
query
.
projectId
=
that
.
projectId
;
}
that
.
$router
.
push
({
path
:
"/prezult"
,
query
});
},
fail
:
function
()
{
that
.
$toast
(
"支付失败,请重试~"
);
},
cancel
:
function
()
{
// that.$toast('支付取消~');
},
complete
:
function
()
{}
};
chooseWXPay
(
payData
);
}
else
{
this
.
$toast
(
res
.
message
);
}
this
.
showLoading
=
false
;
})
.
catch
(()
=>
{
this
.
showLoading
=
false
;
});
},
// 站外微信支付
goWxPayOut
(
orderId
)
{
...
...
@@ -606,54 +728,59 @@ export default {
// openId: getAPPID(),
orderId
,
payChannel
:
1
,
tradeType
:
getTradeType
(),
}
this
.
POST
(
'trade/center/mweb_prepay'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
if
(
res
.
data
)
{
let
redirectUrl
=
this
.
getRedirectUrl
(
orderId
);
let
jumpLink
=
res
.
data
+
'&redirect_url='
+
encodeURIComponent
(
redirectUrl
);
window
.
location
.
href
=
jumpLink
;
tradeType
:
getTradeType
()
};
this
.
POST
(
"trade/center/mweb_prepay"
,
data
)
.
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
if
(
res
.
data
)
{
let
redirectUrl
=
this
.
getRedirectUrl
(
orderId
);
let
jumpLink
=
res
.
data
+
"&redirect_url="
+
encodeURIComponent
(
redirectUrl
);
window
.
location
.
href
=
jumpLink
;
}
}
else
{
this
.
$toast
(
res
.
message
||
"暂时不能支付"
);
}
}
else
{
this
.
$toast
(
res
.
message
||
'暂时不能支付'
);
}
this
.
showLoading
=
false
;
}).
catch
(()
=>
{
this
.
showLoading
=
false
;
})
this
.
showLoading
=
false
;
})
.
catch
(()
=>
{
this
.
showLoading
=
false
;
});
},
getRedirectUrl
(
orderId
)
{
let
path
=
`profexam/#/prezult?orderId=
${
orderId
}
`
;
if
(
this
.
projectId
)
{
path
+=
`&projectId=
${
this
.
projectId
}
`
path
+=
`&projectId=
${
this
.
projectId
}
`
;
}
return
getWebPageUrl
(
path
);
},
// 绑定项目和订单的关系(idType=1)
createRelation
(
projectId
,
orderId
)
{
this
.
POST
(
`cme/projectCard/correlation/1/
${
projectId
}
/
${
orderId
}
`
,
{
channel
:
3
}).
then
(
res
=>
{
this
.
POST
(
`cme/projectCard/correlation/1/
${
projectId
}
/
${
orderId
}
`
,
{
channel
:
3
}).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
//
}
else
{
this
.
$toast
(
res
.
message
);
}
})
})
;
},
// 显示元
yuan
(
fen
)
{
return
convertToYuan
(
fen
);
}
,
}
,
}
}
}
}
;
</
script
>
<
style
lang=
"less"
scoped
>
.goods-details-wrapper {
.swiper-box{
.swiper-box
{
position: relative;
.indicator{
.indicator
{
position: absolute;
right: 10px;
bottom: 10px;
...
...
@@ -667,133 +794,133 @@ export default {
border-radius: 11px;
background: rgba(0, 0, 0, 0.2);
}
.img{
.img
{
display: block;
width: 100%;
}
}
.border-line{
.border-line
{
padding: 20px 15px;
border-bottom: 6px solid #
F8F9FA
;
border-bottom: 6px solid #
f8f9fa
;
}
.info-box{
.title{
.info-box
{
.title
{
font-size: 18px;
font-weight: bold;
padding-bottom: 12px;
}
.price{
.price
{
display: flex;
align-items: baseline;
font-size: 12px;
}
.money{
.money
{
flex: 1;
width: 100px;
}
.yuan{
color: #
FB5B
52;
.yuan
{
color: #
fb5b
52;
font-size: 18px;
font-weight: bold;
}
.fen{
color: #
FB5B
52;
.fen
{
color: #
fb5b
52;
font-weight: bold;
}
.del{
.del
{
color: #979899;
text-decoration: line-through;
margin-left: 6px;
}
.bought{
.bought
{
color: #979899;
}
}
.buy-box{
.buy-box
{
font-size: 14px;
.flex{
.flex
{
display: flex;
align-items: center;
}
.name{
.name
{
flex: 1;
width: 100px;
font-weight: bold;
}
.buy-num{
.buy-num
{
display: flex;
}
.reduce{
.reduce
{
position: relative;
width: 22px;
height: 22px;
background: url(
'~@/images/reduce.png'
) no-repeat center center;
background: url(
"~@/images/reduce.png"
) no-repeat center center;
background-size: 20px auto;
}
.num{
.num
{
width: 30px;
height: 22px;
line-height: 22px;
text-align: center;
}
.plus{
.plus
{
position: relative;
width: 22px;
height: 22px;
background: url(
'~@/images/plus.png'
) no-repeat center center;
background: url(
"~@/images/plus.png"
) no-repeat center center;
background-size: 20px auto;
}
.buy-way{
.buy-way
{
margin-top: 25px;
span{
span
{
color: #979899;
font-size: 12px;
margin-left: 6px;
}
}
.way{
.way
{
line-height: 18px;
padding-left: 28px;
background: url(
'~@/images/wxpay.png'
) no-repeat left center;
background: url(
"~@/images/wxpay.png"
) no-repeat left center;
background-size: 18px auto;
}
.coupon-select {
// line-height: 12px;
padding-right: 15px;
background: url(
'~@/images/coupon/arrow-right.png'
) no-repeat right center;
background: url(
"~@/images/coupon/arrow-right.png"
) no-repeat right center;
background-size: 12px auto;
}
}
.tab-box{
.tab-box
{
display: flex;
position: relative;
height: 50px;
padding: 0 15px;
background-color: #fff;
&::after{
&::after
{
position: absolute;
content: "";
left: 0;
bottom: 0;
width: 200%;
height: 0;
border-bottom: 1px solid #
F0F1F
2;
border-bottom: 1px solid #
f0f1f
2;
transform: scale(0.5);
transform-origin: left center;
}
}
.tab-item{
.tab-item
{
color: #979899;
font-size: 15px;
width: 115px;
height: 50px;
line-height: 50px;
}
.tab-active{
.tab-active
{
color: #373839;
font-weight: bold;
}
.tab-line{
.tab-line
{
position: absolute;
left: 30px;
bottom: 3px;
...
...
@@ -804,12 +931,12 @@ export default {
transform: translate3d(-5px, 0, 0);
transition: left 0.3s;
}
.detail-box{
.detail-box
{
font-size: 14px;
text-align: justify;
padding: 15px 15px 75px;
}
.btn-box{
.btn-box
{
display: flex;
align-items: center;
position: fixed;
...
...
@@ -820,32 +947,32 @@ export default {
padding: 10px 15px;
box-shadow: 0 -4px 4px rgba(240, 240, 240, 0.5);
background-color: #fff;
.money{
.money
{
flex: 1;
width: 100px;
font-size: 14px;
}
.yuan{
color: #
FB5B
52;
.yuan
{
color: #
fb5b
52;
font-size: 18px;
font-weight: bold;
}
.fen{
.fen
{
font-size: 12px;
color: #
FB5B
52;
color: #
fb5b
52;
font-weight: bold;
}
.del{
.del
{
color: #979899;
font-size: 12px;
text-decoration: line-through;
margin-left: 6px;
}
.coupon{
.coupon
{
color: #979899;
font-size: 12px;
}
.btn{
.btn
{
width: 125px;
height: 40px;
line-height: 40px;
...
...
@@ -855,17 +982,16 @@ export default {
font-weight: bold;
border-radius: 20px;
}
.can-but{
background-image: linear-gradient(90deg, #
FFA65F, #FF7A4B
);
.can-but
{
background-image: linear-gradient(90deg, #
ffa65f, #ff7a4b
);
}
.cannot-buy{
background-color: #
C7C8C
9;
.cannot-buy
{
background-color: #
c7c8c
9;
}
}
.coupon-pc {
font-weight: 400;
color: #
FB5B
52;
color: #
fb5b
52;
}
}
</
style
>
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录