Parcourir la source

可发布职位数

lifanagju_citu il y a 1 mois
Parent
commit
f92ec4c20d
2 fichiers modifiés avec 27 ajouts et 7 suppressions
  1. 6 6
      components/PositionList/index.vue
  2. 21 1
      pages/index/position.vue

+ 6 - 6
components/PositionList/index.vue

@@ -74,6 +74,7 @@ import { ref } from 'vue'
 import { timesTampChange } from '@/utils/date'
 import { formatName } from '@/utils/getText'
 import payPopup from '@/components/payPopup'
+import { userStore } from '@/store/user'; const useUserStore = userStore()
 import {
   topJobAdvertisedCancel,
   topJobAdvertised,
@@ -81,7 +82,6 @@ import {
   closeJobAdvertised,
   enableJobAdvertised
 } from '@/api/new/position'
-import { userStore } from '@/store/user'; const useUserStore = userStore()
 const emit = defineEmits(['entClick', 'refresh'])
 const props = defineProps({
   tab: { type: Number, default: 0 },
@@ -99,7 +99,7 @@ const toPay = async (val) => {
   // 待发布且有额度的激活职位即可
   if (userInfo.value.entitlement?.publishJobCount > 0) {
     await enableJobAdvertised([val.id])
-    emit('refresh', true)
+    emit('refresh', { reset: true, updatePublishJobCount: true })
     setTimeout(() => { uni.showToast({ title: '发布成功', icon: 'success' }) }, 1000)
     return
   }
@@ -134,12 +134,12 @@ const handleAction = async (index, type, { id }, item) => {
 
     // 没有可发布额度激活职位需重新付款
     userInfo.value = await useUserStore.getUserInfos()
-    if (index === 1 && userInfo.value?.entitlement.publishJobCount <= 3990039900) {
+    if (index === 1 && userInfo.value?.entitlement?.publishJobCount-0 <= 0) {
       toPay(item)
       return
     }
     await apiList[index](ids)
-    emit('refresh', true)
+    emit('refresh', { reset: true })
     setTimeout(() => { uni.showToast({ title: '操作成功', icon: 'success' }) }, 1000)
     // 
   } catch (error) {
@@ -174,7 +174,7 @@ const closeJob = async () => {
   try {
     uni.showLoading({ title: '关闭中...', mask: true })
     await apiList[handleActionInfo?.index](handleActionInfo?.ids)
-    emit('refresh', true)
+    emit('refresh', { reset: true })
     setTimeout(() => { uni.showToast({ title: '关闭成功', icon: 'success' }) }, 1000)
   } catch (error) {
     uni.showToast({ title: '关闭失败', icon: 'error' })
@@ -208,7 +208,7 @@ const handleToResume = (val) => {
 }
 
 const paySuccess = () => {
-  emit('refresh', true)
+  emit('refresh', { reset: true })
   setTimeout(() => { uni.showToast({ title: '发布成功', icon: 'success', duration: 2000 }) }, 1000)
 }
 

+ 21 - 1
pages/index/position.vue

@@ -19,6 +19,10 @@
               :focus="false"
               @confirm="onSearch"
             ></uni-search-bar>
+            <!-- 可发布职位数 -->
+            <!-- <view v-if="userInfo?.entitlement?.publishJobCount-0" class="publishJobCountBox">
+              <span>可发布职位数 <span class="color-primary">{{ userInfo.entitlement.publishJobCount || 0 }}</span> 个</span>
+            </view> -->
           </view>
           <view v-if="!positionListData?.length && more !== 'loading'" class="d-flex flex-column align-center justify-center ss-m-t-30">
             <view class="nodata-img-parent">
@@ -55,9 +59,12 @@ import { getJobAdvertisedList } from '@/api/new/position'
 import { onShow, onLoad } from '@dcloudio/uni-app'
 import { getAccessToken } from '@/utils/request'
 import { showAuthModal } from '@/hooks/useModal'
+import { userStore } from '@/store/user'; const useUserStore = userStore()
 
 const tab = ref(1)
 
+const userInfo = ref(useUserStore?.userInfo || {})
+
 onLoad((options) => {
   console.log('onLoad:', options)
   if (options?.tab) tab.value = Number(options?.tab)
@@ -147,9 +154,13 @@ const loadingMore = () => {
   getData()
 }
 
-const refresh = (reset = false) => {
+// reset: 刷新列表 updatePublishJobCount: 更新可发布职位数量
+const refresh = async ({ reset = false, updatePublishJobCount = false }) => {
   if (reset) query.value.pageNo = 1
   getData()
+  if (updatePublishJobCount) {
+    userInfo.value = await useUserStore.getUserInfos()
+  }
 }
 
 const handleClickAdd = () => {
@@ -257,4 +268,13 @@ const handleClickAdd = () => {
     }
   }
 }
+.publishJobCountBox {
+  font-size: 12px;
+  margin-left: 30rpx;
+  color: #666;
+  padding-bottom: 10px;
+  .color-primary {
+    font-weight: bold;
+  }
+}
 </style>