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

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