comment 7.2
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="sdetails">
|
||||
<u-swiper :list="list" height="500" border-radius="0" mode="dot"></u-swiper>
|
||||
<view class="spike-view" v-if="type==3">
|
||||
<view class="spike-view" v-if="type == 3">
|
||||
<view class="left">
|
||||
<view class="price">
|
||||
<view class="now-price">¥{{ groupbuyInfo.groupbuy_price }}</view>
|
||||
@@ -25,10 +25,20 @@
|
||||
</view>
|
||||
<view class="hr"></view>
|
||||
<!-- <navs :value="领券"></navs> -->
|
||||
<navs :value="'产品规格'"></navs>
|
||||
<navs :value="'产品规格'" @click.native="showSpec=true"></navs>
|
||||
<!-- <navs :value="'产品颜色'"></navs> -->
|
||||
<!-- <navs :value="'选择尺码'"></navs> -->
|
||||
<!-- <navs v-for="(value, index) in goodsInfo.spec_name" :value="value" :key="index"></navs> -->
|
||||
<view class="comment">
|
||||
<view class="title">
|
||||
<view class="left">商品评价({{ evaluate.evaluate_num }})</view>
|
||||
<view class="right" @click="viewComment">
|
||||
<text>查看全部</text>
|
||||
<image src="/static/image/common/1.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<comment :reply="false" :content="evaluate" v-if="evaluate.evaluate_num"></comment>
|
||||
<view class="comment-none">暂无评价</view>
|
||||
</view>
|
||||
<view class="hr"></view>
|
||||
<view class="group-user" v-if="groupUser.length">
|
||||
<view class="top">
|
||||
@@ -97,12 +107,47 @@
|
||||
<view class="rich">
|
||||
<rich-text :nodes="goodsInfo.mobile_body"></rich-text>
|
||||
</view>
|
||||
<!-- 选择规格数量 -->
|
||||
<u-popup v-model="showSpec" mode="bottom">
|
||||
<scroll-view scroll-y="true" class="spec-popup">
|
||||
<view>
|
||||
<view class="head">
|
||||
<image class="image" :src="goodsInfo.goods_image"></image>
|
||||
<view class="info">
|
||||
<text class="u-line-2">{{goodsInfo.goods_name}}</text>
|
||||
<text>¥{{goodsInfo.goods_price}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<guige @sel="self" ref="guige" v-for="(item,index) in goodsInfo.spec_value" :key="index" :title="goodsInfo.spec_name[index]" :item="item"></guige>
|
||||
<view class="num">
|
||||
<text>购买数量</text>
|
||||
<u-number-box v-model="goodsNumber" @change="valChange"></u-number-box>
|
||||
</view>
|
||||
<view style="height:100rpx"></view>
|
||||
</view>
|
||||
<u-toast ref="uToast" />
|
||||
</scroll-view>
|
||||
</u-popup>
|
||||
<!-- 普通商品 tool -->
|
||||
<view class="tloos" v-if="type == 1">
|
||||
<view class="navs">
|
||||
<image src="/static/image/common/18.png"></image>
|
||||
店铺
|
||||
</view>
|
||||
<view class="navs" style="margin-right:30rpx">
|
||||
<image src="/static/image/common/19.png"></image>
|
||||
客服
|
||||
</view>
|
||||
<view class="button" style="background:rgba(253,211,96,0.6);" v-if="goodsInfo.goods_try == 1">试穿试送</view>
|
||||
<view class="button" style="background:rgba(253,211,96,1);" @click="addCart">加入购物车</view>
|
||||
<view class="button" style="background:rgba(255,120,15,1);" @click="settlementOrder">立即购买</view>
|
||||
</view>
|
||||
<!-- 拼团 tool -->
|
||||
<view class="group-tool" v-if="type==2">
|
||||
<view class="launch" @click="settlementOrder">发起拼团</view>
|
||||
<view class="involvement" @click="showGroupUser=true">参与拼团</view>
|
||||
</view>
|
||||
<!-- 秒杀 -->
|
||||
<!-- 秒杀 tool -->
|
||||
<view class="spike-tool" v-if="type==3">
|
||||
<view class="left">
|
||||
<view>
|
||||
@@ -119,97 +164,111 @@
|
||||
{{ groupbuyInfo.groupbuy_state == 32 ? '时间已结束' : (groupbuyInfo.inventory > groupbuyInfo.groupbuy_buy_quantity ? '立即秒杀' : '已售空') }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 普通商品 tool -->
|
||||
<tloos @buy="buy" @xuanze="xuanze" :id="goodsInfo.goods_commonid" :info="goodsInfo" v-if="type==1"></tloos>
|
||||
<!-- <tloos @buy="buy" @xuanze="xuanze" :id="id" :info="goodsInfo" :type="type"></tloos> -->
|
||||
<u-toast ref="uToast" />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
/*
|
||||
* 详情是请求完存在store的,在这里从store取值
|
||||
**/
|
||||
import navs from "../components/sdetails/navs"
|
||||
import tloos from "../components/sdetails/tloos"
|
||||
import comment from "@/components/comment/index";
|
||||
import navs from "../components/sdetails/navs";
|
||||
import guige from "../components/sdetails/guige"
|
||||
import tloos from "../components/sdetails/tloos";
|
||||
export default {
|
||||
name:"sdetails",
|
||||
name: "sdetails",
|
||||
data() {
|
||||
return {
|
||||
list: [], // 轮播图列表
|
||||
goodsInfo: {},
|
||||
info:{},
|
||||
glist:[],
|
||||
id:0, // 商品id
|
||||
goodsInfo: {}, // 商品信息
|
||||
glist: [], // 规格列表
|
||||
id: 0, // 商品id/秒杀id/拼团 id
|
||||
type: '', // 商品类型 商品详情 1普通 2拼团 3秒杀 4优惠券
|
||||
groupUser: [], // 拼团用户
|
||||
user_suc: [], // 拼团成功用户
|
||||
avatarWidth: '',
|
||||
pintuan_id: '', // 拼团id
|
||||
showGroupUser: false, // 拼团
|
||||
showInvolvementUser: false, // 参团
|
||||
involvemenGroupInfo: [], // 参团的人
|
||||
groupbuyInfo: {}, // 秒杀详情
|
||||
spikeTime: '',
|
||||
timer: '', // 时间定时器
|
||||
timer: '', // 秒杀时间定时器
|
||||
spec_id: '', // 规格 id, 下单用的
|
||||
evaluate: {}, // 评价内容
|
||||
showSpec: false, // 是否显示选择规格
|
||||
goodsNumber: 1,
|
||||
sel: "", // 拼接的规格
|
||||
quanxuan: false, // 规格是否选择
|
||||
}
|
||||
},
|
||||
components:{
|
||||
components: {
|
||||
comment,
|
||||
navs,
|
||||
tloos
|
||||
tloos,
|
||||
guige,
|
||||
},
|
||||
watch: {
|
||||
sel(value){
|
||||
this.xuanze(value);
|
||||
},
|
||||
},
|
||||
onShow() {
|
||||
// if(this.pintuan_id) {
|
||||
// this.$u.api.getPinTuanDetails({
|
||||
// pintuan_id: this.pintuan_id
|
||||
// }).then(res => {
|
||||
// if(res.errCode == 0) {
|
||||
// const goods = {
|
||||
// goods: res.data.data,
|
||||
// type: 2,
|
||||
// }
|
||||
// this.$store.commit('setGoodsDetails', goods);
|
||||
// this.$store.commit('setGoodsId', this.pintuan_id);
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
this.showSpec = false;
|
||||
this.showGroupUser = false;
|
||||
this.showInvolvementUser = false;
|
||||
},
|
||||
onLoad() {
|
||||
this.init();
|
||||
onLoad(option) {
|
||||
// this.init();
|
||||
// console.log(option);
|
||||
this.type = Number(option.type);
|
||||
this.id = option.id;
|
||||
this.getGoodsDetails(this.id);
|
||||
this.setTitle();
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.timer);
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.id = this.$store.state.goods_id;
|
||||
this.type = this.$store.getters.getGoodsType;
|
||||
const info = this.$store.getters.getGoodsInfo;
|
||||
if(this.type == 2) {
|
||||
this.user_suc = info.user_suc;
|
||||
this.groupUser = info.user;
|
||||
this.pintuan_id = info.pintuan_id;
|
||||
}
|
||||
if (this.type == 3) {
|
||||
this.groupbuyInfo = this.$store.state.groupbuyInfo;
|
||||
this.setSpikeTime();
|
||||
}
|
||||
// console.log(this.groupbuyInfo);
|
||||
this.goodsInfo = info.goods;
|
||||
// 设置轮播图
|
||||
let list = [];
|
||||
info.goods_image[0].forEach(item => {
|
||||
// init() {
|
||||
// this.id = this.$store.state.goods_id;
|
||||
// this.type = this.$store.getters.getGoodsType;
|
||||
// const info = this.$store.getters.getGoodsInfo;
|
||||
// // 拼团商品
|
||||
// if(this.type == 2) {
|
||||
// this.user_suc = info.user_suc;
|
||||
// this.groupUser = info.user;
|
||||
// this.pintuan_id = info.pintuan_id;
|
||||
// }
|
||||
// // 秒杀商品
|
||||
// if (this.type == 3) {
|
||||
// this.groupbuyInfo = this.$store.state.groupbuyInfo;
|
||||
// this.setSpikeTime();
|
||||
// }
|
||||
// // console.log(this.groupbuyInfo);
|
||||
// this.goodsInfo = info.goods;
|
||||
// // 设置轮播图
|
||||
// let list = [];
|
||||
// info.goods_image[0].forEach(item => {
|
||||
// let temp = {
|
||||
// image: item
|
||||
// }
|
||||
// list.push(temp);
|
||||
// })
|
||||
// this.list = list;
|
||||
// this.setTitle();
|
||||
// },
|
||||
setSwiperList(list) {
|
||||
let img = [];
|
||||
list.forEach(item => {
|
||||
let temp = {
|
||||
image: item
|
||||
}
|
||||
list.push(temp);
|
||||
img.push(temp);
|
||||
})
|
||||
this.list = list;
|
||||
this.setTitle();
|
||||
this.list = img;
|
||||
},
|
||||
spikeGoods() {
|
||||
this.settlementOrder()
|
||||
},
|
||||
setSpikeTime() {
|
||||
const time = this.groupbuyInfo.groupbuy_endtime;
|
||||
setSpikeTime(time) {
|
||||
// const time = this.groupbuyInfo.groupbuy_endtime;
|
||||
this.timer = setInterval(() => {
|
||||
let spikeTime = time * 1000 - new Date().getTime();
|
||||
// 计算天数
|
||||
@@ -229,61 +288,102 @@ export default {
|
||||
// console.log(this.spikeTime);
|
||||
}, 1000)
|
||||
},
|
||||
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.message,
|
||||
type: res.errCode == 0 ? 'success' : 'warning',
|
||||
})
|
||||
})
|
||||
} else if (info.type == 1) { // 支付
|
||||
this.settlementOrder({num: info.value});
|
||||
}
|
||||
},
|
||||
addCart() {
|
||||
this.$u.api.addCart({
|
||||
goods_id: this.id,
|
||||
quantity: this.goodsNumber,
|
||||
}).then(res => {
|
||||
this.$refs.uToast.show({
|
||||
title: res.message,
|
||||
type: res.errCode == 0 ? 'success' : 'warning',
|
||||
})
|
||||
})
|
||||
},
|
||||
purchase() {
|
||||
this.settlementOrder();
|
||||
},
|
||||
getGoodsDetails(id) {
|
||||
this.id = id;
|
||||
switch (this.type) {
|
||||
case 1:
|
||||
this.ordinaryDetails(id);
|
||||
break;
|
||||
case 2:
|
||||
this.pinTuanDetails(id);
|
||||
break;
|
||||
case 3:
|
||||
this.spikeGoodsDetails(id);
|
||||
break;
|
||||
case 4:
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
// 普通商品
|
||||
ordinaryDetails(id) {
|
||||
this.$u.api.getGoodsDetails({ id: id }).then((res)=>{
|
||||
if (res.errCode == 0) {
|
||||
this.evaluate = res.data.goods_evaluate_info;
|
||||
this.goodsInfo = res.data.goods;
|
||||
let list = [];
|
||||
res.data.goods_image[0].forEach(item => {
|
||||
let temp = {
|
||||
image: item
|
||||
}
|
||||
list.push(temp);
|
||||
})
|
||||
this.list = list;
|
||||
this.info = res.data.goods;
|
||||
this.setSwiperList(res.data.goods_image[0]);
|
||||
this.glist = res.data.spec_list;
|
||||
// console.log(this.goodsInfo.mobile_body);
|
||||
}
|
||||
})
|
||||
},
|
||||
// 下单
|
||||
// 拼团
|
||||
pinTuanDetails(id) {
|
||||
this.$u.api.getPinTuanDetails({
|
||||
pintuan_id: id
|
||||
}).then(res => {
|
||||
if(res.errCode == 0) {
|
||||
this.evaluate = res.data.data.goods_evaluate_info;
|
||||
this.goodsInfo = res.data.data.goods;
|
||||
this.setSwiperList(res.data.data.goods_image[0]);
|
||||
this.glist = res.data.data.spec_list;
|
||||
this.user_suc = res.data.data.user_suc;
|
||||
this.groupUser =res.data.data.user;
|
||||
}
|
||||
})
|
||||
},
|
||||
// 秒杀
|
||||
spikeGoodsDetails(id) {
|
||||
this.$u.api.getSpikeInfo({
|
||||
groupbuy_id: id
|
||||
}).then(res => {
|
||||
if(res.errCode == 0) {
|
||||
this.groupbuyInfo = res.data.groupbuyInfo;
|
||||
this.evaluate = res.data.goodsInfo.goods_evaluate_info;
|
||||
this.goodsInfo = res.data.goodsInfo.goods;
|
||||
this.setSwiperList(res.data.goodsInfo.goods_image[0]);
|
||||
this.setSpikeTime(res.data.groupbuyInfo.groupbuy_endtime);
|
||||
}
|
||||
})
|
||||
},
|
||||
/*
|
||||
* @description 下单 订单步骤1:展示结算数据
|
||||
* @params {Number} type 拼团或者开团
|
||||
* @params {Number} num 数量
|
||||
* @params {Number} ifcart 结算方式 1:购物车 0:直接结算(立即购买/拼团/秒杀)
|
||||
**/
|
||||
settlementOrder({type, num = 1} = {}) {
|
||||
// ifcart 结算方式 1:购物车 0:直接结算(立即购买/拼团/秒杀)
|
||||
settlementOrder({type, num = this.goodsNumber, ifcart = 0} = {}) {
|
||||
let params = {
|
||||
ifcart: 0,
|
||||
ifcart: ifcart,
|
||||
cart_id: [this.goodsInfo.goods_id + '|' + num],
|
||||
}
|
||||
if(this.type == 2) {
|
||||
if(type == 'involvement') {
|
||||
Object.assign(params, {
|
||||
pintuan_id: this.pintuan_id,
|
||||
pintuan_id: this.id,
|
||||
pintuangroup_id: this.involvemenGroupInfo[0].pintuangroup_id
|
||||
})
|
||||
} else {
|
||||
const userId = uni.getStorageSync('user_info').member.member_id;
|
||||
this.$store.commit('setGroupHeadId', userId);
|
||||
Object.assign(params, {
|
||||
pintuan_id: this.pintuan_id,
|
||||
pintuan_id: this.id,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -297,16 +397,42 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
// 参团
|
||||
involvemenGroup(user) {
|
||||
this.involvemenGroupInfo = user;
|
||||
this.showGroupUser = false;
|
||||
this.showInvolvementUser = true;
|
||||
// console.log(this.involvemenGroupInfo);
|
||||
},
|
||||
valChange(e) {
|
||||
// console.log(this.value)
|
||||
},
|
||||
self(){
|
||||
// console.log(this.$refs.guige)
|
||||
let index = 0;
|
||||
let arr = [];
|
||||
for(let i in this.goodsInfo.spec_value){
|
||||
// console.log(i)
|
||||
// console.log(this.$refs.guige[index++].select)
|
||||
// index++;
|
||||
let sel = this.$refs.guige[index++].select
|
||||
if(sel != 0){
|
||||
arr.push(sel)
|
||||
}
|
||||
}
|
||||
// console.log(arr.length)
|
||||
if(arr.length == index){
|
||||
this.sel = arr.join("|")
|
||||
this.quanxuan = true
|
||||
// console.log(this.sel)
|
||||
}
|
||||
},
|
||||
xuanze(id){
|
||||
console.log(id)
|
||||
// this.getGoodsDetails(this.glist[id])
|
||||
// console.log(id)
|
||||
this.getGoodsDetails(this.glist[id])
|
||||
this.id = this.glist[id];
|
||||
},
|
||||
// 设置页面标题
|
||||
setTitle() {
|
||||
let title = '';
|
||||
switch (this.type) {
|
||||
@@ -329,6 +455,14 @@ export default {
|
||||
title: title
|
||||
});
|
||||
},
|
||||
viewComment() {
|
||||
this.$u.route({
|
||||
url: 'pageB/comment/index',
|
||||
params: {
|
||||
id: this.goodsInfo.goods_id
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -336,6 +470,7 @@ export default {
|
||||
.sdetails {
|
||||
padding-bottom: 98rpx;
|
||||
position: relative;
|
||||
background-color: #EEEBEE;
|
||||
.spike-view {
|
||||
position: absolute;
|
||||
top: 396rpx;
|
||||
@@ -397,7 +532,9 @@ export default {
|
||||
}
|
||||
}
|
||||
.info {
|
||||
background:rgba(255,255,255,1);
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
.title{
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 30rpx;
|
||||
@@ -424,12 +561,42 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
.comment {
|
||||
margin-top: 20rpx;
|
||||
background:rgba(255,255,255,1);
|
||||
padding: 30rpx;
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 30rpx;
|
||||
.left {
|
||||
font-size: 30rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
}
|
||||
.right {
|
||||
font-size: 24rpx;
|
||||
color: rgba(153,153,153,1);
|
||||
> image {
|
||||
width: 8rpx;
|
||||
height: 16rpx;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.comment-none {
|
||||
font-size: 26rpx;
|
||||
text-align: center;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
}
|
||||
.hr {
|
||||
width: 100%;
|
||||
height: 20rpx;
|
||||
background-color: #ececec;
|
||||
}
|
||||
.group-user {
|
||||
background: rgba(255,255,255,1);
|
||||
padding: 30rpx;
|
||||
.top {
|
||||
margin-bottom: 28rpx;
|
||||
@@ -739,5 +906,82 @@ export default {
|
||||
background: rgba(221,221,221,1);
|
||||
}
|
||||
}
|
||||
.tloos{
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
position: fixed;
|
||||
height: 98rpx;
|
||||
width: 100%;
|
||||
bottom:0;
|
||||
border-top: 1rpx solid #ececec;
|
||||
z-index: 1000000;
|
||||
.navs{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
flex-shrink: 0;
|
||||
margin-left: 30rpx;
|
||||
>image{
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
.button{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
line-height: 98rpx;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
|
||||
}
|
||||
}
|
||||
.spec-popup {
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
max-height: 750rpx;
|
||||
.head{
|
||||
display: flex;
|
||||
margin-bottom: 30rpx;
|
||||
.image{
|
||||
width: 195rpx;
|
||||
height: 195rpx;
|
||||
border-radius: 10rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.info{
|
||||
display: flex;
|
||||
padding: 21rpx 0;
|
||||
justify-content: space-between;
|
||||
margin-left: 27rpx;
|
||||
flex-direction: column;
|
||||
>text:first-child{
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
>text:last-child{
|
||||
font-size: 30rpx;
|
||||
color: #ff3131;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.num{
|
||||
height: 84rpx;
|
||||
display: flex;
|
||||
border-bottom: #ececec solid 2rpx;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
>text{
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user