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'); ...@@ -18,4 +18,4 @@ export const historyClear = () => api.get('/c/mini/historyClear');
/** /**
* 搜索 * 搜索
*/ */
export const search = (data) => api.post('/c/mini/search',data); export const search = (data) => api.get('/c/mini/search',data);
\ No newline at end of file \ 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 @@ ...@@ -11,13 +11,16 @@
</template> </template>
<script> <script>
import { productsObj } from '../../mock/products';
export default { export default {
data() { data() {
return { return {
productId: '', productId: '',
imgLength:0, imgLength:0,
imgList:[], imgList:[],
productId:'',
skuId:'',
contentImg:'',
contentImgLen:'',
shareTitle:'', shareTitle:'',
shareImg:'' shareImg:''
} }
...@@ -27,24 +30,30 @@ export default { ...@@ -27,24 +30,30 @@ export default {
// options 就是跳转时传递的参数对象 // options 就是跳转时传递的参数对象
console.log('页面参数:', options); console.log('页面参数:', options);
this.productId = options.id; const {productId,skuId,contentImg,contentImgLen,shareTitle,shareImg} = options;
const { productList } = productsObj; this.productId = productId;
const product = productList.find(item => item.id === this.productId); this.skuId = skuId;
this.imgLength = product.imgLength; this.contentImg = contentImg;
this.shareTitle = product.shareTitle; this.contentImgLen = contentImgLen;
this.shareImg = product.shareImg; this.shareTitle = shareTitle;
this.imgList = Array.from({ length: this.imgLength }, (_, index) => { this.shareImg = this.$baseUrl + shareImg;
console.log("this.shareImg:",this.shareImg);
this.imgList = Array.from({ length: this.contentImgLen }, (_, index) => {
return { 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: { methods: {
buyHandler() { buyHandler() {
const _path = `/subPackages/shopMainProcess/product/index?productId=${this.productId}&skuId=${this.skuId}&entrySource=xmh_wechatmp_brand_profamily`
uni.navigateToMiniProgram({ uni.navigateToMiniProgram({
appId: 'wx1234567890abcdef', appId: 'wx4205ec55b793245e',
path: 'pages/index/index', path: _path,
envVersion: 'release',
success(res) { success(res) {
console.log('跳转成功', res) console.log('跳转成功', res)
}, },
...@@ -53,9 +62,7 @@ export default { ...@@ -53,9 +62,7 @@ export default {
} }
}) })
}, },
shareHandler() {
}
}, },
onShareAppMessage() { onShareAppMessage() {
return { return {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<view class="flexinput"> <view class="flexinput">
<image class="icon_search_yellow" :src="$baseUrl+'searchpage/icon_search_yellow.png'"> <image class="icon_search_yellow" :src="$baseUrl+'searchpage/icon_search_yellow.png'">
</image> </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" /> @confirm="confirm" />
</view> </view>
</view> </view>
...@@ -31,17 +31,26 @@ ...@@ -31,17 +31,26 @@
<van-tabs :color="`#d3a358`" line-width="15px" :active="tabIndex" @click="onTabChange"> <van-tabs :color="`#d3a358`" line-width="15px" :active="tabIndex" @click="onTabChange">
<van-tab title="内容" name="content"></van-tab> <van-tab title="内容" name="content"></van-tab>
<van-tab title="工具" name="tool"></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> </van-tabs>
</view> </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||"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"> <view class="card" v-for="(item,index) in resultList[tabIndex]" :key="index">
<image class="pic" :src="$baseUrl+item.bgUrl"></image> <image class="pic" :src="$baseUrl+item.bgUrl"></image>
<view class="desc"> <view class="desc">
{{item.desc}} {{item.desc}}
</view> </view>
<view class="timestr">{{item.timeStr}}</view> <view class="timestr">{{item.timeStr||"2025-06-10"}}</view>
</view> </view>
</view> </view>
...@@ -54,136 +63,136 @@ ...@@ -54,136 +63,136 @@
<script> <script>
import { historySearch,historyClear,search } from '../../api/search'; import { historySearch,historyClear,search } from '../../api/search';
const recentTagsList=[ // const recentTagsList=[
"功能营养","母婴","功能营养","母婴","功能营养","母婴","功能营养","母婴","功能营养","母婴" // "功能营养","母婴","功能营养","母婴","功能营养","母婴","功能营养","母婴","功能营养","母婴"
] // ]
const oftenTagsList=["婴幼儿奶粉","权益","奶酪棒","星飞帆经典"] const oftenTagsList=["婴幼儿奶粉","权益","奶酪棒","星飞帆经典"]
const resultList = { // const resultList = {
"content":[ // "content":[
{ // {
bgUrl:"searchpage/test.png", // bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条", // desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test.png", // bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条", // desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test.png", // bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条", // desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test.png", // bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条", // desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test.png", // bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条", // desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test.png", // bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条", // desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test.png", // bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条", // desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test.png", // bgUrl:"searchpage/test.png",
desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条", // desc:"宝宝出生必做6件事,90 %爸妈漏掉第3条",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
} // }
], // ],
"tool":[ // "tool":[
{ // {
bgUrl:"searchpage/test2.png", // bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”", // desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test2.png", // bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”", // desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test2.png", // bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”", // desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test2.png", // bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”", // desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test2.png", // bgUrl:"searchpage/test2.png",
desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”", // desc:"秋风渐凉,宝宝的免疫力 也进入 “换季挑战期”",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
], // ],
"product":[ // "product":[
{ // {
bgUrl:"searchpage/test3.png", // bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~", // desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test3.png", // bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~", // desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test3.png", // bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~", // desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test3.png", // bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~", // desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
{ // {
bgUrl:"searchpage/test3.png", // bgUrl:"searchpage/test3.png",
desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~", // desc:"3 个 0 成本游戏,让宝宝 越玩越聪明~",
timeStr:"2025-03-10", // timeStr:"2025-03-10",
link:"www.baidu.com" // link:"www.baidu.com"
}, // },
] // ]
} // }
export default { export default {
data() { data() {
return { return {
statusBarHeight: 38, statusBarHeight: 38,
recentTagsList:recentTagsList, recentTagsList:[],
oftenTagsList:oftenTagsList, oftenTagsList:oftenTagsList,
step:1, step:1,
resultList:resultList, resultList:{'tool':[],'content':[],'product':[]},
tabIndex:'content', tabIndex:'content',
searchValue:'' searchValue:''
} }
...@@ -211,12 +220,8 @@ ...@@ -211,12 +220,8 @@
}, },
onTabChange(evt) onTabChange(evt)
{ {
console.log(evt);
this.tabIndex = evt.detail.name; 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){ confirm(evt){
this.searchHandler(evt.detail.value); this.searchHandler(evt.detail.value);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
:indicator-color="indicatorColor" :indicator-active-color="indicatoractiveColor"> :indicator-color="indicatorColor" :indicator-active-color="indicatoractiveColor">
<swiper-item v-for="item in swiperList" :key="item.url"> <swiper-item v-for="item in swiperList" :key="item.url">
<view class="swiper-item banneritem"> <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"> :src="$baseUrl + item.url">
</image> </image>
</view> </view>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</view> </view>
<view v-if="productInfoList.length > 0" class="productbox"> <view v-if="productInfoList.length > 0" class="productbox">
<view class="infobox" :key="index" v-for="(infoItem, index) in productInfoList[channelTabIndex]" <view class="infobox" :key="index" v-for="(infoItem, index) in productInfoList[channelTabIndex]"
@tap="jumpLink(infoItem.link)"> @tap="jumpProduct(infoItem)">
<view class="flexbox"> <view class="flexbox">
<view class="infotitle"> <view class="infotitle">
{{ infoItem.title }} {{ infoItem.title }}
...@@ -132,6 +132,7 @@ ...@@ -132,6 +132,7 @@
import { brandObj } from '../mock/brand'; import { brandObj } from '../mock/brand';
import { fetchBrandJSON } from '../api/brand'; import { fetchBrandJSON } from '../api/brand';
import { jump, JumpType } from '../utils';
export default { export default {
data() { data() {
return { return {
...@@ -189,10 +190,26 @@ export default { ...@@ -189,10 +190,26 @@ export default {
this.swiperIndex = _index; this.swiperIndex = _index;
}, },
jumpLink(_link) { jumpLink(_link,videoUrl) {
// console.log(_link) // 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({ 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) { 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