Commit 597e6aba authored by 张九刚's avatar 张九刚

feat: 更新搜索功能(新ui暂未修改),调整品牌和首页数据结构,优化API请求,删除无用的产品数据

parent e39fed7c
No preview for this file type
......@@ -18,4 +18,4 @@ export const historyClear = () => api.get('/c/mini/historyClear');
/**
* 搜索
*/
export const search = (data) => api.post('/c/mini/search',data);
\ No newline at end of file
export const search = (data) => api.get('/c/mini/search',data);
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
export const productsObj = {
productList: [
{
id: '1-1',
imgLength:20,
shareTitle: '产品1',
shareImg: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
},
{
id: '1-2',
imgLength:10,
shareTitle: '产品2',
shareImg: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
},
{
id: '2-1',
imgLength:15,
shareTitle: '产品1',
shareImg: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
}
]
}
\ No newline at end of file
......@@ -11,13 +11,16 @@
</template>
<script>
import { productsObj } from '../../mock/products';
export default {
data() {
return {
productId: '',
imgLength:0,
imgList:[],
productId:'',
skuId:'',
contentImg:'',
contentImgLen:'',
shareTitle:'',
shareImg:''
}
......@@ -27,24 +30,30 @@ export default {
// options 就是跳转时传递的参数对象
console.log('页面参数:', options);
this.productId = options.id;
const { productList } = productsObj;
const product = productList.find(item => item.id === this.productId);
this.imgLength = product.imgLength;
this.shareTitle = product.shareTitle;
this.shareImg = product.shareImg;
this.imgList = Array.from({ length: this.imgLength }, (_, index) => {
const {productId,skuId,contentImg,contentImgLen,shareTitle,shareImg} = options;
this.productId = productId;
this.skuId = skuId;
this.contentImg = contentImg;
this.contentImgLen = contentImgLen;
this.shareTitle = shareTitle;
this.shareImg = this.$baseUrl + shareImg;
console.log("this.shareImg:",this.shareImg);
this.imgList = Array.from({ length: this.contentImgLen }, (_, index) => {
return {
imgUrl: this.$baseUrl + 'brandpage/products/' + this.productId.split('-')[0] + '/' + this.productId+'/product_'+this.productId.replace('-','_')+'_'+index + '.jpg'
imgUrl: this.$baseUrl + 'brandpage/products/' + contentImg.split('-')[0] + '/'
+ contentImg+'/product_'+contentImg.replace('-','_')+'_'+index + '.jpg'
}
});
console.log(this.imgList);
},
methods: {
buyHandler() {
const _path = `/subPackages/shopMainProcess/product/index?productId=${this.productId}&skuId=${this.skuId}&entrySource=xmh_wechatmp_brand_profamily`
uni.navigateToMiniProgram({
appId: 'wx1234567890abcdef',
path: 'pages/index/index',
envVersion: 'release',
appId: 'wx4205ec55b793245e',
path: _path,
success(res) {
console.log('跳转成功', res)
},
......@@ -53,9 +62,7 @@ export default {
}
})
},
shareHandler() {
}
},
onShareAppMessage() {
return {
......
......@@ -6,7 +6,7 @@
<view class="flexinput">
<image class="icon_search_yellow" :src="$baseUrl+'searchpage/icon_search_yellow.png'">
</image>
<input confirm-type="search" maxlength="50" class="nav-bar-input" type="text" placeholder="输入搜索关键词"
<input confirm-type="search" maxlength="50" :value="searchValue" class="nav-bar-input" type="text" placeholder="输入搜索关键词"
@confirm="confirm" />
</view>
</view>
......@@ -31,17 +31,26 @@
<van-tabs :color="`#d3a358`" line-width="15px" :active="tabIndex" @click="onTabChange">
<van-tab title="内容" name="content"></van-tab>
<van-tab title="工具" name="tool"></van-tab>
<van-tab title="商品" name="product"></van-tab>
<!-- <van-tab title="商品" name="product"></van-tab> -->
</van-tabs>
</view>
<view v-if="step !== 1" class="cardbox">
<view v-if="step !== 1 && tabIndex==='content'" class="cardbox">
<view class="card" v-for="(item,index) in resultList[tabIndex]" :key="index">
<image class="pic" :src="$baseUrl+item.bgUrl"></image>
<view class="desc">
{{item.desc}}
</view>
<view class="timestr">{{item.timeStr}}</view>
<view class="timestr">{{item.timeStr||"2025-06-10"}}</view>
</view>
</view>
<view v-if="step !== 1 && tabIndex==='tool'" class="cardbox">
<view class="card" v-for="(item,index) in resultList[tabIndex]" :key="index">
<image class="pic" :src="$baseUrl+item.bgUrl"></image>
<view class="desc">
{{item.desc}}
</view>
<view class="timestr">{{item.timeStr||"2025-06-10"}}</view>
</view>
</view>
......@@ -54,136 +63,136 @@
<script>
import { historySearch,historyClear,search } from '../../api/search';
const recentTagsList=[
"功能营养","母婴","功能营养","母婴","功能营养","母婴","功能营养","母婴","功能营养","母婴"
]
// const recentTagsList=[
// "功能营养","母婴","功能营养","母婴","功能营养","母婴","功能营养","母婴","功能营养","母婴"
// ]
const oftenTagsList=["婴幼儿奶粉","权益","奶酪棒","星飞帆经典"]
const resultList = {
"content":[
{
bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10",
link:"www.baidu.com"
}
],
"tool":[
{
bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
],
"product":[
{
bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
{
bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10",
link:"www.baidu.com"
},
]
}
// const resultList = {
// "content":[
// {
// bgUrl:"searchpage/test.png",
// desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test.png",
// desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test.png",
// desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test.png",
// desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test.png",
// desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test.png",
// desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test.png",
// desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test.png",
// desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// }
// ],
// "tool":[
// {
// bgUrl:"searchpage/test2.png",
// desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test2.png",
// desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test2.png",
// desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test2.png",
// desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test2.png",
// desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// ],
// "product":[
// {
// bgUrl:"searchpage/test3.png",
// desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test3.png",
// desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test3.png",
// desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test3.png",
// desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// {
// bgUrl:"searchpage/test3.png",
// desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
// timeStr:"2025-03-10",
// link:"www.baidu.com"
// },
// ]
// }
export default {
data() {
return {
statusBarHeight: 38,
recentTagsList:recentTagsList,
recentTagsList:[],
oftenTagsList:oftenTagsList,
step:1,
resultList:resultList,
resultList:{'tool':[],'content':[],'product':[]},
tabIndex:'content',
searchValue:''
}
......@@ -211,12 +220,8 @@
},
onTabChange(evt)
{
console.log(evt);
this.tabIndex = evt.detail.name;
console.log(this.tabIndex);
console.log(this.resultList);
console.log(this.resultList[this.tabIndex]);
console.log(this.resultList['tool']);
},
confirm(evt){
this.searchHandler(evt.detail.value);
......
......@@ -6,7 +6,7 @@
:indicator-color="indicatorColor" :indicator-active-color="indicatoractiveColor">
<swiper-item v-for="item in swiperList" :key="item.url">
<view class="swiper-item banneritem">
<image :data-link="item.link" @tap="jumpLink(item.link)" class="b-img"
<image :data-link="item.link" @tap="jumpLink(item.link,item.videoUrl)" class="b-img"
:src="$baseUrl + item.url">
</image>
</view>
......@@ -34,7 +34,7 @@
</view>
<view v-if="productInfoList.length > 0" class="productbox">
<view class="infobox" :key="index" v-for="(infoItem, index) in productInfoList[channelTabIndex]"
@tap="jumpLink(infoItem.link)">
@tap="jumpProduct(infoItem)">
<view class="flexbox">
<view class="infotitle">
{{ infoItem.title }}
......@@ -132,6 +132,7 @@
import { brandObj } from '../mock/brand';
import { fetchBrandJSON } from '../api/brand';
import { jump, JumpType } from '../utils';
export default {
data() {
return {
......@@ -189,10 +190,26 @@ export default {
this.swiperIndex = _index;
},
jumpLink(_link) {
jumpLink(_link,videoUrl) {
// console.log(_link)
// uni.navigateTo({
// url: "/pages/product/product?id=1-1"
// })
if (videoUrl) {
// 弹出视频
this.currentVideoUrl = videoUrl;
this.showVideo = true;
return;
// 视频弹窗出现后,video标签的autoplay会自动播放
} else if (link) {
// 其他跳转逻辑
jump(link);
}
},
jumpProduct(item){
const {productId,skuId,contentImg,contentImgLen,shareTitle,shareImg} = item;
uni.navigateTo({
url: "/pages/product/product?id=1-1"
url: "/pages/product/product?productId="+productId+"&skuId="+skuId+"&contentImg="+contentImg+"&contentImgLen="+contentImgLen+"&shareTitle="+shareTitle+"&shareImg="+shareImg
})
},
channelTabHandler(_index) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment