1222 行
32 KiB
Vue
1222 行
32 KiB
Vue
<!-- 商品详情 -->
|
||
<template>
|
||
<view class="detail-wrap ">
|
||
<!-- 标题栏 -->
|
||
<view class="nav-box" style="padding-bottom: 20rpx;transition: .3s ease-in-out;" :style="[...navStyle]">
|
||
<view class="state-hack"></view>
|
||
<view :style="{ height: navbarHeight + 'px' }"
|
||
style="display: flex;flex-direction: column;justify-content: flex-end;box-sizing: content-box;">
|
||
<view class="" style="display: flex;align-items: center;">
|
||
<template>
|
||
<view hover-class="back-hover" class="u-m-x-30 u-flex u-row-center u-col-center" @tap="goBack"
|
||
v-if="fixedMode">
|
||
<view class="u-iconfont uicon-arrow-left" style="color: #333;font-size: 28rpx;"></view>
|
||
</view>
|
||
<view hover-class="back-hover" class="back-box u-m-x-30 u-flex u-row-center u-col-center"
|
||
@tap="goBack" v-else>
|
||
<view class="u-iconfont uicon-arrow-left" style="color: #fff;font-size: 28rpx;"></view>
|
||
</view>
|
||
</template>
|
||
<view class="" style="display: flex;align-items: center;gap: 0 60rpx;padding-left: 30rpx;"
|
||
v-if="fixedMode">
|
||
<view v-for="(nav,index) in navList" :class="curNavIndex == index && 'nav-item-active'"
|
||
@tap="handleNavClick(nav,index)">{{nav.name}}</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="tool-button">
|
||
<view style="margin-right: 30rpx;" class="tools-item u-flex-col u-row-center u-col-center"
|
||
@tap="onFavorite(goodsInfo.id)">
|
||
<u-icon :name="Boolean(goodsInfo.favorite) ? 'star-fill' : 'star'" :size="40"
|
||
:color="Boolean(goodsInfo.favorite) ? '#1677FF' : '#666666'"></u-icon>
|
||
<text class="tool-title">收藏</text>
|
||
</view>
|
||
<view class="tools-item u-flex-col u-row-center u-col-center" @tap="onShare">
|
||
<u-icon name="share" size="40" color="#666666"></u-icon>
|
||
<text class="tool-title">分享</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- 缺省页 -->
|
||
<shopro-empty v-if="showEmpty" :image="$IMG_URL + '/imgs/empty/empty_goods_null.png'" :tipText="showEmptyText"
|
||
btnText="返回上一页" @click="$Router.back()"></shopro-empty>
|
||
<view class="detail_box" v-else>
|
||
<view class="detail-content">
|
||
<view class="" id="goods">
|
||
<swiper :indicator-dots="true" @change="changeSwiper" :autoplay="autoplay" :interval="3000"
|
||
:duration="1000" style="height: 750rpx;">
|
||
<swiper-item style="width: 100%;height: 100%;" v-for="(item,index) in goodsInfo.images">
|
||
<view class="swiper-item" style="width: 100%;height: 100%;">
|
||
<image :src="item.src" mode="aspectFill" v-if="item.type == 0 && detailType != 'score'">
|
||
</image>
|
||
<image :src="item" mode="aspectFill" v-if="detailType == 'score'"></image>
|
||
<view @tap="playVideo(index)" class=""
|
||
style="width: 100%;height: 100%;position: relative;" v-if="item.type == 1">
|
||
<video :controls="true" :show-center-play-btn="false" :show-play-btn="false"
|
||
:id="'myVideo'+index" :src="item.src" style="width: 100%;height: 100%;"></video>
|
||
<view v-if="is_play != 'play'" @tap.stop="playVideo(index)" class=""
|
||
style="justify-content: center;width:90rpx;display: flex;align-items:center;height:90rpx;background-color: #fff;position: absolute;left: calc(100% / 2 - 45rpx);top: calc(100% / 2 - 45rpx);border-radius: 45rpx;">
|
||
<u-icon name="play-circle-fill" size="90" color="#1677FF"></u-icon>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</swiper-item>
|
||
</swiper>
|
||
|
||
<!-- 价格卡片组 -->
|
||
<sh-price-card v-if="goodsInfo.id" :detail="goodsInfo" :type="detailType"
|
||
@change="getActivityRules"></sh-price-card>
|
||
|
||
<!-- 标题 -->
|
||
<view
|
||
style="width: 100%;padding-left: 20rpx;padding-right: 20rpx;box-sizing: border-box;margin-top: 20rpx;">
|
||
<view class="u-m-b-10 title-box u-p-20 u-skeleton-fillet">
|
||
<view class="goods-title u-m-b-10 u-ellipsis-2">{{ goodsInfo.title }}</view>
|
||
<view class="sub-title u-ellipsis-2">{{ goodsInfo.subtitle }}</view>
|
||
<view v-show="goodsInfo.activity_type === 'robbuy'" class="rob" style="margin-top: 20rpx;">
|
||
<view class="text-wrapper_9">
|
||
<text class="text_19">抢购流程</text>
|
||
</view>
|
||
<view style="margin-top: 10rpx;">
|
||
<u-steps :list="numList" mode="number" active-color="#1677FF"></u-steps>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 参与的活动 -->
|
||
<sh-activity v-if="goodsInfo.activity_discounts_tags && goodsInfo.activity_discounts_tags.length"
|
||
:detail="goodsInfo.activity_discounts"></sh-activity>
|
||
|
||
<!-- 规格选择 -->
|
||
<view class="sku-box" @tap="showSku = true"
|
||
v-if="activityRules.status !== 'waiting' && checkActivity(goodsInfo.activity_type, 'groupon') && goodsInfo.is_sku">
|
||
<view class="u-flex u-row-between u-col-center">
|
||
<view class="u-flex">
|
||
<text class="title">规格</text>
|
||
<text class="tip">{{ currentSkuText || '请选择规格' }}</text>
|
||
</view>
|
||
<text class="u-iconfont uicon-arrow-right" style="color: #bfbfbf;"></text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 参数 -->
|
||
<sh-params v-if="goodsInfo.params && goodsInfo.params.length" v-model="showParams"
|
||
:paramsList="goodsInfo.params">
|
||
</sh-params>
|
||
|
||
<!-- 服务 -->
|
||
<sh-serve v-if="goodsInfo.service && goodsInfo.service.length" v-model="showServe"
|
||
:serveList="goodsInfo.service"></sh-serve>
|
||
|
||
<!-- 优惠券 -->
|
||
<!-- <sh-coupon
|
||
v-if="goodsInfo.coupons && goodsInfo.coupons.length && goodsInfo.activity_type !== 'seckill' && goodsInfo.activity_type !== 'groupon' && detailType !== 'score'"
|
||
:couponList="goodsInfo.coupons"></sh-coupon> -->
|
||
<sh-coupon
|
||
v-if="goodsInfo.coupons && goodsInfo.coupons.length && goodsInfo.activity_type !== 'groupon' && detailType !== 'score'"
|
||
:couponList="goodsInfo.coupons"></sh-coupon>
|
||
|
||
<!-- 拼团人-->
|
||
<sh-groupon
|
||
v-if="false && goodsInfo.activity && goodsInfo.activity.type === 'groupon' && goodsInfo.activity.rules.team_card === '1' && detailType !== 'score'"
|
||
:grouponData="goodsInfo"></sh-groupon>
|
||
|
||
<!-- 拼团玩法 -->
|
||
<view
|
||
v-if="goodsInfo.activity && Number(goodsInfo.activity.richtext_id) && goodsInfo.activity_type !== 'seckill'"
|
||
class="groupon-play u-flex u-row-between u-p-l-20 u-p-r-20"
|
||
@tap="jump('/pages/public/richtext', { id: goodsInfo.activity.richtext_id })">
|
||
<view class="u-flex">
|
||
<text class="title">玩法</text>
|
||
<view class="description u-ellipsis-1">
|
||
{{ goodsInfo.activity.richtext_title || '开团/参团·邀请好友·人满发货(不满退款' }}
|
||
</view>
|
||
</view>
|
||
<view class="u-iconfont uicon-arrow-right" style="color:#bfbfbf ;font-size: 28rpx;"></view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 选项卡 -->
|
||
<!-- <view class="tab-box u-flex">
|
||
<view class="tab-item u-flex-col u-row-center u-col-center" @tap="onTab(tab.id)"
|
||
v-for="tab in tabList" :key="tab.id">
|
||
<view class="tab-title">
|
||
{{ tab.title }}
|
||
<text v-if="tab.id == 'tab2'" class="comment-num">({{ commentNum }})</text>
|
||
</view>
|
||
<text class="tab-line" :class="{ 'line-active': tabCurrent === tab.id }"></text>
|
||
</view>
|
||
</view> -->
|
||
|
||
<!-- 评价 -->
|
||
<view class="" id="evaluate"
|
||
style="width: 100%;padding-left: 20rpx;padding-right: 20rpx;box-sizing: border-box;margin-bottom: 20rpx;">
|
||
<view class="goods-comment"
|
||
style="background-color: #fff;border-radius: 20rpx;padding: 24rpx;box-sizing: border-box;box-shadow: 0 4rpx 24rpx rgba(0,0,0,0.04);">
|
||
<view class="section-title">
|
||
用户评价
|
||
</view>
|
||
<block v-for="comment in commentList" :key="comment.id"><sh-comment
|
||
:comment="comment"></sh-comment></block>
|
||
<shopro-empty v-show="!commentList.length" marginTop="20rpx"
|
||
:image="$IMG_URL + '/imgs/empty/comment_empty.png'" tipText="暂无评价~"></shopro-empty>
|
||
<view class="more-box u-flex u-row-center u-col-center" v-show="commentNum > 3">
|
||
<button class="u-reset-button more-btn u-flex u-row-center u-col-center"
|
||
@tap="jump('/pages/goods/comment/comment-list', { goodsId: goodsInfo.id })">
|
||
查看全部
|
||
<view class="u-iconfont uicon-arrow-right" style="color:#1677FF ;font-size: 28rpx;">
|
||
</view>
|
||
</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view id="detail" class="tab-detail u-p-20 u-m-b-10"
|
||
style="margin-bottom: 100rpx !important;border-radius: 20rpx;">
|
||
<view class="section-title">
|
||
商品详情
|
||
</view>
|
||
<!-- 详情富文本 -->
|
||
<view class="rich-box ">
|
||
<u-parse :html="goodsInfo.content"></u-parse>
|
||
</view>
|
||
<!-- 参数 -->
|
||
<!-- <view class="goods-size">
|
||
<view class="table-box" v-if="goodsInfo.params && goodsInfo.params.length">
|
||
<view class="t-tr u-flex" v-for="t in goodsInfo.params" :key="t.title">
|
||
<view class="t-head u-flex">{{ t.title }}</view>
|
||
<view class="t-detail">{{ t.content }}</view>
|
||
</view>
|
||
</view>
|
||
</view> -->
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 商品foot -->
|
||
<view class="tabbar-foot safe-area-inset-bottom" v-if="goodsInfo.id">
|
||
<view class="detail-foot_box safe-area-inset-bottom u-flex u-col-center">
|
||
<!-- 左侧:首页 / 客服 / 购物车 -->
|
||
<view class="foot-left u-flex">
|
||
<view class="tools-item u-flex-col u-row-center u-col-center" @tap="goHome">
|
||
<u-icon name="home-fill" size="48" color="#2C2C2C"></u-icon>
|
||
<text class="tool-title">首页</text>
|
||
</view>
|
||
<block v-if="detailType !== 'score'">
|
||
<view @tap="openService" class="tools-item u-flex-col u-row-center u-col-center">
|
||
<u-icon name="kefu-ermai" size="48" color="#2C2C2C"></u-icon>
|
||
<text class="tool-title">客服</text>
|
||
</view>
|
||
<view @tap="handleToCart" class="tools-item u-flex-col u-row-center u-col-center tools-item--cart">
|
||
<u-icon name="shopping-cart-fill" size="48" color="#2C2C2C"></u-icon>
|
||
<text class="tool-title">购物车</text>
|
||
<view v-if="cartNum" class="cart-num">{{ cartNum }}</view>
|
||
</view>
|
||
</block>
|
||
</view>
|
||
<!-- 右侧:操作按钮 -->
|
||
<view class="foot-right">
|
||
<!-- 积分按钮 -->
|
||
<view class="detail-btn-box" v-if="detailType === 'score'"><button
|
||
class="u-reset-button score-btn" @tap="goPay">立即兑换</button></view>
|
||
<view v-if="detailType !== 'score'">
|
||
<!-- 正常按钮 -->
|
||
<view class="detail-btn-box u-flex u-row-around" v-if="!goodsInfo.activity_type">
|
||
<button class=" u-reset-button tool-btn add-btn" @tap="addCart">加入购物车</button>
|
||
<button class=" u-reset-button tool-btn pay-btn" @tap="goPay">立即购买</button>
|
||
</view>
|
||
<!-- 活动按钮 -->
|
||
<view class="detail-btn-box u-row-around"
|
||
v-if="activityRules.status && goodsInfo.activity_type">
|
||
<block v-if="goodsInfo.activity_type == 'robbuy'">
|
||
<button class=" u-reset-button seckilled-btn" v-if="activityRules.status !== 'ing'">
|
||
<text v-if="activityRules.status == 'waiting'">预约未开始</text>
|
||
</button>
|
||
<button @tap="handleRobOrder" class="u-reset-button seckill-btn"
|
||
v-if="activityRules.status === 'ing'">
|
||
立即预约
|
||
</button>
|
||
<button @tap="handleRob" class="u-reset-button seckill-btn"
|
||
v-if="activityRules.status === 'end'">
|
||
立即抢购
|
||
</button>
|
||
</block>
|
||
<block v-else>
|
||
<button class="u-reset-button seckilled-btn" v-if="activityRules.status !== 'ing'">
|
||
<text v-if="activityRules.status == 'waiting'">暂未开始</text>
|
||
<text v-if="activityRules.status == 'end'">已结束</text>
|
||
</button>
|
||
<block v-else>
|
||
<view class="v-btn" style="display: flex;margin-left: 20rpx;">
|
||
<button
|
||
v-if="goodsInfo.activity && (goodsInfo.activity.type === 'promote' || goodsInfo.activity.type === 'seckill' || goodsInfo.activity.type === 'timer')"
|
||
class="u-reset-button tool-btn add-btn" @tap="addCart">
|
||
加入购物车
|
||
</button>
|
||
<!-- 活动中,秒杀 -->
|
||
<button class=" u-reset-button seckill-btn"
|
||
v-if="goodsInfo.activity && goodsInfo.activity.type === 'seckill' || goodsInfo.activity.type === 'timer'"
|
||
@tap="goSeckill">
|
||
立即秒杀
|
||
</button>
|
||
<button class="u-reset-button promote-btn"
|
||
v-if="goodsInfo.activity && goodsInfo.activity.type === 'promote'"
|
||
@tap="goSeckill">
|
||
立即抢购
|
||
</button>
|
||
</view>
|
||
<!-- 活动中,拼团 -->
|
||
<view class="u-flex groupon-btn-box"
|
||
v-if="false && goodsInfo.activity && goodsInfo.activity.type === 'groupon'">
|
||
<button
|
||
class="tool-btn u-reset-button group-add-btn u-flex-col u-row-center u-col-center"
|
||
@tap="payGroupon" v-if="goodsInfo.activity.rules.is_alone === '1'">
|
||
<text class="price font-OPPOSANS">¥{{ goodsInfo.price }}</text>
|
||
<text class="price-title">单独购买</text>
|
||
</button>
|
||
<button
|
||
class=" tool-btn u-reset-button groupon-btn u-flex-col u-row-center u-col-center"
|
||
:style="goodsInfo.activity.rules.is_alone === '0' ? 'width:400rpx' : ''"
|
||
@tap="payGroupon('groupon')">
|
||
<text class="price font-OPPOSANS">¥{{ goodsInfo.groupon_price }}</text>
|
||
<text class="price-title">我要开团</text>
|
||
</button>
|
||
</view>
|
||
</block>
|
||
</block>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 规格弹窗:常驻挂载,由 v-model 控制显隐,避免真机 v-if 重建导致弹层异常 -->
|
||
<shopro-sku v-if="goodsInfo.id" v-model="showSku" :goodsInfo="goodsInfo"
|
||
:activityRules="activityRules"
|
||
:buyType="goodsInfo.activity_type == 'robbuy' || goodsInfo.activity_type == 'seckill' || goodsInfo.activity_type == 'timer' || detailType === 'score' ? 'buy' : buyType"
|
||
:grouponBuyType="grouponBuyType" :goodsType="detailType === 'score' ? 'score' : 'goods'"
|
||
@changeType="changeType" @getSkuText="getSkuText"></shopro-sku>
|
||
|
||
<!-- 分享组件 -->
|
||
<shopro-share v-model="showShare" :posterInfo="goodsInfo" :posterType="'goods'"></shopro-share>
|
||
<!-- 登录 -->
|
||
<shopro-auth-modal v-if="authType"></shopro-auth-modal>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
let systemInfo = uni.getSystemInfoSync();
|
||
import shActivity from './components/sh-activity.vue';
|
||
import shPriceCard from './components/sh-price-card.vue';
|
||
import shServe from './components/sh-serve.vue';
|
||
import shParams from './components/sh-parmas.vue';
|
||
import shGroupon from './components/sh-groupon.vue';
|
||
import shCoupon from './components/sh-coupon.vue';
|
||
import shComment from './components/sh-comment.vue';
|
||
import share from '@/shopro/share';
|
||
|
||
import {
|
||
mapMutations,
|
||
mapActions,
|
||
mapState,
|
||
mapGetters
|
||
} from 'vuex';
|
||
export default {
|
||
components: {
|
||
shServe,
|
||
shParams,
|
||
shPriceCard,
|
||
shGroupon,
|
||
shCoupon,
|
||
shComment,
|
||
shActivity
|
||
},
|
||
data() {
|
||
return {
|
||
numList: [{
|
||
name: '预约'
|
||
}, {
|
||
name: '抢购'
|
||
}, {
|
||
name: '下单'
|
||
}],
|
||
navList: [{
|
||
name: '商品',
|
||
id: 'goods'
|
||
}, {
|
||
name: '评价',
|
||
id: 'evaluate'
|
||
}, {
|
||
name: '详情',
|
||
id: 'detail'
|
||
}],
|
||
cartNum: 0,
|
||
myvideo: null,
|
||
// navbar
|
||
backIconName: 'arrow-left',
|
||
autoplay: true,
|
||
showSku: false, //是否显示规格弹窗
|
||
currentSkuText: '', //选中规格
|
||
detailType: '',
|
||
showShare: false,
|
||
buyType: 'sku',
|
||
is_play: 'stop',
|
||
grouponBuyType: 'alone', //拼团购买方式。
|
||
showEmpty: false,
|
||
showEmptyText: '',
|
||
showServe: false,
|
||
showParams: false,
|
||
goodsInfo: {},
|
||
commentList: [], //商品评价列表
|
||
commentNum: 0, //商品评价总数
|
||
favorite: false,
|
||
activityRules: {},
|
||
currentSkuList: [],
|
||
confirmGoodsInfo: {},
|
||
swiperCurrent: 0, //轮播下标
|
||
tabCurrent: 'tab0',
|
||
tabList: [{
|
||
id: 'tab0',
|
||
title: '商品详情'
|
||
},
|
||
{
|
||
id: 'tab1',
|
||
title: '规格参数'
|
||
},
|
||
{
|
||
id: 'tab2',
|
||
title: '用户评价'
|
||
}
|
||
],
|
||
navStyle: {
|
||
background: ''
|
||
},
|
||
curNavIndex: 0,
|
||
navClickFlag: false,
|
||
divInfo: [],
|
||
loadDivFlag: false,
|
||
fixedMode: false,
|
||
};
|
||
},
|
||
onPageScroll(e) {
|
||
if (e.scrollTop > 50) {
|
||
this.fixedMode = true
|
||
|
||
this.navStyle.background = '#fff'
|
||
} else {
|
||
this.navStyle.background = ''
|
||
this.fixedMode = false
|
||
}
|
||
if (!this.loadDivFlag) {
|
||
let curHeight = 0
|
||
for (let i in this.navList) {
|
||
let view = uni.createSelectorQuery().select("#" + this.navList[i].id)
|
||
view.fields({
|
||
size: true
|
||
}, data => {
|
||
this.divInfo.push(curHeight)
|
||
|
||
curHeight += i == 0 ? (data.height - 80) : data.height
|
||
}).exec()
|
||
}
|
||
this.loadDivFlag = true
|
||
}
|
||
|
||
// 不是点击标签定位的时候才判断当前在位置
|
||
if (!this.navClickFlag) {
|
||
if (e.scrollTop <= this.divInfo[1]) {
|
||
this.curNavIndex = 0
|
||
} else if (e.scrollTop > this.divInfo[1] && e.scrollTop <= this.divInfo[2]) {
|
||
this.curNavIndex = 1
|
||
} else {
|
||
this.curNavIndex = 2
|
||
}
|
||
}
|
||
},
|
||
|
||
// 是否登录
|
||
computed: {
|
||
...mapGetters(['isLogin', 'authType']),
|
||
navbarHeight() {
|
||
// #ifdef APP-PLUS || H5
|
||
return 48;
|
||
// #endif
|
||
// #ifdef MP
|
||
let height = systemInfo.platform == 'ios' ? 44 : 48;
|
||
return height;
|
||
// #endif
|
||
}
|
||
},
|
||
async onLoad() {
|
||
let that = this;
|
||
this.backIconName = getCurrentPages().length > 1 ? 'arrow-left' : 'home-fill';
|
||
const type = this.$Route.query.type;
|
||
this.detailType = type;
|
||
switch (type) {
|
||
case 'score':
|
||
await this.getScoreDetail();
|
||
break;
|
||
default:
|
||
await this.getGoodsDetail();
|
||
}
|
||
},
|
||
onUnload() {
|
||
share.setShareInfo();
|
||
},
|
||
methods: {
|
||
handleToCart() {
|
||
uni.switchTab({
|
||
url: '/pages/index/cart'
|
||
})
|
||
},
|
||
openService() {
|
||
// #ifdef MP-WEIXIN
|
||
wx.openCustomerServiceChat({
|
||
extInfo: {
|
||
url: 'https://work.weixin.qq.com/kfid/kfc5aec53d2111b588a' // 客服地址链接
|
||
},
|
||
corpId: 'wwc5f08e271cf73fb2', // 必须和你小程序上的一致
|
||
success(res) {
|
||
console.log(res, 1)
|
||
},
|
||
fail(res) {
|
||
console.log(res, 2)
|
||
},
|
||
})
|
||
// #endif
|
||
|
||
// #ifdef APP-PLUS
|
||
let wechat = null
|
||
plus.share.getServices(res => {
|
||
wechat = res.find(v => v.id === 'weixin')
|
||
if (wechat) {
|
||
wechat.openCustomerServiceChat({
|
||
corpid: 'wwc5f08e271cf73fb2', // 企业ID
|
||
url: 'https://work.weixin.qq.com/kfid/kfc5aec53d2111b588a', // 客服地址
|
||
}, res => {
|
||
console.log("success:", JSON.stringify(res))
|
||
}, err => {
|
||
console.log("error:", JSON.stringify(err))
|
||
})
|
||
} else {
|
||
uni.showToast({
|
||
title: '当前环境不支持微信操作',
|
||
icon: "error"
|
||
});
|
||
}
|
||
}, function() {
|
||
uni.showToast({
|
||
title: "获取服务失败,不支持该操作。" + JSON.stringify(e),
|
||
icon: 'none'
|
||
})
|
||
});
|
||
// #endif
|
||
},
|
||
handleNavClick(item, index) {
|
||
this.curNavIndex = index;
|
||
|
||
// 设置为点击标签定位
|
||
this.navClickFlag = true;
|
||
|
||
// 滚动位置+10,修复点击标签切换的时候无法选中正确的标签
|
||
uni.pageScrollTo({
|
||
scrollTop: parseInt(this.divInfo[index]) + parseInt(10)
|
||
});
|
||
|
||
// 500毫秒后释放
|
||
setTimeout(() => {
|
||
this.navClickFlag = false;
|
||
}, 500);
|
||
},
|
||
playVideo(index) {
|
||
if (this.is_play == 'stop' || this.is_play == 'pause') {
|
||
this.myvideo = uni.createVideoContext('myVideo' + index)
|
||
this.myvideo.play()
|
||
this.is_play = 'play'
|
||
this.autoplay = false
|
||
return false
|
||
}
|
||
if (this.is_play == 'play') {
|
||
this.myvideo.pause()
|
||
this.is_play = 'pause'
|
||
this.autoplay = true
|
||
return false
|
||
}
|
||
},
|
||
changeSwiper() {
|
||
if (this.myvideo) {
|
||
this.myvideo.stop()
|
||
this.myvideo = null
|
||
this.is_play = 'stop'
|
||
}
|
||
},
|
||
// goBack
|
||
// 微信直播商品跳转详情,需要用小程序原生接口才能返回。
|
||
goBack() {
|
||
let pageList = getCurrentPages();
|
||
if (pageList.length > 1) {
|
||
// #ifdef MP-WEIXIN
|
||
wx.navigateBack();
|
||
// #endif
|
||
// #ifndef MP-WEIXIN
|
||
uni.navigateBack();
|
||
// #endif
|
||
} else {
|
||
this.$Router.replaceAll('/pages/index/index');
|
||
}
|
||
},
|
||
|
||
// 轮播图预览
|
||
onGoodsSwiper(e) {
|
||
this.$tools.previewImage(this.goodsInfo.images, e);
|
||
},
|
||
getActivityRules(e) {
|
||
if (e) {
|
||
this.activityRules = JSON.parse(e);
|
||
}
|
||
},
|
||
// 检测
|
||
checkActivity(data, type) {
|
||
if (type === 'groupon') {
|
||
return false;
|
||
}
|
||
if (data) {
|
||
return !data.includes(type);
|
||
}
|
||
return true;
|
||
},
|
||
// 路由跳转
|
||
jump(path, parmas) {
|
||
this.showShare = false;
|
||
this.$Router.push({
|
||
path: path,
|
||
query: parmas
|
||
});
|
||
},
|
||
// 回到首页
|
||
goHome() {
|
||
this.$Router.replaceAll('/pages/index/index');
|
||
},
|
||
|
||
// 选项卡
|
||
onTab(id) {
|
||
this.tabCurrent = id;
|
||
},
|
||
// 积分详情
|
||
getScoreDetail() {
|
||
let that = this;
|
||
return new Promise((resolve, reject) => {
|
||
that.$http('goods.scoreDetail', {
|
||
id: that.$Route.query.id
|
||
}).then(res => {
|
||
if (res.code === 1) {
|
||
that.goodsInfo = res.data;
|
||
resolve(res.data);
|
||
}
|
||
if (res.code == 0) {
|
||
resolve(false);
|
||
that.$u.toast(res.msg);
|
||
}
|
||
});
|
||
});
|
||
},
|
||
// 商品详情
|
||
getGoodsDetail() {
|
||
let that = this
|
||
return new Promise((resolve, reject) => {
|
||
that.$http(
|
||
'goods.detail', {
|
||
id: that.$Route.query.id
|
||
},
|
||
'',
|
||
false
|
||
).then(res => {
|
||
if (res.code === 1) {
|
||
that.showEmpty = false;
|
||
|
||
let goods_data = res.data
|
||
let images_tem = []
|
||
if (goods_data.images.length > 0) {
|
||
goods_data.images.forEach((item, index) => {
|
||
let arr = item.split(".")
|
||
let inx = (arr.length - 1)
|
||
if (arr[inx] == "mp4") {
|
||
images_tem.push({
|
||
src: item,
|
||
type: 1
|
||
})
|
||
} else {
|
||
images_tem.push({
|
||
src: item,
|
||
type: 0
|
||
})
|
||
}
|
||
})
|
||
}
|
||
|
||
goods_data['images'] = images_tem
|
||
|
||
that.goodsInfo = goods_data;
|
||
that.cartNum = goods_data.cartNum;
|
||
if (that.goodsInfo.activity_type) {
|
||
that.activityRules.status = that.goodsInfo.activity.status_code;
|
||
}
|
||
share.setShareInfo({
|
||
title: that.goodsInfo.title,
|
||
desc: that.goodsInfo.subtitle,
|
||
image: that.goodsInfo.image,
|
||
params: {
|
||
page: 2,
|
||
pageId: that.$Route.query.id
|
||
}
|
||
});
|
||
that.getCommentList();
|
||
resolve(res.data);
|
||
} else {
|
||
resolve(false);
|
||
// that.$u.toast(res.msg);
|
||
that.showEmpty = true;
|
||
that.showEmptyText = res.msg;
|
||
}
|
||
});
|
||
});
|
||
},
|
||
// 商品评论
|
||
getCommentList() {
|
||
let that = this;
|
||
that.$http('goods.commentList', {
|
||
goods_id: that.goodsInfo.id,
|
||
per_page: 3,
|
||
type: 'all'
|
||
}).then(res => {
|
||
if (res.code === 1) {
|
||
that.commentList = res.data.data;
|
||
that.commentNum = res.data.total;
|
||
}
|
||
});
|
||
},
|
||
// 组件返回的type;
|
||
changeType(e) {
|
||
this.buyType = e;
|
||
},
|
||
// 组件返回的规格;
|
||
getSkuText(e) {
|
||
this.currentSkuText = e;
|
||
},
|
||
// 分享
|
||
onShare() {
|
||
this.showShare = true;
|
||
},
|
||
// 加入购物车
|
||
addCart() {
|
||
if (this.isLogin) {
|
||
this.buyType = 'cart';
|
||
this.showSku = true;
|
||
} else {
|
||
this.$store.dispatch('showAuthModal');
|
||
}
|
||
},
|
||
// 立即购买
|
||
goPay() {
|
||
if (this.isLogin) {
|
||
this.buyType = 'buy';
|
||
this.showSku = true;
|
||
} else {
|
||
this.$store.dispatch('showAuthModal');
|
||
}
|
||
},
|
||
// 拼团购买
|
||
payGroupon(type) {
|
||
if (type === 'groupon') {
|
||
uni.showToast({ title: '拼团功能已关闭', icon: 'none' });
|
||
return;
|
||
}
|
||
if (this.isLogin) {
|
||
if (type === 'groupon') {
|
||
this.grouponBuyType = 'groupon';
|
||
} else {
|
||
this.grouponBuyType = 'alone';
|
||
}
|
||
this.buyType = 'buy';
|
||
this.showSku = true;
|
||
} else {
|
||
this.$store.dispatch('showAuthModal');
|
||
}
|
||
},
|
||
// 预约抢购
|
||
handleRobOrder() {
|
||
if (!this.isLogin) {
|
||
this.$store.dispatch('showAuthModal');
|
||
return false;
|
||
}
|
||
|
||
let activity = this.goodsInfo.activity;
|
||
activity.goods_id = this.goodsInfo.id;
|
||
activity.price = this.goodsInfo.price;
|
||
|
||
this.$http('rob.order', {
|
||
activity,
|
||
}).then(res => {
|
||
if (res.code === 200) {
|
||
uni.showModal({
|
||
title: '恭喜您',
|
||
content: res.msg,
|
||
showCancel: false,
|
||
success: r => {
|
||
|
||
}
|
||
})
|
||
} else {
|
||
this.$u.toast(res.msg);
|
||
}
|
||
});
|
||
},
|
||
// 立即秒杀
|
||
handleRob() {
|
||
!this.isLogin ? this.$store.dispatch('showAuthModal') : (this.showSku = true);
|
||
this.buyType = 'buy';
|
||
},
|
||
// 立即秒杀
|
||
goSeckill() {
|
||
!this.isLogin ? this.$store.dispatch('showAuthModal') : (this.showSku = true);
|
||
this.buyType = 'buy';
|
||
},
|
||
// 收藏
|
||
onFavorite(goodsId) {
|
||
let that = this;
|
||
that.$http('goods.favorite', {
|
||
goods_id: goodsId
|
||
}).then(res => {
|
||
if (res.code === 1) {
|
||
that.goodsInfo.favorite = res.data;
|
||
that.$u.toast(res.msg);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
.detail-wrap {
|
||
background: $brand-page-bg;
|
||
min-height: 100vh;
|
||
}
|
||
|
||
.tool-button {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
justify-content: flex-end;
|
||
margin-right: 20rpx;
|
||
margin-top: 30rpx;
|
||
|
||
.tools-item {
|
||
|
||
.tool-img {
|
||
width: 46rpx;
|
||
height: 46rpx;
|
||
}
|
||
|
||
.tool-title {
|
||
font-size: 22rpx;
|
||
line-height: 22rpx;
|
||
padding-top: 8rpx;
|
||
color: $brand-text-muted;
|
||
}
|
||
}
|
||
}
|
||
|
||
.text_19 {
|
||
overflow-wrap: break-word;
|
||
color: rgba(102, 102, 102, 1);
|
||
font-size: 28rpx;
|
||
font-weight: normal;
|
||
text-align: left;
|
||
white-space: nowrap;
|
||
line-height: 40px;
|
||
}
|
||
|
||
.nav-item-active {
|
||
color: $brand-gold !important;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.section-title {
|
||
font-size: 32rpx;
|
||
font-weight: 600;
|
||
color: $brand-text;
|
||
line-height: 1.4;
|
||
margin-bottom: 16rpx;
|
||
}
|
||
|
||
// 标题栏
|
||
.nav-box {
|
||
position: fixed;
|
||
width: 100%;
|
||
min-height: 140rpx;
|
||
z-index: 888;
|
||
top: 0;
|
||
|
||
.back-box {
|
||
background-color: rgba(#000, 0.18);
|
||
width: 60rpx;
|
||
height: 60rpx;
|
||
border-radius: 50%;
|
||
margin-top: 14rpx;
|
||
}
|
||
|
||
.back-hover {
|
||
background-color: rgba(#fff, 0.18);
|
||
}
|
||
|
||
.state-hack {
|
||
width: 100%;
|
||
height: var(--status-bar-height);
|
||
/* #ifdef H5 */
|
||
height: 20rpx;
|
||
/* #endif */
|
||
}
|
||
}
|
||
|
||
// 拼团玩法
|
||
.groupon-play {
|
||
background: #fff;
|
||
line-height: 94rpx;
|
||
|
||
.title {
|
||
font-size: 28rpx;
|
||
color: #999;
|
||
}
|
||
|
||
.description {
|
||
font-size: 28rpx;
|
||
width: 500rpx;
|
||
margin-left: 30rpx;
|
||
}
|
||
}
|
||
|
||
// 选项卡
|
||
.tab-box {
|
||
height: 102rpx;
|
||
width: calc(100% - 40rpx);
|
||
margin-left: 20rpx;
|
||
background: #fff;
|
||
border-bottom: 1rpx solid rgba(#dfdfdf, 0.8);
|
||
margin-top: 10rpx;
|
||
|
||
.tab-item {
|
||
flex: 1;
|
||
height: 100%;
|
||
position: relative;
|
||
font-size: 30rpx;
|
||
font-weight: bold;
|
||
|
||
.tab-line {
|
||
width: 123rpx;
|
||
height: 4rpx;
|
||
left: 50%;
|
||
bottom: 0;
|
||
transform: translateX(-50%);
|
||
background: transparent;
|
||
position: absolute;
|
||
z-index: 2;
|
||
}
|
||
|
||
.line-active {
|
||
background: $brand-gold;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 选项卡内容
|
||
.tab-detail {
|
||
min-height: 300rpx;
|
||
background: #fff;
|
||
width: calc(100% - 40rpx);
|
||
margin-left: 20rpx;
|
||
box-shadow: $brand-shadow;
|
||
|
||
// 规格参数
|
||
.goods-size {
|
||
.table-box {
|
||
width: 710rpx;
|
||
margin: auto;
|
||
background: rgba(255, 255, 255, 1);
|
||
border: 1rpx solid rgba(223, 223, 223, 1);
|
||
|
||
.t-tr {
|
||
border-bottom: 1rpx solid rgba(223, 223, 223, 1);
|
||
|
||
&:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.t-head {
|
||
font-size: 26rpx;
|
||
color: #999;
|
||
flex: 1;
|
||
padding: 15rpx 20rpx;
|
||
height: 100%;
|
||
}
|
||
|
||
.t-detail {
|
||
font-size: 26rpx;
|
||
border-left: 1rpx solid rgba(223, 223, 223, 1);
|
||
flex: 4;
|
||
padding: 15rpx 20rpx;
|
||
height: 100%;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 富文本
|
||
.rich-box {
|
||
::v-deep img {
|
||
display: block;
|
||
}
|
||
}
|
||
|
||
// 评论
|
||
.goods-comment {
|
||
.more-box {
|
||
height: 100rpx;
|
||
background: #fff;
|
||
|
||
.more-btn {
|
||
width: 200rpx;
|
||
line-height: 60rpx;
|
||
border: 1rpx solid $brand-gold;
|
||
border-radius: 30rpx;
|
||
font-size: 26rpx;
|
||
font-weight: 400;
|
||
color: $brand-gold;
|
||
padding: 0;
|
||
background: #fff;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 规格卡片
|
||
.sku-box {
|
||
line-height: 82rpx;
|
||
background: #fff;
|
||
padding: 0 20rpx;
|
||
margin: 10rpx 0;
|
||
font-size: 28rpx;
|
||
|
||
.title {
|
||
color: #999;
|
||
margin-right: 20rpx;
|
||
}
|
||
}
|
||
|
||
// 标题卡片
|
||
.title-box {
|
||
background-color: #fff;
|
||
width: 100%;
|
||
padding: 24rpx;
|
||
box-sizing: border-box;
|
||
border-radius: 20rpx;
|
||
box-shadow: $brand-shadow;
|
||
|
||
.goods-title {
|
||
font-size: 32rpx;
|
||
font-weight: 600;
|
||
line-height: 1.5;
|
||
color: $brand-text;
|
||
}
|
||
|
||
.sub-title {
|
||
color: $brand-gold;
|
||
font-size: 26rpx;
|
||
font-weight: 500;
|
||
line-height: 1.5;
|
||
margin-top: 8rpx;
|
||
}
|
||
}
|
||
|
||
// 底部工具栏
|
||
.tabbar-foot {
|
||
min-height: 100rpx;
|
||
width: 100%;
|
||
}
|
||
|
||
.detail-foot_box {
|
||
min-height: calc(100rpx + env(safe-area-inset-bottom));
|
||
padding: 12rpx 20rpx calc(12rpx + env(safe-area-inset-bottom));
|
||
border-top: 1rpx solid $brand-border;
|
||
background-color: #fff;
|
||
width: 100%;
|
||
position: fixed;
|
||
bottom: 0;
|
||
z-index: 999;
|
||
box-sizing: border-box;
|
||
|
||
.foot-left {
|
||
flex-shrink: 0;
|
||
width: 280rpx;
|
||
justify-content: space-around;
|
||
}
|
||
|
||
.foot-right {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.tools-item {
|
||
position: relative;
|
||
min-width: 80rpx;
|
||
padding: 4rpx 0;
|
||
|
||
.tool-title {
|
||
font-size: 24rpx;
|
||
line-height: 1.2;
|
||
padding-top: 6rpx;
|
||
color: $brand-text;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.cart-num {
|
||
position: absolute;
|
||
top: 0;
|
||
right: 4rpx;
|
||
min-width: 32rpx;
|
||
height: 32rpx;
|
||
line-height: 32rpx;
|
||
padding: 0 8rpx;
|
||
border-radius: 32rpx;
|
||
color: #fff;
|
||
font-size: 20rpx;
|
||
font-weight: 600;
|
||
text-align: center;
|
||
background-color: $brand-price;
|
||
transform: none;
|
||
}
|
||
}
|
||
|
||
.detail-btn-box {
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
|
||
.tool-btn {
|
||
font-size: 28rpx;
|
||
font-weight: 600;
|
||
width: 210rpx;
|
||
height: 72rpx;
|
||
line-height: 72rpx;
|
||
border-radius: 36rpx;
|
||
padding: 0;
|
||
margin-left: 16rpx;
|
||
display: flex;
|
||
flex-direction: row;
|
||
justify-content: center;
|
||
align-items: center;
|
||
|
||
.price {
|
||
font-size: 24rpx;
|
||
line-height: 24rpx;
|
||
font-weight: bold;
|
||
color: rgba(#fff, 0.9);
|
||
}
|
||
|
||
.price-title {
|
||
font-size: 20rpx;
|
||
line-height: 20rpx;
|
||
font-weight: 500;
|
||
color: rgba(#fff, 0.9);
|
||
padding-top: 8rpx;
|
||
}
|
||
}
|
||
|
||
.add-btn {
|
||
background: $brand-primary-light;
|
||
border: 2rpx solid $brand-gold;
|
||
color: #8B6914;
|
||
box-shadow: none;
|
||
}
|
||
|
||
.group-add-btn {
|
||
background: $brand-primary-light;
|
||
border: 2rpx solid $brand-gold;
|
||
color: #8B6914;
|
||
box-shadow: none;
|
||
}
|
||
|
||
.pay-btn {
|
||
background: $brand-gold-gradient;
|
||
color: #FFFFFF;
|
||
font-weight: 600;
|
||
border: none;
|
||
box-shadow: 0 4rpx 16rpx rgba(22, 119, 255, 0.35);
|
||
}
|
||
|
||
.score-btn {
|
||
width: 600rpx;
|
||
line-height: 80rpx;
|
||
background: linear-gradient(90deg, rgba(49, 133, 243, 1), rgba(80, 205, 242, 1));
|
||
box-shadow: 0px 7px 6px 0px rgba(80, 205, 242, 0.2);
|
||
border-radius: 40rpx;
|
||
font-size: 30rpx;
|
||
|
||
font-weight: 500;
|
||
color: rgba(255, 255, 255, 1);
|
||
margin-right: 20rpx;
|
||
}
|
||
|
||
.promote-btn {
|
||
// width: 432rpx;
|
||
width: 230rpx;
|
||
line-height: 70rpx;
|
||
background: linear-gradient(93deg, rgba(214, 172, 98, 1), rgba(255, 226, 188, 1));
|
||
box-shadow: 0px 7rpx 6rpx 0px rgba(#FFE2BC, 0.22);
|
||
font-size: 28rpx;
|
||
|
||
font-weight: 500;
|
||
color: rgba(255, 255, 255, 1);
|
||
border-radius: 35rpx;
|
||
padding: 0;
|
||
margin-right: 20rpx;
|
||
}
|
||
|
||
.seckill-btn {
|
||
// width: 432rpx;
|
||
width: 230rpx;
|
||
line-height: 70rpx;
|
||
background: linear-gradient(93deg, rgba(208, 19, 37, 1), rgba(237, 60, 48, 1));
|
||
box-shadow: 0px 7rpx 6rpx 0px rgba(#ed3c30, 0.22);
|
||
font-size: 28rpx;
|
||
|
||
font-weight: 500;
|
||
color: rgba(255, 255, 255, 1);
|
||
border-radius: 35rpx;
|
||
padding: 0;
|
||
margin-right: 20rpx;
|
||
}
|
||
|
||
.seckilled-btn {
|
||
width: 432rpx;
|
||
line-height: 70rpx;
|
||
background: rgba(221, 221, 221, 1);
|
||
font-size: 28rpx;
|
||
|
||
font-weight: 500;
|
||
color: #999999;
|
||
border-radius: 35rpx;
|
||
padding: 0;
|
||
margin-right: 20rpx;
|
||
}
|
||
|
||
.groupon-btn {
|
||
width: 210rpx;
|
||
height: 70rpx;
|
||
background: linear-gradient(90deg, rgba(254, 131, 42, 1), rgba(255, 102, 0, 1));
|
||
box-shadow: 0px 7rpx 6rpx 0px rgba(255, 104, 4, 0.22);
|
||
border-radius: 35rpx;
|
||
}
|
||
}
|
||
}
|
||
</style> |