Sfoglia il codice sorgente

Merge branch 'feature/七鱼客服' of Software/android-cloud-H5 into develop

zengzhixiang 2 anni fa
parent
commit
b9f8d67782

+ 1 - 1
nuxt.config.js

@@ -70,7 +70,7 @@ export default {
   // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
   plugins: [
     // '~/plugins/api',
-    '~/plugins/file-upload',
+    // '~/plugins/file-upload',
     // '~/plugins/message',
     '~/plugins/toast',
     '~/plugins/error-captured',

+ 18 - 27
pages/customer-service.vue

@@ -6,6 +6,11 @@
 </template>
 <script>
 import qs from 'qs';
+import { fileKeyToUrl } from '@/plugins/file-center.js';
+console.log(
+  '🚀 ~ file: customer-service.vue ~ line 10 ~ fileKeyToUrl',
+  fileKeyToUrl,
+);
 
 export default {
   head() {
@@ -16,7 +21,7 @@ export default {
             'https://qiyukf.com/script/98112bcf552907c28ee450c6a58269c3.js' +
             qs.stringify(
               {
-                hidden: 0,
+                hidden: 1,
                 sdkTemplateId:
                   this.$route.query?.templateId ??
                   process.env.QIYUKF_TEMPLATE_ID,
@@ -54,7 +59,6 @@ export default {
 
       await new Promise((resolve, reject) => {
         ysf('config', {
-          // welcomeTemplateId: 6635862,
           uid: String(this.$auth.user.id),
           name: this.$auth.user.userName,
           mobile: this.$auth.user.phone,
@@ -63,32 +67,19 @@ export default {
             { key: 'real_name', value: this.$auth.user.userName },
             { key: 'mobile_phone', hidden: true, value: this.$auth.user.phone },
             { key: 'email', value: this.$auth.user.email },
-            // {
-            //   key: 'avatar',
-            //   label: '头像',
-            //   value:
-            //     'https://ysf.qiyukf.net/operation/080659b993a45dd546fbd71efd5ef000',
-            // }, // 访客头像
+            {
+              key: 'avatar',
+              label: '头像',
+              value:
+                this.$auth.user.headImgFileId &&
+                fileKeyToUrl(this.$auth.user.headImgFileId),
+            }, // 访客头像
             {
               index: 0,
               key: 'account',
               label: '账号',
               value: this.$auth.user.phone,
-              // href: 'http://example.domain/user/zhangsan',
             },
-            // { index: 1, key: 'sex', label: '性别', value: '先生' },
-            // {
-            //   index: 5,
-            //   key: 'reg_date',
-            //   label: '注册日期',
-            //   value: '2015-11-16',
-            // },
-            // {
-            //   index: 6,
-            //   key: 'last_login',
-            //   label: '上次登录时间',
-            //   value: '2015-12-22 15:38:54',
-            // },
           ]),
           language: 'zh-cn',
           success: resolve,
@@ -96,16 +87,16 @@ export default {
         });
       });
       if (this.isAutoOpen) {
-        this.open({
-          // templateId: 6635862,
-        });
+        this.open();
       }
       if (this.isOnunread) {
         this.onunread();
       }
     },
-    open(data) {
-      this.ysf('open', data);
+    open() {
+      const url = this.ysf('url');
+      location.replace(url);
+      // this.ysf('open', data);
     },
     getUnreadMsg() {
       const result = this.ysf('getUnreadMsg');

+ 3 - 1
plugins/error-captured.js

@@ -3,7 +3,9 @@
 export default function ({ app, $message }) {
   app.errorCaptured = (err, vm, info) => {
     if (process.client) {
-      // console.error(err);
+      if (process.env.NODE_ENV === 'development') {
+        console.error(err);
+      }
       // $message.error({ content: err.message });
       // vm.$toast.fail({ message: err.message, position: 'bottom' });
       vm.$toast.error({ message: err.message });

+ 17 - 0
plugins/file-center.js

@@ -0,0 +1,17 @@
+import qs from 'qs';
+
+let baseURL;
+if (process.env.NODE_ENV === 'development') {
+  // 开发环境通过本地代理
+  baseURL = process.env.FILE_PREFIX;
+} else {
+  // 部署环境通过域名直连
+  baseURL = `http${process.env.FILE_PORT === '443' ? 's' : ''}://${
+    process.env.FILE_HOST
+  }:${process.env.FILE_PORT}/${process.env.FILE_PREFIX}`;
+}
+
+export const fileKeyToUrl = (fileKey, params = {}) =>
+  `${baseURL}/document/newFile/download/0/${
+    process.env.FILE_UPLOAD_KEY
+  }${qs.stringify({ fileKey, ...params }, { addQueryPrefix: true })}`;

+ 0 - 31
plugins/file-upload.js

@@ -1,31 +0,0 @@
-import qs from 'qs';
-export default function ({ $axios }, inject) {
-  let baseURL;
-  if (process.env.NODE_ENV === 'development') {
-    // 开发环境通过本地代理
-    baseURL = process.env.FILE_PREFIX;
-  } else {
-    // 部署环境通过域名直连
-    baseURL = `http${process.env.FILE_PORT === '443' ? 's' : ''}://${
-      process.env.FILE_HOST
-    }:${process.env.FILE_PORT}/${process.env.FILE_PREFIX}`;
-  }
-  const fileUploadServer = $axios.create({
-    baseURL,
-    headers: {},
-  });
-
-  // fileUploadServer.setBaseURL(process.env.FILE_PREFIX);
-  // console.dir(fileUploadServer);
-
-  inject('file', {
-    upload(file) {
-      throw new Error('开发中');
-    },
-    getUrl(params) {
-      return `${baseURL}/document/newFile/download/0/${
-        process.env.FILE_UPLOAD_KEY
-      }${qs.stringify(params, { addQueryPrefix: true })}`;
-    },
-  });
-}

+ 1 - 1
plugins/jweixin.js

@@ -1,5 +1,5 @@
 import wx from 'jweixin-module';
-console.log("🚀 ~ file: jweixin.js ~ line 2 ~ wx", wx)
+// console.log("🚀 ~ file: jweixin.js ~ line 2 ~ wx", wx)
 
 // import Vue from 'vue';
 // import { getConfig } from '~/api/wx/index.js';