goto.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. // $('.sec05-moblie-container').slick({
  2. // arrows: false,
  3. // slidesToShow: 1,
  4. // slidesToScroll: 1,
  5. // infinite: false,
  6. // centerMode: true,
  7. // });
  8. $(".sendbox").hide();
  9. $(document).on("click", ".collectcontent", function (event) {
  10. $(".sendbox").show(500);
  11. $(this).addClass("select");
  12. $(".select").siblings().removeClass('select');
  13. });
  14. $(document).on("click", ".close", function (event) {
  15. // $(this).siblings('.collectcard').removeClass('select');
  16. $(".sendbox").hide(500);
  17. $(".collectcontent").removeClass("select");
  18. });
  19. // 收藏頁面
  20. function collection(collectuserid='') {
  21. console.log('Call collection(' + collectuserid + ')'); // test
  22. var collectcontent = '';
  23. $.ajax({
  24. method: "GET",
  25. url: "https://ark.cards:8228/collection/" + collectuserid + "",
  26. dataType: "json",
  27. })
  28. .done(function (msg) {
  29. for (var i in msg) {
  30. for(var j in msg[i]) {
  31. collectcontent += '\
  32. <div class="collectcontent col">\
  33. <input style="display: none;" type="checkbox" value="'+ msg[i][j].id + '" name="nftid" id="' + msg[i][j].id + '">\
  34. <label for="'+ msg[i][j].id + '">\
  35. <div class="collectcard card h-100">\
  36. <a target="_blank">\
  37. <img src="'+ msg[i][j].imgurl + '"class="card-img-top" alt="...">\
  38. </a>\
  39. <div class="card-body p-2">\
  40. <a target="_blank">\
  41. <h5 class="card-title pt-3">'+ msg[i][j].title + '</h5>\
  42. </a>\
  43. </div>\
  44. </div>\
  45. </label>\
  46. </div>';
  47. /*
  48. collectcontent += '\
  49. <div class="collectcontent col">\
  50. <input style="display: none;" type="checkbox" value="'+ msg[i][j].id + '" name="nftid" id="' + msg[i][j].id + '">\
  51. <label for="'+ msg[i][j].id + '">\
  52. <div class="collectcard card h-100">\
  53. <a target="_blank">\
  54. <img src="'+ msg[i][j].imgurl + '"class="card-img-top" alt="...">\
  55. </a>\
  56. <div class="card-body p-2">\
  57. <a target="_blank">\
  58. <h5 class="card-title pt-3">'+ msg[i][j].title + '</h5>\
  59. </a>\
  60. <p class="card-text">\
  61. '+ msg[i][j].context + ' \
  62. </p>\
  63. <p class="card-text row">\
  64. <small class="text-muted col-6 px-1">\
  65. <img class="mb-1 mx-1 d-inline" style="width: 10px; object-fit: cover; "\
  66. src="./img/sec05/Icon awesome-ethereum.png" alt=""><span>'+ msg[i][j].cost + '</span>\
  67. </small>\
  68. <small class="price col-6 px-0 text-center">\
  69. <img class="mb-1 mx-1 d-inline" style="width: 12px; object-fit: cover; " src="./img/sec05/like.png" alt=""><sp an>'+ msg[i][j].likes + '</span></small>\
  70. </p>\
  71. </div>\
  72. </div>\
  73. </label>\
  74. </div>';
  75. */
  76. }
  77. }
  78. $('.sec05-moblie-container').html(collectcontent);
  79. });
  80. }
  81. // 購買頁面
  82. function shop(collectuserid='') {
  83. console.log('Call shop(' + collectuserid + ')'); // test
  84. $.ajax({
  85. method: "GET",
  86. url: "https://ark.cards:8228/shop/" + collectuserid + "",
  87. // url: "https://ark.cards:8228/shop/Uf161c92b16f84357987a78c2b4b47719",
  88. dataType: "json",
  89. })
  90. .done(function (msg) {
  91. console.log(msg);
  92. // console.log(Object.keys(msg).length);
  93. let msgLen = Object.keys(msg).length;
  94. console.log(msgLen);
  95. var nftmall = '';
  96. var buybox = "";
  97. for (var i = 0; i < msgLen; i++) {
  98. nftmall += '\
  99. <div class="nftmall col">\
  100. <input style="display:none" type="checkbox" value="'+ msg[i].id + '" name="nftid" class="nftname" id="' + msg[i].id + '">\
  101. <label for="'+ msg[i].id + '">\
  102. <div class="collectcard card h-100">\
  103. <a target="_blank">\
  104. <img src="'+ msg[i].imgurl + '"class="card-img-top" alt="...">\
  105. </a>\
  106. <div class="card-body p-2">\
  107. <a target="_blank">\
  108. <h5 class="card-title pt-3">'+ msg[i].title + '</h5>\
  109. </a>\
  110. </div>\
  111. </div>\
  112. </label>\
  113. </div>';
  114. /*
  115. nftmall += '\
  116. <div class="nftmall col">\
  117. <input style="display:none" type="checkbox" value="'+ msg[i].id + '" name="nftid" class="nftname" id="' + msg[i].id + '">\
  118. <label for="'+ msg[i].id + '">\
  119. <div class="collectcard card h-100">\
  120. <a target="_blank">\
  121. <img src="'+ msg[i].imgurl + '"class="card-img-top" alt="...">\
  122. </a>\
  123. <div class="card-body p-2">\
  124. <a target="_blank">\
  125. <h5 class="card-title pt-3">'+ msg[i].title + '</h5>\
  126. </a>\
  127. <p class="card-text">\
  128. '+ msg[i].context + ' \
  129. </p>\
  130. <p class="card-text row">\
  131. <small class="text-muted col-6 px-1">\
  132. <img class="mb-1 mx-1 d-inline" style="width: 10px; object-fit: cover; "\
  133. src="./img/sec05/Icon awesome-ethereum.png" alt=""><span>'+ msg[i].cost + '</span>\
  134. </small>\
  135. <small class="price col-6 px-0 text-center">\
  136. <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>\
  137. </small>\
  138. </p>\
  139. </div>\
  140. </div>\
  141. </label>\
  142. </div>';
  143. */
  144. }
  145. buybox += '\
  146. <div class="p-2">\
  147. <input style="border-radius: 10px; border:none; display: none;" class="p-2 w-100 mb-3" type="text" name="userid" value="' + collectuserid + '" placeholder="請輸入您的userid" required>\
  148. <div class="text-end px-2">\
  149. <p class="text-start text-white mb-2">※一次只能購買一則NFT收藏品</p>\
  150. <button type="button" style="border:1px solid #fff; border-radius: 30px;" class="close btn text-white px-3">取消</button>\
  151. <input style="border-radius: 30px; background:#fff; border: none;" class="send-btn px-3 ms-1 py-2" type="submit" value="購買">\
  152. </div>\
  153. </div>\
  154. </div>';
  155. $('.sec06-nft-mall').html(nftmall);
  156. $('.buybox').html(buybox);
  157. });
  158. }
  159. // Qrcode頁面
  160. function get_data(collectuserid='') {
  161. console.log('Call get_data(' + collectuserid + ')'); // test
  162. $.ajax({
  163. method: "GET",
  164. url: "https://ark.cards:8228/receive/" + collectuserid + "",
  165. // url:"https://api.ptt.cx:8228/receive/Uf161c92b16f84357987a78c2b4b47719",
  166. dataType: "json",
  167. })
  168. .done(function (msg) {
  169. console.log(msg);
  170. var Qrcodeimg = '';
  171. var useraddress = '';
  172. Qrcodeimg += '\
  173. <img class="img-fluid" src="./qrcode/'+ collectuserid + '.png" alt="">\
  174. ';
  175. useraddress += '\
  176. '+ msg.useraddress + '\
  177. ';
  178. $('#Qrcode').html(Qrcodeimg);
  179. $('#copy').html(useraddress);
  180. });
  181. }
  182. // $(document).ready(function () {
  183. // // 收藏頁面
  184. // collection(collectuserid);
  185. // // 購買頁面
  186. // shop(collectuserid);
  187. // // Qrcode頁面
  188. // get_data(collectuserid);
  189. // });
  190. $(".buybox").hide();
  191. $(document).on("click", ".nftmall", function (event) {
  192. $(".buybox").show(500);
  193. $(this).addClass("select");
  194. $(".select").siblings().removeClass('select');
  195. });
  196. $(document).on("click", ".close", function (event) {
  197. // $(this).siblings('.collectcard').removeClass('select');
  198. $(".buybox").hide(500);
  199. $(".nftmall").removeClass("select");
  200. $(".nftname").prop("checked", false);
  201. });
  202. $.fn.serializeObject = function () {
  203. var o = {};
  204. var a = this.serializeArray();
  205. // o["id"] = 0;
  206. // o["time_stamp"] = "";
  207. $.each(a, function () {
  208. if (o[this.name]) {
  209. console.log(o[this.name], o[this.value]); // test
  210. if (!o[this.name].push) {
  211. o[this.name] = [o[this.name]];
  212. }
  213. o[this.name].push(this.value || '');
  214. } else {
  215. o[this.name] = this.value || '';
  216. }
  217. });
  218. return o;
  219. };
  220. // 確定發送按鈕處理
  221. $(".collect-send").submit(function (e) {
  222. /* var formRef = $('#form1').serializeArray();
  223. var jsonString = JSON.stringify(formRef);*/
  224. var jsonInfo = $('.collect-send').serializeObject();
  225. var jsonString = JSON.stringify(jsonInfo);
  226. console.log(jsonString);
  227. $.ajax({
  228. type: 'POST',
  229. url: 'https://ark.cards:8228/send',
  230. data: jsonString,
  231. dataType: 'json',
  232. async: false,
  233. success: function (data) {
  234. console.log('發送成功: ' + JSON.stringify(data));
  235. alert("發送成功");
  236. location.reload();
  237. },
  238. beforeSend: function () {
  239. console.log('beforeSend');
  240. },
  241. complete: function () {
  242. console.log('complete');
  243. },
  244. error: function (jqXHR, textStatus, errorThrown) {
  245. console.log(JSON.stringify(jqXHR));
  246. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  247. console.log('送出失敗: ' + jqXHR.responseText);
  248. }
  249. });
  250. return false;
  251. });
  252. $(".nft-buy").submit(function (e) {
  253. /* var formRef = $('#form1').serializeArray();
  254. var jsonString = JSON.stringify(formRef);*/
  255. var jsonInfo = $('.nft-buy').serializeObject();
  256. var jsonString = JSON.stringify(jsonInfo);
  257. console.log(jsonString),
  258. $.ajax({
  259. type: 'POST',
  260. url: 'https://ark.cards:8228/buy',
  261. data: jsonString,
  262. dataType: 'json',
  263. success: function (data) {
  264. console.log('購買成功: ' + data);
  265. alert("購買成功");
  266. location.reload();
  267. },
  268. beforeSend: function () {
  269. console.log('beforeSend');
  270. },
  271. complete: function () {
  272. console.log('complete');
  273. },
  274. error: function (jqXHR, textStatus, errorThrown) {
  275. console.log(JSON.stringify(jqXHR));
  276. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  277. console.log('送出失敗: ' + jqXHR.responseText);
  278. }
  279. });
  280. return false;
  281. });
  282. function copyEvent(id) {
  283. var str = document.getElementById(id);
  284. window.getSelection().selectAllChildren(str);
  285. document.execCommand("Copy")
  286. toastr.options = {
  287. // 參數設定[註1]
  288. "closeButton": false, // 顯示關閉按鈕
  289. "debug": false, // 除錯
  290. "newestOnTop": false, // 最新一筆顯示在最上面
  291. "progressBar": false, // 顯示隱藏時間進度條
  292. "positionClass": "toast-top-center", // 位置的類別
  293. "preventDuplicates": false, // 隱藏重覆訊息
  294. "onclick": null, // 當點選提示訊息時,則執行此函式
  295. "showDuration": "300", // 顯示時間(單位: 毫秒)
  296. "hideDuration": "1000", // 隱藏時間(單位: 毫秒)
  297. "timeOut": "1000", // 當超過此設定時間時,則隱藏提示訊息(單位: 毫秒)
  298. "extendedTimeOut": "1000", // 當使用者觸碰到提示訊息時,離開後超過此設定時間則隱藏提示訊息(單位: 毫秒)
  299. "showEasing": "swing", // 顯示動畫時間曲線
  300. "hideEasing": "linear", // 隱藏動畫時間曲線
  301. "showMethod": "fadeIn", // 顯示動畫效果
  302. "hideMethod": "fadeOut" // 隱藏動畫效果
  303. }
  304. toastr.success("複製成功");
  305. }