tangning 1 рік тому
батько
коміт
1b10b13f46
3 змінених файлів з 79 додано та 64 видалено
  1. 1 64
      src/App.vue
  2. 2 0
      src/i18n/lang/zh-cn.ts
  3. 76 0
      src/views/feedback/index.vue

+ 1 - 64
src/App.vue

@@ -8,7 +8,6 @@
   import { useCookies } from '@vueuse/integrations/useCookies';
   import { useRouter } from 'vue-router';
   import { useI18n } from 'vue-i18n';
-  import jsonp from 'jsonp'
   const userStore = useUserStore();
   const { t } = useI18n();
   const wxOpenId = computed(() => {
@@ -37,7 +36,6 @@
       useCookies().set('wxOpenId', '');
       getCodeApi(123);
     }
-    wxShare();
   });
   function getUrlKey(name) {
     //获取url 参数
@@ -47,67 +45,6 @@
       ) || null
     );
   }
-  function wxShare() {
-    wxShare () {
-      
-      let url = window.location.href.split('#')[0]
-      if(window.location.ancestorOrigins){url = window.location.ancestorOrigins[0]}
-      jsonp('https://www.4dage.com/wechat/jssdk/share/?uri=' +
-  window.escape(url) + '&name=厦门四维时代微信公众号', 'success_jsonp', function (err, data) {
-        if (err) {
-          console.err(err)
-        } else {
-          console.log(wx)
-          wx.config({
-            debug: false, // 开启调试模式
-            appId: data.appId,
-            timestamp: data.timestamp,
-            nonceStr: data.nonceStr,
-            signature: data.signature,
-            jsApiList: ['checkJsApi',
-              'onMenuShareTimeline',
-              'onMenuShareAppMessage',
-              'onMenuShareQQ',
-              'onMenuShareWeibo',
-              'hideMenuItems',
-              'showMenuItems',
-              'hideAllNonBaseMenuItem',
-              'showAllNonBaseMenuItem',
-              'translateVoice',
-              'startRecord',
-              'stopRecord',
-              'onRecordEnd',
-              'playVoice',
-              'pauseVoice',
-              'stopVoice',
-              'uploadVoice',
-              'downloadVoice']
-          })
-        }
-        wx.error(function (err) {
-          console.log(err)
-        })
-        wx.ready(function () {
-          var shareData = {
-            title: '四维看看', //  标题
-            desc: '可将线下场景自动转为线上四维场景。好用不贵,全球百万用户首选', //  描述
-            link: window.location.href, //  分享的URL,必须和当前打开的网页的URL是一样的
-            imgUrl: 'https://4dkk.4dage.com/FDKKIMG/icon/kankan_icon180.png', //  缩略图地址
-            success: function () {
-
-            },
-            cancel: function () {
-
-            }
-          }
-          wx.onMenuShareAppMessage(shareData)
-          wx.onMenuShareTimeline(shareData)
-          wx.onMenuShareQQ(shareData)
-          wx.onMenuShareQZone(shareData)
-        })
-      })
-    }
-  }
   function getCodeApi(state) {
     //获取code
     console.log('getCodeApi');
@@ -115,7 +52,7 @@
     let scope = 'snsapi_base'; //snsapi_userinfo   //静默授权 用户无感知
     let appid = 'wxac3d59ea82d9b82a';
     let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`;
-    // window.location.replace(url);
+    window.location.replace(url);
   }
 </script>
 <style>

+ 2 - 0
src/i18n/lang/zh-cn.ts

@@ -18,6 +18,8 @@ export const lang: langType = {
     cssMultiLanguage: 'css图片多语言',
   },
   feedback: {
+    shareTitle: '四维时代用户反馈',
+    shareSubTitle: '诚挚的邀您填写,期待您的宝贵意见。(旁边用四维时代logo)',
     upload: '上传',
     uploadsuccess: '上传成功',
     submitSuccess: '提交成功',

+ 76 - 0
src/views/feedback/index.vue

@@ -24,6 +24,7 @@
   // import { Toast } from '@nutui/nutui';
   import { getAllByTypeId, feedbackAdd, getDefaultAddress } from '/@/api/feedback';
   // import { setLang } from '/@/i18n';
+  import jsonp from 'jsonp';
   import { useI18n } from 'vue-i18n';
   const emit = defineEmits(['setActive']);
   const submitPc = ref(null);
@@ -45,6 +46,77 @@
     softwareOptionId: [],
     hardwareOptionId: [],
   });
+  function isWeChat() {
+    //window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息,这个属性可以用来判断浏览器类型
+    var ua = window.navigator.userAgent.toLowerCase();
+    //通过正则表达式匹配ua中是否含有MicroMessenger字符串
+    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
+      return true;
+    } else {
+      return false;
+    }
+  }
+  function wxShare() {
+    let url = window.location.href.split('#')[0];
+    if (window.location.ancestorOrigins) {
+      url = window.location.ancestorOrigins[0];
+    }
+    jsonp(
+      'https://www.4dage.com/wechat/jssdk/share/?uri=' + window.escape(url) + '&name=厦门四维时代微信公众号',
+      'success_jsonp',
+      function (err, data) {
+        if (err) {
+          console.err(err);
+        } else {
+          console.log(wx);
+          wx.config({
+            debug: false, // 开启调试模式
+            appId: data.appId,
+            timestamp: data.timestamp,
+            nonceStr: data.nonceStr,
+            signature: data.signature,
+            jsApiList: [
+              'checkJsApi',
+              'onMenuShareTimeline',
+              'onMenuShareAppMessage',
+              'onMenuShareQQ',
+              'onMenuShareWeibo',
+              'hideMenuItems',
+              'showMenuItems',
+              'hideAllNonBaseMenuItem',
+              'showAllNonBaseMenuItem',
+              'translateVoice',
+              'startRecord',
+              'stopRecord',
+              'onRecordEnd',
+              'playVoice',
+              'pauseVoice',
+              'stopVoice',
+              'uploadVoice',
+              'downloadVoice',
+            ],
+          });
+        }
+        wx.error(function (err) {
+          console.log(err);
+        });
+        wx.ready(function () {
+          var shareData = {
+            title: '四维时代用户反馈', //  标题
+            desc: '诚挚的邀您填写,期待您的宝贵意见。(旁边用四维时代logo)', //  描述
+            link: window.location.href, //  分享的URL,必须和当前打开的网页的URL是一样的
+            imgUrl: 'https://4dkk.4dage.com/FDKKIMG/icon/kankan_icon180.png', //  缩略图地址
+            success: function () {},
+            cancel: function () {},
+          };
+          wx.onMenuShareAppMessage(shareData);
+          wx.onMenuShareTimeline(shareData);
+          wx.onMenuShareQQ(shareData);
+          wx.onMenuShareQZone(shareData);
+        });
+      },
+    );
+  }
   async function onSubmit(formData, setObjId = {}) {
     console.log('feedbackAdd', formData);
     // return new Promise((resolve) => {
@@ -80,6 +152,10 @@
     setObjId.industryOptionId = '';
   }
   onMounted(async () => {
+    let isWeixin = isWeChat();
+    if (isWeixin) {
+      wxShare();
+    }
     let { data } = await getDefaultAddress();
     addres.value = {
       country: locale.value == 'en-us' ? data.countryEn : data.country,