privacy.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="privacy-container">
  3. <!-- 遮罩层 -->
  4. <view class="privacy-mask"></view>
  5. <!-- 弹窗卡片 -->
  6. <view class="privacy-content">
  7. <view class="privacy-title">{{ titleText }}</view>
  8. <view class="privacy-body">
  9. <view class="privacy-intro">
  10. {{ introText }}
  11. <text class="privacy-highlight">《用户服务与隐私协议》</text>
  12. 。我们将遵循"最小必要"原则,仅收集实现服务所必需的信息。
  13. </view>
  14. <view class="privacy-list">
  15. <view class="privacy-item">
  16. <text class="privacy-dot">•</text>
  17. <text>微信昵称、头像 —— 用于展示您的身份</text>
  18. </view>
  19. <view class="privacy-item">
  20. <text class="privacy-dot">•</text>
  21. <text>手机号 —— 用于售后联系与账号安全</text>
  22. </view>
  23. <view class="privacy-item">
  24. <text class="privacy-dot">•</text>
  25. <text>位置信息 —— 用于推荐附近服务(需授权)</text>
  26. </view>
  27. <view class="privacy-item">
  28. <text class="privacy-dot">•</text>
  29. <text>设备信息 —— 用于保障服务稳定运行</text>
  30. </view>
  31. </view>
  32. <view class="privacy-note">
  33. 我们不会主动向第三方共享您的个人信息,除非获得您的明确同意或法律法规要求。
  34. </view>
  35. <text class="privacy-link" @click="goAgreement"
  36. >查看完整协议详情 ></text
  37. >
  38. </view>
  39. <view class="privacy-footer">
  40. <view class="privacy-btn privacy-btn-cancel" @click="onDisagree">
  41. 不同意
  42. </view>
  43. <view class="privacy-btn privacy-btn-confirm" @click="onAgree">
  44. 同意并继续
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. markPrivacyAgreed,
  53. PRIVACY_STORAGE_KEY,
  54. } from '@/util/privacyConfig.js';
  55. export default {
  56. name: 'PrivacyPage',
  57. data() {
  58. return {
  59. // 是否为协议更新(老用户之前同意过旧版本)
  60. isUpdate: false,
  61. };
  62. },
  63. computed: {
  64. // 标题:首次显示"用户服务与隐私协议",更新时显示"隐私协议已更新"
  65. titleText() {
  66. return this.isUpdate ? '隐私协议已更新' : '用户服务与隐私协议';
  67. },
  68. // 介绍文案
  69. introText() {
  70. return this.isUpdate
  71. ? '我们更新了隐私协议,请您认真阅读'
  72. : '欢迎使用本应用!在您首次使用前,请认真阅读';
  73. },
  74. },
  75. created() {
  76. // 判断是首次还是协议更新:
  77. // 有老数据 privacy_agreed: true(旧方案) 或 有旧版本号(新方案但版本不同)→ 视为更新
  78. const oldFlag = uni.getStorageSync('privacy_agreed');
  79. const oldVersion = uni.getStorageSync(PRIVACY_STORAGE_KEY);
  80. this.isUpdate = !!(oldFlag || (oldVersion && oldVersion.length > 0));
  81. },
  82. methods: {
  83. // 同意隐私协议
  84. onAgree() {
  85. // 存版本号(替换老数据)
  86. markPrivacyAgreed();
  87. // 清理老的 boolean 标志(如果存在)
  88. uni.removeStorageSync('privacy_agreed');
  89. uni.showToast({
  90. title: '已同意隐私协议',
  91. icon: 'none',
  92. duration: 1200,
  93. });
  94. setTimeout(() => {
  95. // #ifdef APP-PLUS
  96. // 通知 App.vue 执行全局初始化
  97. var app = getApp();
  98. if (app && app.doAfterPrivacy) {
  99. app.doAfterPrivacy();
  100. }
  101. // #endif
  102. // 跳回首页
  103. uni.reLaunch({
  104. url: '/pages/index/index',
  105. });
  106. }, 800);
  107. },
  108. // 不同意
  109. onDisagree() {
  110. uni.showModal({
  111. title: '提示',
  112. content: '您需要同意隐私协议才能使用本应用',
  113. confirmText: '再次查看',
  114. cancelText: '退出应用',
  115. success: (res) => {
  116. if (!res.confirm) {
  117. // 退出应用:App 端和小程序端分别处理
  118. // #ifdef APP-PLUS
  119. plus.runtime.quit();
  120. // #endif
  121. // #ifdef MP
  122. uni.showToast({
  123. title: '请同意隐私协议后重试',
  124. icon: 'none',
  125. });
  126. // #endif
  127. }
  128. // "再次查看"则什么也不做,弹窗仍在
  129. },
  130. });
  131. },
  132. // 查看完整协议
  133. goAgreement() {
  134. uni.navigateTo({
  135. url: '/pages/login/agreement',
  136. });
  137. },
  138. },
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .privacy-container {
  143. position: fixed;
  144. top: 0;
  145. left: 0;
  146. width: 100%;
  147. height: 100%;
  148. z-index: 9999;
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. }
  153. .privacy-mask {
  154. position: absolute;
  155. top: 0;
  156. left: 0;
  157. width: 100%;
  158. height: 100%;
  159. background-color: rgba(0, 0, 0, 0.55);
  160. }
  161. .privacy-content {
  162. position: relative;
  163. width: 80%;
  164. max-width: 620rpx;
  165. background-color: #ffffff;
  166. border-radius: 24rpx;
  167. overflow: hidden;
  168. }
  169. .privacy-title {
  170. text-align: center;
  171. font-size: 32rpx;
  172. font-weight: 600;
  173. color: #333333;
  174. padding: 40rpx 40rpx 0;
  175. }
  176. .privacy-body {
  177. padding: 28rpx 40rpx 0;
  178. }
  179. .privacy-intro {
  180. font-size: 26rpx;
  181. color: #555555;
  182. line-height: 1.7;
  183. .privacy-highlight {
  184. color: #24b35d;
  185. }
  186. }
  187. .privacy-list {
  188. margin-top: 20rpx;
  189. .privacy-item {
  190. font-size: 24rpx;
  191. color: #666666;
  192. line-height: 2;
  193. .privacy-dot {
  194. color: #24b35d;
  195. margin-right: 6rpx;
  196. }
  197. }
  198. }
  199. .privacy-note {
  200. margin-top: 16rpx;
  201. font-size: 24rpx;
  202. color: #999999;
  203. line-height: 1.6;
  204. }
  205. .privacy-link {
  206. display: block;
  207. margin-top: 28rpx;
  208. font-size: 26rpx;
  209. color: #24b35d;
  210. text-align: center;
  211. padding: 10rpx 0;
  212. }
  213. .privacy-footer {
  214. display: flex;
  215. border-top: 1rpx solid #f0f0f0;
  216. margin-top: 32rpx;
  217. .privacy-btn {
  218. flex: 1;
  219. height: 96rpx;
  220. line-height: 96rpx;
  221. text-align: center;
  222. font-size: 28rpx;
  223. &.privacy-btn-cancel {
  224. color: #999999;
  225. border-right: 1rpx solid #f0f0f0;
  226. }
  227. &.privacy-btn-confirm {
  228. color: #24b35d;
  229. font-weight: 500;
  230. }
  231. &:active {
  232. opacity: 0.7;
  233. }
  234. }
  235. }
  236. </style>