feat: 完成商家改版相关页面与请求工具修改

This commit is contained in:
丁杰 2026-06-03 17:49:38 +08:00
parent d5d7242ec7
commit 1e56c78f12
3 changed files with 186 additions and 155 deletions

View File

@ -1,7 +1,7 @@
<template>
<view class="container">
<view class="positonFixed">
<view class="header-top flex-row-center" :style="{ height: `${100}rpx`,paddingTop:`${statusBarHeight}rpx`}">
<view class="header-top flex-row-center" :style="{ height: `${100 + statusBarHeight}rpx`,paddingTop:`${statusBarHeight}rpx`}">
<view class="left-area" @click="goBack">
<image src="/static/images/back.png" mode="aspectFit" class="back-icon"></image>
</view>
@ -25,7 +25,7 @@
<swiper class="swiper" circular :style="swiperStyle" :current="current" @change="swiperChange"
:disable-touch="current==0">
<swiper-item>
<scroll-view scroll-y :style="{height:`${viewportHeight-100-this.statusBarHeight}rpx`}">
<scroll-view scroll-y :style="{height:`${viewportHeight - 100 - statusBarHeight}rpx`}">
<view class="swiper-items3">
<view class="swiper-item3" :class="{item2Left:index%2 == 0}"
v-for="(item,index) in videoList" :key="index" @click="tovideo(item)">
@ -40,7 +40,7 @@
</scroll-view>
</swiper-item>
<swiper-item>
<scroll-view scroll-y :style="{height:`${viewportHeight-100-this.statusBarHeight-100}rpx`}">
<scroll-view scroll-y :style="{height:`${viewportHeight - 100 - statusBarHeight - 100}rpx`}">
<view class="swiper-items2">
<view class="swiper-item2" :class="{item2Left:index%2 == 0}"
v-for="(item,index) in imagObj[cardListIndex]" :key="index" @click="toimg(item)">
@ -166,7 +166,7 @@
};
}
return {
height: `${this.viewportHeight}rpx`
height: `${this.viewportHeight - 100 - this.statusBarHeight}rpx`
};
},
swiperStyle2() {
@ -176,7 +176,7 @@
};
}
return {
height: `${this.viewportHeight}rpx`
height: `${this.viewportHeight - 100 - this.statusBarHeight}rpx`
};
},
swiperStyle3() {

View File

@ -542,7 +542,7 @@ export default {
//
fetchNoticeList() {
request.post('/sj/notice/list', { page: 1, limit: 6 }).then(res => {
request.post('/sj/notice/list', { page: 1, limit: 5 }).then(res => {
if(res.code == 200 && res.data && res.data.list.length > 0) {
this.noticeList = res.data.list;
}

View File

@ -1,40 +1,27 @@
<template>
<view class="brand-detail-page">
<custom-navbar
:title="info.name || '品牌详情'"
:leftImg="'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/60ae3383-6ff6-4f42-818b-d9b09a9bd0e0.png'"
:showUser="true"
backgroundColor="#ffffff"
titleColor="#333"
borderBottom="none"
:show-headle="true"
:headleSrc="isCollected ? iconCollectOn : iconCollectOff"
@onHeadleClick="toggleCollectStatus"
>
<custom-navbar :title="info.name || '品牌详情'"
:leftImg="'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/60ae3383-6ff6-4f42-818b-d9b09a9bd0e0.png'"
:showUser="true" backgroundColor="#ffffff" titleColor="#333" borderBottom="none" :show-headle="true"
:headleSrc="isCollected ? iconCollectOn : iconCollectOff" @onHeadleClick="toggleCollectStatus">
</custom-navbar>
<!-- 顶部导航栏扩展动态计算位置的拨号图标 -->
<view class="nav-phone-wrap" :style="{ top: phoneIconTop + 'px', right: phoneIconRight + 'px' }" @click="makeCall">
<image src="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/c164280f-1ab9-41b4-9d60-846368364e9c.png" class="nav-phone-icon"></image>
<image src="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/c164280f-1ab9-41b4-9d60-846368364e9c.png"
class="nav-phone-icon"></image>
</view>
<!-- <view class="mock-switch" @click="toggleMockData">
<!-- <view class="mock-switch" @click="toggleMockData">
<text>{{ useMockData ? '关闭模拟数据' : '开启模拟数据' }}</text>
</view> -->
<view class="banner-section" v-if="bannerList && bannerList.length || info.video">
<!-- 原生视频组件 (就地播放) -->
<video
v-if="info.video && isVideoPlaying"
id="myVideo"
class="banner-video"
:src="info.video"
autoplay
controls
object-fit="cover"
></video>
<video v-if="info.video && isVideoPlaying" id="myVideo" class="banner-video" :src="info.video" autoplay controls
object-fit="cover"></video>
<!-- 轮播图区域 (当视频播放时隐藏) -->
<swiper v-else class="banner-swiper" circular @change="onSwiperChange" :autoplay="!info.video">
@ -42,15 +29,12 @@
<image class="banner-img" :src="item" mode="aspectFill"></image>
</swiper-item>
</swiper>
<!-- 居中的视频播放大图标 (当视频播放时隐藏) -->
<image
v-if="info.video && !isVideoPlaying"
class="center-play-icon"
src="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/bb720bb0-4ada-49f6-9ce5-38abfd613d5d.png"
@click="playVideoInPlace"
></image>
<image v-if="info.video && !isVideoPlaying" class="center-play-icon"
src="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/bb720bb0-4ada-49f6-9ce5-38abfd613d5d.png"
@click="playVideoInPlace"></image>
<!-- 视频/图片 相册切换组件 (当视频播放时隐藏) -->
<view class="album" v-if="(info.video || bannerList.length > 0) && !isVideoPlaying">
<view class="album-left" @click="info.video ? playVideoInPlace() : goAlbum()">
@ -62,7 +46,7 @@
<image src="/static/images/icons/right7_13.png" class="album-right-img"></image>
</view>
</view>
<!-- 指示器 (当视频播放时隐藏) -->
<view class="indicator" v-if="!isVideoPlaying && bannerList.length > 0">
<text>{{ currentBannerIndex + 1 }} / {{ bannerList.length }}</text>
@ -72,7 +56,7 @@
<view class="intro-section" v-if="info.name">
<view class="section-title">品牌介绍</view>
<view class="intro-content" :class="{ 'is-expanded': isExpanded }">
<text v-html="info.detail || '暂无品牌介绍'" class="intro-text"></text>
<rich-text :nodes="formatDetailContent" class="intro-text"></rich-text>
</view>
<view class="expand-btn" @click="toggleExpand" v-if="info.detail && info.detail.length > 100">
<text class="expand-text">{{ isExpanded ? '收起查看' : '展开查看' }}</text>
@ -84,19 +68,14 @@
<view class="divider-bg"></view>
<view class="tab-section">
<view class="tab-header">
<view
class="tab-item"
v-for="(tab, index) in availableTabs"
:key="tab.key"
:class="{ active: activeTab === index }"
@click="switchTab(index)"
>
<view class="tab-item" v-for="(tab, index) in availableTabs" :key="tab.key"
:class="{ active: activeTab === index }" @click="switchTab(index)">
<!-- 加上 class="tab-text" 以便控制层级 -->
<text class="tab-text">{{ tab.name }}</text>
<view v-if="activeTab === index" class="active-line"></view>
</view>
</view>
<view class="tab-content" v-if="availableTabs[activeTab]">
<rich-text :nodes="availableTabs[activeTab].content"></rich-text>
</view>
@ -108,18 +87,19 @@
<view class="form-section">
<!-- 动态标题当选中学员招募时显示"立即咨询"否则显示"在线留言" -->
<view class="section-title">{{ activeTabKey === 'student' ? '立即咨询' : '在线留言' }}</view>
<view class="form-list">
<view class="form-item">
<view class="label"><text class="required">*</text>姓名</view>
<input class="input-el" v-model="formData.contact_name" placeholder="请输入您的姓名" placeholder-class="ph-style" />
</view>
<view class="form-item">
<view class="label"><text class="required">*</text>手机号码</view>
<input class="input-el" type="number" maxlength="11" v-model="formData.contact_phone" placeholder="请输入您的手机号码" placeholder-class="ph-style" />
<input class="input-el" type="number" maxlength="11" v-model="formData.contact_phone" placeholder="请输入您的手机号码"
placeholder-class="ph-style" />
</view>
<view class="form-item">
<view class="label"><text class="required">*</text>所在城市</view>
<!-- 替换为复用的弹窗选择器 -->
@ -130,7 +110,7 @@
</view>
</view>
</view>
<view class="form-item">
<view class="label"><text class="required">*</text>意向</view>
<picker class="picker-el" :range="intentionOptions" range-key="label" @change="onIntentionChange">
@ -140,10 +120,11 @@
</view>
</picker>
</view>
<view class="form-item border-none" v-if="formData.intention === 1">
<view class="label"><text class="required">*</text>其他意向</view>
<input class="input-el" v-model="formData.intention_other" placeholder="请填写您的其他意向" placeholder-class="ph-style" />
<input class="input-el" v-model="formData.intention_other" placeholder="请填写您的其他意向"
placeholder-class="ph-style" />
</view>
</view>
@ -159,18 +140,16 @@
<text class="popup-close" @click="hideLocationPopup">×</text>
</view>
<view class="region-body">
<picker-view @change="bindChangeLocation"
class="picker-scroll"
:indicator-style="indicatorStyle"
<picker-view @change="bindChangeLocation" class="picker-scroll" :indicator-style="indicatorStyle"
:value="locationValue">
<picker-view-column>
<view class="picker-item" v-for="(item,index) in ChinaCitys" :key="index">{{item.province}}</view>
<view class="picker-item" v-for="(item, index) in ChinaCitys" :key="index">{{ item.province }}</view>
</picker-view-column>
<picker-view-column>
<view class="picker-item" v-for="(item,index) in locatinCitys" :key="index">{{item.city}}</view>
<view class="picker-item" v-for="(item, index) in locatinCitys" :key="index">{{ item.city }}</view>
</picker-view-column>
<picker-view-column>
<view class="picker-item" v-for="(item,index) in locationAreas" :key="index">{{item.area}}</view>
<view class="picker-item" v-for="(item, index) in locationAreas" :key="index">{{ item.area }}</view>
</picker-view-column>
</picker-view>
</view>
@ -196,7 +175,7 @@
import request from "@/utils/request";
import CustomNavbar from "@/components/custom-navbar/custom-navbar.vue";
import tipsPopup2 from "@/components/tips-popup/tips-popup2";
import ChinaCitys from "@/static/data/ChinaCitys.json";
import ChinaCitys from "@/static/data/ChinaCitys.json";
export default {
components: {
@ -206,11 +185,11 @@ export default {
data() {
return {
//
useMockData: false,
brandId: null,
info: {},
bannerList: [],
useMockData: false,
brandId: null,
info: {},
bannerList: [],
// ====== ======
isLogin: false, //
@ -220,19 +199,19 @@ export default {
isCollected: false, //
//
iconCollectOff: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/561715a5-3de0-49f3-80e4-2662febec500.png',
iconCollectOff: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/561715a5-3de0-49f3-80e4-2662febec500.png',
//
iconCollectOn: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/fe2011b0-a34d-46ee-911a-0ea6f099ad77.png',
// ==================================
isVideoPlaying: false, //
phoneIconTop: 20, // Top
phoneIconRight: 50, // Right
currentBannerIndex: 0,
isExpanded: false,
activeTab: 0,
//
showLocationPopupFlag: false,
indicatorStyle: 'height: 68rpx;',
@ -243,18 +222,20 @@ export default {
formData: {
id: null,
intention: '',
intention_other: '',
contact_name: '',
contact_phone: '',
province_code: '',
city_code: '',
area_code: ''
intention: '',
intention_other: '',
contact_name: '',
contact_phone: '',
province_code: '',
city_code: '',
area_code: ''
},
cityNameText: '',
intentionText: '',
cityNameText: '',
intentionText: '',
hasSubmitted: false,
submittedData: null,
intentionOptions: [
{ value: 2, label: '品牌加盟' },
{ value: 3, label: '购买产品' },
@ -268,18 +249,30 @@ export default {
activeTabKey() {
return this.availableTabs[this.activeTab]?.key || '';
},
formatDetailContent() {
const html = this.info.detail;
if (!html) return '<div style="color:#999;font-size:13px;text-align:center;">暂无品牌介绍</div>';
let newHtml = html.replace(/<img[^>]*>/gi, function (match) {
match = match.replace(/style\s*=\s*["'][^"']*["']/gi, '');
return match.replace(/<img/gi, '<img style="max-width:100%; height:auto; display:block; border-radius:20rpx; margin:8px 0;"');
});
newHtml = newHtml.replace(/<p[^>]*>/gi, '<p style="margin-bottom: 0px; line-height: 1.6; word-break: break-all;">');
return newHtml;
},
availableTabs() {
const tabs = [];
//
const formatRichText = (html) => {
if (!html) return '<div style="color:#999;font-size:13px;text-align:center;">暂无详细说明</div>';
let newHtml = html.replace(/<img[^>]*>/gi, function(match) {
match = match.replace(/style\s*=\s*["'][^"']*["']/gi, '');
let newHtml = html.replace(/<img[^>]*>/gi, function (match) {
match = match.replace(/style\s*=\s*["'][^"']*["']/gi, '');
return match.replace(/<img/gi, '<img style="max-width:100%; height:auto; display:block; border-radius:20rpx; margin:8px 0;"');
});
newHtml = newHtml.replace(/<p[^>]*>/gi, '<p style="margin-bottom: 0px; line-height: 1.6; word-break: break-all;">');
return newHtml;
};
@ -358,8 +351,8 @@ export default {
// 2.
if (!this.brandId) return;
const targetState = this.isCollected ? 2 : 1;
const targetState = this.isCollected ? 2 : 1;
// 3. (Mock)
if (this.useMockData) {
this.isCollected = !this.isCollected;
@ -375,9 +368,9 @@ export default {
}).then((res) => {
if (res.code == 200) {
this.isCollected = !this.isCollected;
uni.showToast({
title: this.isCollected ? '收藏成功' : '已取消收藏',
icon: 'none'
uni.showToast({
title: this.isCollected ? '收藏成功' : '已取消收藏',
icon: 'none'
});
} else {
uni.showToast({ title: res.msg || '操作失败', icon: 'none' });
@ -410,36 +403,36 @@ export default {
let index1 = valueArr[0] || 0;
let index2 = valueArr[1] || 0;
let index3 = valueArr[2] || 0;
let province = this.ChinaCitys[index1].province;
let city = this.locatinCitys[index2].city;
let area = this.locationAreas[index3].area;
//
this.cityNameText = `${province} / ${city} / ${area}`;
this.formData.province_code = province;
this.formData.city_code = city;
this.formData.area_code = area;
this.showLocationPopupFlag = false;
},
initNavLayout() {
let sysInfo = uni.getSystemInfoSync();
// NavBar 44px 40px Y +2px
let top = (sysInfo.statusBarHeight || 0) + 2;
let top = (sysInfo.statusBarHeight || 0) + 2;
//
let right = 50;
let right = 50;
// #ifdef MP-WEIXIN
let menuBtn = uni.getMenuButtonBoundingClientRect();
if (menuBtn) {
top = menuBtn.top + (menuBtn.height / 2) - 20;
top = menuBtn.top + (menuBtn.height / 2) - 20;
// ( 45px )
right = sysInfo.windowWidth - menuBtn.left + 45;
right = sysInfo.windowWidth - menuBtn.left + 45;
}
// #endif
this.phoneIconTop = top;
this.phoneIconRight = right;
},
@ -447,7 +440,7 @@ export default {
//
makeCall() {
//
const phone = this.info.contact_phone || '';
const phone = this.info.contact_phone || '';
if (phone) {
uni.makePhoneCall({
phoneNumber: String(phone),
@ -486,8 +479,8 @@ export default {
}
uni.showLoading({ title: '加载中...' });
request.post("/sj/brand/details", {
id: this.brandId
request.post("/sj/brand/details", {
id: this.brandId
}).then((res) => {
if (res.code == 200 && res.data) {
this.info = res.data;
@ -507,8 +500,8 @@ export default {
injectMockData() {
this.info = {
name: '蜜丝卡伦美甲美睫',
contact_phone: '400-888-8888',
video: 'https://vjs.zencdn.net/v/oceans.mp4',
contact_phone: '400-888-8888',
video: 'https://vjs.zencdn.net/v/oceans.mp4',
banner_imgs: [
'https://images.unsplash.com/photo-1610992015732-2449b76344bc?ixlib=rb-4.0.3&auto=format&fit=crop&w=750&q=80',
'https://images.unsplash.com/photo-1522337660859-02fbefca4702?ixlib=rb-4.0.3&auto=format&fit=crop&w=750&q=80'
@ -554,7 +547,7 @@ export default {
switchTab(index) {
this.activeTab = index;
},
onIntentionChange(e) {
const selectItem = this.intentionOptions[e.detail.value];
this.intentionText = selectItem.label;
@ -566,15 +559,37 @@ export default {
uni.showToast({ title: '请填写完整必填信息', icon: 'none' });
return;
}
if (!/^1[3-9]\d{9}$/.test(this.formData.contact_phone)) {
uni.showToast({ title: '请输入合法的手机号码', icon: 'none' });
return;
}
//
if (this.hasSubmitted && this.submittedData) {
const currentData = JSON.stringify({
contact_name: this.formData.contact_name,
contact_phone: this.formData.contact_phone,
province_code: this.formData.province_code,
city_code: this.formData.city_code,
area_code: this.formData.area_code,
intention: this.formData.intention,
intention_other: this.formData.intention_other
});
if (currentData === this.submittedData) {
uni.showModal({
title: '提示',
content: '未修改内容,不能再次提交',
showCancel: false,
confirmText: '知道了'
});
return;
}
}
if (this.useMockData) {
uni.showToast({ title: '模拟环境下留言提交成功!', icon: 'success' });
this.resetForm();
this.saveSubmittedData();
return;
}
@ -582,7 +597,7 @@ export default {
request.post("/sj/brand/consult", this.formData).then((res) => {
if (res.code == 200) {
uni.showToast({ title: '留言提交成功!', icon: 'success', duration: 2000 });
this.resetForm();
this.saveSubmittedData();
} else {
uni.showToast({ title: res.msg || '提交失败', icon: 'none' });
}
@ -592,7 +607,20 @@ export default {
uni.hideLoading();
});
},
saveSubmittedData() {
this.hasSubmitted = true;
this.submittedData = JSON.stringify({
contact_name: this.formData.contact_name,
contact_phone: this.formData.contact_phone,
province_code: this.formData.province_code,
city_code: this.formData.city_code,
area_code: this.formData.area_code,
intention: this.formData.intention,
intention_other: this.formData.intention_other
});
},
resetForm() {
this.formData = {
id: this.brandId,
@ -630,11 +658,11 @@ export default {
align-items: center;
justify-content: center;
transition: opacity 0.2s;
&:active {
opacity: 0.7;
}
.nav-phone-icon {
width: 44rpx;
height: 44rpx;
@ -661,23 +689,23 @@ export default {
width: 100%;
height: 421rpx;
background-color: #f5f5f5;
.banner-video {
width: 100%;
height: 100%;
display: block;
}
.banner-swiper {
width: 100%;
height: 100%;
}
.banner-img {
width: 100%;
height: 100%;
}
.center-play-icon {
position: absolute;
top: 50%;
@ -687,12 +715,12 @@ export default {
height: 120rpx;
z-index: 20;
transition: opacity 0.3s;
&:active {
opacity: 0.8;
}
}
.album {
position: absolute;
bottom: 10rpx;
@ -704,7 +732,7 @@ export default {
display: flex;
align-items: center;
z-index: 10;
.album-left {
width: 73rpx;
height: 44rpx;
@ -744,7 +772,7 @@ export default {
}
}
}
.indicator {
position: absolute;
right: 20rpx;
@ -764,7 +792,7 @@ export default {
/* 2. 品牌介绍 */
.intro-section {
padding: 40rpx 30rpx;
.section-title {
font-weight: 500;
font-size: 30rpx;
@ -772,7 +800,7 @@ export default {
line-height: 42rpx;
margin-bottom: 24rpx;
}
.intro-content {
font-weight: 400;
font-size: 26rpx;
@ -782,13 +810,13 @@ export default {
-webkit-box-orient: vertical;
-webkit-line-clamp: 19;
overflow: hidden;
white-space: pre-line;
white-space: pre-line;
&.is-expanded {
-webkit-line-clamp: 9999;
}
}
.expand-btn {
display: flex;
justify-content: center;
@ -800,7 +828,7 @@ export default {
width: fit-content;
margin-left: auto;
margin-right: auto;
.expand-text {
font-weight: 400;
font-size: 24rpx;
@ -808,7 +836,7 @@ export default {
line-height: 33rpx;
margin-right: 8rpx;
}
.arrow {
margin-bottom: -2rpx;
width: 10rpx;
@ -817,7 +845,7 @@ export default {
border-bottom: 2rpx solid #999999;
transform: rotate(45deg) translateY(-2rpx);
transition: transform 0.2s ease;
&.up {
transform: rotate(-135deg) translateY(2rpx);
}
@ -834,7 +862,7 @@ export default {
/* 3. 招募详情 Tab */
.tab-section {
padding: 0 30rpx 40rpx;
.tab-header {
display: flex;
justify-content: center;
@ -842,7 +870,7 @@ export default {
padding: 30rpx 0 0 0;
gap: 120rpx;
margin-bottom: 10rpx;
.tab-item {
font-weight: 400;
font-size: 28rpx;
@ -851,7 +879,7 @@ export default {
position: relative;
padding-bottom: 16rpx;
transition: all 0.2s;
&.active {
font-weight: 500;
font-size: 30rpx;
@ -862,7 +890,7 @@ export default {
position: relative;
z-index: 2;
}
.active-line {
position: absolute;
bottom: 20rpx;
@ -877,13 +905,13 @@ export default {
}
}
}
.tab-content {
font-weight: 400;
font-size: 26rpx;
color: #333333;
line-height: 37rpx;
::v-deep img {
max-width: 100% !important;
height: auto !important;
@ -891,8 +919,9 @@ export default {
border-radius: 12rpx;
margin: 20rpx 0;
}
::v-deep p, ::v-deep div {
::v-deep p,
::v-deep div {
margin-bottom: 24rpx;
line-height: 1.6;
}
@ -902,7 +931,7 @@ export default {
/* 4. 在线留言表单 */
.form-section {
padding: 40rpx 30rpx;
.section-title {
font-weight: 500;
font-size: 30rpx;
@ -910,51 +939,52 @@ export default {
line-height: 42rpx;
margin-bottom: 20rpx;
}
.form-list {
.form-item {
display: flex;
align-items: center;
min-height: 104rpx;
border-bottom: 1rpx solid #F5F5F5;
&.border-none {
border-bottom: none;
}
.label {
width: 190rpx;
font-size: 28rpx;
color: #333333;
line-height: 40rpx;
.required {
color: #E5505F;
margin-right: 3rpx;
}
}
.input-el, .picker-el {
.input-el,
.picker-el {
flex: 1;
font-size: 28rpx;
color: #333333;
}
.ph-style {
color: #C4C4C4;
}
.picker-value {
color: #CCCCCC;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
&.has-val {
color: #333333;
}
.arrow-right {
width: 12rpx;
height: 12rpx;
@ -965,7 +995,7 @@ export default {
}
}
}
.submit-btn {
margin-top: 60rpx;
width: 100%;
@ -978,13 +1008,13 @@ export default {
text-align: center;
border: none;
transition: all 0.2s ease;
&::after {
border: none;
}
&.is-active {
background-color: #FF4767;
background-color: #FF4767;
color: #FFFFFF;
box-shadow: 0 8rpx 16rpx rgba(229, 80, 95, 0.15);
}
@ -997,7 +1027,8 @@ export default {
left: 0;
right: 0;
bottom: 0;
z-index: 9999; /* 层级调高,防止被挡住 */
z-index: 9999;
/* 层级调高,防止被挡住 */
visibility: hidden;
opacity: 0;
transition: all 0.3s ease;