From aa56cb2fadf351fe2dd9de068ba26659043eabe0 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Wed, 17 Apr 2024 17:47:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api.js | 20 ++++++++++ pages/columnGoods/goods_search/index.vue | 42 ++++++++++++++------ pages/select_address_n/select_address_n.nvue | 8 ++-- 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/api/api.js b/api/api.js index 5a5c88f..5a9019b 100644 --- a/api/api.js +++ b/api/api.js @@ -433,4 +433,24 @@ export function brigade(data) { return request.get('v2/system/brigade', data, { noAuth: true }); +} + +/** + * 搜索历史记录 + * @param {Object} data + */ +export function userLog(data) { + return request.get('user/log', data, { + noAuth: true + }); +} + +/** + * 删除搜索记录 + * @param {Object} data + */ +export function userLogDelete(data) { + return request.get('user/log/delete', data, { + noAuth: true + }); } \ No newline at end of file diff --git a/pages/columnGoods/goods_search/index.vue b/pages/columnGoods/goods_search/index.vue index ceae2ca..362e729 100644 --- a/pages/columnGoods/goods_search/index.vue +++ b/pages/columnGoods/goods_search/index.vue @@ -12,7 +12,7 @@ 历史记录 - {{item}} + {{item.word}} @@ -137,6 +137,10 @@ getTodayHotSearch, getHotRanking } from '@/api/store.js'; + import { + userLog, + userLogDelete + } from '@/api/api.js'; import shareScence from '@/libs/spread'; import { silenceBindingSpread @@ -207,22 +211,30 @@ } }, onShow: function() { - try { - this.historyList = [] - this.tempStorage = [] - let arr = uni.getStorageSync('historyList') - if (arr.length > 0) { - this.historyList = arr - } else { - this.historyList = [] - } - this.tempStorage = this.historyList - } catch (e) {} + this.getHistoryList(); this.getRoutineHotSearch(); this.getHotSearchList(); this.getHotRankingList(); }, methods: { + getHistoryList(){ + userLog({ + type: this.isShop ? 2 : 1, // 1是商品搜索记录, 2是店铺搜索记录 + }).then(res=>{ + this.historyList = res.data; + }) + // try { + // this.historyList = [] + // this.tempStorage = [] + // let arr = uni.getStorageSync('historyList') + // if (arr.length > 0) { + // this.historyList = arr + // } else { + // this.historyList = [] + // } + // this.tempStorage = this.historyList + // } catch (e) {} + }, // 清空历史记录 remove() { let self = this @@ -233,7 +245,11 @@ if (res.confirm) { self.tempStorage = [] try { - uni.setStorageSync('historyList', self.tempStorage) + userLogDelete({ + type: this.isShop ? 2 : 1, + }).then(res=>{ + console.log(res); + }) self.historyList = [] } catch (e) {} } else if (res.cancel) { diff --git a/pages/select_address_n/select_address_n.nvue b/pages/select_address_n/select_address_n.nvue index a2c40d5..3dbd3b3 100644 --- a/pages/select_address_n/select_address_n.nvue +++ b/pages/select_address_n/select_address_n.nvue @@ -2,10 +2,10 @@ - + + @change="changeCurrent" lineColor="#40af37" lineWidth="105rpx" height="7rpx"> @@ -401,8 +401,8 @@ } .area-item-on { - color: #ff6d20; - border: 2rpx solid #ff6d20; + color: #40af37; + border: 2rpx solid #40af37; } .street {