liudan 11 months ago
parent a2fcaec559
commit 4180ec42d8
  1. 15
      api/home/index.js
  2. 90
      pages/search/index.vue

@ -6,7 +6,9 @@ const api = {
chartsGoodsJing:'goods/chartsGoodsJing',
brandList:'goods/brandList',
typeList:'category/list',
cityInfo:'goods/cityInfo'
cityInfo:'goods/cityInfo',
search:'goods/hotWord',
chartsGoodsJing:'goods/chartsGoodsJing'
}
// 商品列表
@ -31,4 +33,13 @@ export const brandList = (param, option) => {
// 首页分类
export const typeList = (param, option) => {
return request.get(api.typeList, param, option)
}
}
//搜索发现
export const searchFind = (param, option) => {
return request.get(api.search, param, option)
}
//搜索发现内容
export const chartsGoodsJingApi = (param, option) => {
return request.get(api.chartsGoodsJing, param, option)
}

@ -15,24 +15,24 @@
<image src="/static/search/closeEye.png" mode="widthFix" class="findIcon" v-if="!showEye" @click="showEye=!showEye">
</image>
</view>
<view class="others">
<view class="others" @click="getHot">
换一批
</view>
</view>
<view class="hotSearch" v-if="showEye">
<view v-for="(item,index) in searchFindList" :key="index" class="hotItem" @click="searchGoods(item)">
<image src="/static/user/hot.png" mode="" class="hotImg" v-if="index==0"></image>
<text>{{item}}</text>
<text>{{item.word}}</text>
</view>
</view>
<view class="hotSuggest">
<scroll-view class="hotList" scroll-x="true" @scroll="scroll">
<view class="hotItem" v-for="(item,index) in 2" :key="index">
<view class="hotItem" v-for="(item,index) in goodsList" :key="index">
<view class="itemHeade">
<image src="/static/search/hotImg.png" mode="widthFix"></image>
<view class="headTitle">热门数码产品汇总</view>
<view class="headTitle">{{item.name}}</view>
</view>
<view class="itemMain" v-for="(s,k) in 5" :key="k">
<view class="itemMain" v-for="(s,k) in item.goods_list.slice(0,5)" :key="k">
<view class="num1 numCommon" v-if="k==0">
<text>{{k+1}}</text>
</view>
@ -46,14 +46,15 @@
<text>{{k+1}}</text>
</view>
<view class="picContent" v-if="k<3">
<image :src="$picUrl+'/static/index/goods.png'" mode="aspectFit" class="goodsImg"></image>
<!-- <image :src="$picUrl+'/static/index/goods.png'" mode="aspectFit" class="goodsImg"></image> -->
<image :src="s.goods_image" mode="aspectFit" class="goodsImg"></image>
</view>
<view class="goodsInfo">
<view class="goodName">
荣耀PlAY 7T
{{s.goods_name}}
</view>
<view class="goodsSale" v-if="k<3">
今日开售
{{s.selling_point}}
</view>
</view>
</view>
@ -64,6 +65,7 @@
</template>
<script>
import * as GoodsApi from '@/api/home/index.js';
export default {
data() {
return {
@ -71,26 +73,50 @@
searchValue: 'iPhone15',
searchData: [],
searchList: [],
searchFindList:['1999元抢IPad','iPhone15pro','小米手机','小米手机','智能手表好价']
searchFindList:[],
page:1,
goodsList:[],
}
},
onShow() {
if(uni.getStorageSync('searchList')){
this.searchList = uni.getStorageSync('searchList')
this.searchList = Array.from(new Set(this.searchList));
}
// if(uni.getStorageSync('searchList')){
// this.searchList = uni.getStorageSync('searchList')
// this.searchList = Array.from(new Set(this.searchList));
// }
},
onLoad() {
this.getHot()
this.chartsGoodsJingHandle()
},
methods: {
changePage(){
GoodsApi.searchFind({page:this.page}).then(res => {
if(res.data.length==0){
this.page=1;
}else{
this.page++
}
this.getHot()
})
},
getHot(){
GoodsApi.searchFind({page:this.page}).then(res => {
if(res.data.length==0){
this.page=1;
}else{
this.page++;
this.searchFindList = res.data;
}
})
},
searchGoods(item){
this.searchList.push(this.searchValue)
this.searchList = Array.from(new Set(this.searchList));
uni.setStorageSync('searchList', this.searchList)
// this.searchList.push(this.searchValue)
// this.searchList = Array.from(new Set(this.searchList));
// uni.setStorageSync('searchList', this.searchList)
uni.navigateTo({
url: '/pages/goods/list?search=' + item
})
@ -101,6 +127,15 @@
url: '/pages/goods/list?search=' + this.searchValue
})
},
chartsGoodsJingHandle(){
GoodsApi.chartsGoodsJingApi().then(res => {
console.log(res,"8899")
this.goodsList = res.data;
})
}
}
}
</script>
@ -202,6 +237,7 @@
flex-wrap: wrap;
margin:0 40rpx;
margin-top: 20rpx;
justify-content: space-between;
.hotItem {
padding:10rpx 30rpx;
@ -210,6 +246,8 @@
opacity: 1;
display: flex;
align-items: center;
margin-left:12rpx;
// margin:0 20rpx;
margin-bottom: 24rpx;
// height: 64rpx;
// background: #FFFFFF;
@ -294,6 +332,7 @@
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
text{
position: relative;
left:-1rpx;
@ -321,6 +360,7 @@
border-radius: 8rpx 8rpx 8rpx 8rpx;
overflow: hidden;
margin-left: 10rpx;
flex-shrink: 0;
.goodsImg {
width: 100%;
height:100%;
@ -333,27 +373,33 @@
.goodsInfo {
margin-left: 18rpx;
width: calc(100% - 160rpx);
.goodName {
width: 138rpx;
height: 34rpx;
// width: 138rpx;
// height: 34rpx;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #000000;
line-height: 34rpx;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.goodsSale {
width: 96rpx;
height: 34rpx;
// width: 96rpx;
// height: 34rpx;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #9B9B9B;
line-height: 34rpx;
margin-top: 6rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}

Loading…
Cancel
Save