feat 对接搜索推荐

This commit is contained in:
AERWEN\26795 2023-10-25 17:29:54 +08:00
parent c353a9d2ce
commit da8468fe23
4 changed files with 50 additions and 3 deletions

View File

@ -1,6 +1,9 @@
import { import {
getHistorySearchList getHistorySearchList
} from '~/services/home/getHistorySearchList'; } from '~/services/home/getHistorySearchList';
import {
getSearchRecList
} from '~/services/home/getSearchRecList';
import { import {
getHotSearchList getHotSearchList
} from '~/services/home/getHotSearchList'; } from '~/services/home/getHotSearchList';
@ -49,7 +52,7 @@ Page({
async queryPopular() { async queryPopular() {
try { try {
getHotSearchList().then((res) => { getSearchRecList().then((res) => {
if (res.code == 200) { if (res.code == 200) {
this.setData({ this.setData({
popularWords: res.data, popularWords: res.data,
@ -142,6 +145,20 @@ Page({
} }
}, },
// 点击搜索推荐
handleRecTap(e) {
const {
dataset
} = e.currentTarget;
const _searchValue = dataset?.value;
if (_searchValue) {
wx.navigateTo({
url: `/pages/goods/result/index?searchValue=${_searchValue}`,
});
}
},
// TODO:提交搜索 // TODO:提交搜索
handleSubmit(e) { handleSubmit(e) {
const { const {

View File

@ -17,6 +17,19 @@
暂无数据 暂无数据
</view> </view>
</view> </view>
<view class="popular-wrap">
<view class="search-header">
<text class="search-title">搜索推荐</text>
</view>
<view class="search-content" wx:if="{{popularWords.length > 0}}">
<view class="search-item" hover-class="hover-history-item" wx:for="{{popularWords}}" data-value="{{item.title}}" bind:tap="handleRecTap" data-index="{{index}}" wx:key="*this">
{{item.title}}
</view>
</view>
<view wx:else class="search-item">
暂无数据
</view>
</view>
<!-- <view class="popular-wrap"> <!-- <view class="popular-wrap">
<view class="search-header"> <view class="search-header">
<text class="search-title">热门搜索</text> <text class="search-title">热门搜索</text>

View File

@ -461,10 +461,8 @@ Page({
return; return;
} }
// this.payLock = true; // this.payLock = true;
console.log(submitCouponList);
// const resSubmitCouponList = this.handleCouponList(submitCouponList); // const resSubmitCouponList = this.handleCouponList(submitCouponList);
const openId = wx.getStorageSync('openId') const openId = wx.getStorageSync('openId')
console.log(openId, '我的openId');
const params = { const params = {
userAddressReq: settleDetailData.userAddress || userAddressReq, userAddressReq: settleDetailData.userAddress || userAddressReq,
goodsRequestList: goodsRequestList, goodsRequestList: goodsRequestList,

View File

@ -0,0 +1,19 @@
import {
request
} from '../_utils/request';
/** 获取搜索推荐列表 */
export function getSearchRecList() {
return new Promise((resolve, reject) => {
request({
url: `SearchRecommendApi/getSearchRecommendList`,
method: 'GET',
success: function (res) {
resolve(res);
},
fail: function (error) {
reject(error);
}
});
});
}