Browse Source

调整导航栏配置:仅首页使用自定义导航栏,恢复其他页面返回按钮

pull/13/head
Default User 2 months ago
parent
commit
5e349e2c1f
  1. 2
      app.json
  2. 56
      pages/index/index.js
  3. 6
      pages/index/index.json
  4. 57
      pages/index/index.wxml
  5. 61
      pages/index/index.wxss

2
app.json

@ -53,7 +53,7 @@
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff", "navigationBarBackgroundColor": "#ffffff",
"navigationBarTitleText": "又鸟蛋平台", "navigationBarTitleText": "又鸟蛋平台",
"navigationBarTextStyle": "black" "navigationBarTextStyle": "black"
}, },

56
pages/index/index.js

@ -61,6 +61,25 @@ Page({
partnerstatus: '', partnerstatus: '',
viewedGoods: [], // 已浏览商品ID列表 viewedGoods: [], // 已浏览商品ID列表
// 广告轮播图数据
adCarouselList: [
{
id: 1,
imageUrl: '/images/招商图片.jpg',
link: ''
},
{
id: 2,
imageUrl: '/images/立即入驻导航图片.jpg',
link: ''
},
{
id: 3,
imageUrl: '/images/首页分享照片.jpg',
link: ''
}
],
// 侧边栏相关 // 侧边栏相关
showSidebar: false, showSidebar: false,
isDragging: false, isDragging: false,
@ -1233,33 +1252,26 @@ Page({
// 广告点击事件处理 // 广告点击事件处理
onAdClick: function (e) { onAdClick: function (e) {
const adSlot = e.currentTarget.dataset.ad; const ad = e.currentTarget.dataset.ad;
let imageSrc = e.currentTarget.dataset.src; const index = e.currentTarget.dataset.index;
console.log('广告被点击:', ad, '索引:', index);
// 如果没有从data-src获取到,尝试从图片元素直接获取src
if (!imageSrc) {
imageSrc = e.currentTarget.src;
}
console.log('广告被点击, 广告位:', adSlot);
console.log('广告图片路径:', imageSrc);
// 直接预览广告图片(单击触发)
const validImageUrls = [imageSrc];
if (validImageUrls.length > 0 && validImageUrls[0]) { // 如果广告有链接,跳转到链接
if (ad.link) {
wx.navigateTo({
url: ad.link
});
} else {
// 否则预览广告图片,支持左右切换
const { adCarouselList } = this.data;
const validImageUrls = adCarouselList.map(item => item.imageUrl).filter(url => url);
if (validImageUrls.length > 0) {
this.setData({ this.setData({
previewImageUrls: validImageUrls, previewImageUrls: validImageUrls,
previewImageIndex: 0, previewImageIndex: index,
showImagePreview: true showImagePreview: true
}); });
console.log('广告图片预览已打开,图片URL:', validImageUrls[0]); }
} else {
console.error('无法获取广告图片路径');
wx.showToast({
title: '图片加载失败',
icon: 'none'
});
} }
}, },

6
pages/index/index.json

@ -4,5 +4,9 @@
}, },
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"backgroundTextStyle": "dark", "backgroundTextStyle": "dark",
"backgroundColor": "#f8f8f8" "backgroundColor": "#f8f8f8",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTitleText": "",
"navigationBarTextStyle": "black",
"navigationStyle": "custom"
} }

57
pages/index/index.wxml

@ -1,8 +1,31 @@
<view class="container"> <view class="container">
<!-- 顶部搜索区域容器 - 始终固定显示 --> <!-- 顶部搜索区域容器 - 始终固定显示 -->
<view class="top-section-container"> <view class="top-section-container">
<!-- 标题 -->
<view class="title">专业的鸡蛋交易平台</view> <!-- 广告走马灯轮播图 -->
<view class="ad-carousel">
<swiper
class="ad-swiper"
indicator-dots="{{true}}"
autoplay="{{true}}"
interval="3000"
duration="500"
circular="{{true}}"
indicator-color="rgba(255, 255, 255, 0.5)"
indicator-active-color="#ffffff"
>
<swiper-item wx:for="{{adCarouselList}}" wx:key="index">
<image
class="ad-image"
src="{{item.imageUrl}}"
mode="aspectFill"
bindtap="onAdClick"
data-ad="{{item}}"
data-index="{{index}}"
/>
</swiper-item>
</swiper>
</view>
<!-- 搜索区域 --> <!-- 搜索区域 -->
<view class="search-section"> <view class="search-section">
@ -21,6 +44,21 @@
<view class="egg-inner" style="position: relative;" bindtap="openAdvancedFilter">筛选</view> <view class="egg-inner" style="position: relative;" bindtap="openAdvancedFilter">筛选</view>
</view> </view>
</view> </view>
<!-- 品种筛选区域 -->
<view class="category-section">
<view class="category-scroll">
<view
wx:for="{{categories}}"
wx:key="index"
class="egg-item {{selectedCategory === item ? 'active' : ''}}"
bindtap="selectCategory"
data-category="{{item}}"
>
<view class="egg-inner">{{item}}</view>
</view>
</view>
</view>
</view> </view>
<!-- 地区选择器弹窗 --> <!-- 地区选择器弹窗 -->
@ -41,21 +79,6 @@
</view> </view>
</view> </view>
<!-- 品种筛选区域 -->
<view class="category-section">
<view class="category-scroll">
<view
wx:for="{{categories}}"
wx:key="index"
class="egg-item {{selectedCategory === item ? 'active' : ''}}"
bindtap="selectCategory"
data-category="{{item}}"
>
<view class="egg-inner">{{item}}</view>
</view>
</view>
</view>
<!-- 侧边栏按钮 --> <!-- 侧边栏按钮 -->
<view <view
class="sidebar-btn {{sidebarBtnHidden ? 'hidden' : ''}}" class="sidebar-btn {{sidebarBtnHidden ? 'hidden' : ''}}"

61
pages/index/index.wxss

@ -58,16 +58,42 @@ page {
left: 0; left: 0;
right: 0; right: 0;
z-index: 1002; z-index: 1002;
background: rgba(255, 255, 255, 0.95); background: transparent;
backdrop-filter: blur(10rpx); backdrop-filter: none;
-webkit-backdrop-filter: blur(10rpx); -webkit-backdrop-filter: none;
padding: 10rpx 0; padding: 0 0 10rpx;
min-height: 120rpx; min-height: 480rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08); box-shadow: none;
border-bottom: 1rpx solid rgba(0, 0, 0, 0.05); border-bottom: none;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
overflow: visible;
}
/* 广告轮播图样式 */
.ad-carousel {
width: 100%;
margin: 0;
overflow: hidden;
border-radius: 0;
box-shadow: none;
height: 320rpx;
position: relative;
z-index: 1000;
}
.ad-swiper {
width: 100%;
height: 100%;
}
.ad-image {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 0;
background-color: #f5f5f5;
} }
/* 确保所有主要区域背景一致 */ /* 确保所有主要区域背景一致 */
@ -107,14 +133,16 @@ page {
.top-section-container .search-section { .top-section-container .search-section {
padding: 0 30rpx 15rpx; padding: 0 30rpx 15rpx;
width: 100%; width: 100%;
max-width: 800rpx; max-width: 850rpx;
} }
/* 搜索框样式 */ /* 搜索框样式 */
.top-section-container .search-bar { .top-section-container .search-bar {
display: flex; display: flex;
align-items: center; align-items: center;
background: white; background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10rpx);
-webkit-backdrop-filter: blur(10rpx);
border-radius: 50rpx; border-radius: 50rpx;
padding: 5rpx 15rpx; padding: 5rpx 15rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
@ -124,10 +152,10 @@ page {
/* 修复商品列表区域 */ /* 修复商品列表区域 */
.goods-list { .goods-list {
flex: 1; flex: 1;
padding-top: 240rpx; padding-top: 500rpx;
padding-bottom: 20rpx; padding-bottom: 20rpx;
height: auto; height: auto;
min-height: calc(100vh - 260rpx); /* 确保有足够的最小高度 */ min-height: calc(100vh - 520rpx); /* 确保有足够的最小高度 */
box-sizing: border-box; box-sizing: border-box;
overflow-y: auto; overflow-y: auto;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
@ -136,18 +164,15 @@ page {
/* 品种筛选区域调整 - 确保在商品图层之上,搜索框之下 */ /* 品种筛选区域调整 - 确保在商品图层之上,搜索框之下 */
.category-section { .category-section {
position: fixed; width: 100%;
top: 150rpx; max-width: 850rpx;
left: 0;
right: 0;
z-index: 1001;
background: transparent; background: transparent;
padding: 6rpx 0; padding: 10rpx 0;
height: auto; height: auto;
min-height: 70rpx; min-height: 70rpx;
box-sizing: border-box; box-sizing: border-box;
box-shadow: none; box-shadow: none;
margin: 0; margin: 0 auto 10rpx;
} }
/* iOS专用修复 */ /* iOS专用修复 */

Loading…
Cancel
Save