用工小程序前端代码
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.

314 lines
8.5 KiB

6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
  1. <template>
  2. <view>
  3. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="80">
  4. <view class="se-p-20">
  5. <view class="se-p-20 se-bgc-white se-br-10 se-fs-20">
  6. <u-form-item label="姓名" prop="name">
  7. <u--input v-model="form.name" class="se-bgc-f5" placeholder="请输入姓名名称"></u--input>
  8. </u-form-item>
  9. <!-- <u-form-item label="密码" prop="password">
  10. <u--input v-model="form.password" class="se-bgc-f5" placeholder="请输入您的密码"></u--input>
  11. </u-form-item> -->
  12. <u-form-item label="联系电话" prop="mobile">
  13. <u--input v-model="form.mobile" class="se-bgc-f5" placeholder="请输入联系方式"></u--input>
  14. </u-form-item>
  15. <u-form-item label="年龄" prop="age">
  16. <u--input v-model="form.age" class="se-bgc-f5" placeholder="请输入年龄"></u--input>
  17. </u-form-item>
  18. <u-form-item label="性别" prop="sex" @click="handleSexChange">
  19. <u--input @click="handleSexChange" readonly v-model="form.sex" placeholder="请选择性别"
  20. border="none"></u--input>
  21. <u-icon @click="handleSexChange" slot="right" name="arrow-right"></u-icon>
  22. </u-form-item>
  23. <u-form-item label="工种" prop="industryId" @click="handleIndChange">
  24. <u--input v-model="form.industryName" readonly placeholder="请选择工种" border="none"></u--input>
  25. <u-icon slot="right" name="arrow-right"></u-icon>
  26. </u-form-item>
  27. <u-form-item label="薪资待遇" prop="salary">
  28. <view class="se-flex se-flex-h-c">
  29. <u--input v-model="form.salaryMin" class="se-w-200" placeholder="最小值"></u--input>
  30. <text class="se-mx-10">~</text>
  31. <u--input v-model="form.salaryMax" class="se-w-200" placeholder="最大值"></u--input>
  32. </view>
  33. </u-form-item>
  34. <u-form-item label="个人介绍" prop="introduce">
  35. <u--textarea v-model="form.introduce" count class="se-bgc-f5"
  36. placeholder="请选择个人介绍"></u--textarea>
  37. </u-form-item>
  38. </view>
  39. </view>
  40. <view class="se-p-20">
  41. <view class="se-px-20 se-pb-20 se-bgc-white se-br-10 se-fs-20">
  42. <u-form-item prop="idCardFile" labelWidth="2">
  43. <view class="se-flex se-flex-v-sa">
  44. <view class="se-py-20 se-w-p-100 se-flex">
  45. <view class="line-orange"></view>
  46. <view class="se-ml-10">
  47. 身份证上传正反面
  48. </view>
  49. </view>
  50. <view class="se-py-20 se-w-p-100">
  51. <u-upload :fileList="form.idCardFile" @afterRead="afterRead" @delete="deletePic"
  52. name="1" multiple :maxCount="10"></u-upload>
  53. </view>
  54. </view>
  55. </u-form-item>
  56. </view>
  57. </view>
  58. <view class="se-px-20 se-pt-20">
  59. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  60. <view @click="submit"
  61. class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-60 se-lh-60 se-ta-c se-fs-28 se-c-white se-bgc-orange">
  62. <text>申请审核</text>
  63. </view>
  64. <view
  65. class="se-mx-10 se-flex-1 se-b se-br-40 se-flex-h-c se-h-60 se-lh-60 se-ta-c se-fs-28 se-c-66 se-bgc-f5">
  66. <text>联系我们</text>
  67. </view>
  68. </view>
  69. </view>
  70. </u--form>
  71. <!-- 性别 -->
  72. <u-action-sheet :show="showSex" :actions="sexList" title="请选择性别" @close="showSex = false" @select="sexSelect">
  73. </u-action-sheet>
  74. <!-- 种类 -->
  75. <u-action-sheet :show="showType" :actions="typeList" title="请选择种类" @close="showType = false"
  76. @select="typeSelect">
  77. </u-action-sheet>
  78. </view>
  79. </template>
  80. <script>
  81. import {
  82. role,
  83. industryList
  84. } from "@/common/api.js"
  85. export default {
  86. data() {
  87. return {
  88. showSex: false,
  89. sexList: [{
  90. name: '男',
  91. },
  92. {
  93. name: '女',
  94. }
  95. ],
  96. showType: false,
  97. typeList: [],
  98. fileList: [],
  99. form: {
  100. name: '张三',
  101. password: '',
  102. mobile: '13189698114',
  103. age: '23',
  104. sex: '男',
  105. industryId: '1865037318519398402',
  106. industryName: "餐饮",
  107. salary: '',
  108. salaryMin: '1800',
  109. salaryMax: '2400',
  110. introduce: '张三的个人简介',
  111. idCard: '',
  112. idCardFile: [
  113. {
  114. url:"https://tennis-oss.xzaiyp.top/2024-12-22/7af6b40f-96f9-4656-9eff-98dce2223699.png"
  115. }
  116. ]
  117. },
  118. rules: {
  119. name: [{
  120. type: 'string',
  121. required: true,
  122. message: '请输入姓名名称',
  123. trigger: ['blur', 'change']
  124. }],
  125. industryId: [{
  126. type: 'string',
  127. required: true,
  128. message: '请选择行业',
  129. trigger: ['blur', 'change']
  130. }],
  131. // password: [{
  132. // type: 'string',
  133. // required: true,
  134. // message: '请输入您的密码',
  135. // trigger: ['blur', 'change']
  136. // }],
  137. mobile: [{
  138. required: true,
  139. message: '请输入手机号',
  140. trigger: ['change', 'blur'],
  141. },
  142. {
  143. validator: (rule, value, callback) => {
  144. return uni.$u.test.mobile(value);
  145. },
  146. message: '手机号码不正确',
  147. trigger: ['change', 'blur'],
  148. },
  149. ],
  150. age: [{
  151. validator: (rule, value, callback) => {
  152. if (!value) {
  153. callback(new Error('年龄不能为空'));
  154. } else if (isNaN(value)) {
  155. callback(new Error('请输入数字'));
  156. } else if (value < 18 || value > 65) {
  157. callback(new Error('年龄必须在18至65岁之间'));
  158. } else {
  159. callback(); // 验证通过
  160. }
  161. },
  162. trigger: 'blur',
  163. }],
  164. sex: [{
  165. type: 'string',
  166. max: 1,
  167. required: true,
  168. message: '请选择性别',
  169. trigger: ['blur', 'change']
  170. }],
  171. salary: [{
  172. type: 'string',
  173. required: true,
  174. message: '请输入薪资待遇',
  175. trigger: ['blur', 'change']
  176. }],
  177. introduce: [{
  178. type: 'string',
  179. required: true,
  180. message: '请输入个人简介',
  181. trigger: ['blur', 'change']
  182. }],
  183. idCardFile: [{
  184. validator: (rule, value, callback) => {
  185. if (value === null || value === undefined || value === '' || (Array.isArray(
  186. value) && value.length === 0)) {
  187. callback(new Error('请选择身份证'));
  188. } else {
  189. callback();
  190. }
  191. },
  192. trigger: 'blur'
  193. }]
  194. },
  195. }
  196. },
  197. watch: {
  198. 'form.salaryMin': {
  199. handler(newVal, oldVal) {
  200. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMax)) {
  201. this.form.salary = '有'
  202. } else {
  203. this.form.salary = ''
  204. }
  205. },
  206. immediate: true
  207. },
  208. 'form.salaryMax': {
  209. handler(newVal, oldVal) {
  210. if (!uni.$u.test.isEmpty(newVal) && !uni.$u.test.isEmpty(this.form.salaryMin)) {
  211. this.form.salary = '有'
  212. } else {
  213. this.form.salary = ''
  214. }
  215. },
  216. immediate: true
  217. }
  218. },
  219. methods: {
  220. handleIndChange() {
  221. this.showType = true
  222. },
  223. typeSelect(event) {
  224. console.info("selectIndClick", event)
  225. this.form.industryId = event.id
  226. this.form.industryName = event.name
  227. this.showType = false
  228. },
  229. onIndustryList() {
  230. industryList({}).then(response => {
  231. console.info(response)
  232. this.typeList = response.result
  233. }).catch(error => {
  234. })
  235. },
  236. handleSexChange() {
  237. this.showSex = true
  238. },
  239. sexSelect(e) {
  240. this.form.sex = e.name
  241. this.$refs.uForm.validateField('sex')
  242. },
  243. onRole() {
  244. let that = this
  245. let params = {
  246. userName: that.form.name,
  247. industryId: that.form.industryId,
  248. industryName: that.form.industryName,
  249. age: that.form.age,
  250. gender: that.form.sex=="男"?1:2,
  251. moneyMin: that.form.salaryMin,
  252. moneyMax: that.form.salaryMax,
  253. phone: that.form.mobile,
  254. detail: that.form.introduce,
  255. idCard: that.form.idCardFile.map(item => item.url).join(','),
  256. }
  257. role(params).then(response => {
  258. uni.$u.toast("提交成功,等待申请")
  259. setTimeout(()=>{
  260. uni.switchTab({
  261. url:"/pages/home/index"
  262. })
  263. },1500)
  264. }).catch(error => {
  265. setTimeout(()=>{
  266. uni.switchTab({
  267. url:"/pages/home/index"
  268. })
  269. },1500)
  270. })
  271. },
  272. submit() {
  273. this.$refs.uForm.validate().then(res => {
  274. this.onRole()
  275. }).catch(errors => {
  276. // uni.$u.toast('校验失败')
  277. })
  278. },
  279. deletePic(event) {
  280. this.form.idCardFile.splice(e.index, 1)
  281. },
  282. async afterRead(e) {
  283. let self = this
  284. e.file.forEach(file => {
  285. self.$Oss.ossUpload(file.url).then(url => {
  286. self.form.idCardFile.push({
  287. url
  288. })
  289. })
  290. })
  291. }
  292. },
  293. onReady() {
  294. this.onIndustryList()
  295. this.$refs.uForm.setRules(this.rules)
  296. },
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. page {
  301. background-color: #f5f5f5 !important;
  302. }
  303. .line-orange {
  304. width: 8rpx;
  305. height: 32rpx;
  306. background: #ff7a31;
  307. border-radius: 4rpx;
  308. }
  309. </style>