Browse Source

4.22-1.2.41 web端技术信用新增社区影响力模块-与接口调通

bruce 5 years ago
parent
commit
2ee4b845d2
2 changed files with 90 additions and 13 deletions
  1. 58 6
      components/credit/_social.vue
  2. 32 7
      components/credit/data.js

+ 58 - 6
components/credit/_social.vue

@@ -3,10 +3,13 @@
   <section class="app__bg_w app__mt_10">
     <div class="app__f_r app__al_c app__h_50 app__pl_20 app__pr_20 app__fs_15" v-for="social in socials">
       <img :src="social.icon" class="app__img_xs"/>
-      <a class="app__f_g_1 app__ml_10">{{social.name}}</a>
+      <a :href="social.targetUrl" class="app__f_g_1">
+        <a class="app__ml_10 app__fc_666 app__cursor_point">{{social.name}}</a>
+        <a class=" app__ml_20">{{social.account}}</a>
+      </a>
 
       <button class="app__w_70 app__h_30 app__f_r app__al_c app__jf_c app_fc_w app_br_5" @click="goBind(social)"
-              v-bind:class="!social.status || social.status== 0 ? 'app_bg_919AA7' : 'app__bg_308EFF'">{{social.bindStatus==1 ?"已绑定":"未绑定"}}
+              v-bind:class="!social.account ? 'app_bg_919AA7' : 'app__bg_308EFF'" v-if="social.tag !='jishuin'">{{social.account ?"已绑定":"未绑定"}}
       </button>
     </div>
 
@@ -49,6 +52,8 @@
       this.needLogin();
       this.socials = data.socialLines;
       console.log("socials", this.socials);
+
+      this.getData();
     },
     methods: {
       jumpTo(url) {
@@ -57,11 +62,58 @@
       goBind(social) {
         console.log("social", social);
         //未绑定
-        if (!social.status || social.status == 0) {
-          // `proginn://recruit/edit?id=${recruitId}`;
-          location.href = `${this.$store.state.domainConfig.siteUrl}/setting/snsimport`;
+        switch (social.tag) {
+          case "wechat":
+            break;
+          case "jishuin":
+            location.href = social.targetUrl;
+            break;
+          default:
+            if (!social.account) {
+              location.href = `${this.$store.state.domainConfig.siteUrl}/setting/snsimport`;
+            } else {
+              location.href = social.targetUrl;
+            }
+            break;
+
         }
-      }
+
+      },
+      /**
+       * 获取社区数据
+       * @return {Promise<void>}
+       */
+      async getData() {
+        const res = await this.$axios.$post("/api/SocialNetwork/getList");
+        console.log(res);
+        if (res.status == 1) {
+          const data = !res.data ? [] : res.data;
+          this.socials.forEach(so => {
+            so.account = data[so.tag] || "";
+            switch (so.tag) {
+              case"wechat":
+
+                break;
+              case "jishuin":
+                const {userinfo} = this.$store.state || {};
+                //检查登录
+                if (!userinfo || !userinfo.uid) {
+                  this.$message.info("请先登录!");
+                  location.href =
+                    "/?loginbox=show&next=" + encodeURIComponent(location.href);
+                }
+                so.targetUrl = this.$store.state.domainConfig.jishuinUrl + "/u/" + userinfo.uid;
+                console.log("jishuin target url", so.targetUrl);
+                break;
+              default:
+                so.targetUrl = so.account ? so.targetUrl + so.account : "javascript:void(0)";
+                break;
+
+            }
+          });
+        }
+        console.log(this.socials);
+      },
     }
   }
 </script>

+ 32 - 7
components/credit/data.js

@@ -201,46 +201,71 @@ export default {
     {
       id: 0,
       name: "技术圈",
-      icon: require('@/assets/img/sign/jishuinIcon@2x.png')
+      tag: "jishuin",
+      account: "",
+      icon: require('@/assets/img/sign/jishuinIcon@2x.png'),
+      // targetUrl: this.$store.state.domainConfig.jishuinUrl + "/u/"
     },
     {
       id: 1,
       name: "Github",
-      icon: require('@/assets/img/sign/github.png')
+      tag: "github",
+      account: "",
+      icon: require('@/assets/img/sign/github.png'),
+      targetUrl: 'https://github.com/'
     },
     {
       id: 2,
       name: "Gitee",
-      icon: require('@/assets/img/sign/github.png')
+      tag: "gitee",
+      account: "",
+      icon: require('@/assets/img/sign/github.png'),
+      targetUrl: ""
     },
     {
       id: 3,
       name: "CSDN",
-      icon: require('@/assets/img/sign/csdn.png')
+      tag: "csdn",
+      account: "",
+      icon: require('@/assets/img/sign/csdn.png'),
+      targetUrl: "https://blog.csdn.net/"
     },
     {
       id: 4,
       name: "公众号",
-      icon: require('@/assets/img/sign/wechat.png')
+      tag: "wechat",
+      account: "",
+      icon: require('@/assets/img/sign/wechat.png'),
+      targetUrl: "javascript:void(0)"
     },
     {
       id: 5,
       name: "掘金",
-      icon: require('@/assets/img/sign/juejin.png')
+      tag: "juejin",
+      account: "",
+      icon: require('@/assets/img/sign/juejin.png'),
+      targetUrl: 'https://www.juejin.im/user/'
     },
     {
       id: 6,
       name: "RSS订阅",
+      tag: "rss",
+      account: "",
       icon: require('@/assets/img/sign/juejin.png')
     },
     {
       id: 7,
       name: "Dribbble",
-      icon: require('@/assets/img/sign/dribbble.png')
+      tag: "dribbble",
+      account: "",
+      icon: require('@/assets/img/sign/dribbble.png'),
+      targetUrl: "https://dribbble.com/"
     },
     {
       id: 7,
       name: "ZCOOL",
+      tag: "zcool",
+      account: "",
       icon: require('@/assets/img/sign/dribbble.png')
     },
   ],