绿满眶商城微信小程序-uniapp
zxl
2025-07-30 61032da9f6f840c9c96af090d1810bc7a0734f4b
pages/passport/wechatMPLogin.vue
@@ -3,6 +3,7 @@
      <u-navbar :custom-back="back" title="小程序登录"></u-navbar>
      <u-modal v-model="phoneAuthPopup" :mask-close-able="true" :title="projectName+'商城'"
         :show-confirm-button="false">
         <div class="tips">
            为了更好地用户体验,需要您授权手机号
         </div>
@@ -14,6 +15,9 @@
         <div class="box">
            <view class="logo-info">
               <text class="title">欢迎进入{{ projectName }}</text>
            </view>
            <view>
               <text class="small-title">你好,此服务仅绿满筐会员使用</text>
            </view>
            <view class="small-tips">
               <view>为您提供优质服务,{{ projectName }}需要获取以下信息</view>
@@ -38,6 +42,7 @@
</template>
<script>
   import '@/components/uview-components/uview-ui';
   import {
      mpAutoLogin
   } from "@/api/connect.js";
@@ -110,10 +115,7 @@
               url: `/pages/tabbar/home/index`,
            });
         },
         //获取用户信息
      getUserProfile(e) {
            if(!this.checked){
@@ -131,9 +133,13 @@
            desc: "用于完善会员资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
            success: (res) => {
              console.log("success", res)
           // this.$refs.nicknameInput.focus();
              this.nickName = res.userInfo.nickName;
              this.image = res.userInfo.avatarUrl;
           // 打印微信名称
           console.log("微信昵称:", this.nickName);
              /**
               * 根据公有的配置设置登录方式
               */
@@ -154,6 +160,7 @@
                image,
                nickName,
              }).then((apiRes) => {
              console.log(apiRes)
                storage.setAccessToken(apiRes.data.result.accessToken);
                storage.setRefreshToken(apiRes.data.result.refreshToken);
                // 登录成功
@@ -161,6 +168,7 @@
                  title: "登录成功!",
                  icon: "none",
                });
                //获取用户信息
                getUserInfo().then((user) => {
                  storage.setUserInfo(user.data.result);
@@ -193,7 +201,7 @@
             });
             return;
           }
           let code = this.code;
           let image = this.image;
           let nickName = this.nickName;
@@ -204,6 +212,7 @@
             image,
             nickName,
           }).then((res) => {
              console.log(res)
             storage.setAccessToken(res.data.result.accessToken);
             storage.setRefreshToken(res.data.result.refreshToken);
             // 登录成功
@@ -213,9 +222,10 @@
             });
             //获取用户信息
             getUserInfo().then((user) => {
               console.log(user)
               storage.setUserInfo(user.data.result);
               storage.setHasLogin(true);
               uni.navigateBack({
                 delta: 1,
               });
@@ -283,7 +293,12 @@
   .box {
      margin: 0 32rpx;
   }
   .small-title {
      width: 94%;
      padding: 20rpx;
      font-size: 34rpx;
      margin: 0 0 20rpx;
   }
   /* 文字提示*/
   .small-tips {
      width: 94%;