|
|
|
|
@ -2,18 +2,9 @@
|
|
|
|
|
<!-- 商品详情 -->
|
|
|
|
|
<view class="container">
|
|
|
|
|
<!-- 轮播图 -->
|
|
|
|
|
<swiper
|
|
|
|
|
:indicator-dots="indicatorDots"
|
|
|
|
|
:autoplay="autoplay"
|
|
|
|
|
:indicator-color="indicatorColor"
|
|
|
|
|
:interval="interval"
|
|
|
|
|
:duration="duration"
|
|
|
|
|
:indicator-active-color="indicatorActiveColor"
|
|
|
|
|
>
|
|
|
|
|
<block
|
|
|
|
|
v-for="(item, index) in imgs"
|
|
|
|
|
:key="index"
|
|
|
|
|
>
|
|
|
|
|
<swiper :indicator-dots="indicatorDots" :autoplay="autoplay" :indicator-color="indicatorColor" :interval="interval"
|
|
|
|
|
:duration="duration" :indicator-active-color="indicatorActiveColor">
|
|
|
|
|
<block v-for="(item, index) in imgs" :key="index">
|
|
|
|
|
<swiper-item>
|
|
|
|
|
<image :src="item" />
|
|
|
|
|
</swiper-item>
|
|
|
|
|
@ -26,49 +17,42 @@
|
|
|
|
|
<view class="prod-tit">
|
|
|
|
|
{{ prodName }}
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="col"
|
|
|
|
|
@tap="addOrCannelCollection"
|
|
|
|
|
>
|
|
|
|
|
<image
|
|
|
|
|
v-if="!isCollection"
|
|
|
|
|
src="@/static/images/icon/prod-col.png"
|
|
|
|
|
/>
|
|
|
|
|
<image
|
|
|
|
|
v-if="isCollection"
|
|
|
|
|
src="@/static/images/icon/prod-col-red.png"
|
|
|
|
|
/>
|
|
|
|
|
<view class="col" @tap="addOrCannelCollection">
|
|
|
|
|
<image v-if="!isCollection" src="@/static/images/icon/prod-col.png" />
|
|
|
|
|
<image v-if="isCollection" src="@/static/images/icon/prod-col-red.png" />
|
|
|
|
|
收藏
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="sales-p">
|
|
|
|
|
{{ brief }}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="prod-price">
|
|
|
|
|
<text
|
|
|
|
|
v-if="defaultSku && defaultSku.price"
|
|
|
|
|
class="price"
|
|
|
|
|
>
|
|
|
|
|
<view class="prod-price" v-if="productType ==0 || productType==1">
|
|
|
|
|
<text v-if="defaultSku && defaultSku.price" class="price">
|
|
|
|
|
¥
|
|
|
|
|
<text class="price-num">
|
|
|
|
|
{{ wxs.parsePrice(defaultSku.price)[0] }}
|
|
|
|
|
</text>
|
|
|
|
|
.{{ wxs.parsePrice(defaultSku.price)[1] }}
|
|
|
|
|
</text>
|
|
|
|
|
<text
|
|
|
|
|
v-if="defaultSku && defaultSku.oriPrice"
|
|
|
|
|
class="ori-price"
|
|
|
|
|
>
|
|
|
|
|
<text v-if="defaultSku && defaultSku.oriPrice" class="ori-price">
|
|
|
|
|
¥{{ wxs.parsePrice(defaultSku.oriPrice)[0] }}.{{ wxs.parsePrice(defaultSku.oriPrice)[1] }}
|
|
|
|
|
</text>
|
|
|
|
|
<text class="sales" />
|
|
|
|
|
</view>
|
|
|
|
|
<view class="prod-price" v-if="productType ==2">
|
|
|
|
|
<text class="price">
|
|
|
|
|
<text class="price-num">
|
|
|
|
|
{{payScore }}
|
|
|
|
|
</text>
|
|
|
|
|
积分
|
|
|
|
|
</text>
|
|
|
|
|
|
|
|
|
|
<text class="sales" />
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 已选规格 -->
|
|
|
|
|
<view
|
|
|
|
|
class="sku"
|
|
|
|
|
@tap="showSku"
|
|
|
|
|
>
|
|
|
|
|
<view class="sku" @tap="showSku">
|
|
|
|
|
<view class="sku-tit">
|
|
|
|
|
已选
|
|
|
|
|
</view>
|
|
|
|
|
@ -81,10 +65,7 @@
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 评价 -->
|
|
|
|
|
<view class="cmt-wrap">
|
|
|
|
|
<view
|
|
|
|
|
class="cmt-tit"
|
|
|
|
|
@tap="showComment"
|
|
|
|
|
>
|
|
|
|
|
<view class="cmt-tit" @tap="showComment">
|
|
|
|
|
<view class="cmt-t">
|
|
|
|
|
评价
|
|
|
|
|
<text class="cmt-good">
|
|
|
|
|
@ -97,10 +78,7 @@
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cmt-cont">
|
|
|
|
|
<view
|
|
|
|
|
class="cmt-tag"
|
|
|
|
|
@tap="showComment"
|
|
|
|
|
>
|
|
|
|
|
<view class="cmt-tag" @tap="showComment">
|
|
|
|
|
<text>全部({{ prodCommData.number }})</text>
|
|
|
|
|
<text>好评({{ prodCommData.praiseNumber }})</text>
|
|
|
|
|
<text>中评({{ prodCommData.secondaryNumber }})</text>
|
|
|
|
|
@ -108,20 +86,13 @@
|
|
|
|
|
<text>有图({{ prodCommData.picNumber }})</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cmt-items">
|
|
|
|
|
<view
|
|
|
|
|
v-for="(item, index) in littleCommPage"
|
|
|
|
|
:key="index"
|
|
|
|
|
class="cmt-item"
|
|
|
|
|
>
|
|
|
|
|
<view v-for="(item, index) in littleCommPage" :key="index" class="cmt-item">
|
|
|
|
|
<view class="cmt-user">
|
|
|
|
|
<text class="date">
|
|
|
|
|
{{ item.recTime }}
|
|
|
|
|
</text>
|
|
|
|
|
<view class="cmt-user-info">
|
|
|
|
|
<image
|
|
|
|
|
class="user-img"
|
|
|
|
|
:src="item.pic"
|
|
|
|
|
/>
|
|
|
|
|
<image class="user-img" :src="item.pic" />
|
|
|
|
|
<view class="nickname">
|
|
|
|
|
{{ item.nickName }}
|
|
|
|
|
</view>
|
|
|
|
|
@ -130,23 +101,12 @@
|
|
|
|
|
<view class="cmt-cnt">
|
|
|
|
|
{{ item.content }}
|
|
|
|
|
</view>
|
|
|
|
|
<scroll-view
|
|
|
|
|
v-if="item.pics.length"
|
|
|
|
|
class="cmt-attr"
|
|
|
|
|
scroll-x="true"
|
|
|
|
|
>
|
|
|
|
|
<image
|
|
|
|
|
v-for="(commPic, index2) in item.pics"
|
|
|
|
|
:key="index2"
|
|
|
|
|
:src="commPic"
|
|
|
|
|
/>
|
|
|
|
|
<scroll-view v-if="item.pics.length" class="cmt-attr" scroll-x="true">
|
|
|
|
|
<image v-for="(commPic, index2) in item.pics" :key="index2" :src="commPic" />
|
|
|
|
|
</scroll-view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
v-if="prodCommPage.records.length > 2"
|
|
|
|
|
class="cmt-more-v"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="prodCommPage.records.length > 2" class="cmt-more-v">
|
|
|
|
|
<text @tap="showComment">
|
|
|
|
|
查看全部评价
|
|
|
|
|
</text>
|
|
|
|
|
@ -163,98 +123,62 @@
|
|
|
|
|
|
|
|
|
|
<!-- 底部按钮 -->
|
|
|
|
|
<view class="cart-footer">
|
|
|
|
|
<view
|
|
|
|
|
class="btn icon"
|
|
|
|
|
@tap="toHomePage"
|
|
|
|
|
>
|
|
|
|
|
<view class="btn icon" @tap="toHomePage">
|
|
|
|
|
<image src="@/static/images/tabbar/homepage.png" />
|
|
|
|
|
首页
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="btn icon"
|
|
|
|
|
@tap="toCartPage"
|
|
|
|
|
>
|
|
|
|
|
<view class="btn icon" @tap="toCartPage">
|
|
|
|
|
<image src="@/static/images/tabbar/basket.png" />
|
|
|
|
|
购物车
|
|
|
|
|
<view
|
|
|
|
|
v-if="totalCartNum>0"
|
|
|
|
|
class="badge badge-1"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="totalCartNum>0" class="badge badge-1">
|
|
|
|
|
{{ totalCartNum }}
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="btn cart"
|
|
|
|
|
@tap="showSku"
|
|
|
|
|
>
|
|
|
|
|
<view class="btn cart" @tap="showSku">
|
|
|
|
|
<text>加入购物车</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="btn buy"
|
|
|
|
|
@tap="showSku"
|
|
|
|
|
>
|
|
|
|
|
<view class="btn buy" @tap="showSku">
|
|
|
|
|
<text>立即购买</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- end 底部按钮 -->
|
|
|
|
|
|
|
|
|
|
<!-- 规格弹窗 -->
|
|
|
|
|
<view
|
|
|
|
|
v-if="skuShow"
|
|
|
|
|
class="pup-sku"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="skuShow" class="pup-sku">
|
|
|
|
|
<view class="pup-sku-main">
|
|
|
|
|
<view class="pup-sku-header">
|
|
|
|
|
<image
|
|
|
|
|
class="pup-sku-img"
|
|
|
|
|
:src="defaultSku.pic?defaultSku.pic:pic"
|
|
|
|
|
/>
|
|
|
|
|
<view class="pup-sku-price">
|
|
|
|
|
<image class="pup-sku-img" :src="defaultSku.pic?defaultSku.pic:pic" />
|
|
|
|
|
<view class="pup-sku-price" v-if="productType != 2">
|
|
|
|
|
¥
|
|
|
|
|
<text
|
|
|
|
|
v-if="defaultSku && defaultSku.price"
|
|
|
|
|
class="pup-sku-price-int"
|
|
|
|
|
>
|
|
|
|
|
<text v-if="defaultSku && defaultSku.price" class="pup-sku-price-int">
|
|
|
|
|
{{ wxs.parsePrice(defaultSku.price)[0] }}
|
|
|
|
|
</text>
|
|
|
|
|
.{{ wxs.parsePrice(defaultSku.price)[1] }}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="pup-sku-price" v-if="productType == 2">
|
|
|
|
|
<text v-if="defaultSku && defaultSku.price" class="pup-sku-price-int">
|
|
|
|
|
{{payScore}}
|
|
|
|
|
</text>
|
|
|
|
|
积分
|
|
|
|
|
</view>
|
|
|
|
|
<view class="pup-sku-prop">
|
|
|
|
|
<text>已选</text>
|
|
|
|
|
{{ selectedProp.length > 0 ? selectedProp + ',' : '' }}{{ prodNum }}件
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="close"
|
|
|
|
|
@tap="closePopup"
|
|
|
|
|
/>
|
|
|
|
|
<view class="close" @tap="closePopup" />
|
|
|
|
|
</view>
|
|
|
|
|
<view class="pup-sku-body">
|
|
|
|
|
<view class="pup-sku-area">
|
|
|
|
|
<view
|
|
|
|
|
v-if="skuList.length"
|
|
|
|
|
class="sku-box"
|
|
|
|
|
>
|
|
|
|
|
<block
|
|
|
|
|
v-for="(skuGroupItem, skuGroupItemIndex) in skuGroupList"
|
|
|
|
|
:key="skuGroupItemIndex"
|
|
|
|
|
>
|
|
|
|
|
<view
|
|
|
|
|
v-for="(skuLine, key) in skuGroupItem"
|
|
|
|
|
:key="key"
|
|
|
|
|
class="items sku-text"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="skuList.length" class="sku-box">
|
|
|
|
|
<block v-for="(skuGroupItem, skuGroupItemIndex) in skuGroupList" :key="skuGroupItemIndex">
|
|
|
|
|
<view v-for="(skuLine, key) in skuGroupItem" :key="key" class="items sku-text">
|
|
|
|
|
<text class="sku-kind">
|
|
|
|
|
{{ key }}
|
|
|
|
|
</text>
|
|
|
|
|
<view class="con">
|
|
|
|
|
<text
|
|
|
|
|
v-for="skuLineItem in skuLine"
|
|
|
|
|
:key="skuLineItem"
|
|
|
|
|
class="sku-choose-item"
|
|
|
|
|
<text v-for="skuLineItem in skuLine" :key="skuLineItem" class="sku-choose-item"
|
|
|
|
|
:class="[selectedPropList.indexOf(key + ':' + skuLineItem) !== -1?'active':'',
|
|
|
|
|
isSkuLineItemNotOptional(allProperties,selectedPropObj,key,skuLineItem,propKeys)? 'dashed' : '']"
|
|
|
|
|
@click="toChooseItem(skuGroupItemIndex, skuLineItem, key)"
|
|
|
|
|
>
|
|
|
|
|
isSkuLineItemNotOptional(allProperties,selectedPropObj,key,skuLineItem,propKeys)? 'dashed' : '']" @click="toChooseItem(skuGroupItemIndex, skuLineItem, key)">
|
|
|
|
|
{{ skuLineItem }}
|
|
|
|
|
</text>
|
|
|
|
|
</view>
|
|
|
|
|
@ -264,23 +188,13 @@
|
|
|
|
|
</view>
|
|
|
|
|
<view class="pup-sku-count">
|
|
|
|
|
<view class="num-wrap">
|
|
|
|
|
<view
|
|
|
|
|
class="minus"
|
|
|
|
|
@tap="onCountMinus"
|
|
|
|
|
>
|
|
|
|
|
<view class="minus" @tap="onCountMinus">
|
|
|
|
|
<text class="row" />
|
|
|
|
|
</view>
|
|
|
|
|
<view class="text-wrap">
|
|
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
:value="prodNum"
|
|
|
|
|
disabled
|
|
|
|
|
>
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="plus"
|
|
|
|
|
@tap="onCountPlus"
|
|
|
|
|
>
|
|
|
|
|
<input type="number" :value="prodNum" disabled>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="plus" @tap="onCountPlus">
|
|
|
|
|
<text class="row" />
|
|
|
|
|
<text class="col" />
|
|
|
|
|
</view>
|
|
|
|
|
@ -291,16 +205,10 @@
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="pup-sku-footer">
|
|
|
|
|
<view
|
|
|
|
|
class="btn cart"
|
|
|
|
|
@tap="addToCart"
|
|
|
|
|
>
|
|
|
|
|
<view class="btn cart" @tap="addToCart">
|
|
|
|
|
加入购物车
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="btn buy"
|
|
|
|
|
@tap="buyNow"
|
|
|
|
|
>
|
|
|
|
|
<view class="btn buy" @tap="buyNow">
|
|
|
|
|
立即购买
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
@ -308,10 +216,7 @@
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 评价弹窗 -->
|
|
|
|
|
<view
|
|
|
|
|
v-if="commentShow"
|
|
|
|
|
class="cmt-popup"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="commentShow" class="cmt-popup">
|
|
|
|
|
<view class="cmt-tit">
|
|
|
|
|
<view class="cmt-t">
|
|
|
|
|
商品评价
|
|
|
|
|
@ -319,65 +224,35 @@
|
|
|
|
|
好评度{{ prodCommData.positiveRating }}%
|
|
|
|
|
</text>
|
|
|
|
|
</view>
|
|
|
|
|
<text
|
|
|
|
|
class="close"
|
|
|
|
|
@tap="closePopup"
|
|
|
|
|
/>
|
|
|
|
|
<text class="close" @tap="closePopup" />
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cmt-cont">
|
|
|
|
|
<view class="cmt-tag">
|
|
|
|
|
<text
|
|
|
|
|
data-evaluate="-1"
|
|
|
|
|
:class="evaluate==-1?'selected':''"
|
|
|
|
|
@tap="getProdCommPage"
|
|
|
|
|
>
|
|
|
|
|
<text data-evaluate="-1" :class="evaluate==-1?'selected':''" @tap="getProdCommPage">
|
|
|
|
|
全部({{ prodCommData.number }})
|
|
|
|
|
</text>
|
|
|
|
|
<text
|
|
|
|
|
data-evaluate="0"
|
|
|
|
|
:class="evaluate==0?'selected':''"
|
|
|
|
|
@tap="getProdCommPage"
|
|
|
|
|
>
|
|
|
|
|
<text data-evaluate="0" :class="evaluate==0?'selected':''" @tap="getProdCommPage">
|
|
|
|
|
好评({{ prodCommData.praiseNumber }})
|
|
|
|
|
</text>
|
|
|
|
|
<text
|
|
|
|
|
data-evaluate="1"
|
|
|
|
|
:class="evaluate==1?'selected':''"
|
|
|
|
|
@tap="getProdCommPage"
|
|
|
|
|
>
|
|
|
|
|
<text data-evaluate="1" :class="evaluate==1?'selected':''" @tap="getProdCommPage">
|
|
|
|
|
中评({{ prodCommData.secondaryNumber }})
|
|
|
|
|
</text>
|
|
|
|
|
<text
|
|
|
|
|
data-evaluate="2"
|
|
|
|
|
:class="evaluate==2?'selected':''"
|
|
|
|
|
@tap="getProdCommPage"
|
|
|
|
|
>
|
|
|
|
|
<text data-evaluate="2" :class="evaluate==2?'selected':''" @tap="getProdCommPage">
|
|
|
|
|
差评({{ prodCommData.negativeNumber }})
|
|
|
|
|
</text>
|
|
|
|
|
<text
|
|
|
|
|
data-evaluate="3"
|
|
|
|
|
:class="evaluate==3?'selected':''"
|
|
|
|
|
@tap="getProdCommPage"
|
|
|
|
|
>
|
|
|
|
|
<text data-evaluate="3" :class="evaluate==3?'selected':''" @tap="getProdCommPage">
|
|
|
|
|
有图({{ prodCommData.picNumber }})
|
|
|
|
|
</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cmt-items">
|
|
|
|
|
<block v-if="prodCommPage.records.length">
|
|
|
|
|
<view
|
|
|
|
|
v-for="(item, index) in prodCommPage.records"
|
|
|
|
|
:key="index"
|
|
|
|
|
class="cmt-item"
|
|
|
|
|
>
|
|
|
|
|
<view v-for="(item, index) in prodCommPage.records" :key="index" class="cmt-item">
|
|
|
|
|
<view class="cmt-user">
|
|
|
|
|
<text class="date">
|
|
|
|
|
{{ item.recTime }}
|
|
|
|
|
</text>
|
|
|
|
|
<view class="cmt-user-info">
|
|
|
|
|
<image
|
|
|
|
|
class="user-img"
|
|
|
|
|
:src="item.pic"
|
|
|
|
|
/>
|
|
|
|
|
<image class="user-img" :src="item.pic" />
|
|
|
|
|
<view class="nickname">
|
|
|
|
|
{{ item.nickName }}
|
|
|
|
|
</view>
|
|
|
|
|
@ -386,21 +261,10 @@
|
|
|
|
|
<view class="cmt-cnt">
|
|
|
|
|
{{ item.content }}
|
|
|
|
|
</view>
|
|
|
|
|
<scroll-view
|
|
|
|
|
v-if="item.pics.length"
|
|
|
|
|
class="cmt-attr"
|
|
|
|
|
scroll-x="true"
|
|
|
|
|
>
|
|
|
|
|
<image
|
|
|
|
|
v-for="(commPic, index2) in item.pics"
|
|
|
|
|
:key="index2"
|
|
|
|
|
:src="commPic"
|
|
|
|
|
/>
|
|
|
|
|
<scroll-view v-if="item.pics.length" class="cmt-attr" scroll-x="true">
|
|
|
|
|
<image v-for="(commPic, index2) in item.pics" :key="index2" :src="commPic" />
|
|
|
|
|
</scroll-view>
|
|
|
|
|
<view
|
|
|
|
|
v-if="item.replyContent"
|
|
|
|
|
class="cmt-reply"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="item.replyContent" class="cmt-reply">
|
|
|
|
|
<text class="reply-tit">
|
|
|
|
|
店铺回复:
|
|
|
|
|
</text>
|
|
|
|
|
@ -408,17 +272,11 @@
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</block>
|
|
|
|
|
<view
|
|
|
|
|
v-if="!prodCommPage.records.length"
|
|
|
|
|
class="empty"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="!prodCommPage.records.length" class="empty">
|
|
|
|
|
暂无评价
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
v-if="prodCommPage.pages > prodCommPage.current"
|
|
|
|
|
class="load-more"
|
|
|
|
|
>
|
|
|
|
|
<view v-if="prodCommPage.pages > prodCommPage.current" class="load-more">
|
|
|
|
|
<text @tap="getMoreCommPage">
|
|
|
|
|
点击加载更多
|
|
|
|
|
</text>
|
|
|
|
|
@ -429,51 +287,51 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
const wxs = number()
|
|
|
|
|
|
|
|
|
|
const indicatorDots = ref(true)
|
|
|
|
|
const indicatorColor = ref('#f2f2f2')
|
|
|
|
|
const indicatorActiveColor = ref('#eb2444')
|
|
|
|
|
const autoplay = ref(true)
|
|
|
|
|
const interval = ref(3000)
|
|
|
|
|
const duration = ref(1000)
|
|
|
|
|
const selectedProp = ref([])
|
|
|
|
|
let prodId = 0
|
|
|
|
|
/**
|
|
|
|
|
const wxs = number()
|
|
|
|
|
|
|
|
|
|
const indicatorDots = ref(true)
|
|
|
|
|
const indicatorColor = ref('#f2f2f2')
|
|
|
|
|
const indicatorActiveColor = ref('#eb2444')
|
|
|
|
|
const autoplay = ref(true)
|
|
|
|
|
const interval = ref(3000)
|
|
|
|
|
const duration = ref(1000)
|
|
|
|
|
const selectedProp = ref([])
|
|
|
|
|
let prodId = 0
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad((options) => {
|
|
|
|
|
prodId = options.prodid// 加载商品信息
|
|
|
|
|
onLoad((options) => {
|
|
|
|
|
prodId = options.prodid // 加载商品信息
|
|
|
|
|
getProdInfo() // 加载商品数据
|
|
|
|
|
getProdCommData() // 加载评论项
|
|
|
|
|
getLittleProdComm() // 查看用户是否关注
|
|
|
|
|
getCollection()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const app = getApp()
|
|
|
|
|
const totalCartNum = ref(0)
|
|
|
|
|
/**
|
|
|
|
|
const app = getApp()
|
|
|
|
|
const totalCartNum = ref(0)
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow(() => {
|
|
|
|
|
onShow(() => {
|
|
|
|
|
totalCartNum.value = app.globalData.totalCartCount
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 分享设置
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage(() => {
|
|
|
|
|
onShareAppMessage(() => {
|
|
|
|
|
return {
|
|
|
|
|
title: prodName.value,
|
|
|
|
|
path: '/pages/prod/prod?prodid=' + prodId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const isCollection = ref(false)
|
|
|
|
|
/**
|
|
|
|
|
const isCollection = ref(false)
|
|
|
|
|
/**
|
|
|
|
|
* 获取是否关注信息
|
|
|
|
|
*/
|
|
|
|
|
const getCollection = () => {
|
|
|
|
|
const getCollection = () => {
|
|
|
|
|
uni.showLoading()
|
|
|
|
|
http.request({
|
|
|
|
|
url: '/p/user/collection/isCollection',
|
|
|
|
|
@ -482,16 +340,18 @@ const getCollection = () => {
|
|
|
|
|
prodId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(({ data }) => {
|
|
|
|
|
.then(({
|
|
|
|
|
data
|
|
|
|
|
}) => {
|
|
|
|
|
isCollection.value = data
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 添加或者取消收藏商品
|
|
|
|
|
*/
|
|
|
|
|
const addOrCannelCollection = () => {
|
|
|
|
|
const addOrCannelCollection = () => {
|
|
|
|
|
uni.showLoading()
|
|
|
|
|
http.request({
|
|
|
|
|
url: '/p/user/collection/addOrCancel',
|
|
|
|
|
@ -502,20 +362,23 @@ const addOrCannelCollection = () => {
|
|
|
|
|
isCollection.value = !isCollection.value
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const skuList = ref([])
|
|
|
|
|
const brief = ref('')
|
|
|
|
|
const prodNum = ref(1)
|
|
|
|
|
const pic = ref('')
|
|
|
|
|
const imgs = ref('')
|
|
|
|
|
const prodName = ref('')
|
|
|
|
|
const price = ref(0)
|
|
|
|
|
const content = ref('')
|
|
|
|
|
/**
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const skuList = ref([])
|
|
|
|
|
const brief = ref('')
|
|
|
|
|
const prodNum = ref(1)
|
|
|
|
|
const pic = ref('')
|
|
|
|
|
const imgs = ref('')
|
|
|
|
|
const prodName = ref('')
|
|
|
|
|
const price = ref(0)
|
|
|
|
|
const content = ref('')
|
|
|
|
|
let payScore = 1000
|
|
|
|
|
let giveScore = 0
|
|
|
|
|
const productType = ref(0)
|
|
|
|
|
/**
|
|
|
|
|
* 获取商品信息
|
|
|
|
|
*/
|
|
|
|
|
const getProdInfo = () => {
|
|
|
|
|
const getProdInfo = () => {
|
|
|
|
|
uni.showLoading()
|
|
|
|
|
http.request({
|
|
|
|
|
url: '/prod/prodInfo',
|
|
|
|
|
@ -524,7 +387,9 @@ const getProdInfo = () => {
|
|
|
|
|
prodId // userType: 0
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(({ data }) => {
|
|
|
|
|
.then(({
|
|
|
|
|
data
|
|
|
|
|
}) => {
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
if (!data) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
@ -540,14 +405,17 @@ const getProdInfo = () => {
|
|
|
|
|
brief.value = data.brief
|
|
|
|
|
skuList.value = data.skuList
|
|
|
|
|
pic.value = data.pic
|
|
|
|
|
productType.value = data.productType
|
|
|
|
|
payScore = data.payScore
|
|
|
|
|
giveScore = data.giveScore
|
|
|
|
|
// 组装sku
|
|
|
|
|
groupSkuProp(data.skuList, data.price)
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const prodCommData = ref({})
|
|
|
|
|
const getProdCommData = () => {
|
|
|
|
|
const prodCommData = ref({})
|
|
|
|
|
const getProdCommData = () => {
|
|
|
|
|
http.request({
|
|
|
|
|
url: '/prodComm/prodCommData',
|
|
|
|
|
method: 'GET',
|
|
|
|
|
@ -555,36 +423,38 @@ const getProdCommData = () => {
|
|
|
|
|
prodId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(({ data }) => {
|
|
|
|
|
.then(({
|
|
|
|
|
data
|
|
|
|
|
}) => {
|
|
|
|
|
prodCommData.value = data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const prodCommPage = ref({
|
|
|
|
|
const prodCommPage = ref({
|
|
|
|
|
current: 0,
|
|
|
|
|
pages: 0,
|
|
|
|
|
records: []
|
|
|
|
|
})
|
|
|
|
|
/**
|
|
|
|
|
})
|
|
|
|
|
/**
|
|
|
|
|
* 获取部分评论
|
|
|
|
|
*/
|
|
|
|
|
const getLittleProdComm = () => {
|
|
|
|
|
const getLittleProdComm = () => {
|
|
|
|
|
if (prodCommPage.value.records.length) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
getProdCommPage()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getMoreCommPage = () => {
|
|
|
|
|
const getMoreCommPage = () => {
|
|
|
|
|
getProdCommPage()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const littleCommPage = ref([])
|
|
|
|
|
const evaluate = ref(-1)
|
|
|
|
|
/**
|
|
|
|
|
const littleCommPage = ref([])
|
|
|
|
|
const evaluate = ref(-1)
|
|
|
|
|
/**
|
|
|
|
|
* 获取分页获取评论
|
|
|
|
|
*/
|
|
|
|
|
const getProdCommPage = (e) => {
|
|
|
|
|
const getProdCommPage = (e) => {
|
|
|
|
|
if (e) {
|
|
|
|
|
if (e.currentTarget.dataset.evaluate === evaluate.value) {
|
|
|
|
|
return
|
|
|
|
|
@ -607,7 +477,9 @@ const getProdCommPage = (e) => {
|
|
|
|
|
evaluate: evaluate.value
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(({ data }) => {
|
|
|
|
|
.then(({
|
|
|
|
|
data
|
|
|
|
|
}) => {
|
|
|
|
|
data.records.forEach(item => {
|
|
|
|
|
if (item.pics) {
|
|
|
|
|
item.pics = item.pics.split(',')
|
|
|
|
|
@ -625,19 +497,19 @@ const getProdCommPage = (e) => {
|
|
|
|
|
littleCommPage.value = records.slice(0, 2)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
let selectedPropObjList = null
|
|
|
|
|
const skuGroup = ref({})
|
|
|
|
|
const defaultSku = ref(null)
|
|
|
|
|
const selectedPropObj = ref({})
|
|
|
|
|
const propKeys = ref([])
|
|
|
|
|
const allProperties = ref([])
|
|
|
|
|
const findSku = ref(true)
|
|
|
|
|
const skuGroupList = ref([])
|
|
|
|
|
/**
|
|
|
|
|
}
|
|
|
|
|
let selectedPropObjList = null
|
|
|
|
|
const skuGroup = ref({})
|
|
|
|
|
const defaultSku = ref(null)
|
|
|
|
|
const selectedPropObj = ref({})
|
|
|
|
|
const propKeys = ref([])
|
|
|
|
|
const allProperties = ref([])
|
|
|
|
|
const findSku = ref(true)
|
|
|
|
|
const skuGroupList = ref([])
|
|
|
|
|
/**
|
|
|
|
|
* 组装SKU
|
|
|
|
|
*/
|
|
|
|
|
const groupSkuProp = (skuList, defaultPrice) => {
|
|
|
|
|
const groupSkuProp = (skuList, defaultPrice) => {
|
|
|
|
|
if (skuList.length === 1 && !skuList[0].properties) {
|
|
|
|
|
defaultSku.value = skuList[0]
|
|
|
|
|
findSku.value = true
|
|
|
|
|
@ -693,13 +565,13 @@ const groupSkuProp = (skuList, defaultPrice) => {
|
|
|
|
|
skuGroupList.value = unique(_skuGroupList)
|
|
|
|
|
allProperties.value = _allProperties
|
|
|
|
|
parseSelectedObjToVals(skuList)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const selectedPropList = ref(null)
|
|
|
|
|
/**
|
|
|
|
|
const selectedPropList = ref(null)
|
|
|
|
|
/**
|
|
|
|
|
* 将已选的 {key:val,key2:val2}转换成 [val,val2]
|
|
|
|
|
*/
|
|
|
|
|
const parseSelectedObjToVals = (skuList) => {
|
|
|
|
|
const parseSelectedObjToVals = (skuList) => {
|
|
|
|
|
const selectedPropObjListParam = selectedPropObjList
|
|
|
|
|
let selectedPropertiesParam = ''
|
|
|
|
|
const selectedPropListParam = []
|
|
|
|
|
@ -726,12 +598,12 @@ const parseSelectedObjToVals = (skuList) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
findSku.value = findSkuParam
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 判断当前的规格值 是否可以选
|
|
|
|
|
*/
|
|
|
|
|
const isSkuLineItemNotOptional = (allProperties, selectedPropObjParam, key, item, propKeys) => {
|
|
|
|
|
const isSkuLineItemNotOptional = (allProperties, selectedPropObjParam, key, item, propKeys) => {
|
|
|
|
|
const selectedPropObj = Object.assign({}, selectedPropObjParam)
|
|
|
|
|
let properties = ''
|
|
|
|
|
selectedPropObj[key] = item
|
|
|
|
|
@ -750,21 +622,21 @@ const isSkuLineItemNotOptional = (allProperties, selectedPropObjParam, key, item
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 规格点击事件
|
|
|
|
|
*/
|
|
|
|
|
const toChooseItem = (skuGroupItemIndex, skuLineItem, key) => {
|
|
|
|
|
const toChooseItem = (skuGroupItemIndex, skuLineItem, key) => {
|
|
|
|
|
selectedPropObjList[skuGroupItemIndex][key] = skuLineItem
|
|
|
|
|
selectedPropObj.value[key] = skuLineItem
|
|
|
|
|
parseSelectedObjToVals(skuList.value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 去重
|
|
|
|
|
*/
|
|
|
|
|
const unique = (arr) => {
|
|
|
|
|
const unique = (arr) => {
|
|
|
|
|
const map = {}
|
|
|
|
|
arr.forEach(item => {
|
|
|
|
|
const obj = {}
|
|
|
|
|
@ -772,31 +644,31 @@ const unique = (arr) => {
|
|
|
|
|
map[JSON.stringify(obj)] = item
|
|
|
|
|
})
|
|
|
|
|
return Object.keys(map).map(key => JSON.parse(key))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 跳转到首页
|
|
|
|
|
*/
|
|
|
|
|
const toHomePage = () => {
|
|
|
|
|
const toHomePage = () => {
|
|
|
|
|
uni.switchTab({
|
|
|
|
|
url: '/pages/index/index'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 跳转到购物车
|
|
|
|
|
*/
|
|
|
|
|
const toCartPage = () => {
|
|
|
|
|
const toCartPage = () => {
|
|
|
|
|
uni.switchTab({
|
|
|
|
|
url: '/pages/basket/basket'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const shopId = 1
|
|
|
|
|
/**
|
|
|
|
|
const shopId = 1
|
|
|
|
|
/**
|
|
|
|
|
* 加入购物车
|
|
|
|
|
*/
|
|
|
|
|
const addToCart = () => {
|
|
|
|
|
const addToCart = () => {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
mask: true
|
|
|
|
|
})
|
|
|
|
|
@ -819,12 +691,12 @@ const addToCart = () => {
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 立即购买
|
|
|
|
|
*/
|
|
|
|
|
const buyNow = () => {
|
|
|
|
|
const buyNow = () => {
|
|
|
|
|
uni.setStorageSync('orderItem', JSON.stringify({
|
|
|
|
|
prodId,
|
|
|
|
|
skuId: defaultSku.value.skuId,
|
|
|
|
|
@ -834,42 +706,42 @@ const buyNow = () => {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/submit-order/submit-order?orderEntry=1'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 减数量
|
|
|
|
|
*/
|
|
|
|
|
const onCountMinus = () => {
|
|
|
|
|
const onCountMinus = () => {
|
|
|
|
|
if (prodNum.value > 1) {
|
|
|
|
|
prodNum.value = prodNum.value - 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 加数量
|
|
|
|
|
*/
|
|
|
|
|
const onCountPlus = () => {
|
|
|
|
|
const onCountPlus = () => {
|
|
|
|
|
if (prodNum.value < 1000) {
|
|
|
|
|
prodNum.value = prodNum.value + 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const skuShow = ref(false)
|
|
|
|
|
const showSku = () => {
|
|
|
|
|
const skuShow = ref(false)
|
|
|
|
|
const showSku = () => {
|
|
|
|
|
skuShow.value = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const commentShow = ref(false)
|
|
|
|
|
const showComment = () => {
|
|
|
|
|
const commentShow = ref(false)
|
|
|
|
|
const showComment = () => {
|
|
|
|
|
commentShow.value = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const closePopup = () => {
|
|
|
|
|
const closePopup = () => {
|
|
|
|
|
skuShow.value = false
|
|
|
|
|
commentShow.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
@use './prod.scss';
|
|
|
|
|
@use './prod.scss';
|
|
|
|
|
</style>
|
|
|
|
|
|