123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
- <template>
- <view
- class="container commodity-list-wrapper"
- :style="{ overflow: showSkeleton ? 'hidden' : 'auto', height: showSkeleton ? windowHeight + 'px' : 'auto' }"
- >
- <list-skeleton v-if="showSkeleton"></list-skeleton>
- <view class="product-container" v-if="!isShowEmpty" :style="{ paddingTop: searchStatus ? '112rpx' : '' }">
- <scroll-view
- :style="{ height: scrollHeight + 'px' }"
- @scrolltolower="scrolltolower"
- scroll-y
- v-if="productList.length > 0"
- >
- <view
- v-for="(item, index) in productList"
- :key="index"
- :id="item.productId"
- class="all-type-list-content commodity-list"
- @click.stop="navToDetailPage(item.productId)"
- >
- <view class="list-details-image">
- <image mode="widthFix" :src="item.image" class="list-img" alt="list-img"></image>
- <view class="list-details-type">医疗器械</view>
- </view>
- <view class="list-details-info">
- <text class="list-details-title">{{ item.name }}</text>
- <text class="list-details-specs">规格:{{ item.unit != null ? item.unit : '' }}</text>
- <text class="list-details-miniQuantity"
- >起订量:{{ item.ladderPriceFlag == 1 ? item.maxBuyNumber : item.minBuyNumber }}</text
- >
- <view class="list-details-price">
- <view class="list-shop">
- <view class="list-price-none" v-if="item.repurchaseFlag == 1">
- <text class="price-none">¥{{ item.originalPrice }}</text>
- <text class="iconfont icon-wenhao" @click.stop="repurchModel"></text>
- </view>
- <view class="list-price" v-else>
- <text
- class="price-larger"
- :class="
- PromotionsFormat(item.promotions) || item.svipProductFlag == 1 ? 'none' : ''
- "
- >
- ¥{{
- (PromotionsFormat(item.promotions) ? item.originalPrice : item.price)
- | NumFormat
- }}
- </text>
- </view>
- </view>
- <button class="add-cart-btn" @click.stop="operationHanld(item)">数量</button>
- </view>
- <view class="list-details-price">
- <view class="floor-item-act">
- <view class="coupon-tags" v-if="item.couponsLogo">优惠券</view>
- <template v-if="item.actStatus == 1">
- <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
- {{ item.promotions.name }}<text>:¥{{ item.price | NumFormat }}</text>
- </view>
- <view class="floor-tags" v-else>{{ item.promotions.name }}</view>
- </template>
- <template v-if="item.svipProductFlag == 1">
- <view class="svip-tags">
- <view class="tags">SVIP</view>
- <view class="price">{{ item.svipPriceTag }}</view>
- </view>
- </template>
- </view>
- </view>
- </view>
- </view>
- <view v-if="showLoading && productList.length > 4 && !showRegularBtn">
- <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>
- <view class="empty-container" v-else>
- <image
- class="empty-container-image"
- src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AWdWzAAGlgAP0das422.png"
- mode="aspectFit"
- ></image>
- <text class="error-text">您还没有购买过任何商品哟~</text>
- </view>
- <!-- 可拖动悬浮按钮 -->
- <cm-drag
- :cartNum="cartQuantity"
- :isDock="true"
- :existTabBar="true"
- @btnClick="btnClick"
- @btnTouchstart="btnTouchstart"
- @btnTouchend="btnTouchend"
- >
- </cm-drag>
- <!-- 透明模态层 -->
- <modal-layer v-if="isModallayer" />
- </view>
- </template>
- <script>
- import listSkeleton from '@/components/cm-module/listTemplate/listSkeleton'
- import modalLayer from '@/components/modal-layer'
- import uniStars from '@/components/uni-stars/uni-stars.vue'
- import cmDrag from '@/components/cm-custom/cm-drag.vue'
- import { mapState, mapMutations } from 'vuex'
- export default {
- name: 'productList',
- components: {
- listSkeleton,
- modalLayer,
- uniStars,
- cmDrag
- },
- data() {
- return {
- isShowClose: false,
- searchInputVal: '',
- isModallayer: false,
- windowHeight: '',
- showSkeleton: true,
- isShowEmpty: false,
- userId: '',
- scrollHeight: '',
- productList: [],
- showLoading: false,
- loadingNow: true,
- loadingText: '上拉加载更多',
- pageSize: 10,
- pageNum: 1,
- hasNextPage: false,
- pullFlag: true,
- fromRegularPurchasePage: false,
- cartQuantity: 0,
- showRegularBtn: false,
- isPrecedence: false,
- windowWidth: '',
- }
- },
- created() {
- this.setScrollHeight()
- this.$parent.getClubProductNum()
- this.initGetStotage()
- },
- filters: {
- NumFormat: function(text) {
- //处理金额
- return Number(text).toFixed(2)
- }
- },
- computed: {
- ...mapState(['hasLogin', 'userInfo'])
- },
- methods: {
- async initGetStotage() {
- // 初始化
- const userInfo = await this.$api.getStorage()
- const clubInfo = await this.$api.getComStorage('orderUserInfo')
- this.userId = clubInfo.userId ? clubInfo.userId : 0
- this.getProductAgainInfo(false)
- },
- scrolltolower() {
- if (this.hasNextPage && this.pullFlag) {
- this.getProductAgainInfo(true)
- }
- },
- setScrollHeight() {
- const { windowHeight, pixelRatio } = wx.getSystemInfoSync()
- this.windowHeight = windowHeight - 1
- this.scrollHeight = windowHeight - 1
- },
- getProductAgainInfo(loadMore) {
- this.showLoading = true
- this.loadingNow = true
- this.loadingText = '加载中'
- this.isShowEmpty = false
- if (loadMore) {
- this.pageNum += 1
- }
- this.ProductService.GetRepeatBuyAgainProductList({
- userId: this.userId,
- pageNum: this.pageNum,
- pageSize: this.pageSize
- })
- .then(response => {
- this.isShowWrapper = true
- this.showSkeleton = false
- const listData = response.data.results
- if (listData && listData.length > 0) {
- this.hasNextPage = response.data.hasNextPage
- this.isShowEmpty = false
- if (loadMore) {
- this.productList = [...this.productList, ...listData]
- } else {
- this.productList = listData
- console.log(this.productList)
- }
- //价格显示处理
- let isActFlg,
- newProductList = []
- this.productList.map((item, index) => {
- console.log(item)
- if (item.actStatus == 1) {
- isActFlg = true
- } else if (item.actStatus == 1 && item.ladderPriceFlag == 1) {
- isActFlg = true
- } else {
- isActFlg = false
- }
- newProductList.push(Object.assign({}, item, { isShowActFlg: isActFlg }))
- })
- this.productList = newProductList
- console.log(this.productList)
- // 防上拉暴滑
- this.pullFlag = false
- setTimeout(() => {
- this.pullFlag = true
- }, 500)
- // 底部提示文案
- if (this.hasNextPage) {
- this.loadingText = '上拉加载更多'
- } else {
- this.showLoading = true
- this.loadingNow = false
- }
- } else {
- if (!loadMore) {
- this.isShowEmpty = true
- }
- }
- })
- .catch(error => {
- this.$util.msg(error.msg, 2000)
- })
- },
- operationHanld(prop) {
- this.$emit('operationConfim', prop)
- },
- navToDetailPage(id) {
- this.isModallayer = true
- this.$api.navigateTo(`/pages/goods/product?id=${id}`)
- this.isModallayer = false
- },
- repurchModel() {
- this.$util.modal('', '此商品的价格有变化,原来的购买价已不适用', '知道了', '', false, () => {})
- },
- PromotionsFormat(promo) {
- //促销活动类型数据处理
- if (promo != null) {
- if (promo.type == 1 && promo.mode == 1) {
- return true
- } else {
- return false
- }
- }
- return false
- },
- onShowClose() {
- //输入框失去焦点时触发
- if (this.searchInputVal != '') {
- this.isShowClose = true
- } else {
- this.isShowClose = false
- }
- },
- delInputText() {
- //清除输入框内容
- this.searchInputVal = ''
- this.isShowClose = false
- },
- btnClick() {
- this.$emit('goCartPage')
- },
- btnTouchstart() {
- // console.log('btnTouchstart');
- },
- btnTouchend() {
- // console.log('btnTouchend');
- }
- }
- }
- </script>
- <style lang="scss">
- .commodity-list-wrapper {
- scroll-view {
- height: 100%;
- }
- .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: auto;
- padding: 24rpx;
- background: #fff;
- margin-bottom: 2rpx;
- display: flex;
- flex-direction: row;
- box-sizing: content-box;
- .list-details-image{
- width: 218rpx;
- height: 218rpx !important;
- margin-right: 26rpx;
- border-radius: 10rpx;
- border: 2rpx solid #f3f3f3;
- position: relative;
- .list-img {
- width: 218rpx;
- height: 218rpx !important;
- }
- .list-details-type{
- width: 64rpx;
- height: 64rpx;
- text-align: justify;
- box-sizing: border-box;
- padding: 10rpx;
- border-radius: 0 0 8rpx 8rpx;
- background-color: #33CCBF;
- font-size: $font-size-22;
- color: #FFFFFF;
- line-height: 25rpx;
- position: absolute;
- top: 0;
- right: 10rpx;
- }
- }
- }
- .list-details-info {
- width: 442rpx;
- 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 {
- width: 100%;
- display: inline-block;
- margin-top: 8rpx;
- color: #999999;
- }
- .list-details-miniQuantity {
- width: 100%;
- display: inline-block;
- margin-top: 7rpx;
- }
- }
- .list-details-price {
- width: 100%;
- float: left;
- line-height: 54rpx;
- .floor-item-act {
- height: 54rpx;
- text-align: center;
- box-sizing: border-box;
- float: left;
- padding: 11rpx 0;
- }
- .price-icon {
- width: 22rpx;
- height: 28rpx;
- vertical-align: middle;
- margin-right: 10rpx;
- }
- .price-icon + text {
- font-size: 25rpx;
- vertical-align: middle;
- }
- .list-login-now {
- width: 375rpx;
- color: #f8c499;
- .p-no {
- float: left;
- font-size: $font-size-24;
- color: $color-system;
- margin-right: 10rpx;
- }
- }
- .login-now {
- padding: 10rpx 10rpx 10rpx 0;
- }
- .list-none {
- margin-top: 15rpx;
- .price-small {
- font-size: $font-size-24;
- line-height: 40rpx;
- color: #ff2a2a;
- }
- }
- .list-shop {
- height: auto;
- float: left;
- .list-price {
- width: 100%;
- color: #ff2a2a;
- float: left;
- line-height: 54rpx;
- align-items: center;
- justify-content: center;
- .price-larger {
- font-size: $font-size-30;
- display: inline-block;
- &.none {
- text-decoration: line-through;
- color: #999999;
- }
- }
- }
- .list-price-none {
- width: 100%;
- .price-none {
- text-decoration: line-through;
- color: #999999;
- display: inline-block;
- }
- .icon-wenhao {
- font-size: $font-size-32;
- color: #0091ff;
- margin-left: 6rpx;
- }
- }
- }
- .add-cart-btn {
- float: right;
- width: 140rpx;
- height: 54rpx;
- line-height: 54rpx;
- border-radius: 27rpx;
- color: #fff;
- font-size: 24rpx;
- margin-right: 0;
- background: #ffffff;
- border: 1px solid #c9c9c9;
- color: $text-color;
- }
- }
- .cart-icon {
- width: 92rpx;
- height: 92rpx;
- border-radius: 50%;
- background: rgba(255, 147, 0, 0.5);
- position: fixed;
- right: 24rpx;
- bottom: 28%;
- 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>
|