goto.js 11 KB

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