修改了联系方式

This commit is contained in:
Yakumo Hokori
2025-07-12 23:15:38 +08:00
parent 93ce1ae6ad
commit 0736ff58b9
3 changed files with 30 additions and 13 deletions

View File

@@ -222,9 +222,9 @@ async fn get_workorders(range: String) -> Result<WorkOrderResponse, String> {
#[tauri::command]
async fn create_ticket_command(n2p: String, massage_q: String, wx: String) -> Result<String, String> {
async fn create_ticket_command(n2p: String, massage_q: String, wx: Option<String>, mobile: Option<String>) -> Result<String, String> {
let cookie = COOKIE_STORAGE.lock().unwrap().clone().ok_or("未找到登录Cookie")?;
tms_service::create_ticket(&cookie, &n2p, &massage_q, &wx)
tms_service::create_ticket(&cookie, &n2p, &massage_q, wx.as_deref(), mobile.as_deref())
.await
.map_err(|e| e.to_string())
}

View File

@@ -12,8 +12,12 @@ pub fn add(left: u64, right: u64) -> u64 {
left + right
}
pub async fn create_ticket(cookie: &str, n2p: &str, massageQ: &str, wx: &str) -> Result<String, reqwest::Error> {
println!("cookie={},n2n={},问题={}, 微信={}", cookie, n2p, massageQ, wx);
pub async fn create_ticket(cookie: &str, n2p: &str, massageQ: &str, wx: Option<&str>, mobile: Option<&str>) -> Result<String, reqwest::Error> {
if let Some(wx_val) = wx {
println!("cookie={},n2n={},问题={}, 微信={}", cookie, n2p, massageQ, wx_val);
} else if let Some(mobile_val) = mobile {
println!("cookie={},n2n={},问题={}, 手机={}", cookie, n2p, massageQ, mobile_val);
}
// 1. Create a cookie jar and a single client for all requests
let jar = Arc::new(Jar::default());
@@ -66,18 +70,24 @@ pub async fn create_ticket(cookie: &str, n2p: &str, massageQ: &str, wx: &str) ->
// 7. Now the jar should contain all necessary cookies.
// We can proceed to create the work order.
let form_data = &[
let mut form_data = vec![
("type", "99"),
("describe", massageQ),
("input_file[]", ""),
("contact_way", "wx"),
("contact", wx),
("visit_way", "1"),
];
if let Some(wx_val) = wx {
form_data.push(("contact_way", "wx"));
form_data.push(("contact", wx_val));
} else if let Some(mobile_val) = mobile {
form_data.push(("contact_way", "mobile"));
form_data.push(("contact", mobile_val));
}
let post_url = "https://c.baobaot.com/cinema/workorder/ajax_create";
let res = client.post(post_url).form(form_data).send().await?;
let res = client.post(post_url).form(&form_data).send().await?;
let response_bytes = res.bytes().await?;
let response_body = String::from_utf8_lossy(&response_bytes).to_string();

View File

@@ -170,13 +170,20 @@ async function createWorkOrder() {
log.value = '开始创建工单...\n';
try {
const massageQ = `${form.messageQ}${form.gh}`;
log.value += `调用 create_ticket...\n参数: n2p=${form.n2nip}, massageQ=${massageQ}, wx=${form.contact}\n`;
const code = await invoke('create_ticket_command', {
const ticketPayload = {
n2p: form.n2nip,
massageQ: massageQ,
wx: form.contact,
});
};
if (form.contact_way === 'wx') {
ticketPayload.wx = form.contact;
log.value += `调用 create_ticket...\n参数: n2p=${form.n2nip}, massageQ=${massageQ}, wx=${form.contact}\n`;
} else if (form.contact_way === 'mobile') {
ticketPayload.mobile = form.contact;
log.value += `调用 create_ticket...\n参数: n2p=${form.n2nip}, massageQ=${massageQ}, mobile=${form.contact}\n`;
}
const code = await invoke('create_ticket_command', ticketPayload);
log.value += `工单创建请求成功,返回代码: ${code}\n`;
log.value += '正在将工单写入数据库...\n';