goto.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. var buybox = '';
  144. for (var i = 0; i < msgLen; i++) {
  145. nftmall += '\
  146. <div class="nftmall col">\
  147. <input style="display: none;" type="checkbox" value="'+ msg[i].id + '" name="nftidval" class="nftname" id="' + msg[i].id + '">\
  148. <label for="'+ msg[i].id + '">\
  149. <div class="collectcard card h-100">\
  150. <a target="_blank">\
  151. <img src="'+ msg[i].imgurl + '"class="card-img-top" alt="...">\
  152. </a>\
  153. <div class="card-body p-2">\
  154. <a target="_blank">\
  155. <h5 class="card-title pt-3">'+ msg[i].title + '</h5>\
  156. </a>\
  157. <p class="card-text">\
  158. '+ msg[i].context + ' \
  159. </p>\
  160. <p class="card-text row">\
  161. <small class="text-muted col-6 px-1">\
  162. <img class="mb-1 mx-1 d-inline" style="width: 10px; object-fit: cover; "\
  163. src="./img/sec05/Icon awesome-ethereum.png" alt=""><span>'+ msg[i].cost + '</span>\
  164. </small>\
  165. <small class="price col-6 px-0 text-center">\
  166. <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>\
  167. </p>\
  168. </div>\
  169. </div>\
  170. </label>\
  171. </div>';
  172. }
  173. $('.sec06-nft-mall').html(nftmall);
  174. });
  175. });
  176. var data = document.getElementById('comments').value;
  177. $(".nft-buy").submit(function (e) {
  178. /* var formRef = $('#form1').serializeArray();
  179. var jsonString = JSON.stringify(formRef);*/
  180. var jsonInfo = $('.nft-buy').serializeObject();
  181. var jsonString = JSON.stringify(jsonInfo);
  182. console.log(jsonString);
  183. let k = jsonInfo;
  184. let nftproduct = k.nftidval;
  185. console.log(nftproduct);
  186. $.ajax({
  187. type: 'GET',
  188. url: "https://api.ptt.cx:8228/shop/" + collectuserid + "/" + nftproduct + "",
  189. data: jsonString,
  190. dataType: 'json',
  191. success: function (data) {
  192. console.log('購買成功: ' + data);
  193. alert("購買成功");
  194. // location.reload();
  195. },
  196. beforeSend: function () {
  197. console.log('beforeSend');
  198. },
  199. complete: function () {
  200. console.log('complete');
  201. },
  202. error: function (jqXHR, textStatus, errorThrown) {
  203. console.log(JSON.stringify(jqXHR));
  204. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  205. console.log('送出失敗: ' + jqXHR.responseText);
  206. }
  207. });
  208. return false;
  209. });
  210. // $(document).ready(function () {
  211. // function get_data(){
  212. // $.ajax({
  213. // method: "GET",
  214. // // url:"https://api.ptt.cx:8228/collection/""+userid+",
  215. // url:"https://api.ptt.cx:8228/collection/U176663ce100ebb1f4c404d48749decb1_test_000_000_000",
  216. // dataType: "json",
  217. // })
  218. // .done(function (msg) {
  219. // console.log(msg);
  220. // });
  221. // }
  222. // get_data();
  223. // });
  224. // console.log(location.href);
  225. // Qrcode頁面
  226. $(document).ready(function () {
  227. url = location.search;
  228. getSearch = url.split("?")
  229. var userid = getSearch[1];
  230. function get_data() {
  231. $.ajax({
  232. method: "GET",
  233. url: "https://api.ptt.cx:8228/receive/" + userid + "",
  234. // url:"https://api.ptt.cx:8228/receive/Uf161c92b16f84357987a78c2b4b47719",
  235. dataType: "json",
  236. })
  237. .done(function (msg) {
  238. console.log(msg);
  239. console.log(msg.base)
  240. var Qrcodeimg = '';
  241. var useraddress = '';
  242. Qrcodeimg += '\
  243. <img src="'+ msg.base + '" alt="">\
  244. ';
  245. useraddress += '\
  246. '+ msg.useraddress + '\
  247. ';
  248. $('#Qrcode').html(Qrcodeimg);
  249. $('#copy').html(useraddress);
  250. });
  251. }
  252. get_data();
  253. });
  254. function copyEvent(id) {
  255. var str = document.getElementById(id);
  256. window.getSelection().selectAllChildren(str);
  257. document.execCommand("Copy")
  258. toastr.options = {
  259. // 參數設定[註1]
  260. "closeButton": false, // 顯示關閉按鈕
  261. "debug": false, // 除錯
  262. "newestOnTop": false, // 最新一筆顯示在最上面
  263. "progressBar": false, // 顯示隱藏時間進度條
  264. "positionClass": "toast-top-center", // 位置的類別
  265. "preventDuplicates": false, // 隱藏重覆訊息
  266. "onclick": null, // 當點選提示訊息時,則執行此函式
  267. "showDuration": "300", // 顯示時間(單位: 毫秒)
  268. "hideDuration": "1000", // 隱藏時間(單位: 毫秒)
  269. "timeOut": "1000", // 當超過此設定時間時,則隱藏提示訊息(單位: 毫秒)
  270. "extendedTimeOut": "1000", // 當使用者觸碰到提示訊息時,離開後超過此設定時間則隱藏提示訊息(單位: 毫秒)
  271. "showEasing": "swing", // 顯示動畫時間曲線
  272. "hideEasing": "linear", // 隱藏動畫時間曲線
  273. "showMethod": "fadeIn", // 顯示動畫效果
  274. "hideMethod": "fadeOut" // 隱藏動畫效果
  275. }
  276. toastr.success("複製成功");
  277. }