41 lines
791 B
TypeScript
41 lines
791 B
TypeScript
import { ref } from "vue"
|
|
import { onShow } from "@dcloudio/uni-app"
|
|
|
|
import CONSTANT from "@@/constant/storage-constant"
|
|
|
|
/**
|
|
* 第一次同意APP的隐私政策
|
|
* 要和`affirm-modal`组件配合使用
|
|
*/
|
|
export const useFirstAffirm = (showAffirmModal) => {
|
|
const firstAffirm = ref(false)
|
|
|
|
onShow(() => {
|
|
const storage = uni.getStorageSync(CONSTANT.FIRST_AFFIRM)
|
|
if (storage && storage != "") {
|
|
firstAffirm.value = true
|
|
} else {
|
|
firstAffirm.value = false
|
|
}
|
|
if (!firstAffirm.value) {
|
|
showAffirmModal?.()
|
|
}
|
|
})
|
|
|
|
const agree = () => {
|
|
uni.setStorageSync(CONSTANT.FIRST_AFFIRM, 1)
|
|
firstAffirm.value = true
|
|
}
|
|
|
|
const reject = () => {
|
|
uni.removeStorageSync(CONSTANT.FIRST_AFFIRM)
|
|
firstAffirm.value = false
|
|
}
|
|
|
|
return {
|
|
firstAffirm,
|
|
agree,
|
|
reject,
|
|
}
|
|
}
|