Kaynağa Gözat

尝试使用企业微信通讯组件2

Lijy 2 yıl önce
ebeveyn
işleme
9529b9ff6f

+ 64 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/Home.vue

@@ -11,7 +11,10 @@
             <el-col :span="4">
                 <div class="tools" @click.prevent="collapse" style="position: relative;">
                     <i class="fa fa-align-justify"></i>
-                    <span style="position: absolute;width: 350px;left: 60px;">{{user.companyName}}</span>
+                    <span style="position: absolute;width: 350px;left: 60px;">
+                        <span v-if="user.userNameNeedTranslate == '0'">{{user.companyName}}</span>
+                        <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName' :openid='user.companyName'></ww-open-data></span>
+                    </span>
                 </div>
             </el-col>
 
@@ -461,6 +464,60 @@
                     });
                 });
             },
+
+            // 获取企业微信的参数
+            agentConfig() {
+                var curUrl = location.href.split("#")[0];
+                this.http.post("/wxcorp/getCorpWXConfig", {url: curUrl, token: this.user.id}, (res) => {
+                    if (res.code == "ok") {
+                        wx.config({ 
+                        beta: true,
+                        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+                        appId: res.data.appid, // 必填,公众号的唯一标识 
+                        timestamp: res.data.timestamp, // 必填,生成签名的时间戳 
+                        nonceStr: res.data.noncestr, // 必填,生成签名的随机串 
+                        signature: res.data.sign, // 必填,签名,见附录1 
+                        jsApiList: ['chooseImage','previewImage','uploadImage','downloadImage','previewFile','getLocation','agentConfig'] 
+                        });
+                        var that = this;
+                        wx.ready(function(){
+                            // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
+                                that.http.post("/wxcorp/getCorpWXAgentConfig", {url: curUrl, token: that.user.id}, (res) => {
+                                    if (res.code == "ok") {
+                                    console.log()
+                                        wx.agentConfig({
+                                            corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
+                                            agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
+                                            timestamp: res.data.timestamp, // 必填,生成签名的时间戳
+                                            nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
+                                            signature: res.data.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
+                                            jsApiList: ['selectExternalContact'], //必填,传入需要使用的接口名称
+                                            success: function (result) {
+                                                console.log(result, '请求微信成功')
+                                                console.log(window, 'window')
+                                                //  wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
+                                                window.WWOpenData.bind(document.querySelector('ww-open-data'))
+                                            },
+                                            fail: function (res) {
+                                                console.log('查看错误信息', res)
+                                                if (res.errMsg.indexOf('function not exist') > -1) {
+                                                    alert('版本过低请升级')
+                                                }
+                                            },
+                                        })
+                                    }
+                                }, (error) => {
+                                    console.log('查看错误信息' + res)
+                                    if (error.errMsg.indexOf('function not exist') > -1) {
+                                        alert('版本过低请升级')
+                                    }
+                                })
+                        });
+                    }
+                }, (error) => {
+                    console.log(error, '哦耶')
+                })
+            },
         },
         mounted() {
             // console.log(this.$router.options.routes, '看看')
@@ -494,6 +551,12 @@
             } else {
                 this.$router.push("/login");
             }
+
+            // console.log('啊,我被触发了呀')
+            // 获取企业微信参数
+            if(this.user.userNameNeedTranslate == '1') {
+                this.agentConfig()
+            }
         },
     };
 </script>

+ 61 - 106
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -11,7 +11,6 @@
                   </div>
             </div>
             <el-divider style="margin: 0px 0px !important;height:0.5px;"></el-divider>
-            <div v-if="user.companyId == '1081'">{{tixtass}}</div>
             <div class="tree" :style="'height:'+ (tableHeight + 83) + 'px'">
                 <!-- <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" accordion></el-tree> -->
                 <!-- <el-tree :data="data" :props="defaultProps" node-key="id" :expand-on-click-node="false" accordion @node-click="handleNodeClick" :default-expanded-keys="jDarr" @node-expand="jieDian" @node-collapse="shutDown" @current-change="chufa"> -->
@@ -158,7 +157,14 @@
                     </div>
                   </template>
                 </el-table-column>
-                <el-table-column prop="jobNumber" :label="$t('Worknumber')" ></el-table-column>
+                <el-table-column prop="jobNumber" :label="$t('Worknumber')" >
+                    <div>
+                      <div v-if="user.userNameNeedTranslate == 1">
+                        <ww-open-data type='userName' :openid='scope.row.jobNumber'></ww-open-data>
+                      </div>
+                      <div v-else>{{scope.row.jobNumber}}</div>
+                    </div>
+                </el-table-column>
                 <el-table-column prop="phone" :label="$t('shou-ji')" width="120"></el-table-column>
                 <el-table-column prop="departmentName" :label="$t('lable.department')" width="220"></el-table-column>
                 <el-table-column :label="$t('jiao-se')" width="100">
@@ -688,7 +694,6 @@ export default {
   },
   data() {
     return {
-      tixtass: '变化',
       syncMembByCardTimeResultGialog:false,
       syncMembByCardTimeMsg:null,
       editSecret: false,
@@ -2986,109 +2991,59 @@ export default {
             }
           );
     },
-    // 获取企业微信的参数
-    agentConfig() {
-       var curUrl = location.href.split("#")[0];
-       this.http.post("/wxcorp/getCorpWXConfig", {url: curUrl, token: this.user.id}, (res) => {
-          if (res.code == "ok") {
-            this.tixtass = "config,进入"
-            wx.config({ 
-              beta: true,
-              debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-              appId: res.data.appid, // 必填,公众号的唯一标识 
-              timestamp: res.data.timestamp, // 必填,生成签名的时间戳 
-              nonceStr: res.data.noncestr, // 必填,生成签名的随机串 
-              signature: res.data.sign, // 必填,签名,见附录1 
-              jsApiList: ['chooseImage','previewImage','uploadImage','downloadImage','previewFile','getLocation','agentConfig'] 
-            });
-              var that = this;
-              wx.ready(function(){
-                  // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
-                  // if (that.user.companyId == 7) {
-                  //     that.$toast('wx init success==7 ');
-                  //     that.getLocation();
-                  // }
-                  // that.getagentConfigs() 
-                    // var curUrl = location.href.split("#")[0];
-                      // let urls = curUrl + '&debug=1'
-                      that.http.post("/wxcorp/getCorpWXAgentConfig", {url: curUrl, token: that.user.id}, (res) => {
-                          if (res.code == "ok") {
-                          that.tixtass = "处理"
-                          console.log()
-                            wx.agentConfig({
-                                corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
-                                agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
-                                timestamp: res.data.timestamp, // 必填,生成签名的时间戳
-                                nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
-                                signature: res.data.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
-                                jsApiList: ['selectExternalContact'], //必填,传入需要使用的接口名称
-                                success: function (result) {
-                                    console.log(result, '请求微信成功')
-                                    console.log(window, 'window')
-                                    that.tixtass = '注入'
-                                    //  wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
-                                    window.WWOpenData.bind(document.querySelector('ww-open-data'))
-                                },
-                                fail: function (res) {
-                                    that.tixtass = "错误了"
-                                    console.log('查看错误信息', res)
-                                    if (res.errMsg.indexOf('function not exist') > -1) {
-                                        alert('版本过低请升级')
-                                    }
-                                },
-                            })
-                          }
-                      }, (error) => {
-                          console.log('查看错误信息' + res)
-                          this.tixtass = "失败"
-                          if (error.errMsg.indexOf('function not exist') > -1) {
-                              alert('版本过低请升级')
-                          }
-                      })
-              });
-          }
-       }, (error) => {
-          console.log(error, '哦耶')
-       })
-    },
-    getagentConfigs() {
-      this.tixtass = "进了"
-      var curUrl = location.href.split("#")[0];
-      let urls = curUrl + '&debug=1'
-       this.http.post("/wxcorp/getCorpWXAgentConfig", {url: urls, token: this.user.id}, (res) => {
-          if (res.code == "ok") {
-          this.tixtass = "处理"
-          console.log()
-            wx.agentConfig({
-                corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
-                agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
-                timestamp: res.data.timestamp, // 必填,生成签名的时间戳
-                nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
-                signature: res.data.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
-                jsApiList: ['selectExternalContact'], //必填,传入需要使用的接口名称
-                success: function (result) {
-                    console.log(result, '请求微信成功')
-                    this.tixtass = '注入'
-                    //  wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
-                    window.WWOpenData.bind(document.querySelector('ww-open-data'))
-                },
-                fail: function (res) {
-                    this.tixtass = "错误了"
-                    console.log('查看错误信息', res)
-                    if (res.errMsg.indexOf('function not exist') > -1) {
-                        alert('版本过低请升级')
-                    }
-                },
-            })
-          }
-       }, (error) => {
-          console.log('查看错误信息' + res)
-          this.tixtass = "失败"
-          if (error.errMsg.indexOf('function not exist') > -1) {
-              alert('版本过低请升级')
-          }
-       })
-    }
+    // // 获取企业微信的参数
+    // agentConfig() {
+    //    var curUrl = location.href.split("#")[0];
+    //    this.http.post("/wxcorp/getCorpWXConfig", {url: curUrl, token: this.user.id}, (res) => {
+    //       if (res.code == "ok") {
+    //         wx.config({ 
+    //           beta: true,
+    //           debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+    //           appId: res.data.appid, // 必填,公众号的唯一标识 
+    //           timestamp: res.data.timestamp, // 必填,生成签名的时间戳 
+    //           nonceStr: res.data.noncestr, // 必填,生成签名的随机串 
+    //           signature: res.data.sign, // 必填,签名,见附录1 
+    //           jsApiList: ['chooseImage','previewImage','uploadImage','downloadImage','previewFile','getLocation','agentConfig'] 
+    //         });
+    //           var that = this;
+    //           wx.ready(function(){
+    //               // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
+    //                   that.http.post("/wxcorp/getCorpWXAgentConfig", {url: curUrl, token: that.user.id}, (res) => {
+    //                       if (res.code == "ok") {
+    //                       console.log()
+    //                         wx.agentConfig({
+    //                             corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
+    //                             agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
+    //                             timestamp: res.data.timestamp, // 必填,生成签名的时间戳
+    //                             nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
+    //                             signature: res.data.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
+    //                             jsApiList: ['selectExternalContact'], //必填,传入需要使用的接口名称
+    //                             success: function (result) {
+    //                                 console.log(result, '请求微信成功')
+    //                                 console.log(window, 'window')
+    //                                 //  wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
+    //                                 window.WWOpenData.bind(document.querySelector('ww-open-data'))
+    //                             },
+    //                             fail: function (res) {
+    //                                 console.log('查看错误信息', res)
+    //                                 if (res.errMsg.indexOf('function not exist') > -1) {
+    //                                     alert('版本过低请升级')
+    //                                 }
+    //                             },
+    //                         })
+    //                       }
+    //                   }, (error) => {
+    //                       console.log('查看错误信息' + res)
+    //                       if (error.errMsg.indexOf('function not exist') > -1) {
+    //                           alert('版本过低请升级')
+    //                       }
+    //                   })
+    //           });
+    //       }
+    //    }, (error) => {
+    //       console.log(error, '哦耶')
+    //    })
+    // },
   },
   mounted() {
     this.deactiveDate = util.formatDate.format(new Date(), "yyyy-MM-dd");