123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 |
- <!-- 金刚区商品模块 -->
- <template>
- <view class="container commodity-list-wrapper" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
- <list-skeleton v-if="showSkeleton" :listType='0'></list-skeleton>
- <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="toLower" scroll-y v-if="listData.length > 0">
- <view v-for="(item,index) in listData" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">
- <image mode='widthFix' :src="item.mainImage" class="list-img" alt="list-img"></image>
- <view class="list-details-info">
- <text class="list-details-title">{{item.name}}</text>
- <text class="list-details-specs">规格:{{item.unit}}</text>
- <view class="list-details-specs" v-if="item.productCode!=''&&item.productCode!=null">商品编码:{{item.productCode}}</view>
- <view class="list-details-price">
- <template v-if="userIdentity == 3">
- <view class="floor-item-act" v-if="item.actStatus==1">
- <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
- {{item.promotions.name}}<text v-if="item.price1TextFlag != '1' && item.supplierId === shopId">:¥{{ item.price | NumFormat }}</text>
- </view>
- <view class="floor-tags" v-else>{{item.promotions.name}}</view>
- </view>
- <view class="floor-item-act" v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
- <view class="floor-tags">阶梯价格</view>
- </view>
- </template>
- <template v-else>
- <view class="floor-item-act" v-if="item.actStatus==1">
- <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
- {{item.promotions.name}}<text v-if="hasLogin && item.price1TextFlag != '1'">:¥{{ item.price | NumFormat }}</text>
- </view>
- <view class="floor-tags" v-else>{{item.promotions.name}}</view>
- </view>
- <view class="floor-item-act" v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
- <view class="floor-tags">阶梯价格</view>
- </view>
- </template>
- <view v-if="hasLogin" class="list-price">
- <view v-if="userIdentity == 1">
- <text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
- ¥{{ (PromotionsFormat(item.promotions) ? item.price1 : item.retailPrice) | NumFormat }}
- </text>
- </view>
- <view v-if="userIdentity == 4">
- <view class="price-larger" v-if="item.price1TextFlag == '1'">
- <text class="txt">¥未公开价格</text>
- </view>
- <view v-else>
- <view class="price-larger" v-if="item.price1TextFlag == '2'">
- <text class="txt">¥价格仅会员可见</text>
- </view>
- <template v-else>
- <text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
- ¥{{ (PromotionsFormat(item.promotions) ? item.price1 : item.retailPrice) | NumFormat }}
- </text>
- </template>
- </view>
- </view>
- <view v-if="userIdentity == 2">
- <view class="price-larger" v-if="item.price1TextFlag == '1'">
- <text class="txt">¥未公开价格</text>
- </view>
- <template v-else>
- <text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
- ¥{{ (PromotionsFormat(item.promotions) ? item.price1 : item.retailPrice) | NumFormat }}
- </text>
- </template>
- </view>
- </view>
- <view v-else class="list-login-now">
- <text class="p-no">¥</text>
- <uni-stars :stars="parseInt(item.price1Grade)" :font-size='36' :width-info="180"></uni-stars>
- </view>
- </view>
- </view>
- </view>
- <view v-if="showLoading && listData.length > 4">
- <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
- <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
- </view>
- </scroll-view>
- <view class="empty-container" v-if="showEmpty">
- <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AY2ZjAABpmnBICH4247.png"></image>
- <text class="error-text">{{emptyText}}</text>
- </view>
- <!-- 透明模态层 -->
- <modal-layer v-if='isModallayer'></modal-layer>
- </view>
- </template>
- <script>
- import listSkeleton from '@/components/cm-module/listTemplate/listSkeleton'
- import modalLayer from '@/components/cm-module/modal-layer/modal-layer'
- import { mapState,mapMutations } from 'vuex';
- export default{
- name:'CommodityList',
- components:{
- listSkeleton,
- modalLayer,
- },
- props: {
- emptyText: {
- type: String
- },
- serverUrl: {
- type: String
- },
- classifyID: {
- type:Number
- }
- },
- data(){
- return{
- clubStatus:'',
- isModallayer:false,
- windowHeight: '',
- showSkeleton: true,
- showEmpty: false,
- userID: 0,
- userIdentity:'',
- scrollHeight: '',
- listData: [],
- showLoading: false,
- loadingNow: true,
- loadingText: '上拉加载更多',
- pageSize: 20,
- pageNum: 1,
- totalPage: 1,
- hasNextPage:false,
- pullFlag: true,
- cartNum: 0,
- }
- },
- created() {
- // console.log(this.typeId)
- this.setScrollHeight();
- this.$api.getComStorage('userInfo').then((resolve) =>{
- this.clubStatus = resolve.clubStatus
- this.userID = resolve.userID ? resolve.userID :0;
- this.userIdentity = resolve.userIdentity
- this.getListFromServer();
- }).catch(error =>{
- this.getListFromServer();
- })
- },
- filters: {
- NumFormat:function(text) {//处理金额
- return Number(text).toFixed(2);
- },
- },
- computed: {
- ...mapState(['hasLogin','userInfo'])
- },
- methods:{
- toLower() {
- if(this.hasNextPage && this.pullFlag) {
- this.getListFromServer(true);
- }
- },
- setScrollHeight() {
- const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
- this.windowHeight = windowHeight - 1;
- this.scrollHeight = windowHeight - 1;
- },
- getListFromServer(loadMore) {
- this.getQueryGoodslist(loadMore)
- },
- getQueryGoodslist(loadMore){
- this.showLoading = true;
- this.loadingNow = true;
- this.loadingText = '加载中';
- if(loadMore) { this.pageNum += 1; }
- let params ={
- classifyId:this.classifyID,
- userId:this.userID,
- pageNum:this.pageNum,
- pageSize:this.pageSize,
- }
- this.CommonService.GetHomeClassify(params).then(response =>{
- const resList = response.data.results;
- if(resList && resList.length > 0){
- this.showEmpty = false
- this.hasNextPage = response.data.hasNextPage;
- if(loadMore) {
- this.listData = [...this.listData,...resList];
- this.getProductPrice()
- this.showSkeleton = false
- } else {
- this.listData = [...resList];
- this.getProductPrice()
- this.showSkeleton = false
- }
- // 防上拉暴滑
- this.pullFlag = false;
- setTimeout(()=>{ this.pullFlag = true; },500)
- // 底部提示文案
- if(this.hasNextPage) {
- this.loadingText = '上拉加载更多';
- } else {
- this.showLoading = true;
- this.loadingNow = false;
- this.loadingText = '已至底部';
- }
- } else {
- if(!loadMore) { this.showEmpty = true; }
- }
-
- }).catch(error =>{
- this.$util.msg(error.msg,2000);
- })
- },
- getProductPrice(){//获取价格
- let productIdArr = [];
- this.listData.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
- productIdArr.push(item.productID)
- })
- this.productIds = productIdArr.join(",");
- this.ProductService.querySearchProductPrice({userId: this.userID,productIds:this.productIds}).then(response =>{
- if (response.data) {
- this.listData = this.ReturnNewProducts(this.listData,response.data);
- }
- this.priceLoading = false;
- }).catch(error =>{
- this.$util.msg(error.msg,2000)
- })
- },
- ReturnNewProducts(Array,list){//处理对应商品ID的商品价格
- let NewArray = []
- Array.map(item=>{
- for (let i = 0; i < list.length; i++) {
- if( item.productID == list[i].productId ){
- NewArray.push(Object.assign(item,list[i]))
- }
- }
- });
- return NewArray
- },
- navToDetailPage(id) {
- this.isModallayer = true;
- this.$api.navigateTo(`/pages/goods/product?id=${id}`);
- this.isModallayer = false;
- },
- PromotionsFormat(promo){//促销活动类型数据处理
- if(promo!=null){
- if(promo.type == 1 && promo.mode == 1){
- return true
- }else{
- return false
- }
- }
- return false
- }
- }
- }
- </script>
- <style lang="scss">
- .commodity-list-wrapper {
- scroll-view {
- height: 100%;
- border-top: 2rpx solid rgba(0,0,0,0.07);
- }
- .empty-container-image {
- margin-top: -300rpx;
- }
- .toIndexPage {
- bottom: 390rpx;
- }
- .show-more-btn {
- width: 276rpx;
- height: 52rpx;
- line-height: 52rpx;
- border: 2rpx solid #D8D8D8;
- background: #F7F7F7;
- font-size: 26rpx;
- margin: 26rpx 0;
- position: absolute;
- left: 50%;
- margin-left: -138rpx;
- }
- }
- .all-type-list-content {
- height: 216rpx;
- padding: 24rpx;
- background: #fff;
- margin-bottom: 2rpx;
- display: flex;
- flex-direction: row;
- box-sizing: content-box;
- .list-img {
- width: 210rpx;
- height: 218rpx !important;
- margin-right: 26rpx;
- border-radius: 10rpx;
- border: 2rpx solid #f3f3f3;
- }
- }
- .list-details-info {
- width: 466rpx;
- display: flex;
- flex-direction: column;
- font-size: 26rpx;
- position: relative;
- .list-details-title {
- line-height: 38rpx;
- text-overflow: ellipsis;
- overflow: hidden;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .list-details-specs {
- margin-top: 8rpx;
- color: #666666;
- }
- .list-details-miniQuantity {
- margin-top: 7rpx;
- }
- }
- .list-details-price {
- width: 100%;
- height: 54rpx;
- line-height: 54rpx;
- position: absolute;
- bottom: -10rpx;
- right: 0;
- .floor-item-act{
- height: 54rpx;
- text-align: center;
- box-sizing: border-box;
- float: right;
- .floor-tags{
- height: 28rpx;
- border-radius: 6rpx;
- background-color: #FFFFFF;
- line-height: 28rpx;
- color: $color-system;
- text-align: center;
- display: inline-block;
- padding:0 5rpx;
- font-size: $font-size-20;
- margin-left: 15rpx;
- border: 1px solid #E15616;
- }
- }
- .price-icon {
- width: 22rpx;
- height: 28rpx;
- vertical-align: middle;
- margin-right: 10rpx;
- }
- .price-icon + text {
- font-size: 25rpx;
- vertical-align: middle;
- }
- .list-login-now {
- color: #F8C499;
- float: left;
- line-height: 54rpx;
- .p-no{
- float: left;
- font-size: $font-size-24;
- color: $text-color;
- }
- }
- .login-now {
- padding: 10rpx 10rpx 10rpx 0;
- }
- .list-price {
- color: #FF2A2A;
- height: 44rpx;
- float: left;
- .price-larger {
- width: 100%;
- height: 44rpx;
- font-size: 32rpx;
- &.none{
- text-decoration: line-through;
- color: #999999;
- }
- &.small{
- font-size: $font-size-24;
- }
- .txt{
- font-size: $font-size-24;
- display: inline-block;
- line-height: 44rpx;
- text-align: left;
- float: left;
- }
- }
- }
- .add-cart-btn {
- width: 156rpx;
- height: 64rpx;
- line-height: 64rpx;
- border-radius: 32rpx;
- color: #fff;
- font-size: 26rpx;
- margin-right: 0;
- background:linear-gradient(45deg,rgba(255,41,41,1) 0%,rgba(255,109,27,1) 100%);
- }
- }
- .cart-icon {
- width: 92rpx;
- height: 92rpx;
- border-radius: 50%;
- background: rgba(255, 147, 0, 0.5);
- position: fixed;
- right: 24rpx;
- bottom: 30%;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- image {
- width: 58rpx;
- height: 58rpx;
- }
- text {
- font-size: 28rpx;
- position: absolute;
- top: -10rpx;
- right: 0;
- }
- }
- </style>
|