瀏覽代碼

商品详情页面接口调试

yuwenjun1997 3 年之前
父節點
當前提交
764cd31dab

+ 1 - 1
components/views/cm-coupon-popup/cm-coupon-popup.vue

@@ -44,6 +44,7 @@
                         <view class="coupon-section" v-for="item in list" :key="item.couponId">
                             <cm-coupon
                                 :controlType="item.controlType || 'use'"
+                                :status="item.couponStatus"
                                 :checked="item.checked"
                                 :key="item.couponId"
                                 :couponData="item"
@@ -153,7 +154,6 @@ export default {
         },
         // 关闭事件
         handleClose() {
-            this.$refs.popup.open('bottom')
             this.$emit('close')
         }
     }

+ 1 - 1
components/views/cm-coupon/cm-coupon.vue

@@ -171,7 +171,7 @@ export default {
         },
         // 领取优惠券
         async clickReceive() {
-            if (!userId) return this.$router.navigateTo('authorize/login-custom')
+            if (!this.userId) return this.$router.navigateTo('authorize/login-custom')
             try {
                 await this.receiveCoupon(this.couponData)
                 this.$emit('click', this.couponData)

+ 9 - 22
pages/views/goods/components/goods-coupon-list/goods-coupon-list.vue

@@ -1,35 +1,22 @@
 <template>
     <view class="coupon-section">
         <view class="coupon-tags">
-            <view class="tag" v-for="item in couponList" v-text="item.name" :key="item.id"></view>
+            <view class="tag" v-for="item in couponList" v-text="item.couponTitle" :key="item.couponId"></view>
+        </view>
+        <view class="more" @click="$emit('click')">
+            <text>领券</text>
+            <text class="iconfont icon-chakangengduo"></text>
         </view>
-        <view class="more"> <text>领券</text> <text class="iconfont icon-chakangengduo"></text> </view>
     </view>
 </template>
 
 <script>
 export default {
     name: 'goods-coupon-list',
-    data() {
-        return {
-            couponList: [
-                {
-                    id: 1,
-                    name: '满300减60'
-                },
-                {
-                    id: 2,
-                    name: '满300减60'
-                },
-                {
-                    id: 3,
-                    name: '满300减60'
-                },
-                {
-                    id: 4,
-                    name: '满300减60'
-                }
-            ]
+    props: {
+        couponList: {
+            type: [Object, Array],
+            default: null
         }
     }
 }

+ 8 - 20
pages/views/goods/components/goods-coupon-section/goods-coupon-section.vue

@@ -1,10 +1,10 @@
 <template>
-    <view class="goods-coupon-section">
-        <view class="section">
+    <view class="goods-coupon-section" v-if="couponList">
+        <view class="section" @click="$emit('click')">
             <view class="label">优惠券:</view>
             <view class="coupon-tags">
                 <template v-for="(item, index) in couponList">
-                    <view class="tag" v-text="item.name" v-if="index < 2" :key="item.id"></view>
+                    <view class="tag" v-text="item.couponTitle" v-if="index < 2" :key="item.couponId"></view>
                 </template>
                 <text class="ellipsis" v-if="couponList.length > 2">...</text>
             </view>
@@ -15,23 +15,11 @@
 
 <script>
 export default {
-    name:'goods-coupon-section',
-    data() {
-        return {
-            couponList: [
-                {
-                    id: 1,
-                    name: '满300减60'
-                },
-                {
-                    id: 2,
-                    name: '满300减60'
-                },
-                {
-                    id: 3,
-                    name: '满300减60'
-                }
-            ]
+    name: 'goods-coupon-section',
+    props: {
+        couponList: {
+            type: [Object, Array],
+            default: null
         }
     }
 }

+ 20 - 9
pages/views/goods/components/goods-info/goods-info.vue

@@ -1,25 +1,25 @@
 <template>
-    <view class="goods-info">
+    <view class="goods-info" v-if="productData">
         <view class="row">
             <!-- 名称 -->
-            <view class="name">肌本演绎360愉悦修护套组标准版防晒修复补水保湿</view>
+            <view class="name" v-text="productData.name"></view>
             <!-- 分割线 -->
             <view class="dashed"></view>
             <!-- 分享 -->
             <button class="share" @click="$emit('share')">
-                <text class="iconfont icon-fenxiang"></text> <text class="text">分享</text>
+                <text class="iconfont icon-fenxiang"></text>
+                <text class="text">分享</text>
             </button>
         </view>
-        <view class="row">
+        <view class="row" v-if="tagList.length > 0">
             <!-- 标签 -->
             <view class="goods-tags">
-                <view class="tag">韩国恩盛</view> <view class="tag">水光柔皮肤</view> <view class="tag">补水保湿</view>
-                <view class="tag">爽皮肤</view>
+                <view class="tag" v-for="(item, index) in tagList" :key="index">{{ item }}</view>
             </view>
         </view>
-        <view class="row">
+        <view class="row" v-if="recommend">
             <!-- 备注 -->
-            <view class="remark">快递请发中通快递,谢谢!</view>
+            <view class="remark" v-text="recommend"></view>
         </view>
         <tui-divider :height="48"></tui-divider>
         <view class="row">
@@ -35,7 +35,18 @@
 
 <script>
 export default {
-    name: 'goods-info'
+    name: 'goods-info',
+    props: {
+        productData: {
+            type: Object,
+            default: () => null
+        }
+    },
+    computed: {
+        tagList() {
+            return this.productData.tagsList || []
+        }
+    }
 }
 </script>
 

+ 15 - 22
pages/views/goods/components/goods-params-section/goods-params-section.vue

@@ -1,7 +1,11 @@
 <template>
-    <view class="params-section">
+    <view class="params-section" v-if="paramList">
         <view class="section" @click="onShowDetail">
-            <view class="label">参数:</view> <view class="list"><text>品牌</text><text>分类...</text></view>
+            <view class="label">参数:</view>
+            <view class="list">
+                <text>品牌</text>
+                <text>分类...</text>
+            </view>
             <view class="iconfont icon-chakangengduo"></view>
         </view>
         <uni-popup ref="popup" type="bottom">
@@ -10,9 +14,9 @@
                 <view class="title">商品参数</view>
                 <view class="content">
                     <view class="params-list">
-                        <view class="row" v-for="(item, index) in params" :key="index">
-                            <text class="label" v-text="item.name"></text>
-                            <text class="content" v-text="item.content"></text>
+                        <view class="row" v-for="item in paramList" :key="item.id">
+                            <text class="label" v-text="item.paramsName"></text>
+                            <text class="content" v-text="item.paramsContent"></text>
                         </view>
                     </view>
                     <tui-button
@@ -22,8 +26,9 @@
                         @click="$refs.popup.close()"
                         shape="circle"
                         :size="26"
-                        >了解</tui-button
                     >
+                        了解
+                    </tui-button>
                 </view>
             </view>
         </uni-popup>
@@ -34,22 +39,10 @@
 import { mapGetters } from 'vuex'
 export default {
     name: 'goods-params-section',
-    data() {
-        return {
-            params: [
-                {
-                    name: '品牌',
-                    content: '新测试品牌'
-                },
-                {
-                    name: '包装规格',
-                    content: '台'
-                },
-                {
-                    name: '库存',
-                    content: '100'
-                }
-            ]
+    props: {
+        paramList: {
+            type: [Array, Object],
+            default: null
         }
     },
     computed: {

+ 38 - 19
pages/views/goods/components/goods-price/goods-price.vue

@@ -1,26 +1,33 @@
 <template>
-    <view class="goods-price">
+    <view class="goods-price" v-if="productData">
         <view class="row">
-            <view class="price"> <text class="amount">9999.00</text> <text class="delete">12888.00</text> </view>
+            <view class="price">
+                <text class="amount">{{ productData.price | priceFormat }}</text>
+                <text class="delete">{{ productData.normalPrice | priceFormat }}</text>
+            </view>
             <view class="price-tags">
-                <!-- <view class="tag-pt">拼团价</view> 
-                <view class="tag-hd">活动价</view> -->
-                <view class="tag-xs">限时特价</view>
+                <template v-if="priceType !== 'normal'">
+                    <view class="tag-pt" v-if="priceType === 'group'">拼团价</view>
+                    <view class="tag-hd" v-else-if="priceType === 'activity'">活动价</view>
+                    <view class="tag-xs" v-else>限时特价</view>
+                </template>
             </view>
         </view>
-        <view class="row">
+        <view class="row" v-if="hasCouponPrice">
             <!-- 券后价 -->
-            <view class="tag-qh">券后价¥6000.00</view>
+            <view class="tag-qh">券后价¥{{ productData.couponPrice | priceFormat }}</view>
         </view>
 
         <!-- 限时特价结束时间 -->
-        <view class="countdown-box">
+        <view class="countdown-box" v-if="priceType === 'time-limit'">
             <view class="tip">距离结束</view>
             <view class="time">
                 <!-- 时 -->
-                <text class="hh">72</text>:
+                <text class="hh">72</text>
+                :
                 <!-- 分 -->
-                <text class="mm">48</text>:
+                <text class="mm">48</text>
+                :
                 <!-- 秒 -->
                 <text class="ss">33</text>
             </view>
@@ -32,17 +39,29 @@
 export default {
     name: 'goods-price',
     props: {
-        priceType: {
-            type: String,
-            default: 'normal',
-            validator: value => {
-                /* normal: 普通价 | group: 拼团价 | activity: 活动价 | time-limit: 限时特价 | */
-                return ['normal', 'group', 'activity', 'time-limit'].indexOf(value) > -1
-            }
-        },
         productData: {
             type: Object,
-            default: () => {}
+            default: () => null
+        }
+    },
+    computed: {
+        /* 商品价格类型 normal: 普通价 | group: 拼团价 | activity: 活动价 | time-limit: 限时特价 | */
+        priceType() {
+            let type
+            if (this.productData.activeStatus > 0) {
+                type = 'activity'
+            } else if (this.productData.collageStatus > 0) {
+                type = 'group'
+            } else if (this.productData.discountStatus > 0) {
+                type = 'time-limit'
+            } else {
+                type = 'normal'
+            }
+            return type
+        },
+        // 有可使用优惠券
+        hasCouponPrice() {
+            return this.couponStatus > 0
         }
     }
 }

+ 44 - 9
pages/views/goods/components/goods-receive-buy-pupup/goods-receive-buy-pupup.vue → pages/views/goods/components/goods-receive-buy-popup/goods-receive-buy-popup.vue

@@ -1,11 +1,11 @@
 <template>
-    <view class="goods-receive-buy-pupup">
+    <view class="goods-receive-buy-pupup" v-if="productData">
         <uni-popup ref="popup" type="bottom">
             <view class="close iconfont icon-iconfontguanbi" @click="close"></view>
-            <view class="popup-content" :style="{ paddingBottom: safeArea ? 0: '40rpx' }">
+            <view class="popup-content" :style="{ paddingBottom: safeArea ? 0 : '40rpx' }">
                 <view class="content">
                     <!-- 商品图片 -->
-                    <image src="https://picsum.photos/180/180" class="cover"></image>
+                    <image :src="productData.mainImage" class="cover"></image>
                     <view class="info">
                         <!-- 数量 -->
                         <view class="row">
@@ -13,16 +13,35 @@
                                 <view class="label">数量</view>
                                 <cm-number-box class="number-box" v-model="count"></cm-number-box>
                             </view>
-                            <view class="clickable" @click="$emit('detail')">查看活动价</view>
+                            <view
+                                class="clickable"
+                                @click="$emit('detail')"
+                                v-if="productData.activeStatus > 0 && productData.ladderList.length > 0"
+                            >
+                                查看活动价
+                            </view>
                         </view>
                         <!-- 单价 -->
-                        <view class="row"> <view class="label">单价</view> <view class="amount">5000.00</view> </view>
+                        <view class="row">
+                            <view class="label">单价</view>
+                            <view class="amount">{{ productData.price | priceFormat }}</view>
+                        </view>
                         <!-- 券后价 -->
-                        <view class="row"> <view class="tag-qh">券后价¥6000.00</view> </view>
+                        <view class="row" v-if="productData.couponStatus > 0">
+                            <view class="tag-qh">券后价¥{{ productData.couponPrice | priceFormat }}</view>
+                        </view>
                     </view>
                 </view>
-                <view class="tip">当前商品可使用<text>满199元减20</text>优惠券</view>
-                <tui-button type="base" width="600rpx" height="90rpx" shape="circle">领券购买</tui-button>
+                <view class="tip">
+                    <template v-if="productData.couponStatus > 1">
+                        当前商品可使用
+                        <text v-text="currentCoupon.couponTitle"></text>
+                        优惠券
+                    </template>
+                </view>
+                <tui-button type="base" width="600rpx" height="90rpx" shape="circle" @click="$emit('submit', count)">
+                    {{ navbarType === 'buy' ? (productData.couponStatus > 0 ? '领券购买' : '立即购买') : '加入购物车' }}
+                </tui-button>
             </view>
         </uni-popup>
     </view>
@@ -32,7 +51,21 @@
 import { mapGetters } from 'vuex'
 export default {
     name: 'goods-receive-buy-pupup',
-    data() { 
+    props: {
+        productData: {
+            type: Object,
+            default: () => null
+        },
+        currentCoupon: {
+            type: Object,
+            default: () => null
+        },
+        navbarType: {
+            type: String,
+            default: 'buy'
+        }
+    },
+    data() {
         return {
             count: 1
         }
@@ -49,10 +82,12 @@ export default {
         open() {
             this.$refs.popup.open()
             this.$emit('open')
+            this.count = 1
         },
         close() {
             this.$refs.popup.close()
             this.$emit('close')
+            this.count = 1
         }
     }
 }

+ 3 - 3
pages/views/goods/config/config.js

@@ -12,13 +12,13 @@ export const navbarButtonGroup = {
         right: ['拼团购买', '¥1000.00']
     },
 
-    // 限时活动
-    timeLimit: {
+    // 限时活动 / 活动价 + 优惠券
+    activity: {
         left: ['加入购物车'],
         right: ['领券购买', '¥1000.00']
     },
 
-    // 普通方式
+    // 普通方式 不使用优惠券
     normal: {
         left: ['加入购物车'],
         right: ['立即购买']

+ 223 - 39
pages/views/goods/goods-detail.vue

@@ -11,19 +11,27 @@
         <!-- 轮播 -->
         <goods-image-swiper :list="imageList" @click="onSwiperClick" @change="onSwiperChange"></goods-image-swiper>
         <!-- 价格 -->
-        <goods-price></goods-price>
+        <goods-price :productData="productInfo"></goods-price>
 
         <!-- 活动优惠券 -->
-        <goods-coupon-list></goods-coupon-list>
+        <goods-coupon-list
+            @click="couponVisiable = true"
+            :couponList="couponList"
+            v-if="couponList.length > 0"
+        ></goods-coupon-list>
 
         <!-- 商品基本信息:商品名称 && 分享 && 标签 && 备注 && 服务-->
-        <goods-info @share="onShare"></goods-info>
+        <goods-info @share="onShare" :productData="productInfo"></goods-info>
 
         <!-- 参数 -->
-        <view class="section"><goods-params-section></goods-params-section></view>
+        <view class="section" v-if="productInfo.parametersList.length > 0">
+            <goods-params-section :paramList="productInfo.parametersList"></goods-params-section>
+        </view>
 
         <!-- 优惠券 -->
-        <view class="section"><goods-coupon-section></goods-coupon-section></view>
+        <view class="section" v-if="couponList.length > 0">
+            <goods-coupon-section @click="couponVisiable = true" :couponList="couponList"></goods-coupon-section>
+        </view>
 
         <!-- 锚点1 -->
         <view id="anchor-1" class="anchor"></view>
@@ -31,8 +39,9 @@
         <!-- 商品详情 -->
         <view class="section detail">
             <view class="title">商品详情</view>
+            <view v-if="productDetail && productDetail.detailInfo" v-html="productDetail.detailInfo"></view>
             <!-- 空 -->
-            <view class="section-empty">暂无商品详情</view>
+            <view class="section-empty" v-else>暂无商品详情</view>
         </view>
 
         <!-- 锚点2 -->
@@ -41,6 +50,7 @@
         <!-- 服务项目 -->
         <view class="section service-items">
             <view class="title">服务项目</view>
+            <view v-if="productDetail && productDetail.serviceInfo" v-html="productDetail.serviceInfo"></view>
             <!-- 空 -->
             <view class="section-empty">暂无服务项目</view>
         </view>
@@ -63,9 +73,6 @@
             </template>
         </goods-navbar>
 
-        <!-- 安全区域 -->
-        <cm-safe-area-bottom></cm-safe-area-bottom>
-
         <!-- 活动价 -->
         <goods-activity-popup
             ref="activitypPopup"
@@ -75,9 +82,28 @@
         ></goods-activity-popup>
 
         <!-- 领券购买 -->
-        <goods-receive-buy-pupup ref="receiveBuyPopup" @detail="$refs.activitypPopup.open()"></goods-receive-buy-pupup>
+        <goods-receive-buy-popup
+            ref="receiveBuyPopup"
+            :productData="productInfo"
+            :currentCoupon="currentCoupon"
+            :navbarType="navbarTypeFlag"
+            @detail="$refs.activitypPopup.open()"
+            @submit="onSubmit"
+        ></goods-receive-buy-popup>
         <!-- 分享弹窗 -->
         <cm-share-popup ref="sharePopup" :data="posterData" type="product"></cm-share-popup>
+
+        <!-- 优惠券弹窗 -->
+        <cm-coupon-popup
+            :list="couponList"
+            :visiable="couponVisiable"
+            :hasSafeArea="true"
+            @close="couponVisiable = false"
+            @couponClick="onCouponClick"
+        ></cm-coupon-popup>
+
+        <!-- 安全区域 -->
+        <cm-safe-area-bottom></cm-safe-area-bottom>
     </view>
 </template>
 
@@ -86,41 +112,52 @@
 import { navbarButtonGroup } from './config/config.js'
 import { debounce } from '@/common/utils.js'
 import { shareDataResult } from '@/common/share.helper.js'
-import { mapGetters } from 'vuex'
+import { fetchProductDetail } from '@/services/api/goods.js'
+import { fetchCouponListByProductId } from '@/services/api/coupon.js'
+import { mapGetters, mapActions } from 'vuex'
 export default {
     data() {
         return {
-            jumpState: 0,
             isRequest: true,
+            jumpState: 0,
+            productId: '',
             // 轮播图
             currentTab: 0,
-            imageList: ['https://picsum.photos/1000/1000?random=1', 'https://picsum.photos/1000/1000?random=2'],
-            navbarType: 'groupByCoupon',
             leftButton: {},
             rightButton: {},
-            ladderList: [
-                {
-                    buyPrice: '2000',
-                    buyNum: 1
-                },
-                {
-                    buyPrice: '2000',
-                    buyNum: 2
-                },
-                {
-                    buyPrice: '2000',
-                    buyNum: 3
-                }
-            ],
             // 锚点列表
             anchorList: [],
             scorllTop: 0,
             productInfo: {},
+            couponList: [],
+            couponVisiable: false,
+            navbarTypeFlag: '',
+            // 海报数据
             posterData: {}
         }
     },
     computed: {
-        ...mapGetters(['userId'])
+        ...mapGetters(['userId']),
+        // 轮播图
+        imageList() {
+            return this.productInfo.imageList
+        },
+        // 活动价
+        ladderList() {
+            return this.productInfo.ladderList
+        },
+        // 商品详情
+        productDetail() {
+            return this.productInfo.productDetail
+        },
+        // 商品导航类型
+        navbarType() {
+            return this.generateNavbarType()
+        },
+        // 当前商品默认可以使的优惠券
+        currentCoupon() {
+            return this.couponList.find(coupon => coupon.couponId === this.productInfo.couponId)
+        }
     },
     onPageScroll(e) {
         this.scorllTop = e.scrollTop
@@ -135,11 +172,82 @@ export default {
         }
         return shareDataResult(shareData, this.productInfo.name, this.imageList[0])
     },
-    onLoad() {
-        this.initNavbarButton()
-        setTimeout(() => (this.isRequest = false), 2000)
+    onLoad(options) {
+        this.productId = parseInt(options.productId)
+        this.jumpState = parseInt(options.jumpState)
+        this.fetchProductDetail()
     },
     methods: {
+        ...mapActions('cart', ['addToCart']),
+
+        // 立即购买
+        buyNow(count) {
+            let productStp = {
+                productCount: count,
+                productId: this.productInfo.productId,
+                heUserId: this.productInfo.heUserId,
+                collageFlag: 0,
+                collageId: 0,
+                allCount: count
+            }
+            uni.setStorageSync('COMMIT_PRODUCT_INFO', productStp)
+            this.toCreateOrder()
+        },
+
+        // 拼团购买
+        buyGroupNow(count) {
+            console.log('拼团购买')
+            let productStp = {
+                productCount: count,
+                productId: this.productInfo.productId,
+                heUserId: this.productInfo.heUserId,
+                collageFlag: 1,
+                collageId: 0,
+                allCount: count
+            }
+            uni.setStorageSync('COMMIT_PRODUCT_INFO', productStp)
+            this.toCreateOrder()
+        },
+
+        // 跳转到创建订单
+        toCreateOrder() {
+            this.$router.navigateTo('order/order-create?type=product')
+        },
+
+        // 商品提交
+        onSubmit(count) {
+            console.log(count)
+            if (this.navbarTypeFlag === 'cart') {
+                this.addToCart({
+                    productId: this.productInfo.productId,
+                    productCount: count,
+                    heUserId: this.productInfo.heUserId
+                })
+                return this.$refs.receiveBuyPopup.close()
+            }
+
+            if (this.navbarTypeFlag === 'buy') {
+                if (this.productInfo.collageStatus > 0) {
+                    this.buyGroupNow(count)
+                } else {
+                    this.buyNow(count)
+                }
+                return this.$refs.receiveBuyPopup.close()
+            }
+        },
+
+        // 优惠券点击事件
+        onCouponClick(couponData) {
+            const coupon = { ...couponData }
+            if (coupon.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)
+            }
+        },
+
         // 分享事件
         onShare() {
             this.posterData = {
@@ -150,6 +258,7 @@ export default {
             }
             this.$refs.sharePopup.open()
         },
+
         // 轮播图事件
         onSwiperClick() {
             uni.previewImage({
@@ -158,23 +267,31 @@ export default {
                 loop: true
             })
         },
+
         // 轮播图切换
         onSwiperChange(current) {
             this.current = current
         },
-        // 初始化导航按钮
+
+        // 初始化导航按钮文案
         initNavbarButton() {
             const navbarButton = navbarButtonGroup[this.navbarType]
-            console.log(navbarButton)
+            // 拼团商品 + 其他商品
+            if (this.navbarType === 'groupByCoupon') {
+                navbarButton.left[1] = `¥${this.productInfo.normalCouponPrice.toFixed(2)}`
+            } else {
+                navbarButton.right[1] = `¥${this.productInfo.couponPrice.toFixed(2)}`
+            }
             this.leftButton = navbarButton.left
             this.rightButton = navbarButton.right
         },
+
         // 导航菜单右侧按钮点击
         navbarRightClick(index) {
-            if (this.navbarType !== 'normal') {
-                this.$refs.receiveBuyPopup.open()
-            }
+            this.navbarTypeFlag = index > 0 || this.productInfo.collageStatus > 0 ? 'buy' : 'cart'
+            this.$refs.receiveBuyPopup.open()
         },
+
         // 导航栏菜单左侧按钮点击
         navbarLeftClick(index) {
             if (index === 0) {
@@ -184,6 +301,7 @@ export default {
                 this.$router.navigateTo('cart/cart')
             }
         },
+
         // 顶部tab切换
         onTabChange(index) {
             // const selector = `.product-detail #anchor-${index}`
@@ -193,6 +311,7 @@ export default {
                 duration: 300
             })
         },
+
         // 初始化锚点
         getAnchorList: debounce(
             function() {
@@ -202,13 +321,13 @@ export default {
                     .boundingClientRect(data => {
                         this.anchorList = data
                         this.setCurrentTabIndex()
-                        console.log(this.anchorList)
                     })
                     .exec()
             },
             300,
             false
         ),
+
         // 设置tab索引
         setCurrentTabIndex() {
             this.anchorList.forEach((item, index) => {
@@ -216,6 +335,72 @@ export default {
                     this.currentTab = index
                 }
             })
+        },
+
+        // 获取商品详情
+        async fetchProductDetail() {
+            try {
+                const res = await fetchProductDetail({ productId: this.productId, userId: this.userId })
+                this.productInfo = res.data
+                this.isRequest = false
+                this.productInfo.heUserId = this.jumpState === 1 ? 0 : this.userId
+                this.initNavbarButton()
+                this.fetchCouponList()
+            } catch (e) {
+                console.log(e)
+                console.log('获取商品详情失败')
+            }
+        },
+
+        // 生成导航菜单类型
+        generateNavbarType() {
+            const { couponStatus = 0, collageStatus = 0, activeStatus = 0, discountStatus = 0 } = this.productInfo
+            if ((activeStatus > 0 || discountStatus > 0) && couponStatus > 0) {
+                // (限时活动 / 活动价) + 优惠券
+                return 'activity'
+            } else if (collageStatus > 0) {
+                if (couponStatus > 0) {
+                    // 拼团 + 优惠券
+                    return 'groupByCoupon'
+                } else {
+                    // 仅拼团
+                    return 'group'
+                }
+            } else {
+                // 无优惠券
+                return 'normal'
+            }
+        },
+
+        // 创建优惠券
+        generateCoupon(coupon) {
+            const obj = Object.assign({}, coupon)
+            // 添加标题
+            if (coupon.noThresholdFlag > 0) {
+                obj.couponTitle = `减${coupon.couponAmount}`
+            } else {
+                obj.couponTitle = `满${coupon.touchPrice}减${coupon.couponAmount}`
+            }
+            // 添加优惠券状态
+            if (obj.useStatus === 0) {
+                obj.controlType = 'receive'
+            } else if (obj.useStatus === 1) {
+                obj.couponStatus = 'received'
+                obj.controlType = 'search'
+            }
+            return obj
+        },
+
+        // 获取商品可用优惠券
+        async fetchCouponList() {
+            try {
+                const res = await fetchCouponListByProductId({ productId: this.productId, userId: this.userId })
+                this.couponList = res.data.map(coupon => this.generateCoupon(coupon))
+            } catch (e) {
+                //TODO handle the exception
+                console.log(e)
+                console.log('获取优惠券列表失败')
+            }
         }
     }
 }
@@ -246,7 +431,6 @@ export default {
         }
 
         .section-empty {
-            height: 1200rpx;
             font-size: 24rpx;
             color: #999;
         }

+ 1 - 1
pages/views/order/components/order-supplier-area/order-supplier-area.vue

@@ -3,7 +3,7 @@
         <!-- 供应商信息 -->
         <view class="area-top">
             <image class="shop-logo" :src="shopData.logo" mode="widthFix"></image>
-            <view class="shop-name" v-text="shopData.name">你好吗,你快乐吗</view>
+            <view class="shop-name" v-text="shopData.name"></view>
         </view>
         <!-- 商品列表 -->
         <view class="product" v-for="product in shopData.productList" :key="product.productId">