展品维保小程序前端代码接口
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.

273 lines
6.2 KiB

2 weeks ago
2 weeks ago
2 weeks ago
2 weeks 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. 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.department || !userInfo.headImage || !userInfo.nickName || !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. .bg-image {
  135. position: absolute;
  136. top: 0;
  137. left: 0;
  138. width: 100%;
  139. height: 33%;
  140. z-index: 1;
  141. }
  142. .content {
  143. position: relative;
  144. z-index: 2;
  145. height: 100%;
  146. display: flex;
  147. flex-direction: column;
  148. align-items: center;
  149. justify-content: center;
  150. padding: 0 60rpx;
  151. .logo-section {
  152. display: flex;
  153. flex-direction: column;
  154. align-items: center;
  155. margin-bottom: 120rpx;
  156. .logo {
  157. width: 120rpx;
  158. height: 120rpx;
  159. margin-bottom: 40rpx;
  160. }
  161. .title-text {
  162. font-size: 36rpx;
  163. font-weight: 600;
  164. color: $primary-text-color;
  165. text-align: center;
  166. }
  167. }
  168. .login-section {
  169. width: 100%;
  170. display: flex;
  171. flex-direction: column;
  172. align-items: center;
  173. .login-btn {
  174. width: 630rpx;
  175. height: 88rpx;
  176. margin-bottom: 30rpx;
  177. background-color: $primary-color;
  178. border: none;
  179. border-radius: 44rpx;
  180. color: white;
  181. font-size: 32rpx;
  182. font-weight: 500;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. }
  187. .guest-btn {
  188. width: 630rpx;
  189. height: 88rpx;
  190. margin-bottom: 60rpx;
  191. border: 2rpx solid $secondary-text-color;
  192. border-radius: 44rpx;
  193. color: $secondary-text-color;
  194. font-size: 32rpx;
  195. font-weight: 400;
  196. background-color: transparent;
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. }
  201. .agreement-text {
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. font-size: 24rpx;
  206. color: $secondary-text-color;
  207. line-height: 1.5;
  208. .checkbox-container {
  209. margin-right: 12rpx;
  210. cursor: pointer;
  211. .checkbox {
  212. width: 29rpx;
  213. height: 29rpx;
  214. border: 1rpx solid $secondary-text-color;
  215. border-radius: 50%;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. transition: all 0.3s ease;
  220. &.checked {
  221. border-color: $primary-color;
  222. background-color: $primary-color;
  223. }
  224. .checkbox-inner {
  225. width: 16rpx;
  226. height: 16rpx;
  227. background-color: white;
  228. border-radius: 50%;
  229. }
  230. }
  231. }
  232. .agreement-content {
  233. flex: 1;
  234. text-align: left;
  235. display: flex;
  236. .link-text {
  237. color: $primary-color;
  238. text-decoration: underline;
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. </style>