index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view>
  3. <uni-segmented-control :current="current" class="MiSans-Normal" :values="controlList" @clickItem="handleChange" styleType="text" activeColor="#00B760"></uni-segmented-control>
  4. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="height: calc(100vh - 36px);">
  5. <view v-if="items.length">
  6. <PositionList v-if="current === 0" class="pb-10" showReportBtn :list="items" :showJobFairSign="true" :noMore="false" @refresh="refresh"></PositionList>
  7. <Items v-else class="pb-10" :list="items" @action="handleAction"></Items>
  8. <uni-load-more :status="more" />
  9. </view>
  10. <view v-else class="nodata-img-parent">
  11. <image src="https://minio.menduner.com/dev/bb43df1dc91945e05ee93da76e49b34f87b0d10203eb76c20e2d4999a13b9a0a.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
  12. </view>
  13. </scroll-view>
  14. <!-- 同意、拒绝面试 -->
  15. <uni-popup ref="popup" type="dialog">
  16. <uni-popup-dialog :type="type === 'agree' ? 'success' : 'warn'" cancelText="取消" confirmText="确认"
  17. title="系统提示" :content="type === 'agree' ? '确认接受面试吗?' : '确认拒绝面试吗?'" @confirm="handleConfirm" @close="handleClose"
  18. ></uni-popup-dialog>
  19. </uni-popup>
  20. </view>
  21. </template>
  22. <script setup>
  23. import { ref } from 'vue'
  24. import { getJobDeliveryList, getUserInterviewInvitePage, userInterviewInviteConsent, userInterviewInviteReject } from '@/api/user'
  25. import { dealDictObjData } from '@/utils/position'
  26. import PositionList from '@/components/PositionList'
  27. import Items from './item.vue'
  28. import { userStore } from '@/store/user'
  29. import { onLoad } from '@dcloudio/uni-app'
  30. const useUserStore = userStore()
  31. const current = ref(0)
  32. const controlList = ['已投递', '待同意', '待面试', '已完成', '已拒绝']
  33. const statusList = [0, 1, 3, 98]
  34. const more = ref('more')
  35. const items = ref([])
  36. const total = ref(0)
  37. const queryParams = ref({
  38. pageNo: 1,
  39. pageSize: 10
  40. })
  41. const popup = ref()
  42. const type = ref('')
  43. const id = ref(null)
  44. onLoad((options) => {
  45. if (options?.index) {
  46. current.value = Number(options.index)
  47. items.value = []
  48. }
  49. getList()
  50. })
  51. const getList = async () => {
  52. const api = current.value === 0 ? getJobDeliveryList : getUserInterviewInvitePage
  53. if (current.value !== 0) queryParams.value.status = statusList[current.value - 1]
  54. const { data } = await api(queryParams.value)
  55. const list = data?.list || []
  56. if (!list.length && queryParams.value.pageNo === 1) {
  57. items.value = []
  58. return
  59. }
  60. if (list?.length) {
  61. list.forEach(e => {
  62. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  63. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  64. })
  65. items.value = items.value.concat(list)
  66. }
  67. total.value = data?.total || 0
  68. more.value = items.value?.length === total.value ? 'noMore' : 'more'
  69. }
  70. const handleChange = (e) => {
  71. items.value = []
  72. queryParams.value.pageNo = 1
  73. current.value = e.currentIndex
  74. getList()
  75. }
  76. // 加载更多
  77. const loadingMore = () => {
  78. if (total.value <= 0) return
  79. more.value = 'loading'
  80. queryParams.value.pageNo++
  81. getList()
  82. }
  83. const refresh = () => {
  84. queryParams.value.pageNo = 1
  85. items.value = []
  86. getList()
  87. }
  88. // 同意、拒绝
  89. const handleAction = (item, typeVal) => {
  90. id.value = item.id
  91. type.value = typeVal
  92. popup.value.open()
  93. }
  94. const handleClose = () => {
  95. popup.value.close()
  96. type.value = ''
  97. id.value = null
  98. }
  99. const handleConfirm = async () => {
  100. if (!id.value) return
  101. const api = type.value === 'agree' ? userInterviewInviteConsent : userInterviewInviteReject
  102. // 同意需提交手机号
  103. let phone = ''
  104. if (useUserStore?.baseInfo?.phone) phone = useUserStore?.baseInfo?.phone
  105. await api(type.value === 'agree' ? { id: id.value, phone } : id.value)
  106. handleClose()
  107. uni.showToast({
  108. title: '操作成功',
  109. icon: 'success'
  110. })
  111. queryParams.value.pageNo = 1
  112. items.value = []
  113. getList()
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. </style>