四零语境前端代码仓库
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.

282 lines
6.4 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month 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. <!-- Logo和标题区域 -->
  8. <view class="logo-section">
  9. <image class="logo" :src="configParamContent('login_logo')" mode="aspectFit"></image>
  10. <text class="title-text">{{ configParamContent('app_name') }}</text>
  11. </view>
  12. <!-- 登录按钮区域 -->
  13. <view class="login-section">
  14. <button class="login-btn" @click="handleLogin">
  15. 登录
  16. </button>
  17. <button class="guest-btn" @click="handleGuestLogin">
  18. 取消登录
  19. </button>
  20. <!-- 协议文本 -->
  21. <view class="agreement-text">
  22. <view class="agreement-content">
  23. <view class="checkbox-container" @click="toggleAgreement">
  24. <view class="checkbox" :class="{ 'checked': isAgreed }">
  25. <view class="checkbox-inner" v-if="isAgreed"></view>
  26. </view>
  27. </view>
  28. <text >我已阅读并同意
  29. <text class="link-text" @click="showServiceAgreement">服务协议</text>
  30. <text></text>
  31. <text class="link-text" @click="showPrivacyPolicy">隐私政策</text>
  32. </text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 用户协议和隐私政策弹窗 -->
  38. <uv-modal ref="serviceModal" title="《服务协议与隐私条款》" :show-cancel-button="false" confirm-text="我知道了" confirm-color="#06DADC" @confirm="isAgreed = true">
  39. <view class="privacy-content">
  40. <!-- 如果是富文本 -->
  41. <uv-parse :content="configParamContent('privacy_policy')"></uv-parse>
  42. </view>
  43. </uv-modal>
  44. <!-- 用户协议和隐私政策弹窗 -->
  45. <uv-modal ref="guideModal" title="《个人信息保护指引》" :show-cancel-button="false" confirm-text="我知道了" confirm-color="#06DADC" @confirm="isAgreed = true">
  46. <view class="privacy-content">
  47. <!-- 如果是富文本 -->
  48. <uv-parse :content="configParamContent('user_agreement')"></uv-parse>
  49. </view>
  50. </uv-modal>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. name: 'Login',
  56. data() {
  57. return {
  58. isAgreed: false
  59. }
  60. },
  61. methods: {
  62. // 授权登录
  63. handleLogin() {
  64. if (!this.isAgreed) {
  65. this.$refs.serviceModal.open();
  66. this.$refs.guideModal.open();
  67. return
  68. }
  69. uni.login({
  70. provider: 'weixin',
  71. success: async (res) => {
  72. console.log('登录成功', res);
  73. const obj = { }
  74. if (uni.getStorageSync('inviter')){
  75. obj.inviter = uni.getStorageSync('inviter')
  76. }
  77. const { result: loginRes } = await this.$api.login.login({
  78. code: res.code,
  79. ...obj
  80. })
  81. uni.setStorageSync('token', loginRes.token)
  82. const userInfo = loginRes.userInfo
  83. // 存储用户信息到store
  84. this.$store.dispatch('updateUserInfo', userInfo)
  85. if ( !userInfo.avatar || !userInfo.name || !userInfo.phone ){
  86. uni.navigateTo({
  87. url: '/subPages/login/userInfo'
  88. })
  89. return
  90. }else {
  91. uni.showToast({
  92. title: '登录成功',
  93. icon: 'success'
  94. })
  95. uni.switchTab({
  96. url: '/pages/index/home'
  97. });
  98. }
  99. // 登录成功后可以调用后端接口保存用户信息
  100. },
  101. fail: (err) => {
  102. console.log('登录失败', err);
  103. }
  104. })
  105. },
  106. // 游客登录
  107. handleGuestLogin() {
  108. console.log('暂不登录');
  109. // 跳转到主页
  110. uni.switchTab({
  111. url: '/pages/index/home'
  112. });
  113. },
  114. // 显示服务协议
  115. showServiceAgreement() {
  116. this.$refs.serviceModal.open();
  117. console.log('查看服务协议');
  118. // 这里可以跳转到协议页面或显示弹窗
  119. },
  120. // 显示隐私政策
  121. showPrivacyPolicy() {
  122. this.$refs.guideModal.open();
  123. console.log('查看隐私条款');
  124. // 这里可以跳转到隐私政策页面或显示弹窗
  125. },
  126. // 切换协议同意状态
  127. toggleAgreement() {
  128. this.isAgreed = !this.isAgreed;
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .login-container {
  135. position: relative;
  136. width: 100vw;
  137. height: 100vh;
  138. overflow: hidden;
  139. background: #E8FBFB;
  140. .bg-image {
  141. position: absolute;
  142. top: 0;
  143. left: 0;
  144. width: 100%;
  145. height: 100%;
  146. z-index: 1;
  147. }
  148. .content {
  149. position: relative;
  150. z-index: 2;
  151. height: 100%;
  152. display: flex;
  153. flex-direction: column;
  154. align-items: center;
  155. justify-content: center;
  156. padding: 0 60rpx;
  157. .logo-section {
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. margin-bottom: 120rpx;
  162. .logo {
  163. width: 120rpx;
  164. height: 120rpx;
  165. margin-bottom: 40rpx;
  166. }
  167. .title-text {
  168. font-size: 36rpx;
  169. font-weight: 600;
  170. color: $primary-text-color;
  171. text-align: center;
  172. }
  173. }
  174. .login-section {
  175. width: 100%;
  176. display: flex;
  177. flex-direction: column;
  178. align-items: center;
  179. .login-btn {
  180. width: 630rpx;
  181. height: 88rpx;
  182. margin-bottom: 30rpx;
  183. background-color: $primary-color;
  184. border: none;
  185. border-radius: 44rpx;
  186. color: white;
  187. font-size: 32rpx;
  188. font-weight: 500;
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. }
  193. .guest-btn {
  194. width: 630rpx;
  195. height: 88rpx;
  196. margin-bottom: 60rpx;
  197. border: 2rpx solid $primary-color;
  198. border-radius: 44rpx;
  199. color: $primary-color;
  200. font-size: 32rpx;
  201. font-weight: 400;
  202. background-color: transparent;
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. }
  207. .agreement-text {
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. font-size: 24rpx;
  212. color: $secondary-text-color;
  213. line-height: 1.5;
  214. .checkbox-container {
  215. margin-right: 12rpx;
  216. cursor: pointer;
  217. .checkbox {
  218. width: 29rpx;
  219. height: 29rpx;
  220. border: 1rpx solid $secondary-text-color;
  221. border-radius: 50%;
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. transition: all 0.3s ease;
  226. &.checked {
  227. border-color: $primary-color;
  228. background-color: $primary-color;
  229. }
  230. .checkbox-inner {
  231. width: 16rpx;
  232. height: 16rpx;
  233. background-color: white;
  234. border-radius: 50%;
  235. }
  236. }
  237. }
  238. .agreement-content {
  239. flex: 1;
  240. text-align: left;
  241. display: flex;
  242. .link-text {
  243. color: $primary-color;
  244. // text-decoration: underline;
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251. </style>