tianyi 6 months ago
parent
commit
cfe29e2656
  1. 11
      pages/index/index.vue

11
pages/index/index.vue

@ -1060,16 +1060,12 @@
that.mallAds = res.result.mallAds
for(let i=0;i<that.mallAds.length;i++){
if(that.mallAds[i].position == 'home_top'){
// 判断字符串中是否包含逗号
if (that.mallAds[i].adImage.indexOf(',') !== -1) {
// 有逗号:先按逗号分割,再过滤掉空字符串或纯空白字符串,最后映射为 {pic: url} 对象数组
that.adList = that.mallAds[i].adImage
.split(',')
.filter(item => item.trim() !== '') // 过滤掉空项
.map(url => ({
pic: url.trim()
}));
that.adList = that.mallAds[i].adImage.split(',').filter(item => item.trim() !== '').map(url => ({
pic: url.trim()
}));
} else {
// 没有逗号:整个字符串作为一个对象
that.adList = [{
@ -1107,6 +1103,7 @@
}).catch((res) => {});
},
goAdPage(item) {
console.log('hahahahah',item)
uni.navigateTo({
url: item.linkUrl + item.linkParams
})

Loading…
Cancel
Save