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

40 lines
647 B

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