goto.js 12 KB

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