Browse Source

简历投递:消息订阅

Xiao_123 5 months ago
parent
commit
9cc37cfeb9
2 changed files with 41 additions and 7 deletions
  1. 12 0
      api/common.js
  2. 29 7
      pagesB/positionDetail/index.vue

+ 12 - 0
api/common.js

@@ -333,4 +333,16 @@ export const huntSubmit = async (data) => {
       auth: false
     }
   })
+}
+
+// 获得微信小程订阅模板列表
+export const getSubscribeTemplateList = async () => {
+  return request({
+    url: `/app-api/menduner/system/social-user/get-subscribe-template-list`,
+    method: 'GET',
+    custom: {
+      showLoading: false,
+      auth: false
+    }
+  })
 }

+ 29 - 7
pagesB/positionDetail/index.vue

@@ -211,6 +211,7 @@ import { getAccessToken, showNecessaryInfoPopup } from '@/utils/request'
 import { onLoad, onShareAppMessage, onShow } from '@dcloudio/uni-app'
 import { prologue, defaultText } from '@/hooks/useIM'
 import { userStore } from '@/store/user'
+import { getSubscribeTemplateList } from '@/api/common'
 
 const useUserStore = userStore()
 const sharePopup = ref()
@@ -447,6 +448,16 @@ const popup = ref()
 const uploadPopup = ref()
 const resumeList = ref([])
 const selectIndex = ref(null)
+
+const handleOpen = async () => {
+  const { data } = await getPersonResumeCv()
+  resumeList.value = data
+  // 未上传简历
+  if (!resumeList.value?.length) {
+    return uploadPopup.value.open()
+  }
+  popup.value.open()
+}
 const handleDelivery = async () => {
   // 未登录
   if (!getAccessToken()) {
@@ -471,13 +482,24 @@ const handleDelivery = async () => {
     return
   }
 
-  const { data } = await getPersonResumeCv()
-  resumeList.value = data
-  // 未上传简历
-  if (!resumeList.value?.length) {
-    return uploadPopup.value.open()
-  }
-  popup.value.open()
+  // 消息订阅
+  const { data: templateList } = await getSubscribeTemplateList()
+  const tmplIds = templateList.map(e => e.id)
+  console.log(tmplIds, '消息订阅模版ID')
+  uni.requestSubscribeMessage({
+    tmplIds,
+    success:(res)=>{
+      console.log(res, 'uni.requestSubscribeMessage-res')
+      if (res[tmplIds[0]] === 'accept' || res[tmplIds[1]] === 'accept') {
+        console.log('订阅成功', res)
+        handleOpen()
+      }
+    },
+    fail:(err)=>{
+      console.log('订阅失败', err)
+      handleOpen()
+    }
+  })
 }
 const deliverySubmit = async (uploadFile) => {
   const resume = uploadFile ? uploadFile : resumeList.value[selectIndex.value]