|
@@ -19,10 +19,11 @@ $(document).on("click", ".close", function (event) {
|
|
|
$(".collectcontent").removeClass("select");
|
|
|
});
|
|
|
|
|
|
+let userId;
|
|
|
// 收藏頁面
|
|
|
function collection(collectuserid='') {
|
|
|
console.log('Call collection(' + collectuserid + ')'); // test
|
|
|
-
|
|
|
+ userId = collectuserid;
|
|
|
var collectcontent = '';
|
|
|
|
|
|
$.ajax({
|
|
@@ -40,12 +41,15 @@ function collection(collectuserid='') {
|
|
|
for(let i = 0; i < len; i++) {
|
|
|
arr.push(msg[i]);
|
|
|
}
|
|
|
+ arr = arr.filter((item, i) => {
|
|
|
+ return item !== undefined;
|
|
|
+ })
|
|
|
console.log(arr);
|
|
|
for(let i = 0; i < arr.length; i++) {
|
|
|
collectcontent += '\
|
|
|
<div class="collectcontent col">\
|
|
|
- <input style="display: none;" type="radio" value="'+ arr[i].id + '" name="nftid" id="' + arr[i].id + '">\
|
|
|
- <label for="'+ arr[i].id + '">\
|
|
|
+ <input style="display: none;" type="radio" value="'+ arr[i].uid + '" name="nftid" id="' + arr[i].uid + '">\
|
|
|
+ <label for="'+ arr[i].uid + '">\
|
|
|
<div class="collectcard card h-100">\
|
|
|
<a target="_blank">\
|
|
|
<img src="'+ arr[i].imgurl + '"class="card-img-top" alt="...">\
|
|
@@ -179,32 +183,29 @@ $.fn.serializeObject = function () {
|
|
|
|
|
|
// 確定發送按鈕處理
|
|
|
$(".collect-send").submit(function (e) {
|
|
|
- var nftid = $("input[name='nftid']:checked").val();
|
|
|
+ var nftuid = $("input[name='nftid']:checked").val();
|
|
|
+ var amount = $("input[name='amount']").val();
|
|
|
var address = $('#address').val();
|
|
|
-
|
|
|
- var data = `{"nftid":"` + nftid +`","address":"` + address +`"}`;
|
|
|
+ console.log(amount);
|
|
|
+ var data = `{"nftuid": ${nftuid}, "to": "${address}", "userid": "${userId}", "amount": ${amount}}`;
|
|
|
|
|
|
+ var headers = {'accept': 'application/json'}
|
|
|
console.log(data); // test
|
|
|
-
|
|
|
- var url = "https://api.ptt.cx:8750/api/v1/line/send";
|
|
|
-
|
|
|
- var xhr = new XMLHttpRequest();
|
|
|
- xhr.open("POST", url, false);
|
|
|
-
|
|
|
- xhr.setRequestHeader("accept", "application/json");
|
|
|
- xhr.setRequestHeader("Content-Type", "application/json");
|
|
|
-
|
|
|
- xhr.onreadystatechange = function () {
|
|
|
- if (xhr.readyState === 4) {
|
|
|
- console.log(xhr.status);
|
|
|
- console.log(xhr.responseText);
|
|
|
|
|
|
- alert("發送成功");
|
|
|
- location.replace("collect.html");
|
|
|
- }
|
|
|
- };
|
|
|
+ var url = `https://api.ptt.cx:8750/api/v1/line/send?userid=${userId}&to=${address}&nftuid=${nftuid}&amount=${amount}`;
|
|
|
+ axios({
|
|
|
+ method: 'post',
|
|
|
+ url: url,
|
|
|
+ headers,
|
|
|
+ data: ''
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res);
|
|
|
+ window.location.href = './collect.html';
|
|
|
|
|
|
- xhr.send(data);
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err);
|
|
|
+ })
|
|
|
+
|
|
|
});
|
|
|
|
|
|
$(".nft-buy").submit(function (e) {
|