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

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