广场动态样式问题优化

main
wangdong 6 months ago
parent 42ddd9b2bd
commit ae6da1d87e
  1. 7
      pages/index/index.vue
  2. 99
      pages/squareDynamic/index.vue

@ -665,7 +665,7 @@
}) })
} }
this.list = [...arr]; this.list = [...arr];
if (data.select_mechant) { if (data.select_mechant && uni.getStorageSync('storeVersion') == 1) {
this.gridList.splice(5, 1, this.gridList.splice(5, 1,
{ {
image: '/static/tabbar/shop-active.png', image: '/static/tabbar/shop-active.png',
@ -1068,7 +1068,9 @@
uni.setStorageSync('storeVersion', res.data.storeInfo.store_version || 0); uni.setStorageSync('storeVersion', res.data.storeInfo.store_version || 0);
} }
}) })
.finally(() => {}) .finally(() => {
this.queryWxAppSetting();
})
}, },
goJump(path) { goJump(path) {
uni.navigateTo({ uni.navigateTo({
@ -1164,7 +1166,6 @@
this.getServeList(); this.getServeList();
this.queryBannerList(); this.queryBannerList();
this.getStore(); this.getStore();
this.queryWxAppSetting();
this.getAuthorize(); this.getAuthorize();
}, },
onShow() { onShow() {

@ -17,12 +17,12 @@
<view class="time">{{ item.update_time }}</view> <view class="time">{{ item.update_time }}</view>
</view> </view>
</view> </view>
<view class="cont"> <view class="cont" :class="[`cont${index}`, { 'close': item.contH > 120 && !showFullCont.includes(index)}]">
{{ showFullCont.includes(index) ? item.content : calcContentWidth(item.content).splitStr }} {{ item.content }}
<view v-if="!showFullCont.includes(index) && calcContentWidth(item.content).isSplit" class="show-more" @click="showFullCont.push(index)">全文</view>
</view> </view>
<view v-if="item.contH > 120" class="show-more" @click="toggleFullCont(index)">{{ showFullCont.includes(index) ? '收起' : '全文' }}</view>
<view v-if="item.imgs && item.imgs.length > 0" class="pic-list"> <view v-if="item.imgs && item.imgs.length > 0" class="pic-list">
<image v-for="(pic, k) in item.imgs" :key="k" :src="pic.external_url" mode="aspectFill" @click="previewImage(k, item.imgs)"></image> <image v-for="(pic, k) in item.imgs" :key="k" :src="pic.external_url" mode="aspectFill" @click="previewImages(k, item.imgs)"></image>
</view> </view>
<view v-if="item.goodsInfo" class="goods"> <view v-if="item.goodsInfo" class="goods">
<view class="goods-box"> <view class="goods-box">
@ -108,6 +108,7 @@
edge: 20, edge: 20,
userInfo: {}, userInfo: {},
isLogin: false, isLogin: false,
isPreview: false
}; };
}, },
watch: { watch: {
@ -139,16 +140,20 @@
}).exec(); }).exec();
}, },
onShow() { onShow() {
this.loading = false; if (!this.isPreview) {
this.finished = false; this.loading = false;
this.page = 1; this.finished = false;
this.dynamicList = []; this.page = 1;
this.getDynamicList(); this.dynamicList = [];
if (uni.getStorageSync("userInfo").user_id) { this.getDynamicList();
this.isLogin = true if (uni.getStorageSync("userInfo").user_id) {
this.onRefreshPage() this.isLogin = true
this.onRefreshPage()
} else {
this.userInfo = {}
}
} else { } else {
this.userInfo = {} this.isPreview = false;
} }
}, },
methods: { methods: {
@ -197,30 +202,42 @@
console.log(result); console.log(result);
const data = result.data.data; const data = result.data.data;
this.dynamicList = this.dynamicList.concat(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.finished = data.length < this.limit;
this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多"; this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多";
}) })
.finally(() => this.loading = false) .finally(() => this.loading = false)
}, },
calcContentWidth(cont) { getHeight(item, index) {
let len = 0; console.log(item, index);
let spliti = 0; this.$nextTick(() => {
for (var i = 0; i < cont.length; i++) { const query = uni.createSelectorQuery().in(this);
const code = cont.charCodeAt(i); query.select(`.cont${index}`).boundingClientRect(data => {
if (cont.charCodeAt(i) > 255 || cont.charCodeAt(i) < 0) { console.log(data);
len += 17; if (data) {
} else { // data.height
len += 10; console.log('元素高度:', data.height);
} item.contH = data.height;
if (len > 710 && spliti === 0) {
spliti = i;
} }
}).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) { clipCont(cont) {
uni.setClipboardData({ uni.setClipboardData({
@ -348,7 +365,7 @@
this.isMove = false; this.isMove = false;
}, },
previewImage(idx, images) { previewImages(idx, images) {
console.log(idx, images); console.log(idx, images);
const arr = []; const arr = [];
images.forEach(v => { images.forEach(v => {
@ -358,6 +375,7 @@
current: idx, current: idx,
urls: arr, urls: arr,
}) })
this.isPreview = true;
}, },
toGoodsDetail(item) { toGoodsDetail(item) {
this.$navTo('pages/goods/detail', { this.$navTo('pages/goods/detail', {
@ -453,13 +471,22 @@
position: relative; position: relative;
color: #222222; color: #222222;
word-break: break-word; word-break: break-word;
.show-more { white-space: pre-line;
position: absolute; &.close {
right: 10rpx; max-height: 240rpx;
bottom: 0; overflow: hidden;
color: #F34A40; 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 { .pic-list {
margin-top: 24rpx; margin-top: 24rpx;
>image { >image {

Loading…
Cancel
Save