完成商品页对接

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

View File

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