| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- export default {
- data() {
- return {
- serviceTypes: [], // 从上一页传递过来的服务类型列表
- qualifications: {}, // 存储图片路径 { '宠物接送': 'path/to/img', ... }
- }
- },
- onLoad(options) {
- if (options.services) {
- try {
- this.serviceTypes = JSON.parse(options.services);
- // 初始化 qualifications 对象
- this.serviceTypes.forEach(type => {
- // 使用 Vue.set 或直接赋值
- this.qualifications[type] = [];
- });
- } catch (e) {
- console.error('Parse services failed', e);
- }
- }
- },
- methods: {
- chooseImage(serviceName) {
- uni.chooseImage({
- count: 9,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: (res) => {
- if (!this.qualifications[serviceName]) {
- this.qualifications[serviceName] = [];
- }
- this.qualifications[serviceName] = this.qualifications[serviceName].concat(res.tempFilePaths);
- this.$forceUpdate();
- }
- });
- },
- deleteImage(serviceName, index) {
- this.qualifications[serviceName].splice(index, 1);
- this.$forceUpdate();
- },
- goBackToForm() {
- // 尝试返回填写页
- const pages = getCurrentPages();
- if (pages.length > 2) {
- uni.navigateBack({
- delta: 2
- });
- } else {
- // 如果页面栈不够(比如直接进入该页),则重定向
- uni.reLaunch({
- url: '/pages/recruit/form'
- });
- }
- },
- submit() {
- // 校验是否所有资质都已上传
- // const missing = this.serviceTypes.find(type => !this.qualifications[type]);
- // if (missing) {
- // uni.showToast({ title: `请上传${missing}服务资质`, icon: 'none' });
- // return;
- // }
- // 实际可能允许部分上传或者有后台逻辑,这里假设全部必填
- // 为了演示方便,暂时不强制校验,或者校验全部
- // 提交成功,跳转到成功页
- // 提交成功,跳转到成功页
- uni.reLaunch({
- url: '/pages/recruit/success'
- });
- }
- }
- }
|