goto.js 12 KB

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