goto.js 12 KB

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