From ae6da1d87ed4fdaf3c09acfe0e6b79bf65bb4ade Mon Sep 17 00:00:00 2001 From: wangdong <1551135706@qq.com> Date: Mon, 3 Jun 2024 14:51:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=BF=E5=9C=BA=E5=8A=A8=E6=80=81=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 7 +-- pages/squareDynamic/index.vue | 99 ++++++++++++++++++++++------------- 2 files changed, 67 insertions(+), 39 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 7d71ebd..04ee354 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -665,7 +665,7 @@ }) } this.list = [...arr]; - if (data.select_mechant) { + if (data.select_mechant && uni.getStorageSync('storeVersion') == 1) { this.gridList.splice(5, 1, { image: '/static/tabbar/shop-active.png', @@ -1068,7 +1068,9 @@ uni.setStorageSync('storeVersion', res.data.storeInfo.store_version || 0); } }) - .finally(() => {}) + .finally(() => { + this.queryWxAppSetting(); + }) }, goJump(path) { uni.navigateTo({ @@ -1164,7 +1166,6 @@ this.getServeList(); this.queryBannerList(); this.getStore(); - this.queryWxAppSetting(); this.getAuthorize(); }, onShow() { diff --git a/pages/squareDynamic/index.vue b/pages/squareDynamic/index.vue index 500abd3..56308c1 100644 --- a/pages/squareDynamic/index.vue +++ b/pages/squareDynamic/index.vue @@ -17,12 +17,12 @@ {{ item.update_time }} - - {{ showFullCont.includes(index) ? item.content : calcContentWidth(item.content).splitStr }} - 全文 + + {{ item.content }} + {{ showFullCont.includes(index) ? '收起' : '全文' }} - + @@ -108,6 +108,7 @@ edge: 20, userInfo: {}, isLogin: false, + isPreview: false }; }, watch: { @@ -139,16 +140,20 @@ }).exec(); }, onShow() { - this.loading = false; - this.finished = false; - this.page = 1; - this.dynamicList = []; - this.getDynamicList(); - if (uni.getStorageSync("userInfo").user_id) { - this.isLogin = true - this.onRefreshPage() + if (!this.isPreview) { + this.loading = false; + this.finished = false; + this.page = 1; + this.dynamicList = []; + this.getDynamicList(); + if (uni.getStorageSync("userInfo").user_id) { + this.isLogin = true + this.onRefreshPage() + } else { + this.userInfo = {} + } } else { - this.userInfo = {} + this.isPreview = false; } }, methods: { @@ -197,30 +202,42 @@ console.log(result); const data = result.data.data; this.dynamicList = this.dynamicList.concat(data); + this.$nextTick(() => { + if (this.dynamicList) { + this.dynamicList.forEach((item, index) => { + if (!item.contH) { + this.getHeight(item, index); + } + }) + } + }) this.finished = data.length < this.limit; this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多"; }) .finally(() => this.loading = false) }, - calcContentWidth(cont) { - let len = 0; - let spliti = 0; - for (var i = 0; i < cont.length; i++) { - const code = cont.charCodeAt(i); - if (cont.charCodeAt(i) > 255 || cont.charCodeAt(i) < 0) { - len += 17; - } else { - len += 10; - } - if (len > 710 && spliti === 0) { - spliti = i; + getHeight(item, index) { + console.log(item, index); + this.$nextTick(() => { + const query = uni.createSelectorQuery().in(this); + query.select(`.cont${index}`).boundingClientRect(data => { + console.log(data); + if (data) { + // data.height 就是元素的高度 + console.log('元素高度:', data.height); + item.contH = data.height; } + }).exec(); + }) + }, + toggleFullCont(index) { + if (this.showFullCont.includes(index)) { + const idx = this.showFullCont.findIndex(v => v == index); + console.log(idx); + this.showFullCont.splice(idx, 1); + } else { + this.showFullCont.push(index); } - console.log(cont, cont.length, spliti, len); - return { - isSplit: len > 748, - splitStr: len > 710 ? `${cont.split('').splice(0, spliti).join('')}...` : cont, - }; }, clipCont(cont) { uni.setClipboardData({ @@ -348,7 +365,7 @@ this.isMove = false; }, - previewImage(idx, images) { + previewImages(idx, images) { console.log(idx, images); const arr = []; images.forEach(v => { @@ -358,6 +375,7 @@ current: idx, urls: arr, }) + this.isPreview = true; }, toGoodsDetail(item) { this.$navTo('pages/goods/detail', { @@ -453,13 +471,22 @@ position: relative; color: #222222; word-break: break-word; - .show-more { - position: absolute; - right: 10rpx; - bottom: 0; - color: #F34A40; + white-space: pre-line; + &.close { + max-height: 240rpx; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 6; + -webkit-box-orient: vertical; } } + .show-more { + font-size: 28rpx; + line-height: 40rpx; + color: #F34A40; + text-align: right; + } .pic-list { margin-top: 24rpx; >image {