2022-08-03 13:28:45 +00:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<status-container titlet="产品详情" returnc="#FFFFFF">
|
2022-08-08 10:15:03 +00:00
|
|
|
|
<view v-if="loading" slot="content" style="margin-top: -20rpx;">
|
2022-08-03 13:28:45 +00:00
|
|
|
|
<view class="bacf boxshowb">
|
2022-08-05 10:01:57 +00:00
|
|
|
|
<swiper-pu newBottom="20rpx" newHeight="520rpx" :bannerList="bannerList"></swiper-pu>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
<view class="pad-zy30 pad-sx24">
|
2022-08-05 03:05:55 +00:00
|
|
|
|
<view class="fon26 col26">{{shopInfo.name}}</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
<view class="col-e42417 dis ae fon24 mar-s20">
|
2022-08-05 03:05:55 +00:00
|
|
|
|
<view class="bold">¥{{shopInfo.price}}</view>
|
|
|
|
|
<view class="tline-through fon20 col-969696 mar-z10">¥{{shopInfo.original_price}}</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2022-08-15 10:15:13 +00:00
|
|
|
|
<!-- <view class="bacf mar-s30 pad-zy30 pad-x30">
|
2022-08-09 10:21:46 +00:00
|
|
|
|
<view class="bbot pad-x10 pad-s30">
|
|
|
|
|
<span class="fon28 bold posir pad-x10">
|
|
|
|
|
规格/参数
|
|
|
|
|
<view class="posia-xzy" style="height: 6rpx;background-color: #e42417;bottom: -2rpx;"></view>
|
|
|
|
|
</span>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="" v-if="isLoading">
|
|
|
|
|
<view class="disac fon24 col26 mar-s20" v-for="(item,index) in specList" :key="index">
|
|
|
|
|
<view class="">{{item.title}}:</view>
|
|
|
|
|
<view class="disac">
|
|
|
|
|
<view @tap="chooseSpec(index,item1.id)" class="pad-sx10 pad-zy20 radius10 borbot-df mar-y10" :class="moSpecList[index]==item1.id?'specActive':''" v-for="(item1,index1) in item.children" :key="index1">{{item1.title}}</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2022-08-15 10:15:13 +00:00
|
|
|
|
</view> -->
|
2022-08-03 13:28:45 +00:00
|
|
|
|
<view class="bacf mar-s30 pad-zy30 pad-x30">
|
|
|
|
|
<view class="bbot pad-x10 pad-s30">
|
|
|
|
|
<span class="fon28 bold posir pad-x10">
|
|
|
|
|
产品介绍
|
|
|
|
|
<view class="posia-xzy" style="height: 6rpx;background-color: #e42417;bottom: -2rpx;"></view>
|
|
|
|
|
</span>
|
|
|
|
|
</view>
|
2022-08-11 10:27:47 +00:00
|
|
|
|
<view class="rich-text fon24 mar-s30" style="line-height: 1.8;" v-if="ifDetail">
|
2022-08-08 10:15:03 +00:00
|
|
|
|
<rich-text :nodes="richText" style="color: #5a5a5a;"></rich-text>
|
2022-08-05 10:01:57 +00:00
|
|
|
|
</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
|
|
|
|
<!-- 底部按钮 -->
|
2022-08-11 10:27:47 +00:00
|
|
|
|
<view class="posixzy bacf pad-zy30 disjbac pad-sx20 boxshowt">
|
2022-08-05 10:01:57 +00:00
|
|
|
|
<view class="fon30 bold col-e42417">¥{{shopInfo.price}}</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
<view class="disac fon24 colf">
|
2022-08-09 10:21:46 +00:00
|
|
|
|
<view @tap="addCart" class="radius32 disjcac" style="background-color: #FFFFFF;color: #f37617;border: 2rpx solid #f37617; width: 184rpx;height: 64rpx;">加入购物车</view>
|
2022-08-15 10:15:13 +00:00
|
|
|
|
<!-- <view @tap="goConfirmOrder" class="radius32 disjcac mar-z10" style="background-color: #f37617;border: 2rpx solid #f37617;width: 184rpx;height: 64rpx;">立即购买</view> -->
|
|
|
|
|
<view @tap="buyPopu(shopInfo.id,shopInfo.is_buy)" class="radius32 disjcac mar-z10" style="background-color: #f37617;border: 2rpx solid #f37617;width: 184rpx;height: 64rpx;">立即购买</view>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</status-container>
|
2022-08-05 10:01:57 +00:00
|
|
|
|
<!-- 购物车图标 -->
|
2022-08-14 14:27:26 +00:00
|
|
|
|
<image @tap="goCart" class="posi" src="/static/tabbar/icon-cart.png" mode="" lazy-load style="width: 79rpx;height: 79rpx;right: 20rpx;bottom: 160rpx;"></image>
|
2022-08-15 10:15:13 +00:00
|
|
|
|
<buy-popu ref="refbuy"></buy-popu>
|
2022-08-03 13:28:45 +00:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
// 底部组件
|
|
|
|
|
import footTab from '@/components/foot-tabs/foot-tab.vue';
|
|
|
|
|
import list from '@/components/list.vue';
|
|
|
|
|
import swiperPu from '@/components/swipers/swiper-pu.vue';
|
2022-08-15 10:15:13 +00:00
|
|
|
|
import buyPopu from '@/components/buy-popu.vue';
|
2022-08-03 13:28:45 +00:00
|
|
|
|
export default {
|
2022-08-16 10:06:46 +00:00
|
|
|
|
components:{'foot-tab' :footTab,list,swiperPu,buyPopu},
|
2022-08-03 13:28:45 +00:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
richText:'',
|
2022-08-05 03:05:55 +00:00
|
|
|
|
shopId:'',//产品id
|
|
|
|
|
shopInfo:'',//产品详情
|
2022-08-05 10:01:57 +00:00
|
|
|
|
bannerList:[],//产品轮播
|
2022-08-09 10:21:46 +00:00
|
|
|
|
loading:false,
|
|
|
|
|
specList:[],//规格列表
|
|
|
|
|
moSpecList:[],//默认规格
|
|
|
|
|
haveSpecList:[],//有这个规格商品
|
|
|
|
|
isLoading:true,
|
2022-08-11 10:27:47 +00:00
|
|
|
|
shopList:[],
|
|
|
|
|
ifDetail:false
|
2022-08-03 13:28:45 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
// 开启banner图自动轮播
|
|
|
|
|
this.$store.commit('setAutoplay',true);
|
2022-08-08 10:15:03 +00:00
|
|
|
|
uni.removeStorageSync('addressInfo');
|
2022-08-10 10:18:06 +00:00
|
|
|
|
uni.removeStorageSync('orderInfo');
|
|
|
|
|
uni.removeStorageSync('skuList');
|
2022-08-03 13:28:45 +00:00
|
|
|
|
},
|
|
|
|
|
onHide() {
|
|
|
|
|
// 关闭banner图自动轮播
|
|
|
|
|
this.$store.commit('setAutoplay',false);
|
|
|
|
|
},
|
2022-08-12 10:14:13 +00:00
|
|
|
|
onShareAppMessage(res) {
|
|
|
|
|
var shareObj = {
|
|
|
|
|
title: ``, // 默认是小程序的名称(可以写slogan等)
|
|
|
|
|
path: `/pagesB/shop-detail/shop-detail?id=${this.shopId}&invite_code=${uni.getStorageSync('invite_code')}`, // 默认是当前页面,必须是以‘/’开头的完整路径
|
|
|
|
|
imageUrl: ``//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
|
|
|
|
|
};
|
|
|
|
|
return shareObj;
|
|
|
|
|
},
|
2022-08-05 03:05:55 +00:00
|
|
|
|
onLoad(op) {
|
2022-08-12 10:14:13 +00:00
|
|
|
|
if(op.invite_code) {
|
|
|
|
|
// 设置为第一次进入
|
|
|
|
|
this.$store.commit('setFristIn',true);
|
|
|
|
|
uni.setStorageSync('invite_code',op.invite_code);
|
|
|
|
|
} else {
|
|
|
|
|
this.$store.commit('setFristIn',false);
|
|
|
|
|
}
|
2022-08-05 03:05:55 +00:00
|
|
|
|
this.shopId = op.id;
|
|
|
|
|
// 调用产品详情
|
|
|
|
|
this.getDetail();
|
2022-08-03 13:28:45 +00:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2022-08-05 03:05:55 +00:00
|
|
|
|
// 获取产品详情
|
|
|
|
|
getDetail(){
|
|
|
|
|
this.$requst.post('/api/spu/detail',{id:this.shopId}).then(res=>{
|
|
|
|
|
if(res.code==0){
|
2022-08-08 10:15:03 +00:00
|
|
|
|
this.loading = true;
|
2022-08-05 03:05:55 +00:00
|
|
|
|
// 设置产品详情
|
|
|
|
|
this.shopInfo = res.data.detail;
|
|
|
|
|
// 富文本
|
|
|
|
|
this.richText = this.$toolAll.tools.escape2Html(this.shopInfo.content);
|
2022-08-05 10:01:57 +00:00
|
|
|
|
// 产品详情
|
|
|
|
|
let newImg = [];
|
|
|
|
|
if(this.shopInfo.images){
|
|
|
|
|
newImg = this.shopInfo.images.split(',');
|
|
|
|
|
}
|
|
|
|
|
if(newImg.length){
|
|
|
|
|
newImg.forEach(item=>{
|
|
|
|
|
let obj = {
|
|
|
|
|
imgSrc:item,
|
|
|
|
|
url:'',
|
|
|
|
|
isVideo:false,
|
|
|
|
|
poster:''
|
|
|
|
|
}
|
|
|
|
|
this.bannerList.push(obj);
|
|
|
|
|
})
|
2022-08-08 10:15:03 +00:00
|
|
|
|
} else {
|
|
|
|
|
this.bannerList.push({
|
|
|
|
|
imgSrc:this.shopInfo.cover,
|
|
|
|
|
url:'',
|
|
|
|
|
isVideo:false,
|
|
|
|
|
poster:''
|
|
|
|
|
})
|
2022-08-05 10:01:57 +00:00
|
|
|
|
}
|
2022-08-09 10:21:46 +00:00
|
|
|
|
// 商品规格
|
2022-08-16 10:06:46 +00:00
|
|
|
|
this.$requst.get('/api/spu/spec',{id:this.shopId}).then(resspec=>{
|
|
|
|
|
if(resspec.code==0){
|
|
|
|
|
//
|
|
|
|
|
this.ifDetail = true;
|
|
|
|
|
// 所有规格列表
|
|
|
|
|
this.specList = resspec.data.spec;
|
|
|
|
|
// 默认规格
|
|
|
|
|
this.moSpecList = resspec.data.sku.indexes.split('-');
|
|
|
|
|
// 存在规格
|
|
|
|
|
this.haveSpecList = resspec.data.sku_list;
|
|
|
|
|
this.shopList.push({
|
|
|
|
|
sku_list:[
|
|
|
|
|
{
|
|
|
|
|
sku_coding:resspec.data.sku.coding,
|
|
|
|
|
num:1,
|
|
|
|
|
sku_id:resspec.data.sku.id
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-08-05 03:05:55 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2022-08-09 10:21:46 +00:00
|
|
|
|
// 规格选择
|
2022-08-15 10:15:13 +00:00
|
|
|
|
// chooseSpec(index,id1){
|
|
|
|
|
// let tempList = JSON.parse(JSON.stringify(this.moSpecList));
|
|
|
|
|
// tempList.splice(index,1,id1);
|
|
|
|
|
// let exit = this.haveSpecList.findIndex(item=>item.indexes==tempList.join('-'));
|
|
|
|
|
// if(exit!=-1){
|
|
|
|
|
// if(this.haveSpecList[exit].stock){
|
|
|
|
|
// this.isLoading = false;
|
|
|
|
|
// this.moSpecList[index] = id1;
|
|
|
|
|
// this.isLoading = true;
|
|
|
|
|
// this.shopList[0].sku_list[0].sku_coding = this.haveSpecList[exit].coding;
|
|
|
|
|
// this.shopList[0].sku_list[0].sku_id = this.haveSpecList[exit].id;
|
|
|
|
|
// } else {
|
|
|
|
|
// this.$toolAll.tools.showToast('库存不足');
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// this.$toolAll.tools.showToast('暂无该规格');
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// 调起弹框
|
|
|
|
|
buyPopu(id,is_buy){
|
|
|
|
|
if(this.$toolAll.tools.judgeAuth()) {
|
|
|
|
|
if(!is_buy){
|
|
|
|
|
this.$refs.refbuy.ifMask = true;
|
|
|
|
|
this.$refs.refbuy.ifAnimated = true;
|
|
|
|
|
this.$refs.refbuy.isLoading = true;
|
|
|
|
|
this.$refs.refbuy.getSpec(id);
|
2022-08-09 10:21:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-08-03 13:28:45 +00:00
|
|
|
|
// 前往确认订单页
|
2022-08-15 10:15:13 +00:00
|
|
|
|
// goConfirmOrder(){
|
|
|
|
|
// if(this.$toolAll.tools.judgeAuth()) {
|
|
|
|
|
// let params = {
|
|
|
|
|
// sku_list:[
|
|
|
|
|
// this.objField('sku_id')
|
|
|
|
|
// ]
|
|
|
|
|
// };
|
|
|
|
|
// this.$requst.post('/api/order/prepare-info',params).then(res=>{
|
|
|
|
|
// if(res.code==0){
|
|
|
|
|
// uni.navigateTo({
|
|
|
|
|
// url:'/pagesB/confirm-order/confirm-order'
|
|
|
|
|
// })
|
|
|
|
|
// uni.setStorageSync('orderInfo',res.data);
|
|
|
|
|
// uni.setStorageSync('skuList',params.sku_list);
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// },
|
2022-08-09 10:21:46 +00:00
|
|
|
|
// 添加购物车
|
|
|
|
|
addCart(){
|
2022-08-14 14:27:26 +00:00
|
|
|
|
if(this.$toolAll.tools.judgeAuth()) {
|
|
|
|
|
let params = this.objField('sku_coding');
|
|
|
|
|
this.$requst.post('/api/order/shopping-cart-add',params).then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
this.$toolAll.tools.showToast('添加购物车成功(*^▽^*)');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-08-09 10:21:46 +00:00
|
|
|
|
},
|
|
|
|
|
// 删除对象中某个字段
|
2022-08-16 10:06:46 +00:00
|
|
|
|
objField(field){
|
|
|
|
|
let newObj = JSON.parse(JSON.stringify(this.shopList[0].sku_list[0]));
|
|
|
|
|
delete newObj[field];
|
|
|
|
|
return newObj;
|
|
|
|
|
},
|
2022-08-14 14:27:26 +00:00
|
|
|
|
// 前往购物车
|
|
|
|
|
goCart(){
|
|
|
|
|
if(this.$toolAll.tools.judgeAuth()) {
|
|
|
|
|
this.$toolAll.tools.goPage('/pagesB/cart/cart')
|
|
|
|
|
}
|
2022-08-03 13:28:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style></style>
|