esoftplay-market
Version:
market module on esoftplay framework
32 lines (29 loc) • 942 B
text/typescript
// noPage
import AsyncStorage from '@react-native-async-storage/async-storage';
import { LibCurl } from 'esoftplay/cache/lib/curl/import';
import { UserClass } from 'esoftplay/cache/user/class/import';
export default class m {
static productHit(id: string, delay?: number): void {
const user = UserClass.state().get()
let _delay: number = delay || 1000 * 60 * 60
if (user && user?.id) {
AsyncStorage.getItem(id).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/product_list_detail_hits/' + id, null,
(res, msg) => {
AsyncStorage.setItem(id, String(new Date().getTime()))
},
(msg) => { }, 1
)
}
})
}
}
}