login.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="login">
  3. </view>
  4. </template>
  5. <script>
  6. import {
  7. mapGetters,
  8. mapMutations
  9. } from 'vuex'
  10. import {
  11. currentPage,
  12. trottle,
  13. urlencode
  14. } from '@/utils/tools'
  15. import Cache from "@/utils/cache"
  16. import {
  17. BACK_URL,
  18. INVITE_CODE
  19. } from '@/config/cachekey'
  20. export default {
  21. data() {
  22. return {
  23. token: null,
  24. loginUrl: 'https://www.jucai.gov.cn/mobile/auth/login/company?redirect_url='
  25. };
  26. },
  27. async onLoad(option) {
  28. this.authLoginJucai();
  29. },
  30. onShow() {},
  31. onUnload() {
  32. },
  33. methods: {
  34. ...mapMutations(['login']),
  35. async authLoginJucai() {
  36. const {
  37. token
  38. } = this.$Route.query
  39. console.log('token: ' + token)
  40. if (token || this.appConfig.token) {
  41. // uni.showLoading({
  42. // title: '登录中...',
  43. // mask: true
  44. // });
  45. this.loginHandle(token || this.appConfig.token)
  46. } else {
  47. uni.showLoading({
  48. title: '仅对企业开放',
  49. mask: true,
  50. complete: () => {
  51. //延迟0.5s登录,提示用户信息
  52. setTimeout(() => {
  53. location.href = this.loginUrl + urlencode(location.href)
  54. }, 500)
  55. }
  56. });
  57. }
  58. },
  59. // 登录结果处理
  60. async loginHandle(token) {
  61. //保存token,获取用户
  62. this.login({
  63. token: token
  64. })
  65. uni.hideLoading()
  66. //跳转逻辑
  67. if (getCurrentPages().length > 1) {
  68. uni.navigateBack({
  69. success() {
  70. const {
  71. onLoad,
  72. options
  73. } = currentPage()
  74. onLoad && onLoad(options)
  75. }
  76. })
  77. } else if (Cache.get(BACK_URL)) {
  78. this.$Router.replace(Cache.get(BACK_URL))
  79. } else {
  80. this.$Router.pushTab('/pages/index/index')
  81. }
  82. Cache.remove(BACK_URL)
  83. },
  84. },
  85. computed: {
  86. ...mapGetters(['appConfig']),
  87. }
  88. };
  89. </script>
  90. <style lang="scss">
  91. page {
  92. background-color: #fff;
  93. text-align: center;
  94. padding: 0;
  95. .login {
  96. min-height: 100vh;
  97. display: flex;
  98. flex-direction: column;
  99. .mpwx-login {
  100. min-height: 0;
  101. flex: 1;
  102. .avatar {
  103. display: inline-block;
  104. width: 120rpx;
  105. height: 120rpx;
  106. border-radius: 50%;
  107. border: 1px solid #eee;
  108. overflow: hidden;
  109. }
  110. .user-name {
  111. height: 40rpx;
  112. }
  113. .image {
  114. width: 50rpx;
  115. height: 50rpx;
  116. }
  117. .btn {
  118. background-color: #09BB07;
  119. width: 580rpx;
  120. margin: 80rpx auto 0;
  121. }
  122. }
  123. .acount-login {
  124. padding-top: 100rpx;
  125. display: flex;
  126. flex-direction: column;
  127. align-items: center;
  128. box-sizing: border-box;
  129. min-height: 0;
  130. flex: 1;
  131. .logo {
  132. height: 120rpx;
  133. margin-bottom: 50rpx;
  134. }
  135. .input {
  136. width: 670rpx;
  137. border-bottom: $-solid-border;
  138. margin-top: 30rpx;
  139. }
  140. .sms-btn {
  141. border: 1px solid $-color-primary;
  142. width: 176rpx;
  143. height: 60rpx;
  144. box-sizing: border-box;
  145. }
  146. .wx-login {
  147. margin-top: 60rpx;
  148. .image {
  149. margin-top: 40rpx;
  150. width: 80rpx;
  151. height: 80rpx;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. .password-icon {
  158. width: 58rpx;
  159. height: 58rpx;
  160. overflow: hidden;
  161. margin-left: 20rpx;
  162. image {
  163. width: 100%;
  164. }
  165. }
  166. .agreement {
  167. position: fixed;
  168. bottom: 0px;
  169. width: 100%;
  170. padding: 30rpx 0;
  171. }
  172. .modify-container {
  173. padding: 40rpx 30rpx;
  174. width: 100%;
  175. border-radius: 30rpx;
  176. font-size: 28rpx;
  177. text-align: left;
  178. color: #333333;
  179. font-weight: bold;
  180. .title {
  181. padding: 26rpx 0rpx;
  182. }
  183. .btn {
  184. height: 80rpx;
  185. border-radius: 20rpx;
  186. margin: 60rpx 50rpx 0;
  187. }
  188. }
  189. </style>