index.wpy 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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-size: 100% 100%;
  15. background-repeat: no-repeat;
  16. background-position: center;
  17. background-size: cover;
  18. // background: rgba(0, 0, 0.2);
  19. image {
  20. position: relative;
  21. width: 384rpx;
  22. height: 144rpx;
  23. top: 336rpx;
  24. left: 50%;
  25. transform: translateX(-50%);
  26. }
  27. .bind-btn {
  28. position: fixed;
  29. bottom: 200rpx;
  30. left: 50%;
  31. transform: translateX(-50%);
  32. width: 548rpx;
  33. height: 100rpx;
  34. line-height: 100rpx;
  35. border-radius: 56rpx;
  36. background: rgba(61, 203, 204, 1);
  37. border: none;
  38. font-family: PingFang SC;
  39. font-size: 32rpx;
  40. font-weight: 400;
  41. letter-spacing: 0px;
  42. text-align: center;
  43. color: #fff;
  44. }
  45. }
  46. </style>
  47. <template>
  48. <div class="login-box">
  49. <page-top-bar title=" "
  50. titleColor="#1B2129"></page-top-bar>
  51. <div class="login" :style="{'background-image':'url('+h5StaticPath+'/page-bind-tenant/login-bg.jpg)'}">
  52. <image src="{{h5StaticPath +'/page-bind-tenant/logo_title.png'}}" alt=""/>
  53. <button class="bind-btn"
  54. @click.stop="goBindTenant">登录</button>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import wepy from '@wepy/core';
  60. import { mapState } from '@wepy/x';
  61. import store from '@/store';
  62. import config from '@/config';
  63. import { wxLogin } from '@/service/user';
  64. wepy.page({
  65. store,
  66. data: {
  67. h5StaticPath: config.h5StaticPath,
  68. isActivated: 0,
  69. },
  70. computed: {
  71. ...mapState({
  72. token: (state) => state.user.token,
  73. isActivated: (state) => state.user.isActivated,
  74. }),
  75. },
  76. onLoad() {
  77. if (this.isActivated && this.isActivated == 1) {
  78. this.goHome();
  79. } else {
  80. console.log('this.isActivated===45', this.isActivated);
  81. this.checkTenantRegist();
  82. }
  83. },
  84. onShow() {},
  85. methods: {
  86. goBindTenant() {
  87. // wx.navigateTo({
  88. // url: '/pages/bindTenant/index',
  89. // });
  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('setUserInfo', 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. // console.log("gohome");
  121. wx.navigateTo({
  122. url: '/packagesEnv/pages/home/index',
  123. });
  124. },
  125. goAuth() {
  126. console.log('被点击了');
  127. wx.navigateTo({
  128. url: '/pages/auth/index',
  129. });
  130. },
  131. },
  132. created() {},
  133. });
  134. </script>
  135. <config>
  136. {
  137. navigationBarTitleText: '登录',
  138. navigationStyle:"custom",
  139. usingComponents: {
  140. 'page-top-bar': '~@/components/common/page-top-bar',
  141. },
  142. }
  143. </config>