Эх сурвалжийг харах

feat: 完善采购单位监控

zhangyuhan 1 жил өмнө
parent
commit
64eea43474

+ 4 - 0
apps/bigmember_pc/src/composables/quick-monitor/index.js

@@ -1,5 +1,6 @@
 import useProjectQuickMonitorModel from './use/porject'
 import useProjectQuickMonitorModel from './use/porject'
 import useEntQuickMonitorModel from './use/ent'
 import useEntQuickMonitorModel from './use/ent'
+import useClientQuickMonitorModel from './use/client'
 
 
 const GlobalModelCache = {}
 const GlobalModelCache = {}
 
 
@@ -27,6 +28,9 @@ export function useQuickMonitorModel(params) {
     case 'ent':
     case 'ent':
       createModel = useEntQuickMonitorModel
       createModel = useEntQuickMonitorModel
       break
       break
+    case 'client':
+      createModel = useClientQuickMonitorModel
+      break
     default:
     default:
       break
       break
   }
   }

+ 237 - 0
apps/bigmember_pc/src/composables/quick-monitor/use/client.js

@@ -0,0 +1,237 @@
+import { computed, ref, getCurrentInstance } from 'vue'
+import { useStore } from '@/store'
+import { useMonitorModel, useMonitorTipDialog } from './base'
+
+/**
+ * 文案项目配置
+ */
+const TextConfig = {
+  default: '监控',
+  follow: '已监控'
+}
+/**
+ * 弹窗相关配置表
+ */
+const DialogDataMap = {
+  'success-monitor': {
+    title: '监控成功',
+    content:
+      '您可前往“工作台-商机-业主监控”查看业主最新招标动态。为保证您能及时获取新增监控信息推送,请前往开启推送提醒。',
+    footerActions: [
+      {
+        label: '暂不开启',
+        class: 'cancel'
+      },
+      {
+        label: '去开启',
+        class: 'confirm',
+        action: 'doOpenPushSetting'
+      }
+    ]
+  },
+  'max-monitor': {
+    title: '监控业主个数已达上限',
+    content: '您最多可监控$1个业主,可联系客服,申请监控更多业主',
+    footerActions: [
+      {
+        label: '我再想想',
+        class: 'cancel'
+      },
+      {
+        label: '联系客服',
+        class: 'confirm',
+        action: 'doOpenCustomer'
+      }
+    ]
+  },
+  'apply-monitor': {
+    title: '申请监控更多业主',
+    content: '您可联系客服,申请升级产品套餐,监控更多业主',
+    footerActions: [
+      {
+        label: '我再想想',
+        class: 'cancel'
+      },
+      {
+        label: '联系客服',
+        class: 'confirm',
+        action: 'doOpenCustomer'
+      }
+    ]
+  },
+  'cancel-monitor': {
+    title: '确定不再监控?',
+    content: '取消监控,将错过业主最新动态推送',
+    footerActions: [
+      {
+        label: '确认取消',
+        class: 'cancel',
+        action: 'doRemoveFollow'
+      },
+      {
+        label: '我再想想',
+        class: 'confirm'
+      }
+    ]
+  },
+  'success-toast': '监控成功,您可前往“工作台-商机-业主监控”查看'
+}
+
+/**
+ * 弹窗相关事件 Emit
+ */
+// 打开推送提醒设置
+function doOpenPushSetting() {
+  window.open('/swordfish/page_big_pc/push_setting')
+}
+
+function useClientQuickMonitorModel({ type, id }) {
+  const that = getCurrentInstance().proxy
+  const collectElement = ref(null)
+  const { dialogConfig, doOpenDialog, doCloseDialog } =
+    useMonitorTipDialog(DialogDataMap)
+  const HasPowerBigmemberOrEnt = computed(() => {
+    const store = useStore()
+    return store.getters['user/entniche'] || store.getters['user/bigmember']
+  })
+  const loading = ref(false)
+  const { model, doChange, doFetch } = useMonitorModel({ type, id })
+  const monitorPopoverConfig = computed(() => {
+    return {
+      showTip: !model.value.follow,
+      showMore: model.value.follow,
+      showList: true,
+      showCancel: model.value.follow,
+      alreadyNum: model.value.expands.used,
+      remainNum: model.value.expands.surplus,
+      textType: type
+    }
+  })
+
+  // 打开留资弹窗
+  function doOpenCollectDialog(key) {
+    collectElement.value?.noCallApiFn(key, false)
+  }
+
+  // 联系客服
+  function doOpenCustomer() {
+    that?.contactCustomer(that)
+  }
+
+  /**
+   * 监控操作业务流程
+   * 0. 前置权益判断
+   *  0.1 判断是否非大会员、非商机管理用户
+   *    > 否,留资弹窗
+   * 1. 监控成功
+   *  1.1 判断是否开启推送提醒
+   *    > 是,提醒开启推送提醒 success-monitor
+   *    > 否,toast 提醒监控成功 success-toast
+   * 2. 监控失败
+   *  2.1 超出可监控项目个数
+   *    2.1.1 判断是否非大会员、非商机管理用户
+   *      > 是,弹窗提醒 max-monitor
+   *      > 否,留资弹窗
+   *  2.2 其他错误,toast 提醒
+   * @return {Promise<void>}
+   */
+  async function doAddFollow() {
+    if (loading.value) return
+    loading.value = true
+    // 业务流程
+    if (!model.value.follow) {
+      await doChange().then((res) => {
+        if (res.success) {
+          // 判断是否开启推送提醒
+          if (!res.data?.msg_open) {
+            doOpenDialog('success-monitor')
+          } else {
+            that.$toast(DialogDataMap['success-toast'])
+          }
+        } else {
+          // 判断是否超出可监控项目个数
+          if (res.data?.limit_status) {
+            if (HasPowerBigmemberOrEnt.value) {
+              doOpenDialog('max-monitor', { count: res.data?.limit_status })
+            } else {
+              doOpenCollectDialog('pc_buyer_monitor_limit')
+            }
+          }
+          that.$toast(res.msg)
+        }
+      })
+    }
+    loading.value = false
+  }
+
+  /**
+   * 统一处理 dialog, popover emit 事件
+   * @param {string} type
+   *  // popover 事务
+   *  - more 查看监控动态
+   *  - list 查看监控列表
+   *  - apply 申请监控更多
+   *  - cancel 取消监控确认弹窗
+   *  // dialog 事务
+   *  - doCloseDialog 关闭弹窗
+   *  - doRemoveFollow 提交取消监控事务
+   *  - doOpenCustomer 联系客服
+   *  - doOpenPushSetting 打开推送提醒设置
+   */
+  function doClickMonitorActions(type) {
+    switch (type) {
+      case 'doCloseDialog':
+        doCloseDialog()
+        break
+      case 'doOpenCustomer':
+        doCloseDialog()
+        doOpenCustomer()
+        break
+      case 'doOpenPushSetting':
+        doCloseDialog()
+        doOpenPushSetting()
+        break
+      case 'doRemoveFollow':
+        doCloseDialog()
+        doChange().then((res) => {
+          if (!res.success) {
+            that.$toast(res.msg)
+          }
+        })
+        break
+      case 'cancel':
+        doOpenDialog('cancel-monitor')
+        break
+      case 'apply':
+        if (HasPowerBigmemberOrEnt.value) {
+          doOpenDialog('apply-monitor')
+        } else {
+          doOpenCollectDialog('pc_buyer_monitor_more')
+        }
+        break
+      case 'more':
+        break
+      case 'list':
+        break
+      default:
+        break
+    }
+  }
+
+  return {
+    // 基础展示信息
+    model,
+    doFetch,
+    doAddFollow,
+    TextConfig,
+    // popover 悬浮信息
+    monitorPopoverConfig,
+    doClickMonitorActions,
+    // dialog 提示弹窗
+    dialogConfig,
+    // 留资
+    collectElement
+  }
+}
+
+export default useClientQuickMonitorModel

+ 3 - 1
apps/bigmember_pc/src/composables/quick-monitor/use/ent.js

@@ -81,7 +81,9 @@ const DialogDataMap = {
  * 弹窗相关事件 Emit
  * 弹窗相关事件 Emit
  */
  */
 // 打开推送提醒设置
 // 打开推送提醒设置
-function doOpenPushSetting() {}
+function doOpenPushSetting() {
+  window.open('/swordfish/page_big_pc/push_setting')
+}
 
 
 function useEntQuickMonitorModel({ type, id }) {
 function useEntQuickMonitorModel({ type, id }) {
   const that = getCurrentInstance().proxy
   const that = getCurrentInstance().proxy

+ 3 - 1
apps/bigmember_pc/src/composables/quick-monitor/use/porject.js

@@ -81,7 +81,9 @@ const DialogDataMap = {
  * 弹窗相关事件 Emit
  * 弹窗相关事件 Emit
  */
  */
 // 打开推送提醒设置
 // 打开推送提醒设置
-function doOpenPushSetting() {}
+function doOpenPushSetting() {
+  window.open('/swordfish/page_big_pc/push_setting')
+}
 
 
 function useProjectQuickMonitorModel({ type, id }) {
 function useProjectQuickMonitorModel({ type, id }) {
   const that = getCurrentInstance().proxy
   const that = getCurrentInstance().proxy

+ 2 - 2
apps/bigmember_pc/src/views/article-content/components/RecommendEnt.vue

@@ -97,11 +97,11 @@ function doOpen(item) {
             {{ item?.type === 'buyer' ? '采购单位' : '中标单位' }}画像
             {{ item?.type === 'buyer' ? '采购单位' : '中标单位' }}画像
           </span>
           </span>
           <h3>{{ item.name }}</h3>
           <h3>{{ item.name }}</h3>
-          <div class="monitor-action" v-if="item.id">
+          <div class="monitor-action">
             <quick-monitor
             <quick-monitor
               class="action-item"
               class="action-item"
               :type="item.type === 'buyer' ? 'client' : 'ent'"
               :type="item.type === 'buyer' ? 'client' : 'ent'"
-              :params="item.id"
+              :params="item.type === 'buyer' ? item.name : item.id"
             />
             />
           </div>
           </div>
         </div>
         </div>