deming/pageB/sdetails/index.vue

717 lines
18 KiB
Vue
Raw Normal View History

2020-06-15 00:49:26 +00:00
<template>
<view class="sdetails">
2020-07-20 09:17:41 +00:00
<u-swiper :list="list" height="500" border-radius="0" mode="dot"></u-swiper>
2020-07-21 13:02:28 +00:00
<view class="spike-view" v-if="type==3">
<view class="left">
<view class="price">
<view class="now-price">{{ groupbuyInfo.groupbuy_price }}</view>
<view class="origin-price">{{ groupbuyInfo.goods_price }}</view>
</view>
<view class="num">剩余数量{{ groupbuyInfo.inventory - groupbuyInfo.groupbuy_buy_quantity }}</view>
</view>
<view class="right">
<view class="title">秒杀倒计时</view>
<view class="time">{{ spikeTime }}</view>
</view>
</view>
2020-06-15 00:49:26 +00:00
<view class="info">
2020-07-20 09:17:41 +00:00
<view class="title u-line-2">
<text>{{ goodsInfo.store_name }}</text>{{ goodsInfo.goods_name }}
2020-06-15 00:49:26 +00:00
</view>
<view class="pic">
2020-06-29 09:24:57 +00:00
<text>{{ goodsInfo.goods_price }}</text>
<s>{{ goodsInfo.goods_marketprice }}</s>
2020-06-15 00:49:26 +00:00
</view>
</view>
<view class="hr"></view>
2020-06-29 09:24:57 +00:00
<!-- <navs :value="领券"></navs> -->
2020-06-30 10:06:50 +00:00
<navs :value="'产品规格'"></navs>
<navs :value="'产品颜色'"></navs>
<navs :value="'选择尺码'"></navs>
2020-07-20 09:17:41 +00:00
<view class="hr"></view>
<view class="group-user" v-if="groupUser.length">
<view class="top">
<view class="title">{{ groupUser.length }}人正在拼团可直接参与</view>
2020-07-21 13:02:28 +00:00
<view class="view-more" @click="showGroupUser=true">
2020-07-20 09:17:41 +00:00
<text>查看全部</text>
<image src="/static/image/common/1.png"></image>
</view>
</view>
<view class="bottom">
2020-07-21 13:02:28 +00:00
<view class="left" @click="showGroupUser=true">
2020-07-20 09:17:41 +00:00
<view class="avatar">
2020-07-21 13:02:28 +00:00
<image v-for="(user, i) in groupUser.slice(0, 3)" :src="user[0].member_avatar" :key="i"></image>
2020-07-20 09:17:41 +00:00
</view>
<view class="all">
<text>查看全部</text>
<image src="/static/image/common/1.png"></image>
</view>
</view>
<view class="right">
2020-07-21 13:02:28 +00:00
<view class="launch-user" @click="showGroupUser=true">
2020-07-20 09:17:41 +00:00
<image :src="groupUser[0][0].member_avatar"></image>
<text class="u-line-1">{{ groupUser[0][0].member_nickname }}</text>
</view>
<view class="involvement-user">
2020-07-21 13:02:28 +00:00
<view class="item" v-for="(user, i) in groupUser.slice(1, 5)" :key="i" @click="showGroupUser=true">
2020-07-20 09:17:41 +00:00
<image :src="user[0].member_avatar"></image>
<text class="u-line-1">{{ user[0].member_nickname }}</text>
</view>
</view>
</view>
</view>
</view>
2020-07-21 13:02:28 +00:00
<u-popup v-model="showGroupUser" mode="center">
<view class="launch-container">
<view class="title u-line-1">正在拼团</view>
<scroll-view class="launch-view">
<view class="launch-user">
<view class="item" v-for="(user, i) in groupUser" :src="user[0].member_avatar" :key="i" @click="involvemenGroup(user)">
<image class="avatar" :src="user[0].member_avatar"></image>
<view class="name u-line-1">{{ user[0].member_nickname }}</view>
</view>
</view>
</scroll-view>
<image class="close" src="/static/image/common/17.png" @click="showGroupUser=false"></image>
</view>
</u-popup>
<u-popup v-model="showInvolvementUser" mode="center">
<view class="involvement-container" v-if="involvemenGroupInfo.length">
<view class="title u-line-1">参与{{ involvemenGroupInfo[0].member_nickname }}的拼团</view>
<view class="involvement-view">
<view class="item" v-for="(user, i) in involvemenGroupInfo" :key="i">
<image class="avatar" :src="user.member_avatar"></image>
<view class="name u-line-1">{{ user.member_nickname }}</view>
</view>
</view>
<view class="involvement-btn" @click="withImmediate('involvement')">参与拼团</view>
<image class="close" src="/static/image/common/17.png" @click="showInvolvementUser=false"></image>
</view>
</u-popup>
2020-06-15 00:49:26 +00:00
<view class="xiangqing">
<view class="heng"></view>
<view class="title">商品详情</view>
<view class="heng"></view>
</view>
2020-06-29 09:24:57 +00:00
<view class="rich">
<rich-text :nodes="goodsInfo.mobile_body"></rich-text>
</view>
2020-07-20 09:17:41 +00:00
<!-- 拼团 tool -->
<view class="group-tool" v-if="type==2">
<view class="launch" @click="withImmediate">发起拼团</view>
2020-07-21 13:02:28 +00:00
<view class="involvement" @click="showGroupUser=true">参与拼团</view>
</view>
<!-- 秒杀 -->
<view class="spike-tool" v-if="type==3">
<view class="left">
<view>
<image src="/static/image/common/18.png"></image>
<text>店铺</text>
</view>
<view>
<image src="/static/image/common/19.png"></image>
<text>客服</text>
</view>
</view>
<view class="btn" :class="{'cannot': groupbuyInfo.groupbuy_state == 32 || groupbuyInfo.inventory == groupbuyInfo.groupbuy_buy_quantity}">
{{ groupbuyInfo.groupbuy_state == 32 ? '时间已结束' : (groupbuyInfo.inventory > groupbuyInfo.groupbuy_buy_quantity ? '立即秒杀' : '已售空') }}
</view>
2020-07-20 09:17:41 +00:00
</view>
<!-- 普通商品 tool -->
<tloos @buy="buy" @xuanze="xuanze" :id="goodsInfo.goods_commonid" :info="info" v-if="type==1"></tloos>
2020-07-07 06:45:57 +00:00
<u-toast ref="uToast" />
2020-06-15 00:49:26 +00:00
</view>
</template>
<script>
import navs from "../components/sdetails/navs"
import tloos from "../components/sdetails/tloos"
2020-07-20 09:17:41 +00:00
export default {
2020-06-15 00:49:26 +00:00
name:"sdetails",
2020-06-29 09:24:57 +00:00
data() {
return {
2020-07-20 09:17:41 +00:00
list: [], // 轮播图列表
2020-07-07 06:45:57 +00:00
goodsInfo: {},
info:{},
glist:[],
2020-07-20 09:17:41 +00:00
id:0,
2020-07-21 13:02:28 +00:00
type: '', // 商品类型 商品详情 1普通 2拼团 3秒杀 4优惠券
2020-07-20 09:17:41 +00:00
groupUser: [], // 拼团用户
avatarWidth: '',
2020-07-21 13:02:28 +00:00
showGroupUser: false, // 拼团
showInvolvementUser: false, // 参团
involvemenGroupInfo: [], // 参团的人
groupbuyInfo: {}, // 秒杀详情
spikeTime: '',
timer: '', // 时间定时器
2020-06-29 09:24:57 +00:00
}
},
2020-06-15 00:49:26 +00:00
components:{
navs,
tloos
},
2020-07-21 13:02:28 +00:00
onLoad() {
2020-07-20 09:17:41 +00:00
this.init();
2020-06-29 09:24:57 +00:00
},
2020-07-21 13:02:28 +00:00
beforeDestroy() {
clearInterval(this.timer);
},
2020-06-29 09:24:57 +00:00
methods: {
2020-07-20 09:17:41 +00:00
init() {
2020-07-21 13:02:28 +00:00
this.id = this.$store.state.goods_id;
2020-07-20 09:17:41 +00:00
this.type = this.$store.getters.getGoodsType;
const info = this.$store.getters.getGoodsInfo;
2020-07-21 13:02:28 +00:00
if (this.type == 3) {
this.groupbuyInfo = this.$store.state.groupbuyInfo;
this.setSpikeTime();
}
// console.log(this.groupbuyInfo);
if(this.type == 2) {
this.groupUser = info.user;
}
2020-07-20 09:17:41 +00:00
this.goodsInfo = info.goods;
// 设置轮播图
let list = [];
info.goods_image[0].forEach(item => {
let temp = {
image: item
}
list.push(temp);
})
this.list = list;
this.setTitle();
},
2020-07-21 13:02:28 +00:00
setSpikeTime() {
const time = this.groupbuyInfo.groupbuy_endtime;
// console.log(new Date(time*1000));
// console.log(new Date());
this.timer = setInterval(() => {
let spikeTime = time * 1000 - new Date();
//计算出小时数
const leave1 = spikeTime % (24*3600*1000) //计算天数后剩余的毫秒数
const hours = Math.floor(leave1/(3600*1000))
//计算相差分钟数
const leave2 = leave1 % (3600*1000) //计算小时数后剩余的毫秒数
const minutes = Math.floor(leave2 / (60*1000))
//计算相差秒数
const leave3 = leave2 % (60*1000) //计算分钟数后剩余的毫秒数
const seconds = Math.round(leave3 / 1000)
this.spikeTime = hours + ':' + minutes + ':' + seconds;
// console.log(this.spikeTime);
}, 1000)
},
2020-07-07 06:45:57 +00:00
buy(info){
if(info.type == 2){
this.$u.api.addCart({
goods_id: this.id,
quantity: info.value,
}).then(res => {
this.$refs.uToast.show({
title: res.errCode[1],
type: res.errCode == 0 ? 'success' : 'warning',
})
})
}
},
2020-06-29 09:24:57 +00:00
getGoodsDetails(id) {
2020-07-07 06:45:57 +00:00
this.id = id;
2020-06-30 10:06:50 +00:00
this.$u.api.getGoodsDetails({ id: id }).then((res)=>{
2020-06-29 09:24:57 +00:00
if (res.errCode == 0) {
2020-07-15 08:21:43 +00:00
this.goodsInfo = res.data.goods;
let list = [];
res.data.goods_image[0].forEach(item => {
2020-06-29 09:24:57 +00:00
let temp = {
image: item
}
2020-07-15 08:21:43 +00:00
list.push(temp);
2020-06-29 09:24:57 +00:00
})
2020-07-15 08:21:43 +00:00
this.list = list;
2020-07-01 09:32:36 +00:00
// console.log(this.goodsInfo.mobile_body);
2020-06-29 09:24:57 +00:00
}
2020-07-07 06:45:57 +00:00
})
this.$u.api.goodsInfo({id}).then((res)=>{
2020-07-20 09:17:41 +00:00
// console.log(res)
2020-07-07 06:45:57 +00:00
this.info = res.data.goods;
this.glist = res.data.spec_list;
})
2020-07-20 09:17:41 +00:00
},
2020-07-21 13:02:28 +00:00
// 如果有pintuangroup_headid为参团不然为开团
withImmediate(type) {
let params = {
2020-07-20 09:17:41 +00:00
pintuan_id: this.id,
2020-07-21 13:02:28 +00:00
}
// console.log(this.involvemenGroupInfo);
if(type == 'involvement' && this.involvemenGroupInfo.length) {
Object.assign(params, { pintuangroup_headid: this.involvemenGroupInfo[0].user_id });
Object.assign(params, { pintuangroup_id: this.involvemenGroupInfo[0].pintuangroup_id });
}
// console.log(params);
this.$u.api.withImmediate(params).then(res => {
this.showGroupUser = false;
this.showInvolvementUser = false;
if(res.errCode == 0) {
this.settlementOrder();
} else {
this.$u.toast(res.message);
}
})
},
settlementOrder() {
// ifcart 结算方式 1:购物车 0:直接结算(立即购买/拼团/秒杀)
this.$u.api.settlementOrder({
ifcart: 0,
cart_id: [this.goodsInfo.goods_id + '|' + 1],
pintuan_id: this.involvemenGroupInfo[0].user_id,
pintuangroup_id: this.involvemenGroupInfo[0].pintuangroup_id
2020-07-20 09:17:41 +00:00
}).then(res => {
2020-07-21 13:02:28 +00:00
if(res.errCode == 0) {
this.$store.commit('orderType', 3);
this.$store.commit('updateOrderInfo', res.data)
this.$u.route({
url: '/pageC/cart/ConfirmOrder'
})
}
2020-07-20 09:17:41 +00:00
})
},
2020-07-21 13:02:28 +00:00
involvemenGroup(user) {
this.involvemenGroupInfo = user;
this.showGroupUser = false;
this.showInvolvementUser = true;
console.log(this.involvemenGroupInfo);
},
2020-07-07 06:45:57 +00:00
xuanze(id){
2020-07-20 09:17:41 +00:00
// console.log(id)
2020-07-07 06:45:57 +00:00
this.getGoodsDetails(this.glist[id])
2020-07-20 09:17:41 +00:00
},
setTitle() {
let title = '';
switch (this.type) {
case 1:
break;
case 2:
title = '拼团商品详情';
break;
case 1:
break;
case 1:
break;
default:
break;
}
uni.setNavigationBarTitle({
title: title
});
},
2020-06-29 09:24:57 +00:00
},
2020-06-15 00:49:26 +00:00
}
</script>
<style lang="scss" scoped>
2020-07-21 13:02:28 +00:00
.sdetails {
2020-06-29 09:24:57 +00:00
padding-bottom: 98rpx;
2020-07-21 13:02:28 +00:00
position: relative;
.spike-view {
position: absolute;
top: 396rpx;
left: 0;
width: 100%;
height: 104rpx;
background: rgba(255,120,15,1);
opacity: 0.96;
color:rgba(255,255,255,1);
display: flex;
align-items: center;
.left {
height: 104rpx;
flex: 1;
padding-left: 30rpx;
display: flex;
flex-direction: column;
justify-content: center;
.price {
margin-bottom: 22rpx;
display: flex;
align-items: center;
.now-price {
font-size: 32rpx;
font-weight: bold;
margin-right: 16rpx;
}
.origin-price {
font-size: 26rpx;
}
}
.num {
font-size: 22rpx;
font-weight: 500;
}
}
.right {
height: 104rpx;
width: 232rpx;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
&::before {
position: absolute;
left: 0;
content: "";
width: 2rpx;
height: 104rpx;
background:rgba(255,255,255,1);
}
font-size: 26rpx;
font-weight: 500;
.title {
margin-bottom: 18rpx;
}
}
}
.info {
2020-06-15 00:49:26 +00:00
padding: 30rpx;
.title{
flex-wrap: wrap;
2020-06-29 09:24:57 +00:00
margin-bottom: 30rpx;
2020-06-15 00:49:26 +00:00
>text{
padding: 13rpx;
font-size: 24rpx;
color:#fff;
margin-right: 13rpx;
background-color: #FF780F;
display: inline-block;
border-radius: 25rpx;
}
}
.pic{
>text{
font-size: 32rpx;
color: #FF3131;
}
>s{
font-size: 26rpx;
color: #999;
display: inline-block;
margin-left: 30rpx;
}
}
}
2020-07-21 13:02:28 +00:00
.hr {
2020-06-15 00:49:26 +00:00
width: 100%;
height: 20rpx;
background-color: #ececec;
}
2020-07-20 09:17:41 +00:00
.group-user {
padding: 30rpx;
.top {
margin-bottom: 28rpx;
display: flex;
align-items: center;
justify-content: space-between;
.title {
font-size: 30rpx;
color: rgba(51,51,51,1);
}
.view-more {
font-size: 24rpx;
color: rgba(153,153,153,1);
> image {
margin-left: 10rpx;
width: 8rpx;
height: 16rpx;
}
}
}
.bottom {
display: flex;
align-items: center;
font-size: 22rpx;
color: rgba(153,153,153,1);
.left {
margin-right: 40rpx;
.avatar {
width: 120rpx;
height: 60rpx;
margin-bottom: 16rpx;
position: relative;
@mixin avatar($left, $index) {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
position: absolute;
top: 0;
left: $left;
z-index: $index;
}
> image {
&:first-child {
background-color: aliceblue;
@include avatar($left: 0rpx, $index: 7);
}
&:nth-child(2) {
background-color: aquamarine;
@include avatar($left: 30rpx, $index: 8);
}
&:nth-child(3) {
background-color: antiquewhite;
@include avatar($left: 60rpx, $index: 9);
}
}
}
.all {
> image {
margin-left: 10rpx;
width: 8rpx;
height: 16rpx;
}
}
}
.right {
display: flex;
image {
background-color: aquamarine;
width: 60rpx;
height: 60rpx;
margin-bottom: 15rpx;
border-radius: 50%;
}
.launch-user {
margin-right: 40rpx;
text-align: center;
> text {
width: 98rpx;
display: block;
}
}
.involvement-user {
display: flex;
align-items: center;
.item {
text-align: center;
> text {
display: block;
width: 72rpx;
}
&:not(:last-child) {
margin-right: 30rpx;
}
}
}
}
}
}
2020-07-21 13:02:28 +00:00
.launch-container {
width: 558rpx;
height: 655rpx;
background: rgba(255,255,255,1);
border-radius: 20rpx;
position: relative;
overflow: hidden;
.title {
text-align: center;
padding: 40rpx 0;
font-size: 32rpx;
color: rgba(51,51,51,1);
position: relative;
&::after {
content: '';
position: absolute;
width: 558rpx;
height: 2rpx;
background: rgba(234,234,234,1);
bottom: 0;
left: 0;
}
}
.launch-view {
height: 500rpx;
box-sizing: border-box;
padding: 30rpx 50rpx;
.launch-user {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: flex-start;
justify-content: flex-start;
.item {
width: 96rpx;
height: 96rpx;
text-align: center;
margin-bottom: 30rpx;
.avatar {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
margin-bottom: 15rpx;
}
.name {
font-size: 22rpx;
color: rgba(153,153,153,1);
}
&:not(:nth-child(3n)) {
margin-right: 80rpx;
}
}
}
}
.close {
position: absolute;
width: 47rpx;
height: 47rpx;
top: 10rpx;
right: 20rpx;
border-radius: 50%;
}
}
.involvement-container {
width: 558rpx;
height: 486rpx;
background: rgba(255,255,255,1);
border-radius: 20rpx;
position: relative;
overflow: hidden;
.title {
text-align: center;
padding: 40rpx 0;
font-size: 32rpx;
color: rgba(51,51,51,1);
position: relative;
&::after {
content: '';
position: absolute;
width: 558rpx;
height: 2rpx;
background: rgba(234,234,234,1);
bottom: 0;
left: 0;
}
}
.involvement-view {
display: flex;
justify-content: center;
margin: 40rpx 0 70rpx;
.item {
width: 100rpx;
text-align: center;
margin-right: 10rpx;
.avatar {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
margin-bottom: 15rpx;
}
.name {
font-size: 22rpx;
color: rgba(153,153,153,1);
}
}
}
.involvement-btn {
width: 400rpx;
height: 88rpx;
background: rgba(255,120,15,1);
border-radius: 44rpx;
font-size: 30rpx;
color:rgba(255,255,255,1);
text-align: center;
line-height: 88rpx;
margin: 0 auto;
}
.close {
position: absolute;
width: 47rpx;
height: 47rpx;
top: 10rpx;
right: 20rpx;
border-radius: 50%;
}
}
2020-06-15 00:49:26 +00:00
.xiangqing{
display: flex;
height: 85rpx;
background-color: #ececec;
align-items: center;
justify-content: center;
.heng{
width: 79rpx;
height: 2rpx;
background-color: #a9a9a9;
}
font-size: 28rpx;
color: #999;
.title{
margin: 0 20rpx;
}
}
2020-06-29 09:24:57 +00:00
.rich {
width: 100%;
}
2020-07-20 09:17:41 +00:00
.group-tool {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 98rpx;
display: flex;
font-size: 32rpx;
color: rgba(255,255,255,1);
z-index: 99;
.launch {
flex: 1;
background: rgba(253,211,96,1);
line-height: 98rpx;
text-align: center;
}
.involvement {
flex: 1;
background: rgba(255,120,15,1);
line-height: 98rpx;
text-align: center;
}
}
2020-07-21 13:02:28 +00:00
.spike-tool {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 98rpx;
display: flex;
z-index: 99;
.left {
width: 190rpx;
display: flex;
align-items: center;
justify-content: space-around;
> view {
text-align: center;
> image {
width: 35rpx;
height: 35rpx;
margin-bottom: 15rpx;
}
> text {
display: block;
font-size: 24rpx;
color: rgba(102,102,102,1);
}
}
}
.btn {
flex: 1;
height: 98rpx;
line-height: 98rpx;
text-align: center;
font-size: 32rpx;
color: rgba(255,255,255,1);
background: rgba(255,120,15,1);
}
.cannot {
background: rgba(221,221,221,1);
}
}
2020-06-15 00:49:26 +00:00
}
</style>