Sfoglia il codice sorgente

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

zhouyy 4 mesi fa
parent
commit
30d9c170bf

+ 2 - 4
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/login.vue

@@ -18,7 +18,8 @@
 import { ref } from "vue";
 import { useLifecycle } from "@hooks/useCommon.js";
 import { LOGIN_INTERFACE, USER_ID_LOGIN, WE_CHAT_LOGIN, GET_MESSAGE_LIST } from "@hooks/useApi.js";
-import { addressRedirection, obtainEnterpriseWeChatParameters } from "@utility/corpWXparam"
+// import { addressRedirection, obtainEnterpriseWeChatParameters } from "@utility/corpWXparam"
+import { addressRedirection } from "@utility/corpWXparam"
 import useShowToast from "../hooks/useToast";
 import useRouterStore from "@store/useRouterStore.js";
 import useInfoStore from "@store/useInfoStore.js";
@@ -147,9 +148,6 @@ function loginProcessing(data = {}) {
   router.switchTabBar({
     pathName: 'home',
     success: function () {
-      if (isCorpWX.value) {
-        obtainEnterpriseWeChatParameters(data)
-      }
       toastSuccess('登陆成功')
       setTimeout(() => {
         getMessageList()

+ 1 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/pageComponents/contacts/addEditor.vue

@@ -37,7 +37,7 @@ function onSubmit() {
       return
     }
     toastLoading('保存中', 0)
-    const url = props.formValue.id ? '/contacts/updateContacts' : CUSTOMER_ADDED_EDITOR
+    const url = props.formValue.id ? '/contacts/updateContacts' : CONTACT_PERSON_ADDITION_EDITOR
     requests.post(url, { ...props.formValue, ...res.data }).then(() => {
       toastSuccess('保存成功')
       setTimeout(() => {

+ 65 - 0
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/pages/tabbar/home/index.vue

@@ -86,9 +86,74 @@ function returnImageAddress(rows) {
   return row.homeImage
 }
 
+function obtainEnterpriseWeChatParameters(data = {}) {
+  const token = data.id
+  const curUrl = window.location.href.split('#')[0]
+  console.log(wx, '开始调用接口')
+  requests.post('/wxcorp/getCorpWXConfig', { url: curUrl, token }).then((res) => {
+    console.log(res, '<====== 返回的参数 /wxcorp/getCorpWXConfig')
+    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']
+    })
+
+    wx.ready(function () {
+      // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
+      requests.post('/wxcorp/getCorpWXAgentConfig', { url: curUrl, token }).then((res) => {
+        console.log(res, '<====== 返回的参数 /wxcorp/getCorpWXAgentConfig')
+        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', 'openThirdAppServiceChat', 'openAppManage'], //必填,传入需要使用的接口名称
+          success: function (result) {
+            console.log(result, '《+========== 成功1')
+            //  wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
+            window.WWOpenData.bind(document.querySelector('ww-open-data'))
+          },
+          fail: function (res) {
+            console.log(res, '<===== 失败1')
+            if (res.errMsg.indexOf('function not exist') > -1) {
+              alert('版本过低请升级')
+            }
+          },
+        })
+      }).catch(err => {
+        console.log(err, '<===== 失败2')
+        if (err.errMsg.indexOf('function not exist') > -1) {
+          alert('版本过低请升级')
+        }
+      })
+    })
+    wx.error(function (res) {
+      // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
+      // alert('wxConfig发生异常:'+JSON.stringify(res));
+      // 企业第一次授权安装进入后会报not in reliable domain的错误,刷新后正常
+      location.reload();
+    });
+  }).catch(err => {
+    alert(err);
+  })
+}
+
 useLifecycle({
   load: () => {
 
+  },
+  init: () => {
+    console.log('执行一次')
+    const currentEnvironment = navigator.userAgent.toLowerCase();
+    const isCorpWX = currentEnvironment.indexOf("wxwork") > 0 ? true : false
+    if(isCorpWX) {
+      obtainEnterpriseWeChatParameters(userInfo.userInfo)
+    }
   }
 });
 

+ 3 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/src/utility/corpWXparam.js

@@ -1,7 +1,7 @@
 import requests from "@common/requests";
 
 const wxTokenUrl = 'http://mobworktime.ttkuaiban.com/api/wechat/loginByWXCode'
-const coprWxTokenUrl = 'http://worktime.ttkuaiban.com/api/corpWXAuth'
+const coprWxTokenUrl = 'https://mobcrm.ttkuaiban.com/api/corpWXAuth'
 
 export const WX_APPID = 'wx749c84daac654e1e' // 微信appId
 // export const CORP_WX_APPID = 'ww4e237fd6abb635af' // 企业微信appId
@@ -13,6 +13,7 @@ export const CORP_WX_APPID = 'wwdd1137a65ce0fc87' // 企业微信appId
  * @returns 企业微信重定向地址
  */
 export function addressRedirection(isCorpWx = false) {
+  console.log(wx, '<==== wx')
   const appId = isCorpWx ? CORP_WX_APPID : WX_APPID
   const url = isCorpWx ? coprWxTokenUrl : wxTokenUrl
   return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodeURI(url)}&response_type=code&scope=snsapi_base&state=0#wechat_redirect`
@@ -25,6 +26,7 @@ export function addressRedirection(isCorpWx = false) {
 export function obtainEnterpriseWeChatParameters(data = {}) {
   const token = data.id
   const curUrl = window.location.href.split('#')[0]
+  console.log('开始调用接口')
   requests.post(`/wxcorp/getCorpWXConfig`, { url: curUrl, token }).then((res) => {
     console.log(res, '<====== 返回的参数 /wxcorp/getCorpWXConfig')
     wx.config({

+ 1 - 1
fhKeeper/formulahousekeeper/customerBuler-crm-h5/vite.config.js

@@ -43,7 +43,7 @@ export default defineConfig({
     }
   },
   build: {
-    chunkSizeWarningLimit: 1600,
+    chunkSizeWarningLimit: 1600
   },
   vue: {
     compilerOptions: {