瀏覽代碼

预览分享

zhengjinyi 1 年之前
父節點
當前提交
83053bafe4

+ 12 - 0
src/api/user/customer/customer.js

@@ -640,3 +640,15 @@ export function getShopProductList(params) {
     params
   })
 }
+/**
+ * 生成预览码
+ * @param {*} id
+ * @returns
+ */
+export function getMarketPreviewCode(params) {
+  return request({
+    url: '/user/market/preview',
+    method: 'get',
+    params
+  })
+}

+ 5 - 1
src/views/user/customer/components/share-dialog.vue

@@ -39,6 +39,10 @@ export default {
       type: Number,
       default: 2345
     },
+    shareDirectLink: {
+      type: String,
+      default: ''
+    },
     shareLink: {
       type: String,
       default: ''
@@ -87,7 +91,7 @@ export default {
 
     // 直接预览
     handleConfirm() {
-      window.open(this.shareLink, '_blank')
+      window.open(this.shareDirectLink, '_blank')
     },
     handleCanle() {
       // 取消弹窗

+ 21 - 6
src/views/user/customer/market-report-list.vue

@@ -77,7 +77,12 @@
 </template>
 
 <script>
-import { getMarketReportList, updateVisible, deleteMarketReport } from '@/api/user/customer/customer'
+import {
+  getMarketReportList,
+  updateVisible,
+  deleteMarketReport,
+  getMarketPreviewCode
+} from '@/api/user/customer/customer'
 import ShareDialog from './components/share-dialog'
 import { downloadWithUrl } from '@/utils'
 export default {
@@ -170,11 +175,21 @@ export default {
     },
     // 跳转预览
     handlePreview(row) {
-      const urls = `${process.env.VUE_APP_CAIMEI_URL}/charts-preview.html?type=1&shopId=${row.shopId}&marketReportId=${row.id}`
-      this.shareCode = 4567
-      this.shareLink = urls
-      this.shareInfo = row
-      this.dialogVisible = true
+      this.getMarketPreviewCode(row, { id: row.id })
+    },
+    // 调用生成预览码
+    async getMarketPreviewCode(row, params) {
+      try {
+        const res = await getMarketPreviewCode(params)
+        const data = res.data
+        this.shareCode = data.code
+        this.shareLink = `${process.env.VUE_APP_CAIMEI_URL}/charts-preview.html?type=1&shareType=share&shopId=${row.shopId}&marketReportId=${row.id}`
+        this.shareDirectLink = `${process.env.VUE_APP_CAIMEI_URL}/charts-preview.html?type=3&shopId=${row.shopId}&marketReportId=${row.id}`
+        this.shareInfo = row
+        this.dialogVisible = true
+      } catch (error) {
+        console.log(error)
+      }
     },
     // 取消预览
     handleCancel() {