修复首页金刚区显示,广告区显示

This commit is contained in:
Daniel Kou 2026-07-02 16:15:40 +08:00
parent 96f2ee15eb
commit b770725a5d
2 changed files with 82 additions and 92 deletions

View File

@ -237,7 +237,7 @@ page {
} }
.tabList text { .tabList text {
font-size: 30rpx; font-size: 26rpx;
} }
.tabItem { .tabItem {

View File

@ -65,8 +65,7 @@
<!-- 轮播图 --> <!-- 轮播图 -->
<view class="swiper"> <view class="swiper">
<swiper @animationfinish="swipers" autoplay circular> <swiper @animationfinish="swipers" autoplay circular>
<!-- <swiper-item v-for="(item, index) in bannerList" :key="index" @click="headerServerClick(item)"> --> <swiper-item v-for="(item, index) in bannerList" :key="index" @click="handleAdClick(item)">
<swiper-item v-for="(item, index) in bannerList" :key="index">
<image :src="item.pic_src" mode="aspectFill" /> <image :src="item.pic_src" mode="aspectFill" />
</swiper-item> </swiper-item>
</swiper> </swiper>
@ -92,13 +91,12 @@
<!-- 广告横幅 --> <!-- 广告横幅 -->
<view class="serverList1"> <view class="serverList1">
<view class="serverList1_left" v-if="serverLeftList.length > 0"> <view class="serverList1_left" v-if="serverLeftList.length > 0">
<image :src="serverLeft" mode="aspectFill" @tap="toAdvertisingView(serverLeftList)" /> <image :src="serverLeft" mode="aspectFill" @tap="handleAdClick(serverLeftList[0])" />
</view> </view>
<view class="serverList1_right" v-if="serverRightList.length > 0"> <view class="serverList1_right" v-if="serverRightList.length > 0">
<view :class="['serverItemRight', `serverItemRight${index + 1}`]" v-for="(item, index) in serverRightList" <view :class="['serverItemRight', `serverItemRight${index + 1}`]" v-for="(item, index) in serverRightList"
:key="index"> :key="index">
<image :src="item.pic_src" mode="" <image :src="item.pic_src" mode="" @tap="handleAdClick(item)" />
@tap="index === 0 ? toAdvertisingView(serverRightList) : goToPurify(item)" />
</view> </view>
</view> </view>
</view> </view>
@ -112,7 +110,7 @@
<view class="serverList"> <view class="serverList">
<view class="serverList_left"> <view class="serverList_left">
<swiper> <swiper>
<swiper-item v-for="(item, index) in homeLeftList" :key="index" @click="headerServerClick(item)"> <swiper-item v-for="(item, index) in homeLeftList" :key="index" @click="handleAdClick(item)">
<image :src="item.pic_src" alt="" class="serverList_left_img" /> <image :src="item.pic_src" alt="" class="serverList_left_img" />
<!-- <view>{{ item.ad_position }}</view> --> <!-- <view>{{ item.ad_position }}</view> -->
</swiper-item> </swiper-item>
@ -259,6 +257,22 @@ import {
import nav from '../../components/nav/nav'; //1. import nav from '../../components/nav/nav'; //1.
// 广 home_banner_region.ad_position
const AD_POS = {
TOP_BANNER: 1, //
CARD_LEFT: 2, //
CARD_RIGHT_TOP: 3, //
CARD_RIGHT_BOTTOM: 4, //
MID_LEFT: 5, // 广
MID_CENTER_TOP: 6, //
MID_CENTER: 7, //
MID_CENTER_BOTTOM: 8, //
MID_RIGHT_TOP: 9, //
MID_RIGHT_CENTER: 10, //
MID_RIGHT_BOTTOM: 11, //
POPUP: 12, //
BOTTOM_RECOMMEND: 13, //
};
export default { export default {
components: { components: {
@ -353,22 +367,28 @@ export default {
}) })
}, },
// 广 // 广 promotion_type
toAdvertisingView(itemArry) { // 1 / 3(link_url) / 4(appid+link_url) / 5(广)
const item = itemArry[0] handleAdClick(item) {
NavgateTo('/packages/advertising/index/index?id=' + item.id, { isLogin: false }) if (!item) return
}, switch (item.promotion_type) {
case 3: //
// if (!item.link_url) return this.NotOpen()
goToPurify() { if (item.link_url === '/packages/shopEnter/index/index') return this.headershopEnterClick()
uni.navigateToMiniProgram({ return NavgateTo(item.link_url, { isLogin: false })
appId: 'wx77b22c0a0018e580', case 4: //
path: 'pages/newLogin/newLogin', if (!item.appid) return this.NotOpen()
envVersion: 'release', return uni.navigateToMiniProgram({
success(res) { appId: item.appid,
// path: item.link_url || '',
} envVersion: 'release'
}) })
case 5: // 广
return NavgateTo('/packages/advertising/index/index?id=' + item.id, { isLogin: false })
case 1:
default: //
return this.NotOpen()
}
}, },
async goToWuye() { async goToWuye() {
@ -715,87 +735,57 @@ export default {
return (res && res.rows) ? res.rows : []; return (res && res.rows) ? res.rows : [];
}, },
//
withPicUrl(list) {
list.forEach(item => { item.pic_src = picUrl + item.pic_src })
return list
},
// 广广 null
async getBannerAt(position, { placeholder = false } = {}) {
const rows = await this.getBannerRows(position)
const [first] = this.withPicUrl(this.filterShowList(rows, 1))
if (first) return first
return placeholder ? { ad_position: position, pic_src: '' } : null
},
//
async getBannersAt(positions, opts) {
return Promise.all(positions.map(p => this.getBannerAt(p, opts)))
},
async getHomeBanner() { async getHomeBanner() {
const rows = await this.getBannerRows(1); const rows = await this.getBannerRows(AD_POS.TOP_BANNER);
if (rows && rows.length) { return this.withPicUrl(this.filterShowList(rows, 1));
let filterRes = this.filterShowList(rows, 1);
filterRes.forEach(item => {
item.pic_src = picUrl + item.pic_src
})
return filterRes
} else {
return []
}
}, },
async getServerLeft() { async getServerLeft() {
const rows = await this.getBannerRows(2); const rows = await this.getBannerRows(AD_POS.CARD_LEFT);
if (!rows || !rows.length) { const shown = this.withPicUrl(this.filterShowList(rows, 1));
this.serverLeftList = [] this.serverLeftList = shown; // [0]
} return shown.length ? shown[0].pic_src : [];
if (rows && rows.length) {
this.serverLeftList = rows
let filterRes = this.filterShowList(rows, 1);
filterRes.forEach(item => {
item.pic_src = picUrl + item.pic_src
})
const itemUrl = filterRes[0].pic_src
return itemUrl
} else {
return []
}
}, },
async getServerRight() { async getServerRight() {
const rightList = [] // 广
for (let i = 3; i < 5; i++) { const list = await this.getBannersAt([
const rows = await this.getBannerRows(i); AD_POS.CARD_RIGHT_TOP,
if (!rows || !rows.length) { AD_POS.CARD_RIGHT_BOTTOM,
this.serverRightList = [] ]);
} return list.filter(Boolean);
if (rows && rows.length) {
let filterRes = this.filterShowList(rows, 1);
filterRes.forEach(item => {
item.pic_src = picUrl + item.pic_src
})
rightList.push(...filterRes)
}
}
return rightList
}, },
async getHomeMidLeft() { async getHomeMidLeft() {
const rows = await this.getBannerRows(5); const rows = await this.getBannerRows(AD_POS.MID_LEFT);
if (rows && rows.length) { return this.withPicUrl(this.filterShowList(rows, 1));
let filterRes = this.filterShowList(rows, 1);
filterRes.forEach(item => {
item.pic_src = picUrl + item.pic_src
})
return filterRes
} else {
return []
}
}, },
async getHomeMidRight() { async getHomeMidRight() {
const rightList = [] // 6 slice(0,3)/slice(3,6)
for (let i = 6; i < 12; i++) { return this.getBannersAt([
const rows = await this.getBannerRows(i); AD_POS.MID_CENTER_TOP, AD_POS.MID_CENTER, AD_POS.MID_CENTER_BOTTOM,
if (rows && rows.length) { AD_POS.MID_RIGHT_TOP, AD_POS.MID_RIGHT_CENTER, AD_POS.MID_RIGHT_BOTTOM,
let filterRes = this.filterShowList(rows, 1); ], { placeholder: true });
filterRes.forEach(item => {
item.pic_src = picUrl + item.pic_src
})
rightList.push(...filterRes)
} else {
rightList.push({
ad_position: i,
pic_src: ''
})
}
}
return rightList
}, },
// async getHomeCenterTop() { // async getHomeCenterTop() {
@ -936,7 +926,7 @@ export default {
async getHomeBottom(val = false) { async getHomeBottom(val = false) {
const res = await request(apiArr2.getHomeBanner, "POST", { const res = await request(apiArr2.getHomeBanner, "POST", {
ad_code: uni.getStorageSync('ad_code'), ad_code: uni.getStorageSync('ad_code'),
ad_position: 5, ad_position: AD_POS.BOTTOM_RECOMMEND,
longitude: uni.getStorageSync('location').lng, longitude: uni.getStorageSync('location').lng,
latitude: uni.getStorageSync('location').lat, latitude: uni.getStorageSync('location').lat,
page_num: this.bottomPageNum, page_num: this.bottomPageNum,