Browse Source

fix:小程序bug修改

chenzhen2 1 year ago
parent
commit
5c5421ac5d
4 changed files with 112 additions and 86 deletions
  1. 100 76
      src/pages/auth/index.wpy
  2. 4 3
      src/pages/bindTenant/index.wpy
  3. 7 3
      src/pages/index.wpy
  4. 1 4
      src/service/user.js

+ 100 - 76
src/pages/auth/index.wpy

@@ -1,87 +1,107 @@
 <style lang="less">
-.login-box {
-  padding-top: 40px;
-  .avatar-wrapper {
-    padding: 0px;
-    width: 196rpx;
-    height: 196rpx;
-    border-radius: 50%;
-    image {
+page {
+  width: 100%;
+  height: 100%;
+}
+.auth-box {
+  box-sizing: border-box;
+  padding-top: 136rpx;
+  width: 100%;
+  height: 100%;
+  .login-box {
+    padding-top: 40px;
+    .avatar-wrapper {
+      position: relative;
+      padding: 0px;
       width: 196rpx;
       height: 196rpx;
       border-radius: 50%;
+      background: transparent;
+      image {
+        position: absolute;
+        left: 0;
+        top: 0;
+        width: 198rpx;
+        height: 198rpx;
+        z-index: 333;
+        border-radius: 50%;
+      }
     }
-  }
-  .avatar-tip {
-    text-align: center;
-    font-family: PingFang SC;
-    font-size: 28rpx;
-    font-weight: 400;
-    line-height: 44rpx;
-    text-align: center;
-  }
-
-  .bind-btn-box {
-    position: fixed;
-    bottom: 228rpx;
-    left: 50%;
-    transform: translateX(-50%);
-    .bind-btn {
-      width: 548rpx;
-      height: 100rpx;
-      line-height: 100rpx;
-      border-radius: 56rpx;
-      background: rgba(61, 203, 204, 1);
-      border: none;
-      font-family: PingFang SC;
-      font-size: 32rpx;
-      font-weight: 400;
-      letter-spacing: 0px;
+    .avatar-tip {
       text-align: center;
-      color: #fff;
-    }
-    .bind-btn-tip {
-      //styleName: 14/常规;
       font-family: PingFang SC;
-      padding-top: 32rpx;
       font-size: 28rpx;
       font-weight: 400;
       line-height: 44rpx;
       text-align: center;
-      color: rgba(139, 148, 158, 1);
     }
-  }
 
-  .home-btn {
-    margin-top: 240rpx;
-    width: 548rpx;
-    height: 100rpx;
-    line-height: 100rpx;
-    border-radius: 56rpx;
-    border: 1px solid rgba(61, 203, 204, 1);
+    .bind-btn-box {
+      position: fixed;
+      bottom: 228rpx;
+      left: 50%;
+      transform: translateX(-50%);
+      .bind-btn {
+        width: 548rpx;
+        height: 100rpx;
+        line-height: 100rpx;
+        border-radius: 56rpx;
+        background: rgba(61, 203, 204, 1);
+        border: none;
+        font-family: PingFang SC;
+        font-size: 32rpx;
+        font-weight: 400;
+        letter-spacing: 0px;
+        text-align: center;
+        color: #fff;
+      }
+      .bind-btn-tip {
+        //styleName: 14/常规;
+        font-family: PingFang SC;
+        padding-top: 32rpx;
+        font-size: 28rpx;
+        font-weight: 400;
+        line-height: 44rpx;
+        text-align: center;
+        color: rgba(139, 148, 158, 1);
+      }
+    }
+
+    .home-btn {
+      margin-top: 240rpx;
+      width: 548rpx;
+      height: 100rpx;
+      line-height: 100rpx;
+      border-radius: 56rpx;
+      border: 1px solid rgba(61, 203, 204, 1);
+    }
   }
 }
 </style>
 <template>
- <div class="login-box">
-  <button class="avatar-wrapper"
-    v-if="canIUseGetUserProfile"
-    open-type="chooseAvatar" 
-    bind:chooseavatar="onChooseAvatar">
-    <image class="avatar" src="{{avatarUrl}}"/>
-  </button>  
-  <div class="avatar-tip" v-if="canIUseGetUserProfile">可点击获取头像</div>
-  <div class="bind-btn-box">
-   <button class="bind-btn"
-   open-type="getPhoneNumber"
-   bindgetphonenumber="phonenumberAuth"
-   >微信手机号认证</button>
-   <!-- @click="goBindTenant" -->
-   <!-- bindgetphonenumber="phonenumberAuth" -->
-   <div class="bind-btn-tip">确保是入职公司使用的手机号</div>
+<div class="auth-box" :style="{'background-image': 'url('+h5StaticPath+'/page-home/homeBack.jpg)'}">
+  <page-top-bar title=" " 
+  titleColor="#1B2129"></page-top-bar>
+  <div class="login-box">
+    <button class="avatar-wrapper"
+      v-if="canIUseGetUserProfile"
+      open-type="chooseAvatar" 
+      bind:chooseavatar="onChooseAvatar">
+      <image class="avatar" src="{{avatarUrl}}"/>
+    </button>  
+    <div class="avatar-tip" v-if="canIUseGetUserProfile">可点击获取头像</div>
+    <div class="bind-btn-box">
+    <button class="bind-btn"
+    open-type="getPhoneNumber"
+    bindgetphonenumber="phonenumberAuth"
+    >微信手机号认证</button>
+    <!-- @click="goBindTenant" -->
+    <!-- bindgetphonenumber="phonenumberAuth" -->
+    <div class="bind-btn-tip">确保是入职公司使用的手机号</div>
+    </div>
+    <!-- <button class="home-btn" @click="goHome">首页</button> -->
   </div>
-  <!-- <button class="home-btn" @click="goHome">首页</button> -->
- </div>
+</div>
 </template>
 
 <script>
@@ -96,14 +116,15 @@ let defaultAvatarUrl =
 wepy.page({
   store,
   config: {
-    navigationBarTitleText: 'test'
+    navigationBarTitleText: 'test',
   },
   data: {
     nicknameValue: '',
+    h5StaticPath: config.h5StaticPath,
     avatarUrl: defaultAvatarUrl,
     msg: '测试数据',
     canIUseGetUserProfile: false,
-    userInformation: wx.getStorageSync('userInformation')
+    userInformation: wx.getStorageSync('userInformation'),
   },
   onLoad() {
     if (wx.getUserProfile) {
@@ -125,13 +146,13 @@ wepy.page({
           console.log(res.data);
           that.avatarUrl = 'data:image/png;base64,' + res.data;
           setAvatar(that.avatarUrl);
-        }
+        },
       });
     },
     getPageCompanyByPhone() {},
     goHome() {
       wx.navigateTo({
-        url: '/packagesEnv/pages/home/index'
+        url: '/packagesEnv/pages/home/index',
       });
     },
     // 手机号认证
@@ -145,7 +166,7 @@ wepy.page({
     // code 换取手机号
     getHttpPhoneNumber(code) {
       getHttpPhoneNumber(code)
-        .then(res => {
+        .then((res) => {
           let data = res.data || {};
           let phoneNumber = data.purePhoneNumber;
           if (phoneNumber) {
@@ -155,22 +176,25 @@ wepy.page({
             console.log('没获取到手机号');
           }
         })
-        .catch(error => {
+        .catch((error) => {
           console.log('获取手机号的接口失败');
         });
     },
     goBindTenant() {
       console.log('被点击了');
       wx.navigateTo({
-        url: '/pages/bindTenant/index'
+        url: '/pages/bindTenant/index',
       });
-    }
+    },
   },
-  created() {}
+  created() {},
 });
 </script>
 <config>
 {
-navigationBarTitleText: '首页',
+navigationStyle:"custom",
+usingComponents: {
+    'page-top-bar': '~@/components/common/page-top-bar',      
+  },
 }
 </config>

+ 4 - 3
src/pages/bindTenant/index.wpy

@@ -209,8 +209,8 @@ wepy.page({
     // 获取租户数据
     getPageCompanyByPhone() {
       getCompanyDataByPhone().then((res) => {
+        let data = res ;
         console.log(res);
-        let data = res;
         if (data && data.length) {
           this.tenantData = data;
           this.initTentData();
@@ -221,7 +221,7 @@ wepy.page({
             duration: 5000,
             icon: 'none',
           });
-          this.goHome();
+          this.returnLogin();
         }
       });
     },
@@ -234,9 +234,10 @@ wepy.page({
         url: '/packagesEnv/pages/home/index',
       });
     },
+    //  返回登录页面
     returnLogin() {
       wx.navigateTo({
-        url: 'pages/index',
+        url: '/pages/index',
       });
     },
     goEnv() {

+ 7 - 3
src/pages/index.wpy

@@ -11,7 +11,11 @@ page {
 .login {
   width: 100%;
   height: 100%;
-  background: rgba(0, 0, 0.2);
+  // background-size: 100% 100%;
+  background-repeat: no-repeat;
+  background-position: center;
+  background-size: cover;
+  // background: rgba(0, 0, 0.2);
   image {
     position: relative;
     width: 384rpx;
@@ -42,9 +46,9 @@ page {
 </style>
 <template>
   <div class="login-box">
-    <page-top-bar title="" 
+    <page-top-bar title=" " 
   titleColor="#1B2129"></page-top-bar>
-   <div class="login">
+   <div class="login" :style="{'background-image':'url('+h5StaticPath+'/page-bind-tenant/login-bg.jpg)'}">
        <image src="{{h5StaticPath +'/page-bind-tenant/logo_title.png'}}" alt=""/>
        <button class="bind-btn"
         @click.stop="goBindTenant">登录</button>

+ 1 - 4
src/service/user.js

@@ -96,11 +96,8 @@ function wxLogin (type) {
 // 获取租户信息
 function getCompanyDataByPhone() {
   return new Promise((resolve, reject) => {
-    let userPhone = wx.getStorageSync('userPhone');
     let userInfo = store.state.user.userInfo;
-    if (!userPhone) {
-      userPhone = userInfo.phone
-    }
+    let userPhone = userInfo.phone || wx.getStorageSync('userPhone');
     let params = {
       phone: userPhone
     }