You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong_qianduan/pages/search/index.vue

467 lines
10 KiB

11 months ago
<template>
<view class="container">
<view class="search">
9 months ago
<image :src="$picUrl+'/static/home/search.png'" mode="" class="searchIcon"></image>
<input v-model="searchValue" class="input" focus="true" placeholder="iPhone15" type="text" />
10 months ago
<view class="searchBtn" @click="getSearchInfo">
搜索
</view>
</view>
<view class="find">
<view class="findTitle">
8 months ago
<text>搜索历史</text>
<!-- <image src="/static/search/openEye.png" mode="widthFix" class="findIcon" v-if="showEye"
9 months ago
@click="showEye=!showEye">
</image>
9 months ago
<image src="/static/search/closeEye.png" mode="widthFix" class="findIcon" v-if="!showEye"
@click="showEye=!showEye">
8 months ago
</image> -->
<view class="others" v-if="searchList && searchList.length > 0">
<u-icon size="40" color="#999" name="trash" @click="toDo(0)" v-if="isHot"></u-icon>
<view class="do" v-else>
<view class="red" @click="toDo(1)">全部删除</view>
<view class="suc" @click="toDo(2)">完成</view>
</view>
</view>
</view>
8 months ago
</view>
10 months ago
<view class="hotSearch" v-if="showEye">
8 months ago
<view v-for="(item,index) in searchList" :key="index" class="hotItem">
<text @click="searchGoods(item)">{{item}}</text>
<view v-if="isHot == false" class="del" @click="toDo(3,index)"><u-icon size="30" color="#999" name="close-circle"></u-icon></view>
</view>
</view>
10 months ago
<view class="hotSuggest">
<scroll-view class="hotList" scroll-x="true" @scroll="scroll">
9 months ago
<view class="hotItem" v-for="(item,index) in goodsList" :key="index">
10 months ago
<view class="itemHeade">
9 months ago
<image src="/static/search/hotImg.png" mode="widthFix"></image>
9 months ago
<view class="headTitle">{{item.name}}</view>
10 months ago
</view>
9 months ago
<view class="itemMain" v-for="(s,k) in item.goods_list.slice(0,5)" :key="k"
@click="handleTargetGoods(s.goods_id)">
10 months ago
<view class="num1 numCommon" v-if="k==0">
9 months ago
<text>{{k+1}}</text>
10 months ago
</view>
<view class="num2 numCommon" v-if="k==1">
9 months ago
<text>{{k+1}}</text>
10 months ago
</view>
<view class="num3 numCommon" v-if="k==2">
9 months ago
<text>{{k+1}}</text>
</view>
<view class="num4 numCommon" v-if="k>2">
<text>{{k+1}}</text>
10 months ago
</view>
9 months ago
<view class="picContent" v-if="k<3">
9 months ago
<!-- <image :src="$picUrl+'/static/index/goods.png'" mode="aspectFit" class="goodsImg"></image> -->
9 months ago
<image :src="s.goods_image" mode="aspectFit" class="goodsImg"></image>
10 months ago
</view>
<view class="goodsInfo">
<view class="goodName">
9 months ago
{{s.goods_name}}
10 months ago
</view>
<view class="goodsSale" v-if="k<3">
9 months ago
{{s.selling_point}}
10 months ago
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
11 months ago
</template>
<script>
9 months ago
import * as GoodsApi from '@/api/home/index.js';
export default {
data() {
return {
showEye: true,
9 months ago
searchValue: '',
searchData: [],
9 months ago
searchList: [],
9 months ago
searchFindList: [],
page: 1,
goodsList: [],
8 months ago
category_id:0,
isHot: true,
}
},
onShow() {
9 months ago
if (uni.getStorageSync('searchList')) {
this.searchList = uni.getStorageSync('searchList')
this.searchList = Array.from(new Set(this.searchList));
this.searchList=this.searchList.length>0?this.searchList.slice(0,6):[]
}
9 months ago
},
onLoad(op) {
this.category_id=op.category_id
10 months ago
this.getHot()
9 months ago
this.chartsGoodsJingHandle()
},
8 months ago
methods: {
toDo(index,idx){
if(index == 0){
this.isHot = false
}else if(index == 1){
this.searchList = []
uni.removeStorageSync("searchList")
}else if(index == 2){
this.isHot = true
}else if(index == 3){
this.searchList.splice(idx,1)
}
},
9 months ago
// 跳转到秒杀商品详情
handleTargetGoods(sharpGoodsId) {
uni.navigateTo({
url: '/pages/goods/detail?goodsId=' + sharpGoodsId
})
},
changePage() {
GoodsApi.searchFind({
page: this.page
}).then(res => {
if (res.data.length == 0) {
this.page = 1;
} else {
9 months ago
this.page++
}
this.getHot()
})
},
9 months ago
getHot() {
GoodsApi.searchFind({
page: this.page
}).then(res => {
if (res.data.length == 0) {
this.page = 1;
this.$toast('暂无其他搜索发现')
} else {
9 months ago
this.page++;
this.searchFindList = res.data;
}
9 months ago
9 months ago
})
10 months ago
},
9 months ago
searchGoods(item) {
uni.navigateTo({
9 months ago
url: '/pages/goods/list?search=' + item
})
},
getSearchInfo() {
10 months ago
// 搜索
9 months ago
if(this.searchValue){
this.searchList.push(this.searchValue)
this.searchList = Array.from(new Set(this.searchList));
uni.setStorageSync('searchList', this.searchList)
}
uni.redirectTo({
url: '/pages/goods/list?search=' + this.searchValue+'&categoryId=' + this.category_id
})
10 months ago
},
9 months ago
chartsGoodsJingHandle() {
9 months ago
GoodsApi.chartsGoodsJingApi().then(res => {
this.goodsList = res.data;
9 months ago
9 months ago
})
9 months ago
9 months ago
}
}
}
11 months ago
</script>
<style lang="scss" scoped>
.container {
9 months ago
padding: 40rpx 0;
min-height: 100vh;
background: #f7f7f7;
}
.search {
9 months ago
// width: 680rpx;
height: 64rpx;
background: #FFFFFF;
border-radius: 68rpx 68rpx 68rpx 68rpx;
opacity: 1;
border: 2rpx solid #F3202A;
9 months ago
// margin: 10rpx 0 0 20rpx;
display: flex;
align-items: center;
9 months ago
margin: 0 40rpx;
.searchIcon {
width: 28rpx;
height: 28rpx;
opacity: 1;
margin: 0rpx 0 0 26rpx;
}
.input {
flex: 1;
padding-left: 20rpx;
}
.searchBtn {
width: 126rpx;
height: 56rpx;
background: #F3202A;
border-radius: 48rpx 48rpx 48rpx 48rpx;
opacity: 1;
line-height: 56rpx;
text-align: center;
margin-right: 4rpx;
font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #FFFFFF;
}
}
10 months ago
.find {
display: flex;
justify-content: space-between;
align-items: center;
9 months ago
margin: 0 40rpx;
margin-top: 44rpx;
9 months ago
8 months ago
.findTitle {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
9 months ago
&>text {
9 months ago
font-size: 32rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
color: #000000;
}
8 months ago
.do{
display: flex;
align-items: center;
padding: 0 20rpx;
white-space: nowrap;
}
.red{
font-size: 24rpx;
color: #ff0000;
}
.suc{
border-left: 1px solid #ececec;
padding-left: 20rpx;
margin-left: 20rpx;
height: 30rpx;
display: flex;
align-items: center;
font-size: 24rpx;
color: #9B9B9B;
}
10 months ago
.findIcon {
width: 36rpx;
9 months ago
height: auto;
border-radius: 0rpx 0rpx 0rpx 0rpx;
opacity: 1;
margin-left: 22rpx;
9 months ago
margin-top: 3rpx;
9 months ago
position: relative;
9 months ago
top: 4rpx;
}
}
10 months ago
.others {
9 months ago
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #8D8D8D;
9 months ago
margin-right: 14rpx;
}
}
10 months ago
.hotSearch {
display: flex;
align-items: center;
flex-wrap: wrap;
9 months ago
margin: 0 40rpx;
margin-top: 20rpx;
9 months ago
10 months ago
.hotItem {
9 months ago
padding: 10rpx 30rpx;
background: #FFFFFF;
9 months ago
border-radius: 34px 34px 34px 34px;
opacity: 1;
9 months ago
display: flex;
align-items: center;
9 months ago
margin-left: 12rpx;
margin-bottom: 24rpx;
8 months ago
text{
display: block;
max-width: 200rpx;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.del{
border-left: 1px solid #ececec;
padding-left: 20rpx;
margin-left: 20rpx;
height: 30rpx;
display: flex;
align-items: center;
}
10 months ago
.hotImg {
width: 25rpx;
height: 29rpx;
opacity: 1;
}
}
}
.hotSuggest {
10 months ago
width: 100%;
9 months ago
// margin-left: 32rpx;
9 months ago
margin-top: 12rpx;
margin-left: 40rpx;
9 months ago
padding-right: 40rpx;
9 months ago
.hotList {
width: 100%;
10 months ago
white-space: nowrap;
.hotItem {
9 months ago
margin-right: 30rpx;
10 months ago
display: inline-block;
width: 484rpx;
height: 612rpx;
overflow-y: auto;
background-image: url('../../static/search/hotBack.png');
background-size: 100% 100%;
10 months ago
border-radius: 8rpx 8rpx 8rpx 8rpx;
opacity: 1;
9 months ago
padding: 18rpx 20rpx 48rpx 20rpx;
9 months ago
// border: 2rpx solid #FFFFFF;
.itemHeade {
10 months ago
display: flex;
align-items: center;
9 months ago
margin-bottom: 46rpx;
9 months ago
image {
10 months ago
width: 48rpx;
9 months ago
height: auto;
10 months ago
}
9 months ago
.headTitle {
9 months ago
10 months ago
font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 600;
color: #F3202A;
9 months ago
margin-left: 14rpx;
10 months ago
}
}
.itemMain {
10 months ago
display: flex;
align-items: center;
9 months ago
margin-bottom: 22rpx;
// margin: 22rpx 0 0 26rpx;
.numCommon {
10 months ago
width: 34rpx;
height: 28rpx;
background-size: 100% 100%;
text-align: center;
font-size: 20rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 600;
color: #FFFFFF;
9 months ago
// line-height: 28rpx;
display: flex;
align-items: center;
justify-content: center;
9 months ago
flex-shrink: 0;
9 months ago
text {
9 months ago
position: relative;
9 months ago
left: -1rpx;
9 months ago
}
10 months ago
}
.num1 {
10 months ago
background-image: url('/static/search/first.png');
}
.num2 {
10 months ago
background-image: url('/static/search/second.png');
}
.num3 {
10 months ago
background-image: url('/static/search/third.png');
}
.num4 {
10 months ago
background-image: url('/static/search/common.png');
}
9 months ago
.picContent {
10 months ago
width: 100rpx;
height: 90rpx;
border-radius: 8rpx 8rpx 8rpx 8rpx;
9 months ago
overflow: hidden;
10 months ago
margin-left: 10rpx;
9 months ago
flex-shrink: 0;
9 months ago
9 months ago
.goodsImg {
width: 100%;
9 months ago
height: 100%;
9 months ago
// opacity: 1;
//
}
10 months ago
}
9 months ago
9 months ago
.goodsInfo {
10 months ago
margin-left: 18rpx;
9 months ago
width: calc(100% - 160rpx);
9 months ago
.goodName {
9 months ago
// width: 138rpx;
// height: 34rpx;
10 months ago
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #000000;
line-height: 34rpx;
text-align: center;
9 months ago
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
10 months ago
}
.goodsSale {
9 months ago
// width: 96rpx;
// height: 34rpx;
10 months ago
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #9B9B9B;
line-height: 34rpx;
margin-top: 6rpx;
9 months ago
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
10 months ago
}
}
}
}
}
}
9 months ago
</style>