privacy-agreement.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="privacy-page">
  3. <view class="privacy-mask">
  4. <view class="privacy-dialog">
  5. <view class="dialog-header">
  6. <text class="dialog-title">农小禹用户协议和隐私政策</text>
  7. </view>
  8. <view class="dialog-content">
  9. <text class="content-text">
  10. 请你务必审慎阅读、充分理解"用户协议"和"隐私政策"各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、位置信息等信息用于农事管理、设备监控等功能。
  11. </text>
  12. <view class="links-container">
  13. <text class="content-text">你可阅读</text>
  14. <text class="link-text" @click="viewTerms">《用户协议》</text>
  15. <text class="content-text">和</text>
  16. <text class="link-text" @click="viewPrivacy">《隐私政策》</text>
  17. <text class="content-text">了解详细信息。</text>
  18. </view>
  19. <text class="content-text">
  20. 如果你同意,请点击"同意"开始使用我们的服务。
  21. </text>
  22. </view>
  23. <view class="dialog-footer">
  24. <view class="btn btn-cancel" @click="handleDisagree">
  25. <text class="btn-text">不同意</text>
  26. </view>
  27. <view class="btn btn-confirm" @click="handleAgree">
  28. <text class="btn-text btn-text-white">同意</text>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup>
  36. import { onLoad, onBackPress } from '@dcloudio/uni-app'
  37. import privacyUtil from "@/utils/privacy.js"
  38. // 禁用返回按钮
  39. onBackPress(() => {
  40. return true // 返回true表示阻止返回
  41. })
  42. // 页面加载
  43. onLoad(() => {
  44. console.log('隐私协议页面加载')
  45. })
  46. // 同意协议
  47. const handleAgree = () => {
  48. privacyUtil.setAgreement(true)
  49. console.log('用户同意隐私协议')
  50. // 发送全局事件通知应用初始化
  51. uni.$emit('privacyAgreed')
  52. // 返回首页
  53. uni.reLaunch({
  54. url: '/pages/dashboard/index'
  55. })
  56. }
  57. // 不同意协议
  58. const handleDisagree = () => {
  59. uni.showModal({
  60. title: '确认提示',
  61. content: '进入应用前,你需先同意《用户协议》和《隐私政策》,否则将无法使用应用服务。',
  62. confirmText: '同意',
  63. cancelText: '退出应用',
  64. showCancel: true,
  65. success: (res) => {
  66. if (res.confirm) {
  67. privacyUtil.setAgreement(true)
  68. console.log('用户同意隐私协议')
  69. // 发送全局事件通知应用初始化
  70. uni.$emit('privacyAgreed')
  71. // 返回首页
  72. uni.reLaunch({
  73. url: '/pages/dashboard/index'
  74. })
  75. } else {
  76. // #ifdef APP-PLUS
  77. plus.runtime.quit()
  78. // #endif
  79. // #ifdef H5
  80. // H5环境无法直接退出,显示提示
  81. uni.showToast({
  82. title: '请关闭浏览器标签页',
  83. icon: 'none',
  84. duration: 3000
  85. })
  86. // #endif
  87. }
  88. }
  89. })
  90. }
  91. // 查看用户协议
  92. const viewTerms = () => {
  93. uni.navigateTo({
  94. url: '/pages/login/terms'
  95. })
  96. }
  97. // 查看隐私政策
  98. const viewPrivacy = () => {
  99. uni.navigateTo({
  100. url: '/pages/login/privacy'
  101. })
  102. }
  103. </script>
  104. <style scoped>
  105. .privacy-page {
  106. width: 100vw;
  107. height: 100vh;
  108. position: fixed;
  109. top: 0;
  110. left: 0;
  111. z-index: 9999;
  112. }
  113. .privacy-mask {
  114. width: 100%;
  115. height: 100%;
  116. background-color: rgba(0, 0, 0, 0.6);
  117. display: flex;
  118. justify-content: center;
  119. align-items: center;
  120. }
  121. .privacy-dialog {
  122. width: 620rpx;
  123. background-color: #ffffff;
  124. border-radius: 20rpx;
  125. overflow: hidden;
  126. }
  127. .dialog-header {
  128. padding: 40rpx 30rpx 20rpx;
  129. text-align: center;
  130. border-bottom: 1rpx solid #f0f0f0;
  131. }
  132. .dialog-title {
  133. font-size: 36rpx;
  134. font-weight: bold;
  135. color: #333333;
  136. }
  137. .dialog-content {
  138. padding: 30rpx;
  139. max-height: 500rpx;
  140. overflow-y: auto;
  141. }
  142. .content-text {
  143. font-size: 28rpx;
  144. color: #666666;
  145. line-height: 1.8;
  146. }
  147. .links-container {
  148. margin: 20rpx 0;
  149. display: flex;
  150. flex-wrap: wrap;
  151. align-items: center;
  152. }
  153. .link-text {
  154. font-size: 28rpx;
  155. color: #4CAF50;
  156. font-weight: bold;
  157. margin: 0 4rpx;
  158. text-decoration: underline;
  159. }
  160. .dialog-footer {
  161. display: flex;
  162. border-top: 1rpx solid #f0f0f0;
  163. }
  164. .btn {
  165. flex: 1;
  166. height: 100rpx;
  167. display: flex;
  168. justify-content: center;
  169. align-items: center;
  170. }
  171. .btn-cancel {
  172. background-color: #f5f5f5;
  173. border-right: 1rpx solid #e0e0e0;
  174. }
  175. .btn-confirm {
  176. background-color: #4CAF50;
  177. }
  178. .btn-text {
  179. font-size: 32rpx;
  180. color: #666666;
  181. }
  182. .btn-text-white {
  183. color: #ffffff;
  184. font-weight: bold;
  185. }
  186. .btn:active {
  187. opacity: 0.8;
  188. }
  189. </style>