浏览代码

程式寫法改寫

Mike 3 年之前
父节点
当前提交
1a6843a158
共有 1 个文件被更改,包括 49 次插入109 次删除
  1. 49 109
      ArkCard-web/goto.js

+ 49 - 109
ArkCard-web/goto.js

@@ -22,68 +22,61 @@ $(document).on("click", ".close", function (event) {
 var collectuserid = 'U176663ce100ebb1f4c404d48749decb1'; // test
 
 // 收藏頁面
-$(document).ready(function () {
-  // collecturl = location.search;
-  // collecturl = collecturl.split("&")[0];
-  // console.log("collecturl = " + collecturl); // test
-  // getcollect = collecturl.split("?");
-  // var collectuserid = getcollect[1];
-  // console.log(collecturl);
-  
+function collection(collectuserid) {
+  console.log('call collection(' + collectuserid + ')'); // test
+
   $.ajax({
     method: "GET",
     url: "https://ark.cards:8228/collection/" + collectuserid + "",
-    //  url: "https://ark.cards:8228/collection/U09a0698f2a5d41bccbbd03ca988a1d15",
-    //  url: "https://ark.cards:8228/collection/Uf161c92b16f84357987a78c2b4b47719",
-
     dataType: "json",
   })
-    .done(function (msg) {
-      console.log(msg);
-      // console.log(Object.keys(msg).length);
-      let msgLen = Object.keys(msg).length;
-      console.log(msgLen);
-      var collectcontent = '';
-      if (msg[0].id == undefined) {
-        collectcontent += '<p>' + msg + '</p>';
-      } else {
-          for (var i = 0; i < msgLen; i++) {
-          collectcontent += '\
-            <div class="collectcontent col">\
-            <input style="display: none;" type="checkbox" value="'+ msg[i].id + '" name="nftid" id="' + msg[i].id + '">\
-            <label for="'+ msg[i].id + '">\
-            <div class="collectcard card h-100">\
-                <a target="_blank">\
-                    <img src="'+ msg[i].imgurl + '"class="card-img-top" alt="...">\
-                </a>\
-                <div class="card-body p-2">\
-                    <a target="_blank">\
-                        <h5 class="card-title pt-3">'+ msg[i].title + '</h5>\
-                    </a>\
-                    <p class="card-text">\
-                       '+ msg[i].context + ' \
-                    </p>\
-                    <p class="card-text row">\
-                        <small class="text-muted col-6 px-1">\
-                            <img class="mb-1 mx-1 d-inline" style="width: 10px; object-fit: cover; "\
-                                src="./img/sec05/Icon awesome-ethereum.png" alt=""><span>'+ msg[i].cost + '</span>\
-                        </small>\
-                        <small class="price col-6 px-0 text-center">\
-                            <img class="mb-1 mx-1 d-inline" style="width: 12px; object-fit: cover; " src="./img/sec05/like.png" alt=""><span>'+ msg[i].likes + '</span></small>\
-                        </p>\
-                </div>\
-            </div>\
-            </label>\
-          </div>';
-        }
+  .done(function (msg) {
+    console.log(msg);
+    // console.log(Object.keys(msg).length);
+    let msgLen = Object.keys(msg).length;
+    console.log(msgLen);
+    var collectcontent = '';
+    if (msg[0].id == undefined) {
+      collectcontent += '<p>' + msg + '</p>';
+    } else {
+        for (var i = 0; i < msgLen; i++) {
+        collectcontent += '\
+          <div class="collectcontent col">\
+          <input style="display: none;" type="checkbox" value="'+ msg[i].id + '" name="nftid" id="' + msg[i].id + '">\
+          <label for="'+ msg[i].id + '">\
+          <div class="collectcard card h-100">\
+              <a target="_blank">\
+                  <img src="'+ msg[i].imgurl + '"class="card-img-top" alt="...">\
+              </a>\
+              <div class="card-body p-2">\
+                  <a target="_blank">\
+                      <h5 class="card-title pt-3">'+ msg[i].title + '</h5>\
+                  </a>\
+                  <p class="card-text">\
+                      '+ msg[i].context + ' \
+                  </p>\
+                  <p class="card-text row">\
+                      <small class="text-muted col-6 px-1">\
+                          <img class="mb-1 mx-1 d-inline" style="width: 10px; object-fit: cover; "\
+                              src="./img/sec05/Icon awesome-ethereum.png" alt=""><span>'+ msg[i].cost + '</span>\
+                      </small>\
+                      <small class="price col-6 px-0 text-center">\
+                          <img class="mb-1 mx-1 d-inline" style="width: 12px; object-fit: cover; " src="./img/sec05/like.png" alt=""><span>'+ msg[i].likes + '</span></small>\
+                      </p>\
+              </div>\
+          </div>\
+          </label>\
+        </div>';
       }
+    }
 
+    $('.sec05-moblie-container').html(collectcontent);
+  });
+}
 
-      $('.sec05-moblie-container').html(collectcontent);
-
-
-    });
-
+$(document).ready(function () {
+  // 收藏頁面
+  collection(collectuserid);
 });
 
 $(".buybox").hide();
@@ -251,61 +244,8 @@ $(document).ready(function () {
 
 });
 
-// 購買建
-
-// $(".nft-buy").submit(function (e) {
-//   /*	var formRef = $('#form1').serializeArray();
-//     var jsonString = JSON.stringify(formRef);*/
-//   var jsonInfo = $('.nft-buy').serializeObject();
-//   var jsonString = JSON.stringify(jsonInfo);
-//   console.log(jsonString);
-//   let k = jsonInfo;
-//   let nftproduct = k.nftidval;
-//   console.log(nftproduct);
-
-//   $.ajax({
-//     type: 'GET',
-//     url: "https://api.ptt.cx:8228/buy/" + collectuserid + "/" + nftproduct + "",
-//     data: jsonString,
-//     dataType: 'json',
-//     success: function (data) {
-//       console.log('購買成功: ' + data);
-//       alert("購買成功");
-//       location.reload();
-//     },
-//     beforeSend: function () {
-//       console.log('beforeSend');
-//     },
-//     complete: function () {
-//       console.log('complete');
-//     },
-//     error: function (jqXHR, textStatus, errorThrown) {
-//       console.log(JSON.stringify(jqXHR));
-//       console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
-//       console.log('送出失敗: ' + jqXHR.responseText);
-//     }
-//   });
-//   return false;
-// });
-
-// $(document).ready(function () {
-//   function get_data(){
-//     $.ajax({
-//       method: "GET",
-//       // url:"https://api.ptt.cx:8228/collection/""+userid+",
-//       url:"https://api.ptt.cx:8228/collection/U176663ce100ebb1f4c404d48749decb1_test_000_000_000",
-//       dataType: "json",
-//   })
-//   .done(function (msg) {
-//     console.log(msg);
-//   });
-//   }
-//   get_data();
-//  });
-//  console.log(location.href);
-
 // Qrcode頁面
-// $(document).ready(function () {
+$(document).ready(function () {
   // collecturl = location.search;
   // collecturl = collecturl.split("&")[0];
   // console.log("collecturl = " + collecturl); // test
@@ -335,7 +275,7 @@ $(document).ready(function () {
       });
   }
   get_data();
-// });
+});
 
 function copyEvent(id) {
   var str = document.getElementById(id);