-
zhangwei
2024-08-14 ff120d19df422dc6aeb7a35e144d726582aef8f8
src/pages/login/index.vue
@@ -1,15 +1,14 @@
<template>
   <view>
      <view class="wrap">
         <image src="@/static/logo.png" mode="widthFix" class="tip_img"></image>
         <view class="login_tip">
            为了提供更优质的服务,需要获取您的头像和昵称。
         </view>
         <view class="login_btn">
            <!-- #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU -->
            <button v-if="canIUseGetUserProfile" type="primary" class="uni-tip-button" @click="login">授权并登录</button>
            <button v-else type="primary" open-type="getUserInfo" @getuserinfo="login"
            <!-- <button v-if="canIUseGetUserProfile" type="primary" class="uni-tip-button" @click="login">授权并登录</button> -->
            <button  type="primary" open-type="getUserInfo" @getuserinfo="login"
               class="uni-tip-button">授权并登录</button>
            <view class="no_login" @click="back">
               暂不授权
@@ -17,10 +16,8 @@
            <!-- #endif  -->
            <checkbox-group @change="changeAgree">
               <view class="regisiter-agreement">
                  <label>
                     <checkbox value="1" :checked="isChecked" color="#35A6FF" style="transform:scale(0.7)" />
                     已阅读并同意以下协议
                     <text class="color-base-text" @click.stop="openPopup(1)">《用户服务协议》</text>和 <text
                        class="color-base-text" @click.stop="openPopup(2)">《隐私政策》</text>
@@ -103,8 +100,7 @@
               title: '加载中',
               mask: true
            })
            this.$api.sendRequest({
               url: '/api.php/user/info',
            this.$api.temLogin({
               data: {
                  uid: uni.getStorageSync('authInfo').id
               },
@@ -126,8 +122,7 @@
                              uni.removeStorageSync('wx_openid_set');
                              uni.removeStorageSync('source_member');
                              uni.removeStorageSync('authInfo');
                              this.$api.sendRequest({
                                 url: "/api.php/user/is_perfect",
                              this.$api.temLogin({
                                 data: {
                                    uid: res.data.id,
                                 },
@@ -238,8 +233,7 @@
               if (this.isSub) return;
               this.isSub = true;
               this.$api.sendRequest({
                  url: '/api.php/login/binding_mobile',
               this.$api.temLogin({
                  data,
                  success: res => {
                     if (res.code == 1) {
@@ -257,8 +251,7 @@
                                 uni.removeStorageSync('wx_openid_set');
                                 uni.removeStorageSync('source_member');
                                 uni.removeStorageSync('authInfo');
                                 this.$api.sendRequest({
                                    url: "/api.php/user/is_perfect",
                                 this.$api.temLogin({
                                    data: {
                                       uid: res.data.id,
                                    },
@@ -326,26 +319,12 @@
                     avatar: userInfo.avatarUrl,
                  }
                  if (uni.getStorageSync('source_member')) {
                     data.source_member = uni.getStorageSync('source_member')
                  }
                  if (res.code) {
                     this.$api.sendRequest({
                        url: '/api.php/login/wx_login',
                        data,
                        success: res => {
                           if (res.code >= 0) {
                              // if (res.data.openid) this.authInfo.weapp_openid = res.data.openid;
                              // if (res.data.unionid) this.authInfo.wx_unionid = res.data.unionid;
                              typeof callback == 'function' && callback(res);
                           } else {
                              this.$util.showToast({
                                 title: '小程序配置错误'
                              });
                           }
                        }
                     })
                  }
                  // if (uni.getStorageSync('source_member')) {
                  //    data.source_member = uni.getStorageSync('source_member')
                  // }
                  // if (res.code) {
                  //    this.$api.temLogin(data)
                  // }
               },
               fail: () => {
                  this.$util.showToast({
@@ -356,7 +335,7 @@
         },
         login(e) {
            if (!this.isChecked) {
               return this.$util.showToast({
               return this.$common.showToast({
                  title: "请先同意协议"
               })
            }
@@ -399,8 +378,7 @@
                                          uni.removeStorageSync(
                                             'source_member');
                                          uni.removeStorageSync('authInfo');
                                          this.$api.sendRequest({
                                             url: "/api.php/user/is_perfect",
                                          this.$api.temLogin({
                                             data: {
                                                uid: data.data.id,
                                             },
@@ -476,8 +454,7 @@
                                 uni.removeStorageSync('wx_openid_set');
                                 uni.removeStorageSync('source_member');
                                 uni.removeStorageSync('authInfo');
                                 this.$api.sendRequest({
                                    url: "/api.php/user/is_perfect",
                                 this.$api.temLogin({
                                    data: {
                                       uid: data.data.id,
                                    },