绿满眶商城微信小程序-uniapp
peng
2025-07-29 7234a8bfdc91571bb1e5d4fad66cdd5a445712ee
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>
@@ -15,6 +16,7 @@
            <view class="logo-info">
               <text class="title">欢迎进入{{ projectName }}</text>
            </view>
            <view class="small-tips">
               <view>为您提供优质服务,{{ projectName }}需要获取以下信息</view>
               <view>您的公开信息(昵称、头像)</view>
@@ -38,6 +40,7 @@
</template>
<script>
   import '@/components/uview-components/uview-ui';
   import {
      mpAutoLogin
   } from "@/api/connect.js";
@@ -110,10 +113,7 @@
               url: `/pages/tabbar/home/index`,
            });
         },
         //获取用户信息
      getUserProfile(e) {
            if(!this.checked){
@@ -131,9 +131,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 +158,7 @@
                image,
                nickName,
              }).then((apiRes) => {
              console.log(apiRes)
                storage.setAccessToken(apiRes.data.result.accessToken);
                storage.setRefreshToken(apiRes.data.result.refreshToken);
                // 登录成功
@@ -161,6 +166,7 @@
                  title: "登录成功!",
                  icon: "none",
                });
                //获取用户信息
                getUserInfo().then((user) => {
                  storage.setUserInfo(user.data.result);
@@ -193,7 +199,7 @@
             });
             return;
           }
           let code = this.code;
           let image = this.image;
           let nickName = this.nickName;
@@ -204,6 +210,7 @@
             image,
             nickName,
           }).then((res) => {
              console.log(res)
             storage.setAccessToken(res.data.result.accessToken);
             storage.setRefreshToken(res.data.result.refreshToken);
             // 登录成功
@@ -213,6 +220,7 @@
             });
             //获取用户信息
             getUserInfo().then((user) => {
               console.log(user)
               storage.setUserInfo(user.data.result);
               storage.setHasLogin(true);