裂变星小程序-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.

43 lines
756 B

  1. import fetch from '@/api/fetch.js'
  2. const slog = {}
  3. const get = () => {
  4. try {
  5. return slog
  6. // return JSON.parse(uni.getStorageSync('shareLog')) || {}
  7. } catch (err) {
  8. return {}
  9. }
  10. }
  11. const insert = (id) => {
  12. const log = get()
  13. let bef = log[id] || 0
  14. log[id] = bef + 1
  15. uni.setStorageSync('shareLog', JSON.stringify(log))
  16. }
  17. const check = async (id, need_num) => {
  18. try {
  19. const log = get()
  20. const num = parseInt(log[id]) || 0
  21. const safeNeedNum = parseInt(need_num) || 0
  22. const open = num >= safeNeedNum
  23. return { open, need_num: safeNeedNum, num, title: `已转发${num}` }
  24. } catch (err) {
  25. console.error('--校验达标异常', err)
  26. return {}
  27. }
  28. }
  29. export default {
  30. get,
  31. insert,
  32. check,
  33. }