login.vue 6.0 KB

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