123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- <template>
- <!--
- @copyright CYZ
- @time 2022/8/5
- 商品列表(公益福利购、免费领、做公益等页面)
- -->
- <view class="main">
- <view v-if="hasFilter" class="tab-box" :style="`top: calc(${statusBarHeight}px + 44px)`">
- <view @click="tabClick(index)" class="tab" :class="tabActiveIndex==index?'active':''" v-for="(item,index) in tabList" :key="index">{{item.text}}<text v-if="item.hasIcon" class="iconfont2"></text></view>
- </view>
- <view v-if="hasFilter" class="split"></view>
- <view>
- <view class="list-box">
- <view class="list" v-for="(item,index) in listData" :key="index">
- <view class="item" @click="toDetail(item)">
- <image class="cover" mode="aspectFill" :src="item.cover"></image>
- <view class="content">
- <view class="title-box">
- <image v-if="item.area_feature==2" class="tag" mode="aspectFit" src="/static/common/tag6.png"></image>
- <image v-if="item.area_feature==3" class="tag" mode="aspectFit" src="/static/common/tag2.png"></image>
- <text class="title">{{item.title}}</text>
- </view>
- <view class="desc-box">
- <view class="left">
- <template v-if="!item.free">
- <template v-if="!item.point_goods">
- <text class="new-price">
- <text class="company">¥</text>
- <text class="integer">{{formatPrice(item.min_sale_price,'int')}}.</text>
- <text class="float">{{formatPrice(item.min_sale_price,'float')}}</text>
- </text>
- <text class="old-price">¥{{item.min_market_price}}</text>
- </template>
- <template v-else>
- <text class="iconfont2 integral-icon"></text>
- <text class="integral-num">{{item.min_exchange_point}}</text>
- </template>
- </template>
- <template v-if="item.free">
- <image class="tag2" mode="aspectFit" src="/static/common/tag3.png"></image>
- </template>
- </view>
- <text v-if="item.free || item.point_goods" class="have">{{item.result_sale_num}}件已{{item.free?'申领':'出售'}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- //area_feature 区域类型: 0服务体系礼包 1新人专区 2公益申领专区
- export default{
- props: {
- //是否有过滤条件
- hasFilter:{
- type: Boolean,
- default: true
- },
- //是否有分页
- hasPage:{
- type: Boolean,
- default: true
- },
- listData:{
- type: Array,
- default: ()=>{
- return []
- }
- }
- },
- data(){
- return {
- //手机状态栏高度
- statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
- tabList: [{
- text: '综合',
- hasIcon: false,
- sort: ''
- },{
- text: '最新',
- hasIcon: false,
- sort: ''
- },{
- text: '价格',
- hasIcon: true,
- sort: '' // asc或desc
- },{
- text: '销量',
- hasIcon: true,
- sort: '' // asc或desc
- }],
- tabActiveIndex: 0
- }
- },
- created() {},
- methods:{
- /**
- * @param {Object} type int或float
- * description 格式化价格
- */
- formatPrice(price,type){
- let str = ''
- if(type=='int'){
- str = String(price).split('.')[0]
- }
- if(type=='float'){
- str = String(price).split('.').length <= 1?'00':(String(price).split('.')[1])
- }
- return str;
- },
- tabClick(index){
- let that = this;
- this.tabActiveIndex=index;
- if(index != 0 && index != 1){
- if(this.tabList[index].sort == ''){
- if(index == 2){
- this.tabList[index].sort = 'asc';
- }else if(index == 3){
- this.tabList[index].sort = 'desc';
- }
- }else{
- this.tabList[index].sort = this.tabList[index].sort =='asc'?'desc':'asc'
- }
- }
- this.$emit('tabChange',{
- index,
- sort: this.tabList[index].sort
- })
- },
- toDetail(item){
- uni.navigateTo({
- url: `/pages/product/goods/goods?id=${item.goods_id}`
- })
- // 积分商品
- // if(item.point_goods){
- // uni.navigateTo({
- // url: `/pages/product/goods/IntegralGood?id=${item.goods_id}`
- // })
- // // 免费商品
- // }else if(item.free){
- // uni.navigateTo({
- // url: `/pages/product/goods/freeGoods?id=${item.goods_id}`
- // })
- // // 普通商品
- // }else{
- // uni.navigateTo({
- // url: `/pages/product/goods/goods?id=${item.goods_id}`
- // })
- // }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .main{
- .split{
- width: 100%;
- height: 20rpx;
- background-color: #f7f7f7;
- }
- .tab-box{
- position: sticky;
- top: 0;
- left: 0;
- background-color: white;
- z-index: 50;
- height: 86rpx;
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 42rpx;
- box-sizing: border-box;
- border-bottom: none;
- .tab{
- height: 86rpx;
- line-height: 86rpx;
- font-size: 30rpx;
- font-family: PingFang SC, PingFang SC-Regular;
- font-weight: 400;
- text-align: left;
- color: #666666;
- &.active{
- font-weight: 700;
- color: #FA6138;
- }
- }
- }
- .list-box{
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: space-between;
- box-sizing: border-box;
- padding: 40rpx 30rpx;
- .list{
- display: flex;
- flex-direction: column;
- // flex: 1;
- width: 336rpx;
- .item{
- background-color: white;
- width: 100%;
- box-sizing: border-box;
- margin-bottom: 30rpx;
- border-radius: 18rpx;
- padding-bottom: 28rpx;
- filter: drop-shadow(1px 2px 4px rgba(26,58,70,0.1));
- height: 506rpx;
- .cover{
- height: 337rpx;
- width: 100%;
- background-color: #f7f7f7;
- display: block;
- margin-bottom: 10rpx;
- border-radius: 18rpx 18rpx 0 0;
- }
- .content{
- padding: 0 15rpx;
- .title-box{
- height: 75rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- .tag{
- vertical-align: middle;
- margin-right: 15rpx;
- width: 112rpx;
- height: 30rpx;
- line-height: 28rpx;
- }
- .title{
- font-size: 28rpx;
- line-height: 28rpx;
- color: #191919;
- }
- }
- .tag2{
- vertical-align: middle;
- margin-right: 15rpx;
- width: 101rpx;
- height: 33rpx;
- }
- .desc-box{
- margin-top: 22rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .left{
- line-height: 24rpx;
- .integral-icon{
- font-size: 50rpx;
- color: #22a736;
- vertical-align: middle;
- }
- .integral-num{
- font-size: 24rpx;
- font-family: PingFang SC, PingFang SC-Medium;
- font-weight: 500;
- text-align: left;
- color: #808080;
- line-height: 24rpx;
- }
- .new-price{
- font-family: PingFang SC, PingFang SC-Medium;
- font-weight: bold;
- text-align: left;
- color: #FF6600;
- line-height: 24rpx;
- .company{
- font-size: 20rpx;
- font-weight: 400;
- }
- .integer{
- font-size: 36rpx;
- }
- .float{
- font-size: 20rpx;
- font-weight: 400;
- }
- }
- .old-price{
- font-size: 22rpx;
- font-family: PingFang SC, PingFang SC-Medium;
- font-weight: 500;
- text-align: left;
- color: #999999;
- line-height: 24rpx;
- margin-left: 16rpx;
- text-decoration:line-through;
- }
- }
- .have{
- font-size: 24rpx;
- font-family: PingFang SC, PingFang SC-Regular;
- font-weight: 400;
- text-align: left;
- color: #999999;
- }
- }
- }
- }
- &:nth-child(1){
- margin-right: 9rpx;
- }
- &:nth-child(2){
- margin-left: 9rpx;
- }
- }
- }
- }
- </style>
|