post改为json方式
parent
069c3013e9
commit
c58f251953
|
@ -30,7 +30,7 @@ AppFluWindow {
|
|||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
Rectangle {
|
||||
width: parent.width * 0.5
|
||||
height: parent.height
|
||||
color: "#f3f3f3"
|
||||
|
@ -91,28 +91,30 @@ AppFluWindow {
|
|||
//normalColor: "#ffffff"
|
||||
text: "登录"
|
||||
onClicked: {
|
||||
var param ={
|
||||
username: account.text,
|
||||
password: password.text
|
||||
var param = {
|
||||
"username": account.text,
|
||||
"password": password.text
|
||||
}
|
||||
|
||||
Request.post("login",JSON.toString(param), function(result, data) {
|
||||
console.log(result)
|
||||
console.log(data)
|
||||
FluApp.navigate("/");
|
||||
window.close();
|
||||
}, function() {
|
||||
FluApp.navigate("/");
|
||||
window.close();
|
||||
})
|
||||
|
||||
Request.post("login",
|
||||
JSON.stringify(param),
|
||||
function (result, data) {
|
||||
console.log(result)
|
||||
console.log(data)
|
||||
FluApp.navigate("/")
|
||||
window.close()
|
||||
}, function (p1, p2) {
|
||||
console.log(p1)
|
||||
console.log(p2)
|
||||
//FluApp.navigate("/");
|
||||
//window.close();
|
||||
})
|
||||
|
||||
//HttpClient.doGetRequest(
|
||||
// "https://quic.aiortc.org/",
|
||||
// loginItem, "login")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// FluPivotItem {
|
||||
|
@ -125,6 +127,5 @@ AppFluWindow {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,6 +122,20 @@ FluWindow {
|
|||
title_bar.maximizeButton.visible = true
|
||||
// window.backgroundVisible = false
|
||||
window.show()
|
||||
|
||||
Request.post(
|
||||
"knowledge/file", "{\n"
|
||||
+ " \"name\": \"特东局却热\",\n" + " \"brief\": \"fugiat occaecat\",\n"
|
||||
+ " \"size\": 88,\n" + " \"sha256\": \"ea incididunt pariatur\",\n"
|
||||
+ " \"tags\": [\n" + " 43,\n"
|
||||
+ " 45\n" + " ],\n" + " \"parentId\": \"4\"\n" + "}",
|
||||
function (p1, p2) {
|
||||
console.log(p1)
|
||||
console.log(p2)
|
||||
}, function (p1, p2) {
|
||||
console.log(p1)
|
||||
console.log(p2)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ import QtQuick
|
|||
QtObject {
|
||||
id: request
|
||||
|
||||
property string baseUrl: "http://127.0.0.1:4523/m1/2914957-0-5604d062/"
|
||||
property string baseUrl: "http://127.0.0.1:4523/m1/2914957-0-default/"
|
||||
//property string baseUrl: "http://192.168.156.74:8080/"
|
||||
|
||||
// GET
|
||||
function get(url, success, failure) {
|
||||
|
@ -20,17 +21,30 @@ QtObject {
|
|||
// POST
|
||||
function post(url, arg, success, failure) {
|
||||
var xhr = new XMLHttpRequest
|
||||
xhr.open("POST", baseUrl + url)
|
||||
xhr.setRequestHeader("Content-Length", arg.length)
|
||||
xhr.setRequestHeader(
|
||||
"Content-Type",
|
||||
"application/x-www-form-urlencoded;") //用POST的时候一定要有这句
|
||||
xhr.open("POST", baseUrl + url, true)
|
||||
xhr.setRequestHeader('Content-Type', 'application/json')
|
||||
xhr.withCredentials = true
|
||||
xhr.onreadystatechange = function () {
|
||||
handleResponse(xhr, success, failure)
|
||||
}
|
||||
xhr.send(arg)
|
||||
}
|
||||
|
||||
|
||||
/* function post(url, arg, success, failure) {
|
||||
var xhr = new XMLHttpRequest
|
||||
xhr.open("POST", baseUrl + url)
|
||||
xhr.setRequestHeader("Content-Length", arg.length)
|
||||
xhr.setRequestHeader(
|
||||
"Content-Type",
|
||||
"application/x-www-form-urlencoded;") //用POST的时候一定要有这句
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
handleResponse(xhr, success, failure)
|
||||
}
|
||||
xhr.send(arg)
|
||||
}*/
|
||||
|
||||
// 处理返回值
|
||||
function handleResponse(xhr, success, failure) {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
|
|
|
@ -128,6 +128,7 @@ FluArea {
|
|||
right: layout_like.left
|
||||
rightMargin: 20
|
||||
}
|
||||
onClicked: function () {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue