From 0c4f73bb85c3f5671ff359a3adccc323efbc00ad Mon Sep 17 00:00:00 2001 From: lnn19986213 <1667908750@qq.com> Date: Wed, 8 May 2024 16:35:48 +0800 Subject: [PATCH] gx --- src/pagesB/ArtWorks/ArtWorks.vue | 200 ++++++++++++++++++++----------- src/pagesC/shop/Shop.vue | 33 ++++- 2 files changed, 163 insertions(+), 70 deletions(-) diff --git a/src/pagesB/ArtWorks/ArtWorks.vue b/src/pagesB/ArtWorks/ArtWorks.vue index 35859ad..41e71e1 100644 --- a/src/pagesB/ArtWorks/ArtWorks.vue +++ b/src/pagesB/ArtWorks/ArtWorks.vue @@ -8,7 +8,7 @@ - + - + - 热门 + 热门 - + {{item.name}} @@ -37,13 +39,16 @@ 全部作品 - + {{item.name}} - - + + @@ -63,14 +68,16 @@ {{ v.typeName }}-{{ v.typesName }}作品 - + {{a}} - + @@ -83,7 +90,7 @@ {{ v.userNames }} - + {{ v.releaseDate }} @@ -93,7 +100,7 @@ - + @@ -104,6 +111,9 @@ data() { return { load: true, + statusHeight: 0, + titleHeight: 50, + topPartHeight: 0, artValue: '', type: '', types: '', @@ -122,9 +132,22 @@ sonId: '', sonNum: '', // 请求状态识别变量 - requestStatus: false + requestStatus: false, + scrollTop: 0, + old: { + scrollTop: 0 + } }; }, + onReady() { + const systemMsg = uni.getSystemInfoSync(); + this.statusHeight = systemMsg.statusBarHeight + // #ifdef MP-WEIXIN + const menuButtonInfo = uni.getMenuButtonBoundingClientRect() //胶囊 + this.titleHeight = menuButtonInfo.height + (menuButtonInfo.top - systemMsg.statusBarHeight) * 2 + // #endif + this.topPartHeight = this.statusHeight + this.titleHeight + 12 + }, // 下拉刷新 onPullDownRefresh() { this.pages = 1 @@ -143,11 +166,11 @@ name: '全部', type: '', }], - this.pages = 1 + this.pages = 1 this.getType() }, onShow() { - if(this.sonId){ + if (this.sonId) { this.getSonData() } }, @@ -175,7 +198,7 @@ //二级作品分类 getTypeE() { let _this = this - this.http.request('/workType/'+ this.type, {}, "GET").then(res => { + this.http.request('/workType/' + this.type, {}, "GET").then(res => { if (res.code == 200) { res.data.forEach(function(item) { _this.list2.push({ @@ -209,12 +232,11 @@ if (res.code == 200) { _this.workList = res.data.records _this.workList.forEach(function(item) { - console.log(1) - if(item.user){ + if (item.user) { if (item.user.images) { // let img = JSON.parse(item.user.images) // item.user.images = img[0] - }else{ + } else { item.user.images = '../../static/txIcon.png' } } @@ -222,14 +244,15 @@ if (item.file) { let fileArr = item.file.split(',') let gs = fileArr[0].substr(fileArr[0].lastIndexOf(".") + 1) - if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == 'gif' || gs == 'tif' || gs == 'tiff') { + if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == + 'gif' || gs == 'tif' || gs == 'tiff') { item.file = fileArr[0] } else if (gs == 'pdf') { item.file = '../../static/fileImg/pdfS.png' - } + } } if (item.workTag.length > 3) { - let tags = item.workTag.slice(0,3) + let tags = item.workTag.slice(0, 3) item.workTag = tags } }) @@ -249,6 +272,11 @@ }, //上拉 getMoreData() { + if (this.requestStatus) { + // 利用 return 终止函数继续运行 + return false; + } + this.requestStatus = true; const _this = this this.http.request('/works/list', { page: this.pages, @@ -259,25 +287,39 @@ }, "GET").then(res => { if (res.data.records.length > 0) { res.data.records.forEach(function(item) { - if (item.user.images != undefined) { - let img = JSON.parse(item.user.images) - item.user.images = img[0] + if (item.user) { + if (item.user.images) { + // let img = JSON.parse(item.user.images) + // item.user.images = img[0] + } else { + item.user.images = '../../static/txIcon.png' + } } //判断封面图片 - if (item.file != undefined) { + if (item.file) { let fileArr = item.file.split(',') let gs = fileArr[0].substr(fileArr[0].lastIndexOf(".") + 1) - if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == 'gif' || gs == 'tif' || gs == 'tiff') { + if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == + 'gif' || gs == 'tif' || gs == 'tiff') { item.file = fileArr[0] } else if (gs == 'pdf') { item.file = '../../static/fileImg/pdfS.png' - } + } + } + if (item.workTag.length > 3) { + let tags = item.workTag.slice(0, 3) + item.workTag = tags } _this.workList.push(item) }) } else { this.pages-- } + setTimeout(() => { + // 模拟执行完毕 + // 改变 requestStatus + this.requestStatus = false; + }, 500); }).catch(e => { uni.showToast({ @@ -287,7 +329,7 @@ }) }, //点赞 - like(val1, val2,num) { + like(val1, val2, num) { if (val2) { this.workList[num].isGreat = false this.http.request('/worksGreat/delGreat?type=1&workId=' + val1, "POST").then(res => { @@ -317,7 +359,7 @@ } }, //详情页 - toDetail(val,num) { + toDetail(val, num) { this.sonId = val this.sonNum = num uni.navigateTo({ @@ -325,10 +367,10 @@ }) }, //选择一级类型 - chooseOneType(item,index) { - if(index == 0){ + chooseOneType(item, index) { + if (index == 0) { this.type = '' - }else{ + } else { this.type = item this.getTypeE() } @@ -339,26 +381,29 @@ this.list2 = [] this.orderBy = '' this.pages = 1 + this.goTop() this.getData() }, //选择二级类型 - chooseTwoType(val,val2) { + chooseTwoType(val, val2) { this.types = val this.typeT = val2 this.orderBy = '' this.pages = 1 + this.goTop() this.getData() }, search() { this.pages = 1 this.getData() }, - toUser(val1,val2,val3,val4){ + toUser(val1, val2, val3, val4) { uni.navigateTo({ - url: "/pagesA/my/myWorks?id=" + val1 + '&userName=' + val3 + '&userImg=' + val2 + '&isFollow=' + val4 + url: "/pagesA/my/myWorks?id=" + val1 + '&userName=' + val3 + '&userImg=' + val2 + + '&isFollow=' + val4 }) }, - Clickfilter(){ + Clickfilter() { let _this = this if (this.fil == 0) { this.fil = 1 @@ -367,6 +412,7 @@ this.type = '' this.types = '' this.list2 = [] + this.goTop() this.http.request('/works/hot', {}, "GET").then(res => { if (res.code == 200) { _this.workList = res.data @@ -374,18 +420,19 @@ if (item.user.images) { // let img = JSON.parse(item.user.images) // item.user.images = img[0] - }else{ + } else { item.images = '../../static/txIcon.png' } //判断封面图片 if (item.file) { let fileArr = item.file.split(',') let gs = fileArr[0].substr(fileArr[0].lastIndexOf(".") + 1) - if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == 'gif' || gs == 'tif' || gs == 'tiff') { + if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == + 'gif' || gs == 'tif' || gs == 'tiff') { item.file = fileArr[0] } else if (gs == 'pdf') { item.file = '../../static/fileImg/pdfS.png' - } + } } }) } @@ -395,10 +442,10 @@ icon: "none", }); }) - } + } }, - lower(){ - if(this.fil == 0){ + lower() { + if (this.fil == 0) { this.pages++ this.getMoreData(); } @@ -415,6 +462,17 @@ icon: "none", }); }) + }, + scroll: function(e) { + console.log(e) + this.old.scrollTop = e.detail.scrollTop + }, + goTop: function(e) { + // 解决view层不同步的问题 + this.scrollTop = this.old.scrollTop + this.$nextTick(function() { + this.scrollTop = 0 + }); } } } @@ -427,6 +485,7 @@ background-color: transparent !important; bottom: 2px !important; } + .search_box { width: calc(100% - 32px); margin: 0 16px; @@ -441,24 +500,25 @@ width: 100%; height: 100%; } - + .goodPart { width: 750rpx; background: #F8F8F8; height: calc(100vh - 100px); overflow: hidden; - + .gpLeft { width: 168rpx; height: 100%; float: left; - + .gplItem { width: 168rpx; padding: 20rpx 0; font-size: 30rpx; text-align: center; } + .gplItem_C { width: 162rpx; padding: 20rpx 0; @@ -467,41 +527,44 @@ text-align: center; background: #E8E8E8; border-radius: 0 50px 50px 0; - border-left: 6rpx solid #99241B ; + border-left: 6rpx solid #99241B; } } - + .gpRight { width: 546rpx; height: 100%; float: left; - + .gprTop { width: 100%; height: 70rpx; padding: 10px 0; overflow: hidden; - + .gprtItem { height: 64rpx; line-height: 64rpx; padding: 0 30rpx; margin: 0 10rpx; float: left; - .line{ + + .line { width: calc(100% - 40rpx); min-width: 36rpx; margin: 0 auto; height: 6rpx; } } + .gprtItem_C { height: 64rpx; line-height: 64rpx; padding: 0 30rpx; margin: 0 10rpx; float: left; - .line{ + + .line { width: calc(100% - 40rpx); min-width: 36rpx; margin: 0 auto; @@ -510,20 +573,22 @@ } } } + .artworks { background-color: #ffffff; height: calc(100% - 55px); margin-left: 16rpx; + .art_item { margin: 8px 0; border: 1px solid transparent; - + .art_item_top { position: relative; height: 192px; overflow: hidden; border-radius: 8px; - + .like { position: absolute; top: calc(100% - 40px); @@ -536,21 +601,21 @@ display: flex; align-items: center; justify-content: center; - + .img { width: 16px; height: 16px; background: url(../../static/spaceHeart.png) center/100% no-repeat; float: left; } - + .img_selected { width: 16px; height: 16px; background: url(../../static/redHerart.png) center/100% no-repeat; float: left; } - + .select_num { float: left; margin-left: 10rpx; @@ -558,6 +623,7 @@ } } } + .art_item_bott { .title { margin-top: 12px; @@ -565,14 +631,14 @@ font-weight: 600; color: #251B1D; } - + .sub_title { font-size: 12px; color: #AFADB0; margin-top: 12px; margin-bottom: 16px; - - .tag{ + + .tag { // width: 80rpx; text-align: center; border: 1rpx solid #AFADB0; @@ -582,16 +648,16 @@ padding: 4rpx 10rpx; } } - + .img_box { display: flex; justify-content: space-between; align-items: center; - + .puber { display: flex; align-items: center; - + .avtor { border-radius: 12px; overflow: hidden; @@ -599,24 +665,22 @@ height: 24px; margin-right: 4px; } - + .autor { color: #251B1D; font-size: 12px; } } - + .time { color: #AFADB0; font-size: 12px; } - + } } } } } } - - - + \ No newline at end of file diff --git a/src/pagesC/shop/Shop.vue b/src/pagesC/shop/Shop.vue index ddb88c2..2a20f90 100644 --- a/src/pagesC/shop/Shop.vue +++ b/src/pagesC/shop/Shop.vue @@ -46,7 +46,8 @@ - + @@ -117,6 +118,10 @@ orderBy: '', lineBg: '../../static/scrollLine.png', typesOf: '', + scrollTop: 0, + old: { + scrollTop: 0 + } }; }, onReady() { @@ -229,6 +234,11 @@ }, //上拉商品列表 getMoreData() { + if (this.requestStatus) { + // 利用 return 终止函数继续运行 + return false; + } + this.requestStatus = true; let _this = this this.http.request('/goods/list', { page: this.pages, @@ -256,6 +266,11 @@ if (res.data.records.length == 0) { this.pages-- } + setTimeout(() => { + // 模拟执行完毕 + // 改变 requestStatus + this.requestStatus = false; + }, 500); } }).catch(e => { uni.showToast({ @@ -280,6 +295,7 @@ this.list2 = [] this.orderBy = '' this.pages = 1 + this.goTop() this.getData() }, //选择二级类型 @@ -288,6 +304,7 @@ this.typeT = val2 this.orderBy = '' this.pages = 1 + this.goTop() this.getData() }, changeTypesOf(val) { @@ -301,7 +318,7 @@ name: '全部', type: '', }], - this.list2 = [] + this.list2 = [] this.orderBy = '' this.pages = 1 this.getType() @@ -319,6 +336,7 @@ this.types = '' this.list2 = [] this.pages = 1 + this.goTop() this.getData() } }, @@ -335,6 +353,17 @@ lower() { this.pages++ this.getMoreData(); + }, + scroll: function(e) { + console.log(e) + this.old.scrollTop = e.detail.scrollTop + }, + goTop: function(e) { + // 解决view层不同步的问题 + this.scrollTop = this.old.scrollTop + this.$nextTick(function() { + this.scrollTop = 0 + }); } } }