index.wpy 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <style lang="less">
  2. page {
  3. width: 100%;
  4. height: 100%;
  5. }
  6. .login-box {
  7. box-sizing: border-box;
  8. width: 100%;
  9. height: 100%;
  10. }
  11. .login {
  12. width: 100%;
  13. height: 100%;
  14. background: rgba(0, 0, 0.2);
  15. image {
  16. position: relative;
  17. width: 384rpx;
  18. height: 144rpx;
  19. top: 336rpx;
  20. left: 50%;
  21. transform: translateX(-50%);
  22. }
  23. .bind-btn {
  24. position: fixed;
  25. bottom: 200rpx;
  26. left: 50%;
  27. transform: translateX(-50%);
  28. width: 548rpx;
  29. height: 100rpx;
  30. line-height: 100rpx;
  31. border-radius: 56rpx;
  32. background: rgba(61, 203, 204, 1);
  33. border: none;
  34. font-family: PingFang SC;
  35. font-size: 32rpx;
  36. font-weight: 400;
  37. letter-spacing: 0px;
  38. text-align: center;
  39. color: #fff;
  40. }
  41. }
  42. </style>
  43. <template>
  44. <div class="login-box">
  45. <page-top-bar title=""
  46. titleColor="#1B2129"></page-top-bar>
  47. <div class="login">
  48. <image src="{{h5StaticPath +'/page-bind-tenant/logo_title.png'}}" alt=""/>
  49. <button class="bind-btn"
  50. @click="goBindTenant">登录</button>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import wepy from '@wepy/core';
  56. import { mapState } from '@wepy/x';
  57. import store from '@/store';
  58. import config from '@/config';
  59. import { wxLogin,checkLoginNew } from '@/service/user';
  60. wepy.page({
  61. store,
  62. data: {
  63. h5StaticPath: config.h5StaticPath,
  64. isActivated: 0
  65. },
  66. computed: {
  67. ...mapState({ token: state => state.user.token }),
  68. ...mapState({ isActivated: state => state.user.isActivated })
  69. },
  70. onLoad() {},
  71. onShow() {
  72. if (this.isActivated && this.isActivated == 1) {
  73. // this.goHome();
  74. checkLoginNew().then(res => {
  75. console.log(res);
  76. if (res.data && res.data.isActivated == 1) {
  77. this.goHome();
  78. } else {
  79. // wx.navigateTo({
  80. // url: '/pages/index'
  81. // });
  82. }
  83. });
  84. } else {
  85. this.checkTenantRegist();
  86. }
  87. },
  88. methods: {
  89. goBindTenant() {
  90. this.goAuth();
  91. },
  92. // 判断用户是否认证过
  93. checkTenantRegist() {
  94. wxLogin(1)
  95. .then(res => {
  96. this.isActivated = res.isActivated;
  97. let tokenInfo = {
  98. expireTime: res.expireTime,
  99. startTime: res.startTime,
  100. refreshTokenExpireTime: res.refreshTokenExpireTime,
  101. refreshToken: res.refreshToken
  102. };
  103. store.commit('setToken', res.token);
  104. store.commit('setActivated', res.isActivated);
  105. store.commit('setTokenInfo', tokenInfo);
  106. if (this.isActivated && this.isActivated == 1) {
  107. // 已经激活
  108. store.commit('setTokenInfo', res.tokenUser);
  109. this.goHome();
  110. } else if (this.isActivated == 0) {
  111. // 未激活
  112. // this.goAuth();
  113. } else {
  114. // 作废
  115. }
  116. })
  117. .catch(error => {});
  118. },
  119. goHome() {
  120. wx.navigateTo({
  121. url: '/packagesEnv/pages/home/index'
  122. });
  123. // wx.navigateTo({
  124. // url: '/pages/auth/index'
  125. // });
  126. },
  127. goAuth() {
  128. console.log('被点击了');
  129. wx.navigateTo({
  130. url: '/pages/auth/index'
  131. });
  132. }
  133. },
  134. created() {}
  135. });
  136. </script>
  137. <config>
  138. {
  139. navigationBarTitleText: '登录',
  140. navigationStyle:"custom",
  141. usingComponents: {
  142. 'page-top-bar': '~@/components/common/page-top-bar',
  143. },
  144. }
  145. </config>