auth_logic.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. export default {
  2. data() {
  3. return {
  4. formData: {
  5. idType: '居民身份证',
  6. name: '',
  7. idNumber: '',
  8. expiryDate: ''
  9. },
  10. idCardFront: '', // 身份证正面路径
  11. idCardBack: '', // 身份证反面路径
  12. showDatePicker: false,
  13. pickerValue: [0, 0, 0], // YYYY-MM-DD
  14. years: [],
  15. months: [],
  16. days: [],
  17. serviceType: [] // 接收上一页的服务类型
  18. }
  19. },
  20. onLoad(options) {
  21. if (options.services) {
  22. try {
  23. this.serviceType = JSON.parse(options.services);
  24. } catch (e) {
  25. console.error('Parse services failed', e);
  26. }
  27. }
  28. this.initDateData();
  29. },
  30. methods: {
  31. // --- 日期选择器逻辑 (简化版, 仅示意) ---
  32. initDateData() {
  33. const date = new Date();
  34. const year = date.getFullYear();
  35. for (let i = year; i <= year + 20; i++) {
  36. this.years.push(i);
  37. }
  38. for (let i = 1; i <= 12; i++) {
  39. this.months.push(i);
  40. }
  41. for (let i = 1; i <= 31; i++) {
  42. this.days.push(i);
  43. }
  44. },
  45. openDatePicker() {
  46. // this.showDatePicker = true;
  47. // 简单起见,这里可以用 uni.chooseImage 逻辑,但日期通常用 picker
  48. // 为了完全还原UI的自定义picker,这里先用原生 picker 简化,或者复用 form 的逻辑
  49. // 鉴于图1是普通的列表选择样式,这里暂时使用普通 picker 或者 input禁用+点击事件
  50. },
  51. onDateChange(e) {
  52. this.formData.expiryDate = e.detail.value;
  53. },
  54. // --- 图片上传 ---
  55. chooseImage(side) {
  56. uni.chooseImage({
  57. count: 1,
  58. sizeType: ['compressed'],
  59. sourceType: ['album', 'camera'],
  60. success: (res) => {
  61. if (side === 'front') {
  62. this.idCardFront = res.tempFilePaths[0];
  63. } else {
  64. this.idCardBack = res.tempFilePaths[0];
  65. }
  66. }
  67. });
  68. },
  69. // --- 提交 ---
  70. goToQualifications() {
  71. // 简单校验
  72. // 简单校验
  73. /*
  74. if (!this.formData.name || !this.formData.idNumber) {
  75. uni.showToast({ title: '请完善信息', icon: 'none' });
  76. return;
  77. }
  78. if (!this.idCardFront || !this.idCardBack) {
  79. uni.showToast({ title: '请上传证件照', icon: 'none' });
  80. return;
  81. }
  82. */
  83. // 传递数据
  84. const services = JSON.stringify(this.serviceType);
  85. uni.navigateTo({
  86. url: `/pages/recruit/qualifications?services=${services}`
  87. });
  88. }
  89. }
  90. }