diff --git a/YJYF/YJYF.vue b/YJYF/YJYF.vue index ddc436b..4f3197a 100644 --- a/YJYF/YJYF.vue +++ b/YJYF/YJYF.vue @@ -108,50 +108,68 @@ - - + + @@ -232,7 +250,9 @@ /* ---------- 服务保障 ---------- */ /* ---------- 服务保障 / 教程 / Banner(均由后端下发) ---------- */ const assures = ref(['平台认证', '先行赔付', '极速上门', '售后无忧']) - const banner = ref(null) + const banners = ref([]) + const bannerIndex = ref(0) + const showBanners = ref(true) const tutorial = ref({ title: '下单找师傅教程', sub: '3 分钟看懂,下单不踩坑' }) /* ---------- 服务图标:纯 CSS 图元,零图片依赖 @@ -256,7 +276,8 @@ cats.value = res.cats || [] badge.value = res.badge || { coupon: 0, unread: 0 } if (res.assures && res.assures.length) assures.value = res.assures - if (res.banners && res.banners.length) banner.value = res.banners[0] + if (res.banners && res.banners.length) banners.value = res.banners + if (bannerIndex.value >= banners.value.length) bannerIndex.value = 0 if (res.tutorial) tutorial.value = res.tutorial } catch (e) {} } @@ -279,8 +300,28 @@ }) const onMore = () => uni.navigateTo({ url: '/pages/service/list?cat_id=15&cat_name=' + encodeURIComponent('更多服务') }) const onLearn = () => toast('教程模块开发中') - const onBanner = () => uni.navigateTo({ url: '/pages/service/list?cat_id=1&cat_name=' + encodeURIComponent('家具') }) - const onCloseBanner = () => toast('已关闭') + const onBannerChange = (e) => { + bannerIndex.value = (e && e.detail && e.detail.current) ? e.detail.current : 0 + } + const goBanner = (i) => { bannerIndex.value = i } + const onBanner = (b) => { + if (!b || !b.link) { + if (b && b.theme === 'brand') return + toast('活动详情敬请期待') + return + } + const link = b.link + if (/^https?:\/\//i.test(link)) { + uni.setClipboardData({ data: link, success: () => toast('链接已复制') }) + return + } + if (link.indexOf('/YJYF/') === 0) { + uni.reLaunch({ url: link }) + return + } + uni.navigateTo({ url: link }) + } + const onCloseBanner = () => { showBanners.value = false } const onOrder = () => { if (!needLogin()) return uni.navigateTo({ url: '/pages/order/quick' }) @@ -1006,6 +1047,112 @@ font-weight: 700; } + /* ---------- 品牌 / 服务主题轮播 ---------- */ + .banner-wrap { margin-top: 24rpx; } + .banner-swiper { + height: 380rpx; + border-radius: 24rpx; + overflow: hidden; + box-shadow: 0 12rpx 28rpx rgba(236, 110, 12, 0.20); + } + .banner-slide { + position: relative; + width: 100%; + height: 100%; + box-sizing: border-box; + padding: 30rpx 30rpx 26rpx; + overflow: hidden; + border-radius: 24rpx; + } + .slide-bg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 0; } + .slide-mask { + position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 1; + background: linear-gradient(90deg, rgba(0,0,0,.38) 0%, rgba(0,0,0,.08) 100%); + } + .slide-deco { position: absolute; border-radius: 50%; z-index: 1; } + .theme-promo { background: linear-gradient(125deg, #FFF3E2 0%, #FFE0BE 45%, #FFC894 100%); } + .theme-promo .slide-deco.d1 { width: 300rpx; height: 300rpx; right: -90rpx; top: -120rpx; background: rgba(255,255,255,.55); } + .theme-promo .slide-deco.d2 { width: 170rpx; height: 170rpx; left: -70rpx; bottom: -80rpx; background: rgba(255,138,60,.16); } + .theme-service { background: linear-gradient(125deg, #FFB062 0%, #F68A22 52%, #EC6E0C 100%); } + .theme-brand { background: linear-gradient(125deg, #FFB062 0%, #F68A22 48%, #EC6E0C 100%); } + .theme-service .slide-deco.d1, .theme-brand .slide-deco.d1 { + width: 320rpx; height: 320rpx; right: -110rpx; top: -130rpx; background: rgba(255,255,255,.12); + } + .theme-service .slide-deco.d2, .theme-brand .slide-deco.d2 { + width: 160rpx; height: 160rpx; left: -60rpx; bottom: -70rpx; background: rgba(255,255,255,.08); + } + .slide-tags { position: relative; z-index: 2; display: flex; } + .slide-tag { + padding: 0 14rpx; line-height: 34rpx; border-radius: 17rpx; + font-size: 20rpx; letter-spacing: 1rpx; + } + .theme-promo .slide-tag { background: linear-gradient(135deg, #F5452B 0%, #D92210 100%); color: #FFE9A8; } + .theme-promo .slide-tag.ghost { margin-left: 10rpx; background: rgba(232,51,27,.12); color: #C0392B; } + .theme-service .slide-tag { background: rgba(255,255,255,.22); color: #fff; } + .slide-title { + position: relative; z-index: 2; display: block; margin-top: 14rpx; + font-size: 46rpx; font-weight: 800; letter-spacing: 1rpx; line-height: 1.18; + } + .theme-promo .slide-title { color: #E8331B; text-shadow: 0 3rpx 0 #FFE9A8; } + .theme-service .slide-title { color: #fff; } + .slide-sub { position: relative; z-index: 2; display: block; margin-top: 8rpx; font-size: 24rpx; line-height: 1.4; } + .theme-promo .slide-sub { color: #C0392B; } + .theme-service .slide-sub { color: rgba(255,255,255,.92); } + .slide-bottom { + position: absolute; left: 30rpx; right: 30rpx; bottom: 26rpx; z-index: 3; + display: flex; align-items: center; justify-content: space-between; + } + .slide-date { padding: 0 16rpx; line-height: 34rpx; border-radius: 17rpx; font-size: 21rpx; } + .theme-promo .slide-date { background: rgba(232,51,27,.10); color: #C0392B; } + .theme-service .slide-date { background: rgba(255,255,255,.18); color: #fff; } + .slide-cta { + height: 60rpx; padding: 0 26rpx; display: flex; align-items: center; + border-radius: 30rpx; font-size: 24rpx; font-weight: 600; + } + .theme-promo .slide-cta { + background: linear-gradient(135deg, #FF9E2E 0%, #EE6C05 100%); color: #fff; + box-shadow: 0 6rpx 16rpx rgba(238,108,5,.32); + } + .theme-service .slide-cta { + background: #fff; color: #E36B0C; + box-shadow: 0 6rpx 16rpx rgba(0,0,0,.12); + } + .slide-close { + position: absolute; right: 20rpx; top: 20rpx; z-index: 4; + width: 40rpx; height: 40rpx; line-height: 36rpx; text-align: center; + border-radius: 50%; font-size: 28rpx; + } + .theme-promo .slide-close { background: rgba(0,0,0,.10); color: #B85E2A; } + .slide-watermark { + position: absolute; right: 26rpx; bottom: -18rpx; z-index: 1; + font-size: 220rpx; line-height: 1; font-weight: 800; color: rgba(255,255,255,.09); + } + .brand-head { position: relative; z-index: 2; display: flex; align-items: center; } + .brand-line { width: 6rpx; height: 28rpx; border-radius: 3rpx; background: #FFF0C9; margin-right: 10rpx; } + .brand-title { font-size: 28rpx; font-weight: 600; color: #FFF3DF; letter-spacing: 1rpx; } + .brand-grid { position: relative; z-index: 2; display: flex; align-items: flex-end; margin-top: 24rpx; } + .brand-cell { flex: 1; display: flex; flex-direction: column; align-items: center; border-left: 2rpx solid rgba(255,255,255,.28); } + .brand-cell:first-child { border-left: none; } + .brand-value { font-size: 48rpx; line-height: 58rpx; font-weight: 800; color: #fff; letter-spacing: 1rpx; } + .brand-label { margin-top: 6rpx; font-size: 22rpx; color: rgba(255,255,255,.85); } + .brand-foot { + position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; + margin-top: 24rpx; padding-top: 18rpx; border-top: 2rpx solid rgba(255,255,255,.22); + } + .brand-foot-txt { font-size: 22rpx; color: rgba(255,255,255,.90); } + .brand-seal { padding: 6rpx 14rpx; border-radius: 8rpx; background: #FFF4E3; color: #E8331B; font-size: 20rpx; font-weight: 700; } + .banner-slide.has-image .slide-title, + .banner-slide.has-image .slide-sub, + .banner-slide.has-image .brand-title, + .banner-slide.has-image .brand-value, + .banner-slide.has-image .brand-label, + .banner-slide.has-image .brand-foot-txt, + .banner-slide.has-image .slide-tag, + .banner-slide.has-image .slide-date { color: #fff; } + .banner-dots { display: flex; align-items: center; justify-content: center; margin-top: 14rpx; } + .banner-dot { width: 12rpx; height: 6rpx; border-radius: 3rpx; background: #FFD4B5; margin: 0 5rpx; transition: all .25s; } + .banner-dot.on { width: 30rpx; background: #F0710D; } + .foot-tip { padding: 36rpx 0 10rpx; text-align: center; diff --git a/db/schema_phase8.sql b/db/schema_phase8.sql new file mode 100644 index 0000000..391c9a3 --- /dev/null +++ b/db/schema_phase8.sql @@ -0,0 +1,45 @@ +-- ============================================================================ +-- 优匠优服 · Phase 8 首页轮播品牌化 + 后台可配置 +-- 新增:主题样式 theme / 按钮文案 action_text / 平台实力统计 JSON stats +-- 默认 4 张:双11活动 / 平台实力 / 家电清洗 / 师傅上门 +-- ============================================================================ +SET NAMES utf8mb4; + +ALTER TABLE `fa_banner` + ADD COLUMN `theme` varchar(20) NOT NULL DEFAULT 'promo' + COMMENT 'promo活动促销 / brand平台实力 / service服务主题' AFTER `date_text`, + ADD COLUMN `action_text` varchar(30) NOT NULL DEFAULT '立即抢购' + COMMENT '按钮文案,品牌数据卡留空则不显示' AFTER `theme`, + ADD COLUMN `stats` text NULL + COMMENT '平台实力统计JSON,仅brand主题使用' AFTER `action_text`; + +-- 现有双11活动位补齐主题配置 +UPDATE `fa_banner` +SET `theme` = 'promo', + `action_text` = '立即抢购', + `link` = '/pages/service/list?cat_id=1&cat_name=%E5%AE%B6%E5%85%B7', + `stats` = NULL, + `weigh` = 100, + `status` = 'normal', + `updatetime` = UNIX_TIMESTAMP() +WHERE `id` = 1; + +-- 品牌实力 / 服务主题轮播 +INSERT INTO `fa_banner` +(`id`,`badge`,`title`,`subtitle`,`date_text`,`theme`,`action_text`,`stats`,`image`,`link`,`weigh`,`status`,`createtime`,`updatetime`) VALUES +(2,'平台实力','平台实力','已有 176276994 个订单找到师傅','下单越多 · 越优惠','brand','', + '[{"value":"460万+","label":"专业师傅"},{"value":"99.9%","label":"区域覆盖到村镇"},{"value":"1762万","label":"成功订单"}]', + '','',95,'normal',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()), +(3,'服务主题','家电清洗季','空调 / 洗衣机 / 油烟机深度清洗','9.9 折起','service','立即预约',NULL,'', + '/pages/service/list?cat_id=10&cat_name=%E5%AE%B6%E7%94%B5',90,'normal',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()), +(4,'师傅上门','快至 30 分钟上门','家具安装 / 卫浴维修 / 灯具更换','先验收 · 后付款','service','立即下单',NULL,'', + '/pages/order/quick',85,'normal',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()) +ON DUPLICATE KEY UPDATE + `badge`=VALUES(`badge`), `title`=VALUES(`title`), `subtitle`=VALUES(`subtitle`), + `date_text`=VALUES(`date_text`), `theme`=VALUES(`theme`), `action_text`=VALUES(`action_text`), + `stats`=VALUES(`stats`), `image`=VALUES(`image`), `link`=VALUES(`link`), + `weigh`=VALUES(`weigh`), `status`=VALUES(`status`), `updatetime`=VALUES(`updatetime`); + +-- 回滚: +-- 先确认并备份 fa_banner 数据,再执行: +-- ALTER TABLE fa_banner DROP COLUMN `stats`, DROP COLUMN `action_text`, DROP COLUMN `theme`; diff --git a/server/application/admin/view/banner/add.html b/server/application/admin/view/banner/add.html index 5c2bc53..06854b3 100644 --- a/server/application/admin/view/banner/add.html +++ b/server/application/admin/view/banner/add.html @@ -24,11 +24,34 @@ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 仅“平台实力”主题使用;每项包含 value 和 label,留空使用默认平台数据 +
+
- +
@@ -41,7 +64,7 @@
- +
diff --git a/server/application/admin/view/banner/edit.html b/server/application/admin/view/banner/edit.html index 64e98f3..e6bb205 100644 --- a/server/application/admin/view/banner/edit.html +++ b/server/application/admin/view/banner/edit.html @@ -24,11 +24,34 @@
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 仅“平台实力”主题使用;每项包含 value 和 label,留空使用默认平台数据 +
+
- +
@@ -41,7 +64,7 @@
- +
diff --git a/server/application/api/controller/Home.php b/server/application/api/controller/Home.php index ae0b496..b97af42 100644 --- a/server/application/api/controller/Home.php +++ b/server/application/api/controller/Home.php @@ -187,33 +187,121 @@ class Home extends Base } /** - * 首页运营位(后台 fa_banner 可管,缺省回落到内置文案) + * 首页轮播(后台 fa_banner 可管,支持活动 / 平台实力 / 服务主题) */ protected function banners() { - $rows = Db::name('banner')->where('status', 'normal')->order('weigh desc,id desc')->limit(5)->select(); + $rows = Db::name('banner') + ->field('id,badge,title,subtitle,date_text,theme,action_text,stats,image,link,weigh') + ->where('status', 'normal') + ->order('weigh desc,id desc') + ->limit(8) + ->select(); if (!$rows) { - return [[ - 'id' => 0, 'badge' => '家装季', 'title' => '双11 狂欢大促', - 'subtitle' => '下单立减 · 满额再返券', 'date_text' => '10.23 - 11.15', - 'image' => '', 'link' => '', - ]]; + return $this->defaultBanners(); } + + $themeText = [ + 'promo' => '活动促销', + 'brand' => '平台实力', + 'service' => '服务主题', + ]; + $ret = []; foreach ($rows as $r) { + $theme = isset($themeText[$r['theme']]) ? $r['theme'] : 'promo'; + $stats = $this->parseBannerStats(isset($r['stats']) ? $r['stats'] : ''); + if ($theme === 'brand' && empty($stats)) { + $stats = $this->defaultBrandStats(); + } + $actionText = trim((string)$r['action_text']); + if ($actionText === '' && $theme !== 'brand') { + $actionText = '立即查看'; + } $ret[] = [ - 'id' => (int)$r['id'], - 'badge' => $r['badge'], - 'title' => $r['title'], - 'subtitle' => $r['subtitle'], - 'date_text' => $r['date_text'], - 'image' => $r['image'], - 'link' => $r['link'], + 'id' => (int)$r['id'], + 'badge' => $r['badge'], + 'title' => $r['title'], + 'subtitle' => $r['subtitle'], + 'date_text' => $r['date_text'], + 'theme' => $theme, + 'theme_text' => $themeText[$theme], + 'action_text' => $actionText, + 'stats' => $stats, + 'image' => $r['image'], + 'link' => $r['link'], ]; } return $ret; } + /** + * 解析平台实力主题的统计 JSON + */ + protected function parseBannerStats($raw) + { + $raw = trim((string)$raw); + if ($raw === '') { + return []; + } + $decoded = json_decode($raw, true); + if (!is_array($decoded)) { + return []; + } + $out = []; + foreach ($decoded as $item) { + if (!is_array($item) || !isset($item['value']) || !isset($item['label'])) { + continue; + } + $out[] = [ + 'value' => (string)$item['value'], + 'label' => (string)$item['label'], + ]; + } + return $out; + } + + /** + * 平台实力默认指标 + */ + protected function defaultBrandStats() + { + return [ + ['value' => '460万+', 'label' => '专业师傅'], + ['value' => '99.9%', 'label' => '区域覆盖到村镇'], + ['value' => '1762万', 'label' => '成功订单'], + ]; + } + + /** + * 无后台数据时的兜底轮播 + */ + protected function defaultBanners() + { + return [ + [ + 'id' => 0, 'badge' => '家装季', 'title' => '双11 狂欢大促', + 'subtitle' => '下单立减 · 满额再返券', 'date_text' => '10.23 - 11.15', + 'theme' => 'promo', 'theme_text' => '活动促销', 'action_text' => '立即抢购', + 'stats' => [], 'image' => '', + 'link' => '/pages/service/list?cat_id=1&cat_name=%E5%AE%B6%E5%85%B7', + ], + [ + 'id' => -1, 'badge' => '平台实力', 'title' => '平台实力', + 'subtitle' => '已有 176276994 个订单找到师傅', 'date_text' => '下单越多 · 越优惠', + 'theme' => 'brand', 'theme_text' => '平台实力', 'action_text' => '', + 'stats' => $this->defaultBrandStats(), 'image' => '', 'link' => '', + ], + [ + 'id' => -2, 'badge' => '服务主题', 'title' => '家电清洗季', + 'subtitle' => '空调 / 洗衣机 / 油烟机深度清洗', 'date_text' => '9.9 折起', + 'theme' => 'service', 'theme_text' => '服务主题', 'action_text' => '立即预约', + 'stats' => [], 'image' => '', + 'link' => '/pages/service/list?cat_id=10&cat_name=%E5%AE%B6%E7%94%B5', + ], + ]; + } + /** * 读取 fa_config 中的逗号分隔列表 */