esoftplay-market
Version:
market module on esoftplay framework
30 lines (27 loc) • 950 B
text/typescript
// noPage
import AsyncStorage from '@react-native-async-storage/async-storage';
import { LibCurl } from 'esoftplay/cache/lib/curl/import';
export default class m {
static keywordHit(keyword: string, product_id?: string, delay?: number): void {
let _delay: number = delay || 1000 * 60 * 60 * 24
const id_product = product_id || 0
console.log(keyword + '-' + id_product);
AsyncStorage.getItem(keyword + '-' + id_product).then((res) => {
let lastHit: any = res
if (lastHit) {
let _lastHit: number = parseInt(lastHit)
if (new Date().getTime() - _lastHit >= _delay) {
lastHit = undefined
}
}
if (!lastHit) {
new LibCurl('shop/keyword', { keyword: keyword, product_id: id_product },
(res, msg) => {
AsyncStorage.setItem(keyword + '-' + id_product, String(new Date().getTime()))
},
(msg) => { }, 1
)
}
})
}
}