goto.js 12 KB

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