完成商品页对接

This commit is contained in:
wangsongsole 2022-09-27 11:28:09 +08:00
parent 69ac837cd1
commit 3e17a193aa
2 changed files with 122 additions and 70 deletions

View File

@ -6,6 +6,7 @@
html {
font-size: 26.66666667vw;
height: 100%;
}
@ -49,7 +50,7 @@ img {
width: 100%;
position: relative;
margin-top: -0.4rem;
z-index: 1002;
z-index: 997;
}
#app .bottom {
@ -177,7 +178,7 @@ img {
}
.swiper-container {
height: 2.5rem;
height: 2.2rem;
}
.swiper-pagination-bullet {
@ -238,7 +239,6 @@ img {
.topBanner .banner {
height: 2.41rem;
margin: 0;
padding-top: 0.5rem;
}
#homepage h2 {
@ -274,16 +274,21 @@ img {
#homepage .bottom>img {
border-radius: 0.05rem;
margin-bottom: 0.14rem;
}
#rotation {
margin-top: 0.1rem;
}
#rotation .commodity {
width: 94%;
height: 2.5rem;
background: #FFFFFF;
height: 2.2rem;
border-radius: 0.05rem;
position: relative;
display: flex;
align-items: center;
background: #fff;
}
#rotation .swiper-wrapper {
@ -385,12 +390,13 @@ img {
}
/* 闁稿繑鍨跺畷鏌ュ箰婢舵劖灏<E58A96> */
#rotation .exchangeBtn {
.exchangeBtn {
width: 3.37rem;
height: 0.45rem;
background: #F98F5B;
border-radius: 0.21rem;
margin-bottom: 0.24rem;
margin-top: 0.24rem;
color: #AAAAAA;
font-size: 0.19rem;
display: flex;
@ -558,18 +564,27 @@ img.changegray {
/* overflow-y: auto; */
}
/* 闁活厸鏅犲Ο鈧柟鐑樺笧婢э拷 */
#matrix {
margin-top: 0.1rem;
}
#matrix .listcommity {
width: 94%;
position: relative;
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
display: grid;
grid-template-columns: repeat(3, 33.3%);
grid-gap: 0.2rem 0;
background: #fff;
box-sizing: border-box;
border-radius: 0.05rem;
padding: 0.2rem 0;
box-sizing: border-box;
justify-items: center;
align-items: center;
}
#matrix .listcommity li {
@ -577,7 +592,6 @@ img.changegray {
height: 1.85rem;
display: flex;
flex-direction: column;
margin: 0 0 0.17rem 0;
border-radius: 0.05rem;
position: relative;
border-radius: 0.08rem;
@ -589,12 +603,6 @@ img.changegray {
outline: 0.01rem solid #F9FAFA;
}
/* //閸熷棗鎼ч惌鈺呮█閸ユ崘绶<E5B498> */
#matrix .listcommity li:nth-child(3n+2) {
margin-right: calc((100% - 0.92*3.43rem)/2);
margin-left: calc((100% - 0.92*3.43rem)/2);
}
#matrix .listcommity li img {
width: 0.58rem;
@ -743,7 +751,7 @@ img.changegray {
.bottomBtn {
position: fixed;
bottom: 0rem;
z-index: 88;
z-index: 998;
left: 50%;
margin-left: -1.745rem;
}
@ -1067,7 +1075,7 @@ img.changegray {
position: fixed;
width: 0.3rem;
right: 0;
top: 0.2rem;
top: 0.8rem;
z-index: 1000;
}
@ -1397,19 +1405,21 @@ ul {
.title {
font-size: 0.19rem;
color: #0A0A0A;
display: flex;
align-items: flex-end;
width: 94%;
margin: 0.23rem auto;
margin: 0.20rem auto 0;
height: 0.3rem;
display: flex;
align-items: center;
}
.title>p {
margin: 0;
width: 100%;
}
.or {
width: 0.18rem;
height: 0.22rem;
width: auto;
height: 100%;
margin: 0;
margin-right: 0.05rem;
}

View File

@ -21,7 +21,13 @@
</head>
<body>
<div id="homepage">
<div id="homepage" :style="{background:
(viewConfig.backgroundImg.iswitch&&viewConfig.backgroundImg.bgImg?
`url(${viewConfig.backgroundImg.bgImg})`
:viewConfig.backgroundImg.bgColor),
backgroundSize: '100% 100%',
paddingBottom: (viewConfig.bottomBar.iswitch!=='1'||calculateTabLength()<2)?'0.14rem':'0.5rem'
}">
<div v-show="loading">
<preload-component />
</div>
@ -29,31 +35,45 @@
<!-- 配置的顶部banner -->
<div class="topBanner">
<div class="search-backpresty">
<img class="backpresty" @click="backHandler" v-if="goodsShow&&!iskey"
<div class="search-backpresty" :style="{
background:(viewConfig.search.iswitch==='1'?(viewConfig.search.bgColor):'none'),
position:(viewConfig.search.iswitch!=='1'?'fixed':'absolute')
}">
<img class="backpresty" @click="backHandler" v-if="goodsShow&&!isKey"
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/backprepageBtn.png"
alt="">
<div class="search-box">
<input type="text" class="search" placeholder="请输入关键字查找">
<div class="search-box" v-if="viewConfig.search.iswitch==='1'">
<input type="text" class="search" :style="{
color:viewConfig.search.fontColor,
textAlign:viewConfig.search.textAlign,
background:viewConfig.search.borderColor,
borderRadius:(viewConfig.search.shape==='circular'?'0.15rem':0) }"
:placeholder="viewConfig.search.placeholder">
<img class="search-img" src="./img/search.png" alt="">
</div>
</div>
<img class="banner" :src="topImg" alt="">
<img class="banner" :src="viewConfig.top_image" alt="">
</div>
<!-- 配置的图片 -->
<div class="autoImg">
<img src="./img/coupon.png" alt="">
<div class="autoImg" v-if="viewConfig.picture.img">
<img :src="viewConfig.picture.img" @click="autoImgHandle" alt="">
</div>
<!-- 配置的标题 -->
<div class="title">
<img src="./img/or.png" alt="" class="or">
<p>热销商品</p>
<div class="title" v-if="viewConfig.title.iswitch==='1'">
<img :src="viewConfig.title.pic" alt="" class="or" v-if="viewConfig.title.comstyle==='2'">
<p :style="{
color:viewConfig.title.fontColor,
fontSize:(viewConfig.title.fontSize==='1'?'0.13rem'
:(viewConfig.title.fontSize==='2'?'.16rem':'0.19rem')),
textAlign:viewConfig.title.textAlign }" v-if="viewConfig.title.comstyle==='1'">
{{viewConfig.title.text}}
</p>
</div>
<!-- 轮播展示 -->
<div id="rotation" v-if="layout=='2'">
<div id="rotation" v-if="viewConfig.list==='2'">
<div class="saleNull" v-if="!goodsNum">
<img src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/saleNull.png" alt="">
</div>
@ -88,26 +108,21 @@
:class="item.stock&&(item.stock<0||item.available!=1)&&(item.available!=2?'changegray':'')">
</div>
<p class="price">
原价¥180.60
原价¥{{item.origin_price}}
</p>
<p class="money">
券后价
<span class="sign"></span>
<span class="current-price">100</span>
<span class="current-price">{{item.coupon_price}}</span>
</p>
</div>
</div>
</div>
</div>
<div class="exchangeBtn"
:class="(gstatus!=1?describe.type:false)&&describe.type!=2&&(describe.content?'bottomBtn noexchangeBtn':'noexchangeBtn':describe.type)&&describe.type!=2&&(describe.content?'bottomBtn':'')"
:style="{background: bgcolor,color:ftcolor}" @click="exchangeBtn()">
立即兑换
</div>
</div>
<!-- 列表 展示-->
<div id="list" v-if="layout=='1'">
<div id="list" v-if="viewConfig.list==='1'">
<div class="saleNull" v-if="!goodsNum">
<img src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/saleNull.png" alt="">
</div>
@ -125,9 +140,11 @@
{{item.type==1?item.entity.product_name:item.entity.batch_goods_name}}</font>
<div class="details">
<p class="sign"></p>
<p class="price">15</p>
<p class="price">{{item.origin_price}}</p>
<p class="coupon">券后价</p>
<p class="original-price">原价¥20</p>
<p class="original-price">
原价¥{{item.coupon_price}}
</p>
</div>
</div>
</div>
@ -136,7 +153,7 @@
</div>
<!-- 矩阵展示 -->
<div id="matrix" v-if="layout=='3'">
<div id="matrix" v-if="viewConfig.list==='3'">
<div class="saleNull" v-if="!goodsNum">
<img src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/saleNull.png" alt="">
</div>
@ -164,10 +181,10 @@
</div>
<div class="detail-text">
<font>{{item.type==1?item.entity.product_name:item.entity.batch_goods_name}}</font>
<p class="original-price">原价¥25</p>
<p class="original-price">原价¥{{item.origin_price}}</p>
<p>
<span class="sign"></span>
<span class="price">20</span>
<span class="price">{{item.coupon_price}}</span>
<span class="coupon">券后价</span>
</p>
</div>
@ -175,10 +192,17 @@
</ul>
</div>
<div class="bottom" id="bottom" :class="layout==2?'tipset':''" v-show="describe.type">
<div class="bottom" id="bottom" :class="viewConfig.list===2?'tipset':''" v-show="describe.type">
<img :src="describe.bg_image" v-show="describe.type==1&&describe.bg_image">
<div v-html="describe.content" class="goodsTip" v-show="describe.type==3&&describe.content"></div>
</div>
<div class="exchangeBtn"
:class="(viewConfig.bottomBar.iswitch!=='1'||calculateTabLength()<2)?'bottomBtn':''"
v-if="viewConfig.list==='2'" :style="{background: viewConfig.bgcolor,color:viewConfig.font_color}"
@click="exchangeBtn()">
立即支付
</div>
</div>
@ -205,7 +229,7 @@
<!-- 弹出提示 -->
<div class="popboxshow" v-if="popboxshow&&popboxtype=='提示'" :class="popboxshow?'active':''">
<div class="tip">
<p :class="gstatus==4||gstatus==6?'yettip':''">{{tiptext}}</p>
<p :class="gstatus==4||gstatus==6?'yettip':''">{{tipText}}</p>
<span @click="successchangeBtn" :class="gstatus==4||gstatus==6?'yetexchange':''">知道了</span>
</div>
</div>
@ -222,7 +246,7 @@
src="http://lsxd-customcard-h5.oss-cn-hangzhou.aliyuncs.com/cardpwd/img/commimgs/close.png" alt=""
@click="closeBtn()">
<tab-component :current="1" />
<tab-component v-if="!suspension" :current="1" />
</div>
</body>
<script>
@ -231,7 +255,6 @@
data () {
return {
swiperDataList: [], //轮播
layout: 1,
maskshow: false,
promtshow: false,
promttip: '',
@ -241,18 +264,15 @@
suspension: false,
popboxshow: false,
popboxtype: '兑换',
topImg: '',
goodsShow: true,
goodsNum: false,
exchangeCommity: {}, //兑换选择的商品
bgcolor: '',
describe: {},
ftcolor: '',
iskey: true,
allgoods: [],
isKey: true,
showType: 0,
tiptext: '还没开始哟兑换时间为2021-12-05 12:12:12至2021-01-01 12:12:12',
tipText: '还没开始哟兑换时间为2021-12-05 12:12:12至2021-01-01 12:12:12',
successTip: '兑换成功请直接登录app使用',
viewConfig: {} //动态数据
}
},
components: {
@ -262,14 +282,13 @@
created () {
this.getGoods();
let productConfig = JSON.parse(sessionStorage.getItem('product_list'));
this.bgcolor = productConfig.button_color;
this.ftcolor = productConfig.font_color;
this.topImg = productConfig.top_image;
document.title = sessionStorage.getItem('title');
this.layout = productConfig.list;
this.iskey = sessionStorage.getItem('haskey');
this.isKey = sessionStorage.getItem('haskey');
this.describe = productConfig.describe;
this.viewConfig = productConfig
},
methods: {
tabHandle (id) {
this.tabActive = id
@ -278,19 +297,23 @@
closeTip () {
this.suspension = false;
},
susTipFn () {
this.suspension = true;
},
onSelected (item) {
this.exchangeCommity = item;
this.gstatus = item.available;
},
backHandler () {
let backUrl = window.history.length;
if (window.history.length) {
history.go(-backUrl + 1);
}
},
// 单条弹框
openDialog () {
this.promtshow = true;
@ -299,6 +322,7 @@
this.promttip = '';
}, 3000)
},
//根据token获取商品信息
async getGoods () {
let self = this;
@ -323,7 +347,7 @@
self.maskshow = true;
self.popboxtype = '提示';
self.popboxshow = true;
self.tiptext = res.message;
self.tipText = res.message;
if (res.code == -1) {
setTimeout(() => {
window.location.href = sessionStorage.getItem('white_link');
@ -407,6 +431,7 @@
req.axiosPost('/key/products', data).then(res => {
if (res.code == 200) {
self.swiperDataList = res.data;
console.log(res.data);
sessionStorage.setItem('goodsCount', res.data.length);
self.goodsShow = res.data.length > 1;
if (res.data && res.data.length == 1) {//单个商品直接进入详情页面
@ -438,7 +463,7 @@
self.maskshow = true;
self.popboxtype = '提示';
self.popboxshow = true;
self.tiptext = res.message;
self.tipText = res.message;
if (res.code == -1) {
let haskey = sessionStorage.getItem('haskey');
if (haskey) {
@ -457,6 +482,7 @@
});
}
},
//选择商品点击兑换
exchangeBtn (row = this.exchangeCommity) {
let gstatus = row.available;
@ -469,14 +495,15 @@
}
sessionStorage.setItem('goodsInfo', JSON.stringify(row));
//type :1 兑换码 2:立减金
window.location.replace(row.type == 1 ? "./exchange.html" : "./reduce.html");
window.location.replace("./exchange.html");
} else {
this.maskshow = true;
this.popboxshow = true;
this.popboxtype = '提示';
this.tiptext = product_status(gstatus, row);
this.tipText = product_status(gstatus, row);
}
},
//关闭,关闭弹框
closeBtn () {
this.popboxshow = false;
@ -485,6 +512,13 @@
window.history.go(0);
}
},
/* 判Tab长度 */
calculateTabLength () {
return this.viewConfig.bottomBar.navlist.filter(item => item.iswitch === '1').length
},
//关闭弹出框,仅关闭弹框
successchangeBtn () {
this.maskshow = false;
@ -493,9 +527,17 @@
window.history.go(0);
}
},
//刷新页面
successchangeBtnFn () {
window.history.go(0);
},
/* 图片跳转 */
autoImgHandle () {
if (this.viewConfig.jumpType === '1') {
window.location.href = this.viewConfig.jumpUrl
}
}
}
})