You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
high-mini/physical-merchants/classify/goodsDetail/goodsDetail.vue

743 lines
14 KiB

2 years ago
<template>
<view class="">
<!-- 商品主图轮播 -->
2 years ago
<view class="swiper-box" v-if="goodsDetail.bannerImg">
2 years ago
<swiper circular="true" :autoplay="false" style="height: 288px;" @change="swiperChange">
2 years ago
<swiper-item class="fotct" v-for="(swiper,index) in goodsDetail.bannerImg" :key="index">
<image mode="heightFix" style="height: 100%;" :src="swiper" @click="perImage(index,goodsDetail.bannerImg)"></image>
2 years ago
</swiper-item>
</swiper>
2 years ago
<view class="indicator">{{currentSwiper+1}}/{{goodsDetail.bannerImg.length}}</view>
2 years ago
</view>
2 years ago
2 years ago
<!-- 商品信息 -->
<view class="goods-container ">
<!-- 商品信息 -->
<view class="goods-message br bg-white marb10">
<view class="goods-price">
2 years ago
<text>&yen;{{goodsDetail.price}}</text>
<text class="old">&yen;{{goodsDetail.originalPrice}}</text>
</view>
2 years ago
<view class="goods-title">
2 years ago
<view class="goods-text">{{goodsDetail.name || ''}}</view>
<view class="goods-desc">{{goodsDetail.listDescribe || ''}}</view>
2 years ago
</view>
</view>
2 years ago
2 years ago
<!-- 选择参数 -->
<view class="br bg-white parameter width100 " @click="showPopup(1)">
2 years ago
<view class=" ">
2 years ago
选择
</view>
2 years ago
<view class="color999 font14">
2 years ago
规格
2 years ago
</view>
2 years ago
<view class="icon-ymt to-right"></view>
2 years ago
</view>
<!-- 保障 -->
<view class="br bg-white parameter width100 " @click="showPopup(2)">
2 years ago
<view class=" ">
2 years ago
保障
</view>
2 years ago
<view class="color999 font14">
2 years ago
破损包赔 · 假一赔四 · 退货运费险
</view>
2 years ago
<view class="icon-ymt to-right"></view>
2 years ago
</view>
2 years ago
2 years ago
<!--评论-->
2 years ago
<!-- <view class="br bg-white width100 marb10" @click="goComment">
2 years ago
<view class="parameter">
<view class="color999 " >
评论
</view>
<view class=" " >
</view>
<view class="icon-ymt to-right"></view>
</view>
2 years ago
</view> -->
2 years ago
<!-- 详情 -->
2 years ago
<view class="font13 goods-desc-img br tc marb10 colorccc">
2 years ago
商品详情
</view>
<view style="font-size: 0;" >
2 years ago
<image mode="widthFix" class="width100" v-for="(item,index) in goodsDetail.detailImg" :key="index"
2 years ago
:src="item" @click="perImage(index,goodsDetail.detailImg)">
2 years ago
</image>
</view>
<noMore></noMore>
</view>
2 years ago
2 years ago
<!-- 底部购物车 -->
<view class="uni-container">
2 years ago
<view class="goods-carts">
<uniGoodsNav :options="options" :fill="true" :button-group="buttonGroup" @click="onClick"
@buttonClick="buttonClick" />
</view>
2 years ago
</view>
2 years ago
2 years ago
<!-- 选择类别 -->
<wybPopup ref="popup" zIndex="999" height="500" type="bottom" width="500" :scrollY="true" radius="6" :showCloseIcon="true">
2 years ago
2 years ago
<cart-choose :goodsDetail="goodsDetail" :status="status" @refreshCartNum="refreshCartNum"
:specificationList="specificationList" @close="close"></cart-choose>
2 years ago
</wybPopup>
2 years ago
2 years ago
<!-- 保障 -->
2 years ago
<wybPopup ref="popup2" type="bottom" width="500" :scrollY="true" radius="6" :showCloseIcon="true">
2 years ago
2 years ago
<view class="choose-detail baozhang-detail">
2 years ago
<view>
2 years ago
<view class="baozhangTitle fontwig6 font16 mart10">
2 years ago
破损包退
2 years ago
</view>
<view class="baozhangDescDesc font13 mart10">
2 years ago
签收72小时之内发现商品破损或商品变形等保存有限证件商家24小时内响应并退款诚信用户享受极速退款
2 years ago
</view>
</view>
2 years ago
<view>
2 years ago
<view class="baozhangTitle fontwig6 font16 mart10">
假一赔四
</view>
<view class="baozhangDescDesc font13 mart10">
正品保障,假一赔四
</view>
</view>
2 years ago
<view>
2 years ago
<view class="baozhangTitle fontwig6 font16 mart10">
2 years ago
七天无理由退换
2 years ago
</view>
<view class="baozhangDescDesc font13 mart10">
满足相应条件时消费者可申请"七天无理由退换货"
</view>
</view>
2 years ago
2 years ago
<view class="fcorfff baozhang-btn " @click="closeBaoZhang">
我知道了
</view>
2 years ago
2 years ago
</view>
2 years ago
2 years ago
</wybPopup>
2 years ago
2 years ago
</view>
</template>
<script>
2 years ago
import noMore from '@/components/no-more/no-more.vue'
import wybPopup from '@/components/wyb-popup/wyb-popup.vue'
2 years ago
2 years ago
import cartChoose from '@/components/cart-choose/cart-choose.vue'
2 years ago
import uniGoodsNav from '@/components/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue'
2 years ago
import {
findGoodsDetailById,
getShoppingCartList,
insertShoppingCart,
findGoodsSkuByGoodsId
} from '@/Utils/physicalObject.js';
2 years ago
const app = getApp();
2 years ago
export default {
2 years ago
data() {
return {
imageUrl: app.globalData.imgUrl, //图片地址
2 years ago
//轮播图下标
currentSwiper: 0,
2 years ago
isStar: false,
2 years ago
//
2 years ago
options: [
2 years ago
// {
// icon: 'chat',
// text: '客服',
// }, {
// icon: 'shoucang31',
// text: '收藏',
// },
2 years ago
{
icon: 'cart',
text: '购物车',
info: 0,
color: "#646566"
}
],
2 years ago
buttonGroup: [{
text: '加入购物车',
backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)',
color: '#fff'
},
{
text: '立即购买',
backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
color: '#fff'
}
],
2 years ago
isShowCang: false,
2 years ago
// scIcon:'shoucang31-select'
// scIcon:'shoucang31'
2 years ago
goodsId: 0,
2 years ago
goodsDetail: {},
2 years ago
specificationList: [],
// 0,加入购物车,1:加入购物车,直接购买,2:直接购买
status: 1
2 years ago
}
},
watch: {
2 years ago
isShowCang: function(n) {
if (n) {
this.options[1].icon = "shoucang31-select"
} else {
this.options[1].icon = "shoucang31"
}
return
}
2 years ago
},
2 years ago
onLoad(options) {
2 years ago
this.goodsId = options.goodsId;
this.findGoodsById();
2 years ago
2 years ago
},
2 years ago
components: {
2 years ago
wybPopup,
cartChoose,
uniGoodsNav,
noMore
},
2 years ago
onShow() {
this.refreshCartNum();
2 years ago
// if(this.options[1].shoucang == true){
2 years ago
2 years ago
// }
2 years ago
2 years ago
// this.isStar=this.options[1].shoucang
2 years ago
2 years ago
// 判断是否收藏了该物品
2 years ago
2 years ago
// this.isShowCang?
2 years ago
2 years ago
},
2 years ago
methods: {
2 years ago
// 刷新购物车数量
2 years ago
refreshCartNum() {
getShoppingCartList().then(res => {
2 years ago
if (res.return_code == '000000') {
this.options[0].info = res.return_data.length;
2 years ago
} else {
2 years ago
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
}
2 years ago
})
2 years ago
},
2 years ago
findGoodsById() {
2 years ago
let _this = this;
2 years ago
let params = {
id: _this.goodsId
2 years ago
}
2 years ago
uni.showLoading({
title: '加载中',
mask: true,
});
findGoodsDetailById(params).then(res => {
uni.hideLoading();
2 years ago
if (res.return_code == '000000') {
2 years ago
this.goodsDetail = res.return_data;
this.goodsDetail.bannerImg = res.return_data.bannerImg.split(",").map(temp => this
.imageUrl + temp);
this.goodsDetail.detailImg = res.return_data.detailImg.split(",").map(temp => this
.imageUrl + temp);
console.log(this.goodsDetail, )
2 years ago
// let list =item.map(temp=>this.imageUrl + temp)
2 years ago
} else {
2 years ago
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
}
})
},
2 years ago
2 years ago
//显示弹出
2 years ago
showPopup(num) {
if (num == 1) { //选择规格弹出
this.status = 1;
this.findGoodsSku(this.goodsId);
} else if (num == 2) { //保障弹出
2 years ago
this.$refs.popup2.show();
}
2 years ago
2 years ago
},
//关闭选择参数
2 years ago
close() {
2 years ago
this.$refs.popup.hide();
},
//关闭保障--我知道了
2 years ago
closeBaoZhang() {
2 years ago
this.$refs.popup2.hide();
},
//查看大图
2 years ago
perImage(index, item) {
2 years ago
uni.previewImage({
current: Number(index), //预览图片的下标
urls: item //预览图片的地址,必须要数组形式,如果不是数组形式就转换成数组形式就可以
})
},
//轮播图指示器
swiperChange(event) {
this.currentSwiper = event.detail.current;
},
//点击去评论页面
2 years ago
goComment() {
2 years ago
//要判断评论条数
2 years ago
2 years ago
// uni.navigateTo({
// url: "../goods-comment/goods-comment?gid=" + 1598348
// })
2 years ago
},
2 years ago
2 years ago
// 客服,收藏,购物车图标点击事件
onClick(e) {
2 years ago
2 years ago
// 购物车
2 years ago
if (e.index == 0) {
// console.log("点击去购物车页面")
uni.navigateTo({
2 years ago
url: "/physical-merchants/classify/cart/cart"
2 years ago
})
2 years ago
return
2 years ago
2 years ago
}
// 收藏
2 years ago
// if(e.index == 1){
// this.isShowCang = !this.isShowCang;
// console.log("点击收藏")
// return
2 years ago
2 years ago
// }
2 years ago
// 购物车
2 years ago
// if(e.index == 2){
// console.log("点击去购物车")
// uni.navigateTo({
2 years ago
// url:"/physical-merchants/classify/cart/cart"
2 years ago
// })
// return
2 years ago
2 years ago
// }
2 years ago
2 years ago
// uni.showToast({
// title: `点击${e.content.text}`,
// icon: 'none'
// })
},
//加入购物车,立即购买按钮点击事件
buttonClick(e) {
2 years ago
this.findGoodsSku(this.goodsId);
2 years ago
// 加入购物车
2 years ago
if (e.index == 0) {
this.status = 0;
// console.log("加入购物车")
} else if (e.index == 1) {
this.status = 2;
// console.log("立即购买")
2 years ago
}
2 years ago
2 years ago
},
//加入购物车
2 years ago
toCart() {
let params = {
2 years ago
// goodsId:this.specificationList[this.chooseIndex].goodsId,
// num:this.chooseNumber,
// sku:this.specificationList[this.chooseIndex].id,
// whetherCheck:true
}
2 years ago
2 years ago
// insertShoppingCart(params).then(async res=>{
// let title ;
// if (res.return_code == '000000') {
// title = res.return_data;
// this.$emit("refreshCartNum")
2 years ago
2 years ago
// }else{
// title = res.return_msg;
// }
// uni.showToast({
// title: title,
// icon: 'none',
// duration: 2000
// })
2 years ago
2 years ago
// this.$emit("close")
2 years ago
2 years ago
// })
2 years ago
2 years ago
},
// 查询规格
2 years ago
findGoodsSku(id) {
2 years ago
this.specificationList = [];
2 years ago
let params = {
goodsId: id
2 years ago
};
2 years ago
findGoodsSkuByGoodsId(params).then(res => {
2 years ago
if (res.return_code == '000000') {
2 years ago
if (res.return_data && res.return_data.length > 0) {
2 years ago
this.specificationList = res.return_data;
this.$refs.popup.show();
2 years ago
} else {
2 years ago
this.specificationList = [];
}
2 years ago
} else {
2 years ago
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
}
2 years ago
2 years ago
})
2 years ago
2 years ago
},
2 years ago
2 years ago
}
}
</script>
<style lang="scss" scoped>
// 修改uni-goods-nav默认图标颜色
2 years ago
2 years ago
// 底部购物车
.goods-carts {
2 years ago
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
position: fixed;
left: 0;
right: 0;
/* #ifdef H5 */
left: var(--window-left);
right: var(--window-right);
/* #endif */
bottom: 0;
}
2 years ago
// 轮播图
2 years ago
.swiper-box {
2 years ago
position: relative;
width: 100%;
swiper {
width: 100%;
swiper-item {
image {
width: 100%;
}
}
}
.indicator {
display: flex;
justify-content: center;
align-items: center;
padding: 0 25upx;
height: 40upx;
border-radius: 40upx;
font-size: 22upx;
position: absolute;
bottom: 20upx;
right: 20upx;
color: #fff;
background-color: rgba(0, 0, 0, 0.2);
}
}
2 years ago
.tc {
text-align: center;
}
.br {
border-radius: 10rpx;
box-sizing: border-box;
padding: 20rpx;
}
.bg-white {
background-color: #fff;
}
.price-tag {
font-family: Arial;
font-weight: bold;
}
//商品详情
.goods-container {
padding: 20rpx 20rpx 60px;
background-color: #F6F6F6;
}
.goods-price {
font-family: Arial;
font-weight: bold;
color: red;
font-size: 28px;
.old {
text-decoration: line-through;
color: #CCCCCC;
display: inline-block;
padding-left: 20rpx;
font-size: 20px;
}
}
.goods-title {
2 years ago
width: 100%;
padding: 0 10rpx 0 0;
// height: 140rpx;
2 years ago
}
.goods-title .goods-text {
height: 50rpx;
line-height: 50rpx;
font-size: 30rpx;
padding: 20rpx 0 10rpx;
}
.goods-title .goods-desc {
height: 40rpx;
line-height: 40rpx;
font-size: 24rpx;
color: #999999;
}
//选择参数
.parameter {
display: flex;
justify-content: space-between;
2 years ago
align-items: center;
2 years ago
border-bottom: 1px solid #F6F6F6;
}
.parameter:last-of-type {
border-bottom: none
}
//popUp
.choose-detail {
position: relative;
2 years ago
//保障
&.baozhang-detail {
padding:30px 10px 10px;
2 years ago
box-sizing: border-box;
height:calc(100% - 100rpx);
2 years ago
.baozhangTitle {}
.baozhangDescDesc {
color: #999999;
}
.baozhang-btn {
position: fixed;
bottom: 20rpx;
width: calc(100% - 40rpx);
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
2 years ago
text-align: center;
background: linear-gradient(to right, #FF8E01, #FD5100);
}
2 years ago
}
2 years ago
//选择
// .choose-top {
// display: flex;
// align-items: center;
// height: 160rpx;
// color: red;
// .choose-img {
// width: 160rpx;
// height: 160rpx;
// border-radius: 20rpx;
// }
// .choose-price {
// }
// .choose-less-price {
// display: inline-block;
// height: 40rpx;
// line-height: 40rpx;
// padding:4rpx 10rpx;
// color: white;
// background-color:#F95100 ;
// border-radius: 20rpx;
// }
// }
// .choose-bottom {
// .choose-bottom-title{
// }
// .choose-select {
// .choose-item{
// display: flex;
// align-items: center;
// height: 60rpx;
// border-radius: 20rpx;
// overflow: hidden;
// background-color:#F6F6F6;
// border:1px solid transparent;
// width: fit-content;
// .img{
// width: 60rpx;
// height: 60rpx;
// }
// }
// .choose-active{
// border-color: #F95100;
// }
// }
// .choose-num{
// display: flex;
// height: 60rpx;
// justify-content: space-between;
// align-items: center;
// .choose-change{
// width: 240rpx;
// background-color:#F4F4F4;
// height: 100%;
// border-radius: 30rpx;
// display: flex;
// .number{
// // width: 80rpx;
// height: 60rpx;
// line-height: 60rpx;
// text-align: center;
// color: #333333;
// font-size: 30rpx;
// }
// .width140{
// width: 120rpx !important;
// }
// .wid25{
// width: 60rpx !important;
// background-color:#f8f8f8 ;
// border-radius: 30rpx;
// }
// }
// }
// }
// .choose-cart{
// position: fixed;
// bottom: 0;
// width: calc(100% - 40rpx);
// padding-bottom: 20rpx;
// .choose-way{
// height: 60rpx;
// width: 100%;
// border-radius: 30rpx;
// overflow: hidden;
// display: flex;
// align-items: center;
// .way{
// width: 50%;
// height: 60rpx;
// line-height: 60rpx;
// text-align: center;
// }
// .bgcolor-ri{
// background-color: #FD5100;
// }
// .bgcolor-left{
// background-color: #FF8E01;
// }
// }
// }
2 years ago
}
2 years ago
//商品信息图片
.goods-desc-img {}
</style>