修改了联系方式
This commit is contained in:
@@ -222,9 +222,9 @@ async fn get_workorders(range: String) -> Result<WorkOrderResponse, String> {
|
|||||||
|
|
||||||
|
|
||||||
#[tauri::command]
|
#[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")?;
|
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
|
.await
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,12 @@ pub fn add(left: u64, right: u64) -> u64 {
|
|||||||
left + right
|
left + right
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_ticket(cookie: &str, n2p: &str, massageQ: &str, wx: &str) -> Result<String, reqwest::Error> {
|
pub async fn create_ticket(cookie: &str, n2p: &str, massageQ: &str, wx: Option<&str>, mobile: Option<&str>) -> Result<String, reqwest::Error> {
|
||||||
println!("cookie={},n2n={},问题={}, 微信={}", cookie, n2p, massageQ, wx);
|
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
|
// 1. Create a cookie jar and a single client for all requests
|
||||||
let jar = Arc::new(Jar::default());
|
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.
|
// 7. Now the jar should contain all necessary cookies.
|
||||||
// We can proceed to create the work order.
|
// We can proceed to create the work order.
|
||||||
|
|
||||||
let form_data = &[
|
let mut form_data = vec![
|
||||||
("type", "99"),
|
("type", "99"),
|
||||||
("describe", massageQ),
|
("describe", massageQ),
|
||||||
("input_file[]", ""),
|
("input_file[]", ""),
|
||||||
("contact_way", "wx"),
|
|
||||||
("contact", wx),
|
|
||||||
("visit_way", "1"),
|
("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 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_bytes = res.bytes().await?;
|
||||||
let response_body = String::from_utf8_lossy(&response_bytes).to_string();
|
let response_body = String::from_utf8_lossy(&response_bytes).to_string();
|
||||||
|
|
||||||
|
|||||||
@@ -170,13 +170,20 @@ async function createWorkOrder() {
|
|||||||
log.value = '开始创建工单...\n';
|
log.value = '开始创建工单...\n';
|
||||||
try {
|
try {
|
||||||
const massageQ = `${form.messageQ}${form.gh}`;
|
const massageQ = `${form.messageQ}${form.gh}`;
|
||||||
log.value += `调用 create_ticket...\n参数: n2p=${form.n2nip}, massageQ=${massageQ}, wx=${form.contact}\n`;
|
const ticketPayload = {
|
||||||
|
|
||||||
const code = await invoke('create_ticket_command', {
|
|
||||||
n2p: form.n2nip,
|
n2p: form.n2nip,
|
||||||
massageQ: massageQ,
|
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 += `工单创建请求成功,返回代码: ${code}\n`;
|
||||||
log.value += '正在将工单写入数据库...\n';
|
log.value += '正在将工单写入数据库...\n';
|
||||||
|
|||||||
Reference in New Issue
Block a user