ソースを参照

添加获取蓝信用户信息接口

aaa 4 年 前
コミット
03d0276ad4
2 ファイル変更28 行追加1 行削除
  1. 3 1
      src/api/modules/user.js
  2. 25 0
      src/views/home/index.vue

+ 3 - 1
src/api/modules/user.js

@@ -25,6 +25,8 @@ export default {
     // 查看总榜
     JTXT_GET_EVENTS_USERNAME_DATE: "/events/{userName}/{date}",
     // 获取蓝信签名
-    JTXT_GET_LAN_XIN_SIGNATURE: "/lanXin/getJsApiSignature"
+    JTXT_GET_LAN_XIN_SIGNATURE: "/lanXin/getJsApiSignature",
+    // 获取蓝信用户信息
+    JTXT_GET_LAN_XIN_USER_INFO: "/lanXin/getUserInfo"
   }
 };

+ 25 - 0
src/views/home/index.vue

@@ -93,6 +93,7 @@ export default {
   created() {
     this.initFun();
     this.getLanXinSignature();
+    this.getLanXinCode();
   },
   watch: {
     // 监听:首页切换tab的下标
@@ -225,6 +226,30 @@ export default {
           this.$store.commit("toggleLoading", false);
         });
     },
+    // 获取蓝信免登陆授权吗
+    getLanXinCode() {
+      console.log("getLanXinCode--code-");
+      lx.biz
+        .getAuthCode({
+          appId: process.env.VUE_APP_LANXIN_APPID
+        })
+        .then(res => {
+          let authCode = res.authCode;
+          this.getLanXinUserInfo(authCode);
+        });
+    },
+    // 获取蓝信用户信息
+    getLanXinUserInfo(authCode) {
+      let params = { authCode: authCode };
+      this.$_http
+        .get(this.$_API.JTXT_GET_LAN_XIN_USER_INFO, { params })
+        .then(res => {
+          console.log("蓝信用户信息---" + JSON.stringify(res));
+        })
+        .catch(() => {
+          this.$store.commit("toggleLoading", false);
+        });
+    },
     // 蓝信API调用例子
     lanXinTest() {
       lx.biz.chooseContacts(