用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 lines
6.6 KiB

  1. <template>
  2. <view class="u-page se-w-vw-100">
  3. <!-- 招聘信息头部 -->
  4. <view class="se-m-20 se-br-20 se-bs-b se-bgc-white se-py-20 se-px-30" v-if="jobInfo">
  5. <view class="se-flex se-flex-h-sb se-mb-10">
  6. <view class="se-flex se-fw-6">
  7. <text class="se-c-black se-fs-30">{{jobInfo.title}}</text>
  8. <text class="se-mx-10 se-b-l"></text>
  9. <text class="se-fs-28 se-c-orange">日薪:{{jobInfo.salaryDay}}</text>
  10. </view>
  11. <view class="se-c-orange se-fs-32 se-fw-6">
  12. {{jobInfo.salaryMin}}-{{jobInfo.salaryMax}}k
  13. </view>
  14. </view>
  15. <view class="se-py-10">
  16. <text class="se-c-text-sub se-fs-22 se-mr-10 se-py-5 se-px-20 se-br-5 se-bgc-f5"
  17. v-if="jobInfo.categoryOne_dictText">{{jobInfo.categoryOne_dictText}}</text>
  18. <text class="se-c-text-sub se-fs-22 se-mr-10 se-py-5 se-px-20 se-br-5 se-bgc-f5"
  19. v-if="jobInfo.categoryTwo_dictText">{{jobInfo.categoryTwo_dictText}}</text>
  20. </view>
  21. <view class="se-flex se-flex-h-sb">
  22. <view class="se-flex se-flex-h-c">
  23. <u-icon name="map"></u-icon>
  24. <text class="se-c-text-sub se-fs-24 se-pl-10 se-toe-3">{{jobInfo.address}}</text>
  25. </view>
  26. <view
  27. style="flex-shrink: 0;"
  28. class="se-c-orange se-fs-24 se-fw-6">
  29. {{orderList.length}}个订单
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 招聘状态显示 -->
  34. <view class="se-px-40 se-pb-20" v-if="jobInfo">
  35. <view class="se-flex se-flex-h-c">
  36. <view class="se-py-8 se-px-20 se-br-15"
  37. :style="jobInfo.status == 1 ? 'background-color: rgba(255, 77, 79, 0.15);' : 'background-color: rgba(82, 196, 26, 0.15);'">
  38. <text :style="jobInfo.status == 1 ? 'color: #d32f2f; font-weight: 600;' : 'color: #388e3c; font-weight: 600;'"
  39. class="se-fs-26">
  40. {{jobInfo.status == 1 ? '已招满' : '招聘中'}}
  41. </text>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="se-p-40">
  46. <view class="se-px-40 se-mb-30 se-py-30 se-bgc-white se-br-40 se-bs-b"
  47. v-for="(item, index) in orderList"
  48. :key="index"
  49. @click="onOrderDetail(item)">
  50. <view class="se-flex se-flex-h-sb se-fw-6 se-fs-32 se-pb-20">
  51. <view class="se-flex">
  52. </view>
  53. <view class="se-c-red">
  54. {{ getStatusText(item) }}
  55. </view>
  56. </view>
  57. <view class="se-flex se-bgc-f5 se-br-20 se-p-20">
  58. <view class="se-w-160 se-h-160">
  59. <image class="se-w-160 se-h-160 se-br-10" :src="item.employResume ?
  60. item.employResume.headImage
  61. : '/static/image/user.png'" mode="aspectFill"></image>
  62. </view>
  63. <view class="se-ml-20 se-flex se-flex-v-sa se-flex-ai-fs se-flex-1">
  64. <view class="se-fw-6 se-c-black se-fs-30 se-display-ib se-mb-10">求职者{{item.jobName}}</view>
  65. <view class="se-fs-24 se-c-text-third se-display-ib se-mb-5">联系电话{{item.jobPhone}}</view>
  66. <view class="se-fs-24 se-c-text-third se-display-ib se-mb-5">接单时间{{item.createTime | formatTime}}</view>
  67. <view class="se-fs-24 se-c-text-third se-display-ib se-mb-5">工作地址{{item.jobAddress}}</view>
  68. </view>
  69. </view>
  70. </view>
  71. <u-empty v-if="orderList && orderList.length==0" mode="list" text="暂无订单信息"></u-empty>
  72. </view>
  73. <!-- 已招满按钮 -->
  74. <view class="se-p-40 se-pt-0" v-if="jobInfo && jobInfo.status == 0">
  75. <view class="se-bgc-orange se-br-20 se-py-30 se-flex se-flex-h-c se-flex-v-c"
  76. @click="onStopJob">
  77. <text class="se-c-white se-fs-32 se-fw-6">已招满</text>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import {
  84. getTaskById,
  85. stopJob
  86. } from "@/common/api.js"
  87. import {
  88. getStatusText
  89. } from "@/utils/statusText.js"
  90. export default {
  91. data() {
  92. return {
  93. orderList: [],
  94. jobInfo: null,
  95. jobId: null
  96. }
  97. },
  98. filters: {
  99. formatTime(time) {
  100. if (!time) return '';
  101. // 处理时间戳格式(可能是毫秒或字符串)
  102. let timestamp;
  103. if (typeof time === 'number') {
  104. // 如果是数字,直接使用
  105. timestamp = time;
  106. } else {
  107. // 如果是字符串,转换为时间戳
  108. timestamp = new Date(time).getTime();
  109. }
  110. const currentTime = new Date().getTime();
  111. const diff = (currentTime - timestamp) / 1000; // 时间差,单位:秒
  112. // 计算月差,判断是否超过一个月
  113. const oneMonthInSeconds = 30 * 24 * 60 * 60;
  114. if (diff > oneMonthInSeconds) {
  115. let date = new Date(timestamp);
  116. let year = date.getFullYear();
  117. let month = date.getMonth() + 1;
  118. let day = date.getDate();
  119. if (month < 10) month = "0" + month;
  120. if (day < 10) day = "0" + day;
  121. return `${year}-${month}-${day}`;
  122. } else {
  123. // 计算秒、分钟、小时的差值
  124. if (diff < 60) {
  125. return `${Math.floor(diff)}秒钟前`;
  126. } else if (diff < 60 * 60) {
  127. return `${Math.floor(diff / 60)}分钟前`;
  128. } else if (diff < 60 * 60 * 24) {
  129. return `${Math.floor(diff / 60 / 60)}小时前`;
  130. } else {
  131. // 显示天数
  132. return `${Math.floor(diff / 60 / 60 / 24)}天前`;
  133. }
  134. }
  135. }
  136. },
  137. onLoad(options) {
  138. if (options.jobId) {
  139. this.jobId = options.jobId;
  140. }
  141. },
  142. onShow(){
  143. this.getJobDetail();
  144. },
  145. methods: {
  146. getStatusText,
  147. getJobDetail() {
  148. getTaskById({ id: this.jobId }).then(response => {
  149. if (response.success) {
  150. this.jobInfo = response.result;
  151. this.orderList = this.jobInfo.employOrder || [];
  152. // 设置页面标题
  153. uni.setNavigationBarTitle({
  154. title: `${this.jobInfo.title} - 订单列表`
  155. });
  156. } else {
  157. uni.showToast({
  158. title: '获取工作详情失败',
  159. icon: 'none'
  160. });
  161. }
  162. })
  163. },
  164. onOrderDetail(order) {
  165. uni.navigateTo({
  166. url: `/pages_subpack/order-detail/boss?orderId=${order.id}&type=true`
  167. });
  168. },
  169. onStopJob() {
  170. uni.showModal({
  171. title: '确认操作',
  172. content: '确定要将此招聘标记为已招满吗?',
  173. success: (res) => {
  174. if (res.confirm) {
  175. this.stopJobRequest();
  176. }
  177. }
  178. });
  179. },
  180. stopJobRequest() {
  181. stopJob({ id: this.jobId }).then(response => {
  182. if (response.success) {
  183. uni.showToast({
  184. title: '操作成功',
  185. icon: 'success'
  186. });
  187. // 更新本地状态
  188. this.jobInfo.status = 1;
  189. // 返回上一页或刷新页面
  190. setTimeout(() => {
  191. uni.navigateBack();
  192. }, 1500);
  193. } else {
  194. uni.showToast({
  195. title: response.message || '操作失败',
  196. icon: 'none'
  197. });
  198. }
  199. }).catch(error => {
  200. console.error('停止招聘失败:', error);
  201. uni.showToast({
  202. title: '网络错误',
  203. icon: 'none'
  204. });
  205. });
  206. }
  207. }
  208. }
  209. </script>
  210. <style>
  211. </style>