feat: 隐私协议

This commit is contained in:
Burt 2024-01-22 17:44:23 +08:00
parent e91358c895
commit d9050a8944
3 changed files with 49 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -10,11 +10,23 @@
<image class="w-8 h-8 rounded-full" :src="userStore.userInfo?.avatar"></image> <image class="w-8 h-8 rounded-full" :src="userStore.userInfo?.avatar"></image>
<view class="ml-2">{{ userStore.userInfo?.nickname }}</view> <view class="ml-2">{{ userStore.userInfo?.nickname }}</view>
</view> </view>
<view class="flex items-center leading-6" v-else @click="show = true"> <view class="flex items-center leading-6" v-else @click="onLogin">
<view class="i-carbon-user-avatar"></view> <view class="i-carbon-user-avatar"></view>
<view class="ml-2">点击显示微信头像</view> <view class="ml-2">点击显示微信头像2</view>
</view> </view>
<fly-login v-model="show" />
<view v-if="showPrivacyModal">
<view>隐私弹窗内容....</view>
<button @tap="handleOpenPrivacyContract">查看隐私协议</button>
<button
id="agree-btn"
open-type="agreePrivacyAuthorization"
@agreeprivacyauthorization="handleAgreePrivacyAuthorization"
>
同意
</button>
</view>
<fly-login v-model="showLoginModal" />
<fly-content :line="10" /> <fly-content :line="10" />
<button v-if="hasLogin" class="mt-2" @click="logout">退出登录</button> <button v-if="hasLogin" class="mt-2" @click="logout">退出登录</button>
</view> </view>
@ -23,7 +35,38 @@
<script lang="ts" setup name="WxLogin"> <script lang="ts" setup name="WxLogin">
import { useUserStore } from '@/store' import { useUserStore } from '@/store'
const show = ref(false) const showPrivacyModal = ref(false)
const showLoginModal = ref(false)
const onLogin = () => {
wx.getPrivacySetting({
success(res) {
// : res = { needAuthorization: true/false, privacyContractName: 'xxx' }
console.log(res)
if (res.needAuthorization) {
//
showPrivacyModal.value = true
} else {
//
showLoginModal.value = true
}
},
})
}
const handleOpenPrivacyContract = () => {
//
wx.openPrivacyContract({
success: () => {}, //
fail: () => {}, //
complete: () => {},
})
}
const handleAgreePrivacyAuthorization = () => {
//
//
showPrivacyModal.value = false
showLoginModal.value = true
}
const userStore = useUserStore() const userStore = useUserStore()
const hasLogin = computed(() => userStore.userInfo?.nickname) const hasLogin = computed(() => userStore.userInfo?.nickname)
const logout = () => { const logout = () => {

View File

@ -4,8 +4,8 @@
} }
</route> </route>
<template> <template>
<view>我的</view> <view class="ml-4">wx的openid: </view>
<view>wx的openid:{{ openId }} </view> <view class="ml-4">{{ openId }}</view>
<wx-login /> <wx-login />
</template> </template>