裂变星小程序-25.03.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

54 lines
775 B

import fetch from '@/api/fetch.js'
let slog = {}
const get = () => {
try {
return slog
// return JSON.parse(uni.getStorageSync('shareLog')) || {}
} catch (err) {
return {}
}
}
const clear = () => {
slog = {}
}
const insert = (id) => {
const log = get()
let bef = log[id] || 0
log[id] = bef + 1
uni.setStorageSync('shareLog', JSON.stringify(log))
}
const check = async (id, need_num) => {
try {
const log = get()
const num = parseInt(log[id]) || 0
const safeNeedNum = parseInt(need_num) || 0
const open = num >= safeNeedNum
return {
open,
need_num: safeNeedNum,
num,
title: `已转发${num}`
}
} catch (err) {
console.error('--校验达标异常', err)
return {}
}
}
export default {
get,
insert,
check,
clear,
}