goto.js 9.6 KB

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