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.
 
 
 
 

669 lines
23 KiB

<template>
<view style="background-color: #fff;">
<view class="">
<view class="info_box">
<view class="left" @click="goDetail">
<view class="l_left">
<image :src="info.logo" mode=""></image>
</view>
<view class="l_right" style="padding-bottom: 10rpx;">
<view class="l_r_top">
{{info.name}} <text style="color: #999; margin-left: 10rpx;" class="iconfont icon-arrow-right"></text>
</view>
<view class="l_r_bot">
<text>粉丝数 {{info.fans_count}}</text>
</view>
</view>
</view>
<view class="right" @click="followFn" :style="{border:info.isFollow?'1px solid '+t('color1')+'':'',color:info.isFollow?t('color1'):'#fff','background-color':info.isFollow?'':t('color1')}">
{{info.isFollow?'已关注':'关注'}}
</view>
</view>
<view class="head_max_box">
<view class="item" @click="tabClick(0)" :style="{color:tabIndex == 0?'#fff':'#333','background-color': tabIndex == 0?t('color1'):''}">
商品
</view>
<view class="item" @click="tabClick(1)" :style="{color:tabIndex == 1?'#fff':'#333','background-color': tabIndex == 1?t('color1'):''}">
领券
</view>
</view>
<view class="conteont" v-if="tabIndex == 0">
<view class="serach_tab">
<view class="serach_box">
<text class="iconfont icon-search" :style="{color:t('color1'),'font-size':'46rpx'}"></text>
<!-- <input type="text" v-model="keyword" placeholder="请输入搜索内容" /> -->
<input :value="keyword" placeholder="搜索感兴趣的商品" placeholder-style="font-size:24rpx;color:#C2C2C2" @confirm="searchConfirm" @input="searchChange"></input>
</view>
<view class="head_box">
<view class="item" :class="{'itemz':!field||field=='sort'}" @tap.stop="sortClick" data-field="sort" data-order="desc">
<text class="txt">综合</text>
</view>
<view class="item" :class="{'itemz':field=='sales'}" @tap.stop="sortClick" data-field="sales" data-order="desc">
<text class="txt">销量</text>
</view>
<view class="item" :class="{'itemz':field=='createtime'}" @tap.stop="sortClick" data-field="createtime" data-order="desc">
<text class="txt">新品</text>
</view>
<view class="item" :class="{'itemz':field=='sell_price'}" @tap.stop="sortClick" data-field="sell_price" :data-order="order=='asc'?'desc':'asc'">
<text class="txt">价格</text>
</view>
</view>
</view>
<view class="product-container">
<block v-if="datalist && datalist.length>0">
<dp-product-item v-if="productlisttype=='item2'" :data="datalist" :menuindex="menuindex"></dp-product-item>
<dp-product-itemlist v-if="productlisttype=='itemlist'" :data="datalist" :menuindex="menuindex"></dp-product-itemlist>
</block>
<nomore text="没有更多商品了" v-if="nomore"></nomore>
<nodata text="没有查找到相关商品" v-if="nodata"></nodata>
<loading v-if="loading"></loading>
</view>
</view>
<view class="conteont" v-if="tabIndex == 1">
<view class="coupon-list">
<view v-for="(item, index) in datalist" :key="item.id" style="display: flex; position: relative;" @tap.stop="goto" :data-url="'coupondetail?id=' + item.id">
<image style="position: absolute; width: 100%; height: 100%;" :src="event_rul + '/static/img/static/icon/b857ece13154962c055e341ca457d37d_thumb.png'" mode=""></image>
<image v-if="(item.haveget>=item.perlimit) ||item.stock<=0 " style="position: absolute; width: 16.5%; height: 100%; right: 0;" :src="event_rul + '/static/img/static/icon/926b1fd8b5d002dc4c2a3d00be8b2c57.png'" mode=""></image>
<image v-else style="position: absolute; width: 16.5%; height: 100%; right: 0;" :src="event_rul + '/static/img/static/icon/c4c6ce333b8b8943564cfa36d830cfda.png'" mode=""></image>
<view class="coupon" style="flex: 1;">
<view class="pt_left">
<view class="pt_left-content">
<view class="f1" :style="{color:t('color1')}" v-if="item.type==1"><text class="t0">¥</text><text class="t1">{{item.money}}</text></view>
<view class="f1" :style="{color:t('color1')}" v-if="item.type==2">礼品券</view>
<view class="f1" :style="{color:t('color1')}" v-if="item.type==3"><text class="t1">{{item.limit_count}}</text><text class="t2">次</text></view>
<view class="f1" :style="{color:t('color1')}" v-if="item.type==4">抵运费</view>
<view class="f1" :style="{color:t('color1')}" v-if="item.type==5"><text class="t0">¥</text><text class="t1">{{item.money}}</text></view>
<view class="f2" :style="{color:t('color1')}" v-if="item.type==1 || item.type==4 || item.type==5">
<text v-if="item.minprice>0">满{{item.minprice}}元可用</text>
<text v-else>无门槛</text>
</view>
</view>
</view>
<view class="pt_right">
<view class="f1">
<view class="t1">{{item.name}}</view>
<text class="t2" :style="{background:'rgba('+t('color1rgb')+',0.1)',color:t('color1')}" v-if="item.type==1">代金券</text>
<text class="t2" :style="{background:'rgba('+t('color1rgb')+',0.1)',color:t('color1')}" v-if="item.type==2">礼品券</text>
<text class="t2" :style="{background:'rgba('+t('color1rgb')+',0.1)',color:t('color1')}" v-if="item.type==3">计次券</text>
<text class="t2" :style="{background:'rgba('+t('color1rgb')+',0.1)',color:t('color1')}" v-if="item.type==4">运费抵扣券</text>
<text class="t2" :style="{background:'rgba('+t('color1rgb')+',0.1)',color:t('color1')}" v-if="item.type==5">餐饮券</text>
<view class="t4" v-if="item.bid>0">适用商家:{{item.bname}}</view>
<view class="t3" :style="item.bid>0?'margin-top:0':'margin-top:10rpx'">有效期至 {{item.yxqdate}}</view>
</view>
<!-- <button class="btn" v-if="item.haveget>=item.perlimit" style="background:#9d9d9d">已领取</button> -->
<!-- <button class="btn" v-else-if="item.stock<=0" style="background:#9d9d9d">已抢光了</button> -->
<!-- <button class="btn" :style="{background:'linear-gradient(270deg,'+t('color1')+' 0%,rgba('+t('color1rgb')+',0.8) 100%)'}" v-else @tap.stop="getcoupon" :data-id="item.id" :data-price="item.price" :data-score="item.score" :data-key="index">{{item.price > 0 ? '购买' : (item.score>0?'兑换':'领取')}}</button> -->
</view>
</view>
<view class="max_right" style="z-index: 1;">
<view v-if="item.haveget>=item.perlimit" class="box">
已领取过
</view>
<view v-else-if="item.stock<=0" class="box">
已抢光了
</view>
<view v-else class="box" @click.stop="drawCoupon(item.id)">
立即领取
</view>
</view>
</view>
</view>
<nodata v-if="nodata" :text="'暂无可领' + t('优惠券')"></nodata>
<nomore v-if="nomore"></nomore>
</view>
</view>
<loading v-if="loading"></loading>
<dp-tabbar :opt="opt" @getmenuindex="getmenuindex"></dp-tabbar>
<popmsg ref="popmsg"></popmsg>
</view>
</template>
<script>
var app = getApp();
export default {
data() {
return {
info:{},
tabIndex:0,
opt:{},
loading:false,
isload: false,
menuindex:-1,
nomore:false,
nodata:false,
keyword: '',
pagenum: 1,
datalist: [],
history_list: [],
history_show: false,
order: '',
field:'',
oldcid: "",
catchecid: "",
catchegid: "",
cid: "",
gid: '',
cid2:'',
oldcid2: "",
catchecid2: "",
clist: [],
clist2: [],
glist: [],
productlisttype: 'item2',
showfilter: "",
cpid:0,
bid:0,
event_rul: app.globalData.event_url,
};
},
onLoad: function (opt) {
this.opt = app.getopts(opt);
this.oldcid = this.opt.cid || '';
this.catchecid = this.opt.cid;
this.cid = this.opt.cid;
this.cid2 = this.opt.cid2 || '';
this.oldcid2 = this.opt.cid2 || '';
this.catchecid2 = this.opt.cid2;
this.gid = this.opt.gid;
this.cpid = this.opt.cpid || 0;
this.bid = this.opt.bid ? this.opt.bid : 0;
//console.log(this.bid);
if(this.cpid > 0){
uni.setNavigationBarTitle({
title: '可用商品列表'
});
}
var productlisttype = app.getCache('productlisttype');
if (productlisttype) this.productlisttype = productlisttype;
this.history_list = app.getCache('search_history_list');
this.getdata();
this.getInfo();
},
onPullDownRefresh: function () {
this.getdata();
},
onReachBottom: function () {
if (!this.nodata && !this.nomore) {
this.pagenum = this.pagenum + 1;
if(this.tabIndex == 0){
this.getprolist();
}else{
this.getCoupon();
}
}
},
methods: {
// 点击领取优惠券
drawCoupon(id) {
app.post('ApiCoupon/getcoupon', {id:id}, res => {
app.error(res.msg)
})
},
goDetail(){
uni.navigateTo({
url:'/pages/store/detail?id='+this.opt.id
})
},
followFn(){
var that = this;
app.post('ApiMy/addFollow', {follow_id: that.opt.id ||'',type:'store'}, function (res) {
console.log(res)
uni.showToast({
title:res.msg,
icon:'none'
})
that.getInfo()
// that.info = res.business
})
},
getInfo(){
var that = this;
app.get('ApiBusiness/newIndex', {id: that.opt.id ||''}, function (res) {
console.log(res)
that.info = res.business
})
},
getCoupon: function () {
var that = this;
var pagenum = that.pagenum;
var st = that.st;
var bid = that.opt && (that.opt.bid || that.opt.bid === '0') ? that.opt.bid : '';
that.loading = true;
that.nomore = false;
that.nodata = false;
app.post('ApiCoupon/couponlist', {st: st,pagenum: pagenum,bid: that.opt.id}, function (res) {
that.loading = false;
var data = res.data;
if (pagenum == 1) {
that.datalist = data;
if (data.length == 0) {
that.nodata = true;
}
}else{
if (data.length == 0) {
that.nomore = true;
} else {
var datalist = that.datalist;
var newdata = datalist.concat(data);
that.datalist = newdata;
}
}
that.loaded();
});
},
getcoupon: function (e) {
var that = this;
var datalist = that.datalist;
var id = e.currentTarget.dataset.id;
var score = parseInt(e.currentTarget.dataset.score);
var price = e.currentTarget.dataset.price;
if (price > 0) {
app.post('ApiCoupon/buycoupon', {id: id}, function (res) {
if(res.status == 0) {
app.error(res.msg);
} else {
app.goto('/pages/pay/pay?id=' + res.payorderid);
}
})
return;
}
var key = e.currentTarget.dataset.key;
if (score > 0) {
app.confirm('确定要消耗' + score + '' + that.t('积分') + '兑换吗?', function () {
app.showLoading('兑换中');
app.post('ApiCoupon/getcoupon', {id: id}, function (data) {
app.showLoading(false);
if (data.status == 0) {
app.error(data.msg);
} else {
app.success(data.msg);
datalist[key]['haveget'] = data.haveget;
that.datalist = datalist;
}
});
});
} else {
app.showLoading('领取中');
app.post('ApiCoupon/getcoupon', {id: id}, function (data) {
app.showLoading(false);
if (data.status == 0) {
app.error(data.msg);
} else {
app.success(data.msg);
datalist[key]['haveget'] = data.haveget;
that.datalist = datalist;
}
});
}
},
tabClick(e){
this.pagenum = 1;
this.datalist = [];
this.tabIndex = e;
if(e == 0){
this.getdata();
}else{
this.getCoupon()
}
},
getdata:function(){
var that = this;
that.pagenum = 1;
that.datalist = [];
var cid = that.opt.cid;
var gid = that.opt.gid;
var bid = that.opt.id ? that.opt.id : '';
var cid2 = that.cid2;
that.loading = true;
app.get('ApiShop/prolist', {cid: cid,gid: gid,bid:bid,cid2:cid2}, function (res) {
that.loading = false;
that.clist = res.clist;
that.clist2 = res.clist2;
that.glist = res.glist;
that.loaded();
that.getprolist();
});
},
getprolist: function () {
var that = this;
var pagenum = that.pagenum;
var keyword = that.keyword;
var order = that.order;
var field = that.field;
var gid = that.gid;
var cid = that.cid;
var cid2 = that.cid2;
var cpid = that.cpid;
that.history_show = false;
that.loading = true;
that.nodata = false;
that.nomore = false;
var bid = that.opt.id ? that.opt.id : '';
app.post('ApiShop/getprolist',{pagenum: pagenum,keyword: keyword,field: field,order: order,gid: gid,cid: cid,cid2:cid2,cpid:cpid,bid:bid}, function (res) {
that.loading = false;
var data = res.data;
if (pagenum == 1) {
that.datalist = data;
if (data.length == 0) {
that.nodata = true;
}
}else{
if (data.length == 0) {
that.nomore = true;
} else {
var datalist = that.datalist;
var newdata = datalist.concat(data);
that.datalist = newdata;
}
}
});
},
// 打开窗口
showDrawer(e) {
console.log(e)
this.$refs[e].open()
},
// 关闭窗口
closeDrawer(e) {
this.$refs[e].close()
},
// 抽屉状态发生变化触发
change(e, type) {
console.log((type === 'showLeft' ? '左窗口' : '右窗口') + (e ? '打开' : '关闭'));
this[type] = e
},
searchChange: function (e) {
this.keyword = e.detail.value;
if (e.detail.value == '') {
this.history_show = true;
this.datalist = [];
}
},
searchbtn: function () {
var that = this;
if (that.history_show) {
var keyword = that.keyword;
that.searchproduct();
} else {
if (that.productlisttype == 'itemlist') {
that.productlisttype = 'item2';
app.setCache('productlisttype', 'item2');
} else {
that.productlisttype = 'itemlist';
app.setCache('productlisttype', 'itemlist');
}
}
},
searchConfirm: function (e) {
var that = this;
var keyword = e.detail.value;
that.keyword = keyword
that.searchproduct();
},
searchproduct: function () {
var that = this;
that.pagenum = 1;
that.datalist = [];
that.addHistory();
that.getprolist();
},
sortClick: function (e) {
var that = this;
var t = e.currentTarget.dataset;
that.field = t.field;
that.order = t.order;
that.searchproduct();
},
groupClick: function (e) {
var that = this;
var gid = e.currentTarget.dataset.gid;
if(gid === true) gid = '';
that.catchegid = gid
},
cateClick: function (e) {
var that = this;
var cid = e.currentTarget.dataset.cid;
if(cid === true) cid = '';
that.catchecid = cid
},
cate2Click: function (e) {
var that = this;
var cid2 = e.currentTarget.dataset.cid2;
if(cid2 === true) cid2 = '';
that.catchecid2 = cid2
},
filterConfirm(){
this.cid = this.catchecid;
this.cid2 = this.catchecid2;
this.gid = this.catchegid;
this.searchproduct();
this.$refs['showRight'].close()
},
filterReset(){
this.catchecid = this.oldcid;
this.catchecid2 = this.oldcid2;
this.catchegid = '';
},
filterClick: function () {
this.showfilter = !this.showfilter
},
addHistory: function () {
var that = this;
var keyword = that.keyword;
if (app.isNull(keyword)) return;
var historylist = app.getCache('search_history_list');
if (app.isNull(historylist)) historylist = [];
historylist.unshift(keyword);
var newhistorylist = [];
for (var i in historylist) {
if (historylist[i] != keyword || i == 0) {
newhistorylist.push(historylist[i]);
}
}
if (newhistorylist.length > 5) newhistorylist.splice(5, 1);
app.setCache('search_history_list', newhistorylist);
that.history_list = newhistorylist
},
historyClick: function (e){
var that = this;
var keyword = e.currentTarget.dataset.value;
if (keyword.length == 0) return;
that.keyword = keyword;
that.searchproduct();
},
deleteSearchHistory: function () {
var that = this;
that.history_list = null;
app.removeCache("search_history_list");
}
}
};
</script>
<style lang="scss">
.max_right{
z-index: 1;
/* width: 100%; */
display: flex;
justify-content: center;
margin-right: 14rpx;
align-items: center;
.box{
font-size: 32prx;
color: #fff;
/* padding-right: 9rpx; */
/* height: 100%; */
/* margin-left: -20rpx; */
width: 70rpx;
}
}
.serach_tab{
background-color: #fff;
// display: flex;
// align-items: center;
padding:0 20rpx;
padding-top: 30rpx;
.serach_box{
display: flex;
align-items: center;
.iconfont{
margin: 0 20rpx;
}
height:60rpx;border-radius:30rpx;border:0;background-color:#f7f7f7;flex:1;
input{height:100%;flex:1;padding:0 20rpx;font-size:28rpx;color:#333;}
}
}
.head_box{
background-color: #fff;
display: flex;
align-items: center;
padding: 30rpx 20rpx 30rpx 0rpx;
// justify-content: space-between;
.item{
margin-right: 20rpx;
}
.itemz{
font-size: 30rpx;
color: #efbd6f;
font-weight: bold;
}
}
.head_max_box{
background-color: #FFFFFF;
display: flex;
.item{
flex: 1;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
border-radius: 10rpx;
}
}
.info_box{
display: flex;
align-items: center;
padding: 30rpx 20rpx;
justify-content: space-between;
.left{
display: flex;
flex: 1;
.l_left{
margin-right: 14rpx;
image{
width:120rpx;
height: 120rpx;
border-radius: 10rpx;
border-radius: 10rpx;
}
}
.l_right{
display: flex;
flex-direction: column;
justify-content: space-between;
.l_r_top{
font-size: 32rpx;
font-weight: bold;
}
.l_r_bot{
display: flex;
align-items:center;
font-size: 24rpx;
color: #999;
.iconfont{
margin-left: 14rpx;
}
}
}
}
.right{
width: 120rpx;
text-align: center;
font-size: 24rpx;
padding: 10rpx 20rpx;
// border: ;
border-radius: 10rpx;
color: #999;
}
}
.coupon-list{width:100%;padding:20rpx}
.coupon{flex: 1; z-index: 1; display:flex;border-radius:10rpx;overflow:hidden}
.coupon .pt_left{min-height:200rpx;color: #FFF;width:30%;display:flex;flex-direction:column;align-items:center;justify-content:center}
.coupon .pt_left-content{width:100%;height:100%;margin:30rpx 0;border-right:1px solid #EEEEEE;display:flex;flex-direction:column;align-items:center;justify-content:center}
.coupon .pt_left .f1{font-size:40rpx;font-weight:bold;text-align:center;}
.coupon .pt_left .t0{padding-right:0;}
.coupon .pt_left .t1{font-size:60rpx;}
.coupon .pt_left .t2{padding-left:10rpx;}
.coupon .pt_left .f2{font-size:20rpx;color:#4E535B;text-align:center;}
.coupon .pt_right{width:70%;display:flex;min-height:200rpx;text-align: left;padding:20rpx 20rpx;position:relative}
.coupon .pt_right .f1{flex-grow: 1;flex-shrink: 1;}
.coupon .pt_right .f1 .t1{font-size:28rpx;color:#2B2B2B;font-weight:bold;height:60rpx;line-height:60rpx;overflow:hidden}
.coupon .pt_right .f1 .t2{height:36rpx;line-height:36rpx;font-size:20rpx;font-weight:bold;padding:0 16rpx;border-radius:4rpx}
.coupon .pt_right .f1 .t3{font-size:20rpx;color:#999999;height:46rpx;line-height:46rpx;}
.coupon .pt_right .f1 .t4{font-size:20rpx;color:#999999;height:46rpx;line-height:46rpx;}
.coupon .pt_right .btn{position:absolute;right:30rpx;top:50%;margin-top:-28rpx;border-radius:28rpx;width:160rpx;height:56rpx;line-height:56rpx;color:#fff}
.coupon .pt_right .sygq{position:absolute;right:30rpx;top:50%;margin-top:-50rpx;width:100rpx;height:100rpx;}
.search-container {position: fixed;width: 100%;background: #fff;z-index:9;top:var(--window-top)}
.topsearch{width:100%;padding:16rpx 20rpx;}
.topsearch .f1{height:60rpx;border-radius:30rpx;border:0;background-color:#f7f7f7;flex:1}
.topsearch .f1 .img{width:24rpx;height:24rpx;margin-left:10px}
.topsearch .f1 input{height:100%;flex:1;padding:0 20rpx;font-size:28rpx;color:#333;}
.topsearch .search-btn{display:flex;align-items:center;color:#5a5a5a;font-size:30rpx;width:60rpx;text-align:center;margin-left:20rpx}
.search-navbar {display: flex;text-align: center;align-items:center;padding:5rpx 0}
.search-navbar-item {flex: 1;height: 70rpx;line-height: 70rpx;position: relative;font-size:28rpx;font-weight:bold;color:#323232}
.search-navbar-item .iconshangla{position: absolute;top:-4rpx;padding: 0 6rpx;font-size: 20rpx;color:#7D7D7D}
.search-navbar-item .icondaoxu{position: absolute;top: 8rpx;padding: 0 6rpx;font-size: 20rpx;color:#7D7D7D}
.search-navbar-item .iconshaixuan{margin-left:10rpx;font-size:22rpx;color:#7d7d7d}
.search-history {padding: 24rpx 34rpx;}
.search-history .search-history-title {color: #666;}
.search-history .delete-search-history {float: right;padding: 15rpx 20rpx;margin-top: -15rpx;}
.search-history-list {padding: 24rpx 0 0 0;}
.search-history-list .search-history-item {display: inline-block;height: 50rpx;line-height: 50rpx;padding: 0 20rpx;margin: 0 10rpx 10rpx 0;background: #ddd;border-radius: 10rpx;font-size: 26rpx;}
.filter-scroll-view{margin-top:var(--window-top)}
.search-filter{display: flex;flex-direction: column;text-align: left;width:100%;flex-wrap:wrap;padding:0;}
.filter-content-title{color:#999;font-size:28rpx;height:30rpx;line-height:30rpx;padding:0 30rpx;margin-top:30rpx;margin-bottom:10rpx}
.filter-title{color:#BBBBBB;font-size:32rpx;background:#F8F8F8;padding:60rpx 0 30rpx 20rpx;}
.search-filter-content{display: flex;flex-wrap:wrap;padding:10rpx 20rpx;}
.search-filter-content .filter-item{background:#F4F4F4;border-radius:28rpx;color:#2B2B2B;font-weight:bold;margin:10rpx 10rpx;min-width:140rpx;height:56rpx;line-height:56rpx;text-align:center;font-size: 24rpx;padding:0 30rpx}
.search-filter-content .close{text-align: right;font-size:24rpx;color:#ff4544;width:100%;padding-right:20rpx}
.search-filter button .icon{margin-top:6rpx;height:54rpx;}
.search-filter-btn{display:flex;padding:30rpx 30rpx;justify-content: space-between}
.search-filter-btn .btn{width:240rpx;height:66rpx;line-height:66rpx;background:#fff;border:1px solid #e5e5e5;border-radius:33rpx;color:#2B2B2B;font-weight:bold;font-size:24rpx;text-align:center}
.search-filter-btn .btn2{width:240rpx;height:66rpx;line-height:66rpx;border-radius:33rpx;color:#fff;font-weight:bold;font-size:24rpx;text-align:center}
.product-container {width: 100%;font-size:26rpx;padding:0 24rpx}
</style>