Authored by QC-L

更新搜索相关逻辑 review by 黄敬囿

... ... @@ -41,8 +41,8 @@
}
.progress-box {
/* position: absolute; */
width: 220rpx;
height: 220rpx;
width: 240rpx;
height: 240rpx;
display: flex;
margin-right: 50rpx;
/* align-items: center; */
... ... @@ -53,13 +53,13 @@
.progress-bg {
position: absolute;
width: 220rpx;
height: 220rpx;
width: 240rpx;
height: 240rpx;
}
.progress-canvas {
width: 220rpx;
height: 220rpx;
width: 240rpx;
height: 240rpx;
}
.progress-text {
... ...
... ... @@ -66,26 +66,37 @@ export default class Search extends Component {
if (e.detail.value === '') {
return;
}
this.savaLateSearch(e);
this.saveLateSearch(e);
router.go('productList', {
query: e.detail.value
});
}
savaLateSearch(e) {
saveLateSearch(e) {
const latelySearch = this.state.latelySearch;
if (latelySearch.length >= 10) {
latelySearch.pop();
}
latelySearch.unshift({search_word: e.detail.value});
let setList = this.removeSameSearch(latelySearch, e.detail.value);
setList.unshift({search_word: e.detail.value});
try {
Taro.setStorageSync('latelySearch', latelySearch);
Taro.setStorageSync('latelySearch', setList);
} catch (error) {
console.log(error);
}
this.setState({
latelySearch
})
// this.setState({
// latelySearch
// })
}
removeSameSearch(arr, search_word) {
let hash = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i].search_word !== search_word) {
hash.push(arr[i]);
}
}
return hash;
}
onRemoveAllSearch() {
... ...
... ... @@ -277,14 +277,25 @@ export default class SearchList extends Component {
if (searchList.length >= 10) {
searchList.pop();
}
searchList.unshift({search_word: e.detail.value});
let setList = this.removeSameSearch(searchList, e.detail.value);
setList.unshift({ search_word: e.detail.value });
try {
Taro.setStorageSync('latelySearch', searchList);
Taro.setStorageSync('latelySearch', setList);
} catch (error) {
console.log(error);
}
}
removeSameSearch(arr, search_word) {
let hash = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i].search_word !== search_word) {
hash.push(arr[i]);
}
}
return hash;
}
goYohoBuyMinApp() {
wx.navigateToMiniProgram({
appId: 'wx084ab813d88c594b',
... ...
'use strict';
var strictUriEncode = require('strict-uri-encode');
var objectAssign = require('object-assign');
var strictUriEncode = require('./strict-uri-encode');
var objectAssign = require('./object-assign');
function encode(value, opts) {
if (opts.encode) {
... ...