|
@@ -30,6 +30,10 @@
|
|
|
<!-- 商品基本信息:商品名称 && 分享 && 标签 && 备注 && 服务-->
|
|
|
<goods-info @share="onShare" :productData="productInfo"></goods-info>
|
|
|
|
|
|
+ <view class="section" v-if="productInfo.skus.length > 0">
|
|
|
+ <goods-unit-section :skuList="productInfo.skus" @click="onUnitClick"></goods-unit-section>
|
|
|
+ </view>
|
|
|
+
|
|
|
<!-- 参数 -->
|
|
|
<view class="section" v-if="productInfo.parametersList.length > 0">
|
|
|
<goods-params-section :paramList="productInfo.parametersList"></goods-params-section>
|
|
@@ -46,13 +50,7 @@
|
|
|
<!-- 商品详情 -->
|
|
|
<view class="section detail">
|
|
|
<view class="title">商品详情</view>
|
|
|
- <!-- <view
|
|
|
- v-if="productDetail.detailInfo"
|
|
|
- v-html="productDetail.detailInfo"
|
|
|
- style="overflow-x: hidden;"
|
|
|
- ></view> -->
|
|
|
<template v-if="productDetail && productDetail.detailInfo">
|
|
|
- <!-- <parser :html="productDetail.detailInfo" :img-mode="widthFix"></parser> -->
|
|
|
<uParse :content="productDetail.detailInfo" />
|
|
|
</template>
|
|
|
<!-- 空 -->
|
|
@@ -96,17 +94,7 @@
|
|
|
@open="$refs.receiveBuyPopup.close()"
|
|
|
@close="$refs.receiveBuyPopup.open()"
|
|
|
></goods-activity-popup>
|
|
|
-
|
|
|
- <!-- 领券购买 -->
|
|
|
- <goods-receive-buy-popup
|
|
|
- ref="receiveBuyPopup"
|
|
|
- :productData="productInfo"
|
|
|
- :couponTip="couponTip"
|
|
|
- :groupBuyFlag="groupBuyFlag"
|
|
|
- :navbarType="navbarTypeFlag"
|
|
|
- @detail="$refs.activitypPopup.open()"
|
|
|
- @submit="onSubmit"
|
|
|
- ></goods-receive-buy-popup>
|
|
|
+
|
|
|
<!-- 分享弹窗 -->
|
|
|
<cm-share-popup ref="sharePopup" :data="posterData" type="product"></cm-share-popup>
|
|
|
|
|
@@ -121,14 +109,24 @@
|
|
|
|
|
|
<!-- 返回顶部 -->
|
|
|
<tui-scroll-top :scrollTop="scrollTop" :bottom="80"></tui-scroll-top>
|
|
|
+
|
|
|
+ <!-- 购买弹窗 -->
|
|
|
+ <cm-goods-buy-popup
|
|
|
+ v-model="goodsBuyPopup"
|
|
|
+ :product="productInfo"
|
|
|
+ :couponList="couponList"
|
|
|
+ :useType="useType"
|
|
|
+ :buttonType="buttonType"
|
|
|
+ @confirm="onSubmit"
|
|
|
+ v-if="productInfo"
|
|
|
+ ></cm-goods-buy-popup>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
// 配置
|
|
|
-import { generateActivityType, generatePriceType, generateNavbarButtonText } from './commons/helper.js'
|
|
|
-// import Parser from '@/pages/views/goods/components/jyf-Parser/index.vue'//富文本处理
|
|
|
-// import marked from '@/components/uni/marked'
|
|
|
+import { generateNavbarButtonText } from './commons/helper.js'
|
|
|
+import { generateActivityType, generatePriceType } from '@/common/goods.helper.js'
|
|
|
import uParse from '@/components/uni/uParse/src/wxParse'
|
|
|
import { debounce } from '@/common/utils.js'
|
|
|
import { shareDataResult } from '@/common/share.helper.js'
|
|
@@ -161,7 +159,11 @@ export default {
|
|
|
posterData: {},
|
|
|
collageId: '',
|
|
|
groupBuyFlag: false, // 用户是否拼团购买
|
|
|
- autoplay: true
|
|
|
+ autoplay: true,
|
|
|
+ // 购买商品弹窗
|
|
|
+ goodsBuyPopup: false,
|
|
|
+ useType: 'buy',
|
|
|
+ buttonType: 'left'
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -208,7 +210,6 @@ export default {
|
|
|
onLoad(options) {
|
|
|
this.productId = parseInt(options.productId)
|
|
|
this.jumpState = parseInt(options.jumpState)
|
|
|
- // this.fetchProductDetail()
|
|
|
},
|
|
|
onShow() {
|
|
|
this.autoplay = true
|
|
@@ -220,19 +221,21 @@ export default {
|
|
|
methods: {
|
|
|
...mapActions('cart', ['addToCart']),
|
|
|
|
|
|
+ // 选择规格
|
|
|
+ onUnitClick() {
|
|
|
+ this.useType = 'unit'
|
|
|
+ this.goodsBuyPopup = true
|
|
|
+ },
|
|
|
+
|
|
|
// 商品提交
|
|
|
- onSubmit(count) {
|
|
|
- // 加入购物车
|
|
|
- if (this.navbarTypeFlag === 'cart') {
|
|
|
+ onSubmit(detail) {
|
|
|
+ if (detail.type === 'cart') {
|
|
|
this.addToCart({
|
|
|
- productId: this.productInfo.productId,
|
|
|
- productCount: count,
|
|
|
+ skuId: detail.sku.skuId,
|
|
|
+ productCount: detail.count,
|
|
|
heUserId: this.productInfo.heUserId
|
|
|
})
|
|
|
- }
|
|
|
-
|
|
|
- // 立即购买(提交商品信息)
|
|
|
- if (this.navbarTypeFlag === 'buy') {
|
|
|
+ } else if (detail.type === 'buy') {
|
|
|
if (!this.userId) {
|
|
|
const pages = getCurrentPages()
|
|
|
const page = pages[pages.length - 1]
|
|
@@ -240,39 +243,26 @@ export default {
|
|
|
uni.redirectTo({ url: '/pages/authorize/login-custom' })
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
const submitData = {
|
|
|
- productId: this.productInfo.productId, // 产品id
|
|
|
- productCount: count, // 产品购买数量
|
|
|
+ productId: detail.sku.productId, // 产品id
|
|
|
+ skuId: detail.sku.skuId, // sku id
|
|
|
+ productCount: detail.count, // 产品购买数量
|
|
|
heUserId: this.productInfo.heUserId, // 协销用户id
|
|
|
collageFlag: this.groupBuyFlag ? 1 : 0, // 是否拼团购买
|
|
|
collageId: this.collageId, // 拼团id
|
|
|
- couponId: this.productInfo.couponId, // 默认使用优惠券id
|
|
|
- allCount: count // 商品总数
|
|
|
+ couponId: detail.sku.couponId, // 默认使用优惠券id
|
|
|
+ allCount: detail.count // 商品总数
|
|
|
}
|
|
|
uni.setStorageSync('COMMIT_PRODUCT_INFO', submitData)
|
|
|
this.$router.navigateTo('order/order-create?type=product')
|
|
|
}
|
|
|
-
|
|
|
- this.$refs.receiveBuyPopup.close()
|
|
|
+ this.goodsBuyPopup = false
|
|
|
},
|
|
|
|
|
|
// 优惠券点击事件
|
|
|
onCouponClick(couponData) {
|
|
|
if (couponData.controlType === 'receive') {
|
|
|
- // const index = this.couponList.findIndex(item => item.couponId === coupon.couponId)
|
|
|
- // this.couponList.splice(index, 1)
|
|
|
- // coupon.controlType = 'buy'
|
|
|
- // coupon.couponStatus = 'received'
|
|
|
- // this.$set(this.couponList, index, coupon)
|
|
|
this.fetchCouponList()
|
|
|
- // this.couponList = this.couponList.map(coupon => {
|
|
|
- // if (coupon.couponId === couponData.couponId) {
|
|
|
- // coupon.controlType = 'search'
|
|
|
- // coupon.couponStatus = 'received'
|
|
|
- // }
|
|
|
- // return coupon
|
|
|
- // })
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -319,12 +309,12 @@ export default {
|
|
|
// 导航菜单右侧按钮点击
|
|
|
navbarRightClick(index) {
|
|
|
this.navbarTypeFlag = index > 0 || this.productInfo.collageStatus > 0 ? 'buy' : 'cart'
|
|
|
-
|
|
|
if (this.productInfo.activityType === 'group') {
|
|
|
this.groupBuyFlag = index > 0
|
|
|
}
|
|
|
-
|
|
|
- this.$refs.receiveBuyPopup.open()
|
|
|
+ this.useType = 'buy'
|
|
|
+ this.buttonType = index === 0 ? 'left' : 'right'
|
|
|
+ this.goodsBuyPopup = true
|
|
|
},
|
|
|
|
|
|
// 导航栏菜单左侧按钮点击
|
|
@@ -346,7 +336,6 @@ export default {
|
|
|
|
|
|
// 顶部tab切换
|
|
|
onTabChange(index) {
|
|
|
- // const selector = `.product-detail #anchor-${index}`
|
|
|
const offset = this.anchorList[index].top
|
|
|
uni.pageScrollTo({
|
|
|
scrollTop: this.scrollTop + offset - 40 - 10,
|
|
@@ -383,9 +372,9 @@ export default {
|
|
|
async fetchProductDetail() {
|
|
|
try {
|
|
|
const res = await fetchProductDetail({ productId: this.productId, userId: this.userId })
|
|
|
- this.productInfo = this.generateProductInfo(res.data)
|
|
|
this.isRequest = false
|
|
|
this.productInfo.heUserId = this.jumpState === 1 ? 0 : this.userId
|
|
|
+ this.productInfo = this.generateProductInfo(res.data)
|
|
|
this.initNavbarButton()
|
|
|
this.fetchCouponList()
|
|
|
} catch (e) {
|
|
@@ -429,9 +418,9 @@ export default {
|
|
|
const obj = Object.assign({}, coupon)
|
|
|
// 添加标题
|
|
|
if (coupon.noThresholdFlag > 0) {
|
|
|
- obj.couponTitle = `减¥${coupon.couponAmount}`
|
|
|
+ obj.couponTitle = `减¥${coupon.couponAmount}元`
|
|
|
} else {
|
|
|
- obj.couponTitle = `满¥${coupon.touchPrice}减¥${coupon.couponAmount}`
|
|
|
+ obj.couponTitle = `满¥${coupon.touchPrice}元减¥${coupon.couponAmount}元`
|
|
|
}
|
|
|
// 添加优惠券状态
|
|
|
if (obj.useStatus === 0) {
|
|
@@ -456,10 +445,16 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 处理商品信息
|
|
|
- generateProductInfo(product = {}) {
|
|
|
+ generateProductInfo(product) {
|
|
|
+ if (!product) return product
|
|
|
// 商品活动类型
|
|
|
product.activityType = generateActivityType(product)
|
|
|
product.priceType = generatePriceType(product)
|
|
|
+ product.skus = product.skus.map(sku => {
|
|
|
+ sku.activityType = generateActivityType(sku)
|
|
|
+ sku.priceType = generatePriceType(sku)
|
|
|
+ return sku
|
|
|
+ })
|
|
|
return product
|
|
|
}
|
|
|
}
|