16 changed files with 169 additions and 34 deletions
@ -0,0 +1,93 @@ |
|||
<?php |
|||
include "T8_Authorization.php"; |
|||
echo "ii"; |
|||
?> |
|||
<script> |
|||
get_Auth(); |
|||
window.addEventListener('message', function(event) { |
|||
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { |
|||
var validation = event.data; |
|||
console.log("event"); |
|||
console.log(validation); |
|||
|
|||
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; |
|||
var apiurl = 'http://60.244.87.101:880/twWebAPI/V1/APCHECKBILL/PostERPData'; |
|||
headerParam = { |
|||
CHI_Authorization: `${validation}`, |
|||
}; |
|||
var body = [{ |
|||
"name": "MasterTable", |
|||
"rows": [{ |
|||
"BillNo": "Z003", |
|||
"BillDate": 20230930, |
|||
"OrgId": "1000", |
|||
"TypeId": "OPV", |
|||
"BizPartnerId": "03051501", |
|||
"CurrId": "RMB", |
|||
"CurrOAmount":1, |
|||
"CurrLAmount":5, |
|||
"TaxId": "ST005", |
|||
"PersonId": "M0008", |
|||
"DeptId": "220", |
|||
"CompId": "1001", |
|||
"CreditAgeDate": 20230930, |
|||
"RecBizPartnerId": "03051501", |
|||
"CreatorId":"M0005", |
|||
"IsPriceWithTax":1, |
|||
"IsCounteract":1 |
|||
}] |
|||
}, |
|||
{ |
|||
"name": "DetailTable", |
|||
"rows": [{ |
|||
"BillNo": "Z003", |
|||
"RowCode": 1, |
|||
"RowNo": 1, |
|||
"ItemType": 0, |
|||
"MaterialId": "MX00000001", |
|||
"UnitId": "PCS", |
|||
"MaterialSpec": "", |
|||
"SQuantity": 10, |
|||
"SPrice": 105, |
|||
"OAmount": 1000, |
|||
"OTax": 50, |
|||
"OAmountWithTax": 1050, |
|||
"TaxId": "ST005" |
|||
}, |
|||
{ |
|||
"BillNo": "Z003", |
|||
"RowCode": 2, |
|||
"RowNo": 2, |
|||
"ItemType": 0, |
|||
"MaterialId": "MX00000001", |
|||
"UnitId": "PCS", |
|||
"MaterialSpec": "", |
|||
"SQuantity": 15, |
|||
"SPrice": 210, |
|||
"OAmount": 3000, |
|||
"OTax": 150, |
|||
"OAmountWithTax": 3150, |
|||
"TaxId": "ST005" |
|||
} |
|||
] |
|||
} |
|||
]; |
|||
var json = JSON.stringify(body); |
|||
obj = { |
|||
type: 'POST', |
|||
// url: `${corsurl}${apiurl}`, |
|||
url: `${apiurl}`, |
|||
// dataType: 'json', |
|||
headers: headerParam, |
|||
data: json, |
|||
dataType: "json", |
|||
success: function(res) { |
|||
console.log(res.Status); |
|||
console.log(res.ErrorMsg); |
|||
console.log(res.Data); |
|||
} |
|||
}; |
|||
jQuery.ajax(obj); |
|||
} |
|||
}) |
|||
</script> |
@ -0,0 +1,55 @@ |
|||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> |
|||
<?php |
|||
$now = gmdate("YmdHis"); |
|||
$data = 'M0000.' . $now; |
|||
$sign = hash_hmac('SHA256', $data, '964C834F7BF2BB70', false); |
|||
|
|||
?> |
|||
|
|||
<script> |
|||
// var api_key = '964C834F7BF2BB70'; |
|||
// var validation = ""; |
|||
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; |
|||
// headerParam = { |
|||
// UserId: 'M0000', |
|||
// Pwd: 'M012290493119', |
|||
// TimestampUTC: <?= $now ?>, |
|||
// Sign: '<?= $sign ?>' |
|||
// }; |
|||
|
|||
// obj = { |
|||
// type: 'get', |
|||
// url: `${apiurl}`, |
|||
// dataType: 'json', |
|||
// headers: headerParam, |
|||
// crossDomain: true, |
|||
// success: function(res) { |
|||
// validation = res.Data['CHI_Authorization']; |
|||
// }, |
|||
// error: function(err){ |
|||
// console.log(err); |
|||
// } |
|||
// }; |
|||
// jQuery.ajax(obj); |
|||
fetch('http://60.244.87.101:880//twWebAPI/GetAuth', { |
|||
method: 'GET', |
|||
headers: { |
|||
'Origin': 'https://www.masada.com.tw', |
|||
'Access-Control-Request-Method': 'GET', |
|||
'Access-Control-Request-Headers': 'X-Requested-With, Content-Type' |
|||
} |
|||
}) |
|||
.then(function(response) { |
|||
if (response.ok) { |
|||
return response.json(); |
|||
} else { |
|||
throw new Error('網絡錯誤'); |
|||
} |
|||
}) |
|||
.then(function(data) { |
|||
// 處理成功的回應 |
|||
}) |
|||
.catch(function(error) { |
|||
// 處理錯誤 |
|||
}); |
|||
</script> |
Loading…
Reference in new issue