login.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="logo-content">
  4. <image :src="imagePath" mode="aspectFit" class="logo-image"></image>
  5. <text class="title">金邻助家</text>
  6. </view>
  7. <image
  8. src="/static/13779@1x.png"
  9. mode="widthFix"
  10. class="house-illustration"
  11. ></image>
  12. <view class="slogan-content">
  13. <text class="slogan-text">着力打造全国居家服务行业标准</text>
  14. <text class="slogan-text">和建立综合信用评价体系</text>
  15. </view>
  16. <!-- 波浪容器 -->
  17. <view class="wave-container">
  18. <image src="/static/Vector 1@1x.png" mode="widthFix" class="wave-img"></image>
  19. <image src="/static/Vector 2@1x.png" mode="widthFix" class="wave-img"></image>
  20. </view>
  21. <view class="actions-container">
  22. <up-button
  23. custom-style="{ 'background-color': '#623F34', 'color': '#FFFFFF', 'border-radius': '25px', 'height': '50px', 'line-height': '50px', 'fontSize': '18px' }"
  24. class="login-button"
  25. @click="handleLogin"
  26. >微信授权登录</up-button
  27. >
  28. <view class="xieyi text-center">
  29. <text class="text-grey1">登录即代表同意</text>
  30. <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
  31. <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import { ref, reactive, onMounted } from 'vue'
  38. import { useRouter } from 'vue-router' // 根据实际情况选择路由库
  39. import store from '@/store'
  40. const imagePath = '/static/9efd1.png' // Path to the logo image (red tree)
  41. // 获取全局配置
  42. // const globalConfig = getApp().globalData.config;
  43. const register = ref(false) // 用户注册开关
  44. const loginForm = reactive({
  45. username: '',
  46. password: '',
  47. code: '',
  48. uuid: '',
  49. })
  50. // const codeUrl = ref(""); // Not used in the new design
  51. // const captchaEnabled = ref(true); // Not used in the new design
  52. const router = useRouter()
  53. // 用户注册 - assuming this might be needed later, keeping it
  54. const handleUserRegister = () => {
  55. router.push('/pages/register') // 替换为实际的路由跳转逻辑
  56. }
  57. // 隐私协议
  58. const handlePrivacy = () => {
  59. uni.navigateTo({
  60. url: '/pages_home/pages/login/index',
  61. })
  62. }
  63. // 用户协议
  64. const handleUserAgrement = () => {
  65. uni.navigateTo({
  66. url: '/pages_home/pages/login/user',
  67. })
  68. }
  69. // 登录方法
  70. const handleLogin = async () => {
  71. uni.showLoading({
  72. title: '登录中,请耐心等待...',
  73. }) // 使用uni-app的loading方法替代$modal.loading
  74. // 获取服务商信息
  75. uni.getProvider({
  76. service: 'oauth',
  77. success: (res) => {
  78. console.log(res)
  79. },
  80. })
  81. // 获取code
  82. uni.login({
  83. provider: 'weixin',
  84. success: (res) => {
  85. if (res.code == 500) {
  86. uni.showLoading({
  87. title: '系统暂未开发,敬请期待',
  88. })
  89. } else if (res.code == 400) {
  90. uni.showLoading({
  91. title: '系统暂未开放',
  92. })
  93. }
  94. loginForm.code = res.code
  95. // 获取用户信息
  96. uni.getUserInfo({
  97. success: (res) => {
  98. console.log('用户信息', res)
  99. },
  100. })
  101. pwdLogin()
  102. uni.hideLoading()
  103. },
  104. })
  105. }
  106. // 密码登录
  107. const pwdLogin = async () => {
  108. if (!store) {
  109. console.error('Store is not defined')
  110. return
  111. }
  112. store.dispatch('Login', loginForm).then(() => {
  113. // uni.hideLoading(); // 关闭加载提示
  114. loginSuccess()
  115. })
  116. }
  117. // 登录成功后,处理函数
  118. const loginSuccess = () => {
  119. store.dispatch('GetInfo').then((res) => {
  120. console.log(store.state.user.userOrWorker, '>>>>99')
  121. if (store.state.user.userOrWorker == 0) {
  122. uni.reLaunch({
  123. url: '/pages/UserSelection',
  124. })
  125. return
  126. }
  127. uni.setStorageSync('userType', store.state.user.userOrWorker)
  128. uni.switchTab({
  129. url: '/pages/index',
  130. })
  131. })
  132. }
  133. // 页面加载时
  134. onMounted(() => {
  135. uni.setStorageSync('userType', 0)
  136. // open(); // Popup related, removed
  137. })
  138. </script>
  139. <style lang="scss" scoped>
  140. page {
  141. height: 100vh;
  142. width: 100%;
  143. }
  144. .normal-login-container {
  145. width: 100%;
  146. height: 100vh;
  147. position: relative;
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. // background: linear-gradient(180deg, #ffa485 0%, #f6b053 100%);
  152. overflow: hidden;
  153. }
  154. .logo-content {
  155. margin-top: 177rpx;
  156. display: flex;
  157. flex-direction: column;
  158. align-items: center;
  159. .logo-image {
  160. width: 90rpx;
  161. height: 90rpx;
  162. margin-bottom: 20rpx;
  163. }
  164. .title {
  165. font-family: PingFang SC;
  166. font-size: 38rpx;
  167. font-weight: 600;
  168. line-height: 38rpx;
  169. color: #ffffff;
  170. text-align: center;
  171. }
  172. }
  173. .house-illustration {
  174. width: 560rpx;
  175. margin-top: 60rpx;
  176. margin-bottom: 40rpx;
  177. }
  178. .slogan-content {
  179. text-align: center;
  180. .slogan-text {
  181. font-size: 28rpx;
  182. color: #593931;
  183. line-height: 38rpx;
  184. display: block;
  185. }
  186. }
  187. .actions-container {
  188. width: 100%;
  189. padding: 0 80rpx;
  190. position: absolute;
  191. bottom: 80rpx;
  192. left: 0;
  193. z-index: 2;
  194. .login-button {
  195. width: 100%;
  196. height: 88rpx;
  197. line-height: 88rpx;
  198. border-radius: 44rpx !important;
  199. background-color: #623f34 !important;
  200. color: #ffffff !important;
  201. font-size: 32rpx !important;
  202. font-weight: 400;
  203. }
  204. .xieyi {
  205. margin-top: 24rpx;
  206. text-align: center;
  207. .text-grey1 {
  208. font-size: 24rpx;
  209. color: #333333;
  210. }
  211. .text-blue {
  212. font-size: 24rpx;
  213. color: #1a88ff;
  214. margin: 0 4rpx;
  215. }
  216. }
  217. }
  218. /* 波浪区域样式 */
  219. .wave-container {
  220. position: absolute;
  221. bottom: 0;
  222. left: 0;
  223. width: 100%;
  224. height: 300rpx;
  225. overflow: hidden;
  226. z-index: 1;
  227. .wave-img {
  228. position: absolute;
  229. bottom: 0;
  230. left: 0;
  231. width: 100%;
  232. height: 100%;
  233. &:first-child {
  234. opacity: 0.4;
  235. mix-blend-mode: multiply;
  236. }
  237. &:last-child {
  238. transform: translateY(20rpx);
  239. }
  240. }
  241. }
  242. </style>