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

284 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">展品维保报修小程序</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 obj = { }
  76. if (uni.getStorageSync('inviter')){
  77. obj.inviter = uni.getStorageSync('inviter')
  78. }
  79. const { result: loginRes } = await this.$api.login.login({
  80. code: res.code,
  81. ...obj
  82. })
  83. uni.setStorageSync('token', loginRes.token)
  84. const userInfo = loginRes.userInfo
  85. // 存储用户信息到store
  86. this.$store.dispatch('updateUserInfo', userInfo)
  87. if ( !userInfo.avatar || !userInfo.name || !userInfo.phone ){
  88. uni.navigateTo({
  89. url: '/subPages/login/userInfo'
  90. })
  91. return
  92. }else {
  93. uni.showToast({
  94. title: '登录成功',
  95. icon: 'success'
  96. })
  97. uni.switchTab({
  98. url: '/pages/index/home'
  99. });
  100. }
  101. // 登录成功后可以调用后端接口保存用户信息
  102. },
  103. fail: (err) => {
  104. console.log('登录失败', err);
  105. }
  106. })
  107. },
  108. // 游客登录
  109. handleGuestLogin() {
  110. console.log('暂不登录');
  111. // 跳转到主页
  112. uni.switchTab({
  113. url: '/pages/index/home'
  114. });
  115. },
  116. // 显示服务协议
  117. showServiceAgreement() {
  118. this.$refs.serviceModal.open();
  119. console.log('查看服务协议');
  120. // 这里可以跳转到协议页面或显示弹窗
  121. },
  122. // 显示隐私政策
  123. showPrivacyPolicy() {
  124. this.$refs.guideModal.open();
  125. console.log('查看隐私条款');
  126. // 这里可以跳转到隐私政策页面或显示弹窗
  127. },
  128. // 切换协议同意状态
  129. toggleAgreement() {
  130. this.isAgreed = !this.isAgreed;
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .login-container {
  137. position: relative;
  138. width: 100vw;
  139. height: 100vh;
  140. overflow: hidden;
  141. background: #E8FBFB;
  142. .bg-image {
  143. position: absolute;
  144. top: 0;
  145. left: 0;
  146. width: 100%;
  147. height: 100%;
  148. z-index: 1;
  149. }
  150. .content {
  151. position: relative;
  152. z-index: 2;
  153. height: 100%;
  154. display: flex;
  155. flex-direction: column;
  156. align-items: center;
  157. justify-content: center;
  158. padding: 0 60rpx;
  159. .logo-section {
  160. display: flex;
  161. flex-direction: column;
  162. align-items: center;
  163. margin-bottom: 120rpx;
  164. .logo {
  165. width: 120rpx;
  166. height: 120rpx;
  167. margin-bottom: 40rpx;
  168. }
  169. .title-text {
  170. font-size: 36rpx;
  171. font-weight: 600;
  172. color: $primary-text-color;
  173. text-align: center;
  174. }
  175. }
  176. .login-section {
  177. width: 100%;
  178. display: flex;
  179. flex-direction: column;
  180. align-items: center;
  181. .login-btn {
  182. width: 630rpx;
  183. height: 88rpx;
  184. margin-bottom: 30rpx;
  185. background-color: $primary-color;
  186. border: none;
  187. border-radius: 44rpx;
  188. color: white;
  189. font-size: 32rpx;
  190. font-weight: 500;
  191. display: flex;
  192. align-items: center;
  193. justify-content: center;
  194. }
  195. .guest-btn {
  196. width: 630rpx;
  197. height: 88rpx;
  198. margin-bottom: 60rpx;
  199. border: 2rpx solid $primary-color;
  200. border-radius: 44rpx;
  201. color: $primary-color;
  202. font-size: 32rpx;
  203. font-weight: 400;
  204. background-color: transparent;
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. }
  209. .agreement-text {
  210. display: flex;
  211. align-items: center;
  212. justify-content: center;
  213. font-size: 24rpx;
  214. color: $secondary-text-color;
  215. line-height: 1.5;
  216. .checkbox-container {
  217. margin-right: 12rpx;
  218. cursor: pointer;
  219. .checkbox {
  220. width: 29rpx;
  221. height: 29rpx;
  222. border: 1rpx solid $secondary-text-color;
  223. border-radius: 50%;
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. transition: all 0.3s ease;
  228. &.checked {
  229. border-color: $primary-color;
  230. background-color: $primary-color;
  231. }
  232. .checkbox-inner {
  233. width: 16rpx;
  234. height: 16rpx;
  235. background-color: white;
  236. border-radius: 50%;
  237. }
  238. }
  239. }
  240. .agreement-content {
  241. flex: 1;
  242. text-align: left;
  243. display: flex;
  244. .link-text {
  245. color: $primary-color;
  246. // text-decoration: underline;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>