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.
high-mini/components/goods-list/goods-list.vue

800 lines
17 KiB

2 years ago
<template>
<view style="height: 100%;">
<!-- perspective: 1000; -->
2 years ago
<scroll-view v-if="typeList=='classify'" class="scroll-view goods-list" :scroll-top="scrollTop"
@scroll="handleScroll" scroll-y="true" :lower-threshold="lowerThreshold"
@scrolltolower="handleScrolltolower" @touchstart="handleTouchStart"
@touchmove.stop.prevent="handleTouchMove" @touchend="handleTouchEnd">
<!-- @touchmove.stop.prevent @touch.stop -->
2 years ago
<view class="scroll-content1" :style="[scrollContentStyle]">
<!-- 下拉 -->
<view class="pull-down-view">
2 years ago
<view class="refresh-view">
<text
:class="' pull-down-text icon-ymt '+(refreshStatus == 'soon'?' to-blod-down ':refreshStatus == 'sure'?' to-blod-up ':' ') ">{{ refreshText[refreshStatus] }}</text>
2 years ago
</view>
</view>
2 years ago
2 years ago
<view class="scroll-list">
<view class="right-content-actual pr bs" :style="'padding-bottom:'+paddBottom+'px;'">
<view v-if="(propData || null) != null && propData.length > 0" class="oh">
2 years ago
<view v-for="(item, index) in propData" :key="index">
<view @click="goGoodsDetail(item.id)" class="goods-item bs">
<image :src="imageUrl+item.listImg" mode="aspectFill" class="goods-img bs"></image>
<view class="goods-detail">
<view class="goods-title">
<view class="goods-text">{{item.name}}</view>
<!-- <view v-if="(item.simple_desc || null) != null" class="goods-desc">{{item.simple_desc}}</view> -->
<view class="goods-desc">{{item.listDescribe || ''}}</view>
2 years ago
</view>
2 years ago
<view class="goods-item-bottom">
<view class="goods-price">
2 years ago
<view class="new-price">&yen;{{item.price}}</view>
2 years ago
<view class="old-price">&yen;{{item.originalPrice}}</view>
</view>
<view class="goods-num">
2 years ago
<view class="icon cart cart-class"
@click.stop="cartIconChoose(item.id)">
2 years ago
</view>
</view>
</view>
2 years ago
</view>
</view>
</view>
2 years ago
</view>
2 years ago
2 years ago
</view>
2 years ago
2 years ago
</view>
2 years ago
2 years ago
<!-- -->
<view class=" empty-content" v-if="propData.length == 0">
2 years ago
<image class="empty-text" mode="widthFix" :src="imagewxUrl+imgadres"></image>
<!-- <text class="empty-text">{{ emptyText }}</text> -->
2 years ago
</view>
2 years ago
2 years ago
<!-- 底部上滑 -->
2 years ago
<view class="pull-up-view">
<view class="load-view">
2 years ago
<view class="loading-animation" v-if="loadStatus == 'loading'"></view>
2 years ago
<text
:class="' loading-text icon-ymt '+(loadStatus == 'soon'?' to-blod-up ':loadStatus == 'sure'?' to-blod-down ':' ') ">{{ loadText[loadStatus] }}</text>
2 years ago
</view>
2 years ago
</view>
2 years ago
</view>
</scroll-view>
2 years ago
2 years ago
<!--search-List -->
2 years ago
2 years ago
<scroll-view v-if="typeList=='goodsSearch'" scroll-y="true" class="ht-auto goods-list" @scroll="handleScroll"
:scroll-top="scrollTop" @scrolltolower="scroll_lower" lower-threshold="30">
<!-- <view class="right-content-actual pr bs" :style="'padding-bottom:'+paddBottom+'px;'"> -->
2 years ago
<view v-if="(propData || null) != null && propData.length > 0">
<view v-for="(item, index) in propData" :key="index">
<view @click="goGoodsDetail(item.id)" class="goods-item bs">
<image :src="imageUrl+item.listImg" mode="aspectFill" class="goods-img bs"></image>
<view class="goods-detail">
<view class="goods-title">
<view class="goods-text">{{item.name}}</view>
<!-- <view v-if="(item.simple_desc || null) != null" class="goods-desc">{{item.simple_desc}}</view> -->
<view class="goods-desc">{{item.listDescribe || ''}}</view>
</view>
<view class="goods-item-bottom">
<view class="goods-price">
<view class="new-price">&yen;{{item.price}}</view>
<view class="old-price">&yen;{{item.originalPrice}}</view>
2 years ago
</view>
2 years ago
<view class="goods-num">
<view class="icon cart cart-class" @click.stop="cartIconChoose(item.id)">
2 years ago
</view>
</view>
2 years ago
</view>
2 years ago
2 years ago
</view>
</view>
2 years ago
</view>
2 years ago
2 years ago
<noMore :bgColor="'#ffffff'"></noMore>
</view>
<!-- -->
<view class=" empty-content" v-else>
<image class="empty-text" mode="widthFix" :src="imagewxUrl+imgadres"></image>
<!-- <text class="empty-text">{{ emptyText }}</text> -->
</view>
<!-- </view> -->
2 years ago
2 years ago
</scroll-view>
2 years ago
2 years ago
<!-- 购物车 -->
2 years ago
<view :class="' gouwuche searchCart ' " @click.prevent="goCart">
2 years ago
<!-- cartNum -->
2 years ago
<uniBadge class="uni-badge-left-margin badgeClass" max-num="99" :text="cartNum+''" type="warning"
size="small" />
<view class="icon cart font40">
2 years ago
2 years ago
</view>
</view>
2 years ago
<!-- 选择类别 -->
<wybPopup ref="popup" zIndex="999" type="bottom" height="500" width="500" :scrollY="true" radius="6" :showCloseIcon="true">
2 years ago
<cart-choose @refreshCartNum="refreshCartNum" :specificationList="specificationList" @close="close">
</cart-choose>
2 years ago
</wybPopup>
</view>
2 years ago
2 years ago
</template>
<script>
2 years ago
import noMore from '@/components/no-more/no-more.vue'
2 years ago
import wybPopup from '@/components/wyb-popup/wyb-popup.vue'
2 years ago
import cartChoose from '@/components/cart-choose/cart-choose.vue'
2 years ago
import {
findGoodsSkuByGoodsId,
getShoppingCartList
} from '@/Utils/physicalObject.js'
2 years ago
import uniBadge from '@/components/uni-badge/components/uni-badge/uni-badge.vue'
const app = getApp();
2 years ago
export default {
2 years ago
data() {
return {
cartNum: 0,
imageUrl: app.globalData.imgUrl, //图片地址
imagewxUrl: app.globalData.imageWxImg,
imgadres: 'goods_default_pages.png',
2 years ago
scrollTop: 0,
currentScrollTop: 0,
2 years ago
// start
refresherThreshold: 50,
lowerThreshold: 50,
pullingDown: false, // 是否正在下拉
pullDownHeight: 0, // 下拉高度
pullDownTimeStamp: 0, // 下拉时的时间戳
pullingUp: false, // 是否正在上拉
pullUpHeight: 0, // 上拉高度
pullUpTimeStamp: 0, // 上拉时的时间戳
maxDistance: 100,
touchDirection: '',
list: [],
emptyText: "暂无数据",
loadStatus: 'soon',
loadText: {
loading: '加载中~',
nomore: '',
soon: '上滑查看下一分类',
sure: '释放查看下一分类',
},
refreshStatus: 'soon',
refreshText: {
soon: '下滑查看上一分类',
sure: '释放查看上一分类',
nomore: '没有更多啦~',
refreshing: '正在刷新中~'
},
//end
specificationList: [],
2 years ago
}
2 years ago
2 years ago
},
2 years ago
created() {
1 year ago
// this.refreshCartNum();
2 years ago
},
mounted() {
this.handleInit();
2 years ago
},
props: {
propData: {
type: Array,
2 years ago
default () {
return []
}
2 years ago
},
2 years ago
paddBottom: {
type: Number,
default: 0,
2 years ago
},
2 years ago
pageData: {
type: Object,
2 years ago
default() {
return {
pageStart: 1,
pageNum: 0,
allData: 0
}
2 years ago
}
},
2 years ago
selectObject: {
type: Object,
2 years ago
default(){
return {
selectIndex: 0,
length: 0
}
}
2 years ago
},
2 years ago
typeList: {
type: String,
default: "classify"
},
2 years ago
},
2 years ago
watch: {
2 years ago
2 years ago
selectObject: {
2 years ago
handler(n, o) {
2 years ago
if (n.selectIndex == n.length - 1) {
2 years ago
this.loadStatus = "nomore"
2 years ago
} else {
2 years ago
this.loadStatus = "soon"
}
2 years ago
if (n.selectIndex == 0) {
2 years ago
this.refreshStatus = "nomore"
2 years ago
} else {
2 years ago
this.refreshStatus = "soon"
}
2 years ago
2 years ago
},
2 years ago
deep: true, // 深度监听
immediate: true, // 初始化监听
2 years ago
},
2 years ago
2 years ago
},
2 years ago
computed: {
scrollContentStyle() {
const style = {};
2 years ago
const {
pullDownHeight,
pullingDown,
pullUpHeight,
pullingUp
} = this;
2 years ago
style.transform = pullingDown && !pullingUp ? `translateY(${pullDownHeight}px)` : `translateY(0px)`;
style.transition = pullingDown && !pullingUp ? `transform .1s linear` :
2 years ago
`transform 0.3s cubic-bezier(0.19,1.64,0.42,0.72)`;
2 years ago
return style;
},
2 years ago
2 years ago
},
2 years ago
components: {
2 years ago
wybPopup,
cartChoose,
noMore,
2 years ago
uniBadge
2 years ago
2 years ago
},
2 years ago
methods: {
2 years ago
2 years ago
goCart() {
2 years ago
uni.navigateTo({
2 years ago
url: "/physical-merchants/classify/cart/cart"
2 years ago
})
2 years ago
},
2 years ago
// 刷新购物车数量
2 years ago
refreshCartNum() {
this.scrollTop = this.currentScrollTop;
2 years ago
getShoppingCartList().then(res => {
2 years ago
if (res.return_code == '000000') {
2 years ago
this.cartNum = res.return_data.length;
} else {
2 years ago
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
}
2 years ago
})
2 years ago
},
2 years ago
2 years ago
//查看商品详情
2 years ago
goGoodsDetail(id) {
2 years ago
uni.navigateTo({
2 years ago
url: '/physical-merchants/classify/goodsDetail/goodsDetail?goodsId=' + id
2 years ago
})
},
2 years ago
// 购物车商品图标点击
2 years ago
cartIconChoose(id) {
2 years ago
this.specificationList = [];
2 years ago
let params = {
goodsId: id
2 years ago
};
// console.log(params)
2 years ago
findGoodsSkuByGoodsId(params).then(res => {
2 years ago
if (res.return_code == '000000') {
2 years ago
if (res.return_data && res.return_data.length > 0) {
2 years ago
this.specificationList = res.return_data;
this.$refs.popup.show();
// console.log(this.specificationList)
2 years ago
} else {
2 years ago
this.specificationList = [];
}
2 years ago
} else {
2 years ago
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
}
2 years ago
2 years ago
})
2 years ago
2 years ago
},
//popup关闭选择方法
2 years ago
close() {
2 years ago
this.$refs.popup.hide();
},
2 years ago
scroll_lower() {
2 years ago
this.$emit("loadData")
},
2 years ago
2 years ago
//start
2 years ago
// 下滑触底后 数据加载
loadData() {
this.waiting = true;
this.$emit('loadData', res => {
this.waiting = false;
this.list = res.list;
this.total = res.total;
this.currentPage++;
this.handleComputeData();
});
},
// 计算数据
handleComputeData() {
const len = this.list.length;
const total = this.total;
if (len >= this.total) {
this.loadStatus = 'soon';
} else if (len < this.total) {
this.loadStatus = 'loading';
}
},
// 下滑触底事件
handleScrolltolower(e) {
this.$emit('scrolltolower', e);
if (this.loadStatus == 'nomore' || this.waiting) return;
this.loadData();
},
// 滚动事件
handleScroll(e) {
this.currentScrollTop = e.detail.scrollTop;
// this.$emit('scroll', e);
2 years ago
},
// 触摸按下处理
handleTouchStart(e) {
this.pullingDown = true;
this.currentTouchStartY = e.touches[0].clientY;
},
// 触摸按下滑动处理
handleTouchMove(e) {
// 顶部下滑
if (e.touches[0].clientY >= this.currentTouchStartY) {
this.pullingUp = false;
this.touchDirection = 'top';
const currentTouchMoveY = e.touches[0].clientY;
let movingDistance = (currentTouchMoveY - this.currentTouchStartY);
if (this.selectObject.selectIndex == 0) {
this.refreshStatus = 'nomore'
} else if (movingDistance > this.refresherThreshold) {
this.refreshStatus = 'sure'; // 释放
} else {
this.refreshStatus = 'soon'; // 划
}
let computeDistance = movingDistance;
if (computeDistance > this.maxDistance) {
computeDistance = this.maxDistance;
}
this.pullDownHeight = computeDistance;
} else {
this.pullingUp = true;
this.pullingDown = false;
// 底部上滑
this.touchDirection = 'bottom';
const currentTouchMoveY = e.touches[0].clientY;
let movingDistance = (this.currentTouchStartY - currentTouchMoveY);
if (this.selectObject.selectIndex == this.selectObject.length - 1) {
this.loadStatus = 'nomore';
} else if (movingDistance >= this.lowerThreshold) {
this.loadStatus = 'sure'; //释放
} else {
this.loadStatus = 'soon'; //划
}
let computeDistance = movingDistance;
if (computeDistance > this.maxDistance) {
computeDistance = this.maxDistance;
}
this.pullUpHeight = computeDistance;
}
},
// 触摸松开处理
handleTouchEnd(e) {
// 顶部下滑
if (this.touchDirection == 'top') {
if (this.pullDownHeight >= this.refresherThreshold && this.selectObject.selectIndex > 0) {
this.$emit("switchCategory", "prev")
}
// 底部上滑
} else if (this.touchDirection == 'bottom') {
if (this.pullUpHeight >= this.lowerThreshold && this.selectObject.selectIndex < (this.selectObject
.length - 1)) {
this.$emit("switchCategory", "next")
}
}
this.pullDownHeight = 0;
this.pullUpHeight = 0;
this.pullingDown = false;
this.pullingUp = false;
},
// 初始化
handleInit() {
this.currentPage = this.page;
this.currentSize = this.size;
// console.log()
// this.computedHeight();
},
// end
2 years ago
}
2 years ago
2 years ago
}
</script>
2 years ago
<style lang="scss" scoped>
2 years ago
// 购物车
2 years ago
.gouwuche {
position: absolute;
bottom: 10px;
right: 25px;
width: 35px;
height: 35px;
2 years ago
color: #3DA7E7 !important;
2 years ago
.font40 {
font-size: 35px !important;
color: #F0AD4E;
}
2 years ago
}
2 years ago
.searchCart {
bottom: 27px !important;
right: 30px !important;
}
2 years ago
2 years ago
.badgeClass {
2 years ago
position: absolute;
2 years ago
top: -5px;
2 years ago
right: -10px;
2 years ago
}
2 years ago
//
2 years ago
.br {
border: 1px solid #ffffff;
2 years ago
}
2 years ago
.bs {
box-sizing: border-box;
2 years ago
}
2 years ago
.goods-list .goods-item {
display: flex;
align-items: center;
2 years ago
width: 100%;
2 years ago
height: 240rpx;
/* margin-bottom: 20rpx; */
color: #333333;
padding: 0 20rpx 10rpx;
border-bottom: 1px solid #F6F6F6;
}
.goods-list {
background-color: #ffffff;
}
.goods-list .goods-img {
/* width: 190rpx; */
height: 100% !important;
width: 200rpx;
padding: 10rpx;
}
.goods-list .goods-detail {
width: calc(100% - 190rpx);
2 years ago
height: 100%;
2 years ago
}
.goods-title {
width: 100%;
padding: 0 10rpx 0 0;
height: 140rpx;
}
.goods-title .goods-text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 50rpx;
line-height: 50rpx;
font-size: 30rpx;
padding: 20rpx 0 10rpx;
}
.goods-title .goods-desc {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 40rpx;
line-height: 40rpx;
font-size: 24rpx;
color: #999999;
}
.goods-item-bottom {
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.goods-item-bottom .goods-price {
font-family: Arial;
padding-left: 20rpx;
}
.goods-item-bottom .new-price {
color: #3DA7E7;
font-weight: bold;
font-size: 18px;
2 years ago
}
.goods-item-bottom .old-price {
font-size: 24rpx;
color: #D6D6D6;
font-weight: bold;
text-decoration: line-through;
}
.goods-item-bottom .goods-num {
height: 80rpx;
}
.goods-item-bottom .cart-class {
width: 80rpx;
height: 80rpx;
line-height: 80rpx;
color: #3DA7E7;
text-align: center;
font-size: 50rpx;
2 years ago
}
/* gundong */
// 空
.empty-content {
height: calc(100% - 20px);
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
.empty-image {
2 years ago
width: 100%;
}
2 years ago
.empty-text {
width: 80%;
display: block;
color: #606266;
margin-top: 40rpx;
margin-bottom: 20rpx;
}
}
.scroll-view {
height: 100%;
2 years ago
2 years ago
.scroll-content1 {
2 years ago
width: 100%;
padding-bottom: 40px;
2 years ago
2 years ago
// position: relative;
// height: inherit;
.empty-view {
width: 100%;
height: 100%;
2 years ago
display: flex;
align-items: center;
2 years ago
justify-content: center;
}
.pull-down-view {
width: 100%;
top: 0;
left: 0;
padding: 30rpx 0;
display: flex;
position: absolute;
align-items: center;
2 years ago
flex-direction: column;
2 years ago
justify-content: center;
transform: translateY(-100%);
.refresh-view {
display: flex;
align-items: center;
flex-direction: column;
.loading-animation {
width: 50rpx;
height: 50rpx;
}
.pull-down-text {
color: #606266;
font-size: 24rpx;
margin-top: 10rpx;
}
2 years ago
}
}
2 years ago
.scroll-list {
display: flex;
flex-direction: column;
2 years ago
}
2 years ago
.loading-view {
width: 100%;
height: 100%;
2 years ago
display: flex;
align-items: center;
2 years ago
flex-direction: column;
justify-content: center;
.loading-animation {
width: 40rpx;
height: 40rpx;
}
2 years ago
.loading-text {
color: #606266;
font-size: 24rpx;
2 years ago
margin-top: 10rpx;
2 years ago
}
}
2 years ago
.pull-up-view {
2 years ago
width: 100%;
2 years ago
// padding: 15rpx 0;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
.load-view {
display: flex;
align-items: center;
.loading-text {
color: #606266;
font-size: 24rpx;
margin-left: 20rpx;
}
2 years ago
}
2 years ago
}
.loading-animation {
position: relative;
&::after,
&::before {
left: 0;
width: 100%;
position: absolute;
border: 0 solid currentColor;
background-color: #b7b7b7;
2 years ago
}
2 years ago
&::after {
content: '';
top: -25%;
z-index: 1;
height: 100%;
border-radius: 10%;
animation: spin 0.6s -0.1s linear infinite;
2 years ago
}
2 years ago
&::before {
content: '';
bottom: -9%;
height: 10%;
background: #000;
border-radius: 50%;
opacity: 0.2;
animation: shadow 0.6s -0.1s linear infinite;
2 years ago
}
2 years ago
@keyframes spin {
17% {
border-bottom-right-radius: 10%;
}
25% {
transform: translateY(25%) rotate(22.5deg);
}
50% {
border-bottom-right-radius: 100%;
transform: translateY(50%) scale(1, 0.9) rotate(45deg);
}
75% {
transform: translateY(25%) rotate(67.5deg);
}
100% {
transform: translateY(0) rotate(90deg);
}
2 years ago
}
2 years ago
@keyframes shadow {
50% {
transform: scale(1.25, 1);
}
2 years ago
}
}
}
}
2 years ago
</style>