木邻有你前端代码仓库
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.

292 lines
8.2 KiB

8 months ago
8 months ago
8 months ago
8 months ago
  1. <template>
  2. <view class="login-container">
  3. <!-- 背景图 -->
  4. <image class="bg-image" src="/subPages/static/登录_背景图.png" mode="aspectFill"></image>
  5. <!-- 内容区域 -->
  6. <view class="content">
  7. <!-- 标题图片 -->
  8. <view class="title-section">
  9. <image class="title-image" src="/subPages/static/登录_标题.png" mode="widthFix"></image>
  10. </view>
  11. <!-- 按钮区域 -->
  12. <view class="button-section">
  13. <!-- 授权手机号登录按钮 -->
  14. <view class="login-btn primary" @click="phoneLogin">
  15. <text class="btn-text">授权手机号登录</text>
  16. </view>
  17. <!-- 取消登录按钮 -->
  18. <view class="login-btn secondary" @click="cancelLogin">
  19. <text class="btn-text">取消登录</text>
  20. </view>
  21. <!-- 协议文字 -->
  22. <view class="agreement-text-container">
  23. <view class="agreement-checkbox-row">
  24. <view class="custom-checkbox" @click="toggleAgreement">
  25. <uv-icon
  26. v-if="!isAgreed"
  27. name="checkmark-circle"
  28. size="20"
  29. color="#cccccc">
  30. </uv-icon>
  31. <uv-icon
  32. v-else
  33. name="checkmark-circle-fill"
  34. size="20"
  35. color="#1488DB">
  36. </uv-icon>
  37. </view>
  38. <view class="agreement-text-content">
  39. <text class="agreement-text">阅读并同意我们的 </text>
  40. <text class="agreement-link" @click="showAgreement">服务协议与隐私条款</text>
  41. <text class="agreement-text"> 以及 </text>
  42. <text class="agreement-link" @click="showPrivacy">个人信息保护指引</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. name: 'Login',
  53. data() {
  54. return {
  55. isAgreed: false
  56. }
  57. },
  58. methods: {
  59. // 切换协议同意状态
  60. toggleAgreement() {
  61. this.isAgreed = !this.isAgreed;
  62. console.log('协议同意状态:', this.isAgreed);
  63. },
  64. // 手机号授权登录
  65. phoneLogin() {
  66. if (!this.isAgreed) {
  67. uni.showToast({
  68. title: '请先同意协议条款',
  69. icon: 'none'
  70. });
  71. return;
  72. }
  73. uni.login({
  74. provider: 'weixin',
  75. success: async (loginRes) => {
  76. const res = await this.$api.login.login({
  77. code: loginRes.code
  78. })
  79. uni.setStorageSync('token', res.result.token)
  80. const userInfo = res.result.userInfo
  81. if (!userInfo.headImage || !userInfo.nickName || !userInfo.phone) {
  82. uni.showToast({
  83. title: '请先完善个人信息',
  84. icon: 'none'
  85. })
  86. setTimeout(() => {
  87. uni.navigateTo({
  88. url: '/subPages/login/userInfo'
  89. })
  90. }, 500)
  91. }else {
  92. uni.showToast({
  93. title: '登录成功',
  94. icon: 'success'
  95. })
  96. setTimeout(() => {
  97. uni.switchTab({
  98. url: '/pages/index/index'
  99. })
  100. }, 500)
  101. }
  102. },
  103. fail: (error) => {
  104. uni.showToast({
  105. title: `${error.errMsg}`,
  106. icon: 'none'
  107. })
  108. }
  109. })
  110. },
  111. // 取消登录
  112. cancelLogin() {
  113. console.log('取消登录');
  114. uni.switchTab({
  115. url: '/pages/index/index'
  116. })
  117. },
  118. // 显示服务协议
  119. showAgreement() {
  120. uni.showModal({
  121. title: '服务协议',
  122. content: '用户服务协议\n\n为使用小程序名称的服务,您应当阅读并遵守《用户服务协议》(以下简称"本协议")。请您务必审慎阅读、充分理解各条款内容,特别是免责或者限制责任的条款,以及开通或使用某项服务的单独协议,并选择接受或不接受。限制、免责条款或者其他涉及您重大权益的条款可能以加粗、加下划线等形式提示您重点注意。\n\n除非您已阅读并接受本协议所有条款,否则您无权下载、安装或使用本软件及其相关服务。您的下载、安装、使用、获取账号、登录等行为即视为您已阅读并同意上述协议的约束。\n\n【协议的范围】\n本协议及《隐私政策》是您与小程序名称经营者之间关于用户使用小程序名称下',
  123. showCancel: true,
  124. cancelText: '拒绝',
  125. confirmText: '同意',
  126. success: function (res) {
  127. if (res.confirm) {
  128. console.log('用户同意服务协议');
  129. } else if (res.cancel) {
  130. console.log('用户拒绝服务协议');
  131. }
  132. }
  133. });
  134. },
  135. // 显示隐私条款
  136. showPrivacy() {
  137. uni.showModal({
  138. title: '隐私政策',
  139. content: '【小程序名称】(以下称"我们")深知个人信息安全的重要性,我们将按照法律法规的规定,保护您的个人信息及隐私安全。我们制定本"隐私政策"并特别提示:希望您在使用【小程序名称】及相关服务前仔细阅读并理解本隐私政策,以便您出当的选择。\n\n本隐私政策将帮助您了解:\n• 我们会遵循隐私政策收集、使用您的信息,但不会仅因为您同意本隐私政策而采用强制捆绑的方式一揽子收集个人信息。\n• 当您使用或开启相关功能或使用服务时,为实现功能、服务所必需,我们会收集、使用相关信息。除非是为实现基本业务功能或根据法律法规要求所必需的必要信息,您均可以拒绝提供且不影响其他功能或服务。我们将在隐私政策',
  140. showCancel: true,
  141. cancelText: '拒绝',
  142. confirmText: '同意',
  143. success: function (res) {
  144. if (res.confirm) {
  145. console.log('用户同意隐私政策');
  146. } else if (res.cancel) {
  147. console.log('用户拒绝隐私政策');
  148. }
  149. }
  150. });
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .login-container {
  157. position: relative;
  158. width: 100vw;
  159. height: 100vh;
  160. overflow: hidden;
  161. }
  162. .bg-image {
  163. position: absolute;
  164. top: 0;
  165. left: 0;
  166. width: 100%;
  167. height: 40%;
  168. z-index: 1;
  169. }
  170. .content {
  171. position: relative;
  172. z-index: 2;
  173. height: 100%;
  174. display: flex;
  175. flex-direction: column;
  176. padding: 0 40rpx;
  177. }
  178. .title-section {
  179. flex: 1;
  180. display: flex;
  181. align-items: flex-end;
  182. justify-content: center;
  183. padding-top: 300rpx;
  184. .title-image {
  185. width: 80%;
  186. max-width: 500rpx;
  187. }
  188. }
  189. .welcome-section {
  190. display: flex;
  191. justify-content: center;
  192. margin-bottom: 100rpx;
  193. .welcome-box {
  194. border: 2rpx dashed #1488DB;
  195. border-radius: 10rpx;
  196. padding: 20rpx 40rpx;
  197. background: rgba(255, 255, 255, 0.9);
  198. .welcome-text {
  199. font-size: 28rpx;
  200. color: #1488DB;
  201. font-weight: 500;
  202. }
  203. }
  204. }
  205. .button-section {
  206. flex: 1;
  207. margin-bottom: 60rpx;
  208. align-items: flex-start;
  209. .login-btn {
  210. width: 100%;
  211. height: 88rpx;
  212. border-radius: 44rpx;
  213. display: flex;
  214. align-items: center;
  215. justify-content: center;
  216. margin-bottom: 30rpx;
  217. &.primary {
  218. background: #1488DB;
  219. .btn-text {
  220. color: #ffffff;
  221. font-size: 32rpx;
  222. font-weight: 500;
  223. }
  224. }
  225. &.secondary {
  226. background: rgba(255, 255, 255, 0.9);
  227. border: 2rpx solid #cccccc;
  228. .btn-text {
  229. color: #666666;
  230. font-size: 32rpx;
  231. }
  232. }
  233. }
  234. .agreement-text-container {
  235. margin-top: 40rpx;
  236. .agreement-checkbox-row {
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. .custom-checkbox {
  241. margin-right: 10rpx;
  242. display: flex;
  243. align-items: center;
  244. }
  245. .agreement-text-content {
  246. flex: 1;
  247. text-align: left;
  248. .agreement-text {
  249. font-size: 24rpx;
  250. color: #666666;
  251. }
  252. .agreement-link {
  253. font-size: 24rpx;
  254. color: #1488DB;
  255. text-decoration: underline;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. </style>