2025-05-19 01:08:33 +00:00
|
|
|
const { baseUrl } = require('../../../request');
|
2025-05-17 15:17:14 +00:00
|
|
|
|
2025-05-19 01:08:33 +00:00
|
|
|
Page({
|
2025-05-17 15:17:14 +00:00
|
|
|
data: {
|
2025-05-19 01:08:33 +00:00
|
|
|
projectId: '', // 项目id
|
|
|
|
promoCodeDesc: '', // 富文本推广码说明
|
|
|
|
salespersonName: '',
|
|
|
|
salespersonPhone: '',
|
|
|
|
mode: 'add' // 'add'(新增) or 'view'(查看资料)
|
2025-05-17 15:17:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onLoad(options) {
|
2025-05-19 01:08:33 +00:00
|
|
|
this.setData({
|
|
|
|
projectId: options.id || '',
|
|
|
|
promoCodeDesc: decodeURIComponent(options.desc || ''),
|
|
|
|
mode: options.mode || 'add',
|
|
|
|
salespersonName: options.name ? decodeURIComponent(options.name) : '',
|
|
|
|
salespersonPhone: options.phone ? decodeURIComponent(options.phone) : ''
|
|
|
|
});
|
2025-05-17 15:17:14 +00:00
|
|
|
},
|
|
|
|
|
2025-05-19 01:08:33 +00:00
|
|
|
// 输入绑定
|
|
|
|
onNameInput(e) {
|
|
|
|
// 仅在新增模式允许编辑
|
|
|
|
if (this.data.mode !== 'view') {
|
|
|
|
this.setData({ salespersonName: e.detail.value });
|
|
|
|
}
|
2025-05-17 15:17:14 +00:00
|
|
|
},
|
2025-05-19 01:08:33 +00:00
|
|
|
onPhoneInput(e) {
|
|
|
|
if (this.data.mode !== 'view') {
|
|
|
|
this.setData({ salespersonPhone: e.detail.value });
|
|
|
|
}
|
2025-05-17 15:17:14 +00:00
|
|
|
},
|
|
|
|
|
2025-05-19 01:08:33 +00:00
|
|
|
// 申请资料报备
|
|
|
|
onApply() {
|
|
|
|
// 如果是查看模式,阻止提交
|
|
|
|
if (this.data.mode === 'view') return;
|
|
|
|
|
|
|
|
const { salespersonName, salespersonPhone, projectId } = this.data;
|
|
|
|
|
|
|
|
if (!salespersonName.trim()) {
|
|
|
|
wx.showToast({ title: '请输入业务员姓名', icon: 'none' });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const phoneReg = /^1[3-9]\d{9}$/;
|
|
|
|
if (!salespersonPhone.trim()) {
|
|
|
|
wx.showToast({ title: '请输入手机号', icon: 'none' });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!phoneReg.test(salespersonPhone.trim())) {
|
|
|
|
wx.showToast({ title: '手机号格式不正确', icon: 'none' });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const token = wx.getStorageSync('token');
|
|
|
|
wx.request({
|
|
|
|
url: baseUrl + '/promoCodeApply/apply',
|
|
|
|
method: 'POST',
|
|
|
|
header: {
|
|
|
|
'Authorization': token,
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
salespersonName,
|
|
|
|
salespersonPhone,
|
|
|
|
projectId
|
|
|
|
},
|
|
|
|
success: (res) => {
|
|
|
|
if (res.data.code === 1) {
|
|
|
|
wx.showToast({
|
|
|
|
title: '申请成功',
|
|
|
|
icon: 'success',
|
|
|
|
duration: 1000
|
|
|
|
});
|
|
|
|
setTimeout(() => {
|
|
|
|
wx.navigateBack();
|
|
|
|
}, 1000);
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
title: res.data.message || '申请失败',
|
|
|
|
icon: 'none'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail: () => {
|
|
|
|
wx.showToast({
|
|
|
|
title: '网络错误',
|
|
|
|
icon: 'none'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2025-05-17 15:17:14 +00:00
|
|
|
}
|
2025-05-19 01:08:33 +00:00
|
|
|
});
|