login.vue 6.4 KB

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